es-module-shims 2.3.1 → 2.4.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.
- package/README.md +12 -1
- package/dist/es-module-shims.debug.js +142 -131
- package/dist/es-module-shims.js +133 -122
- package/dist/es-module-shims.wasm.js +133 -122
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -30,7 +30,7 @@ Because we are still using the native module loader the edge cases work out comp
|
|
|
30
30
|
Include ES Module Shims with a `async` attribute on the script, then include an import map and module scripts normally:
|
|
31
31
|
|
|
32
32
|
```html
|
|
33
|
-
<script async src="https://ga.jspm.io/npm:es-module-shims@2.
|
|
33
|
+
<script async src="https://ga.jspm.io/npm:es-module-shims@2.4.1/dist/es-module-shims.js"></script>
|
|
34
34
|
|
|
35
35
|
<!-- https://generator.jspm.io/#U2NhYGBkDM0rySzJSU1hKEpNTC5xMLTQM9Az0C1K1jMAAKFS5w0gAA -->
|
|
36
36
|
<script type="importmap">
|
|
@@ -701,6 +701,7 @@ Provide a `esmsInitOptions` on the global scope before `es-module-shims` is load
|
|
|
701
701
|
* [revokeBlobURLs](#revoke-blob-urls)
|
|
702
702
|
* [shimMode](#shim-mode-option)
|
|
703
703
|
* [skip](#skip)
|
|
704
|
+
* [version](#version)
|
|
704
705
|
|
|
705
706
|
```html
|
|
706
707
|
<script>
|
|
@@ -739,6 +740,8 @@ window.esmsInitOptions = {
|
|
|
739
740
|
meta: (meta, url) => void // default is noop
|
|
740
741
|
// Hook top-level imports
|
|
741
742
|
onimport: (url, options, parentUrl, source) => void // default is noop
|
|
743
|
+
// Ensure only the exact provided version of es-module-shims registered
|
|
744
|
+
version: '2.4.0' // default is empty
|
|
742
745
|
}
|
|
743
746
|
</script>
|
|
744
747
|
<script async src="es-module-shims.js"></script>
|
|
@@ -888,6 +891,14 @@ When passing an array, relative URLs or paths ending in `/` can be provided:
|
|
|
888
891
|
<script async src="es-module-shims.js"></script>
|
|
889
892
|
```
|
|
890
893
|
|
|
894
|
+
### Version
|
|
895
|
+
|
|
896
|
+
When there is a risk of multiple versions of ES Module Shims on the same page, deconflicting is managed by logic that will opt-out of initializing ES Module Shims if it has already been initialized. In addition, ES Module Shims itself is frozen and locked from further mutations.
|
|
897
|
+
|
|
898
|
+
To better support cooporative multi-version cases, as of version 2.4.0, we support a `version` option, which when set will skip initialization if the current version of ES Module Shims does not match this exact expected version.
|
|
899
|
+
|
|
900
|
+
This way, any other old versions after version 2.4.0 running on the page can effectively be turned off, ensuring only the defined version of the polyfill initiates the polyfill.
|
|
901
|
+
|
|
891
902
|
### Revoke Blob URLs
|
|
892
903
|
|
|
893
904
|
When polyfilling the missing features `es-module-shims` would create in-memory blobs using `URL.createObjectURL()` for each processed module.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** ES Module Shims 2.
|
|
1
|
+
/** ES Module Shims @version 2.4.1 */
|
|
2
2
|
(function (exports) {
|
|
3
3
|
|
|
4
4
|
let invalidate;
|
|
@@ -162,13 +162,6 @@
|
|
|
162
162
|
];
|
|
163
163
|
};
|
|
164
164
|
|
|
165
|
-
if (self.importShim) {
|
|
166
|
-
console.info(
|
|
167
|
-
`es-module-shims: skipping initialization as importShim was already registered by another polyfill instance`
|
|
168
|
-
);
|
|
169
|
-
return;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
165
|
const hasDocument = typeof document !== 'undefined';
|
|
173
166
|
|
|
174
167
|
const noop = () => {};
|
|
@@ -181,11 +174,24 @@
|
|
|
181
174
|
|
|
182
175
|
const dynamicImport = (u, errUrl) => import(u);
|
|
183
176
|
|
|
177
|
+
const defineValue = (obj, prop, value) =>
|
|
178
|
+
Object.defineProperty(obj, prop, { writable: false, configurable: false, value });
|
|
179
|
+
|
|
184
180
|
const optionsScript = hasDocument ? document.querySelector('script[type=esms-options]') : undefined;
|
|
185
181
|
|
|
186
182
|
const esmsInitOptions = optionsScript ? JSON.parse(optionsScript.innerHTML) : {};
|
|
187
183
|
Object.assign(esmsInitOptions, self.esmsInitOptions || {});
|
|
188
184
|
|
|
185
|
+
const version = "2.4.1";
|
|
186
|
+
|
|
187
|
+
const r$1 = esmsInitOptions.version;
|
|
188
|
+
if (self.importShim || (r$1 && r$1 !== version)) {
|
|
189
|
+
console.info(
|
|
190
|
+
`es-module-shims: skipping initialization as ${r$1 ? `configured for ${r$1}` : 'another instance has already registered'}`
|
|
191
|
+
);
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
|
|
189
195
|
// shim mode is determined on initialization, no late shim mode
|
|
190
196
|
const shimMode =
|
|
191
197
|
esmsInitOptions.shimMode ||
|
|
@@ -379,9 +385,9 @@
|
|
|
379
385
|
|
|
380
386
|
const resolveAndComposeImportMap = (json, baseUrl, parentMap) => {
|
|
381
387
|
const outMap = {
|
|
382
|
-
imports:
|
|
383
|
-
scopes:
|
|
384
|
-
integrity:
|
|
388
|
+
imports: { ...parentMap.imports },
|
|
389
|
+
scopes: { ...parentMap.scopes },
|
|
390
|
+
integrity: { ...parentMap.integrity }
|
|
385
391
|
};
|
|
386
392
|
|
|
387
393
|
if (json.imports) resolveAndComposePackages(json.imports, outMap.imports, baseUrl, parentMap);
|
|
@@ -470,120 +476,121 @@
|
|
|
470
476
|
}
|
|
471
477
|
};
|
|
472
478
|
|
|
473
|
-
// support browsers without dynamic import support (eg Firefox 6x)
|
|
474
|
-
let supportsJsonType = false;
|
|
475
|
-
let supportsCssType = false;
|
|
476
|
-
|
|
477
|
-
const supports = hasDocument && HTMLScriptElement.supports;
|
|
478
|
-
|
|
479
|
-
let supportsImportMaps = supports && supports.name === 'supports' && supports('importmap');
|
|
480
|
-
let supportsWasmInstancePhase = false;
|
|
481
|
-
let supportsWasmSourcePhase = false;
|
|
482
|
-
let supportsMultipleImportMaps = false;
|
|
483
|
-
|
|
484
|
-
const wasmBytes = [0, 97, 115, 109, 1, 0, 0, 0];
|
|
485
|
-
|
|
486
|
-
let featureDetectionPromise = (async function () {
|
|
487
|
-
if (!hasDocument)
|
|
488
|
-
return Promise.all([
|
|
489
|
-
import(createBlob(`import"${createBlob('{}', 'text/json')}"with{type:"json"}`)).then(
|
|
490
|
-
() => (
|
|
491
|
-
(supportsJsonType = true),
|
|
492
|
-
import(createBlob(`import"${createBlob('', 'text/css')}"with{type:"css"}`)).then(
|
|
493
|
-
() => (supportsCssType = true),
|
|
494
|
-
noop
|
|
495
|
-
)
|
|
496
|
-
),
|
|
497
|
-
noop
|
|
498
|
-
),
|
|
499
|
-
wasmInstancePhaseEnabled &&
|
|
500
|
-
import(createBlob(`import"${createBlob(new Uint8Array(wasmBytes), 'application/wasm')}"`)).then(
|
|
501
|
-
() => (supportsWasmInstancePhase = true),
|
|
502
|
-
noop
|
|
503
|
-
),
|
|
504
|
-
wasmSourcePhaseEnabled &&
|
|
505
|
-
import(createBlob(`import source x from"${createBlob(new Uint8Array(wasmBytes), 'application/wasm')}"`)).then(
|
|
506
|
-
() => (supportsWasmSourcePhase = true),
|
|
507
|
-
noop
|
|
508
|
-
)
|
|
509
|
-
]);
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
iframe
|
|
514
|
-
iframe.
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
//
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
//
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
// setting
|
|
574
|
-
//
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
if
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
479
|
+
// support browsers without dynamic import support (eg Firefox 6x)
|
|
480
|
+
let supportsJsonType = false;
|
|
481
|
+
let supportsCssType = false;
|
|
482
|
+
|
|
483
|
+
const supports = hasDocument && HTMLScriptElement.supports;
|
|
484
|
+
|
|
485
|
+
let supportsImportMaps = supports && supports.name === 'supports' && supports('importmap');
|
|
486
|
+
let supportsWasmInstancePhase = false;
|
|
487
|
+
let supportsWasmSourcePhase = false;
|
|
488
|
+
let supportsMultipleImportMaps = false;
|
|
489
|
+
|
|
490
|
+
const wasmBytes = [0, 97, 115, 109, 1, 0, 0, 0];
|
|
491
|
+
|
|
492
|
+
let featureDetectionPromise = (async function () {
|
|
493
|
+
if (!hasDocument)
|
|
494
|
+
return Promise.all([
|
|
495
|
+
import(createBlob(`import"${createBlob('{}', 'text/json')}"with{type:"json"}`)).then(
|
|
496
|
+
() => (
|
|
497
|
+
(supportsJsonType = true),
|
|
498
|
+
import(createBlob(`import"${createBlob('', 'text/css')}"with{type:"css"}`)).then(
|
|
499
|
+
() => (supportsCssType = true),
|
|
500
|
+
noop
|
|
501
|
+
)
|
|
502
|
+
),
|
|
503
|
+
noop
|
|
504
|
+
),
|
|
505
|
+
wasmInstancePhaseEnabled &&
|
|
506
|
+
import(createBlob(`import"${createBlob(new Uint8Array(wasmBytes), 'application/wasm')}"`)).then(
|
|
507
|
+
() => (supportsWasmInstancePhase = true),
|
|
508
|
+
noop
|
|
509
|
+
),
|
|
510
|
+
wasmSourcePhaseEnabled &&
|
|
511
|
+
import(createBlob(`import source x from"${createBlob(new Uint8Array(wasmBytes), 'application/wasm')}"`)).then(
|
|
512
|
+
() => (supportsWasmSourcePhase = true),
|
|
513
|
+
noop
|
|
514
|
+
)
|
|
515
|
+
]);
|
|
516
|
+
|
|
517
|
+
const msgTag = `s${version}`;
|
|
518
|
+
return new Promise(resolve => {
|
|
519
|
+
const iframe = document.createElement('iframe');
|
|
520
|
+
iframe.style.display = 'none';
|
|
521
|
+
iframe.setAttribute('nonce', nonce);
|
|
522
|
+
function cb({ data }) {
|
|
523
|
+
const isFeatureDetectionMessage = Array.isArray(data) && data[0] === msgTag;
|
|
524
|
+
if (!isFeatureDetectionMessage) return;
|
|
525
|
+
[
|
|
526
|
+
,
|
|
527
|
+
supportsImportMaps,
|
|
528
|
+
supportsMultipleImportMaps,
|
|
529
|
+
supportsJsonType,
|
|
530
|
+
supportsCssType,
|
|
531
|
+
supportsWasmSourcePhase,
|
|
532
|
+
supportsWasmInstancePhase
|
|
533
|
+
] = data;
|
|
534
|
+
resolve();
|
|
535
|
+
document.head.removeChild(iframe);
|
|
536
|
+
window.removeEventListener('message', cb, false);
|
|
537
|
+
}
|
|
538
|
+
window.addEventListener('message', cb, false);
|
|
539
|
+
|
|
540
|
+
// Feature checking with careful avoidance of unnecessary work - all gated on initial import map supports check. CSS gates on JSON feature check, Wasm instance phase gates on wasm source phase check.
|
|
541
|
+
const importMapTest = `<script nonce=${nonce || ''}>b=(s,type='text/javascript')=>URL.createObjectURL(new Blob([s],{type}));c=u=>import(u).then(()=>true,()=>false);i=innerText=>document.head.appendChild(Object.assign(document.createElement('script'),{type:'importmap',nonce:"${nonce}",innerText}));i(\`{"imports":{"x":"\${b('')}"}}\`);i(\`{"imports":{"y":"\${b('')}"}}\`);cm=${
|
|
542
|
+
supportsImportMaps ? `c(b(\`import"\${b('{}','text/json')}"with{type:"json"}\`))` : 'false'
|
|
543
|
+
};sp=${
|
|
544
|
+
supportsImportMaps && wasmSourcePhaseEnabled ?
|
|
545
|
+
`c(b(\`import source x from "\${b(new Uint8Array(${JSON.stringify(wasmBytes)}),'application/wasm')\}"\`))`
|
|
546
|
+
: 'false'
|
|
547
|
+
};Promise.all([${supportsImportMaps ? 'true' : "c('x')"},${supportsImportMaps ? "c('y')" : false},cm,${
|
|
548
|
+
supportsImportMaps ? `cm.then(s=>s?c(b(\`import"\${b('','text/css')\}"with{type:"css"}\`)):false)` : 'false'
|
|
549
|
+
},sp,${
|
|
550
|
+
supportsImportMaps && wasmInstancePhaseEnabled ?
|
|
551
|
+
`${wasmSourcePhaseEnabled ? 'sp.then(s=>s?' : ''}c(b(\`import"\${b(new Uint8Array(${JSON.stringify(wasmBytes)}),'application/wasm')\}"\`))${wasmSourcePhaseEnabled ? ':false)' : ''}`
|
|
552
|
+
: 'false'
|
|
553
|
+
}]).then(a=>parent.postMessage(['${msgTag}'].concat(a),'*'))<${''}/script>`;
|
|
554
|
+
|
|
555
|
+
// Safari will call onload eagerly on head injection, but we don't want the Wechat
|
|
556
|
+
// path to trigger before setting srcdoc, therefore we track the timing
|
|
557
|
+
let readyForOnload = false,
|
|
558
|
+
onloadCalledWhileNotReady = false;
|
|
559
|
+
function doOnload() {
|
|
560
|
+
if (!readyForOnload) {
|
|
561
|
+
onloadCalledWhileNotReady = true;
|
|
562
|
+
return;
|
|
563
|
+
}
|
|
564
|
+
// WeChat browser doesn't support setting srcdoc scripts
|
|
565
|
+
// But iframe sandboxes don't support contentDocument so we do this as a fallback
|
|
566
|
+
const doc = iframe.contentDocument;
|
|
567
|
+
if (doc && doc.head.childNodes.length === 0) {
|
|
568
|
+
const s = doc.createElement('script');
|
|
569
|
+
if (nonce) s.setAttribute('nonce', nonce);
|
|
570
|
+
s.innerHTML = importMapTest.slice(15 + (nonce ? nonce.length : 0), -9);
|
|
571
|
+
doc.head.appendChild(s);
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
iframe.onload = doOnload;
|
|
576
|
+
// WeChat browser requires append before setting srcdoc
|
|
577
|
+
document.head.appendChild(iframe);
|
|
578
|
+
|
|
579
|
+
// setting srcdoc is not supported in React native webviews on iOS
|
|
580
|
+
// setting src to a blob URL results in a navigation event in webviews
|
|
581
|
+
// document.write gives usability warnings
|
|
582
|
+
readyForOnload = true;
|
|
583
|
+
if ('srcdoc' in iframe) iframe.srcdoc = importMapTest;
|
|
584
|
+
else iframe.contentDocument.write(importMapTest);
|
|
585
|
+
// retrigger onload for Safari only if necessary
|
|
586
|
+
if (onloadCalledWhileNotReady) doOnload();
|
|
587
|
+
});
|
|
588
|
+
})();
|
|
589
|
+
|
|
590
|
+
featureDetectionPromise = featureDetectionPromise.then(() => {
|
|
591
|
+
console.info(
|
|
592
|
+
`es-module-shims: detected native support - module types: (${[...(supportsJsonType ? ['json'] : []), ...(supportsCssType ? ['css'] : []), ...(supportsWasmInstancePhase ? ['wasm'] : [])].join(', ')}), ${supportsWasmSourcePhase ? 'source phase' : 'no source phase'}, ${supportsMultipleImportMaps ? '' : 'no '}multiple import maps, ${supportsImportMaps ? '' : 'no '}import maps`
|
|
593
|
+
);
|
|
587
594
|
});
|
|
588
595
|
|
|
589
596
|
/* es-module-lexer 1.7.0 */
|
|
@@ -673,8 +680,6 @@
|
|
|
673
680
|
|
|
674
681
|
if (hotReload) importShim$1.hotReload = hotReload$1;
|
|
675
682
|
|
|
676
|
-
self.importShim = importShim$1;
|
|
677
|
-
|
|
678
683
|
const defaultResolve = (id, parentUrl) => {
|
|
679
684
|
return (
|
|
680
685
|
resolveImportMap(composedImportMap, resolveIfNotPlainOrUrl(id, parentUrl) || id, parentUrl) ||
|
|
@@ -696,12 +701,19 @@
|
|
|
696
701
|
if (!shimMode) throw new Error('Unsupported in polyfill mode.');
|
|
697
702
|
composedImportMap = resolveAndComposeImportMap(importMapIn, baseUrl, composedImportMap);
|
|
698
703
|
};
|
|
704
|
+
importShim$1.version = version;
|
|
699
705
|
|
|
700
706
|
const registry = (importShim$1._r = {});
|
|
701
707
|
// Wasm caches
|
|
702
708
|
const sourceCache = (importShim$1._s = {});
|
|
703
709
|
(importShim$1._i = new WeakMap());
|
|
704
710
|
|
|
711
|
+
// Ensure this version is the only version
|
|
712
|
+
defineValue(self, 'importShim', Object.freeze(importShim$1));
|
|
713
|
+
const shimModeOptions = { ...esmsInitOptions, shimMode: true };
|
|
714
|
+
if (optionsScript) optionsScript.innerHTML = JSON.stringify(shimModeOptions);
|
|
715
|
+
self.esmsInitOptions = shimModeOptions;
|
|
716
|
+
|
|
705
717
|
const loadAll = async (load, seen) => {
|
|
706
718
|
seen[load.u] = 1;
|
|
707
719
|
await load.L;
|
|
@@ -735,8 +747,7 @@
|
|
|
735
747
|
if (!shimMode && typeof WebAssembly !== 'undefined') {
|
|
736
748
|
if (wasmSourcePhaseEnabled && !Object.getPrototypeOf(WebAssembly.Module).name) {
|
|
737
749
|
const s = Symbol();
|
|
738
|
-
const brand = m =>
|
|
739
|
-
Object.defineProperty(m, s, { writable: false, configurable: false, value: 'WebAssembly.Module' });
|
|
750
|
+
const brand = m => defineValue(m, s, 'WebAssembly.Module');
|
|
740
751
|
class AbstractModuleSource {
|
|
741
752
|
get [Symbol.toStringTag]() {
|
|
742
753
|
if (this[s]) return this[s];
|
|
@@ -1098,7 +1109,7 @@
|
|
|
1098
1109
|
const mapIntegrity = composedImportMap.integrity[url];
|
|
1099
1110
|
const res = await doFetch(
|
|
1100
1111
|
url,
|
|
1101
|
-
mapIntegrity && !fetchOpts.integrity ?
|
|
1112
|
+
mapIntegrity && !fetchOpts.integrity ? { ...fetchOpts, integrity: mapIntegrity } : fetchOpts,
|
|
1102
1113
|
parent
|
|
1103
1114
|
);
|
|
1104
1115
|
const r = res.url;
|
|
@@ -1253,7 +1264,7 @@
|
|
|
1253
1264
|
if (d >= 0 || resolved.N) load.N = true;
|
|
1254
1265
|
if (d !== -1) return;
|
|
1255
1266
|
if (skip && skip(resolved.r) && !sourcePhase) return { l: { b: resolved.r }, s: false };
|
|
1256
|
-
if (childFetchOpts.integrity) childFetchOpts =
|
|
1267
|
+
if (childFetchOpts.integrity) childFetchOpts = { ...childFetchOpts, integrity: undefined };
|
|
1257
1268
|
const child = { l: getOrCreateLoad(resolved.r, childFetchOpts, load.r, source), s: sourcePhase };
|
|
1258
1269
|
// assertion case -> inline the CSS / JSON URL directly
|
|
1259
1270
|
if (source === '') child.l.b = child.l.u;
|
package/dist/es-module-shims.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** ES Module Shims 2.
|
|
1
|
+
/** ES Module Shims @version 2.4.1 */
|
|
2
2
|
(function (exports) {
|
|
3
3
|
|
|
4
4
|
let invalidate;
|
|
@@ -161,10 +161,6 @@
|
|
|
161
161
|
];
|
|
162
162
|
};
|
|
163
163
|
|
|
164
|
-
if (self.importShim) {
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
164
|
const hasDocument = typeof document !== 'undefined';
|
|
169
165
|
|
|
170
166
|
const noop = () => {};
|
|
@@ -177,11 +173,21 @@
|
|
|
177
173
|
|
|
178
174
|
const dynamicImport = (u, errUrl) => import(u);
|
|
179
175
|
|
|
176
|
+
const defineValue = (obj, prop, value) =>
|
|
177
|
+
Object.defineProperty(obj, prop, { writable: false, configurable: false, value });
|
|
178
|
+
|
|
180
179
|
const optionsScript = hasDocument ? document.querySelector('script[type=esms-options]') : undefined;
|
|
181
180
|
|
|
182
181
|
const esmsInitOptions = optionsScript ? JSON.parse(optionsScript.innerHTML) : {};
|
|
183
182
|
Object.assign(esmsInitOptions, self.esmsInitOptions || {});
|
|
184
183
|
|
|
184
|
+
const version = "2.4.1";
|
|
185
|
+
|
|
186
|
+
const r$1 = esmsInitOptions.version;
|
|
187
|
+
if (self.importShim || (r$1 && r$1 !== version)) {
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
|
|
185
191
|
// shim mode is determined on initialization, no late shim mode
|
|
186
192
|
const shimMode =
|
|
187
193
|
esmsInitOptions.shimMode ||
|
|
@@ -375,9 +381,9 @@
|
|
|
375
381
|
|
|
376
382
|
const resolveAndComposeImportMap = (json, baseUrl, parentMap) => {
|
|
377
383
|
const outMap = {
|
|
378
|
-
imports:
|
|
379
|
-
scopes:
|
|
380
|
-
integrity:
|
|
384
|
+
imports: { ...parentMap.imports },
|
|
385
|
+
scopes: { ...parentMap.scopes },
|
|
386
|
+
integrity: { ...parentMap.integrity }
|
|
381
387
|
};
|
|
382
388
|
|
|
383
389
|
if (json.imports) resolveAndComposePackages(json.imports, outMap.imports, baseUrl, parentMap);
|
|
@@ -466,114 +472,115 @@
|
|
|
466
472
|
}
|
|
467
473
|
};
|
|
468
474
|
|
|
469
|
-
// support browsers without dynamic import support (eg Firefox 6x)
|
|
470
|
-
let supportsJsonType = false;
|
|
471
|
-
let supportsCssType = false;
|
|
472
|
-
|
|
473
|
-
const supports = hasDocument && HTMLScriptElement.supports;
|
|
474
|
-
|
|
475
|
-
let supportsImportMaps = supports && supports.name === 'supports' && supports('importmap');
|
|
476
|
-
let supportsWasmInstancePhase = false;
|
|
477
|
-
let supportsWasmSourcePhase = false;
|
|
478
|
-
let supportsMultipleImportMaps = false;
|
|
479
|
-
|
|
480
|
-
const wasmBytes = [0, 97, 115, 109, 1, 0, 0, 0];
|
|
481
|
-
|
|
482
|
-
let featureDetectionPromise = (async function () {
|
|
483
|
-
if (!hasDocument)
|
|
484
|
-
return Promise.all([
|
|
485
|
-
import(createBlob(`import"${createBlob('{}', 'text/json')}"with{type:"json"}`)).then(
|
|
486
|
-
() => (
|
|
487
|
-
(supportsJsonType = true),
|
|
488
|
-
import(createBlob(`import"${createBlob('', 'text/css')}"with{type:"css"}`)).then(
|
|
489
|
-
() => (supportsCssType = true),
|
|
490
|
-
noop
|
|
491
|
-
)
|
|
492
|
-
),
|
|
493
|
-
noop
|
|
494
|
-
),
|
|
495
|
-
wasmInstancePhaseEnabled &&
|
|
496
|
-
import(createBlob(`import"${createBlob(new Uint8Array(wasmBytes), 'application/wasm')}"`)).then(
|
|
497
|
-
() => (supportsWasmInstancePhase = true),
|
|
498
|
-
noop
|
|
499
|
-
),
|
|
500
|
-
wasmSourcePhaseEnabled &&
|
|
501
|
-
import(createBlob(`import source x from"${createBlob(new Uint8Array(wasmBytes), 'application/wasm')}"`)).then(
|
|
502
|
-
() => (supportsWasmSourcePhase = true),
|
|
503
|
-
noop
|
|
504
|
-
)
|
|
505
|
-
]);
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
iframe
|
|
510
|
-
iframe.
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
//
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
//
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
// setting
|
|
570
|
-
//
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
if
|
|
576
|
-
|
|
475
|
+
// support browsers without dynamic import support (eg Firefox 6x)
|
|
476
|
+
let supportsJsonType = false;
|
|
477
|
+
let supportsCssType = false;
|
|
478
|
+
|
|
479
|
+
const supports = hasDocument && HTMLScriptElement.supports;
|
|
480
|
+
|
|
481
|
+
let supportsImportMaps = supports && supports.name === 'supports' && supports('importmap');
|
|
482
|
+
let supportsWasmInstancePhase = false;
|
|
483
|
+
let supportsWasmSourcePhase = false;
|
|
484
|
+
let supportsMultipleImportMaps = false;
|
|
485
|
+
|
|
486
|
+
const wasmBytes = [0, 97, 115, 109, 1, 0, 0, 0];
|
|
487
|
+
|
|
488
|
+
let featureDetectionPromise = (async function () {
|
|
489
|
+
if (!hasDocument)
|
|
490
|
+
return Promise.all([
|
|
491
|
+
import(createBlob(`import"${createBlob('{}', 'text/json')}"with{type:"json"}`)).then(
|
|
492
|
+
() => (
|
|
493
|
+
(supportsJsonType = true),
|
|
494
|
+
import(createBlob(`import"${createBlob('', 'text/css')}"with{type:"css"}`)).then(
|
|
495
|
+
() => (supportsCssType = true),
|
|
496
|
+
noop
|
|
497
|
+
)
|
|
498
|
+
),
|
|
499
|
+
noop
|
|
500
|
+
),
|
|
501
|
+
wasmInstancePhaseEnabled &&
|
|
502
|
+
import(createBlob(`import"${createBlob(new Uint8Array(wasmBytes), 'application/wasm')}"`)).then(
|
|
503
|
+
() => (supportsWasmInstancePhase = true),
|
|
504
|
+
noop
|
|
505
|
+
),
|
|
506
|
+
wasmSourcePhaseEnabled &&
|
|
507
|
+
import(createBlob(`import source x from"${createBlob(new Uint8Array(wasmBytes), 'application/wasm')}"`)).then(
|
|
508
|
+
() => (supportsWasmSourcePhase = true),
|
|
509
|
+
noop
|
|
510
|
+
)
|
|
511
|
+
]);
|
|
512
|
+
|
|
513
|
+
const msgTag = `s${version}`;
|
|
514
|
+
return new Promise(resolve => {
|
|
515
|
+
const iframe = document.createElement('iframe');
|
|
516
|
+
iframe.style.display = 'none';
|
|
517
|
+
iframe.setAttribute('nonce', nonce);
|
|
518
|
+
function cb({ data }) {
|
|
519
|
+
const isFeatureDetectionMessage = Array.isArray(data) && data[0] === msgTag;
|
|
520
|
+
if (!isFeatureDetectionMessage) return;
|
|
521
|
+
[
|
|
522
|
+
,
|
|
523
|
+
supportsImportMaps,
|
|
524
|
+
supportsMultipleImportMaps,
|
|
525
|
+
supportsJsonType,
|
|
526
|
+
supportsCssType,
|
|
527
|
+
supportsWasmSourcePhase,
|
|
528
|
+
supportsWasmInstancePhase
|
|
529
|
+
] = data;
|
|
530
|
+
resolve();
|
|
531
|
+
document.head.removeChild(iframe);
|
|
532
|
+
window.removeEventListener('message', cb, false);
|
|
533
|
+
}
|
|
534
|
+
window.addEventListener('message', cb, false);
|
|
535
|
+
|
|
536
|
+
// Feature checking with careful avoidance of unnecessary work - all gated on initial import map supports check. CSS gates on JSON feature check, Wasm instance phase gates on wasm source phase check.
|
|
537
|
+
const importMapTest = `<script nonce=${nonce || ''}>b=(s,type='text/javascript')=>URL.createObjectURL(new Blob([s],{type}));c=u=>import(u).then(()=>true,()=>false);i=innerText=>document.head.appendChild(Object.assign(document.createElement('script'),{type:'importmap',nonce:"${nonce}",innerText}));i(\`{"imports":{"x":"\${b('')}"}}\`);i(\`{"imports":{"y":"\${b('')}"}}\`);cm=${
|
|
538
|
+
supportsImportMaps ? `c(b(\`import"\${b('{}','text/json')}"with{type:"json"}\`))` : 'false'
|
|
539
|
+
};sp=${
|
|
540
|
+
supportsImportMaps && wasmSourcePhaseEnabled ?
|
|
541
|
+
`c(b(\`import source x from "\${b(new Uint8Array(${JSON.stringify(wasmBytes)}),'application/wasm')\}"\`))`
|
|
542
|
+
: 'false'
|
|
543
|
+
};Promise.all([${supportsImportMaps ? 'true' : "c('x')"},${supportsImportMaps ? "c('y')" : false},cm,${
|
|
544
|
+
supportsImportMaps ? `cm.then(s=>s?c(b(\`import"\${b('','text/css')\}"with{type:"css"}\`)):false)` : 'false'
|
|
545
|
+
},sp,${
|
|
546
|
+
supportsImportMaps && wasmInstancePhaseEnabled ?
|
|
547
|
+
`${wasmSourcePhaseEnabled ? 'sp.then(s=>s?' : ''}c(b(\`import"\${b(new Uint8Array(${JSON.stringify(wasmBytes)}),'application/wasm')\}"\`))${wasmSourcePhaseEnabled ? ':false)' : ''}`
|
|
548
|
+
: 'false'
|
|
549
|
+
}]).then(a=>parent.postMessage(['${msgTag}'].concat(a),'*'))<${''}/script>`;
|
|
550
|
+
|
|
551
|
+
// Safari will call onload eagerly on head injection, but we don't want the Wechat
|
|
552
|
+
// path to trigger before setting srcdoc, therefore we track the timing
|
|
553
|
+
let readyForOnload = false,
|
|
554
|
+
onloadCalledWhileNotReady = false;
|
|
555
|
+
function doOnload() {
|
|
556
|
+
if (!readyForOnload) {
|
|
557
|
+
onloadCalledWhileNotReady = true;
|
|
558
|
+
return;
|
|
559
|
+
}
|
|
560
|
+
// WeChat browser doesn't support setting srcdoc scripts
|
|
561
|
+
// But iframe sandboxes don't support contentDocument so we do this as a fallback
|
|
562
|
+
const doc = iframe.contentDocument;
|
|
563
|
+
if (doc && doc.head.childNodes.length === 0) {
|
|
564
|
+
const s = doc.createElement('script');
|
|
565
|
+
if (nonce) s.setAttribute('nonce', nonce);
|
|
566
|
+
s.innerHTML = importMapTest.slice(15 + (nonce ? nonce.length : 0), -9);
|
|
567
|
+
doc.head.appendChild(s);
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
iframe.onload = doOnload;
|
|
572
|
+
// WeChat browser requires append before setting srcdoc
|
|
573
|
+
document.head.appendChild(iframe);
|
|
574
|
+
|
|
575
|
+
// setting srcdoc is not supported in React native webviews on iOS
|
|
576
|
+
// setting src to a blob URL results in a navigation event in webviews
|
|
577
|
+
// document.write gives usability warnings
|
|
578
|
+
readyForOnload = true;
|
|
579
|
+
if ('srcdoc' in iframe) iframe.srcdoc = importMapTest;
|
|
580
|
+
else iframe.contentDocument.write(importMapTest);
|
|
581
|
+
// retrigger onload for Safari only if necessary
|
|
582
|
+
if (onloadCalledWhileNotReady) doOnload();
|
|
583
|
+
});
|
|
577
584
|
})();
|
|
578
585
|
|
|
579
586
|
/* es-module-lexer 1.7.0 */
|
|
@@ -661,8 +668,6 @@
|
|
|
661
668
|
|
|
662
669
|
if (hotReload) importShim$1.hotReload = hotReload$1;
|
|
663
670
|
|
|
664
|
-
self.importShim = importShim$1;
|
|
665
|
-
|
|
666
671
|
const defaultResolve = (id, parentUrl) => {
|
|
667
672
|
return (
|
|
668
673
|
resolveImportMap(composedImportMap, resolveIfNotPlainOrUrl(id, parentUrl) || id, parentUrl) ||
|
|
@@ -684,12 +689,19 @@
|
|
|
684
689
|
if (!shimMode) throw new Error('Unsupported in polyfill mode.');
|
|
685
690
|
composedImportMap = resolveAndComposeImportMap(importMapIn, baseUrl, composedImportMap);
|
|
686
691
|
};
|
|
692
|
+
importShim$1.version = version;
|
|
687
693
|
|
|
688
694
|
const registry = (importShim$1._r = {});
|
|
689
695
|
// Wasm caches
|
|
690
696
|
const sourceCache = (importShim$1._s = {});
|
|
691
697
|
(importShim$1._i = new WeakMap());
|
|
692
698
|
|
|
699
|
+
// Ensure this version is the only version
|
|
700
|
+
defineValue(self, 'importShim', Object.freeze(importShim$1));
|
|
701
|
+
const shimModeOptions = { ...esmsInitOptions, shimMode: true };
|
|
702
|
+
if (optionsScript) optionsScript.innerHTML = JSON.stringify(shimModeOptions);
|
|
703
|
+
self.esmsInitOptions = shimModeOptions;
|
|
704
|
+
|
|
693
705
|
const loadAll = async (load, seen) => {
|
|
694
706
|
seen[load.u] = 1;
|
|
695
707
|
await load.L;
|
|
@@ -723,8 +735,7 @@
|
|
|
723
735
|
if (!shimMode && typeof WebAssembly !== 'undefined') {
|
|
724
736
|
if (wasmSourcePhaseEnabled && !Object.getPrototypeOf(WebAssembly.Module).name) {
|
|
725
737
|
const s = Symbol();
|
|
726
|
-
const brand = m =>
|
|
727
|
-
Object.defineProperty(m, s, { writable: false, configurable: false, value: 'WebAssembly.Module' });
|
|
738
|
+
const brand = m => defineValue(m, s, 'WebAssembly.Module');
|
|
728
739
|
class AbstractModuleSource {
|
|
729
740
|
get [Symbol.toStringTag]() {
|
|
730
741
|
if (this[s]) return this[s];
|
|
@@ -1080,7 +1091,7 @@
|
|
|
1080
1091
|
const mapIntegrity = composedImportMap.integrity[url];
|
|
1081
1092
|
const res = await doFetch(
|
|
1082
1093
|
url,
|
|
1083
|
-
mapIntegrity && !fetchOpts.integrity ?
|
|
1094
|
+
mapIntegrity && !fetchOpts.integrity ? { ...fetchOpts, integrity: mapIntegrity } : fetchOpts,
|
|
1084
1095
|
parent
|
|
1085
1096
|
);
|
|
1086
1097
|
const r = res.url;
|
|
@@ -1235,7 +1246,7 @@
|
|
|
1235
1246
|
if (d >= 0 || resolved.N) load.N = true;
|
|
1236
1247
|
if (d !== -1) return;
|
|
1237
1248
|
if (skip && skip(resolved.r) && !sourcePhase) return { l: { b: resolved.r }, s: false };
|
|
1238
|
-
if (childFetchOpts.integrity) childFetchOpts =
|
|
1249
|
+
if (childFetchOpts.integrity) childFetchOpts = { ...childFetchOpts, integrity: undefined };
|
|
1239
1250
|
const child = { l: getOrCreateLoad(resolved.r, childFetchOpts, load.r, source), s: sourcePhase };
|
|
1240
1251
|
// assertion case -> inline the CSS / JSON URL directly
|
|
1241
1252
|
if (source === '') child.l.b = child.l.u;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** ES Module Shims Wasm 2.
|
|
1
|
+
/** ES Module Shims Wasm @version 2.4.1 */
|
|
2
2
|
(function (exports) {
|
|
3
3
|
|
|
4
4
|
let invalidate;
|
|
@@ -161,10 +161,6 @@
|
|
|
161
161
|
];
|
|
162
162
|
};
|
|
163
163
|
|
|
164
|
-
if (self.importShim) {
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
164
|
const hasDocument = typeof document !== 'undefined';
|
|
169
165
|
|
|
170
166
|
const noop = () => {};
|
|
@@ -177,11 +173,21 @@
|
|
|
177
173
|
|
|
178
174
|
const dynamicImport = (u, errUrl) => import(u);
|
|
179
175
|
|
|
176
|
+
const defineValue = (obj, prop, value) =>
|
|
177
|
+
Object.defineProperty(obj, prop, { writable: false, configurable: false, value });
|
|
178
|
+
|
|
180
179
|
const optionsScript = hasDocument ? document.querySelector('script[type=esms-options]') : undefined;
|
|
181
180
|
|
|
182
181
|
const esmsInitOptions = optionsScript ? JSON.parse(optionsScript.innerHTML) : {};
|
|
183
182
|
Object.assign(esmsInitOptions, self.esmsInitOptions || {});
|
|
184
183
|
|
|
184
|
+
const version = "2.4.1";
|
|
185
|
+
|
|
186
|
+
const r = esmsInitOptions.version;
|
|
187
|
+
if (self.importShim || (r && r !== version)) {
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
|
|
185
191
|
// shim mode is determined on initialization, no late shim mode
|
|
186
192
|
const shimMode =
|
|
187
193
|
esmsInitOptions.shimMode ||
|
|
@@ -375,9 +381,9 @@
|
|
|
375
381
|
|
|
376
382
|
const resolveAndComposeImportMap = (json, baseUrl, parentMap) => {
|
|
377
383
|
const outMap = {
|
|
378
|
-
imports:
|
|
379
|
-
scopes:
|
|
380
|
-
integrity:
|
|
384
|
+
imports: { ...parentMap.imports },
|
|
385
|
+
scopes: { ...parentMap.scopes },
|
|
386
|
+
integrity: { ...parentMap.integrity }
|
|
381
387
|
};
|
|
382
388
|
|
|
383
389
|
if (json.imports) resolveAndComposePackages(json.imports, outMap.imports, baseUrl, parentMap);
|
|
@@ -466,114 +472,115 @@
|
|
|
466
472
|
}
|
|
467
473
|
};
|
|
468
474
|
|
|
469
|
-
// support browsers without dynamic import support (eg Firefox 6x)
|
|
470
|
-
let supportsJsonType = false;
|
|
471
|
-
let supportsCssType = false;
|
|
472
|
-
|
|
473
|
-
const supports = hasDocument && HTMLScriptElement.supports;
|
|
474
|
-
|
|
475
|
-
let supportsImportMaps = supports && supports.name === 'supports' && supports('importmap');
|
|
476
|
-
let supportsWasmInstancePhase = false;
|
|
477
|
-
let supportsWasmSourcePhase = false;
|
|
478
|
-
let supportsMultipleImportMaps = false;
|
|
479
|
-
|
|
480
|
-
const wasmBytes = [0, 97, 115, 109, 1, 0, 0, 0];
|
|
481
|
-
|
|
482
|
-
let featureDetectionPromise = (async function () {
|
|
483
|
-
if (!hasDocument)
|
|
484
|
-
return Promise.all([
|
|
485
|
-
import(createBlob(`import"${createBlob('{}', 'text/json')}"with{type:"json"}`)).then(
|
|
486
|
-
() => (
|
|
487
|
-
(supportsJsonType = true),
|
|
488
|
-
import(createBlob(`import"${createBlob('', 'text/css')}"with{type:"css"}`)).then(
|
|
489
|
-
() => (supportsCssType = true),
|
|
490
|
-
noop
|
|
491
|
-
)
|
|
492
|
-
),
|
|
493
|
-
noop
|
|
494
|
-
),
|
|
495
|
-
wasmInstancePhaseEnabled &&
|
|
496
|
-
import(createBlob(`import"${createBlob(new Uint8Array(wasmBytes), 'application/wasm')}"`)).then(
|
|
497
|
-
() => (supportsWasmInstancePhase = true),
|
|
498
|
-
noop
|
|
499
|
-
),
|
|
500
|
-
wasmSourcePhaseEnabled &&
|
|
501
|
-
import(createBlob(`import source x from"${createBlob(new Uint8Array(wasmBytes), 'application/wasm')}"`)).then(
|
|
502
|
-
() => (supportsWasmSourcePhase = true),
|
|
503
|
-
noop
|
|
504
|
-
)
|
|
505
|
-
]);
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
iframe
|
|
510
|
-
iframe.
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
//
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
//
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
// setting
|
|
570
|
-
//
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
if
|
|
576
|
-
|
|
475
|
+
// support browsers without dynamic import support (eg Firefox 6x)
|
|
476
|
+
let supportsJsonType = false;
|
|
477
|
+
let supportsCssType = false;
|
|
478
|
+
|
|
479
|
+
const supports = hasDocument && HTMLScriptElement.supports;
|
|
480
|
+
|
|
481
|
+
let supportsImportMaps = supports && supports.name === 'supports' && supports('importmap');
|
|
482
|
+
let supportsWasmInstancePhase = false;
|
|
483
|
+
let supportsWasmSourcePhase = false;
|
|
484
|
+
let supportsMultipleImportMaps = false;
|
|
485
|
+
|
|
486
|
+
const wasmBytes = [0, 97, 115, 109, 1, 0, 0, 0];
|
|
487
|
+
|
|
488
|
+
let featureDetectionPromise = (async function () {
|
|
489
|
+
if (!hasDocument)
|
|
490
|
+
return Promise.all([
|
|
491
|
+
import(createBlob(`import"${createBlob('{}', 'text/json')}"with{type:"json"}`)).then(
|
|
492
|
+
() => (
|
|
493
|
+
(supportsJsonType = true),
|
|
494
|
+
import(createBlob(`import"${createBlob('', 'text/css')}"with{type:"css"}`)).then(
|
|
495
|
+
() => (supportsCssType = true),
|
|
496
|
+
noop
|
|
497
|
+
)
|
|
498
|
+
),
|
|
499
|
+
noop
|
|
500
|
+
),
|
|
501
|
+
wasmInstancePhaseEnabled &&
|
|
502
|
+
import(createBlob(`import"${createBlob(new Uint8Array(wasmBytes), 'application/wasm')}"`)).then(
|
|
503
|
+
() => (supportsWasmInstancePhase = true),
|
|
504
|
+
noop
|
|
505
|
+
),
|
|
506
|
+
wasmSourcePhaseEnabled &&
|
|
507
|
+
import(createBlob(`import source x from"${createBlob(new Uint8Array(wasmBytes), 'application/wasm')}"`)).then(
|
|
508
|
+
() => (supportsWasmSourcePhase = true),
|
|
509
|
+
noop
|
|
510
|
+
)
|
|
511
|
+
]);
|
|
512
|
+
|
|
513
|
+
const msgTag = `s${version}`;
|
|
514
|
+
return new Promise(resolve => {
|
|
515
|
+
const iframe = document.createElement('iframe');
|
|
516
|
+
iframe.style.display = 'none';
|
|
517
|
+
iframe.setAttribute('nonce', nonce);
|
|
518
|
+
function cb({ data }) {
|
|
519
|
+
const isFeatureDetectionMessage = Array.isArray(data) && data[0] === msgTag;
|
|
520
|
+
if (!isFeatureDetectionMessage) return;
|
|
521
|
+
[
|
|
522
|
+
,
|
|
523
|
+
supportsImportMaps,
|
|
524
|
+
supportsMultipleImportMaps,
|
|
525
|
+
supportsJsonType,
|
|
526
|
+
supportsCssType,
|
|
527
|
+
supportsWasmSourcePhase,
|
|
528
|
+
supportsWasmInstancePhase
|
|
529
|
+
] = data;
|
|
530
|
+
resolve();
|
|
531
|
+
document.head.removeChild(iframe);
|
|
532
|
+
window.removeEventListener('message', cb, false);
|
|
533
|
+
}
|
|
534
|
+
window.addEventListener('message', cb, false);
|
|
535
|
+
|
|
536
|
+
// Feature checking with careful avoidance of unnecessary work - all gated on initial import map supports check. CSS gates on JSON feature check, Wasm instance phase gates on wasm source phase check.
|
|
537
|
+
const importMapTest = `<script nonce=${nonce || ''}>b=(s,type='text/javascript')=>URL.createObjectURL(new Blob([s],{type}));c=u=>import(u).then(()=>true,()=>false);i=innerText=>document.head.appendChild(Object.assign(document.createElement('script'),{type:'importmap',nonce:"${nonce}",innerText}));i(\`{"imports":{"x":"\${b('')}"}}\`);i(\`{"imports":{"y":"\${b('')}"}}\`);cm=${
|
|
538
|
+
supportsImportMaps ? `c(b(\`import"\${b('{}','text/json')}"with{type:"json"}\`))` : 'false'
|
|
539
|
+
};sp=${
|
|
540
|
+
supportsImportMaps && wasmSourcePhaseEnabled ?
|
|
541
|
+
`c(b(\`import source x from "\${b(new Uint8Array(${JSON.stringify(wasmBytes)}),'application/wasm')\}"\`))`
|
|
542
|
+
: 'false'
|
|
543
|
+
};Promise.all([${supportsImportMaps ? 'true' : "c('x')"},${supportsImportMaps ? "c('y')" : false},cm,${
|
|
544
|
+
supportsImportMaps ? `cm.then(s=>s?c(b(\`import"\${b('','text/css')\}"with{type:"css"}\`)):false)` : 'false'
|
|
545
|
+
},sp,${
|
|
546
|
+
supportsImportMaps && wasmInstancePhaseEnabled ?
|
|
547
|
+
`${wasmSourcePhaseEnabled ? 'sp.then(s=>s?' : ''}c(b(\`import"\${b(new Uint8Array(${JSON.stringify(wasmBytes)}),'application/wasm')\}"\`))${wasmSourcePhaseEnabled ? ':false)' : ''}`
|
|
548
|
+
: 'false'
|
|
549
|
+
}]).then(a=>parent.postMessage(['${msgTag}'].concat(a),'*'))<${''}/script>`;
|
|
550
|
+
|
|
551
|
+
// Safari will call onload eagerly on head injection, but we don't want the Wechat
|
|
552
|
+
// path to trigger before setting srcdoc, therefore we track the timing
|
|
553
|
+
let readyForOnload = false,
|
|
554
|
+
onloadCalledWhileNotReady = false;
|
|
555
|
+
function doOnload() {
|
|
556
|
+
if (!readyForOnload) {
|
|
557
|
+
onloadCalledWhileNotReady = true;
|
|
558
|
+
return;
|
|
559
|
+
}
|
|
560
|
+
// WeChat browser doesn't support setting srcdoc scripts
|
|
561
|
+
// But iframe sandboxes don't support contentDocument so we do this as a fallback
|
|
562
|
+
const doc = iframe.contentDocument;
|
|
563
|
+
if (doc && doc.head.childNodes.length === 0) {
|
|
564
|
+
const s = doc.createElement('script');
|
|
565
|
+
if (nonce) s.setAttribute('nonce', nonce);
|
|
566
|
+
s.innerHTML = importMapTest.slice(15 + (nonce ? nonce.length : 0), -9);
|
|
567
|
+
doc.head.appendChild(s);
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
iframe.onload = doOnload;
|
|
572
|
+
// WeChat browser requires append before setting srcdoc
|
|
573
|
+
document.head.appendChild(iframe);
|
|
574
|
+
|
|
575
|
+
// setting srcdoc is not supported in React native webviews on iOS
|
|
576
|
+
// setting src to a blob URL results in a navigation event in webviews
|
|
577
|
+
// document.write gives usability warnings
|
|
578
|
+
readyForOnload = true;
|
|
579
|
+
if ('srcdoc' in iframe) iframe.srcdoc = importMapTest;
|
|
580
|
+
else iframe.contentDocument.write(importMapTest);
|
|
581
|
+
// retrigger onload for Safari only if necessary
|
|
582
|
+
if (onloadCalledWhileNotReady) doOnload();
|
|
583
|
+
});
|
|
577
584
|
})();
|
|
578
585
|
|
|
579
586
|
/* es-module-lexer 1.7.0 */
|
|
@@ -661,8 +668,6 @@
|
|
|
661
668
|
|
|
662
669
|
if (hotReload) importShim$1.hotReload = hotReload$1;
|
|
663
670
|
|
|
664
|
-
self.importShim = importShim$1;
|
|
665
|
-
|
|
666
671
|
const defaultResolve = (id, parentUrl) => {
|
|
667
672
|
return (
|
|
668
673
|
resolveImportMap(composedImportMap, resolveIfNotPlainOrUrl(id, parentUrl) || id, parentUrl) ||
|
|
@@ -684,12 +689,19 @@
|
|
|
684
689
|
if (!shimMode) throw new Error('Unsupported in polyfill mode.');
|
|
685
690
|
composedImportMap = resolveAndComposeImportMap(importMapIn, baseUrl, composedImportMap);
|
|
686
691
|
};
|
|
692
|
+
importShim$1.version = version;
|
|
687
693
|
|
|
688
694
|
const registry = (importShim$1._r = {});
|
|
689
695
|
// Wasm caches
|
|
690
696
|
const sourceCache = (importShim$1._s = {});
|
|
691
697
|
(importShim$1._i = new WeakMap());
|
|
692
698
|
|
|
699
|
+
// Ensure this version is the only version
|
|
700
|
+
defineValue(self, 'importShim', Object.freeze(importShim$1));
|
|
701
|
+
const shimModeOptions = { ...esmsInitOptions, shimMode: true };
|
|
702
|
+
if (optionsScript) optionsScript.innerHTML = JSON.stringify(shimModeOptions);
|
|
703
|
+
self.esmsInitOptions = shimModeOptions;
|
|
704
|
+
|
|
693
705
|
const loadAll = async (load, seen) => {
|
|
694
706
|
seen[load.u] = 1;
|
|
695
707
|
await load.L;
|
|
@@ -723,8 +735,7 @@
|
|
|
723
735
|
if (!shimMode && typeof WebAssembly !== 'undefined') {
|
|
724
736
|
if (wasmSourcePhaseEnabled && !Object.getPrototypeOf(WebAssembly.Module).name) {
|
|
725
737
|
const s = Symbol();
|
|
726
|
-
const brand = m =>
|
|
727
|
-
Object.defineProperty(m, s, { writable: false, configurable: false, value: 'WebAssembly.Module' });
|
|
738
|
+
const brand = m => defineValue(m, s, 'WebAssembly.Module');
|
|
728
739
|
class AbstractModuleSource {
|
|
729
740
|
get [Symbol.toStringTag]() {
|
|
730
741
|
if (this[s]) return this[s];
|
|
@@ -1080,7 +1091,7 @@
|
|
|
1080
1091
|
const mapIntegrity = composedImportMap.integrity[url];
|
|
1081
1092
|
const res = await doFetch(
|
|
1082
1093
|
url,
|
|
1083
|
-
mapIntegrity && !fetchOpts.integrity ?
|
|
1094
|
+
mapIntegrity && !fetchOpts.integrity ? { ...fetchOpts, integrity: mapIntegrity } : fetchOpts,
|
|
1084
1095
|
parent
|
|
1085
1096
|
);
|
|
1086
1097
|
const r = res.url;
|
|
@@ -1235,7 +1246,7 @@
|
|
|
1235
1246
|
if (d >= 0 || resolved.N) load.N = true;
|
|
1236
1247
|
if (d !== -1) return;
|
|
1237
1248
|
if (skip && skip(resolved.r) && !sourcePhase) return { l: { b: resolved.r }, s: false };
|
|
1238
|
-
if (childFetchOpts.integrity) childFetchOpts =
|
|
1249
|
+
if (childFetchOpts.integrity) childFetchOpts = { ...childFetchOpts, integrity: undefined };
|
|
1239
1250
|
const child = { l: getOrCreateLoad(resolved.r, childFetchOpts, load.r, source), s: sourcePhase };
|
|
1240
1251
|
// assertion case -> inline the CSS / JSON URL directly
|
|
1241
1252
|
if (source === '') child.l.b = child.l.u;
|