@jsenv/core 27.0.0-alpha.68 → 27.0.0-alpha.70
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.
|
@@ -393,25 +393,19 @@ const installHtmlSupervisor = ({
|
|
|
393
393
|
}
|
|
394
394
|
};
|
|
395
395
|
|
|
396
|
-
const
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
if (next) {
|
|
403
|
-
__html_supervisor__.addScriptToExecute(next);
|
|
396
|
+
const classicExecutionQueue = createExecutionQueue(performExecution);
|
|
397
|
+
const deferedExecutionQueue = createExecutionQueue(performExecution);
|
|
398
|
+
deferedExecutionQueue.waitFor(new Promise(resolve => {
|
|
399
|
+
if (document.readyState === "interactive" || document.readyState === "complete") {
|
|
400
|
+
resolve();
|
|
404
401
|
} else {
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
}
|
|
402
|
+
document.addEventListener("readystatechange", () => {
|
|
403
|
+
if (document.readyState === "interactive") {
|
|
404
|
+
resolve();
|
|
405
|
+
}
|
|
406
|
+
});
|
|
410
407
|
}
|
|
411
|
-
};
|
|
412
|
-
|
|
413
|
-
const deferQueue = [];
|
|
414
|
-
let previousDeferDonePromise = null;
|
|
408
|
+
}));
|
|
415
409
|
|
|
416
410
|
__html_supervisor__.addScriptToExecute = async scriptToExecute => {
|
|
417
411
|
if (scriptToExecute.async) {
|
|
@@ -422,52 +416,19 @@ const installHtmlSupervisor = ({
|
|
|
422
416
|
const useDeferQueue = scriptToExecute.defer || scriptToExecute.type === "js_module";
|
|
423
417
|
|
|
424
418
|
if (useDeferQueue) {
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
return;
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
if (previousDonePromise) {
|
|
431
|
-
// defer must wait for the regular script to be done
|
|
432
|
-
deferQueue.push(scriptToExecute);
|
|
433
|
-
return;
|
|
434
|
-
}
|
|
419
|
+
// defer must wait for classic script to be done
|
|
420
|
+
const classicExecutionPromise = classicExecutionQueue.getPromise();
|
|
435
421
|
|
|
436
|
-
if (
|
|
437
|
-
|
|
438
|
-
return;
|
|
422
|
+
if (classicExecutionPromise) {
|
|
423
|
+
deferedExecutionQueue.waitFor(classicExecutionPromise);
|
|
439
424
|
}
|
|
440
425
|
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
dequeue();
|
|
445
|
-
return;
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
if (previousDonePromise) {
|
|
449
|
-
queue.push(scriptToExecute);
|
|
450
|
-
return;
|
|
426
|
+
deferedExecutionQueue.executeAsap(scriptToExecute);
|
|
427
|
+
} else {
|
|
428
|
+
classicExecutionQueue.executeAsap(scriptToExecute);
|
|
451
429
|
}
|
|
452
|
-
|
|
453
|
-
previousDonePromise = performExecution(scriptToExecute);
|
|
454
|
-
await previousDonePromise;
|
|
455
|
-
previousDonePromise = null;
|
|
456
|
-
dequeue();
|
|
457
430
|
};
|
|
458
431
|
|
|
459
|
-
if (document.readyState !== "interactive" && document.readyState !== "complete") {
|
|
460
|
-
document.addEventListener("readystatechange", () => {
|
|
461
|
-
if (document.readyState === "interactive") {
|
|
462
|
-
const nextDefered = deferQueue.shift();
|
|
463
|
-
|
|
464
|
-
if (nextDefered) {
|
|
465
|
-
__html_supervisor__.addScriptToExecute(nextDefered);
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
});
|
|
469
|
-
}
|
|
470
|
-
|
|
471
432
|
__html_supervisor__.collectScriptResults = async () => {
|
|
472
433
|
collectCalled = true;
|
|
473
434
|
|
|
@@ -519,4 +480,43 @@ const superviseScriptTypeModule = ({
|
|
|
519
480
|
});
|
|
520
481
|
};
|
|
521
482
|
|
|
483
|
+
const createExecutionQueue = execute => {
|
|
484
|
+
const scripts = [];
|
|
485
|
+
let promiseToWait = null;
|
|
486
|
+
|
|
487
|
+
const waitFor = async promise => {
|
|
488
|
+
promiseToWait = promise;
|
|
489
|
+
promiseToWait.then(() => {
|
|
490
|
+
promiseToWait = null;
|
|
491
|
+
dequeue();
|
|
492
|
+
}, () => {
|
|
493
|
+
promiseToWait = null;
|
|
494
|
+
dequeue();
|
|
495
|
+
});
|
|
496
|
+
};
|
|
497
|
+
|
|
498
|
+
const executeAsap = async script => {
|
|
499
|
+
if (promiseToWait) {
|
|
500
|
+
scripts.push(script);
|
|
501
|
+
return;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
waitFor(execute(script));
|
|
505
|
+
};
|
|
506
|
+
|
|
507
|
+
const dequeue = () => {
|
|
508
|
+
const scriptWaiting = scripts.shift();
|
|
509
|
+
|
|
510
|
+
if (scriptWaiting) {
|
|
511
|
+
__html_supervisor__.addScriptToExecute(scriptWaiting);
|
|
512
|
+
}
|
|
513
|
+
};
|
|
514
|
+
|
|
515
|
+
return {
|
|
516
|
+
waitFor,
|
|
517
|
+
executeAsap,
|
|
518
|
+
getPromise: () => promiseToWait
|
|
519
|
+
};
|
|
520
|
+
};
|
|
521
|
+
|
|
522
522
|
export { installHtmlSupervisor, superviseScriptTypeModule };
|
package/dist/main.js
CHANGED
|
@@ -8403,7 +8403,7 @@ const startDevServer = async ({
|
|
|
8403
8403
|
// - inside a forked child process
|
|
8404
8404
|
// - inside a worker thread
|
|
8405
8405
|
// (because node cluster won't work)
|
|
8406
|
-
devServerAutoreload = typeof process.send !== "function" && !parentPort && !process.
|
|
8406
|
+
devServerAutoreload = typeof process.send !== "function" && !parentPort && !process.env.VSCODE_INSPECTOR_OPTIONS,
|
|
8407
8407
|
clientFiles = {
|
|
8408
8408
|
"./**": true,
|
|
8409
8409
|
"./**/.*/": false,
|
|
@@ -13143,7 +13143,7 @@ const startBuildServer = async ({
|
|
|
13143
13143
|
// - inside a forked child process
|
|
13144
13144
|
// - inside a worker thread
|
|
13145
13145
|
// (because node cluster won't work)
|
|
13146
|
-
buildServerAutoreload = typeof process.send !== "function" && !parentPort && !process.
|
|
13146
|
+
buildServerAutoreload = typeof process.send !== "function" && !parentPort && !process.env.VSCODE_INSPECTOR_OPTIONS,
|
|
13147
13147
|
cooldownBetweenFileEvents
|
|
13148
13148
|
}) => {
|
|
13149
13149
|
const logger = createLogger({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/core",
|
|
3
|
-
"version": "27.0.0-alpha.
|
|
3
|
+
"version": "27.0.0-alpha.70",
|
|
4
4
|
"description": "Tool to develop, test and build js projects",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"@financial-times/polyfill-useragent-normaliser": "2.0.1",
|
|
70
70
|
"@jsenv/abort": "4.1.2",
|
|
71
71
|
"@jsenv/babel-plugins": "1.0.2",
|
|
72
|
-
"@jsenv/filesystem": "4.0.
|
|
72
|
+
"@jsenv/filesystem": "4.0.2",
|
|
73
73
|
"@jsenv/importmap": "1.2.0",
|
|
74
74
|
"@jsenv/integrity": "0.0.1",
|
|
75
75
|
"@jsenv/log": "1.6.3",
|
|
@@ -77,8 +77,8 @@
|
|
|
77
77
|
"@jsenv/node-esm-resolution": "0.0.10",
|
|
78
78
|
"@jsenv/server": "12.6.3",
|
|
79
79
|
"@jsenv/uneval": "1.6.0",
|
|
80
|
-
"@jsenv/utils": "1.8.
|
|
81
|
-
"@jsenv/urls": "1.1.
|
|
80
|
+
"@jsenv/utils": "1.8.5",
|
|
81
|
+
"@jsenv/urls": "1.1.2",
|
|
82
82
|
"construct-style-sheets-polyfill": "3.1.0",
|
|
83
83
|
"cssnano": "5.1.7",
|
|
84
84
|
"cssnano-preset-default": "5.2.7",
|
|
@@ -61,7 +61,7 @@ export const startBuildServer = async ({
|
|
|
61
61
|
// (because node cluster won't work)
|
|
62
62
|
buildServerAutoreload = typeof process.send !== "function" &&
|
|
63
63
|
!parentPort &&
|
|
64
|
-
!process.
|
|
64
|
+
!process.env.VSCODE_INSPECTOR_OPTIONS,
|
|
65
65
|
cooldownBetweenFileEvents,
|
|
66
66
|
}) => {
|
|
67
67
|
const logger = createLogger({ logLevel })
|
|
@@ -42,7 +42,7 @@ export const startDevServer = async ({
|
|
|
42
42
|
// (because node cluster won't work)
|
|
43
43
|
devServerAutoreload = typeof process.send !== "function" &&
|
|
44
44
|
!parentPort &&
|
|
45
|
-
!process.
|
|
45
|
+
!process.env.VSCODE_INSPECTOR_OPTIONS,
|
|
46
46
|
clientFiles = {
|
|
47
47
|
"./**": true,
|
|
48
48
|
"./**/.*/": false, // any folder starting with a dot is ignored (includes .git,.jsenv for instance)
|
|
@@ -133,21 +133,24 @@ export const installHtmlSupervisor = ({ logs, measurePerf }) => {
|
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
-
const
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
136
|
+
const classicExecutionQueue = createExecutionQueue(performExecution)
|
|
137
|
+
const deferedExecutionQueue = createExecutionQueue(performExecution)
|
|
138
|
+
deferedExecutionQueue.waitFor(
|
|
139
|
+
new Promise((resolve) => {
|
|
140
|
+
if (
|
|
141
|
+
document.readyState === "interactive" ||
|
|
142
|
+
document.readyState === "complete"
|
|
143
|
+
) {
|
|
144
|
+
resolve()
|
|
145
|
+
} else {
|
|
146
|
+
document.addEventListener("readystatechange", () => {
|
|
147
|
+
if (document.readyState === "interactive") {
|
|
148
|
+
resolve()
|
|
149
|
+
}
|
|
150
|
+
})
|
|
146
151
|
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
const deferQueue = []
|
|
150
|
-
let previousDeferDonePromise = null
|
|
152
|
+
}),
|
|
153
|
+
)
|
|
151
154
|
__html_supervisor__.addScriptToExecute = async (scriptToExecute) => {
|
|
152
155
|
if (scriptToExecute.async) {
|
|
153
156
|
performExecution(scriptToExecute)
|
|
@@ -156,46 +159,15 @@ export const installHtmlSupervisor = ({ logs, measurePerf }) => {
|
|
|
156
159
|
const useDeferQueue =
|
|
157
160
|
scriptToExecute.defer || scriptToExecute.type === "js_module"
|
|
158
161
|
if (useDeferQueue) {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
if (previousDonePromise) {
|
|
164
|
-
// defer must wait for the regular script to be done
|
|
165
|
-
deferQueue.push(scriptToExecute)
|
|
166
|
-
return
|
|
167
|
-
}
|
|
168
|
-
if (previousDeferDonePromise) {
|
|
169
|
-
deferQueue.push(scriptToExecute)
|
|
170
|
-
return
|
|
162
|
+
// defer must wait for classic script to be done
|
|
163
|
+
const classicExecutionPromise = classicExecutionQueue.getPromise()
|
|
164
|
+
if (classicExecutionPromise) {
|
|
165
|
+
deferedExecutionQueue.waitFor(classicExecutionPromise)
|
|
171
166
|
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
dequeue()
|
|
176
|
-
return
|
|
177
|
-
}
|
|
178
|
-
if (previousDonePromise) {
|
|
179
|
-
queue.push(scriptToExecute)
|
|
180
|
-
return
|
|
167
|
+
deferedExecutionQueue.executeAsap(scriptToExecute)
|
|
168
|
+
} else {
|
|
169
|
+
classicExecutionQueue.executeAsap(scriptToExecute)
|
|
181
170
|
}
|
|
182
|
-
previousDonePromise = performExecution(scriptToExecute)
|
|
183
|
-
await previousDonePromise
|
|
184
|
-
previousDonePromise = null
|
|
185
|
-
dequeue()
|
|
186
|
-
}
|
|
187
|
-
if (
|
|
188
|
-
document.readyState !== "interactive" &&
|
|
189
|
-
document.readyState !== "complete"
|
|
190
|
-
) {
|
|
191
|
-
document.addEventListener("readystatechange", () => {
|
|
192
|
-
if (document.readyState === "interactive") {
|
|
193
|
-
const nextDefered = deferQueue.shift()
|
|
194
|
-
if (nextDefered) {
|
|
195
|
-
__html_supervisor__.addScriptToExecute(nextDefered)
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
})
|
|
199
171
|
}
|
|
200
172
|
|
|
201
173
|
__html_supervisor__.collectScriptResults = async () => {
|
|
@@ -240,3 +212,43 @@ export const superviseScriptTypeModule = ({ src, isInline }) => {
|
|
|
240
212
|
execute: () => import(new URL(src, document.location.href).href),
|
|
241
213
|
})
|
|
242
214
|
}
|
|
215
|
+
|
|
216
|
+
const createExecutionQueue = (execute) => {
|
|
217
|
+
const scripts = []
|
|
218
|
+
|
|
219
|
+
let promiseToWait = null
|
|
220
|
+
const waitFor = async (promise) => {
|
|
221
|
+
promiseToWait = promise
|
|
222
|
+
promiseToWait.then(
|
|
223
|
+
() => {
|
|
224
|
+
promiseToWait = null
|
|
225
|
+
dequeue()
|
|
226
|
+
},
|
|
227
|
+
() => {
|
|
228
|
+
promiseToWait = null
|
|
229
|
+
dequeue()
|
|
230
|
+
},
|
|
231
|
+
)
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
const executeAsap = async (script) => {
|
|
235
|
+
if (promiseToWait) {
|
|
236
|
+
scripts.push(script)
|
|
237
|
+
return
|
|
238
|
+
}
|
|
239
|
+
waitFor(execute(script))
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
const dequeue = () => {
|
|
243
|
+
const scriptWaiting = scripts.shift()
|
|
244
|
+
if (scriptWaiting) {
|
|
245
|
+
__html_supervisor__.addScriptToExecute(scriptWaiting)
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
return {
|
|
250
|
+
waitFor,
|
|
251
|
+
executeAsap,
|
|
252
|
+
getPromise: () => promiseToWait,
|
|
253
|
+
}
|
|
254
|
+
}
|