es-module-shims 1.10.0 → 2.0.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/README.md +148 -125
- package/dist/es-module-shims.debug.js +722 -583
- package/dist/es-module-shims.js +708 -576
- package/dist/es-module-shims.wasm.js +708 -576
- package/index.d.ts +1 -0
- package/package.json +3 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* ES Module Shims DEBUG BUILD
|
|
1
|
+
/* ES Module Shims DEBUG BUILD 2.0.0 */
|
|
2
2
|
(function () {
|
|
3
3
|
|
|
4
4
|
const hasDocument = typeof document !== 'undefined';
|
|
@@ -10,7 +10,13 @@
|
|
|
10
10
|
const esmsInitOptions = optionsScript ? JSON.parse(optionsScript.innerHTML) : {};
|
|
11
11
|
Object.assign(esmsInitOptions, self.esmsInitOptions || {});
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
// shim mode is determined on initialization, no late shim mode
|
|
14
|
+
const shimMode =
|
|
15
|
+
hasDocument ?
|
|
16
|
+
esmsInitOptions.shimMode ||
|
|
17
|
+
document.querySelectorAll('script[type=module-shim],script[type=importmap-shim],link[rel=modulepreload-shim]')
|
|
18
|
+
.length > 0
|
|
19
|
+
: true;
|
|
14
20
|
|
|
15
21
|
const importHook = globalHook(shimMode && esmsInitOptions.onimport);
|
|
16
22
|
const resolveHook = globalHook(shimMode && esmsInitOptions.resolve);
|
|
@@ -22,15 +28,14 @@
|
|
|
22
28
|
let nonce = esmsInitOptions.nonce;
|
|
23
29
|
if (!nonce && hasDocument) {
|
|
24
30
|
const nonceElement = document.querySelector('script[nonce]');
|
|
25
|
-
if (nonceElement)
|
|
26
|
-
nonce = nonceElement.nonce || nonceElement.getAttribute('nonce');
|
|
31
|
+
if (nonceElement) nonce = nonceElement.nonce || nonceElement.getAttribute('nonce');
|
|
27
32
|
}
|
|
28
33
|
|
|
29
34
|
const onerror = globalHook(esmsInitOptions.onerror || noop);
|
|
30
35
|
|
|
31
|
-
const { revokeBlobURLs, noLoadEventRetriggers,
|
|
36
|
+
const { revokeBlobURLs, noLoadEventRetriggers, enforceIntegrity } = esmsInitOptions;
|
|
32
37
|
|
|
33
|
-
function globalHook
|
|
38
|
+
function globalHook(name) {
|
|
34
39
|
return typeof name === 'string' ? self[name] : name;
|
|
35
40
|
}
|
|
36
41
|
|
|
@@ -40,25 +45,30 @@
|
|
|
40
45
|
const wasmModulesEnabled = enable.includes('wasm-modules');
|
|
41
46
|
const sourcePhaseEnabled = enable.includes('source-phase');
|
|
42
47
|
|
|
43
|
-
const onpolyfill =
|
|
44
|
-
|
|
45
|
-
|
|
48
|
+
const onpolyfill =
|
|
49
|
+
esmsInitOptions.onpolyfill ?
|
|
50
|
+
globalHook(esmsInitOptions.onpolyfill)
|
|
51
|
+
: () => {
|
|
52
|
+
console.log(`%c^^ Module error above is polyfilled and can be ignored ^^`, 'font-weight:900;color:#391');
|
|
53
|
+
};
|
|
46
54
|
|
|
47
55
|
const edge = !navigator.userAgentData && !!navigator.userAgent.match(/Edge\/\d+\.\d+/);
|
|
48
56
|
|
|
49
|
-
const baseUrl =
|
|
50
|
-
?
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
57
|
+
const baseUrl =
|
|
58
|
+
hasDocument ?
|
|
59
|
+
document.baseURI
|
|
60
|
+
: `${location.protocol}//${location.host}${
|
|
61
|
+
location.pathname.includes('/') ?
|
|
62
|
+
location.pathname.slice(0, location.pathname.lastIndexOf('/') + 1)
|
|
63
|
+
: location.pathname
|
|
64
|
+
}`;
|
|
54
65
|
|
|
55
66
|
const createBlob = (source, type = 'text/javascript') => URL.createObjectURL(new Blob([source], { type }));
|
|
56
67
|
let { skip } = esmsInitOptions;
|
|
57
68
|
if (Array.isArray(skip)) {
|
|
58
69
|
const l = skip.map(s => new URL(s, baseUrl).href);
|
|
59
|
-
skip = s => l.some(i => i[i.length - 1] === '/' && s.startsWith(i) || s === i);
|
|
60
|
-
}
|
|
61
|
-
else if (typeof skip === 'string') {
|
|
70
|
+
skip = s => l.some(i => (i[i.length - 1] === '/' && s.startsWith(i)) || s === i);
|
|
71
|
+
} else if (typeof skip === 'string') {
|
|
62
72
|
const r = new RegExp(skip);
|
|
63
73
|
skip = s => r.test(s);
|
|
64
74
|
} else if (skip instanceof RegExp) {
|
|
@@ -67,418 +77,466 @@
|
|
|
67
77
|
|
|
68
78
|
const dispatchError = error => self.dispatchEvent(Object.assign(new Event('error'), { error }));
|
|
69
79
|
|
|
70
|
-
const throwError = err => {
|
|
80
|
+
const throwError = err => {
|
|
81
|
+
(self.reportError || dispatchError)(err), void onerror(err);
|
|
82
|
+
};
|
|
71
83
|
|
|
72
|
-
function fromParent
|
|
84
|
+
function fromParent(parent) {
|
|
73
85
|
return parent ? ` imported from ${parent}` : '';
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
let importMapSrcOrLazy = false;
|
|
77
|
-
|
|
78
|
-
function setImportMapSrcOrLazy () {
|
|
79
|
-
importMapSrcOrLazy = true;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// shim mode is determined on initialization, no late shim mode
|
|
83
|
-
if (!shimMode) {
|
|
84
|
-
if (document.querySelectorAll('script[type=module-shim],script[type=importmap-shim],link[rel=modulepreload-shim]').length) {
|
|
85
|
-
shimMode = true;
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
let seenScript = false;
|
|
89
|
-
for (const script of document.querySelectorAll('script[type=module],script[type=importmap]')) {
|
|
90
|
-
if (!seenScript) {
|
|
91
|
-
if (script.type === 'module' && !script.ep)
|
|
92
|
-
seenScript = true;
|
|
93
|
-
}
|
|
94
|
-
else if (script.type === 'importmap' && seenScript) {
|
|
95
|
-
importMapSrcOrLazy = true;
|
|
96
|
-
break;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
86
|
}
|
|
101
87
|
|
|
102
|
-
const backslashRegEx = /\\/g;
|
|
103
|
-
|
|
104
|
-
function asURL
|
|
105
|
-
try {
|
|
106
|
-
if (url.indexOf(':') !== -1)
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
catch (_) {}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
function resolveUrl (relUrl, parentUrl) {
|
|
113
|
-
return resolveIfNotPlainOrUrl(relUrl, parentUrl) || (asURL(relUrl) || resolveIfNotPlainOrUrl('./' + relUrl, parentUrl));
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
function resolveIfNotPlainOrUrl (relUrl, parentUrl) {
|
|
117
|
-
const hIdx = parentUrl.indexOf('#'), qIdx = parentUrl.indexOf('?');
|
|
118
|
-
if (hIdx + qIdx > -2)
|
|
119
|
-
parentUrl = parentUrl.slice(0, hIdx === -1 ? qIdx : qIdx === -1 || qIdx > hIdx ? hIdx : qIdx);
|
|
120
|
-
if (relUrl.indexOf('\\') !== -1)
|
|
121
|
-
relUrl = relUrl.replace(backslashRegEx, '/');
|
|
122
|
-
// protocol-relative
|
|
123
|
-
if (relUrl[0] === '/' && relUrl[1] === '/') {
|
|
124
|
-
return parentUrl.slice(0, parentUrl.indexOf(':') + 1) + relUrl;
|
|
125
|
-
}
|
|
126
|
-
// relative-url
|
|
127
|
-
else if (relUrl[0] === '.' && (relUrl[1] === '/' || relUrl[1] === '.' && (relUrl[2] === '/' || relUrl.length === 2 && (relUrl += '/')) ||
|
|
128
|
-
relUrl.length === 1 && (relUrl += '/')) ||
|
|
129
|
-
relUrl[0] === '/') {
|
|
130
|
-
const parentProtocol = parentUrl.slice(0, parentUrl.indexOf(':') + 1);
|
|
131
|
-
if (parentProtocol === 'blob:') {
|
|
132
|
-
throw new TypeError(`Failed to resolve module specifier "${relUrl}". Invalid relative url or base scheme isn't hierarchical.`);
|
|
133
|
-
}
|
|
134
|
-
// Disabled, but these cases will give inconsistent results for deep backtracking
|
|
135
|
-
//if (parentUrl[parentProtocol.length] !== '/')
|
|
136
|
-
// throw new Error('Cannot resolve');
|
|
137
|
-
// read pathname from parent URL
|
|
138
|
-
// pathname taken to be part after leading "/"
|
|
139
|
-
let pathname;
|
|
140
|
-
if (parentUrl[parentProtocol.length + 1] === '/') {
|
|
141
|
-
// resolving to a :// so we need to read out the auth and host
|
|
142
|
-
if (parentProtocol !== 'file:') {
|
|
143
|
-
pathname = parentUrl.slice(parentProtocol.length + 2);
|
|
144
|
-
pathname = pathname.slice(pathname.indexOf('/') + 1);
|
|
145
|
-
}
|
|
146
|
-
else {
|
|
147
|
-
pathname = parentUrl.slice(8);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
else {
|
|
151
|
-
// resolving to :/ so pathname is the /... part
|
|
152
|
-
pathname = parentUrl.slice(parentProtocol.length + (parentUrl[parentProtocol.length] === '/'));
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
if (relUrl[0] === '/')
|
|
156
|
-
return parentUrl.slice(0, parentUrl.length - pathname.length - 1) + relUrl;
|
|
157
|
-
|
|
158
|
-
// join together and split for removal of .. and . segments
|
|
159
|
-
// looping the string instead of anything fancy for perf reasons
|
|
160
|
-
// '../../../../../z' resolved to 'x/y' is just 'z'
|
|
161
|
-
const segmented = pathname.slice(0, pathname.lastIndexOf('/') + 1) + relUrl;
|
|
162
|
-
|
|
163
|
-
const output = [];
|
|
164
|
-
let segmentIndex = -1;
|
|
165
|
-
for (let i = 0; i < segmented.length; i++) {
|
|
166
|
-
// busy reading a segment - only terminate on '/'
|
|
167
|
-
if (segmentIndex !== -1) {
|
|
168
|
-
if (segmented[i] === '/') {
|
|
169
|
-
output.push(segmented.slice(segmentIndex, i + 1));
|
|
170
|
-
segmentIndex = -1;
|
|
171
|
-
}
|
|
172
|
-
continue;
|
|
173
|
-
}
|
|
174
|
-
// new segment - check if it is relative
|
|
175
|
-
else if (segmented[i] === '.') {
|
|
176
|
-
// ../ segment
|
|
177
|
-
if (segmented[i + 1] === '.' && (segmented[i + 2] === '/' || i + 2 === segmented.length)) {
|
|
178
|
-
output.pop();
|
|
179
|
-
i += 2;
|
|
180
|
-
continue;
|
|
181
|
-
}
|
|
182
|
-
// ./ segment
|
|
183
|
-
else if (segmented[i + 1] === '/' || i + 1 === segmented.length) {
|
|
184
|
-
i += 1;
|
|
185
|
-
continue;
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
// it is the start of a new segment
|
|
189
|
-
while (segmented[i] === '/') i++;
|
|
190
|
-
segmentIndex = i;
|
|
191
|
-
}
|
|
192
|
-
// finish reading out the last segment
|
|
193
|
-
if (segmentIndex !== -1)
|
|
194
|
-
output.push(segmented.slice(segmentIndex));
|
|
195
|
-
return parentUrl.slice(0, parentUrl.length - pathname.length) + output.join('');
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
function resolveAndComposeImportMap (json, baseUrl, parentMap) {
|
|
200
|
-
const outMap = { imports: Object.assign({}, parentMap.imports), scopes: Object.assign({}, parentMap.scopes), integrity: Object.assign({}, parentMap.integrity) };
|
|
201
|
-
|
|
202
|
-
if (json.imports)
|
|
203
|
-
resolveAndComposePackages(json.imports, outMap.imports, baseUrl, parentMap);
|
|
204
|
-
|
|
205
|
-
if (json.scopes)
|
|
206
|
-
for (let s in json.scopes) {
|
|
207
|
-
const resolvedScope = resolveUrl(s, baseUrl);
|
|
208
|
-
resolveAndComposePackages(json.scopes[s], outMap.scopes[resolvedScope] || (outMap.scopes[resolvedScope] = {}), baseUrl, parentMap);
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
if (json.integrity)
|
|
212
|
-
resolveAndComposeIntegrity(json.integrity, outMap.integrity, baseUrl);
|
|
213
|
-
|
|
214
|
-
return outMap;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
function getMatch (path, matchObj) {
|
|
218
|
-
if (matchObj[path])
|
|
219
|
-
return path;
|
|
220
|
-
let sepIndex = path.length;
|
|
221
|
-
do {
|
|
222
|
-
const segment = path.slice(0, sepIndex + 1);
|
|
223
|
-
if (segment in matchObj)
|
|
224
|
-
return segment;
|
|
225
|
-
} while ((sepIndex = path.lastIndexOf('/', sepIndex - 1)) !== -1)
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
function applyPackages (id, packages) {
|
|
229
|
-
const pkgName = getMatch(id, packages);
|
|
230
|
-
if (pkgName) {
|
|
231
|
-
const pkg = packages[pkgName];
|
|
232
|
-
if (pkg === null) return;
|
|
233
|
-
return pkg + id.slice(pkgName.length);
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
function resolveImportMap (importMap, resolvedOrPlain, parentUrl) {
|
|
239
|
-
let scopeUrl = parentUrl && getMatch(parentUrl, importMap.scopes);
|
|
240
|
-
while (scopeUrl) {
|
|
241
|
-
const packageResolution = applyPackages(resolvedOrPlain, importMap.scopes[scopeUrl]);
|
|
242
|
-
if (packageResolution)
|
|
243
|
-
return packageResolution;
|
|
244
|
-
scopeUrl = getMatch(scopeUrl.slice(0, scopeUrl.lastIndexOf('/')), importMap.scopes);
|
|
245
|
-
}
|
|
246
|
-
return applyPackages(resolvedOrPlain, importMap.imports) || resolvedOrPlain.indexOf(':') !== -1 && resolvedOrPlain;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
function resolveAndComposePackages (packages, outPackages, baseUrl, parentMap) {
|
|
250
|
-
for (let p in packages) {
|
|
251
|
-
const resolvedLhs = resolveIfNotPlainOrUrl(p, baseUrl) || p;
|
|
252
|
-
if ((!shimMode || !mapOverrides) && outPackages[resolvedLhs] && (outPackages[resolvedLhs] !== packages[resolvedLhs])) {
|
|
253
|
-
throw Error(`Rejected map override "${resolvedLhs}" from ${outPackages[resolvedLhs]} to ${packages[resolvedLhs]}.`);
|
|
254
|
-
}
|
|
255
|
-
let target = packages[p];
|
|
256
|
-
if (typeof target !== 'string')
|
|
257
|
-
continue;
|
|
258
|
-
const mapped = resolveImportMap(parentMap, resolveIfNotPlainOrUrl(target, baseUrl) || target, baseUrl);
|
|
259
|
-
if (mapped) {
|
|
260
|
-
outPackages[resolvedLhs] = mapped;
|
|
261
|
-
continue;
|
|
262
|
-
}
|
|
263
|
-
console.warn(`Mapping "${p}" -> "${packages[p]}" does not resolve`);
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
function resolveAndComposeIntegrity (integrity, outIntegrity, baseUrl) {
|
|
268
|
-
for (let p in integrity) {
|
|
269
|
-
const resolvedLhs = resolveIfNotPlainOrUrl(p, baseUrl) || p;
|
|
270
|
-
if ((!shimMode || !mapOverrides) && outIntegrity[resolvedLhs] && (outIntegrity[resolvedLhs] !== integrity[resolvedLhs])) {
|
|
271
|
-
throw Error(`Rejected map integrity override "${resolvedLhs}" from ${outIntegrity[resolvedLhs]} to ${integrity[resolvedLhs]}.`);
|
|
272
|
-
}
|
|
273
|
-
outIntegrity[resolvedLhs] = integrity[p];
|
|
274
|
-
}
|
|
88
|
+
const backslashRegEx = /\\/g;
|
|
89
|
+
|
|
90
|
+
function asURL(url) {
|
|
91
|
+
try {
|
|
92
|
+
if (url.indexOf(':') !== -1) return new URL(url).href;
|
|
93
|
+
} catch (_) {}
|
|
275
94
|
}
|
|
276
95
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
const
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
96
|
+
function resolveUrl(relUrl, parentUrl) {
|
|
97
|
+
return resolveIfNotPlainOrUrl(relUrl, parentUrl) || asURL(relUrl) || resolveIfNotPlainOrUrl('./' + relUrl, parentUrl);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function resolveIfNotPlainOrUrl(relUrl, parentUrl) {
|
|
101
|
+
const hIdx = parentUrl.indexOf('#'),
|
|
102
|
+
qIdx = parentUrl.indexOf('?');
|
|
103
|
+
if (hIdx + qIdx > -2)
|
|
104
|
+
parentUrl = parentUrl.slice(
|
|
105
|
+
0,
|
|
106
|
+
hIdx === -1 ? qIdx
|
|
107
|
+
: qIdx === -1 || qIdx > hIdx ? hIdx
|
|
108
|
+
: qIdx
|
|
109
|
+
);
|
|
110
|
+
if (relUrl.indexOf('\\') !== -1) relUrl = relUrl.replace(backslashRegEx, '/');
|
|
111
|
+
// protocol-relative
|
|
112
|
+
if (relUrl[0] === '/' && relUrl[1] === '/') {
|
|
113
|
+
return parentUrl.slice(0, parentUrl.indexOf(':') + 1) + relUrl;
|
|
114
|
+
}
|
|
115
|
+
// relative-url
|
|
116
|
+
else if (
|
|
117
|
+
(relUrl[0] === '.' &&
|
|
118
|
+
(relUrl[1] === '/' ||
|
|
119
|
+
(relUrl[1] === '.' && (relUrl[2] === '/' || (relUrl.length === 2 && (relUrl += '/')))) ||
|
|
120
|
+
(relUrl.length === 1 && (relUrl += '/')))) ||
|
|
121
|
+
relUrl[0] === '/'
|
|
122
|
+
) {
|
|
123
|
+
const parentProtocol = parentUrl.slice(0, parentUrl.indexOf(':') + 1);
|
|
124
|
+
if (parentProtocol === 'blob:') {
|
|
125
|
+
throw new TypeError(
|
|
126
|
+
`Failed to resolve module specifier "${relUrl}". Invalid relative url or base scheme isn't hierarchical.`
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
// Disabled, but these cases will give inconsistent results for deep backtracking
|
|
130
|
+
//if (parentUrl[parentProtocol.length] !== '/')
|
|
131
|
+
// throw new Error('Cannot resolve');
|
|
132
|
+
// read pathname from parent URL
|
|
133
|
+
// pathname taken to be part after leading "/"
|
|
134
|
+
let pathname;
|
|
135
|
+
if (parentUrl[parentProtocol.length + 1] === '/') {
|
|
136
|
+
// resolving to a :// so we need to read out the auth and host
|
|
137
|
+
if (parentProtocol !== 'file:') {
|
|
138
|
+
pathname = parentUrl.slice(parentProtocol.length + 2);
|
|
139
|
+
pathname = pathname.slice(pathname.indexOf('/') + 1);
|
|
140
|
+
} else {
|
|
141
|
+
pathname = parentUrl.slice(8);
|
|
142
|
+
}
|
|
143
|
+
} else {
|
|
144
|
+
// resolving to :/ so pathname is the /... part
|
|
145
|
+
pathname = parentUrl.slice(parentProtocol.length + (parentUrl[parentProtocol.length] === '/'));
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if (relUrl[0] === '/') return parentUrl.slice(0, parentUrl.length - pathname.length - 1) + relUrl;
|
|
149
|
+
|
|
150
|
+
// join together and split for removal of .. and . segments
|
|
151
|
+
// looping the string instead of anything fancy for perf reasons
|
|
152
|
+
// '../../../../../z' resolved to 'x/y' is just 'z'
|
|
153
|
+
const segmented = pathname.slice(0, pathname.lastIndexOf('/') + 1) + relUrl;
|
|
154
|
+
|
|
155
|
+
const output = [];
|
|
156
|
+
let segmentIndex = -1;
|
|
157
|
+
for (let i = 0; i < segmented.length; i++) {
|
|
158
|
+
// busy reading a segment - only terminate on '/'
|
|
159
|
+
if (segmentIndex !== -1) {
|
|
160
|
+
if (segmented[i] === '/') {
|
|
161
|
+
output.push(segmented.slice(segmentIndex, i + 1));
|
|
162
|
+
segmentIndex = -1;
|
|
163
|
+
}
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
// new segment - check if it is relative
|
|
167
|
+
else if (segmented[i] === '.') {
|
|
168
|
+
// ../ segment
|
|
169
|
+
if (segmented[i + 1] === '.' && (segmented[i + 2] === '/' || i + 2 === segmented.length)) {
|
|
170
|
+
output.pop();
|
|
171
|
+
i += 2;
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
// ./ segment
|
|
175
|
+
else if (segmented[i + 1] === '/' || i + 1 === segmented.length) {
|
|
176
|
+
i += 1;
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
// it is the start of a new segment
|
|
181
|
+
while (segmented[i] === '/') i++;
|
|
182
|
+
segmentIndex = i;
|
|
183
|
+
}
|
|
184
|
+
// finish reading out the last segment
|
|
185
|
+
if (segmentIndex !== -1) output.push(segmented.slice(segmentIndex));
|
|
186
|
+
return parentUrl.slice(0, parentUrl.length - pathname.length) + output.join('');
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function resolveAndComposeImportMap(json, baseUrl, parentMap) {
|
|
191
|
+
const outMap = {
|
|
192
|
+
imports: Object.assign({}, parentMap.imports),
|
|
193
|
+
scopes: Object.assign({}, parentMap.scopes),
|
|
194
|
+
integrity: Object.assign({}, parentMap.integrity)
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
if (json.imports) resolveAndComposePackages(json.imports, outMap.imports, baseUrl, parentMap);
|
|
198
|
+
|
|
199
|
+
if (json.scopes)
|
|
200
|
+
for (let s in json.scopes) {
|
|
201
|
+
const resolvedScope = resolveUrl(s, baseUrl);
|
|
202
|
+
resolveAndComposePackages(
|
|
203
|
+
json.scopes[s],
|
|
204
|
+
outMap.scopes[resolvedScope] || (outMap.scopes[resolvedScope] = {}),
|
|
205
|
+
baseUrl,
|
|
206
|
+
parentMap
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
if (json.integrity) resolveAndComposeIntegrity(json.integrity, outMap.integrity, baseUrl);
|
|
211
|
+
|
|
212
|
+
return outMap;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function getMatch(path, matchObj) {
|
|
216
|
+
if (matchObj[path]) return path;
|
|
217
|
+
let sepIndex = path.length;
|
|
218
|
+
do {
|
|
219
|
+
const segment = path.slice(0, sepIndex + 1);
|
|
220
|
+
if (segment in matchObj) return segment;
|
|
221
|
+
} while ((sepIndex = path.lastIndexOf('/', sepIndex - 1)) !== -1);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function applyPackages(id, packages) {
|
|
225
|
+
const pkgName = getMatch(id, packages);
|
|
226
|
+
if (pkgName) {
|
|
227
|
+
const pkg = packages[pkgName];
|
|
228
|
+
if (pkg === null) return;
|
|
229
|
+
return pkg + id.slice(pkgName.length);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
function resolveImportMap(importMap, resolvedOrPlain, parentUrl) {
|
|
234
|
+
let scopeUrl = parentUrl && getMatch(parentUrl, importMap.scopes);
|
|
235
|
+
while (scopeUrl) {
|
|
236
|
+
const packageResolution = applyPackages(resolvedOrPlain, importMap.scopes[scopeUrl]);
|
|
237
|
+
if (packageResolution) return packageResolution;
|
|
238
|
+
scopeUrl = getMatch(scopeUrl.slice(0, scopeUrl.lastIndexOf('/')), importMap.scopes);
|
|
239
|
+
}
|
|
240
|
+
return applyPackages(resolvedOrPlain, importMap.imports) || (resolvedOrPlain.indexOf(':') !== -1 && resolvedOrPlain);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
function resolveAndComposePackages(packages, outPackages, baseUrl, parentMap) {
|
|
244
|
+
for (let p in packages) {
|
|
245
|
+
const resolvedLhs = resolveIfNotPlainOrUrl(p, baseUrl) || p;
|
|
246
|
+
if (
|
|
247
|
+
(!shimMode || !mapOverrides) &&
|
|
248
|
+
outPackages[resolvedLhs] &&
|
|
249
|
+
outPackages[resolvedLhs] !== packages[resolvedLhs]
|
|
250
|
+
) {
|
|
251
|
+
console.warn(
|
|
252
|
+
`es-module-shims: Rejected map override "${resolvedLhs}" from ${outPackages[resolvedLhs]} to ${packages[resolvedLhs]}.`
|
|
253
|
+
);
|
|
254
|
+
continue;
|
|
255
|
+
}
|
|
256
|
+
let target = packages[p];
|
|
257
|
+
if (typeof target !== 'string') continue;
|
|
258
|
+
const mapped = resolveImportMap(parentMap, resolveIfNotPlainOrUrl(target, baseUrl) || target, baseUrl);
|
|
259
|
+
if (mapped) {
|
|
260
|
+
outPackages[resolvedLhs] = mapped;
|
|
261
|
+
continue;
|
|
262
|
+
}
|
|
263
|
+
console.warn(`es-module-shims: Mapping "${p}" -> "${packages[p]}" does not resolve`);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
function resolveAndComposeIntegrity(integrity, outIntegrity, baseUrl) {
|
|
268
|
+
for (let p in integrity) {
|
|
269
|
+
const resolvedLhs = resolveIfNotPlainOrUrl(p, baseUrl) || p;
|
|
270
|
+
if (
|
|
271
|
+
(!shimMode || !mapOverrides) &&
|
|
272
|
+
outIntegrity[resolvedLhs] &&
|
|
273
|
+
outIntegrity[resolvedLhs] !== integrity[resolvedLhs]
|
|
274
|
+
) {
|
|
275
|
+
console.warn(
|
|
276
|
+
`es-module-shims: Rejected map integrity override "${resolvedLhs}" from ${outIntegrity[resolvedLhs]} to ${integrity[resolvedLhs]}.`
|
|
277
|
+
);
|
|
278
|
+
}
|
|
279
|
+
outIntegrity[resolvedLhs] = integrity[p];
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
let dynamicImport = !hasDocument && (0, eval)('u=>import(u)');
|
|
284
|
+
|
|
285
|
+
let supportsDynamicImport;
|
|
286
|
+
|
|
287
|
+
const dynamicImportCheck =
|
|
288
|
+
hasDocument &&
|
|
289
|
+
new Promise(resolve => {
|
|
290
|
+
const s = Object.assign(document.createElement('script'), {
|
|
291
|
+
src: createBlob('self._d=u=>import(u)'),
|
|
292
|
+
ep: true
|
|
293
|
+
});
|
|
294
|
+
s.setAttribute('nonce', nonce);
|
|
295
|
+
s.addEventListener('load', () => {
|
|
296
|
+
if (!(supportsDynamicImport = !!(dynamicImport = self._d))) {
|
|
297
|
+
let err;
|
|
298
|
+
window.addEventListener('error', _err => (err = _err));
|
|
299
|
+
dynamicImport = (url, opts) =>
|
|
300
|
+
new Promise((resolve, reject) => {
|
|
301
|
+
const s = Object.assign(document.createElement('script'), {
|
|
302
|
+
type: 'module',
|
|
303
|
+
src: createBlob(`import*as m from'${url}';self._esmsi=m`)
|
|
304
|
+
});
|
|
305
|
+
err = undefined;
|
|
306
|
+
s.ep = true;
|
|
307
|
+
if (nonce) s.setAttribute('nonce', nonce);
|
|
308
|
+
// Safari is unique in supporting module script error events
|
|
309
|
+
s.addEventListener('error', cb);
|
|
310
|
+
s.addEventListener('load', cb);
|
|
311
|
+
function cb(_err) {
|
|
312
|
+
document.head.removeChild(s);
|
|
313
|
+
if (self._esmsi) {
|
|
314
|
+
resolve(self._esmsi, baseUrl);
|
|
315
|
+
self._esmsi = undefined;
|
|
316
|
+
} else {
|
|
317
|
+
reject(
|
|
318
|
+
(!(_err instanceof Event) && _err) ||
|
|
319
|
+
(err && err.error) ||
|
|
320
|
+
new Error(`Error loading ${(opts && opts.errUrl) || url} (${s.src}).`)
|
|
321
|
+
);
|
|
322
|
+
err = undefined;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
document.head.appendChild(s);
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
document.head.removeChild(s);
|
|
329
|
+
delete self._d;
|
|
330
|
+
resolve();
|
|
331
|
+
});
|
|
332
|
+
document.head.appendChild(s);
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
// support browsers without dynamic import support (eg Firefox 6x)
|
|
336
|
+
let supportsJsonType = false;
|
|
337
|
+
let supportsCssType = false;
|
|
338
|
+
|
|
339
|
+
const supports = hasDocument && HTMLScriptElement.supports;
|
|
340
|
+
|
|
341
|
+
let supportsImportMaps = supports && supports.name === 'supports' && supports('importmap');
|
|
342
|
+
let supportsImportMeta = supportsDynamicImport;
|
|
343
|
+
let supportsWasmModules = false;
|
|
344
|
+
let supportsSourcePhase = false;
|
|
345
|
+
let supportsMultipleImportMaps = false;
|
|
346
|
+
|
|
347
|
+
const wasmBytes = [0, 97, 115, 109, 1, 0, 0, 0];
|
|
348
|
+
|
|
349
|
+
let featureDetectionPromise = Promise.resolve(dynamicImportCheck).then(() => {
|
|
350
|
+
if (!supportsDynamicImport) return;
|
|
351
|
+
if (!hasDocument)
|
|
352
|
+
return Promise.all([
|
|
353
|
+
supportsImportMaps || dynamicImport(createBlob('import.meta')).then(() => (supportsImportMeta = true), noop),
|
|
354
|
+
cssModulesEnabled &&
|
|
355
|
+
dynamicImport(createBlob(`import"${createBlob('', 'text/css')}"with{type:"css"}`)).then(
|
|
356
|
+
() => (supportsCssType = true),
|
|
357
|
+
noop
|
|
358
|
+
),
|
|
359
|
+
jsonModulesEnabled &&
|
|
360
|
+
dynamicImport(createBlob(`import"${createBlob('{}', 'text/json')}"with{type:"json"}`)).then(
|
|
361
|
+
() => (supportsJsonType = true),
|
|
362
|
+
noop
|
|
363
|
+
),
|
|
364
|
+
wasmModulesEnabled &&
|
|
365
|
+
dynamicImport(createBlob(`import"${createBlob(new Uint8Array(wasmBytes), 'application/wasm')}"`)).then(
|
|
366
|
+
() => (supportsWasmModules = true),
|
|
367
|
+
noop
|
|
368
|
+
),
|
|
369
|
+
wasmModulesEnabled &&
|
|
370
|
+
sourcePhaseEnabled &&
|
|
371
|
+
dynamicImport(
|
|
372
|
+
createBlob(`import source x from"${createBlob(new Uint8Array(wasmBytes), 'application/wasm')}"`)
|
|
373
|
+
).then(() => (supportsSourcePhase = true), noop)
|
|
374
|
+
]);
|
|
375
|
+
|
|
376
|
+
return new Promise(resolve => {
|
|
377
|
+
const iframe = document.createElement('iframe');
|
|
378
|
+
iframe.style.display = 'none';
|
|
379
|
+
iframe.setAttribute('nonce', nonce);
|
|
380
|
+
function cb({ data }) {
|
|
381
|
+
const isFeatureDetectionMessage = Array.isArray(data) && data[0] === 'esms';
|
|
382
|
+
if (!isFeatureDetectionMessage) return;
|
|
383
|
+
[
|
|
384
|
+
,
|
|
385
|
+
supportsImportMaps,
|
|
386
|
+
supportsImportMeta,
|
|
387
|
+
supportsMultipleImportMaps,
|
|
388
|
+
supportsCssType,
|
|
389
|
+
supportsJsonType,
|
|
390
|
+
supportsWasmModules,
|
|
391
|
+
supportsSourcePhase
|
|
392
|
+
] = data;
|
|
393
|
+
resolve();
|
|
394
|
+
document.head.removeChild(iframe);
|
|
395
|
+
window.removeEventListener('message', cb, false);
|
|
396
|
+
}
|
|
397
|
+
window.addEventListener('message', cb, false);
|
|
398
|
+
|
|
399
|
+
const importMapTest = `<script nonce=${nonce || ''}>b=(s,type='text/javascript')=>URL.createObjectURL(new Blob([s],{type}));i=innerText=>document.head.appendChild(Object.assign(document.createElement('script'),{type:'importmap',nonce:"${nonce}",innerText}));i(\`{"imports":{"x":"\${b('')}"}}\`);i(\`{"imports":{"y":"\${b('')}"}}\`);Promise.all([${
|
|
400
|
+
supportsImportMaps ? 'true,true' : `'x',b('import.meta')`
|
|
401
|
+
},'y',${cssModulesEnabled ? `b(\`import"\${b('','text/css')}"with{type:"css"}\`)` : 'false'}, ${
|
|
402
|
+
jsonModulesEnabled ? `b(\`import"\${b('{}','text/json')\}"with{type:"json"}\`)` : 'false'
|
|
403
|
+
},${
|
|
404
|
+
wasmModulesEnabled ?
|
|
405
|
+
`b(\`import"\${b(new Uint8Array(${JSON.stringify(wasmBytes)}),'application/wasm')\}"\`)`
|
|
406
|
+
: 'false'
|
|
407
|
+
},${
|
|
408
|
+
wasmModulesEnabled && sourcePhaseEnabled ?
|
|
409
|
+
`b(\`import source x from "\${b(new Uint8Array(${JSON.stringify(wasmBytes)}),'application/wasm')\}"\`)`
|
|
410
|
+
: 'false'
|
|
411
|
+
}].map(x =>typeof x==='string'?import(x).then(()=>true,()=>false):x)).then(a=>parent.postMessage(['esms'].concat(a),'*'))<${''}/script>`;
|
|
412
|
+
|
|
413
|
+
// Safari will call onload eagerly on head injection, but we don't want the Wechat
|
|
414
|
+
// path to trigger before setting srcdoc, therefore we track the timing
|
|
415
|
+
let readyForOnload = false,
|
|
416
|
+
onloadCalledWhileNotReady = false;
|
|
417
|
+
function doOnload() {
|
|
418
|
+
if (!readyForOnload) {
|
|
419
|
+
onloadCalledWhileNotReady = true;
|
|
420
|
+
return;
|
|
421
|
+
}
|
|
422
|
+
// WeChat browser doesn't support setting srcdoc scripts
|
|
423
|
+
// But iframe sandboxes don't support contentDocument so we do this as a fallback
|
|
424
|
+
const doc = iframe.contentDocument;
|
|
425
|
+
if (doc && doc.head.childNodes.length === 0) {
|
|
426
|
+
const s = doc.createElement('script');
|
|
427
|
+
if (nonce) s.setAttribute('nonce', nonce);
|
|
428
|
+
s.innerHTML = importMapTest.slice(15 + (nonce ? nonce.length : 0), -9);
|
|
429
|
+
doc.head.appendChild(s);
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
iframe.onload = doOnload;
|
|
434
|
+
// WeChat browser requires append before setting srcdoc
|
|
435
|
+
document.head.appendChild(iframe);
|
|
436
|
+
|
|
437
|
+
// setting srcdoc is not supported in React native webviews on iOS
|
|
438
|
+
// setting src to a blob URL results in a navigation event in webviews
|
|
439
|
+
// document.write gives usability warnings
|
|
440
|
+
readyForOnload = true;
|
|
441
|
+
if ('srcdoc' in iframe) iframe.srcdoc = importMapTest;
|
|
442
|
+
else iframe.contentDocument.write(importMapTest);
|
|
443
|
+
// retrigger onload for Safari only if necessary
|
|
444
|
+
if (onloadCalledWhileNotReady) doOnload();
|
|
445
|
+
});
|
|
322
446
|
});
|
|
323
447
|
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
const supports = hasDocument && HTMLScriptElement.supports;
|
|
329
|
-
|
|
330
|
-
let supportsImportMaps = supports && supports.name === 'supports' && supports('importmap');
|
|
331
|
-
let supportsImportMeta = supportsDynamicImport;
|
|
332
|
-
let supportsWasmModules = false;
|
|
333
|
-
let supportsSourcePhase = false;
|
|
334
|
-
|
|
335
|
-
const wasmBytes = [0,97,115,109,1,0,0,0];
|
|
336
|
-
|
|
337
|
-
let featureDetectionPromise = Promise.resolve(dynamicImportCheck).then(() => {
|
|
338
|
-
if (!supportsDynamicImport)
|
|
339
|
-
return;
|
|
340
|
-
if (!hasDocument)
|
|
341
|
-
return Promise.all([
|
|
342
|
-
supportsImportMaps || dynamicImport(createBlob('import.meta')).then(() => supportsImportMeta = true, noop),
|
|
343
|
-
cssModulesEnabled && dynamicImport(createBlob(`import"${createBlob('', 'text/css')}"with{type:"css"}`)).then(() => supportsCssAssertions = true, noop),
|
|
344
|
-
jsonModulesEnabled && dynamicImport(createBlob(`import"${createBlob('{}', 'text/json')}"with{type:"json"}`)).then(() => supportsJsonAssertions = true, noop),
|
|
345
|
-
wasmModulesEnabled && dynamicImport(createBlob(`import"${createBlob(new Uint8Array(wasmBytes), 'application/wasm')}"`)).then(() => supportsWasmModules = true, noop),
|
|
346
|
-
wasmModulesEnabled && sourcePhaseEnabled && dynamicImport(createBlob(`import source x from"${createBlob(new Uint8Array(wasmBytes), 'application/wasm')}"`)).then(() => supportsSourcePhase = true, noop),
|
|
347
|
-
]);
|
|
348
|
-
|
|
349
|
-
return new Promise(resolve => {
|
|
350
|
-
console.info(`es-module-shims: performing feature detections for ${`${supportsImportMaps ? '' : 'import maps, '}${cssModulesEnabled ? 'css modules, ' : ''}${jsonModulesEnabled ? 'json modules, ' : ''}${wasmModulesEnabled ? 'wasm modules, ' : ''}${wasmModulesEnabled && sourcePhaseEnabled ? 'source phase, ' : ''}`.slice(0, -2)}`);
|
|
351
|
-
const iframe = document.createElement('iframe');
|
|
352
|
-
iframe.style.display = 'none';
|
|
353
|
-
iframe.setAttribute('nonce', nonce);
|
|
354
|
-
function cb ({ data }) {
|
|
355
|
-
const isFeatureDetectionMessage = Array.isArray(data) && data[0] === 'esms';
|
|
356
|
-
if (!isFeatureDetectionMessage)
|
|
357
|
-
return;
|
|
358
|
-
[, supportsImportMaps, supportsImportMeta, supportsCssAssertions, supportsJsonAssertions, supportsWasmModules, supportsSourcePhase] = data;
|
|
359
|
-
resolve();
|
|
360
|
-
document.head.removeChild(iframe);
|
|
361
|
-
window.removeEventListener('message', cb, false);
|
|
362
|
-
}
|
|
363
|
-
window.addEventListener('message', cb, false);
|
|
364
|
-
|
|
365
|
-
const importMapTest = `<script nonce=${nonce || ''}>b=(s,type='text/javascript')=>URL.createObjectURL(new Blob([s],{type}));document.head.appendChild(Object.assign(document.createElement('script'),{type:'importmap',nonce:"${nonce}",innerText:\`{"imports":{"x":"\${b('')}"}}\`}));Promise.all([${
|
|
366
|
-
supportsImportMaps ? 'true,true' : `'x',b('import.meta')`}, ${
|
|
367
|
-
cssModulesEnabled ? `b(\`import"\${b('','text/css')}"with{type:"css"}\`)` : 'false'}, ${
|
|
368
|
-
jsonModulesEnabled ? `b(\`import"\${b('{}','text/json')\}"with{type:"json"}\`)` : 'false'}, ${
|
|
369
|
-
wasmModulesEnabled ? `b(\`import"\${b(new Uint8Array(${JSON.stringify(wasmBytes)}),'application/wasm')\}"\`)` : 'false'}, ${
|
|
370
|
-
wasmModulesEnabled && sourcePhaseEnabled ? `b(\`import source x from "\${b(new Uint8Array(${JSON.stringify(wasmBytes)}),'application/wasm')\}"\`)` : 'false'}].map(x =>typeof x==='string'?import(x).then(()=>true,()=>false):x)).then(a=>parent.postMessage(['esms'].concat(a),'*'))<${''}/script>`;
|
|
371
|
-
|
|
372
|
-
// Safari will call onload eagerly on head injection, but we don't want the Wechat
|
|
373
|
-
// path to trigger before setting srcdoc, therefore we track the timing
|
|
374
|
-
let readyForOnload = false, onloadCalledWhileNotReady = false;
|
|
375
|
-
function doOnload () {
|
|
376
|
-
if (!readyForOnload) {
|
|
377
|
-
onloadCalledWhileNotReady = true;
|
|
378
|
-
return;
|
|
379
|
-
}
|
|
380
|
-
// WeChat browser doesn't support setting srcdoc scripts
|
|
381
|
-
// But iframe sandboxes don't support contentDocument so we do this as a fallback
|
|
382
|
-
const doc = iframe.contentDocument;
|
|
383
|
-
if (doc && doc.head.childNodes.length === 0) {
|
|
384
|
-
const s = doc.createElement('script');
|
|
385
|
-
if (nonce)
|
|
386
|
-
s.setAttribute('nonce', nonce);
|
|
387
|
-
s.innerHTML = importMapTest.slice(15 + (nonce ? nonce.length : 0), -9);
|
|
388
|
-
doc.head.appendChild(s);
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
iframe.onload = doOnload;
|
|
393
|
-
// WeChat browser requires append before setting srcdoc
|
|
394
|
-
document.head.appendChild(iframe);
|
|
395
|
-
|
|
396
|
-
// setting srcdoc is not supported in React native webviews on iOS
|
|
397
|
-
// setting src to a blob URL results in a navigation event in webviews
|
|
398
|
-
// document.write gives usability warnings
|
|
399
|
-
readyForOnload = true;
|
|
400
|
-
if ('srcdoc' in iframe)
|
|
401
|
-
iframe.srcdoc = importMapTest;
|
|
402
|
-
else
|
|
403
|
-
iframe.contentDocument.write(importMapTest);
|
|
404
|
-
// retrigger onload for Safari only if necessary
|
|
405
|
-
if (onloadCalledWhileNotReady) doOnload();
|
|
406
|
-
});
|
|
407
|
-
});
|
|
408
|
-
|
|
409
|
-
featureDetectionPromise = featureDetectionPromise.then(() => {
|
|
410
|
-
console.info(`es-module-shims: detected native support - ${supportsDynamicImport ? '' : 'no '}dynamic import, ${supportsImportMeta ? '' : 'no '}import meta, ${supportsImportMaps ? '' : 'no '}import maps`);
|
|
448
|
+
featureDetectionPromise = featureDetectionPromise.then(() => {
|
|
449
|
+
console.info(
|
|
450
|
+
`es-module-shims: detected native support - module types: (${[...(supportsJsonType ? ['json'] : []), ...(supportsCssType ? ['css'] : []), ...(supportsWasmModules ? 'wasm' : '')].join(', ')}), ${supportsMultipleImportMaps ? '' : 'no '}multiple import maps, ${supportsDynamicImport ? '' : 'no '}dynamic import, ${supportsImportMeta ? '' : 'no '}import meta, ${supportsImportMaps ? '' : 'no '}import maps`
|
|
451
|
+
);
|
|
411
452
|
});
|
|
412
453
|
|
|
413
|
-
/* es-module-lexer 1.
|
|
414
|
-
let e,a,r,i=2<<19;const s=1===new Uint8Array(new Uint16Array([1]).buffer)[0]?function(e,a){const r=e.length;let i=0;for(;i<r;)a[i]=e.charCodeAt(i++);}:function(e,a){const r=e.length;let i=0;for(;i<r;){const r=e.charCodeAt(i);a[i++]=(255&r)<<8|r>>>8;}},f="xportmportlassetaourceromsyncunctionssertvoyiedelecontininstantybreareturdebuggeawaithrwhileforifcatcfinallels";let t,c$1,n;function parse(k,l="@"){t=k,c$1=l;const u=2*t.length+(2<<18);if(u>i||!e){for(;u>i;)i*=2;a=new ArrayBuffer(i),s(f,new Uint16Array(a,16,110)),e=function(e,a,r){"use asm";var i=new e.Int8Array(r),s=new e.Int16Array(r),f=new e.Int32Array(r),t=new e.Uint8Array(r),c=new e.Uint16Array(r),n=1040;function b(){var e=0,a=0,r=0,t=0,b=0,o=0;o=n;n=n+10240|0;i[804]=1;i[803]=0;s[399]=0;s[400]=0;f[69]=f[2];i[805]=0;f[68]=0;i[802]=0;f[70]=o+2048;f[71]=o;i[806]=0;e=(f[3]|0)+-2|0;f[72]=e;a=e+(f[66]<<1)|0;f[73]=a;e:while(1){r=e+2|0;f[72]=r;if(e>>>0>=a>>>0){b=18;break}a:do{switch(s[r>>1]|0){case 9:case 10:case 11:case 12:case 13:case 32:break;case 101:{if((((s[400]|0)==0?H(r)|0:0)?(m(e+4|0,16,10)|0)==0:0)?(k(),(i[804]|0)==0):0){b=9;break e}else b=17;break}case 105:{if(H(r)|0?(m(e+4|0,26,10)|0)==0:0){l();b=17;}else b=17;break}case 59:{b=17;break}case 47:switch(s[e+4>>1]|0){case 47:{P();break a}case 42:{y(1);break a}default:{b=16;break e}}default:{b=16;break e}}}while(0);if((b|0)==17){b=0;f[69]=f[72];}e=f[72]|0;a=f[73]|0;}if((b|0)==9){e=f[72]|0;f[69]=e;b=19;}else if((b|0)==16){i[804]=0;f[72]=e;b=19;}else if((b|0)==18)if(!(i[802]|0)){e=r;b=19;}else e=0;do{if((b|0)==19){e:while(1){a=e+2|0;f[72]=a;if(e>>>0>=(f[73]|0)>>>0){b=86;break}a:do{switch(s[a>>1]|0){case 9:case 10:case 11:case 12:case 13:case 32:break;case 101:{if(((s[400]|0)==0?H(a)|0:0)?(m(e+4|0,16,10)|0)==0:0){k();b=85;}else b=85;break}case 105:{if(H(a)|0?(m(e+4|0,26,10)|0)==0:0){l();b=85;}else b=85;break}case 99:{if((H(a)|0?(m(e+4|0,36,8)|0)==0:0)?V(s[e+12>>1]|0)|0:0){i[806]=1;b=85;}else b=85;break}case 40:{t=f[70]|0;a=s[400]|0;b=a&65535;f[t+(b<<3)>>2]=1;r=f[69]|0;s[400]=a+1<<16>>16;f[t+(b<<3)+4>>2]=r;b=85;break}case 41:{a=s[400]|0;if(!(a<<16>>16)){b=36;break e}b=a+-1<<16>>16;s[400]=b;t=s[399]|0;a=t&65535;if(t<<16>>16!=0?(f[(f[70]|0)+((b&65535)<<3)>>2]|0)==5:0){a=f[(f[71]|0)+(a+-1<<2)>>2]|0;r=a+4|0;if(!(f[r>>2]|0))f[r>>2]=(f[69]|0)+2;f[a+12>>2]=e+4;s[399]=t+-1<<16>>16;b=85;}else b=85;break}case 123:{b=f[69]|0;t=f[63]|0;e=b;do{if((s[b>>1]|0)==41&(t|0)!=0?(f[t+4>>2]|0)==(b|0):0){a=f[64]|0;f[63]=a;if(!a){f[59]=0;break}else {f[a+32>>2]=0;break}}}while(0);t=f[70]|0;r=s[400]|0;b=r&65535;f[t+(b<<3)>>2]=(i[806]|0)==0?2:6;s[400]=r+1<<16>>16;f[t+(b<<3)+4>>2]=e;i[806]=0;b=85;break}case 125:{e=s[400]|0;if(!(e<<16>>16)){b=49;break e}t=f[70]|0;b=e+-1<<16>>16;s[400]=b;if((f[t+((b&65535)<<3)>>2]|0)==4){h();b=85;}else b=85;break}case 39:{v(39);b=85;break}case 34:{v(34);b=85;break}case 47:switch(s[e+4>>1]|0){case 47:{P();break a}case 42:{y(1);break a}default:{e=f[69]|0;a=s[e>>1]|0;r:do{if(!(U(a)|0)){switch(a<<16>>16){case 41:if(D(f[(f[70]|0)+(c[400]<<3)+4>>2]|0)|0)break r;else {b=66;break r}case 125:break;default:{b=66;break r}}r=f[70]|0;t=c[400]|0;if(!(p(f[r+(t<<3)+4>>2]|0)|0)?(f[r+(t<<3)>>2]|0)!=6:0)b=66;}else switch(a<<16>>16){case 46:if(((s[e+-2>>1]|0)+-48&65535)<10){b=66;break r}else break r;case 43:if((s[e+-2>>1]|0)==43){b=66;break r}else break r;case 45:if((s[e+-2>>1]|0)==45){b=66;break r}else break r;default:break r}}while(0);r:do{if((b|0)==66?(0,!(u(e)|0)):0){switch(a<<16>>16){case 0:break r;case 47:{if(i[805]|0)break r;break}default:{}}b=f[65]|0;if((b|0?e>>>0>=(f[b>>2]|0)>>>0:0)?e>>>0<=(f[b+4>>2]|0)>>>0:0){g();i[805]=0;b=85;break a}r=f[3]|0;do{if(e>>>0<=r>>>0)break;e=e+-2|0;f[69]=e;a=s[e>>1]|0;}while(!(E(a)|0));if(F(a)|0){do{if(e>>>0<=r>>>0)break;e=e+-2|0;f[69]=e;}while(F(s[e>>1]|0)|0);if(j(e)|0){g();i[805]=0;b=85;break a}}i[805]=1;b=85;break a}}while(0);g();i[805]=0;b=85;break a}}case 96:{t=f[70]|0;r=s[400]|0;b=r&65535;f[t+(b<<3)+4>>2]=f[69];s[400]=r+1<<16>>16;f[t+(b<<3)>>2]=3;h();b=85;break}default:b=85;}}while(0);if((b|0)==85){b=0;f[69]=f[72];}e=f[72]|0;}if((b|0)==36){T();e=0;break}else if((b|0)==49){T();e=0;break}else if((b|0)==86){e=(i[802]|0)==0?(s[399]|s[400])<<16>>16==0:0;break}}}while(0);n=o;return e|0}function k(){var e=0,a=0,r=0,t=0,c=0,n=0,b=0,k=0,l=0,u=0,h=0,d=0,C=0,g=0;k=f[72]|0;l=f[65]|0;g=k+12|0;f[72]=g;r=w(1)|0;e=f[72]|0;if(!((e|0)==(g|0)?!(I(r)|0):0))C=3;e:do{if((C|0)==3){a:do{switch(r<<16>>16){case 123:{f[72]=e+2;e=w(1)|0;a=f[72]|0;while(1){if(W(e)|0){v(e);e=(f[72]|0)+2|0;f[72]=e;}else {q(e)|0;e=f[72]|0;}w(1)|0;e=A(a,e)|0;if(e<<16>>16==44){f[72]=(f[72]|0)+2;e=w(1)|0;}if(e<<16>>16==125){C=15;break}g=a;a=f[72]|0;if((a|0)==(g|0)){C=12;break}if(a>>>0>(f[73]|0)>>>0){C=14;break}}if((C|0)==12){T();break e}else if((C|0)==14){T();break e}else if((C|0)==15){i[803]=1;f[72]=(f[72]|0)+2;break a}break}case 42:{f[72]=e+2;w(1)|0;g=f[72]|0;A(g,g)|0;break}default:{i[804]=0;switch(r<<16>>16){case 100:{k=e+14|0;f[72]=k;switch((w(1)|0)<<16>>16){case 97:{a=f[72]|0;if((m(a+2|0,66,8)|0)==0?(c=a+10|0,F(s[c>>1]|0)|0):0){f[72]=c;w(0)|0;C=22;}break}case 102:{C=22;break}case 99:{a=f[72]|0;if(((m(a+2|0,36,8)|0)==0?(t=a+10|0,g=s[t>>1]|0,V(g)|0|g<<16>>16==123):0)?(f[72]=t,n=w(1)|0,n<<16>>16!=123):0){d=n;C=31;}break}default:{}}r:do{if((C|0)==22?(b=f[72]|0,(m(b+2|0,74,14)|0)==0):0){r=b+16|0;a=s[r>>1]|0;if(!(V(a)|0))switch(a<<16>>16){case 40:case 42:break;default:break r}f[72]=r;a=w(1)|0;if(a<<16>>16==42){f[72]=(f[72]|0)+2;a=w(1)|0;}if(a<<16>>16!=40){d=a;C=31;}}}while(0);if((C|0)==31?(u=f[72]|0,q(d)|0,h=f[72]|0,h>>>0>u>>>0):0){O(e,k,u,h);f[72]=(f[72]|0)+-2;break e}O(e,k,0,0);f[72]=e+12;break e}case 97:{f[72]=e+10;w(0)|0;e=f[72]|0;C=35;break}case 102:{C=35;break}case 99:{if((m(e+2|0,36,8)|0)==0?(a=e+10|0,E(s[a>>1]|0)|0):0){f[72]=a;g=w(1)|0;C=f[72]|0;q(g)|0;g=f[72]|0;O(C,g,C,g);f[72]=(f[72]|0)+-2;break e}e=e+4|0;f[72]=e;break}case 108:case 118:break;default:break e}if((C|0)==35){f[72]=e+16;e=w(1)|0;if(e<<16>>16==42){f[72]=(f[72]|0)+2;e=w(1)|0;}C=f[72]|0;q(e)|0;g=f[72]|0;O(C,g,C,g);f[72]=(f[72]|0)+-2;break e}f[72]=e+6;i[804]=0;r=w(1)|0;e=f[72]|0;r=(q(r)|0|32)<<16>>16==123;t=f[72]|0;if(r){f[72]=t+2;g=w(1)|0;e=f[72]|0;q(g)|0;}r:while(1){a=f[72]|0;if((a|0)==(e|0))break;O(e,a,e,a);a=w(1)|0;if(r)switch(a<<16>>16){case 93:case 125:break e;default:{}}e=f[72]|0;if(a<<16>>16!=44){C=51;break}f[72]=e+2;a=w(1)|0;e=f[72]|0;switch(a<<16>>16){case 91:case 123:{C=51;break r}default:{}}q(a)|0;}if((C|0)==51)f[72]=e+-2;if(!r)break e;f[72]=t+-2;break e}}}while(0);g=(w(1)|0)<<16>>16==102;e=f[72]|0;if(g?(m(e+2|0,60,6)|0)==0:0){f[72]=e+8;o(k,w(1)|0,0);e=(l|0)==0?240:l+16|0;while(1){e=f[e>>2]|0;if(!e)break e;f[e+12>>2]=0;f[e+8>>2]=0;e=e+16|0;}}f[72]=e+-2;}}while(0);return}function l(){var e=0,a=0,r=0,t=0,c=0,n=0,b=0;c=f[72]|0;r=c+12|0;f[72]=r;t=w(1)|0;a=f[72]|0;e:do{if(t<<16>>16!=46)if(t<<16>>16==115&a>>>0>r>>>0)if((m(a+2|0,50,10)|0)==0?(e=a+12|0,V(s[e>>1]|0)|0):0)n=14;else {a=6;r=0;n=46;}else {e=t;r=0;n=15;}else {f[72]=a+2;switch((w(1)|0)<<16>>16){case 109:{e=f[72]|0;if(m(e+2|0,44,6)|0)break e;a=f[69]|0;if(!(G(a)|0)?(s[a>>1]|0)==46:0)break e;d(c,c,e+8|0,2);break e}case 115:{e=f[72]|0;if(m(e+2|0,50,10)|0)break e;a=f[69]|0;if(!(G(a)|0)?(s[a>>1]|0)==46:0)break e;e=e+12|0;n=14;break e}default:break e}}}while(0);if((n|0)==14){f[72]=e;e=w(1)|0;r=1;n=15;}e:do{if((n|0)==15)switch(e<<16>>16){case 40:{a=f[70]|0;b=s[400]|0;t=b&65535;f[a+(t<<3)>>2]=5;e=f[72]|0;s[400]=b+1<<16>>16;f[a+(t<<3)+4>>2]=e;if((s[f[69]>>1]|0)==46)break e;f[72]=e+2;a=w(1)|0;d(c,f[72]|0,0,e);if(r){e=f[63]|0;f[e+28>>2]=5;}else e=f[63]|0;c=f[71]|0;b=s[399]|0;s[399]=b+1<<16>>16;f[c+((b&65535)<<2)>>2]=e;switch(a<<16>>16){case 39:{v(39);break}case 34:{v(34);break}default:{f[72]=(f[72]|0)+-2;break e}}e=(f[72]|0)+2|0;f[72]=e;switch((w(1)|0)<<16>>16){case 44:{f[72]=(f[72]|0)+2;w(1)|0;c=f[63]|0;f[c+4>>2]=e;b=f[72]|0;f[c+16>>2]=b;i[c+24>>0]=1;f[72]=b+-2;break e}case 41:{s[400]=(s[400]|0)+-1<<16>>16;b=f[63]|0;f[b+4>>2]=e;f[b+12>>2]=(f[72]|0)+2;i[b+24>>0]=1;s[399]=(s[399]|0)+-1<<16>>16;break e}default:{f[72]=(f[72]|0)+-2;break e}}}case 123:{if(r){a=12;r=1;n=46;break e}e=f[72]|0;if(s[400]|0){f[72]=e+-2;break e}while(1){if(e>>>0>=(f[73]|0)>>>0)break;e=w(1)|0;if(!(W(e)|0)){if(e<<16>>16==125){n=36;break}}else v(e);e=(f[72]|0)+2|0;f[72]=e;}if((n|0)==36)f[72]=(f[72]|0)+2;b=(w(1)|0)<<16>>16==102;e=f[72]|0;if(b?m(e+2|0,60,6)|0:0){T();break e}f[72]=e+8;e=w(1)|0;if(W(e)|0){o(c,e,0);break e}else {T();break e}}default:{if(r){a=12;r=1;n=46;break e}switch(e<<16>>16){case 42:case 39:case 34:{r=0;n=48;break e}default:{a=6;r=0;n=46;break e}}}}}while(0);if((n|0)==46){e=f[72]|0;if((e|0)==(c+(a<<1)|0))f[72]=e+-2;else n=48;}do{if((n|0)==48){if(s[400]|0){f[72]=(f[72]|0)+-2;break}e=f[73]|0;a=f[72]|0;while(1){if(a>>>0>=e>>>0){n=55;break}t=s[a>>1]|0;if(W(t)|0){n=53;break}b=a+2|0;f[72]=b;a=b;}if((n|0)==53){o(c,t,r);break}else if((n|0)==55){T();break}}}while(0);return}function u(e){e=e|0;var a=0,r=0;e:do{switch(s[e>>1]|0){case 100:switch(s[e+-2>>1]|0){case 105:{a=$(e+-4|0,98,2)|0;break e}case 108:{a=$(e+-4|0,102,3)|0;break e}default:{a=0;break e}}case 101:switch(s[e+-2>>1]|0){case 115:switch(s[e+-4>>1]|0){case 108:{a=B(e+-6|0,101)|0;break e}case 97:{a=B(e+-6|0,99)|0;break e}default:{a=0;break e}}case 116:{a=$(e+-4|0,108,4)|0;break e}case 117:{a=$(e+-4|0,116,6)|0;break e}default:{a=0;break e}}case 102:{if((s[e+-2>>1]|0)==111){r=e+-4|0;if((r|0)!=(f[3]|0)?(a=s[r>>1]|0,!(E(a)|0)):0)if(a<<16>>16==101)switch(s[e+-6>>1]|0){case 99:{a=$(e+-8|0,128,6)|0;break e}case 112:{a=$(e+-8|0,140,2)|0;break e}default:{a=0;break e}}else a=0;else a=1;}else a=0;break}case 107:{a=$(e+-2|0,144,4)|0;break}case 110:{a=e+-2|0;if(B(a,105)|0)a=1;else a=$(a,152,5)|0;break}case 111:{a=B(e+-2|0,100)|0;break}case 114:{a=$(e+-2|0,162,7)|0;break}case 116:{a=$(e+-2|0,176,4)|0;break}case 119:switch(s[e+-2>>1]|0){case 101:{a=B(e+-4|0,110)|0;break e}case 111:{a=$(e+-4|0,184,3)|0;break e}default:{a=0;break e}}default:a=0;}}while(0);return a|0}function o(e,a,r){e=e|0;a=a|0;r=r|0;var i=0,t=0;i=(f[72]|0)+2|0;switch(a<<16>>16){case 39:{v(39);t=5;break}case 34:{v(34);t=5;break}default:T();}do{if((t|0)==5){d(e,i,f[72]|0,1);if(r)f[(f[63]|0)+28>>2]=4;f[72]=(f[72]|0)+2;a=w(0)|0;r=a<<16>>16==97;if(r){i=f[72]|0;if(m(i+2|0,88,10)|0)t=13;}else {i=f[72]|0;if(!(((a<<16>>16==119?(s[i+2>>1]|0)==105:0)?(s[i+4>>1]|0)==116:0)?(s[i+6>>1]|0)==104:0))t=13;}if((t|0)==13){f[72]=i+-2;break}f[72]=i+((r?6:4)<<1);if((w(1)|0)<<16>>16!=123){f[72]=i;break}r=f[72]|0;a=r;e:while(1){f[72]=a+2;a=w(1)|0;switch(a<<16>>16){case 39:{v(39);f[72]=(f[72]|0)+2;a=w(1)|0;break}case 34:{v(34);f[72]=(f[72]|0)+2;a=w(1)|0;break}default:a=q(a)|0;}if(a<<16>>16!=58){t=22;break}f[72]=(f[72]|0)+2;switch((w(1)|0)<<16>>16){case 39:{v(39);break}case 34:{v(34);break}default:{t=26;break e}}f[72]=(f[72]|0)+2;switch((w(1)|0)<<16>>16){case 125:{t=31;break e}case 44:break;default:{t=30;break e}}f[72]=(f[72]|0)+2;if((w(1)|0)<<16>>16==125){t=31;break}a=f[72]|0;}if((t|0)==22){f[72]=i;break}else if((t|0)==26){f[72]=i;break}else if((t|0)==30){f[72]=i;break}else if((t|0)==31){t=f[63]|0;f[t+16>>2]=r;f[t+12>>2]=(f[72]|0)+2;break}}}while(0);return}function h(){var e=0,a=0,r=0,i=0;a=f[73]|0;r=f[72]|0;e:while(1){e=r+2|0;if(r>>>0>=a>>>0){a=10;break}switch(s[e>>1]|0){case 96:{a=7;break e}case 36:{if((s[r+4>>1]|0)==123){a=6;break e}break}case 92:{e=r+4|0;break}default:{}}r=e;}if((a|0)==6){e=r+4|0;f[72]=e;a=f[70]|0;i=s[400]|0;r=i&65535;f[a+(r<<3)>>2]=4;s[400]=i+1<<16>>16;f[a+(r<<3)+4>>2]=e;}else if((a|0)==7){f[72]=e;r=f[70]|0;i=(s[400]|0)+-1<<16>>16;s[400]=i;if((f[r+((i&65535)<<3)>>2]|0)!=3)T();}else if((a|0)==10){f[72]=e;T();}return}function w(e){e=e|0;var a=0,r=0,i=0;r=f[72]|0;e:do{a=s[r>>1]|0;a:do{if(a<<16>>16!=47)if(e)if(V(a)|0)break;else break e;else if(F(a)|0)break;else break e;else switch(s[r+2>>1]|0){case 47:{P();break a}case 42:{y(e);break a}default:{a=47;break e}}}while(0);i=f[72]|0;r=i+2|0;f[72]=r;}while(i>>>0<(f[73]|0)>>>0);return a|0}function d(e,a,r,s){e=e|0;a=a|0;r=r|0;s=s|0;var t=0,c=0;c=f[67]|0;f[67]=c+36;t=f[63]|0;f[((t|0)==0?236:t+32|0)>>2]=c;f[64]=t;f[63]=c;f[c+8>>2]=e;if(2==(s|0)){e=3;t=r;}else {t=1==(s|0);e=t?1:2;t=t?r+2|0:0;}f[c+12>>2]=t;f[c+28>>2]=e;f[c>>2]=a;f[c+4>>2]=r;f[c+16>>2]=0;f[c+20>>2]=s;a=1==(s|0);i[c+24>>0]=a&1;f[c+32>>2]=0;if(a|2==(s|0))i[803]=1;return}function v(e){e=e|0;var a=0,r=0,i=0,t=0;t=f[73]|0;a=f[72]|0;while(1){i=a+2|0;if(a>>>0>=t>>>0){a=9;break}r=s[i>>1]|0;if(r<<16>>16==e<<16>>16){a=10;break}if(r<<16>>16==92){r=a+4|0;if((s[r>>1]|0)==13){a=a+6|0;a=(s[a>>1]|0)==10?a:r;}else a=r;}else if(Z(r)|0){a=9;break}else a=i;}if((a|0)==9){f[72]=i;T();}else if((a|0)==10)f[72]=i;return}function A(e,a){e=e|0;a=a|0;var r=0,i=0,t=0,c=0;r=f[72]|0;i=s[r>>1]|0;c=(e|0)==(a|0);t=c?0:e;c=c?0:a;if(i<<16>>16==97){f[72]=r+4;r=w(1)|0;e=f[72]|0;if(W(r)|0){v(r);a=(f[72]|0)+2|0;f[72]=a;}else {q(r)|0;a=f[72]|0;}i=w(1)|0;r=f[72]|0;}if((r|0)!=(e|0))O(e,a,t,c);return i|0}function C(){var e=0,a=0,r=0;r=f[73]|0;a=f[72]|0;e:while(1){e=a+2|0;if(a>>>0>=r>>>0){a=6;break}switch(s[e>>1]|0){case 13:case 10:{a=6;break e}case 93:{a=7;break e}case 92:{e=a+4|0;break}default:{}}a=e;}if((a|0)==6){f[72]=e;T();e=0;}else if((a|0)==7){f[72]=e;e=93;}return e|0}function g(){var e=0,a=0,r=0;e:while(1){e=f[72]|0;a=e+2|0;f[72]=a;if(e>>>0>=(f[73]|0)>>>0){r=7;break}switch(s[a>>1]|0){case 13:case 10:{r=7;break e}case 47:break e;case 91:{C()|0;break}case 92:{f[72]=e+4;break}default:{}}}if((r|0)==7)T();return}function p(e){e=e|0;switch(s[e>>1]|0){case 62:{e=(s[e+-2>>1]|0)==61;break}case 41:case 59:{e=1;break}case 104:{e=$(e+-2|0,210,4)|0;break}case 121:{e=$(e+-2|0,218,6)|0;break}case 101:{e=$(e+-2|0,230,3)|0;break}default:e=0;}return e|0}function y(e){e=e|0;var a=0,r=0,i=0,t=0,c=0;t=(f[72]|0)+2|0;f[72]=t;r=f[73]|0;while(1){a=t+2|0;if(t>>>0>=r>>>0)break;i=s[a>>1]|0;if(!e?Z(i)|0:0)break;if(i<<16>>16==42?(s[t+4>>1]|0)==47:0){c=8;break}t=a;}if((c|0)==8){f[72]=a;a=t+4|0;}f[72]=a;return}function m(e,a,r){e=e|0;a=a|0;r=r|0;var s=0,f=0;e:do{if(!r)e=0;else {while(1){s=i[e>>0]|0;f=i[a>>0]|0;if(s<<24>>24!=f<<24>>24)break;r=r+-1|0;if(!r){e=0;break e}else {e=e+1|0;a=a+1|0;}}e=(s&255)-(f&255)|0;}}while(0);return e|0}function I(e){e=e|0;e:do{switch(e<<16>>16){case 38:case 37:case 33:{e=1;break}default:if((e&-8)<<16>>16==40|(e+-58&65535)<6)e=1;else {switch(e<<16>>16){case 91:case 93:case 94:{e=1;break e}default:{}}e=(e+-123&65535)<4;}}}while(0);return e|0}function U(e){e=e|0;e:do{switch(e<<16>>16){case 38:case 37:case 33:break;default:if(!((e+-58&65535)<6|(e+-40&65535)<7&e<<16>>16!=41)){switch(e<<16>>16){case 91:case 94:break e;default:{}}return e<<16>>16!=125&(e+-123&65535)<4|0}}}while(0);return 1}function x(e){e=e|0;var a=0;a=s[e>>1]|0;e:do{if((a+-9&65535)>=5){switch(a<<16>>16){case 160:case 32:{a=1;break e}default:{}}if(I(a)|0)return a<<16>>16!=46|(G(e)|0)|0;else a=0;}else a=1;}while(0);return a|0}function S(e){e=e|0;var a=0,r=0,i=0,t=0;r=n;n=n+16|0;i=r;f[i>>2]=0;f[66]=e;a=f[3]|0;t=a+(e<<1)|0;e=t+2|0;s[t>>1]=0;f[i>>2]=e;f[67]=e;f[59]=0;f[63]=0;f[61]=0;f[60]=0;f[65]=0;f[62]=0;n=r;return a|0}function O(e,a,r,s){e=e|0;a=a|0;r=r|0;s=s|0;var t=0,c=0;t=f[67]|0;f[67]=t+20;c=f[65]|0;f[((c|0)==0?240:c+16|0)>>2]=t;f[65]=t;f[t>>2]=e;f[t+4>>2]=a;f[t+8>>2]=r;f[t+12>>2]=s;f[t+16>>2]=0;i[803]=1;return}function $(e,a,r){e=e|0;a=a|0;r=r|0;var i=0,s=0;i=e+(0-r<<1)|0;s=i+2|0;e=f[3]|0;if(s>>>0>=e>>>0?(m(s,a,r<<1)|0)==0:0)if((s|0)==(e|0))e=1;else e=x(i)|0;else e=0;return e|0}function j(e){e=e|0;switch(s[e>>1]|0){case 107:{e=$(e+-2|0,144,4)|0;break}case 101:{if((s[e+-2>>1]|0)==117)e=$(e+-4|0,116,6)|0;else e=0;break}default:e=0;}return e|0}function B(e,a){e=e|0;a=a|0;var r=0;r=f[3]|0;if(r>>>0<=e>>>0?(s[e>>1]|0)==a<<16>>16:0)if((r|0)==(e|0))r=1;else r=E(s[e+-2>>1]|0)|0;else r=0;return r|0}function E(e){e=e|0;e:do{if((e+-9&65535)<5)e=1;else {switch(e<<16>>16){case 32:case 160:{e=1;break e}default:{}}e=e<<16>>16!=46&(I(e)|0);}}while(0);return e|0}function P(){var e=0,a=0,r=0;e=f[73]|0;r=f[72]|0;e:while(1){a=r+2|0;if(r>>>0>=e>>>0)break;switch(s[a>>1]|0){case 13:case 10:break e;default:r=a;}}f[72]=a;return}function q(e){e=e|0;while(1){if(V(e)|0)break;if(I(e)|0)break;e=(f[72]|0)+2|0;f[72]=e;e=s[e>>1]|0;if(!(e<<16>>16)){e=0;break}}return e|0}function z(){var e=0;e=f[(f[61]|0)+20>>2]|0;switch(e|0){case 1:{e=-1;break}case 2:{e=-2;break}default:e=e-(f[3]|0)>>1;}return e|0}function D(e){e=e|0;if(!($(e,190,5)|0)?!($(e,200,3)|0):0)e=$(e,206,2)|0;else e=1;return e|0}function F(e){e=e|0;switch(e<<16>>16){case 160:case 32:case 12:case 11:case 9:{e=1;break}default:e=0;}return e|0}function G(e){e=e|0;if((s[e>>1]|0)==46?(s[e+-2>>1]|0)==46:0)e=(s[e+-4>>1]|0)==46;else e=0;return e|0}function H(e){e=e|0;if((f[3]|0)==(e|0))e=1;else e=x(e+-2|0)|0;return e|0}function J(){var e=0;e=f[(f[62]|0)+12>>2]|0;if(!e)e=-1;else e=e-(f[3]|0)>>1;return e|0}function K(){var e=0;e=f[(f[61]|0)+12>>2]|0;if(!e)e=-1;else e=e-(f[3]|0)>>1;return e|0}function L(){var e=0;e=f[(f[62]|0)+8>>2]|0;if(!e)e=-1;else e=e-(f[3]|0)>>1;return e|0}function M(){var e=0;e=f[(f[61]|0)+16>>2]|0;if(!e)e=-1;else e=e-(f[3]|0)>>1;return e|0}function N(){var e=0;e=f[(f[61]|0)+4>>2]|0;if(!e)e=-1;else e=e-(f[3]|0)>>1;return e|0}function Q(){var e=0;e=f[61]|0;e=f[((e|0)==0?236:e+32|0)>>2]|0;f[61]=e;return (e|0)!=0|0}function R(){var e=0;e=f[62]|0;e=f[((e|0)==0?240:e+16|0)>>2]|0;f[62]=e;return (e|0)!=0|0}function T(){i[802]=1;f[68]=(f[72]|0)-(f[3]|0)>>1;f[72]=(f[73]|0)+2;return}function V(e){e=e|0;return (e|128)<<16>>16==160|(e+-9&65535)<5|0}function W(e){e=e|0;return e<<16>>16==39|e<<16>>16==34|0}function X(){return (f[(f[61]|0)+8>>2]|0)-(f[3]|0)>>1|0}function Y(){return (f[(f[62]|0)+4>>2]|0)-(f[3]|0)>>1|0}function Z(e){e=e|0;return e<<16>>16==13|e<<16>>16==10|0}function _(){return (f[f[61]>>2]|0)-(f[3]|0)>>1|0}function ee(){return (f[f[62]>>2]|0)-(f[3]|0)>>1|0}function ae(){return t[(f[61]|0)+24>>0]|0|0}function re(e){e=e|0;f[3]=e;return}function ie(){return f[(f[61]|0)+28>>2]|0}function se(){return (i[803]|0)!=0|0}function fe(){return (i[804]|0)!=0|0}function te(){return f[68]|0}function ce(e){e=e|0;n=e+992+15&-16;return 992}return {su:ce,ai:M,e:te,ee:Y,ele:J,els:L,es:ee,f:fe,id:z,ie:N,ip:ae,is:_,it:ie,ms:se,p:b,re:R,ri:Q,sa:S,se:K,ses:re,ss:X}}("undefined"!=typeof self?self:global,{},a),r=e.su(i-(2<<17));}const h=t.length+1;e.ses(r),e.sa(h-1),s(t,new Uint16Array(a,r,h)),e.p()||(n=e.e(),o());const w=[],d=[];for(;e.ri();){const a=e.is(),r=e.ie(),i=e.ai(),s=e.id(),f=e.ss(),c=e.se(),n=e.it();let k;e.ip()&&(k=b(-1===s?a:a+1,t.charCodeAt(-1===s?a-1:a))),w.push({t:n,n:k,s:a,e:r,ss:f,se:c,d:s,a:i});}for(;e.re();){const a=e.es(),r=e.ee(),i=e.els(),s=e.ele(),f=t.charCodeAt(a),c=i>=0?t.charCodeAt(i):-1;d.push({s:a,e:r,ls:i,le:s,n:34===f||39===f?b(a+1,f):t.slice(a,r),ln:i<0?void 0:34===c||39===c?b(i+1,c):t.slice(i,s)});}return [w,d,!!e.f(),!!e.ms()]}function b(e,a){n=e;let r="",i=n;for(;;){n>=t.length&&o();const e=t.charCodeAt(n);if(e===a)break;92===e?(r+=t.slice(i,n),r+=k(),i=n):(8232===e||8233===e||u(e)&&o(),++n);}return r+=t.slice(i,n++),r}function k(){let e=t.charCodeAt(++n);switch(++n,e){case 110:return "\n";case 114:return "\r";case 120:return String.fromCharCode(l(2));case 117:return function(){const e=t.charCodeAt(n);let a;123===e?(++n,a=l(t.indexOf("}",n)-n),++n,a>1114111&&o()):a=l(4);return a<=65535?String.fromCharCode(a):(a-=65536,String.fromCharCode(55296+(a>>10),56320+(1023&a)))}();case 116:return "\t";case 98:return "\b";case 118:return "\v";case 102:return "\f";case 13:10===t.charCodeAt(n)&&++n;case 10:return "";case 56:case 57:o();default:if(e>=48&&e<=55){let a=t.substr(n-1,3).match(/^[0-7]+/)[0],r=parseInt(a,8);return r>255&&(a=a.slice(0,-1),r=parseInt(a,8)),n+=a.length-1,e=t.charCodeAt(n),"0"===a&&56!==e&&57!==e||o(),String.fromCharCode(r)}return u(e)?"":String.fromCharCode(e)}}function l(e){const a=n;let r=0,i=0;for(let a=0;a<e;++a,++n){let e,s=t.charCodeAt(n);if(95!==s){if(s>=97)e=s-97+10;else if(s>=65)e=s-65+10;else {if(!(s>=48&&s<=57))break;e=s-48;}if(e>=16)break;i=s,r=16*r+e;}else 95!==i&&0!==a||o(),i=s;}return 95!==i&&n-a===e||o(),r}function u(e){return 13===e||10===e}function o(){throw Object.assign(Error(`Parse error ${c$1}:${t.slice(0,n).split("\n").length}:${n-t.lastIndexOf("\n",n-1)}`),{idx:n})}
|
|
454
|
+
/* es-module-lexer 1.6.0 */
|
|
455
|
+
let e,a,r,i=2<<19;const s=1===new Uint8Array(new Uint16Array([1]).buffer)[0]?function(e,a){const r=e.length;let i=0;for(;i<r;)a[i]=e.charCodeAt(i++);}:function(e,a){const r=e.length;let i=0;for(;i<r;){const r=e.charCodeAt(i);a[i++]=(255&r)<<8|r>>>8;}},f="xportmportlassforetaourceromsyncunctionssertvoyiedelecontininstantybreareturdebuggeawaithrwhileifcatcfinallels";let t,c$1,n;function parse(k,l="@"){t=k,c$1=l;const u=2*t.length+(2<<18);if(u>i||!e){for(;u>i;)i*=2;a=new ArrayBuffer(i),s(f,new Uint16Array(a,16,110)),e=function(e,a,r){"use asm";var i=new e.Int8Array(r),s=new e.Int16Array(r),f=new e.Int32Array(r),t=new e.Uint8Array(r),c=new e.Uint16Array(r),n=1040;function b(){var e=0,a=0,r=0,t=0,c=0,b=0,u=0;u=n;n=n+10240|0;i[804]=1;i[803]=0;s[399]=0;s[400]=0;f[69]=f[2];i[805]=0;f[68]=0;i[802]=0;f[70]=u+2048;f[71]=u;i[806]=0;e=(f[3]|0)+-2|0;f[72]=e;a=e+(f[66]<<1)|0;f[73]=a;e:while(1){r=e+2|0;f[72]=r;if(e>>>0>=a>>>0){t=18;break}a:do{switch(s[r>>1]|0){case 9:case 10:case 11:case 12:case 13:case 32:break;case 101:{if((((s[400]|0)==0?H(r)|0:0)?(m(e+4|0,16,10)|0)==0:0)?(k(),(i[804]|0)==0):0){t=9;break e}else t=17;break}case 105:{if(H(r)|0?(m(e+4|0,26,10)|0)==0:0){l();t=17;}else t=17;break}case 59:{t=17;break}case 47:switch(s[e+4>>1]|0){case 47:{P();break a}case 42:{y(1);break a}default:{t=16;break e}}default:{t=16;break e}}}while(0);if((t|0)==17){t=0;f[69]=f[72];}e=f[72]|0;a=f[73]|0;}if((t|0)==9){e=f[72]|0;f[69]=e;t=19;}else if((t|0)==16){i[804]=0;f[72]=e;t=19;}else if((t|0)==18)if(!(i[802]|0)){e=r;t=19;}else e=0;do{if((t|0)==19){e:while(1){a=e+2|0;f[72]=a;if(e>>>0>=(f[73]|0)>>>0){t=92;break}a:do{switch(s[a>>1]|0){case 9:case 10:case 11:case 12:case 13:case 32:break;case 101:{if(((s[400]|0)==0?H(a)|0:0)?(m(e+4|0,16,10)|0)==0:0){k();t=91;}else t=91;break}case 105:{if(H(a)|0?(m(e+4|0,26,10)|0)==0:0){l();t=91;}else t=91;break}case 99:{if((H(a)|0?(m(e+4|0,36,8)|0)==0:0)?V(s[e+12>>1]|0)|0:0){i[806]=1;t=91;}else t=91;break}case 40:{r=f[70]|0;e=s[400]|0;t=e&65535;f[r+(t<<3)>>2]=1;a=f[69]|0;s[400]=e+1<<16>>16;f[r+(t<<3)+4>>2]=a;t=91;break}case 41:{a=s[400]|0;if(!(a<<16>>16)){t=36;break e}r=a+-1<<16>>16;s[400]=r;t=s[399]|0;a=t&65535;if(t<<16>>16!=0?(f[(f[70]|0)+((r&65535)<<3)>>2]|0)==5:0){a=f[(f[71]|0)+(a+-1<<2)>>2]|0;r=a+4|0;if(!(f[r>>2]|0))f[r>>2]=(f[69]|0)+2;f[a+12>>2]=e+4;s[399]=t+-1<<16>>16;t=91;}else t=91;break}case 123:{t=f[69]|0;r=f[63]|0;e=t;do{if((s[t>>1]|0)==41&(r|0)!=0?(f[r+4>>2]|0)==(t|0):0){a=f[64]|0;f[63]=a;if(!a){f[59]=0;break}else {f[a+32>>2]=0;break}}}while(0);r=f[70]|0;a=s[400]|0;t=a&65535;f[r+(t<<3)>>2]=(i[806]|0)==0?2:6;s[400]=a+1<<16>>16;f[r+(t<<3)+4>>2]=e;i[806]=0;t=91;break}case 125:{e=s[400]|0;if(!(e<<16>>16)){t=49;break e}r=f[70]|0;t=e+-1<<16>>16;s[400]=t;if((f[r+((t&65535)<<3)>>2]|0)==4){h();t=91;}else t=91;break}case 39:{v(39);t=91;break}case 34:{v(34);t=91;break}case 47:switch(s[e+4>>1]|0){case 47:{P();break a}case 42:{y(1);break a}default:{e=f[69]|0;a=s[e>>1]|0;r:do{if(!(U(a)|0))if(a<<16>>16==41){r=s[400]|0;if(!(D(f[(f[70]|0)+((r&65535)<<3)+4>>2]|0)|0))t=65;}else t=64;else switch(a<<16>>16){case 46:if(((s[e+-2>>1]|0)+-48&65535)<10){t=64;break r}else break r;case 43:if((s[e+-2>>1]|0)==43){t=64;break r}else break r;case 45:if((s[e+-2>>1]|0)==45){t=64;break r}else break r;default:break r}}while(0);if((t|0)==64){r=s[400]|0;t=65;}r:do{if((t|0)==65){t=0;if(r<<16>>16!=0?(c=f[70]|0,b=(r&65535)+-1|0,a<<16>>16==102?(f[c+(b<<3)>>2]|0)==1:0):0){if((s[e+-2>>1]|0)==111?$(f[c+(b<<3)+4>>2]|0,44,3)|0:0)break}else t=69;if((t|0)==69?(0,a<<16>>16==125):0){t=f[70]|0;r=r&65535;if(p(f[t+(r<<3)+4>>2]|0)|0)break;if((f[t+(r<<3)>>2]|0)==6)break}if(!(o(e)|0)){switch(a<<16>>16){case 0:break r;case 47:{if(i[805]|0)break r;break}default:{}}t=f[65]|0;if((t|0?e>>>0>=(f[t>>2]|0)>>>0:0)?e>>>0<=(f[t+4>>2]|0)>>>0:0){g();i[805]=0;t=91;break a}r=f[3]|0;do{if(e>>>0<=r>>>0)break;e=e+-2|0;f[69]=e;a=s[e>>1]|0;}while(!(E(a)|0));if(F(a)|0){do{if(e>>>0<=r>>>0)break;e=e+-2|0;f[69]=e;}while(F(s[e>>1]|0)|0);if(j(e)|0){g();i[805]=0;t=91;break a}}i[805]=1;t=91;break a}}}while(0);g();i[805]=0;t=91;break a}}case 96:{r=f[70]|0;a=s[400]|0;t=a&65535;f[r+(t<<3)+4>>2]=f[69];s[400]=a+1<<16>>16;f[r+(t<<3)>>2]=3;h();t=91;break}default:t=91;}}while(0);if((t|0)==91){t=0;f[69]=f[72];}e=f[72]|0;}if((t|0)==36){T();e=0;break}else if((t|0)==49){T();e=0;break}else if((t|0)==92){e=(i[802]|0)==0?(s[399]|s[400])<<16>>16==0:0;break}}}while(0);n=u;return e|0}function k(){var e=0,a=0,r=0,t=0,c=0,n=0,b=0,k=0,l=0,o=0,h=0,d=0,C=0,g=0;k=f[72]|0;l=f[65]|0;g=k+12|0;f[72]=g;r=w(1)|0;e=f[72]|0;if(!((e|0)==(g|0)?!(I(r)|0):0))C=3;e:do{if((C|0)==3){a:do{switch(r<<16>>16){case 123:{f[72]=e+2;e=w(1)|0;a=f[72]|0;while(1){if(W(e)|0){v(e);e=(f[72]|0)+2|0;f[72]=e;}else {q(e)|0;e=f[72]|0;}w(1)|0;e=A(a,e)|0;if(e<<16>>16==44){f[72]=(f[72]|0)+2;e=w(1)|0;}if(e<<16>>16==125){C=15;break}g=a;a=f[72]|0;if((a|0)==(g|0)){C=12;break}if(a>>>0>(f[73]|0)>>>0){C=14;break}}if((C|0)==12){T();break e}else if((C|0)==14){T();break e}else if((C|0)==15){i[803]=1;f[72]=(f[72]|0)+2;break a}break}case 42:{f[72]=e+2;w(1)|0;g=f[72]|0;A(g,g)|0;break}default:{i[804]=0;switch(r<<16>>16){case 100:{k=e+14|0;f[72]=k;switch((w(1)|0)<<16>>16){case 97:{a=f[72]|0;if((m(a+2|0,72,8)|0)==0?(c=a+10|0,F(s[c>>1]|0)|0):0){f[72]=c;w(0)|0;C=22;}break}case 102:{C=22;break}case 99:{a=f[72]|0;if(((m(a+2|0,36,8)|0)==0?(t=a+10|0,g=s[t>>1]|0,V(g)|0|g<<16>>16==123):0)?(f[72]=t,n=w(1)|0,n<<16>>16!=123):0){d=n;C=31;}break}default:{}}r:do{if((C|0)==22?(b=f[72]|0,(m(b+2|0,80,14)|0)==0):0){r=b+16|0;a=s[r>>1]|0;if(!(V(a)|0))switch(a<<16>>16){case 40:case 42:break;default:break r}f[72]=r;a=w(1)|0;if(a<<16>>16==42){f[72]=(f[72]|0)+2;a=w(1)|0;}if(a<<16>>16!=40){d=a;C=31;}}}while(0);if((C|0)==31?(o=f[72]|0,q(d)|0,h=f[72]|0,h>>>0>o>>>0):0){O(e,k,o,h);f[72]=(f[72]|0)+-2;break e}O(e,k,0,0);f[72]=e+12;break e}case 97:{f[72]=e+10;w(0)|0;e=f[72]|0;C=35;break}case 102:{C=35;break}case 99:{if((m(e+2|0,36,8)|0)==0?(a=e+10|0,E(s[a>>1]|0)|0):0){f[72]=a;g=w(1)|0;C=f[72]|0;q(g)|0;g=f[72]|0;O(C,g,C,g);f[72]=(f[72]|0)+-2;break e}e=e+4|0;f[72]=e;break}case 108:case 118:break;default:break e}if((C|0)==35){f[72]=e+16;e=w(1)|0;if(e<<16>>16==42){f[72]=(f[72]|0)+2;e=w(1)|0;}C=f[72]|0;q(e)|0;g=f[72]|0;O(C,g,C,g);f[72]=(f[72]|0)+-2;break e}f[72]=e+6;i[804]=0;r=w(1)|0;e=f[72]|0;r=(q(r)|0|32)<<16>>16==123;t=f[72]|0;if(r){f[72]=t+2;g=w(1)|0;e=f[72]|0;q(g)|0;}r:while(1){a=f[72]|0;if((a|0)==(e|0))break;O(e,a,e,a);a=w(1)|0;if(r)switch(a<<16>>16){case 93:case 125:break e;default:{}}e=f[72]|0;if(a<<16>>16!=44){C=51;break}f[72]=e+2;a=w(1)|0;e=f[72]|0;switch(a<<16>>16){case 91:case 123:{C=51;break r}default:{}}q(a)|0;}if((C|0)==51)f[72]=e+-2;if(!r)break e;f[72]=t+-2;break e}}}while(0);g=(w(1)|0)<<16>>16==102;e=f[72]|0;if(g?(m(e+2|0,66,6)|0)==0:0){f[72]=e+8;u(k,w(1)|0,0);e=(l|0)==0?240:l+16|0;while(1){e=f[e>>2]|0;if(!e)break e;f[e+12>>2]=0;f[e+8>>2]=0;e=e+16|0;}}f[72]=e+-2;}}while(0);return}function l(){var e=0,a=0,r=0,t=0,c=0,n=0,b=0;c=f[72]|0;r=c+12|0;f[72]=r;t=w(1)|0;a=f[72]|0;e:do{if(t<<16>>16!=46)if(t<<16>>16==115&a>>>0>r>>>0)if((m(a+2|0,56,10)|0)==0?(e=a+12|0,V(s[e>>1]|0)|0):0)n=14;else {a=6;r=0;n=46;}else {e=t;r=0;n=15;}else {f[72]=a+2;switch((w(1)|0)<<16>>16){case 109:{e=f[72]|0;if(m(e+2|0,50,6)|0)break e;a=f[69]|0;if(!(G(a)|0)?(s[a>>1]|0)==46:0)break e;d(c,c,e+8|0,2);break e}case 115:{e=f[72]|0;if(m(e+2|0,56,10)|0)break e;a=f[69]|0;if(!(G(a)|0)?(s[a>>1]|0)==46:0)break e;e=e+12|0;n=14;break e}default:break e}}}while(0);if((n|0)==14){f[72]=e;e=w(1)|0;r=1;n=15;}e:do{if((n|0)==15)switch(e<<16>>16){case 40:{a=f[70]|0;b=s[400]|0;t=b&65535;f[a+(t<<3)>>2]=5;e=f[72]|0;s[400]=b+1<<16>>16;f[a+(t<<3)+4>>2]=e;if((s[f[69]>>1]|0)==46)break e;f[72]=e+2;a=w(1)|0;d(c,f[72]|0,0,e);if(r){e=f[63]|0;f[e+28>>2]=5;}else e=f[63]|0;c=f[71]|0;b=s[399]|0;s[399]=b+1<<16>>16;f[c+((b&65535)<<2)>>2]=e;switch(a<<16>>16){case 39:{v(39);break}case 34:{v(34);break}default:{f[72]=(f[72]|0)+-2;break e}}e=(f[72]|0)+2|0;f[72]=e;switch((w(1)|0)<<16>>16){case 44:{f[72]=(f[72]|0)+2;w(1)|0;c=f[63]|0;f[c+4>>2]=e;b=f[72]|0;f[c+16>>2]=b;i[c+24>>0]=1;f[72]=b+-2;break e}case 41:{s[400]=(s[400]|0)+-1<<16>>16;b=f[63]|0;f[b+4>>2]=e;f[b+12>>2]=(f[72]|0)+2;i[b+24>>0]=1;s[399]=(s[399]|0)+-1<<16>>16;break e}default:{f[72]=(f[72]|0)+-2;break e}}}case 123:{if(r){a=12;r=1;n=46;break e}e=f[72]|0;if(s[400]|0){f[72]=e+-2;break e}while(1){if(e>>>0>=(f[73]|0)>>>0)break;e=w(1)|0;if(!(W(e)|0)){if(e<<16>>16==125){n=36;break}}else v(e);e=(f[72]|0)+2|0;f[72]=e;}if((n|0)==36)f[72]=(f[72]|0)+2;b=(w(1)|0)<<16>>16==102;e=f[72]|0;if(b?m(e+2|0,66,6)|0:0){T();break e}f[72]=e+8;e=w(1)|0;if(W(e)|0){u(c,e,0);break e}else {T();break e}}default:{if(r){a=12;r=1;n=46;break e}switch(e<<16>>16){case 42:case 39:case 34:{r=0;n=48;break e}default:{a=6;r=0;n=46;break e}}}}}while(0);if((n|0)==46){e=f[72]|0;if((e|0)==(c+(a<<1)|0))f[72]=e+-2;else n=48;}do{if((n|0)==48){if(s[400]|0){f[72]=(f[72]|0)+-2;break}e=f[73]|0;a=f[72]|0;while(1){if(a>>>0>=e>>>0){n=55;break}t=s[a>>1]|0;if(W(t)|0){n=53;break}b=a+2|0;f[72]=b;a=b;}if((n|0)==53){u(c,t,r);break}else if((n|0)==55){T();break}}}while(0);return}function u(e,a,r){e=e|0;a=a|0;r=r|0;var i=0,t=0;i=(f[72]|0)+2|0;switch(a<<16>>16){case 39:{v(39);t=5;break}case 34:{v(34);t=5;break}default:T();}do{if((t|0)==5){d(e,i,f[72]|0,1);if(r)f[(f[63]|0)+28>>2]=4;f[72]=(f[72]|0)+2;a=w(0)|0;r=a<<16>>16==97;if(r){i=f[72]|0;if(m(i+2|0,94,10)|0)t=13;}else {i=f[72]|0;if(!(((a<<16>>16==119?(s[i+2>>1]|0)==105:0)?(s[i+4>>1]|0)==116:0)?(s[i+6>>1]|0)==104:0))t=13;}if((t|0)==13){f[72]=i+-2;break}f[72]=i+((r?6:4)<<1);if((w(1)|0)<<16>>16!=123){f[72]=i;break}r=f[72]|0;a=r;e:while(1){f[72]=a+2;a=w(1)|0;switch(a<<16>>16){case 39:{v(39);f[72]=(f[72]|0)+2;a=w(1)|0;break}case 34:{v(34);f[72]=(f[72]|0)+2;a=w(1)|0;break}default:a=q(a)|0;}if(a<<16>>16!=58){t=22;break}f[72]=(f[72]|0)+2;switch((w(1)|0)<<16>>16){case 39:{v(39);break}case 34:{v(34);break}default:{t=26;break e}}f[72]=(f[72]|0)+2;switch((w(1)|0)<<16>>16){case 125:{t=31;break e}case 44:break;default:{t=30;break e}}f[72]=(f[72]|0)+2;if((w(1)|0)<<16>>16==125){t=31;break}a=f[72]|0;}if((t|0)==22){f[72]=i;break}else if((t|0)==26){f[72]=i;break}else if((t|0)==30){f[72]=i;break}else if((t|0)==31){t=f[63]|0;f[t+16>>2]=r;f[t+12>>2]=(f[72]|0)+2;break}}}while(0);return}function o(e){e=e|0;e:do{switch(s[e>>1]|0){case 100:switch(s[e+-2>>1]|0){case 105:{e=$(e+-4|0,104,2)|0;break e}case 108:{e=$(e+-4|0,108,3)|0;break e}default:{e=0;break e}}case 101:switch(s[e+-2>>1]|0){case 115:switch(s[e+-4>>1]|0){case 108:{e=B(e+-6|0,101)|0;break e}case 97:{e=B(e+-6|0,99)|0;break e}default:{e=0;break e}}case 116:{e=$(e+-4|0,114,4)|0;break e}case 117:{e=$(e+-4|0,122,6)|0;break e}default:{e=0;break e}}case 102:{if((s[e+-2>>1]|0)==111?(s[e+-4>>1]|0)==101:0)switch(s[e+-6>>1]|0){case 99:{e=$(e+-8|0,134,6)|0;break e}case 112:{e=$(e+-8|0,146,2)|0;break e}default:{e=0;break e}}else e=0;break}case 107:{e=$(e+-2|0,150,4)|0;break}case 110:{e=e+-2|0;if(B(e,105)|0)e=1;else e=$(e,158,5)|0;break}case 111:{e=B(e+-2|0,100)|0;break}case 114:{e=$(e+-2|0,168,7)|0;break}case 116:{e=$(e+-2|0,182,4)|0;break}case 119:switch(s[e+-2>>1]|0){case 101:{e=B(e+-4|0,110)|0;break e}case 111:{e=$(e+-4|0,190,3)|0;break e}default:{e=0;break e}}default:e=0;}}while(0);return e|0}function h(){var e=0,a=0,r=0,i=0;a=f[73]|0;r=f[72]|0;e:while(1){e=r+2|0;if(r>>>0>=a>>>0){a=10;break}switch(s[e>>1]|0){case 96:{a=7;break e}case 36:{if((s[r+4>>1]|0)==123){a=6;break e}break}case 92:{e=r+4|0;break}default:{}}r=e;}if((a|0)==6){e=r+4|0;f[72]=e;a=f[70]|0;i=s[400]|0;r=i&65535;f[a+(r<<3)>>2]=4;s[400]=i+1<<16>>16;f[a+(r<<3)+4>>2]=e;}else if((a|0)==7){f[72]=e;r=f[70]|0;i=(s[400]|0)+-1<<16>>16;s[400]=i;if((f[r+((i&65535)<<3)>>2]|0)!=3)T();}else if((a|0)==10){f[72]=e;T();}return}function w(e){e=e|0;var a=0,r=0,i=0;r=f[72]|0;e:do{a=s[r>>1]|0;a:do{if(a<<16>>16!=47)if(e)if(V(a)|0)break;else break e;else if(F(a)|0)break;else break e;else switch(s[r+2>>1]|0){case 47:{P();break a}case 42:{y(e);break a}default:{a=47;break e}}}while(0);i=f[72]|0;r=i+2|0;f[72]=r;}while(i>>>0<(f[73]|0)>>>0);return a|0}function d(e,a,r,s){e=e|0;a=a|0;r=r|0;s=s|0;var t=0,c=0;c=f[67]|0;f[67]=c+36;t=f[63]|0;f[((t|0)==0?236:t+32|0)>>2]=c;f[64]=t;f[63]=c;f[c+8>>2]=e;if(2==(s|0)){e=3;t=r;}else {t=1==(s|0);e=t?1:2;t=t?r+2|0:0;}f[c+12>>2]=t;f[c+28>>2]=e;f[c>>2]=a;f[c+4>>2]=r;f[c+16>>2]=0;f[c+20>>2]=s;a=1==(s|0);i[c+24>>0]=a&1;f[c+32>>2]=0;if(a|2==(s|0))i[803]=1;return}function v(e){e=e|0;var a=0,r=0,i=0,t=0;t=f[73]|0;a=f[72]|0;while(1){i=a+2|0;if(a>>>0>=t>>>0){a=9;break}r=s[i>>1]|0;if(r<<16>>16==e<<16>>16){a=10;break}if(r<<16>>16==92){r=a+4|0;if((s[r>>1]|0)==13){a=a+6|0;a=(s[a>>1]|0)==10?a:r;}else a=r;}else if(Z(r)|0){a=9;break}else a=i;}if((a|0)==9){f[72]=i;T();}else if((a|0)==10)f[72]=i;return}function A(e,a){e=e|0;a=a|0;var r=0,i=0,t=0,c=0;r=f[72]|0;i=s[r>>1]|0;c=(e|0)==(a|0);t=c?0:e;c=c?0:a;if(i<<16>>16==97){f[72]=r+4;r=w(1)|0;e=f[72]|0;if(W(r)|0){v(r);a=(f[72]|0)+2|0;f[72]=a;}else {q(r)|0;a=f[72]|0;}i=w(1)|0;r=f[72]|0;}if((r|0)!=(e|0))O(e,a,t,c);return i|0}function C(){var e=0,a=0,r=0;r=f[73]|0;a=f[72]|0;e:while(1){e=a+2|0;if(a>>>0>=r>>>0){a=6;break}switch(s[e>>1]|0){case 13:case 10:{a=6;break e}case 93:{a=7;break e}case 92:{e=a+4|0;break}default:{}}a=e;}if((a|0)==6){f[72]=e;T();e=0;}else if((a|0)==7){f[72]=e;e=93;}return e|0}function g(){var e=0,a=0,r=0;e:while(1){e=f[72]|0;a=e+2|0;f[72]=a;if(e>>>0>=(f[73]|0)>>>0){r=7;break}switch(s[a>>1]|0){case 13:case 10:{r=7;break e}case 47:break e;case 91:{C()|0;break}case 92:{f[72]=e+4;break}default:{}}}if((r|0)==7)T();return}function p(e){e=e|0;switch(s[e>>1]|0){case 62:{e=(s[e+-2>>1]|0)==61;break}case 41:case 59:{e=1;break}case 104:{e=$(e+-2|0,210,4)|0;break}case 121:{e=$(e+-2|0,218,6)|0;break}case 101:{e=$(e+-2|0,230,3)|0;break}default:e=0;}return e|0}function y(e){e=e|0;var a=0,r=0,i=0,t=0,c=0;t=(f[72]|0)+2|0;f[72]=t;r=f[73]|0;while(1){a=t+2|0;if(t>>>0>=r>>>0)break;i=s[a>>1]|0;if(!e?Z(i)|0:0)break;if(i<<16>>16==42?(s[t+4>>1]|0)==47:0){c=8;break}t=a;}if((c|0)==8){f[72]=a;a=t+4|0;}f[72]=a;return}function m(e,a,r){e=e|0;a=a|0;r=r|0;var s=0,f=0;e:do{if(!r)e=0;else {while(1){s=i[e>>0]|0;f=i[a>>0]|0;if(s<<24>>24!=f<<24>>24)break;r=r+-1|0;if(!r){e=0;break e}else {e=e+1|0;a=a+1|0;}}e=(s&255)-(f&255)|0;}}while(0);return e|0}function I(e){e=e|0;e:do{switch(e<<16>>16){case 38:case 37:case 33:{e=1;break}default:if((e&-8)<<16>>16==40|(e+-58&65535)<6)e=1;else {switch(e<<16>>16){case 91:case 93:case 94:{e=1;break e}default:{}}e=(e+-123&65535)<4;}}}while(0);return e|0}function U(e){e=e|0;e:do{switch(e<<16>>16){case 38:case 37:case 33:break;default:if(!((e+-58&65535)<6|(e+-40&65535)<7&e<<16>>16!=41)){switch(e<<16>>16){case 91:case 94:break e;default:{}}return e<<16>>16!=125&(e+-123&65535)<4|0}}}while(0);return 1}function x(e){e=e|0;var a=0;a=s[e>>1]|0;e:do{if((a+-9&65535)>=5){switch(a<<16>>16){case 160:case 32:{a=1;break e}default:{}}if(I(a)|0)return a<<16>>16!=46|(G(e)|0)|0;else a=0;}else a=1;}while(0);return a|0}function S(e){e=e|0;var a=0,r=0,i=0,t=0;r=n;n=n+16|0;i=r;f[i>>2]=0;f[66]=e;a=f[3]|0;t=a+(e<<1)|0;e=t+2|0;s[t>>1]=0;f[i>>2]=e;f[67]=e;f[59]=0;f[63]=0;f[61]=0;f[60]=0;f[65]=0;f[62]=0;n=r;return a|0}function O(e,a,r,s){e=e|0;a=a|0;r=r|0;s=s|0;var t=0,c=0;t=f[67]|0;f[67]=t+20;c=f[65]|0;f[((c|0)==0?240:c+16|0)>>2]=t;f[65]=t;f[t>>2]=e;f[t+4>>2]=a;f[t+8>>2]=r;f[t+12>>2]=s;f[t+16>>2]=0;i[803]=1;return}function $(e,a,r){e=e|0;a=a|0;r=r|0;var i=0,s=0;i=e+(0-r<<1)|0;s=i+2|0;e=f[3]|0;if(s>>>0>=e>>>0?(m(s,a,r<<1)|0)==0:0)if((s|0)==(e|0))e=1;else e=x(i)|0;else e=0;return e|0}function j(e){e=e|0;switch(s[e>>1]|0){case 107:{e=$(e+-2|0,150,4)|0;break}case 101:{if((s[e+-2>>1]|0)==117)e=$(e+-4|0,122,6)|0;else e=0;break}default:e=0;}return e|0}function B(e,a){e=e|0;a=a|0;var r=0;r=f[3]|0;if(r>>>0<=e>>>0?(s[e>>1]|0)==a<<16>>16:0)if((r|0)==(e|0))r=1;else r=E(s[e+-2>>1]|0)|0;else r=0;return r|0}function E(e){e=e|0;e:do{if((e+-9&65535)<5)e=1;else {switch(e<<16>>16){case 32:case 160:{e=1;break e}default:{}}e=e<<16>>16!=46&(I(e)|0);}}while(0);return e|0}function P(){var e=0,a=0,r=0;e=f[73]|0;r=f[72]|0;e:while(1){a=r+2|0;if(r>>>0>=e>>>0)break;switch(s[a>>1]|0){case 13:case 10:break e;default:r=a;}}f[72]=a;return}function q(e){e=e|0;while(1){if(V(e)|0)break;if(I(e)|0)break;e=(f[72]|0)+2|0;f[72]=e;e=s[e>>1]|0;if(!(e<<16>>16)){e=0;break}}return e|0}function z(){var e=0;e=f[(f[61]|0)+20>>2]|0;switch(e|0){case 1:{e=-1;break}case 2:{e=-2;break}default:e=e-(f[3]|0)>>1;}return e|0}function D(e){e=e|0;if(!($(e,196,5)|0)?!($(e,44,3)|0):0)e=$(e,206,2)|0;else e=1;return e|0}function F(e){e=e|0;switch(e<<16>>16){case 160:case 32:case 12:case 11:case 9:{e=1;break}default:e=0;}return e|0}function G(e){e=e|0;if((s[e>>1]|0)==46?(s[e+-2>>1]|0)==46:0)e=(s[e+-4>>1]|0)==46;else e=0;return e|0}function H(e){e=e|0;if((f[3]|0)==(e|0))e=1;else e=x(e+-2|0)|0;return e|0}function J(){var e=0;e=f[(f[62]|0)+12>>2]|0;if(!e)e=-1;else e=e-(f[3]|0)>>1;return e|0}function K(){var e=0;e=f[(f[61]|0)+12>>2]|0;if(!e)e=-1;else e=e-(f[3]|0)>>1;return e|0}function L(){var e=0;e=f[(f[62]|0)+8>>2]|0;if(!e)e=-1;else e=e-(f[3]|0)>>1;return e|0}function M(){var e=0;e=f[(f[61]|0)+16>>2]|0;if(!e)e=-1;else e=e-(f[3]|0)>>1;return e|0}function N(){var e=0;e=f[(f[61]|0)+4>>2]|0;if(!e)e=-1;else e=e-(f[3]|0)>>1;return e|0}function Q(){var e=0;e=f[61]|0;e=f[((e|0)==0?236:e+32|0)>>2]|0;f[61]=e;return (e|0)!=0|0}function R(){var e=0;e=f[62]|0;e=f[((e|0)==0?240:e+16|0)>>2]|0;f[62]=e;return (e|0)!=0|0}function T(){i[802]=1;f[68]=(f[72]|0)-(f[3]|0)>>1;f[72]=(f[73]|0)+2;return}function V(e){e=e|0;return (e|128)<<16>>16==160|(e+-9&65535)<5|0}function W(e){e=e|0;return e<<16>>16==39|e<<16>>16==34|0}function X(){return (f[(f[61]|0)+8>>2]|0)-(f[3]|0)>>1|0}function Y(){return (f[(f[62]|0)+4>>2]|0)-(f[3]|0)>>1|0}function Z(e){e=e|0;return e<<16>>16==13|e<<16>>16==10|0}function _(){return (f[f[61]>>2]|0)-(f[3]|0)>>1|0}function ee(){return (f[f[62]>>2]|0)-(f[3]|0)>>1|0}function ae(){return t[(f[61]|0)+24>>0]|0|0}function re(e){e=e|0;f[3]=e;return}function ie(){return f[(f[61]|0)+28>>2]|0}function se(){return (i[803]|0)!=0|0}function fe(){return (i[804]|0)!=0|0}function te(){return f[68]|0}function ce(e){e=e|0;n=e+992+15&-16;return 992}return {su:ce,ai:M,e:te,ee:Y,ele:J,els:L,es:ee,f:fe,id:z,ie:N,ip:ae,is:_,it:ie,ms:se,p:b,re:R,ri:Q,sa:S,se:K,ses:re,ss:X}}("undefined"!=typeof self?self:global,{},a),r=e.su(i-(2<<17));}const h=t.length+1;e.ses(r),e.sa(h-1),s(t,new Uint16Array(a,r,h)),e.p()||(n=e.e(),o());const w=[],d=[];for(;e.ri();){const a=e.is(),r=e.ie(),i=e.ai(),s=e.id(),f=e.ss(),c=e.se(),n=e.it();let k;e.ip()&&(k=b(-1===s?a:a+1,t.charCodeAt(-1===s?a-1:a))),w.push({t:n,n:k,s:a,e:r,ss:f,se:c,d:s,a:i});}for(;e.re();){const a=e.es(),r=e.ee(),i=e.els(),s=e.ele(),f=t.charCodeAt(a),c=i>=0?t.charCodeAt(i):-1;d.push({s:a,e:r,ls:i,le:s,n:34===f||39===f?b(a+1,f):t.slice(a,r),ln:i<0?void 0:34===c||39===c?b(i+1,c):t.slice(i,s)});}return [w,d,!!e.f(),!!e.ms()]}function b(e,a){n=e;let r="",i=n;for(;;){n>=t.length&&o();const e=t.charCodeAt(n);if(e===a)break;92===e?(r+=t.slice(i,n),r+=k(),i=n):(8232===e||8233===e||u(e)&&o(),++n);}return r+=t.slice(i,n++),r}function k(){let e=t.charCodeAt(++n);switch(++n,e){case 110:return "\n";case 114:return "\r";case 120:return String.fromCharCode(l(2));case 117:return function(){const e=t.charCodeAt(n);let a;123===e?(++n,a=l(t.indexOf("}",n)-n),++n,a>1114111&&o()):a=l(4);return a<=65535?String.fromCharCode(a):(a-=65536,String.fromCharCode(55296+(a>>10),56320+(1023&a)))}();case 116:return "\t";case 98:return "\b";case 118:return "\v";case 102:return "\f";case 13:10===t.charCodeAt(n)&&++n;case 10:return "";case 56:case 57:o();default:if(e>=48&&e<=55){let a=t.substr(n-1,3).match(/^[0-7]+/)[0],r=parseInt(a,8);return r>255&&(a=a.slice(0,-1),r=parseInt(a,8)),n+=a.length-1,e=t.charCodeAt(n),"0"===a&&56!==e&&57!==e||o(),String.fromCharCode(r)}return u(e)?"":String.fromCharCode(e)}}function l(e){const a=n;let r=0,i=0;for(let a=0;a<e;++a,++n){let e,s=t.charCodeAt(n);if(95!==s){if(s>=97)e=s-97+10;else if(s>=65)e=s-65+10;else {if(!(s>=48&&s<=57))break;e=s-48;}if(e>=16)break;i=s,r=16*r+e;}else 95!==i&&0!==a||o(),i=s;}return 95!==i&&n-a===e||o(),r}function u(e){return 13===e||10===e}function o(){throw Object.assign(Error(`Parse error ${c$1}:${t.slice(0,n).split("\n").length}:${n-t.lastIndexOf("\n",n-1)}`),{idx:n})}
|
|
415
456
|
|
|
416
|
-
async function _resolve
|
|
457
|
+
async function _resolve(id, parentUrl) {
|
|
417
458
|
const urlResolved = resolveIfNotPlainOrUrl(id, parentUrl) || asURL(id);
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
459
|
+
const firstResolved = firstImportMap && resolveImportMap(firstImportMap, urlResolved || id, parentUrl);
|
|
460
|
+
const composedResolved =
|
|
461
|
+
composedImportMap === firstImportMap ? firstResolved : (
|
|
462
|
+
resolveImportMap(composedImportMap, urlResolved || id, parentUrl)
|
|
463
|
+
);
|
|
464
|
+
const resolved = composedResolved || firstResolved || throwUnresolved(id, parentUrl);
|
|
465
|
+
// needsShim, shouldShim per load record to set on parent
|
|
466
|
+
let n = false,
|
|
467
|
+
N = false;
|
|
468
|
+
if (!supportsImportMaps) {
|
|
469
|
+
// bare specifier -> needs shim
|
|
470
|
+
if (!urlResolved) n = true;
|
|
471
|
+
// url mapping -> should shim
|
|
472
|
+
else if (urlResolved !== resolved) N = true;
|
|
473
|
+
} else if (!supportsMultipleImportMaps) {
|
|
474
|
+
// bare specifier and not resolved by first import map -> needs shim
|
|
475
|
+
if (!urlResolved && !firstResolved) n = true;
|
|
476
|
+
// resolution doesn't match first import map -> should shim
|
|
477
|
+
if (firstResolved && resolved !== firstResolved) N = true;
|
|
478
|
+
}
|
|
479
|
+
return { r: resolved, n, N };
|
|
423
480
|
}
|
|
424
481
|
|
|
425
|
-
const resolve =
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
482
|
+
const resolve =
|
|
483
|
+
resolveHook ?
|
|
484
|
+
(id, parentUrl) => {
|
|
485
|
+
const result = resolveHook(id, parentUrl, defaultResolve);
|
|
486
|
+
return result ? { r: result, n: true, N: true } : _resolve(id, parentUrl);
|
|
487
|
+
}
|
|
488
|
+
: _resolve;
|
|
432
489
|
|
|
433
490
|
// supports:
|
|
434
491
|
// import('mod');
|
|
435
492
|
// import('mod', { opts });
|
|
436
493
|
// import('mod', { opts }, parentUrl);
|
|
437
494
|
// import('mod', parentUrl);
|
|
438
|
-
async function importHandler
|
|
495
|
+
async function importHandler(id, ...args) {
|
|
439
496
|
// parentUrl if present will be the last argument
|
|
440
497
|
let parentUrl = args[args.length - 1];
|
|
441
|
-
if (typeof parentUrl !== 'string')
|
|
442
|
-
parentUrl = baseUrl;
|
|
498
|
+
if (typeof parentUrl !== 'string') parentUrl = baseUrl;
|
|
443
499
|
// needed for shim check
|
|
444
500
|
await initPromise;
|
|
445
501
|
if (importHook) await importHook(id, typeof args[1] !== 'string' ? args[1] : {}, parentUrl);
|
|
446
|
-
if (
|
|
447
|
-
if (hasDocument)
|
|
448
|
-
|
|
449
|
-
if (!shimMode)
|
|
450
|
-
acceptingImportMaps = false;
|
|
502
|
+
if (shimMode || !baselinePassthrough) {
|
|
503
|
+
if (hasDocument) processScriptsAndPreloads();
|
|
504
|
+
legacyAcceptingImportMaps = false;
|
|
451
505
|
}
|
|
452
506
|
await importMapPromise;
|
|
453
507
|
return (await resolve(id, parentUrl)).r;
|
|
454
508
|
}
|
|
455
509
|
|
|
456
510
|
// import()
|
|
457
|
-
async function importShim
|
|
511
|
+
async function importShim(...args) {
|
|
512
|
+
console.info(`es-module-shims: importShim("${args[0]}")`);
|
|
458
513
|
return topLevelLoad(await importHandler(...args), { credentials: 'same-origin' });
|
|
459
514
|
}
|
|
460
515
|
|
|
461
516
|
// import.source()
|
|
462
517
|
if (sourcePhaseEnabled)
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
518
|
+
importShim.source = async function importShimSource(...args) {
|
|
519
|
+
const url = await importHandler(...args);
|
|
520
|
+
const load = getOrCreateLoad(url, { credentials: 'same-origin' }, null, null);
|
|
521
|
+
lastLoad = undefined;
|
|
522
|
+
if (firstPolyfillLoad && !shimMode && load.n && nativelyLoaded) {
|
|
523
|
+
onpolyfill();
|
|
524
|
+
firstPolyfillLoad = false;
|
|
525
|
+
}
|
|
526
|
+
await load.f;
|
|
527
|
+
return importShim._s[load.r];
|
|
528
|
+
};
|
|
474
529
|
|
|
475
530
|
self.importShim = importShim;
|
|
476
531
|
|
|
477
|
-
function defaultResolve
|
|
478
|
-
return
|
|
532
|
+
function defaultResolve(id, parentUrl) {
|
|
533
|
+
return (
|
|
534
|
+
resolveImportMap(composedImportMap, resolveIfNotPlainOrUrl(id, parentUrl) || id, parentUrl) ||
|
|
535
|
+
throwUnresolved(id, parentUrl)
|
|
536
|
+
);
|
|
479
537
|
}
|
|
480
538
|
|
|
481
|
-
function throwUnresolved
|
|
539
|
+
function throwUnresolved(id, parentUrl) {
|
|
482
540
|
throw Error(`Unable to resolve specifier '${id}'${fromParent(parentUrl)}`);
|
|
483
541
|
}
|
|
484
542
|
|
|
@@ -488,43 +546,59 @@
|
|
|
488
546
|
return result && !result.then ? result : defaultResolve(id, parentUrl);
|
|
489
547
|
};
|
|
490
548
|
|
|
491
|
-
function metaResolve
|
|
549
|
+
function metaResolve(id, parentUrl = this.url) {
|
|
492
550
|
return resolveSync(id, parentUrl);
|
|
493
551
|
}
|
|
494
552
|
|
|
495
553
|
importShim.resolve = resolveSync;
|
|
496
|
-
importShim.getImportMap = () => JSON.parse(JSON.stringify(
|
|
554
|
+
importShim.getImportMap = () => JSON.parse(JSON.stringify(composedImportMap));
|
|
497
555
|
importShim.addImportMap = importMapIn => {
|
|
498
556
|
if (!shimMode) throw new Error('Unsupported in polyfill mode.');
|
|
499
|
-
|
|
557
|
+
composedImportMap = resolveAndComposeImportMap(importMapIn, baseUrl, composedImportMap);
|
|
500
558
|
};
|
|
501
559
|
|
|
502
|
-
const registry = importShim._r = {};
|
|
503
|
-
const sourceCache = importShim._s = {};
|
|
560
|
+
const registry = (importShim._r = {});
|
|
561
|
+
const sourceCache = (importShim._s = {});
|
|
504
562
|
|
|
505
|
-
async function loadAll
|
|
563
|
+
async function loadAll(load, seen) {
|
|
506
564
|
seen[load.u] = 1;
|
|
507
565
|
await load.L;
|
|
508
|
-
await Promise.all(
|
|
509
|
-
|
|
510
|
-
return;
|
|
511
|
-
|
|
512
|
-
return dep
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
if (!load.n)
|
|
516
|
-
load.n = load.d.some(dep => dep.l.n);
|
|
566
|
+
await Promise.all(
|
|
567
|
+
load.d.map(({ l: dep, s: sourcePhase }) => {
|
|
568
|
+
if (dep.b || seen[dep.u]) return;
|
|
569
|
+
if (sourcePhase) return dep.f;
|
|
570
|
+
return loadAll(dep, seen);
|
|
571
|
+
})
|
|
572
|
+
);
|
|
573
|
+
if (!load.n) load.n = load.d.some(dep => dep.l.n);
|
|
517
574
|
}
|
|
518
575
|
|
|
519
|
-
let
|
|
576
|
+
let importMapSrc = false;
|
|
577
|
+
let multipleImportMaps = false;
|
|
578
|
+
let firstImportMap = null;
|
|
579
|
+
// To support polyfilling multiple import maps, we separately track the composed import map from the first import map
|
|
580
|
+
let composedImportMap = { imports: {}, scopes: {}, integrity: {} };
|
|
520
581
|
let baselinePassthrough;
|
|
521
582
|
|
|
522
583
|
const initPromise = featureDetectionPromise.then(() => {
|
|
523
|
-
baselinePassthrough =
|
|
524
|
-
|
|
584
|
+
baselinePassthrough =
|
|
585
|
+
esmsInitOptions.polyfillEnable !== true &&
|
|
586
|
+
supportsDynamicImport &&
|
|
587
|
+
supportsImportMeta &&
|
|
588
|
+
supportsImportMaps &&
|
|
589
|
+
(!jsonModulesEnabled || supportsJsonType) &&
|
|
590
|
+
(!cssModulesEnabled || supportsCssType) &&
|
|
591
|
+
(!wasmModulesEnabled || supportsWasmModules) &&
|
|
592
|
+
(!sourcePhaseEnabled || supportsSourcePhase) &&
|
|
593
|
+
(!multipleImportMaps || supportsMultipleImportMaps) &&
|
|
594
|
+
!importMapSrc;
|
|
595
|
+
console.info(
|
|
596
|
+
`es-module-shims: init ${shimMode ? 'shim mode' : 'polyfill mode'}, ${baselinePassthrough ? 'baseline passthrough' : 'polyfill engaged'}`
|
|
597
|
+
);
|
|
525
598
|
if (sourcePhaseEnabled && typeof WebAssembly !== 'undefined' && !Object.getPrototypeOf(WebAssembly.Module).name) {
|
|
526
599
|
const s = Symbol();
|
|
527
|
-
const brand = m =>
|
|
600
|
+
const brand = m =>
|
|
601
|
+
Object.defineProperty(m, s, { writable: false, configurable: false, value: 'WebAssembly.Module' });
|
|
528
602
|
class AbstractModuleSource {
|
|
529
603
|
get [Symbol.toStringTag]() {
|
|
530
604
|
if (this[s]) return this[s];
|
|
@@ -532,11 +606,14 @@
|
|
|
532
606
|
}
|
|
533
607
|
}
|
|
534
608
|
const { Module: wasmModule, compile: wasmCompile, compileStreaming: wasmCompileStreaming } = WebAssembly;
|
|
535
|
-
WebAssembly.Module = Object.setPrototypeOf(
|
|
536
|
-
|
|
537
|
-
|
|
609
|
+
WebAssembly.Module = Object.setPrototypeOf(
|
|
610
|
+
Object.assign(function Module(...args) {
|
|
611
|
+
return brand(new wasmModule(...args));
|
|
612
|
+
}, wasmModule),
|
|
613
|
+
AbstractModuleSource
|
|
614
|
+
);
|
|
538
615
|
WebAssembly.Module.prototype = Object.setPrototypeOf(wasmModule.prototype, AbstractModuleSource.prototype);
|
|
539
|
-
WebAssembly.compile = function compile
|
|
616
|
+
WebAssembly.compile = function compile(...args) {
|
|
540
617
|
return wasmCompile(...args).then(brand);
|
|
541
618
|
};
|
|
542
619
|
WebAssembly.compileStreaming = function compileStreaming(...args) {
|
|
@@ -549,27 +626,10 @@
|
|
|
549
626
|
HTMLScriptElement.supports = type => type === 'importmap' || supports(type);
|
|
550
627
|
}
|
|
551
628
|
if (shimMode || !baselinePassthrough) {
|
|
552
|
-
|
|
553
|
-
for (const mutation of mutations) {
|
|
554
|
-
if (mutation.type !== 'childList') continue;
|
|
555
|
-
for (const node of mutation.addedNodes) {
|
|
556
|
-
if (node.tagName === 'SCRIPT') {
|
|
557
|
-
if (node.type === (shimMode ? 'module-shim' : 'module'))
|
|
558
|
-
processScript(node, true);
|
|
559
|
-
if (node.type === (shimMode ? 'importmap-shim' : 'importmap'))
|
|
560
|
-
processImportMap(node, true);
|
|
561
|
-
}
|
|
562
|
-
else if (node.tagName === 'LINK' && node.rel === (shimMode ? 'modulepreload-shim' : 'modulepreload')) {
|
|
563
|
-
processPreload(node);
|
|
564
|
-
}
|
|
565
|
-
}
|
|
566
|
-
}
|
|
567
|
-
}).observe(document, {childList: true, subtree: true});
|
|
568
|
-
processScriptsAndPreloads();
|
|
629
|
+
attachMutationObserver();
|
|
569
630
|
if (document.readyState === 'complete') {
|
|
570
631
|
readyStateCompleteCheck();
|
|
571
|
-
}
|
|
572
|
-
else {
|
|
632
|
+
} else {
|
|
573
633
|
async function readyListener() {
|
|
574
634
|
await initPromise;
|
|
575
635
|
processScriptsAndPreloads();
|
|
@@ -582,26 +642,49 @@
|
|
|
582
642
|
}
|
|
583
643
|
}
|
|
584
644
|
}
|
|
645
|
+
processScriptsAndPreloads();
|
|
585
646
|
return undefined;
|
|
586
647
|
});
|
|
648
|
+
|
|
649
|
+
function attachMutationObserver() {
|
|
650
|
+
new MutationObserver(mutations => {
|
|
651
|
+
for (const mutation of mutations) {
|
|
652
|
+
if (mutation.type !== 'childList') continue;
|
|
653
|
+
for (const node of mutation.addedNodes) {
|
|
654
|
+
if (node.tagName === 'SCRIPT') {
|
|
655
|
+
if (node.type === (shimMode ? 'module-shim' : 'module') && !node.ep) processScript(node, true);
|
|
656
|
+
if (node.type === (shimMode ? 'importmap-shim' : 'importmap') && !node.ep) processImportMap(node, true);
|
|
657
|
+
} else if (
|
|
658
|
+
node.tagName === 'LINK' &&
|
|
659
|
+
node.rel === (shimMode ? 'modulepreload-shim' : 'modulepreload') &&
|
|
660
|
+
!node.ep
|
|
661
|
+
) {
|
|
662
|
+
processPreload(node);
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
}).observe(document, { childList: true, subtree: true });
|
|
667
|
+
processScriptsAndPreloads();
|
|
668
|
+
}
|
|
669
|
+
|
|
587
670
|
let importMapPromise = initPromise;
|
|
588
671
|
let firstPolyfillLoad = true;
|
|
589
|
-
let
|
|
672
|
+
let legacyAcceptingImportMaps = true;
|
|
590
673
|
|
|
591
|
-
async function topLevelLoad
|
|
592
|
-
|
|
593
|
-
acceptingImportMaps = false;
|
|
674
|
+
async function topLevelLoad(url, fetchOpts, source, nativelyLoaded, lastStaticLoadPromise) {
|
|
675
|
+
legacyAcceptingImportMaps = false;
|
|
594
676
|
await initPromise;
|
|
595
677
|
await importMapPromise;
|
|
596
678
|
if (importHook) await importHook(url, typeof fetchOpts !== 'string' ? fetchOpts : {}, '');
|
|
597
679
|
// early analysis opt-out - no need to even fetch if we have feature support
|
|
598
680
|
if (!shimMode && baselinePassthrough) {
|
|
599
|
-
console.info(`es-module-shims: load
|
|
681
|
+
console.info(`es-module-shims: early load exit as we have baseline modules support ${url}`);
|
|
600
682
|
// for polyfill case, only dynamic import needs a return value here, and dynamic import will never pass nativelyLoaded
|
|
601
|
-
if (nativelyLoaded)
|
|
602
|
-
return null;
|
|
683
|
+
if (nativelyLoaded) return null;
|
|
603
684
|
await lastStaticLoadPromise;
|
|
604
|
-
return dynamicImport(source ? createBlob(source) : url, {
|
|
685
|
+
return dynamicImport(source ? createBlob(source) : url, {
|
|
686
|
+
errUrl: url || source
|
|
687
|
+
});
|
|
605
688
|
}
|
|
606
689
|
const load = getOrCreateLoad(url, fetchOpts, null, source);
|
|
607
690
|
linkLoad(load, fetchOpts);
|
|
@@ -621,8 +704,7 @@
|
|
|
621
704
|
}
|
|
622
705
|
const module = await dynamicImport(!shimMode && !load.n && nativelyLoaded ? load.u : load.b, { errUrl: load.u });
|
|
623
706
|
// if the top-level load is a shell, run its update function
|
|
624
|
-
if (load.s)
|
|
625
|
-
(await dynamicImport(load.s)).u$_(module);
|
|
707
|
+
if (load.s) (await dynamicImport(load.s)).u$_(module);
|
|
626
708
|
if (revokeBlobURLs) revokeObjectURLs(Object.keys(seen));
|
|
627
709
|
// when tla is supported, this should return the tla promise as an actual handle
|
|
628
710
|
// so readystate can still correspond to the sync subgraph exec completions
|
|
@@ -636,7 +718,7 @@
|
|
|
636
718
|
schedule(cleanup);
|
|
637
719
|
function cleanup() {
|
|
638
720
|
const batchStartIndex = batch * 100;
|
|
639
|
-
if (batchStartIndex > keysLength) return
|
|
721
|
+
if (batchStartIndex > keysLength) return;
|
|
640
722
|
for (const key of registryKeys.slice(batchStartIndex, batchStartIndex + 100)) {
|
|
641
723
|
const load = registry[key];
|
|
642
724
|
if (load) URL.revokeObjectURL(load.b);
|
|
@@ -646,21 +728,29 @@
|
|
|
646
728
|
}
|
|
647
729
|
}
|
|
648
730
|
|
|
649
|
-
function urlJsString
|
|
731
|
+
function urlJsString(url) {
|
|
650
732
|
return `'${url.replace(/'/g, "\\'")}'`;
|
|
651
733
|
}
|
|
652
734
|
|
|
653
735
|
let lastLoad;
|
|
654
|
-
function resolveDeps
|
|
655
|
-
if (load.b || !seen[load.u])
|
|
656
|
-
return;
|
|
736
|
+
function resolveDeps(load, seen) {
|
|
737
|
+
if (load.b || !seen[load.u]) return;
|
|
657
738
|
seen[load.u] = 0;
|
|
658
739
|
|
|
659
740
|
for (const { l: dep, s: sourcePhase } of load.d) {
|
|
660
|
-
if (!sourcePhase)
|
|
661
|
-
|
|
741
|
+
if (!sourcePhase) resolveDeps(dep, seen);
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
// use native loader whenever possible (n = needs shim) via executable subgraph passthrough
|
|
745
|
+
// so long as the module doesn't use dynamic import or unsupported URL mappings (N = should shim)
|
|
746
|
+
if (!shimMode && !load.n && !load.N) {
|
|
747
|
+
load.b = lastLoad = load.u;
|
|
748
|
+
load.S = undefined;
|
|
749
|
+
return;
|
|
662
750
|
}
|
|
663
751
|
|
|
752
|
+
console.info(`es-module-shims: polyfilling ${load.u}`);
|
|
753
|
+
|
|
664
754
|
const [imports, exports] = load.a;
|
|
665
755
|
|
|
666
756
|
// "execution"
|
|
@@ -671,8 +761,10 @@
|
|
|
671
761
|
|
|
672
762
|
// once all deps have loaded we can inline the dependency resolution blobs
|
|
673
763
|
// and define this blob
|
|
674
|
-
let lastIndex = 0,
|
|
675
|
-
|
|
764
|
+
let lastIndex = 0,
|
|
765
|
+
depIndex = 0,
|
|
766
|
+
dynamicImportEndStack = [];
|
|
767
|
+
function pushStringTo(originalIndex) {
|
|
676
768
|
while (dynamicImportEndStack[dynamicImportEndStack.length - 1] < originalIndex) {
|
|
677
769
|
const dynamicImportEnd = dynamicImportEndStack.pop();
|
|
678
770
|
resolvedSource += `${source.slice(lastIndex, dynamicImportEnd)}, ${urlJsString(load.r)}`;
|
|
@@ -695,20 +787,24 @@
|
|
|
695
787
|
}
|
|
696
788
|
// dependency source replacements
|
|
697
789
|
else if (dynamicImportIndex === -1) {
|
|
698
|
-
let { l: depLoad } = load.d[depIndex++],
|
|
790
|
+
let { l: depLoad } = load.d[depIndex++],
|
|
791
|
+
blobUrl = depLoad.b,
|
|
792
|
+
cycleShell = !blobUrl;
|
|
699
793
|
if (cycleShell) {
|
|
700
794
|
// circular shell creation
|
|
701
795
|
if (!(blobUrl = depLoad.s)) {
|
|
702
|
-
blobUrl = depLoad.s = createBlob(
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
796
|
+
blobUrl = depLoad.s = createBlob(
|
|
797
|
+
`export function u$_(m){${depLoad.a[1]
|
|
798
|
+
.map(({ s, e }, i) => {
|
|
799
|
+
const q = depLoad.S[s] === '"' || depLoad.S[s] === "'";
|
|
800
|
+
return `e$_${i}=m${q ? `[` : '.'}${depLoad.S.slice(s, e)}${q ? `]` : ''}`;
|
|
801
|
+
})
|
|
802
|
+
.join(',')}}${
|
|
803
|
+
depLoad.a[1].length ? `let ${depLoad.a[1].map((_, i) => `e$_${i}`).join(',')};` : ''
|
|
804
|
+
}export {${depLoad.a[1]
|
|
805
|
+
.map(({ s, e }, i) => `e$_${i} as ${depLoad.S.slice(s, e)}`)
|
|
806
|
+
.join(',')}}\n//# sourceURL=${depLoad.r}?cycle`
|
|
807
|
+
);
|
|
712
808
|
}
|
|
713
809
|
}
|
|
714
810
|
|
|
@@ -741,14 +837,21 @@
|
|
|
741
837
|
|
|
742
838
|
// support progressive cycle binding updates (try statement avoids tdz errors)
|
|
743
839
|
if (load.s && (imports.length === 0 || imports[imports.length - 1].d === -1))
|
|
744
|
-
resolvedSource += `\n;import{u$_}from'${load.s}';try{u$_({${exports
|
|
840
|
+
resolvedSource += `\n;import{u$_}from'${load.s}';try{u$_({${exports
|
|
841
|
+
.filter(e => e.ln)
|
|
842
|
+
.map(({ s, e, ln }) => `${source.slice(s, e)}:${ln}`)
|
|
843
|
+
.join(',')}})}catch(_){};\n`;
|
|
745
844
|
|
|
746
|
-
function pushSourceURL
|
|
845
|
+
function pushSourceURL(commentPrefix, commentStart) {
|
|
747
846
|
const urlStart = commentStart + commentPrefix.length;
|
|
748
847
|
const commentEnd = source.indexOf('\n', urlStart);
|
|
749
848
|
const urlEnd = commentEnd !== -1 ? commentEnd : source.length;
|
|
849
|
+
let sourceUrl = source.slice(urlStart, urlEnd);
|
|
850
|
+
try {
|
|
851
|
+
sourceUrl = new URL(sourceUrl, load.r).href;
|
|
852
|
+
} catch {}
|
|
750
853
|
pushStringTo(urlStart);
|
|
751
|
-
resolvedSource +=
|
|
854
|
+
resolvedSource += sourceUrl;
|
|
752
855
|
lastIndex = urlEnd;
|
|
753
856
|
}
|
|
754
857
|
|
|
@@ -760,21 +863,23 @@
|
|
|
760
863
|
if (sourceMapURLCommentStart < lastIndex) sourceMapURLCommentStart = -1;
|
|
761
864
|
|
|
762
865
|
// sourceURL first / only
|
|
763
|
-
if (
|
|
866
|
+
if (
|
|
867
|
+
sourceURLCommentStart !== -1 &&
|
|
868
|
+
(sourceMapURLCommentStart === -1 || sourceMapURLCommentStart > sourceURLCommentStart)
|
|
869
|
+
) {
|
|
764
870
|
pushSourceURL(sourceURLCommentPrefix, sourceURLCommentStart);
|
|
765
871
|
}
|
|
766
872
|
// sourceMappingURL
|
|
767
873
|
if (sourceMapURLCommentStart !== -1) {
|
|
768
874
|
pushSourceURL(sourceMapURLCommentPrefix, sourceMapURLCommentStart);
|
|
769
875
|
// sourceURL last
|
|
770
|
-
if (sourceURLCommentStart !== -1 &&
|
|
876
|
+
if (sourceURLCommentStart !== -1 && sourceURLCommentStart > sourceMapURLCommentStart)
|
|
771
877
|
pushSourceURL(sourceURLCommentPrefix, sourceURLCommentStart);
|
|
772
878
|
}
|
|
773
879
|
|
|
774
880
|
pushStringTo(source.length);
|
|
775
881
|
|
|
776
|
-
if (sourceURLCommentStart === -1)
|
|
777
|
-
resolvedSource += sourceURLCommentPrefix + load.r;
|
|
882
|
+
if (sourceURLCommentStart === -1) resolvedSource += sourceURLCommentPrefix + load.r;
|
|
778
883
|
|
|
779
884
|
load.b = lastLoad = createBlob(resolvedSource);
|
|
780
885
|
load.S = undefined;
|
|
@@ -793,29 +898,24 @@
|
|
|
793
898
|
// restrict in-flight fetches to a pool of 100
|
|
794
899
|
let p = [];
|
|
795
900
|
let c = 0;
|
|
796
|
-
function pushFetchPool
|
|
797
|
-
if (++c > 100)
|
|
798
|
-
return new Promise(r => p.push(r));
|
|
901
|
+
function pushFetchPool() {
|
|
902
|
+
if (++c > 100) return new Promise(r => p.push(r));
|
|
799
903
|
}
|
|
800
|
-
function popFetchPool
|
|
904
|
+
function popFetchPool() {
|
|
801
905
|
c--;
|
|
802
|
-
if (p.length)
|
|
803
|
-
p.shift()();
|
|
906
|
+
if (p.length) p.shift()();
|
|
804
907
|
}
|
|
805
908
|
|
|
806
|
-
async function doFetch
|
|
807
|
-
if (enforceIntegrity && !fetchOpts.integrity)
|
|
808
|
-
throw Error(`No integrity for ${url}${fromParent(parent)}.`);
|
|
909
|
+
async function doFetch(url, fetchOpts, parent) {
|
|
910
|
+
if (enforceIntegrity && !fetchOpts.integrity) throw Error(`No integrity for ${url}${fromParent(parent)}.`);
|
|
809
911
|
const poolQueue = pushFetchPool();
|
|
810
912
|
if (poolQueue) await poolQueue;
|
|
811
913
|
try {
|
|
812
914
|
var res = await fetchHook(url, fetchOpts);
|
|
813
|
-
}
|
|
814
|
-
catch (e) {
|
|
915
|
+
} catch (e) {
|
|
815
916
|
e.message = `Unable to fetch ${url}${fromParent(parent)} - see network log for details.\n` + e.message;
|
|
816
917
|
throw e;
|
|
817
|
-
}
|
|
818
|
-
finally {
|
|
918
|
+
} finally {
|
|
819
919
|
popFetchPool();
|
|
820
920
|
}
|
|
821
921
|
|
|
@@ -827,17 +927,22 @@
|
|
|
827
927
|
return res;
|
|
828
928
|
}
|
|
829
929
|
|
|
830
|
-
async function fetchModule
|
|
831
|
-
const mapIntegrity =
|
|
832
|
-
const res = await doFetch(
|
|
930
|
+
async function fetchModule(url, fetchOpts, parent) {
|
|
931
|
+
const mapIntegrity = composedImportMap.integrity[url];
|
|
932
|
+
const res = await doFetch(
|
|
933
|
+
url,
|
|
934
|
+
mapIntegrity && !fetchOpts.integrity ? Object.assign({}, fetchOpts, { integrity: mapIntegrity }) : fetchOpts,
|
|
935
|
+
parent
|
|
936
|
+
);
|
|
833
937
|
const r = res.url;
|
|
834
938
|
const contentType = res.headers.get('content-type');
|
|
835
|
-
if (jsContentType.test(contentType))
|
|
836
|
-
return { r, s: await res.text(), sp: null, t: 'js' };
|
|
939
|
+
if (jsContentType.test(contentType)) return { r, s: await res.text(), sp: null, t: 'js' };
|
|
837
940
|
else if (wasmContentType.test(contentType)) {
|
|
838
941
|
const module = await (sourceCache[r] || (sourceCache[r] = WebAssembly.compileStreaming(res)));
|
|
839
942
|
sourceCache[r] = module;
|
|
840
|
-
let s = '',
|
|
943
|
+
let s = '',
|
|
944
|
+
i = 0,
|
|
945
|
+
importObj = '';
|
|
841
946
|
for (const impt of WebAssembly.Module.imports(module)) {
|
|
842
947
|
const specifier = urlJsString(impt.module);
|
|
843
948
|
s += `import * as impt${i} from ${specifier};\n`;
|
|
@@ -849,19 +954,27 @@
|
|
|
849
954
|
s += `export const ${expt.name} = instance.exports['${expt.name}'];\n`;
|
|
850
955
|
}
|
|
851
956
|
return { r, s, t: 'wasm' };
|
|
852
|
-
}
|
|
853
|
-
else if (jsonContentType.test(contentType))
|
|
957
|
+
} else if (jsonContentType.test(contentType))
|
|
854
958
|
return { r, s: `export default ${await res.text()}`, sp: null, t: 'json' };
|
|
855
959
|
else if (cssContentType.test(contentType)) {
|
|
856
|
-
return {
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
960
|
+
return {
|
|
961
|
+
r,
|
|
962
|
+
s: `var s=new CSSStyleSheet();s.replaceSync(${JSON.stringify(
|
|
963
|
+
(await res.text()).replace(
|
|
964
|
+
cssUrlRegEx,
|
|
965
|
+
(_match, quotes = '', relUrl1, relUrl2) => `url(${quotes}${resolveUrl(relUrl1 || relUrl2, url)}${quotes})`
|
|
966
|
+
)
|
|
967
|
+
)});export default s;`,
|
|
968
|
+
ss: null,
|
|
969
|
+
t: 'css'
|
|
970
|
+
};
|
|
971
|
+
} else
|
|
972
|
+
throw Error(
|
|
973
|
+
`Unsupported Content-Type "${contentType}" loading ${url}${fromParent(parent)}. Modules must be served with a valid MIME type like application/javascript.`
|
|
974
|
+
);
|
|
862
975
|
}
|
|
863
976
|
|
|
864
|
-
function getOrCreateLoad
|
|
977
|
+
function getOrCreateLoad(url, fetchOpts, parent, source) {
|
|
865
978
|
if (source && registry[url]) {
|
|
866
979
|
let i = 0;
|
|
867
980
|
while (registry[url + ++i]);
|
|
@@ -890,6 +1003,8 @@
|
|
|
890
1003
|
s: undefined,
|
|
891
1004
|
// needsShim
|
|
892
1005
|
n: false,
|
|
1006
|
+
// shouldShim
|
|
1007
|
+
N: false,
|
|
893
1008
|
// type
|
|
894
1009
|
t: null,
|
|
895
1010
|
// meta
|
|
@@ -901,16 +1016,23 @@
|
|
|
901
1016
|
let t;
|
|
902
1017
|
({ r: load.r, s: load.S, t } = await (fetchCache[url] || fetchModule(url, fetchOpts, parent)));
|
|
903
1018
|
if (t && !shimMode) {
|
|
904
|
-
if (
|
|
1019
|
+
if (
|
|
1020
|
+
(t === 'css' && !cssModulesEnabled) ||
|
|
1021
|
+
(t === 'json' && !jsonModulesEnabled) ||
|
|
1022
|
+
(t === 'wasm' && !wasmModulesEnabled)
|
|
1023
|
+
)
|
|
905
1024
|
throw featErr(`${t}-modules`);
|
|
906
|
-
if (
|
|
1025
|
+
if (
|
|
1026
|
+
(t === 'css' && !supportsCssType) ||
|
|
1027
|
+
(t === 'json' && !supportsJsonType) ||
|
|
1028
|
+
(t === 'wasm' && !supportsWasmModules)
|
|
1029
|
+
)
|
|
907
1030
|
load.n = true;
|
|
908
1031
|
}
|
|
909
1032
|
}
|
|
910
1033
|
try {
|
|
911
1034
|
load.a = parse(load.S, load.u);
|
|
912
|
-
}
|
|
913
|
-
catch (e) {
|
|
1035
|
+
} catch (e) {
|
|
914
1036
|
throwError(e);
|
|
915
1037
|
load.a = [[], [], false];
|
|
916
1038
|
}
|
|
@@ -919,76 +1041,81 @@
|
|
|
919
1041
|
return load;
|
|
920
1042
|
}
|
|
921
1043
|
|
|
922
|
-
const featErr = feat =>
|
|
1044
|
+
const featErr = feat =>
|
|
1045
|
+
Error(
|
|
1046
|
+
`${feat} feature must be enabled via <script type="esms-options">{ "polyfillEnable": ["${feat}"] }<${''}/script>`
|
|
1047
|
+
);
|
|
923
1048
|
|
|
924
|
-
function linkLoad
|
|
1049
|
+
function linkLoad(load, fetchOpts) {
|
|
925
1050
|
if (load.L) return;
|
|
926
1051
|
load.L = load.f.then(async () => {
|
|
927
1052
|
let childFetchOpts = fetchOpts;
|
|
928
|
-
load.d = (
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
1053
|
+
load.d = (
|
|
1054
|
+
await Promise.all(
|
|
1055
|
+
load.a[0].map(async ({ n, d, t }) => {
|
|
1056
|
+
const sourcePhase = t >= 4;
|
|
1057
|
+
if (sourcePhase && !sourcePhaseEnabled) throw featErr('source-phase');
|
|
1058
|
+
if (
|
|
1059
|
+
(d >= 0 && !supportsDynamicImport) ||
|
|
1060
|
+
(d === -2 && !supportsImportMeta) ||
|
|
1061
|
+
(sourcePhase && !supportsSourcePhase)
|
|
1062
|
+
)
|
|
1063
|
+
load.n = true;
|
|
1064
|
+
if (d !== -1 || !n) return;
|
|
1065
|
+
const resolved = await resolve(n, load.r || load.u);
|
|
1066
|
+
if (resolved.n) load.n = true;
|
|
1067
|
+
if (d >= 0 || resolved.N) load.N = true;
|
|
1068
|
+
if (d !== -1) return;
|
|
1069
|
+
if (skip && skip(resolved.r) && !sourcePhase) return { l: { b: resolved.r }, s: false };
|
|
1070
|
+
if (childFetchOpts.integrity) childFetchOpts = Object.assign({}, childFetchOpts, { integrity: undefined });
|
|
1071
|
+
const child = { l: getOrCreateLoad(resolved.r, childFetchOpts, load.r, null), s: sourcePhase };
|
|
1072
|
+
if (!child.s) linkLoad(child.l, fetchOpts);
|
|
1073
|
+
// load, sourcePhase
|
|
1074
|
+
return child;
|
|
1075
|
+
})
|
|
1076
|
+
)
|
|
1077
|
+
).filter(l => l);
|
|
948
1078
|
});
|
|
949
1079
|
}
|
|
950
1080
|
|
|
951
|
-
function processScriptsAndPreloads
|
|
1081
|
+
function processScriptsAndPreloads() {
|
|
952
1082
|
console.info(`es-module-shims: processing scripts`);
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
for (const script of document.querySelectorAll(
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
1083
|
+
for (const link of document.querySelectorAll(shimMode ? 'link[rel=modulepreload-shim]' : 'link[rel=modulepreload]')) {
|
|
1084
|
+
if (!link.ep) processPreload(link);
|
|
1085
|
+
}
|
|
1086
|
+
for (const script of document.querySelectorAll('script[type]')) {
|
|
1087
|
+
if (script.type === 'importmap' + (shimMode ? '-shim' : '')) {
|
|
1088
|
+
if (!script.ep) processImportMap(script);
|
|
1089
|
+
} else if (script.type === 'module' + (shimMode ? '-shim' : '')) {
|
|
1090
|
+
legacyAcceptingImportMaps = false;
|
|
1091
|
+
if (!script.ep) processScript(script);
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
961
1094
|
}
|
|
962
1095
|
|
|
963
|
-
function getFetchOpts
|
|
1096
|
+
function getFetchOpts(script) {
|
|
964
1097
|
const fetchOpts = {};
|
|
965
|
-
if (script.integrity)
|
|
966
|
-
|
|
967
|
-
if (script.
|
|
968
|
-
|
|
969
|
-
if (script.
|
|
970
|
-
|
|
971
|
-
if (script.crossOrigin === 'use-credentials')
|
|
972
|
-
fetchOpts.credentials = 'include';
|
|
973
|
-
else if (script.crossOrigin === 'anonymous')
|
|
974
|
-
fetchOpts.credentials = 'omit';
|
|
975
|
-
else
|
|
976
|
-
fetchOpts.credentials = 'same-origin';
|
|
1098
|
+
if (script.integrity) fetchOpts.integrity = script.integrity;
|
|
1099
|
+
if (script.referrerPolicy) fetchOpts.referrerPolicy = script.referrerPolicy;
|
|
1100
|
+
if (script.fetchPriority) fetchOpts.priority = script.fetchPriority;
|
|
1101
|
+
if (script.crossOrigin === 'use-credentials') fetchOpts.credentials = 'include';
|
|
1102
|
+
else if (script.crossOrigin === 'anonymous') fetchOpts.credentials = 'omit';
|
|
1103
|
+
else fetchOpts.credentials = 'same-origin';
|
|
977
1104
|
return fetchOpts;
|
|
978
1105
|
}
|
|
979
1106
|
|
|
980
1107
|
let lastStaticLoadPromise = Promise.resolve();
|
|
981
1108
|
|
|
982
1109
|
let domContentLoadedCnt = 1;
|
|
983
|
-
function domContentLoadedCheck
|
|
1110
|
+
function domContentLoadedCheck() {
|
|
984
1111
|
if (--domContentLoadedCnt === 0 && !noLoadEventRetriggers && (shimMode || !baselinePassthrough)) {
|
|
985
1112
|
console.info(`es-module-shims: DOMContentLoaded refire`);
|
|
986
1113
|
document.dispatchEvent(new Event('DOMContentLoaded'));
|
|
987
1114
|
}
|
|
988
1115
|
}
|
|
989
1116
|
let loadCnt = 1;
|
|
990
|
-
function loadCheck
|
|
991
|
-
if (--loadCnt === 0 &&
|
|
1117
|
+
function loadCheck() {
|
|
1118
|
+
if (--loadCnt === 0 && !noLoadEventRetriggers && (shimMode || !baselinePassthrough)) {
|
|
992
1119
|
console.info(`es-module-shims: load refire`);
|
|
993
1120
|
window.dispatchEvent(new Event('load'));
|
|
994
1121
|
}
|
|
@@ -1006,41 +1133,54 @@
|
|
|
1006
1133
|
}
|
|
1007
1134
|
|
|
1008
1135
|
let readyStateCompleteCnt = 1;
|
|
1009
|
-
function readyStateCompleteCheck
|
|
1136
|
+
function readyStateCompleteCheck() {
|
|
1010
1137
|
if (--readyStateCompleteCnt === 0 && !noLoadEventRetriggers && (shimMode || !baselinePassthrough)) {
|
|
1011
1138
|
console.info(`es-module-shims: readystatechange complete refire`);
|
|
1012
1139
|
document.dispatchEvent(new Event('readystatechange'));
|
|
1013
1140
|
}
|
|
1014
1141
|
}
|
|
1015
1142
|
|
|
1016
|
-
const hasNext = script => script.nextSibling || script.parentNode && hasNext(script.parentNode);
|
|
1017
|
-
const epCheck = (script, ready) =>
|
|
1143
|
+
const hasNext = script => script.nextSibling || (script.parentNode && hasNext(script.parentNode));
|
|
1144
|
+
const epCheck = (script, ready) =>
|
|
1145
|
+
script.ep ||
|
|
1146
|
+
(!ready && ((!script.src && !script.innerHTML) || !hasNext(script))) ||
|
|
1147
|
+
script.getAttribute('noshim') !== null ||
|
|
1148
|
+
!(script.ep = true);
|
|
1018
1149
|
|
|
1019
|
-
function processImportMap
|
|
1150
|
+
function processImportMap(script, ready = readyStateCompleteCnt > 0) {
|
|
1020
1151
|
if (epCheck(script, ready)) return;
|
|
1021
|
-
// we dont currently support
|
|
1152
|
+
// we dont currently support external import maps in polyfill mode to match native
|
|
1022
1153
|
if (script.src) {
|
|
1023
|
-
if (!shimMode)
|
|
1024
|
-
|
|
1025
|
-
setImportMapSrcOrLazy();
|
|
1154
|
+
if (!shimMode) return;
|
|
1155
|
+
importMapSrc = true;
|
|
1026
1156
|
}
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1157
|
+
importMapPromise = importMapPromise
|
|
1158
|
+
.then(async () => {
|
|
1159
|
+
composedImportMap = resolveAndComposeImportMap(
|
|
1160
|
+
script.src ? await (await doFetch(script.src, getFetchOpts(script))).json() : JSON.parse(script.innerHTML),
|
|
1161
|
+
script.src || baseUrl,
|
|
1162
|
+
composedImportMap
|
|
1163
|
+
);
|
|
1164
|
+
})
|
|
1165
|
+
.catch(e => {
|
|
1166
|
+
console.log(e);
|
|
1167
|
+
if (e instanceof SyntaxError)
|
|
1168
|
+
e = new Error(`Unable to parse import map ${e.message} in: ${script.src || script.innerHTML}`);
|
|
1169
|
+
throwError(e);
|
|
1170
|
+
});
|
|
1171
|
+
if (!firstImportMap && legacyAcceptingImportMaps) importMapPromise.then(() => (firstImportMap = composedImportMap));
|
|
1172
|
+
if (!legacyAcceptingImportMaps && !multipleImportMaps) {
|
|
1173
|
+
multipleImportMaps = true;
|
|
1174
|
+
if (baselinePassthrough && !supportsMultipleImportMaps) {
|
|
1175
|
+
console.info(`es-module-shims: disabling baseline passthrough due to multiple import maps`);
|
|
1176
|
+
baselinePassthrough = false;
|
|
1177
|
+
if (hasDocument) attachMutationObserver();
|
|
1178
|
+
}
|
|
1040
1179
|
}
|
|
1180
|
+
legacyAcceptingImportMaps = false;
|
|
1041
1181
|
}
|
|
1042
1182
|
|
|
1043
|
-
function processScript
|
|
1183
|
+
function processScript(script, ready = readyStateCompleteCnt > 0) {
|
|
1044
1184
|
if (epCheck(script, ready)) return;
|
|
1045
1185
|
// does this load block readystate complete
|
|
1046
1186
|
const isBlockingReadyScript = script.getAttribute('async') === null && readyStateCompleteCnt > 0;
|
|
@@ -1050,25 +1190,24 @@
|
|
|
1050
1190
|
if (isLoadScript) loadCnt++;
|
|
1051
1191
|
if (isBlockingReadyScript) readyStateCompleteCnt++;
|
|
1052
1192
|
if (isDomContentLoadedScript) domContentLoadedCnt++;
|
|
1053
|
-
console.info(`es-module-shims:
|
|
1054
|
-
const loadPromise = topLevelLoad(
|
|
1055
|
-
.
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
if (
|
|
1063
|
-
|
|
1193
|
+
console.info(`es-module-shims: loading ${script.src || '<inline>'}`);
|
|
1194
|
+
const loadPromise = topLevelLoad(
|
|
1195
|
+
script.src || baseUrl,
|
|
1196
|
+
getFetchOpts(script),
|
|
1197
|
+
!script.src && script.innerHTML,
|
|
1198
|
+
!shimMode,
|
|
1199
|
+
isBlockingReadyScript && lastStaticLoadPromise
|
|
1200
|
+
).catch(throwError);
|
|
1201
|
+
if (!noLoadEventRetriggers) loadPromise.then(() => script.dispatchEvent(new Event('load')));
|
|
1202
|
+
if (isBlockingReadyScript) lastStaticLoadPromise = loadPromise.then(readyStateCompleteCheck);
|
|
1203
|
+
if (isDomContentLoadedScript) loadPromise.then(domContentLoadedCheck);
|
|
1204
|
+
if (isLoadScript) loadPromise.then(loadCheck);
|
|
1064
1205
|
}
|
|
1065
1206
|
|
|
1066
1207
|
const fetchCache = {};
|
|
1067
|
-
function processPreload
|
|
1068
|
-
if (link.ep) return;
|
|
1208
|
+
function processPreload(link) {
|
|
1069
1209
|
link.ep = true;
|
|
1070
|
-
if (fetchCache[link.href])
|
|
1071
|
-
return;
|
|
1210
|
+
if (fetchCache[link.href]) return;
|
|
1072
1211
|
fetchCache[link.href] = fetchModule(link.href, getFetchOpts(link));
|
|
1073
1212
|
}
|
|
1074
1213
|
|