es-module-shims 2.0.2 → 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 +388 -445
- package/dist/es-module-shims.js +374 -436
- package/dist/es-module-shims.wasm.js +374 -436
- package/package.json +1 -1
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
/* ES Module Shims DEBUG BUILD 2.0.
|
|
1
|
+
/* ES Module Shims DEBUG BUILD 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,376 +85,321 @@
|
|
|
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
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
if (
|
|
445
|
-
|
|
446
|
-
|
|
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
|
+
}
|
|
447
282
|
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
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
|
+
})();
|
|
392
|
+
|
|
393
|
+
featureDetectionPromise = featureDetectionPromise.then(() => {
|
|
394
|
+
console.info(
|
|
395
|
+
`es-module-shims: detected native support - module types: (${[...(supportsJsonType ? ['json'] : []), ...(supportsCssType ? ['css'] : []), ...(supportsWasmModules ? ['wasm'] : [])].join(', ')}), ${supportsSourcePhase ? 'source phase' : 'no source phase'}, ${supportsMultipleImportMaps ? '' : 'no '}multiple import maps, ${supportsImportMaps ? '' : 'no '}import maps`
|
|
396
|
+
);
|
|
452
397
|
});
|
|
453
398
|
|
|
454
399
|
/* es-module-lexer 1.6.0 */
|
|
455
400
|
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})}
|
|
456
401
|
|
|
457
|
-
|
|
402
|
+
function _resolve(id, parentUrl = baseUrl) {
|
|
458
403
|
const urlResolved = resolveIfNotPlainOrUrl(id, parentUrl) || asURL(id);
|
|
459
404
|
const firstResolved = firstImportMap && resolveImportMap(firstImportMap, urlResolved || id, parentUrl);
|
|
460
405
|
const composedResolved =
|
|
@@ -481,44 +426,57 @@
|
|
|
481
426
|
|
|
482
427
|
const resolve =
|
|
483
428
|
resolveHook ?
|
|
484
|
-
(id, parentUrl) => {
|
|
429
|
+
(id, parentUrl = baseUrl) => {
|
|
485
430
|
const result = resolveHook(id, parentUrl, defaultResolve);
|
|
486
431
|
return result ? { r: result, n: true, N: true } : _resolve(id, parentUrl);
|
|
487
432
|
}
|
|
488
433
|
: _resolve;
|
|
489
434
|
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
// parentUrl if present will be the last argument
|
|
497
|
-
let parentUrl = args[args.length - 1];
|
|
498
|
-
if (typeof parentUrl !== 'string') parentUrl = baseUrl;
|
|
499
|
-
// needed for shim check
|
|
500
|
-
await initPromise;
|
|
501
|
-
if (importHook) await importHook(id, typeof args[1] !== 'string' ? args[1] : {}, parentUrl);
|
|
435
|
+
async function importHandler(id, opts, parentUrl = baseUrl, sourcePhase) {
|
|
436
|
+
await initPromise; // needed for shim check
|
|
437
|
+
console.info(
|
|
438
|
+
`es-module-shims: importShim${sourcePhase ? '.source' : ''}("${id}"${opts ? ', ' + JSON.stringify(opts) : ''})`
|
|
439
|
+
);
|
|
440
|
+
if (importHook) await importHook(id, opts, parentUrl);
|
|
502
441
|
if (shimMode || !baselinePassthrough) {
|
|
503
442
|
if (hasDocument) processScriptsAndPreloads();
|
|
504
443
|
legacyAcceptingImportMaps = false;
|
|
505
444
|
}
|
|
506
445
|
await importMapPromise;
|
|
507
|
-
return
|
|
446
|
+
return resolve(id, parentUrl).r;
|
|
508
447
|
}
|
|
509
448
|
|
|
510
|
-
//
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
449
|
+
// supports:
|
|
450
|
+
// import('mod');
|
|
451
|
+
// import('mod', { opts });
|
|
452
|
+
// import('mod', { opts }, parentUrl);
|
|
453
|
+
// import('mod', parentUrl);
|
|
454
|
+
async function importShim(specifier, opts, parentUrl) {
|
|
455
|
+
if (typeof opts === 'string') {
|
|
456
|
+
parentUrl = opts;
|
|
457
|
+
opts = undefined;
|
|
458
|
+
}
|
|
459
|
+
const url = await importHandler(specifier, opts, parentUrl);
|
|
460
|
+
// if we dynamically import CSS or JSON, and these are supported, use a wrapper module to
|
|
461
|
+
// support getting those imports from the native loader, because `import(specifier, options)`
|
|
462
|
+
// is not supported in older browsers to use syntactically.
|
|
463
|
+
const type = typeof opts === 'object' && typeof opts.with === 'object' && opts.with.type;
|
|
464
|
+
if ((supportsCssType && type === 'css') || (supportsJsonType && type === 'json')) {
|
|
465
|
+
return dynamicImport(createBlob(`export{default}from"${url}"with{type:"${type}"`));
|
|
466
|
+
}
|
|
467
|
+
return topLevelLoad(url, { credentials: 'same-origin' });
|
|
514
468
|
}
|
|
515
469
|
|
|
516
470
|
// import.source()
|
|
471
|
+
// (opts not currently supported as no use cases yet)
|
|
517
472
|
if (sourcePhaseEnabled)
|
|
518
|
-
importShim.source = async function importShimSource(
|
|
519
|
-
|
|
473
|
+
importShim.source = async function importShimSource(specifier, opts, parentUrl) {
|
|
474
|
+
if (typeof opts === 'string') {
|
|
475
|
+
parentUrl = opts;
|
|
476
|
+
opts = undefined;
|
|
477
|
+
}
|
|
478
|
+
const url = await importHandler(specifier, opts, parentUrl, true);
|
|
520
479
|
const load = getOrCreateLoad(url, { credentials: 'same-origin' }, null, null);
|
|
521
|
-
lastLoad = undefined;
|
|
522
480
|
if (firstPolyfillLoad && !shimMode && load.n && nativelyLoaded) {
|
|
523
481
|
onpolyfill();
|
|
524
482
|
firstPolyfillLoad = false;
|
|
@@ -540,17 +498,11 @@
|
|
|
540
498
|
throw Error(`Unable to resolve specifier '${id}'${fromParent(parentUrl)}`);
|
|
541
499
|
}
|
|
542
500
|
|
|
543
|
-
const resolveSync = (id, parentUrl = baseUrl) => {
|
|
544
|
-
parentUrl = `${parentUrl}`;
|
|
545
|
-
const result = resolveHook && resolveHook(id, parentUrl, defaultResolve);
|
|
546
|
-
return result && !result.then ? result : defaultResolve(id, parentUrl);
|
|
547
|
-
};
|
|
548
|
-
|
|
549
501
|
function metaResolve(id, parentUrl = this.url) {
|
|
550
|
-
return
|
|
502
|
+
return resolve(id, `${parentUrl}`).r;
|
|
551
503
|
}
|
|
552
504
|
|
|
553
|
-
importShim.resolve =
|
|
505
|
+
importShim.resolve = (id, parentUrl) => resolve(id, parentUrl).r;
|
|
554
506
|
importShim.getImportMap = () => JSON.parse(JSON.stringify(composedImportMap));
|
|
555
507
|
importShim.addImportMap = importMapIn => {
|
|
556
508
|
if (!shimMode) throw new Error('Unsupported in polyfill mode.');
|
|
@@ -582,8 +534,6 @@
|
|
|
582
534
|
const initPromise = featureDetectionPromise.then(() => {
|
|
583
535
|
baselinePassthrough =
|
|
584
536
|
esmsInitOptions.polyfillEnable !== true &&
|
|
585
|
-
supportsDynamicImport &&
|
|
586
|
-
supportsImportMeta &&
|
|
587
537
|
supportsImportMaps &&
|
|
588
538
|
(!jsonModulesEnabled || supportsJsonType) &&
|
|
589
539
|
(!cssModulesEnabled || supportsCssType) &&
|
|
@@ -646,7 +596,7 @@
|
|
|
646
596
|
});
|
|
647
597
|
|
|
648
598
|
function attachMutationObserver() {
|
|
649
|
-
new MutationObserver(mutations => {
|
|
599
|
+
const observer = new MutationObserver(mutations => {
|
|
650
600
|
for (const mutation of mutations) {
|
|
651
601
|
if (mutation.type !== 'childList') continue;
|
|
652
602
|
for (const node of mutation.addedNodes) {
|
|
@@ -662,7 +612,9 @@
|
|
|
662
612
|
}
|
|
663
613
|
}
|
|
664
614
|
}
|
|
665
|
-
})
|
|
615
|
+
});
|
|
616
|
+
observer.observe(document.head, { childList: true });
|
|
617
|
+
observer.observe(document.body, { childList: true });
|
|
666
618
|
processScriptsAndPreloads();
|
|
667
619
|
}
|
|
668
620
|
|
|
@@ -677,33 +629,34 @@
|
|
|
677
629
|
if (importHook) await importHook(url, typeof fetchOpts !== 'string' ? fetchOpts : {}, '');
|
|
678
630
|
// early analysis opt-out - no need to even fetch if we have feature support
|
|
679
631
|
if (!shimMode && baselinePassthrough) {
|
|
680
|
-
console.info(`es-module-shims: early
|
|
632
|
+
console.info(`es-module-shims: early exit for ${url} due to baseline modules support`);
|
|
681
633
|
// for polyfill case, only dynamic import needs a return value here, and dynamic import will never pass nativelyLoaded
|
|
682
634
|
if (nativelyLoaded) return null;
|
|
683
635
|
await lastStaticLoadPromise;
|
|
684
|
-
return dynamicImport(source ? createBlob(source) : url
|
|
685
|
-
errUrl: url || source
|
|
686
|
-
});
|
|
636
|
+
return dynamicImport(source ? createBlob(source) : url);
|
|
687
637
|
}
|
|
688
638
|
const load = getOrCreateLoad(url, fetchOpts, null, source);
|
|
689
639
|
linkLoad(load, fetchOpts);
|
|
690
640
|
const seen = {};
|
|
691
641
|
await loadAll(load, seen);
|
|
692
|
-
lastLoad = undefined;
|
|
693
642
|
resolveDeps(load, seen);
|
|
694
643
|
await lastStaticLoadPromise;
|
|
644
|
+
if (!shimMode && !load.n && nativelyLoaded) {
|
|
645
|
+
console.info(
|
|
646
|
+
`es-module-shims: early exit after graph analysis of ${url} - graph ran natively without needing polyfill`
|
|
647
|
+
);
|
|
648
|
+
return;
|
|
649
|
+
}
|
|
695
650
|
if (source && !shimMode && !load.n) {
|
|
696
|
-
|
|
697
|
-
if (revokeBlobURLs) revokeObjectURLs(Object.keys(seen));
|
|
698
|
-
return await dynamicImport(createBlob(source), { errUrl: source });
|
|
651
|
+
return await dynamicImport(createBlob(source));
|
|
699
652
|
}
|
|
700
653
|
if (firstPolyfillLoad && !shimMode && load.n && nativelyLoaded) {
|
|
701
654
|
onpolyfill();
|
|
702
655
|
firstPolyfillLoad = false;
|
|
703
656
|
}
|
|
704
|
-
const module = await
|
|
657
|
+
const module = await (!shimMode && !load.n && !load.N ? import(load.u) : dynamicImport(load.b, load.u));
|
|
705
658
|
// if the top-level load is a shell, run its update function
|
|
706
|
-
if (load.s) (await dynamicImport(load.s)).u$_(module);
|
|
659
|
+
if (load.s) (await dynamicImport(load.s, load.u)).u$_(module);
|
|
707
660
|
if (revokeBlobURLs) revokeObjectURLs(Object.keys(seen));
|
|
708
661
|
// when tla is supported, this should return the tla promise as an actual handle
|
|
709
662
|
// so readystate can still correspond to the sync subgraph exec completions
|
|
@@ -720,7 +673,7 @@
|
|
|
720
673
|
if (batchStartIndex > keysLength) return;
|
|
721
674
|
for (const key of registryKeys.slice(batchStartIndex, batchStartIndex + 100)) {
|
|
722
675
|
const load = registry[key];
|
|
723
|
-
if (load) URL.revokeObjectURL(load.b);
|
|
676
|
+
if (load && load.b) URL.revokeObjectURL(load.b);
|
|
724
677
|
}
|
|
725
678
|
batch++;
|
|
726
679
|
schedule(cleanup);
|
|
@@ -731,7 +684,6 @@
|
|
|
731
684
|
return `'${url.replace(/'/g, "\\'")}'`;
|
|
732
685
|
}
|
|
733
686
|
|
|
734
|
-
let lastLoad;
|
|
735
687
|
function resolveDeps(load, seen) {
|
|
736
688
|
if (load.b || !seen[load.u]) return;
|
|
737
689
|
seen[load.u] = 0;
|
|
@@ -746,7 +698,7 @@
|
|
|
746
698
|
// use native loader whenever possible (n = needs shim) via executable subgraph passthrough
|
|
747
699
|
// so long as the module doesn't use dynamic import or unsupported URL mappings (N = should shim)
|
|
748
700
|
if (!shimMode && !load.n && !load.N) {
|
|
749
|
-
load.b =
|
|
701
|
+
load.b = load.u;
|
|
750
702
|
load.S = undefined;
|
|
751
703
|
return;
|
|
752
704
|
}
|
|
@@ -758,8 +710,7 @@
|
|
|
758
710
|
// "execution"
|
|
759
711
|
const source = load.S;
|
|
760
712
|
|
|
761
|
-
|
|
762
|
-
let resolvedSource = edge && lastLoad ? `import '${lastLoad}';` : '';
|
|
713
|
+
let resolvedSource = '';
|
|
763
714
|
|
|
764
715
|
// once all deps have loaded we can inline the dependency resolution blobs
|
|
765
716
|
// and define this blob
|
|
@@ -883,7 +834,7 @@
|
|
|
883
834
|
|
|
884
835
|
if (sourceURLCommentStart === -1) resolvedSource += sourceURLCommentPrefix + load.r;
|
|
885
836
|
|
|
886
|
-
load.b =
|
|
837
|
+
load.b = createBlob(resolvedSource);
|
|
887
838
|
load.S = undefined;
|
|
888
839
|
}
|
|
889
840
|
|
|
@@ -938,7 +889,7 @@
|
|
|
938
889
|
);
|
|
939
890
|
const r = res.url;
|
|
940
891
|
const contentType = res.headers.get('content-type');
|
|
941
|
-
if (jsContentType.test(contentType)) return { r, s: await res.text(),
|
|
892
|
+
if (jsContentType.test(contentType)) return { r, s: await res.text(), t: 'js' };
|
|
942
893
|
else if (wasmContentType.test(contentType)) {
|
|
943
894
|
const module = await (sourceCache[r] || (sourceCache[r] = WebAssembly.compileStreaming(res)));
|
|
944
895
|
sourceCache[r] = module;
|
|
@@ -956,8 +907,7 @@
|
|
|
956
907
|
s += `export const ${expt.name} = instance.exports['${expt.name}'];\n`;
|
|
957
908
|
}
|
|
958
909
|
return { r, s, t: 'wasm' };
|
|
959
|
-
} else if (jsonContentType.test(contentType))
|
|
960
|
-
return { r, s: `export default ${await res.text()}`, sp: null, t: 'json' };
|
|
910
|
+
} else if (jsonContentType.test(contentType)) return { r, s: `export default ${await res.text()}`, t: 'json' };
|
|
961
911
|
else if (cssContentType.test(contentType)) {
|
|
962
912
|
return {
|
|
963
913
|
r,
|
|
@@ -967,7 +917,6 @@
|
|
|
967
917
|
(_match, quotes = '', relUrl1, relUrl2) => `url(${quotes}${resolveUrl(relUrl1 || relUrl2, url)}${quotes})`
|
|
968
918
|
)
|
|
969
919
|
)});export default s;`,
|
|
970
|
-
ss: null,
|
|
971
920
|
t: 'css'
|
|
972
921
|
};
|
|
973
922
|
} else
|
|
@@ -1054,36 +1003,30 @@
|
|
|
1054
1003
|
if (load.L) return;
|
|
1055
1004
|
load.L = load.f.then(async () => {
|
|
1056
1005
|
let childFetchOpts = fetchOpts;
|
|
1057
|
-
load.d =
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
if (
|
|
1062
|
-
if (
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
// load, sourcePhase
|
|
1078
|
-
return child;
|
|
1079
|
-
})
|
|
1080
|
-
)
|
|
1081
|
-
).filter(l => l);
|
|
1006
|
+
load.d = load.a[0]
|
|
1007
|
+
.map(({ n, d, t }) => {
|
|
1008
|
+
const sourcePhase = t >= 4;
|
|
1009
|
+
if (sourcePhase) {
|
|
1010
|
+
if (!sourcePhaseEnabled) throw featErr('source-phase');
|
|
1011
|
+
if (!supportsSourcePhase) load.n = true;
|
|
1012
|
+
}
|
|
1013
|
+
if (d !== -1 || !n) return;
|
|
1014
|
+
const resolved = resolve(n, load.r || load.u);
|
|
1015
|
+
if (resolved.n) load.n = true;
|
|
1016
|
+
if (d >= 0 || resolved.N) load.N = true;
|
|
1017
|
+
if (d !== -1) return;
|
|
1018
|
+
if (skip && skip(resolved.r) && !sourcePhase) return { l: { b: resolved.r }, s: false };
|
|
1019
|
+
if (childFetchOpts.integrity) childFetchOpts = Object.assign({}, childFetchOpts, { integrity: undefined });
|
|
1020
|
+
const child = { l: getOrCreateLoad(resolved.r, childFetchOpts, load.r, null), s: sourcePhase };
|
|
1021
|
+
if (!child.s) linkLoad(child.l, fetchOpts);
|
|
1022
|
+
// load, sourcePhase
|
|
1023
|
+
return child;
|
|
1024
|
+
})
|
|
1025
|
+
.filter(l => l);
|
|
1082
1026
|
});
|
|
1083
1027
|
}
|
|
1084
1028
|
|
|
1085
1029
|
function processScriptsAndPreloads() {
|
|
1086
|
-
console.info(`es-module-shims: processing scripts`);
|
|
1087
1030
|
for (const link of document.querySelectorAll(shimMode ? 'link[rel=modulepreload-shim]' : 'link[rel=modulepreload]')) {
|
|
1088
1031
|
if (!link.ep) processPreload(link);
|
|
1089
1032
|
}
|
|
@@ -1153,6 +1096,7 @@
|
|
|
1153
1096
|
|
|
1154
1097
|
function processImportMap(script, ready = readyStateCompleteCnt > 0) {
|
|
1155
1098
|
if (epCheck(script, ready)) return;
|
|
1099
|
+
console.info(`es-module-shims: reading import map`);
|
|
1156
1100
|
// we dont currently support external import maps in polyfill mode to match native
|
|
1157
1101
|
if (script.src) {
|
|
1158
1102
|
if (!shimMode) return;
|
|
@@ -1167,7 +1111,6 @@
|
|
|
1167
1111
|
);
|
|
1168
1112
|
})
|
|
1169
1113
|
.catch(e => {
|
|
1170
|
-
console.log(e);
|
|
1171
1114
|
if (e instanceof SyntaxError)
|
|
1172
1115
|
e = new Error(`Unable to parse import map ${e.message} in: ${script.src || script.innerHTML}`);
|
|
1173
1116
|
throwError(e);
|
|
@@ -1186,6 +1129,7 @@
|
|
|
1186
1129
|
|
|
1187
1130
|
function processScript(script, ready = readyStateCompleteCnt > 0) {
|
|
1188
1131
|
if (epCheck(script, ready)) return;
|
|
1132
|
+
console.info(`es-module-shims: checking script ${script.src || '<inline>'}`);
|
|
1189
1133
|
// does this load block readystate complete
|
|
1190
1134
|
const isBlockingReadyScript = script.getAttribute('async') === null && readyStateCompleteCnt > 0;
|
|
1191
1135
|
// does this load block DOMContentLoaded
|
|
@@ -1194,7 +1138,6 @@
|
|
|
1194
1138
|
if (isLoadScript) loadCnt++;
|
|
1195
1139
|
if (isBlockingReadyScript) readyStateCompleteCnt++;
|
|
1196
1140
|
if (isDomContentLoadedScript) domContentLoadedCnt++;
|
|
1197
|
-
console.info(`es-module-shims: loading ${script.src || '<inline>'}`);
|
|
1198
1141
|
const loadPromise = topLevelLoad(
|
|
1199
1142
|
script.src || baseUrl,
|
|
1200
1143
|
getFetchOpts(script),
|