@jsenv/core 25.3.0 → 25.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser_runtime/asset-manifest.json +2 -2
- package/dist/browser_runtime/{browser_runtime_91c5a3b8.js → browser_runtime_0e3396a1.js} +15 -16
- package/dist/browser_runtime/{browser_runtime_91c5a3b8.js.map → browser_runtime_0e3396a1.js.map} +13 -13
- package/dist/build_manifest.js +5 -5
- package/dist/compile_proxy/asset-manifest.json +2 -2
- package/dist/compile_proxy/compile_proxy.html__inline__20_2334a374.js.map +342 -0
- package/dist/compile_proxy/{compile_proxy_8dfaee51.html → compile_proxy_9f737eaf.html} +357 -398
- package/dist/redirector/asset-manifest.json +2 -2
- package/dist/redirector/redirector.html__inline__12_009c47c7.js.map +348 -0
- package/dist/redirector/{redirector_3e9a97b9.html → redirector_96f74871.html} +378 -421
- package/dist/toolbar/asset-manifest.json +2 -2
- package/dist/toolbar/{toolbar.main_6c1b3d82.js.map → toolbar.main_86335f90.js.map} +82 -115
- package/dist/toolbar/{toolbar_361afb84.html → toolbar_d3a918a4.html} +487 -508
- package/dist/toolbar_injector/asset-manifest.json +2 -2
- package/dist/toolbar_injector/toolbar_injector_978bbd14.js +267 -0
- package/dist/toolbar_injector/toolbar_injector_978bbd14.js.map +119 -0
- package/package.json +12 -11
- package/src/buildProject.js +31 -26
- package/src/dev_server.js +76 -87
- package/src/execute.js +3 -8
- package/src/internal/browser_launcher/{browser_runtime_report.js → browser_runtime_profile.js} +21 -15
- package/src/internal/browser_launcher/executeHtmlFile.js +22 -14
- package/src/internal/browser_launcher/from_playwright.js +6 -4
- package/src/internal/browser_runtime/browser_runtime.js +12 -14
- package/src/internal/browser_runtime/createBrowserRuntime.js +7 -6
- package/src/internal/browser_utils/fetchAndEvalUsingFetch.js +1 -1
- package/src/internal/browser_utils/fetchJson.js +1 -1
- package/src/internal/browser_utils/{fetch-browser.js → fetch_browser.js} +0 -2
- package/src/internal/building/buildUsingRollup.js +41 -57
- package/src/internal/building/rollup_plugin_jsenv.js +28 -8
- package/src/internal/compiling/babel_parse_error.js +9 -0
- package/src/internal/{babel_plugin_transform_import_meta.js → compiling/babel_plugin_transform_import_meta.js} +58 -9
- package/src/internal/compiling/compileFile.js +2 -2
- package/src/internal/compiling/compileHtml.js +1 -1
- package/src/internal/compiling/createCompiledFileService.js +25 -74
- package/src/internal/compiling/js-compilation-service/transformJs.js +153 -23
- package/src/internal/compiling/jsenvCompilerForHtml.js +29 -32
- package/src/internal/compiling/jsenvCompilerForImportmap.js +2 -2
- package/src/internal/compiling/jsenvCompilerForJavaScript.js +2 -4
- package/src/internal/compiling/jsenv_directory/comparison_utils.js +24 -0
- package/src/internal/compiling/{compile-directory/compile-asset.js → jsenv_directory/compile_asset.js} +0 -0
- package/src/internal/compiling/jsenv_directory/compile_context.js +68 -0
- package/src/internal/compiling/jsenv_directory/compile_profile.js +218 -0
- package/src/internal/compiling/{compile-directory/createLockRegistry.js → jsenv_directory/file_lock_registry.js} +0 -0
- package/src/internal/compiling/{compile-directory/createLockRegistry.test.js → jsenv_directory/file_lock_registry.test.js} +2 -1
- package/src/internal/compiling/{compile-directory → jsenv_directory}/fs-optimized-for-cache.js +0 -0
- package/src/internal/compiling/{compile-directory → jsenv_directory}/getOrGenerateCompiledFile.js +2 -2
- package/src/internal/compiling/jsenv_directory/jsenv_directory.js +174 -0
- package/src/internal/compiling/{compile-directory → jsenv_directory}/updateMeta.js +1 -1
- package/src/internal/compiling/{compile-directory → jsenv_directory}/validateCache.js +0 -0
- package/src/internal/compiling/sse_service/sse_service.js +369 -0
- package/src/internal/compiling/startCompileServer.js +156 -804
- package/src/internal/compiling/transformResultToCompilationResult.js +2 -2
- package/src/internal/dev_server/exploring/exploring.js +10 -8
- package/src/internal/dev_server/toolbar/compilation/toolbar.compilation.js +85 -78
- package/src/internal/dev_server/toolbar/settings/toolbar.settings.js +13 -0
- package/src/internal/dev_server/toolbar/toolbar.html +40 -16
- package/src/internal/dev_server/toolbar/toolbar.injector.js +11 -17
- package/src/internal/dev_server/toolbar/toolbar.main.js +6 -6
- package/src/internal/executing/executeConcurrently.js +1 -1
- package/src/internal/executing/executePlan.js +2 -3
- package/src/internal/{generateGroupMap → features}/babel_plugins_compatibility.js +8 -8
- package/src/internal/features/browser_feature_detection/browser_feature_detect_dynamic_import.js +20 -0
- package/src/internal/features/browser_feature_detection/browser_feature_detect_import_assertions_css.js +23 -0
- package/src/internal/features/browser_feature_detection/browser_feature_detect_import_assertions_json.js +25 -0
- package/src/internal/features/browser_feature_detection/browser_feature_detect_importmap.js +37 -0
- package/src/internal/features/browser_feature_detection/browser_feature_detect_new_stylesheet.js +9 -0
- package/src/internal/features/browser_feature_detection/browser_feature_detect_top_level_await.js +14 -0
- package/src/internal/features/browser_feature_detection/browser_feature_detection.js +85 -0
- package/src/internal/{browser_feature_detection → features/browser_feature_detection}/compile_proxy.html +1 -1
- package/src/internal/features/browser_feature_detection/execute_with_script_module.js +24 -0
- package/src/internal/features/features_compat_from_runtime.js +38 -0
- package/src/internal/features/features_compat_from_runtime_support.js +31 -0
- package/src/internal/{generateGroupMap → features}/features_compatibility.js +3 -3
- package/src/internal/{node_feature_detection → features/node_feature_detection}/feature_detect_dynamic_import.mjs +0 -0
- package/src/internal/{node_feature_detection → features/node_feature_detection}/feature_detect_top_level_await.mjs +0 -0
- package/src/internal/{node_feature_detection/nodeSupportsDynamicImport.js → features/node_feature_detection/node_feature_detect_dynamic_import.js} +0 -0
- package/src/internal/{node_feature_detection/nodeSupportsTopLevelAwait.js → features/node_feature_detection/node_feature_detect_top_level_await.js} +0 -0
- package/src/internal/features/node_feature_detection/node_feature_detection.js +66 -0
- package/src/internal/node_launcher/createControllableNodeProcess.js +4 -3
- package/src/internal/node_launcher/node_runtime_report.js +15 -9
- package/src/internal/node_runtime/fetchSource.js +2 -4
- package/src/internal/node_runtime/node_execution_systemjs.js +2 -5
- package/src/internal/{dev_server/redirector → redirector}/redirector.html +8 -18
- package/src/internal/{generateGroupMap/jsenvRuntimeSupport.js → runtime_support/jsenv_runtime_support.js} +0 -0
- package/src/internal/{generateGroupMap → runtime_support}/runtime_support.js +0 -0
- package/src/internal/url_conversion.js +12 -17
- package/src/launchNode.js +29 -41
- package/dist/compile_proxy/compile_proxy.html__inline__20_809f35f7.js.map +0 -392
- package/dist/redirector/redirector.html__inline__15_e391410e.js.map +0 -397
- package/dist/toolbar_injector/toolbar_injector_fac1e995.js +0 -973
- package/dist/toolbar_injector/toolbar_injector_fac1e995.js.map +0 -294
- package/src/internal/CONSTANTS.js +0 -11
- package/src/internal/browser_feature_detection/browser_feature_detection.js +0 -274
- package/src/internal/compiling/js-compilation-service/jsenvTransform.js +0 -242
- package/src/internal/generateGroupMap/generateGroupMap.js +0 -65
- package/src/internal/generateGroupMap/one_runtime_compat.js +0 -38
- package/src/internal/generateGroupMap/runtime_compat.js +0 -34
- package/src/internal/generateGroupMap/runtime_compat_composition.js +0 -76
- package/src/internal/generateGroupMap/shake_babel_plugin_map.js +0 -21
- package/src/internal/node_feature_detection/node_feature_detection.js +0 -117
- package/src/internal/node_runtime/detectNode.js +0 -3
- package/src/internal/runtime/computeCompileIdFromGroupId.js +0 -30
- package/src/internal/runtime/resolveGroup.js +0 -13
- package/src/internal/runtime/resolveRuntimeGroup.js +0 -11
|
@@ -16,8 +16,8 @@ import {
|
|
|
16
16
|
setCssSourceMappingUrl,
|
|
17
17
|
sourcemapToBase64Url,
|
|
18
18
|
} from "../sourceMappingURLUtils.js"
|
|
19
|
-
import { generateCompilationAssetUrl } from "./
|
|
20
|
-
import { testFilePresence } from "./
|
|
19
|
+
import { generateCompilationAssetUrl } from "./jsenv_directory/compile_asset.js"
|
|
20
|
+
import { testFilePresence } from "./jsenv_directory/fs-optimized-for-cache.js"
|
|
21
21
|
|
|
22
22
|
const isWindows = process.platform === "win32"
|
|
23
23
|
|
|
@@ -12,7 +12,7 @@ const fetchJSON = async (url, options) => {
|
|
|
12
12
|
const groupPreference = createPreference("group")
|
|
13
13
|
|
|
14
14
|
const run = async () => {
|
|
15
|
-
const { projectDirectoryUrl, explorableConfig,
|
|
15
|
+
const { projectDirectoryUrl, explorableConfig, jsenvDirectoryRelativeUrl } =
|
|
16
16
|
await fetchExploringJson()
|
|
17
17
|
|
|
18
18
|
const files = await fetchJSON(`/.jsenv/explorables.json`, {
|
|
@@ -20,16 +20,18 @@ const run = async () => {
|
|
|
20
20
|
})
|
|
21
21
|
|
|
22
22
|
const compileServerOrigin = document.location.origin
|
|
23
|
-
const
|
|
24
|
-
new URL(
|
|
23
|
+
const jsenvDirectoryServerUrl = String(
|
|
24
|
+
new URL(jsenvDirectoryRelativeUrl, compileServerOrigin),
|
|
25
25
|
)
|
|
26
26
|
const documentUrl = document.location.href
|
|
27
27
|
let compileId
|
|
28
28
|
|
|
29
|
-
const
|
|
30
|
-
if (
|
|
31
|
-
const
|
|
32
|
-
|
|
29
|
+
const jsenvDirectoryIndex = documentUrl.indexOf(jsenvDirectoryServerUrl)
|
|
30
|
+
if (jsenvDirectoryIndex === 0) {
|
|
31
|
+
const afterJsenvDirectory = documentUrl.slice(
|
|
32
|
+
jsenvDirectoryServerUrl.length,
|
|
33
|
+
)
|
|
34
|
+
compileId = afterJsenvDirectory.split("/")[0]
|
|
33
35
|
} else {
|
|
34
36
|
compileId = null
|
|
35
37
|
}
|
|
@@ -134,7 +136,7 @@ const run = async () => {
|
|
|
134
136
|
|
|
135
137
|
const urlToVisitFromRelativeUrl = (relativeUrl) => {
|
|
136
138
|
if (compileId) {
|
|
137
|
-
return `${compileServerOrigin}/${
|
|
139
|
+
return `${compileServerOrigin}/${jsenvDirectoryRelativeUrl}${compileId}/${relativeUrl}`
|
|
138
140
|
}
|
|
139
141
|
return `${compileServerOrigin}/${relativeUrl}`
|
|
140
142
|
}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import { scanBrowserRuntimeFeatures } from "../../../browser_feature_detection/browser_feature_detection.js"
|
|
1
|
+
import { scanBrowserRuntimeFeatures } from "../../../features/browser_feature_detection/browser_feature_detection.js"
|
|
2
2
|
import { removeForceHideElement } from "../util/dom.js"
|
|
3
3
|
import { enableVariant } from "../variant/variant.js"
|
|
4
|
+
import {
|
|
5
|
+
enableWarningStyle,
|
|
6
|
+
disableWarningStyle,
|
|
7
|
+
} from "../settings/toolbar.settings.js"
|
|
4
8
|
|
|
5
9
|
export const renderCompilationInToolbar = ({ compileGroup }) => {
|
|
6
10
|
const browserSupportRootNode = document.querySelector("#browser_support")
|
|
@@ -11,19 +15,17 @@ export const renderCompilationInToolbar = ({ compileGroup }) => {
|
|
|
11
15
|
|
|
12
16
|
scanBrowserRuntimeFeatures().then(
|
|
13
17
|
({
|
|
14
|
-
|
|
15
|
-
featuresReport,
|
|
16
|
-
customCompilerPatterns,
|
|
17
|
-
missingFeatureNames,
|
|
18
|
+
jsenvDirectoryRelativeUrl,
|
|
18
19
|
inlineImportMapIntoHTML,
|
|
19
|
-
|
|
20
|
+
compileProfile,
|
|
20
21
|
compileId,
|
|
22
|
+
runtimeReport,
|
|
21
23
|
}) => {
|
|
22
|
-
const browserSupport =
|
|
23
|
-
?
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
: "
|
|
24
|
+
const browserSupport = compileId
|
|
25
|
+
? "no"
|
|
26
|
+
: inlineImportMapIntoHTML
|
|
27
|
+
? "partial"
|
|
28
|
+
: "full"
|
|
27
29
|
enableVariant(browserSupportRootNode, {
|
|
28
30
|
browserSupport,
|
|
29
31
|
})
|
|
@@ -33,13 +35,9 @@ export const renderCompilationInToolbar = ({ compileGroup }) => {
|
|
|
33
35
|
).onclick = () => {
|
|
34
36
|
// eslint-disable-next-line no-alert
|
|
35
37
|
window.alert(
|
|
36
|
-
`Source files needs to be compiled to be executable in this browser because: ${
|
|
38
|
+
`Source files needs to be compiled to be executable in this browser because: ${listWhatIsMissing(
|
|
37
39
|
{
|
|
38
|
-
|
|
39
|
-
featuresReport,
|
|
40
|
-
customCompilerPatterns,
|
|
41
|
-
missingFeatureNames,
|
|
42
|
-
inlineImportMapIntoHTML,
|
|
40
|
+
compileProfile,
|
|
43
41
|
},
|
|
44
42
|
)}`,
|
|
45
43
|
)
|
|
@@ -50,11 +48,8 @@ export const renderCompilationInToolbar = ({ compileGroup }) => {
|
|
|
50
48
|
).onclick = () => {
|
|
51
49
|
// eslint-disable-next-line no-alert
|
|
52
50
|
window.alert(
|
|
53
|
-
`Source files (except html) can be executed directly in this browser because: ${
|
|
51
|
+
`Source files (except html) can be executed directly in this browser because: ${listWhatIsSupported(
|
|
54
52
|
{
|
|
55
|
-
featuresReport,
|
|
56
|
-
customCompilerPatterns,
|
|
57
|
-
missingFeatureNames,
|
|
58
53
|
inlineImportMapIntoHTML,
|
|
59
54
|
},
|
|
60
55
|
)}`,
|
|
@@ -66,11 +61,8 @@ export const renderCompilationInToolbar = ({ compileGroup }) => {
|
|
|
66
61
|
).onclick = () => {
|
|
67
62
|
// eslint-disable-next-line no-alert
|
|
68
63
|
window.alert(
|
|
69
|
-
`Source files can be executed directly in this browser because: ${
|
|
64
|
+
`Source files can be executed directly in this browser because: ${listWhatIsSupported(
|
|
70
65
|
{
|
|
71
|
-
featuresReport,
|
|
72
|
-
customCompilerPatterns,
|
|
73
|
-
missingFeatureNames,
|
|
74
66
|
inlineImportMapIntoHTML,
|
|
75
67
|
},
|
|
76
68
|
)}`,
|
|
@@ -78,28 +70,52 @@ export const renderCompilationInToolbar = ({ compileGroup }) => {
|
|
|
78
70
|
}
|
|
79
71
|
}
|
|
80
72
|
|
|
81
|
-
const
|
|
73
|
+
const actualCompileId = compileGroup.compileId
|
|
74
|
+
const expectedCompiledId = compileId
|
|
75
|
+
const shouldSwitchCompileId =
|
|
76
|
+
expectedCompiledId &&
|
|
77
|
+
actualCompileId &&
|
|
78
|
+
actualCompileId !== expectedCompiledId
|
|
79
|
+
const shouldCompile = !actualCompileId && browserSupport === "no"
|
|
80
|
+
const filesCompilation = shouldSwitchCompileId
|
|
81
|
+
? "mismatch"
|
|
82
|
+
: actualCompileId
|
|
82
83
|
? "yes"
|
|
83
84
|
: inlineImportMapIntoHTML
|
|
84
85
|
? "html_only"
|
|
85
86
|
: "no"
|
|
87
|
+
const hasWarning = shouldCompile || shouldSwitchCompileId
|
|
88
|
+
|
|
86
89
|
enableVariant(filesCompilationRootNode, {
|
|
87
90
|
filesCompilation,
|
|
88
|
-
|
|
91
|
+
compilation_link: shouldSwitchCompileId
|
|
92
|
+
? "mismatch"
|
|
93
|
+
: actualCompileId
|
|
94
|
+
? "source"
|
|
95
|
+
: "compiled",
|
|
89
96
|
})
|
|
90
|
-
|
|
91
|
-
(
|
|
92
|
-
|
|
93
|
-
}
|
|
94
|
-
|
|
97
|
+
if (filesCompilation === "yes") {
|
|
98
|
+
document.querySelector(
|
|
99
|
+
".files_compilation_text",
|
|
100
|
+
).innerHTML = `Files shown are compiled for ${runtimeReport.name}@${runtimeReport.version}`
|
|
101
|
+
}
|
|
102
|
+
filesCompilationRootNode.querySelector("a.link_to_source_files").onclick =
|
|
95
103
|
() => {
|
|
96
|
-
window.parent.location = `/${
|
|
104
|
+
window.parent.location.href = `/${compileGroup.fileRelativeUrl}`
|
|
97
105
|
}
|
|
106
|
+
filesCompilationRootNode.querySelector(
|
|
107
|
+
"a.link_to_compiled_files",
|
|
108
|
+
).onclick = () => {
|
|
109
|
+
window.parent.location.href = `/${jsenvDirectoryRelativeUrl}${compileId}/${compileGroup.fileRelativeUrl}`
|
|
110
|
+
}
|
|
111
|
+
filesCompilationRootNode.querySelector(
|
|
112
|
+
"a.link_to_appropriate_files",
|
|
113
|
+
).onclick = () => {
|
|
114
|
+
window.parent.location.href = `/${jsenvDirectoryRelativeUrl}${expectedCompiledId}/${compileGroup.fileRelativeUrl}`
|
|
115
|
+
}
|
|
98
116
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
if (shouldCompile) {
|
|
117
|
+
if (hasWarning) {
|
|
118
|
+
enableWarningStyle()
|
|
103
119
|
document
|
|
104
120
|
.querySelector(".files_compilation_text")
|
|
105
121
|
.setAttribute("data-warning", "")
|
|
@@ -110,6 +126,7 @@ export const renderCompilationInToolbar = ({ compileGroup }) => {
|
|
|
110
126
|
.querySelector("#settings-button")
|
|
111
127
|
.setAttribute("data-warning", "")
|
|
112
128
|
} else {
|
|
129
|
+
disableWarningStyle()
|
|
113
130
|
document
|
|
114
131
|
.querySelector(".files_compilation_text")
|
|
115
132
|
.removeAttribute("data-warning")
|
|
@@ -124,63 +141,53 @@ export const renderCompilationInToolbar = ({ compileGroup }) => {
|
|
|
124
141
|
)
|
|
125
142
|
}
|
|
126
143
|
|
|
127
|
-
const
|
|
128
|
-
missingOnly,
|
|
129
|
-
featuresReport,
|
|
130
|
-
customCompilerPatterns,
|
|
131
|
-
missingFeatureNames,
|
|
132
|
-
inlineImportMapIntoHTML,
|
|
133
|
-
}) => {
|
|
144
|
+
const listWhatIsSupported = ({ inlineImportMapIntoHTML }) => {
|
|
134
145
|
const parts = []
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
if (!missingOnly) {
|
|
138
|
-
if (inlineImportMapIntoHTML) {
|
|
139
|
-
parts.push(`importmaps are supported (only when inlined in html files)`)
|
|
140
|
-
} else {
|
|
141
|
-
parts.push(`importmaps are supported`)
|
|
142
|
-
}
|
|
143
|
-
}
|
|
146
|
+
if (inlineImportMapIntoHTML) {
|
|
147
|
+
parts.push(`importmaps are supported (only when inlined in html files)`)
|
|
144
148
|
} else {
|
|
145
|
-
parts.push(`importmaps are
|
|
149
|
+
parts.push(`importmaps are supported`)
|
|
146
150
|
}
|
|
151
|
+
parts.push(`dynamic imports are supported`)
|
|
152
|
+
parts.push(`top level await is supported`)
|
|
153
|
+
parts.push(`all features are natively supported`)
|
|
154
|
+
return `
|
|
155
|
+
- ${parts.join(`
|
|
156
|
+
- `)}`
|
|
157
|
+
}
|
|
147
158
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
159
|
+
const listWhatIsMissing = ({ compileProfile }) => {
|
|
160
|
+
const parts = []
|
|
161
|
+
const { missingFeatures } = compileProfile
|
|
162
|
+
if (missingFeatures.importmap) {
|
|
163
|
+
parts.push(`importmaps are not supported`)
|
|
164
|
+
}
|
|
165
|
+
if (missingFeatures.dynamicImport) {
|
|
153
166
|
parts.push(`dynamic imports are not supported`)
|
|
154
167
|
}
|
|
155
|
-
|
|
156
|
-
if (featuresReport.topLevelAwait) {
|
|
157
|
-
if (!missingOnly) {
|
|
158
|
-
parts.push(`top level await is supported`)
|
|
159
|
-
}
|
|
160
|
-
} else {
|
|
168
|
+
if (missingFeatures.topLevelAwait) {
|
|
161
169
|
parts.push(`top level await is not supported`)
|
|
162
170
|
}
|
|
163
|
-
|
|
171
|
+
const missingFeatureNames = Object.keys(missingFeatures).filter((name) => {
|
|
172
|
+
return (
|
|
173
|
+
name !== "importmap" &&
|
|
174
|
+
name !== "dynamicImport" &&
|
|
175
|
+
name !== "topLevelAwait" &&
|
|
176
|
+
name !== "custom_compiler_patterns"
|
|
177
|
+
)
|
|
178
|
+
})
|
|
164
179
|
const missingFeatureCount = missingFeatureNames.length
|
|
165
|
-
if (missingFeatureCount
|
|
166
|
-
if (!missingOnly) {
|
|
167
|
-
parts.push(`all features are natively supported`)
|
|
168
|
-
}
|
|
169
|
-
} else {
|
|
180
|
+
if (missingFeatureCount > 0) {
|
|
170
181
|
parts.push(
|
|
171
182
|
`${missingFeatureCount} features are missing: ${missingFeatureNames}`,
|
|
172
183
|
)
|
|
173
184
|
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
if (customCompilerCount === 0) {
|
|
177
|
-
// no need to talk about something unused
|
|
178
|
-
} else {
|
|
185
|
+
const { custom_compiler_patterns } = missingFeatures
|
|
186
|
+
if (custom_compiler_patterns) {
|
|
179
187
|
parts.push(
|
|
180
|
-
`${
|
|
188
|
+
`${custom_compiler_patterns.length} custom compilers enabled: ${custom_compiler_patterns}`,
|
|
181
189
|
)
|
|
182
190
|
}
|
|
183
|
-
|
|
184
191
|
return `
|
|
185
192
|
- ${parts.join(`
|
|
186
193
|
- `)}`
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
activateToolbarSection,
|
|
5
5
|
updateIframeOverflowOnParentWindow,
|
|
6
6
|
} from "../util/dom.js"
|
|
7
|
+
import { enableVariant } from "../variant/variant.js"
|
|
7
8
|
|
|
8
9
|
export const renderToolbarSettings = () => {
|
|
9
10
|
document.querySelector("#settings-button").onclick = toggleSettings
|
|
@@ -18,6 +19,18 @@ const toggleSettings = () => {
|
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
21
|
|
|
22
|
+
export const enableWarningStyle = () => {
|
|
23
|
+
enableVariant(document.querySelector("#settings-button"), {
|
|
24
|
+
has_warning: "yes",
|
|
25
|
+
})
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const disableWarningStyle = () => {
|
|
29
|
+
enableVariant(document.querySelector("#settings-button"), {
|
|
30
|
+
has_warning: "no",
|
|
31
|
+
})
|
|
32
|
+
}
|
|
33
|
+
|
|
21
34
|
export const settingsAreVisible = () => {
|
|
22
35
|
return toolbarSectionIsActive(document.querySelector(`#settings`))
|
|
23
36
|
}
|
|
@@ -436,18 +436,27 @@
|
|
|
436
436
|
>Files shown are source files, except html</span
|
|
437
437
|
>
|
|
438
438
|
<span data-when="filesCompilation:yes"
|
|
439
|
-
>Files shown are compiled</span
|
|
439
|
+
>Files shown are compiled for {runtime}</span
|
|
440
|
+
>
|
|
441
|
+
<span data-when="filesCompilation:mismatch"
|
|
442
|
+
>Files shown are compiled for an other runtime</span
|
|
440
443
|
>
|
|
441
444
|
</div>
|
|
442
445
|
<a
|
|
443
|
-
data-when="
|
|
444
|
-
class="
|
|
446
|
+
data-when="compilation_link:source"
|
|
447
|
+
class="link_to_source_files"
|
|
445
448
|
href="javascript:void(0);"
|
|
446
449
|
>Switch to source files</a
|
|
447
450
|
>
|
|
448
451
|
<a
|
|
449
|
-
data-when="
|
|
450
|
-
class="
|
|
452
|
+
data-when="compilation_link:mismatch"
|
|
453
|
+
class="link_to_appropriate_files"
|
|
454
|
+
href="javascript:void(0);"
|
|
455
|
+
>Switch to appropriate files</a
|
|
456
|
+
>
|
|
457
|
+
<a
|
|
458
|
+
data-when="compilation_link:compiled"
|
|
459
|
+
class="link_to_compiled_files"
|
|
451
460
|
href="javascript:void(0);"
|
|
452
461
|
>Switch to compiled files</a
|
|
453
462
|
>
|
|
@@ -457,17 +466,32 @@
|
|
|
457
466
|
</div>
|
|
458
467
|
</div>
|
|
459
468
|
<button id="settings-button" class="toolbar-icon-wrapper">
|
|
460
|
-
<
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
469
|
+
<div data-when="has_warning:yes">
|
|
470
|
+
<svg
|
|
471
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
472
|
+
viewBox="0 0 511.999 511.999"
|
|
473
|
+
width="24px"
|
|
474
|
+
height="24px"
|
|
475
|
+
class="iconToolbar"
|
|
476
|
+
>
|
|
477
|
+
<path
|
|
478
|
+
d="M506.43 421.536 291.573 49.394c-15.814-27.391-55.327-27.401-71.147 0L5.568 421.536c-15.814 27.391 3.934 61.616 35.574 61.616h429.714c31.629.001 51.394-34.214 35.574-61.616zm-231.609-36.502c0 10.394-8.427 18.821-18.821 18.821s-18.821-8.427-18.821-18.821v-11.239c0-10.394 8.427-18.821 18.821-18.821s18.821 8.427 18.821 18.821v11.239zm0-73.332c0 10.394-8.427 18.821-18.821 18.821s-18.821-8.427-18.821-18.821v-107.89c0-10.394 8.427-18.821 18.821-18.821s18.821 8.427 18.821 18.821v107.89z"
|
|
479
|
+
/>
|
|
480
|
+
</svg>
|
|
481
|
+
</div>
|
|
482
|
+
<div data-when="has_warning:no">
|
|
483
|
+
<svg
|
|
484
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
485
|
+
viewBox="0 0 24 24"
|
|
486
|
+
width="24px"
|
|
487
|
+
height="24px"
|
|
488
|
+
class="iconToolbar"
|
|
489
|
+
>
|
|
490
|
+
<path
|
|
491
|
+
d="M19.14,12.94c0.04-0.3,0.06-0.61,0.06-0.94c0-0.32-0.02-0.64-0.07-0.94l2.03-1.58c0.18-0.14,0.23-0.41,0.12-0.61 l-1.92-3.32c-0.12-0.22-0.37-0.29-0.59-0.22l-2.39,0.96c-0.5-0.38-1.03-0.7-1.62-0.94L14.4,2.81c-0.04-0.24-0.24-0.41-0.48-0.41 h-3.84c-0.24,0-0.43,0.17-0.47,0.41L9.25,5.35C8.66,5.59,8.12,5.92,7.63,6.29L5.24,5.33c-0.22-0.08-0.47,0-0.59,0.22L2.74,8.87 C2.62,9.08,2.66,9.34,2.86,9.48l2.03,1.58C4.84,11.36,4.8,11.69,4.8,12s0.02,0.64,0.07,0.94l-2.03,1.58 c-0.18,0.14-0.23,0.41-0.12,0.61l1.92,3.32c0.12,0.22,0.37,0.29,0.59,0.22l2.39-0.96c0.5,0.38,1.03,0.7,1.62,0.94l0.36,2.54 c0.05,0.24,0.24,0.41,0.48,0.41h3.84c0.24,0,0.44-0.17,0.47-0.41l0.36-2.54c0.59-0.24,1.13-0.56,1.62-0.94l2.39,0.96 c0.22,0.08,0.47,0,0.59-0.22l1.92-3.32c0.12-0.22,0.07-0.47-0.12-0.61L19.14,12.94z M12,15.6c-1.98,0-3.6-1.62-3.6-3.6 s1.62-3.6,3.6-3.6s3.6,1.62,3.6,3.6S13.98,15.6,12,15.6z"
|
|
492
|
+
/>
|
|
493
|
+
</svg>
|
|
494
|
+
</div>
|
|
471
495
|
</button>
|
|
472
496
|
</section>
|
|
473
497
|
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { fetchExploringJson } from "@jsenv/core/src/internal/dev_server/exploring/fetchExploringJson.js"
|
|
2
1
|
import { setAttributes, setStyles } from "./util/dom.js"
|
|
3
2
|
|
|
4
3
|
// eslint-disable-next-line no-undef
|
|
@@ -8,18 +7,12 @@ const jsenvLogoSvgUrl = new URL("./jsenv-logo.svg", import.meta.url)
|
|
|
8
7
|
const injectToolbar = async () => {
|
|
9
8
|
await new Promise((resolve) => {
|
|
10
9
|
if (window.requestIdleCallback) {
|
|
11
|
-
window.requestIdleCallback(resolve)
|
|
10
|
+
window.requestIdleCallback(resolve, { timeout: 400 })
|
|
12
11
|
} else {
|
|
13
12
|
window.requestAnimationFrame(resolve)
|
|
14
13
|
}
|
|
15
14
|
})
|
|
16
15
|
|
|
17
|
-
const { jsenvDirectoryRelativeUrl } = await fetchExploringJson()
|
|
18
|
-
const jsenvDirectoryServerUrl = resolveUrl(
|
|
19
|
-
jsenvDirectoryRelativeUrl,
|
|
20
|
-
document.location.origin,
|
|
21
|
-
)
|
|
22
|
-
|
|
23
16
|
const placeholder = getToolbarPlaceholder()
|
|
24
17
|
|
|
25
18
|
const iframe = document.createElement("iframe")
|
|
@@ -43,14 +36,15 @@ const injectToolbar = async () => {
|
|
|
43
36
|
"border": "none",
|
|
44
37
|
})
|
|
45
38
|
const iframeLoadedPromise = iframeToLoadedPromise(iframe)
|
|
46
|
-
const jsenvToolbarHtmlServerUrl =
|
|
47
|
-
TOOLBAR_BUILD_RELATIVE_URL,
|
|
48
|
-
jsenvDirectoryServerUrl,
|
|
49
|
-
)
|
|
39
|
+
const jsenvToolbarHtmlServerUrl = `/${TOOLBAR_BUILD_RELATIVE_URL}`
|
|
50
40
|
// set iframe src BEFORE putting it into the DOM (prevent firefox adding an history entry)
|
|
51
41
|
iframe.setAttribute("src", jsenvToolbarHtmlServerUrl)
|
|
52
42
|
placeholder.parentNode.replaceChild(iframe, placeholder)
|
|
53
43
|
|
|
44
|
+
addToolbarEventCallback(iframe, "toolbar_ready", () => {
|
|
45
|
+
sendCommandToToolbar(iframe, "renderToolbar")
|
|
46
|
+
})
|
|
47
|
+
|
|
54
48
|
await iframeLoadedPromise
|
|
55
49
|
iframe.removeAttribute("tabindex")
|
|
56
50
|
|
|
@@ -150,9 +144,6 @@ const injectToolbar = async () => {
|
|
|
150
144
|
showToolbarTrigger()
|
|
151
145
|
}
|
|
152
146
|
})
|
|
153
|
-
addToolbarEventCallback(iframe, "toolbar_ready", () => {
|
|
154
|
-
sendCommandToToolbar(iframe, "renderToolbar")
|
|
155
|
-
})
|
|
156
147
|
|
|
157
148
|
return iframe
|
|
158
149
|
}
|
|
@@ -226,10 +217,13 @@ const iframeToLoadedPromise = (iframe) => {
|
|
|
226
217
|
})
|
|
227
218
|
}
|
|
228
219
|
|
|
229
|
-
const resolveUrl = (url, baseUrl) => String(new URL(url, baseUrl))
|
|
230
|
-
|
|
231
220
|
if (document.readyState === "complete") {
|
|
232
221
|
injectToolbar()
|
|
233
222
|
} else {
|
|
234
223
|
window.addEventListener("load", injectToolbar)
|
|
224
|
+
// document.addEventListener("readystatechange", () => {
|
|
225
|
+
// if (document.readyState === "complete") {
|
|
226
|
+
// injectToolbar()
|
|
227
|
+
// }
|
|
228
|
+
// })
|
|
235
229
|
}
|
|
@@ -30,10 +30,10 @@ const renderToolbar = async () => {
|
|
|
30
30
|
const compileServerOrigin = window.parent.location.origin
|
|
31
31
|
// this should not block the whole toolbar rendering + interactivity
|
|
32
32
|
const exploringConfig = await fetchExploringJson()
|
|
33
|
-
const {
|
|
33
|
+
const { jsenvDirectoryRelativeUrl, livereloading } = exploringConfig
|
|
34
34
|
const compileGroup = getCompileGroup({
|
|
35
35
|
executedFileCompiledUrl,
|
|
36
|
-
|
|
36
|
+
jsenvDirectoryRelativeUrl,
|
|
37
37
|
compileServerOrigin,
|
|
38
38
|
})
|
|
39
39
|
const executedFileRelativeUrl = compileGroup.fileRelativeUrl
|
|
@@ -165,11 +165,11 @@ const showToolbar = ({ animate = true } = {}) => {
|
|
|
165
165
|
|
|
166
166
|
const getCompileGroup = ({
|
|
167
167
|
executedFileCompiledUrl,
|
|
168
|
-
|
|
168
|
+
jsenvDirectoryRelativeUrl,
|
|
169
169
|
compileServerOrigin,
|
|
170
170
|
}) => {
|
|
171
171
|
const outDirectoryServerUrl = String(
|
|
172
|
-
new URL(
|
|
172
|
+
new URL(jsenvDirectoryRelativeUrl, compileServerOrigin),
|
|
173
173
|
)
|
|
174
174
|
if (urlIsInsideOf(executedFileCompiledUrl, outDirectoryServerUrl)) {
|
|
175
175
|
const afterCompileDirectory = urlToRelativeUrl(
|
|
@@ -180,13 +180,13 @@ const getCompileGroup = ({
|
|
|
180
180
|
const fileRelativeUrl = afterCompileDirectory.slice(slashIndex + 1)
|
|
181
181
|
return {
|
|
182
182
|
fileRelativeUrl,
|
|
183
|
-
|
|
183
|
+
jsenvDirectoryRelativeUrl,
|
|
184
184
|
compileId: afterCompileDirectory.slice(0, slashIndex),
|
|
185
185
|
}
|
|
186
186
|
}
|
|
187
187
|
return {
|
|
188
188
|
fileRelativeUrl: new URL(executedFileCompiledUrl).pathname.slice(1),
|
|
189
|
-
|
|
189
|
+
jsenvDirectoryRelativeUrl,
|
|
190
190
|
compileId: null,
|
|
191
191
|
}
|
|
192
192
|
}
|
|
@@ -215,7 +215,7 @@ export const executeConcurrently = async (
|
|
|
215
215
|
projectDirectoryUrl,
|
|
216
216
|
compileServerOrigin: compileServer.origin,
|
|
217
217
|
compileServerId: compileServer.id,
|
|
218
|
-
|
|
218
|
+
jsenvDirectoryRelativeUrl: compileServer.jsenvDirectoryRelativeUrl,
|
|
219
219
|
|
|
220
220
|
collectCoverage: coverage,
|
|
221
221
|
coverageIgnorePredicate,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Abort, raceProcessTeardownEvents } from "@jsenv/abort"
|
|
2
2
|
import { createDetailedMessage } from "@jsenv/logger"
|
|
3
3
|
|
|
4
|
-
import { mergeRuntimeSupport } from "@jsenv/core/src/internal/
|
|
4
|
+
import { mergeRuntimeSupport } from "@jsenv/core/src/internal/runtime_support/runtime_support.js"
|
|
5
5
|
import { startCompileServer } from "../compiling/startCompileServer.js"
|
|
6
6
|
import { babelPluginInstrument } from "./coverage/babel_plugin_instrument.js"
|
|
7
7
|
import { generateExecutionSteps } from "./generateExecutionSteps.js"
|
|
@@ -112,7 +112,6 @@ export const executePlan = async (
|
|
|
112
112
|
projectDirectoryUrl,
|
|
113
113
|
jsenvDirectoryRelativeUrl,
|
|
114
114
|
jsenvDirectoryClean,
|
|
115
|
-
outDirectoryName: "dev",
|
|
116
115
|
|
|
117
116
|
importResolutionMethod,
|
|
118
117
|
importDefaultExtension,
|
|
@@ -146,7 +145,7 @@ export const executePlan = async (
|
|
|
146
145
|
executionSteps = await generateExecutionSteps(
|
|
147
146
|
{
|
|
148
147
|
...plan,
|
|
149
|
-
[compileServer.
|
|
148
|
+
[compileServer.jsenvDirectoryRelativeUrl]: null,
|
|
150
149
|
},
|
|
151
150
|
{
|
|
152
151
|
signal: multipleExecutionsOperation.signal,
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
// than importing it from an undocumented location.
|
|
9
9
|
// Ideally it would be documented or a separate module
|
|
10
10
|
|
|
11
|
-
export const
|
|
11
|
+
export const babelPluginCompatMap = {
|
|
12
12
|
"proposal-numeric-separator": {
|
|
13
13
|
chrome: "75",
|
|
14
14
|
opera: "62",
|
|
@@ -425,14 +425,14 @@ export const jsenvBabelPluginCompatMap = {
|
|
|
425
425
|
|
|
426
426
|
// copy of transform-async-to-generator
|
|
427
427
|
// so that async is not transpiled when supported
|
|
428
|
-
|
|
429
|
-
|
|
428
|
+
babelPluginCompatMap["transform-async-to-promises"] =
|
|
429
|
+
babelPluginCompatMap["transform-async-to-generator"]
|
|
430
430
|
|
|
431
|
-
|
|
432
|
-
|
|
431
|
+
babelPluginCompatMap["regenerator-transform"] =
|
|
432
|
+
babelPluginCompatMap["transform-regenerator"]
|
|
433
433
|
|
|
434
434
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis#browser_compatibility
|
|
435
|
-
|
|
435
|
+
babelPluginCompatMap["global-this-as-jsenv-import"] = {
|
|
436
436
|
edge: "79",
|
|
437
437
|
firefox: "65",
|
|
438
438
|
chrome: "71",
|
|
@@ -444,12 +444,12 @@ jsenvBabelPluginCompatMap["global-this-as-jsenv-import"] = {
|
|
|
444
444
|
}
|
|
445
445
|
|
|
446
446
|
// needs support for both json and css
|
|
447
|
-
|
|
447
|
+
babelPluginCompatMap["transform-import-assertions"] = {
|
|
448
448
|
chrome: "93",
|
|
449
449
|
edge: "93",
|
|
450
450
|
}
|
|
451
451
|
|
|
452
|
-
|
|
452
|
+
babelPluginCompatMap["new-stylesheet-as-jsenv-import"] = {
|
|
453
453
|
chrome: "93",
|
|
454
454
|
edge: "93",
|
|
455
455
|
}
|
package/src/internal/features/browser_feature_detection/browser_feature_detect_dynamic_import.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {
|
|
2
|
+
asBase64Url,
|
|
3
|
+
executeWithScriptModuleInjection,
|
|
4
|
+
} from "./execute_with_script_module.js"
|
|
5
|
+
|
|
6
|
+
export const supportsDynamicImport = async () => {
|
|
7
|
+
const moduleSource = asBase64Url(`export default 42`)
|
|
8
|
+
try {
|
|
9
|
+
await executeWithScriptModuleInjection(
|
|
10
|
+
`window.__jsenv_runtime_test_dynamic_import__ = import(${JSON.stringify(
|
|
11
|
+
moduleSource,
|
|
12
|
+
)})`,
|
|
13
|
+
)
|
|
14
|
+
const namespace = await window.__jsenv_runtime_test_dynamic_import__
|
|
15
|
+
delete window.__jsenv_runtime_test_dynamic_import__
|
|
16
|
+
return namespace.default === 42
|
|
17
|
+
} catch (e) {
|
|
18
|
+
return false
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {
|
|
2
|
+
asBase64Url,
|
|
3
|
+
executeWithScriptModuleInjection,
|
|
4
|
+
} from "./execute_with_script_module.js"
|
|
5
|
+
|
|
6
|
+
export const supportsCssImportAssertions = async () => {
|
|
7
|
+
const cssBase64Url = asBase64Url("p { color: red; }", "text/css")
|
|
8
|
+
const moduleSource = asBase64Url(
|
|
9
|
+
`import css from "${cssBase64Url}" assert { type: "css" }
|
|
10
|
+
export default css`,
|
|
11
|
+
)
|
|
12
|
+
try {
|
|
13
|
+
await executeWithScriptModuleInjection(
|
|
14
|
+
`window.__jsenv_runtime_test_css_import_assertion__ = import(${JSON.stringify(
|
|
15
|
+
moduleSource,
|
|
16
|
+
)})`,
|
|
17
|
+
)
|
|
18
|
+
const namespace = await window.__jsenv_runtime_test_css_import_assertion__
|
|
19
|
+
return namespace.default instanceof CSSStyleSheet
|
|
20
|
+
} catch (e) {
|
|
21
|
+
return false
|
|
22
|
+
}
|
|
23
|
+
}
|