@jsenv/core 24.2.2 → 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.
- package/{license → LICENSE} +0 -0
- 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-d3d98c2e.html +4778 -0
- package/dist/toolbar/toolbar.main-cab36c15.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-01f71ce3.js} +85 -65
- package/dist/toolbar_injector/toolbar_injector-01f71ce3.js.map +294 -0
- package/main.js +0 -1
- package/package.json +4 -2
- package/readme.md +10 -7
- package/src/buildProject.js +6 -2
- package/src/dev_server.js +22 -130
- 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_launcher}/createSharing.js +0 -0
- package/src/internal/{browser-launcher → browser_launcher}/executeHtmlFile.js +7 -4
- 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 +34 -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 +53 -36
- package/src/internal/dev_server/toolbar/toolbar.main.js +44 -31
- package/src/internal/dev_server/toolbar/util/fetching.js +1 -1
- 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_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 +3 -3
- package/src/launchNode.js +33 -7
- package/src/requireUsingChildProcess.js +1 -1
- package/dist/jsenv_compile_proxy.js +0 -1339
- package/dist/jsenv_compile_proxy.js.map +0 -378
- package/dist/jsenv_event_source_client.js.map +0 -126
- package/dist/jsenv_exploring_index.js +0 -1092
- package/dist/jsenv_exploring_index.js.map +0 -353
- package/dist/jsenv_exploring_redirector.js +0 -1386
- package/dist/jsenv_exploring_redirector.js.map +0 -384
- package/dist/jsenv_redirector.js +0 -1388
- package/dist/jsenv_redirector.js.map +0 -384
- package/dist/jsenv_toolbar.js +0 -2880
- package/dist/jsenv_toolbar.js.map +0 -771
- package/dist/jsenv_toolbar_injector.js.map +0 -301
- package/src/internal/browser-launcher/jsenv_compile_proxy.html +0 -13
- package/src/internal/browser-launcher/jsenv_compile_proxy.js +0 -5
- package/src/internal/dev_server/event_source_client/event_source_client_file_info.js +0 -17
- package/src/internal/dev_server/exploring/exploring_file_info.js +0 -21
- package/src/internal/dev_server/redirector/redirector.js +0 -30
- package/src/internal/dev_server/redirector/redirector_file_info.js +0 -24
- package/src/internal/dev_server/toolbar/backtolist/toolbar.backtolist.js +0 -33
- package/src/internal/dev_server/toolbar/toolbar_file_info.js +0 -37
- package/src/internal/node-launcher/node-js-file.js +0 -110
- package/src/internal/runtime/createNodeRuntime/createNodeRuntime.js +0 -32
- package/src/internal/runtime/node-feature-detect/nodeSupportsTopLevelAwait.js +0 -18
- package/src/nodeRuntime.js +0 -5
|
@@ -51,6 +51,7 @@ import {
|
|
|
51
51
|
import { collectNodesMutations } from "../parsing.utils.js"
|
|
52
52
|
|
|
53
53
|
import { collectSvgMutations } from "../svg/parseSvgRessource.js"
|
|
54
|
+
import { moveCssUrls } from "../css/moveCssUrls.js"
|
|
54
55
|
|
|
55
56
|
export const parseHtmlRessource = async (
|
|
56
57
|
htmlRessource,
|
|
@@ -144,11 +145,12 @@ export const parseHtmlRessource = async (
|
|
|
144
145
|
]
|
|
145
146
|
|
|
146
147
|
return async (params) => {
|
|
147
|
-
htmlMutations.
|
|
148
|
-
|
|
148
|
+
await htmlMutations.reduce(async (previous, mutationCallback) => {
|
|
149
|
+
await previous
|
|
150
|
+
await mutationCallback({
|
|
149
151
|
...params,
|
|
150
152
|
})
|
|
151
|
-
})
|
|
153
|
+
}, Promise.resolve())
|
|
152
154
|
|
|
153
155
|
const htmlAfterTransformation = htmlAstToHtmlString(htmlAst)
|
|
154
156
|
const html = minify
|
|
@@ -507,7 +509,11 @@ const linkStylesheetHrefVisitor = (
|
|
|
507
509
|
ressourceSpecifier: hrefAttribute.value,
|
|
508
510
|
...referenceLocationFromHtmlNode(link, "href"),
|
|
509
511
|
})
|
|
510
|
-
return ({
|
|
512
|
+
return async ({
|
|
513
|
+
getUrlRelativeToImporter,
|
|
514
|
+
precomputeBuildRelativeUrl,
|
|
515
|
+
buildDirectoryUrl,
|
|
516
|
+
}) => {
|
|
511
517
|
const { ressource } = cssReference
|
|
512
518
|
|
|
513
519
|
if (ressource.isExternal) {
|
|
@@ -516,18 +522,38 @@ const linkStylesheetHrefVisitor = (
|
|
|
516
522
|
|
|
517
523
|
if (shouldInline({ ressource, htmlNode: link })) {
|
|
518
524
|
const { bufferAfterBuild } = ressource
|
|
519
|
-
let
|
|
520
|
-
const
|
|
525
|
+
let code = String(bufferAfterBuild)
|
|
526
|
+
const { buildRelativeUrl } = ressource
|
|
527
|
+
const cssBuildUrl = resolveUrl(buildRelativeUrl, buildDirectoryUrl)
|
|
528
|
+
const htmlUrl = resolveUrl(
|
|
529
|
+
precomputeBuildRelativeUrl(htmlRessource),
|
|
530
|
+
buildDirectoryUrl,
|
|
531
|
+
)
|
|
532
|
+
|
|
533
|
+
const moveResult = await moveCssUrls({
|
|
534
|
+
code,
|
|
535
|
+
from: cssBuildUrl,
|
|
536
|
+
to: htmlUrl,
|
|
537
|
+
// moveCssUrls will change the css source code
|
|
538
|
+
// Ideally we should update the sourcemap referenced by css
|
|
539
|
+
// to target the one after css urls are moved.
|
|
540
|
+
// It means we should force sourcemap ressource to the new one
|
|
541
|
+
// until it's supported we prevent postcss from updating the
|
|
542
|
+
// sourcemap comment, othwise css would reference a sourcemap
|
|
543
|
+
// that won't by in the build directory
|
|
544
|
+
sourcemapMethod: null,
|
|
545
|
+
})
|
|
546
|
+
code = moveResult.code
|
|
547
|
+
|
|
548
|
+
const sourcemapRelativeUrl = getCssSourceMappingUrl(code)
|
|
521
549
|
if (sourcemapRelativeUrl) {
|
|
522
|
-
const
|
|
523
|
-
const cssBuildUrl = resolveUrl(buildRelativeUrl, "file:///")
|
|
550
|
+
const cssBuildUrl = resolveUrl(buildRelativeUrl, buildDirectoryUrl)
|
|
524
551
|
const sourcemapBuildUrl = resolveUrl(sourcemapRelativeUrl, cssBuildUrl)
|
|
525
|
-
const htmlUrl = resolveUrl(htmlRessource.fileNamePattern, "file:///")
|
|
526
552
|
const sourcemapInlineUrl = urlToRelativeUrl(sourcemapBuildUrl, htmlUrl)
|
|
527
|
-
|
|
553
|
+
code = setCssSourceMappingUrl(code, sourcemapInlineUrl)
|
|
528
554
|
}
|
|
529
555
|
|
|
530
|
-
replaceHtmlNode(link, `<style>${
|
|
556
|
+
replaceHtmlNode(link, `<style>${code}</style>`, {
|
|
531
557
|
attributesToIgnore: ["href", "rel", "as", "crossorigin", "type"],
|
|
532
558
|
})
|
|
533
559
|
cssReference.inlinedCallback()
|
|
@@ -39,6 +39,7 @@ export const parseRessource = (
|
|
|
39
39
|
minifyJs,
|
|
40
40
|
minifyHtml,
|
|
41
41
|
minifyCssOptions,
|
|
42
|
+
cssConcatenation,
|
|
42
43
|
},
|
|
43
44
|
) => {
|
|
44
45
|
const { contentType } = ressource
|
|
@@ -124,10 +125,12 @@ export const parseRessource = (
|
|
|
124
125
|
|
|
125
126
|
if (contentType === "text/css") {
|
|
126
127
|
return parseCssRessource(ressource, notifiers, {
|
|
128
|
+
asProjectUrl,
|
|
127
129
|
asOriginalUrl,
|
|
128
130
|
asOriginalServerUrl,
|
|
129
131
|
minify,
|
|
130
132
|
minifyCssOptions,
|
|
133
|
+
cssConcatenation,
|
|
131
134
|
})
|
|
132
135
|
}
|
|
133
136
|
|
|
@@ -49,6 +49,7 @@ export const createRessourceBuilder = (
|
|
|
49
49
|
entryUrl,
|
|
50
50
|
entryBuffer,
|
|
51
51
|
entryBuildRelativeUrl,
|
|
52
|
+
urlVersionningForEntryPoints,
|
|
52
53
|
}) => {
|
|
53
54
|
// The entry point is conceptually referenced by code passing "entryPointMap"
|
|
54
55
|
// to buildProject. So we analyse stack trace to put this function caller
|
|
@@ -68,8 +69,12 @@ export const createRessourceBuilder = (
|
|
|
68
69
|
isEntryPoint: true,
|
|
69
70
|
|
|
70
71
|
// don't hash asset entry points
|
|
71
|
-
|
|
72
|
-
|
|
72
|
+
...(urlVersionningForEntryPoints
|
|
73
|
+
? {}
|
|
74
|
+
: {
|
|
75
|
+
urlVersioningDisabled: true,
|
|
76
|
+
fileNamePattern: entryBuildRelativeUrl,
|
|
77
|
+
}),
|
|
73
78
|
})
|
|
74
79
|
entryReference.isProgrammatic = true
|
|
75
80
|
|
|
@@ -567,6 +572,10 @@ export const createRessourceBuilder = (
|
|
|
567
572
|
)
|
|
568
573
|
await transform({
|
|
569
574
|
buildDirectoryUrl,
|
|
575
|
+
precomputeBuildRelativeUrl: (ressource) =>
|
|
576
|
+
precomputeBuildRelativeUrlForRessource(ressource, {
|
|
577
|
+
lineBreakNormalization,
|
|
578
|
+
}),
|
|
570
579
|
getUrlRelativeToImporter: (referencedRessource) => {
|
|
571
580
|
const ressourceImporter = ressource
|
|
572
581
|
|
|
@@ -1021,7 +1030,7 @@ const isEmitChunkNeeded = ({ ressource, reference }) => {
|
|
|
1021
1030
|
*
|
|
1022
1031
|
* see also:
|
|
1023
1032
|
* - https://rollupjs.org/guide/en/#thisemitfileemittedfile-emittedchunk--emittedasset--string
|
|
1024
|
-
* -https://github.com/rollup/rollup/issues/2872
|
|
1033
|
+
* - https://github.com/rollup/rollup/issues/2872
|
|
1025
1034
|
*/
|
|
1026
1035
|
const referenceShouldBeIgnoredWarning = ({
|
|
1027
1036
|
isJsModule,
|
|
@@ -10,8 +10,7 @@ export const babelPluginImportAssertions = (
|
|
|
10
10
|
return {
|
|
11
11
|
...babelPluginImportVisitor(
|
|
12
12
|
babel,
|
|
13
|
-
// During
|
|
14
|
-
// sepcifier or type is dynamic.
|
|
13
|
+
// During build we throw on import call expression where "specifier" or "type" is dynamic
|
|
15
14
|
// Here there is no strong need to throw because keeping the source code intact
|
|
16
15
|
// will throw an error when browser will execute the code
|
|
17
16
|
({ importPath, specifierPath }) => {
|
|
@@ -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"
|
|
@@ -295,9 +299,6 @@ export const startCompileServer = async ({
|
|
|
295
299
|
outDirectoryUrl,
|
|
296
300
|
compileServerMetaFileInfo,
|
|
297
301
|
}),
|
|
298
|
-
"service: compile proxy": createCompileProxyService({
|
|
299
|
-
projectDirectoryUrl,
|
|
300
|
-
}),
|
|
301
302
|
"service:compiled file": createCompiledFileService({
|
|
302
303
|
logger,
|
|
303
304
|
|
|
@@ -913,15 +914,24 @@ const createSourceFileService = ({
|
|
|
913
914
|
const relativeUrl = request.pathname.slice(1)
|
|
914
915
|
projectFileRequestedCallback(relativeUrl, request)
|
|
915
916
|
|
|
916
|
-
const
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
mtimeEnabled: projectFileCacheStrategy === "mtime",
|
|
922
|
-
},
|
|
917
|
+
const fileUrl = new URL(request.ressource.slice(1), projectDirectoryUrl)
|
|
918
|
+
.href
|
|
919
|
+
const fileIsInsideJsenvDistDirectory = urlIsInsideOf(
|
|
920
|
+
fileUrl,
|
|
921
|
+
new URL("./dist/", jsenvCoreDirectoryUrl),
|
|
923
922
|
)
|
|
924
923
|
|
|
924
|
+
const responsePromise = fetchFileSystem(fileUrl, {
|
|
925
|
+
headers: request.headers,
|
|
926
|
+
etagEnabled: projectFileCacheStrategy === "etag",
|
|
927
|
+
mtimeEnabled: projectFileCacheStrategy === "mtime",
|
|
928
|
+
...(fileIsInsideJsenvDistDirectory
|
|
929
|
+
? {
|
|
930
|
+
cacheControl: `private,max-age=${60 * 60 * 24 * 30},immutable`,
|
|
931
|
+
}
|
|
932
|
+
: {}),
|
|
933
|
+
})
|
|
934
|
+
|
|
925
935
|
return responsePromise
|
|
926
936
|
}
|
|
927
937
|
}
|
|
@@ -965,6 +975,12 @@ const createCompileServerMetaFileInfo = ({
|
|
|
965
975
|
sourcemapMappingFileInfo.url,
|
|
966
976
|
projectDirectoryUrl,
|
|
967
977
|
)
|
|
978
|
+
// The object below must list everything that can influence how the
|
|
979
|
+
// compiled files are generated. So that the cahce for those generated files is
|
|
980
|
+
// not reused when it should not
|
|
981
|
+
// In some cases the parameters influences only a subset of files and ideally
|
|
982
|
+
// this parameter should somehow invalidate a subset of the cache
|
|
983
|
+
// To keep things simple these parameters currently invalidates the whole cache
|
|
968
984
|
const compileServerMeta = {
|
|
969
985
|
jsenvDirectoryRelativeUrl,
|
|
970
986
|
outDirectoryRelativeUrl,
|
|
@@ -983,8 +999,15 @@ const createCompileServerMetaFileInfo = ({
|
|
|
983
999
|
sourcemapMappingFileRelativeUrl,
|
|
984
1000
|
errorStackRemapping: true,
|
|
985
1001
|
|
|
1002
|
+
// used to consider the logic generating files may have changed
|
|
986
1003
|
jsenvCorePackageVersion,
|
|
1004
|
+
|
|
1005
|
+
// impact only HTML files
|
|
987
1006
|
jsenvToolbarInjection,
|
|
1007
|
+
TOOLBAR_INJECTOR_BUILD_URL,
|
|
1008
|
+
EVENT_SOURCE_CLIENT_BUILD_URL,
|
|
1009
|
+
BROWSER_RUNTIME_BUILD_URL,
|
|
1010
|
+
|
|
988
1011
|
env,
|
|
989
1012
|
}
|
|
990
1013
|
return {
|
|
@@ -1054,27 +1077,6 @@ const createCompileServerMetaService = ({
|
|
|
1054
1077
|
}
|
|
1055
1078
|
}
|
|
1056
1079
|
|
|
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
1080
|
const readPackage = (packagePath) => {
|
|
1079
1081
|
const buffer = readFileSync(packagePath)
|
|
1080
1082
|
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>
|