@jsenv/core 24.2.2 → 24.3.1
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/{license → LICENSE} +0 -0
- package/dist/browser_runtime/browser_runtime-fbd309a1.js +5137 -0
- package/dist/browser_runtime/browser_runtime-fbd309a1.js.map +1064 -0
- package/dist/{jsenv_browser_system.js → browser_system/browser_system-29eda202.js} +12 -12
- package/dist/{jsenv_browser_system.js.map → browser_system/browser_system-29eda202.js.map} +64 -64
- package/dist/build_manifest.js +12 -0
- package/dist/compile_proxy/assets/s.js-749702e8.map +242 -0
- package/dist/compile_proxy/compile_proxy-405777e6.html +2074 -0
- package/dist/compile_proxy/compile_proxy.html__inline__20-39c0801c.js.map +385 -0
- package/dist/{jsenv_event_source_client.js → event_source_client/event_source_client-9f14c8b9.js} +39 -21
- package/dist/event_source_client/event_source_client-9f14c8b9.js.map +127 -0
- package/dist/redirector/assets/s.js-749702e8.map +242 -0
- package/dist/redirector/redirector-237cd168.html +2118 -0
- package/dist/redirector/redirector.html__inline__15-33acb0b9.js.map +390 -0
- package/dist/toolbar/assets/compilation.css-209d68b4.map +12 -0
- package/dist/toolbar/assets/eventsource.css-38cd0a36.map +12 -0
- package/dist/toolbar/assets/execution.css-0ebe522f.map +12 -0
- package/dist/toolbar/assets/focus.css-3f9c156d.map +12 -0
- package/dist/toolbar/assets/light-theme.css-78b19a80.map +12 -0
- package/dist/toolbar/assets/overflow-menu.css-d9688a1c.map +12 -0
- package/dist/toolbar/assets/s.js-749702e8.map +242 -0
- package/dist/toolbar/assets/settings.css-2b81b245.map +12 -0
- package/dist/toolbar/assets/toolbar.main.css-846920e9.map +28 -0
- package/dist/toolbar/assets/tooltip.css-03395ee6.map +12 -0
- package/dist/toolbar/toolbar-d3d98c2e.html +4778 -0
- package/dist/toolbar/toolbar.main-cab36c15.js.map +795 -0
- package/dist/toolbar_injector/assets/jsenv-logo-188b9ca6.svg +95 -0
- package/dist/{jsenv_toolbar_injector.js → toolbar_injector/toolbar_injector-01f71ce3.js} +85 -65
- package/dist/toolbar_injector/toolbar_injector-01f71ce3.js.map +294 -0
- package/main.js +0 -1
- package/package.json +4 -2
- package/readme.md +10 -7
- package/src/buildProject.js +6 -2
- package/src/dev_server.js +22 -130
- package/src/importUsingChildProcess.js +1 -1
- package/src/internal/{runtime/detectBrowser/detectBrowser.js → browser_detection/browser_detection.js} +0 -0
- package/src/internal/{runtime/detectBrowser → browser_detection}/detectAndroid.js +0 -0
- package/src/internal/{runtime/detectBrowser → browser_detection}/detectChrome.js +0 -0
- package/src/internal/{runtime/detectBrowser → browser_detection}/detectEdge.js +0 -0
- package/src/internal/{runtime/detectBrowser → browser_detection}/detectElectron.js +0 -0
- package/src/internal/{runtime/detectBrowser → browser_detection}/detectFirefox.js +0 -0
- package/src/internal/{runtime/detectBrowser → browser_detection}/detectIOS.js +0 -0
- package/src/internal/{runtime/detectBrowser → browser_detection}/detectInternetExplorer.js +0 -0
- package/src/internal/{runtime/detectBrowser → browser_detection}/detectOpera.js +0 -0
- package/src/internal/{runtime/detectBrowser → browser_detection}/detectSafari.js +0 -0
- package/src/internal/{runtime/detectBrowser → browser_detection}/util.js +0 -0
- package/src/internal/{runtime/createBrowserRuntime/scanBrowserRuntimeFeatures.js → browser_feature_detection/browser_feature_detection.js} +116 -81
- package/src/internal/browser_feature_detection/compile_proxy.html +27 -0
- package/src/internal/{browser-launcher → browser_launcher}/createSharing.js +0 -0
- package/src/internal/{browser-launcher → browser_launcher}/executeHtmlFile.js +7 -4
- package/src/internal/{browser-launcher → browser_launcher}/trackPageToNotify.js +0 -0
- package/src/internal/{browser-launcher/jsenv-browser-system.js → browser_runtime/browser_runtime.js} +4 -4
- package/src/internal/{runtime/createBrowserRuntime/createBrowserSystem.js → browser_runtime/browser_system.js} +3 -2
- package/src/internal/{runtime/createBrowserRuntime → browser_runtime}/createBrowserRuntime.js +7 -5
- package/src/internal/{browser-launcher → browser_runtime}/displayErrorInDocument.js +0 -0
- package/src/internal/{browser-launcher → browser_runtime}/displayErrorNotification.js +2 -4
- package/src/internal/{runtime/createBrowserRuntime → browser_runtime}/evalSource.js +2 -0
- package/src/internal/{runtime/createBrowserRuntime → browser_runtime}/makeNamespaceTransferable.js +0 -0
- package/src/internal/{browser-utils → browser_utils}/fetch-browser.js +2 -0
- package/src/internal/{browser-utils → browser_utils}/fetchAndEvalUsingFetch.js +3 -0
- package/src/internal/{browser-utils → browser_utils}/fetchAndEvalUsingScript.js +2 -0
- package/src/internal/{browser-utils → browser_utils}/fetchJson.js +0 -0
- package/src/internal/{browser-utils → browser_utils}/fetchUsingXHR.js +4 -4
- package/src/internal/building/buildUsingRollup.js +4 -0
- package/src/internal/building/createJsenvRollupPlugin.js +19 -9
- package/src/internal/building/css/applyPostCss.js +19 -8
- package/src/internal/building/css/moveCssUrls.js +44 -0
- package/src/internal/building/css/parseCssRessource.js +67 -17
- package/src/internal/building/css/parseCssUrls.js +29 -23
- package/src/internal/building/css/postcss_plugin_url_visitor.js +11 -20
- package/src/internal/building/css/replaceCssUrls.js +38 -19
- package/src/internal/building/css_module.js +6 -10
- package/src/internal/building/html/parseHtmlRessource.js +37 -11
- package/src/internal/building/parseRessource.js +3 -0
- package/src/internal/building/ressource_builder.js +12 -3
- package/src/internal/compiling/babel_plugin_import_assertions.js +1 -2
- package/src/internal/compiling/html_source_file_service.js +23 -21
- package/src/internal/compiling/jsenvCompilerForHtml.js +15 -22
- package/src/internal/compiling/startCompileServer.js +34 -32
- package/src/internal/dev_server/event_source_client/event_source_connection.js +28 -19
- package/src/internal/dev_server/exploring/exploring.html +7 -2
- package/src/internal/dev_server/exploring/fetchExploringJson.js +4 -9
- package/src/internal/dev_server/redirector/redirector.html +37 -2
- package/src/internal/dev_server/toolbar/compilation/toolbar.compilation.js +4 -7
- package/src/internal/dev_server/toolbar/eventsource/toolbar.eventsource.js +2 -2
- package/src/internal/dev_server/toolbar/notification/toolbar.notification.js +75 -44
- package/src/internal/dev_server/toolbar/toolbar.html +31 -5
- package/src/internal/dev_server/toolbar/toolbar.injector.js +53 -36
- package/src/internal/dev_server/toolbar/toolbar.main.js +44 -31
- package/src/internal/dev_server/toolbar/util/fetching.js +1 -1
- package/src/internal/generateGroupMap/one_runtime_compat.js +1 -1
- package/src/internal/generateGroupMap/runtime_compat_composition.js +1 -1
- package/src/internal/generateGroupMap/runtime_support.js +1 -1
- package/src/internal/jsenvInternalFiles.js +0 -26
- package/src/internal/jsenv_builds.js +19 -0
- package/src/internal/{runtime/node-feature-detect/feature-detect-dynamic-import.mjs → node_feature_detection/feature_detect_dynamic_import.mjs} +0 -0
- package/src/internal/{runtime/node-feature-detect/feature-detect-top-level-await.mjs → node_feature_detection/feature_detect_top_level_await.mjs} +0 -0
- package/src/internal/{runtime/node-feature-detect → node_feature_detection}/nodeSupportsDynamicImport.js +0 -0
- package/src/internal/node_feature_detection/nodeSupportsTopLevelAwait.js +16 -0
- package/src/internal/{runtime/createNodeRuntime/scanNodeRuntimeFeatures.js → node_feature_detection/node_feature_detection.js} +12 -13
- package/src/internal/{node-launcher → node_launcher}/createChildProcessOptions.js +0 -0
- package/src/internal/{node-launcher → node_launcher}/createControllableNodeProcess.js +9 -14
- package/src/internal/{node-launcher → node_launcher}/kill_process_tree.js +0 -0
- package/src/internal/{node-launcher → node_launcher}/processOptions.js +0 -0
- package/src/internal/{runtime/detectNode → node_runtime}/detectNode.js +0 -0
- package/src/internal/{runtime/createNodeRuntime → node_runtime}/evalSource.js +1 -1
- package/src/internal/{runtime/createNodeRuntime → node_runtime}/fetchSource.js +1 -1
- package/src/internal/{node-launcher → node_runtime}/nodeControllableFile.mjs +14 -11
- package/src/internal/{runtime/createNodeRuntime/createNodeExecutionWithDynamicImport.js → node_runtime/node_execution_dynamic_import.js} +34 -6
- package/src/internal/node_runtime/node_execution_performance.js +67 -0
- package/src/internal/{runtime/createNodeRuntime/createNodeExecutionWithSystemJs.js → node_runtime/node_execution_systemjs.js} +38 -24
- package/src/internal/{runtime/createNodeRuntime/createNodeSystem.js → node_runtime/node_system.js} +4 -4
- package/src/internal/runtime/computeCompileIdFromGroupId.js +1 -0
- package/src/internal/runtime/resolveGroup.js +1 -1
- package/src/internal/runtime/resolveRuntimeGroup.js +2 -2
- package/src/internal/{semantic-versioning → semantic_versioning}/findHighestVersion.js +0 -0
- package/src/internal/{semantic-versioning → semantic_versioning}/findLowestVersion.js +0 -0
- package/src/internal/{semantic-versioning → semantic_versioning}/index.js +0 -0
- package/src/internal/{semantic-versioning → semantic_versioning}/valueToVersion.js +0 -0
- package/src/internal/{semantic-versioning → semantic_versioning}/versionCompare.js +0 -0
- package/src/internal/{semantic-versioning → semantic_versioning}/versionIsAbove.js +0 -0
- package/src/internal/{semantic-versioning → semantic_versioning}/versionIsBelow.js +0 -0
- package/src/internal/{semantic-versioning → semantic_versioning}/versionIsEqual.js +0 -0
- package/src/launchBrowser.js +3 -3
- package/src/launchNode.js +33 -7
- package/src/requireUsingChildProcess.js +1 -1
- package/dist/jsenv_compile_proxy.js +0 -1339
- package/dist/jsenv_compile_proxy.js.map +0 -378
- package/dist/jsenv_event_source_client.js.map +0 -126
- package/dist/jsenv_exploring_index.js +0 -1092
- package/dist/jsenv_exploring_index.js.map +0 -353
- package/dist/jsenv_exploring_redirector.js +0 -1386
- package/dist/jsenv_exploring_redirector.js.map +0 -384
- package/dist/jsenv_redirector.js +0 -1388
- package/dist/jsenv_redirector.js.map +0 -384
- package/dist/jsenv_toolbar.js +0 -2880
- package/dist/jsenv_toolbar.js.map +0 -771
- package/dist/jsenv_toolbar_injector.js.map +0 -301
- package/src/internal/browser-launcher/jsenv_compile_proxy.html +0 -13
- package/src/internal/browser-launcher/jsenv_compile_proxy.js +0 -5
- package/src/internal/dev_server/event_source_client/event_source_client_file_info.js +0 -17
- package/src/internal/dev_server/exploring/exploring_file_info.js +0 -21
- package/src/internal/dev_server/redirector/redirector.js +0 -30
- package/src/internal/dev_server/redirector/redirector_file_info.js +0 -24
- package/src/internal/dev_server/toolbar/backtolist/toolbar.backtolist.js +0 -33
- package/src/internal/dev_server/toolbar/toolbar_file_info.js +0 -37
- package/src/internal/node-launcher/node-js-file.js +0 -110
- package/src/internal/runtime/createNodeRuntime/createNodeRuntime.js +0 -32
- package/src/internal/runtime/node-feature-detect/nodeSupportsTopLevelAwait.js +0 -18
- package/src/nodeRuntime.js +0 -5
package/src/dev_server.js
CHANGED
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
} from "@jsenv/filesystem"
|
|
6
6
|
import { setupRoutes } from "@jsenv/server"
|
|
7
7
|
|
|
8
|
+
import { REDIRECTOR_BUILD_URL } from "@jsenv/core/dist/build_manifest.js"
|
|
8
9
|
import { jsenvCoreDirectoryUrl } from "./internal/jsenvCoreDirectoryUrl.js"
|
|
9
10
|
import {
|
|
10
11
|
assertProjectDirectoryUrl,
|
|
@@ -15,21 +16,12 @@ import {
|
|
|
15
16
|
computeOutDirectoryRelativeUrl,
|
|
16
17
|
} from "./internal/compiling/startCompileServer.js"
|
|
17
18
|
import { jsenvExplorableConfig } from "./jsenvExplorableConfig.js"
|
|
18
|
-
|
|
19
|
-
redirectorHtmlFileInfo,
|
|
20
|
-
redirectorJsFileInfo,
|
|
21
|
-
} from "./internal/dev_server/redirector/redirector_file_info.js"
|
|
22
|
-
import {
|
|
23
|
-
exploringIndexHtmlFileInfo,
|
|
24
|
-
exploringIndexJsFileInfo,
|
|
25
|
-
} from "@jsenv/core/src/internal/dev_server/exploring/exploring_file_info.js"
|
|
26
|
-
import { toolbarJsFileInfo } from "@jsenv/core/src/internal/dev_server/toolbar/toolbar_file_info.js"
|
|
19
|
+
|
|
27
20
|
import {
|
|
28
21
|
sourcemapMainFileInfo,
|
|
29
22
|
sourcemapMappingFileInfo,
|
|
30
23
|
} from "./internal/jsenvInternalFiles.js"
|
|
31
24
|
import { jsenvRuntimeSupportDuringDev } from "./jsenvRuntimeSupportDuringDev.js"
|
|
32
|
-
import { eventSourceClientFileInfo } from "./internal/dev_server/event_source_client/event_source_client_file_info.js"
|
|
33
25
|
|
|
34
26
|
export const startDevServer = async ({
|
|
35
27
|
signal = new AbortController().signal,
|
|
@@ -45,10 +37,7 @@ export const startDevServer = async ({
|
|
|
45
37
|
|
|
46
38
|
projectDirectoryUrl,
|
|
47
39
|
explorableConfig = jsenvExplorableConfig,
|
|
48
|
-
mainFileRelativeUrl
|
|
49
|
-
exploringIndexHtmlFileInfo.sourceUrl,
|
|
50
|
-
projectDirectoryUrl,
|
|
51
|
-
),
|
|
40
|
+
mainFileRelativeUrl,
|
|
52
41
|
jsenvDirectoryRelativeUrl,
|
|
53
42
|
outDirectoryName = "dev",
|
|
54
43
|
jsenvToolbar = true,
|
|
@@ -70,6 +59,16 @@ export const startDevServer = async ({
|
|
|
70
59
|
projectDirectoryUrl = assertProjectDirectoryUrl({ projectDirectoryUrl })
|
|
71
60
|
await assertProjectDirectoryExists({ projectDirectoryUrl })
|
|
72
61
|
|
|
62
|
+
if (mainFileRelativeUrl === undefined) {
|
|
63
|
+
mainFileRelativeUrl = urlToRelativeUrl(
|
|
64
|
+
new URL(
|
|
65
|
+
"./src/internal/dev_server/exploring/exploring.html",
|
|
66
|
+
jsenvCoreDirectoryUrl,
|
|
67
|
+
).href,
|
|
68
|
+
projectDirectoryUrl,
|
|
69
|
+
)
|
|
70
|
+
}
|
|
71
|
+
|
|
73
72
|
const outDirectoryRelativeUrl = computeOutDirectoryRelativeUrl({
|
|
74
73
|
projectDirectoryUrl,
|
|
75
74
|
jsenvDirectoryRelativeUrl,
|
|
@@ -90,19 +89,14 @@ export const startDevServer = async ({
|
|
|
90
89
|
plugins,
|
|
91
90
|
customServices: {
|
|
92
91
|
...customServices,
|
|
93
|
-
"jsenv:redirector": createRedirectorService({
|
|
92
|
+
"jsenv:redirector": await createRedirectorService({
|
|
94
93
|
projectDirectoryUrl,
|
|
95
94
|
mainFileRelativeUrl,
|
|
96
95
|
}),
|
|
97
|
-
"jsenv:event_source_client": createEventSourceClientService({
|
|
98
|
-
projectDirectoryUrl,
|
|
99
|
-
}),
|
|
100
|
-
"jsenv:exploring_index": createExploringIndexService({
|
|
101
|
-
projectDirectoryUrl,
|
|
102
|
-
}),
|
|
103
96
|
"jsenv:exploring_json": createExploringJsonService({
|
|
104
97
|
projectDirectoryUrl,
|
|
105
98
|
outDirectoryRelativeUrl,
|
|
99
|
+
mainFileRelativeUrl,
|
|
106
100
|
explorableConfig,
|
|
107
101
|
livereloading,
|
|
108
102
|
}),
|
|
@@ -111,9 +105,6 @@ export const startDevServer = async ({
|
|
|
111
105
|
outDirectoryRelativeUrl,
|
|
112
106
|
explorableConfig,
|
|
113
107
|
}),
|
|
114
|
-
"jsenv:toolbar": createToolbarService({
|
|
115
|
-
projectDirectoryUrl,
|
|
116
|
-
}),
|
|
117
108
|
},
|
|
118
109
|
|
|
119
110
|
projectDirectoryUrl,
|
|
@@ -138,16 +129,12 @@ export const startDevServer = async ({
|
|
|
138
129
|
return compileServer
|
|
139
130
|
}
|
|
140
131
|
|
|
141
|
-
const createRedirectorService = ({
|
|
132
|
+
const createRedirectorService = async ({
|
|
142
133
|
projectDirectoryUrl,
|
|
143
134
|
mainFileRelativeUrl,
|
|
144
135
|
}) => {
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
projectDirectoryUrl,
|
|
148
|
-
)
|
|
149
|
-
const jsenvRedirectorJsBuildRelativeUrlForProject = urlToRelativeUrl(
|
|
150
|
-
redirectorJsFileInfo.buildUrl,
|
|
136
|
+
const redirectorRelativeUrlForProject = urlToRelativeUrl(
|
|
137
|
+
REDIRECTOR_BUILD_URL,
|
|
151
138
|
projectDirectoryUrl,
|
|
152
139
|
)
|
|
153
140
|
return setupRoutes({
|
|
@@ -156,7 +143,7 @@ const createRedirectorService = ({
|
|
|
156
143
|
return {
|
|
157
144
|
status: 307,
|
|
158
145
|
headers: {
|
|
159
|
-
location: `${request.origin}/${
|
|
146
|
+
location: `${request.origin}/${redirectorRelativeUrlForProject}?redirect=${redirectTarget}`,
|
|
160
147
|
},
|
|
161
148
|
}
|
|
162
149
|
},
|
|
@@ -167,105 +154,12 @@ const createRedirectorService = ({
|
|
|
167
154
|
headers: {
|
|
168
155
|
location: `${
|
|
169
156
|
request.origin
|
|
170
|
-
}/${
|
|
157
|
+
}/${redirectorRelativeUrlForProject}?redirect=${encodeURIComponent(
|
|
171
158
|
redirectTarget,
|
|
172
159
|
)}`,
|
|
173
160
|
},
|
|
174
161
|
}
|
|
175
162
|
},
|
|
176
|
-
"/.jsenv/redirector.js": (request) => {
|
|
177
|
-
return {
|
|
178
|
-
status: 307,
|
|
179
|
-
headers: {
|
|
180
|
-
location: `${request.origin}/${jsenvRedirectorJsBuildRelativeUrlForProject}`,
|
|
181
|
-
},
|
|
182
|
-
}
|
|
183
|
-
},
|
|
184
|
-
})
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
const createEventSourceClientService = ({ projectDirectoryUrl }) => {
|
|
188
|
-
const eventSourceClientBuildRelativeUrlForProject = urlToRelativeUrl(
|
|
189
|
-
eventSourceClientFileInfo.buildUrl,
|
|
190
|
-
projectDirectoryUrl,
|
|
191
|
-
)
|
|
192
|
-
return setupRoutes({
|
|
193
|
-
"/.jsenv/event_source_client.js": (request) => {
|
|
194
|
-
return {
|
|
195
|
-
status: 307,
|
|
196
|
-
headers: {
|
|
197
|
-
location: `${request.origin}/${eventSourceClientBuildRelativeUrlForProject}`,
|
|
198
|
-
},
|
|
199
|
-
}
|
|
200
|
-
},
|
|
201
|
-
// unfortunately browser resolves sourcemap to url before redirection (not after).
|
|
202
|
-
// It means browser tries to load source map from "/.jsenv/jsenv-toolbar.js.map"
|
|
203
|
-
// we could also inline sourcemap but it's not yet possible
|
|
204
|
-
// inside buildProject
|
|
205
|
-
"/.jsenv/event_source_client.js.map": (request) => {
|
|
206
|
-
return {
|
|
207
|
-
status: 307,
|
|
208
|
-
headers: {
|
|
209
|
-
location: `${request.origin}/${eventSourceClientBuildRelativeUrlForProject}.map`,
|
|
210
|
-
},
|
|
211
|
-
}
|
|
212
|
-
},
|
|
213
|
-
})
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
const createExploringIndexService = ({ projectDirectoryUrl }) => {
|
|
217
|
-
const jsenvExploringJsBuildRelativeUrlForProject = urlToRelativeUrl(
|
|
218
|
-
exploringIndexJsFileInfo.buildUrl,
|
|
219
|
-
projectDirectoryUrl,
|
|
220
|
-
)
|
|
221
|
-
return setupRoutes({
|
|
222
|
-
"/.jsenv/exploring.index.js": (request) => {
|
|
223
|
-
return {
|
|
224
|
-
status: 307,
|
|
225
|
-
headers: {
|
|
226
|
-
location: `${request.origin}/${jsenvExploringJsBuildRelativeUrlForProject}`,
|
|
227
|
-
},
|
|
228
|
-
}
|
|
229
|
-
},
|
|
230
|
-
// unfortunately browser resolves sourcemap to url before redirection (not after).
|
|
231
|
-
// It means browser tries to load source map from "/.jsenv/jsenv-toolbar.js.map"
|
|
232
|
-
// we could also inline sourcemap but it's not yet possible
|
|
233
|
-
// inside buildProject
|
|
234
|
-
"/.jsenv/jsenv_exploring_index.js.map": (request) => {
|
|
235
|
-
return {
|
|
236
|
-
status: 307,
|
|
237
|
-
headers: {
|
|
238
|
-
location: `${request.origin}/${jsenvExploringJsBuildRelativeUrlForProject}.map`,
|
|
239
|
-
},
|
|
240
|
-
}
|
|
241
|
-
},
|
|
242
|
-
})
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
const createToolbarService = ({ projectDirectoryUrl }) => {
|
|
246
|
-
const toolbarJsBuildRelativeUrlForProject = urlToRelativeUrl(
|
|
247
|
-
toolbarJsFileInfo.buildUrl,
|
|
248
|
-
projectDirectoryUrl,
|
|
249
|
-
)
|
|
250
|
-
|
|
251
|
-
return setupRoutes({
|
|
252
|
-
"/.jsenv/toolbar.main.js": (request) => {
|
|
253
|
-
const jsenvToolbarJsBuildServerUrl = `${request.origin}/${toolbarJsBuildRelativeUrlForProject}`
|
|
254
|
-
return {
|
|
255
|
-
status: 307,
|
|
256
|
-
headers: {
|
|
257
|
-
location: jsenvToolbarJsBuildServerUrl,
|
|
258
|
-
},
|
|
259
|
-
}
|
|
260
|
-
},
|
|
261
|
-
"/.jsenv/jsenv_toolbar.js.map": (request) => {
|
|
262
|
-
return {
|
|
263
|
-
status: 307,
|
|
264
|
-
headers: {
|
|
265
|
-
location: `${request.origin}/${toolbarJsBuildRelativeUrlForProject}.map`,
|
|
266
|
-
},
|
|
267
|
-
}
|
|
268
|
-
},
|
|
269
163
|
})
|
|
270
164
|
}
|
|
271
165
|
|
|
@@ -274,6 +168,7 @@ const createExploringJsonService = ({
|
|
|
274
168
|
outDirectoryRelativeUrl,
|
|
275
169
|
explorableConfig,
|
|
276
170
|
livereloading,
|
|
171
|
+
mainFileRelativeUrl,
|
|
277
172
|
}) => {
|
|
278
173
|
return (request) => {
|
|
279
174
|
if (
|
|
@@ -287,10 +182,7 @@ const createExploringJsonService = ({
|
|
|
287
182
|
jsenvCoreDirectoryUrl,
|
|
288
183
|
projectDirectoryUrl,
|
|
289
184
|
),
|
|
290
|
-
exploringHtmlFileRelativeUrl:
|
|
291
|
-
exploringIndexHtmlFileInfo.sourceUrl,
|
|
292
|
-
projectDirectoryUrl,
|
|
293
|
-
),
|
|
185
|
+
exploringHtmlFileRelativeUrl: mainFileRelativeUrl,
|
|
294
186
|
sourcemapMainFileRelativeUrl: urlToRelativeUrl(
|
|
295
187
|
sourcemapMainFileInfo.url,
|
|
296
188
|
jsenvCoreDirectoryUrl,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { launchAndExecute } from "./internal/executing/launchAndExecute.js"
|
|
2
|
-
import { createControllableNodeProcess } from "./internal/
|
|
2
|
+
import { createControllableNodeProcess } from "./internal/node_launcher/createControllableNodeProcess.js"
|
|
3
3
|
|
|
4
4
|
export const importUsingChildProcess = async (
|
|
5
5
|
fileUrl,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import { resolveGroup } from "../resolveGroup.js"
|
|
1
|
+
/* eslint-env browser */
|
|
2
|
+
|
|
3
|
+
import { computeCompileIdFromGroupId } from "../runtime/computeCompileIdFromGroupId.js"
|
|
4
|
+
import { resolveGroup } from "../runtime/resolveGroup.js"
|
|
5
|
+
import { fetchJson } from "../browser_utils/fetchJson.js"
|
|
6
|
+
import { detectBrowser } from "../browser_detection/browser_detection.js"
|
|
5
7
|
|
|
6
8
|
export const scanBrowserRuntimeFeatures = async ({
|
|
7
9
|
coverageHandledFromOutside = false,
|
|
@@ -61,44 +63,6 @@ export const scanBrowserRuntimeFeatures = async ({
|
|
|
61
63
|
}
|
|
62
64
|
}
|
|
63
65
|
|
|
64
|
-
const detectSupportedFeatures = async ({
|
|
65
|
-
featuresReport,
|
|
66
|
-
failFastOnFeatureDetection,
|
|
67
|
-
inlineImportMapIntoHTML,
|
|
68
|
-
}) => {
|
|
69
|
-
// start testing importmap support first and not in paralell
|
|
70
|
-
// so that there is not module script loaded beore importmap is injected
|
|
71
|
-
// it would log an error in chrome console and return undefined
|
|
72
|
-
const importmap = await supportsImportmap({
|
|
73
|
-
// chrome supports inline but not remote importmap
|
|
74
|
-
// https://github.com/WICG/import-maps/issues/235
|
|
75
|
-
|
|
76
|
-
// at this stage we won't know if the html file will use
|
|
77
|
-
// an importmap or not and if that importmap is inline or specified with an src
|
|
78
|
-
// so we should test if browser support local and remote importmap.
|
|
79
|
-
// But there exploring server can inline importmap by transforming html
|
|
80
|
-
// and in that case we can test only the local importmap support
|
|
81
|
-
// so we test importmap support and the remote one
|
|
82
|
-
remote: !inlineImportMapIntoHTML,
|
|
83
|
-
})
|
|
84
|
-
featuresReport.importmap = importmap
|
|
85
|
-
if (!importmap && failFastOnFeatureDetection) {
|
|
86
|
-
return
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
const dynamicImport = await supportsDynamicImport()
|
|
90
|
-
featuresReport.dynamicImport = dynamicImport
|
|
91
|
-
if (!dynamicImport && failFastOnFeatureDetection) {
|
|
92
|
-
return
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
const topLevelAwait = await supportsTopLevelAwait()
|
|
96
|
-
featuresReport.topLevelAwait = topLevelAwait
|
|
97
|
-
if (!topLevelAwait && failFastOnFeatureDetection) {
|
|
98
|
-
return
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
66
|
const pluginRequiredNamesFromGroupInfo = async (
|
|
103
67
|
groupInfo,
|
|
104
68
|
{ featuresReport, coverageHandledFromOutside },
|
|
@@ -140,25 +104,51 @@ const pluginRequiredNamesFromGroupInfo = async (
|
|
|
140
104
|
return requiredPluginNames
|
|
141
105
|
}
|
|
142
106
|
|
|
143
|
-
const
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
107
|
+
const detectSupportedFeatures = async ({
|
|
108
|
+
featuresReport,
|
|
109
|
+
failFastOnFeatureDetection,
|
|
110
|
+
inlineImportMapIntoHTML,
|
|
111
|
+
}) => {
|
|
112
|
+
// start testing importmap support first and not in paralell
|
|
113
|
+
// so that there is not module script loaded beore importmap is injected
|
|
114
|
+
// it would log an error in chrome console and return undefined
|
|
115
|
+
const importmap = await supportsImportmap({
|
|
116
|
+
// chrome supports inline but not remote importmap
|
|
117
|
+
// https://github.com/WICG/import-maps/issues/235
|
|
118
|
+
|
|
119
|
+
// at this stage we won't know if the html file will use
|
|
120
|
+
// an importmap or not and if that importmap is inline or specified with an src
|
|
121
|
+
// so we should test if browser support local and remote importmap.
|
|
122
|
+
// But there exploring server can inline importmap by transforming html
|
|
123
|
+
// and in that case we can test only the local importmap support
|
|
124
|
+
// so we test importmap support and the remote one
|
|
125
|
+
remote: !inlineImportMapIntoHTML,
|
|
126
|
+
})
|
|
127
|
+
featuresReport.importmap = importmap
|
|
128
|
+
if (!importmap && failFastOnFeatureDetection) {
|
|
129
|
+
return
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const dynamicImport = await supportsDynamicImport()
|
|
133
|
+
featuresReport.dynamicImport = dynamicImport
|
|
134
|
+
if (!dynamicImport && failFastOnFeatureDetection) {
|
|
135
|
+
return
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const topLevelAwait = await supportsTopLevelAwait()
|
|
139
|
+
featuresReport.topLevelAwait = topLevelAwait
|
|
140
|
+
if (!topLevelAwait && failFastOnFeatureDetection) {
|
|
141
|
+
return
|
|
150
142
|
}
|
|
151
143
|
}
|
|
152
144
|
|
|
153
145
|
const supportsImportmap = async ({ remote = true } = {}) => {
|
|
154
146
|
const specifier = asBase64Url(`export default false`)
|
|
155
|
-
|
|
156
147
|
const importMap = {
|
|
157
148
|
imports: {
|
|
158
149
|
[specifier]: asBase64Url(`export default true`),
|
|
159
150
|
},
|
|
160
151
|
}
|
|
161
|
-
|
|
162
152
|
const importmapScript = document.createElement("script")
|
|
163
153
|
const importmapString = JSON.stringify(importMap, null, " ")
|
|
164
154
|
importmapScript.type = "importmap"
|
|
@@ -169,59 +159,74 @@ const supportsImportmap = async ({ remote = true } = {}) => {
|
|
|
169
159
|
} else {
|
|
170
160
|
importmapScript.textContent = importmapString
|
|
171
161
|
}
|
|
172
|
-
|
|
173
162
|
document.body.appendChild(importmapScript)
|
|
174
163
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
document.body.removeChild(scriptModule)
|
|
186
|
-
document.body.removeChild(importmapScript)
|
|
187
|
-
resolve(supported)
|
|
188
|
-
}
|
|
189
|
-
scriptModule.onerror = () => {
|
|
190
|
-
document.body.removeChild(scriptModule)
|
|
191
|
-
document.body.removeChild(importmapScript)
|
|
192
|
-
reject()
|
|
193
|
-
}
|
|
194
|
-
document.body.appendChild(scriptModule)
|
|
195
|
-
})
|
|
164
|
+
try {
|
|
165
|
+
await executeWithScriptModuleInjection(
|
|
166
|
+
`import supported from "${specifier}"; window.__jsenv_runtime_test_importmap__ = supported`,
|
|
167
|
+
)
|
|
168
|
+
document.body.removeChild(importmapScript)
|
|
169
|
+
return window.__jsenv_runtime_test_importmap__
|
|
170
|
+
} catch (e) {
|
|
171
|
+
document.body.removeChild(importmapScript)
|
|
172
|
+
return false
|
|
173
|
+
}
|
|
196
174
|
}
|
|
197
175
|
|
|
198
176
|
const supportsDynamicImport = async () => {
|
|
199
177
|
const moduleSource = asBase64Url(`export default 42`)
|
|
200
178
|
try {
|
|
201
|
-
|
|
179
|
+
await executeWithScriptModuleInjection(
|
|
180
|
+
`window.__jsenv_runtime_test_dynamic_import__ = import(${JSON.stringify(
|
|
181
|
+
moduleSource,
|
|
182
|
+
)})`,
|
|
183
|
+
)
|
|
184
|
+
const namespace = await window.__jsenv_runtime_test_dynamic_import__
|
|
202
185
|
return namespace.default === 42
|
|
203
186
|
} catch (e) {
|
|
204
187
|
return false
|
|
205
188
|
}
|
|
206
189
|
}
|
|
207
190
|
|
|
191
|
+
const supportsNewStylesheet = () => {
|
|
192
|
+
try {
|
|
193
|
+
// eslint-disable-next-line no-new
|
|
194
|
+
new CSSStyleSheet()
|
|
195
|
+
return true
|
|
196
|
+
} catch (e) {
|
|
197
|
+
return false
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
208
201
|
const supportsTopLevelAwait = async () => {
|
|
209
|
-
const moduleSource = asBase64Url(`export default await Promise.resolve(42)`)
|
|
210
202
|
try {
|
|
211
|
-
|
|
212
|
-
|
|
203
|
+
await executeWithScriptModuleInjection(
|
|
204
|
+
`window.__jsenv_runtime_test_top_level_await__ = await Promise.resolve(42)`,
|
|
205
|
+
)
|
|
206
|
+
return window.__jsenv_runtime_test_top_level_await__ === 42
|
|
213
207
|
} catch (e) {
|
|
214
208
|
return false
|
|
215
209
|
}
|
|
216
210
|
}
|
|
217
211
|
|
|
212
|
+
// to execute in a browser devtools
|
|
213
|
+
// const featuresReport = {}
|
|
214
|
+
// await detectSupportedFeatures({ featuresReport, inlineImportMapIntoHTML: true })
|
|
215
|
+
// console.log(featuresReport)
|
|
216
|
+
|
|
218
217
|
const supportsJsonImportAssertions = async () => {
|
|
219
218
|
const jsonBase64Url = asBase64Url("42", "application/json")
|
|
220
219
|
const moduleSource = asBase64Url(
|
|
221
|
-
`
|
|
220
|
+
`import data from "${jsonBase64Url}" assert { type: "json" }
|
|
221
|
+
export default data`,
|
|
222
222
|
)
|
|
223
223
|
try {
|
|
224
|
-
|
|
224
|
+
await executeWithScriptModuleInjection(
|
|
225
|
+
`window.__jsenv_runtime_test_json_import_assertion__ = import(${JSON.stringify(
|
|
226
|
+
moduleSource,
|
|
227
|
+
)})`,
|
|
228
|
+
)
|
|
229
|
+
const namespace = await window.__jsenv_runtime_test_json_import_assertion__
|
|
225
230
|
return namespace.default === 42
|
|
226
231
|
} catch (e) {
|
|
227
232
|
return false
|
|
@@ -231,16 +236,46 @@ const supportsJsonImportAssertions = async () => {
|
|
|
231
236
|
const supportsCssImportAssertions = async () => {
|
|
232
237
|
const cssBase64Url = asBase64Url("p { color: red; }", "text/css")
|
|
233
238
|
const moduleSource = asBase64Url(
|
|
234
|
-
`
|
|
239
|
+
`import css from "${cssBase64Url}" assert { type: "css" }
|
|
240
|
+
export default css`,
|
|
235
241
|
)
|
|
236
242
|
try {
|
|
237
|
-
|
|
243
|
+
await executeWithScriptModuleInjection(
|
|
244
|
+
`window.__jsenv_runtime_test_css_import_assertion__ = import(${JSON.stringify(
|
|
245
|
+
moduleSource,
|
|
246
|
+
)})`,
|
|
247
|
+
)
|
|
248
|
+
const namespace = await window.__jsenv_runtime_test_css_import_assertion__
|
|
238
249
|
return namespace.default instanceof CSSStyleSheet
|
|
239
250
|
} catch (e) {
|
|
240
251
|
return false
|
|
241
252
|
}
|
|
242
253
|
}
|
|
243
254
|
|
|
255
|
+
const executeWithScriptModuleInjection = (code) => {
|
|
256
|
+
const scriptModule = document.createElement("script")
|
|
257
|
+
scriptModule.type = "module"
|
|
258
|
+
|
|
259
|
+
const loadPromise = new Promise((resolve, reject) => {
|
|
260
|
+
scriptModule.onload = () => {
|
|
261
|
+
document.body.removeChild(scriptModule)
|
|
262
|
+
resolve()
|
|
263
|
+
}
|
|
264
|
+
scriptModule.onerror = () => {
|
|
265
|
+
document.body.removeChild(scriptModule)
|
|
266
|
+
reject()
|
|
267
|
+
}
|
|
268
|
+
document.body.appendChild(scriptModule)
|
|
269
|
+
})
|
|
270
|
+
|
|
271
|
+
scriptModule.src = asBase64Url(code)
|
|
272
|
+
|
|
273
|
+
return loadPromise
|
|
274
|
+
}
|
|
275
|
+
|
|
244
276
|
const asBase64Url = (text, mimeType = "application/javascript") => {
|
|
245
277
|
return `data:${mimeType};base64,${window.btoa(text)}`
|
|
246
278
|
}
|
|
279
|
+
|
|
280
|
+
// const cssImportAssertions = await supportsCssImportAssertions()
|
|
281
|
+
// console.log({ cssImportAssertions })
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>Compile proxy</title>
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
|
+
<meta charset="utf-8" />
|
|
7
|
+
<link rel="icon" href="data:," />
|
|
8
|
+
</head>
|
|
9
|
+
|
|
10
|
+
<body>
|
|
11
|
+
<script>
|
|
12
|
+
window.readyPromise = new Promise((resolve) => {
|
|
13
|
+
window.resolveReadyPromise = resolve
|
|
14
|
+
})
|
|
15
|
+
</script>
|
|
16
|
+
<script
|
|
17
|
+
type="importmap"
|
|
18
|
+
src="../../../node_resolution.importmap"
|
|
19
|
+
></script>
|
|
20
|
+
<script type="module">
|
|
21
|
+
import { scanBrowserRuntimeFeatures } from "./browser_feature_detection.js"
|
|
22
|
+
|
|
23
|
+
window.scanBrowserRuntimeFeatures = scanBrowserRuntimeFeatures
|
|
24
|
+
window.resolveReadyPromise()
|
|
25
|
+
</script>
|
|
26
|
+
</body>
|
|
27
|
+
</html>
|
|
File without changes
|
|
@@ -5,10 +5,10 @@ import {
|
|
|
5
5
|
urlToExtension,
|
|
6
6
|
} from "@jsenv/filesystem"
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import { COMPILE_PROXY_BUILD_URL } from "@jsenv/core/dist/build_manifest.js"
|
|
9
9
|
import { filterV8Coverage } from "@jsenv/core/src/internal/executing/coverage_utils/v8_coverage_from_directory.js"
|
|
10
10
|
import { composeTwoFileByFileIstanbulCoverages } from "@jsenv/core/src/internal/executing/coverage_utils/istanbul_coverage_composition.js"
|
|
11
|
-
import { evalSource } from "../
|
|
11
|
+
import { evalSource } from "../node_runtime/evalSource.js"
|
|
12
12
|
import { escapeRegexpSpecialCharacters } from "../escapeRegexpSpecialCharacters.js"
|
|
13
13
|
|
|
14
14
|
export const executeHtmlFile = async (
|
|
@@ -39,7 +39,7 @@ export const executeHtmlFile = async (
|
|
|
39
39
|
await assertFilePresence(fileUrl)
|
|
40
40
|
|
|
41
41
|
const compileProxyProjectRelativeUrl = urlToRelativeUrl(
|
|
42
|
-
|
|
42
|
+
COMPILE_PROXY_BUILD_URL,
|
|
43
43
|
projectDirectoryUrl,
|
|
44
44
|
)
|
|
45
45
|
const compileProxyClientUrl = resolveUrl(
|
|
@@ -55,7 +55,10 @@ export const executeHtmlFile = async (
|
|
|
55
55
|
executeOperation.throwIfAborted()
|
|
56
56
|
const browserRuntimeFeaturesReport = await page.evaluate(
|
|
57
57
|
/* istanbul ignore next */
|
|
58
|
-
({ coverageHandledFromOutside }) => {
|
|
58
|
+
async ({ coverageHandledFromOutside }) => {
|
|
59
|
+
// eslint-disable-next-line no-undef
|
|
60
|
+
await window.readyPromise
|
|
61
|
+
|
|
59
62
|
// eslint-disable-next-line no-undef
|
|
60
63
|
return window.scanBrowserRuntimeFeatures({
|
|
61
64
|
coverageHandledFromOutside,
|
|
File without changes
|
package/src/internal/{browser-launcher/jsenv-browser-system.js → browser_runtime/browser_runtime.js}
RENAMED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/* eslint-env browser */
|
|
2
2
|
|
|
3
|
-
import { unevalException } from "../unevalException.js"
|
|
4
|
-
import { createBrowserRuntime } from "../runtime/createBrowserRuntime/createBrowserRuntime.js"
|
|
5
3
|
import { installBrowserErrorStackRemapping } from "../error-stack-remapping/installBrowserErrorStackRemapping.js"
|
|
6
|
-
import { fetchUrl } from "../
|
|
7
|
-
import { fetchAndEvalUsingFetch } from "../
|
|
4
|
+
import { fetchUrl } from "../browser_utils/fetch-browser.js"
|
|
5
|
+
import { fetchAndEvalUsingFetch } from "../browser_utils/fetchAndEvalUsingFetch.js"
|
|
6
|
+
import { unevalException } from "../unevalException.js"
|
|
8
7
|
import { memoize } from "../memoize.js"
|
|
9
8
|
|
|
10
9
|
import { displayErrorInDocument } from "./displayErrorInDocument.js"
|
|
11
10
|
import { displayErrorNotification } from "./displayErrorNotification.js"
|
|
11
|
+
import { createBrowserRuntime } from "./createBrowserRuntime.js"
|
|
12
12
|
|
|
13
13
|
const getNavigationStartTime = () => {
|
|
14
14
|
try {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
/* eslint-env browser */
|
|
2
2
|
|
|
3
|
-
import "../
|
|
3
|
+
import { getJavaScriptModuleResponseError } from "../runtime/module-registration.js"
|
|
4
|
+
import "../runtime/s.js"
|
|
4
5
|
|
|
5
6
|
export const createBrowserSystem = ({
|
|
6
7
|
compileServerOrigin,
|
package/src/internal/{runtime/createBrowserRuntime → browser_runtime}/createBrowserRuntime.js
RENAMED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
+
/* eslint-env browser */
|
|
2
|
+
|
|
1
3
|
import { normalizeImportMap } from "@jsenv/importmap/src/normalizeImportMap.js"
|
|
2
4
|
|
|
3
5
|
// do not use memoize from @jsenv/filesystem to avoid pulling @jsenv/filesystem code into the browser build
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { measureAsyncFnPerf } from "
|
|
6
|
+
import { fetchUrl } from "../browser_utils/fetch-browser.js"
|
|
7
|
+
import { createImportResolverForImportmap } from "../import-resolution/import-resolver-importmap.js"
|
|
8
|
+
import { memoize } from "../memoize.js"
|
|
9
|
+
import { measureAsyncFnPerf } from "../perf_browser.js"
|
|
8
10
|
|
|
9
|
-
import { createBrowserSystem } from "./
|
|
11
|
+
import { createBrowserSystem } from "./browser_system.js"
|
|
10
12
|
import { makeNamespaceTransferable } from "./makeNamespaceTransferable.js"
|
|
11
13
|
|
|
12
14
|
const memoizedCreateBrowserSystem = memoize(createBrowserSystem)
|
|
File without changes
|