es-module-shims 2.5.0 → 2.5.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 +2 -3
- package/dist/es-module-shims.debug.js +890 -901
- package/dist/es-module-shims.js +873 -884
- package/dist/es-module-shims.wasm.js +873 -884
- package/index.d.ts +30 -2
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/** ES Module Shims Wasm @version 2.5.
|
|
2
|
-
(function (
|
|
1
|
+
/** ES Module Shims Wasm @version 2.5.1 */
|
|
2
|
+
(function () {
|
|
3
3
|
|
|
4
4
|
let invalidate;
|
|
5
5
|
const hotReload$1 = url => invalidate(new URL(url, baseUrl).href);
|
|
@@ -93,25 +93,23 @@
|
|
|
93
93
|
});
|
|
94
94
|
|
|
95
95
|
invalidate = (url, fromUrl, seen = []) => {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
if (!hotState.a) for (const parent of hotState.p) invalidate(parent, url, seen);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
if (!curInvalidationInterval) curInvalidationInterval = setTimeout(handleInvalidations, hotReloadInterval);
|
|
96
|
+
const hotState = hotRegistry[url];
|
|
97
|
+
if (!hotState || seen.includes(url)) return false;
|
|
98
|
+
seen.push(url);
|
|
99
|
+
hotState.A = false;
|
|
100
|
+
if (
|
|
101
|
+
fromUrl &&
|
|
102
|
+
hotState.a &&
|
|
103
|
+
hotState.a.some(([d]) => d && (typeof d === 'string' ? d === fromUrl : d.includes(fromUrl)))
|
|
104
|
+
) {
|
|
105
|
+
curInvalidationRoots.add(fromUrl);
|
|
106
|
+
} else {
|
|
107
|
+
if (hotState.e || hotState.a) curInvalidationRoots.add(url);
|
|
108
|
+
hotState.v++;
|
|
109
|
+
if (!hotState.a) for (const parent of hotState.p) invalidate(parent, url, seen);
|
|
114
110
|
}
|
|
111
|
+
if (!curInvalidationInterval) curInvalidationInterval = setTimeout(handleInvalidations, hotReloadInterval);
|
|
112
|
+
return true;
|
|
115
113
|
};
|
|
116
114
|
|
|
117
115
|
const handleInvalidations = () => {
|
|
@@ -168,12 +166,6 @@
|
|
|
168
166
|
|
|
169
167
|
const noop = () => {};
|
|
170
168
|
|
|
171
|
-
const chain = (a, b) =>
|
|
172
|
-
function () {
|
|
173
|
-
a.apply(this, arguments);
|
|
174
|
-
b.apply(this, arguments);
|
|
175
|
-
};
|
|
176
|
-
|
|
177
169
|
const dynamicImport = (u, errUrl) => import(u);
|
|
178
170
|
|
|
179
171
|
const defineValue = (obj, prop, value) =>
|
|
@@ -184,7 +176,7 @@
|
|
|
184
176
|
const esmsInitOptions = optionsScript ? JSON.parse(optionsScript.innerHTML) : {};
|
|
185
177
|
Object.assign(esmsInitOptions, self.esmsInitOptions || {});
|
|
186
178
|
|
|
187
|
-
const version = "2.5.
|
|
179
|
+
const version = "2.5.1";
|
|
188
180
|
|
|
189
181
|
const r = esmsInitOptions.version;
|
|
190
182
|
if (self.importShim || (r && r !== version)) {
|
|
@@ -589,865 +581,862 @@
|
|
|
589
581
|
/* es-module-lexer 1.7.0 */
|
|
590
582
|
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",A[A.StaticDeferPhase=6]="StaticDeferPhase",A[A.DynamicDeferPhase=7]="DynamicDeferPhase";}(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/AUHA8gALfwBBwPIACwd6FQZtZW1vcnkCAAJzYQAAAWUAAwJpcwAEAmllAAUCc3MABgJzZQAHAml0AAgCYWkACQJpZAAKAmlwAAsCZXMADAJlZQANA2VscwAOA2VsZQAPAnJpABACcmUAEQFmABICbXMAEwVwYXJzZQAUC19faGVhcF9iYXNlAwEKzkQwaAEBf0EAIAA2AoAKQQAoAtwJIgEgAEEBdGoiAEEAOwEAQQAgAEECaiIANgKECkEAIAA2AogKQQBBADYC4AlBAEEANgLwC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//wNxIgFBd2oiAkEXSw0AQQEgAnRBn4CABHENAgsgAUGgAUYNASAAIQIgARAoDQJBACECQQBBACgCsAoiAEECajYCsAogAC8BAiIADQAMAgsLIAAhAgsgAkH//wNxC6sBAQR/AkACQEEAKAKwCiICLwEAIgNB4QBGDQAgASEEIAAhBQwBC0EAIAJBBGo2ArAKQQEQKSECQQAoArAKIQUCQAJAIAJBIkYNACACQSdGDQAgAhAsGkEAKAKwCiEEDAELIAIQGkEAQQAoArAKQQJqIgQ2ArAKC0EBECkhA0EAKAKwCiECCwJAIAIgBUYNACAFIARBACAAIAAgAUYiAhtBACABIAIbEAILIAMLcgEEf0EAKAKwCiEAQQAoArQKIQECQAJAA0AgAEECaiECIAAgAU8NAQJAAkAgAi8BACIDQaR/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;}));
|
|
591
583
|
|
|
592
|
-
const _resolve = (id, parentUrl = baseUrl) => {
|
|
593
|
-
const urlResolved = resolveIfNotPlainOrUrl(id, parentUrl) || asURL(id);
|
|
594
|
-
const firstResolved = firstImportMap && resolveImportMap(firstImportMap, urlResolved || id, parentUrl);
|
|
595
|
-
const composedResolved =
|
|
596
|
-
composedImportMap === firstImportMap ? firstResolved : (
|
|
597
|
-
resolveImportMap(composedImportMap, urlResolved || id, parentUrl)
|
|
598
|
-
);
|
|
599
|
-
const resolved = composedResolved || firstResolved || throwUnresolved(id, parentUrl);
|
|
600
|
-
// needsShim, shouldShim per load record to set on parent
|
|
601
|
-
let n = false,
|
|
602
|
-
N = false;
|
|
603
|
-
if (!supportsImportMaps) {
|
|
604
|
-
// bare specifier -> needs shim
|
|
605
|
-
if (!urlResolved) n = true;
|
|
606
|
-
// url mapping -> should shim
|
|
607
|
-
else if (urlResolved !== resolved) N = true;
|
|
608
|
-
} else if (!supportsMultipleImportMaps) {
|
|
609
|
-
// bare specifier and not resolved by first import map -> needs shim
|
|
610
|
-
if (!urlResolved && !firstResolved) n = true;
|
|
611
|
-
// resolution doesn't match first import map -> should shim
|
|
612
|
-
if (firstResolved && resolved !== firstResolved) N = true;
|
|
613
|
-
}
|
|
614
|
-
return { r: resolved, n, N };
|
|
615
|
-
};
|
|
616
|
-
|
|
617
|
-
const resolve = (id, parentUrl) => {
|
|
618
|
-
if (!resolveHook) return _resolve(id, parentUrl);
|
|
619
|
-
const result = resolveHook(id, parentUrl, defaultResolve);
|
|
620
|
-
|
|
621
|
-
return result ? { r: result, n: true, N: true } : _resolve(id, parentUrl);
|
|
622
|
-
};
|
|
623
|
-
|
|
624
|
-
// import()
|
|
625
|
-
async function importShim$1(id, opts, parentUrl) {
|
|
626
|
-
if (typeof opts === 'string') {
|
|
627
|
-
parentUrl = opts;
|
|
628
|
-
opts = undefined;
|
|
629
|
-
}
|
|
630
|
-
await initPromise; // needed for shim check
|
|
631
|
-
if (shimMode || !baselinePassthrough) {
|
|
632
|
-
if (hasDocument) processScriptsAndPreloads();
|
|
633
|
-
legacyAcceptingImportMaps = false;
|
|
634
|
-
}
|
|
635
|
-
let sourceType = undefined;
|
|
636
|
-
if (typeof opts === 'object') {
|
|
637
|
-
if (opts.lang === 'ts') sourceType = 'ts';
|
|
638
|
-
if (typeof opts.with === 'object' && typeof opts.with.type === 'string') {
|
|
639
|
-
sourceType = opts.with.type;
|
|
640
|
-
}
|
|
641
|
-
}
|
|
642
|
-
return topLevelLoad(id, parentUrl || baseUrl, defaultFetchOpts, undefined, undefined, undefined, sourceType);
|
|
643
|
-
}
|
|
644
|
-
|
|
645
|
-
// import.source()
|
|
646
|
-
// (opts not currently supported as no use cases yet)
|
|
647
|
-
if (shimMode || wasmSourcePhaseEnabled)
|
|
648
|
-
importShim$1.source = async (id, opts, parentUrl) => {
|
|
649
|
-
if (typeof opts === 'string') {
|
|
650
|
-
parentUrl = opts;
|
|
651
|
-
opts = undefined;
|
|
652
|
-
}
|
|
653
|
-
await initPromise; // needed for shim check
|
|
654
|
-
if (shimMode || !baselinePassthrough) {
|
|
655
|
-
if (hasDocument) processScriptsAndPreloads();
|
|
656
|
-
legacyAcceptingImportMaps = false;
|
|
657
|
-
}
|
|
658
|
-
await importMapPromise;
|
|
659
|
-
const url = resolve(id, parentUrl || baseUrl).r;
|
|
660
|
-
const load = getOrCreateLoad(url, defaultFetchOpts, undefined, undefined);
|
|
661
|
-
if (firstPolyfillLoad && !shimMode && load.n && nativelyLoaded) {
|
|
662
|
-
onpolyfill();
|
|
663
|
-
firstPolyfillLoad = false;
|
|
664
|
-
}
|
|
665
|
-
await load.f;
|
|
666
|
-
return importShim$1._s[load.r];
|
|
667
|
-
};
|
|
668
|
-
|
|
669
|
-
// import.defer() is just a proxy for import(), since we can't actually defer
|
|
670
|
-
if (shimMode || deferPhaseEnabled) importShim$1.defer = importShim$1;
|
|
671
|
-
|
|
672
|
-
if (hotReload) importShim$1.hotReload = hotReload$1;
|
|
673
|
-
|
|
674
|
-
const defaultResolve = (id, parentUrl) => {
|
|
675
|
-
return (
|
|
676
|
-
resolveImportMap(composedImportMap, resolveIfNotPlainOrUrl(id, parentUrl) || id, parentUrl) ||
|
|
677
|
-
throwUnresolved(id, parentUrl)
|
|
678
|
-
);
|
|
679
|
-
};
|
|
680
|
-
|
|
681
|
-
const throwUnresolved = (id, parentUrl) => {
|
|
682
|
-
throw Error(`Unable to resolve specifier '${id}'${fromParent(parentUrl)}`);
|
|
683
|
-
};
|
|
684
|
-
|
|
685
|
-
const metaResolve = function (id, parentUrl = this.url) {
|
|
686
|
-
return resolve(id, `${parentUrl}`).r;
|
|
687
|
-
};
|
|
688
|
-
|
|
689
|
-
importShim$1.resolve = (id, parentUrl) => resolve(id, parentUrl).r;
|
|
690
|
-
importShim$1.getImportMap = () => JSON.parse(JSON.stringify(composedImportMap));
|
|
691
|
-
importShim$1.addImportMap = importMapIn => {
|
|
692
|
-
if (!shimMode) throw new Error('Unsupported in polyfill mode.');
|
|
693
|
-
composedImportMap = resolveAndComposeImportMap(importMapIn, baseUrl, composedImportMap);
|
|
694
|
-
};
|
|
695
|
-
importShim$1.version = version;
|
|
696
|
-
|
|
697
|
-
const registry = (importShim$1._r = {});
|
|
698
|
-
// Wasm caches
|
|
699
|
-
const sourceCache = (importShim$1._s = {});
|
|
700
|
-
(importShim$1._i = new WeakMap());
|
|
701
|
-
|
|
702
|
-
// Ensure this version is the only version
|
|
703
|
-
defineValue(self, 'importShim', Object.freeze(importShim$1));
|
|
704
|
-
const shimModeOptions = { ...esmsInitOptions, shimMode: true };
|
|
705
|
-
if (optionsScript) optionsScript.innerHTML = JSON.stringify(shimModeOptions);
|
|
706
|
-
self.esmsInitOptions = shimModeOptions;
|
|
707
|
-
|
|
708
|
-
const loadAll = async (load, seen) => {
|
|
709
|
-
seen[load.u] = 1;
|
|
710
|
-
await load.L;
|
|
711
|
-
await Promise.all(
|
|
712
|
-
load.d.map(({ l: dep, s: sourcePhase }) => {
|
|
713
|
-
if (dep.b || seen[dep.u]) return;
|
|
714
|
-
if (sourcePhase) return dep.f;
|
|
715
|
-
return loadAll(dep, seen);
|
|
716
|
-
})
|
|
717
|
-
);
|
|
718
|
-
};
|
|
719
|
-
|
|
720
|
-
let importMapSrc = false;
|
|
721
|
-
let multipleImportMaps = false;
|
|
722
|
-
let firstImportMap = null;
|
|
723
|
-
// To support polyfilling multiple import maps, we separately track the composed import map from the first import map
|
|
724
|
-
let composedImportMap = { imports: {}, scopes: {}, integrity: {} };
|
|
725
|
-
let baselinePassthrough;
|
|
726
|
-
|
|
727
|
-
const initPromise = featureDetectionPromise.then(() => {
|
|
728
|
-
baselinePassthrough =
|
|
729
|
-
esmsInitOptions.polyfillEnable !== true &&
|
|
730
|
-
supportsImportMaps &&
|
|
731
|
-
supportsJsonType &&
|
|
732
|
-
supportsCssType &&
|
|
733
|
-
(!wasmInstancePhaseEnabled || supportsWasmInstancePhase) &&
|
|
734
|
-
(!wasmSourcePhaseEnabled || supportsWasmSourcePhase) &&
|
|
735
|
-
!deferPhaseEnabled &&
|
|
736
|
-
(!multipleImportMaps || supportsMultipleImportMaps) &&
|
|
737
|
-
!importMapSrc;
|
|
738
|
-
if (!shimMode && typeof WebAssembly !== 'undefined') {
|
|
739
|
-
if (wasmSourcePhaseEnabled && !Object.getPrototypeOf(WebAssembly.Module).name) {
|
|
740
|
-
const s = Symbol();
|
|
741
|
-
const brand = m => defineValue(m, s, 'WebAssembly.Module');
|
|
742
|
-
class AbstractModuleSource {
|
|
743
|
-
get [Symbol.toStringTag]() {
|
|
744
|
-
if (this[s]) return this[s];
|
|
745
|
-
throw new TypeError('Not an AbstractModuleSource');
|
|
746
|
-
}
|
|
747
|
-
}
|
|
748
|
-
const { Module: wasmModule, compile: wasmCompile, compileStreaming: wasmCompileStreaming } = WebAssembly;
|
|
749
|
-
WebAssembly.Module = Object.setPrototypeOf(
|
|
750
|
-
Object.assign(function Module(...args) {
|
|
751
|
-
return brand(new wasmModule(...args));
|
|
752
|
-
}, wasmModule),
|
|
753
|
-
AbstractModuleSource
|
|
754
|
-
);
|
|
755
|
-
WebAssembly.Module.prototype = Object.setPrototypeOf(wasmModule.prototype, AbstractModuleSource.prototype);
|
|
756
|
-
WebAssembly.compile = function compile(...args) {
|
|
757
|
-
return wasmCompile(...args).then(brand);
|
|
758
|
-
};
|
|
759
|
-
WebAssembly.compileStreaming = function compileStreaming(...args) {
|
|
760
|
-
return wasmCompileStreaming(...args).then(brand);
|
|
761
|
-
};
|
|
762
|
-
}
|
|
763
|
-
}
|
|
764
|
-
if (hasDocument) {
|
|
765
|
-
if (!supportsImportMaps) {
|
|
766
|
-
const supports = HTMLScriptElement.supports || (type => type === 'classic' || type === 'module');
|
|
767
|
-
HTMLScriptElement.supports = type => type === 'importmap' || supports(type);
|
|
768
|
-
}
|
|
769
|
-
if (shimMode || !baselinePassthrough) {
|
|
770
|
-
attachMutationObserver();
|
|
771
|
-
if (document.readyState === 'complete') {
|
|
772
|
-
readyStateCompleteCheck();
|
|
773
|
-
} else {
|
|
774
|
-
document.addEventListener('readystatechange', readyListener);
|
|
775
|
-
}
|
|
776
|
-
}
|
|
777
|
-
processScriptsAndPreloads();
|
|
778
|
-
}
|
|
779
|
-
return init;
|
|
780
|
-
});
|
|
781
|
-
|
|
782
|
-
const attachMutationObserver = () => {
|
|
783
|
-
const observer = new MutationObserver(mutations => {
|
|
784
|
-
for (const mutation of mutations) {
|
|
785
|
-
if (mutation.type !== 'childList') continue;
|
|
786
|
-
for (const node of mutation.addedNodes) {
|
|
787
|
-
if (node.tagName === 'SCRIPT') {
|
|
788
|
-
if (node.type === (shimMode ? 'module-shim' : 'module') && !node.ep) processScript(node, true);
|
|
789
|
-
if (node.type === (shimMode ? 'importmap-shim' : 'importmap') && !node.ep) processImportMap(node, true);
|
|
790
|
-
} else if (
|
|
791
|
-
node.tagName === 'LINK' &&
|
|
792
|
-
node.rel === (shimMode ? 'modulepreload-shim' : 'modulepreload') &&
|
|
793
|
-
!node.ep
|
|
794
|
-
) {
|
|
795
|
-
processPreload(node);
|
|
796
|
-
}
|
|
797
|
-
}
|
|
798
|
-
}
|
|
799
|
-
});
|
|
800
|
-
observer.observe(document, { childList: true });
|
|
801
|
-
observer.observe(document.head, { childList: true });
|
|
802
|
-
processScriptsAndPreloads();
|
|
803
|
-
};
|
|
804
|
-
|
|
805
|
-
let importMapPromise = initPromise;
|
|
806
|
-
let firstPolyfillLoad = true;
|
|
807
|
-
let legacyAcceptingImportMaps = true;
|
|
808
|
-
|
|
809
|
-
const topLevelLoad = async (
|
|
810
|
-
url,
|
|
811
|
-
parentUrl,
|
|
812
|
-
fetchOpts,
|
|
813
|
-
source,
|
|
814
|
-
nativelyLoaded,
|
|
815
|
-
lastStaticLoadPromise,
|
|
816
|
-
sourceType
|
|
817
|
-
) => {
|
|
818
|
-
await initPromise;
|
|
819
|
-
await importMapPromise;
|
|
820
|
-
url = (await resolve(url, parentUrl)).r;
|
|
821
|
-
|
|
822
|
-
// we mock import('./x.css', { with: { type: 'css' }}) support via an inline static reexport
|
|
823
|
-
// because we can't syntactically pass through to dynamic import with a second argument
|
|
824
|
-
if (sourceType === 'css' || sourceType === 'json') {
|
|
825
|
-
// Direct reexport for hot reloading skipped due to Firefox bug https://bugzilla.mozilla.org/show_bug.cgi?id=1965620
|
|
826
|
-
source = `import m from'${url}'with{type:"${sourceType}"};export default m;`;
|
|
827
|
-
url += '?entry';
|
|
828
|
-
}
|
|
829
|
-
|
|
830
|
-
if (importHook) await importHook(url, typeof fetchOpts !== 'string' ? fetchOpts : {}, parentUrl, source, sourceType);
|
|
831
|
-
// early analysis opt-out - no need to even fetch if we have feature support
|
|
832
|
-
if (!shimMode && baselinePassthrough && nativePassthrough && sourceType !== 'ts') {
|
|
833
|
-
// for polyfill case, only dynamic import needs a return value here, and dynamic import will never pass nativelyLoaded
|
|
834
|
-
if (nativelyLoaded) return null;
|
|
835
|
-
await lastStaticLoadPromise;
|
|
836
|
-
return dynamicImport(source ? createBlob(source) : url);
|
|
837
|
-
}
|
|
838
|
-
const load = getOrCreateLoad(url, fetchOpts, undefined, source);
|
|
839
|
-
linkLoad(load, fetchOpts);
|
|
840
|
-
const seen = {};
|
|
841
|
-
await loadAll(load, seen);
|
|
842
|
-
resolveDeps(load, seen);
|
|
843
|
-
await lastStaticLoadPromise;
|
|
844
|
-
if (!shimMode && !load.n) {
|
|
845
|
-
if (nativelyLoaded) {
|
|
846
|
-
return;
|
|
847
|
-
}
|
|
848
|
-
if (source) {
|
|
849
|
-
return await dynamicImport(createBlob(source));
|
|
850
|
-
}
|
|
851
|
-
}
|
|
852
|
-
if (firstPolyfillLoad && !shimMode && load.n && nativelyLoaded) {
|
|
853
|
-
onpolyfill();
|
|
854
|
-
firstPolyfillLoad = false;
|
|
855
|
-
}
|
|
856
|
-
const module = await (shimMode || load.n || load.N || !nativePassthrough || (!nativelyLoaded && source) ?
|
|
857
|
-
dynamicImport(load.b, load.u)
|
|
858
|
-
: import(load.u));
|
|
859
|
-
// if the top-level load is a shell, run its update function
|
|
860
|
-
if (load.s) (await dynamicImport(load.s, load.u)).u$_(module);
|
|
861
|
-
if (revokeBlobURLs) revokeObjectURLs(Object.keys(seen));
|
|
862
|
-
return module;
|
|
863
|
-
};
|
|
864
|
-
|
|
865
|
-
const revokeObjectURLs = registryKeys => {
|
|
866
|
-
let curIdx = 0;
|
|
867
|
-
const handler = self.requestIdleCallback || self.requestAnimationFrame;
|
|
868
|
-
handler(cleanup);
|
|
869
|
-
function cleanup() {
|
|
870
|
-
for (const key of registryKeys.slice(curIdx, (curIdx += 100))) {
|
|
871
|
-
const load = registry[key];
|
|
872
|
-
if (load && load.b && load.b !== load.u) URL.revokeObjectURL(load.b);
|
|
873
|
-
}
|
|
874
|
-
if (curIdx < registryKeys.length) handler(cleanup);
|
|
875
|
-
}
|
|
876
|
-
};
|
|
877
|
-
|
|
878
|
-
const urlJsString = url => `'${url.replace(/'/g, "\\'")}'`;
|
|
879
|
-
|
|
880
|
-
let resolvedSource, lastIndex;
|
|
881
|
-
const pushStringTo = (load, originalIndex, dynamicImportEndStack) => {
|
|
882
|
-
while (dynamicImportEndStack[dynamicImportEndStack.length - 1] < originalIndex) {
|
|
883
|
-
const dynamicImportEnd = dynamicImportEndStack.pop();
|
|
884
|
-
resolvedSource += `${load.S.slice(lastIndex, dynamicImportEnd)}, ${urlJsString(load.r)}`;
|
|
885
|
-
lastIndex = dynamicImportEnd;
|
|
886
|
-
}
|
|
887
|
-
resolvedSource += load.S.slice(lastIndex, originalIndex);
|
|
888
|
-
lastIndex = originalIndex;
|
|
889
|
-
};
|
|
890
|
-
|
|
891
|
-
const pushSourceURL = (load, commentPrefix, commentStart, dynamicImportEndStack) => {
|
|
892
|
-
const urlStart = commentStart + commentPrefix.length;
|
|
893
|
-
const commentEnd = load.S.indexOf('\n', urlStart);
|
|
894
|
-
const urlEnd = commentEnd !== -1 ? commentEnd : load.S.length;
|
|
895
|
-
let sourceUrl = load.S.slice(urlStart, urlEnd);
|
|
896
|
-
try {
|
|
897
|
-
sourceUrl = new URL(sourceUrl, load.r).href;
|
|
898
|
-
} catch {}
|
|
899
|
-
pushStringTo(load, urlStart, dynamicImportEndStack);
|
|
900
|
-
resolvedSource += sourceUrl;
|
|
901
|
-
lastIndex = urlEnd;
|
|
902
|
-
};
|
|
903
|
-
|
|
904
|
-
const resolveDeps = (load, seen) => {
|
|
905
|
-
if (load.b || !seen[load.u]) return;
|
|
906
|
-
seen[load.u] = 0;
|
|
907
|
-
|
|
908
|
-
for (const { l: dep, s: sourcePhase } of load.d) {
|
|
909
|
-
if (!sourcePhase) resolveDeps(dep, seen);
|
|
910
|
-
}
|
|
911
|
-
|
|
912
|
-
if (!load.n) load.n = load.d.some(dep => dep.l.n);
|
|
913
|
-
if (!load.N) load.N = load.d.some(dep => dep.l.N);
|
|
914
|
-
|
|
915
|
-
// use native loader whenever possible (n = needs shim) via executable subgraph passthrough
|
|
916
|
-
// so long as the module doesn't use dynamic import or unsupported URL mappings (N = should shim)
|
|
917
|
-
if (nativePassthrough && !shimMode && !load.n && !load.N) {
|
|
918
|
-
load.b = load.u;
|
|
919
|
-
load.S = undefined;
|
|
920
|
-
return;
|
|
921
|
-
}
|
|
922
|
-
|
|
923
|
-
const [imports, exports] = load.a;
|
|
924
|
-
|
|
925
|
-
// "execution"
|
|
926
|
-
let source = load.S,
|
|
927
|
-
depIndex = 0,
|
|
928
|
-
dynamicImportEndStack = [];
|
|
929
|
-
|
|
930
|
-
// once all deps have loaded we can inline the dependency resolution blobs
|
|
931
|
-
// and define this blob
|
|
932
|
-
(resolvedSource = ''), (lastIndex = 0);
|
|
933
|
-
|
|
934
|
-
for (const { s: start, e: end, ss: statementStart, se: statementEnd, d: dynamicImportIndex, t, a } of imports) {
|
|
935
|
-
// source phase
|
|
936
|
-
if (t === 4) {
|
|
937
|
-
let { l: depLoad } = load.d[depIndex++];
|
|
938
|
-
pushStringTo(load, statementStart, dynamicImportEndStack);
|
|
939
|
-
resolvedSource += `${source.slice(statementStart, start - 1).replace('source', '')}/*${source.slice(start - 1, end + 1)}*/'${createBlob(`export default importShim._s[${urlJsString(depLoad.r)}]`)}'`;
|
|
940
|
-
lastIndex = end + 1;
|
|
941
|
-
}
|
|
942
|
-
// dependency source replacements
|
|
943
|
-
else if (dynamicImportIndex === -1) {
|
|
944
|
-
let keepAssertion = false;
|
|
945
|
-
if (a > 0 && !shimMode) {
|
|
946
|
-
const assertion = source.slice(a, statementEnd - 1);
|
|
947
|
-
// strip assertions only when unsupported in polyfill mode
|
|
948
|
-
keepAssertion =
|
|
949
|
-
nativePassthrough &&
|
|
950
|
-
((supportsJsonType && assertion.includes('json')) || (supportsCssType && assertion.includes('css')));
|
|
951
|
-
}
|
|
952
|
-
|
|
953
|
-
// defer phase stripping
|
|
954
|
-
if (t === 6) {
|
|
955
|
-
pushStringTo(load, statementStart, dynamicImportEndStack);
|
|
956
|
-
resolvedSource += source.slice(statementStart, start - 1).replace('defer', '');
|
|
957
|
-
lastIndex = start;
|
|
958
|
-
}
|
|
959
|
-
let { l: depLoad } = load.d[depIndex++],
|
|
960
|
-
blobUrl = depLoad.b,
|
|
961
|
-
cycleShell = !blobUrl;
|
|
962
|
-
if (cycleShell) {
|
|
963
|
-
// circular shell creation
|
|
964
|
-
if (!(blobUrl = depLoad.s)) {
|
|
965
|
-
blobUrl = depLoad.s = createBlob(
|
|
966
|
-
`export function u$_(m){${depLoad.a[1]
|
|
967
|
-
.map(({ s, e }, i) => {
|
|
968
|
-
const q = depLoad.S[s] === '"' || depLoad.S[s] === "'";
|
|
969
|
-
return `e$_${i}=m${q ? `[` : '.'}${depLoad.S.slice(s, e)}${q ? `]` : ''}`;
|
|
970
|
-
})
|
|
971
|
-
.join(',')}}${
|
|
972
|
-
depLoad.a[1].length ? `let ${depLoad.a[1].map((_, i) => `e$_${i}`).join(',')};` : ''
|
|
973
|
-
}export {${depLoad.a[1]
|
|
974
|
-
.map(({ s, e }, i) => `e$_${i} as ${depLoad.S.slice(s, e)}`)
|
|
975
|
-
.join(',')}}\n//# sourceURL=${depLoad.r}?cycle`
|
|
976
|
-
);
|
|
977
|
-
}
|
|
978
|
-
}
|
|
979
|
-
|
|
980
|
-
pushStringTo(load, start - 1, dynamicImportEndStack);
|
|
981
|
-
resolvedSource += `/*${source.slice(start - 1, end + 1)}*/'${blobUrl}'`;
|
|
982
|
-
|
|
983
|
-
// circular shell execution
|
|
984
|
-
if (!cycleShell && depLoad.s) {
|
|
985
|
-
resolvedSource += `;import*as m$_${depIndex} from'${depLoad.b}';import{u$_ as u$_${depIndex}}from'${depLoad.s}';u$_${depIndex}(m$_${depIndex})`;
|
|
986
|
-
depLoad.s = undefined;
|
|
987
|
-
}
|
|
988
|
-
lastIndex = keepAssertion ? end + 1 : statementEnd;
|
|
989
|
-
}
|
|
990
|
-
// import.meta
|
|
991
|
-
else if (dynamicImportIndex === -2) {
|
|
992
|
-
load.m = { url: load.r, resolve: metaResolve };
|
|
993
|
-
if (metaHook) metaHook(load.m, load.u);
|
|
994
|
-
pushStringTo(load, start, dynamicImportEndStack);
|
|
995
|
-
resolvedSource += `importShim._r[${urlJsString(load.u)}].m`;
|
|
996
|
-
lastIndex = statementEnd;
|
|
997
|
-
}
|
|
998
|
-
// dynamic import
|
|
999
|
-
else {
|
|
1000
|
-
pushStringTo(load, statementStart + 6, dynamicImportEndStack);
|
|
1001
|
-
resolvedSource += `Shim${t === 5 ? '.source' : ''}(`;
|
|
1002
|
-
dynamicImportEndStack.push(statementEnd - 1);
|
|
1003
|
-
lastIndex = start;
|
|
1004
|
-
}
|
|
1005
|
-
}
|
|
1006
|
-
|
|
1007
|
-
// support progressive cycle binding updates (try statement avoids tdz errors)
|
|
1008
|
-
if (load.s && (imports.length === 0 || imports[imports.length - 1].d === -1))
|
|
1009
|
-
resolvedSource += `\n;import{u$_}from'${load.s}';try{u$_({${exports
|
|
1010
|
-
.filter(e => e.ln)
|
|
1011
|
-
.map(({ s, e, ln }) => `${source.slice(s, e)}:${ln}`)
|
|
1012
|
-
.join(',')}})}catch(_){};\n`;
|
|
1013
|
-
|
|
1014
|
-
let sourceURLCommentStart = source.lastIndexOf(sourceURLCommentPrefix);
|
|
1015
|
-
let sourceMapURLCommentStart = source.lastIndexOf(sourceMapURLCommentPrefix);
|
|
1016
|
-
|
|
1017
|
-
// ignore sourceMap comments before already spliced code
|
|
1018
|
-
if (sourceURLCommentStart < lastIndex) sourceURLCommentStart = -1;
|
|
1019
|
-
if (sourceMapURLCommentStart < lastIndex) sourceMapURLCommentStart = -1;
|
|
1020
|
-
|
|
1021
|
-
// sourceURL first / only
|
|
1022
|
-
if (
|
|
1023
|
-
sourceURLCommentStart !== -1 &&
|
|
1024
|
-
(sourceMapURLCommentStart === -1 || sourceMapURLCommentStart > sourceURLCommentStart)
|
|
1025
|
-
) {
|
|
1026
|
-
pushSourceURL(load, sourceURLCommentPrefix, sourceURLCommentStart, dynamicImportEndStack);
|
|
1027
|
-
}
|
|
1028
|
-
// sourceMappingURL
|
|
1029
|
-
if (sourceMapURLCommentStart !== -1) {
|
|
1030
|
-
pushSourceURL(load, sourceMapURLCommentPrefix, sourceMapURLCommentStart, dynamicImportEndStack);
|
|
1031
|
-
// sourceURL last
|
|
1032
|
-
if (sourceURLCommentStart !== -1 && sourceURLCommentStart > sourceMapURLCommentStart)
|
|
1033
|
-
pushSourceURL(load, sourceURLCommentPrefix, sourceURLCommentStart, dynamicImportEndStack);
|
|
1034
|
-
}
|
|
1035
|
-
|
|
1036
|
-
pushStringTo(load, source.length, dynamicImportEndStack);
|
|
1037
|
-
|
|
1038
|
-
if (sourceURLCommentStart === -1) resolvedSource += sourceURLCommentPrefix + load.r;
|
|
1039
|
-
|
|
1040
|
-
load.b = createBlob(resolvedSource);
|
|
1041
|
-
load.S = resolvedSource = undefined;
|
|
1042
|
-
};
|
|
1043
|
-
|
|
1044
|
-
const sourceURLCommentPrefix = '\n//# sourceURL=';
|
|
1045
|
-
const sourceMapURLCommentPrefix = '\n//# sourceMappingURL=';
|
|
1046
|
-
|
|
1047
|
-
const jsContentType = /^(text|application)\/(x-)?javascript(;|$)/;
|
|
1048
|
-
const wasmContentType = /^application\/wasm(;|$)/;
|
|
1049
|
-
const jsonContentType = /^(text|application)\/json(;|$)/;
|
|
1050
|
-
const cssContentType = /^(text|application)\/css(;|$)/;
|
|
1051
|
-
const tsContentType = /^application\/typescript(;|$)|/;
|
|
1052
|
-
|
|
1053
|
-
const cssUrlRegEx = /url\(\s*(?:(["'])((?:\\.|[^\n\\"'])+)\1|((?:\\.|[^\s,"'()\\])+))\s*\)/g;
|
|
1054
|
-
|
|
1055
|
-
// restrict in-flight fetches to a pool of 100
|
|
1056
|
-
let p = [];
|
|
1057
|
-
let c = 0;
|
|
1058
|
-
const pushFetchPool = () => {
|
|
1059
|
-
if (++c > 100) return new Promise(r => p.push(r));
|
|
1060
|
-
};
|
|
1061
|
-
const popFetchPool = () => {
|
|
1062
|
-
c--;
|
|
1063
|
-
if (p.length) p.shift()();
|
|
1064
|
-
};
|
|
1065
|
-
|
|
1066
|
-
const doFetch = async (url, fetchOpts, parent) => {
|
|
1067
|
-
if (enforceIntegrity && !fetchOpts.integrity) throw Error(`No integrity for ${url}${fromParent(parent)}.`);
|
|
1068
|
-
const poolQueue = pushFetchPool();
|
|
1069
|
-
if (poolQueue) await poolQueue;
|
|
1070
|
-
try {
|
|
1071
|
-
var res = await fetchHook(url, fetchOpts);
|
|
1072
|
-
} catch (e) {
|
|
1073
|
-
e.message = `Unable to fetch ${url}${fromParent(parent)} - see network log for details.\n` + e.message;
|
|
1074
|
-
throw e;
|
|
1075
|
-
} finally {
|
|
1076
|
-
popFetchPool();
|
|
1077
|
-
}
|
|
1078
|
-
|
|
1079
|
-
if (!res.ok) {
|
|
1080
|
-
const error = new TypeError(`${res.status} ${res.statusText} ${res.url}${fromParent(parent)}`);
|
|
1081
|
-
error.response = res;
|
|
1082
|
-
throw error;
|
|
1083
|
-
}
|
|
1084
|
-
return res;
|
|
1085
|
-
};
|
|
1086
|
-
|
|
1087
|
-
let esmsTsTransform;
|
|
1088
|
-
const initTs = async () => {
|
|
1089
|
-
const m = await import(tsTransform);
|
|
1090
|
-
if (!esmsTsTransform) esmsTsTransform = m.transform;
|
|
1091
|
-
};
|
|
1092
|
-
|
|
1093
|
-
const hotPrefix = 'var h=import.meta.hot,';
|
|
1094
|
-
const fetchModule = async (url, fetchOpts, parent) => {
|
|
1095
|
-
const mapIntegrity = composedImportMap.integrity[url];
|
|
1096
|
-
const res = await doFetch(
|
|
1097
|
-
url,
|
|
1098
|
-
mapIntegrity && !fetchOpts.integrity ? { ...fetchOpts, integrity: mapIntegrity } : fetchOpts,
|
|
1099
|
-
parent
|
|
1100
|
-
);
|
|
1101
|
-
const r = res.url;
|
|
1102
|
-
const contentType = res.headers.get('content-type');
|
|
1103
|
-
if (jsContentType.test(contentType)) return { r, s: await res.text(), t: 'js' };
|
|
1104
|
-
else if (wasmContentType.test(contentType)) {
|
|
1105
|
-
const wasmModule = await (sourceCache[r] || (sourceCache[r] = WebAssembly.compileStreaming(res)));
|
|
1106
|
-
const exports = WebAssembly.Module.exports(wasmModule);
|
|
1107
|
-
sourceCache[r] = wasmModule;
|
|
1108
|
-
const rStr = urlJsString(r);
|
|
1109
|
-
let s = `import*as $_ns from${rStr};`,
|
|
1110
|
-
i = 0,
|
|
1111
|
-
obj = '';
|
|
1112
|
-
for (const { module, kind } of WebAssembly.Module.imports(wasmModule)) {
|
|
1113
|
-
const specifier = urlJsString(module);
|
|
1114
|
-
s += `import*as impt${i} from${specifier};\n`;
|
|
1115
|
-
obj += `${specifier}:${kind === 'global' ? `importShim._i.get(impt${i})||impt${i++}` : `impt${i++}`},`;
|
|
1116
|
-
}
|
|
1117
|
-
s += `${hotPrefix}i=await WebAssembly.instantiate(importShim._s[${rStr}],{${obj}});importShim._i.set($_ns,i);`;
|
|
1118
|
-
obj = '';
|
|
1119
|
-
for (const { name, kind } of exports) {
|
|
1120
|
-
s += `export let ${name}=i.exports['${name}'];`;
|
|
1121
|
-
if (kind === 'global') s += `try{${name}=${name}.value}catch{${name}=undefined}`;
|
|
1122
|
-
obj += `${name},`;
|
|
1123
|
-
}
|
|
1124
|
-
s += `if(h)h.accept(m=>({${obj}}=m))`;
|
|
1125
|
-
return { r, s, t: 'wasm' };
|
|
1126
|
-
} else if (jsonContentType.test(contentType))
|
|
1127
|
-
return {
|
|
1128
|
-
r,
|
|
1129
|
-
s: `${hotPrefix}j=${await res.text()};export{j as default};if(h)h.accept(m=>j=m.default)`,
|
|
1130
|
-
t: 'json'
|
|
1131
|
-
};
|
|
1132
|
-
else if (cssContentType.test(contentType)) {
|
|
1133
|
-
return {
|
|
1134
|
-
r,
|
|
1135
|
-
s: `${hotPrefix}s=h&&h.data.s||new CSSStyleSheet();s.replaceSync(${JSON.stringify(
|
|
1136
|
-
(await res.text()).replace(
|
|
1137
|
-
cssUrlRegEx,
|
|
1138
|
-
(_match, quotes = '', relUrl1, relUrl2) => `url(${quotes}${resolveUrl(relUrl1 || relUrl2, url)}${quotes})`
|
|
1139
|
-
)
|
|
1140
|
-
)});if(h){h.data.s=s;h.accept(()=>{})}export default s`,
|
|
1141
|
-
t: 'css'
|
|
1142
|
-
};
|
|
1143
|
-
} else if (tsContentType.test(contentType) || url.endsWith('.ts') || url.endsWith('.mts')) {
|
|
1144
|
-
const source = await res.text();
|
|
1145
|
-
if (!esmsTsTransform) await initTs();
|
|
1146
|
-
const transformed = esmsTsTransform(source, url);
|
|
1147
|
-
// even if the TypeScript is valid JavaScript, unless it was a top-level inline source, it wasn't served with
|
|
1148
|
-
// a valid JS MIME here, so we must still polyfill it
|
|
1149
|
-
return { r, s: transformed === undefined ? source : transformed, t: 'ts' };
|
|
1150
|
-
} else
|
|
1151
|
-
throw Error(
|
|
1152
|
-
`Unsupported Content-Type "${contentType}" loading ${url}${fromParent(parent)}. Modules must be served with a valid MIME type like application/javascript.`
|
|
1153
|
-
);
|
|
1154
|
-
};
|
|
1155
|
-
|
|
1156
|
-
const isUnsupportedType = type => {
|
|
1157
|
-
if (type === 'wasm' && !wasmInstancePhaseEnabled && !wasmSourcePhaseEnabled) throw featErr(`wasm-modules`);
|
|
1158
|
-
return (
|
|
1159
|
-
(type === 'css' && !supportsCssType) ||
|
|
1160
|
-
(type === 'json' && !supportsJsonType) ||
|
|
1161
|
-
(type === 'wasm' && !supportsWasmInstancePhase && !supportsWasmSourcePhase) ||
|
|
1162
|
-
type === 'ts'
|
|
1163
|
-
);
|
|
1164
|
-
};
|
|
1165
|
-
|
|
1166
|
-
const getOrCreateLoad = (url, fetchOpts, parent, source) => {
|
|
1167
|
-
if (source && registry[url]) {
|
|
1168
|
-
let i = 0;
|
|
1169
|
-
while (registry[url + '#' + ++i]);
|
|
1170
|
-
url += '#' + i;
|
|
1171
|
-
}
|
|
1172
|
-
let load = registry[url];
|
|
1173
|
-
if (load) return load;
|
|
1174
|
-
registry[url] = load = {
|
|
1175
|
-
// url
|
|
1176
|
-
u: url,
|
|
1177
|
-
// response url
|
|
1178
|
-
r: source ? url : undefined,
|
|
1179
|
-
// fetchPromise
|
|
1180
|
-
f: undefined,
|
|
1181
|
-
// source
|
|
1182
|
-
S: source,
|
|
1183
|
-
// linkPromise
|
|
1184
|
-
L: undefined,
|
|
1185
|
-
// analysis
|
|
1186
|
-
a: undefined,
|
|
1187
|
-
// deps
|
|
1188
|
-
d: undefined,
|
|
1189
|
-
// blobUrl
|
|
1190
|
-
b: undefined,
|
|
1191
|
-
// shellUrl
|
|
1192
|
-
s: undefined,
|
|
1193
|
-
// needsShim: does it fail execution in the current native loader?
|
|
1194
|
-
n: false,
|
|
1195
|
-
// shouldShim: does it need to be loaded by the polyfill loader?
|
|
1196
|
-
N: false,
|
|
1197
|
-
// type
|
|
1198
|
-
t: null,
|
|
1199
|
-
// meta
|
|
1200
|
-
m: null
|
|
1201
|
-
};
|
|
1202
|
-
load.f = (async () => {
|
|
1203
|
-
if (load.S === undefined) {
|
|
1204
|
-
// preload fetch options override fetch options (race)
|
|
1205
|
-
({ r: load.r, s: load.S, t: load.t } = await (fetchCache[url] || fetchModule(url, fetchOpts, parent)));
|
|
1206
|
-
if (!load.n && load.t !== 'js' && !shimMode && isUnsupportedType(load.t)) {
|
|
1207
|
-
load.n = true;
|
|
1208
|
-
}
|
|
1209
|
-
}
|
|
1210
|
-
try {
|
|
1211
|
-
load.a = parse(load.S, load.u);
|
|
1212
|
-
} catch (e) {
|
|
1213
|
-
throwError(e);
|
|
1214
|
-
load.a = [[], [], false];
|
|
1215
|
-
}
|
|
1216
|
-
return load;
|
|
1217
|
-
})();
|
|
1218
|
-
return load;
|
|
1219
|
-
};
|
|
1220
|
-
|
|
1221
|
-
const featErr = feat =>
|
|
1222
|
-
Error(
|
|
1223
|
-
`${feat} feature must be enabled via <script type="esms-options">{ "polyfillEnable": ["${feat}"] }<${''}/script>`
|
|
1224
|
-
);
|
|
1225
|
-
|
|
1226
|
-
const linkLoad = (load, fetchOpts) => {
|
|
1227
|
-
if (load.L) return;
|
|
1228
|
-
load.L = load.f.then(async () => {
|
|
1229
|
-
let childFetchOpts = fetchOpts;
|
|
1230
|
-
load.d = load.a[0]
|
|
1231
|
-
.map(({ n, d, t, a, se }) => {
|
|
1232
|
-
const phaseImport = t >= 4;
|
|
1233
|
-
const sourcePhase = phaseImport && t < 6;
|
|
1234
|
-
if (phaseImport) {
|
|
1235
|
-
if (!shimMode && (sourcePhase ? !wasmSourcePhaseEnabled : !deferPhaseEnabled))
|
|
1236
|
-
throw featErr(sourcePhase ? 'wasm-module-sources' : 'import-defer');
|
|
1237
|
-
if (!sourcePhase || !supportsWasmSourcePhase) load.n = true;
|
|
1238
|
-
}
|
|
1239
|
-
let source = undefined;
|
|
1240
|
-
if (a > 0 && !shimMode && nativePassthrough) {
|
|
1241
|
-
const assertion = load.S.slice(a, se - 1);
|
|
1242
|
-
// no need to fetch JSON/CSS if supported, since it's a leaf node, we'll just strip the assertion syntax
|
|
1243
|
-
if (assertion.includes('json')) {
|
|
1244
|
-
if (supportsJsonType) source = '';
|
|
1245
|
-
else load.n = true;
|
|
1246
|
-
} else if (assertion.includes('css')) {
|
|
1247
|
-
if (supportsCssType) source = '';
|
|
1248
|
-
else load.n = true;
|
|
1249
|
-
}
|
|
1250
|
-
}
|
|
1251
|
-
if (d !== -1 || !n) return;
|
|
1252
|
-
const resolved = resolve(n, load.r || load.u);
|
|
1253
|
-
if (resolved.n) load.n = true;
|
|
1254
|
-
if (d >= 0 || resolved.N) load.N = true;
|
|
1255
|
-
if (d !== -1) return;
|
|
1256
|
-
if (skip && skip(resolved.r) && !sourcePhase) return { l: { b: resolved.r }, s: false };
|
|
1257
|
-
if (childFetchOpts.integrity) childFetchOpts = { ...childFetchOpts, integrity: undefined };
|
|
1258
|
-
const child = { l: getOrCreateLoad(resolved.r, childFetchOpts, load.r, source), s: sourcePhase };
|
|
1259
|
-
// assertion case -> inline the CSS / JSON URL directly
|
|
1260
|
-
if (source === '') child.l.b = child.l.u;
|
|
1261
|
-
if (!child.s) linkLoad(child.l, fetchOpts);
|
|
1262
|
-
// load, sourcePhase
|
|
1263
|
-
return child;
|
|
1264
|
-
})
|
|
1265
|
-
.filter(l => l);
|
|
1266
|
-
});
|
|
1267
|
-
};
|
|
1268
|
-
|
|
1269
|
-
const processScriptsAndPreloads = () => {
|
|
1270
|
-
for (const link of document.querySelectorAll(shimMode ? 'link[rel=modulepreload-shim]' : 'link[rel=modulepreload]')) {
|
|
1271
|
-
if (!link.ep) processPreload(link);
|
|
1272
|
-
}
|
|
1273
|
-
for (const script of document.querySelectorAll('script[type]')) {
|
|
1274
|
-
if (script.type === 'importmap' + (shimMode ? '-shim' : '')) {
|
|
1275
|
-
if (!script.ep) processImportMap(script);
|
|
1276
|
-
} else if (script.type === 'module' + (shimMode ? '-shim' : '')) {
|
|
1277
|
-
legacyAcceptingImportMaps = false;
|
|
1278
|
-
if (!script.ep) processScript(script);
|
|
1279
|
-
}
|
|
1280
|
-
}
|
|
1281
|
-
};
|
|
1282
|
-
|
|
1283
|
-
const getFetchOpts = script => {
|
|
1284
|
-
const fetchOpts = {};
|
|
1285
|
-
if (script.integrity) fetchOpts.integrity = script.integrity;
|
|
1286
|
-
if (script.referrerPolicy) fetchOpts.referrerPolicy = script.referrerPolicy;
|
|
1287
|
-
if (script.fetchPriority) fetchOpts.priority = script.fetchPriority;
|
|
1288
|
-
if (script.crossOrigin === 'use-credentials') fetchOpts.credentials = 'include';
|
|
1289
|
-
else if (script.crossOrigin === 'anonymous') fetchOpts.credentials = 'omit';
|
|
1290
|
-
else fetchOpts.credentials = 'same-origin';
|
|
1291
|
-
return fetchOpts;
|
|
1292
|
-
};
|
|
1293
|
-
|
|
1294
|
-
let lastStaticLoadPromise = Promise.resolve();
|
|
1295
|
-
|
|
1296
|
-
let domContentLoaded = false;
|
|
1297
|
-
let domContentLoadedCnt = 1;
|
|
1298
|
-
const domContentLoadedCheck = m => {
|
|
1299
|
-
if (m === undefined) {
|
|
1300
|
-
if (domContentLoaded) return;
|
|
1301
|
-
domContentLoaded = true;
|
|
1302
|
-
domContentLoadedCnt--;
|
|
1303
|
-
}
|
|
1304
|
-
if (--domContentLoadedCnt === 0 && !noLoadEventRetriggers && (shimMode || !baselinePassthrough)) {
|
|
1305
|
-
document.removeEventListener('DOMContentLoaded', domContentLoadedEvent);
|
|
1306
|
-
document.dispatchEvent(new Event('DOMContentLoaded'));
|
|
1307
|
-
}
|
|
1308
|
-
};
|
|
1309
|
-
let loadCnt = 1;
|
|
1310
|
-
const loadCheck = () => {
|
|
1311
|
-
if (--loadCnt === 0 && !noLoadEventRetriggers && (shimMode || !baselinePassthrough)) {
|
|
1312
|
-
window.removeEventListener('load', loadEvent);
|
|
1313
|
-
window.dispatchEvent(new Event('load'));
|
|
1314
|
-
}
|
|
1315
|
-
};
|
|
1316
|
-
|
|
1317
|
-
const domContentLoadedEvent = async () => {
|
|
1318
|
-
await initPromise;
|
|
1319
|
-
domContentLoadedCheck();
|
|
1320
|
-
};
|
|
1321
|
-
const loadEvent = async () => {
|
|
1322
|
-
await initPromise;
|
|
1323
|
-
domContentLoadedCheck();
|
|
1324
|
-
loadCheck();
|
|
1325
|
-
};
|
|
1326
|
-
|
|
1327
|
-
// this should always trigger because we assume es-module-shims is itself a domcontentloaded requirement
|
|
1328
|
-
if (hasDocument) {
|
|
1329
|
-
document.addEventListener('DOMContentLoaded', domContentLoadedEvent);
|
|
1330
|
-
window.addEventListener('load', loadEvent);
|
|
1331
|
-
}
|
|
1332
|
-
|
|
1333
|
-
const readyListener = async () => {
|
|
1334
|
-
await initPromise;
|
|
1335
|
-
processScriptsAndPreloads();
|
|
1336
|
-
if (document.readyState === 'complete') {
|
|
1337
|
-
readyStateCompleteCheck();
|
|
1338
|
-
}
|
|
1339
|
-
};
|
|
1340
|
-
|
|
1341
|
-
let readyStateCompleteCnt = 1;
|
|
1342
|
-
const readyStateCompleteCheck = () => {
|
|
1343
|
-
if (--readyStateCompleteCnt === 0) {
|
|
1344
|
-
domContentLoadedCheck();
|
|
1345
|
-
if (!noLoadEventRetriggers && (shimMode || !baselinePassthrough)) {
|
|
1346
|
-
document.removeEventListener('readystatechange', readyListener);
|
|
1347
|
-
document.dispatchEvent(new Event('readystatechange'));
|
|
1348
|
-
}
|
|
1349
|
-
}
|
|
1350
|
-
};
|
|
1351
|
-
|
|
1352
|
-
const hasNext = script => script.nextSibling || (script.parentNode && hasNext(script.parentNode));
|
|
1353
|
-
const epCheck = (script, ready) =>
|
|
1354
|
-
script.ep ||
|
|
1355
|
-
(!ready && ((!script.src && !script.innerHTML) || !hasNext(script))) ||
|
|
1356
|
-
script.getAttribute('noshim') !== null ||
|
|
1357
|
-
!(script.ep = true);
|
|
1358
|
-
|
|
1359
|
-
const processImportMap = (script, ready = readyStateCompleteCnt > 0) => {
|
|
1360
|
-
if (epCheck(script, ready)) return;
|
|
1361
|
-
// we dont currently support external import maps in polyfill mode to match native
|
|
1362
|
-
if (script.src) {
|
|
1363
|
-
if (!shimMode) return;
|
|
1364
|
-
importMapSrc = true;
|
|
1365
|
-
}
|
|
1366
|
-
importMapPromise = importMapPromise
|
|
1367
|
-
.then(async () => {
|
|
1368
|
-
composedImportMap = resolveAndComposeImportMap(
|
|
1369
|
-
script.src ? await (await doFetch(script.src, getFetchOpts(script))).json() : JSON.parse(script.innerHTML),
|
|
1370
|
-
script.src || baseUrl,
|
|
1371
|
-
composedImportMap
|
|
1372
|
-
);
|
|
1373
|
-
})
|
|
1374
|
-
.catch(e => {
|
|
1375
|
-
if (e instanceof SyntaxError)
|
|
1376
|
-
e = new Error(`Unable to parse import map ${e.message} in: ${script.src || script.innerHTML}`);
|
|
1377
|
-
throwError(e);
|
|
1378
|
-
});
|
|
1379
|
-
if (!firstImportMap && legacyAcceptingImportMaps) importMapPromise.then(() => (firstImportMap = composedImportMap));
|
|
1380
|
-
if (!legacyAcceptingImportMaps && !multipleImportMaps) {
|
|
1381
|
-
multipleImportMaps = true;
|
|
1382
|
-
if (!shimMode && baselinePassthrough && !supportsMultipleImportMaps) {
|
|
1383
|
-
baselinePassthrough = false;
|
|
1384
|
-
if (hasDocument) attachMutationObserver();
|
|
1385
|
-
}
|
|
1386
|
-
}
|
|
1387
|
-
legacyAcceptingImportMaps = false;
|
|
1388
|
-
};
|
|
1389
|
-
|
|
1390
|
-
const processScript = (script, ready = readyStateCompleteCnt > 0) => {
|
|
1391
|
-
if (epCheck(script, ready)) return;
|
|
1392
|
-
// does this load block readystate complete
|
|
1393
|
-
const isBlockingReadyScript = script.getAttribute('async') === null && readyStateCompleteCnt > 0;
|
|
1394
|
-
// does this load block DOMContentLoaded
|
|
1395
|
-
const isDomContentLoadedScript = domContentLoadedCnt > 0;
|
|
1396
|
-
const isLoadScript = loadCnt > 0;
|
|
1397
|
-
if (isLoadScript) loadCnt++;
|
|
1398
|
-
if (isBlockingReadyScript) readyStateCompleteCnt++;
|
|
1399
|
-
if (isDomContentLoadedScript) domContentLoadedCnt++;
|
|
1400
|
-
let loadPromise;
|
|
1401
|
-
const ts = script.lang === 'ts';
|
|
1402
|
-
if (ts && !script.src) {
|
|
1403
|
-
loadPromise = Promise.resolve(esmsTsTransform || initTs())
|
|
1404
|
-
.then(() => {
|
|
1405
|
-
const transformed = esmsTsTransform(script.innerHTML, baseUrl);
|
|
1406
|
-
if (transformed !== undefined) {
|
|
1407
|
-
onpolyfill();
|
|
1408
|
-
firstPolyfillLoad = false;
|
|
1409
|
-
}
|
|
1410
|
-
return topLevelLoad(
|
|
1411
|
-
script.src || baseUrl,
|
|
1412
|
-
baseUrl,
|
|
1413
|
-
getFetchOpts(script),
|
|
1414
|
-
transformed === undefined ? script.innerHTML : transformed,
|
|
1415
|
-
!shimMode && transformed === undefined,
|
|
1416
|
-
isBlockingReadyScript && lastStaticLoadPromise,
|
|
1417
|
-
'ts'
|
|
1418
|
-
);
|
|
1419
|
-
})
|
|
1420
|
-
.catch(throwError);
|
|
1421
|
-
} else {
|
|
1422
|
-
loadPromise = topLevelLoad(
|
|
1423
|
-
script.src || baseUrl,
|
|
1424
|
-
baseUrl,
|
|
1425
|
-
getFetchOpts(script),
|
|
1426
|
-
!script.src ? script.innerHTML : undefined,
|
|
1427
|
-
!shimMode,
|
|
1428
|
-
isBlockingReadyScript && lastStaticLoadPromise,
|
|
1429
|
-
ts ? 'ts' : undefined
|
|
1430
|
-
).catch(throwError);
|
|
1431
|
-
}
|
|
1432
|
-
if (!noLoadEventRetriggers) loadPromise.then(() => script.dispatchEvent(new Event('load')));
|
|
1433
|
-
if (isBlockingReadyScript && !ts) {
|
|
1434
|
-
lastStaticLoadPromise = loadPromise.then(readyStateCompleteCheck);
|
|
1435
|
-
}
|
|
1436
|
-
if (isDomContentLoadedScript) loadPromise.then(domContentLoadedCheck);
|
|
1437
|
-
if (isLoadScript) loadPromise.then(loadCheck);
|
|
1438
|
-
};
|
|
1439
|
-
|
|
1440
|
-
const fetchCache = {};
|
|
1441
|
-
const processPreload = link => {
|
|
1442
|
-
link.ep = true;
|
|
1443
|
-
if (fetchCache[link.href]) return;
|
|
1444
|
-
fetchCache[link.href] = fetchModule(link.href, getFetchOpts(link));
|
|
584
|
+
const _resolve = (id, parentUrl = baseUrl) => {
|
|
585
|
+
const urlResolved = resolveIfNotPlainOrUrl(id, parentUrl) || asURL(id);
|
|
586
|
+
const firstResolved = firstImportMap && resolveImportMap(firstImportMap, urlResolved || id, parentUrl);
|
|
587
|
+
const composedResolved =
|
|
588
|
+
composedImportMap === firstImportMap ? firstResolved : (
|
|
589
|
+
resolveImportMap(composedImportMap, urlResolved || id, parentUrl)
|
|
590
|
+
);
|
|
591
|
+
const resolved = composedResolved || firstResolved || throwUnresolved(id, parentUrl);
|
|
592
|
+
// needsShim, shouldShim per load record to set on parent
|
|
593
|
+
let n = false,
|
|
594
|
+
N = false;
|
|
595
|
+
if (!supportsImportMaps) {
|
|
596
|
+
// bare specifier -> needs shim
|
|
597
|
+
if (!urlResolved) n = true;
|
|
598
|
+
// url mapping -> should shim
|
|
599
|
+
else if (urlResolved !== resolved) N = true;
|
|
600
|
+
} else if (!supportsMultipleImportMaps) {
|
|
601
|
+
// bare specifier and not resolved by first import map -> needs shim
|
|
602
|
+
if (!urlResolved && !firstResolved) n = true;
|
|
603
|
+
// resolution doesn't match first import map -> should shim
|
|
604
|
+
if (firstResolved && resolved !== firstResolved) N = true;
|
|
605
|
+
}
|
|
606
|
+
return { r: resolved, n, N };
|
|
607
|
+
};
|
|
608
|
+
|
|
609
|
+
const resolve = (id, parentUrl) => {
|
|
610
|
+
if (!resolveHook) return _resolve(id, parentUrl);
|
|
611
|
+
const result = resolveHook(id, parentUrl, defaultResolve);
|
|
612
|
+
|
|
613
|
+
return result ? { r: result, n: true, N: true } : _resolve(id, parentUrl);
|
|
614
|
+
};
|
|
615
|
+
|
|
616
|
+
// import()
|
|
617
|
+
async function importShim$1(id, opts, parentUrl) {
|
|
618
|
+
if (typeof opts === 'string') {
|
|
619
|
+
parentUrl = opts;
|
|
620
|
+
opts = undefined;
|
|
621
|
+
}
|
|
622
|
+
await initPromise; // needed for shim check
|
|
623
|
+
if (shimMode || !baselinePassthrough) {
|
|
624
|
+
if (hasDocument) processScriptsAndPreloads();
|
|
625
|
+
legacyAcceptingImportMaps = false;
|
|
626
|
+
}
|
|
627
|
+
let sourceType = undefined;
|
|
628
|
+
if (typeof opts === 'object') {
|
|
629
|
+
if (opts.lang === 'ts') sourceType = 'ts';
|
|
630
|
+
if (typeof opts.with === 'object' && typeof opts.with.type === 'string') {
|
|
631
|
+
sourceType = opts.with.type;
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
return topLevelLoad(id, parentUrl || baseUrl, defaultFetchOpts, undefined, undefined, undefined, sourceType);
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
// import.source()
|
|
638
|
+
// (opts not currently supported as no use cases yet)
|
|
639
|
+
if (shimMode || wasmSourcePhaseEnabled)
|
|
640
|
+
importShim$1.source = async (id, opts, parentUrl) => {
|
|
641
|
+
if (typeof opts === 'string') {
|
|
642
|
+
parentUrl = opts;
|
|
643
|
+
opts = undefined;
|
|
644
|
+
}
|
|
645
|
+
await initPromise; // needed for shim check
|
|
646
|
+
if (shimMode || !baselinePassthrough) {
|
|
647
|
+
if (hasDocument) processScriptsAndPreloads();
|
|
648
|
+
legacyAcceptingImportMaps = false;
|
|
649
|
+
}
|
|
650
|
+
await importMapPromise;
|
|
651
|
+
const url = resolve(id, parentUrl || baseUrl).r;
|
|
652
|
+
const load = getOrCreateLoad(url, defaultFetchOpts, undefined, undefined);
|
|
653
|
+
if (firstPolyfillLoad && !shimMode && load.n && nativelyLoaded) {
|
|
654
|
+
onpolyfill();
|
|
655
|
+
firstPolyfillLoad = false;
|
|
656
|
+
}
|
|
657
|
+
await load.f;
|
|
658
|
+
return importShim$1._s[load.r];
|
|
659
|
+
};
|
|
660
|
+
|
|
661
|
+
// import.defer() is just a proxy for import(), since we can't actually defer
|
|
662
|
+
if (shimMode || deferPhaseEnabled) importShim$1.defer = importShim$1;
|
|
663
|
+
|
|
664
|
+
if (hotReload) importShim$1.hotReload = hotReload$1;
|
|
665
|
+
|
|
666
|
+
const defaultResolve = (id, parentUrl) => {
|
|
667
|
+
return (
|
|
668
|
+
resolveImportMap(composedImportMap, resolveIfNotPlainOrUrl(id, parentUrl) || id, parentUrl) ||
|
|
669
|
+
throwUnresolved(id, parentUrl)
|
|
670
|
+
);
|
|
671
|
+
};
|
|
672
|
+
|
|
673
|
+
const throwUnresolved = (id, parentUrl) => {
|
|
674
|
+
throw Error(`Unable to resolve specifier '${id}'${fromParent(parentUrl)}`);
|
|
675
|
+
};
|
|
676
|
+
|
|
677
|
+
const metaResolve = function (id, parentUrl = this.url) {
|
|
678
|
+
return resolve(id, `${parentUrl}`).r;
|
|
679
|
+
};
|
|
680
|
+
|
|
681
|
+
importShim$1.resolve = (id, parentUrl) => resolve(id, parentUrl).r;
|
|
682
|
+
importShim$1.getImportMap = () => JSON.parse(JSON.stringify(composedImportMap));
|
|
683
|
+
importShim$1.addImportMap = importMapIn => {
|
|
684
|
+
if (!shimMode) throw new Error('Unsupported in polyfill mode.');
|
|
685
|
+
composedImportMap = resolveAndComposeImportMap(importMapIn, baseUrl, composedImportMap);
|
|
686
|
+
};
|
|
687
|
+
importShim$1.version = version;
|
|
688
|
+
|
|
689
|
+
const registry = (importShim$1._r = {});
|
|
690
|
+
// Wasm caches
|
|
691
|
+
const sourceCache = (importShim$1._s = {});
|
|
692
|
+
(importShim$1._i = new WeakMap());
|
|
693
|
+
|
|
694
|
+
// Ensure this version is the only version
|
|
695
|
+
defineValue(self, 'importShim', Object.freeze(importShim$1));
|
|
696
|
+
const shimModeOptions = { ...esmsInitOptions, shimMode: true };
|
|
697
|
+
if (optionsScript) optionsScript.innerHTML = JSON.stringify(shimModeOptions);
|
|
698
|
+
self.esmsInitOptions = shimModeOptions;
|
|
699
|
+
|
|
700
|
+
const loadAll = async (load, seen) => {
|
|
701
|
+
seen[load.u] = 1;
|
|
702
|
+
await load.L;
|
|
703
|
+
await Promise.all(
|
|
704
|
+
load.d.map(({ l: dep, s: sourcePhase }) => {
|
|
705
|
+
if (dep.b || seen[dep.u]) return;
|
|
706
|
+
if (sourcePhase) return dep.f;
|
|
707
|
+
return loadAll(dep, seen);
|
|
708
|
+
})
|
|
709
|
+
);
|
|
710
|
+
};
|
|
711
|
+
|
|
712
|
+
let importMapSrc = false;
|
|
713
|
+
let multipleImportMaps = false;
|
|
714
|
+
let firstImportMap = null;
|
|
715
|
+
// To support polyfilling multiple import maps, we separately track the composed import map from the first import map
|
|
716
|
+
let composedImportMap = { imports: {}, scopes: {}, integrity: {} };
|
|
717
|
+
let baselinePassthrough;
|
|
718
|
+
|
|
719
|
+
const initPromise = featureDetectionPromise.then(() => {
|
|
720
|
+
baselinePassthrough =
|
|
721
|
+
esmsInitOptions.polyfillEnable !== true &&
|
|
722
|
+
supportsImportMaps &&
|
|
723
|
+
supportsJsonType &&
|
|
724
|
+
supportsCssType &&
|
|
725
|
+
(!wasmInstancePhaseEnabled || supportsWasmInstancePhase) &&
|
|
726
|
+
(!wasmSourcePhaseEnabled || supportsWasmSourcePhase) &&
|
|
727
|
+
!deferPhaseEnabled &&
|
|
728
|
+
(!multipleImportMaps || supportsMultipleImportMaps) &&
|
|
729
|
+
!importMapSrc;
|
|
730
|
+
if (!shimMode && typeof WebAssembly !== 'undefined') {
|
|
731
|
+
if (wasmSourcePhaseEnabled && !Object.getPrototypeOf(WebAssembly.Module).name) {
|
|
732
|
+
const s = Symbol();
|
|
733
|
+
const brand = m => defineValue(m, s, 'WebAssembly.Module');
|
|
734
|
+
class AbstractModuleSource {
|
|
735
|
+
get [Symbol.toStringTag]() {
|
|
736
|
+
if (this[s]) return this[s];
|
|
737
|
+
throw new TypeError('Not an AbstractModuleSource');
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
const { Module: wasmModule, compile: wasmCompile, compileStreaming: wasmCompileStreaming } = WebAssembly;
|
|
741
|
+
WebAssembly.Module = Object.setPrototypeOf(
|
|
742
|
+
Object.assign(function Module(...args) {
|
|
743
|
+
return brand(new wasmModule(...args));
|
|
744
|
+
}, wasmModule),
|
|
745
|
+
AbstractModuleSource
|
|
746
|
+
);
|
|
747
|
+
WebAssembly.Module.prototype = Object.setPrototypeOf(wasmModule.prototype, AbstractModuleSource.prototype);
|
|
748
|
+
WebAssembly.compile = function compile(...args) {
|
|
749
|
+
return wasmCompile(...args).then(brand);
|
|
750
|
+
};
|
|
751
|
+
WebAssembly.compileStreaming = function compileStreaming(...args) {
|
|
752
|
+
return wasmCompileStreaming(...args).then(brand);
|
|
753
|
+
};
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
if (hasDocument) {
|
|
757
|
+
if (!supportsImportMaps) {
|
|
758
|
+
const supports = HTMLScriptElement.supports || (type => type === 'classic' || type === 'module');
|
|
759
|
+
HTMLScriptElement.supports = type => type === 'importmap' || supports(type);
|
|
760
|
+
}
|
|
761
|
+
if (shimMode || !baselinePassthrough) {
|
|
762
|
+
attachMutationObserver();
|
|
763
|
+
if (document.readyState === 'complete') {
|
|
764
|
+
readyStateCompleteCheck();
|
|
765
|
+
} else {
|
|
766
|
+
document.addEventListener('readystatechange', readyListener);
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
processScriptsAndPreloads();
|
|
770
|
+
}
|
|
771
|
+
return init;
|
|
772
|
+
});
|
|
773
|
+
|
|
774
|
+
const attachMutationObserver = () => {
|
|
775
|
+
const observer = new MutationObserver(mutations => {
|
|
776
|
+
for (const mutation of mutations) {
|
|
777
|
+
if (mutation.type !== 'childList') continue;
|
|
778
|
+
for (const node of mutation.addedNodes) {
|
|
779
|
+
if (node.tagName === 'SCRIPT') {
|
|
780
|
+
if (node.type === (shimMode ? 'module-shim' : 'module') && !node.ep) processScript(node, true);
|
|
781
|
+
if (node.type === (shimMode ? 'importmap-shim' : 'importmap') && !node.ep) processImportMap(node, true);
|
|
782
|
+
} else if (
|
|
783
|
+
node.tagName === 'LINK' &&
|
|
784
|
+
node.rel === (shimMode ? 'modulepreload-shim' : 'modulepreload') &&
|
|
785
|
+
!node.ep
|
|
786
|
+
) {
|
|
787
|
+
processPreload(node);
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
});
|
|
792
|
+
observer.observe(document, { childList: true });
|
|
793
|
+
observer.observe(document.head, { childList: true });
|
|
794
|
+
processScriptsAndPreloads();
|
|
795
|
+
};
|
|
796
|
+
|
|
797
|
+
let importMapPromise = initPromise;
|
|
798
|
+
let firstPolyfillLoad = true;
|
|
799
|
+
let legacyAcceptingImportMaps = true;
|
|
800
|
+
|
|
801
|
+
const topLevelLoad = async (
|
|
802
|
+
url,
|
|
803
|
+
parentUrl,
|
|
804
|
+
fetchOpts,
|
|
805
|
+
source,
|
|
806
|
+
nativelyLoaded,
|
|
807
|
+
lastStaticLoadPromise,
|
|
808
|
+
sourceType
|
|
809
|
+
) => {
|
|
810
|
+
await initPromise;
|
|
811
|
+
await importMapPromise;
|
|
812
|
+
url = (await resolve(url, parentUrl)).r;
|
|
813
|
+
|
|
814
|
+
// we mock import('./x.css', { with: { type: 'css' }}) support via an inline static reexport
|
|
815
|
+
// because we can't syntactically pass through to dynamic import with a second argument
|
|
816
|
+
if (sourceType === 'css' || sourceType === 'json') {
|
|
817
|
+
// Direct reexport for hot reloading skipped due to Firefox bug https://bugzilla.mozilla.org/show_bug.cgi?id=1965620
|
|
818
|
+
source = `import m from'${url}'with{type:"${sourceType}"};export default m;`;
|
|
819
|
+
url += '?entry';
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
if (importHook) await importHook(url, typeof fetchOpts !== 'string' ? fetchOpts : {}, parentUrl, source, sourceType);
|
|
823
|
+
// early analysis opt-out - no need to even fetch if we have feature support
|
|
824
|
+
if (!shimMode && baselinePassthrough && nativePassthrough && sourceType !== 'ts') {
|
|
825
|
+
// for polyfill case, only dynamic import needs a return value here, and dynamic import will never pass nativelyLoaded
|
|
826
|
+
if (nativelyLoaded) return null;
|
|
827
|
+
await lastStaticLoadPromise;
|
|
828
|
+
return dynamicImport(source ? createBlob(source) : url);
|
|
829
|
+
}
|
|
830
|
+
const load = getOrCreateLoad(url, fetchOpts, undefined, source);
|
|
831
|
+
linkLoad(load, fetchOpts);
|
|
832
|
+
const seen = {};
|
|
833
|
+
await loadAll(load, seen);
|
|
834
|
+
resolveDeps(load, seen);
|
|
835
|
+
await lastStaticLoadPromise;
|
|
836
|
+
if (!shimMode && !load.n) {
|
|
837
|
+
if (nativelyLoaded) {
|
|
838
|
+
return;
|
|
839
|
+
}
|
|
840
|
+
if (source) {
|
|
841
|
+
return await dynamicImport(createBlob(source));
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
if (firstPolyfillLoad && !shimMode && load.n && nativelyLoaded) {
|
|
845
|
+
onpolyfill();
|
|
846
|
+
firstPolyfillLoad = false;
|
|
847
|
+
}
|
|
848
|
+
const module = await (shimMode || load.n || load.N || !nativePassthrough || (!nativelyLoaded && source) ?
|
|
849
|
+
dynamicImport(load.b, load.u)
|
|
850
|
+
: import(load.u));
|
|
851
|
+
// if the top-level load is a shell, run its update function
|
|
852
|
+
if (load.s) (await dynamicImport(load.s, load.u)).u$_(module);
|
|
853
|
+
if (revokeBlobURLs) revokeObjectURLs(Object.keys(seen));
|
|
854
|
+
return module;
|
|
855
|
+
};
|
|
856
|
+
|
|
857
|
+
const revokeObjectURLs = registryKeys => {
|
|
858
|
+
let curIdx = 0;
|
|
859
|
+
const handler = self.requestIdleCallback || self.requestAnimationFrame;
|
|
860
|
+
handler(cleanup);
|
|
861
|
+
function cleanup() {
|
|
862
|
+
for (const key of registryKeys.slice(curIdx, (curIdx += 100))) {
|
|
863
|
+
const load = registry[key];
|
|
864
|
+
if (load && load.b && load.b !== load.u) URL.revokeObjectURL(load.b);
|
|
865
|
+
}
|
|
866
|
+
if (curIdx < registryKeys.length) handler(cleanup);
|
|
867
|
+
}
|
|
868
|
+
};
|
|
869
|
+
|
|
870
|
+
const urlJsString = url => `'${url.replace(/'/g, "\\'")}'`;
|
|
871
|
+
|
|
872
|
+
let resolvedSource, lastIndex;
|
|
873
|
+
const pushStringTo = (load, originalIndex, dynamicImportEndStack) => {
|
|
874
|
+
while (dynamicImportEndStack[dynamicImportEndStack.length - 1] < originalIndex) {
|
|
875
|
+
const dynamicImportEnd = dynamicImportEndStack.pop();
|
|
876
|
+
resolvedSource += `${load.S.slice(lastIndex, dynamicImportEnd)}, ${urlJsString(load.r)}`;
|
|
877
|
+
lastIndex = dynamicImportEnd;
|
|
878
|
+
}
|
|
879
|
+
resolvedSource += load.S.slice(lastIndex, originalIndex);
|
|
880
|
+
lastIndex = originalIndex;
|
|
881
|
+
};
|
|
882
|
+
|
|
883
|
+
const pushSourceURL = (load, commentPrefix, commentStart, dynamicImportEndStack) => {
|
|
884
|
+
const urlStart = commentStart + commentPrefix.length;
|
|
885
|
+
const commentEnd = load.S.indexOf('\n', urlStart);
|
|
886
|
+
const urlEnd = commentEnd !== -1 ? commentEnd : load.S.length;
|
|
887
|
+
let sourceUrl = load.S.slice(urlStart, urlEnd);
|
|
888
|
+
try {
|
|
889
|
+
sourceUrl = new URL(sourceUrl, load.r).href;
|
|
890
|
+
} catch {}
|
|
891
|
+
pushStringTo(load, urlStart, dynamicImportEndStack);
|
|
892
|
+
resolvedSource += sourceUrl;
|
|
893
|
+
lastIndex = urlEnd;
|
|
894
|
+
};
|
|
895
|
+
|
|
896
|
+
const resolveDeps = (load, seen) => {
|
|
897
|
+
if (load.b || !seen[load.u]) return;
|
|
898
|
+
seen[load.u] = 0;
|
|
899
|
+
|
|
900
|
+
for (const { l: dep, s: sourcePhase } of load.d) {
|
|
901
|
+
if (!sourcePhase) resolveDeps(dep, seen);
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
if (!load.n) load.n = load.d.some(dep => dep.l.n);
|
|
905
|
+
if (!load.N) load.N = load.d.some(dep => dep.l.N);
|
|
906
|
+
|
|
907
|
+
// use native loader whenever possible (n = needs shim) via executable subgraph passthrough
|
|
908
|
+
// so long as the module doesn't use dynamic import or unsupported URL mappings (N = should shim)
|
|
909
|
+
if (nativePassthrough && !shimMode && !load.n && !load.N) {
|
|
910
|
+
load.b = load.u;
|
|
911
|
+
load.S = undefined;
|
|
912
|
+
return;
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
const [imports, exports] = load.a;
|
|
916
|
+
|
|
917
|
+
// "execution"
|
|
918
|
+
let source = load.S,
|
|
919
|
+
depIndex = 0,
|
|
920
|
+
dynamicImportEndStack = [];
|
|
921
|
+
|
|
922
|
+
// once all deps have loaded we can inline the dependency resolution blobs
|
|
923
|
+
// and define this blob
|
|
924
|
+
(resolvedSource = ''), (lastIndex = 0);
|
|
925
|
+
|
|
926
|
+
for (const { s: start, e: end, ss: statementStart, se: statementEnd, d: dynamicImportIndex, t, a } of imports) {
|
|
927
|
+
// source phase
|
|
928
|
+
if (t === 4) {
|
|
929
|
+
let { l: depLoad } = load.d[depIndex++];
|
|
930
|
+
pushStringTo(load, statementStart, dynamicImportEndStack);
|
|
931
|
+
resolvedSource += `${source.slice(statementStart, start - 1).replace('source', '')}/*${source.slice(start - 1, end + 1)}*/'${createBlob(`export default importShim._s[${urlJsString(depLoad.r)}]`)}'`;
|
|
932
|
+
lastIndex = end + 1;
|
|
933
|
+
}
|
|
934
|
+
// dependency source replacements
|
|
935
|
+
else if (dynamicImportIndex === -1) {
|
|
936
|
+
let keepAssertion = false;
|
|
937
|
+
if (a > 0 && !shimMode) {
|
|
938
|
+
const assertion = source.slice(a, statementEnd - 1);
|
|
939
|
+
// strip assertions only when unsupported in polyfill mode
|
|
940
|
+
keepAssertion =
|
|
941
|
+
nativePassthrough &&
|
|
942
|
+
((supportsJsonType && assertion.includes('json')) || (supportsCssType && assertion.includes('css')));
|
|
943
|
+
}
|
|
944
|
+
|
|
945
|
+
// defer phase stripping
|
|
946
|
+
if (t === 6) {
|
|
947
|
+
pushStringTo(load, statementStart, dynamicImportEndStack);
|
|
948
|
+
resolvedSource += source.slice(statementStart, start - 1).replace('defer', '');
|
|
949
|
+
lastIndex = start;
|
|
950
|
+
}
|
|
951
|
+
let { l: depLoad } = load.d[depIndex++],
|
|
952
|
+
blobUrl = depLoad.b,
|
|
953
|
+
cycleShell = !blobUrl;
|
|
954
|
+
if (cycleShell) {
|
|
955
|
+
// circular shell creation
|
|
956
|
+
if (!(blobUrl = depLoad.s)) {
|
|
957
|
+
blobUrl = depLoad.s = createBlob(
|
|
958
|
+
`export function u$_(m){${depLoad.a[1]
|
|
959
|
+
.map(({ s, e }, i) => {
|
|
960
|
+
const q = depLoad.S[s] === '"' || depLoad.S[s] === "'";
|
|
961
|
+
return `e$_${i}=m${q ? `[` : '.'}${depLoad.S.slice(s, e)}${q ? `]` : ''}`;
|
|
962
|
+
})
|
|
963
|
+
.join(',')}}${
|
|
964
|
+
depLoad.a[1].length ? `let ${depLoad.a[1].map((_, i) => `e$_${i}`).join(',')};` : ''
|
|
965
|
+
}export {${depLoad.a[1]
|
|
966
|
+
.map(({ s, e }, i) => `e$_${i} as ${depLoad.S.slice(s, e)}`)
|
|
967
|
+
.join(',')}}\n//# sourceURL=${depLoad.r}?cycle`
|
|
968
|
+
);
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
pushStringTo(load, start - 1, dynamicImportEndStack);
|
|
973
|
+
resolvedSource += `/*${source.slice(start - 1, end + 1)}*/'${blobUrl}'`;
|
|
974
|
+
|
|
975
|
+
// circular shell execution
|
|
976
|
+
if (!cycleShell && depLoad.s) {
|
|
977
|
+
resolvedSource += `;import*as m$_${depIndex} from'${depLoad.b}';import{u$_ as u$_${depIndex}}from'${depLoad.s}';u$_${depIndex}(m$_${depIndex})`;
|
|
978
|
+
depLoad.s = undefined;
|
|
979
|
+
}
|
|
980
|
+
lastIndex = keepAssertion ? end + 1 : statementEnd;
|
|
981
|
+
}
|
|
982
|
+
// import.meta
|
|
983
|
+
else if (dynamicImportIndex === -2) {
|
|
984
|
+
load.m = { url: load.r, resolve: metaResolve };
|
|
985
|
+
if (metaHook) metaHook(load.m, load.u);
|
|
986
|
+
pushStringTo(load, start, dynamicImportEndStack);
|
|
987
|
+
resolvedSource += `importShim._r[${urlJsString(load.u)}].m`;
|
|
988
|
+
lastIndex = statementEnd;
|
|
989
|
+
}
|
|
990
|
+
// dynamic import
|
|
991
|
+
else {
|
|
992
|
+
pushStringTo(load, statementStart + 6, dynamicImportEndStack);
|
|
993
|
+
resolvedSource += `Shim${t === 5 ? '.source' : ''}(`;
|
|
994
|
+
dynamicImportEndStack.push(statementEnd - 1);
|
|
995
|
+
lastIndex = start;
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
|
|
999
|
+
// support progressive cycle binding updates (try statement avoids tdz errors)
|
|
1000
|
+
if (load.s && (imports.length === 0 || imports[imports.length - 1].d === -1))
|
|
1001
|
+
resolvedSource += `\n;import{u$_}from'${load.s}';try{u$_({${exports
|
|
1002
|
+
.filter(e => e.ln)
|
|
1003
|
+
.map(({ s, e, ln }) => `${source.slice(s, e)}:${ln}`)
|
|
1004
|
+
.join(',')}})}catch(_){};\n`;
|
|
1005
|
+
|
|
1006
|
+
let sourceURLCommentStart = source.lastIndexOf(sourceURLCommentPrefix);
|
|
1007
|
+
let sourceMapURLCommentStart = source.lastIndexOf(sourceMapURLCommentPrefix);
|
|
1008
|
+
|
|
1009
|
+
// ignore sourceMap comments before already spliced code
|
|
1010
|
+
if (sourceURLCommentStart < lastIndex) sourceURLCommentStart = -1;
|
|
1011
|
+
if (sourceMapURLCommentStart < lastIndex) sourceMapURLCommentStart = -1;
|
|
1012
|
+
|
|
1013
|
+
// sourceURL first / only
|
|
1014
|
+
if (
|
|
1015
|
+
sourceURLCommentStart !== -1 &&
|
|
1016
|
+
(sourceMapURLCommentStart === -1 || sourceMapURLCommentStart > sourceURLCommentStart)
|
|
1017
|
+
) {
|
|
1018
|
+
pushSourceURL(load, sourceURLCommentPrefix, sourceURLCommentStart, dynamicImportEndStack);
|
|
1019
|
+
}
|
|
1020
|
+
// sourceMappingURL
|
|
1021
|
+
if (sourceMapURLCommentStart !== -1) {
|
|
1022
|
+
pushSourceURL(load, sourceMapURLCommentPrefix, sourceMapURLCommentStart, dynamicImportEndStack);
|
|
1023
|
+
// sourceURL last
|
|
1024
|
+
if (sourceURLCommentStart !== -1 && sourceURLCommentStart > sourceMapURLCommentStart)
|
|
1025
|
+
pushSourceURL(load, sourceURLCommentPrefix, sourceURLCommentStart, dynamicImportEndStack);
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
pushStringTo(load, source.length, dynamicImportEndStack);
|
|
1029
|
+
|
|
1030
|
+
if (sourceURLCommentStart === -1) resolvedSource += sourceURLCommentPrefix + load.r;
|
|
1031
|
+
|
|
1032
|
+
load.b = createBlob(resolvedSource);
|
|
1033
|
+
load.S = resolvedSource = undefined;
|
|
1034
|
+
};
|
|
1035
|
+
|
|
1036
|
+
const sourceURLCommentPrefix = '\n//# sourceURL=';
|
|
1037
|
+
const sourceMapURLCommentPrefix = '\n//# sourceMappingURL=';
|
|
1038
|
+
|
|
1039
|
+
const jsContentType = /^(text|application)\/(x-)?javascript(;|$)/;
|
|
1040
|
+
const wasmContentType = /^application\/wasm(;|$)/;
|
|
1041
|
+
const jsonContentType = /^(text|application)\/json(;|$)/;
|
|
1042
|
+
const cssContentType = /^(text|application)\/css(;|$)/;
|
|
1043
|
+
const tsContentType = /^application\/typescript(;|$)|/;
|
|
1044
|
+
|
|
1045
|
+
const cssUrlRegEx = /url\(\s*(?:(["'])((?:\\.|[^\n\\"'])+)\1|((?:\\.|[^\s,"'()\\])+))\s*\)/g;
|
|
1046
|
+
|
|
1047
|
+
// restrict in-flight fetches to a pool of 100
|
|
1048
|
+
let p = [];
|
|
1049
|
+
let c = 0;
|
|
1050
|
+
const pushFetchPool = () => {
|
|
1051
|
+
if (++c > 100) return new Promise(r => p.push(r));
|
|
1052
|
+
};
|
|
1053
|
+
const popFetchPool = () => {
|
|
1054
|
+
c--;
|
|
1055
|
+
if (p.length) p.shift()();
|
|
1056
|
+
};
|
|
1057
|
+
|
|
1058
|
+
const doFetch = async (url, fetchOpts, parent) => {
|
|
1059
|
+
if (enforceIntegrity && !fetchOpts.integrity) throw Error(`No integrity for ${url}${fromParent(parent)}.`);
|
|
1060
|
+
const poolQueue = pushFetchPool();
|
|
1061
|
+
if (poolQueue) await poolQueue;
|
|
1062
|
+
try {
|
|
1063
|
+
var res = await fetchHook(url, fetchOpts);
|
|
1064
|
+
} catch (e) {
|
|
1065
|
+
e.message = `Unable to fetch ${url}${fromParent(parent)} - see network log for details.\n` + e.message;
|
|
1066
|
+
throw e;
|
|
1067
|
+
} finally {
|
|
1068
|
+
popFetchPool();
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
if (!res.ok) {
|
|
1072
|
+
const error = new TypeError(`${res.status} ${res.statusText} ${res.url}${fromParent(parent)}`);
|
|
1073
|
+
error.response = res;
|
|
1074
|
+
throw error;
|
|
1075
|
+
}
|
|
1076
|
+
return res;
|
|
1077
|
+
};
|
|
1078
|
+
|
|
1079
|
+
let esmsTsTransform;
|
|
1080
|
+
const initTs = async () => {
|
|
1081
|
+
const m = await import(tsTransform);
|
|
1082
|
+
if (!esmsTsTransform) esmsTsTransform = m.transform;
|
|
1083
|
+
};
|
|
1084
|
+
|
|
1085
|
+
const hotPrefix = 'var h=import.meta.hot,';
|
|
1086
|
+
const fetchModule = async (url, fetchOpts, parent) => {
|
|
1087
|
+
const mapIntegrity = composedImportMap.integrity[url];
|
|
1088
|
+
const res = await doFetch(
|
|
1089
|
+
url,
|
|
1090
|
+
mapIntegrity && !fetchOpts.integrity ? { ...fetchOpts, integrity: mapIntegrity } : fetchOpts,
|
|
1091
|
+
parent
|
|
1092
|
+
);
|
|
1093
|
+
const r = res.url;
|
|
1094
|
+
const contentType = res.headers.get('content-type');
|
|
1095
|
+
if (jsContentType.test(contentType)) return { r, s: await res.text(), t: 'js' };
|
|
1096
|
+
else if (wasmContentType.test(contentType)) {
|
|
1097
|
+
const wasmModule = await (sourceCache[r] || (sourceCache[r] = WebAssembly.compileStreaming(res)));
|
|
1098
|
+
const exports = WebAssembly.Module.exports(wasmModule);
|
|
1099
|
+
sourceCache[r] = wasmModule;
|
|
1100
|
+
const rStr = urlJsString(r);
|
|
1101
|
+
let s = `import*as $_ns from${rStr};`,
|
|
1102
|
+
i = 0,
|
|
1103
|
+
obj = '';
|
|
1104
|
+
for (const { module, kind } of WebAssembly.Module.imports(wasmModule)) {
|
|
1105
|
+
const specifier = urlJsString(module);
|
|
1106
|
+
s += `import*as impt${i} from${specifier};\n`;
|
|
1107
|
+
obj += `${specifier}:${kind === 'global' ? `importShim._i.get(impt${i})||impt${i++}` : `impt${i++}`},`;
|
|
1108
|
+
}
|
|
1109
|
+
s += `${hotPrefix}i=await WebAssembly.instantiate(importShim._s[${rStr}],{${obj}});importShim._i.set($_ns,i);`;
|
|
1110
|
+
obj = '';
|
|
1111
|
+
for (const { name, kind } of exports) {
|
|
1112
|
+
s += `export let ${name}=i.exports['${name}'];`;
|
|
1113
|
+
if (kind === 'global') s += `try{${name}=${name}.value}catch{${name}=undefined}`;
|
|
1114
|
+
obj += `${name},`;
|
|
1115
|
+
}
|
|
1116
|
+
s += `if(h)h.accept(m=>({${obj}}=m))`;
|
|
1117
|
+
return { r, s, t: 'wasm' };
|
|
1118
|
+
} else if (jsonContentType.test(contentType))
|
|
1119
|
+
return {
|
|
1120
|
+
r,
|
|
1121
|
+
s: `${hotPrefix}j=${await res.text()};export{j as default};if(h)h.accept(m=>j=m.default)`,
|
|
1122
|
+
t: 'json'
|
|
1123
|
+
};
|
|
1124
|
+
else if (cssContentType.test(contentType)) {
|
|
1125
|
+
return {
|
|
1126
|
+
r,
|
|
1127
|
+
s: `${hotPrefix}s=h&&h.data.s||new CSSStyleSheet();s.replaceSync(${JSON.stringify(
|
|
1128
|
+
(await res.text()).replace(
|
|
1129
|
+
cssUrlRegEx,
|
|
1130
|
+
(_match, quotes = '', relUrl1, relUrl2) => `url(${quotes}${resolveUrl(relUrl1 || relUrl2, url)}${quotes})`
|
|
1131
|
+
)
|
|
1132
|
+
)});if(h){h.data.s=s;h.accept(()=>{})}export default s`,
|
|
1133
|
+
t: 'css'
|
|
1134
|
+
};
|
|
1135
|
+
} else if (tsContentType.test(contentType) || url.endsWith('.ts') || url.endsWith('.mts')) {
|
|
1136
|
+
const source = await res.text();
|
|
1137
|
+
if (!esmsTsTransform) await initTs();
|
|
1138
|
+
const transformed = esmsTsTransform(source, url);
|
|
1139
|
+
// even if the TypeScript is valid JavaScript, unless it was a top-level inline source, it wasn't served with
|
|
1140
|
+
// a valid JS MIME here, so we must still polyfill it
|
|
1141
|
+
return { r, s: transformed === undefined ? source : transformed, t: 'ts' };
|
|
1142
|
+
} else
|
|
1143
|
+
throw Error(
|
|
1144
|
+
`Unsupported Content-Type "${contentType}" loading ${url}${fromParent(parent)}. Modules must be served with a valid MIME type like application/javascript.`
|
|
1145
|
+
);
|
|
1146
|
+
};
|
|
1147
|
+
|
|
1148
|
+
const isUnsupportedType = type => {
|
|
1149
|
+
if (type === 'wasm' && !wasmInstancePhaseEnabled && !wasmSourcePhaseEnabled) throw featErr(`wasm-modules`);
|
|
1150
|
+
return (
|
|
1151
|
+
(type === 'css' && !supportsCssType) ||
|
|
1152
|
+
(type === 'json' && !supportsJsonType) ||
|
|
1153
|
+
(type === 'wasm' && !supportsWasmInstancePhase && !supportsWasmSourcePhase) ||
|
|
1154
|
+
type === 'ts'
|
|
1155
|
+
);
|
|
1156
|
+
};
|
|
1157
|
+
|
|
1158
|
+
const getOrCreateLoad = (url, fetchOpts, parent, source) => {
|
|
1159
|
+
if (source && registry[url]) {
|
|
1160
|
+
let i = 0;
|
|
1161
|
+
while (registry[url + '#' + ++i]);
|
|
1162
|
+
url += '#' + i;
|
|
1163
|
+
}
|
|
1164
|
+
let load = registry[url];
|
|
1165
|
+
if (load) return load;
|
|
1166
|
+
registry[url] = load = {
|
|
1167
|
+
// url
|
|
1168
|
+
u: url,
|
|
1169
|
+
// response url
|
|
1170
|
+
r: source ? url : undefined,
|
|
1171
|
+
// fetchPromise
|
|
1172
|
+
f: undefined,
|
|
1173
|
+
// source
|
|
1174
|
+
S: source,
|
|
1175
|
+
// linkPromise
|
|
1176
|
+
L: undefined,
|
|
1177
|
+
// analysis
|
|
1178
|
+
a: undefined,
|
|
1179
|
+
// deps
|
|
1180
|
+
d: undefined,
|
|
1181
|
+
// blobUrl
|
|
1182
|
+
b: undefined,
|
|
1183
|
+
// shellUrl
|
|
1184
|
+
s: undefined,
|
|
1185
|
+
// needsShim: does it fail execution in the current native loader?
|
|
1186
|
+
n: false,
|
|
1187
|
+
// shouldShim: does it need to be loaded by the polyfill loader?
|
|
1188
|
+
N: false,
|
|
1189
|
+
// type
|
|
1190
|
+
t: null,
|
|
1191
|
+
// meta
|
|
1192
|
+
m: null
|
|
1193
|
+
};
|
|
1194
|
+
load.f = (async () => {
|
|
1195
|
+
if (load.S === undefined) {
|
|
1196
|
+
// preload fetch options override fetch options (race)
|
|
1197
|
+
({ r: load.r, s: load.S, t: load.t } = await (fetchCache[url] || fetchModule(url, fetchOpts, parent)));
|
|
1198
|
+
if (!load.n && load.t !== 'js' && !shimMode && isUnsupportedType(load.t)) {
|
|
1199
|
+
load.n = true;
|
|
1200
|
+
}
|
|
1201
|
+
}
|
|
1202
|
+
try {
|
|
1203
|
+
load.a = parse(load.S, load.u);
|
|
1204
|
+
} catch (e) {
|
|
1205
|
+
throwError(e);
|
|
1206
|
+
load.a = [[], [], false];
|
|
1207
|
+
}
|
|
1208
|
+
return load;
|
|
1209
|
+
})();
|
|
1210
|
+
return load;
|
|
1211
|
+
};
|
|
1212
|
+
|
|
1213
|
+
const featErr = feat =>
|
|
1214
|
+
Error(
|
|
1215
|
+
`${feat} feature must be enabled via <script type="esms-options">{ "polyfillEnable": ["${feat}"] }<${''}/script>`
|
|
1216
|
+
);
|
|
1217
|
+
|
|
1218
|
+
const linkLoad = (load, fetchOpts) => {
|
|
1219
|
+
if (load.L) return;
|
|
1220
|
+
load.L = load.f.then(async () => {
|
|
1221
|
+
let childFetchOpts = fetchOpts;
|
|
1222
|
+
load.d = load.a[0]
|
|
1223
|
+
.map(({ n, d, t, a, se }) => {
|
|
1224
|
+
const phaseImport = t >= 4;
|
|
1225
|
+
const sourcePhase = phaseImport && t < 6;
|
|
1226
|
+
if (phaseImport) {
|
|
1227
|
+
if (!shimMode && (sourcePhase ? !wasmSourcePhaseEnabled : !deferPhaseEnabled))
|
|
1228
|
+
throw featErr(sourcePhase ? 'wasm-module-sources' : 'import-defer');
|
|
1229
|
+
if (!sourcePhase || !supportsWasmSourcePhase) load.n = true;
|
|
1230
|
+
}
|
|
1231
|
+
let source = undefined;
|
|
1232
|
+
if (a > 0 && !shimMode && nativePassthrough) {
|
|
1233
|
+
const assertion = load.S.slice(a, se - 1);
|
|
1234
|
+
// no need to fetch JSON/CSS if supported, since it's a leaf node, we'll just strip the assertion syntax
|
|
1235
|
+
if (assertion.includes('json')) {
|
|
1236
|
+
if (supportsJsonType) source = '';
|
|
1237
|
+
else load.n = true;
|
|
1238
|
+
} else if (assertion.includes('css')) {
|
|
1239
|
+
if (supportsCssType) source = '';
|
|
1240
|
+
else load.n = true;
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
if (d !== -1 || !n) return;
|
|
1244
|
+
const resolved = resolve(n, load.r || load.u);
|
|
1245
|
+
if (resolved.n) load.n = true;
|
|
1246
|
+
if (d >= 0 || resolved.N) load.N = true;
|
|
1247
|
+
if (d !== -1) return;
|
|
1248
|
+
if (skip && skip(resolved.r) && !sourcePhase) return { l: { b: resolved.r }, s: false };
|
|
1249
|
+
if (childFetchOpts.integrity) childFetchOpts = { ...childFetchOpts, integrity: undefined };
|
|
1250
|
+
const child = { l: getOrCreateLoad(resolved.r, childFetchOpts, load.r, source), s: sourcePhase };
|
|
1251
|
+
// assertion case -> inline the CSS / JSON URL directly
|
|
1252
|
+
if (source === '') child.l.b = child.l.u;
|
|
1253
|
+
if (!child.s) linkLoad(child.l, fetchOpts);
|
|
1254
|
+
// load, sourcePhase
|
|
1255
|
+
return child;
|
|
1256
|
+
})
|
|
1257
|
+
.filter(l => l);
|
|
1258
|
+
});
|
|
1259
|
+
};
|
|
1260
|
+
|
|
1261
|
+
const processScriptsAndPreloads = () => {
|
|
1262
|
+
for (const link of document.querySelectorAll(shimMode ? 'link[rel=modulepreload-shim]' : 'link[rel=modulepreload]')) {
|
|
1263
|
+
if (!link.ep) processPreload(link);
|
|
1264
|
+
}
|
|
1265
|
+
for (const script of document.querySelectorAll('script[type]')) {
|
|
1266
|
+
if (script.type === 'importmap' + (shimMode ? '-shim' : '')) {
|
|
1267
|
+
if (!script.ep) processImportMap(script);
|
|
1268
|
+
} else if (script.type === 'module' + (shimMode ? '-shim' : '')) {
|
|
1269
|
+
legacyAcceptingImportMaps = false;
|
|
1270
|
+
if (!script.ep) processScript(script);
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1273
|
+
};
|
|
1274
|
+
|
|
1275
|
+
const getFetchOpts = script => {
|
|
1276
|
+
const fetchOpts = {};
|
|
1277
|
+
if (script.integrity) fetchOpts.integrity = script.integrity;
|
|
1278
|
+
if (script.referrerPolicy) fetchOpts.referrerPolicy = script.referrerPolicy;
|
|
1279
|
+
if (script.fetchPriority) fetchOpts.priority = script.fetchPriority;
|
|
1280
|
+
if (script.crossOrigin === 'use-credentials') fetchOpts.credentials = 'include';
|
|
1281
|
+
else if (script.crossOrigin === 'anonymous') fetchOpts.credentials = 'omit';
|
|
1282
|
+
else fetchOpts.credentials = 'same-origin';
|
|
1283
|
+
return fetchOpts;
|
|
1284
|
+
};
|
|
1285
|
+
|
|
1286
|
+
let lastStaticLoadPromise = Promise.resolve();
|
|
1287
|
+
|
|
1288
|
+
let domContentLoaded = false;
|
|
1289
|
+
let domContentLoadedCnt = 1;
|
|
1290
|
+
const domContentLoadedCheck = m => {
|
|
1291
|
+
if (m === undefined) {
|
|
1292
|
+
if (domContentLoaded) return;
|
|
1293
|
+
domContentLoaded = true;
|
|
1294
|
+
domContentLoadedCnt--;
|
|
1295
|
+
}
|
|
1296
|
+
if (--domContentLoadedCnt === 0 && !noLoadEventRetriggers && (shimMode || !baselinePassthrough)) {
|
|
1297
|
+
document.removeEventListener('DOMContentLoaded', domContentLoadedEvent);
|
|
1298
|
+
document.dispatchEvent(new Event('DOMContentLoaded'));
|
|
1299
|
+
}
|
|
1300
|
+
};
|
|
1301
|
+
let loadCnt = 1;
|
|
1302
|
+
const loadCheck = () => {
|
|
1303
|
+
if (--loadCnt === 0 && !noLoadEventRetriggers && (shimMode || !baselinePassthrough)) {
|
|
1304
|
+
window.removeEventListener('load', loadEvent);
|
|
1305
|
+
window.dispatchEvent(new Event('load'));
|
|
1306
|
+
}
|
|
1307
|
+
};
|
|
1308
|
+
|
|
1309
|
+
const domContentLoadedEvent = async () => {
|
|
1310
|
+
await initPromise;
|
|
1311
|
+
domContentLoadedCheck();
|
|
1312
|
+
};
|
|
1313
|
+
const loadEvent = async () => {
|
|
1314
|
+
await initPromise;
|
|
1315
|
+
domContentLoadedCheck();
|
|
1316
|
+
loadCheck();
|
|
1317
|
+
};
|
|
1318
|
+
|
|
1319
|
+
// this should always trigger because we assume es-module-shims is itself a domcontentloaded requirement
|
|
1320
|
+
if (hasDocument) {
|
|
1321
|
+
document.addEventListener('DOMContentLoaded', domContentLoadedEvent);
|
|
1322
|
+
window.addEventListener('load', loadEvent);
|
|
1323
|
+
}
|
|
1324
|
+
|
|
1325
|
+
const readyListener = async () => {
|
|
1326
|
+
await initPromise;
|
|
1327
|
+
processScriptsAndPreloads();
|
|
1328
|
+
if (document.readyState === 'complete') {
|
|
1329
|
+
readyStateCompleteCheck();
|
|
1330
|
+
}
|
|
1445
1331
|
};
|
|
1446
1332
|
|
|
1447
|
-
|
|
1333
|
+
let readyStateCompleteCnt = 1;
|
|
1334
|
+
const readyStateCompleteCheck = () => {
|
|
1335
|
+
if (--readyStateCompleteCnt === 0) {
|
|
1336
|
+
domContentLoadedCheck();
|
|
1337
|
+
if (!noLoadEventRetriggers && (shimMode || !baselinePassthrough)) {
|
|
1338
|
+
document.removeEventListener('readystatechange', readyListener);
|
|
1339
|
+
document.dispatchEvent(new Event('readystatechange'));
|
|
1340
|
+
}
|
|
1341
|
+
}
|
|
1342
|
+
};
|
|
1343
|
+
|
|
1344
|
+
const hasNext = script => script.nextSibling || (script.parentNode && hasNext(script.parentNode));
|
|
1345
|
+
const epCheck = (script, ready) =>
|
|
1346
|
+
script.ep ||
|
|
1347
|
+
(!ready && ((!script.src && !script.innerHTML) || !hasNext(script))) ||
|
|
1348
|
+
script.getAttribute('noshim') !== null ||
|
|
1349
|
+
!(script.ep = true);
|
|
1350
|
+
|
|
1351
|
+
const processImportMap = (script, ready = readyStateCompleteCnt > 0) => {
|
|
1352
|
+
if (epCheck(script, ready)) return;
|
|
1353
|
+
// we dont currently support external import maps in polyfill mode to match native
|
|
1354
|
+
if (script.src) {
|
|
1355
|
+
if (!shimMode) return;
|
|
1356
|
+
importMapSrc = true;
|
|
1357
|
+
}
|
|
1358
|
+
importMapPromise = importMapPromise
|
|
1359
|
+
.then(async () => {
|
|
1360
|
+
composedImportMap = resolveAndComposeImportMap(
|
|
1361
|
+
script.src ? await (await doFetch(script.src, getFetchOpts(script))).json() : JSON.parse(script.innerHTML),
|
|
1362
|
+
script.src || baseUrl,
|
|
1363
|
+
composedImportMap
|
|
1364
|
+
);
|
|
1365
|
+
})
|
|
1366
|
+
.catch(e => {
|
|
1367
|
+
if (e instanceof SyntaxError)
|
|
1368
|
+
e = new Error(`Unable to parse import map ${e.message} in: ${script.src || script.innerHTML}`);
|
|
1369
|
+
throwError(e);
|
|
1370
|
+
});
|
|
1371
|
+
if (!firstImportMap && legacyAcceptingImportMaps) importMapPromise.then(() => (firstImportMap = composedImportMap));
|
|
1372
|
+
if (!legacyAcceptingImportMaps && !multipleImportMaps) {
|
|
1373
|
+
multipleImportMaps = true;
|
|
1374
|
+
if (!shimMode && baselinePassthrough && !supportsMultipleImportMaps) {
|
|
1375
|
+
baselinePassthrough = false;
|
|
1376
|
+
if (hasDocument) attachMutationObserver();
|
|
1377
|
+
}
|
|
1378
|
+
}
|
|
1379
|
+
legacyAcceptingImportMaps = false;
|
|
1380
|
+
};
|
|
1448
1381
|
|
|
1449
|
-
|
|
1382
|
+
const processScript = (script, ready = readyStateCompleteCnt > 0) => {
|
|
1383
|
+
if (epCheck(script, ready)) return;
|
|
1384
|
+
// does this load block readystate complete
|
|
1385
|
+
const isBlockingReadyScript = script.getAttribute('async') === null && readyStateCompleteCnt > 0;
|
|
1386
|
+
// does this load block DOMContentLoaded
|
|
1387
|
+
const isDomContentLoadedScript = domContentLoadedCnt > 0;
|
|
1388
|
+
const isLoadScript = loadCnt > 0;
|
|
1389
|
+
if (isLoadScript) loadCnt++;
|
|
1390
|
+
if (isBlockingReadyScript) readyStateCompleteCnt++;
|
|
1391
|
+
if (isDomContentLoadedScript) domContentLoadedCnt++;
|
|
1392
|
+
let loadPromise;
|
|
1393
|
+
const ts = script.lang === 'ts';
|
|
1394
|
+
if (ts && !script.src) {
|
|
1395
|
+
loadPromise = Promise.resolve(esmsTsTransform || initTs())
|
|
1396
|
+
.then(() => {
|
|
1397
|
+
const transformed = esmsTsTransform(script.innerHTML, baseUrl);
|
|
1398
|
+
if (transformed !== undefined) {
|
|
1399
|
+
onpolyfill();
|
|
1400
|
+
firstPolyfillLoad = false;
|
|
1401
|
+
}
|
|
1402
|
+
return topLevelLoad(
|
|
1403
|
+
script.src || baseUrl,
|
|
1404
|
+
baseUrl,
|
|
1405
|
+
getFetchOpts(script),
|
|
1406
|
+
transformed === undefined ? script.innerHTML : transformed,
|
|
1407
|
+
!shimMode && transformed === undefined,
|
|
1408
|
+
isBlockingReadyScript && lastStaticLoadPromise,
|
|
1409
|
+
'ts'
|
|
1410
|
+
);
|
|
1411
|
+
})
|
|
1412
|
+
.catch(throwError);
|
|
1413
|
+
} else {
|
|
1414
|
+
loadPromise = topLevelLoad(
|
|
1415
|
+
script.src || baseUrl,
|
|
1416
|
+
baseUrl,
|
|
1417
|
+
getFetchOpts(script),
|
|
1418
|
+
!script.src ? script.innerHTML : undefined,
|
|
1419
|
+
!shimMode,
|
|
1420
|
+
isBlockingReadyScript && lastStaticLoadPromise,
|
|
1421
|
+
ts ? 'ts' : undefined
|
|
1422
|
+
).catch(throwError);
|
|
1423
|
+
}
|
|
1424
|
+
if (!noLoadEventRetriggers) loadPromise.then(() => script.dispatchEvent(new Event('load')));
|
|
1425
|
+
if (isBlockingReadyScript && !ts) {
|
|
1426
|
+
lastStaticLoadPromise = loadPromise.then(readyStateCompleteCheck);
|
|
1427
|
+
}
|
|
1428
|
+
if (isDomContentLoadedScript) loadPromise.then(domContentLoadedCheck);
|
|
1429
|
+
if (isLoadScript) loadPromise.then(loadCheck);
|
|
1430
|
+
};
|
|
1450
1431
|
|
|
1451
|
-
|
|
1432
|
+
const fetchCache = {};
|
|
1433
|
+
const processPreload = link => {
|
|
1434
|
+
link.ep = true;
|
|
1435
|
+
initPromise.then(() => {
|
|
1436
|
+
if (baselinePassthrough && !shimMode) return;
|
|
1437
|
+
if (fetchCache[link.href]) return;
|
|
1438
|
+
fetchCache[link.href] = fetchModule(link.href, getFetchOpts(link));
|
|
1439
|
+
});
|
|
1440
|
+
};
|
|
1452
1441
|
|
|
1453
|
-
})(
|
|
1442
|
+
})();
|