@jsenv/core 28.0.0 → 28.1.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/controllable_child_process.mjs +1 -2
- package/dist/controllable_worker_thread.mjs +1 -2
- package/dist/js/autoreload.js +27 -11
- package/dist/js/execute_using_dynamic_import.js +804 -1
- package/dist/js/script_type_module_supervisor.js +129 -0
- package/dist/js/supervisor.js +921 -0
- package/dist/js/{wrapper.mjs → ws.js} +0 -0
- package/dist/main.js +555 -616
- package/package.json +13 -13
- package/readme.md +2 -2
- package/src/build/build.js +8 -8
- package/src/build/inject_global_version_mappings.js +3 -3
- package/src/build/{resync_ressource_hints.js → resync_resource_hints.js} +10 -12
- package/src/build/start_build_server.js +4 -7
- package/src/dev/start_dev_server.js +2 -2
- package/src/execute/execute.js +1 -1
- package/src/execute/run.js +26 -38
- package/src/execute/runtimes/browsers/from_playwright.js +51 -77
- package/src/execute/runtimes/node/node_child_process.js +36 -36
- package/src/execute/runtimes/node/node_worker_thread.js +36 -36
- package/src/omega/kitchen.js +33 -14
- package/src/omega/omega_server.js +2 -2
- package/src/omega/server/file_service.js +5 -5
- package/src/omega/url_graph/url_graph_load.js +4 -4
- package/src/omega/url_graph/url_info_transformations.js +8 -1
- package/src/omega/url_graph.js +3 -3
- package/src/plugins/autoreload/client/reload.js +22 -9
- package/src/plugins/autoreload/jsenv_plugin_autoreload_client.js +5 -5
- package/src/plugins/autoreload/jsenv_plugin_autoreload_server.js +3 -3
- package/src/plugins/autoreload/jsenv_plugin_hmr.js +1 -1
- package/src/plugins/explorer/jsenv_plugin_explorer.js +1 -1
- package/src/plugins/import_meta_hot/html_hot_dependencies.js +6 -6
- package/src/plugins/importmap/jsenv_plugin_importmap.js +5 -3
- package/src/plugins/inject_globals/inject_globals.js +3 -3
- package/src/plugins/inline/jsenv_plugin_data_urls.js +1 -1
- package/src/plugins/inline/jsenv_plugin_html_inline_content.js +10 -5
- package/src/plugins/node_esm_resolution/jsenv_plugin_node_esm_resolution.js +2 -13
- package/src/plugins/plugin_controller.js +2 -2
- package/src/plugins/plugins.js +5 -5
- package/src/plugins/server_events/jsenv_plugin_server_events_client_injection.js +4 -4
- package/src/plugins/supervisor/client/script_type_module_supervisor.js +108 -0
- package/src/plugins/supervisor/client/supervisor.js +921 -0
- package/src/plugins/{html_supervisor/jsenv_plugin_html_supervisor.js → supervisor/jsenv_plugin_supervisor.js} +131 -105
- package/src/plugins/toolbar/client/execution/toolbar_execution.js +1 -1
- package/src/plugins/toolbar/jsenv_plugin_toolbar.js +5 -5
- package/src/plugins/transpilation/as_js_classic/jsenv_plugin_as_js_classic.js +9 -7
- package/src/plugins/transpilation/as_js_classic/jsenv_plugin_as_js_classic_html.js +8 -7
- package/src/plugins/transpilation/babel/jsenv_plugin_babel.js +13 -7
- package/src/plugins/transpilation/babel/new_stylesheet/babel_plugin_new_stylesheet_as_jsenv_import.js +6 -4
- package/src/plugins/transpilation/jsenv_plugin_transpilation.js +4 -2
- package/src/plugins/url_analysis/html/html_urls.js +13 -12
- package/src/plugins/url_analysis/jsenv_plugin_url_analysis.js +1 -1
- package/src/test/coverage/babel_plugin_instrument.js +1 -35
- package/src/test/coverage/empty_coverage_factory.js +1 -1
- package/src/test/execute_plan.js +7 -3
- package/src/test/execute_test_plan.js +2 -1
- package/src/test/logs_file_execution.js +49 -8
- package/dist/js/html_supervisor_installer.js +0 -1091
- package/dist/js/html_supervisor_setup.js +0 -89
- package/dist/js/uneval.js +0 -804
- package/src/plugins/html_supervisor/client/error_formatter.js +0 -426
- package/src/plugins/html_supervisor/client/error_in_notification.js +0 -21
- package/src/plugins/html_supervisor/client/error_overlay.js +0 -191
- package/src/plugins/html_supervisor/client/html_supervisor_installer.js +0 -315
- package/src/plugins/html_supervisor/client/html_supervisor_setup.js +0 -89
- package/src/plugins/html_supervisor/client/perf_browser.js +0 -17
- package/src/plugins/html_supervisor/client/uneval_exception.js +0 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/core",
|
|
3
|
-
"version": "28.
|
|
3
|
+
"version": "28.1.0",
|
|
4
4
|
"description": "Tool to develop, test and build js projects",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -66,14 +66,14 @@
|
|
|
66
66
|
"@c88/v8-coverage": "0.1.1",
|
|
67
67
|
"@financial-times/polyfill-useragent-normaliser": "2.0.1",
|
|
68
68
|
"@jsenv/abort": "4.2.3",
|
|
69
|
-
"@jsenv/ast": "1.
|
|
69
|
+
"@jsenv/ast": "1.2.0",
|
|
70
70
|
"@jsenv/babel-plugins": "1.0.6",
|
|
71
|
-
"@jsenv/filesystem": "4.1.
|
|
71
|
+
"@jsenv/filesystem": "4.1.2",
|
|
72
72
|
"@jsenv/importmap": "1.2.1",
|
|
73
73
|
"@jsenv/integrity": "0.0.1",
|
|
74
|
-
"@jsenv/log": "3.
|
|
74
|
+
"@jsenv/log": "3.2.0",
|
|
75
75
|
"@jsenv/node-esm-resolution": "0.1.0",
|
|
76
|
-
"@jsenv/server": "14.
|
|
76
|
+
"@jsenv/server": "14.1.1",
|
|
77
77
|
"@jsenv/sourcemap": "1.0.4",
|
|
78
78
|
"@jsenv/uneval": "1.6.0",
|
|
79
79
|
"@jsenv/url-meta": "7.0.0",
|
|
@@ -87,9 +87,9 @@
|
|
|
87
87
|
"istanbul-lib-instrument": "5.2.0",
|
|
88
88
|
"istanbul-lib-report": "3.0.0",
|
|
89
89
|
"istanbul-reports": "3.1.5",
|
|
90
|
-
"launch-editor": "2.
|
|
90
|
+
"launch-editor": "2.5.0",
|
|
91
91
|
"pidtree": "0.6.0",
|
|
92
|
-
"rollup": "2.77.
|
|
92
|
+
"rollup": "2.77.2",
|
|
93
93
|
"string-width": "5.1.2",
|
|
94
94
|
"strip-ansi": "7.0.1",
|
|
95
95
|
"terser": "5.14.2",
|
|
@@ -97,19 +97,19 @@
|
|
|
97
97
|
"wrap-ansi": "8.0.1"
|
|
98
98
|
},
|
|
99
99
|
"devDependencies": {
|
|
100
|
-
"@babel/eslint-parser": "7.18.
|
|
100
|
+
"@babel/eslint-parser": "7.18.9",
|
|
101
101
|
"@babel/plugin-syntax-import-assertions": "7.18.6",
|
|
102
|
-
"@jsenv/assert": "2.
|
|
102
|
+
"@jsenv/assert": "2.7.0",
|
|
103
103
|
"@jsenv/eslint-config": "16.2.1",
|
|
104
104
|
"@jsenv/file-size-impact": "13.0.1",
|
|
105
|
-
"@jsenv/https-local": "
|
|
105
|
+
"@jsenv/https-local": "3.0.1",
|
|
106
106
|
"@jsenv/package-workspace": "0.4.1",
|
|
107
107
|
"@jsenv/performance-impact": "3.0.1",
|
|
108
|
-
"eslint": "8.
|
|
109
|
-
"eslint-plugin-html": "7.
|
|
108
|
+
"eslint": "8.21.0",
|
|
109
|
+
"eslint-plugin-html": "7.1.0",
|
|
110
110
|
"eslint-plugin-import": "2.26.0",
|
|
111
111
|
"eslint-plugin-react": "7.30.1",
|
|
112
|
-
"playwright": "1.24.
|
|
112
|
+
"playwright": "1.24.2",
|
|
113
113
|
"prettier": "2.7.1"
|
|
114
114
|
}
|
|
115
115
|
}
|
package/readme.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# @jsenv/core [](https://www.npmjs.com/package/@jsenv/core)
|
|
2
2
|
|
|
3
3
|
Jsenv was first created to write tests that could be executed in different runtimes.
|
|
4
|
-
It has naturally evolved to cover the core needs of a JavaScript project: developement, testing and building for production.
|
|
4
|
+
It has naturally evolved to cover the core needs of a JavaScript project: developement, testing and building for production.
|
|
5
5
|
|
|
6
6
|
- :exploding_head: Execute HTML files as tests
|
|
7
7
|
- :sparkles: A single tool for the whole developer experience
|
|
@@ -16,7 +16,7 @@ npm create jsenv@latest
|
|
|
16
16
|
```
|
|
17
17
|
|
|
18
18
|
This command prompts to choose a demo from a list.
|
|
19
|
-
Each demo contains preconfigured scripts
|
|
19
|
+
Each demo contains preconfigured scripts:
|
|
20
20
|
|
|
21
21
|
- `npm run dev`: starts a dev server with autoreload.
|
|
22
22
|
- `npm run test`: execute test files on browsers(s) and/or Node.js.
|
package/src/build/build.js
CHANGED
|
@@ -45,7 +45,7 @@ import { createBuilUrlsGenerator } from "./build_urls_generator.js"
|
|
|
45
45
|
import { injectGlobalVersionMapping } from "./inject_global_version_mappings.js"
|
|
46
46
|
import { createVersionGenerator } from "./version_generator.js"
|
|
47
47
|
import { injectServiceWorkerUrls } from "./inject_service_worker_urls.js"
|
|
48
|
-
import {
|
|
48
|
+
import { resyncResourceHints } from "./resync_resource_hints.js"
|
|
49
49
|
|
|
50
50
|
// default runtimeCompat corresponds to
|
|
51
51
|
// "we can keep <script type="module"> intact":
|
|
@@ -314,13 +314,13 @@ build ${entryPointKeys.length} entry points`)
|
|
|
314
314
|
})
|
|
315
315
|
rawUrlInfo.references.forEach((reference) => {
|
|
316
316
|
if (
|
|
317
|
-
reference.
|
|
317
|
+
reference.isResourceHint &&
|
|
318
318
|
reference.expectedType === "js_module"
|
|
319
319
|
) {
|
|
320
320
|
const referencedUrlInfo = rawGraph.getUrlInfo(reference.url)
|
|
321
321
|
if (
|
|
322
322
|
referencedUrlInfo &&
|
|
323
|
-
// something else than the
|
|
323
|
+
// something else than the resource hint is using this url
|
|
324
324
|
referencedUrlInfo.dependents.size > 0
|
|
325
325
|
) {
|
|
326
326
|
addToBundlerIfAny(referencedUrlInfo)
|
|
@@ -611,7 +611,7 @@ build ${entryPointKeys.length} entry points`)
|
|
|
611
611
|
`urls should be inside build directory at this stage, found "${reference.url}"`,
|
|
612
612
|
)
|
|
613
613
|
}
|
|
614
|
-
if (reference.
|
|
614
|
+
if (reference.isResourceHint) {
|
|
615
615
|
// return the raw url, we will resync at the end
|
|
616
616
|
return rawUrls[reference.url]
|
|
617
617
|
}
|
|
@@ -717,7 +717,7 @@ build ${entryPointKeys.length} entry points`)
|
|
|
717
717
|
kitchen: finalGraphKitchen,
|
|
718
718
|
outDirectoryUrl: new URL(".jsenv/postbuild/", rootDirectoryUrl),
|
|
719
719
|
writeGeneratedFiles,
|
|
720
|
-
|
|
720
|
+
skipResourceHint: true,
|
|
721
721
|
startLoading: (cookEntryFile) => {
|
|
722
722
|
entryUrls.forEach((entryUrl) => {
|
|
723
723
|
const [, postBuildEntryUrlInfo] = cookEntryFile({
|
|
@@ -786,7 +786,7 @@ ${Array.from(finalGraph.urlInfoMap.keys()).join("\n")}`,
|
|
|
786
786
|
urlInfo.data.buildUrlIsVersioned = useVersionedUrl
|
|
787
787
|
urlInfo.data.buildUrlSpecifier = buildUrlSpecifier
|
|
788
788
|
})
|
|
789
|
-
await
|
|
789
|
+
await resyncResourceHints({
|
|
790
790
|
logger,
|
|
791
791
|
finalGraphKitchen,
|
|
792
792
|
finalGraph,
|
|
@@ -1116,7 +1116,7 @@ const applyUrlVersioning = async ({
|
|
|
1116
1116
|
if (reference.isInline || reference.url.startsWith("data:")) {
|
|
1117
1117
|
return null
|
|
1118
1118
|
}
|
|
1119
|
-
if (reference.
|
|
1119
|
+
if (reference.isResourceHint) {
|
|
1120
1120
|
return null
|
|
1121
1121
|
}
|
|
1122
1122
|
// specifier comes from "normalize" hook done a bit earlier in this file
|
|
@@ -1185,7 +1185,7 @@ const applyUrlVersioning = async ({
|
|
|
1185
1185
|
operation: buildOperation,
|
|
1186
1186
|
urlGraph: finalGraph,
|
|
1187
1187
|
kitchen: versioningKitchen,
|
|
1188
|
-
|
|
1188
|
+
skipResourceHint: true,
|
|
1189
1189
|
writeGeneratedFiles,
|
|
1190
1190
|
startLoading: (cookEntryFile) => {
|
|
1191
1191
|
postBuildEntryUrls.forEach((postBuildEntryUrl) => {
|
|
@@ -61,12 +61,12 @@ const injectors = {
|
|
|
61
61
|
injectScriptNodeAsEarlyAsPossible(
|
|
62
62
|
htmlAst,
|
|
63
63
|
createHtmlNode({
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
tagName: "script",
|
|
65
|
+
textContent: generateClientCodeForVersionMappings(versionMappings, {
|
|
66
66
|
globalName: "window",
|
|
67
67
|
}),
|
|
68
|
-
"injected-by": "jsenv:versioning",
|
|
69
68
|
}),
|
|
69
|
+
"jsenv:versioning",
|
|
70
70
|
)
|
|
71
71
|
return {
|
|
72
72
|
content: stringifyHtmlAst(htmlAst),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* Update <link rel="preload"> and friends after build (once we know everything)
|
|
3
3
|
*
|
|
4
|
-
* - Used to remove
|
|
4
|
+
* - Used to remove resource hint targeting an url that is no longer used:
|
|
5
5
|
* - Happens because of import assertions transpilation (file is inlined into JS)
|
|
6
6
|
*/
|
|
7
7
|
|
|
@@ -16,19 +16,19 @@ import {
|
|
|
16
16
|
|
|
17
17
|
import { GRAPH } from "./graph_utils.js"
|
|
18
18
|
|
|
19
|
-
export const
|
|
19
|
+
export const resyncResourceHints = async ({
|
|
20
20
|
logger,
|
|
21
21
|
finalGraphKitchen,
|
|
22
22
|
finalGraph,
|
|
23
23
|
rawUrls,
|
|
24
24
|
postBuildRedirections,
|
|
25
25
|
}) => {
|
|
26
|
-
const
|
|
26
|
+
const resourceHintActions = []
|
|
27
27
|
GRAPH.forEach(finalGraph, (urlInfo) => {
|
|
28
28
|
if (urlInfo.type !== "html") {
|
|
29
29
|
return
|
|
30
30
|
}
|
|
31
|
-
|
|
31
|
+
resourceHintActions.push(async () => {
|
|
32
32
|
const htmlAst = parseHtmlString(urlInfo.content, {
|
|
33
33
|
storeOriginalPositions: false,
|
|
34
34
|
})
|
|
@@ -38,14 +38,14 @@ export const resyncRessourceHints = async ({
|
|
|
38
38
|
return
|
|
39
39
|
}
|
|
40
40
|
const rel = getHtmlNodeAttribute(linkNode, "rel")
|
|
41
|
-
const
|
|
41
|
+
const isresourceHint = [
|
|
42
42
|
"preconnect",
|
|
43
43
|
"dns-prefetch",
|
|
44
44
|
"prefetch",
|
|
45
45
|
"preload",
|
|
46
46
|
"modulepreload",
|
|
47
47
|
].includes(rel)
|
|
48
|
-
if (!
|
|
48
|
+
if (!isresourceHint) {
|
|
49
49
|
return
|
|
50
50
|
}
|
|
51
51
|
|
|
@@ -57,7 +57,7 @@ export const resyncRessourceHints = async ({
|
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
if (!buildUrl) {
|
|
60
|
-
logger.warn(`remove
|
|
60
|
+
logger.warn(`remove resource hint because cannot find "${href}"`)
|
|
61
61
|
actions.push(() => {
|
|
62
62
|
removeHtmlNode(linkNode)
|
|
63
63
|
})
|
|
@@ -67,7 +67,7 @@ export const resyncRessourceHints = async ({
|
|
|
67
67
|
const urlInfo = finalGraph.getUrlInfo(buildUrl)
|
|
68
68
|
if (!urlInfo) {
|
|
69
69
|
logger.warn(
|
|
70
|
-
`remove
|
|
70
|
+
`remove resource hint because cannot find "${buildUrl}" in the graph`,
|
|
71
71
|
)
|
|
72
72
|
actions.push(() => {
|
|
73
73
|
removeHtmlNode(linkNode)
|
|
@@ -75,9 +75,7 @@ export const resyncRessourceHints = async ({
|
|
|
75
75
|
return
|
|
76
76
|
}
|
|
77
77
|
if (urlInfo.dependents.size === 0) {
|
|
78
|
-
logger.info(
|
|
79
|
-
`remove ressource hint because "${href}" not used anymore`,
|
|
80
|
-
)
|
|
78
|
+
logger.info(`remove resource hint because "${href}" not used anymore`)
|
|
81
79
|
actions.push(() => {
|
|
82
80
|
removeHtmlNode(linkNode)
|
|
83
81
|
})
|
|
@@ -109,6 +107,6 @@ export const resyncRessourceHints = async ({
|
|
|
109
107
|
})
|
|
110
108
|
})
|
|
111
109
|
await Promise.all(
|
|
112
|
-
|
|
110
|
+
resourceHintActions.map((resourceHintAction) => resourceHintAction()),
|
|
113
111
|
)
|
|
114
112
|
}
|
|
@@ -208,18 +208,15 @@ export const startBuildServer = async ({
|
|
|
208
208
|
|
|
209
209
|
const createBuildFilesService = ({ buildDirectoryUrl, buildIndexPath }) => {
|
|
210
210
|
return (request) => {
|
|
211
|
-
const urlIsVersioned = new URL(
|
|
212
|
-
|
|
213
|
-
request.origin,
|
|
214
|
-
).searchParams.has("v")
|
|
215
|
-
if (buildIndexPath && request.ressource === "/") {
|
|
211
|
+
const urlIsVersioned = new URL(request.url).searchParams.has("v")
|
|
212
|
+
if (buildIndexPath && request.resource === "/") {
|
|
216
213
|
request = {
|
|
217
214
|
...request,
|
|
218
|
-
|
|
215
|
+
resource: `/${buildIndexPath}`,
|
|
219
216
|
}
|
|
220
217
|
}
|
|
221
218
|
return fetchFileSystem(
|
|
222
|
-
new URL(request.
|
|
219
|
+
new URL(request.resource.slice(1), buildDirectoryUrl),
|
|
223
220
|
{
|
|
224
221
|
headers: request.headers,
|
|
225
222
|
cacheControl: urlIsVersioned
|
|
@@ -48,7 +48,7 @@ export const startDevServer = async ({
|
|
|
48
48
|
runtimeCompat = defaultRuntimeCompat,
|
|
49
49
|
plugins = [],
|
|
50
50
|
urlAnalysis = {},
|
|
51
|
-
|
|
51
|
+
supervisor = true,
|
|
52
52
|
nodeEsmResolution,
|
|
53
53
|
fileSystemMagicResolution,
|
|
54
54
|
transpilation,
|
|
@@ -160,7 +160,7 @@ export const startDevServer = async ({
|
|
|
160
160
|
|
|
161
161
|
plugins,
|
|
162
162
|
urlAnalysis,
|
|
163
|
-
|
|
163
|
+
supervisor,
|
|
164
164
|
nodeEsmResolution,
|
|
165
165
|
fileSystemMagicResolution,
|
|
166
166
|
transpilation,
|
package/src/execute/execute.js
CHANGED
package/src/execute/run.js
CHANGED
|
@@ -16,7 +16,11 @@ export const run = async ({
|
|
|
16
16
|
runtime,
|
|
17
17
|
runtimeParams,
|
|
18
18
|
}) => {
|
|
19
|
-
const result = {
|
|
19
|
+
const result = {
|
|
20
|
+
status: "pending",
|
|
21
|
+
errors: [],
|
|
22
|
+
namespace: null,
|
|
23
|
+
}
|
|
20
24
|
const callbacks = []
|
|
21
25
|
|
|
22
26
|
const onConsoleRef = { current: () => {} }
|
|
@@ -25,6 +29,7 @@ export const run = async ({
|
|
|
25
29
|
|
|
26
30
|
const runOperation = Abort.startOperation()
|
|
27
31
|
runOperation.addAbortSignal(signal)
|
|
32
|
+
let timeoutAbortSource
|
|
28
33
|
if (
|
|
29
34
|
// ideally we would rather log than the timeout is ignored
|
|
30
35
|
// when keepRunning is true
|
|
@@ -32,24 +37,8 @@ export const run = async ({
|
|
|
32
37
|
typeof allocatedMs === "number" &&
|
|
33
38
|
allocatedMs !== Infinity
|
|
34
39
|
) {
|
|
35
|
-
|
|
36
|
-
callbacks.push(() => {
|
|
37
|
-
if (
|
|
38
|
-
result.status === "errored" &&
|
|
39
|
-
Abort.isAbortError(result.error) &&
|
|
40
|
-
timeoutAbortSource.signal.aborted
|
|
41
|
-
) {
|
|
42
|
-
result.status = "timedout"
|
|
43
|
-
delete result.error
|
|
44
|
-
}
|
|
45
|
-
})
|
|
40
|
+
timeoutAbortSource = runOperation.timeout(allocatedMs)
|
|
46
41
|
}
|
|
47
|
-
callbacks.push(() => {
|
|
48
|
-
if (result.status === "errored" && Abort.isAbortError(result.error)) {
|
|
49
|
-
result.status = "aborted"
|
|
50
|
-
delete result.error
|
|
51
|
-
}
|
|
52
|
-
})
|
|
53
42
|
const consoleCalls = []
|
|
54
43
|
onConsoleRef.current = ({ type, text }) => {
|
|
55
44
|
if (mirrorConsole) {
|
|
@@ -64,9 +53,7 @@ export const run = async ({
|
|
|
64
53
|
}
|
|
65
54
|
}
|
|
66
55
|
if (collectConsole) {
|
|
67
|
-
|
|
68
|
-
result.consoleCalls = consoleCalls
|
|
69
|
-
})
|
|
56
|
+
result.consoleCalls = consoleCalls
|
|
70
57
|
}
|
|
71
58
|
|
|
72
59
|
// we do not keep coverage in memory, it can grow very big
|
|
@@ -133,29 +120,30 @@ export const run = async ({
|
|
|
133
120
|
if (winner.name === "aborted") {
|
|
134
121
|
runOperation.throwIfAborted()
|
|
135
122
|
}
|
|
136
|
-
|
|
137
|
-
const { status, namespace, error, performance } = winner.data
|
|
123
|
+
const { status, namespace, errors, performance } = winner.data
|
|
138
124
|
result.status = status
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
} else {
|
|
142
|
-
result.namespace = namespace
|
|
143
|
-
}
|
|
125
|
+
result.errors.push(...errors)
|
|
126
|
+
result.namespace = namespace
|
|
144
127
|
if (collectPerformance) {
|
|
145
128
|
result.performance = performance
|
|
146
129
|
}
|
|
147
|
-
callbacks.forEach((callback) => {
|
|
148
|
-
callback()
|
|
149
|
-
})
|
|
150
|
-
return result
|
|
151
130
|
} catch (e) {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
131
|
+
if (Abort.isAbortError(e)) {
|
|
132
|
+
if (timeoutAbortSource && timeoutAbortSource.signal.aborted) {
|
|
133
|
+
result.status = "timedout"
|
|
134
|
+
} else {
|
|
135
|
+
result.status = "aborted"
|
|
136
|
+
}
|
|
137
|
+
} else {
|
|
138
|
+
result.status = "errored"
|
|
139
|
+
result.errors.push(e)
|
|
140
|
+
}
|
|
158
141
|
} finally {
|
|
159
142
|
await runOperation.end()
|
|
160
143
|
}
|
|
144
|
+
|
|
145
|
+
callbacks.forEach((callback) => {
|
|
146
|
+
callback()
|
|
147
|
+
})
|
|
148
|
+
return result
|
|
161
149
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Script } from "node:vm"
|
|
2
1
|
import { writeFileSync } from "node:fs"
|
|
3
2
|
|
|
4
3
|
import { createDetailedMessage } from "@jsenv/log"
|
|
@@ -10,7 +9,6 @@ import {
|
|
|
10
9
|
} from "@jsenv/abort"
|
|
11
10
|
import { moveUrl } from "@jsenv/urls"
|
|
12
11
|
import { memoize } from "@jsenv/utils/src/memoize/memoize.js"
|
|
13
|
-
import { escapeRegexpSpecialChars } from "@jsenv/utils/src/string/escape_regexp_special_chars.js"
|
|
14
12
|
|
|
15
13
|
import { filterV8Coverage } from "@jsenv/core/src/test/coverage/v8_coverage.js"
|
|
16
14
|
import { composeTwoFileByFileIstanbulCoverages } from "@jsenv/core/src/test/coverage/istanbul_coverage_composition.js"
|
|
@@ -121,7 +119,11 @@ export const createRuntimeFromPlaywright = ({
|
|
|
121
119
|
}
|
|
122
120
|
}
|
|
123
121
|
|
|
124
|
-
const result = {
|
|
122
|
+
const result = {
|
|
123
|
+
status: "pending",
|
|
124
|
+
namespace: null,
|
|
125
|
+
errors: [],
|
|
126
|
+
}
|
|
125
127
|
const callbacks = []
|
|
126
128
|
if (coverageEnabled) {
|
|
127
129
|
if (
|
|
@@ -251,18 +253,18 @@ export const createRuntimeFromPlaywright = ({
|
|
|
251
253
|
})
|
|
252
254
|
},
|
|
253
255
|
// https://github.com/GoogleChrome/puppeteer/blob/v1.4.0/docs/api.md#event-pageerror
|
|
254
|
-
pageerror: (
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
},
|
|
256
|
+
// pageerror: () => {
|
|
257
|
+
// return registerEvent({
|
|
258
|
+
// object: page,
|
|
259
|
+
// eventType: "pageerror",
|
|
260
|
+
// callback: (error) => {
|
|
261
|
+
// if (ignoreErrorHook(error)) {
|
|
262
|
+
// return
|
|
263
|
+
// }
|
|
264
|
+
// result.errors.push(transformErrorHook(error))
|
|
265
|
+
// },
|
|
266
|
+
// })
|
|
267
|
+
// },
|
|
266
268
|
closed: (cb) => {
|
|
267
269
|
// https://github.com/GoogleChrome/puppeteer/blob/v1.4.0/docs/api.md#event-disconnected
|
|
268
270
|
if (isBrowserDedicatedToExecution) {
|
|
@@ -301,32 +303,14 @@ export const createRuntimeFromPlaywright = ({
|
|
|
301
303
|
/* eslint-disable no-undef */
|
|
302
304
|
/* istanbul ignore next */
|
|
303
305
|
() => {
|
|
304
|
-
if (!window.
|
|
305
|
-
throw new Error(`window.
|
|
306
|
+
if (!window.__supervisor__) {
|
|
307
|
+
throw new Error(`window.__supervisor__ not found`)
|
|
306
308
|
}
|
|
307
|
-
return window.
|
|
309
|
+
return window.__supervisor__.getScriptExecutionResults()
|
|
308
310
|
},
|
|
309
311
|
/* eslint-enable no-undef */
|
|
310
312
|
)
|
|
311
|
-
|
|
312
|
-
if (status === "errored") {
|
|
313
|
-
const { exceptionSource } = returnValue
|
|
314
|
-
const error = evalException(exceptionSource, {
|
|
315
|
-
rootDirectoryUrl,
|
|
316
|
-
devServerOrigin,
|
|
317
|
-
transformErrorHook,
|
|
318
|
-
})
|
|
319
|
-
cb({
|
|
320
|
-
status: "errored",
|
|
321
|
-
error,
|
|
322
|
-
namespace: scriptExecutionResults,
|
|
323
|
-
})
|
|
324
|
-
} else {
|
|
325
|
-
cb({
|
|
326
|
-
status: "completed",
|
|
327
|
-
namespace: scriptExecutionResults,
|
|
328
|
-
})
|
|
329
|
-
}
|
|
313
|
+
cb(returnValue)
|
|
330
314
|
} catch (e) {
|
|
331
315
|
reject(e)
|
|
332
316
|
}
|
|
@@ -336,39 +320,46 @@ export const createRuntimeFromPlaywright = ({
|
|
|
336
320
|
)
|
|
337
321
|
})
|
|
338
322
|
|
|
339
|
-
const
|
|
323
|
+
const writeResult = async () => {
|
|
340
324
|
const winner = await winnerPromise
|
|
341
325
|
if (winner.name === "aborted") {
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
}
|
|
326
|
+
result.status = "aborted"
|
|
327
|
+
return
|
|
345
328
|
}
|
|
346
|
-
if (winner.name === "error"
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
}
|
|
329
|
+
if (winner.name === "error") {
|
|
330
|
+
let error = winner.data
|
|
331
|
+
result.status = "errored"
|
|
332
|
+
result.errors.push(error)
|
|
333
|
+
return
|
|
352
334
|
}
|
|
353
335
|
if (winner.name === "closed") {
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
336
|
+
result.status = "errored"
|
|
337
|
+
result.errors.push(
|
|
338
|
+
isBrowserDedicatedToExecution
|
|
357
339
|
? new Error(`browser disconnected during execution`)
|
|
358
340
|
: new Error(`page closed during execution`),
|
|
359
|
-
|
|
341
|
+
)
|
|
342
|
+
return
|
|
360
343
|
}
|
|
361
|
-
|
|
344
|
+
// winner.name = 'response'
|
|
345
|
+
const { executionResults } = winner.data
|
|
346
|
+
result.status = "completed"
|
|
347
|
+
result.namespace = executionResults
|
|
348
|
+
Object.keys(executionResults).forEach((key) => {
|
|
349
|
+
const executionResult = executionResults[key]
|
|
350
|
+
if (executionResult.status === "errored") {
|
|
351
|
+
result.status = "errored"
|
|
352
|
+
result.errors.push({
|
|
353
|
+
...executionResult.exception,
|
|
354
|
+
stack: executionResult.exception.text,
|
|
355
|
+
})
|
|
356
|
+
}
|
|
357
|
+
})
|
|
358
|
+
return
|
|
362
359
|
}
|
|
363
360
|
|
|
364
361
|
try {
|
|
365
|
-
|
|
366
|
-
result.status = status
|
|
367
|
-
if (status === "errored") {
|
|
368
|
-
result.error = error
|
|
369
|
-
} else {
|
|
370
|
-
result.namespace = namespace
|
|
371
|
-
}
|
|
362
|
+
await writeResult()
|
|
372
363
|
if (collectPerformance) {
|
|
373
364
|
result.performance = performance
|
|
374
365
|
}
|
|
@@ -378,7 +369,7 @@ export const createRuntimeFromPlaywright = ({
|
|
|
378
369
|
}, Promise.resolve())
|
|
379
370
|
} catch (e) {
|
|
380
371
|
result.status = "errored"
|
|
381
|
-
result.
|
|
372
|
+
result.errors = [e]
|
|
382
373
|
}
|
|
383
374
|
if (keepRunning) {
|
|
384
375
|
stopSignal.notify = cleanup
|
|
@@ -533,20 +524,3 @@ const registerEvent = ({ object, eventType, callback }) => {
|
|
|
533
524
|
object.removeListener(eventType, callback)
|
|
534
525
|
}
|
|
535
526
|
}
|
|
536
|
-
|
|
537
|
-
const evalException = (
|
|
538
|
-
exceptionSource,
|
|
539
|
-
{ rootDirectoryUrl, devServerOrigin, transformErrorHook },
|
|
540
|
-
) => {
|
|
541
|
-
const script = new Script(exceptionSource, { filename: "" })
|
|
542
|
-
const error = script.runInThisContext()
|
|
543
|
-
if (error && error instanceof Error) {
|
|
544
|
-
const remoteRootRegexp = new RegExp(
|
|
545
|
-
escapeRegexpSpecialChars(`${devServerOrigin}/`),
|
|
546
|
-
"g",
|
|
547
|
-
)
|
|
548
|
-
error.stack = error.stack.replace(remoteRootRegexp, rootDirectoryUrl)
|
|
549
|
-
error.message = error.message.replace(remoteRootRegexp, rootDirectoryUrl)
|
|
550
|
-
}
|
|
551
|
-
return transformErrorHook(error)
|
|
552
|
-
}
|