This commit is contained in:
Yamozha
2021-04-02 02:24:13 +03:00
parent c23950b545
commit 7256d79e2c
31493 changed files with 3036630 additions and 0 deletions

View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2018 react-native-community
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -0,0 +1,36 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.debuggerUIMiddleware = debuggerUIMiddleware;
function _serveStatic() {
const data = _interopRequireDefault(require("serve-static"));
_serveStatic = function () {
return data;
};
return data;
}
function _path() {
const data = _interopRequireDefault(require("path"));
_path = function () {
return data;
};
return data;
}
function debuggerUIMiddleware() {
return (0, _serveStatic().default)(_path().default.join(__dirname, '..', 'ui'), {
cacheControl: false
});
}
//# sourceMappingURL=index.js.map

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -0,0 +1,6 @@
parcelRequire=function(e,r,t,n){var i,o="function"==typeof parcelRequire&&parcelRequire,u="function"==typeof require&&require;function f(t,n){if(!r[t]){if(!e[t]){var i="function"==typeof parcelRequire&&parcelRequire;if(!n&&i)return i(t,!0);if(o)return o(t,!0);if(u&&"string"==typeof t)return u(t);var c=new Error("Cannot find module '"+t+"'");throw c.code="MODULE_NOT_FOUND",c}p.resolve=function(r){return e[t][1][r]||r},p.cache={};var l=r[t]=new f.Module(t);e[t][0].call(l.exports,p,l,l.exports,this)}return r[t].exports;function p(e){return f(p.resolve(e))}}f.isParcelRequire=!0,f.Module=function(e){this.id=e,this.bundle=f,this.exports={}},f.modules=e,f.cache=r,f.parent=o,f.register=function(r,t){e[r]=[function(e,r){r.exports=t},{}]};for(var c=0;c<t.length;c++)try{f(t[c])}catch(e){i||(i=e)}if(t.length){var l=f(t[t.length-1]);"object"==typeof exports&&"undefined"!=typeof module?module.exports=l:"function"==typeof define&&define.amd?define(function(){return l}):n&&(this[n]=l)}if(parcelRequire=f,i)throw i;return f}({"Hdai":[function(require,module,exports) {
function o(t){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?module.exports=o=function(o){return typeof o}:module.exports=o=function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},o(t)}module.exports=o;
},{}],"sYUN":[function(require,module,exports) {
"use strict";var e=t(require("@babel/runtime/helpers/typeof"));function t(e){return e&&e.__esModule?e:{default:e}}onmessage=function(){var t,i,n=(i=!1,function(){i||console.warn.toString().includes("[native code]")||(i=!0,console.warn("Remote debugger is in a background tab which may cause apps to perform slowly. Fix this by foregrounding the tab (or opening it in a separate window)."))}),r={executeApplicationScript:function(e,t){for(var i in e.inject)self[i]=JSON.parse(e.inject[i]);var n;try{importScripts(e.url)}catch(r){n=r.message}t(null,n)},setDebuggerVisibility:function(e){t=e.visibilityState}};return function(i){"hidden"===t&&n();var a=i.data,o=function(e,t){postMessage({replyID:a.id,result:e,error:t})},s=r[a.method];if(s)s(a,o);else{var c,u=[[],[],[],0];try{"object"===("undefined"==typeof __fbBatchedBridge?"undefined":(0,e.default)(__fbBatchedBridge))?u=__fbBatchedBridge[a.method].apply(null,a.arguments):c="Failed to call function, __fbBatchedBridge is undefined"}catch(d){c=d.message}finally{o(JSON.stringify(u),c)}}}}();
},{"@babel/runtime/helpers/typeof":"Hdai"}]},{},["sYUN"], null)
//# sourceMappingURL=/debugger-ui/debuggerWorker.aca173c4.js.map

View File

@ -0,0 +1,92 @@
"use strict";
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/
/* global __fbBatchedBridge, self, importScripts, postMessage, onmessage: true */
/* eslint no-unused-vars: 0 */
onmessage = function () {
var visibilityState;
var showVisibilityWarning = function () {
var hasWarned = false;
return function () {
// Wait until `YellowBox` gets initialized before displaying the warning.
if (hasWarned || console.warn.toString().includes('[native code]')) {
return;
}
hasWarned = true;
console.warn('Remote debugger is in a background tab which may cause apps to ' + 'perform slowly. Fix this by foregrounding the tab (or opening it in ' + 'a separate window).');
};
}();
var messageHandlers = {
executeApplicationScript: function (message, sendReply) {
for (var key in message.inject) {
self[key] = JSON.parse(message.inject[key]);
}
var error;
try {
importScripts(message.url);
} catch (err) {
error = err.message;
}
sendReply(null
/* result */
, error);
},
setDebuggerVisibility: function (message) {
visibilityState = message.visibilityState;
}
};
return function (message) {
if (visibilityState === 'hidden') {
showVisibilityWarning();
}
var object = message.data;
var sendReply = function (result, error) {
postMessage({
replyID: object.id,
result: result,
error: error
});
};
var handler = messageHandlers[object.method];
if (handler) {
// Special cased handlers
handler(object, sendReply);
} else {
// Other methods get called on the bridge
var returnValue = [[], [], [], 0];
var error;
try {
if (typeof __fbBatchedBridge === 'object') {
returnValue = __fbBatchedBridge[object.method].apply(null, object.arguments);
} else {
error = 'Failed to call function, __fbBatchedBridge is undefined';
}
} catch (err) {
error = err.message;
} finally {
sendReply(JSON.stringify(returnValue), error);
}
}
};
}();
//# sourceMappingURL=debuggerWorker.js.map

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@ -0,0 +1,37 @@
html,
body {
font-family: Helvetica, Verdana, sans-serif;
font-size: large;
font-weight: 200;
height: 100%;
margin: 0;
padding: 0;
}
.shortcut {
border-radius: 4px;
color: #eee;
background-color: #333;
font-family: 'Monaco', monospace;
font-size: medium;
letter-spacing: 3px;
padding: 4px;
}
.content {
padding: 10px;
}
.reload-btn {
padding: 5px 10px;
}
body.dark {
background-color: #242424;
color: #afafaf;
}
.dark .shortcut {
color: #c1c1c1;
}
.dark a {
color: #3b99fc;
}
input[type='checkbox'] {
vertical-align: middle;
}

View File

@ -0,0 +1 @@
<!DOCTYPE html><html><head><meta charset="utf-8"><link rel="icon" href="data:;base64,iVBORw0KGgo="><title>React Native Debugger</title><script src="/debugger-ui/ui.e31bb0bc.js"></script><link rel="stylesheet" href="/debugger-ui/ui.e31bb0bc.css"></head><body> <div class="content"> <label for="dark"> <input type="checkbox" id="dark" onclick="Page.toggleDarkTheme()"> Dark Theme </label> <label for="maintain-priority"> <input type="checkbox" id="maintain-priority" onclick="Page.togglePriorityMaintenance()"> Maintain Priority </label> <p> React Native JS code runs as a web worker inside this tab. </p> <p> Press <kbd id="shortcut" class="shortcut">⌘⌥I</kbd> to open Developer Tools. Enable <a href="https://stackoverflow.com/a/17324511/232122" target="_blank">Pause On Caught Exceptions</a> for a better debugging experience. </p> <p> You may also install <a href="https://www.npmjs.com/package/react-devtools" target="_blank">the standalone version of React Developer Tools</a> to inspect the React component hierarchy, their props, and state. </p> <p>Status: <span id="status">Loading...</span></p> <button class="reload-btn" onclick="window.onReloadClicked()"> Reload app </button> </div> <audio id="silence" loop="" src="/debugger-ui/priority.5583346b.wav"></audio> </body></html>

View File

@ -0,0 +1,244 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
require("./index.css");
var _blueIcon = _interopRequireDefault(require("./assets/blue-icon.png"));
var _grayIcon = _interopRequireDefault(require("./assets/gray-icon.png"));
var _orangeIcon = _interopRequireDefault(require("./assets/orange-icon.png"));
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/
/* eslint-env browser */
const isMacLike = /(Mac|iPhone|iPod|iPad)/i.test(navigator.platform);
const refreshShortcut = isMacLike ? '⌘R' : 'Ctrl R';
window.onload = function () {
if (!isMacLike) {
document.getElementById('shortcut').innerHTML = 'Ctrl⇧J';
}
Page.render();
};
window.onReloadClicked = function () {
var xhr = new XMLHttpRequest();
xhr.open('GET', `${window.location.origin}/reload`, true);
xhr.send();
};
const Page = window.Page = {
state: {
isDark: localStorage.getItem('darkTheme') === null ? window.matchMedia('(prefers-color-scheme: dark)').matches : localStorage.getItem('darkTheme') === 'on',
isPriorityMaintained: localStorage.getItem('maintainPriority') === 'on',
status: {
type: 'disconnected'
},
visibilityState: document.visibilityState
},
setState(partialState) {
Page.state = Object.assign({}, Page.state, partialState);
Page.render();
},
render() {
const {
isDark,
isPriorityMaintained,
status,
visibilityState
} = Page.state;
const statusNode = document.getElementById('status');
switch (status.type) {
case 'connected':
statusNode.innerHTML = 'Debugger session #' + status.id + ' active.';
break;
case 'error':
statusNode.innerHTML = status.error.reason || 'Disconnected from proxy. Attempting reconnection. Is node server running?';
break;
case 'connecting':
case 'disconnected': // Fall through.
default:
statusNode.innerHTML = 'Waiting, press <span class="shortcut">' + refreshShortcut + '</span> in simulator to reload and connect.';
break;
}
const linkNode = document.querySelector('link[rel=icon]');
if (status.type === 'disconnected' || status.type === 'error') {
linkNode.href = _grayIcon.default;
} else {
if (visibilityState === 'visible' || isPriorityMaintained) {
linkNode.href = _blueIcon.default;
} else {
linkNode.href = _orangeIcon.default;
}
}
const darkCheckbox = document.getElementById('dark');
document.body.classList.toggle('dark', isDark);
darkCheckbox.checked = isDark;
localStorage.setItem('darkTheme', isDark ? 'on' : '');
const maintainPriorityCheckbox = document.getElementById('maintain-priority');
const silence = document.getElementById('silence');
silence.volume = 0.1;
if (isPriorityMaintained) {
silence.play();
} else {
silence.pause();
}
maintainPriorityCheckbox.checked = isPriorityMaintained;
localStorage.setItem('maintainPriority', isPriorityMaintained ? 'on' : '');
},
toggleDarkTheme() {
Page.setState({
isDark: !Page.state.isDark
});
},
togglePriorityMaintenance() {
Page.setState({
isPriorityMaintained: !Page.state.isPriorityMaintained
});
}
};
function connectToDebuggerProxy() {
const ws = new WebSocket('ws://' + window.location.host + '/debugger-proxy?role=debugger&name=Chrome');
let worker;
function createJSRuntime() {
// This worker will run the application JavaScript code,
// making sure that it's run in an environment without a global
// document, to make it consistent with the JSC executor environment.
worker = new Worker('./debuggerWorker.js');
worker.onmessage = function (message) {
ws.send(JSON.stringify(message.data));
};
window.onbeforeunload = function () {
return 'If you reload this page, it is going to break the debugging session. ' + 'Press ' + refreshShortcut + ' on the device to reload.';
};
updateVisibility();
}
function shutdownJSRuntime() {
if (worker) {
worker.terminate();
worker = null;
window.onbeforeunload = null;
}
}
function updateVisibility() {
if (worker && !Page.state.isPriorityMaintained) {
worker.postMessage({
method: 'setDebuggerVisibility',
visibilityState: document.visibilityState
});
}
Page.setState({
visibilityState: document.visibilityState
});
}
ws.onopen = function () {
Page.setState({
status: {
type: 'connecting'
}
});
};
ws.onmessage = async function (message) {
if (!message.data) {
return;
}
const object = JSON.parse(message.data);
if (object.$event === 'client-disconnected') {
shutdownJSRuntime();
Page.setState({
status: {
type: 'disconnected'
}
});
return;
}
if (!object.method) {
return;
} // Special message that asks for a new JS runtime
if (object.method === 'prepareJSRuntime') {
shutdownJSRuntime();
console.clear();
createJSRuntime();
ws.send(JSON.stringify({
replyID: object.id
}));
Page.setState({
status: {
type: 'connected',
id: object.id
}
});
} else if (object.method === '$disconnected') {
shutdownJSRuntime();
Page.setState({
status: {
type: 'disconnected'
}
});
} else {
worker.postMessage(object);
}
};
ws.onclose = function (error) {
shutdownJSRuntime();
Page.setState({
status: {
type: 'error',
error
}
});
if (error.reason) {
console.warn(error.reason);
}
setTimeout(connectToDebuggerProxy, 500);
}; // Let debuggerWorker.js know when we're not visible so that we can warn about
// poor performance when using remote debugging.
document.addEventListener('visibilitychange', updateVisibility, false);
}
connectToDebuggerProxy();
//# sourceMappingURL=index.js.map

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -0,0 +1,2 @@
body,html{font-family:Helvetica,Verdana,sans-serif;font-size:large;font-weight:200;height:100%;margin:0;padding:0}.shortcut{border-radius:4px;color:#eee;background-color:#333;font-family:Monaco,monospace;font-size:medium;letter-spacing:3px;padding:4px}.content{padding:10px}.reload-btn{padding:5px 10px}body.dark{background-color:#242424;color:#afafaf}.dark .shortcut{color:#c1c1c1}.dark a{color:#3b99fc}input[type=checkbox]{vertical-align:middle}
/*# sourceMappingURL=/debugger-ui/ui.e31bb0bc.css.map */

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,24 @@
{
"name": "@react-native-community/cli-debugger-ui",
"version": "4.13.1",
"license": "MIT",
"main": "./build/middleware",
"scripts": {
"build": "yarn build:ui && yarn build:middleware",
"build:ui": "parcel build --no-content-hash src/ui/index.html --out-dir build/ui --public-url '/debugger-ui'",
"build:middleware": "tsc"
},
"files": [
"build",
"!*.d.ts",
"!*.map"
],
"devDependencies": {
"@babel/core": "^7.6.4",
"parcel-bundler": "^1.12.4"
},
"dependencies": {
"serve-static": "^1.13.1"
},
"gitHead": "30ef010898ffb98ac906ea78aed25ad9bffbbde7"
}