@jsenv/core 24.2.1 → 24.3.3
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/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-29e91dcd.html +4779 -0
- package/dist/toolbar/toolbar.main-53e1ab2b.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-0af91b43.js} +87 -65
- package/dist/toolbar_injector/toolbar_injector-0af91b43.js.map +294 -0
- package/main.js +0 -1
- package/package.json +2 -1
- package/readme.md +10 -7
- package/src/buildProject.js +6 -2
- package/src/dev_server.js +26 -130
- package/src/execute.js +7 -10
- 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_runtime_report.js +75 -0
- package/src/internal/{browser-launcher → browser_launcher}/createSharing.js +0 -0
- package/src/internal/{browser-launcher → browser_launcher}/executeHtmlFile.js +13 -16
- 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 +37 -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 +55 -36
- package/src/internal/dev_server/toolbar/toolbar.main.js +45 -31
- package/src/internal/dev_server/toolbar/util/fetching.js +1 -1
- package/src/internal/executing/executeConcurrently.js +5 -4
- package/src/internal/executing/executePlan.js +1 -2
- 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_runtime_report.js +71 -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 +12 -3
- package/src/launchNode.js +36 -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
|
},
|
|
@@ -165,100 +152,11 @@ const createRedirectorService = ({
|
|
|
165
152
|
return {
|
|
166
153
|
status: 307,
|
|
167
154
|
headers: {
|
|
168
|
-
location: `${
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
return {
|
|
174
|
-
status: 307,
|
|
175
|
-
headers: {
|
|
176
|
-
location: `${request.origin}/${jsenvRedirectorJsBuildRelativeUrlForProject}`,
|
|
177
|
-
},
|
|
178
|
-
}
|
|
179
|
-
},
|
|
180
|
-
})
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
const createEventSourceClientService = ({ projectDirectoryUrl }) => {
|
|
184
|
-
const eventSourceClientBuildRelativeUrlForProject = urlToRelativeUrl(
|
|
185
|
-
eventSourceClientFileInfo.buildUrl,
|
|
186
|
-
projectDirectoryUrl,
|
|
187
|
-
)
|
|
188
|
-
return setupRoutes({
|
|
189
|
-
"/.jsenv/event_source_client.js": (request) => {
|
|
190
|
-
return {
|
|
191
|
-
status: 307,
|
|
192
|
-
headers: {
|
|
193
|
-
location: `${request.origin}/${eventSourceClientBuildRelativeUrlForProject}`,
|
|
194
|
-
},
|
|
195
|
-
}
|
|
196
|
-
},
|
|
197
|
-
// unfortunately browser resolves sourcemap to url before redirection (not after).
|
|
198
|
-
// It means browser tries to load source map from "/.jsenv/jsenv-toolbar.js.map"
|
|
199
|
-
// we could also inline sourcemap but it's not yet possible
|
|
200
|
-
// inside buildProject
|
|
201
|
-
"/.jsenv/event_source_client.js.map": (request) => {
|
|
202
|
-
return {
|
|
203
|
-
status: 307,
|
|
204
|
-
headers: {
|
|
205
|
-
location: `${request.origin}/${eventSourceClientBuildRelativeUrlForProject}.map`,
|
|
206
|
-
},
|
|
207
|
-
}
|
|
208
|
-
},
|
|
209
|
-
})
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
const createExploringIndexService = ({ projectDirectoryUrl }) => {
|
|
213
|
-
const jsenvExploringJsBuildRelativeUrlForProject = urlToRelativeUrl(
|
|
214
|
-
exploringIndexJsFileInfo.buildUrl,
|
|
215
|
-
projectDirectoryUrl,
|
|
216
|
-
)
|
|
217
|
-
return setupRoutes({
|
|
218
|
-
"/.jsenv/exploring.index.js": (request) => {
|
|
219
|
-
return {
|
|
220
|
-
status: 307,
|
|
221
|
-
headers: {
|
|
222
|
-
location: `${request.origin}/${jsenvExploringJsBuildRelativeUrlForProject}`,
|
|
223
|
-
},
|
|
224
|
-
}
|
|
225
|
-
},
|
|
226
|
-
// unfortunately browser resolves sourcemap to url before redirection (not after).
|
|
227
|
-
// It means browser tries to load source map from "/.jsenv/jsenv-toolbar.js.map"
|
|
228
|
-
// we could also inline sourcemap but it's not yet possible
|
|
229
|
-
// inside buildProject
|
|
230
|
-
"/.jsenv/jsenv_exploring_index.js.map": (request) => {
|
|
231
|
-
return {
|
|
232
|
-
status: 307,
|
|
233
|
-
headers: {
|
|
234
|
-
location: `${request.origin}/${jsenvExploringJsBuildRelativeUrlForProject}.map`,
|
|
235
|
-
},
|
|
236
|
-
}
|
|
237
|
-
},
|
|
238
|
-
})
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
const createToolbarService = ({ projectDirectoryUrl }) => {
|
|
242
|
-
const toolbarJsBuildRelativeUrlForProject = urlToRelativeUrl(
|
|
243
|
-
toolbarJsFileInfo.buildUrl,
|
|
244
|
-
projectDirectoryUrl,
|
|
245
|
-
)
|
|
246
|
-
|
|
247
|
-
return setupRoutes({
|
|
248
|
-
"/.jsenv/toolbar.main.js": (request) => {
|
|
249
|
-
const jsenvToolbarJsBuildServerUrl = `${request.origin}/${toolbarJsBuildRelativeUrlForProject}`
|
|
250
|
-
return {
|
|
251
|
-
status: 307,
|
|
252
|
-
headers: {
|
|
253
|
-
location: jsenvToolbarJsBuildServerUrl,
|
|
254
|
-
},
|
|
255
|
-
}
|
|
256
|
-
},
|
|
257
|
-
"/.jsenv/jsenv_toolbar.js.map": (request) => {
|
|
258
|
-
return {
|
|
259
|
-
status: 307,
|
|
260
|
-
headers: {
|
|
261
|
-
location: `${request.origin}/${toolbarJsBuildRelativeUrlForProject}.map`,
|
|
155
|
+
location: `${
|
|
156
|
+
request.origin
|
|
157
|
+
}/${redirectorRelativeUrlForProject}?redirect=${encodeURIComponent(
|
|
158
|
+
redirectTarget,
|
|
159
|
+
)}`,
|
|
262
160
|
},
|
|
263
161
|
}
|
|
264
162
|
},
|
|
@@ -270,6 +168,7 @@ const createExploringJsonService = ({
|
|
|
270
168
|
outDirectoryRelativeUrl,
|
|
271
169
|
explorableConfig,
|
|
272
170
|
livereloading,
|
|
171
|
+
mainFileRelativeUrl,
|
|
273
172
|
}) => {
|
|
274
173
|
return (request) => {
|
|
275
174
|
if (
|
|
@@ -283,10 +182,7 @@ const createExploringJsonService = ({
|
|
|
283
182
|
jsenvCoreDirectoryUrl,
|
|
284
183
|
projectDirectoryUrl,
|
|
285
184
|
),
|
|
286
|
-
exploringHtmlFileRelativeUrl:
|
|
287
|
-
exploringIndexHtmlFileInfo.sourceUrl,
|
|
288
|
-
projectDirectoryUrl,
|
|
289
|
-
),
|
|
185
|
+
exploringHtmlFileRelativeUrl: mainFileRelativeUrl,
|
|
290
186
|
sourcemapMainFileRelativeUrl: urlToRelativeUrl(
|
|
291
187
|
sourcemapMainFileInfo.url,
|
|
292
188
|
jsenvCoreDirectoryUrl,
|
package/src/execute.js
CHANGED
|
@@ -88,11 +88,7 @@ export const execute = async ({
|
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
try {
|
|
91
|
-
const {
|
|
92
|
-
outDirectoryRelativeUrl,
|
|
93
|
-
origin: compileServerOrigin,
|
|
94
|
-
stop,
|
|
95
|
-
} = await startCompileServer({
|
|
91
|
+
const compileServer = await startCompileServer({
|
|
96
92
|
signal: executeOperation.signal,
|
|
97
93
|
logLevel: compileServerLogLevel,
|
|
98
94
|
|
|
@@ -117,7 +113,7 @@ export const execute = async ({
|
|
|
117
113
|
compileServerCanWriteOnFilesystem,
|
|
118
114
|
})
|
|
119
115
|
executeOperation.addEndCallback(async () => {
|
|
120
|
-
await stop("execution done")
|
|
116
|
+
await compileServer.stop("execution done")
|
|
121
117
|
})
|
|
122
118
|
|
|
123
119
|
const result = await launchAndExecute({
|
|
@@ -127,8 +123,9 @@ export const execute = async ({
|
|
|
127
123
|
runtime,
|
|
128
124
|
runtimeParams: {
|
|
129
125
|
projectDirectoryUrl,
|
|
130
|
-
compileServerOrigin,
|
|
131
|
-
|
|
126
|
+
compileServerOrigin: compileServer.origin,
|
|
127
|
+
compileServerId: compileServer.id,
|
|
128
|
+
outDirectoryRelativeUrl: compileServer.outDirectoryRelativeUrl,
|
|
132
129
|
...runtimeParams,
|
|
133
130
|
},
|
|
134
131
|
executeParams: {
|
|
@@ -155,8 +152,8 @@ export const execute = async ({
|
|
|
155
152
|
})
|
|
156
153
|
|
|
157
154
|
if (collectCompileServerInfo) {
|
|
158
|
-
result.
|
|
159
|
-
result.
|
|
155
|
+
result.compileServerOrigin = compileServer.origin
|
|
156
|
+
result.outDirectoryRelativeUrl = compileServer.outDirectoryRelativeUrl
|
|
160
157
|
}
|
|
161
158
|
|
|
162
159
|
if (result.status === "errored") {
|
|
@@ -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>
|