@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
|
@@ -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 = () => {
|
|
@@ -1,25 +1,56 @@
|
|
|
1
1
|
import { createPreference } from "../util/preferences.js"
|
|
2
|
+
import { enableVariant } from "../variant/variant.js"
|
|
2
3
|
|
|
4
|
+
const notificationAvailable = typeof window.Notification === "function"
|
|
3
5
|
const notificationPreference = createPreference("notification")
|
|
4
6
|
|
|
5
7
|
const arrayOfOpenedNotifications = []
|
|
6
8
|
export const renderToolbarNotification = () => {
|
|
7
9
|
const notifCheckbox = document.querySelector("#toggle-notifs")
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
10
|
+
if (!notificationAvailable) {
|
|
11
|
+
const notifSetting = document.querySelector(".settings-notification")
|
|
12
|
+
notifSetting.setAttribute("data-disabled", "true")
|
|
13
|
+
notifSetting.setAttribute(
|
|
14
|
+
"title",
|
|
15
|
+
`Notification not available in the browser`,
|
|
16
|
+
)
|
|
17
|
+
notifCheckbox.disabled = true
|
|
18
|
+
return
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const updatePermission = () => {
|
|
22
|
+
if (Notification.permission === "denied") {
|
|
23
|
+
const notifSetting = document.querySelector(".settings-notification")
|
|
24
|
+
notifSetting.setAttribute("data-disabled", "true")
|
|
25
|
+
notifSetting.setAttribute("title", `Notification denied`)
|
|
26
|
+
notifCheckbox.disabled = true
|
|
27
|
+
return
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
notifCheckbox.checked = getNotificationPreference()
|
|
31
|
+
notifCheckbox.onchange = () => {
|
|
32
|
+
setNotificationPreference(notifCheckbox.checked)
|
|
33
|
+
if (!notifCheckbox.checked) {
|
|
34
|
+
// slice because arrayOfOpenedNotifications can be mutated while looping
|
|
35
|
+
arrayOfOpenedNotifications.slice().forEach((notification) => {
|
|
36
|
+
notification.close()
|
|
37
|
+
})
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const notifPermission = Notification.permission
|
|
41
|
+
enableVariant(document.querySelector(".notification-text"), {
|
|
42
|
+
notif_permission: notifPermission === "granted" ? "yes" : "no",
|
|
43
|
+
})
|
|
44
|
+
if (notifPermission === "default") {
|
|
45
|
+
document.querySelector("a.request_notification_permission").onclick =
|
|
46
|
+
() => {
|
|
47
|
+
requestPermission().then(() => {
|
|
48
|
+
updatePermission()
|
|
49
|
+
})
|
|
50
|
+
}
|
|
21
51
|
}
|
|
22
52
|
}
|
|
53
|
+
updatePermission()
|
|
23
54
|
}
|
|
24
55
|
|
|
25
56
|
export const notifyExecutionResult = (
|
|
@@ -64,8 +95,6 @@ export const notifyExecutionResult = (
|
|
|
64
95
|
}
|
|
65
96
|
}
|
|
66
97
|
|
|
67
|
-
const notificationAvailable = typeof window.Notification === "function"
|
|
68
|
-
|
|
69
98
|
const getNotificationPreference = () =>
|
|
70
99
|
notificationPreference.has() ? notificationPreference.get() : true
|
|
71
100
|
|
|
@@ -76,46 +105,48 @@ const getFaviconHref = () => {
|
|
|
76
105
|
return link ? link.href : undefined
|
|
77
106
|
}
|
|
78
107
|
|
|
108
|
+
let permission = "default"
|
|
109
|
+
|
|
79
110
|
const notify = notificationAvailable
|
|
80
111
|
? async (
|
|
81
112
|
title,
|
|
82
113
|
{ clickToFocus = false, clickToClose = false, ...options } = {},
|
|
83
114
|
) => {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
notification.
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
115
|
+
if (permission !== "granted") {
|
|
116
|
+
return null
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const notification = new Notification(title, options)
|
|
120
|
+
arrayOfOpenedNotifications.push(notification)
|
|
121
|
+
notification.onclick = () => {
|
|
122
|
+
// but if the user navigated inbetween
|
|
123
|
+
// focusing window will show something else
|
|
124
|
+
// in that case it could be great to do something
|
|
125
|
+
// maybe like showing a message saying this execution
|
|
126
|
+
// is no longer visible
|
|
127
|
+
// we could also navigauate to this file execution but
|
|
128
|
+
// there is no guarantee re-executing the file would give same output
|
|
129
|
+
// and it would also trigger an other notification
|
|
130
|
+
if (clickToFocus) window.focus()
|
|
131
|
+
if (clickToClose) notification.close()
|
|
132
|
+
}
|
|
133
|
+
notification.onclose = () => {
|
|
134
|
+
const index = arrayOfOpenedNotifications.indexOf(notification)
|
|
135
|
+
if (index > -1) {
|
|
136
|
+
arrayOfOpenedNotifications.splice(index, 1)
|
|
105
137
|
}
|
|
106
|
-
return notification
|
|
107
138
|
}
|
|
108
|
-
return
|
|
139
|
+
return notification
|
|
109
140
|
}
|
|
110
141
|
: () => {}
|
|
111
142
|
|
|
112
|
-
let
|
|
143
|
+
let requestPromise
|
|
113
144
|
const requestPermission = notificationAvailable
|
|
114
145
|
? async () => {
|
|
115
|
-
if (
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
146
|
+
if (requestPromise) return requestPromise
|
|
147
|
+
requestPromise = Notification.requestPermission()
|
|
148
|
+
permission = await requestPromise
|
|
149
|
+
requestPromise = undefined
|
|
119
150
|
return permission
|
|
120
151
|
}
|
|
121
|
-
: () => Promise.resolve("
|
|
152
|
+
: () => Promise.resolve("default")
|
|
@@ -5,7 +5,12 @@
|
|
|
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
|
-
<link
|
|
8
|
+
<link
|
|
9
|
+
rel="stylesheet"
|
|
10
|
+
type="text/css"
|
|
11
|
+
href="./toolbar.main.css"
|
|
12
|
+
data-jsenv-force-inline
|
|
13
|
+
/>
|
|
9
14
|
</head>
|
|
10
15
|
<body>
|
|
11
16
|
<div id="toolbar-overlay"></div>
|
|
@@ -13,7 +18,7 @@
|
|
|
13
18
|
<div id="toolbar">
|
|
14
19
|
<div id="toolbar-wrapper">
|
|
15
20
|
<section id="file-list-link" data-responsive-toolbar-element>
|
|
16
|
-
<a class="toolbar-icon-wrapper" href="">
|
|
21
|
+
<a class="toolbar-icon-wrapper" href="/">
|
|
17
22
|
<svg
|
|
18
23
|
id="fileIconSvg"
|
|
19
24
|
class="iconToolbar"
|
|
@@ -251,7 +256,7 @@
|
|
|
251
256
|
</div>
|
|
252
257
|
<div id="settings-box-body">
|
|
253
258
|
<div class="settings-box-items-wrapper">
|
|
254
|
-
<div class="settings-box-item">
|
|
259
|
+
<div class="settings-box-item settings-notification">
|
|
255
260
|
<div class="category-title">
|
|
256
261
|
<svg
|
|
257
262
|
xmlns="http://www.w3.org/2000/svg"
|
|
@@ -274,6 +279,14 @@
|
|
|
274
279
|
</label>
|
|
275
280
|
<div class="category-subtitle">
|
|
276
281
|
Send system notification when execution fails or is fixed.
|
|
282
|
+
<div class="notification-text">
|
|
283
|
+
<a
|
|
284
|
+
data-when="notif_permission:no"
|
|
285
|
+
class="request_notification_permission"
|
|
286
|
+
href="javascript:void(0);"
|
|
287
|
+
>Enable notification</a
|
|
288
|
+
>
|
|
289
|
+
</div>
|
|
277
290
|
</div>
|
|
278
291
|
</div>
|
|
279
292
|
<div class="settings-box-item settings-livereload">
|
|
@@ -526,7 +539,7 @@
|
|
|
526
539
|
<!--
|
|
527
540
|
Reusable svg(s)
|
|
528
541
|
-->
|
|
529
|
-
<div style="display: none">
|
|
542
|
+
<div style="display: none; position: absolute">
|
|
530
543
|
<svg
|
|
531
544
|
id="loading_svg"
|
|
532
545
|
xmlns="http://www.w3.org/2000/svg"
|
|
@@ -551,6 +564,19 @@
|
|
|
551
564
|
module approach wil be faster because
|
|
552
565
|
no compilation will be necessary
|
|
553
566
|
-->
|
|
554
|
-
<script
|
|
567
|
+
<script
|
|
568
|
+
type="importmap"
|
|
569
|
+
src="../../../../node_resolution.importmap"
|
|
570
|
+
></script>
|
|
571
|
+
<script>
|
|
572
|
+
// here we should create something like window.toolbar = {}
|
|
573
|
+
// and a promise the toolbar injector can listen to act on the toolbar
|
|
574
|
+
// or we could just consider all communication should pass by postmessage
|
|
575
|
+
</script>
|
|
576
|
+
<script
|
|
577
|
+
type="module"
|
|
578
|
+
src="./toolbar.main.js"
|
|
579
|
+
data-jsenv-force-inline
|
|
580
|
+
></script>
|
|
555
581
|
</body>
|
|
556
582
|
</html>
|
|
@@ -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,54 @@ 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
|
+
sendCommandToToolbar(iframe, "renderToolbar")
|
|
172
154
|
|
|
173
155
|
return iframe
|
|
174
156
|
}
|
|
175
157
|
|
|
158
|
+
const addToolbarEventCallback = (iframe, eventName, callback) => {
|
|
159
|
+
const messageEventCallback = (messageEvent) => {
|
|
160
|
+
const { data } = messageEvent
|
|
161
|
+
if (typeof data !== "object") {
|
|
162
|
+
return
|
|
163
|
+
}
|
|
164
|
+
const { __jsenv__ } = data
|
|
165
|
+
if (!__jsenv__) {
|
|
166
|
+
return
|
|
167
|
+
}
|
|
168
|
+
if (__jsenv__.event !== eventName) {
|
|
169
|
+
return
|
|
170
|
+
}
|
|
171
|
+
callback(__jsenv__.data)
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
window.addEventListener("message", messageEventCallback, false)
|
|
175
|
+
return () => {
|
|
176
|
+
window.removeEventListener("message", messageEventCallback, false)
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
const sendCommandToToolbar = (iframe, command, ...args) => {
|
|
181
|
+
iframe.contentWindow.postMessage(
|
|
182
|
+
{
|
|
183
|
+
__jsenv__: {
|
|
184
|
+
command,
|
|
185
|
+
args,
|
|
186
|
+
},
|
|
187
|
+
},
|
|
188
|
+
window.origin,
|
|
189
|
+
)
|
|
190
|
+
}
|
|
191
|
+
|
|
176
192
|
const getToolbarPlaceholder = () => {
|
|
177
193
|
const placeholder = queryPlaceholder()
|
|
178
194
|
if (placeholder) {
|
|
@@ -188,8 +204,9 @@ const getToolbarPlaceholder = () => {
|
|
|
188
204
|
return createTooolbarPlaceholder()
|
|
189
205
|
}
|
|
190
206
|
|
|
191
|
-
const queryPlaceholder = () =>
|
|
192
|
-
document.querySelector("[data-jsenv-toolbar-placeholder]")
|
|
207
|
+
const queryPlaceholder = () => {
|
|
208
|
+
return document.querySelector("[data-jsenv-toolbar-placeholder]")
|
|
209
|
+
}
|
|
193
210
|
|
|
194
211
|
const createTooolbarPlaceholder = () => {
|
|
195
212
|
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,54 @@ 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
|
-
|
|
226
|
+
addExternalCommandCallback("renderToolbar", () => {
|
|
227
|
+
renderToolbar()
|
|
228
|
+
})
|
|
229
|
+
addExternalCommandCallback("showToolbar", () => {
|
|
230
|
+
showToolbar()
|
|
231
|
+
})
|
|
232
|
+
addExternalCommandCallback("hideToolbar", () => {
|
|
233
|
+
hideToolbar()
|
|
234
|
+
})
|
|
235
|
+
|
|
236
|
+
window.toolbar = {
|
|
237
|
+
render: renderToolbar,
|
|
238
|
+
show: showToolbar,
|
|
239
|
+
hide: () => hideToolbar(),
|
|
240
|
+
}
|
|
@@ -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
|
+
})
|