@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.
Files changed (112) hide show
  1. package/dist/browser_runtime/asset-manifest.json +2 -2
  2. package/dist/browser_runtime/{browser_runtime_91c5a3b8.js → browser_runtime_0e3396a1.js} +15 -16
  3. package/dist/browser_runtime/{browser_runtime_91c5a3b8.js.map → browser_runtime_0e3396a1.js.map} +13 -13
  4. package/dist/build_manifest.js +5 -5
  5. package/dist/compile_proxy/asset-manifest.json +2 -2
  6. package/dist/compile_proxy/compile_proxy.html__inline__20_f4285042.js.map +343 -0
  7. package/dist/compile_proxy/{compile_proxy_8dfaee51.html → compile_proxy_ab528227.html} +358 -397
  8. package/dist/redirector/asset-manifest.json +2 -2
  9. package/dist/redirector/redirector.html__inline__12_404b8295.js.map +349 -0
  10. package/dist/redirector/{redirector_3e9a97b9.html → redirector_6df2620a.html} +369 -407
  11. package/dist/toolbar/asset-manifest.json +2 -2
  12. package/dist/toolbar/toolbar.main_279b3a68.js.map +764 -0
  13. package/dist/toolbar/{toolbar_361afb84.html → toolbar_0a91ca3b.html} +1509 -1583
  14. package/dist/toolbar_injector/asset-manifest.json +2 -2
  15. package/dist/toolbar_injector/{toolbar_injector_fac1e995.js → toolbar_injector_34f6ad8e.js} +18 -15
  16. package/dist/toolbar_injector/{toolbar_injector_fac1e995.js.map → toolbar_injector_34f6ad8e.js.map} +15 -15
  17. package/package.json +16 -12
  18. package/readme.md +54 -54
  19. package/src/buildProject.js +31 -26
  20. package/src/dev_server.js +111 -92
  21. package/src/execute.js +3 -8
  22. package/src/internal/browser_launcher/{browser_runtime_report.js → browser_runtime_profile.js} +21 -15
  23. package/src/internal/browser_launcher/executeHtmlFile.js +22 -14
  24. package/src/internal/browser_launcher/from_playwright.js +6 -4
  25. package/src/internal/browser_runtime/browser_runtime.js +12 -14
  26. package/src/internal/browser_runtime/createBrowserRuntime.js +7 -6
  27. package/src/internal/browser_utils/fetchAndEvalUsingFetch.js +1 -1
  28. package/src/internal/browser_utils/fetchJson.js +1 -1
  29. package/src/internal/browser_utils/{fetch-browser.js → fetch_browser.js} +0 -2
  30. package/src/internal/building/buildUsingRollup.js +41 -57
  31. package/src/internal/building/html/parseHtmlRessource.js +2 -1
  32. package/src/internal/building/rollup_plugin_jsenv.js +28 -8
  33. package/src/internal/compiling/babel_parse_error.js +9 -0
  34. package/src/internal/{babel_plugin_transform_import_meta.js → compiling/babel_plugin_transform_import_meta.js} +58 -9
  35. package/src/internal/compiling/compileFile.js +2 -2
  36. package/src/internal/compiling/compileHtml.js +1 -1
  37. package/src/internal/compiling/createCompiledFileService.js +25 -74
  38. package/src/internal/compiling/js-compilation-service/transformJs.js +153 -23
  39. package/src/internal/compiling/jsenvCompilerForHtml.js +29 -32
  40. package/src/internal/compiling/jsenvCompilerForImportmap.js +2 -2
  41. package/src/internal/compiling/jsenvCompilerForJavaScript.js +2 -4
  42. package/src/internal/compiling/jsenv_directory/comparison_utils.js +24 -0
  43. package/src/internal/compiling/{compile-directory/compile-asset.js → jsenv_directory/compile_asset.js} +0 -0
  44. package/src/internal/compiling/jsenv_directory/compile_context.js +68 -0
  45. package/src/internal/compiling/jsenv_directory/compile_profile.js +218 -0
  46. package/src/internal/compiling/{compile-directory/createLockRegistry.js → jsenv_directory/file_lock_registry.js} +0 -0
  47. package/src/internal/compiling/{compile-directory/createLockRegistry.test.js → jsenv_directory/file_lock_registry.test.js} +2 -1
  48. package/src/internal/compiling/{compile-directory → jsenv_directory}/fs-optimized-for-cache.js +0 -0
  49. package/src/internal/compiling/{compile-directory → jsenv_directory}/getOrGenerateCompiledFile.js +2 -2
  50. package/src/internal/compiling/jsenv_directory/jsenv_directory.js +174 -0
  51. package/src/internal/compiling/{compile-directory → jsenv_directory}/updateMeta.js +1 -1
  52. package/src/internal/compiling/{compile-directory → jsenv_directory}/validateCache.js +0 -0
  53. package/src/internal/compiling/sse_service/sse_service.js +369 -0
  54. package/src/internal/compiling/startCompileServer.js +157 -804
  55. package/src/internal/compiling/transformResultToCompilationResult.js +2 -2
  56. package/src/internal/dev_server/exploring/exploring.js +10 -8
  57. package/src/internal/dev_server/toolbar/compilation/toolbar.compilation.js +92 -78
  58. package/src/internal/dev_server/toolbar/settings/toolbar.settings.js +13 -0
  59. package/src/internal/dev_server/toolbar/toolbar.html +46 -16
  60. package/src/internal/dev_server/toolbar/toolbar.injector.js +17 -15
  61. package/src/internal/dev_server/toolbar/toolbar.main.js +12 -16
  62. package/src/internal/executing/executeConcurrently.js +1 -1
  63. package/src/internal/executing/executePlan.js +2 -3
  64. package/src/internal/{generateGroupMap → features}/babel_plugins_compatibility.js +8 -8
  65. package/src/internal/features/browser_feature_detection/browser_feature_detect_dynamic_import.js +20 -0
  66. package/src/internal/features/browser_feature_detection/browser_feature_detect_import_assertions_css.js +23 -0
  67. package/src/internal/features/browser_feature_detection/browser_feature_detect_import_assertions_json.js +25 -0
  68. package/src/internal/features/browser_feature_detection/browser_feature_detect_importmap.js +37 -0
  69. package/src/internal/features/browser_feature_detection/browser_feature_detect_new_stylesheet.js +9 -0
  70. package/src/internal/features/browser_feature_detection/browser_feature_detect_top_level_await.js +14 -0
  71. package/src/internal/features/browser_feature_detection/browser_feature_detection.js +89 -0
  72. package/src/internal/{browser_feature_detection → features/browser_feature_detection}/compile_proxy.html +1 -1
  73. package/src/internal/features/browser_feature_detection/execute_with_script_module.js +24 -0
  74. package/src/internal/features/features_compat_from_runtime.js +38 -0
  75. package/src/internal/features/features_compat_from_runtime_support.js +31 -0
  76. package/src/internal/{generateGroupMap → features}/features_compatibility.js +3 -3
  77. package/src/internal/{node_feature_detection → features/node_feature_detection}/feature_detect_dynamic_import.mjs +0 -0
  78. package/src/internal/{node_feature_detection → features/node_feature_detection}/feature_detect_top_level_await.mjs +0 -0
  79. package/src/internal/{node_feature_detection/nodeSupportsDynamicImport.js → features/node_feature_detection/node_feature_detect_dynamic_import.js} +0 -0
  80. package/src/internal/{node_feature_detection/nodeSupportsTopLevelAwait.js → features/node_feature_detection/node_feature_detect_top_level_await.js} +0 -0
  81. package/src/internal/features/node_feature_detection/node_feature_detection.js +66 -0
  82. package/src/internal/jsenv_remote_directory.js +1 -1
  83. package/src/internal/node_launcher/createControllableNodeProcess.js +4 -3
  84. package/src/internal/node_launcher/node_runtime_report.js +15 -9
  85. package/src/internal/node_runtime/fetchSource.js +2 -4
  86. package/src/internal/node_runtime/node_execution_systemjs.js +2 -5
  87. package/src/internal/redirector/redirector.html +40 -0
  88. package/src/internal/{generateGroupMap/jsenvRuntimeSupport.js → runtime_support/jsenv_runtime_support.js} +0 -0
  89. package/src/internal/{generateGroupMap → runtime_support}/runtime_support.js +0 -0
  90. package/src/internal/url_conversion.js +12 -17
  91. package/src/launchNode.js +29 -41
  92. package/dist/compile_proxy/compile_proxy.html__inline__20_809f35f7.js.map +0 -392
  93. package/dist/redirector/redirector.html__inline__15_e391410e.js.map +0 -397
  94. package/dist/toolbar/toolbar.main_6c1b3d82.js.map +0 -802
  95. package/src/internal/CONSTANTS.js +0 -11
  96. package/src/internal/browser_feature_detection/browser_feature_detection.js +0 -274
  97. package/src/internal/compiling/js-compilation-service/jsenvTransform.js +0 -242
  98. package/src/internal/dev_server/redirector/redirector.html +0 -48
  99. package/src/internal/generateGroupMap/generateGroupMap.js +0 -65
  100. package/src/internal/generateGroupMap/one_runtime_compat.js +0 -38
  101. package/src/internal/generateGroupMap/runtime_compat.js +0 -34
  102. package/src/internal/generateGroupMap/runtime_compat_composition.js +0 -76
  103. package/src/internal/generateGroupMap/shake_babel_plugin_map.js +0 -21
  104. package/src/internal/integrity/integrity_algorithms.js +0 -26
  105. package/src/internal/integrity/integrity_parsing.js +0 -50
  106. package/src/internal/integrity/integrity_update.js +0 -23
  107. package/src/internal/integrity/integrity_validation.js +0 -49
  108. package/src/internal/node_feature_detection/node_feature_detection.js +0 -117
  109. package/src/internal/node_runtime/detectNode.js +0 -3
  110. package/src/internal/runtime/computeCompileIdFromGroupId.js +0 -30
  111. package/src/internal/runtime/resolveGroup.js +0 -13
  112. package/src/internal/runtime/resolveRuntimeGroup.js +0 -11
@@ -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/generateGroupMap/jsenvRuntimeSupport.js"
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 { outDirectoryRelativeUrl, origin: compileServerOrigin } = compileServer
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
- importMapInWebWorkers,
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 assertentryPoints = ({ entryPoints }) => {
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
- computeOutDirectoryRelativeUrl,
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
- outDirectoryRelativeUrl,
101
+ jsenvDirectoryRelativeUrl,
107
102
  mainFileRelativeUrl,
108
103
  explorableConfig,
109
104
  livereloading,
110
105
  }),
111
106
  "jsenv:explorables_json": createExplorableJsonService({
112
107
  projectDirectoryUrl,
113
- outDirectoryRelativeUrl,
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: `${request.origin}/${redirectorRelativeUrlForProject}?redirect=${redirectTarget}`,
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
- }/${redirectorRelativeUrlForProject}?redirect=${encodeURIComponent(
170
- redirectTarget,
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
- outDirectoryRelativeUrl,
199
+ jsenvDirectoryRelativeUrl,
181
200
  explorableConfig,
182
201
  livereloading,
183
202
  mainFileRelativeUrl,
184
203
  }) => {
185
204
  return (request) => {
186
205
  if (
187
- request.ressource === "/.jsenv/exploring.json" &&
188
- request.method === "GET"
206
+ request.ressource !== "/.jsenv/exploring.json" ||
207
+ request.method !== "GET"
189
208
  ) {
190
- const data = {
209
+ return null
210
+ }
211
+ const data = {
212
+ projectDirectoryUrl,
213
+ jsenvDirectoryRelativeUrl,
214
+ jsenvCoreDirectoryRelativeUrl: urlToRelativeUrl(
215
+ jsenvCoreDirectoryUrl,
191
216
  projectDirectoryUrl,
192
- outDirectoryRelativeUrl,
193
- jsenvDirectoryRelativeUrl: urlToRelativeUrl(
194
- jsenvCoreDirectoryUrl,
195
- projectDirectoryUrl,
196
- ),
197
- exploringHtmlFileRelativeUrl: mainFileRelativeUrl,
198
- sourcemapMainFileRelativeUrl: urlToRelativeUrl(
199
- sourcemapMainFileInfo.url,
200
- jsenvCoreDirectoryUrl,
201
- ),
202
- sourcemapMappingFileRelativeUrl: urlToRelativeUrl(
203
- sourcemapMappingFileInfo.url,
204
- jsenvCoreDirectoryUrl,
205
- ),
206
- explorableConfig,
207
- livereloading,
208
- }
209
- const json = JSON.stringify(data)
210
- return {
211
- status: 200,
212
- headers: {
213
- "cache-control": "no-store",
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
- outDirectoryRelativeUrl,
245
+ jsenvDirectoryRelativeUrl,
227
246
  explorableConfig,
228
247
  }) => {
229
248
  return async (request) => {
230
249
  if (
231
- request.ressource === "/.jsenv/explorables.json" &&
232
- request.method === "GET"
250
+ request.ressource !== "/.jsenv/explorables.json" ||
251
+ request.method !== "GET"
233
252
  ) {
234
- const structuredMetaMapRelativeForExplorable = {}
235
- Object.keys(explorableConfig).forEach((explorableGroup) => {
236
- const explorableGroupConfig = explorableConfig[explorableGroup]
237
- structuredMetaMapRelativeForExplorable[explorableGroup] = {
238
- "**/.jsenv/": false, // temporary (in theory) to avoid visting .jsenv directory in jsenv itself
239
- ...explorableGroupConfig,
240
- [outDirectoryRelativeUrl]: false,
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/generateGroupMap/runtime_support.js"
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
- outDirectoryRelativeUrl: compileServer.outDirectoryRelativeUrl,
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.outDirectoryRelativeUrl = compileServer.outDirectoryRelativeUrl
159
+ result.jsenvDirectoryRelativeUrl = compileServer.jsenvDirectoryRelativeUrl
165
160
  }
166
161
 
167
162
  if (result.status === "errored") {
@@ -1,34 +1,39 @@
1
- export const getBrowserRuntimeReport = async ({
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 browserRuntimeFeaturesReport = await page.evaluate(
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
- failFastOnFeatureDetection: true,
27
+ forceSource,
28
+ forceCompilation,
26
29
  })
30
+ return runtimeProfile
27
31
  },
28
- { coverageHandledFromOutside },
32
+ /* eslint-enable no-undef */
33
+ { coverageHandledFromOutside, forceSource, forceCompilation },
29
34
  )
30
- cache.write(browserRuntimeFeaturesReport)
31
- return browserRuntimeFeaturesReport
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) => {