es-module-shims 2.0.1 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -6
- package/dist/es-module-shims.debug.js +389 -446
- package/dist/es-module-shims.js +375 -437
- package/dist/es-module-shims.wasm.js +375 -437
- package/package.json +1 -1
package/dist/es-module-shims.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
/* ES Module Shims 2.0.
|
|
1
|
+
/* ES Module Shims 2.0.3 */
|
|
2
2
|
(function () {
|
|
3
3
|
|
|
4
4
|
const hasDocument = typeof document !== 'undefined';
|
|
5
5
|
|
|
6
6
|
const noop = () => {};
|
|
7
7
|
|
|
8
|
+
const dynamicImport = (u, errUrl) => import(u);
|
|
9
|
+
|
|
8
10
|
const optionsScript = hasDocument ? document.querySelector('script[type=esms-options]') : undefined;
|
|
9
11
|
|
|
10
12
|
const esmsInitOptions = optionsScript ? JSON.parse(optionsScript.innerHTML) : {};
|
|
@@ -52,8 +54,6 @@
|
|
|
52
54
|
console.log(`%c^^ Module error above is polyfilled and can be ignored ^^`, 'font-weight:900;color:#391');
|
|
53
55
|
};
|
|
54
56
|
|
|
55
|
-
const edge = !navigator.userAgentData && !!navigator.userAgent.match(/Edge\/\d+\.\d+/);
|
|
56
|
-
|
|
57
57
|
const baseUrl =
|
|
58
58
|
hasDocument ?
|
|
59
59
|
document.baseURI
|
|
@@ -85,370 +85,315 @@
|
|
|
85
85
|
return parent ? ` imported from ${parent}` : '';
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
const backslashRegEx = /\\/g;
|
|
89
|
-
|
|
90
|
-
function asURL(url) {
|
|
91
|
-
try {
|
|
92
|
-
if (url.indexOf(':') !== -1) return new URL(url).href;
|
|
93
|
-
} catch (_) {}
|
|
94
|
-
}
|
|
95
|
-
|
|
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)');
|
|
88
|
+
const backslashRegEx = /\\/g;
|
|
284
89
|
|
|
285
|
-
|
|
90
|
+
function asURL(url) {
|
|
91
|
+
try {
|
|
92
|
+
if (url.indexOf(':') !== -1) return new URL(url).href;
|
|
93
|
+
} catch (_) {}
|
|
94
|
+
}
|
|
286
95
|
|
|
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
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
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);
|
|
327
142
|
}
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
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
|
+
}
|
|
436
282
|
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
283
|
+
// support browsers without dynamic import support (eg Firefox 6x)
|
|
284
|
+
let supportsJsonType = false;
|
|
285
|
+
let supportsCssType = false;
|
|
286
|
+
|
|
287
|
+
const supports = hasDocument && HTMLScriptElement.supports;
|
|
288
|
+
|
|
289
|
+
let supportsImportMaps = supports && supports.name === 'supports' && supports('importmap');
|
|
290
|
+
let supportsWasmModules = false;
|
|
291
|
+
let supportsSourcePhase = false;
|
|
292
|
+
let supportsMultipleImportMaps = false;
|
|
293
|
+
|
|
294
|
+
const wasmBytes = [0, 97, 115, 109, 1, 0, 0, 0];
|
|
295
|
+
|
|
296
|
+
let featureDetectionPromise = (async function () {
|
|
297
|
+
if (!hasDocument)
|
|
298
|
+
return Promise.all([
|
|
299
|
+
cssModulesEnabled &&
|
|
300
|
+
import(createBlob(`import"${createBlob('', 'text/css')}"with{type:"css"}`)).then(
|
|
301
|
+
() => (supportsCssType = true),
|
|
302
|
+
noop
|
|
303
|
+
),
|
|
304
|
+
jsonModulesEnabled &&
|
|
305
|
+
import(createBlob(`import"${createBlob('{}', 'text/json')}"with{type:"json"}`)).then(
|
|
306
|
+
() => (supportsJsonType = true),
|
|
307
|
+
noop
|
|
308
|
+
),
|
|
309
|
+
wasmModulesEnabled &&
|
|
310
|
+
import(createBlob(`import"${createBlob(new Uint8Array(wasmBytes), 'application/wasm')}"`)).then(
|
|
311
|
+
() => (supportsWasmModules = true),
|
|
312
|
+
noop
|
|
313
|
+
),
|
|
314
|
+
wasmModulesEnabled &&
|
|
315
|
+
sourcePhaseEnabled &&
|
|
316
|
+
import(createBlob(`import source x from"${createBlob(new Uint8Array(wasmBytes), 'application/wasm')}"`)).then(
|
|
317
|
+
() => (supportsSourcePhase = true),
|
|
318
|
+
noop
|
|
319
|
+
)
|
|
320
|
+
]);
|
|
321
|
+
|
|
322
|
+
return new Promise(resolve => {
|
|
323
|
+
const iframe = document.createElement('iframe');
|
|
324
|
+
iframe.style.display = 'none';
|
|
325
|
+
iframe.setAttribute('nonce', nonce);
|
|
326
|
+
function cb({ data }) {
|
|
327
|
+
const isFeatureDetectionMessage = Array.isArray(data) && data[0] === 'esms';
|
|
328
|
+
if (!isFeatureDetectionMessage) return;
|
|
329
|
+
[
|
|
330
|
+
,
|
|
331
|
+
supportsImportMaps,
|
|
332
|
+
supportsMultipleImportMaps,
|
|
333
|
+
supportsCssType,
|
|
334
|
+
supportsJsonType,
|
|
335
|
+
supportsWasmModules,
|
|
336
|
+
supportsSourcePhase
|
|
337
|
+
] = data;
|
|
338
|
+
resolve();
|
|
339
|
+
document.head.removeChild(iframe);
|
|
340
|
+
window.removeEventListener('message', cb, false);
|
|
341
|
+
}
|
|
342
|
+
window.addEventListener('message', cb, false);
|
|
343
|
+
|
|
344
|
+
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([${
|
|
345
|
+
supportsImportMaps ? 'true' : "'x'"
|
|
346
|
+
},${supportsImportMaps ? "'y'" : false},${supportsImportMaps && cssModulesEnabled ? `b(\`import"\${b('','text/css')}"with{type:"css"}\`)` : 'false'}, ${
|
|
347
|
+
supportsImportMaps && jsonModulesEnabled ? `b(\`import"\${b('{}','text/json')\}"with{type:"json"}\`)` : 'false'
|
|
348
|
+
},${
|
|
349
|
+
supportsImportMaps && wasmModulesEnabled ?
|
|
350
|
+
`b(\`import"\${b(new Uint8Array(${JSON.stringify(wasmBytes)}),'application/wasm')\}"\`)`
|
|
351
|
+
: 'false'
|
|
352
|
+
},${
|
|
353
|
+
supportsImportMaps && wasmModulesEnabled && sourcePhaseEnabled ?
|
|
354
|
+
`b(\`import source x from "\${b(new Uint8Array(${JSON.stringify(wasmBytes)}),'application/wasm')\}"\`)`
|
|
355
|
+
: 'false'
|
|
356
|
+
}].map(x =>typeof x==='string'?import(x).then(()=>true,()=>false):x)).then(a=>parent.postMessage(['esms'].concat(a),'*'))<${''}/script>`;
|
|
357
|
+
|
|
358
|
+
// Safari will call onload eagerly on head injection, but we don't want the Wechat
|
|
359
|
+
// path to trigger before setting srcdoc, therefore we track the timing
|
|
360
|
+
let readyForOnload = false,
|
|
361
|
+
onloadCalledWhileNotReady = false;
|
|
362
|
+
function doOnload() {
|
|
363
|
+
if (!readyForOnload) {
|
|
364
|
+
onloadCalledWhileNotReady = true;
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
367
|
+
// WeChat browser doesn't support setting srcdoc scripts
|
|
368
|
+
// But iframe sandboxes don't support contentDocument so we do this as a fallback
|
|
369
|
+
const doc = iframe.contentDocument;
|
|
370
|
+
if (doc && doc.head.childNodes.length === 0) {
|
|
371
|
+
const s = doc.createElement('script');
|
|
372
|
+
if (nonce) s.setAttribute('nonce', nonce);
|
|
373
|
+
s.innerHTML = importMapTest.slice(15 + (nonce ? nonce.length : 0), -9);
|
|
374
|
+
doc.head.appendChild(s);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
iframe.onload = doOnload;
|
|
379
|
+
// WeChat browser requires append before setting srcdoc
|
|
380
|
+
document.head.appendChild(iframe);
|
|
381
|
+
|
|
382
|
+
// setting srcdoc is not supported in React native webviews on iOS
|
|
383
|
+
// setting src to a blob URL results in a navigation event in webviews
|
|
384
|
+
// document.write gives usability warnings
|
|
385
|
+
readyForOnload = true;
|
|
386
|
+
if ('srcdoc' in iframe) iframe.srcdoc = importMapTest;
|
|
387
|
+
else iframe.contentDocument.write(importMapTest);
|
|
388
|
+
// retrigger onload for Safari only if necessary
|
|
389
|
+
if (onloadCalledWhileNotReady) doOnload();
|
|
390
|
+
});
|
|
391
|
+
})();
|
|
447
392
|
|
|
448
393
|
/* es-module-lexer 1.6.0 */
|
|
449
394
|
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$1,c$1,n;function parse(k,l="@"){t$1=k,c$1=l;const u=2*t$1.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$1.length+1;e.ses(r),e.sa(h-1),s(t$1,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$1.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$1.charCodeAt(a),c=i>=0?t$1.charCodeAt(i):-1;d.push({s:a,e:r,ls:i,le:s,n:34===f||39===f?b(a+1,f):t$1.slice(a,r),ln:i<0?void 0:34===c||39===c?b(i+1,c):t$1.slice(i,s)});}return [w,d,!!e.f(),!!e.ms()]}function b(e,a){n=e;let r="",i=n;for(;;){n>=t$1.length&&o();const e=t$1.charCodeAt(n);if(e===a)break;92===e?(r+=t$1.slice(i,n),r+=k(),i=n):(8232===e||8233===e||u(e)&&o(),++n);}return r+=t$1.slice(i,n++),r}function k(){let e=t$1.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$1.charCodeAt(n);let a;123===e?(++n,a=l(t$1.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$1.charCodeAt(n)&&++n;case 10:return "";case 56:case 57:o();default:if(e>=48&&e<=55){let a=t$1.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$1.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$1.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$1.slice(0,n).split("\n").length}:${n-t$1.lastIndexOf("\n",n-1)}`),{idx:n})}
|
|
450
395
|
|
|
451
|
-
|
|
396
|
+
function _resolve(id, parentUrl = baseUrl) {
|
|
452
397
|
const urlResolved = resolveIfNotPlainOrUrl(id, parentUrl) || asURL(id);
|
|
453
398
|
const firstResolved = firstImportMap && resolveImportMap(firstImportMap, urlResolved || id, parentUrl);
|
|
454
399
|
const composedResolved =
|
|
@@ -475,43 +420,54 @@
|
|
|
475
420
|
|
|
476
421
|
const resolve =
|
|
477
422
|
resolveHook ?
|
|
478
|
-
(id, parentUrl) => {
|
|
423
|
+
(id, parentUrl = baseUrl) => {
|
|
479
424
|
const result = resolveHook(id, parentUrl, defaultResolve);
|
|
480
425
|
return result ? { r: result, n: true, N: true } : _resolve(id, parentUrl);
|
|
481
426
|
}
|
|
482
427
|
: _resolve;
|
|
483
428
|
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
// import('mod', { opts }, parentUrl);
|
|
488
|
-
// import('mod', parentUrl);
|
|
489
|
-
async function importHandler(id, ...args) {
|
|
490
|
-
// parentUrl if present will be the last argument
|
|
491
|
-
let parentUrl = args[args.length - 1];
|
|
492
|
-
if (typeof parentUrl !== 'string') parentUrl = baseUrl;
|
|
493
|
-
// needed for shim check
|
|
494
|
-
await initPromise;
|
|
495
|
-
if (importHook) await importHook(id, typeof args[1] !== 'string' ? args[1] : {}, parentUrl);
|
|
429
|
+
async function importHandler(id, opts, parentUrl = baseUrl, sourcePhase) {
|
|
430
|
+
await initPromise; // needed for shim check
|
|
431
|
+
if (importHook) await importHook(id, opts, parentUrl);
|
|
496
432
|
if (shimMode || !baselinePassthrough) {
|
|
497
433
|
if (hasDocument) processScriptsAndPreloads();
|
|
498
434
|
legacyAcceptingImportMaps = false;
|
|
499
435
|
}
|
|
500
436
|
await importMapPromise;
|
|
501
|
-
return
|
|
437
|
+
return resolve(id, parentUrl).r;
|
|
502
438
|
}
|
|
503
439
|
|
|
504
|
-
//
|
|
505
|
-
|
|
506
|
-
|
|
440
|
+
// supports:
|
|
441
|
+
// import('mod');
|
|
442
|
+
// import('mod', { opts });
|
|
443
|
+
// import('mod', { opts }, parentUrl);
|
|
444
|
+
// import('mod', parentUrl);
|
|
445
|
+
async function importShim(specifier, opts, parentUrl) {
|
|
446
|
+
if (typeof opts === 'string') {
|
|
447
|
+
parentUrl = opts;
|
|
448
|
+
opts = undefined;
|
|
449
|
+
}
|
|
450
|
+
const url = await importHandler(specifier, opts, parentUrl);
|
|
451
|
+
// if we dynamically import CSS or JSON, and these are supported, use a wrapper module to
|
|
452
|
+
// support getting those imports from the native loader, because `import(specifier, options)`
|
|
453
|
+
// is not supported in older browsers to use syntactically.
|
|
454
|
+
const type = typeof opts === 'object' && typeof opts.with === 'object' && opts.with.type;
|
|
455
|
+
if ((supportsCssType && type === 'css') || (supportsJsonType && type === 'json')) {
|
|
456
|
+
return dynamicImport(createBlob(`export{default}from"${url}"with{type:"${type}"`));
|
|
457
|
+
}
|
|
458
|
+
return topLevelLoad(url, { credentials: 'same-origin' });
|
|
507
459
|
}
|
|
508
460
|
|
|
509
461
|
// import.source()
|
|
462
|
+
// (opts not currently supported as no use cases yet)
|
|
510
463
|
if (sourcePhaseEnabled)
|
|
511
|
-
importShim.source = async function importShimSource(
|
|
512
|
-
|
|
464
|
+
importShim.source = async function importShimSource(specifier, opts, parentUrl) {
|
|
465
|
+
if (typeof opts === 'string') {
|
|
466
|
+
parentUrl = opts;
|
|
467
|
+
opts = undefined;
|
|
468
|
+
}
|
|
469
|
+
const url = await importHandler(specifier, opts, parentUrl);
|
|
513
470
|
const load = getOrCreateLoad(url, { credentials: 'same-origin' }, null, null);
|
|
514
|
-
lastLoad = undefined;
|
|
515
471
|
if (firstPolyfillLoad && !shimMode && load.n && nativelyLoaded) {
|
|
516
472
|
onpolyfill();
|
|
517
473
|
firstPolyfillLoad = false;
|
|
@@ -533,17 +489,11 @@
|
|
|
533
489
|
throw Error(`Unable to resolve specifier '${id}'${fromParent(parentUrl)}`);
|
|
534
490
|
}
|
|
535
491
|
|
|
536
|
-
const resolveSync = (id, parentUrl = baseUrl) => {
|
|
537
|
-
parentUrl = `${parentUrl}`;
|
|
538
|
-
const result = resolveHook && resolveHook(id, parentUrl, defaultResolve);
|
|
539
|
-
return result && !result.then ? result : defaultResolve(id, parentUrl);
|
|
540
|
-
};
|
|
541
|
-
|
|
542
492
|
function metaResolve(id, parentUrl = this.url) {
|
|
543
|
-
return
|
|
493
|
+
return resolve(id, `${parentUrl}`).r;
|
|
544
494
|
}
|
|
545
495
|
|
|
546
|
-
importShim.resolve =
|
|
496
|
+
importShim.resolve = (id, parentUrl) => resolve(id, parentUrl).r;
|
|
547
497
|
importShim.getImportMap = () => JSON.parse(JSON.stringify(composedImportMap));
|
|
548
498
|
importShim.addImportMap = importMapIn => {
|
|
549
499
|
if (!shimMode) throw new Error('Unsupported in polyfill mode.');
|
|
@@ -575,8 +525,6 @@
|
|
|
575
525
|
const initPromise = featureDetectionPromise.then(() => {
|
|
576
526
|
baselinePassthrough =
|
|
577
527
|
esmsInitOptions.polyfillEnable !== true &&
|
|
578
|
-
supportsDynamicImport &&
|
|
579
|
-
supportsImportMeta &&
|
|
580
528
|
supportsImportMaps &&
|
|
581
529
|
(!jsonModulesEnabled || supportsJsonType) &&
|
|
582
530
|
(!cssModulesEnabled || supportsCssType) &&
|
|
@@ -630,13 +578,13 @@
|
|
|
630
578
|
document.addEventListener('readystatechange', readyListener);
|
|
631
579
|
}
|
|
632
580
|
}
|
|
581
|
+
processScriptsAndPreloads();
|
|
633
582
|
}
|
|
634
|
-
processScriptsAndPreloads();
|
|
635
583
|
return undefined;
|
|
636
584
|
});
|
|
637
585
|
|
|
638
586
|
function attachMutationObserver() {
|
|
639
|
-
new MutationObserver(mutations => {
|
|
587
|
+
const observer = new MutationObserver(mutations => {
|
|
640
588
|
for (const mutation of mutations) {
|
|
641
589
|
if (mutation.type !== 'childList') continue;
|
|
642
590
|
for (const node of mutation.addedNodes) {
|
|
@@ -652,7 +600,9 @@
|
|
|
652
600
|
}
|
|
653
601
|
}
|
|
654
602
|
}
|
|
655
|
-
})
|
|
603
|
+
});
|
|
604
|
+
observer.observe(document.head, { childList: true });
|
|
605
|
+
observer.observe(document.body, { childList: true });
|
|
656
606
|
processScriptsAndPreloads();
|
|
657
607
|
}
|
|
658
608
|
|
|
@@ -670,29 +620,27 @@
|
|
|
670
620
|
// for polyfill case, only dynamic import needs a return value here, and dynamic import will never pass nativelyLoaded
|
|
671
621
|
if (nativelyLoaded) return null;
|
|
672
622
|
await lastStaticLoadPromise;
|
|
673
|
-
return dynamicImport(source ? createBlob(source) : url
|
|
674
|
-
errUrl: url || source
|
|
675
|
-
});
|
|
623
|
+
return dynamicImport(source ? createBlob(source) : url);
|
|
676
624
|
}
|
|
677
625
|
const load = getOrCreateLoad(url, fetchOpts, null, source);
|
|
678
626
|
linkLoad(load, fetchOpts);
|
|
679
627
|
const seen = {};
|
|
680
628
|
await loadAll(load, seen);
|
|
681
|
-
lastLoad = undefined;
|
|
682
629
|
resolveDeps(load, seen);
|
|
683
630
|
await lastStaticLoadPromise;
|
|
631
|
+
if (!shimMode && !load.n && nativelyLoaded) {
|
|
632
|
+
return;
|
|
633
|
+
}
|
|
684
634
|
if (source && !shimMode && !load.n) {
|
|
685
|
-
|
|
686
|
-
if (revokeBlobURLs) revokeObjectURLs(Object.keys(seen));
|
|
687
|
-
return await dynamicImport(createBlob(source), { errUrl: source });
|
|
635
|
+
return await dynamicImport(createBlob(source));
|
|
688
636
|
}
|
|
689
637
|
if (firstPolyfillLoad && !shimMode && load.n && nativelyLoaded) {
|
|
690
638
|
onpolyfill();
|
|
691
639
|
firstPolyfillLoad = false;
|
|
692
640
|
}
|
|
693
|
-
const module = await
|
|
641
|
+
const module = await (!shimMode && !load.n && !load.N ? import(load.u) : dynamicImport(load.b, load.u));
|
|
694
642
|
// if the top-level load is a shell, run its update function
|
|
695
|
-
if (load.s) (await dynamicImport(load.s)).u$_(module);
|
|
643
|
+
if (load.s) (await dynamicImport(load.s, load.u)).u$_(module);
|
|
696
644
|
if (revokeBlobURLs) revokeObjectURLs(Object.keys(seen));
|
|
697
645
|
// when tla is supported, this should return the tla promise as an actual handle
|
|
698
646
|
// so readystate can still correspond to the sync subgraph exec completions
|
|
@@ -709,7 +657,7 @@
|
|
|
709
657
|
if (batchStartIndex > keysLength) return;
|
|
710
658
|
for (const key of registryKeys.slice(batchStartIndex, batchStartIndex + 100)) {
|
|
711
659
|
const load = registry[key];
|
|
712
|
-
if (load) URL.revokeObjectURL(load.b);
|
|
660
|
+
if (load && load.b) URL.revokeObjectURL(load.b);
|
|
713
661
|
}
|
|
714
662
|
batch++;
|
|
715
663
|
schedule(cleanup);
|
|
@@ -720,7 +668,6 @@
|
|
|
720
668
|
return `'${url.replace(/'/g, "\\'")}'`;
|
|
721
669
|
}
|
|
722
670
|
|
|
723
|
-
let lastLoad;
|
|
724
671
|
function resolveDeps(load, seen) {
|
|
725
672
|
if (load.b || !seen[load.u]) return;
|
|
726
673
|
seen[load.u] = 0;
|
|
@@ -735,7 +682,7 @@
|
|
|
735
682
|
// use native loader whenever possible (n = needs shim) via executable subgraph passthrough
|
|
736
683
|
// so long as the module doesn't use dynamic import or unsupported URL mappings (N = should shim)
|
|
737
684
|
if (!shimMode && !load.n && !load.N) {
|
|
738
|
-
load.b =
|
|
685
|
+
load.b = load.u;
|
|
739
686
|
load.S = undefined;
|
|
740
687
|
return;
|
|
741
688
|
}
|
|
@@ -745,8 +692,7 @@
|
|
|
745
692
|
// "execution"
|
|
746
693
|
const source = load.S;
|
|
747
694
|
|
|
748
|
-
|
|
749
|
-
let resolvedSource = edge && lastLoad ? `import '${lastLoad}';` : '';
|
|
695
|
+
let resolvedSource = '';
|
|
750
696
|
|
|
751
697
|
// once all deps have loaded we can inline the dependency resolution blobs
|
|
752
698
|
// and define this blob
|
|
@@ -870,7 +816,7 @@
|
|
|
870
816
|
|
|
871
817
|
if (sourceURLCommentStart === -1) resolvedSource += sourceURLCommentPrefix + load.r;
|
|
872
818
|
|
|
873
|
-
load.b =
|
|
819
|
+
load.b = createBlob(resolvedSource);
|
|
874
820
|
load.S = undefined;
|
|
875
821
|
}
|
|
876
822
|
|
|
@@ -925,7 +871,7 @@
|
|
|
925
871
|
);
|
|
926
872
|
const r = res.url;
|
|
927
873
|
const contentType = res.headers.get('content-type');
|
|
928
|
-
if (jsContentType.test(contentType)) return { r, s: await res.text(),
|
|
874
|
+
if (jsContentType.test(contentType)) return { r, s: await res.text(), t: 'js' };
|
|
929
875
|
else if (wasmContentType.test(contentType)) {
|
|
930
876
|
const module = await (sourceCache[r] || (sourceCache[r] = WebAssembly.compileStreaming(res)));
|
|
931
877
|
sourceCache[r] = module;
|
|
@@ -943,8 +889,7 @@
|
|
|
943
889
|
s += `export const ${expt.name} = instance.exports['${expt.name}'];\n`;
|
|
944
890
|
}
|
|
945
891
|
return { r, s, t: 'wasm' };
|
|
946
|
-
} else if (jsonContentType.test(contentType))
|
|
947
|
-
return { r, s: `export default ${await res.text()}`, sp: null, t: 'json' };
|
|
892
|
+
} else if (jsonContentType.test(contentType)) return { r, s: `export default ${await res.text()}`, t: 'json' };
|
|
948
893
|
else if (cssContentType.test(contentType)) {
|
|
949
894
|
return {
|
|
950
895
|
r,
|
|
@@ -954,7 +899,6 @@
|
|
|
954
899
|
(_match, quotes = '', relUrl1, relUrl2) => `url(${quotes}${resolveUrl(relUrl1 || relUrl2, url)}${quotes})`
|
|
955
900
|
)
|
|
956
901
|
)});export default s;`,
|
|
957
|
-
ss: null,
|
|
958
902
|
t: 'css'
|
|
959
903
|
};
|
|
960
904
|
} else
|
|
@@ -1041,31 +985,26 @@
|
|
|
1041
985
|
if (load.L) return;
|
|
1042
986
|
load.L = load.f.then(async () => {
|
|
1043
987
|
let childFetchOpts = fetchOpts;
|
|
1044
|
-
load.d =
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
if (
|
|
1049
|
-
if (
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
// load, sourcePhase
|
|
1065
|
-
return child;
|
|
1066
|
-
})
|
|
1067
|
-
)
|
|
1068
|
-
).filter(l => l);
|
|
988
|
+
load.d = load.a[0]
|
|
989
|
+
.map(({ n, d, t }) => {
|
|
990
|
+
const sourcePhase = t >= 4;
|
|
991
|
+
if (sourcePhase) {
|
|
992
|
+
if (!sourcePhaseEnabled) throw featErr('source-phase');
|
|
993
|
+
if (!supportsSourcePhase) load.n = true;
|
|
994
|
+
}
|
|
995
|
+
if (d !== -1 || !n) return;
|
|
996
|
+
const resolved = resolve(n, load.r || load.u);
|
|
997
|
+
if (resolved.n) load.n = true;
|
|
998
|
+
if (d >= 0 || resolved.N) load.N = true;
|
|
999
|
+
if (d !== -1) return;
|
|
1000
|
+
if (skip && skip(resolved.r) && !sourcePhase) return { l: { b: resolved.r }, s: false };
|
|
1001
|
+
if (childFetchOpts.integrity) childFetchOpts = Object.assign({}, childFetchOpts, { integrity: undefined });
|
|
1002
|
+
const child = { l: getOrCreateLoad(resolved.r, childFetchOpts, load.r, null), s: sourcePhase };
|
|
1003
|
+
if (!child.s) linkLoad(child.l, fetchOpts);
|
|
1004
|
+
// load, sourcePhase
|
|
1005
|
+
return child;
|
|
1006
|
+
})
|
|
1007
|
+
.filter(l => l);
|
|
1069
1008
|
});
|
|
1070
1009
|
}
|
|
1071
1010
|
|
|
@@ -1150,7 +1089,6 @@
|
|
|
1150
1089
|
);
|
|
1151
1090
|
})
|
|
1152
1091
|
.catch(e => {
|
|
1153
|
-
console.log(e);
|
|
1154
1092
|
if (e instanceof SyntaxError)
|
|
1155
1093
|
e = new Error(`Unable to parse import map ${e.message} in: ${script.src || script.innerHTML}`);
|
|
1156
1094
|
throwError(e);
|