vxrn 0.1.83 → 0.1.85

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (145) hide show
  1. package/.depcheckrc +1 -0
  2. package/LICENSE +22 -0
  3. package/dist/cjs/cli.native.js +53 -58
  4. package/dist/cjs/cli.native.js.map +1 -1
  5. package/dist/cjs/exports/build.js +4 -3
  6. package/dist/cjs/exports/build.js.map +1 -1
  7. package/dist/cjs/exports/build.native.js +59 -61
  8. package/dist/cjs/exports/build.native.js.map +1 -1
  9. package/dist/cjs/exports/createServer.native.js +53 -58
  10. package/dist/cjs/exports/createServer.native.js.map +1 -1
  11. package/dist/cjs/exports/dev.native.js +65 -79
  12. package/dist/cjs/exports/dev.native.js.map +1 -1
  13. package/dist/cjs/exports/serve.native.js +53 -58
  14. package/dist/cjs/exports/serve.native.js.map +1 -1
  15. package/dist/cjs/plugins/clientInjectPlugin.native.js +53 -58
  16. package/dist/cjs/plugins/clientInjectPlugin.native.js.map +1 -1
  17. package/dist/cjs/plugins/reactNativeCommonJsPlugin.js +1 -2
  18. package/dist/cjs/plugins/reactNativeCommonJsPlugin.js.map +1 -1
  19. package/dist/cjs/plugins/reactNativeCommonJsPlugin.native.js +60 -72
  20. package/dist/cjs/plugins/reactNativeCommonJsPlugin.native.js.map +1 -1
  21. package/dist/cjs/plugins/reactNativeHMRPlugin.js +1 -2
  22. package/dist/cjs/plugins/reactNativeHMRPlugin.js.map +1 -1
  23. package/dist/cjs/plugins/reactNativeHMRPlugin.native.js +59 -70
  24. package/dist/cjs/plugins/reactNativeHMRPlugin.native.js.map +1 -1
  25. package/dist/cjs/utils/findDepsToOptimize.js +167 -0
  26. package/dist/cjs/utils/findDepsToOptimize.js.map +6 -0
  27. package/dist/cjs/utils/findDepsToOptimize.native.js +564 -0
  28. package/dist/cjs/utils/findDepsToOptimize.native.js.map +6 -0
  29. package/dist/cjs/utils/getBaseViteConfig.js +12 -1
  30. package/dist/cjs/utils/getBaseViteConfig.js.map +1 -1
  31. package/dist/cjs/utils/getBaseViteConfig.native.js +12 -1
  32. package/dist/cjs/utils/getBaseViteConfig.native.js.map +2 -2
  33. package/dist/cjs/utils/getOptimizeDeps.native.js +6 -12
  34. package/dist/cjs/utils/getOptimizeDeps.native.js.map +1 -1
  35. package/dist/cjs/utils/getOptionsFilled.native.js +59 -70
  36. package/dist/cjs/utils/getOptionsFilled.native.js.map +1 -1
  37. package/dist/cjs/utils/getReactNativeBundle.native.js +53 -58
  38. package/dist/cjs/utils/getReactNativeBundle.native.js.map +1 -1
  39. package/dist/cjs/utils/getVitePath.native.js +53 -58
  40. package/dist/cjs/utils/getVitePath.native.js.map +1 -1
  41. package/dist/cjs/utils/getViteServerConfig.native.js +59 -70
  42. package/dist/cjs/utils/getViteServerConfig.native.js.map +1 -1
  43. package/dist/cjs/utils/patches.native.js +59 -70
  44. package/dist/cjs/utils/patches.native.js.map +1 -1
  45. package/dist/cjs/utils/readVXRNConfig.native.js +53 -58
  46. package/dist/cjs/utils/readVXRNConfig.native.js.map +1 -1
  47. package/dist/cjs/utils/swapPrebuiltReactModules.js +1 -2
  48. package/dist/cjs/utils/swapPrebuiltReactModules.js.map +1 -1
  49. package/dist/cjs/utils/swapPrebuiltReactModules.native.js +54 -60
  50. package/dist/cjs/utils/swapPrebuiltReactModules.native.js.map +1 -1
  51. package/dist/cjs/utils/uniq.native.js +6 -12
  52. package/dist/cjs/utils/uniq.native.js.map +1 -1
  53. package/dist/cjs/vendor/debugger-app/index.js +0 -22
  54. package/dist/cjs/vendor/debugger-app/index.js.map +2 -2
  55. package/dist/cjs/vendor/debugger-app/index.native.js +0 -22
  56. package/dist/cjs/vendor/debugger-app/index.native.js.map +3 -3
  57. package/dist/cjs/vendor/debugger-app/src/debuggerWorker.js +0 -46
  58. package/dist/cjs/vendor/debugger-app/src/debuggerWorker.js.map +3 -3
  59. package/dist/cjs/vendor/debugger-app/src/debuggerWorker.native.js +0 -54
  60. package/dist/cjs/vendor/debugger-app/src/debuggerWorker.native.js.map +3 -3
  61. package/dist/cjs/vendor/debugger-app/src/index.js +0 -104
  62. package/dist/cjs/vendor/debugger-app/src/index.js.map +3 -3
  63. package/dist/cjs/vendor/debugger-app/src/index.native.js +0 -132
  64. package/dist/cjs/vendor/debugger-app/src/index.native.js.map +3 -3
  65. package/dist/esm/cli.native.js +53 -58
  66. package/dist/esm/cli.native.js.map +1 -1
  67. package/dist/esm/exports/build.js +4 -3
  68. package/dist/esm/exports/build.js.map +1 -1
  69. package/dist/esm/exports/build.mjs +4 -3
  70. package/dist/esm/exports/build.native.js +59 -61
  71. package/dist/esm/exports/build.native.js.map +1 -1
  72. package/dist/esm/exports/createServer.native.js +53 -58
  73. package/dist/esm/exports/createServer.native.js.map +1 -1
  74. package/dist/esm/exports/dev.native.js +65 -79
  75. package/dist/esm/exports/dev.native.js.map +1 -1
  76. package/dist/esm/exports/serve.native.js +53 -58
  77. package/dist/esm/exports/serve.native.js.map +1 -1
  78. package/dist/esm/plugins/clientInjectPlugin.native.js +53 -58
  79. package/dist/esm/plugins/clientInjectPlugin.native.js.map +1 -1
  80. package/dist/esm/plugins/reactNativeCommonJsPlugin.js +1 -2
  81. package/dist/esm/plugins/reactNativeCommonJsPlugin.js.map +1 -1
  82. package/dist/esm/plugins/reactNativeCommonJsPlugin.native.js +60 -72
  83. package/dist/esm/plugins/reactNativeCommonJsPlugin.native.js.map +1 -1
  84. package/dist/esm/plugins/reactNativeHMRPlugin.js +1 -2
  85. package/dist/esm/plugins/reactNativeHMRPlugin.js.map +1 -1
  86. package/dist/esm/plugins/reactNativeHMRPlugin.native.js +59 -70
  87. package/dist/esm/plugins/reactNativeHMRPlugin.native.js.map +1 -1
  88. package/dist/esm/utils/findDepsToOptimize.js +145 -0
  89. package/dist/esm/utils/findDepsToOptimize.js.map +6 -0
  90. package/dist/esm/utils/findDepsToOptimize.mjs +130 -0
  91. package/dist/esm/utils/findDepsToOptimize.native.js +530 -0
  92. package/dist/esm/utils/findDepsToOptimize.native.js.map +6 -0
  93. package/dist/esm/utils/getBaseViteConfig.js +12 -1
  94. package/dist/esm/utils/getBaseViteConfig.js.map +1 -1
  95. package/dist/esm/utils/getBaseViteConfig.mjs +3 -1
  96. package/dist/esm/utils/getBaseViteConfig.native.js +12 -1
  97. package/dist/esm/utils/getBaseViteConfig.native.js.map +2 -2
  98. package/dist/esm/utils/getOptimizeDeps.native.js +6 -12
  99. package/dist/esm/utils/getOptimizeDeps.native.js.map +1 -1
  100. package/dist/esm/utils/getOptionsFilled.native.js +59 -70
  101. package/dist/esm/utils/getOptionsFilled.native.js.map +1 -1
  102. package/dist/esm/utils/getReactNativeBundle.native.js +53 -58
  103. package/dist/esm/utils/getReactNativeBundle.native.js.map +1 -1
  104. package/dist/esm/utils/getVitePath.native.js +53 -58
  105. package/dist/esm/utils/getVitePath.native.js.map +1 -1
  106. package/dist/esm/utils/getViteServerConfig.native.js +59 -70
  107. package/dist/esm/utils/getViteServerConfig.native.js.map +1 -1
  108. package/dist/esm/utils/patches.native.js +59 -70
  109. package/dist/esm/utils/patches.native.js.map +1 -1
  110. package/dist/esm/utils/readVXRNConfig.native.js +53 -58
  111. package/dist/esm/utils/readVXRNConfig.native.js.map +1 -1
  112. package/dist/esm/utils/swapPrebuiltReactModules.js +1 -2
  113. package/dist/esm/utils/swapPrebuiltReactModules.js.map +1 -1
  114. package/dist/esm/utils/swapPrebuiltReactModules.native.js +54 -60
  115. package/dist/esm/utils/swapPrebuiltReactModules.native.js.map +1 -1
  116. package/dist/esm/utils/uniq.native.js +6 -12
  117. package/dist/esm/utils/uniq.native.js.map +1 -1
  118. package/dist/esm/vendor/debugger-app/index.js +0 -5
  119. package/dist/esm/vendor/debugger-app/index.js.map +2 -2
  120. package/dist/esm/vendor/debugger-app/index.mjs +0 -3
  121. package/dist/esm/vendor/debugger-app/index.native.js +0 -5
  122. package/dist/esm/vendor/debugger-app/index.native.js.map +3 -3
  123. package/dist/esm/vendor/debugger-app/src/debuggerWorker.js +0 -46
  124. package/dist/esm/vendor/debugger-app/src/debuggerWorker.js.map +3 -3
  125. package/dist/esm/vendor/debugger-app/src/debuggerWorker.mjs +0 -47
  126. package/dist/esm/vendor/debugger-app/src/debuggerWorker.native.js +0 -54
  127. package/dist/esm/vendor/debugger-app/src/debuggerWorker.native.js.map +3 -3
  128. package/dist/esm/vendor/debugger-app/src/index.js +0 -86
  129. package/dist/esm/vendor/debugger-app/src/index.js.map +2 -2
  130. package/dist/esm/vendor/debugger-app/src/index.mjs +0 -125
  131. package/dist/esm/vendor/debugger-app/src/index.native.js +0 -115
  132. package/dist/esm/vendor/debugger-app/src/index.native.js.map +3 -3
  133. package/package.json +10 -26
  134. package/src/exports/build.ts +3 -2
  135. package/src/types.ts +2 -3
  136. package/src/utils/findDepsToOptimize.ts +293 -0
  137. package/src/utils/getBaseViteConfig.ts +12 -0
  138. package/src/vendor/debugger-app/index.js +2 -2
  139. package/src/vendor/debugger-app/src/debuggerWorker.js +77 -77
  140. package/src/vendor/debugger-app/src/index.js +199 -199
  141. package/src/vendor/debugger-app/webpack.config.cjs +70 -70
  142. package/types/types.d.ts +2 -3
  143. package/types/utils/findDepsToOptimize.d.ts +19 -0
  144. package/types/utils/getOptionsFilled.d.ts +1 -0
  145. package/src/vendor/debugger-app/index.d.ts +0 -2
@@ -1,84 +1,84 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- */
1
+ // /**
2
+ // * Copyright (c) Facebook, Inc. and its affiliates.
3
+ // *
4
+ // * This source code is licensed under the MIT license found in the
5
+ // * LICENSE file in the root directory of this source tree.
6
+ // *
7
+ // */
8
8
 
9
- /* global __fbBatchedBridge, importScripts */
10
- /* eslint no-unused-vars: 0 */
11
- /* eslint no-restricted-globals: 0 */
9
+ // /* global __fbBatchedBridge, importScripts */
10
+ // /* eslint no-unused-vars: 0 */
11
+ // /* eslint no-restricted-globals: 0 */
12
12
 
13
- onmessage = (function () {
14
- var visibilityState;
15
- var showVisibilityWarning = (function () {
16
- var hasWarned = false;
17
- return function () {
18
- // Wait until `YellowBox` gets initialized before displaying the warning.
19
- if (hasWarned || console.warn.toString().includes('[native code]')) {
20
- return;
21
- }
22
- hasWarned = true;
23
- console.warn(
24
- 'Remote debugger is in a background tab which may cause apps to ' +
25
- 'perform slowly. Fix this by foregrounding the tab (or opening it in ' +
26
- 'a separate window).'
27
- );
28
- };
29
- })();
13
+ // onmessage = (function () {
14
+ // var visibilityState;
15
+ // var showVisibilityWarning = (function () {
16
+ // var hasWarned = false;
17
+ // return function () {
18
+ // // Wait until `YellowBox` gets initialized before displaying the warning.
19
+ // if (hasWarned || console.warn.toString().includes('[native code]')) {
20
+ // return;
21
+ // }
22
+ // hasWarned = true;
23
+ // console.warn(
24
+ // 'Remote debugger is in a background tab which may cause apps to ' +
25
+ // 'perform slowly. Fix this by foregrounding the tab (or opening it in ' +
26
+ // 'a separate window).'
27
+ // );
28
+ // };
29
+ // })();
30
30
 
31
- var messageHandlers = {
32
- executeApplicationScript: function (message, sendReply) {
33
- for (var key in message.inject) {
34
- self[key] = JSON.parse(message.inject[key]);
35
- }
36
- var error;
37
- try {
38
- importScripts(message.url);
39
- } catch (err) {
40
- error = err.message;
41
- }
42
- sendReply(null /* result */, error);
43
- },
44
- setDebuggerVisibility: function (message) {
45
- visibilityState = message.visibilityState;
46
- },
47
- };
31
+ // var messageHandlers = {
32
+ // executeApplicationScript: function (message, sendReply) {
33
+ // for (var key in message.inject) {
34
+ // self[key] = JSON.parse(message.inject[key]);
35
+ // }
36
+ // var error;
37
+ // try {
38
+ // importScripts(message.url);
39
+ // } catch (err) {
40
+ // error = err.message;
41
+ // }
42
+ // sendReply(null /* result */, error);
43
+ // },
44
+ // setDebuggerVisibility: function (message) {
45
+ // visibilityState = message.visibilityState;
46
+ // },
47
+ // };
48
48
 
49
- return function (message) {
50
- if (visibilityState === 'hidden') {
51
- showVisibilityWarning();
52
- }
49
+ // return function (message) {
50
+ // if (visibilityState === 'hidden') {
51
+ // showVisibilityWarning();
52
+ // }
53
53
 
54
- var object = message.data;
54
+ // var object = message.data;
55
55
 
56
- var sendReply = function (result, error) {
57
- postMessage({ replyID: object.id, result: result, error: error });
58
- };
56
+ // var sendReply = function (result, error) {
57
+ // postMessage({ replyID: object.id, result: result, error: error });
58
+ // };
59
59
 
60
- var handler = messageHandlers[object.method];
61
- if (handler) {
62
- // Special cased handlers
63
- handler(object, sendReply);
64
- } else {
65
- // Other methods get called on the bridge
66
- var returnValue = [[], [], [], 0];
67
- var error;
68
- try {
69
- if (typeof __fbBatchedBridge === 'object') {
70
- returnValue = __fbBatchedBridge[object.method].apply(
71
- null,
72
- object.arguments
73
- );
74
- } else {
75
- error = 'Failed to call function, __fbBatchedBridge is undefined';
76
- }
77
- } catch (err) {
78
- error = err.message;
79
- } finally {
80
- sendReply(JSON.stringify(returnValue), error);
81
- }
82
- }
83
- };
84
- })();
60
+ // var handler = messageHandlers[object.method];
61
+ // if (handler) {
62
+ // // Special cased handlers
63
+ // handler(object, sendReply);
64
+ // } else {
65
+ // // Other methods get called on the bridge
66
+ // var returnValue = [[], [], [], 0];
67
+ // var error;
68
+ // try {
69
+ // if (typeof __fbBatchedBridge === 'object') {
70
+ // returnValue = __fbBatchedBridge[object.method].apply(
71
+ // null,
72
+ // object.arguments
73
+ // );
74
+ // } else {
75
+ // error = 'Failed to call function, __fbBatchedBridge is undefined';
76
+ // }
77
+ // } catch (err) {
78
+ // error = err.message;
79
+ // } finally {
80
+ // sendReply(JSON.stringify(returnValue), error);
81
+ // }
82
+ // }
83
+ // };
84
+ // })();
@@ -1,199 +1,199 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- */
8
-
9
- /* eslint-env browser */
10
- import './index.css';
11
- // import blueIcon from './assets/blue-icon.png';
12
- // import grayIcon from './assets/gray-icon.png';
13
- // import orangeIcon from './assets/orange-icon.png';
14
- import DebuggerWorker from './debuggerWorker.js';
15
-
16
- const blueIcon = ''
17
- const grayIcon = ''
18
- const orangeIcon = ''
19
-
20
- const isMacLike = /(Mac|iPhone|iPod|iPad)/i.test(navigator.platform);
21
- const refreshShortcut = isMacLike ? '⌘R' : 'Ctrl R';
22
- window.onload = function () {
23
- if (!isMacLike) {
24
- document.getElementById('shortcut').innerHTML = 'Ctrl⇧J';
25
- }
26
- Page.render();
27
- };
28
-
29
- window.onReloadClicked = function () {
30
- var xhr = new XMLHttpRequest();
31
- xhr.open('GET', `${window.location.origin}/reload`, true);
32
- xhr.send();
33
- };
34
-
35
- const Page = (window.Page = {
36
- state: {
37
- isDark:
38
- localStorage.getItem('darkTheme') === null
39
- ? window.matchMedia('(prefers-color-scheme: dark)').matches
40
- : localStorage.getItem('darkTheme') === 'on',
41
- isPriorityMaintained: localStorage.getItem('maintainPriority') === 'on',
42
- status: { type: 'disconnected' },
43
- visibilityState: document.visibilityState,
44
- },
45
-
46
- setState(partialState) {
47
- Page.state = Object.assign({}, Page.state, partialState);
48
- Page.render();
49
- },
50
-
51
- render() {
52
- const { isDark, isPriorityMaintained, status, visibilityState } =
53
- Page.state;
54
-
55
- const statusNode = document.getElementById('status');
56
- switch (status.type) {
57
- case 'connected':
58
- statusNode.innerHTML = 'Debugger session #' + status.id + ' active.';
59
- break;
60
- case 'error':
61
- statusNode.innerHTML =
62
- status.error.reason ||
63
- 'Disconnected from proxy. Attempting reconnection. Is node server running?';
64
- break;
65
- case 'connecting':
66
- case 'disconnected':
67
- // Fall through.
68
- default:
69
- statusNode.innerHTML =
70
- 'Waiting, press <span class="shortcut">' +
71
- refreshShortcut +
72
- '</span> in simulator to reload and connect.';
73
- break;
74
- }
75
-
76
- const linkNode = document.querySelector('link[rel=icon]');
77
- if (status.type === 'disconnected' || status.type === 'error') {
78
- linkNode.href = grayIcon;
79
- } else {
80
- if (visibilityState === 'visible' || isPriorityMaintained) {
81
- linkNode.href = blueIcon;
82
- } else {
83
- linkNode.href = orangeIcon;
84
- }
85
- }
86
-
87
- const darkCheckbox = document.getElementById('dark');
88
- document.body.classList.toggle('dark', isDark);
89
- darkCheckbox.checked = isDark;
90
- localStorage.setItem('darkTheme', isDark ? 'on' : '');
91
-
92
- const maintainPriorityCheckbox =
93
- document.getElementById('maintain-priority');
94
- maintainPriorityCheckbox.checked = isPriorityMaintained;
95
- localStorage.setItem('maintainPriority', isPriorityMaintained ? 'on' : '');
96
- },
97
-
98
- toggleDarkTheme() {
99
- Page.setState({ isDark: !Page.state.isDark });
100
- },
101
-
102
- togglePriorityMaintenance() {
103
- Page.setState({ isPriorityMaintained: !Page.state.isPriorityMaintained });
104
- },
105
- });
106
-
107
- function connectToDebuggerProxy() {
108
- const ws = new WebSocket(
109
- 'ws://' + window.location.host + '/debugger-proxy?role=debugger&name=Chrome'
110
- );
111
- let worker;
112
-
113
- function createJSRuntime() {
114
- // This worker will run the application JavaScript code,
115
- // making sure that it's run in an environment without a global
116
- // document, to make it consistent with the JSC executor environment.
117
- worker = new DebuggerWorker();
118
- worker.onmessage = function (message) {
119
- ws.send(JSON.stringify(message.data));
120
- };
121
- window.onbeforeunload = function () {
122
- return (
123
- 'If you reload this page, it is going to break the debugging session. ' +
124
- 'Press ' +
125
- refreshShortcut +
126
- ' on the device to reload.'
127
- );
128
- };
129
- updateVisibility();
130
- }
131
-
132
- function shutdownJSRuntime() {
133
- if (worker) {
134
- worker.terminate();
135
- worker = null;
136
- window.onbeforeunload = null;
137
- }
138
- }
139
-
140
- function updateVisibility() {
141
- if (worker && !Page.state.isPriorityMaintained) {
142
- worker.postMessage({
143
- method: 'setDebuggerVisibility',
144
- visibilityState: document.visibilityState,
145
- });
146
- }
147
- Page.setState({ visibilityState: document.visibilityState });
148
- }
149
-
150
- ws.onopen = function () {
151
- Page.setState({ status: { type: 'connecting' } });
152
- };
153
-
154
- ws.onmessage = function (message) {
155
- if (!message.data) {
156
- return;
157
- }
158
- const object = JSON.parse(message.data);
159
-
160
- if (object.$event === 'client-disconnected') {
161
- shutdownJSRuntime();
162
- Page.setState({ status: { type: 'disconnected' } });
163
- return;
164
- }
165
-
166
- if (!object.method) {
167
- return;
168
- }
169
-
170
- // Special message that asks for a new JS runtime
171
- if (object.method === 'prepareJSRuntime') {
172
- shutdownJSRuntime();
173
- console.clear();
174
- createJSRuntime();
175
- ws.send(JSON.stringify({ replyID: object.id }));
176
- Page.setState({ status: { type: 'connected', id: object.id } });
177
- } else if (object.method === '$disconnected') {
178
- shutdownJSRuntime();
179
- Page.setState({ status: { type: 'disconnected' } });
180
- } else {
181
- worker.postMessage(object);
182
- }
183
- };
184
-
185
- ws.onclose = function (error) {
186
- shutdownJSRuntime();
187
- Page.setState({ status: { type: 'error', error } });
188
- if (error.reason) {
189
- console.warn(error.reason);
190
- }
191
- setTimeout(connectToDebuggerProxy, 500);
192
- };
193
-
194
- // Let debuggerWorker.js know when we're not visible so that we can warn about
195
- // poor performance when using remote debugging.
196
- document.addEventListener('visibilitychange', updateVisibility, false);
197
- }
198
-
199
- connectToDebuggerProxy();
1
+ // /**
2
+ // * Copyright (c) Facebook, Inc. and its affiliates.
3
+ // *
4
+ // * This source code is licensed under the MIT license found in the
5
+ // * LICENSE file in the root directory of this source tree.
6
+ // *
7
+ // */
8
+
9
+ // /* eslint-env browser */
10
+ // import './index.css';
11
+ // // import blueIcon from './assets/blue-icon.png';
12
+ // // import grayIcon from './assets/gray-icon.png';
13
+ // // import orangeIcon from './assets/orange-icon.png';
14
+ // import DebuggerWorker from './debuggerWorker.js';
15
+
16
+ // const blueIcon = ''
17
+ // const grayIcon = ''
18
+ // const orangeIcon = ''
19
+
20
+ // const isMacLike = /(Mac|iPhone|iPod|iPad)/i.test(navigator.platform);
21
+ // const refreshShortcut = isMacLike ? '⌘R' : 'Ctrl R';
22
+ // window.onload = function () {
23
+ // if (!isMacLike) {
24
+ // document.getElementById('shortcut').innerHTML = 'Ctrl⇧J';
25
+ // }
26
+ // Page.render();
27
+ // };
28
+
29
+ // window.onReloadClicked = function () {
30
+ // var xhr = new XMLHttpRequest();
31
+ // xhr.open('GET', `${window.location.origin}/reload`, true);
32
+ // xhr.send();
33
+ // };
34
+
35
+ // const Page = (window.Page = {
36
+ // state: {
37
+ // isDark:
38
+ // localStorage.getItem('darkTheme') === null
39
+ // ? window.matchMedia('(prefers-color-scheme: dark)').matches
40
+ // : localStorage.getItem('darkTheme') === 'on',
41
+ // isPriorityMaintained: localStorage.getItem('maintainPriority') === 'on',
42
+ // status: { type: 'disconnected' },
43
+ // visibilityState: document.visibilityState,
44
+ // },
45
+
46
+ // setState(partialState) {
47
+ // Page.state = Object.assign({}, Page.state, partialState);
48
+ // Page.render();
49
+ // },
50
+
51
+ // render() {
52
+ // const { isDark, isPriorityMaintained, status, visibilityState } =
53
+ // Page.state;
54
+
55
+ // const statusNode = document.getElementById('status');
56
+ // switch (status.type) {
57
+ // case 'connected':
58
+ // statusNode.innerHTML = 'Debugger session #' + status.id + ' active.';
59
+ // break;
60
+ // case 'error':
61
+ // statusNode.innerHTML =
62
+ // status.error.reason ||
63
+ // 'Disconnected from proxy. Attempting reconnection. Is node server running?';
64
+ // break;
65
+ // case 'connecting':
66
+ // case 'disconnected':
67
+ // // Fall through.
68
+ // default:
69
+ // statusNode.innerHTML =
70
+ // 'Waiting, press <span class="shortcut">' +
71
+ // refreshShortcut +
72
+ // '</span> in simulator to reload and connect.';
73
+ // break;
74
+ // }
75
+
76
+ // const linkNode = document.querySelector('link[rel=icon]');
77
+ // if (status.type === 'disconnected' || status.type === 'error') {
78
+ // linkNode.href = grayIcon;
79
+ // } else {
80
+ // if (visibilityState === 'visible' || isPriorityMaintained) {
81
+ // linkNode.href = blueIcon;
82
+ // } else {
83
+ // linkNode.href = orangeIcon;
84
+ // }
85
+ // }
86
+
87
+ // const darkCheckbox = document.getElementById('dark');
88
+ // document.body.classList.toggle('dark', isDark);
89
+ // darkCheckbox.checked = isDark;
90
+ // localStorage.setItem('darkTheme', isDark ? 'on' : '');
91
+
92
+ // const maintainPriorityCheckbox =
93
+ // document.getElementById('maintain-priority');
94
+ // maintainPriorityCheckbox.checked = isPriorityMaintained;
95
+ // localStorage.setItem('maintainPriority', isPriorityMaintained ? 'on' : '');
96
+ // },
97
+
98
+ // toggleDarkTheme() {
99
+ // Page.setState({ isDark: !Page.state.isDark });
100
+ // },
101
+
102
+ // togglePriorityMaintenance() {
103
+ // Page.setState({ isPriorityMaintained: !Page.state.isPriorityMaintained });
104
+ // },
105
+ // });
106
+
107
+ // function connectToDebuggerProxy() {
108
+ // const ws = new WebSocket(
109
+ // 'ws://' + window.location.host + '/debugger-proxy?role=debugger&name=Chrome'
110
+ // );
111
+ // let worker;
112
+
113
+ // function createJSRuntime() {
114
+ // // This worker will run the application JavaScript code,
115
+ // // making sure that it's run in an environment without a global
116
+ // // document, to make it consistent with the JSC executor environment.
117
+ // worker = new DebuggerWorker();
118
+ // worker.onmessage = function (message) {
119
+ // ws.send(JSON.stringify(message.data));
120
+ // };
121
+ // window.onbeforeunload = function () {
122
+ // return (
123
+ // 'If you reload this page, it is going to break the debugging session. ' +
124
+ // 'Press ' +
125
+ // refreshShortcut +
126
+ // ' on the device to reload.'
127
+ // );
128
+ // };
129
+ // updateVisibility();
130
+ // }
131
+
132
+ // function shutdownJSRuntime() {
133
+ // if (worker) {
134
+ // worker.terminate();
135
+ // worker = null;
136
+ // window.onbeforeunload = null;
137
+ // }
138
+ // }
139
+
140
+ // function updateVisibility() {
141
+ // if (worker && !Page.state.isPriorityMaintained) {
142
+ // worker.postMessage({
143
+ // method: 'setDebuggerVisibility',
144
+ // visibilityState: document.visibilityState,
145
+ // });
146
+ // }
147
+ // Page.setState({ visibilityState: document.visibilityState });
148
+ // }
149
+
150
+ // ws.onopen = function () {
151
+ // Page.setState({ status: { type: 'connecting' } });
152
+ // };
153
+
154
+ // ws.onmessage = function (message) {
155
+ // if (!message.data) {
156
+ // return;
157
+ // }
158
+ // const object = JSON.parse(message.data);
159
+
160
+ // if (object.$event === 'client-disconnected') {
161
+ // shutdownJSRuntime();
162
+ // Page.setState({ status: { type: 'disconnected' } });
163
+ // return;
164
+ // }
165
+
166
+ // if (!object.method) {
167
+ // return;
168
+ // }
169
+
170
+ // // Special message that asks for a new JS runtime
171
+ // if (object.method === 'prepareJSRuntime') {
172
+ // shutdownJSRuntime();
173
+ // console.clear();
174
+ // createJSRuntime();
175
+ // ws.send(JSON.stringify({ replyID: object.id }));
176
+ // Page.setState({ status: { type: 'connected', id: object.id } });
177
+ // } else if (object.method === '$disconnected') {
178
+ // shutdownJSRuntime();
179
+ // Page.setState({ status: { type: 'disconnected' } });
180
+ // } else {
181
+ // worker.postMessage(object);
182
+ // }
183
+ // };
184
+
185
+ // ws.onclose = function (error) {
186
+ // shutdownJSRuntime();
187
+ // Page.setState({ status: { type: 'error', error } });
188
+ // if (error.reason) {
189
+ // console.warn(error.reason);
190
+ // }
191
+ // setTimeout(connectToDebuggerProxy, 500);
192
+ // };
193
+
194
+ // // Let debuggerWorker.js know when we're not visible so that we can warn about
195
+ // // poor performance when using remote debugging.
196
+ // document.addEventListener('visibilitychange', updateVisibility, false);
197
+ // }
198
+
199
+ // connectToDebuggerProxy();