@jsenv/core 24.2.1 → 24.3.3
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 +26 -130
- package/src/execute.js +7 -10
- 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}/createSharing.js +0 -0
- package/src/internal/{browser-launcher → browser_launcher}/executeHtmlFile.js +13 -16
- 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 +5 -4
- package/src/internal/executing/executePlan.js +1 -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 +12 -3
- 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/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
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { fetchExploringJson } from "@jsenv/core/src/internal/dev_server/exploring/fetchExploringJson.js"
|
|
2
2
|
import { setAttributes, setStyles } from "./util/dom.js"
|
|
3
3
|
|
|
4
|
+
// eslint-disable-next-line no-undef
|
|
5
|
+
const TOOLBAR_BUILD_RELATIVE_URL = __TOOLBAR_BUILD_RELATIVE_URL_
|
|
6
|
+
const jsenvLogoSvgUrl = new URL("./jsenv-logo.svg", import.meta.url)
|
|
7
|
+
|
|
4
8
|
const injectToolbar = async () => {
|
|
5
9
|
await new Promise((resolve) => {
|
|
6
10
|
if (window.requestIdleCallback) {
|
|
@@ -40,7 +44,7 @@ const injectToolbar = async () => {
|
|
|
40
44
|
})
|
|
41
45
|
const iframeLoadedPromise = iframeToLoadedPromise(iframe)
|
|
42
46
|
const jsenvToolbarHtmlServerUrl = resolveUrl(
|
|
43
|
-
|
|
47
|
+
TOOLBAR_BUILD_RELATIVE_URL,
|
|
44
48
|
jsenvDirectoryServerUrl,
|
|
45
49
|
)
|
|
46
50
|
// set iframe src BEFORE putting it into the DOM (prevent firefox adding an history entry)
|
|
@@ -50,40 +54,11 @@ const injectToolbar = async () => {
|
|
|
50
54
|
await iframeLoadedPromise
|
|
51
55
|
iframe.removeAttribute("tabindex")
|
|
52
56
|
|
|
53
|
-
const listenToolbarIframeEvent = (event, fn) => {
|
|
54
|
-
window.addEventListener(
|
|
55
|
-
"message",
|
|
56
|
-
(messageEvent) => {
|
|
57
|
-
const { data } = messageEvent
|
|
58
|
-
if (typeof data !== "object") return
|
|
59
|
-
const { jsenv } = data
|
|
60
|
-
if (!jsenv) return
|
|
61
|
-
const { type } = data
|
|
62
|
-
if (type !== event) return
|
|
63
|
-
fn(data.value)
|
|
64
|
-
},
|
|
65
|
-
false,
|
|
66
|
-
)
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
listenToolbarIframeEvent("toolbar-visibility-change", (visible) => {
|
|
70
|
-
if (visible) {
|
|
71
|
-
hideToolbarTrigger()
|
|
72
|
-
} else {
|
|
73
|
-
showToolbarTrigger()
|
|
74
|
-
}
|
|
75
|
-
})
|
|
76
|
-
|
|
77
57
|
const div = document.createElement("div")
|
|
78
|
-
const jsenvLogoUrl = resolveUrl(
|
|
79
|
-
"./src/internal/dev_server/toolbar/jsenv-logo.svg",
|
|
80
|
-
jsenvDirectoryServerUrl,
|
|
81
|
-
)
|
|
82
|
-
const jsenvLogoSvgSrc = jsenvLogoUrl
|
|
83
58
|
div.innerHTML = `
|
|
84
59
|
<div id="jsenv-toolbar-trigger">
|
|
85
60
|
<svg id="jsenv-toolbar-trigger-icon">
|
|
86
|
-
<use xlink:href="${
|
|
61
|
+
<use xlink:href="${jsenvLogoSvgUrl}#jsenv-logo"></use>
|
|
87
62
|
</svg>
|
|
88
63
|
<style>
|
|
89
64
|
#jsenv-toolbar-trigger {
|
|
@@ -148,7 +123,7 @@ const injectToolbar = async () => {
|
|
|
148
123
|
collapseToolbarTrigger()
|
|
149
124
|
}
|
|
150
125
|
toolbarTrigger.onclick = () => {
|
|
151
|
-
|
|
126
|
+
sendCommandToToolbar(iframe, "showToolbar")
|
|
152
127
|
}
|
|
153
128
|
|
|
154
129
|
const showToolbarTrigger = () => {
|
|
@@ -166,13 +141,56 @@ const injectToolbar = async () => {
|
|
|
166
141
|
const collapseToolbarTrigger = () => {
|
|
167
142
|
toolbarTrigger.removeAttribute("data-expanded", "")
|
|
168
143
|
}
|
|
169
|
-
hideToolbarTrigger()
|
|
170
144
|
|
|
171
|
-
|
|
145
|
+
hideToolbarTrigger()
|
|
146
|
+
addToolbarEventCallback(iframe, "toolbar-visibility-change", (visible) => {
|
|
147
|
+
if (visible) {
|
|
148
|
+
hideToolbarTrigger()
|
|
149
|
+
} else {
|
|
150
|
+
showToolbarTrigger()
|
|
151
|
+
}
|
|
152
|
+
})
|
|
153
|
+
addToolbarEventCallback(iframe, "toolbar_ready", () => {
|
|
154
|
+
sendCommandToToolbar(iframe, "renderToolbar")
|
|
155
|
+
})
|
|
172
156
|
|
|
173
157
|
return iframe
|
|
174
158
|
}
|
|
175
159
|
|
|
160
|
+
const addToolbarEventCallback = (iframe, eventName, callback) => {
|
|
161
|
+
const messageEventCallback = (messageEvent) => {
|
|
162
|
+
const { data } = messageEvent
|
|
163
|
+
if (typeof data !== "object") {
|
|
164
|
+
return
|
|
165
|
+
}
|
|
166
|
+
const { __jsenv__ } = data
|
|
167
|
+
if (!__jsenv__) {
|
|
168
|
+
return
|
|
169
|
+
}
|
|
170
|
+
if (__jsenv__.event !== eventName) {
|
|
171
|
+
return
|
|
172
|
+
}
|
|
173
|
+
callback(__jsenv__.data)
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
window.addEventListener("message", messageEventCallback, false)
|
|
177
|
+
return () => {
|
|
178
|
+
window.removeEventListener("message", messageEventCallback, false)
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
const sendCommandToToolbar = (iframe, command, ...args) => {
|
|
183
|
+
iframe.contentWindow.postMessage(
|
|
184
|
+
{
|
|
185
|
+
__jsenv__: {
|
|
186
|
+
command,
|
|
187
|
+
args,
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
window.origin,
|
|
191
|
+
)
|
|
192
|
+
}
|
|
193
|
+
|
|
176
194
|
const getToolbarPlaceholder = () => {
|
|
177
195
|
const placeholder = queryPlaceholder()
|
|
178
196
|
if (placeholder) {
|
|
@@ -188,8 +206,9 @@ const getToolbarPlaceholder = () => {
|
|
|
188
206
|
return createTooolbarPlaceholder()
|
|
189
207
|
}
|
|
190
208
|
|
|
191
|
-
const queryPlaceholder = () =>
|
|
192
|
-
document.querySelector("[data-jsenv-toolbar-placeholder]")
|
|
209
|
+
const queryPlaceholder = () => {
|
|
210
|
+
return document.querySelector("[data-jsenv-toolbar-placeholder]")
|
|
211
|
+
}
|
|
193
212
|
|
|
194
213
|
const createTooolbarPlaceholder = () => {
|
|
195
214
|
const placeholder = document.createElement("span")
|
|
@@ -4,7 +4,6 @@ import { urlToRelativeUrl } from "@jsenv/filesystem/src/urlToRelativeUrl.js"
|
|
|
4
4
|
import { fetchExploringJson } from "../exploring/fetchExploringJson.js"
|
|
5
5
|
import { startJavaScriptAnimation } from "../toolbar/util/animation.js"
|
|
6
6
|
import "./focus/toolbar.focus.js"
|
|
7
|
-
import { renderBackToListInToolbar } from "./backtolist/toolbar.backtolist.js"
|
|
8
7
|
import {
|
|
9
8
|
getToolbarIframe,
|
|
10
9
|
deactivateToolbarSection,
|
|
@@ -45,16 +44,6 @@ const renderToolbar = async () => {
|
|
|
45
44
|
hideSettings()
|
|
46
45
|
}
|
|
47
46
|
|
|
48
|
-
const toolbarElement = document.querySelector("#toolbar")
|
|
49
|
-
exposeOnParentWindow({
|
|
50
|
-
toolbar: {
|
|
51
|
-
element: toolbarElement,
|
|
52
|
-
show: showToolbar,
|
|
53
|
-
hide: () => hideToolbar(),
|
|
54
|
-
toggle: toogleToolbar,
|
|
55
|
-
},
|
|
56
|
-
})
|
|
57
|
-
|
|
58
47
|
const toolbarVisible = toolbarVisibilityPreference.has()
|
|
59
48
|
? toolbarVisibilityPreference.get()
|
|
60
49
|
: true
|
|
@@ -65,11 +54,6 @@ const renderToolbar = async () => {
|
|
|
65
54
|
hideToolbar({ animate: false })
|
|
66
55
|
}
|
|
67
56
|
|
|
68
|
-
renderBackToListInToolbar({
|
|
69
|
-
outDirectoryRelativeUrl,
|
|
70
|
-
exploringHtmlFileRelativeUrl: exploringConfig.exploringHtmlFileRelativeUrl,
|
|
71
|
-
})
|
|
72
|
-
|
|
73
57
|
renderToolbarNotification()
|
|
74
58
|
makeToolbarResponsive()
|
|
75
59
|
renderToolbarSettings()
|
|
@@ -91,16 +75,6 @@ const renderToolbar = async () => {
|
|
|
91
75
|
toogleToolbar()
|
|
92
76
|
}
|
|
93
77
|
|
|
94
|
-
const exposeOnParentWindow = (object) => {
|
|
95
|
-
let { __jsenv__ } = window.parent
|
|
96
|
-
if (!__jsenv__) {
|
|
97
|
-
__jsenv__ = {}
|
|
98
|
-
window.parent.__jsenv__ = {}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
Object.assign(__jsenv__, object)
|
|
102
|
-
}
|
|
103
|
-
|
|
104
78
|
const toogleToolbar = () => {
|
|
105
79
|
if (toolbarIsVisible()) {
|
|
106
80
|
hideToolbar()
|
|
@@ -213,15 +187,55 @@ const getCompileGroup = ({
|
|
|
213
187
|
}
|
|
214
188
|
}
|
|
215
189
|
|
|
216
|
-
const
|
|
190
|
+
const addExternalCommandCallback = (command, callback) => {
|
|
191
|
+
const messageEventCallback = (messageEvent) => {
|
|
192
|
+
const { data } = messageEvent
|
|
193
|
+
if (typeof data !== "object") {
|
|
194
|
+
return
|
|
195
|
+
}
|
|
196
|
+
const { __jsenv__ } = data
|
|
197
|
+
if (!__jsenv__) {
|
|
198
|
+
return
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
if (__jsenv__.command !== command) {
|
|
202
|
+
return
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
callback(...__jsenv__.args)
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
window.addEventListener("message", messageEventCallback)
|
|
209
|
+
return () => {
|
|
210
|
+
window.removeEventListener("message", messageEventCallback)
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
const sendEventToParent = (name, data) => {
|
|
217
215
|
window.parent.postMessage(
|
|
218
216
|
{
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
217
|
+
__jsenv__: {
|
|
218
|
+
event: name,
|
|
219
|
+
data,
|
|
220
|
+
},
|
|
222
221
|
},
|
|
223
222
|
"*",
|
|
224
223
|
)
|
|
225
224
|
}
|
|
226
225
|
|
|
227
|
-
window.
|
|
226
|
+
window.toolbar = {
|
|
227
|
+
render: renderToolbar,
|
|
228
|
+
show: showToolbar,
|
|
229
|
+
hide: () => hideToolbar(),
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
addExternalCommandCallback("renderToolbar", () => {
|
|
233
|
+
renderToolbar()
|
|
234
|
+
})
|
|
235
|
+
addExternalCommandCallback("showToolbar", () => {
|
|
236
|
+
showToolbar()
|
|
237
|
+
})
|
|
238
|
+
addExternalCommandCallback("hideToolbar", () => {
|
|
239
|
+
hideToolbar()
|
|
240
|
+
})
|
|
241
|
+
sendEventToParent("toolbar_ready")
|
|
@@ -27,8 +27,7 @@ export const executeConcurrently = async (
|
|
|
27
27
|
launchAndExecuteLogLevel,
|
|
28
28
|
|
|
29
29
|
projectDirectoryUrl,
|
|
30
|
-
|
|
31
|
-
outDirectoryRelativeUrl,
|
|
30
|
+
compileServer,
|
|
32
31
|
|
|
33
32
|
babelPluginMap,
|
|
34
33
|
|
|
@@ -206,8 +205,10 @@ export const executeConcurrently = async (
|
|
|
206
205
|
coverageTempDirectoryUrl,
|
|
207
206
|
runtimeParams: {
|
|
208
207
|
projectDirectoryUrl,
|
|
209
|
-
compileServerOrigin,
|
|
210
|
-
|
|
208
|
+
compileServerOrigin: compileServer.origin,
|
|
209
|
+
compileServerId: compileServer.id,
|
|
210
|
+
outDirectoryRelativeUrl: compileServer.outDirectoryRelativeUrl,
|
|
211
|
+
|
|
211
212
|
collectCoverage: coverage,
|
|
212
213
|
coverageIgnorePredicate,
|
|
213
214
|
coverageForceIstanbul,
|
|
@@ -146,8 +146,7 @@ export const executePlan = async (
|
|
|
146
146
|
launchAndExecuteLogLevel,
|
|
147
147
|
|
|
148
148
|
projectDirectoryUrl,
|
|
149
|
-
|
|
150
|
-
outDirectoryRelativeUrl: compileServer.outDirectoryRelativeUrl,
|
|
149
|
+
compileServer,
|
|
151
150
|
|
|
152
151
|
// not sure we actually have to pass import params to executeConcurrently
|
|
153
152
|
importResolutionMethod,
|
|
@@ -14,32 +14,6 @@ export const jsenvNodeSystemFileInfo = {
|
|
|
14
14
|
),
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
export const jsenvBrowserSystemFileInfo = {
|
|
18
|
-
jsenvRelativeUrl: "./src/internal/browser-launcher/jsenv-browser-system.js",
|
|
19
|
-
jsenvBuildRelativeUrl: "./jsenv_browser_system.js",
|
|
20
|
-
jsenvBuildUrl: resolveUrl(
|
|
21
|
-
"./dist/jsenv_browser_system.js",
|
|
22
|
-
jsenvCoreDirectoryUrl,
|
|
23
|
-
),
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export const jsenvCompileProxyHtmlFileInfo = {
|
|
27
|
-
jsenvRelativeUrl: "./src/internal/browser-launcher/jsenv_compile_proxy.html",
|
|
28
|
-
url: resolveUrl(
|
|
29
|
-
"./src/internal/browser-launcher/jsenv_compile_proxy.html",
|
|
30
|
-
jsenvCoreDirectoryUrl,
|
|
31
|
-
),
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export const jsenvCompileProxyFileInfo = {
|
|
35
|
-
jsenvRelativeUrl: "./src/internal/browser-launcher/jsenv_compile_proxy.js",
|
|
36
|
-
jsenvBuildRelativeUrl: "./jsenv_compile_proxy.js",
|
|
37
|
-
jsenvBuildUrl: resolveUrl(
|
|
38
|
-
"./dist/jsenv_compile_proxy.js",
|
|
39
|
-
jsenvCoreDirectoryUrl,
|
|
40
|
-
),
|
|
41
|
-
}
|
|
42
|
-
|
|
43
17
|
export const sourcemapMainFileInfo = {
|
|
44
18
|
url: fileSystemPathToUrl(require.resolve("source-map/dist/source-map.js")),
|
|
45
19
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { readFile } from "@jsenv/filesystem"
|
|
2
|
+
|
|
3
|
+
import { jsenvCoreDirectoryUrl } from "./jsenvCoreDirectoryUrl.js"
|
|
4
|
+
|
|
5
|
+
export const getJsenvBuildUrl = async (buildRelativeUrlWithoutHash) => {
|
|
6
|
+
try {
|
|
7
|
+
const manifest = await readFile(
|
|
8
|
+
new URL("./dist/manifest.json", jsenvCoreDirectoryUrl),
|
|
9
|
+
{ as: "json" },
|
|
10
|
+
)
|
|
11
|
+
const buildRelativeUrl = manifest[buildRelativeUrlWithoutHash]
|
|
12
|
+
return new URL(buildRelativeUrl, jsenvCoreDirectoryUrl).href
|
|
13
|
+
} catch (e) {
|
|
14
|
+
if (e.code === "ENOENT") {
|
|
15
|
+
return null
|
|
16
|
+
}
|
|
17
|
+
throw e
|
|
18
|
+
}
|
|
19
|
+
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { memoize } from "@jsenv/filesystem"
|
|
2
|
+
|
|
3
|
+
const FEATURE_DETECT_DYNAMIC_IMPORT_FILE_URL = new URL(
|
|
4
|
+
"./feature_detect_top_level_await.mjs",
|
|
5
|
+
import.meta.url,
|
|
6
|
+
).href
|
|
7
|
+
|
|
8
|
+
export const nodeSupportsTopLevelAwait = memoize(async () => {
|
|
9
|
+
try {
|
|
10
|
+
const namespace = await import(FEATURE_DETECT_DYNAMIC_IMPORT_FILE_URL)
|
|
11
|
+
const supported = namespace.default === 42
|
|
12
|
+
return supported
|
|
13
|
+
} catch (e) {
|
|
14
|
+
return false
|
|
15
|
+
}
|
|
16
|
+
})
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { computeCompileIdFromGroupId } from "
|
|
4
|
-
import { nodeSupportsDynamicImport } from "
|
|
5
|
-
import { nodeSupportsTopLevelAwait } from "
|
|
6
|
-
import { fetchSource } from "
|
|
1
|
+
import { resolveGroup } from "@jsenv/core/src/internal/runtime/resolveGroup.js"
|
|
2
|
+
import { detectNode } from "@jsenv/core/src/internal/node_runtime/detectNode.js"
|
|
3
|
+
import { computeCompileIdFromGroupId } from "@jsenv/core/src/internal/runtime/computeCompileIdFromGroupId.js"
|
|
4
|
+
import { nodeSupportsDynamicImport } from "@jsenv/core/src/internal/node_feature_detection/nodeSupportsDynamicImport.js"
|
|
5
|
+
import { nodeSupportsTopLevelAwait } from "@jsenv/core/src/internal/node_feature_detection/nodeSupportsTopLevelAwait.js"
|
|
6
|
+
import { fetchSource } from "@jsenv/core/src/internal/node_runtime/fetchSource.js"
|
|
7
7
|
|
|
8
8
|
export const scanNodeRuntimeFeatures = async ({
|
|
9
9
|
compileServerOrigin,
|
|
10
10
|
outDirectoryRelativeUrl,
|
|
11
|
+
coverageHandledFromOutside = false,
|
|
11
12
|
}) => {
|
|
12
13
|
const outDirectoryServerUrl = `${compileServerOrigin}/${outDirectoryRelativeUrl}`
|
|
13
14
|
const {
|
|
@@ -35,10 +36,7 @@ export const scanNodeRuntimeFeatures = async ({
|
|
|
35
36
|
})
|
|
36
37
|
const pluginRequiredNameArray = pluginRequiredNamesFromGroupInfo(groupInfo, {
|
|
37
38
|
featuresReport,
|
|
38
|
-
|
|
39
|
-
// instrumentation CAN be handed by process.env.NODE_V8_COVERAGE
|
|
40
|
-
// "transform-instrument" becomes non mandatory
|
|
41
|
-
coverageHandledFromOutside: process.env.NODE_V8_COVERAGE,
|
|
39
|
+
coverageHandledFromOutside,
|
|
42
40
|
})
|
|
43
41
|
|
|
44
42
|
const canAvoidCompilation =
|
|
@@ -102,9 +100,10 @@ const pluginRequiredNamesFromGroupInfo = (
|
|
|
102
100
|
if (coverageHandledFromOutside) {
|
|
103
101
|
markPluginAsSupported("transform-instrument")
|
|
104
102
|
}
|
|
105
|
-
//
|
|
106
|
-
//
|
|
107
|
-
//
|
|
103
|
+
// CSS import assertions and constructable stylesheet are not supported by Node.js
|
|
104
|
+
// but we assume they are not used for code executed in Node.js
|
|
105
|
+
// Without this check code executed on Node.js would always be compiled
|
|
106
|
+
// because import assertions and constructable stylesheet are enabled by default
|
|
108
107
|
markPluginAsSupported("transform-import-assertions")
|
|
109
108
|
markPluginAsSupported("new-stylesheet-as-jsenv-import")
|
|
110
109
|
|
|
File without changes
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import { fork } from "node:child_process"
|
|
2
2
|
import { uneval } from "@jsenv/uneval"
|
|
3
3
|
import { createLogger, createDetailedMessage } from "@jsenv/logger"
|
|
4
|
-
import {
|
|
5
|
-
urlToFileSystemPath,
|
|
6
|
-
resolveUrl,
|
|
7
|
-
assertFilePresence,
|
|
8
|
-
} from "@jsenv/filesystem"
|
|
4
|
+
import { urlToFileSystemPath, assertFilePresence } from "@jsenv/filesystem"
|
|
9
5
|
import {
|
|
10
6
|
Abort,
|
|
11
7
|
raceCallbacks,
|
|
@@ -13,8 +9,7 @@ import {
|
|
|
13
9
|
createCallbackListNotifiedOnce,
|
|
14
10
|
} from "@jsenv/abort"
|
|
15
11
|
|
|
16
|
-
import { nodeSupportsDynamicImport } from "../
|
|
17
|
-
import { jsenvCoreDirectoryUrl } from "../jsenvCoreDirectoryUrl.js"
|
|
12
|
+
import { nodeSupportsDynamicImport } from "../node_feature_detection/nodeSupportsDynamicImport.js"
|
|
18
13
|
import { createChildProcessOptions } from "./createChildProcessOptions.js"
|
|
19
14
|
import {
|
|
20
15
|
processOptionsFromExecArgv,
|
|
@@ -22,10 +17,10 @@ import {
|
|
|
22
17
|
} from "./processOptions.js"
|
|
23
18
|
import { killProcessTree } from "./kill_process_tree.js"
|
|
24
19
|
|
|
25
|
-
const
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
)
|
|
20
|
+
const NODE_CONTROLLABLE_FILE_URL = new URL(
|
|
21
|
+
"../node_runtime/nodeControllableFile.mjs",
|
|
22
|
+
import.meta.url,
|
|
23
|
+
).href
|
|
29
24
|
|
|
30
25
|
// https://nodejs.org/api/process.html#process_signal_events
|
|
31
26
|
const SIGINT_SIGNAL_NUMBER = 2
|
|
@@ -79,12 +74,12 @@ export const createControllableNodeProcess = async ({
|
|
|
79
74
|
throw new TypeError(`env must be an object, got ${env}`)
|
|
80
75
|
}
|
|
81
76
|
|
|
82
|
-
await assertFilePresence(
|
|
77
|
+
await assertFilePresence(NODE_CONTROLLABLE_FILE_URL)
|
|
83
78
|
const envForChildProcess = {
|
|
84
79
|
...(inheritProcessEnv ? process.env : {}),
|
|
85
80
|
...env,
|
|
86
81
|
}
|
|
87
|
-
const childProcess = fork(urlToFileSystemPath(
|
|
82
|
+
const childProcess = fork(urlToFileSystemPath(NODE_CONTROLLABLE_FILE_URL), {
|
|
88
83
|
execArgv,
|
|
89
84
|
// silent: true
|
|
90
85
|
stdio: ["pipe", "pipe", "pipe", "ipc"],
|
|
@@ -111,7 +106,7 @@ export const createControllableNodeProcess = async ({
|
|
|
111
106
|
if (logProcessCommand) {
|
|
112
107
|
console.log(
|
|
113
108
|
`${process.argv[0]} ${execArgv.join(" ")} ${urlToFileSystemPath(
|
|
114
|
-
|
|
109
|
+
NODE_CONTROLLABLE_FILE_URL,
|
|
115
110
|
)}`,
|
|
116
111
|
)
|
|
117
112
|
}
|
|
File without changes
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { scanNodeRuntimeFeatures } from "@jsenv/core/src/internal/node_feature_detection/node_feature_detection.js"
|
|
2
|
+
|
|
3
|
+
export const getNodeRuntimeReport = async ({
|
|
4
|
+
runtime,
|
|
5
|
+
compileServerId,
|
|
6
|
+
compileServerOrigin,
|
|
7
|
+
outDirectoryRelativeUrl,
|
|
8
|
+
coverageHandledFromOutside,
|
|
9
|
+
}) => {
|
|
10
|
+
const cache = cacheFromParams({
|
|
11
|
+
runtime,
|
|
12
|
+
compileServerId,
|
|
13
|
+
compileServerOrigin,
|
|
14
|
+
outDirectoryRelativeUrl,
|
|
15
|
+
coverageHandledFromOutside,
|
|
16
|
+
})
|
|
17
|
+
const entry = cache.read()
|
|
18
|
+
if (entry) {
|
|
19
|
+
return entry
|
|
20
|
+
}
|
|
21
|
+
const nodeRuntimeFeaturesReport = await scanNodeRuntimeFeatures({
|
|
22
|
+
compileServerOrigin,
|
|
23
|
+
outDirectoryRelativeUrl,
|
|
24
|
+
coverageHandledFromOutside,
|
|
25
|
+
})
|
|
26
|
+
cache.write(nodeRuntimeFeaturesReport)
|
|
27
|
+
return nodeRuntimeFeaturesReport
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
let currentCacheParams
|
|
31
|
+
let currentCacheValue
|
|
32
|
+
const cacheFromParams = ({
|
|
33
|
+
compileServerId,
|
|
34
|
+
compileServerOrigin,
|
|
35
|
+
outDirectoryRelativeUrl,
|
|
36
|
+
coverageHandledFromOutside,
|
|
37
|
+
}) => {
|
|
38
|
+
const params = {
|
|
39
|
+
compileServerId,
|
|
40
|
+
compileServerOrigin,
|
|
41
|
+
outDirectoryRelativeUrl,
|
|
42
|
+
coverageHandledFromOutside,
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (!currentCacheParams) {
|
|
46
|
+
currentCacheParams = params
|
|
47
|
+
return {
|
|
48
|
+
read: () => null,
|
|
49
|
+
write: (value) => {
|
|
50
|
+
currentCacheValue = value
|
|
51
|
+
},
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (JSON.stringify(currentCacheParams) !== JSON.stringify(params)) {
|
|
56
|
+
return {
|
|
57
|
+
read: () => null,
|
|
58
|
+
write: (value) => {
|
|
59
|
+
currentCacheParams = params
|
|
60
|
+
currentCacheValue = value
|
|
61
|
+
},
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return {
|
|
66
|
+
read: () => currentCacheValue,
|
|
67
|
+
write: (value) => {
|
|
68
|
+
currentCacheValue = value
|
|
69
|
+
},
|
|
70
|
+
}
|
|
71
|
+
}
|
|
File without changes
|
|
File without changes
|
|
@@ -1,19 +1,26 @@
|
|
|
1
1
|
import v8 from "node:v8"
|
|
2
2
|
import { uneval } from "@jsenv/uneval"
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
const NODE_EXECUTION_DYNAMIC_IMPORT_URL = new URL(
|
|
5
|
+
"./node_execution_dynamic_import.js",
|
|
6
|
+
import.meta.url,
|
|
7
|
+
).href
|
|
8
|
+
const NODE_EXECUTION_SYSTEMJS_URL = new URL(
|
|
9
|
+
"./node_execution_systemjs.js",
|
|
10
|
+
import.meta.url,
|
|
11
|
+
).href
|
|
5
12
|
|
|
6
13
|
const ACTIONS_AVAILABLE = {
|
|
7
|
-
"execute-using-dynamic-import
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
14
|
+
"execute-using-dynamic-import": async (executeParams) => {
|
|
15
|
+
const { execute } = await import(NODE_EXECUTION_DYNAMIC_IMPORT_URL)
|
|
16
|
+
return execute(executeParams)
|
|
17
|
+
},
|
|
18
|
+
"execute-using-systemjs": async (executeParams) => {
|
|
19
|
+
const { execute } = await import(NODE_EXECUTION_SYSTEMJS_URL)
|
|
12
20
|
return execute(executeParams)
|
|
13
21
|
},
|
|
14
22
|
"execute-using-import": async ({ fileUrl }) => {
|
|
15
23
|
const namespace = await import(fileUrl)
|
|
16
|
-
|
|
17
24
|
const namespaceResolved = {}
|
|
18
25
|
await Promise.all([
|
|
19
26
|
...Object.keys(namespace).map(async (key) => {
|
|
@@ -21,19 +28,15 @@ const ACTIONS_AVAILABLE = {
|
|
|
21
28
|
namespaceResolved[key] = value
|
|
22
29
|
}),
|
|
23
30
|
])
|
|
24
|
-
|
|
25
31
|
return namespaceResolved
|
|
26
32
|
},
|
|
27
33
|
"execute-using-require": async ({ fileUrl }) => {
|
|
28
34
|
const { createRequire } = await import("module")
|
|
29
35
|
const { fileURLToPath } = await import("url")
|
|
30
|
-
|
|
31
36
|
const filePath = fileURLToPath(fileUrl)
|
|
32
37
|
const require = createRequire(fileUrl)
|
|
33
|
-
|
|
34
38
|
// eslint-disable-next-line import/no-dynamic-require
|
|
35
39
|
const namespace = require(filePath)
|
|
36
|
-
|
|
37
40
|
const namespaceResolved = {}
|
|
38
41
|
await Promise.all([
|
|
39
42
|
...Object.keys(namespace).map(async (key) => {
|