es-module-shims 1.10.1 → 2.0.0

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