@jsenv/core 24.1.0-alpha.0 → 24.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (180) hide show
  1. package/{license → LICENSE} +0 -0
  2. package/dist/browser_runtime/browser_runtime-fbd309a1.js +5137 -0
  3. package/dist/browser_runtime/browser_runtime-fbd309a1.js.map +1064 -0
  4. package/dist/{jsenv_browser_system.js → browser_system/browser_system-29eda202.js} +12 -12
  5. package/dist/{jsenv_browser_system.js.map → browser_system/browser_system-29eda202.js.map} +64 -64
  6. package/dist/build_manifest.js +12 -0
  7. package/dist/compile_proxy/assets/s.js-749702e8.map +242 -0
  8. package/dist/compile_proxy/compile_proxy-405777e6.html +2074 -0
  9. package/dist/compile_proxy/compile_proxy.html__inline__20-39c0801c.js.map +385 -0
  10. package/dist/event_source_client/event_source_client-9f14c8b9.js +356 -0
  11. package/dist/event_source_client/event_source_client-9f14c8b9.js.map +127 -0
  12. package/dist/redirector/assets/s.js-749702e8.map +242 -0
  13. package/dist/redirector/redirector-237cd168.html +2118 -0
  14. package/dist/redirector/redirector.html__inline__15-33acb0b9.js.map +390 -0
  15. package/dist/toolbar/assets/compilation.css-209d68b4.map +12 -0
  16. package/dist/toolbar/assets/eventsource.css-38cd0a36.map +12 -0
  17. package/dist/toolbar/assets/execution.css-0ebe522f.map +12 -0
  18. package/dist/toolbar/assets/focus.css-3f9c156d.map +12 -0
  19. package/dist/toolbar/assets/light-theme.css-78b19a80.map +12 -0
  20. package/dist/toolbar/assets/overflow-menu.css-d9688a1c.map +12 -0
  21. package/dist/toolbar/assets/s.js-749702e8.map +242 -0
  22. package/dist/toolbar/assets/settings.css-2b81b245.map +12 -0
  23. package/dist/toolbar/assets/toolbar.main.css-846920e9.map +28 -0
  24. package/dist/toolbar/assets/tooltip.css-03395ee6.map +12 -0
  25. package/dist/toolbar/toolbar-d3d98c2e.html +4778 -0
  26. package/dist/toolbar/toolbar.main-cab36c15.js.map +795 -0
  27. package/dist/toolbar_injector/assets/jsenv-logo-188b9ca6.svg +95 -0
  28. package/dist/{jsenv_toolbar_injector.js → toolbar_injector/toolbar_injector-01f71ce3.js} +62 -137
  29. package/dist/toolbar_injector/toolbar_injector-01f71ce3.js.map +294 -0
  30. package/main.js +0 -1
  31. package/package.json +4 -2
  32. package/readme.md +10 -7
  33. package/src/buildProject.js +8 -2
  34. package/src/dev_server.js +45 -102
  35. package/src/importUsingChildProcess.js +1 -1
  36. package/src/internal/{runtime/detectBrowser/detectBrowser.js → browser_detection/browser_detection.js} +0 -0
  37. package/src/internal/{runtime/detectBrowser → browser_detection}/detectAndroid.js +0 -0
  38. package/src/internal/{runtime/detectBrowser → browser_detection}/detectChrome.js +0 -0
  39. package/src/internal/{runtime/detectBrowser → browser_detection}/detectEdge.js +0 -0
  40. package/src/internal/{runtime/detectBrowser → browser_detection}/detectElectron.js +0 -0
  41. package/src/internal/{runtime/detectBrowser → browser_detection}/detectFirefox.js +0 -0
  42. package/src/internal/{runtime/detectBrowser → browser_detection}/detectIOS.js +0 -0
  43. package/src/internal/{runtime/detectBrowser → browser_detection}/detectInternetExplorer.js +0 -0
  44. package/src/internal/{runtime/detectBrowser → browser_detection}/detectOpera.js +0 -0
  45. package/src/internal/{runtime/detectBrowser → browser_detection}/detectSafari.js +0 -0
  46. package/src/internal/{runtime/detectBrowser → browser_detection}/util.js +0 -0
  47. package/src/internal/{runtime/createBrowserRuntime/scanBrowserRuntimeFeatures.js → browser_feature_detection/browser_feature_detection.js} +116 -81
  48. package/src/internal/browser_feature_detection/compile_proxy.html +27 -0
  49. package/src/internal/{browser-launcher → browser_launcher}/createSharing.js +0 -0
  50. package/src/internal/{browser-launcher → browser_launcher}/executeHtmlFile.js +7 -4
  51. package/src/internal/{browser-launcher → browser_launcher}/trackPageToNotify.js +0 -0
  52. package/src/internal/{browser-launcher/jsenv-browser-system.js → browser_runtime/browser_runtime.js} +4 -4
  53. package/src/internal/{runtime/createBrowserRuntime/createBrowserSystem.js → browser_runtime/browser_system.js} +3 -2
  54. package/src/internal/{runtime/createBrowserRuntime → browser_runtime}/createBrowserRuntime.js +7 -5
  55. package/src/internal/{browser-launcher → browser_runtime}/displayErrorInDocument.js +0 -0
  56. package/src/internal/{browser-launcher → browser_runtime}/displayErrorNotification.js +2 -4
  57. package/src/internal/{runtime/createBrowserRuntime → browser_runtime}/evalSource.js +2 -0
  58. package/src/internal/{runtime/createBrowserRuntime → browser_runtime}/makeNamespaceTransferable.js +0 -0
  59. package/src/internal/{browser-utils → browser_utils}/fetch-browser.js +2 -0
  60. package/src/internal/{browser-utils → browser_utils}/fetchAndEvalUsingFetch.js +3 -0
  61. package/src/internal/{browser-utils → browser_utils}/fetchAndEvalUsingScript.js +2 -0
  62. package/src/internal/{browser-utils → browser_utils}/fetchJson.js +0 -0
  63. package/src/internal/{browser-utils → browser_utils}/fetchUsingXHR.js +4 -4
  64. package/src/internal/building/buildUsingRollup.js +4 -0
  65. package/src/internal/building/createJsenvRollupPlugin.js +19 -9
  66. package/src/internal/building/css/applyPostCss.js +19 -8
  67. package/src/internal/building/css/moveCssUrls.js +44 -0
  68. package/src/internal/building/css/parseCssRessource.js +67 -17
  69. package/src/internal/building/css/parseCssUrls.js +29 -23
  70. package/src/internal/building/css/postcss_plugin_url_visitor.js +11 -20
  71. package/src/internal/building/css/replaceCssUrls.js +38 -19
  72. package/src/internal/building/css_module.js +6 -10
  73. package/src/internal/building/html/parseHtmlRessource.js +37 -11
  74. package/src/internal/building/parseRessource.js +3 -0
  75. package/src/internal/building/ressource_builder.js +12 -3
  76. package/src/internal/compiling/babel_plugin_import_assertions.js +1 -2
  77. package/src/internal/compiling/compile-directory/validateCache.js +0 -5
  78. package/src/internal/compiling/compileFile.js +17 -54
  79. package/src/internal/compiling/createCompiledFileService.js +2 -0
  80. package/src/internal/compiling/html_source_file_service.js +49 -13
  81. package/src/internal/compiling/jsenvCompilerForHtml.js +29 -12
  82. package/src/internal/compiling/startCompileServer.js +39 -33
  83. package/src/internal/dev_server/event_source_client/event_source_client.js +63 -0
  84. package/src/internal/{toolbar/eventsource/connectEventSource.js → dev_server/event_source_client/event_source_connection.js} +66 -88
  85. package/src/internal/dev_server/event_source_client/file_changes.js +82 -0
  86. package/src/internal/dev_server/event_source_client/livereload_preference.js +13 -0
  87. package/src/internal/{exploring → dev_server/exploring}/exploring.css +0 -0
  88. package/src/internal/{exploring → dev_server/exploring}/exploring.html +8 -3
  89. package/src/internal/{exploring → dev_server/exploring}/exploring.js +0 -0
  90. package/src/internal/{exploring → dev_server/exploring}/fetchExploringJson.js +4 -9
  91. package/src/internal/dev_server/redirector/redirector.html +48 -0
  92. package/src/internal/{toolbar → dev_server/toolbar}/animation/toolbar.animation.js +0 -0
  93. package/src/internal/{toolbar → dev_server/toolbar}/compilation/compilation.css +0 -0
  94. package/src/internal/{toolbar → dev_server/toolbar}/compilation/toolbar.compilation.js +4 -7
  95. package/src/internal/{toolbar → dev_server/toolbar}/eventsource/eventsource.css +0 -0
  96. package/src/internal/dev_server/toolbar/eventsource/toolbar.eventsource.js +83 -0
  97. package/src/internal/{toolbar → dev_server/toolbar}/execution/execution.css +0 -0
  98. package/src/internal/{toolbar → dev_server/toolbar}/execution/toolbar.execution.js +0 -0
  99. package/src/internal/{toolbar → dev_server/toolbar}/focus/focus.css +0 -0
  100. package/src/internal/{toolbar → dev_server/toolbar}/focus/toolbar.focus.js +0 -0
  101. package/src/internal/{toolbar → dev_server/toolbar}/jsenv-logo.svg +0 -0
  102. package/src/internal/dev_server/toolbar/notification/toolbar.notification.js +152 -0
  103. package/src/internal/{toolbar → dev_server/toolbar}/responsive/overflow-menu.css +0 -0
  104. package/src/internal/{toolbar → dev_server/toolbar}/responsive/toolbar.responsive.js +0 -0
  105. package/src/internal/{toolbar → dev_server/toolbar}/settings/settings.css +0 -0
  106. package/src/internal/{toolbar → dev_server/toolbar}/settings/toolbar.settings.js +0 -0
  107. package/src/internal/{toolbar → dev_server/toolbar}/theme/jsenv-theme.css +0 -0
  108. package/src/internal/{toolbar → dev_server/toolbar}/theme/light-theme.css +0 -0
  109. package/src/internal/{toolbar → dev_server/toolbar}/theme/toolbar.theme.js +0 -0
  110. package/src/internal/{toolbar → dev_server/toolbar}/toolbar.html +35 -42
  111. package/src/internal/{toolbar → dev_server/toolbar}/toolbar.injector.js +53 -125
  112. package/src/internal/{toolbar → dev_server/toolbar}/toolbar.main.css +0 -0
  113. package/src/internal/{toolbar → dev_server/toolbar}/toolbar.main.js +44 -31
  114. package/src/internal/{toolbar → dev_server/toolbar}/tooltip/tooltip.css +0 -0
  115. package/src/internal/{toolbar → dev_server/toolbar}/tooltip/tooltip.js +0 -0
  116. package/src/internal/{toolbar → dev_server/toolbar}/util/animation.js +0 -0
  117. package/src/internal/{toolbar → dev_server/toolbar}/util/dom.js +0 -0
  118. package/src/internal/{toolbar → dev_server/toolbar}/util/fetching.js +2 -2
  119. package/src/internal/{toolbar → dev_server/toolbar}/util/jsenvLogger.js +0 -0
  120. package/src/internal/{toolbar → dev_server/toolbar}/util/preferences.js +0 -0
  121. package/src/internal/{toolbar → dev_server/toolbar}/util/responsive.js +0 -0
  122. package/src/internal/{toolbar → dev_server/toolbar}/util/util.js +0 -0
  123. package/src/internal/{toolbar → dev_server/toolbar}/variant/variant.js +0 -0
  124. package/src/internal/generateGroupMap/one_runtime_compat.js +1 -1
  125. package/src/internal/generateGroupMap/runtime_compat_composition.js +1 -1
  126. package/src/internal/generateGroupMap/runtime_support.js +1 -1
  127. package/src/internal/jsenvInternalFiles.js +0 -84
  128. package/src/internal/jsenv_builds.js +19 -0
  129. package/src/internal/{runtime/node-feature-detect/feature-detect-dynamic-import.mjs → node_feature_detection/feature_detect_dynamic_import.mjs} +0 -0
  130. package/src/internal/{runtime/node-feature-detect/feature-detect-top-level-await.mjs → node_feature_detection/feature_detect_top_level_await.mjs} +0 -0
  131. package/src/internal/{runtime/node-feature-detect → node_feature_detection}/nodeSupportsDynamicImport.js +0 -0
  132. package/src/internal/node_feature_detection/nodeSupportsTopLevelAwait.js +16 -0
  133. package/src/internal/{runtime/createNodeRuntime/scanNodeRuntimeFeatures.js → node_feature_detection/node_feature_detection.js} +12 -13
  134. package/src/internal/{node-launcher → node_launcher}/createChildProcessOptions.js +0 -0
  135. package/src/internal/{node-launcher → node_launcher}/createControllableNodeProcess.js +9 -14
  136. package/src/internal/{node-launcher → node_launcher}/kill_process_tree.js +0 -0
  137. package/src/internal/{node-launcher → node_launcher}/processOptions.js +0 -0
  138. package/src/internal/{runtime/detectNode → node_runtime}/detectNode.js +0 -0
  139. package/src/internal/{runtime/createNodeRuntime → node_runtime}/evalSource.js +1 -1
  140. package/src/internal/{runtime/createNodeRuntime → node_runtime}/fetchSource.js +1 -1
  141. package/src/internal/{node-launcher → node_runtime}/nodeControllableFile.mjs +14 -11
  142. package/src/internal/{runtime/createNodeRuntime/createNodeExecutionWithDynamicImport.js → node_runtime/node_execution_dynamic_import.js} +34 -6
  143. package/src/internal/node_runtime/node_execution_performance.js +67 -0
  144. package/src/internal/{runtime/createNodeRuntime/createNodeExecutionWithSystemJs.js → node_runtime/node_execution_systemjs.js} +38 -24
  145. package/src/internal/{runtime/createNodeRuntime/createNodeSystem.js → node_runtime/node_system.js} +4 -4
  146. package/src/internal/runtime/computeCompileIdFromGroupId.js +1 -0
  147. package/src/internal/runtime/resolveGroup.js +1 -1
  148. package/src/internal/runtime/resolveRuntimeGroup.js +2 -2
  149. package/src/internal/{semantic-versioning → semantic_versioning}/findHighestVersion.js +0 -0
  150. package/src/internal/{semantic-versioning → semantic_versioning}/findLowestVersion.js +0 -0
  151. package/src/internal/{semantic-versioning → semantic_versioning}/index.js +0 -0
  152. package/src/internal/{semantic-versioning → semantic_versioning}/valueToVersion.js +0 -0
  153. package/src/internal/{semantic-versioning → semantic_versioning}/versionCompare.js +0 -0
  154. package/src/internal/{semantic-versioning → semantic_versioning}/versionIsAbove.js +0 -0
  155. package/src/internal/{semantic-versioning → semantic_versioning}/versionIsBelow.js +0 -0
  156. package/src/internal/{semantic-versioning → semantic_versioning}/versionIsEqual.js +0 -0
  157. package/src/launchBrowser.js +3 -3
  158. package/src/launchNode.js +33 -7
  159. package/src/requireUsingChildProcess.js +1 -1
  160. package/dist/jsenv_compile_proxy.js +0 -1339
  161. package/dist/jsenv_compile_proxy.js.map +0 -378
  162. package/dist/jsenv_exploring_index.js +0 -1092
  163. package/dist/jsenv_exploring_index.js.map +0 -353
  164. package/dist/jsenv_exploring_redirector.js +0 -1386
  165. package/dist/jsenv_exploring_redirector.js.map +0 -384
  166. package/dist/jsenv_toolbar.js +0 -3347
  167. package/dist/jsenv_toolbar.js.map +0 -846
  168. package/dist/jsenv_toolbar_injector.js.map +0 -320
  169. package/src/internal/browser-launcher/jsenv_compile_proxy.html +0 -13
  170. package/src/internal/browser-launcher/jsenv_compile_proxy.js +0 -5
  171. package/src/internal/exploring/exploring.redirector.html +0 -13
  172. package/src/internal/exploring/exploring.redirector.js +0 -28
  173. package/src/internal/node-launcher/node-js-file.js +0 -110
  174. package/src/internal/runtime/createNodeRuntime/createNodeRuntime.js +0 -32
  175. package/src/internal/runtime/node-feature-detect/nodeSupportsTopLevelAwait.js +0 -18
  176. package/src/internal/toolbar/backtolist/toolbar.backtolist.js +0 -33
  177. package/src/internal/toolbar/eventsource/connectCompileServerEventSource.js +0 -74
  178. package/src/internal/toolbar/eventsource/toolbar.eventsource.js +0 -239
  179. package/src/internal/toolbar/notification/toolbar.notification.js +0 -121
  180. 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,14 +16,10 @@ import {
15
16
  computeOutDirectoryRelativeUrl,
16
17
  } from "./internal/compiling/startCompileServer.js"
17
18
  import { jsenvExplorableConfig } from "./jsenvExplorableConfig.js"
19
+
18
20
  import {
19
21
  sourcemapMainFileInfo,
20
22
  sourcemapMappingFileInfo,
21
- jsenvExploringRedirectorHtmlFileInfo,
22
- jsenvExploringRedirectorJsFileInfo,
23
- jsenvExploringIndexHtmlFileInfo,
24
- jsenvExploringIndexJsFileInfo,
25
- jsenvToolbarJsFileInfo,
26
23
  } from "./internal/jsenvInternalFiles.js"
27
24
  import { jsenvRuntimeSupportDuringDev } from "./jsenvRuntimeSupportDuringDev.js"
28
25
 
@@ -40,10 +37,7 @@ export const startDevServer = async ({
40
37
 
41
38
  projectDirectoryUrl,
42
39
  explorableConfig = jsenvExplorableConfig,
43
- mainFileRelativeUrl = urlToRelativeUrl(
44
- jsenvExploringIndexHtmlFileInfo.url,
45
- projectDirectoryUrl,
46
- ),
40
+ mainFileRelativeUrl,
47
41
  jsenvDirectoryRelativeUrl,
48
42
  outDirectoryName = "dev",
49
43
  jsenvToolbar = true,
@@ -59,34 +53,28 @@ export const startDevServer = async ({
59
53
  sourcemapMethod,
60
54
  customCompilers,
61
55
  livereloadWatchConfig,
56
+ livereloadLogLevel,
62
57
  jsenvDirectoryClean,
63
58
  }) => {
64
59
  projectDirectoryUrl = assertProjectDirectoryUrl({ projectDirectoryUrl })
65
60
  await assertProjectDirectoryExists({ projectDirectoryUrl })
66
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
+
67
72
  const outDirectoryRelativeUrl = computeOutDirectoryRelativeUrl({
68
73
  projectDirectoryUrl,
69
74
  jsenvDirectoryRelativeUrl,
70
75
  outDirectoryName,
71
76
  })
72
77
 
73
- const redirectFiles = createRedirectFilesService({
74
- projectDirectoryUrl,
75
- outDirectoryRelativeUrl,
76
- mainFileRelativeUrl,
77
- })
78
- const serveExploringData = createExploringDataService({
79
- projectDirectoryUrl,
80
- outDirectoryRelativeUrl,
81
- explorableConfig,
82
- livereloading,
83
- })
84
- const serveExplorableListAsJson = createExplorableListAsJsonService({
85
- projectDirectoryUrl,
86
- outDirectoryRelativeUrl,
87
- explorableConfig,
88
- })
89
-
90
78
  const compileServer = await startCompileServer({
91
79
  signal,
92
80
  handleSIGINT,
@@ -101,13 +89,27 @@ export const startDevServer = async ({
101
89
  plugins,
102
90
  customServices: {
103
91
  ...customServices,
104
- "jsenv:redirector": redirectFiles,
105
- "jsenv:exploring-data": serveExploringData,
106
- "jsenv:explorables": serveExplorableListAsJson,
92
+ "jsenv:redirector": await createRedirectorService({
93
+ projectDirectoryUrl,
94
+ mainFileRelativeUrl,
95
+ }),
96
+ "jsenv:exploring_json": createExploringJsonService({
97
+ projectDirectoryUrl,
98
+ outDirectoryRelativeUrl,
99
+ mainFileRelativeUrl,
100
+ explorableConfig,
101
+ livereloading,
102
+ }),
103
+ "jsenv:explorables_json": createExplorableJsonService({
104
+ projectDirectoryUrl,
105
+ outDirectoryRelativeUrl,
106
+ explorableConfig,
107
+ }),
107
108
  },
108
109
 
109
110
  projectDirectoryUrl,
110
111
  livereloadSSE: livereloading,
112
+ jsenvEventSourceClientInjection: true,
111
113
  jsenvToolbarInjection: jsenvToolbar,
112
114
  jsenvDirectoryRelativeUrl,
113
115
  outDirectoryName,
@@ -120,109 +122,53 @@ export const startDevServer = async ({
120
122
  babelPluginMap,
121
123
  runtimeSupport: runtimeSupportDuringDev,
122
124
  livereloadWatchConfig,
125
+ livereloadLogLevel,
123
126
  jsenvDirectoryClean,
124
127
  })
125
128
 
126
129
  return compileServer
127
130
  }
128
131
 
129
- const createRedirectFilesService = ({
132
+ const createRedirectorService = async ({
130
133
  projectDirectoryUrl,
131
134
  mainFileRelativeUrl,
132
135
  }) => {
133
- const jsenvExploringRedirectorHtmlRelativeUrlForProject = urlToRelativeUrl(
134
- jsenvExploringRedirectorHtmlFileInfo.url,
135
- projectDirectoryUrl,
136
- )
137
- const jsenvExploringRedirectorJsBuildRelativeUrlForProject = urlToRelativeUrl(
138
- jsenvExploringRedirectorJsFileInfo.jsenvBuildUrl,
136
+ const redirectorRelativeUrlForProject = urlToRelativeUrl(
137
+ REDIRECTOR_BUILD_URL,
139
138
  projectDirectoryUrl,
140
139
  )
141
- const jsenvExploringJsBuildRelativeUrlForProject = urlToRelativeUrl(
142
- jsenvExploringIndexJsFileInfo.jsenvBuildUrl,
143
- projectDirectoryUrl,
144
- )
145
- const jsenvToolbarJsBuildRelativeUrlForProject = urlToRelativeUrl(
146
- jsenvToolbarJsFileInfo.jsenvBuildUrl,
147
- projectDirectoryUrl,
148
- )
149
-
150
140
  return setupRoutes({
151
141
  "/": (request) => {
152
142
  const redirectTarget = mainFileRelativeUrl
153
- const jsenvExploringRedirectorHtmlServerUrl = `${request.origin}/${jsenvExploringRedirectorHtmlRelativeUrlForProject}?redirect=${redirectTarget}`
154
143
  return {
155
144
  status: 307,
156
145
  headers: {
157
- location: jsenvExploringRedirectorHtmlServerUrl,
146
+ location: `${request.origin}/${redirectorRelativeUrlForProject}?redirect=${redirectTarget}`,
158
147
  },
159
148
  }
160
149
  },
161
150
  "/.jsenv/redirect/:rest*": (request) => {
162
151
  const redirectTarget = request.ressource.slice("/.jsenv/redirect/".length)
163
- const jsenvExploringRedirectorHtmlServerUrl = `${request.origin}/${jsenvExploringRedirectorHtmlRelativeUrlForProject}?redirect=${redirectTarget}`
164
- return {
165
- status: 307,
166
- headers: {
167
- location: jsenvExploringRedirectorHtmlServerUrl,
168
- },
169
- }
170
- },
171
- "/.jsenv/exploring.redirector.js": (request) => {
172
- const jsenvExploringRedirectorBuildServerUrl = `${request.origin}/${jsenvExploringRedirectorJsBuildRelativeUrlForProject}`
173
- return {
174
- status: 307,
175
- headers: {
176
- location: jsenvExploringRedirectorBuildServerUrl,
177
- },
178
- }
179
- },
180
- "/.jsenv/exploring.index.js": (request) => {
181
- const jsenvExploringJsBuildServerUrl = `${request.origin}/${jsenvExploringJsBuildRelativeUrlForProject}`
182
- return {
183
- status: 307,
184
- headers: {
185
- location: jsenvExploringJsBuildServerUrl,
186
- },
187
- }
188
- },
189
- "/.jsenv/toolbar.main.js": (request) => {
190
- const jsenvToolbarJsBuildServerUrl = `${request.origin}/${jsenvToolbarJsBuildRelativeUrlForProject}`
191
152
  return {
192
153
  status: 307,
193
154
  headers: {
194
- location: jsenvToolbarJsBuildServerUrl,
195
- },
196
- }
197
- },
198
- // unfortunately browser resolves sourcemap to url before redirection (not after).
199
- // It means browser tries to load source map from "/.jsenv/jsenv-toolbar.js.map"
200
- // we could also inline sourcemap but it's not yet possible
201
- // inside buildProject
202
- "/.jsenv/jsenv_exploring_index.js.map": (request) => {
203
- return {
204
- status: 307,
205
- headers: {
206
- location: `${request.origin}/${jsenvExploringJsBuildRelativeUrlForProject}.map`,
207
- },
208
- }
209
- },
210
- "/.jsenv/jsenv_toolbar.js.map": (request) => {
211
- return {
212
- status: 307,
213
- headers: {
214
- location: `${request.origin}/${jsenvToolbarJsBuildRelativeUrlForProject}.map`,
155
+ location: `${
156
+ request.origin
157
+ }/${redirectorRelativeUrlForProject}?redirect=${encodeURIComponent(
158
+ redirectTarget,
159
+ )}`,
215
160
  },
216
161
  }
217
162
  },
218
163
  })
219
164
  }
220
165
 
221
- const createExploringDataService = ({
166
+ const createExploringJsonService = ({
222
167
  projectDirectoryUrl,
223
168
  outDirectoryRelativeUrl,
224
169
  explorableConfig,
225
170
  livereloading,
171
+ mainFileRelativeUrl,
226
172
  }) => {
227
173
  return (request) => {
228
174
  if (
@@ -236,10 +182,7 @@ const createExploringDataService = ({
236
182
  jsenvCoreDirectoryUrl,
237
183
  projectDirectoryUrl,
238
184
  ),
239
- exploringHtmlFileRelativeUrl: urlToRelativeUrl(
240
- jsenvExploringIndexHtmlFileInfo.url,
241
- projectDirectoryUrl,
242
- ),
185
+ exploringHtmlFileRelativeUrl: mainFileRelativeUrl,
243
186
  sourcemapMainFileRelativeUrl: urlToRelativeUrl(
244
187
  sourcemapMainFileInfo.url,
245
188
  jsenvCoreDirectoryUrl,
@@ -266,7 +209,7 @@ const createExploringDataService = ({
266
209
  }
267
210
  }
268
211
 
269
- const createExplorableListAsJsonService = ({
212
+ const createExplorableJsonService = ({
270
213
  projectDirectoryUrl,
271
214
  outDirectoryRelativeUrl,
272
215
  explorableConfig,
@@ -1,5 +1,5 @@
1
1
  import { launchAndExecute } from "./internal/executing/launchAndExecute.js"
2
- import { createControllableNodeProcess } from "./internal/node-launcher/createControllableNodeProcess.js"
2
+ import { createControllableNodeProcess } from "./internal/node_launcher/createControllableNodeProcess.js"
3
3
 
4
4
  export const importUsingChildProcess = async (
5
5
  fileUrl,
@@ -1,7 +1,9 @@
1
- import { fetchJson } from "../../browser-utils/fetchJson.js"
2
- import { computeCompileIdFromGroupId } from "../computeCompileIdFromGroupId.js"
3
- import { detectBrowser } from "../detectBrowser/detectBrowser.js"
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 supportsNewStylesheet = () => {
144
- try {
145
- // eslint-disable-next-line no-new
146
- new CSSStyleSheet()
147
- return true
148
- } catch (e) {
149
- return false
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
- const scriptModule = document.createElement("script")
176
- scriptModule.type = "module"
177
- scriptModule.src = asBase64Url(
178
- `import supported from "${specifier}"; window.__importmap_supported = supported`,
179
- )
180
-
181
- return new Promise((resolve, reject) => {
182
- scriptModule.onload = () => {
183
- const supported = window.__importmap_supported
184
- delete window.__importmap_supported
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
- const namespace = await import(moduleSource)
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
- const namespace = await import(moduleSource)
212
- return namespace.default === 42
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
- `export { default } from "${jsonBase64Url}" assert { type: "json" }`,
220
+ `import data from "${jsonBase64Url}" assert { type: "json" }
221
+ export default data`,
222
222
  )
223
223
  try {
224
- const namespace = await import(moduleSource)
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
- `export { default } from "${cssBase64Url}" assert { type: "css" }`,
239
+ `import css from "${cssBase64Url}" assert { type: "css" }
240
+ export default css`,
235
241
  )
236
242
  try {
237
- const namespace = await import(moduleSource)
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>
@@ -5,10 +5,10 @@ import {
5
5
  urlToExtension,
6
6
  } from "@jsenv/filesystem"
7
7
 
8
- import { jsenvCompileProxyHtmlFileInfo } from "@jsenv/core/src/internal/jsenvInternalFiles.js"
8
+ import { COMPILE_PROXY_BUILD_URL } from "@jsenv/core/dist/build_manifest.js"
9
9
  import { filterV8Coverage } from "@jsenv/core/src/internal/executing/coverage_utils/v8_coverage_from_directory.js"
10
10
  import { composeTwoFileByFileIstanbulCoverages } from "@jsenv/core/src/internal/executing/coverage_utils/istanbul_coverage_composition.js"
11
- import { evalSource } from "../runtime/createNodeRuntime/evalSource.js"
11
+ import { evalSource } from "../node_runtime/evalSource.js"
12
12
  import { escapeRegexpSpecialCharacters } from "../escapeRegexpSpecialCharacters.js"
13
13
 
14
14
  export const executeHtmlFile = async (
@@ -39,7 +39,7 @@ export const executeHtmlFile = async (
39
39
  await assertFilePresence(fileUrl)
40
40
 
41
41
  const compileProxyProjectRelativeUrl = urlToRelativeUrl(
42
- jsenvCompileProxyHtmlFileInfo.url,
42
+ COMPILE_PROXY_BUILD_URL,
43
43
  projectDirectoryUrl,
44
44
  )
45
45
  const compileProxyClientUrl = resolveUrl(
@@ -55,7 +55,10 @@ export const executeHtmlFile = async (
55
55
  executeOperation.throwIfAborted()
56
56
  const browserRuntimeFeaturesReport = await page.evaluate(
57
57
  /* istanbul ignore next */
58
- ({ coverageHandledFromOutside }) => {
58
+ async ({ coverageHandledFromOutside }) => {
59
+ // eslint-disable-next-line no-undef
60
+ await window.readyPromise
61
+
59
62
  // eslint-disable-next-line no-undef
60
63
  return window.scanBrowserRuntimeFeatures({
61
64
  coverageHandledFromOutside,
@@ -1,14 +1,14 @@
1
1
  /* eslint-env browser */
2
2
 
3
- import { unevalException } from "../unevalException.js"
4
- import { createBrowserRuntime } from "../runtime/createBrowserRuntime/createBrowserRuntime.js"
5
3
  import { installBrowserErrorStackRemapping } from "../error-stack-remapping/installBrowserErrorStackRemapping.js"
6
- import { fetchUrl } from "../browser-utils/fetch-browser.js"
7
- import { fetchAndEvalUsingFetch } from "../browser-utils/fetchAndEvalUsingFetch.js"
4
+ import { fetchUrl } from "../browser_utils/fetch-browser.js"
5
+ import { fetchAndEvalUsingFetch } from "../browser_utils/fetchAndEvalUsingFetch.js"
6
+ import { unevalException } from "../unevalException.js"
8
7
  import { memoize } from "../memoize.js"
9
8
 
10
9
  import { displayErrorInDocument } from "./displayErrorInDocument.js"
11
10
  import { displayErrorNotification } from "./displayErrorNotification.js"
11
+ import { createBrowserRuntime } from "./createBrowserRuntime.js"
12
12
 
13
13
  const getNavigationStartTime = () => {
14
14
  try {
@@ -1,6 +1,7 @@
1
- import { getJavaScriptModuleResponseError } from "../module-registration.js"
1
+ /* eslint-env browser */
2
2
 
3
- import "../s.js"
3
+ import { getJavaScriptModuleResponseError } from "../runtime/module-registration.js"
4
+ import "../runtime/s.js"
4
5
 
5
6
  export const createBrowserSystem = ({
6
7
  compileServerOrigin,