@jsenv/core 24.2.2 → 24.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser_runtime/browser_runtime-fbd309a1.js +5137 -0
- package/dist/browser_runtime/browser_runtime-fbd309a1.js.map +1064 -0
- package/dist/{jsenv_browser_system.js → browser_system/browser_system-29eda202.js} +12 -12
- package/dist/{jsenv_browser_system.js.map → browser_system/browser_system-29eda202.js.map} +64 -64
- package/dist/build_manifest.js +12 -0
- package/dist/compile_proxy/assets/s.js-749702e8.map +242 -0
- package/dist/compile_proxy/compile_proxy-405777e6.html +2074 -0
- package/dist/compile_proxy/compile_proxy.html__inline__20-39c0801c.js.map +385 -0
- package/dist/{jsenv_event_source_client.js → event_source_client/event_source_client-9f14c8b9.js} +39 -21
- package/dist/event_source_client/event_source_client-9f14c8b9.js.map +127 -0
- package/dist/redirector/assets/s.js-749702e8.map +242 -0
- package/dist/redirector/redirector-237cd168.html +2118 -0
- package/dist/redirector/redirector.html__inline__15-33acb0b9.js.map +390 -0
- package/dist/toolbar/assets/compilation.css-209d68b4.map +12 -0
- package/dist/toolbar/assets/eventsource.css-38cd0a36.map +12 -0
- package/dist/toolbar/assets/execution.css-0ebe522f.map +12 -0
- package/dist/toolbar/assets/focus.css-3f9c156d.map +12 -0
- package/dist/toolbar/assets/light-theme.css-78b19a80.map +12 -0
- package/dist/toolbar/assets/overflow-menu.css-d9688a1c.map +12 -0
- package/dist/toolbar/assets/s.js-749702e8.map +242 -0
- package/dist/toolbar/assets/settings.css-2b81b245.map +12 -0
- package/dist/toolbar/assets/toolbar.main.css-846920e9.map +28 -0
- package/dist/toolbar/assets/tooltip.css-03395ee6.map +12 -0
- package/dist/toolbar/toolbar-29e91dcd.html +4779 -0
- package/dist/toolbar/toolbar.main-53e1ab2b.js.map +795 -0
- package/dist/toolbar_injector/assets/jsenv-logo-188b9ca6.svg +95 -0
- package/dist/{jsenv_toolbar_injector.js → toolbar_injector/toolbar_injector-0af91b43.js} +87 -65
- package/dist/toolbar_injector/toolbar_injector-0af91b43.js.map +294 -0
- package/main.js +0 -1
- package/package.json +2 -1
- package/readme.md +10 -7
- package/src/buildProject.js +6 -2
- package/src/dev_server.js +22 -130
- package/src/execute.js +7 -10
- package/src/executeTestPlan.js +7 -1
- package/src/importUsingChildProcess.js +1 -1
- package/src/internal/{runtime/detectBrowser/detectBrowser.js → browser_detection/browser_detection.js} +0 -0
- package/src/internal/{runtime/detectBrowser → browser_detection}/detectAndroid.js +0 -0
- package/src/internal/{runtime/detectBrowser → browser_detection}/detectChrome.js +0 -0
- package/src/internal/{runtime/detectBrowser → browser_detection}/detectEdge.js +0 -0
- package/src/internal/{runtime/detectBrowser → browser_detection}/detectElectron.js +0 -0
- package/src/internal/{runtime/detectBrowser → browser_detection}/detectFirefox.js +0 -0
- package/src/internal/{runtime/detectBrowser → browser_detection}/detectIOS.js +0 -0
- package/src/internal/{runtime/detectBrowser → browser_detection}/detectInternetExplorer.js +0 -0
- package/src/internal/{runtime/detectBrowser → browser_detection}/detectOpera.js +0 -0
- package/src/internal/{runtime/detectBrowser → browser_detection}/detectSafari.js +0 -0
- package/src/internal/{runtime/detectBrowser → browser_detection}/util.js +0 -0
- package/src/internal/{runtime/createBrowserRuntime/scanBrowserRuntimeFeatures.js → browser_feature_detection/browser_feature_detection.js} +116 -81
- package/src/internal/browser_feature_detection/compile_proxy.html +27 -0
- package/src/internal/browser_launcher/browser_runtime_report.js +75 -0
- package/src/internal/{browser-launcher → browser_launcher}/executeHtmlFile.js +13 -16
- package/src/internal/browser_launcher/from_playwright.js +314 -0
- package/src/internal/{browser-launcher → browser_launcher}/trackPageToNotify.js +0 -0
- package/src/internal/{browser-launcher/jsenv-browser-system.js → browser_runtime/browser_runtime.js} +4 -4
- package/src/internal/{runtime/createBrowserRuntime/createBrowserSystem.js → browser_runtime/browser_system.js} +3 -2
- package/src/internal/{runtime/createBrowserRuntime → browser_runtime}/createBrowserRuntime.js +7 -5
- package/src/internal/{browser-launcher → browser_runtime}/displayErrorInDocument.js +0 -0
- package/src/internal/{browser-launcher → browser_runtime}/displayErrorNotification.js +2 -4
- package/src/internal/{runtime/createBrowserRuntime → browser_runtime}/evalSource.js +2 -0
- package/src/internal/{runtime/createBrowserRuntime → browser_runtime}/makeNamespaceTransferable.js +0 -0
- package/src/internal/{browser-utils → browser_utils}/fetch-browser.js +2 -0
- package/src/internal/{browser-utils → browser_utils}/fetchAndEvalUsingFetch.js +3 -0
- package/src/internal/{browser-utils → browser_utils}/fetchAndEvalUsingScript.js +2 -0
- package/src/internal/{browser-utils → browser_utils}/fetchJson.js +0 -0
- package/src/internal/{browser-utils → browser_utils}/fetchUsingXHR.js +4 -4
- package/src/internal/building/buildUsingRollup.js +4 -0
- package/src/internal/building/createJsenvRollupPlugin.js +19 -9
- package/src/internal/building/css/applyPostCss.js +19 -8
- package/src/internal/building/css/moveCssUrls.js +44 -0
- package/src/internal/building/css/parseCssRessource.js +67 -17
- package/src/internal/building/css/parseCssUrls.js +29 -23
- package/src/internal/building/css/postcss_plugin_url_visitor.js +11 -20
- package/src/internal/building/css/replaceCssUrls.js +38 -19
- package/src/internal/building/css_module.js +6 -10
- package/src/internal/building/html/parseHtmlRessource.js +37 -11
- package/src/internal/building/parseRessource.js +3 -0
- package/src/internal/building/ressource_builder.js +12 -3
- package/src/internal/compiling/babel_plugin_import_assertions.js +1 -2
- package/src/internal/compiling/html_source_file_service.js +23 -21
- package/src/internal/compiling/jsenvCompilerForHtml.js +15 -22
- package/src/internal/compiling/startCompileServer.js +37 -32
- package/src/internal/dev_server/event_source_client/event_source_connection.js +28 -19
- package/src/internal/dev_server/exploring/exploring.html +7 -2
- package/src/internal/dev_server/exploring/fetchExploringJson.js +4 -9
- package/src/internal/dev_server/redirector/redirector.html +37 -2
- package/src/internal/dev_server/toolbar/compilation/toolbar.compilation.js +4 -7
- package/src/internal/dev_server/toolbar/eventsource/toolbar.eventsource.js +2 -2
- package/src/internal/dev_server/toolbar/notification/toolbar.notification.js +75 -44
- package/src/internal/dev_server/toolbar/toolbar.html +31 -5
- package/src/internal/dev_server/toolbar/toolbar.injector.js +55 -36
- package/src/internal/dev_server/toolbar/toolbar.main.js +45 -31
- package/src/internal/dev_server/toolbar/util/fetching.js +1 -1
- package/src/internal/executing/executeConcurrently.js +15 -11
- package/src/internal/executing/executePlan.js +3 -2
- package/src/internal/generateGroupMap/one_runtime_compat.js +1 -1
- package/src/internal/generateGroupMap/runtime_compat_composition.js +1 -1
- package/src/internal/generateGroupMap/runtime_support.js +1 -1
- package/src/internal/jsenvInternalFiles.js +0 -26
- package/src/internal/jsenv_builds.js +19 -0
- package/src/internal/{runtime/node-feature-detect/feature-detect-dynamic-import.mjs → node_feature_detection/feature_detect_dynamic_import.mjs} +0 -0
- package/src/internal/{runtime/node-feature-detect/feature-detect-top-level-await.mjs → node_feature_detection/feature_detect_top_level_await.mjs} +0 -0
- package/src/internal/{runtime/node-feature-detect → node_feature_detection}/nodeSupportsDynamicImport.js +0 -0
- package/src/internal/node_feature_detection/nodeSupportsTopLevelAwait.js +16 -0
- package/src/internal/{runtime/createNodeRuntime/scanNodeRuntimeFeatures.js → node_feature_detection/node_feature_detection.js} +12 -13
- package/src/internal/{node-launcher → node_launcher}/createChildProcessOptions.js +0 -0
- package/src/internal/{node-launcher → node_launcher}/createControllableNodeProcess.js +9 -14
- package/src/internal/{node-launcher → node_launcher}/kill_process_tree.js +0 -0
- package/src/internal/node_launcher/node_runtime_report.js +71 -0
- package/src/internal/{node-launcher → node_launcher}/processOptions.js +0 -0
- package/src/internal/{runtime/detectNode → node_runtime}/detectNode.js +0 -0
- package/src/internal/{runtime/createNodeRuntime → node_runtime}/evalSource.js +1 -1
- package/src/internal/{runtime/createNodeRuntime → node_runtime}/fetchSource.js +1 -1
- package/src/internal/{node-launcher → node_runtime}/nodeControllableFile.mjs +14 -11
- package/src/internal/{runtime/createNodeRuntime/createNodeExecutionWithDynamicImport.js → node_runtime/node_execution_dynamic_import.js} +34 -6
- package/src/internal/node_runtime/node_execution_performance.js +67 -0
- package/src/internal/{runtime/createNodeRuntime/createNodeExecutionWithSystemJs.js → node_runtime/node_execution_systemjs.js} +38 -24
- package/src/internal/{runtime/createNodeRuntime/createNodeSystem.js → node_runtime/node_system.js} +4 -4
- package/src/internal/runtime/computeCompileIdFromGroupId.js +1 -0
- package/src/internal/runtime/resolveGroup.js +1 -1
- package/src/internal/runtime/resolveRuntimeGroup.js +2 -2
- package/src/internal/{semantic-versioning → semantic_versioning}/findHighestVersion.js +0 -0
- package/src/internal/{semantic-versioning → semantic_versioning}/findLowestVersion.js +0 -0
- package/src/internal/{semantic-versioning → semantic_versioning}/index.js +0 -0
- package/src/internal/{semantic-versioning → semantic_versioning}/valueToVersion.js +0 -0
- package/src/internal/{semantic-versioning → semantic_versioning}/versionCompare.js +0 -0
- package/src/internal/{semantic-versioning → semantic_versioning}/versionIsAbove.js +0 -0
- package/src/internal/{semantic-versioning → semantic_versioning}/versionIsBelow.js +0 -0
- package/src/internal/{semantic-versioning → semantic_versioning}/versionIsEqual.js +0 -0
- package/src/launchBrowser.js +33 -492
- package/src/launchNode.js +36 -7
- package/src/requireUsingChildProcess.js +1 -1
- package/dist/jsenv_compile_proxy.js +0 -1339
- package/dist/jsenv_compile_proxy.js.map +0 -378
- package/dist/jsenv_event_source_client.js.map +0 -126
- package/dist/jsenv_exploring_index.js +0 -1092
- package/dist/jsenv_exploring_index.js.map +0 -353
- package/dist/jsenv_exploring_redirector.js +0 -1386
- package/dist/jsenv_exploring_redirector.js.map +0 -384
- package/dist/jsenv_redirector.js +0 -1388
- package/dist/jsenv_redirector.js.map +0 -384
- package/dist/jsenv_toolbar.js +0 -2880
- package/dist/jsenv_toolbar.js.map +0 -771
- package/dist/jsenv_toolbar_injector.js.map +0 -301
- package/src/internal/browser-launcher/createSharing.js +0 -70
- package/src/internal/browser-launcher/jsenv_compile_proxy.html +0 -13
- package/src/internal/browser-launcher/jsenv_compile_proxy.js +0 -5
- package/src/internal/dev_server/event_source_client/event_source_client_file_info.js +0 -17
- package/src/internal/dev_server/exploring/exploring_file_info.js +0 -21
- package/src/internal/dev_server/redirector/redirector.js +0 -30
- package/src/internal/dev_server/redirector/redirector_file_info.js +0 -24
- package/src/internal/dev_server/toolbar/backtolist/toolbar.backtolist.js +0 -33
- package/src/internal/dev_server/toolbar/toolbar_file_info.js +0 -37
- package/src/internal/node-launcher/node-js-file.js +0 -110
- package/src/internal/runtime/createNodeRuntime/createNodeRuntime.js +0 -32
- package/src/internal/runtime/node-feature-detect/nodeSupportsTopLevelAwait.js +0 -18
- package/src/nodeRuntime.js +0 -5
|
@@ -21,14 +21,12 @@ import {
|
|
|
21
21
|
import { moveImportMap } from "@jsenv/importmap"
|
|
22
22
|
import { createDetailedMessage } from "@jsenv/logger"
|
|
23
23
|
|
|
24
|
-
import { fetchUrl } from "@jsenv/core/src/internal/fetchUrl.js"
|
|
25
|
-
import { jsenvBrowserSystemFileInfo } from "@jsenv/core/src/internal/jsenvInternalFiles.js"
|
|
26
|
-
import { redirectorHtmlFileInfo } from "@jsenv/core/src/internal/dev_server/redirector/redirector_file_info.js"
|
|
27
|
-
import { eventSourceClientFileInfo } from "@jsenv/core/src/internal/dev_server/event_source_client/event_source_client_file_info.js"
|
|
28
24
|
import {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
BROWSER_RUNTIME_BUILD_URL,
|
|
26
|
+
EVENT_SOURCE_CLIENT_BUILD_URL,
|
|
27
|
+
TOOLBAR_INJECTOR_BUILD_URL,
|
|
28
|
+
} from "@jsenv/core/dist/build_manifest.js"
|
|
29
|
+
import { fetchUrl } from "@jsenv/core/src/internal/fetchUrl.js"
|
|
32
30
|
import { stringifyDataUrl } from "@jsenv/core/src/internal/dataUrl.utils.js"
|
|
33
31
|
import {
|
|
34
32
|
parseHtmlString,
|
|
@@ -43,6 +41,9 @@ import {
|
|
|
43
41
|
setHtmlNodeText,
|
|
44
42
|
getUniqueNameForInlineHtmlNode,
|
|
45
43
|
} from "./compileHtml.js"
|
|
44
|
+
import { jsenvCoreDirectoryUrl } from "../jsenvCoreDirectoryUrl.js"
|
|
45
|
+
|
|
46
|
+
const jsenvDistDirectoryUrl = new URL("./dist/", jsenvCoreDirectoryUrl).href
|
|
46
47
|
|
|
47
48
|
export const createTransformHtmlSourceFileService = ({
|
|
48
49
|
logger,
|
|
@@ -70,6 +71,10 @@ export const createTransformHtmlSourceFileService = ({
|
|
|
70
71
|
const relativeUrl = ressource.slice(1)
|
|
71
72
|
const fileUrl = resolveUrl(relativeUrl, projectDirectoryUrl)
|
|
72
73
|
|
|
74
|
+
if (urlIsInsideOf(fileUrl, jsenvDistDirectoryUrl)) {
|
|
75
|
+
return null
|
|
76
|
+
}
|
|
77
|
+
|
|
73
78
|
const inlineScript = htmlInlineScriptMap.get(fileUrl)
|
|
74
79
|
if (inlineScript) {
|
|
75
80
|
return {
|
|
@@ -159,41 +164,38 @@ const transformHTMLSourceFile = async ({
|
|
|
159
164
|
})
|
|
160
165
|
}
|
|
161
166
|
|
|
162
|
-
const
|
|
163
|
-
|
|
167
|
+
const browserRuntimeBuildUrlRelativeToProject = urlToRelativeUrl(
|
|
168
|
+
BROWSER_RUNTIME_BUILD_URL,
|
|
164
169
|
projectDirectoryUrl,
|
|
165
170
|
)
|
|
171
|
+
|
|
166
172
|
const eventSourceClientBuildRelativeUrlForProject = urlToRelativeUrl(
|
|
167
|
-
|
|
173
|
+
EVENT_SOURCE_CLIENT_BUILD_URL,
|
|
168
174
|
projectDirectoryUrl,
|
|
169
175
|
)
|
|
176
|
+
|
|
170
177
|
const toolbarInjectorBuildRelativeUrlForProject = urlToRelativeUrl(
|
|
171
|
-
|
|
178
|
+
TOOLBAR_INJECTOR_BUILD_URL,
|
|
172
179
|
projectDirectoryUrl,
|
|
173
180
|
)
|
|
181
|
+
|
|
174
182
|
manipulateHtmlAst(htmlAst, {
|
|
175
183
|
scriptInjections: [
|
|
176
|
-
...(
|
|
177
|
-
fileUrl !== redirectorHtmlFileInfo.sourceUrl &&
|
|
178
|
-
jsenvScriptInjection
|
|
184
|
+
...(jsenvScriptInjection
|
|
179
185
|
? [
|
|
180
186
|
{
|
|
181
|
-
src: `/${
|
|
187
|
+
src: `/${browserRuntimeBuildUrlRelativeToProject}`,
|
|
182
188
|
},
|
|
183
189
|
]
|
|
184
190
|
: []),
|
|
185
|
-
...(
|
|
186
|
-
fileUrl !== redirectorHtmlFileInfo.sourceUrl &&
|
|
187
|
-
jsenvEventSourceClientInjection
|
|
191
|
+
...(jsenvEventSourceClientInjection
|
|
188
192
|
? [
|
|
189
193
|
{
|
|
190
194
|
src: `/${eventSourceClientBuildRelativeUrlForProject}`,
|
|
191
195
|
},
|
|
192
196
|
]
|
|
193
197
|
: []),
|
|
194
|
-
...(
|
|
195
|
-
fileUrl !== redirectorHtmlFileInfo.sourceUrl &&
|
|
196
|
-
jsenvToolbarInjection
|
|
198
|
+
...(jsenvToolbarInjection
|
|
197
199
|
? [
|
|
198
200
|
{
|
|
199
201
|
src: `/${toolbarInjectorBuildRelativeUrlForProject}`,
|
|
@@ -2,14 +2,14 @@ import { resolveUrl, urlToRelativeUrl } from "@jsenv/filesystem"
|
|
|
2
2
|
import { moveImportMap, composeTwoImportMaps } from "@jsenv/importmap"
|
|
3
3
|
import { createDetailedMessage } from "@jsenv/logger"
|
|
4
4
|
|
|
5
|
-
import { jsenvBrowserSystemFileInfo } from "@jsenv/core/src/internal/jsenvInternalFiles.js"
|
|
6
|
-
import { eventSourceClientFileInfo } from "@jsenv/core/src/internal/dev_server/event_source_client/event_source_client_file_info.js"
|
|
7
5
|
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
BROWSER_RUNTIME_BUILD_URL,
|
|
7
|
+
EVENT_SOURCE_CLIENT_BUILD_URL,
|
|
8
|
+
TOOLBAR_INJECTOR_BUILD_URL,
|
|
9
|
+
} from "@jsenv/core/dist/build_manifest.js"
|
|
11
10
|
import { fetchUrl } from "@jsenv/core/src/internal/fetchUrl.js"
|
|
12
11
|
import { getDefaultImportMap } from "@jsenv/core/src/internal/import-resolution/importmap-default.js"
|
|
12
|
+
|
|
13
13
|
import {
|
|
14
14
|
setJavaScriptSourceMappingUrl,
|
|
15
15
|
sourcemapToBase64Url,
|
|
@@ -54,16 +54,18 @@ export const compileHtml = async ({
|
|
|
54
54
|
jsenvToolbarInjection,
|
|
55
55
|
onHtmlImportmapInfo,
|
|
56
56
|
}) => {
|
|
57
|
-
const
|
|
58
|
-
|
|
57
|
+
const browserRuntimeBuildUrlRelativeToProject = urlToRelativeUrl(
|
|
58
|
+
BROWSER_RUNTIME_BUILD_URL,
|
|
59
59
|
projectDirectoryUrl,
|
|
60
60
|
)
|
|
61
|
+
|
|
61
62
|
const eventSourceClientBuildRelativeUrlForProject = urlToRelativeUrl(
|
|
62
|
-
|
|
63
|
+
EVENT_SOURCE_CLIENT_BUILD_URL,
|
|
63
64
|
projectDirectoryUrl,
|
|
64
65
|
)
|
|
66
|
+
|
|
65
67
|
const toolbarInjectorBuildRelativeUrlForProject = urlToRelativeUrl(
|
|
66
|
-
|
|
68
|
+
TOOLBAR_INJECTOR_BUILD_URL,
|
|
67
69
|
projectDirectoryUrl,
|
|
68
70
|
)
|
|
69
71
|
|
|
@@ -74,26 +76,23 @@ export const compileHtml = async ({
|
|
|
74
76
|
await mutateRessourceHints(htmlAst)
|
|
75
77
|
}
|
|
76
78
|
|
|
77
|
-
const urlNoSearch = urlWithoutSearch(url)
|
|
78
|
-
|
|
79
79
|
manipulateHtmlAst(htmlAst, {
|
|
80
80
|
scriptInjections: [
|
|
81
|
-
...(
|
|
81
|
+
...(jsenvScriptInjection
|
|
82
82
|
? [
|
|
83
83
|
{
|
|
84
|
-
src: `/${
|
|
84
|
+
src: `/${browserRuntimeBuildUrlRelativeToProject}`,
|
|
85
85
|
},
|
|
86
86
|
]
|
|
87
87
|
: []),
|
|
88
|
-
...(
|
|
89
|
-
jsenvEventSourceClientInjection
|
|
88
|
+
...(jsenvEventSourceClientInjection
|
|
90
89
|
? [
|
|
91
90
|
{
|
|
92
91
|
src: `/${eventSourceClientBuildRelativeUrlForProject}`,
|
|
93
92
|
},
|
|
94
93
|
]
|
|
95
94
|
: []),
|
|
96
|
-
...(
|
|
95
|
+
...(jsenvToolbarInjection
|
|
97
96
|
? [
|
|
98
97
|
{
|
|
99
98
|
src: `/${toolbarInjectorBuildRelativeUrlForProject}`,
|
|
@@ -405,9 +404,3 @@ const mutateRessourceHints = async (htmlAst) => {
|
|
|
405
404
|
)
|
|
406
405
|
mutations.forEach((mutation) => mutation())
|
|
407
406
|
}
|
|
408
|
-
|
|
409
|
-
const urlWithoutSearch = (url) => {
|
|
410
|
-
const urlObject = new URL(url)
|
|
411
|
-
urlObject.search = ""
|
|
412
|
-
return urlObject.href
|
|
413
|
-
}
|
|
@@ -29,12 +29,16 @@ import {
|
|
|
29
29
|
createCallbackListNotifiedOnce,
|
|
30
30
|
} from "@jsenv/abort"
|
|
31
31
|
|
|
32
|
+
import {
|
|
33
|
+
TOOLBAR_INJECTOR_BUILD_URL,
|
|
34
|
+
EVENT_SOURCE_CLIENT_BUILD_URL,
|
|
35
|
+
BROWSER_RUNTIME_BUILD_URL,
|
|
36
|
+
} from "@jsenv/core/dist/build_manifest.js"
|
|
32
37
|
import { generateGroupMap } from "@jsenv/core/src/internal/generateGroupMap/generateGroupMap.js"
|
|
33
38
|
import { isBrowserPartOfSupportedRuntimes } from "@jsenv/core/src/internal/generateGroupMap/runtime_support.js"
|
|
34
39
|
import { loadBabelPluginMapFromFile } from "./load_babel_plugin_map_from_file.js"
|
|
35
40
|
import { extractSyntaxBabelPluginMap } from "./babel_plugins.js"
|
|
36
41
|
import {
|
|
37
|
-
jsenvCompileProxyFileInfo,
|
|
38
42
|
sourcemapMainFileInfo,
|
|
39
43
|
sourcemapMappingFileInfo,
|
|
40
44
|
} from "../jsenvInternalFiles.js"
|
|
@@ -47,6 +51,8 @@ import { createCompiledFileService } from "./createCompiledFileService.js"
|
|
|
47
51
|
import { urlIsCompilationAsset } from "./compile-directory/compile-asset.js"
|
|
48
52
|
import { createTransformHtmlSourceFileService } from "./html_source_file_service.js"
|
|
49
53
|
|
|
54
|
+
let compileServerId = 0
|
|
55
|
+
|
|
50
56
|
export const startCompileServer = async ({
|
|
51
57
|
signal = new AbortController().signal,
|
|
52
58
|
handleSIGINT,
|
|
@@ -295,9 +301,6 @@ export const startCompileServer = async ({
|
|
|
295
301
|
outDirectoryUrl,
|
|
296
302
|
compileServerMetaFileInfo,
|
|
297
303
|
}),
|
|
298
|
-
"service: compile proxy": createCompileProxyService({
|
|
299
|
-
projectDirectoryUrl,
|
|
300
|
-
}),
|
|
301
304
|
"service:compiled file": createCompiledFileService({
|
|
302
305
|
logger,
|
|
303
306
|
|
|
@@ -388,6 +391,7 @@ export const startCompileServer = async ({
|
|
|
388
391
|
})
|
|
389
392
|
|
|
390
393
|
return {
|
|
394
|
+
id: compileServerId++,
|
|
391
395
|
jsenvDirectoryRelativeUrl,
|
|
392
396
|
outDirectoryRelativeUrl,
|
|
393
397
|
...compileServer,
|
|
@@ -913,15 +917,24 @@ const createSourceFileService = ({
|
|
|
913
917
|
const relativeUrl = request.pathname.slice(1)
|
|
914
918
|
projectFileRequestedCallback(relativeUrl, request)
|
|
915
919
|
|
|
916
|
-
const
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
mtimeEnabled: projectFileCacheStrategy === "mtime",
|
|
922
|
-
},
|
|
920
|
+
const fileUrl = new URL(request.ressource.slice(1), projectDirectoryUrl)
|
|
921
|
+
.href
|
|
922
|
+
const fileIsInsideJsenvDistDirectory = urlIsInsideOf(
|
|
923
|
+
fileUrl,
|
|
924
|
+
new URL("./dist/", jsenvCoreDirectoryUrl),
|
|
923
925
|
)
|
|
924
926
|
|
|
927
|
+
const responsePromise = fetchFileSystem(fileUrl, {
|
|
928
|
+
headers: request.headers,
|
|
929
|
+
etagEnabled: projectFileCacheStrategy === "etag",
|
|
930
|
+
mtimeEnabled: projectFileCacheStrategy === "mtime",
|
|
931
|
+
...(fileIsInsideJsenvDistDirectory
|
|
932
|
+
? {
|
|
933
|
+
cacheControl: `private,max-age=${60 * 60 * 24 * 30},immutable`,
|
|
934
|
+
}
|
|
935
|
+
: {}),
|
|
936
|
+
})
|
|
937
|
+
|
|
925
938
|
return responsePromise
|
|
926
939
|
}
|
|
927
940
|
}
|
|
@@ -965,6 +978,12 @@ const createCompileServerMetaFileInfo = ({
|
|
|
965
978
|
sourcemapMappingFileInfo.url,
|
|
966
979
|
projectDirectoryUrl,
|
|
967
980
|
)
|
|
981
|
+
// The object below must list everything that can influence how the
|
|
982
|
+
// compiled files are generated. So that the cahce for those generated files is
|
|
983
|
+
// not reused when it should not
|
|
984
|
+
// In some cases the parameters influences only a subset of files and ideally
|
|
985
|
+
// this parameter should somehow invalidate a subset of the cache
|
|
986
|
+
// To keep things simple these parameters currently invalidates the whole cache
|
|
968
987
|
const compileServerMeta = {
|
|
969
988
|
jsenvDirectoryRelativeUrl,
|
|
970
989
|
outDirectoryRelativeUrl,
|
|
@@ -983,8 +1002,15 @@ const createCompileServerMetaFileInfo = ({
|
|
|
983
1002
|
sourcemapMappingFileRelativeUrl,
|
|
984
1003
|
errorStackRemapping: true,
|
|
985
1004
|
|
|
1005
|
+
// used to consider the logic generating files may have changed
|
|
986
1006
|
jsenvCorePackageVersion,
|
|
1007
|
+
|
|
1008
|
+
// impact only HTML files
|
|
987
1009
|
jsenvToolbarInjection,
|
|
1010
|
+
TOOLBAR_INJECTOR_BUILD_URL,
|
|
1011
|
+
EVENT_SOURCE_CLIENT_BUILD_URL,
|
|
1012
|
+
BROWSER_RUNTIME_BUILD_URL,
|
|
1013
|
+
|
|
988
1014
|
env,
|
|
989
1015
|
}
|
|
990
1016
|
return {
|
|
@@ -1054,27 +1080,6 @@ const createCompileServerMetaService = ({
|
|
|
1054
1080
|
}
|
|
1055
1081
|
}
|
|
1056
1082
|
|
|
1057
|
-
const createCompileProxyService = ({ projectDirectoryUrl }) => {
|
|
1058
|
-
const jsenvCompileProxyRelativeUrlForProject = urlToRelativeUrl(
|
|
1059
|
-
jsenvCompileProxyFileInfo.jsenvBuildUrl,
|
|
1060
|
-
projectDirectoryUrl,
|
|
1061
|
-
)
|
|
1062
|
-
|
|
1063
|
-
return (request) => {
|
|
1064
|
-
if (request.ressource === "/.jsenv/jsenv_compile_proxy.js") {
|
|
1065
|
-
const jsenvCompileProxyBuildServerUrl = `${request.origin}/${jsenvCompileProxyRelativeUrlForProject}`
|
|
1066
|
-
return {
|
|
1067
|
-
status: 307,
|
|
1068
|
-
headers: {
|
|
1069
|
-
location: jsenvCompileProxyBuildServerUrl,
|
|
1070
|
-
},
|
|
1071
|
-
}
|
|
1072
|
-
}
|
|
1073
|
-
|
|
1074
|
-
return null
|
|
1075
|
-
}
|
|
1076
|
-
}
|
|
1077
|
-
|
|
1078
1083
|
const readPackage = (packagePath) => {
|
|
1079
1084
|
const buffer = readFileSync(packagePath)
|
|
1080
1085
|
const string = String(buffer)
|
|
@@ -11,21 +11,34 @@ export const createEventSourceConnection = (
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
const eventSourceOrigin = new URL(eventSourceUrl).origin
|
|
14
|
+
Object.keys(events).forEach((eventName) => {
|
|
15
|
+
const eventCallback = events[eventName]
|
|
16
|
+
events[eventName] = (e) => {
|
|
17
|
+
if (e.origin === eventSourceOrigin) {
|
|
18
|
+
if (e.lastEventId) {
|
|
19
|
+
lastEventId = e.lastEventId
|
|
20
|
+
}
|
|
21
|
+
eventCallback(e)
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
})
|
|
14
25
|
|
|
15
26
|
let connectionStatus = "default"
|
|
16
27
|
let connectionStatusChangeCallback = () => {}
|
|
17
|
-
let
|
|
28
|
+
let _disconnect = () => {}
|
|
18
29
|
|
|
19
30
|
const goToStatus = (newStatus) => {
|
|
20
|
-
connectionStatus
|
|
21
|
-
|
|
31
|
+
if (newStatus !== connectionStatus) {
|
|
32
|
+
connectionStatus = newStatus
|
|
33
|
+
connectionStatusChangeCallback()
|
|
34
|
+
}
|
|
22
35
|
}
|
|
23
36
|
|
|
24
37
|
const attemptConnection = (url) => {
|
|
25
38
|
const eventSource = new EventSource(url, {
|
|
26
39
|
withCredentials: true,
|
|
27
40
|
})
|
|
28
|
-
|
|
41
|
+
_disconnect = () => {
|
|
29
42
|
if (
|
|
30
43
|
connectionStatus !== "connecting" &&
|
|
31
44
|
connectionStatus !== "connected"
|
|
@@ -37,6 +50,9 @@ export const createEventSourceConnection = (
|
|
|
37
50
|
}
|
|
38
51
|
eventSource.onerror = undefined
|
|
39
52
|
eventSource.close()
|
|
53
|
+
Object.keys(events).forEach((eventName) => {
|
|
54
|
+
eventSource.removeEventListener(eventName, events[eventName])
|
|
55
|
+
})
|
|
40
56
|
goToStatus("disconnected")
|
|
41
57
|
}
|
|
42
58
|
let retryCount = 0
|
|
@@ -45,7 +61,7 @@ export const createEventSourceConnection = (
|
|
|
45
61
|
if (errorEvent.target.readyState === EventSource.CONNECTING) {
|
|
46
62
|
if (retryCount > retryMaxAttempt) {
|
|
47
63
|
console.info(`could not connect after ${retryMaxAttempt} attempt`)
|
|
48
|
-
|
|
64
|
+
_disconnect()
|
|
49
65
|
return
|
|
50
66
|
}
|
|
51
67
|
|
|
@@ -57,7 +73,7 @@ export const createEventSourceConnection = (
|
|
|
57
73
|
console.info(
|
|
58
74
|
`could not connect in less than ${retryAllocatedMs} ms`,
|
|
59
75
|
)
|
|
60
|
-
|
|
76
|
+
_disconnect()
|
|
61
77
|
return
|
|
62
78
|
}
|
|
63
79
|
}
|
|
@@ -68,7 +84,7 @@ export const createEventSourceConnection = (
|
|
|
68
84
|
}
|
|
69
85
|
|
|
70
86
|
if (errorEvent.target.readyState === EventSource.CLOSED) {
|
|
71
|
-
|
|
87
|
+
_disconnect()
|
|
72
88
|
return
|
|
73
89
|
}
|
|
74
90
|
}
|
|
@@ -76,14 +92,7 @@ export const createEventSourceConnection = (
|
|
|
76
92
|
goToStatus("connected")
|
|
77
93
|
}
|
|
78
94
|
Object.keys(events).forEach((eventName) => {
|
|
79
|
-
eventSource.addEventListener(eventName,
|
|
80
|
-
if (e.origin === eventSourceOrigin) {
|
|
81
|
-
if (e.lastEventId) {
|
|
82
|
-
lastEventId = e.lastEventId
|
|
83
|
-
}
|
|
84
|
-
events[eventName](e)
|
|
85
|
-
}
|
|
86
|
-
})
|
|
95
|
+
eventSource.addEventListener(eventName, events[eventName])
|
|
87
96
|
})
|
|
88
97
|
if (!events.hasOwnProperty("welcome")) {
|
|
89
98
|
eventSource.addEventListener("welcome", (e) => {
|
|
@@ -107,21 +116,21 @@ export const createEventSourceConnection = (
|
|
|
107
116
|
}
|
|
108
117
|
|
|
109
118
|
const removePageUnloadListener = listenPageUnload(() => {
|
|
110
|
-
|
|
119
|
+
_disconnect()
|
|
111
120
|
})
|
|
112
121
|
|
|
113
122
|
const destroy = () => {
|
|
114
123
|
removePageUnloadListener()
|
|
115
|
-
|
|
124
|
+
_disconnect()
|
|
116
125
|
}
|
|
117
126
|
|
|
118
127
|
return {
|
|
119
128
|
getConnectionStatus: () => connectionStatus,
|
|
120
|
-
|
|
129
|
+
setConnectionStatusChangeCallback: (callback) => {
|
|
121
130
|
connectionStatusChangeCallback = callback
|
|
122
131
|
},
|
|
123
132
|
connect,
|
|
124
|
-
disconnect,
|
|
133
|
+
disconnect: () => _disconnect(),
|
|
125
134
|
destroy,
|
|
126
135
|
}
|
|
127
136
|
}
|
|
@@ -35,7 +35,12 @@
|
|
|
35
35
|
<div id="explorables-header">
|
|
36
36
|
<div id="explorables_header_and_menu">
|
|
37
37
|
<h2 style="white-space: nowrap">
|
|
38
|
-
<svg
|
|
38
|
+
<svg
|
|
39
|
+
id="fileIconSvgConfig"
|
|
40
|
+
viewBox="0 0 24 24"
|
|
41
|
+
width="32"
|
|
42
|
+
height="32"
|
|
43
|
+
>
|
|
39
44
|
<path d="M0 0h24v24H0V0z" fill="none" />
|
|
40
45
|
<path
|
|
41
46
|
d="M8 16h8v2H8zm0-4h8v2H8zm6-10H6c-1.1 0-2 .9-2 2v16c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zm4 18H6V4h7v5h5v11z"
|
|
@@ -69,6 +74,6 @@
|
|
|
69
74
|
</section>
|
|
70
75
|
</article>
|
|
71
76
|
</div>
|
|
72
|
-
<script src="
|
|
77
|
+
<script type="module" src="./exploring.js"></script>
|
|
73
78
|
</body>
|
|
74
79
|
</html>
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { fetchJson } from "../../browser-utils/fetchJson.js"
|
|
1
|
+
import { fetchJson } from "../../browser_utils/fetchJson.js"
|
|
4
2
|
|
|
5
3
|
export const fetchExploringJson = async ({ signal } = {}) => {
|
|
6
4
|
try {
|
|
@@ -13,12 +11,9 @@ export const fetchExploringJson = async ({ signal } = {}) => {
|
|
|
13
11
|
throw e
|
|
14
12
|
}
|
|
15
13
|
throw new Error(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
["error stack"]: e.stack,
|
|
20
|
-
},
|
|
21
|
-
),
|
|
14
|
+
`Cannot communicate with exploring server due to a network error
|
|
15
|
+
--- error stack ---
|
|
16
|
+
${e.stack}`,
|
|
22
17
|
)
|
|
23
18
|
}
|
|
24
19
|
}
|
|
@@ -1,13 +1,48 @@
|
|
|
1
1
|
<!DOCTYPE html>
|
|
2
2
|
<html>
|
|
3
3
|
<head>
|
|
4
|
-
<title>
|
|
4
|
+
<title>Jsenv redirector</title>
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
6
|
<meta charset="utf-8" />
|
|
7
7
|
<link rel="icon" href="data:," />
|
|
8
8
|
</head>
|
|
9
9
|
|
|
10
10
|
<body>
|
|
11
|
-
<script
|
|
11
|
+
<script
|
|
12
|
+
type="importmap"
|
|
13
|
+
src="../../../../node_resolution.importmap"
|
|
14
|
+
></script>
|
|
15
|
+
<script type="module">
|
|
16
|
+
import { scanBrowserRuntimeFeatures } from "../../browser_feature_detection/browser_feature_detection.js"
|
|
17
|
+
|
|
18
|
+
const redirect = async () => {
|
|
19
|
+
const redirectTarget = new URLSearchParams(window.location.search).get(
|
|
20
|
+
"redirect",
|
|
21
|
+
)
|
|
22
|
+
const browserRuntimeFeaturesReport = await scanBrowserRuntimeFeatures({
|
|
23
|
+
failFastOnFeatureDetection: true,
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
const href = `${getDirectoryUrl(
|
|
27
|
+
browserRuntimeFeaturesReport,
|
|
28
|
+
)}${redirectTarget}`
|
|
29
|
+
// It's IMPORTANT to use location.replace and NOT location.href = url
|
|
30
|
+
// otherwise it would break the back button
|
|
31
|
+
window.location.replace(href)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const getDirectoryUrl = ({
|
|
35
|
+
canAvoidCompilation,
|
|
36
|
+
outDirectoryRelativeUrl,
|
|
37
|
+
compileId,
|
|
38
|
+
}) => {
|
|
39
|
+
if (canAvoidCompilation) {
|
|
40
|
+
return `/`
|
|
41
|
+
}
|
|
42
|
+
return `/${outDirectoryRelativeUrl}${compileId}/`
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
redirect()
|
|
46
|
+
</script>
|
|
12
47
|
</body>
|
|
13
48
|
</html>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { scanBrowserRuntimeFeatures } from "../../../
|
|
1
|
+
import { scanBrowserRuntimeFeatures } from "../../../browser_feature_detection/browser_feature_detection.js"
|
|
2
2
|
import { removeForceHideElement } from "../util/dom.js"
|
|
3
3
|
import { enableVariant } from "../variant/variant.js"
|
|
4
4
|
|
|
@@ -133,8 +133,7 @@ const getBrowserSupportMessage = ({
|
|
|
133
133
|
}) => {
|
|
134
134
|
const parts = []
|
|
135
135
|
|
|
136
|
-
|
|
137
|
-
if (importmapSupported) {
|
|
136
|
+
if (featuresReport.importmap) {
|
|
138
137
|
if (!missingOnly) {
|
|
139
138
|
if (inlineImportMapIntoHTML) {
|
|
140
139
|
parts.push(`importmaps are supported (only when inlined in html files)`)
|
|
@@ -146,8 +145,7 @@ const getBrowserSupportMessage = ({
|
|
|
146
145
|
parts.push(`importmaps are not supported`)
|
|
147
146
|
}
|
|
148
147
|
|
|
149
|
-
|
|
150
|
-
if (dynamicImportSupported) {
|
|
148
|
+
if (featuresReport.dynamicImport) {
|
|
151
149
|
if (!missingOnly) {
|
|
152
150
|
parts.push(`dynamic imports are supported`)
|
|
153
151
|
}
|
|
@@ -155,8 +153,7 @@ const getBrowserSupportMessage = ({
|
|
|
155
153
|
parts.push(`dynamic imports are not supported`)
|
|
156
154
|
}
|
|
157
155
|
|
|
158
|
-
|
|
159
|
-
if (topLevelAwaitSupported) {
|
|
156
|
+
if (featuresReport.topLevelAwait) {
|
|
160
157
|
if (!missingOnly) {
|
|
161
158
|
parts.push(`top level await is supported`)
|
|
162
159
|
}
|
|
@@ -15,9 +15,9 @@ export const initToolbarEventSource = ({ livereloading }) => {
|
|
|
15
15
|
if (!livereloadingAvailableOnServer) {
|
|
16
16
|
disableLivereloadSetting()
|
|
17
17
|
}
|
|
18
|
-
parentEventSourceClient.setConnectionStatusChangeCallback
|
|
18
|
+
parentEventSourceClient.setConnectionStatusChangeCallback(() => {
|
|
19
19
|
updateEventSourceIndicator()
|
|
20
|
-
}
|
|
20
|
+
})
|
|
21
21
|
const livereloadCheckbox = document.querySelector("#toggle-livereload")
|
|
22
22
|
livereloadCheckbox.checked = parentEventSourceClient.isLivereloadEnabled()
|
|
23
23
|
livereloadCheckbox.onchange = () => {
|