@jsenv/core 25.2.1 → 25.4.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/dist/browser_runtime/asset-manifest.json +2 -2
- package/dist/browser_runtime/{browser_runtime_91c5a3b8.js → browser_runtime_0e3396a1.js} +15 -16
- package/dist/browser_runtime/{browser_runtime_91c5a3b8.js.map → browser_runtime_0e3396a1.js.map} +13 -13
- package/dist/build_manifest.js +5 -5
- package/dist/compile_proxy/asset-manifest.json +2 -2
- package/dist/compile_proxy/compile_proxy.html__inline__20_f4285042.js.map +343 -0
- package/dist/compile_proxy/{compile_proxy_8dfaee51.html → compile_proxy_ab528227.html} +358 -397
- package/dist/redirector/asset-manifest.json +2 -2
- package/dist/redirector/redirector.html__inline__12_404b8295.js.map +349 -0
- package/dist/redirector/{redirector_3e9a97b9.html → redirector_6df2620a.html} +369 -407
- package/dist/toolbar/asset-manifest.json +2 -2
- package/dist/toolbar/toolbar.main_279b3a68.js.map +764 -0
- package/dist/toolbar/{toolbar_361afb84.html → toolbar_0a91ca3b.html} +1509 -1583
- package/dist/toolbar_injector/asset-manifest.json +2 -2
- package/dist/toolbar_injector/{toolbar_injector_fac1e995.js → toolbar_injector_34f6ad8e.js} +18 -15
- package/dist/toolbar_injector/{toolbar_injector_fac1e995.js.map → toolbar_injector_34f6ad8e.js.map} +15 -15
- package/package.json +16 -12
- package/readme.md +54 -54
- package/src/buildProject.js +31 -26
- package/src/dev_server.js +111 -92
- package/src/execute.js +3 -8
- package/src/internal/browser_launcher/{browser_runtime_report.js → browser_runtime_profile.js} +21 -15
- package/src/internal/browser_launcher/executeHtmlFile.js +22 -14
- package/src/internal/browser_launcher/from_playwright.js +6 -4
- package/src/internal/browser_runtime/browser_runtime.js +12 -14
- package/src/internal/browser_runtime/createBrowserRuntime.js +7 -6
- package/src/internal/browser_utils/fetchAndEvalUsingFetch.js +1 -1
- package/src/internal/browser_utils/fetchJson.js +1 -1
- package/src/internal/browser_utils/{fetch-browser.js → fetch_browser.js} +0 -2
- package/src/internal/building/buildUsingRollup.js +41 -57
- package/src/internal/building/html/parseHtmlRessource.js +2 -1
- package/src/internal/building/rollup_plugin_jsenv.js +28 -8
- package/src/internal/compiling/babel_parse_error.js +9 -0
- package/src/internal/{babel_plugin_transform_import_meta.js → compiling/babel_plugin_transform_import_meta.js} +58 -9
- package/src/internal/compiling/compileFile.js +2 -2
- package/src/internal/compiling/compileHtml.js +1 -1
- package/src/internal/compiling/createCompiledFileService.js +25 -74
- package/src/internal/compiling/js-compilation-service/transformJs.js +153 -23
- package/src/internal/compiling/jsenvCompilerForHtml.js +29 -32
- package/src/internal/compiling/jsenvCompilerForImportmap.js +2 -2
- package/src/internal/compiling/jsenvCompilerForJavaScript.js +2 -4
- package/src/internal/compiling/jsenv_directory/comparison_utils.js +24 -0
- package/src/internal/compiling/{compile-directory/compile-asset.js → jsenv_directory/compile_asset.js} +0 -0
- package/src/internal/compiling/jsenv_directory/compile_context.js +68 -0
- package/src/internal/compiling/jsenv_directory/compile_profile.js +218 -0
- package/src/internal/compiling/{compile-directory/createLockRegistry.js → jsenv_directory/file_lock_registry.js} +0 -0
- package/src/internal/compiling/{compile-directory/createLockRegistry.test.js → jsenv_directory/file_lock_registry.test.js} +2 -1
- package/src/internal/compiling/{compile-directory → jsenv_directory}/fs-optimized-for-cache.js +0 -0
- package/src/internal/compiling/{compile-directory → jsenv_directory}/getOrGenerateCompiledFile.js +2 -2
- package/src/internal/compiling/jsenv_directory/jsenv_directory.js +174 -0
- package/src/internal/compiling/{compile-directory → jsenv_directory}/updateMeta.js +1 -1
- package/src/internal/compiling/{compile-directory → jsenv_directory}/validateCache.js +0 -0
- package/src/internal/compiling/sse_service/sse_service.js +369 -0
- package/src/internal/compiling/startCompileServer.js +157 -804
- package/src/internal/compiling/transformResultToCompilationResult.js +2 -2
- package/src/internal/dev_server/exploring/exploring.js +10 -8
- package/src/internal/dev_server/toolbar/compilation/toolbar.compilation.js +92 -78
- package/src/internal/dev_server/toolbar/settings/toolbar.settings.js +13 -0
- package/src/internal/dev_server/toolbar/toolbar.html +46 -16
- package/src/internal/dev_server/toolbar/toolbar.injector.js +17 -15
- package/src/internal/dev_server/toolbar/toolbar.main.js +12 -16
- package/src/internal/executing/executeConcurrently.js +1 -1
- package/src/internal/executing/executePlan.js +2 -3
- package/src/internal/{generateGroupMap → features}/babel_plugins_compatibility.js +8 -8
- package/src/internal/features/browser_feature_detection/browser_feature_detect_dynamic_import.js +20 -0
- package/src/internal/features/browser_feature_detection/browser_feature_detect_import_assertions_css.js +23 -0
- package/src/internal/features/browser_feature_detection/browser_feature_detect_import_assertions_json.js +25 -0
- package/src/internal/features/browser_feature_detection/browser_feature_detect_importmap.js +37 -0
- package/src/internal/features/browser_feature_detection/browser_feature_detect_new_stylesheet.js +9 -0
- package/src/internal/features/browser_feature_detection/browser_feature_detect_top_level_await.js +14 -0
- package/src/internal/features/browser_feature_detection/browser_feature_detection.js +89 -0
- package/src/internal/{browser_feature_detection → features/browser_feature_detection}/compile_proxy.html +1 -1
- package/src/internal/features/browser_feature_detection/execute_with_script_module.js +24 -0
- package/src/internal/features/features_compat_from_runtime.js +38 -0
- package/src/internal/features/features_compat_from_runtime_support.js +31 -0
- package/src/internal/{generateGroupMap → features}/features_compatibility.js +3 -3
- package/src/internal/{node_feature_detection → features/node_feature_detection}/feature_detect_dynamic_import.mjs +0 -0
- package/src/internal/{node_feature_detection → features/node_feature_detection}/feature_detect_top_level_await.mjs +0 -0
- package/src/internal/{node_feature_detection/nodeSupportsDynamicImport.js → features/node_feature_detection/node_feature_detect_dynamic_import.js} +0 -0
- package/src/internal/{node_feature_detection/nodeSupportsTopLevelAwait.js → features/node_feature_detection/node_feature_detect_top_level_await.js} +0 -0
- package/src/internal/features/node_feature_detection/node_feature_detection.js +66 -0
- package/src/internal/jsenv_remote_directory.js +1 -1
- package/src/internal/node_launcher/createControllableNodeProcess.js +4 -3
- package/src/internal/node_launcher/node_runtime_report.js +15 -9
- package/src/internal/node_runtime/fetchSource.js +2 -4
- package/src/internal/node_runtime/node_execution_systemjs.js +2 -5
- package/src/internal/redirector/redirector.html +40 -0
- package/src/internal/{generateGroupMap/jsenvRuntimeSupport.js → runtime_support/jsenv_runtime_support.js} +0 -0
- package/src/internal/{generateGroupMap → runtime_support}/runtime_support.js +0 -0
- package/src/internal/url_conversion.js +12 -17
- package/src/launchNode.js +29 -41
- package/dist/compile_proxy/compile_proxy.html__inline__20_809f35f7.js.map +0 -392
- package/dist/redirector/redirector.html__inline__15_e391410e.js.map +0 -397
- package/dist/toolbar/toolbar.main_6c1b3d82.js.map +0 -802
- package/src/internal/CONSTANTS.js +0 -11
- package/src/internal/browser_feature_detection/browser_feature_detection.js +0 -274
- package/src/internal/compiling/js-compilation-service/jsenvTransform.js +0 -242
- package/src/internal/dev_server/redirector/redirector.html +0 -48
- package/src/internal/generateGroupMap/generateGroupMap.js +0 -65
- package/src/internal/generateGroupMap/one_runtime_compat.js +0 -38
- package/src/internal/generateGroupMap/runtime_compat.js +0 -34
- package/src/internal/generateGroupMap/runtime_compat_composition.js +0 -76
- package/src/internal/generateGroupMap/shake_babel_plugin_map.js +0 -21
- package/src/internal/integrity/integrity_algorithms.js +0 -26
- package/src/internal/integrity/integrity_parsing.js +0 -50
- package/src/internal/integrity/integrity_update.js +0 -23
- package/src/internal/integrity/integrity_validation.js +0 -49
- package/src/internal/node_feature_detection/node_feature_detection.js +0 -117
- package/src/internal/node_runtime/detectNode.js +0 -3
- package/src/internal/runtime/computeCompileIdFromGroupId.js +0 -30
- package/src/internal/runtime/resolveGroup.js +0 -13
- package/src/internal/runtime/resolveRuntimeGroup.js +0 -11
package/src/buildProject.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { createLogger, createDetailedMessage } from "@jsenv/logger"
|
|
2
1
|
import { resolveDirectoryUrl } from "@jsenv/filesystem"
|
|
2
|
+
import { createLogger, createDetailedMessage } from "@jsenv/logger"
|
|
3
3
|
import { Abort, raceProcessTeardownEvents } from "@jsenv/abort"
|
|
4
4
|
|
|
5
|
-
import { shakeBabelPluginMap } from "@jsenv/core/src/internal/generateGroupMap/shake_babel_plugin_map.js"
|
|
6
|
-
import { COMPILE_ID_BEST } from "@jsenv/core/src/internal/CONSTANTS.js"
|
|
7
5
|
import {
|
|
8
6
|
assertProjectDirectoryUrl,
|
|
9
7
|
assertProjectDirectoryExists,
|
|
@@ -13,7 +11,11 @@ import { buildUsingRollup } from "@jsenv/core/src/internal/building/buildUsingRo
|
|
|
13
11
|
import {
|
|
14
12
|
jsenvBrowserRuntimeSupport,
|
|
15
13
|
jsenvNodeRuntimeSupport,
|
|
16
|
-
} from "@jsenv/core/src/internal/
|
|
14
|
+
} from "@jsenv/core/src/internal/runtime_support/jsenv_runtime_support.js"
|
|
15
|
+
import {
|
|
16
|
+
isNodePartOfSupportedRuntimes,
|
|
17
|
+
isBrowserPartOfSupportedRuntimes,
|
|
18
|
+
} from "@jsenv/core/src/internal/runtime_support/runtime_support.js"
|
|
17
19
|
|
|
18
20
|
/**
|
|
19
21
|
* Generate optimized version of source files into a directory
|
|
@@ -126,19 +128,15 @@ export const buildProject = async ({
|
|
|
126
128
|
`format must be "systemjs" when importMapInWebWorkers is enabled`,
|
|
127
129
|
)
|
|
128
130
|
}
|
|
129
|
-
|
|
130
131
|
projectDirectoryUrl = assertProjectDirectoryUrl({ projectDirectoryUrl })
|
|
131
132
|
await assertProjectDirectoryExists({ projectDirectoryUrl })
|
|
132
|
-
|
|
133
|
-
assertentryPoints({ entryPoints })
|
|
134
|
-
|
|
133
|
+
assertEntryPoints({ entryPoints })
|
|
135
134
|
if (Object.keys(entryPoints).length === 0) {
|
|
136
135
|
logger.error(`entryPoints is an empty object`)
|
|
137
136
|
return {
|
|
138
137
|
rollupBuilds: {},
|
|
139
138
|
}
|
|
140
139
|
}
|
|
141
|
-
|
|
142
140
|
assertBuildDirectoryRelativeUrl({ buildDirectoryRelativeUrl })
|
|
143
141
|
const buildDirectoryUrl = resolveDirectoryUrl(
|
|
144
142
|
buildDirectoryRelativeUrl,
|
|
@@ -151,7 +149,6 @@ export const buildProject = async ({
|
|
|
151
149
|
|
|
152
150
|
const buildOperation = Abort.startOperation()
|
|
153
151
|
buildOperation.addAbortSignal(signal)
|
|
154
|
-
|
|
155
152
|
if (handleSIGINT) {
|
|
156
153
|
buildOperation.addAbortSource((abort) => {
|
|
157
154
|
return raceProcessTeardownEvents(
|
|
@@ -162,7 +159,6 @@ export const buildProject = async ({
|
|
|
162
159
|
)
|
|
163
160
|
})
|
|
164
161
|
}
|
|
165
|
-
|
|
166
162
|
const compileServer = await startCompileServer({
|
|
167
163
|
signal: buildOperation.signal,
|
|
168
164
|
logLevel: compileServerLogLevel,
|
|
@@ -210,12 +206,26 @@ export const buildProject = async ({
|
|
|
210
206
|
compileServerCanReadFromFilesystem: filesystemCache,
|
|
211
207
|
compileServerCanWriteOnFilesystem: filesystemCache,
|
|
212
208
|
})
|
|
213
|
-
|
|
214
209
|
buildOperation.addEndCallback(async () => {
|
|
215
210
|
await compileServer.stop(`build cleanup`)
|
|
216
211
|
})
|
|
217
|
-
|
|
218
|
-
const
|
|
212
|
+
const node = isNodePartOfSupportedRuntimes(runtimeSupport)
|
|
213
|
+
const browser = isBrowserPartOfSupportedRuntimes(runtimeSupport)
|
|
214
|
+
const { compileId, compileProfile } =
|
|
215
|
+
await compileServer.createCompileIdFromRuntimeReport({
|
|
216
|
+
env: {
|
|
217
|
+
browser,
|
|
218
|
+
node,
|
|
219
|
+
},
|
|
220
|
+
name: "jsenv_build",
|
|
221
|
+
version: "1",
|
|
222
|
+
runtimeSupport,
|
|
223
|
+
// "rollup_plugin_jsenv.js" expects to hit the compile server
|
|
224
|
+
// so we force compilation by adding a fake feature called "force_compilation"
|
|
225
|
+
// one day we'll test how code behaves if zero transformations is required during
|
|
226
|
+
// the build and update code as needed
|
|
227
|
+
forceCompilation: true,
|
|
228
|
+
})
|
|
219
229
|
|
|
220
230
|
try {
|
|
221
231
|
const result = await buildUsingRollup({
|
|
@@ -224,9 +234,6 @@ export const buildProject = async ({
|
|
|
224
234
|
|
|
225
235
|
entryPoints,
|
|
226
236
|
projectDirectoryUrl,
|
|
227
|
-
compileServerOrigin,
|
|
228
|
-
compileDirectoryRelativeUrl: `${outDirectoryRelativeUrl}${COMPILE_ID_BEST}/`,
|
|
229
|
-
jsenvDirectoryRelativeUrl: compileServer.jsenvDirectoryRelativeUrl,
|
|
230
237
|
buildDirectoryUrl,
|
|
231
238
|
buildDirectoryClean,
|
|
232
239
|
assetManifestFile,
|
|
@@ -244,19 +251,17 @@ export const buildProject = async ({
|
|
|
244
251
|
systemJsUrl,
|
|
245
252
|
globalName,
|
|
246
253
|
globals,
|
|
247
|
-
babelPluginMap: shakeBabelPluginMap({
|
|
248
|
-
babelPluginMap: compileServer.babelPluginMap,
|
|
249
|
-
missingFeatureNames:
|
|
250
|
-
compileServer.compileServerGroupMap[COMPILE_ID_BEST]
|
|
251
|
-
.missingFeatureNames,
|
|
252
|
-
}),
|
|
253
|
-
runtimeSupport,
|
|
254
254
|
workers,
|
|
255
255
|
serviceWorkers,
|
|
256
256
|
serviceWorkerFinalizer,
|
|
257
257
|
classicWorkers,
|
|
258
258
|
classicServiceWorkers,
|
|
259
|
-
|
|
259
|
+
|
|
260
|
+
node,
|
|
261
|
+
browser,
|
|
262
|
+
compileServer,
|
|
263
|
+
compileProfile,
|
|
264
|
+
compileId,
|
|
260
265
|
|
|
261
266
|
urlVersioning,
|
|
262
267
|
lineBreakNormalization,
|
|
@@ -287,7 +292,7 @@ export const buildProject = async ({
|
|
|
287
292
|
}
|
|
288
293
|
}
|
|
289
294
|
|
|
290
|
-
const
|
|
295
|
+
const assertEntryPoints = ({ entryPoints }) => {
|
|
291
296
|
if (typeof entryPoints !== "object") {
|
|
292
297
|
throw new TypeError(`entryPoints must be an object, got ${entryPoints}`)
|
|
293
298
|
}
|
package/src/dev_server.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import { setupRoutes } from "@jsenv/server"
|
|
1
2
|
import {
|
|
2
3
|
normalizeStructuredMetaMap,
|
|
3
4
|
collectFiles,
|
|
4
5
|
urlToRelativeUrl,
|
|
5
6
|
} from "@jsenv/filesystem"
|
|
6
|
-
import { setupRoutes } from "@jsenv/server"
|
|
7
7
|
|
|
8
8
|
import { REDIRECTOR_BUILD_URL } from "@jsenv/core/dist/build_manifest.js"
|
|
9
|
+
import { setUrlSearchParamsDescriptor } from "@jsenv/core/src/internal/url_utils.js"
|
|
9
10
|
import { jsenvCoreDirectoryUrl } from "./internal/jsenvCoreDirectoryUrl.js"
|
|
10
11
|
import {
|
|
11
12
|
assertProjectDirectoryUrl,
|
|
@@ -13,14 +14,13 @@ import {
|
|
|
13
14
|
} from "./internal/argUtils.js"
|
|
14
15
|
import {
|
|
15
16
|
startCompileServer,
|
|
16
|
-
|
|
17
|
+
assertAndNormalizeJsenvDirectoryRelativeUrl,
|
|
17
18
|
} from "./internal/compiling/startCompileServer.js"
|
|
18
|
-
import { jsenvExplorableConfig } from "./jsenvExplorableConfig.js"
|
|
19
|
-
|
|
20
19
|
import {
|
|
21
20
|
sourcemapMainFileInfo,
|
|
22
21
|
sourcemapMappingFileInfo,
|
|
23
22
|
} from "./internal/jsenvInternalFiles.js"
|
|
23
|
+
import { jsenvExplorableConfig } from "./jsenvExplorableConfig.js"
|
|
24
24
|
|
|
25
25
|
export const startDevServer = async ({
|
|
26
26
|
signal = new AbortController().signal,
|
|
@@ -28,7 +28,7 @@ export const startDevServer = async ({
|
|
|
28
28
|
port,
|
|
29
29
|
ip,
|
|
30
30
|
protocol,
|
|
31
|
-
http2,
|
|
31
|
+
http2 = false, // disable by default for now because it is buggy on safari
|
|
32
32
|
certificate,
|
|
33
33
|
privateKey,
|
|
34
34
|
plugins,
|
|
@@ -38,7 +38,6 @@ export const startDevServer = async ({
|
|
|
38
38
|
explorableConfig = jsenvExplorableConfig,
|
|
39
39
|
mainFileRelativeUrl,
|
|
40
40
|
jsenvDirectoryRelativeUrl,
|
|
41
|
-
outDirectoryName = "dev",
|
|
42
41
|
jsenvToolbar = true,
|
|
43
42
|
livereloading = true,
|
|
44
43
|
inlineImportMapIntoHTML = true,
|
|
@@ -66,7 +65,6 @@ export const startDevServer = async ({
|
|
|
66
65
|
}) => {
|
|
67
66
|
projectDirectoryUrl = assertProjectDirectoryUrl({ projectDirectoryUrl })
|
|
68
67
|
await assertProjectDirectoryExists({ projectDirectoryUrl })
|
|
69
|
-
|
|
70
68
|
if (mainFileRelativeUrl === undefined) {
|
|
71
69
|
mainFileRelativeUrl = urlToRelativeUrl(
|
|
72
70
|
new URL(
|
|
@@ -76,13 +74,10 @@ export const startDevServer = async ({
|
|
|
76
74
|
projectDirectoryUrl,
|
|
77
75
|
)
|
|
78
76
|
}
|
|
79
|
-
|
|
80
|
-
const outDirectoryRelativeUrl = computeOutDirectoryRelativeUrl({
|
|
77
|
+
jsenvDirectoryRelativeUrl = assertAndNormalizeJsenvDirectoryRelativeUrl({
|
|
81
78
|
projectDirectoryUrl,
|
|
82
79
|
jsenvDirectoryRelativeUrl,
|
|
83
|
-
outDirectoryName,
|
|
84
80
|
})
|
|
85
|
-
|
|
86
81
|
const compileServer = await startCompileServer({
|
|
87
82
|
signal,
|
|
88
83
|
handleSIGINT,
|
|
@@ -103,14 +98,14 @@ export const startDevServer = async ({
|
|
|
103
98
|
}),
|
|
104
99
|
"jsenv:exploring_json": createExploringJsonService({
|
|
105
100
|
projectDirectoryUrl,
|
|
106
|
-
|
|
101
|
+
jsenvDirectoryRelativeUrl,
|
|
107
102
|
mainFileRelativeUrl,
|
|
108
103
|
explorableConfig,
|
|
109
104
|
livereloading,
|
|
110
105
|
}),
|
|
111
106
|
"jsenv:explorables_json": createExplorableJsonService({
|
|
112
107
|
projectDirectoryUrl,
|
|
113
|
-
|
|
108
|
+
jsenvDirectoryRelativeUrl,
|
|
114
109
|
explorableConfig,
|
|
115
110
|
}),
|
|
116
111
|
},
|
|
@@ -120,7 +115,6 @@ export const startDevServer = async ({
|
|
|
120
115
|
jsenvEventSourceClientInjection: true,
|
|
121
116
|
jsenvToolbarInjection: jsenvToolbar,
|
|
122
117
|
jsenvDirectoryRelativeUrl,
|
|
123
|
-
outDirectoryName,
|
|
124
118
|
inlineImportMapIntoHTML,
|
|
125
119
|
|
|
126
120
|
compileServerCanReadFromFilesystem,
|
|
@@ -155,20 +149,45 @@ const createRedirectorService = async ({
|
|
|
155
149
|
return {
|
|
156
150
|
status: 307,
|
|
157
151
|
headers: {
|
|
158
|
-
location:
|
|
152
|
+
location: setUrlSearchParamsDescriptor(
|
|
153
|
+
`${request.origin}/${redirectorRelativeUrlForProject}`,
|
|
154
|
+
{
|
|
155
|
+
redirect: redirectTarget,
|
|
156
|
+
},
|
|
157
|
+
),
|
|
159
158
|
},
|
|
160
159
|
}
|
|
161
160
|
},
|
|
161
|
+
// compile server (compiled file service to be precised)
|
|
162
|
+
// is already implementing this redirection when a compile id do not exists
|
|
163
|
+
// and "redirect" is not a valid compile id
|
|
164
|
+
// That being said I prefer to keep it to be explicit and shortcircuit the logic
|
|
162
165
|
"/.jsenv/redirect/:rest*": (request) => {
|
|
163
166
|
const redirectTarget = request.ressource.slice("/.jsenv/redirect/".length)
|
|
164
167
|
return {
|
|
165
168
|
status: 307,
|
|
166
169
|
headers: {
|
|
167
|
-
location:
|
|
168
|
-
request.origin
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
170
|
+
location: setUrlSearchParamsDescriptor(
|
|
171
|
+
`${request.origin}/${redirectorRelativeUrlForProject}`,
|
|
172
|
+
{
|
|
173
|
+
redirect: redirectTarget,
|
|
174
|
+
},
|
|
175
|
+
),
|
|
176
|
+
},
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
"/.jsenv/force/:rest*": (request) => {
|
|
180
|
+
const redirectTarget = request.ressource.slice("/.jsenv/force/".length)
|
|
181
|
+
return {
|
|
182
|
+
status: 307,
|
|
183
|
+
headers: {
|
|
184
|
+
location: setUrlSearchParamsDescriptor(
|
|
185
|
+
`${request.origin}/${redirectorRelativeUrlForProject}`,
|
|
186
|
+
{
|
|
187
|
+
redirect: redirectTarget,
|
|
188
|
+
force_compilation: 1,
|
|
189
|
+
},
|
|
190
|
+
),
|
|
172
191
|
},
|
|
173
192
|
}
|
|
174
193
|
},
|
|
@@ -177,98 +196,98 @@ const createRedirectorService = async ({
|
|
|
177
196
|
|
|
178
197
|
const createExploringJsonService = ({
|
|
179
198
|
projectDirectoryUrl,
|
|
180
|
-
|
|
199
|
+
jsenvDirectoryRelativeUrl,
|
|
181
200
|
explorableConfig,
|
|
182
201
|
livereloading,
|
|
183
202
|
mainFileRelativeUrl,
|
|
184
203
|
}) => {
|
|
185
204
|
return (request) => {
|
|
186
205
|
if (
|
|
187
|
-
request.ressource
|
|
188
|
-
request.method
|
|
206
|
+
request.ressource !== "/.jsenv/exploring.json" ||
|
|
207
|
+
request.method !== "GET"
|
|
189
208
|
) {
|
|
190
|
-
|
|
209
|
+
return null
|
|
210
|
+
}
|
|
211
|
+
const data = {
|
|
212
|
+
projectDirectoryUrl,
|
|
213
|
+
jsenvDirectoryRelativeUrl,
|
|
214
|
+
jsenvCoreDirectoryRelativeUrl: urlToRelativeUrl(
|
|
215
|
+
jsenvCoreDirectoryUrl,
|
|
191
216
|
projectDirectoryUrl,
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
"content-type": "application/json",
|
|
215
|
-
"content-length": Buffer.byteLength(json),
|
|
216
|
-
},
|
|
217
|
-
body: json,
|
|
218
|
-
}
|
|
217
|
+
),
|
|
218
|
+
exploringHtmlFileRelativeUrl: mainFileRelativeUrl,
|
|
219
|
+
sourcemapMainFileRelativeUrl: urlToRelativeUrl(
|
|
220
|
+
sourcemapMainFileInfo.url,
|
|
221
|
+
jsenvCoreDirectoryUrl,
|
|
222
|
+
),
|
|
223
|
+
sourcemapMappingFileRelativeUrl: urlToRelativeUrl(
|
|
224
|
+
sourcemapMappingFileInfo.url,
|
|
225
|
+
jsenvCoreDirectoryUrl,
|
|
226
|
+
),
|
|
227
|
+
explorableConfig,
|
|
228
|
+
livereloading,
|
|
229
|
+
}
|
|
230
|
+
const json = JSON.stringify(data)
|
|
231
|
+
return {
|
|
232
|
+
status: 200,
|
|
233
|
+
headers: {
|
|
234
|
+
"cache-control": "no-store",
|
|
235
|
+
"content-type": "application/json",
|
|
236
|
+
"content-length": Buffer.byteLength(json),
|
|
237
|
+
},
|
|
238
|
+
body: json,
|
|
219
239
|
}
|
|
220
|
-
return null
|
|
221
240
|
}
|
|
222
241
|
}
|
|
223
242
|
|
|
224
243
|
const createExplorableJsonService = ({
|
|
225
244
|
projectDirectoryUrl,
|
|
226
|
-
|
|
245
|
+
jsenvDirectoryRelativeUrl,
|
|
227
246
|
explorableConfig,
|
|
228
247
|
}) => {
|
|
229
248
|
return async (request) => {
|
|
230
249
|
if (
|
|
231
|
-
request.ressource
|
|
232
|
-
request.method
|
|
250
|
+
request.ressource !== "/.jsenv/explorables.json" ||
|
|
251
|
+
request.method !== "GET"
|
|
233
252
|
) {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
const structuredMetaMapForExplorable = normalizeStructuredMetaMap(
|
|
244
|
-
structuredMetaMapRelativeForExplorable,
|
|
245
|
-
projectDirectoryUrl,
|
|
246
|
-
)
|
|
247
|
-
const matchingFileResultArray = await collectFiles({
|
|
248
|
-
directoryUrl: projectDirectoryUrl,
|
|
249
|
-
structuredMetaMap: structuredMetaMapForExplorable,
|
|
250
|
-
predicate: (meta) =>
|
|
251
|
-
Object.keys(meta).some((explorableGroup) =>
|
|
252
|
-
Boolean(meta[explorableGroup]),
|
|
253
|
-
),
|
|
254
|
-
})
|
|
255
|
-
const explorableFiles = matchingFileResultArray.map(
|
|
256
|
-
({ relativeUrl, meta }) => ({
|
|
257
|
-
relativeUrl,
|
|
258
|
-
meta,
|
|
259
|
-
}),
|
|
260
|
-
)
|
|
261
|
-
const json = JSON.stringify(explorableFiles)
|
|
262
|
-
return {
|
|
263
|
-
status: 200,
|
|
264
|
-
headers: {
|
|
265
|
-
"cache-control": "no-store",
|
|
266
|
-
"content-type": "application/json",
|
|
267
|
-
"content-length": Buffer.byteLength(json),
|
|
268
|
-
},
|
|
269
|
-
body: json,
|
|
253
|
+
return null
|
|
254
|
+
}
|
|
255
|
+
const structuredMetaMapRelativeForExplorable = {}
|
|
256
|
+
Object.keys(explorableConfig).forEach((explorableGroup) => {
|
|
257
|
+
const explorableGroupConfig = explorableConfig[explorableGroup]
|
|
258
|
+
structuredMetaMapRelativeForExplorable[explorableGroup] = {
|
|
259
|
+
"**/.jsenv/": false, // temporary (in theory) to avoid visting .jsenv directory in jsenv itself
|
|
260
|
+
...explorableGroupConfig,
|
|
261
|
+
[jsenvDirectoryRelativeUrl]: false,
|
|
270
262
|
}
|
|
263
|
+
})
|
|
264
|
+
const structuredMetaMapForExplorable = normalizeStructuredMetaMap(
|
|
265
|
+
structuredMetaMapRelativeForExplorable,
|
|
266
|
+
projectDirectoryUrl,
|
|
267
|
+
)
|
|
268
|
+
const matchingFileResultArray = await collectFiles({
|
|
269
|
+
directoryUrl: projectDirectoryUrl,
|
|
270
|
+
structuredMetaMap: structuredMetaMapForExplorable,
|
|
271
|
+
predicate: (meta) =>
|
|
272
|
+
Object.keys(meta).some((explorableGroup) =>
|
|
273
|
+
Boolean(meta[explorableGroup]),
|
|
274
|
+
),
|
|
275
|
+
})
|
|
276
|
+
const explorableFiles = matchingFileResultArray.map(
|
|
277
|
+
({ relativeUrl, meta }) => ({
|
|
278
|
+
relativeUrl,
|
|
279
|
+
meta,
|
|
280
|
+
}),
|
|
281
|
+
)
|
|
282
|
+
const json = JSON.stringify(explorableFiles)
|
|
283
|
+
return {
|
|
284
|
+
status: 200,
|
|
285
|
+
headers: {
|
|
286
|
+
"cache-control": "no-store",
|
|
287
|
+
"content-type": "application/json",
|
|
288
|
+
"content-length": Buffer.byteLength(json),
|
|
289
|
+
},
|
|
290
|
+
body: json,
|
|
271
291
|
}
|
|
272
|
-
return null
|
|
273
292
|
}
|
|
274
293
|
}
|
package/src/execute.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Abort, raceProcessTeardownEvents } from "@jsenv/abort"
|
|
2
2
|
|
|
3
|
-
import { normalizeRuntimeSupport } from "@jsenv/core/src/internal/
|
|
3
|
+
import { normalizeRuntimeSupport } from "@jsenv/core/src/internal/runtime_support/runtime_support.js"
|
|
4
4
|
import {
|
|
5
5
|
assertProjectDirectoryUrl,
|
|
6
6
|
assertProjectDirectoryExists,
|
|
@@ -61,14 +61,12 @@ export const execute = async ({
|
|
|
61
61
|
}) => {
|
|
62
62
|
projectDirectoryUrl = assertProjectDirectoryUrl({ projectDirectoryUrl })
|
|
63
63
|
await assertProjectDirectoryExists({ projectDirectoryUrl })
|
|
64
|
-
|
|
65
64
|
if (typeof fileRelativeUrl !== "string") {
|
|
66
65
|
throw new TypeError(
|
|
67
66
|
`fileRelativeUrl must be a string, got ${fileRelativeUrl}`,
|
|
68
67
|
)
|
|
69
68
|
}
|
|
70
69
|
fileRelativeUrl = fileRelativeUrl.replace(/\\/g, "/")
|
|
71
|
-
|
|
72
70
|
if (typeof runtime !== "object") {
|
|
73
71
|
throw new TypeError(`runtime must be an object, got ${runtime}`)
|
|
74
72
|
}
|
|
@@ -77,7 +75,6 @@ export const execute = async ({
|
|
|
77
75
|
`runtime.launch must be a function, got ${runtime.launch}`,
|
|
78
76
|
)
|
|
79
77
|
}
|
|
80
|
-
|
|
81
78
|
const executeOperation = Abort.startOperation()
|
|
82
79
|
executeOperation.addAbortSignal(signal)
|
|
83
80
|
if (handleSIGINT) {
|
|
@@ -90,7 +87,6 @@ export const execute = async ({
|
|
|
90
87
|
)
|
|
91
88
|
})
|
|
92
89
|
}
|
|
93
|
-
|
|
94
90
|
try {
|
|
95
91
|
const compileServer = await startCompileServer({
|
|
96
92
|
signal: executeOperation.signal,
|
|
@@ -99,7 +95,6 @@ export const execute = async ({
|
|
|
99
95
|
projectDirectoryUrl,
|
|
100
96
|
jsenvDirectoryRelativeUrl,
|
|
101
97
|
jsenvDirectoryClean,
|
|
102
|
-
outDirectoryName: "dev",
|
|
103
98
|
|
|
104
99
|
importDefaultExtension,
|
|
105
100
|
|
|
@@ -133,7 +128,7 @@ export const execute = async ({
|
|
|
133
128
|
projectDirectoryUrl,
|
|
134
129
|
compileServerOrigin: compileServer.origin,
|
|
135
130
|
compileServerId: compileServer.id,
|
|
136
|
-
|
|
131
|
+
jsenvDirectoryRelativeUrl: compileServer.jsenvDirectoryRelativeUrl,
|
|
137
132
|
...runtimeParams,
|
|
138
133
|
},
|
|
139
134
|
executeParams: {
|
|
@@ -161,7 +156,7 @@ export const execute = async ({
|
|
|
161
156
|
|
|
162
157
|
if (collectCompileServerInfo) {
|
|
163
158
|
result.compileServerOrigin = compileServer.origin
|
|
164
|
-
result.
|
|
159
|
+
result.jsenvDirectoryRelativeUrl = compileServer.jsenvDirectoryRelativeUrl
|
|
165
160
|
}
|
|
166
161
|
|
|
167
162
|
if (result.status === "errored") {
|
package/src/internal/browser_launcher/{browser_runtime_report.js → browser_runtime_profile.js}
RENAMED
|
@@ -1,34 +1,39 @@
|
|
|
1
|
-
export const
|
|
1
|
+
export const getBrowserRuntimeProfile = async ({
|
|
2
2
|
page,
|
|
3
|
-
coverageHandledFromOutside,
|
|
4
3
|
runtime,
|
|
5
4
|
compileServerId,
|
|
5
|
+
coverageHandledFromOutside,
|
|
6
|
+
forceSource,
|
|
7
|
+
forceCompilation,
|
|
6
8
|
}) => {
|
|
7
9
|
const cache = cacheFromParams({
|
|
8
10
|
runtime,
|
|
9
11
|
compileServerId,
|
|
10
12
|
coverageHandledFromOutside,
|
|
13
|
+
forceSource,
|
|
14
|
+
forceCompilation,
|
|
11
15
|
})
|
|
12
16
|
const entry = cache.read()
|
|
13
17
|
if (entry) {
|
|
14
18
|
return entry
|
|
15
19
|
}
|
|
16
|
-
const
|
|
20
|
+
const browserRuntimeProfile = await page.evaluate(
|
|
21
|
+
/* eslint-disable no-undef */
|
|
17
22
|
/* istanbul ignore next */
|
|
18
|
-
async ({ coverageHandledFromOutside }) => {
|
|
19
|
-
// eslint-disable-next-line no-undef
|
|
23
|
+
async ({ coverageHandledFromOutside, forceSource, forceCompilation }) => {
|
|
20
24
|
await window.readyPromise
|
|
21
|
-
|
|
22
|
-
// eslint-disable-next-line no-undef
|
|
23
|
-
return window.scanBrowserRuntimeFeatures({
|
|
25
|
+
const runtimeProfile = await window.scanBrowserRuntimeFeatures({
|
|
24
26
|
coverageHandledFromOutside,
|
|
25
|
-
|
|
27
|
+
forceSource,
|
|
28
|
+
forceCompilation,
|
|
26
29
|
})
|
|
30
|
+
return runtimeProfile
|
|
27
31
|
},
|
|
28
|
-
|
|
32
|
+
/* eslint-enable no-undef */
|
|
33
|
+
{ coverageHandledFromOutside, forceSource, forceCompilation },
|
|
29
34
|
)
|
|
30
|
-
cache.write(
|
|
31
|
-
return
|
|
35
|
+
cache.write(browserRuntimeProfile)
|
|
36
|
+
return browserRuntimeProfile
|
|
32
37
|
}
|
|
33
38
|
|
|
34
39
|
let currentCacheParams
|
|
@@ -37,13 +42,16 @@ const cacheFromParams = ({
|
|
|
37
42
|
runtime,
|
|
38
43
|
compileServerId,
|
|
39
44
|
coverageHandledFromOutside,
|
|
45
|
+
forceSource,
|
|
46
|
+
forceCompilation,
|
|
40
47
|
}) => {
|
|
41
48
|
const params = {
|
|
42
49
|
compileServerId,
|
|
43
50
|
coverageHandledFromOutside,
|
|
51
|
+
forceSource,
|
|
52
|
+
forceCompilation,
|
|
44
53
|
}
|
|
45
54
|
const runtimeLabel = `${runtime.name}/${runtime.version}`
|
|
46
|
-
|
|
47
55
|
if (!currentCacheParams) {
|
|
48
56
|
currentCacheParams = params
|
|
49
57
|
currentCacheValue = {}
|
|
@@ -54,7 +62,6 @@ const cacheFromParams = ({
|
|
|
54
62
|
},
|
|
55
63
|
}
|
|
56
64
|
}
|
|
57
|
-
|
|
58
65
|
if (JSON.stringify(currentCacheParams) !== JSON.stringify(params)) {
|
|
59
66
|
return {
|
|
60
67
|
read: () => null,
|
|
@@ -65,7 +72,6 @@ const cacheFromParams = ({
|
|
|
65
72
|
},
|
|
66
73
|
}
|
|
67
74
|
}
|
|
68
|
-
|
|
69
75
|
return {
|
|
70
76
|
read: () => currentCacheValue[runtimeLabel],
|
|
71
77
|
write: (value) => {
|