@jsenv/core 23.8.2 → 23.8.7
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/jsenv_browser_system.js +46 -39
- package/dist/jsenv_browser_system.js.map +14 -14
- package/dist/jsenv_compile_proxy.js.map +6 -6
- package/dist/jsenv_exploring_index.js.map +5 -5
- package/dist/jsenv_exploring_redirector.js.map +12 -12
- package/dist/jsenv_toolbar.js.map +7 -7
- package/dist/jsenv_toolbar_injector.js.map +5 -5
- package/helpers/babel/.eslintrc.cjs +24 -24
- package/helpers/babel/AsyncGenerator/AsyncGenerator.js +81 -81
- package/helpers/babel/AwaitValue/AwaitValue.js +3 -3
- package/helpers/babel/applyDecoratorDescriptor/applyDecoratorDescriptor.js +33 -33
- package/helpers/babel/arrayLikeToArray/arrayLikeToArray.js +7 -7
- package/helpers/babel/arrayWithHoles/arrayWithHoles.js +4 -4
- package/helpers/babel/arrayWithoutHoles/arrayWithoutHoles.js +6 -6
- package/helpers/babel/assertThisInitialized/assertThisInitialized.js +7 -7
- package/helpers/babel/asyncGeneratorDelegate/asyncGeneratorDelegate.js +40 -40
- package/helpers/babel/asyncIterator/asyncIterator.js +12 -12
- package/helpers/babel/asyncToGenerator/asyncToGenerator.js +34 -34
- package/helpers/babel/awaitAsyncGenerator/awaitAsyncGenerator.js +5 -5
- package/helpers/babel/classApplyDescriptorDestructureSet/classApplyDescriptorDestructureSet.js +20 -20
- package/helpers/babel/classApplyDescriptorGet/classApplyDescriptorGet.js +6 -6
- package/helpers/babel/classApplyDescriptorSet/classApplyDescriptorSet.js +13 -13
- package/helpers/babel/classCallCheck/classCallCheck.js +5 -5
- package/helpers/babel/classCheckPrivateStaticAccess/classCheckPrivateStaticAccess.js +5 -5
- package/helpers/babel/classCheckPrivateStaticFieldDescriptor/classCheckPrivateStaticFieldDescriptor.js +6 -6
- package/helpers/babel/classExtractFieldDescriptor/classExtractFieldDescriptor.js +7 -7
- package/helpers/babel/classNameTDZError/classNameTDZError.js +4 -4
- package/helpers/babel/classPrivateFieldDestructureSet/classPrivateFieldDestructureSet.js +7 -7
- package/helpers/babel/classPrivateFieldGet/classPrivateFieldGet.js +7 -7
- package/helpers/babel/classPrivateFieldLooseBase/classPrivateFieldLooseBase.js +6 -6
- package/helpers/babel/classPrivateFieldLooseKey/classPrivateFieldLooseKey.js +5 -5
- package/helpers/babel/classPrivateFieldSet/classPrivateFieldSet.js +8 -8
- package/helpers/babel/classPrivateMethodGet/classPrivateMethodGet.js +6 -6
- package/helpers/babel/classPrivateMethodSet/classPrivateMethodSet.js +3 -3
- package/helpers/babel/classStaticPrivateFieldSpecGet/classStaticPrivateFieldSpecGet.js +9 -9
- package/helpers/babel/classStaticPrivateFieldSpecSet/classStaticPrivateFieldSpecSet.js +15 -15
- package/helpers/babel/classStaticPrivateMethodGet/classStaticPrivateMethodGet.js +6 -6
- package/helpers/babel/classStaticPrivateMethodSet/classStaticPrivateMethodSet.js +3 -3
- package/helpers/babel/construct/construct.js +16 -16
- package/helpers/babel/createClass/createClass.js +15 -15
- package/helpers/babel/createForOfIteratorHelper/createForOfIteratorHelper.js +60 -60
- package/helpers/babel/createForOfIteratorHelperLoose/createForOfIteratorHelperLoose.js +23 -23
- package/helpers/babel/createRawReactElement/createRawReactElement.js +50 -50
- package/helpers/babel/createSuper/createSuper.js +22 -22
- package/helpers/babel/decorate/decorate.js +403 -403
- package/helpers/babel/defaults/defaults.js +11 -11
- package/helpers/babel/defineEnumerableProperties/defineEnumerableProperties.js +23 -23
- package/helpers/babel/defineProperty/defineProperty.js +18 -18
- package/helpers/babel/extends/extends.js +14 -14
- package/helpers/babel/get/get.js +13 -13
- package/helpers/babel/getPrototypeOf/getPrototypeOf.js +4 -4
- package/helpers/babel/inherits/inherits.js +15 -15
- package/helpers/babel/inheritsLoose/inheritsLoose.js +7 -7
- package/helpers/babel/initializerDefineProperty/initializerDefineProperty.js +10 -10
- package/helpers/babel/initializerWarningHelper/initializerWarningHelper.js +6 -6
- package/helpers/babel/instanceof/instanceof.js +6 -6
- package/helpers/babel/interopRequireDefault/interopRequireDefault.js +3 -3
- package/helpers/babel/interopRequireWildcard/interopRequireWildcard.js +37 -37
- package/helpers/babel/isNativeFunction/isNativeFunction.js +4 -4
- package/helpers/babel/isNativeReflectConstruct/isNativeReflectConstruct.js +21 -21
- package/helpers/babel/iterableToArray/iterableToArray.js +7 -7
- package/helpers/babel/iterableToArrayLimit/iterableToArrayLimit.js +36 -36
- package/helpers/babel/iterableToArrayLimitLoose/iterableToArrayLimitLoose.js +10 -10
- package/helpers/babel/jsx/jsx.js +45 -45
- package/helpers/babel/maybeArrayLike/maybeArrayLike.js +10 -10
- package/helpers/babel/newArrowCheck/newArrowCheck.js +5 -5
- package/helpers/babel/nonIterableRest/nonIterableRest.js +5 -5
- package/helpers/babel/nonIterableSpread/nonIterableSpread.js +5 -5
- package/helpers/babel/objectDestructuringEmpty/objectDestructuringEmpty.js +3 -3
- package/helpers/babel/objectSpread/objectSpread.js +23 -23
- package/helpers/babel/objectSpread2/objectSpread2.js +33 -33
- package/helpers/babel/objectWithoutProperties/objectWithoutProperties.js +19 -19
- package/helpers/babel/objectWithoutPropertiesLoose/objectWithoutPropertiesLoose.js +13 -13
- package/helpers/babel/possibleConstructorReturn/possibleConstructorReturn.js +10 -10
- package/helpers/babel/readOnlyError/readOnlyError.js +4 -4
- package/helpers/babel/readme.md +9 -9
- package/helpers/babel/set/set.js +44 -44
- package/helpers/babel/setPrototypeOf/setPrototypeOf.js +6 -6
- package/helpers/babel/skipFirstGeneratorNext/skipFirstGeneratorNext.js +8 -8
- package/helpers/babel/slicedToArray/slicedToArray.js +10 -10
- package/helpers/babel/slicedToArrayLoose/slicedToArrayLoose.js +13 -13
- package/helpers/babel/superPropBase/superPropBase.js +10 -10
- package/helpers/babel/taggedTemplateLiteral/taggedTemplateLiteral.js +10 -10
- package/helpers/babel/taggedTemplateLiteralLoose/taggedTemplateLiteralLoose.js +7 -7
- package/helpers/babel/tdz/tdz.js +4 -4
- package/helpers/babel/temporalRef/temporalRef.js +6 -6
- package/helpers/babel/temporalUndefined/temporalUndefined.js +3 -3
- package/helpers/babel/toArray/toArray.js +10 -10
- package/helpers/babel/toConsumableArray/toConsumableArray.js +10 -10
- package/helpers/babel/toPrimitive/toPrimitive.js +10 -10
- package/helpers/babel/toPropertyKey/toPropertyKey.js +6 -6
- package/helpers/babel/typeof/typeof.js +14 -14
- package/helpers/babel/unsupportedIterableToArray/unsupportedIterableToArray.js +12 -12
- package/helpers/babel/wrapAsyncGenerator/wrapAsyncGenerator.js +8 -8
- package/helpers/babel/wrapNativeSuper/wrapNativeSuper.js +30 -30
- package/helpers/babel/wrapRegExp/wrapRegExp.js +63 -63
- package/helpers/babel/writeOnlyError/writeOnlyError.js +4 -4
- package/helpers/regenerator-runtime/regenerator-runtime.js +748 -748
- package/{LICENSE → license} +21 -21
- package/package.json +2 -2
- package/src/buildProject.js +300 -300
- package/src/execute.js +184 -184
- package/src/internal/browser-launcher/jsenv-browser-system.js +203 -199
- package/src/internal/building/buildUsingRollup.js +2 -10
- package/src/internal/compiling/babel_plugin_import_assertions.js +121 -121
- package/src/internal/compiling/babel_plugin_import_metadata.js +22 -22
- package/src/internal/compiling/babel_plugin_import_visitor.js +84 -84
- package/src/internal/compiling/compile-directory/getOrGenerateCompiledFile.js +268 -268
- package/src/internal/compiling/compile-directory/updateMeta.js +154 -154
- package/src/internal/compiling/compile-directory/validateCache.js +265 -265
- package/src/internal/compiling/compileFile.js +233 -224
- package/src/internal/compiling/compileHtml.js +550 -550
- package/src/internal/compiling/createCompiledFileService.js +291 -291
- package/src/internal/compiling/html_source_file_service.js +403 -404
- package/src/internal/compiling/js-compilation-service/jsenvTransform.js +272 -270
- package/src/internal/compiling/jsenvCompilerForHtml.js +374 -308
- package/src/internal/compiling/jsenvCompilerForJavaScript.js +2 -0
- package/src/internal/compiling/startCompileServer.js +1086 -1048
- package/src/internal/compiling/transformResultToCompilationResult.js +220 -220
- package/src/internal/executing/coverage/babel_plugin_instrument.js +90 -90
- package/src/internal/executing/coverage/reportToCoverage.js +193 -187
- package/src/internal/executing/executePlan.js +183 -183
- package/src/internal/executing/launchAndExecute.js +458 -458
- package/src/internal/generateGroupMap/featuresCompatMap.js +29 -0
- package/src/internal/generateGroupMap/jsenvBabelPluginCompatMap.js +1 -8
- package/src/internal/runtime/createBrowserRuntime/scanBrowserRuntimeFeatures.js +246 -246
- package/src/internal/runtime/createNodeRuntime/scanNodeRuntimeFeatures.js +112 -112
- package/src/internal/runtime/s.js +727 -727
- package/src/internal/toolbar/jsenv-logo.svg +144 -144
- package/src/internal/toolbar/toolbar.main.css +196 -196
- package/src/internal/toolbar/toolbar.main.js +227 -227
- package/src/internal/url_conversion.js +317 -317
- package/src/startExploring.js +309 -309
|
@@ -1,199 +1,203 @@
|
|
|
1
|
-
/* eslint-env browser */
|
|
2
|
-
|
|
3
|
-
import { unevalException } from "../unevalException.js"
|
|
4
|
-
import { createBrowserRuntime } from "../runtime/createBrowserRuntime/createBrowserRuntime.js"
|
|
5
|
-
import { installBrowserErrorStackRemapping } from "../error-stack-remapping/installBrowserErrorStackRemapping.js"
|
|
6
|
-
import { fetchUrl } from "../browser-utils/fetch-browser.js"
|
|
7
|
-
import { fetchAndEvalUsingFetch } from "../browser-utils/fetchAndEvalUsingFetch.js"
|
|
8
|
-
import { memoize } from "../memoize.js"
|
|
9
|
-
|
|
10
|
-
const getNavigationStartTime = () => {
|
|
11
|
-
try {
|
|
12
|
-
return window.performance.timing.navigationStart
|
|
13
|
-
} catch (e) {
|
|
14
|
-
return Date.now()
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const navigationStartTime = getNavigationStartTime()
|
|
19
|
-
|
|
20
|
-
const readyPromise = new Promise((resolve) => {
|
|
21
|
-
if (document.readyState === "complete") {
|
|
22
|
-
resolve()
|
|
23
|
-
} else {
|
|
24
|
-
const loadCallback = () => {
|
|
25
|
-
window.removeEventListener("load", loadCallback)
|
|
26
|
-
resolve()
|
|
27
|
-
}
|
|
28
|
-
window.addEventListener("load", loadCallback)
|
|
29
|
-
}
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
const fileExecutionMap = {}
|
|
33
|
-
|
|
34
|
-
const executionResultPromise = readyPromise.then(async () => {
|
|
35
|
-
const fileExecutionResultMap = {}
|
|
36
|
-
const fileExecutionResultPromises = []
|
|
37
|
-
let status = "completed"
|
|
38
|
-
let exceptionSource = ""
|
|
39
|
-
Object.keys(fileExecutionMap).forEach((key) => {
|
|
40
|
-
fileExecutionResultMap[key] = null // to get always same order for Object.keys(executionResult)
|
|
41
|
-
const fileExecutionResultPromise = fileExecutionMap[key]
|
|
42
|
-
fileExecutionResultPromises.push(fileExecutionResultPromise)
|
|
43
|
-
fileExecutionResultPromise.then((fileExecutionResult) => {
|
|
44
|
-
fileExecutionResultMap[key] = fileExecutionResult
|
|
45
|
-
if (fileExecutionResult.status === "errored") {
|
|
46
|
-
status = "errored"
|
|
47
|
-
exceptionSource = fileExecutionResult.exceptionSource
|
|
48
|
-
}
|
|
49
|
-
})
|
|
50
|
-
})
|
|
51
|
-
await Promise.all(fileExecutionResultPromises)
|
|
52
|
-
|
|
53
|
-
return {
|
|
54
|
-
status,
|
|
55
|
-
...(status === "errored" ? { exceptionSource } : {}),
|
|
56
|
-
startTime: navigationStartTime,
|
|
57
|
-
endTime: Date.now(),
|
|
58
|
-
fileExecutionResultMap,
|
|
59
|
-
}
|
|
60
|
-
})
|
|
61
|
-
|
|
62
|
-
const executeFileUsingDynamicImport = async (
|
|
63
|
-
specifier,
|
|
64
|
-
identifier = specifier,
|
|
65
|
-
) => {
|
|
66
|
-
const { currentScript } = document
|
|
67
|
-
const fileExecutionResultPromise = (async () => {
|
|
68
|
-
try {
|
|
69
|
-
const url = new URL(specifier, document.location.href).href
|
|
70
|
-
performance.mark(`jsenv_file_import_start`)
|
|
71
|
-
const namespace = await import(url)
|
|
72
|
-
performance.measure(`jsenv_file_import`, `jsenv_file_import_start`)
|
|
73
|
-
const executionResult = {
|
|
74
|
-
status: "completed",
|
|
75
|
-
namespace,
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
//
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
globalErrorEvent.
|
|
130
|
-
globalErrorEvent.
|
|
131
|
-
|
|
132
|
-
globalErrorEvent.
|
|
133
|
-
|
|
134
|
-
globalErrorEvent.
|
|
135
|
-
globalErrorEvent.
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
const
|
|
149
|
-
const
|
|
150
|
-
const
|
|
151
|
-
const
|
|
152
|
-
|
|
153
|
-
const
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
error
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
1
|
+
/* eslint-env browser */
|
|
2
|
+
|
|
3
|
+
import { unevalException } from "../unevalException.js"
|
|
4
|
+
import { createBrowserRuntime } from "../runtime/createBrowserRuntime/createBrowserRuntime.js"
|
|
5
|
+
import { installBrowserErrorStackRemapping } from "../error-stack-remapping/installBrowserErrorStackRemapping.js"
|
|
6
|
+
import { fetchUrl } from "../browser-utils/fetch-browser.js"
|
|
7
|
+
import { fetchAndEvalUsingFetch } from "../browser-utils/fetchAndEvalUsingFetch.js"
|
|
8
|
+
import { memoize } from "../memoize.js"
|
|
9
|
+
|
|
10
|
+
const getNavigationStartTime = () => {
|
|
11
|
+
try {
|
|
12
|
+
return window.performance.timing.navigationStart
|
|
13
|
+
} catch (e) {
|
|
14
|
+
return Date.now()
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const navigationStartTime = getNavigationStartTime()
|
|
19
|
+
|
|
20
|
+
const readyPromise = new Promise((resolve) => {
|
|
21
|
+
if (document.readyState === "complete") {
|
|
22
|
+
resolve()
|
|
23
|
+
} else {
|
|
24
|
+
const loadCallback = () => {
|
|
25
|
+
window.removeEventListener("load", loadCallback)
|
|
26
|
+
resolve()
|
|
27
|
+
}
|
|
28
|
+
window.addEventListener("load", loadCallback)
|
|
29
|
+
}
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
const fileExecutionMap = {}
|
|
33
|
+
|
|
34
|
+
const executionResultPromise = readyPromise.then(async () => {
|
|
35
|
+
const fileExecutionResultMap = {}
|
|
36
|
+
const fileExecutionResultPromises = []
|
|
37
|
+
let status = "completed"
|
|
38
|
+
let exceptionSource = ""
|
|
39
|
+
Object.keys(fileExecutionMap).forEach((key) => {
|
|
40
|
+
fileExecutionResultMap[key] = null // to get always same order for Object.keys(executionResult)
|
|
41
|
+
const fileExecutionResultPromise = fileExecutionMap[key]
|
|
42
|
+
fileExecutionResultPromises.push(fileExecutionResultPromise)
|
|
43
|
+
fileExecutionResultPromise.then((fileExecutionResult) => {
|
|
44
|
+
fileExecutionResultMap[key] = fileExecutionResult
|
|
45
|
+
if (fileExecutionResult.status === "errored") {
|
|
46
|
+
status = "errored"
|
|
47
|
+
exceptionSource = fileExecutionResult.exceptionSource
|
|
48
|
+
}
|
|
49
|
+
})
|
|
50
|
+
})
|
|
51
|
+
await Promise.all(fileExecutionResultPromises)
|
|
52
|
+
|
|
53
|
+
return {
|
|
54
|
+
status,
|
|
55
|
+
...(status === "errored" ? { exceptionSource } : {}),
|
|
56
|
+
startTime: navigationStartTime,
|
|
57
|
+
endTime: Date.now(),
|
|
58
|
+
fileExecutionResultMap,
|
|
59
|
+
}
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
const executeFileUsingDynamicImport = async (
|
|
63
|
+
specifier,
|
|
64
|
+
identifier = specifier,
|
|
65
|
+
) => {
|
|
66
|
+
const { currentScript } = document
|
|
67
|
+
const fileExecutionResultPromise = (async () => {
|
|
68
|
+
try {
|
|
69
|
+
const url = new URL(specifier, document.location.href).href
|
|
70
|
+
performance.mark(`jsenv_file_import_start`)
|
|
71
|
+
const namespace = await import(url)
|
|
72
|
+
performance.measure(`jsenv_file_import`, `jsenv_file_import_start`)
|
|
73
|
+
const executionResult = {
|
|
74
|
+
status: "completed",
|
|
75
|
+
namespace,
|
|
76
|
+
coverage: readCoverage(),
|
|
77
|
+
}
|
|
78
|
+
return executionResult
|
|
79
|
+
} catch (e) {
|
|
80
|
+
performance.measure(`jsenv_file_import`, `jsenv_file_import_start`)
|
|
81
|
+
const executionResult = {
|
|
82
|
+
status: "errored",
|
|
83
|
+
exceptionSource: unevalException(e),
|
|
84
|
+
coverage: readCoverage(),
|
|
85
|
+
}
|
|
86
|
+
onExecutionError(executionResult, { currentScript })
|
|
87
|
+
return executionResult
|
|
88
|
+
}
|
|
89
|
+
})()
|
|
90
|
+
fileExecutionMap[identifier] = fileExecutionResultPromise
|
|
91
|
+
return fileExecutionResultPromise
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const executeFileUsingSystemJs = (specifier) => {
|
|
95
|
+
// si on a déja importer ce fichier ??
|
|
96
|
+
// if (specifier in fileExecutionMap) {
|
|
97
|
+
|
|
98
|
+
// }
|
|
99
|
+
|
|
100
|
+
const { currentScript } = document
|
|
101
|
+
|
|
102
|
+
const fileExecutionResultPromise = (async () => {
|
|
103
|
+
const browserRuntime = await getBrowserRuntime()
|
|
104
|
+
const executionResult = await browserRuntime.executeFile(specifier, {
|
|
105
|
+
measurePerformance: true,
|
|
106
|
+
collectPerformance: true,
|
|
107
|
+
})
|
|
108
|
+
if (executionResult.status === "errored") {
|
|
109
|
+
onExecutionError(executionResult, { currentScript })
|
|
110
|
+
}
|
|
111
|
+
return executionResult
|
|
112
|
+
})()
|
|
113
|
+
fileExecutionMap[specifier] = fileExecutionResultPromise
|
|
114
|
+
return fileExecutionResultPromise
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const onExecutionError = (executionResult, { currentScript }) => {
|
|
118
|
+
// eslint-disable-next-line no-eval
|
|
119
|
+
const originalError = window.eval(executionResult.exceptionSource)
|
|
120
|
+
if (originalError.code === "NETWORK_FAILURE") {
|
|
121
|
+
if (currentScript) {
|
|
122
|
+
const errorEvent = new Event("error")
|
|
123
|
+
currentScript.dispatchEvent(errorEvent)
|
|
124
|
+
}
|
|
125
|
+
} else {
|
|
126
|
+
const { parsingError } = originalError
|
|
127
|
+
const globalErrorEvent = new Event("error")
|
|
128
|
+
if (parsingError) {
|
|
129
|
+
globalErrorEvent.filename = parsingError.filename
|
|
130
|
+
globalErrorEvent.lineno = parsingError.lineNumber
|
|
131
|
+
globalErrorEvent.message = parsingError.message
|
|
132
|
+
globalErrorEvent.colno = parsingError.columnNumber
|
|
133
|
+
} else {
|
|
134
|
+
globalErrorEvent.filename = originalError.filename
|
|
135
|
+
globalErrorEvent.lineno = originalError.lineno
|
|
136
|
+
globalErrorEvent.message = originalError.message
|
|
137
|
+
globalErrorEvent.colno = originalError.columnno
|
|
138
|
+
}
|
|
139
|
+
window.dispatchEvent(globalErrorEvent)
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const getBrowserRuntime = memoize(async () => {
|
|
144
|
+
const compileServerOrigin = document.location.origin
|
|
145
|
+
const compileMetaResponse = await fetchUrl(
|
|
146
|
+
`${compileServerOrigin}/.jsenv/__compile_server_meta__.json`,
|
|
147
|
+
)
|
|
148
|
+
const compileMeta = await compileMetaResponse.json()
|
|
149
|
+
const { outDirectoryRelativeUrl, errorStackRemapping } = compileMeta
|
|
150
|
+
const outDirectoryUrl = `${compileServerOrigin}/${outDirectoryRelativeUrl}`
|
|
151
|
+
const afterOutDirectory = document.location.href.slice(outDirectoryUrl.length)
|
|
152
|
+
const parts = afterOutDirectory.split("/")
|
|
153
|
+
const compileId = parts[0]
|
|
154
|
+
|
|
155
|
+
const browserRuntime = await createBrowserRuntime({
|
|
156
|
+
compileServerOrigin,
|
|
157
|
+
outDirectoryRelativeUrl,
|
|
158
|
+
compileId,
|
|
159
|
+
})
|
|
160
|
+
|
|
161
|
+
if (errorStackRemapping && Error.captureStackTrace) {
|
|
162
|
+
const { sourcemapMainFileRelativeUrl, sourcemapMappingFileRelativeUrl } =
|
|
163
|
+
compileMeta
|
|
164
|
+
|
|
165
|
+
await fetchAndEvalUsingFetch(
|
|
166
|
+
`${compileServerOrigin}/${sourcemapMainFileRelativeUrl}`,
|
|
167
|
+
)
|
|
168
|
+
const { SourceMapConsumer } = window.sourceMap
|
|
169
|
+
SourceMapConsumer.initialize({
|
|
170
|
+
"lib/mappings.wasm": `${compileServerOrigin}/${sourcemapMappingFileRelativeUrl}`,
|
|
171
|
+
})
|
|
172
|
+
const { getErrorOriginalStackString } = installBrowserErrorStackRemapping({
|
|
173
|
+
SourceMapConsumer,
|
|
174
|
+
})
|
|
175
|
+
|
|
176
|
+
const errorTransform = async (error) => {
|
|
177
|
+
// code can throw something else than an error
|
|
178
|
+
// in that case return it unchanged
|
|
179
|
+
if (!error || !(error instanceof Error)) return error
|
|
180
|
+
const originalStack = await getErrorOriginalStackString(error)
|
|
181
|
+
error.stack = originalStack
|
|
182
|
+
return error
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
const executeFile = browserRuntime.executeFile
|
|
186
|
+
browserRuntime.executeFile = (file, options = {}) => {
|
|
187
|
+
return executeFile(file, { errorTransform, ...options })
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
return browserRuntime
|
|
192
|
+
})
|
|
193
|
+
|
|
194
|
+
const livereloadingCallbacks = {}
|
|
195
|
+
|
|
196
|
+
const readCoverage = () => window.__coverage__
|
|
197
|
+
|
|
198
|
+
window.__jsenv__ = {
|
|
199
|
+
livereloadingCallbacks,
|
|
200
|
+
executionResultPromise,
|
|
201
|
+
executeFileUsingDynamicImport,
|
|
202
|
+
executeFileUsingSystemJs,
|
|
203
|
+
}
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
isNodePartOfSupportedRuntimes,
|
|
15
15
|
isBrowserPartOfSupportedRuntimes,
|
|
16
16
|
} from "@jsenv/core/src/internal/generateGroupMap/runtime_support.js"
|
|
17
|
+
import { featuresCompatMap } from "@jsenv/core/src/internal/generateGroupMap/featuresCompatMap.js"
|
|
17
18
|
import { createRuntimeCompat } from "@jsenv/core/src/internal/generateGroupMap/runtime_compat.js"
|
|
18
19
|
import { createJsenvRollupPlugin } from "./createJsenvRollupPlugin.js"
|
|
19
20
|
|
|
@@ -71,16 +72,7 @@ export const buildUsingRollup = async ({
|
|
|
71
72
|
import_assertion_type_json: true,
|
|
72
73
|
import_assertion_type_css: true,
|
|
73
74
|
},
|
|
74
|
-
pluginCompatMap:
|
|
75
|
-
import_assertion_type_json: {
|
|
76
|
-
chrome: "91",
|
|
77
|
-
edge: "91",
|
|
78
|
-
},
|
|
79
|
-
import_assertion_type_css: {
|
|
80
|
-
chrome: "93",
|
|
81
|
-
edge: "93",
|
|
82
|
-
},
|
|
83
|
-
},
|
|
75
|
+
pluginCompatMap: featuresCompatMap,
|
|
84
76
|
})
|
|
85
77
|
const importAssertionsSupport = {
|
|
86
78
|
json:
|