@jsenv/core 27.4.0 → 27.5.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/js/autoreload.js +359 -0
- package/dist/js/execute_using_dynamic_import.js +1 -1
- package/dist/js/html_supervisor_installer.js +221 -73
- package/dist/js/html_supervisor_setup.js +3 -4
- package/dist/js/new_stylesheet.js +26 -58
- package/dist/js/server_events_client.js +307 -0
- package/dist/main.js +7483 -7281
- package/package.json +11 -10
- package/{README.md → readme.md} +8 -9
- package/src/build/build.js +12 -16
- package/src/build/start_build_server.js +24 -28
- package/src/dev/start_dev_server.js +30 -94
- package/src/execute/execute.js +17 -35
- package/src/omega/errors.js +20 -18
- package/src/omega/kitchen.js +7 -6
- package/src/omega/omega_server.js +96 -127
- package/src/omega/server/file_service.js +247 -46
- package/src/omega/url_graph.js +33 -20
- package/src/plugins/autoreload/client/autoreload.js +201 -0
- package/src/plugins/autoreload/{dev_sse/client → client}/autoreload_preference.js +0 -0
- package/src/plugins/autoreload/{dev_sse/client → client}/reload.js +29 -10
- package/src/plugins/autoreload/{dev_sse/client → client}/url_helpers.js +0 -0
- package/src/plugins/autoreload/jsenv_plugin_autoreload.js +4 -4
- package/src/plugins/autoreload/{dev_sse/jsenv_plugin_dev_sse_client.js → jsenv_plugin_autoreload_client.js} +8 -8
- package/src/plugins/autoreload/jsenv_plugin_autoreload_server.js +196 -0
- package/src/{dev/plugins → plugins}/explorer/client/explorer.html +0 -0
- package/src/{dev/plugins → plugins}/explorer/client/jsenv.png +0 -0
- package/src/{dev/plugins → plugins}/explorer/jsenv_plugin_explorer.js +1 -3
- package/src/plugins/html_supervisor/client/{error_in_document.js → error_overlay.js} +73 -17
- package/src/plugins/html_supervisor/client/html_supervisor_installer.js +127 -54
- package/src/plugins/html_supervisor/client/html_supervisor_setup.js +3 -4
- package/src/plugins/html_supervisor/jsenv_plugin_html_supervisor.js +19 -12
- package/src/plugins/inline/jsenv_plugin_html_inline_content.js +97 -117
- package/src/plugins/node_esm_resolution/jsenv_plugin_node_esm_resolution.js +66 -58
- package/src/plugins/plugin_controller.js +102 -67
- package/src/plugins/plugins.js +10 -8
- package/src/{helpers/event_source/event_source.js → plugins/server_events/client/event_source_connection.js} +102 -31
- package/src/plugins/server_events/client/server_events_client.js +17 -0
- package/src/plugins/server_events/jsenv_plugin_server_events_client_injection.js +48 -0
- package/src/plugins/server_events/server_events_dispatcher.js +69 -0
- package/src/{dev/plugins → plugins}/toolbar/client/animation/toolbar_animation.js +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/eventsource/eventsource.css +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/eventsource/toolbar_eventsource.js +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/execution/execution.css +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/execution/toolbar_execution.js +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/focus/focus.css +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/focus/toolbar_focus.js +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/jsenv_logo.svg +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/notification/toolbar_notification.js +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/responsive/overflow_menu.css +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/responsive/toolbar_responsive.js +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/settings/settings.css +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/settings/toolbar_settings.js +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/theme/jsenv_theme.css +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/theme/light_theme.css +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/theme/toolbar_theme.js +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/toolbar.html +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/toolbar_injector.js +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/toolbar_main.css +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/toolbar_main.js +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/tooltip/tooltip.css +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/tooltip/tooltip.js +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/util/animation.js +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/util/dom.js +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/util/fetch_using_xhr.js +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/util/fetching.js +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/util/iframe_to_parent_href.js +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/util/jsenv_logger.js +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/util/preferences.js +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/util/responsive.js +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/util/util.js +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/variant/variant.js +0 -0
- package/src/{dev/plugins → plugins}/toolbar/jsenv_plugin_toolbar.js +0 -0
- package/src/plugins/transpilation/as_js_classic/jsenv_plugin_as_js_classic_html.js +4 -3
- package/src/plugins/transpilation/babel/new_stylesheet/client/new_stylesheet.js +25 -55
- package/src/plugins/transpilation/import_assertions/jsenv_plugin_import_assertions.js +44 -24
- package/src/plugins/transpilation/jsenv_plugin_transpilation.js +6 -1
- package/src/plugins/url_analysis/html/html_urls.js +8 -8
- package/src/test/execute_plan.js +36 -54
- package/src/test/execute_test_plan.js +2 -2
- package/dist/js/event_source_client.js +0 -549
- package/src/helpers/event_source/sse_service.js +0 -53
- package/src/plugins/autoreload/dev_sse/client/event_source_client.js +0 -193
- package/src/plugins/autoreload/dev_sse/jsenv_plugin_dev_sse_server.js +0 -192
|
@@ -14,7 +14,11 @@ import { urlToFilename, injectQueryParams } from "@jsenv/urls"
|
|
|
14
14
|
|
|
15
15
|
import { JS_QUOTES } from "@jsenv/utils/src/string/js_quotes.js"
|
|
16
16
|
|
|
17
|
-
export const jsenvPluginImportAssertions = (
|
|
17
|
+
export const jsenvPluginImportAssertions = ({
|
|
18
|
+
json = "auto",
|
|
19
|
+
css = "auto",
|
|
20
|
+
text = "auto",
|
|
21
|
+
}) => {
|
|
18
22
|
const updateReference = (reference, searchParam) => {
|
|
19
23
|
reference.expectedType = "js_module"
|
|
20
24
|
reference.filename = `${urlToFilename(reference.url)}.js`
|
|
@@ -33,42 +37,58 @@ export const jsenvPluginImportAssertions = () => {
|
|
|
33
37
|
const importAssertions = {
|
|
34
38
|
name: "jsenv:import_assertions",
|
|
35
39
|
appliesDuring: "*",
|
|
40
|
+
init: (context) => {
|
|
41
|
+
// transpilation is forced during build so that
|
|
42
|
+
// - avoid rollup to see import assertions
|
|
43
|
+
// We would have to tell rollup to ignore import with assertion
|
|
44
|
+
// - means rollup can bundle more js file together
|
|
45
|
+
// - means url versioning can work for css inlined in js
|
|
46
|
+
if (context.scenario === "build") {
|
|
47
|
+
json = true
|
|
48
|
+
css = true
|
|
49
|
+
text = true
|
|
50
|
+
}
|
|
51
|
+
},
|
|
36
52
|
redirectUrl: {
|
|
37
53
|
js_import_export: (reference, context) => {
|
|
38
54
|
if (!reference.assert) {
|
|
39
55
|
return null
|
|
40
56
|
}
|
|
41
|
-
// during build always replace import assertions with the js:
|
|
42
|
-
// - avoid rollup to see import assertions
|
|
43
|
-
// We would have to tell rollup to ignore import with assertion
|
|
44
|
-
// - means rollup can bundle more js file together
|
|
45
|
-
// - means url versioning can work for css inlined in js
|
|
46
57
|
if (reference.assert.type === "json") {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
58
|
+
const shouldTranspileJsonImportAssertion =
|
|
59
|
+
json === true
|
|
60
|
+
? true
|
|
61
|
+
: json === "auto"
|
|
62
|
+
? !context.isSupportedOnCurrentClients("import_type_json")
|
|
63
|
+
: false
|
|
64
|
+
if (shouldTranspileJsonImportAssertion) {
|
|
65
|
+
return updateReference(reference, "as_json_module")
|
|
52
66
|
}
|
|
53
|
-
return
|
|
67
|
+
return null
|
|
54
68
|
}
|
|
55
69
|
if (reference.assert.type === "css") {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
70
|
+
const shouldTranspileCssImportAssertion =
|
|
71
|
+
css === true
|
|
72
|
+
? true
|
|
73
|
+
: css === "auto"
|
|
74
|
+
? !context.isSupportedOnCurrentClients("import_type_css")
|
|
75
|
+
: false
|
|
76
|
+
if (shouldTranspileCssImportAssertion) {
|
|
77
|
+
return updateReference(reference, "as_css_module")
|
|
61
78
|
}
|
|
62
|
-
return
|
|
79
|
+
return null
|
|
63
80
|
}
|
|
64
81
|
if (reference.assert.type === "text") {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
82
|
+
const shouldTranspileTextImportAssertion =
|
|
83
|
+
text === true
|
|
84
|
+
? true
|
|
85
|
+
: text === "auto"
|
|
86
|
+
? !context.isSupportedOnCurrentClients("import_type_text")
|
|
87
|
+
: false
|
|
88
|
+
if (shouldTranspileTextImportAssertion) {
|
|
89
|
+
return updateReference(reference, "as_text_module")
|
|
70
90
|
}
|
|
71
|
-
return
|
|
91
|
+
return null
|
|
72
92
|
}
|
|
73
93
|
return null
|
|
74
94
|
},
|
|
@@ -22,9 +22,14 @@ export const jsenvPluginTranspilation = ({
|
|
|
22
22
|
babelHelpersAsImport = true,
|
|
23
23
|
getCustomBabelPlugins,
|
|
24
24
|
}) => {
|
|
25
|
+
if (importAssertions === true) {
|
|
26
|
+
importAssertions = {}
|
|
27
|
+
}
|
|
25
28
|
return [
|
|
26
29
|
// import assertions we want it all the time
|
|
27
|
-
...(importAssertions
|
|
30
|
+
...(importAssertions
|
|
31
|
+
? [jsenvPluginImportAssertions(importAssertions)]
|
|
32
|
+
: []),
|
|
28
33
|
// babel also so that rollup can bundle babel helpers for instance
|
|
29
34
|
jsenvPluginBabel({
|
|
30
35
|
topLevelAwait,
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
getHtmlNodePosition,
|
|
6
6
|
setHtmlNodeAttributes,
|
|
7
7
|
getHtmlNodeAttributePosition,
|
|
8
|
+
analyzeScriptNode,
|
|
8
9
|
parseSrcSet,
|
|
9
10
|
stringifyHtmlAst,
|
|
10
11
|
} from "@jsenv/ast"
|
|
@@ -188,16 +189,15 @@ const visitHtmlUrls = ({ url, htmlAst, onUrl }) => {
|
|
|
188
189
|
},
|
|
189
190
|
// style: () => {},
|
|
190
191
|
script: (node) => {
|
|
191
|
-
const type =
|
|
192
|
-
|
|
193
|
-
"
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
}[type]
|
|
192
|
+
const { type } = analyzeScriptNode(node)
|
|
193
|
+
if (type === "text") {
|
|
194
|
+
// ignore <script type="whatever" src="./file.js">
|
|
195
|
+
// per HTML spec https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#attr-type
|
|
196
|
+
return
|
|
197
|
+
}
|
|
198
198
|
visitAttributeAsUrlSpecifier({
|
|
199
199
|
type: "script_src",
|
|
200
|
-
expectedType,
|
|
200
|
+
expectedType: type,
|
|
201
201
|
node,
|
|
202
202
|
attributeName: "src",
|
|
203
203
|
})
|
package/src/test/execute_plan.js
CHANGED
|
@@ -16,9 +16,6 @@ import { ensureEmptyDirectory, writeFileSync } from "@jsenv/filesystem"
|
|
|
16
16
|
|
|
17
17
|
import { babelPluginInstrument } from "./coverage/babel_plugin_instrument.js"
|
|
18
18
|
import { reportToCoverage } from "./coverage/report_to_coverage.js"
|
|
19
|
-
import { createUrlGraph } from "@jsenv/core/src/omega/url_graph.js"
|
|
20
|
-
import { getCorePlugins } from "@jsenv/core/src/plugins/plugins.js"
|
|
21
|
-
import { createKitchen } from "@jsenv/core/src/omega/kitchen.js"
|
|
22
19
|
import { startOmegaServer } from "@jsenv/core/src/omega/omega_server.js"
|
|
23
20
|
import { run } from "@jsenv/core/src/execute/run.js"
|
|
24
21
|
|
|
@@ -43,6 +40,7 @@ export const executePlan = async (
|
|
|
43
40
|
|
|
44
41
|
rootDirectoryUrl,
|
|
45
42
|
keepRunning,
|
|
43
|
+
services,
|
|
46
44
|
defaultMsAllocatedPerExecution,
|
|
47
45
|
maxExecutionsInParallel,
|
|
48
46
|
failFast,
|
|
@@ -68,7 +66,7 @@ export const executePlan = async (
|
|
|
68
66
|
protocol,
|
|
69
67
|
privateKey,
|
|
70
68
|
certificate,
|
|
71
|
-
|
|
69
|
+
host,
|
|
72
70
|
port,
|
|
73
71
|
|
|
74
72
|
beforeExecutionCallback = () => {},
|
|
@@ -198,64 +196,48 @@ export const executePlan = async (
|
|
|
198
196
|
stopAfterAllSignal,
|
|
199
197
|
}
|
|
200
198
|
if (someNeedsServer) {
|
|
201
|
-
const urlGraph = createUrlGraph()
|
|
202
|
-
const kitchen = createKitchen({
|
|
203
|
-
signal,
|
|
204
|
-
logger,
|
|
205
|
-
rootDirectoryUrl,
|
|
206
|
-
urlGraph,
|
|
207
|
-
scenario,
|
|
208
|
-
sourcemaps,
|
|
209
|
-
runtimeCompat: runtimes,
|
|
210
|
-
writeGeneratedFiles,
|
|
211
|
-
plugins: [
|
|
212
|
-
...plugins,
|
|
213
|
-
...getCorePlugins({
|
|
214
|
-
rootDirectoryUrl,
|
|
215
|
-
urlGraph,
|
|
216
|
-
scenario,
|
|
217
|
-
runtimeCompat: runtimes,
|
|
218
|
-
|
|
219
|
-
htmlSupervisor: true,
|
|
220
|
-
nodeEsmResolution,
|
|
221
|
-
fileSystemMagicResolution,
|
|
222
|
-
transpilation: {
|
|
223
|
-
...transpilation,
|
|
224
|
-
getCustomBabelPlugins: ({ clientRuntimeCompat }) => {
|
|
225
|
-
if (
|
|
226
|
-
coverageEnabled &&
|
|
227
|
-
(coverageMethodForBrowsers !== "playwright_api" ||
|
|
228
|
-
Object.keys(clientRuntimeCompat)[0] !== "chrome")
|
|
229
|
-
) {
|
|
230
|
-
return {
|
|
231
|
-
"transform-instrument": [
|
|
232
|
-
babelPluginInstrument,
|
|
233
|
-
{
|
|
234
|
-
rootDirectoryUrl,
|
|
235
|
-
coverageConfig,
|
|
236
|
-
},
|
|
237
|
-
],
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
return {}
|
|
241
|
-
},
|
|
242
|
-
},
|
|
243
|
-
}),
|
|
244
|
-
],
|
|
245
|
-
})
|
|
246
199
|
const server = await startOmegaServer({
|
|
247
200
|
signal: multipleExecutionsOperation.signal,
|
|
248
201
|
logLevel: "warn",
|
|
249
|
-
rootDirectoryUrl,
|
|
250
|
-
urlGraph,
|
|
251
|
-
kitchen,
|
|
252
|
-
scenario,
|
|
253
202
|
keepProcessAlive: false,
|
|
254
203
|
port,
|
|
255
|
-
|
|
204
|
+
host,
|
|
256
205
|
protocol,
|
|
257
206
|
certificate,
|
|
258
207
|
privateKey,
|
|
208
|
+
services,
|
|
209
|
+
|
|
210
|
+
rootDirectoryUrl,
|
|
211
|
+
scenario,
|
|
212
|
+
runtimeCompat: runtimes,
|
|
213
|
+
|
|
214
|
+
plugins,
|
|
215
|
+
htmlSupervisor: true,
|
|
216
|
+
nodeEsmResolution,
|
|
217
|
+
fileSystemMagicResolution,
|
|
218
|
+
transpilation: {
|
|
219
|
+
...transpilation,
|
|
220
|
+
getCustomBabelPlugins: ({ clientRuntimeCompat }) => {
|
|
221
|
+
if (
|
|
222
|
+
coverageEnabled &&
|
|
223
|
+
(coverageMethodForBrowsers !== "playwright_api" ||
|
|
224
|
+
Object.keys(clientRuntimeCompat)[0] !== "chrome")
|
|
225
|
+
) {
|
|
226
|
+
return {
|
|
227
|
+
"transform-instrument": [
|
|
228
|
+
babelPluginInstrument,
|
|
229
|
+
{
|
|
230
|
+
rootDirectoryUrl,
|
|
231
|
+
coverageConfig,
|
|
232
|
+
},
|
|
233
|
+
],
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
return {}
|
|
237
|
+
},
|
|
238
|
+
},
|
|
239
|
+
sourcemaps,
|
|
240
|
+
writeGeneratedFiles,
|
|
259
241
|
})
|
|
260
242
|
multipleExecutionsOperation.addEndCallback(async () => {
|
|
261
243
|
await server.stop()
|
|
@@ -90,7 +90,7 @@ export const executeTestPlan = async ({
|
|
|
90
90
|
protocol,
|
|
91
91
|
privateKey,
|
|
92
92
|
certificate,
|
|
93
|
-
|
|
93
|
+
host,
|
|
94
94
|
port,
|
|
95
95
|
}) => {
|
|
96
96
|
const logger = createLogger({ logLevel })
|
|
@@ -177,7 +177,7 @@ export const executeTestPlan = async ({
|
|
|
177
177
|
protocol,
|
|
178
178
|
privateKey,
|
|
179
179
|
certificate,
|
|
180
|
-
|
|
180
|
+
host,
|
|
181
181
|
port,
|
|
182
182
|
})
|
|
183
183
|
if (
|