158 lines
7.1 KiB
HTML
158 lines
7.1 KiB
HTML
<!doctype html>
|
|
<!--
|
|
Copyright (c) 2015-present, Facebook, Inc.
|
|
All rights reserved.
|
|
|
|
This source code is licensed under the BSD-style license found in the
|
|
LICENSE file in the root directory of this source tree. An additional grant
|
|
of patent rights can be found in the PATENTS file in the same directory.
|
|
-->
|
|
|
|
<html>
|
|
<head>
|
|
<meta charset=utf-8>
|
|
<!-- Base 64 encoded favicon, to avoid extra request to server -->
|
|
<link rel="icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAppQTFRFAAAA////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////9/3/uu/9n+n9s+396fr/6vr/tO79ue/99P3/te79j+X8u+/9oOn9h+P8xPH+/P7//f//xfL+juX8su399v3/jeX81fX+0fT+ieT8sO39iOP8z/T+2/f+iuT88Pz/7Pv/4fj+fOD8dt/83ff+8/z/jOT84vj+7fv/heP8w/H+8vz/g+L8zvT+0PT+2Pb+6Pr++f7/k+b8oun9rOz9bt37cN77fuH8q+v9qOv9xvL+mef9c978e+D8jeT8hOL8cN78l+f94/j+leb8vvD93/j+1/b+luf8wfD97vv/gOH8/v//wPD+dN/8qev9huP87/v/9Pz/6fr+m+j9+v7/ruz94Pj+feH8Xtn75/n+dd/8mOf8vfD9nej9b937X9n76/v/muj9se399f3/quv98fz/wfH+3Pf+2fb+5Pn+3vf+wvH+kOX8kub83/f+ct78geL82vf+keX8euD8cd78oen9d9/8eeD8nOj9p+r9i+T8yvP+zfT+gOL8cd771vb+ieP80vX+8Pv/v/D9r+z9vO/9o+r9t+795IXGEwAAAFZ0Uk5TAAARTpOtw9bVwpFLECF6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1UgXhV8AAAAldEVYdGRhdGU6Y3JlYXRlADIwMTYtMTAtMDVUMTQ6Mjk6MTMrMDA6MDATO+D3AAAAJXRFWHRkYXRlOm1vZGlmeQAyMDE2LTEwLTA1VDE0OjI5OjEzKzAwOjAwYmZYSwAAAEZ0RVh0c29mdHdhcmUASW1hZ2VNYWdpY2sgNi43LjgtOSAyMDE0LTA1LTEyIFExNiBodHRwOi8vd3d3LmltYWdlbWFnaWNrLm9yZ9yG7QAAAAAYdEVYdFRodW1iOjpEb2N1bWVudDo6UGFnZXMAMaf/uy8AAAAYdEVYdFRodW1iOjpJbWFnZTo6aGVpZ2h0ADE5Mg8AcoUAAAAXdEVYdFRodW1iOjpJbWFnZTo6V2lkdGgAMTky06whCAAAABl0RVh0VGh1bWI6Ok1pbWV0eXBlAGltYWdlL3BuZz+yVk4AAAAXdEVYdFRodW1iOjpNVGltZQAxNDc1Njc3NzUzbJvFlQAAAA90RVh0VGh1bWI6OlNpemUAMEJClKI+7AAAAFZ0RVh0VGh1bWI6OlVSSQBmaWxlOi8vL21udGxvZy9mYXZpY29ucy8yMDE2LTEwLTA1LzViOTFlZDY3MjZlOTY2ODRjZjdlNmFmOWFhZmIyZGIzLmljby5wbmd2ygvUAAAAAElFTkSuQmCC">
|
|
<title>React Native Debugger</title>
|
|
<script>
|
|
/* eslint-env browser */
|
|
(function() {
|
|
|
|
function setStatus(status) {
|
|
document.getElementById('status').innerHTML = status;
|
|
}
|
|
|
|
var isMacLike = /(Mac|iPhone|iPod|iPad)/i.test(navigator.platform);
|
|
var refresh_shortcut = isMacLike ? '⌘R' : 'Ctrl R';
|
|
window.onload = function() {
|
|
if (!isMacLike) {
|
|
document.getElementById('dev_tools_shortcut').innerHTML = 'Ctrl⇧J';
|
|
}
|
|
};
|
|
|
|
var INITIAL_MESSAGE = 'Waiting, press <span class="shortcut">' + refresh_shortcut + '</span> in simulator to reload and connect.';
|
|
|
|
function connectToDebuggerProxy() {
|
|
var worker;
|
|
var ws = new WebSocket('ws://' + window.location.host + '/debugger-proxy?role=debugger&name=Chrome');
|
|
|
|
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. ' +
|
|
'You should press' + refresh_shortcut + 'in simulator to reload.';
|
|
};
|
|
updateVisibility();
|
|
}
|
|
|
|
function shutdownJSRuntime() {
|
|
if (worker) {
|
|
worker.terminate();
|
|
worker = null;
|
|
window.onbeforeunload = null;
|
|
}
|
|
}
|
|
|
|
function updateVisibility() {
|
|
if (worker) {
|
|
worker.postMessage({
|
|
method: 'setDebuggerVisibility',
|
|
visibilityState: document.visibilityState,
|
|
});
|
|
}
|
|
}
|
|
|
|
ws.onopen = function() {
|
|
setStatus(INITIAL_MESSAGE);
|
|
};
|
|
|
|
ws.onmessage = function(message) {
|
|
if (!message.data) {
|
|
return;
|
|
}
|
|
var object = JSON.parse(message.data);
|
|
|
|
if (object.$event === 'client-disconnected') {
|
|
shutdownJSRuntime();
|
|
setStatus('Waiting, press <span class="shortcut">' + refresh_shortcut + '</span> in simulator to reload and connect.');
|
|
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}));
|
|
setStatus('Debugger session #' + object.id + ' active.');
|
|
} else if (object.method === '$disconnected') {
|
|
shutdownJSRuntime();
|
|
setStatus(INITIAL_MESSAGE);
|
|
} else {
|
|
// Otherwise, pass through to the worker.
|
|
worker.postMessage(object);
|
|
}
|
|
};
|
|
|
|
ws.onclose = function(e) {
|
|
shutdownJSRuntime();
|
|
setStatus('Disconnected from proxy. Attempting reconnection. Is node server running?');
|
|
if (e.reason) {
|
|
setStatus(e.reason);
|
|
console.warn(e.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();
|
|
|
|
})();
|
|
</script>
|
|
<style type="text/css">
|
|
body {
|
|
font-family: Helvetica, Verdana, sans-serif;
|
|
font-size: large;
|
|
font-weight: 200;
|
|
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;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="content">
|
|
<p>
|
|
React Native JS code runs inside this Chrome tab.
|
|
</p>
|
|
<p>Press <kbd id='dev_tools_shortcut' class="shortcut">⌘⌥J</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>Status: <span id="status">Loading...</span></p>
|
|
</div>
|
|
</body>
|
|
</html>
|