es-module-shims 1.10.1 → 2.0.1

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.1 */
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 (_) {}
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
+ }
275
281
  }
276
282
 
277
283
  let dynamicImport = !hasDocument && (0, eval)('u=>import(u)');
278
284
 
279
285
  let supportsDynamicImport;
280
286
 
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}).`));
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
+ });
311
305
  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
- });
323
-
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);
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
+ });
388
327
  }
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
- });
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/AUHA8gALfwBBwPIACwd6FQZtZW1vcnkCAAJzYQAAAWUAAwJpcwAEAmllAAUCc3MABgJzZQAHAml0AAgCYWkACQJpZAAKAmlwAAsCZXMADAJlZQANA2VscwAOA2VsZQAPAnJpABACcmUAEQFmABICbXMAEwVwYXJzZQAUC19faGVhcF9iYXNlAwEKm0EwaAEBf0EAIAA2AoAKQQAoAtwJIgEgAEEBdGoiAEEAOwEAQQAgAEECaiIANgKECkEAIAA2AogKQQBBADYC4AlBAEEANgLwCUEAQQA2AugJQQBBADYC5AlBAEEANgL4CUEAQQA2AuwJIAEL0wEBA39BACgC8AkhBEEAQQAoAogKIgU2AvAJQQAgBDYC9AlBACAFQSRqNgKICiAEQSBqQeAJIAQbIAU2AgBBACgC1AkhBEEAKALQCSEGIAUgATYCACAFIAA2AgggBSACIAJBAmpBACAGIANGIgAbIAQgA0YiBBs2AgwgBSADNgIUIAVBADYCECAFIAI2AgQgBUEANgIgIAVBA0EBQQIgABsgBBs2AhwgBUEAKALQCSADRiICOgAYAkACQCACDQBBACgC1AkgA0cNAQtBAEEBOgCMCgsLXgEBf0EAKAL4CSIEQRBqQeQJIAQbQQAoAogKIgQ2AgBBACAENgL4CUEAIARBFGo2AogKQQBBAToAjAogBEEANgIQIAQgAzYCDCAEIAI2AgggBCABNgIEIAQgADYCAAsIAEEAKAKQCgsVAEEAKALoCSgCAEEAKALcCWtBAXULHgEBf0EAKALoCSgCBCIAQQAoAtwJa0EBdUF/IAAb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gAnRBn4CABHENAgsgAUGgAUYNASAAIQIgARAoDQJBACECQQBBACgCsAoiAEECajYCsAogAC8BAiIADQAMAgsLIAAhAgsgAkH//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/fwADMTAAAQECAgICAgICAgICAgICAgICAgIAAwMDBAQAAAUAAAAAAAMDAwAGAAAABwAGAgUEBQFwAQEBBQMBAAEGDwJ/AUHA8gALfwBBwPIACwd6FQZtZW1vcnkCAAJzYQAAAWUAAwJpcw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AKwCiEAQQAoArQKIQECQAJAA0AgAEECaiECIAAgAU8NAQJAAkAgAi8BACIDQaR/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,55 @@
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
+ );
512
566
  }
513
567
 
514
- let importMap = { imports: {}, scopes: {}, integrity: {} };
568
+ let importMapSrc = false;
569
+ let multipleImportMaps = false;
570
+ let firstImportMap = null;
571
+ // To support polyfilling multiple import maps, we separately track the composed import map from the first import map
572
+ let composedImportMap = { imports: {}, scopes: {}, integrity: {} };
515
573
  let baselinePassthrough;
516
574
 
517
575
  const initPromise = featureDetectionPromise.then(() => {
518
- baselinePassthrough = esmsInitOptions.polyfillEnable !== true && supportsDynamicImport && supportsImportMeta && supportsImportMaps && (!jsonModulesEnabled || supportsJsonAssertions) && (!cssModulesEnabled || supportsCssAssertions) && (!wasmModulesEnabled || supportsWasmModules) && (!sourcePhaseEnabled || supportsSourcePhase) && !importMapSrcOrLazy;
576
+ baselinePassthrough =
577
+ esmsInitOptions.polyfillEnable !== true &&
578
+ supportsDynamicImport &&
579
+ supportsImportMeta &&
580
+ supportsImportMaps &&
581
+ (!jsonModulesEnabled || supportsJsonType) &&
582
+ (!cssModulesEnabled || supportsCssType) &&
583
+ (!wasmModulesEnabled || supportsWasmModules) &&
584
+ (!sourcePhaseEnabled || supportsSourcePhase) &&
585
+ (!multipleImportMaps || supportsMultipleImportMaps) &&
586
+ !importMapSrc;
519
587
  if (sourcePhaseEnabled && typeof WebAssembly !== 'undefined' && !Object.getPrototypeOf(WebAssembly.Module).name) {
520
588
  const s = Symbol();
521
- const brand = m => Object.defineProperty(m, s, { writable: false, configurable: false, value: 'WebAssembly.Module' });
589
+ const brand = m =>
590
+ Object.defineProperty(m, s, { writable: false, configurable: false, value: 'WebAssembly.Module' });
522
591
  class AbstractModuleSource {
523
592
  get [Symbol.toStringTag]() {
524
593
  if (this[s]) return this[s];
@@ -526,11 +595,14 @@
526
595
  }
527
596
  }
528
597
  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);
598
+ WebAssembly.Module = Object.setPrototypeOf(
599
+ Object.assign(function Module(...args) {
600
+ return brand(new wasmModule(...args));
601
+ }, wasmModule),
602
+ AbstractModuleSource
603
+ );
532
604
  WebAssembly.Module.prototype = Object.setPrototypeOf(wasmModule.prototype, AbstractModuleSource.prototype);
533
- WebAssembly.compile = function compile (...args) {
605
+ WebAssembly.compile = function compile(...args) {
534
606
  return wasmCompile(...args).then(brand);
535
607
  };
536
608
  WebAssembly.compileStreaming = function compileStreaming(...args) {
@@ -543,27 +615,10 @@
543
615
  HTMLScriptElement.supports = type => type === 'importmap' || supports(type);
544
616
  }
545
617
  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();
618
+ attachMutationObserver();
563
619
  if (document.readyState === 'complete') {
564
620
  readyStateCompleteCheck();
565
- }
566
- else {
621
+ } else {
567
622
  async function readyListener() {
568
623
  await initPromise;
569
624
  processScriptsAndPreloads();
@@ -576,25 +631,48 @@
576
631
  }
577
632
  }
578
633
  }
634
+ processScriptsAndPreloads();
579
635
  return init;
580
636
  });
637
+
638
+ function attachMutationObserver() {
639
+ new MutationObserver(mutations => {
640
+ for (const mutation of mutations) {
641
+ if (mutation.type !== 'childList') continue;
642
+ for (const node of mutation.addedNodes) {
643
+ if (node.tagName === 'SCRIPT') {
644
+ if (node.type === (shimMode ? 'module-shim' : 'module') && !node.ep) processScript(node, true);
645
+ if (node.type === (shimMode ? 'importmap-shim' : 'importmap') && !node.ep) processImportMap(node, true);
646
+ } else if (
647
+ node.tagName === 'LINK' &&
648
+ node.rel === (shimMode ? 'modulepreload-shim' : 'modulepreload') &&
649
+ !node.ep
650
+ ) {
651
+ processPreload(node);
652
+ }
653
+ }
654
+ }
655
+ }).observe(document, { childList: true, subtree: true });
656
+ processScriptsAndPreloads();
657
+ }
658
+
581
659
  let importMapPromise = initPromise;
582
660
  let firstPolyfillLoad = true;
583
- let acceptingImportMaps = true;
661
+ let legacyAcceptingImportMaps = true;
584
662
 
585
- async function topLevelLoad (url, fetchOpts, source, nativelyLoaded, lastStaticLoadPromise) {
586
- if (!shimMode)
587
- acceptingImportMaps = false;
663
+ async function topLevelLoad(url, fetchOpts, source, nativelyLoaded, lastStaticLoadPromise) {
664
+ legacyAcceptingImportMaps = false;
588
665
  await initPromise;
589
666
  await importMapPromise;
590
667
  if (importHook) await importHook(url, typeof fetchOpts !== 'string' ? fetchOpts : {}, '');
591
668
  // early analysis opt-out - no need to even fetch if we have feature support
592
669
  if (!shimMode && baselinePassthrough) {
593
670
  // for polyfill case, only dynamic import needs a return value here, and dynamic import will never pass nativelyLoaded
594
- if (nativelyLoaded)
595
- return null;
671
+ if (nativelyLoaded) return null;
596
672
  await lastStaticLoadPromise;
597
- return dynamicImport(source ? createBlob(source) : url, { errUrl: url || source });
673
+ return dynamicImport(source ? createBlob(source) : url, {
674
+ errUrl: url || source
675
+ });
598
676
  }
599
677
  const load = getOrCreateLoad(url, fetchOpts, null, source);
600
678
  linkLoad(load, fetchOpts);
@@ -614,8 +692,7 @@
614
692
  }
615
693
  const module = await dynamicImport(!shimMode && !load.n && nativelyLoaded ? load.u : load.b, { errUrl: load.u });
616
694
  // if the top-level load is a shell, run its update function
617
- if (load.s)
618
- (await dynamicImport(load.s)).u$_(module);
695
+ if (load.s) (await dynamicImport(load.s)).u$_(module);
619
696
  if (revokeBlobURLs) revokeObjectURLs(Object.keys(seen));
620
697
  // when tla is supported, this should return the tla promise as an actual handle
621
698
  // so readystate can still correspond to the sync subgraph exec completions
@@ -629,7 +706,7 @@
629
706
  schedule(cleanup);
630
707
  function cleanup() {
631
708
  const batchStartIndex = batch * 100;
632
- if (batchStartIndex > keysLength) return
709
+ if (batchStartIndex > keysLength) return;
633
710
  for (const key of registryKeys.slice(batchStartIndex, batchStartIndex + 100)) {
634
711
  const load = registry[key];
635
712
  if (load) URL.revokeObjectURL(load.b);
@@ -639,19 +716,28 @@
639
716
  }
640
717
  }
641
718
 
642
- function urlJsString (url) {
719
+ function urlJsString(url) {
643
720
  return `'${url.replace(/'/g, "\\'")}'`;
644
721
  }
645
722
 
646
723
  let lastLoad;
647
- function resolveDeps (load, seen) {
648
- if (load.b || !seen[load.u])
649
- return;
724
+ function resolveDeps(load, seen) {
725
+ if (load.b || !seen[load.u]) return;
650
726
  seen[load.u] = 0;
651
727
 
652
728
  for (const { l: dep, s: sourcePhase } of load.d) {
653
- if (!sourcePhase)
654
- resolveDeps(dep, seen);
729
+ if (!sourcePhase) resolveDeps(dep, seen);
730
+ }
731
+
732
+ if (!load.n) load.n = load.d.some(dep => dep.l.n);
733
+ if (!load.N) load.N = load.d.some(dep => dep.l.N);
734
+
735
+ // use native loader whenever possible (n = needs shim) via executable subgraph passthrough
736
+ // so long as the module doesn't use dynamic import or unsupported URL mappings (N = should shim)
737
+ if (!shimMode && !load.n && !load.N) {
738
+ load.b = lastLoad = load.u;
739
+ load.S = undefined;
740
+ return;
655
741
  }
656
742
 
657
743
  const [imports, exports] = load.a;
@@ -664,8 +750,10 @@
664
750
 
665
751
  // once all deps have loaded we can inline the dependency resolution blobs
666
752
  // and define this blob
667
- let lastIndex = 0, depIndex = 0, dynamicImportEndStack = [];
668
- function pushStringTo (originalIndex) {
753
+ let lastIndex = 0,
754
+ depIndex = 0,
755
+ dynamicImportEndStack = [];
756
+ function pushStringTo(originalIndex) {
669
757
  while (dynamicImportEndStack[dynamicImportEndStack.length - 1] < originalIndex) {
670
758
  const dynamicImportEnd = dynamicImportEndStack.pop();
671
759
  resolvedSource += `${source.slice(lastIndex, dynamicImportEnd)}, ${urlJsString(load.r)}`;
@@ -688,20 +776,24 @@
688
776
  }
689
777
  // dependency source replacements
690
778
  else if (dynamicImportIndex === -1) {
691
- let { l: depLoad } = load.d[depIndex++], blobUrl = depLoad.b, cycleShell = !blobUrl;
779
+ let { l: depLoad } = load.d[depIndex++],
780
+ blobUrl = depLoad.b,
781
+ cycleShell = !blobUrl;
692
782
  if (cycleShell) {
693
783
  // circular shell creation
694
784
  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`);
785
+ blobUrl = depLoad.s = createBlob(
786
+ `export function u$_(m){${depLoad.a[1]
787
+ .map(({ s, e }, i) => {
788
+ const q = depLoad.S[s] === '"' || depLoad.S[s] === "'";
789
+ return `e$_${i}=m${q ? `[` : '.'}${depLoad.S.slice(s, e)}${q ? `]` : ''}`;
790
+ })
791
+ .join(',')}}${
792
+ depLoad.a[1].length ? `let ${depLoad.a[1].map((_, i) => `e$_${i}`).join(',')};` : ''
793
+ }export {${depLoad.a[1]
794
+ .map(({ s, e }, i) => `e$_${i} as ${depLoad.S.slice(s, e)}`)
795
+ .join(',')}}\n//# sourceURL=${depLoad.r}?cycle`
796
+ );
705
797
  }
706
798
  }
707
799
 
@@ -734,9 +826,12 @@
734
826
 
735
827
  // support progressive cycle binding updates (try statement avoids tdz errors)
736
828
  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`;
829
+ resolvedSource += `\n;import{u$_}from'${load.s}';try{u$_({${exports
830
+ .filter(e => e.ln)
831
+ .map(({ s, e, ln }) => `${source.slice(s, e)}:${ln}`)
832
+ .join(',')}})}catch(_){};\n`;
738
833
 
739
- function pushSourceURL (commentPrefix, commentStart) {
834
+ function pushSourceURL(commentPrefix, commentStart) {
740
835
  const urlStart = commentStart + commentPrefix.length;
741
836
  const commentEnd = source.indexOf('\n', urlStart);
742
837
  const urlEnd = commentEnd !== -1 ? commentEnd : source.length;
@@ -757,21 +852,23 @@
757
852
  if (sourceMapURLCommentStart < lastIndex) sourceMapURLCommentStart = -1;
758
853
 
759
854
  // sourceURL first / only
760
- if (sourceURLCommentStart !== -1 && (sourceMapURLCommentStart === -1 || sourceMapURLCommentStart > sourceURLCommentStart)) {
855
+ if (
856
+ sourceURLCommentStart !== -1 &&
857
+ (sourceMapURLCommentStart === -1 || sourceMapURLCommentStart > sourceURLCommentStart)
858
+ ) {
761
859
  pushSourceURL(sourceURLCommentPrefix, sourceURLCommentStart);
762
860
  }
763
861
  // sourceMappingURL
764
862
  if (sourceMapURLCommentStart !== -1) {
765
863
  pushSourceURL(sourceMapURLCommentPrefix, sourceMapURLCommentStart);
766
864
  // sourceURL last
767
- if (sourceURLCommentStart !== -1 && (sourceURLCommentStart > sourceMapURLCommentStart))
865
+ if (sourceURLCommentStart !== -1 && sourceURLCommentStart > sourceMapURLCommentStart)
768
866
  pushSourceURL(sourceURLCommentPrefix, sourceURLCommentStart);
769
867
  }
770
868
 
771
869
  pushStringTo(source.length);
772
870
 
773
- if (sourceURLCommentStart === -1)
774
- resolvedSource += sourceURLCommentPrefix + load.r;
871
+ if (sourceURLCommentStart === -1) resolvedSource += sourceURLCommentPrefix + load.r;
775
872
 
776
873
  load.b = lastLoad = createBlob(resolvedSource);
777
874
  load.S = undefined;
@@ -790,29 +887,24 @@
790
887
  // restrict in-flight fetches to a pool of 100
791
888
  let p = [];
792
889
  let c = 0;
793
- function pushFetchPool () {
794
- if (++c > 100)
795
- return new Promise(r => p.push(r));
890
+ function pushFetchPool() {
891
+ if (++c > 100) return new Promise(r => p.push(r));
796
892
  }
797
- function popFetchPool () {
893
+ function popFetchPool() {
798
894
  c--;
799
- if (p.length)
800
- p.shift()();
895
+ if (p.length) p.shift()();
801
896
  }
802
897
 
803
- async function doFetch (url, fetchOpts, parent) {
804
- if (enforceIntegrity && !fetchOpts.integrity)
805
- throw Error(`No integrity for ${url}${fromParent(parent)}.`);
898
+ async function doFetch(url, fetchOpts, parent) {
899
+ if (enforceIntegrity && !fetchOpts.integrity) throw Error(`No integrity for ${url}${fromParent(parent)}.`);
806
900
  const poolQueue = pushFetchPool();
807
901
  if (poolQueue) await poolQueue;
808
902
  try {
809
903
  var res = await fetchHook(url, fetchOpts);
810
- }
811
- catch (e) {
904
+ } catch (e) {
812
905
  e.message = `Unable to fetch ${url}${fromParent(parent)} - see network log for details.\n` + e.message;
813
906
  throw e;
814
- }
815
- finally {
907
+ } finally {
816
908
  popFetchPool();
817
909
  }
818
910
 
@@ -824,17 +916,22 @@
824
916
  return res;
825
917
  }
826
918
 
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);
919
+ async function fetchModule(url, fetchOpts, parent) {
920
+ const mapIntegrity = composedImportMap.integrity[url];
921
+ const res = await doFetch(
922
+ url,
923
+ mapIntegrity && !fetchOpts.integrity ? Object.assign({}, fetchOpts, { integrity: mapIntegrity }) : fetchOpts,
924
+ parent
925
+ );
830
926
  const r = res.url;
831
927
  const contentType = res.headers.get('content-type');
832
- if (jsContentType.test(contentType))
833
- return { r, s: await res.text(), sp: null, t: 'js' };
928
+ if (jsContentType.test(contentType)) return { r, s: await res.text(), sp: null, t: 'js' };
834
929
  else if (wasmContentType.test(contentType)) {
835
930
  const module = await (sourceCache[r] || (sourceCache[r] = WebAssembly.compileStreaming(res)));
836
931
  sourceCache[r] = module;
837
- let s = '', i = 0, importObj = '';
932
+ let s = '',
933
+ i = 0,
934
+ importObj = '';
838
935
  for (const impt of WebAssembly.Module.imports(module)) {
839
936
  const specifier = urlJsString(impt.module);
840
937
  s += `import * as impt${i} from ${specifier};\n`;
@@ -846,19 +943,41 @@
846
943
  s += `export const ${expt.name} = instance.exports['${expt.name}'];\n`;
847
944
  }
848
945
  return { r, s, t: 'wasm' };
849
- }
850
- else if (jsonContentType.test(contentType))
946
+ } else if (jsonContentType.test(contentType))
851
947
  return { r, s: `export default ${await res.text()}`, sp: null, t: 'json' };
852
948
  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.`);
949
+ return {
950
+ r,
951
+ s: `var s=new CSSStyleSheet();s.replaceSync(${JSON.stringify(
952
+ (await res.text()).replace(
953
+ cssUrlRegEx,
954
+ (_match, quotes = '', relUrl1, relUrl2) => `url(${quotes}${resolveUrl(relUrl1 || relUrl2, url)}${quotes})`
955
+ )
956
+ )});export default s;`,
957
+ ss: null,
958
+ t: 'css'
959
+ };
960
+ } else
961
+ throw Error(
962
+ `Unsupported Content-Type "${contentType}" loading ${url}${fromParent(parent)}. Modules must be served with a valid MIME type like application/javascript.`
963
+ );
964
+ }
965
+
966
+ function isUnsupportedType(type) {
967
+ if (
968
+ (type === 'css' && !cssModulesEnabled) ||
969
+ (type === 'json' && !jsonModulesEnabled) ||
970
+ (type === 'wasm' && !wasmModulesEnabled)
971
+ )
972
+ throw featErr(`${t}-modules`);
973
+ return (
974
+ (type === 'css' && !supportsCssType) ||
975
+ (type === 'json' && !supportsJsonType) ||
976
+ (type === 'wasm' && !supportsWasmModules)
977
+ );
859
978
  }
860
979
 
861
- function getOrCreateLoad (url, fetchOpts, parent, source) {
980
+ function getOrCreateLoad(url, fetchOpts, parent, source) {
862
981
  if (source && registry[url]) {
863
982
  let i = 0;
864
983
  while (registry[url + ++i]);
@@ -887,6 +1006,8 @@
887
1006
  s: undefined,
888
1007
  // needsShim
889
1008
  n: false,
1009
+ // shouldShim
1010
+ N: false,
890
1011
  // type
891
1012
  t: null,
892
1013
  // meta
@@ -895,19 +1016,14 @@
895
1016
  load.f = (async () => {
896
1017
  if (!load.S) {
897
1018
  // preload fetch options override fetch options (race)
898
- let t;
899
- ({ r: load.r, s: load.S, t } = await (fetchCache[url] || fetchModule(url, fetchOpts, parent)));
900
- if (t && !shimMode) {
901
- if (t === 'css' && !cssModulesEnabled || t === 'json' && !jsonModulesEnabled || t === 'wasm' && !wasmModulesEnabled)
902
- throw featErr(`${t}-modules`);
903
- if (t === 'css' && !supportsCssAssertions || t === 'json' && !supportsJsonAssertions || t === 'wasm' && !supportsWasmModules)
904
- load.n = true;
1019
+ ({ r: load.r, s: load.S, t: load.t } = await (fetchCache[url] || fetchModule(url, fetchOpts, parent)));
1020
+ if (load.t !== 'js' && !shimMode && isUnsupportedType(load.t)) {
1021
+ load.n = true;
905
1022
  }
906
1023
  }
907
1024
  try {
908
1025
  load.a = parse(load.S, load.u);
909
- }
910
- catch (e) {
1026
+ } catch (e) {
911
1027
  throwError(e);
912
1028
  load.a = [[], [], false];
913
1029
  }
@@ -916,74 +1032,79 @@
916
1032
  return load;
917
1033
  }
918
1034
 
919
- const featErr = feat => Error(`${feat} feature must be enabled via <script type="esms-options">{ "polyfillEnable": ["${feat}"] }<${''}/script>`);
1035
+ const featErr = feat =>
1036
+ Error(
1037
+ `${feat} feature must be enabled via <script type="esms-options">{ "polyfillEnable": ["${feat}"] }<${''}/script>`
1038
+ );
920
1039
 
921
- function linkLoad (load, fetchOpts) {
1040
+ function linkLoad(load, fetchOpts) {
922
1041
  if (load.L) return;
923
1042
  load.L = load.f.then(async () => {
924
1043
  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);
1044
+ load.d = (
1045
+ await Promise.all(
1046
+ load.a[0].map(async ({ n, d, t }) => {
1047
+ const sourcePhase = t >= 4;
1048
+ if (sourcePhase && !sourcePhaseEnabled) throw featErr('source-phase');
1049
+ if (
1050
+ (d >= 0 && !supportsDynamicImport) ||
1051
+ (d === -2 && !supportsImportMeta) ||
1052
+ (sourcePhase && !supportsSourcePhase)
1053
+ )
1054
+ load.n = true;
1055
+ if (d !== -1 || !n) return;
1056
+ const resolved = await resolve(n, load.r || load.u);
1057
+ if (resolved.n) load.n = true;
1058
+ if (d >= 0 || resolved.N) load.N = true;
1059
+ if (d !== -1) return;
1060
+ if (skip && skip(resolved.r) && !sourcePhase) return { l: { b: resolved.r }, s: false };
1061
+ if (childFetchOpts.integrity) childFetchOpts = Object.assign({}, childFetchOpts, { integrity: undefined });
1062
+ const child = { l: getOrCreateLoad(resolved.r, childFetchOpts, load.r, null), s: sourcePhase };
1063
+ if (!child.s) linkLoad(child.l, fetchOpts);
1064
+ // load, sourcePhase
1065
+ return child;
1066
+ })
1067
+ )
1068
+ ).filter(l => l);
945
1069
  });
946
1070
  }
947
1071
 
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);
1072
+ function processScriptsAndPreloads() {
1073
+ for (const link of document.querySelectorAll(shimMode ? 'link[rel=modulepreload-shim]' : 'link[rel=modulepreload]')) {
1074
+ if (!link.ep) processPreload(link);
1075
+ }
1076
+ for (const script of document.querySelectorAll('script[type]')) {
1077
+ if (script.type === 'importmap' + (shimMode ? '-shim' : '')) {
1078
+ if (!script.ep) processImportMap(script);
1079
+ } else if (script.type === 'module' + (shimMode ? '-shim' : '')) {
1080
+ legacyAcceptingImportMaps = false;
1081
+ if (!script.ep) processScript(script);
1082
+ }
1083
+ }
957
1084
  }
958
1085
 
959
- function getFetchOpts (script) {
1086
+ function getFetchOpts(script) {
960
1087
  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';
1088
+ if (script.integrity) fetchOpts.integrity = script.integrity;
1089
+ if (script.referrerPolicy) fetchOpts.referrerPolicy = script.referrerPolicy;
1090
+ if (script.fetchPriority) fetchOpts.priority = script.fetchPriority;
1091
+ if (script.crossOrigin === 'use-credentials') fetchOpts.credentials = 'include';
1092
+ else if (script.crossOrigin === 'anonymous') fetchOpts.credentials = 'omit';
1093
+ else fetchOpts.credentials = 'same-origin';
973
1094
  return fetchOpts;
974
1095
  }
975
1096
 
976
1097
  let lastStaticLoadPromise = Promise.resolve();
977
1098
 
978
1099
  let domContentLoadedCnt = 1;
979
- function domContentLoadedCheck () {
1100
+ function domContentLoadedCheck() {
980
1101
  if (--domContentLoadedCnt === 0 && !noLoadEventRetriggers && (shimMode || !baselinePassthrough)) {
981
1102
  document.dispatchEvent(new Event('DOMContentLoaded'));
982
1103
  }
983
1104
  }
984
1105
  let loadCnt = 1;
985
- function loadCheck () {
986
- if (--loadCnt === 0 && globalLoadEventRetrigger && !noLoadEventRetriggers && (shimMode || !baselinePassthrough)) {
1106
+ function loadCheck() {
1107
+ if (--loadCnt === 0 && !noLoadEventRetriggers && (shimMode || !baselinePassthrough)) {
987
1108
  window.dispatchEvent(new Event('load'));
988
1109
  }
989
1110
  }
@@ -1000,40 +1121,52 @@
1000
1121
  }
1001
1122
 
1002
1123
  let readyStateCompleteCnt = 1;
1003
- function readyStateCompleteCheck () {
1124
+ function readyStateCompleteCheck() {
1004
1125
  if (--readyStateCompleteCnt === 0 && !noLoadEventRetriggers && (shimMode || !baselinePassthrough)) {
1005
1126
  document.dispatchEvent(new Event('readystatechange'));
1006
1127
  }
1007
1128
  }
1008
1129
 
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);
1130
+ const hasNext = script => script.nextSibling || (script.parentNode && hasNext(script.parentNode));
1131
+ const epCheck = (script, ready) =>
1132
+ script.ep ||
1133
+ (!ready && ((!script.src && !script.innerHTML) || !hasNext(script))) ||
1134
+ script.getAttribute('noshim') !== null ||
1135
+ !(script.ep = true);
1011
1136
 
1012
- function processImportMap (script, ready = readyStateCompleteCnt > 0) {
1137
+ function processImportMap(script, ready = readyStateCompleteCnt > 0) {
1013
1138
  if (epCheck(script, ready)) return;
1014
- // we dont currently support multiple, external or dynamic imports maps in polyfill mode to match native
1139
+ // we dont currently support external import maps in polyfill mode to match native
1015
1140
  if (script.src) {
1016
- if (!shimMode)
1017
- return;
1018
- setImportMapSrcOrLazy();
1141
+ if (!shimMode) return;
1142
+ importMapSrc = true;
1019
1143
  }
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;
1144
+ importMapPromise = importMapPromise
1145
+ .then(async () => {
1146
+ composedImportMap = resolveAndComposeImportMap(
1147
+ script.src ? await (await doFetch(script.src, getFetchOpts(script))).json() : JSON.parse(script.innerHTML),
1148
+ script.src || baseUrl,
1149
+ composedImportMap
1150
+ );
1151
+ })
1152
+ .catch(e => {
1153
+ console.log(e);
1154
+ if (e instanceof SyntaxError)
1155
+ e = new Error(`Unable to parse import map ${e.message} in: ${script.src || script.innerHTML}`);
1156
+ throwError(e);
1157
+ });
1158
+ if (!firstImportMap && legacyAcceptingImportMaps) importMapPromise.then(() => (firstImportMap = composedImportMap));
1159
+ if (!legacyAcceptingImportMaps && !multipleImportMaps) {
1160
+ multipleImportMaps = true;
1161
+ if (baselinePassthrough && !supportsMultipleImportMaps) {
1162
+ baselinePassthrough = false;
1163
+ if (hasDocument) attachMutationObserver();
1164
+ }
1033
1165
  }
1166
+ legacyAcceptingImportMaps = false;
1034
1167
  }
1035
1168
 
1036
- function processScript (script, ready = readyStateCompleteCnt > 0) {
1169
+ function processScript(script, ready = readyStateCompleteCnt > 0) {
1037
1170
  if (epCheck(script, ready)) return;
1038
1171
  // does this load block readystate complete
1039
1172
  const isBlockingReadyScript = script.getAttribute('async') === null && readyStateCompleteCnt > 0;
@@ -1043,24 +1176,23 @@
1043
1176
  if (isLoadScript) loadCnt++;
1044
1177
  if (isBlockingReadyScript) readyStateCompleteCnt++;
1045
1178
  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);
1179
+ const loadPromise = topLevelLoad(
1180
+ script.src || baseUrl,
1181
+ getFetchOpts(script),
1182
+ !script.src && script.innerHTML,
1183
+ !shimMode,
1184
+ isBlockingReadyScript && lastStaticLoadPromise
1185
+ ).catch(throwError);
1186
+ if (!noLoadEventRetriggers) loadPromise.then(() => script.dispatchEvent(new Event('load')));
1187
+ if (isBlockingReadyScript) lastStaticLoadPromise = loadPromise.then(readyStateCompleteCheck);
1188
+ if (isDomContentLoadedScript) loadPromise.then(domContentLoadedCheck);
1189
+ if (isLoadScript) loadPromise.then(loadCheck);
1056
1190
  }
1057
1191
 
1058
1192
  const fetchCache = {};
1059
- function processPreload (link) {
1060
- if (link.ep) return;
1193
+ function processPreload(link) {
1061
1194
  link.ep = true;
1062
- if (fetchCache[link.href])
1063
- return;
1195
+ if (fetchCache[link.href]) return;
1064
1196
  fetchCache[link.href] = fetchModule(link.href, getFetchOpts(link));
1065
1197
  }
1066
1198