@jsenv/core 29.1.18 → 29.2.0
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.
- package/dist/babel_helpers/AsyncGenerator/AsyncGenerator.js +3 -16
- package/dist/babel_helpers/applyDecoratorDescriptor/applyDecoratorDescriptor.js +0 -5
- package/dist/babel_helpers/applyDecs/applyDecs.js +54 -241
- package/dist/babel_helpers/applyDecs2023/applyDecs2023.js +47 -195
- package/dist/babel_helpers/arrayLikeToArray/arrayLikeToArray.js +0 -2
- package/dist/babel_helpers/arrayWithoutHoles/arrayWithoutHoles.js +2 -1
- package/dist/babel_helpers/assertThisInitialized/assertThisInitialized.js +0 -1
- package/dist/babel_helpers/asyncGeneratorDelegate/asyncGeneratorDelegate.js +4 -14
- package/dist/babel_helpers/asyncIterator/asyncIterator.js +5 -20
- package/dist/babel_helpers/asyncToGenerator/asyncToGenerator.js +2 -8
- package/dist/babel_helpers/awaitAsyncGenerator/awaitAsyncGenerator.js +1 -3
- package/dist/babel_helpers/classApplyDescriptorDestructureSet/classApplyDescriptorDestructureSet.js +0 -4
- package/dist/babel_helpers/classApplyDescriptorGet/classApplyDescriptorGet.js +0 -1
- package/dist/babel_helpers/classApplyDescriptorSet/classApplyDescriptorSet.js +0 -1
- package/dist/babel_helpers/classExtractFieldDescriptor/classExtractFieldDescriptor.js +0 -1
- package/dist/babel_helpers/classPrivateFieldLooseBase/classPrivateFieldLooseBase.js +0 -1
- package/dist/babel_helpers/classPrivateMethodGet/classPrivateMethodGet.js +0 -1
- package/dist/babel_helpers/construct/construct.js +5 -5
- package/dist/babel_helpers/createClass/createClass.js +0 -1
- package/dist/babel_helpers/createForOfIteratorHelper/createForOfIteratorHelper.js +5 -9
- package/dist/babel_helpers/createForOfIteratorHelperLoose/createForOfIteratorHelperLoose.js +2 -3
- package/dist/babel_helpers/createRawReactElement/createRawReactElement.js +2 -8
- package/dist/babel_helpers/createSuper/createSuper.js +2 -4
- package/dist/babel_helpers/decorate/decorate.js +60 -311
- package/dist/babel_helpers/defaults/defaults.js +0 -3
- package/dist/babel_helpers/defineEnumerableProperties/defineEnumerableProperties.js +2 -5
- package/dist/babel_helpers/defineProperty/defineProperty.js +0 -1
- package/dist/babel_helpers/extends/extends.js +0 -3
- package/dist/babel_helpers/get/get.js +0 -3
- package/dist/babel_helpers/getPrototypeOf/getPrototypeOf.js +2 -1
- package/dist/babel_helpers/inherits/inherits.js +2 -3
- package/dist/babel_helpers/instanceof/instanceof.js +0 -1
- package/dist/babel_helpers/interopRequireWildcard/interopRequireWildcard.js +0 -10
- package/dist/babel_helpers/isNativeReflectConstruct/isNativeReflectConstruct.js +6 -6
- package/dist/babel_helpers/iterableToArrayLimit/iterableToArrayLimit.js +0 -5
- package/dist/babel_helpers/iterableToArrayLimitLoose/iterableToArrayLimitLoose.js +2 -5
- package/dist/babel_helpers/jsx/jsx.js +2 -8
- package/dist/babel_helpers/maybeArrayLike/maybeArrayLike.js +2 -3
- package/dist/babel_helpers/objectSpread/objectSpread.js +4 -6
- package/dist/babel_helpers/objectSpread2/objectSpread2.js +3 -8
- package/dist/babel_helpers/objectWithoutProperties/objectWithoutProperties.js +0 -3
- package/dist/babel_helpers/objectWithoutPropertiesLoose/objectWithoutPropertiesLoose.js +0 -2
- package/dist/babel_helpers/possibleConstructorReturn/possibleConstructorReturn.js +0 -1
- package/dist/babel_helpers/set/set.js +2 -12
- package/dist/babel_helpers/superPropBase/superPropBase.js +0 -1
- package/dist/babel_helpers/taggedTemplateLiteral/taggedTemplateLiteral.js +0 -1
- package/dist/babel_helpers/taggedTemplateLiteralLoose/taggedTemplateLiteralLoose.js +0 -1
- package/dist/babel_helpers/toPrimitive/toPrimitive.js +1 -5
- package/dist/babel_helpers/typeof/typeof.js +0 -2
- package/dist/babel_helpers/wrapNativeSuper/wrapNativeSuper.js +0 -7
- package/dist/babel_helpers/wrapRegExp/wrapRegExp.js +5 -19
- package/dist/controllable_child_process.mjs +17 -27
- package/dist/controllable_worker_thread.mjs +4 -16
- package/dist/js/autoreload.js +13 -56
- package/dist/js/execute_using_dynamic_import.js +40 -164
- package/dist/js/global_this.js +2 -10
- package/dist/js/import_meta_hot.js +3 -9
- package/dist/js/new_stylesheet.js +0 -59
- package/dist/js/regenerator_runtime.js +80 -156
- package/dist/js/s.js +25 -113
- package/dist/js/s.js.map +10 -10
- package/dist/js/script_type_module_supervisor.js +4 -13
- package/dist/js/server_events_client.js +10 -38
- package/dist/js/supervisor.js +25 -167
- package/dist/js/v8_coverage.js +29 -92
- package/dist/js/ws.js +226 -704
- package/dist/main.js +761 -4155
- package/package.json +8 -8
- package/src/plugins/import_meta_url/client/import_meta_url_browser.js +1 -2
- package/src/plugins/import_meta_url/client/import_meta_url_commonjs.mjs +1 -1
- package/src/plugins/plugins.js +1 -1
- package/src/plugins/transpilation/as_js_classic/helpers-string.js +1 -0
- package/src/plugins/transpilation/babel/global_this/client/global_this.js +0 -2
|
@@ -11,13 +11,12 @@ const ACTION_REQUEST_EVENT_NAME = "action";
|
|
|
11
11
|
const ACTION_RESPONSE_EVENT_NAME = "action-result";
|
|
12
12
|
const ACTION_RESPONSE_STATUS_FAILED = "action-failed";
|
|
13
13
|
const ACTION_RESPONSE_STATUS_COMPLETED = "action-completed";
|
|
14
|
-
|
|
15
14
|
const sendActionFailed = error => {
|
|
16
15
|
if (error.hasOwnProperty("toString")) {
|
|
17
16
|
delete error.toString;
|
|
18
17
|
}
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
sendToParent(ACTION_RESPONSE_EVENT_NAME,
|
|
19
|
+
// process.send algorithm does not send non enumerable values
|
|
21
20
|
// so use @jsenv/uneval
|
|
22
21
|
uneval({
|
|
23
22
|
status: ACTION_RESPONSE_STATUS_FAILED,
|
|
@@ -26,9 +25,9 @@ const sendActionFailed = error => {
|
|
|
26
25
|
ignoreSymbols: true
|
|
27
26
|
}));
|
|
28
27
|
};
|
|
29
|
-
|
|
30
28
|
const sendActionCompleted = value => {
|
|
31
|
-
sendToParent(ACTION_RESPONSE_EVENT_NAME,
|
|
29
|
+
sendToParent(ACTION_RESPONSE_EVENT_NAME,
|
|
30
|
+
// here we use JSON.stringify because we should not
|
|
32
31
|
// have non enumerable value (unlike there is on Error objects)
|
|
33
32
|
// otherwise uneval is quite slow to turn a giant object
|
|
34
33
|
// into a string (and value can be giant when using coverage)
|
|
@@ -37,7 +36,6 @@ const sendActionCompleted = value => {
|
|
|
37
36
|
value
|
|
38
37
|
}));
|
|
39
38
|
};
|
|
40
|
-
|
|
41
39
|
const sendToParent = (type, data) => {
|
|
42
40
|
// this can keep process alive longer than expected
|
|
43
41
|
// when source is a long string.
|
|
@@ -49,51 +47,41 @@ const sendToParent = (type, data) => {
|
|
|
49
47
|
data
|
|
50
48
|
});
|
|
51
49
|
};
|
|
52
|
-
|
|
53
50
|
const onceParentMessage = (type, callback) => {
|
|
54
51
|
const listener = message => {
|
|
55
52
|
if (message && message.jsenv && message.type === type) {
|
|
56
53
|
removeListener(); // commenting this line keep this worker alive
|
|
57
|
-
|
|
58
54
|
callback(message.data);
|
|
59
55
|
}
|
|
60
56
|
};
|
|
61
|
-
|
|
62
57
|
const removeListener = () => {
|
|
63
58
|
parentPort.removeListener("message", listener);
|
|
64
59
|
};
|
|
65
|
-
|
|
66
60
|
parentPort.on("message", listener);
|
|
67
61
|
return removeListener;
|
|
68
62
|
};
|
|
69
|
-
|
|
70
63
|
const removeActionRequestListener = onceParentMessage(ACTION_REQUEST_EVENT_NAME, async ({
|
|
71
64
|
actionType,
|
|
72
65
|
actionParams
|
|
73
66
|
}) => {
|
|
74
67
|
const action = ACTIONS_AVAILABLE[actionType];
|
|
75
|
-
|
|
76
68
|
if (!action) {
|
|
77
69
|
sendActionFailed(new Error(`unknown action ${actionType}`));
|
|
78
70
|
return;
|
|
79
71
|
}
|
|
80
|
-
|
|
81
72
|
let value;
|
|
82
73
|
let failed = false;
|
|
83
|
-
|
|
84
74
|
try {
|
|
85
75
|
value = await action(actionParams);
|
|
86
76
|
} catch (e) {
|
|
87
77
|
failed = true;
|
|
88
78
|
value = e;
|
|
89
79
|
}
|
|
90
|
-
|
|
91
80
|
if (failed) {
|
|
92
81
|
sendActionFailed(value);
|
|
93
82
|
} else {
|
|
94
83
|
sendActionCompleted(value);
|
|
95
84
|
}
|
|
96
|
-
|
|
97
85
|
if (actionParams.exitAfterAction) {
|
|
98
86
|
removeActionRequestListener();
|
|
99
87
|
}
|
package/dist/js/autoreload.js
CHANGED
|
@@ -3,11 +3,9 @@ import { parseSrcSet, stringifySrcSet } from "@jsenv/ast/src/html/html_src_set.j
|
|
|
3
3
|
|
|
4
4
|
const isAutoreloadEnabled = () => {
|
|
5
5
|
const value = window.localStorage.getItem("autoreload");
|
|
6
|
-
|
|
7
6
|
if (value === "0") {
|
|
8
7
|
return false;
|
|
9
8
|
}
|
|
10
|
-
|
|
11
9
|
return true;
|
|
12
10
|
};
|
|
13
11
|
const setAutoreloadPreference = value => {
|
|
@@ -18,7 +16,6 @@ const compareTwoUrlPaths = (url, otherUrl) => {
|
|
|
18
16
|
if (url === otherUrl) {
|
|
19
17
|
return true;
|
|
20
18
|
}
|
|
21
|
-
|
|
22
19
|
const urlObject = new URL(url);
|
|
23
20
|
const otherUrlObject = new URL(otherUrl);
|
|
24
21
|
return urlObject.origin === otherUrlObject.origin && urlObject.pathname === otherUrlObject.pathname;
|
|
@@ -36,33 +33,28 @@ const injectQuery = (url, query) => {
|
|
|
36
33
|
|
|
37
34
|
const reloadHtmlPage = () => {
|
|
38
35
|
window.location.reload(true);
|
|
39
|
-
};
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
// This function can consider everything as hot reloadable:
|
|
40
39
|
// - no need to check [hot-accept]and [hot-decline] attributes for instance
|
|
41
40
|
// This is because if something should full reload, we receive "full_reload"
|
|
42
41
|
// from server and this function is not called
|
|
43
|
-
|
|
44
42
|
const getDOMNodesUsingUrl = urlToReload => {
|
|
45
43
|
const nodes = [];
|
|
46
|
-
|
|
47
44
|
const shouldReloadUrl = urlCandidate => {
|
|
48
45
|
return compareTwoUrlPaths(urlCandidate, urlToReload);
|
|
49
46
|
};
|
|
50
|
-
|
|
51
47
|
const visitNodeAttributeAsUrl = (node, attributeName) => {
|
|
52
48
|
let attribute = node[attributeName];
|
|
53
|
-
|
|
54
49
|
if (!attribute) {
|
|
55
50
|
return;
|
|
56
51
|
}
|
|
57
|
-
|
|
58
52
|
if (SVGAnimatedString && attribute instanceof SVGAnimatedString) {
|
|
59
53
|
attribute = attribute.animVal;
|
|
60
54
|
}
|
|
61
|
-
|
|
62
55
|
if (!shouldReloadUrl(attribute)) {
|
|
63
56
|
return;
|
|
64
57
|
}
|
|
65
|
-
|
|
66
58
|
nodes.push({
|
|
67
59
|
node,
|
|
68
60
|
reload: () => {
|
|
@@ -74,7 +66,6 @@ const getDOMNodesUsingUrl = urlToReload => {
|
|
|
74
66
|
copy.src = injectQuery(node.src, {
|
|
75
67
|
hmr: Date.now()
|
|
76
68
|
});
|
|
77
|
-
|
|
78
69
|
if (node.parentNode) {
|
|
79
70
|
node.parentNode.replaceChild(copy, node);
|
|
80
71
|
} else {
|
|
@@ -88,7 +79,6 @@ const getDOMNodesUsingUrl = urlToReload => {
|
|
|
88
79
|
}
|
|
89
80
|
});
|
|
90
81
|
};
|
|
91
|
-
|
|
92
82
|
Array.from(document.querySelectorAll(`link[rel="stylesheet"]`)).forEach(link => {
|
|
93
83
|
visitNodeAttributeAsUrl(link, "href");
|
|
94
84
|
});
|
|
@@ -98,10 +88,8 @@ const getDOMNodesUsingUrl = urlToReload => {
|
|
|
98
88
|
Array.from(document.querySelectorAll("script")).forEach(script => {
|
|
99
89
|
visitNodeAttributeAsUrl(script, "src");
|
|
100
90
|
const inlinedFromSrc = script.getAttribute("inlined-from-src");
|
|
101
|
-
|
|
102
91
|
if (inlinedFromSrc) {
|
|
103
92
|
const inlinedFromUrl = new URL(inlinedFromSrc, window.location.origin).href;
|
|
104
|
-
|
|
105
93
|
if (shouldReloadUrl(inlinedFromUrl)) {
|
|
106
94
|
nodes.push({
|
|
107
95
|
node: script,
|
|
@@ -112,28 +100,26 @@ const getDOMNodesUsingUrl = urlToReload => {
|
|
|
112
100
|
});
|
|
113
101
|
}
|
|
114
102
|
}
|
|
115
|
-
});
|
|
103
|
+
});
|
|
104
|
+
// There is no real need to update a.href because the resource will be fetched when clicked.
|
|
116
105
|
// But in a scenario where the resource was already visited and is in browser cache, adding
|
|
117
106
|
// the dynamic query param ensure the cache is invalidated
|
|
118
|
-
|
|
119
107
|
Array.from(document.querySelectorAll("a")).forEach(a => {
|
|
120
108
|
visitNodeAttributeAsUrl(a, "href");
|
|
121
|
-
});
|
|
109
|
+
});
|
|
110
|
+
// About iframes:
|
|
122
111
|
// - By default iframe itself and everything inside trigger a parent page full-reload
|
|
123
112
|
// - Adding [hot-accept] on the iframe means parent page won't reload when iframe full/hot reload
|
|
124
113
|
// In that case and if there is code in the iframe and parent doing post message communication:
|
|
125
114
|
// you must put import.meta.hot.decline() for code involved in communication.
|
|
126
115
|
// (both in parent and iframe)
|
|
127
|
-
|
|
128
116
|
Array.from(document.querySelectorAll("img")).forEach(img => {
|
|
129
117
|
visitNodeAttributeAsUrl(img, "src");
|
|
130
118
|
const srcset = img.srcset;
|
|
131
|
-
|
|
132
119
|
if (srcset) {
|
|
133
120
|
const srcCandidates = parseSrcSet(srcset);
|
|
134
121
|
srcCandidates.forEach(srcCandidate => {
|
|
135
122
|
const url = new URL(srcCandidate.specifier, `${window.location.href}`);
|
|
136
|
-
|
|
137
123
|
if (shouldReloadUrl(url)) {
|
|
138
124
|
srcCandidate.specifier = injectQuery(url, {
|
|
139
125
|
hmr: Date.now()
|
|
@@ -150,12 +136,12 @@ const getDOMNodesUsingUrl = urlToReload => {
|
|
|
150
136
|
});
|
|
151
137
|
Array.from(document.querySelectorAll("source")).forEach(source => {
|
|
152
138
|
visitNodeAttributeAsUrl(source, "src");
|
|
153
|
-
});
|
|
154
|
-
|
|
139
|
+
});
|
|
140
|
+
// svg image tag
|
|
155
141
|
Array.from(document.querySelectorAll("image")).forEach(image => {
|
|
156
142
|
visitNodeAttributeAsUrl(image, "href");
|
|
157
|
-
});
|
|
158
|
-
|
|
143
|
+
});
|
|
144
|
+
// svg use
|
|
159
145
|
Array.from(document.querySelectorAll("use")).forEach(use => {
|
|
160
146
|
visitNodeAttributeAsUrl(use, "href");
|
|
161
147
|
});
|
|
@@ -183,7 +169,6 @@ const reloader = {
|
|
|
183
169
|
messages: [],
|
|
184
170
|
addMessage: reloadMessage => {
|
|
185
171
|
reloader.messages.push(reloadMessage);
|
|
186
|
-
|
|
187
172
|
if (isAutoreloadEnabled()) {
|
|
188
173
|
reloader.reload();
|
|
189
174
|
} else {
|
|
@@ -192,42 +177,34 @@ const reloader = {
|
|
|
192
177
|
},
|
|
193
178
|
reload: () => {
|
|
194
179
|
const someEffectIsFullReload = reloader.messages.some(reloadMessage => reloadMessage.type === "full");
|
|
195
|
-
|
|
196
180
|
if (someEffectIsFullReload) {
|
|
197
181
|
reloadHtmlPage();
|
|
198
182
|
return;
|
|
199
183
|
}
|
|
200
|
-
|
|
201
184
|
reloader.setStatus("reloading");
|
|
202
|
-
|
|
203
185
|
const onApplied = reloadMessage => {
|
|
204
186
|
const index = reloader.messages.indexOf(reloadMessage);
|
|
205
187
|
reloader.messages.splice(index, 1);
|
|
206
|
-
|
|
207
188
|
if (reloader.messages.length === 0) {
|
|
208
189
|
reloader.setStatus("idle");
|
|
209
190
|
}
|
|
210
191
|
};
|
|
211
|
-
|
|
212
192
|
const setReloadMessagePromise = (reloadMessage, promise) => {
|
|
213
193
|
promise.then(() => {
|
|
214
194
|
onApplied(reloadMessage);
|
|
215
195
|
reloader.currentExecution = null;
|
|
216
196
|
}, e => {
|
|
217
197
|
reloader.setStatus("failed");
|
|
218
|
-
|
|
219
198
|
if (typeof window.reportError === "function") {
|
|
220
199
|
window.reportError(e);
|
|
221
200
|
} else {
|
|
222
201
|
console.error(e);
|
|
223
202
|
}
|
|
224
|
-
|
|
225
203
|
console.error(`[jsenv] Hot reload failed after ${reloadMessage.reason}.
|
|
226
204
|
This could be due to syntax errors or importing non-existent modules (see errors in console)`);
|
|
227
205
|
reloader.currentExecution = null;
|
|
228
206
|
});
|
|
229
207
|
};
|
|
230
|
-
|
|
231
208
|
reloader.messages.forEach(reloadMessage => {
|
|
232
209
|
if (reloadMessage.type === "hot") {
|
|
233
210
|
const promise = addToHotQueue(() => {
|
|
@@ -242,21 +219,17 @@ This could be due to syntax errors or importing non-existent modules (see errors
|
|
|
242
219
|
};
|
|
243
220
|
let pendingCallbacks = [];
|
|
244
221
|
let running = false;
|
|
245
|
-
|
|
246
222
|
const addToHotQueue = async callback => {
|
|
247
223
|
pendingCallbacks.push(callback);
|
|
248
224
|
dequeue();
|
|
249
225
|
};
|
|
250
|
-
|
|
251
226
|
const dequeue = async () => {
|
|
252
227
|
if (running) {
|
|
253
228
|
return;
|
|
254
229
|
}
|
|
255
|
-
|
|
256
230
|
const callbacks = pendingCallbacks.slice();
|
|
257
231
|
pendingCallbacks = [];
|
|
258
232
|
running = true;
|
|
259
|
-
|
|
260
233
|
try {
|
|
261
234
|
await callbacks.reduce(async (previous, callback) => {
|
|
262
235
|
await previous;
|
|
@@ -264,13 +237,11 @@ const dequeue = async () => {
|
|
|
264
237
|
}, Promise.resolve());
|
|
265
238
|
} finally {
|
|
266
239
|
running = false;
|
|
267
|
-
|
|
268
240
|
if (pendingCallbacks.length) {
|
|
269
241
|
dequeue();
|
|
270
242
|
}
|
|
271
243
|
}
|
|
272
244
|
};
|
|
273
|
-
|
|
274
245
|
const applyHotReload = async ({
|
|
275
246
|
hotInstructions
|
|
276
247
|
}) => {
|
|
@@ -281,14 +252,14 @@ const applyHotReload = async ({
|
|
|
281
252
|
}) => {
|
|
282
253
|
await previous;
|
|
283
254
|
const urlToFetch = new URL(boundary, `${window.location.origin}/`).href;
|
|
284
|
-
const urlHotMeta = urlHotMetas[urlToFetch];
|
|
255
|
+
const urlHotMeta = urlHotMetas[urlToFetch];
|
|
256
|
+
// there is no url hot meta when:
|
|
285
257
|
// - code was not executed (code splitting with dynamic import)
|
|
286
258
|
// - import.meta.hot.accept() is not called (happens for HTML and CSS)
|
|
287
259
|
|
|
288
260
|
if (type === "prune") {
|
|
289
261
|
if (urlHotMeta) {
|
|
290
262
|
delete urlHotMetas[urlToFetch];
|
|
291
|
-
|
|
292
263
|
if (urlHotMeta.disposeCallback) {
|
|
293
264
|
console.groupCollapsed(`[jsenv] cleanup ${boundary} (previously used in ${acceptedBy})`);
|
|
294
265
|
console.log(`call dispose callback`);
|
|
@@ -296,53 +267,43 @@ const applyHotReload = async ({
|
|
|
296
267
|
console.groupEnd();
|
|
297
268
|
}
|
|
298
269
|
}
|
|
299
|
-
|
|
300
270
|
return null;
|
|
301
271
|
}
|
|
302
|
-
|
|
303
272
|
if (acceptedBy === boundary) {
|
|
304
273
|
console.groupCollapsed(`[jsenv] hot reloading ${boundary}`);
|
|
305
274
|
} else {
|
|
306
275
|
console.groupCollapsed(`[jsenv] hot reloading ${acceptedBy} usage in ${boundary}`);
|
|
307
276
|
}
|
|
308
|
-
|
|
309
277
|
if (type === "js_module") {
|
|
310
278
|
if (!urlHotMeta) {
|
|
311
279
|
// code was not executed, no need to re-execute it
|
|
312
280
|
return null;
|
|
313
281
|
}
|
|
314
|
-
|
|
315
282
|
if (urlHotMeta.disposeCallback) {
|
|
316
283
|
console.log(`call dispose callback`);
|
|
317
284
|
await urlHotMeta.disposeCallback();
|
|
318
285
|
}
|
|
319
|
-
|
|
320
286
|
console.log(`importing js module`);
|
|
321
287
|
reloader.currentExecution = {
|
|
322
288
|
type: "dynamic_import",
|
|
323
289
|
url: urlToFetch
|
|
324
290
|
};
|
|
325
291
|
const namespace = await reloadJsImport(urlToFetch);
|
|
326
|
-
|
|
327
292
|
if (urlHotMeta.acceptCallback) {
|
|
328
293
|
await urlHotMeta.acceptCallback(namespace);
|
|
329
294
|
}
|
|
330
|
-
|
|
331
295
|
console.log(`js module import done`);
|
|
332
296
|
console.groupEnd();
|
|
333
297
|
return namespace;
|
|
334
298
|
}
|
|
335
|
-
|
|
336
299
|
if (type === "html") {
|
|
337
300
|
if (!compareTwoUrlPaths(urlToFetch, window.location.href)) {
|
|
338
301
|
// we are not in that HTML page
|
|
339
302
|
return null;
|
|
340
303
|
}
|
|
341
|
-
|
|
342
304
|
const urlToReload = new URL(acceptedBy, `${window.location.origin}/`).href;
|
|
343
305
|
const domNodesUsingUrl = getDOMNodesUsingUrl(urlToReload);
|
|
344
306
|
const domNodesCount = domNodesUsingUrl.length;
|
|
345
|
-
|
|
346
307
|
if (domNodesCount === 0) {
|
|
347
308
|
console.log(`no dom node using ${acceptedBy}`);
|
|
348
309
|
} else if (domNodesCount === 1) {
|
|
@@ -354,18 +315,14 @@ const applyHotReload = async ({
|
|
|
354
315
|
domNodesUsingUrl.reload();
|
|
355
316
|
});
|
|
356
317
|
}
|
|
357
|
-
|
|
358
318
|
console.groupEnd();
|
|
359
319
|
return null;
|
|
360
320
|
}
|
|
361
|
-
|
|
362
321
|
console.warn(`unknown update type: "${type}"`);
|
|
363
322
|
return null;
|
|
364
323
|
}, Promise.resolve());
|
|
365
324
|
};
|
|
366
|
-
|
|
367
325
|
window.__reloader__ = reloader;
|
|
368
|
-
|
|
369
326
|
window.__server_events__.listenEvents({
|
|
370
327
|
reload: reloadServerEvent => {
|
|
371
328
|
reloader.addMessage(reloadServerEvent.data);
|