es-module-shims 2.5.1 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +88 -15
- package/dist/es-module-shims.debug.js +1004 -1002
- package/dist/es-module-shims.js +985 -983
- package/dist/es-module-shims.wasm.js +985 -983
- package/index.d.ts +161 -33
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** ES Module Shims @version 2.
|
|
1
|
+
/** ES Module Shims @version 2.6.0 */
|
|
2
2
|
(function () {
|
|
3
3
|
|
|
4
4
|
let invalidate;
|
|
@@ -23,9 +23,7 @@
|
|
|
23
23
|
hotState.e = typeof source === 'string' ? source : true;
|
|
24
24
|
hotState.t = sourceType;
|
|
25
25
|
};
|
|
26
|
-
const hotMetaHook = (metaObj, url) =>
|
|
27
|
-
metaObj.hot = new Hot(url);
|
|
28
|
-
};
|
|
26
|
+
const hotMetaHook = (metaObj, url) => (metaObj.hot = new Hot(url));
|
|
29
27
|
|
|
30
28
|
const Hot = class Hot {
|
|
31
29
|
constructor(url) {
|
|
@@ -50,10 +48,9 @@
|
|
|
50
48
|
}
|
|
51
49
|
invalidate() {
|
|
52
50
|
const hotState = getHotState(this.url);
|
|
53
|
-
hotState.a = null;
|
|
54
|
-
hotState.A = true;
|
|
51
|
+
hotState.a = hotState.A = null;
|
|
55
52
|
const seen = [this.url];
|
|
56
|
-
|
|
53
|
+
hotState.p.forEach(p => invalidate(p, this.url, seen));
|
|
57
54
|
}
|
|
58
55
|
};
|
|
59
56
|
|
|
@@ -107,7 +104,7 @@
|
|
|
107
104
|
} else {
|
|
108
105
|
if (hotState.e || hotState.a) curInvalidationRoots.add(url);
|
|
109
106
|
hotState.v++;
|
|
110
|
-
if (!hotState.a)
|
|
107
|
+
if (!hotState.a) hotState.p.forEach(p => invalidate(p, url, seen));
|
|
111
108
|
}
|
|
112
109
|
if (!curInvalidationInterval) curInvalidationInterval = setTimeout(handleInvalidations, hotReloadInterval);
|
|
113
110
|
return true;
|
|
@@ -128,26 +125,25 @@
|
|
|
128
125
|
hotState.t
|
|
129
126
|
).then(m => {
|
|
130
127
|
if (hotState.a) {
|
|
131
|
-
hotState.a.
|
|
128
|
+
hotState.a.forEach(([d, c]) => d === null && !earlyRoots.has(c) && c(m));
|
|
132
129
|
// unload should be the latest unload handler from the just loaded module
|
|
133
130
|
if (hotState.u) {
|
|
134
131
|
hotState.u(hotState.d);
|
|
135
132
|
hotState.u = null;
|
|
136
133
|
}
|
|
137
134
|
}
|
|
138
|
-
|
|
139
|
-
const hotState = hotRegistry[
|
|
135
|
+
hotState.p.forEach(p => {
|
|
136
|
+
const hotState = hotRegistry[p];
|
|
140
137
|
if (hotState && hotState.a)
|
|
141
|
-
hotState.a.
|
|
142
|
-
|
|
138
|
+
hotState.a.forEach(
|
|
139
|
+
async ([d, c]) =>
|
|
143
140
|
d &&
|
|
144
141
|
!earlyRoots.has(c) &&
|
|
145
142
|
(typeof d === 'string' ?
|
|
146
143
|
d === root && c(m)
|
|
147
144
|
: c(await Promise.all(d.map(d => (earlyRoots.push(c), importShim(toVersioned(d, getHotState(d))))))))
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
}
|
|
145
|
+
);
|
|
146
|
+
});
|
|
151
147
|
}, throwError);
|
|
152
148
|
}
|
|
153
149
|
curInvalidationRoots = new Set();
|
|
@@ -163,118 +159,125 @@
|
|
|
163
159
|
];
|
|
164
160
|
};
|
|
165
161
|
|
|
166
|
-
const hasDocument = typeof document !== 'undefined';
|
|
167
|
-
|
|
168
|
-
const noop = () => {};
|
|
169
|
-
|
|
170
|
-
const dynamicImport = (u, errUrl) => import(u);
|
|
171
|
-
|
|
172
|
-
const defineValue = (obj, prop, value) =>
|
|
173
|
-
Object.defineProperty(obj, prop, { writable: false, configurable: false, value });
|
|
174
|
-
|
|
175
|
-
const optionsScript = hasDocument ? document.querySelector('script[type=esms-options]') : undefined;
|
|
176
|
-
|
|
177
|
-
const esmsInitOptions = optionsScript ? JSON.parse(optionsScript.innerHTML) : {};
|
|
178
|
-
Object.assign(esmsInitOptions, self.esmsInitOptions || {});
|
|
179
|
-
|
|
180
|
-
const version = "2.
|
|
181
|
-
|
|
182
|
-
const r$1 = esmsInitOptions.version;
|
|
183
|
-
if (self.importShim || (r$1 && r$1 !== version)) {
|
|
184
|
-
console.info(
|
|
185
|
-
`es-module-shims: skipping initialization as ${r$1 ? `configured for ${r$1}` : 'another instance has already registered'}`
|
|
186
|
-
);
|
|
187
|
-
return;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
// shim mode is determined on initialization, no late shim mode
|
|
191
|
-
const shimMode =
|
|
192
|
-
esmsInitOptions.shimMode ||
|
|
193
|
-
(hasDocument &&
|
|
194
|
-
document.querySelectorAll('script[type=module-shim],script[type=importmap-shim],link[rel=modulepreload-shim]')
|
|
195
|
-
.length > 0);
|
|
196
|
-
|
|
197
|
-
let importHook,
|
|
198
|
-
resolveHook,
|
|
199
|
-
fetchHook = fetch,
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
'
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
const
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
const
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
const
|
|
241
|
-
|
|
242
|
-
const
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
const
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
:
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
162
|
+
const hasDocument = typeof document !== 'undefined';
|
|
163
|
+
|
|
164
|
+
const noop = () => {};
|
|
165
|
+
|
|
166
|
+
const dynamicImport = (u, errUrl) => import(u);
|
|
167
|
+
|
|
168
|
+
const defineValue = (obj, prop, value) =>
|
|
169
|
+
Object.defineProperty(obj, prop, { writable: false, configurable: false, value });
|
|
170
|
+
|
|
171
|
+
const optionsScript = hasDocument ? document.querySelector('script[type=esms-options]') : undefined;
|
|
172
|
+
|
|
173
|
+
const esmsInitOptions = optionsScript ? JSON.parse(optionsScript.innerHTML) : {};
|
|
174
|
+
Object.assign(esmsInitOptions, self.esmsInitOptions || {});
|
|
175
|
+
|
|
176
|
+
const version = "2.6.0";
|
|
177
|
+
|
|
178
|
+
const r$1 = esmsInitOptions.version;
|
|
179
|
+
if (self.importShim || (r$1 && r$1 !== version)) {
|
|
180
|
+
console.info(
|
|
181
|
+
`es-module-shims: skipping initialization as ${r$1 ? `configured for ${r$1}` : 'another instance has already registered'}`
|
|
182
|
+
);
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// shim mode is determined on initialization, no late shim mode
|
|
187
|
+
const shimMode =
|
|
188
|
+
esmsInitOptions.shimMode ||
|
|
189
|
+
(hasDocument &&
|
|
190
|
+
document.querySelectorAll('script[type=module-shim],script[type=importmap-shim],link[rel=modulepreload-shim]')
|
|
191
|
+
.length > 0);
|
|
192
|
+
|
|
193
|
+
let importHook,
|
|
194
|
+
resolveHook,
|
|
195
|
+
fetchHook = fetch,
|
|
196
|
+
sourceHook,
|
|
197
|
+
metaHook,
|
|
198
|
+
tsTransform =
|
|
199
|
+
esmsInitOptions.tsTransform ||
|
|
200
|
+
(hasDocument && document.currentScript && document.currentScript.src.replace(/(\.\w+)?\.js$/, '-typescript.js')) ||
|
|
201
|
+
'./es-module-shims-typescript.js';
|
|
202
|
+
|
|
203
|
+
const defaultFetchOpts = { credentials: 'same-origin' };
|
|
204
|
+
|
|
205
|
+
const globalHook = name => (typeof name === 'string' ? self[name] : name);
|
|
206
|
+
|
|
207
|
+
if (esmsInitOptions.onimport) importHook = globalHook(esmsInitOptions.onimport);
|
|
208
|
+
if (esmsInitOptions.resolve) resolveHook = globalHook(esmsInitOptions.resolve);
|
|
209
|
+
if (esmsInitOptions.fetch) fetchHook = globalHook(esmsInitOptions.fetch);
|
|
210
|
+
if (esmsInitOptions.source) sourceHook = globalHook(esmsInitOptions.source);
|
|
211
|
+
if (esmsInitOptions.meta) metaHook = globalHook(esmsInitOptions.meta);
|
|
212
|
+
|
|
213
|
+
const hasCustomizationHooks = importHook || resolveHook || fetchHook !== fetch || sourceHook || metaHook;
|
|
214
|
+
|
|
215
|
+
const {
|
|
216
|
+
noLoadEventRetriggers,
|
|
217
|
+
enforceIntegrity,
|
|
218
|
+
hotReload,
|
|
219
|
+
hotReloadInterval = 100,
|
|
220
|
+
nativePassthrough = !hasCustomizationHooks && !hotReload
|
|
221
|
+
} = esmsInitOptions;
|
|
222
|
+
|
|
223
|
+
if (hotReload) [importHook, resolveHook, metaHook] = initHotReload();
|
|
224
|
+
|
|
225
|
+
const mapOverrides = esmsInitOptions.mapOverrides;
|
|
226
|
+
|
|
227
|
+
let nonce = esmsInitOptions.nonce;
|
|
228
|
+
if (!nonce && hasDocument) {
|
|
229
|
+
const nonceElement = document.querySelector('script[nonce]');
|
|
230
|
+
if (nonceElement) nonce = nonceElement.nonce || nonceElement.getAttribute('nonce');
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
const onerror = globalHook(esmsInitOptions.onerror || console.error.bind(console));
|
|
234
|
+
|
|
235
|
+
const enable = Array.isArray(esmsInitOptions.polyfillEnable) ? esmsInitOptions.polyfillEnable : [];
|
|
236
|
+
const disable = Array.isArray(esmsInitOptions.polyfillDisable) ? esmsInitOptions.polyfillDisable : [];
|
|
237
|
+
|
|
238
|
+
const enableAll = esmsInitOptions.polyfillEnable === 'all' || enable.includes('all');
|
|
239
|
+
const wasmInstancePhaseEnabled =
|
|
240
|
+
enable.includes('wasm-modules') || enable.includes('wasm-module-instances') || enableAll;
|
|
241
|
+
const wasmSourcePhaseEnabled =
|
|
242
|
+
enable.includes('wasm-modules') || enable.includes('wasm-module-sources') || enableAll;
|
|
243
|
+
const deferPhaseEnabled = enable.includes('import-defer') || enableAll;
|
|
244
|
+
const cssModulesEnabled = !disable.includes('css-modules');
|
|
245
|
+
const jsonModulesEnabled = !disable.includes('json-modules');
|
|
246
|
+
|
|
247
|
+
const onpolyfill =
|
|
248
|
+
esmsInitOptions.onpolyfill ?
|
|
249
|
+
globalHook(esmsInitOptions.onpolyfill)
|
|
250
|
+
: () => {
|
|
251
|
+
console.log(`%c^^ Module error above is polyfilled and can be ignored ^^`, 'font-weight:900;color:#391');
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
const baseUrl =
|
|
255
|
+
hasDocument ?
|
|
256
|
+
document.baseURI
|
|
257
|
+
: `${location.protocol}//${location.host}${
|
|
258
|
+
location.pathname.includes('/') ?
|
|
259
|
+
location.pathname.slice(0, location.pathname.lastIndexOf('/') + 1)
|
|
260
|
+
: location.pathname
|
|
261
|
+
}`;
|
|
262
|
+
|
|
263
|
+
const createBlob = (source, type = 'text/javascript') => URL.createObjectURL(new Blob([source], { type }));
|
|
264
|
+
let { skip } = esmsInitOptions;
|
|
265
|
+
if (Array.isArray(skip)) {
|
|
266
|
+
const l = skip.map(s => new URL(s, baseUrl).href);
|
|
267
|
+
skip = s => l.some(i => (i[i.length - 1] === '/' && s.startsWith(i)) || s === i);
|
|
268
|
+
} else if (typeof skip === 'string') {
|
|
269
|
+
const r = new RegExp(skip);
|
|
270
|
+
skip = s => r.test(s);
|
|
271
|
+
} else if (skip instanceof RegExp) {
|
|
272
|
+
skip = s => skip.test(s);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
const dispatchError = error => self.dispatchEvent(Object.assign(new Event('error'), { error }));
|
|
276
|
+
|
|
277
|
+
const throwError = err => {
|
|
278
|
+
(self.reportError || dispatchError)(err), void onerror(err);
|
|
279
|
+
};
|
|
280
|
+
|
|
278
281
|
const fromParent = parent => (parent ? ` imported from ${parent}` : '');
|
|
279
282
|
|
|
280
283
|
const backslashRegEx = /\\/g;
|
|
@@ -534,13 +537,15 @@
|
|
|
534
537
|
|
|
535
538
|
// 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.
|
|
536
539
|
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=${
|
|
537
|
-
supportsImportMaps ? `c(b(\`import"\${b('{}','text/json')}"with{type:"json"}\`))` : 'false'
|
|
540
|
+
supportsImportMaps && jsonModulesEnabled ? `c(b(\`import"\${b('{}','text/json')}"with{type:"json"}\`))` : 'false'
|
|
538
541
|
};sp=${
|
|
539
542
|
supportsImportMaps && wasmSourcePhaseEnabled ?
|
|
540
543
|
`c(b(\`import source x from "\${b(new Uint8Array(${JSON.stringify(wasmBytes)}),'application/wasm')\}"\`))`
|
|
541
544
|
: 'false'
|
|
542
545
|
};Promise.all([${supportsImportMaps ? 'true' : "c('x')"},${supportsImportMaps ? "c('y')" : false},cm,${
|
|
543
|
-
supportsImportMaps
|
|
546
|
+
supportsImportMaps && cssModulesEnabled ?
|
|
547
|
+
`cm.then(s=>s?c(b(\`import"\${b('','text/css')\}"with{type:"css"}\`)):false)`
|
|
548
|
+
: 'false'
|
|
544
549
|
},sp,${
|
|
545
550
|
supportsImportMaps && wasmInstancePhaseEnabled ?
|
|
546
551
|
`${wasmSourcePhaseEnabled ? 'sp.then(s=>s?' : ''}c(b(\`import"\${b(new Uint8Array(${JSON.stringify(wasmBytes)}),'application/wasm')\}"\`))${wasmSourcePhaseEnabled ? ':false)' : ''}`
|
|
@@ -591,878 +596,875 @@
|
|
|
591
596
|
/* es-module-lexer 1.7.0 */
|
|
592
597
|
let e,a,r,i=2<<19;const s=1===new Uint8Array(new Uint16Array([1]).buffer)[0]?function(e,a){const r=e.length;let i=0;for(;i<r;)a[i]=e.charCodeAt(i++);}:function(e,a){const r=e.length;let i=0;for(;i<r;){const r=e.charCodeAt(i);a[i++]=(255&r)<<8|r>>>8;}},f="xportmportlassforetaourceeferromsyncunctionssertvoyiedelecontininstantybreareturdebuggeawaithrwhileifcatcfinallels";let t,c$1,n;function parse(k,l="@"){t=k,c$1=l;const u=2*t.length+(2<<18);if(u>i||!e){for(;u>i;)i*=2;a=new ArrayBuffer(i),s(f,new Uint16Array(a,16,114)),e=function(e,a,r){"use asm";var i=new e.Int8Array(r),s=new e.Int16Array(r),f=new e.Int32Array(r),t=new e.Uint8Array(r),c=new e.Uint16Array(r),n=1040;function b(){var e=0,a=0,r=0,t=0,c=0,b=0,u=0;u=n;n=n+10240|0;i[812]=1;i[811]=0;s[403]=0;s[404]=0;f[71]=f[2];i[813]=0;f[70]=0;i[810]=0;f[72]=u+2048;f[73]=u;i[814]=0;e=(f[3]|0)+-2|0;f[74]=e;a=e+(f[68]<<1)|0;f[75]=a;e:while(1){r=e+2|0;f[74]=r;if(e>>>0>=a>>>0){t=18;break}a:do{switch(s[r>>1]|0){case 9:case 10:case 11:case 12:case 13:case 32:break;case 101:{if((((s[404]|0)==0?H(r)|0:0)?(m(e+4|0,16,10)|0)==0:0)?(k(),(i[812]|0)==0):0){t=9;break e}else t=17;break}case 105:{if(H(r)|0?(m(e+4|0,26,10)|0)==0:0){l();t=17;}else t=17;break}case 59:{t=17;break}case 47:switch(s[e+4>>1]|0){case 47:{P();break a}case 42:{y(1);break a}default:{t=16;break e}}default:{t=16;break e}}}while(0);if((t|0)==17){t=0;f[71]=f[74];}e=f[74]|0;a=f[75]|0;}if((t|0)==9){e=f[74]|0;f[71]=e;t=19;}else if((t|0)==16){i[812]=0;f[74]=e;t=19;}else if((t|0)==18)if(!(i[810]|0)){e=r;t=19;}else e=0;do{if((t|0)==19){e:while(1){a=e+2|0;f[74]=a;if(e>>>0>=(f[75]|0)>>>0){t=92;break}a:do{switch(s[a>>1]|0){case 9:case 10:case 11:case 12:case 13:case 32:break;case 101:{if(((s[404]|0)==0?H(a)|0:0)?(m(e+4|0,16,10)|0)==0:0){k();t=91;}else t=91;break}case 105:{if(H(a)|0?(m(e+4|0,26,10)|0)==0:0){l();t=91;}else t=91;break}case 99:{if((H(a)|0?(m(e+4|0,36,8)|0)==0:0)?V(s[e+12>>1]|0)|0:0){i[814]=1;t=91;}else t=91;break}case 40:{r=f[72]|0;e=s[404]|0;t=e&65535;f[r+(t<<3)>>2]=1;a=f[71]|0;s[404]=e+1<<16>>16;f[r+(t<<3)+4>>2]=a;t=91;break}case 41:{a=s[404]|0;if(!(a<<16>>16)){t=36;break e}r=a+-1<<16>>16;s[404]=r;t=s[403]|0;a=t&65535;if(t<<16>>16!=0?(f[(f[72]|0)+((r&65535)<<3)>>2]|0)==5:0){a=f[(f[73]|0)+(a+-1<<2)>>2]|0;r=a+4|0;if(!(f[r>>2]|0))f[r>>2]=(f[71]|0)+2;f[a+12>>2]=e+4;s[403]=t+-1<<16>>16;t=91;}else t=91;break}case 123:{t=f[71]|0;r=f[65]|0;e=t;do{if((s[t>>1]|0)==41&(r|0)!=0?(f[r+4>>2]|0)==(t|0):0){a=f[66]|0;f[65]=a;if(!a){f[61]=0;break}else {f[a+32>>2]=0;break}}}while(0);r=f[72]|0;a=s[404]|0;t=a&65535;f[r+(t<<3)>>2]=(i[814]|0)==0?2:6;s[404]=a+1<<16>>16;f[r+(t<<3)+4>>2]=e;i[814]=0;t=91;break}case 125:{e=s[404]|0;if(!(e<<16>>16)){t=49;break e}r=f[72]|0;t=e+-1<<16>>16;s[404]=t;if((f[r+((t&65535)<<3)>>2]|0)==4){h();t=91;}else t=91;break}case 39:{v(39);t=91;break}case 34:{v(34);t=91;break}case 47:switch(s[e+4>>1]|0){case 47:{P();break a}case 42:{y(1);break a}default:{e=f[71]|0;a=s[e>>1]|0;r:do{if(!(U(a)|0))if(a<<16>>16==41){r=s[404]|0;if(!(D(f[(f[72]|0)+((r&65535)<<3)+4>>2]|0)|0))t=65;}else t=64;else switch(a<<16>>16){case 46:if(((s[e+-2>>1]|0)+-48&65535)<10){t=64;break r}else break r;case 43:if((s[e+-2>>1]|0)==43){t=64;break r}else break r;case 45:if((s[e+-2>>1]|0)==45){t=64;break r}else break r;default:break r}}while(0);if((t|0)==64){r=s[404]|0;t=65;}r:do{if((t|0)==65){t=0;if(r<<16>>16!=0?(c=f[72]|0,b=(r&65535)+-1|0,a<<16>>16==102?(f[c+(b<<3)>>2]|0)==1:0):0){if((s[e+-2>>1]|0)==111?$(f[c+(b<<3)+4>>2]|0,44,3)|0:0)break}else t=69;if((t|0)==69?(0,a<<16>>16==125):0){t=f[72]|0;r=r&65535;if(p(f[t+(r<<3)+4>>2]|0)|0)break;if((f[t+(r<<3)>>2]|0)==6)break}if(!(o(e)|0)){switch(a<<16>>16){case 0:break r;case 47:{if(i[813]|0)break r;break}default:{}}t=f[67]|0;if((t|0?e>>>0>=(f[t>>2]|0)>>>0:0)?e>>>0<=(f[t+4>>2]|0)>>>0:0){g();i[813]=0;t=91;break a}r=f[3]|0;do{if(e>>>0<=r>>>0)break;e=e+-2|0;f[71]=e;a=s[e>>1]|0;}while(!(E(a)|0));if(F(a)|0){do{if(e>>>0<=r>>>0)break;e=e+-2|0;f[71]=e;}while(F(s[e>>1]|0)|0);if(j(e)|0){g();i[813]=0;t=91;break a}}i[813]=1;t=91;break a}}}while(0);g();i[813]=0;t=91;break a}}case 96:{r=f[72]|0;a=s[404]|0;t=a&65535;f[r+(t<<3)+4>>2]=f[71];s[404]=a+1<<16>>16;f[r+(t<<3)>>2]=3;h();t=91;break}default:t=91;}}while(0);if((t|0)==91){t=0;f[71]=f[74];}e=f[74]|0;}if((t|0)==36){T();e=0;break}else if((t|0)==49){T();e=0;break}else if((t|0)==92){e=(i[810]|0)==0?(s[403]|s[404])<<16>>16==0:0;break}}}while(0);n=u;return e|0}function k(){var e=0,a=0,r=0,t=0,c=0,n=0,b=0,k=0,l=0,o=0,h=0,d=0,C=0,g=0;k=f[74]|0;l=f[67]|0;g=k+12|0;f[74]=g;r=w(1)|0;e=f[74]|0;if(!((e|0)==(g|0)?!(I(r)|0):0))C=3;e:do{if((C|0)==3){a:do{switch(r<<16>>16){case 123:{f[74]=e+2;e=w(1)|0;a=f[74]|0;while(1){if(W(e)|0){v(e);e=(f[74]|0)+2|0;f[74]=e;}else {q(e)|0;e=f[74]|0;}w(1)|0;e=A(a,e)|0;if(e<<16>>16==44){f[74]=(f[74]|0)+2;e=w(1)|0;}if(e<<16>>16==125){C=15;break}g=a;a=f[74]|0;if((a|0)==(g|0)){C=12;break}if(a>>>0>(f[75]|0)>>>0){C=14;break}}if((C|0)==12){T();break e}else if((C|0)==14){T();break e}else if((C|0)==15){i[811]=1;f[74]=(f[74]|0)+2;break a}break}case 42:{f[74]=e+2;w(1)|0;g=f[74]|0;A(g,g)|0;break}default:{i[812]=0;switch(r<<16>>16){case 100:{k=e+14|0;f[74]=k;switch((w(1)|0)<<16>>16){case 97:{a=f[74]|0;if((m(a+2|0,80,8)|0)==0?(c=a+10|0,F(s[c>>1]|0)|0):0){f[74]=c;w(0)|0;C=22;}break}case 102:{C=22;break}case 99:{a=f[74]|0;if(((m(a+2|0,36,8)|0)==0?(t=a+10|0,g=s[t>>1]|0,V(g)|0|g<<16>>16==123):0)?(f[74]=t,n=w(1)|0,n<<16>>16!=123):0){d=n;C=31;}break}default:{}}r:do{if((C|0)==22?(b=f[74]|0,(m(b+2|0,88,14)|0)==0):0){r=b+16|0;a=s[r>>1]|0;if(!(V(a)|0))switch(a<<16>>16){case 40:case 42:break;default:break r}f[74]=r;a=w(1)|0;if(a<<16>>16==42){f[74]=(f[74]|0)+2;a=w(1)|0;}if(a<<16>>16!=40){d=a;C=31;}}}while(0);if((C|0)==31?(o=f[74]|0,q(d)|0,h=f[74]|0,h>>>0>o>>>0):0){O(e,k,o,h);f[74]=(f[74]|0)+-2;break e}O(e,k,0,0);f[74]=e+12;break e}case 97:{f[74]=e+10;w(0)|0;e=f[74]|0;C=35;break}case 102:{C=35;break}case 99:{if((m(e+2|0,36,8)|0)==0?(a=e+10|0,E(s[a>>1]|0)|0):0){f[74]=a;g=w(1)|0;C=f[74]|0;q(g)|0;g=f[74]|0;O(C,g,C,g);f[74]=(f[74]|0)+-2;break e}e=e+4|0;f[74]=e;break}case 108:case 118:break;default:break e}if((C|0)==35){f[74]=e+16;e=w(1)|0;if(e<<16>>16==42){f[74]=(f[74]|0)+2;e=w(1)|0;}C=f[74]|0;q(e)|0;g=f[74]|0;O(C,g,C,g);f[74]=(f[74]|0)+-2;break e}f[74]=e+6;i[812]=0;r=w(1)|0;e=f[74]|0;r=(q(r)|0|32)<<16>>16==123;t=f[74]|0;if(r){f[74]=t+2;g=w(1)|0;e=f[74]|0;q(g)|0;}r:while(1){a=f[74]|0;if((a|0)==(e|0))break;O(e,a,e,a);a=w(1)|0;if(r)switch(a<<16>>16){case 93:case 125:break e;default:{}}e=f[74]|0;if(a<<16>>16!=44){C=51;break}f[74]=e+2;a=w(1)|0;e=f[74]|0;switch(a<<16>>16){case 91:case 123:{C=51;break r}default:{}}q(a)|0;}if((C|0)==51)f[74]=e+-2;if(!r)break e;f[74]=t+-2;break e}}}while(0);g=(w(1)|0)<<16>>16==102;e=f[74]|0;if(g?(m(e+2|0,74,6)|0)==0:0){f[74]=e+8;u(k,w(1)|0,0);e=(l|0)==0?248:l+16|0;while(1){e=f[e>>2]|0;if(!e)break e;f[e+12>>2]=0;f[e+8>>2]=0;e=e+16|0;}}f[74]=e+-2;}}while(0);return}function l(){var e=0,a=0,r=0,t=0,c=0,n=0,b=0;b=f[74]|0;c=b+12|0;f[74]=c;e=w(1)|0;t=f[74]|0;e:do{if(e<<16>>16!=46){if(!(e<<16>>16==115&t>>>0>c>>>0)){if(!(e<<16>>16==100&t>>>0>(b+10|0)>>>0)){t=0;n=28;break}if(m(t+2|0,66,8)|0){a=t;e=100;t=0;n=59;break}e=t+10|0;if(!(V(s[e>>1]|0)|0)){a=t;e=100;t=0;n=59;break}f[74]=e;e=w(1)|0;if(e<<16>>16==42){e=42;t=2;n=61;break}f[74]=t;t=0;n=28;break}if((m(t+2|0,56,10)|0)==0?(r=t+12|0,V(s[r>>1]|0)|0):0){f[74]=r;e=w(1)|0;a=f[74]|0;if((a|0)!=(r|0)){if(e<<16>>16!=102){t=1;n=28;break}if(m(a+2|0,74,6)|0){e=102;t=1;n=59;break}if(!(E(s[a+8>>1]|0)|0)){e=102;t=1;n=59;break}}f[74]=t;t=0;n=28;}else {a=t;e=115;t=0;n=59;}}else {f[74]=t+2;switch((w(1)|0)<<16>>16){case 109:{e=f[74]|0;if(m(e+2|0,50,6)|0)break e;a=f[71]|0;if(!(G(a)|0)?(s[a>>1]|0)==46:0)break e;d(b,b,e+8|0,2);break e}case 115:{e=f[74]|0;if(m(e+2|0,56,10)|0)break e;a=f[71]|0;if(!(G(a)|0)?(s[a>>1]|0)==46:0)break e;f[74]=e+12;e=w(1)|0;t=1;n=28;break e}case 100:{e=f[74]|0;if(m(e+2|0,66,8)|0)break e;a=f[71]|0;if(!(G(a)|0)?(s[a>>1]|0)==46:0)break e;f[74]=e+10;e=w(1)|0;t=2;n=28;break e}default:break e}}}while(0);e:do{if((n|0)==28){if(e<<16>>16==40){r=f[72]|0;a=s[404]|0;c=a&65535;f[r+(c<<3)>>2]=5;e=f[74]|0;s[404]=a+1<<16>>16;f[r+(c<<3)+4>>2]=e;if((s[f[71]>>1]|0)==46)break;f[74]=e+2;a=w(1)|0;d(b,f[74]|0,0,e);if(!t)e=f[65]|0;else {e=f[65]|0;f[e+28>>2]=(t|0)==1?5:7;}c=f[73]|0;b=s[403]|0;s[403]=b+1<<16>>16;f[c+((b&65535)<<2)>>2]=e;switch(a<<16>>16){case 39:{v(39);break}case 34:{v(34);break}default:{f[74]=(f[74]|0)+-2;break e}}e=(f[74]|0)+2|0;f[74]=e;switch((w(1)|0)<<16>>16){case 44:{f[74]=(f[74]|0)+2;w(1)|0;c=f[65]|0;f[c+4>>2]=e;b=f[74]|0;f[c+16>>2]=b;i[c+24>>0]=1;f[74]=b+-2;break e}case 41:{s[404]=(s[404]|0)+-1<<16>>16;b=f[65]|0;f[b+4>>2]=e;f[b+12>>2]=(f[74]|0)+2;i[b+24>>0]=1;s[403]=(s[403]|0)+-1<<16>>16;break e}default:{f[74]=(f[74]|0)+-2;break e}}}if(!((t|0)==0&e<<16>>16==123)){switch(e<<16>>16){case 42:case 39:case 34:{n=61;break e}default:{}}a=f[74]|0;n=59;break}e=f[74]|0;if(s[404]|0){f[74]=e+-2;break}while(1){if(e>>>0>=(f[75]|0)>>>0)break;e=w(1)|0;if(!(W(e)|0)){if(e<<16>>16==125){n=49;break}}else v(e);e=(f[74]|0)+2|0;f[74]=e;}if((n|0)==49)f[74]=(f[74]|0)+2;c=(w(1)|0)<<16>>16==102;e=f[74]|0;if(c?m(e+2|0,74,6)|0:0){T();break}f[74]=e+8;e=w(1)|0;if(W(e)|0){u(b,e,0);break}else {T();break}}}while(0);if((n|0)==59)if((a|0)==(c|0))f[74]=b+10;else n=61;do{if((n|0)==61){if(!((e<<16>>16==42|(t|0)!=2)&(s[404]|0)==0)){f[74]=(f[74]|0)+-2;break}e=f[75]|0;a=f[74]|0;while(1){if(a>>>0>=e>>>0){n=68;break}r=s[a>>1]|0;if(W(r)|0){n=66;break}n=a+2|0;f[74]=n;a=n;}if((n|0)==66){u(b,r,t);break}else if((n|0)==68){T();break}}}while(0);return}function u(e,a,r){e=e|0;a=a|0;r=r|0;var i=0,t=0;i=(f[74]|0)+2|0;switch(a<<16>>16){case 39:{v(39);t=5;break}case 34:{v(34);t=5;break}default:T();}do{if((t|0)==5){d(e,i,f[74]|0,1);if((r|0)>0)f[(f[65]|0)+28>>2]=(r|0)==1?4:6;f[74]=(f[74]|0)+2;a=w(0)|0;r=a<<16>>16==97;if(r){i=f[74]|0;if(m(i+2|0,102,10)|0)t=13;}else {i=f[74]|0;if(!(((a<<16>>16==119?(s[i+2>>1]|0)==105:0)?(s[i+4>>1]|0)==116:0)?(s[i+6>>1]|0)==104:0))t=13;}if((t|0)==13){f[74]=i+-2;break}f[74]=i+((r?6:4)<<1);if((w(1)|0)<<16>>16!=123){f[74]=i;break}r=f[74]|0;a=r;e:while(1){f[74]=a+2;a=w(1)|0;switch(a<<16>>16){case 39:{v(39);f[74]=(f[74]|0)+2;a=w(1)|0;break}case 34:{v(34);f[74]=(f[74]|0)+2;a=w(1)|0;break}default:a=q(a)|0;}if(a<<16>>16!=58){t=22;break}f[74]=(f[74]|0)+2;switch((w(1)|0)<<16>>16){case 39:{v(39);break}case 34:{v(34);break}default:{t=26;break e}}f[74]=(f[74]|0)+2;switch((w(1)|0)<<16>>16){case 125:{t=31;break e}case 44:break;default:{t=30;break e}}f[74]=(f[74]|0)+2;if((w(1)|0)<<16>>16==125){t=31;break}a=f[74]|0;}if((t|0)==22){f[74]=i;break}else if((t|0)==26){f[74]=i;break}else if((t|0)==30){f[74]=i;break}else if((t|0)==31){t=f[65]|0;f[t+16>>2]=r;f[t+12>>2]=(f[74]|0)+2;break}}}while(0);return}function o(e){e=e|0;e:do{switch(s[e>>1]|0){case 100:switch(s[e+-2>>1]|0){case 105:{e=$(e+-4|0,112,2)|0;break e}case 108:{e=$(e+-4|0,116,3)|0;break e}default:{e=0;break e}}case 101:switch(s[e+-2>>1]|0){case 115:switch(s[e+-4>>1]|0){case 108:{e=B(e+-6|0,101)|0;break e}case 97:{e=B(e+-6|0,99)|0;break e}default:{e=0;break e}}case 116:{e=$(e+-4|0,122,4)|0;break e}case 117:{e=$(e+-4|0,130,6)|0;break e}default:{e=0;break e}}case 102:{if((s[e+-2>>1]|0)==111?(s[e+-4>>1]|0)==101:0)switch(s[e+-6>>1]|0){case 99:{e=$(e+-8|0,142,6)|0;break e}case 112:{e=$(e+-8|0,154,2)|0;break e}default:{e=0;break e}}else e=0;break}case 107:{e=$(e+-2|0,158,4)|0;break}case 110:{e=e+-2|0;if(B(e,105)|0)e=1;else e=$(e,166,5)|0;break}case 111:{e=B(e+-2|0,100)|0;break}case 114:{e=$(e+-2|0,176,7)|0;break}case 116:{e=$(e+-2|0,190,4)|0;break}case 119:switch(s[e+-2>>1]|0){case 101:{e=B(e+-4|0,110)|0;break e}case 111:{e=$(e+-4|0,198,3)|0;break e}default:{e=0;break e}}default:e=0;}}while(0);return e|0}function h(){var e=0,a=0,r=0,i=0;a=f[75]|0;r=f[74]|0;e:while(1){e=r+2|0;if(r>>>0>=a>>>0){a=10;break}switch(s[e>>1]|0){case 96:{a=7;break e}case 36:{if((s[r+4>>1]|0)==123){a=6;break e}break}case 92:{e=r+4|0;break}default:{}}r=e;}if((a|0)==6){e=r+4|0;f[74]=e;a=f[72]|0;i=s[404]|0;r=i&65535;f[a+(r<<3)>>2]=4;s[404]=i+1<<16>>16;f[a+(r<<3)+4>>2]=e;}else if((a|0)==7){f[74]=e;r=f[72]|0;i=(s[404]|0)+-1<<16>>16;s[404]=i;if((f[r+((i&65535)<<3)>>2]|0)!=3)T();}else if((a|0)==10){f[74]=e;T();}return}function w(e){e=e|0;var a=0,r=0,i=0;r=f[74]|0;e:do{a=s[r>>1]|0;a:do{if(a<<16>>16!=47)if(e)if(V(a)|0)break;else break e;else if(F(a)|0)break;else break e;else switch(s[r+2>>1]|0){case 47:{P();break a}case 42:{y(e);break a}default:{a=47;break e}}}while(0);i=f[74]|0;r=i+2|0;f[74]=r;}while(i>>>0<(f[75]|0)>>>0);return a|0}function d(e,a,r,s){e=e|0;a=a|0;r=r|0;s=s|0;var t=0,c=0;c=f[69]|0;f[69]=c+36;t=f[65]|0;f[((t|0)==0?244:t+32|0)>>2]=c;f[66]=t;f[65]=c;f[c+8>>2]=e;if(2==(s|0)){e=3;t=r;}else {t=1==(s|0);e=t?1:2;t=t?r+2|0:0;}f[c+12>>2]=t;f[c+28>>2]=e;f[c>>2]=a;f[c+4>>2]=r;f[c+16>>2]=0;f[c+20>>2]=s;a=1==(s|0);i[c+24>>0]=a&1;f[c+32>>2]=0;if(a|2==(s|0))i[811]=1;return}function v(e){e=e|0;var a=0,r=0,i=0,t=0;t=f[75]|0;a=f[74]|0;while(1){i=a+2|0;if(a>>>0>=t>>>0){a=9;break}r=s[i>>1]|0;if(r<<16>>16==e<<16>>16){a=10;break}if(r<<16>>16==92){r=a+4|0;if((s[r>>1]|0)==13){a=a+6|0;a=(s[a>>1]|0)==10?a:r;}else a=r;}else if(Z(r)|0){a=9;break}else a=i;}if((a|0)==9){f[74]=i;T();}else if((a|0)==10)f[74]=i;return}function A(e,a){e=e|0;a=a|0;var r=0,i=0,t=0,c=0;r=f[74]|0;i=s[r>>1]|0;c=(e|0)==(a|0);t=c?0:e;c=c?0:a;if(i<<16>>16==97){f[74]=r+4;r=w(1)|0;e=f[74]|0;if(W(r)|0){v(r);a=(f[74]|0)+2|0;f[74]=a;}else {q(r)|0;a=f[74]|0;}i=w(1)|0;r=f[74]|0;}if((r|0)!=(e|0))O(e,a,t,c);return i|0}function C(){var e=0,a=0,r=0;r=f[75]|0;a=f[74]|0;e:while(1){e=a+2|0;if(a>>>0>=r>>>0){a=6;break}switch(s[e>>1]|0){case 13:case 10:{a=6;break e}case 93:{a=7;break e}case 92:{e=a+4|0;break}default:{}}a=e;}if((a|0)==6){f[74]=e;T();e=0;}else if((a|0)==7){f[74]=e;e=93;}return e|0}function g(){var e=0,a=0,r=0;e:while(1){e=f[74]|0;a=e+2|0;f[74]=a;if(e>>>0>=(f[75]|0)>>>0){r=7;break}switch(s[a>>1]|0){case 13:case 10:{r=7;break e}case 47:break e;case 91:{C()|0;break}case 92:{f[74]=e+4;break}default:{}}}if((r|0)==7)T();return}function p(e){e=e|0;switch(s[e>>1]|0){case 62:{e=(s[e+-2>>1]|0)==61;break}case 41:case 59:{e=1;break}case 104:{e=$(e+-2|0,218,4)|0;break}case 121:{e=$(e+-2|0,226,6)|0;break}case 101:{e=$(e+-2|0,238,3)|0;break}default:e=0;}return e|0}function y(e){e=e|0;var a=0,r=0,i=0,t=0,c=0;t=(f[74]|0)+2|0;f[74]=t;r=f[75]|0;while(1){a=t+2|0;if(t>>>0>=r>>>0)break;i=s[a>>1]|0;if(!e?Z(i)|0:0)break;if(i<<16>>16==42?(s[t+4>>1]|0)==47:0){c=8;break}t=a;}if((c|0)==8){f[74]=a;a=t+4|0;}f[74]=a;return}function m(e,a,r){e=e|0;a=a|0;r=r|0;var s=0,f=0;e:do{if(!r)e=0;else {while(1){s=i[e>>0]|0;f=i[a>>0]|0;if(s<<24>>24!=f<<24>>24)break;r=r+-1|0;if(!r){e=0;break e}else {e=e+1|0;a=a+1|0;}}e=(s&255)-(f&255)|0;}}while(0);return e|0}function I(e){e=e|0;e:do{switch(e<<16>>16){case 38:case 37:case 33:{e=1;break}default:if((e&-8)<<16>>16==40|(e+-58&65535)<6)e=1;else {switch(e<<16>>16){case 91:case 93:case 94:{e=1;break e}default:{}}e=(e+-123&65535)<4;}}}while(0);return e|0}function U(e){e=e|0;e:do{switch(e<<16>>16){case 38:case 37:case 33:break;default:if(!((e+-58&65535)<6|(e+-40&65535)<7&e<<16>>16!=41)){switch(e<<16>>16){case 91:case 94:break e;default:{}}return e<<16>>16!=125&(e+-123&65535)<4|0}}}while(0);return 1}function x(e){e=e|0;var a=0;a=s[e>>1]|0;e:do{if((a+-9&65535)>=5){switch(a<<16>>16){case 160:case 32:{a=1;break e}default:{}}if(I(a)|0)return a<<16>>16!=46|(G(e)|0)|0;else a=0;}else a=1;}while(0);return a|0}function S(e){e=e|0;var a=0,r=0,i=0,t=0;r=n;n=n+16|0;i=r;f[i>>2]=0;f[68]=e;a=f[3]|0;t=a+(e<<1)|0;e=t+2|0;s[t>>1]=0;f[i>>2]=e;f[69]=e;f[61]=0;f[65]=0;f[63]=0;f[62]=0;f[67]=0;f[64]=0;n=r;return a|0}function O(e,a,r,s){e=e|0;a=a|0;r=r|0;s=s|0;var t=0,c=0;t=f[69]|0;f[69]=t+20;c=f[67]|0;f[((c|0)==0?248:c+16|0)>>2]=t;f[67]=t;f[t>>2]=e;f[t+4>>2]=a;f[t+8>>2]=r;f[t+12>>2]=s;f[t+16>>2]=0;i[811]=1;return}function $(e,a,r){e=e|0;a=a|0;r=r|0;var i=0,s=0;i=e+(0-r<<1)|0;s=i+2|0;e=f[3]|0;if(s>>>0>=e>>>0?(m(s,a,r<<1)|0)==0:0)if((s|0)==(e|0))e=1;else e=x(i)|0;else e=0;return e|0}function j(e){e=e|0;switch(s[e>>1]|0){case 107:{e=$(e+-2|0,158,4)|0;break}case 101:{if((s[e+-2>>1]|0)==117)e=$(e+-4|0,130,6)|0;else e=0;break}default:e=0;}return e|0}function B(e,a){e=e|0;a=a|0;var r=0;r=f[3]|0;if(r>>>0<=e>>>0?(s[e>>1]|0)==a<<16>>16:0)if((r|0)==(e|0))r=1;else r=E(s[e+-2>>1]|0)|0;else r=0;return r|0}function E(e){e=e|0;e:do{if((e+-9&65535)<5)e=1;else {switch(e<<16>>16){case 32:case 160:{e=1;break e}default:{}}e=e<<16>>16!=46&(I(e)|0);}}while(0);return e|0}function P(){var e=0,a=0,r=0;e=f[75]|0;r=f[74]|0;e:while(1){a=r+2|0;if(r>>>0>=e>>>0)break;switch(s[a>>1]|0){case 13:case 10:break e;default:r=a;}}f[74]=a;return}function q(e){e=e|0;while(1){if(V(e)|0)break;if(I(e)|0)break;e=(f[74]|0)+2|0;f[74]=e;e=s[e>>1]|0;if(!(e<<16>>16)){e=0;break}}return e|0}function z(){var e=0;e=f[(f[63]|0)+20>>2]|0;switch(e|0){case 1:{e=-1;break}case 2:{e=-2;break}default:e=e-(f[3]|0)>>1;}return e|0}function D(e){e=e|0;if(!($(e,204,5)|0)?!($(e,44,3)|0):0)e=$(e,214,2)|0;else e=1;return e|0}function F(e){e=e|0;switch(e<<16>>16){case 160:case 32:case 12:case 11:case 9:{e=1;break}default:e=0;}return e|0}function G(e){e=e|0;if((s[e>>1]|0)==46?(s[e+-2>>1]|0)==46:0)e=(s[e+-4>>1]|0)==46;else e=0;return e|0}function H(e){e=e|0;if((f[3]|0)==(e|0))e=1;else e=x(e+-2|0)|0;return e|0}function J(){var e=0;e=f[(f[64]|0)+12>>2]|0;if(!e)e=-1;else e=e-(f[3]|0)>>1;return e|0}function K(){var e=0;e=f[(f[63]|0)+12>>2]|0;if(!e)e=-1;else e=e-(f[3]|0)>>1;return e|0}function L(){var e=0;e=f[(f[64]|0)+8>>2]|0;if(!e)e=-1;else e=e-(f[3]|0)>>1;return e|0}function M(){var e=0;e=f[(f[63]|0)+16>>2]|0;if(!e)e=-1;else e=e-(f[3]|0)>>1;return e|0}function N(){var e=0;e=f[(f[63]|0)+4>>2]|0;if(!e)e=-1;else e=e-(f[3]|0)>>1;return e|0}function Q(){var e=0;e=f[63]|0;e=f[((e|0)==0?244:e+32|0)>>2]|0;f[63]=e;return (e|0)!=0|0}function R(){var e=0;e=f[64]|0;e=f[((e|0)==0?248:e+16|0)>>2]|0;f[64]=e;return (e|0)!=0|0}function T(){i[810]=1;f[70]=(f[74]|0)-(f[3]|0)>>1;f[74]=(f[75]|0)+2;return}function V(e){e=e|0;return (e|128)<<16>>16==160|(e+-9&65535)<5|0}function W(e){e=e|0;return e<<16>>16==39|e<<16>>16==34|0}function X(){return (f[(f[63]|0)+8>>2]|0)-(f[3]|0)>>1|0}function Y(){return (f[(f[64]|0)+4>>2]|0)-(f[3]|0)>>1|0}function Z(e){e=e|0;return e<<16>>16==13|e<<16>>16==10|0}function _(){return (f[f[63]>>2]|0)-(f[3]|0)>>1|0}function ee(){return (f[f[64]>>2]|0)-(f[3]|0)>>1|0}function ae(){return t[(f[63]|0)+24>>0]|0|0}function re(e){e=e|0;f[3]=e;return}function ie(){return f[(f[63]|0)+28>>2]|0}function se(){return (i[811]|0)!=0|0}function fe(){return (i[812]|0)!=0|0}function te(){return f[70]|0}function ce(e){e=e|0;n=e+992+15&-16;return 992}return {su:ce,ai:M,e:te,ee:Y,ele:J,els:L,es:ee,f:fe,id:z,ie:N,ip:ae,is:_,it:ie,ms:se,p:b,re:R,ri:Q,sa:S,se:K,ses:re,ss:X}}("undefined"!=typeof self?self:global,{},a),r=e.su(i-(2<<17));}const h=t.length+1;e.ses(r),e.sa(h-1),s(t,new Uint16Array(a,r,h)),e.p()||(n=e.e(),o());const w=[],d=[];for(;e.ri();){const a=e.is(),r=e.ie(),i=e.ai(),s=e.id(),f=e.ss(),c=e.se(),n=e.it();let k;e.ip()&&(k=b(-1===s?a:a+1,t.charCodeAt(-1===s?a-1:a))),w.push({t:n,n:k,s:a,e:r,ss:f,se:c,d:s,a:i});}for(;e.re();){const a=e.es(),r=e.ee(),i=e.els(),s=e.ele(),f=t.charCodeAt(a),c=i>=0?t.charCodeAt(i):-1;d.push({s:a,e:r,ls:i,le:s,n:34===f||39===f?b(a+1,f):t.slice(a,r),ln:i<0?void 0:34===c||39===c?b(i+1,c):t.slice(i,s)});}return [w,d,!!e.f(),!!e.ms()]}function b(e,a){n=e;let r="",i=n;for(;;){n>=t.length&&o();const e=t.charCodeAt(n);if(e===a)break;92===e?(r+=t.slice(i,n),r+=k(),i=n):(8232===e||8233===e||u(e)&&o(),++n);}return r+=t.slice(i,n++),r}function k(){let e=t.charCodeAt(++n);switch(++n,e){case 110:return "\n";case 114:return "\r";case 120:return String.fromCharCode(l(2));case 117:return function(){const e=t.charCodeAt(n);let a;123===e?(++n,a=l(t.indexOf("}",n)-n),++n,a>1114111&&o()):a=l(4);return a<=65535?String.fromCharCode(a):(a-=65536,String.fromCharCode(55296+(a>>10),56320+(1023&a)))}();case 116:return "\t";case 98:return "\b";case 118:return "\v";case 102:return "\f";case 13:10===t.charCodeAt(n)&&++n;case 10:return "";case 56:case 57:o();default:if(e>=48&&e<=55){let a=t.substr(n-1,3).match(/^[0-7]+/)[0],r=parseInt(a,8);return r>255&&(a=a.slice(0,-1),r=parseInt(a,8)),n+=a.length-1,e=t.charCodeAt(n),"0"===a&&56!==e&&57!==e||o(),String.fromCharCode(r)}return u(e)?"":String.fromCharCode(e)}}function l(e){const a=n;let r=0,i=0;for(let a=0;a<e;++a,++n){let e,s=t.charCodeAt(n);if(95!==s){if(s>=97)e=s-97+10;else if(s>=65)e=s-65+10;else {if(!(s>=48&&s<=57))break;e=s-48;}if(e>=16)break;i=s,r=16*r+e;}else 95!==i&&0!==a||o(),i=s;}return 95!==i&&n-a===e||o(),r}function u(e){return 13===e||10===e}function o(){throw Object.assign(Error(`Parse error ${c$1}:${t.slice(0,n).split("\n").length}:${n-t.lastIndexOf("\n",n-1)}`),{idx:n})}
|
|
593
598
|
|
|
594
|
-
const _resolve = (id, parentUrl = baseUrl) => {
|
|
595
|
-
const urlResolved = resolveIfNotPlainOrUrl(id, parentUrl) || asURL(id);
|
|
596
|
-
const firstResolved = firstImportMap && resolveImportMap(firstImportMap, urlResolved || id, parentUrl);
|
|
597
|
-
const composedResolved =
|
|
598
|
-
composedImportMap === firstImportMap ? firstResolved : (
|
|
599
|
-
resolveImportMap(composedImportMap, urlResolved || id, parentUrl)
|
|
600
|
-
);
|
|
601
|
-
const resolved = composedResolved || firstResolved || throwUnresolved(id, parentUrl);
|
|
602
|
-
// needsShim, shouldShim per load record to set on parent
|
|
603
|
-
let n = false,
|
|
604
|
-
N = false;
|
|
605
|
-
if (!supportsImportMaps) {
|
|
606
|
-
// bare specifier -> needs shim
|
|
607
|
-
if (!urlResolved) n = true;
|
|
608
|
-
// url mapping -> should shim
|
|
609
|
-
else if (urlResolved !== resolved) N = true;
|
|
610
|
-
} else if (!supportsMultipleImportMaps) {
|
|
611
|
-
// bare specifier and not resolved by first import map -> needs shim
|
|
612
|
-
if (!urlResolved && !firstResolved) n = true;
|
|
613
|
-
// resolution doesn't match first import map -> should shim
|
|
614
|
-
if (firstResolved && resolved !== firstResolved) N = true;
|
|
615
|
-
}
|
|
616
|
-
return { r: resolved, n, N };
|
|
617
|
-
};
|
|
618
|
-
|
|
619
|
-
const resolve = (id, parentUrl) => {
|
|
620
|
-
if (!resolveHook) return _resolve(id, parentUrl);
|
|
621
|
-
const result = resolveHook(id, parentUrl, defaultResolve);
|
|
622
|
-
|
|
623
|
-
return result ? { r: result, n: true, N: true } : _resolve(id, parentUrl);
|
|
624
|
-
};
|
|
625
|
-
|
|
626
|
-
// import()
|
|
627
|
-
async function importShim$1(id, opts, parentUrl) {
|
|
628
|
-
if (typeof opts === 'string') {
|
|
629
|
-
parentUrl = opts;
|
|
630
|
-
opts = undefined;
|
|
631
|
-
}
|
|
632
|
-
await initPromise; // needed for shim check
|
|
633
|
-
console.info(`es-module-shims: importShim("${id}"${opts ? ', ' + JSON.stringify(opts) : ''})`);
|
|
634
|
-
if (shimMode || !
|
|
635
|
-
if (hasDocument) processScriptsAndPreloads();
|
|
636
|
-
legacyAcceptingImportMaps = false;
|
|
637
|
-
}
|
|
638
|
-
let sourceType = undefined;
|
|
639
|
-
if (typeof opts === 'object') {
|
|
640
|
-
if (opts.lang === 'ts') sourceType = 'ts';
|
|
641
|
-
if (typeof opts.with === 'object' && typeof opts.with.type === 'string') {
|
|
642
|
-
sourceType = opts.with.type;
|
|
643
|
-
}
|
|
644
|
-
}
|
|
645
|
-
return topLevelLoad(id, parentUrl || baseUrl, defaultFetchOpts, undefined, undefined, undefined, sourceType);
|
|
646
|
-
}
|
|
647
|
-
|
|
648
|
-
// import.source()
|
|
649
|
-
// (opts not currently supported as no use cases yet)
|
|
650
|
-
if (shimMode || wasmSourcePhaseEnabled)
|
|
651
|
-
importShim$1.source = async (id, opts, parentUrl) => {
|
|
652
|
-
if (typeof opts === 'string') {
|
|
653
|
-
parentUrl = opts;
|
|
654
|
-
opts = undefined;
|
|
655
|
-
}
|
|
656
|
-
await initPromise; // needed for shim check
|
|
657
|
-
console.info(`es-module-shims: importShim.source("${id}"${opts ? ', ' + JSON.stringify(opts) : ''})`);
|
|
658
|
-
if (shimMode || !
|
|
659
|
-
if (hasDocument) processScriptsAndPreloads();
|
|
660
|
-
legacyAcceptingImportMaps = false;
|
|
661
|
-
}
|
|
662
|
-
await importMapPromise;
|
|
663
|
-
const url = resolve(id, parentUrl || baseUrl).r;
|
|
664
|
-
const load = getOrCreateLoad(url, defaultFetchOpts, undefined, undefined);
|
|
665
|
-
if (firstPolyfillLoad && !shimMode && load.n && nativelyLoaded) {
|
|
666
|
-
onpolyfill();
|
|
667
|
-
firstPolyfillLoad = false;
|
|
668
|
-
}
|
|
669
|
-
await load.f;
|
|
670
|
-
return importShim$1._s[load.r];
|
|
671
|
-
};
|
|
672
|
-
|
|
673
|
-
// import.defer() is just a proxy for import(), since we can't actually defer
|
|
674
|
-
if (shimMode || deferPhaseEnabled) importShim$1.defer = importShim$1;
|
|
675
|
-
|
|
676
|
-
if (hotReload) importShim$1.hotReload = hotReload$1;
|
|
677
|
-
|
|
678
|
-
const defaultResolve = (id, parentUrl) => {
|
|
679
|
-
return (
|
|
680
|
-
resolveImportMap(composedImportMap, resolveIfNotPlainOrUrl(id, parentUrl) || id, parentUrl) ||
|
|
681
|
-
throwUnresolved(id, parentUrl)
|
|
682
|
-
);
|
|
683
|
-
};
|
|
684
|
-
|
|
685
|
-
const throwUnresolved = (id, parentUrl) => {
|
|
686
|
-
throw Error(`Unable to resolve specifier '${id}'${fromParent(parentUrl)}`);
|
|
687
|
-
};
|
|
688
|
-
|
|
689
|
-
const metaResolve = function (id, parentUrl = this.url) {
|
|
690
|
-
return resolve(id, `${parentUrl}`).r;
|
|
691
|
-
};
|
|
692
|
-
|
|
693
|
-
importShim$1.resolve = (id, parentUrl) => resolve(id, parentUrl).r;
|
|
694
|
-
importShim$1.getImportMap = () => JSON.parse(JSON.stringify(composedImportMap));
|
|
695
|
-
importShim$1.addImportMap = importMapIn => {
|
|
696
|
-
if (!shimMode) throw new Error('Unsupported in polyfill mode.');
|
|
697
|
-
composedImportMap = resolveAndComposeImportMap(importMapIn, baseUrl, composedImportMap);
|
|
698
|
-
};
|
|
699
|
-
importShim$1.version = version;
|
|
700
|
-
|
|
701
|
-
const registry = (importShim$1._r = {});
|
|
702
|
-
// Wasm caches
|
|
703
|
-
const sourceCache = (importShim$1._s = {});
|
|
704
|
-
(importShim$1._i = new WeakMap());
|
|
705
|
-
|
|
706
|
-
// Ensure this version is the only version
|
|
707
|
-
defineValue(self, 'importShim', Object.freeze(importShim$1));
|
|
708
|
-
const shimModeOptions = { ...esmsInitOptions, shimMode: true };
|
|
709
|
-
if (optionsScript) optionsScript.innerHTML = JSON.stringify(shimModeOptions);
|
|
710
|
-
self.esmsInitOptions = shimModeOptions;
|
|
711
|
-
|
|
712
|
-
const loadAll = async (load, seen) => {
|
|
713
|
-
seen[load.u] = 1;
|
|
714
|
-
await load.L;
|
|
715
|
-
await Promise.all(
|
|
716
|
-
load.d.map(({ l: dep, s: sourcePhase }) => {
|
|
717
|
-
if (dep.b || seen[dep.u]) return;
|
|
718
|
-
if (sourcePhase) return dep.f;
|
|
719
|
-
return loadAll(dep, seen);
|
|
720
|
-
})
|
|
721
|
-
);
|
|
722
|
-
};
|
|
723
|
-
|
|
724
|
-
let importMapSrc = false;
|
|
725
|
-
let multipleImportMaps = false;
|
|
726
|
-
let firstImportMap = null;
|
|
727
|
-
// To support polyfilling multiple import maps, we separately track the composed import map from the first import map
|
|
728
|
-
let composedImportMap = { imports: {}, scopes: {}, integrity: {} };
|
|
729
|
-
let
|
|
730
|
-
|
|
731
|
-
const initPromise = featureDetectionPromise.then(() => {
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
(!
|
|
738
|
-
|
|
739
|
-
!
|
|
740
|
-
|
|
741
|
-
!
|
|
742
|
-
if (!shimMode && typeof WebAssembly !== 'undefined') {
|
|
743
|
-
if (wasmSourcePhaseEnabled && !Object.getPrototypeOf(WebAssembly.Module).name) {
|
|
744
|
-
const s = Symbol();
|
|
745
|
-
const brand = m => defineValue(m, s, 'WebAssembly.Module');
|
|
746
|
-
class AbstractModuleSource {
|
|
747
|
-
get [Symbol.toStringTag]() {
|
|
748
|
-
if (this[s]) return this[s];
|
|
749
|
-
throw new TypeError('Not an AbstractModuleSource');
|
|
750
|
-
}
|
|
751
|
-
}
|
|
752
|
-
const { Module: wasmModule, compile: wasmCompile, compileStreaming: wasmCompileStreaming } = WebAssembly;
|
|
753
|
-
WebAssembly.Module = Object.setPrototypeOf(
|
|
754
|
-
Object.assign(function Module(...args) {
|
|
755
|
-
return brand(new wasmModule(...args));
|
|
756
|
-
}, wasmModule),
|
|
757
|
-
AbstractModuleSource
|
|
758
|
-
);
|
|
759
|
-
WebAssembly.Module.prototype = Object.setPrototypeOf(wasmModule.prototype, AbstractModuleSource.prototype);
|
|
760
|
-
WebAssembly.compile = function compile(...args) {
|
|
761
|
-
return wasmCompile(...args).then(brand);
|
|
762
|
-
};
|
|
763
|
-
WebAssembly.compileStreaming = function compileStreaming(...args) {
|
|
764
|
-
return wasmCompileStreaming(...args).then(brand);
|
|
765
|
-
};
|
|
766
|
-
}
|
|
767
|
-
}
|
|
768
|
-
if (hasDocument) {
|
|
769
|
-
if (!supportsImportMaps) {
|
|
770
|
-
const supports = HTMLScriptElement.supports || (type => type === 'classic' || type === 'module');
|
|
771
|
-
HTMLScriptElement.supports = type => type === 'importmap' || supports(type);
|
|
772
|
-
}
|
|
773
|
-
if (shimMode || !
|
|
774
|
-
attachMutationObserver();
|
|
775
|
-
if (document.readyState === 'complete') {
|
|
776
|
-
readyStateCompleteCheck();
|
|
777
|
-
} else {
|
|
778
|
-
document.addEventListener('readystatechange', readyListener);
|
|
779
|
-
}
|
|
780
|
-
}
|
|
781
|
-
processScriptsAndPreloads();
|
|
782
|
-
}
|
|
783
|
-
return undefined;
|
|
784
|
-
});
|
|
785
|
-
|
|
786
|
-
const attachMutationObserver = () => {
|
|
787
|
-
const observer = new MutationObserver(mutations => {
|
|
788
|
-
for (const mutation of mutations) {
|
|
789
|
-
if (mutation.type !== 'childList') continue;
|
|
790
|
-
for (const node of mutation.addedNodes) {
|
|
791
|
-
if (node.tagName === 'SCRIPT') {
|
|
792
|
-
if (node.type === (shimMode ? 'module-shim' : 'module') && !node.ep) processScript(node, true);
|
|
793
|
-
if (node.type === (shimMode ? 'importmap-shim' : 'importmap') && !node.ep) processImportMap(node, true);
|
|
794
|
-
} else if (
|
|
795
|
-
node.tagName === 'LINK' &&
|
|
796
|
-
node.rel === (shimMode ? 'modulepreload-shim' : 'modulepreload') &&
|
|
797
|
-
!node.ep
|
|
798
|
-
) {
|
|
799
|
-
processPreload(node);
|
|
800
|
-
}
|
|
801
|
-
}
|
|
802
|
-
}
|
|
803
|
-
});
|
|
804
|
-
observer.observe(document, { childList: true });
|
|
805
|
-
observer.observe(document.head, { childList: true });
|
|
806
|
-
processScriptsAndPreloads();
|
|
807
|
-
};
|
|
808
|
-
|
|
809
|
-
let importMapPromise = initPromise;
|
|
810
|
-
let firstPolyfillLoad = true;
|
|
811
|
-
let legacyAcceptingImportMaps = true;
|
|
812
|
-
|
|
813
|
-
const topLevelLoad = async (
|
|
814
|
-
url,
|
|
815
|
-
parentUrl,
|
|
816
|
-
fetchOpts,
|
|
817
|
-
source,
|
|
818
|
-
nativelyLoaded,
|
|
819
|
-
lastStaticLoadPromise,
|
|
820
|
-
sourceType
|
|
821
|
-
) => {
|
|
822
|
-
await initPromise;
|
|
823
|
-
await importMapPromise;
|
|
824
|
-
url = (await resolve(url, parentUrl)).r;
|
|
825
|
-
|
|
826
|
-
// we mock import('./x.css', { with: { type: 'css' }}) support via an inline static reexport
|
|
827
|
-
// because we can't syntactically pass through to dynamic import with a second argument
|
|
828
|
-
if (sourceType === 'css' || sourceType === 'json') {
|
|
829
|
-
// Direct reexport for hot reloading skipped due to Firefox bug https://bugzilla.mozilla.org/show_bug.cgi?id=1965620
|
|
830
|
-
source = `import m from'${url}'with{type:"${sourceType}"};export default m;`;
|
|
831
|
-
url += '?entry';
|
|
832
|
-
}
|
|
833
|
-
|
|
834
|
-
if (importHook) await importHook(url, typeof fetchOpts !== 'string' ? fetchOpts : {}, parentUrl, source, sourceType);
|
|
835
|
-
// early analysis opt-out - no need to even fetch if we have feature support
|
|
836
|
-
if (!shimMode &&
|
|
837
|
-
console.info(`es-module-shims: early exit for ${url} due to baseline modules support`);
|
|
838
|
-
// for polyfill case, only dynamic import needs a return value here, and dynamic import will never pass nativelyLoaded
|
|
839
|
-
if (nativelyLoaded) return null;
|
|
840
|
-
await lastStaticLoadPromise;
|
|
841
|
-
return dynamicImport(source ? createBlob(source) : url);
|
|
842
|
-
}
|
|
843
|
-
const load = getOrCreateLoad(url, fetchOpts, undefined, source);
|
|
844
|
-
linkLoad(load, fetchOpts);
|
|
845
|
-
const seen = {};
|
|
846
|
-
await loadAll(load, seen);
|
|
847
|
-
resolveDeps(load, seen);
|
|
848
|
-
await lastStaticLoadPromise;
|
|
849
|
-
if (!shimMode && !load.n) {
|
|
850
|
-
if (nativelyLoaded) {
|
|
851
|
-
console.info(
|
|
852
|
-
`es-module-shims: early exit after graph analysis of ${url} - graph ran natively without needing polyfill`
|
|
853
|
-
);
|
|
854
|
-
return;
|
|
855
|
-
}
|
|
856
|
-
if (source) {
|
|
857
|
-
return await dynamicImport(createBlob(source));
|
|
858
|
-
}
|
|
859
|
-
}
|
|
860
|
-
if (firstPolyfillLoad && !shimMode && load.n && nativelyLoaded) {
|
|
861
|
-
onpolyfill();
|
|
862
|
-
firstPolyfillLoad = false;
|
|
863
|
-
}
|
|
864
|
-
const module = await (shimMode || load.n || load.N || !nativePassthrough || (!nativelyLoaded && source) ?
|
|
865
|
-
dynamicImport(load.b, load.u)
|
|
866
|
-
: import(load.u));
|
|
867
|
-
// if the top-level load is a shell, run its update function
|
|
868
|
-
if (load.s) (await dynamicImport(load.s, load.u)).u$_(module);
|
|
869
|
-
|
|
870
|
-
return module;
|
|
871
|
-
};
|
|
872
|
-
|
|
873
|
-
const revokeObjectURLs = registryKeys => {
|
|
874
|
-
let curIdx = 0;
|
|
875
|
-
const handler = self.requestIdleCallback || self.requestAnimationFrame;
|
|
876
|
-
handler(cleanup);
|
|
877
|
-
function cleanup() {
|
|
878
|
-
for (const key of registryKeys.slice(curIdx, (curIdx += 100))) {
|
|
879
|
-
const load = registry[key];
|
|
880
|
-
if (load && load.b && load.b !== load.u) URL.revokeObjectURL(load.b);
|
|
881
|
-
}
|
|
882
|
-
if (curIdx < registryKeys.length) handler(cleanup);
|
|
883
|
-
}
|
|
884
|
-
};
|
|
885
|
-
|
|
886
|
-
const urlJsString = url => `'${url.replace(/'/g, "\\'")}'`;
|
|
887
|
-
|
|
888
|
-
let resolvedSource, lastIndex;
|
|
889
|
-
const pushStringTo = (load, originalIndex, dynamicImportEndStack) => {
|
|
890
|
-
while (dynamicImportEndStack[dynamicImportEndStack.length - 1] < originalIndex) {
|
|
891
|
-
const dynamicImportEnd = dynamicImportEndStack.pop();
|
|
892
|
-
resolvedSource += `${load.S.slice(lastIndex, dynamicImportEnd)}, ${urlJsString(load.r)}`;
|
|
893
|
-
lastIndex = dynamicImportEnd;
|
|
894
|
-
}
|
|
895
|
-
resolvedSource += load.S.slice(lastIndex, originalIndex);
|
|
896
|
-
lastIndex = originalIndex;
|
|
897
|
-
};
|
|
898
|
-
|
|
899
|
-
const pushSourceURL = (load, commentPrefix, commentStart, dynamicImportEndStack) => {
|
|
900
|
-
const urlStart = commentStart + commentPrefix.length;
|
|
901
|
-
const commentEnd = load.S.indexOf('\n', urlStart);
|
|
902
|
-
const urlEnd = commentEnd !== -1 ? commentEnd : load.S.length;
|
|
903
|
-
let sourceUrl = load.S.slice(urlStart, urlEnd);
|
|
904
|
-
try {
|
|
905
|
-
sourceUrl = new URL(sourceUrl, load.r).href;
|
|
906
|
-
} catch {}
|
|
907
|
-
pushStringTo(load, urlStart, dynamicImportEndStack);
|
|
908
|
-
resolvedSource += sourceUrl;
|
|
909
|
-
lastIndex = urlEnd;
|
|
910
|
-
};
|
|
911
|
-
|
|
912
|
-
const resolveDeps = (load, seen) => {
|
|
913
|
-
if (load.b || !seen[load.u]) return;
|
|
914
|
-
seen[load.u] = 0;
|
|
915
|
-
|
|
916
|
-
for (const { l: dep, s: sourcePhase } of load.d) {
|
|
917
|
-
if (!sourcePhase) resolveDeps(dep, seen);
|
|
918
|
-
}
|
|
919
|
-
|
|
920
|
-
if (!load.n) load.n = load.d.some(dep => dep.l.n);
|
|
921
|
-
if (!load.N) load.N = load.d.some(dep => dep.l.N);
|
|
922
|
-
|
|
923
|
-
// use native loader whenever possible (n = needs shim) via executable subgraph passthrough
|
|
924
|
-
// so long as the module doesn't use dynamic import or unsupported URL mappings (N = should shim)
|
|
925
|
-
if (nativePassthrough && !shimMode && !load.n && !load.N) {
|
|
926
|
-
load.b = load.u;
|
|
927
|
-
load.S = undefined;
|
|
928
|
-
return;
|
|
929
|
-
}
|
|
930
|
-
|
|
931
|
-
console.info(`es-module-shims: polyfilling ${load.u}`);
|
|
932
|
-
|
|
933
|
-
const [imports, exports] = load.a;
|
|
934
|
-
|
|
935
|
-
// "execution"
|
|
936
|
-
let source = load.S,
|
|
937
|
-
depIndex = 0,
|
|
938
|
-
dynamicImportEndStack = [];
|
|
939
|
-
|
|
940
|
-
// once all deps have loaded we can inline the dependency resolution blobs
|
|
941
|
-
// and define this blob
|
|
942
|
-
(resolvedSource = ''), (lastIndex = 0);
|
|
943
|
-
|
|
944
|
-
for (const { s: start, e: end, ss: statementStart, se: statementEnd, d: dynamicImportIndex, t, a } of imports) {
|
|
945
|
-
// source phase
|
|
946
|
-
if (t === 4) {
|
|
947
|
-
let { l: depLoad } = load.d[depIndex++];
|
|
948
|
-
pushStringTo(load, statementStart, dynamicImportEndStack);
|
|
949
|
-
resolvedSource += `${source.slice(statementStart, start - 1).replace('source', '')}/*${source.slice(start - 1, end + 1)}*/'${createBlob(`export default importShim._s[${urlJsString(depLoad.r)}]`)}'`;
|
|
950
|
-
lastIndex = end + 1;
|
|
951
|
-
}
|
|
952
|
-
// dependency source replacements
|
|
953
|
-
else if (dynamicImportIndex === -1) {
|
|
954
|
-
let keepAssertion = false;
|
|
955
|
-
if (a > 0 && !shimMode) {
|
|
956
|
-
const assertion = source.slice(a, statementEnd - 1);
|
|
957
|
-
// strip assertions only when unsupported in polyfill mode
|
|
958
|
-
keepAssertion =
|
|
959
|
-
nativePassthrough &&
|
|
960
|
-
((supportsJsonType && assertion.includes('json')) || (supportsCssType && assertion.includes('css')));
|
|
961
|
-
}
|
|
962
|
-
|
|
963
|
-
// defer phase stripping
|
|
964
|
-
if (t === 6) {
|
|
965
|
-
pushStringTo(load, statementStart, dynamicImportEndStack);
|
|
966
|
-
resolvedSource += source.slice(statementStart, start - 1).replace('defer', '');
|
|
967
|
-
lastIndex = start;
|
|
968
|
-
}
|
|
969
|
-
let { l: depLoad } = load.d[depIndex++],
|
|
970
|
-
blobUrl = depLoad.b,
|
|
971
|
-
cycleShell = !blobUrl;
|
|
972
|
-
if (cycleShell) {
|
|
973
|
-
// circular shell creation
|
|
974
|
-
if (!(blobUrl = depLoad.s)) {
|
|
975
|
-
blobUrl = depLoad.s = createBlob(
|
|
976
|
-
`export function u$_(m){${depLoad.a[1]
|
|
977
|
-
.map(({ s, e }, i) => {
|
|
978
|
-
const q = depLoad.S[s] === '"' || depLoad.S[s] === "'";
|
|
979
|
-
return `e$_${i}=m${q ? `[` : '.'}${depLoad.S.slice(s, e)}${q ? `]` : ''}`;
|
|
980
|
-
})
|
|
981
|
-
.join(',')}}${
|
|
982
|
-
depLoad.a[1].length ? `let ${depLoad.a[1].map((_, i) => `e$_${i}`).join(',')};` : ''
|
|
983
|
-
}export {${depLoad.a[1]
|
|
984
|
-
.map(({ s, e }, i) => `e$_${i} as ${depLoad.S.slice(s, e)}`)
|
|
985
|
-
.join(',')}}\n//# sourceURL=${depLoad.r}?cycle`
|
|
986
|
-
);
|
|
987
|
-
}
|
|
988
|
-
}
|
|
989
|
-
|
|
990
|
-
pushStringTo(load, start - 1, dynamicImportEndStack);
|
|
991
|
-
resolvedSource += `/*${source.slice(start - 1, end + 1)}*/'${blobUrl}'`;
|
|
992
|
-
|
|
993
|
-
// circular shell execution
|
|
994
|
-
if (!cycleShell && depLoad.s) {
|
|
995
|
-
resolvedSource += `;import*as m$_${depIndex} from'${depLoad.b}';import{u$_ as u$_${depIndex}}from'${depLoad.s}';u$_${depIndex}(m$_${depIndex})`;
|
|
996
|
-
depLoad.s = undefined;
|
|
997
|
-
}
|
|
998
|
-
lastIndex = keepAssertion ? end + 1 : statementEnd;
|
|
999
|
-
}
|
|
1000
|
-
// import.meta
|
|
1001
|
-
else if (dynamicImportIndex === -2) {
|
|
1002
|
-
load.m = { url: load.r, resolve: metaResolve };
|
|
1003
|
-
if (metaHook) metaHook(load.m, load.u);
|
|
1004
|
-
pushStringTo(load, start, dynamicImportEndStack);
|
|
1005
|
-
resolvedSource += `importShim._r[${urlJsString(load.u)}].m`;
|
|
1006
|
-
lastIndex = statementEnd;
|
|
1007
|
-
}
|
|
1008
|
-
// dynamic import
|
|
1009
|
-
else {
|
|
1010
|
-
pushStringTo(load, statementStart + 6, dynamicImportEndStack);
|
|
1011
|
-
resolvedSource += `Shim${t === 5 ? '.source' : ''}(`;
|
|
1012
|
-
dynamicImportEndStack.push(statementEnd - 1);
|
|
1013
|
-
lastIndex = start;
|
|
1014
|
-
}
|
|
1015
|
-
}
|
|
1016
|
-
|
|
1017
|
-
// support progressive cycle binding updates (try statement avoids tdz errors)
|
|
1018
|
-
if (load.s && (imports.length === 0 || imports[imports.length - 1].d === -1))
|
|
1019
|
-
resolvedSource += `\n;import{u$_}from'${load.s}';try{u$_({${exports
|
|
1020
|
-
.filter(e => e.ln)
|
|
1021
|
-
.map(({ s, e, ln }) => `${source.slice(s, e)}:${ln}`)
|
|
1022
|
-
.join(',')}})}catch(_){};\n`;
|
|
1023
|
-
|
|
1024
|
-
let sourceURLCommentStart = source.lastIndexOf(sourceURLCommentPrefix);
|
|
1025
|
-
let sourceMapURLCommentStart = source.lastIndexOf(sourceMapURLCommentPrefix);
|
|
1026
|
-
|
|
1027
|
-
// ignore sourceMap comments before already spliced code
|
|
1028
|
-
if (sourceURLCommentStart < lastIndex) sourceURLCommentStart = -1;
|
|
1029
|
-
if (sourceMapURLCommentStart < lastIndex) sourceMapURLCommentStart = -1;
|
|
1030
|
-
|
|
1031
|
-
// sourceURL first / only
|
|
1032
|
-
if (
|
|
1033
|
-
sourceURLCommentStart !== -1 &&
|
|
1034
|
-
(sourceMapURLCommentStart === -1 || sourceMapURLCommentStart > sourceURLCommentStart)
|
|
1035
|
-
) {
|
|
1036
|
-
pushSourceURL(load, sourceURLCommentPrefix, sourceURLCommentStart, dynamicImportEndStack);
|
|
1037
|
-
}
|
|
1038
|
-
// sourceMappingURL
|
|
1039
|
-
if (sourceMapURLCommentStart !== -1) {
|
|
1040
|
-
pushSourceURL(load, sourceMapURLCommentPrefix, sourceMapURLCommentStart, dynamicImportEndStack);
|
|
1041
|
-
// sourceURL last
|
|
1042
|
-
if (sourceURLCommentStart !== -1 && sourceURLCommentStart > sourceMapURLCommentStart)
|
|
1043
|
-
pushSourceURL(load, sourceURLCommentPrefix, sourceURLCommentStart, dynamicImportEndStack);
|
|
1044
|
-
}
|
|
1045
|
-
|
|
1046
|
-
pushStringTo(load, source.length, dynamicImportEndStack);
|
|
1047
|
-
|
|
1048
|
-
if (sourceURLCommentStart === -1) resolvedSource += sourceURLCommentPrefix + load.r;
|
|
1049
|
-
|
|
1050
|
-
load.b = createBlob(resolvedSource);
|
|
1051
|
-
load.S = resolvedSource = undefined;
|
|
1052
|
-
};
|
|
1053
|
-
|
|
1054
|
-
const sourceURLCommentPrefix = '\n//# sourceURL=';
|
|
1055
|
-
const sourceMapURLCommentPrefix = '\n//# sourceMappingURL=';
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
const
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
if (!
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
obj
|
|
1133
|
-
}
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
//
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
}
|
|
1221
|
-
|
|
1222
|
-
load.a =
|
|
1223
|
-
}
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
);
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
if (assertion.includes('
|
|
1255
|
-
if (
|
|
1256
|
-
else load.n = true;
|
|
1257
|
-
}
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
if (d
|
|
1263
|
-
|
|
1264
|
-
if (resolved.
|
|
1265
|
-
if (
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
if (
|
|
1269
|
-
|
|
1270
|
-
//
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
for (const
|
|
1282
|
-
if (
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
if (!script.ep)
|
|
1287
|
-
}
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
if (script.
|
|
1297
|
-
if (script.
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
let
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
script.ep
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
if (
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
)
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
const
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
if (
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
script.
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
.
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
script.src
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
if (
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
if (fetchCache[link.href]) return;
|
|
1464
|
-
fetchCache[link.href] = fetchModule(link.href, getFetchOpts(link));
|
|
1465
|
-
});
|
|
599
|
+
const _resolve = (id, parentUrl = baseUrl) => {
|
|
600
|
+
const urlResolved = resolveIfNotPlainOrUrl(id, parentUrl) || asURL(id);
|
|
601
|
+
const firstResolved = firstImportMap && resolveImportMap(firstImportMap, urlResolved || id, parentUrl);
|
|
602
|
+
const composedResolved =
|
|
603
|
+
composedImportMap === firstImportMap ? firstResolved : (
|
|
604
|
+
resolveImportMap(composedImportMap, urlResolved || id, parentUrl)
|
|
605
|
+
);
|
|
606
|
+
const resolved = composedResolved || firstResolved || throwUnresolved(id, parentUrl);
|
|
607
|
+
// needsShim, shouldShim per load record to set on parent
|
|
608
|
+
let n = false,
|
|
609
|
+
N = false;
|
|
610
|
+
if (!supportsImportMaps) {
|
|
611
|
+
// bare specifier -> needs shim
|
|
612
|
+
if (!urlResolved) n = true;
|
|
613
|
+
// url mapping -> should shim
|
|
614
|
+
else if (urlResolved !== resolved) N = true;
|
|
615
|
+
} else if (!supportsMultipleImportMaps) {
|
|
616
|
+
// bare specifier and not resolved by first import map -> needs shim
|
|
617
|
+
if (!urlResolved && !firstResolved) n = true;
|
|
618
|
+
// resolution doesn't match first import map -> should shim
|
|
619
|
+
if (firstResolved && resolved !== firstResolved) N = true;
|
|
620
|
+
}
|
|
621
|
+
return { r: resolved, n, N };
|
|
622
|
+
};
|
|
623
|
+
|
|
624
|
+
const resolve = (id, parentUrl) => {
|
|
625
|
+
if (!resolveHook) return _resolve(id, parentUrl);
|
|
626
|
+
const result = resolveHook(id, parentUrl, defaultResolve);
|
|
627
|
+
|
|
628
|
+
return result ? { r: result, n: true, N: true } : _resolve(id, parentUrl);
|
|
629
|
+
};
|
|
630
|
+
|
|
631
|
+
// import()
|
|
632
|
+
async function importShim$1(id, opts, parentUrl) {
|
|
633
|
+
if (typeof opts === 'string') {
|
|
634
|
+
parentUrl = opts;
|
|
635
|
+
opts = undefined;
|
|
636
|
+
}
|
|
637
|
+
await initPromise; // needed for shim check
|
|
638
|
+
console.info(`es-module-shims: importShim("${id}"${opts ? ', ' + JSON.stringify(opts) : ''})`);
|
|
639
|
+
if (shimMode || !baselineSupport) {
|
|
640
|
+
if (hasDocument) processScriptsAndPreloads();
|
|
641
|
+
legacyAcceptingImportMaps = false;
|
|
642
|
+
}
|
|
643
|
+
let sourceType = undefined;
|
|
644
|
+
if (typeof opts === 'object') {
|
|
645
|
+
if (opts.lang === 'ts') sourceType = 'ts';
|
|
646
|
+
if (typeof opts.with === 'object' && typeof opts.with.type === 'string') {
|
|
647
|
+
sourceType = opts.with.type;
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
return topLevelLoad(id, parentUrl || baseUrl, defaultFetchOpts, undefined, undefined, undefined, sourceType);
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
// import.source()
|
|
654
|
+
// (opts not currently supported as no use cases yet)
|
|
655
|
+
if (shimMode || wasmSourcePhaseEnabled)
|
|
656
|
+
importShim$1.source = async (id, opts, parentUrl) => {
|
|
657
|
+
if (typeof opts === 'string') {
|
|
658
|
+
parentUrl = opts;
|
|
659
|
+
opts = undefined;
|
|
660
|
+
}
|
|
661
|
+
await initPromise; // needed for shim check
|
|
662
|
+
console.info(`es-module-shims: importShim.source("${id}"${opts ? ', ' + JSON.stringify(opts) : ''})`);
|
|
663
|
+
if (shimMode || !baselineSupport) {
|
|
664
|
+
if (hasDocument) processScriptsAndPreloads();
|
|
665
|
+
legacyAcceptingImportMaps = false;
|
|
666
|
+
}
|
|
667
|
+
await importMapPromise;
|
|
668
|
+
const url = resolve(id, parentUrl || baseUrl).r;
|
|
669
|
+
const load = getOrCreateLoad(url, defaultFetchOpts, undefined, undefined);
|
|
670
|
+
if (firstPolyfillLoad && !shimMode && load.n && nativelyLoaded) {
|
|
671
|
+
onpolyfill();
|
|
672
|
+
firstPolyfillLoad = false;
|
|
673
|
+
}
|
|
674
|
+
await load.f;
|
|
675
|
+
return importShim$1._s[load.r];
|
|
676
|
+
};
|
|
677
|
+
|
|
678
|
+
// import.defer() is just a proxy for import(), since we can't actually defer
|
|
679
|
+
if (shimMode || deferPhaseEnabled) importShim$1.defer = importShim$1;
|
|
680
|
+
|
|
681
|
+
if (hotReload) importShim$1.hotReload = hotReload$1;
|
|
682
|
+
|
|
683
|
+
const defaultResolve = (id, parentUrl) => {
|
|
684
|
+
return (
|
|
685
|
+
resolveImportMap(composedImportMap, resolveIfNotPlainOrUrl(id, parentUrl) || id, parentUrl) ||
|
|
686
|
+
throwUnresolved(id, parentUrl)
|
|
687
|
+
);
|
|
688
|
+
};
|
|
689
|
+
|
|
690
|
+
const throwUnresolved = (id, parentUrl) => {
|
|
691
|
+
throw Error(`Unable to resolve specifier '${id}'${fromParent(parentUrl)}`);
|
|
692
|
+
};
|
|
693
|
+
|
|
694
|
+
const metaResolve = function (id, parentUrl = this.url) {
|
|
695
|
+
return resolve(id, `${parentUrl}`).r;
|
|
696
|
+
};
|
|
697
|
+
|
|
698
|
+
importShim$1.resolve = (id, parentUrl) => resolve(id, parentUrl).r;
|
|
699
|
+
importShim$1.getImportMap = () => JSON.parse(JSON.stringify(composedImportMap));
|
|
700
|
+
importShim$1.addImportMap = importMapIn => {
|
|
701
|
+
if (!shimMode) throw new Error('Unsupported in polyfill mode.');
|
|
702
|
+
composedImportMap = resolveAndComposeImportMap(importMapIn, baseUrl, composedImportMap);
|
|
703
|
+
};
|
|
704
|
+
importShim$1.version = version;
|
|
705
|
+
|
|
706
|
+
const registry = (importShim$1._r = {});
|
|
707
|
+
// Wasm caches
|
|
708
|
+
const sourceCache = (importShim$1._s = {});
|
|
709
|
+
(importShim$1._i = new WeakMap());
|
|
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
|
+
|
|
717
|
+
const loadAll = async (load, seen) => {
|
|
718
|
+
seen[load.u] = 1;
|
|
719
|
+
await load.L;
|
|
720
|
+
await Promise.all(
|
|
721
|
+
load.d.map(({ l: dep, s: sourcePhase }) => {
|
|
722
|
+
if (dep.b || seen[dep.u]) return;
|
|
723
|
+
if (sourcePhase) return dep.f;
|
|
724
|
+
return loadAll(dep, seen);
|
|
725
|
+
})
|
|
726
|
+
);
|
|
727
|
+
};
|
|
728
|
+
|
|
729
|
+
let importMapSrc = false;
|
|
730
|
+
let multipleImportMaps = false;
|
|
731
|
+
let firstImportMap = null;
|
|
732
|
+
// To support polyfilling multiple import maps, we separately track the composed import map from the first import map
|
|
733
|
+
let composedImportMap = { imports: {}, scopes: {}, integrity: {} };
|
|
734
|
+
let baselineSupport;
|
|
735
|
+
|
|
736
|
+
const initPromise = featureDetectionPromise.then(() => {
|
|
737
|
+
baselineSupport =
|
|
738
|
+
supportsImportMaps &&
|
|
739
|
+
(!jsonModulesEnabled || supportsJsonType) &&
|
|
740
|
+
(!cssModulesEnabled || supportsCssType) &&
|
|
741
|
+
(!wasmInstancePhaseEnabled || supportsWasmInstancePhase) &&
|
|
742
|
+
(!wasmSourcePhaseEnabled || supportsWasmSourcePhase) &&
|
|
743
|
+
!deferPhaseEnabled &&
|
|
744
|
+
(!multipleImportMaps || supportsMultipleImportMaps) &&
|
|
745
|
+
!importMapSrc &&
|
|
746
|
+
!hasCustomizationHooks;
|
|
747
|
+
if (!shimMode && typeof WebAssembly !== 'undefined') {
|
|
748
|
+
if (wasmSourcePhaseEnabled && !Object.getPrototypeOf(WebAssembly.Module).name) {
|
|
749
|
+
const s = Symbol();
|
|
750
|
+
const brand = m => defineValue(m, s, 'WebAssembly.Module');
|
|
751
|
+
class AbstractModuleSource {
|
|
752
|
+
get [Symbol.toStringTag]() {
|
|
753
|
+
if (this[s]) return this[s];
|
|
754
|
+
throw new TypeError('Not an AbstractModuleSource');
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
const { Module: wasmModule, compile: wasmCompile, compileStreaming: wasmCompileStreaming } = WebAssembly;
|
|
758
|
+
WebAssembly.Module = Object.setPrototypeOf(
|
|
759
|
+
Object.assign(function Module(...args) {
|
|
760
|
+
return brand(new wasmModule(...args));
|
|
761
|
+
}, wasmModule),
|
|
762
|
+
AbstractModuleSource
|
|
763
|
+
);
|
|
764
|
+
WebAssembly.Module.prototype = Object.setPrototypeOf(wasmModule.prototype, AbstractModuleSource.prototype);
|
|
765
|
+
WebAssembly.compile = function compile(...args) {
|
|
766
|
+
return wasmCompile(...args).then(brand);
|
|
767
|
+
};
|
|
768
|
+
WebAssembly.compileStreaming = function compileStreaming(...args) {
|
|
769
|
+
return wasmCompileStreaming(...args).then(brand);
|
|
770
|
+
};
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
if (hasDocument) {
|
|
774
|
+
if (!supportsImportMaps) {
|
|
775
|
+
const supports = HTMLScriptElement.supports || (type => type === 'classic' || type === 'module');
|
|
776
|
+
HTMLScriptElement.supports = type => type === 'importmap' || supports(type);
|
|
777
|
+
}
|
|
778
|
+
if (shimMode || !baselineSupport) {
|
|
779
|
+
attachMutationObserver();
|
|
780
|
+
if (document.readyState === 'complete') {
|
|
781
|
+
readyStateCompleteCheck();
|
|
782
|
+
} else {
|
|
783
|
+
document.addEventListener('readystatechange', readyListener);
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
processScriptsAndPreloads();
|
|
787
|
+
}
|
|
788
|
+
return undefined;
|
|
789
|
+
});
|
|
790
|
+
|
|
791
|
+
const attachMutationObserver = () => {
|
|
792
|
+
const observer = new MutationObserver(mutations => {
|
|
793
|
+
for (const mutation of mutations) {
|
|
794
|
+
if (mutation.type !== 'childList') continue;
|
|
795
|
+
for (const node of mutation.addedNodes) {
|
|
796
|
+
if (node.tagName === 'SCRIPT') {
|
|
797
|
+
if (node.type === (shimMode ? 'module-shim' : 'module') && !node.ep) processScript(node, true);
|
|
798
|
+
if (node.type === (shimMode ? 'importmap-shim' : 'importmap') && !node.ep) processImportMap(node, true);
|
|
799
|
+
} else if (
|
|
800
|
+
node.tagName === 'LINK' &&
|
|
801
|
+
node.rel === (shimMode ? 'modulepreload-shim' : 'modulepreload') &&
|
|
802
|
+
!node.ep
|
|
803
|
+
) {
|
|
804
|
+
processPreload(node);
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
});
|
|
809
|
+
observer.observe(document, { childList: true });
|
|
810
|
+
observer.observe(document.head, { childList: true });
|
|
811
|
+
processScriptsAndPreloads();
|
|
812
|
+
};
|
|
813
|
+
|
|
814
|
+
let importMapPromise = initPromise;
|
|
815
|
+
let firstPolyfillLoad = true;
|
|
816
|
+
let legacyAcceptingImportMaps = true;
|
|
817
|
+
|
|
818
|
+
const topLevelLoad = async (
|
|
819
|
+
url,
|
|
820
|
+
parentUrl,
|
|
821
|
+
fetchOpts,
|
|
822
|
+
source,
|
|
823
|
+
nativelyLoaded,
|
|
824
|
+
lastStaticLoadPromise,
|
|
825
|
+
sourceType
|
|
826
|
+
) => {
|
|
827
|
+
await initPromise;
|
|
828
|
+
await importMapPromise;
|
|
829
|
+
url = (await resolve(url, parentUrl)).r;
|
|
830
|
+
|
|
831
|
+
// we mock import('./x.css', { with: { type: 'css' }}) support via an inline static reexport
|
|
832
|
+
// because we can't syntactically pass through to dynamic import with a second argument
|
|
833
|
+
if (sourceType === 'css' || sourceType === 'json') {
|
|
834
|
+
// Direct reexport for hot reloading skipped due to Firefox bug https://bugzilla.mozilla.org/show_bug.cgi?id=1965620
|
|
835
|
+
source = `import m from'${url}'with{type:"${sourceType}"};export default m;`;
|
|
836
|
+
url += '?entry';
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
if (importHook) await importHook(url, typeof fetchOpts !== 'string' ? fetchOpts : {}, parentUrl, source, sourceType);
|
|
840
|
+
// early analysis opt-out - no need to even fetch if we have feature support
|
|
841
|
+
if (!shimMode && baselineSupport && nativePassthrough && sourceType !== 'ts') {
|
|
842
|
+
console.info(`es-module-shims: early exit for ${url} due to baseline modules support`);
|
|
843
|
+
// for polyfill case, only dynamic import needs a return value here, and dynamic import will never pass nativelyLoaded
|
|
844
|
+
if (nativelyLoaded) return null;
|
|
845
|
+
await lastStaticLoadPromise;
|
|
846
|
+
return dynamicImport(source ? createBlob(source) : url);
|
|
847
|
+
}
|
|
848
|
+
const load = getOrCreateLoad(url, fetchOpts, undefined, source);
|
|
849
|
+
linkLoad(load, fetchOpts);
|
|
850
|
+
const seen = {};
|
|
851
|
+
await loadAll(load, seen);
|
|
852
|
+
resolveDeps(load, seen);
|
|
853
|
+
await lastStaticLoadPromise;
|
|
854
|
+
if (!shimMode && !load.n) {
|
|
855
|
+
if (nativelyLoaded) {
|
|
856
|
+
console.info(
|
|
857
|
+
`es-module-shims: early exit after graph analysis of ${url} - graph ran natively without needing polyfill`
|
|
858
|
+
);
|
|
859
|
+
return;
|
|
860
|
+
}
|
|
861
|
+
if (source) {
|
|
862
|
+
return await dynamicImport(createBlob(source));
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
if (firstPolyfillLoad && !shimMode && load.n && nativelyLoaded) {
|
|
866
|
+
onpolyfill();
|
|
867
|
+
firstPolyfillLoad = false;
|
|
868
|
+
}
|
|
869
|
+
const module = await (shimMode || load.n || load.N || !nativePassthrough || (!nativelyLoaded && source) ?
|
|
870
|
+
dynamicImport(load.b, load.u)
|
|
871
|
+
: import(load.u));
|
|
872
|
+
// if the top-level load is a shell, run its update function
|
|
873
|
+
if (load.s) (await dynamicImport(load.s, load.u)).u$_(module);
|
|
874
|
+
revokeObjectURLs(Object.keys(seen));
|
|
875
|
+
return module;
|
|
876
|
+
};
|
|
877
|
+
|
|
878
|
+
const revokeObjectURLs = registryKeys => {
|
|
879
|
+
let curIdx = 0;
|
|
880
|
+
const handler = self.requestIdleCallback || self.requestAnimationFrame;
|
|
881
|
+
handler(cleanup);
|
|
882
|
+
function cleanup() {
|
|
883
|
+
for (const key of registryKeys.slice(curIdx, (curIdx += 100))) {
|
|
884
|
+
const load = registry[key];
|
|
885
|
+
if (load && load.b && load.b !== load.u) URL.revokeObjectURL(load.b);
|
|
886
|
+
}
|
|
887
|
+
if (curIdx < registryKeys.length) handler(cleanup);
|
|
888
|
+
}
|
|
889
|
+
};
|
|
890
|
+
|
|
891
|
+
const urlJsString = url => `'${url.replace(/'/g, "\\'")}'`;
|
|
892
|
+
|
|
893
|
+
let resolvedSource, lastIndex;
|
|
894
|
+
const pushStringTo = (load, originalIndex, dynamicImportEndStack) => {
|
|
895
|
+
while (dynamicImportEndStack[dynamicImportEndStack.length - 1] < originalIndex) {
|
|
896
|
+
const dynamicImportEnd = dynamicImportEndStack.pop();
|
|
897
|
+
resolvedSource += `${load.S.slice(lastIndex, dynamicImportEnd)}, ${urlJsString(load.r)}`;
|
|
898
|
+
lastIndex = dynamicImportEnd;
|
|
899
|
+
}
|
|
900
|
+
resolvedSource += load.S.slice(lastIndex, originalIndex);
|
|
901
|
+
lastIndex = originalIndex;
|
|
902
|
+
};
|
|
903
|
+
|
|
904
|
+
const pushSourceURL = (load, commentPrefix, commentStart, dynamicImportEndStack) => {
|
|
905
|
+
const urlStart = commentStart + commentPrefix.length;
|
|
906
|
+
const commentEnd = load.S.indexOf('\n', urlStart);
|
|
907
|
+
const urlEnd = commentEnd !== -1 ? commentEnd : load.S.length;
|
|
908
|
+
let sourceUrl = load.S.slice(urlStart, urlEnd);
|
|
909
|
+
try {
|
|
910
|
+
sourceUrl = new URL(sourceUrl, load.r).href;
|
|
911
|
+
} catch {}
|
|
912
|
+
pushStringTo(load, urlStart, dynamicImportEndStack);
|
|
913
|
+
resolvedSource += sourceUrl;
|
|
914
|
+
lastIndex = urlEnd;
|
|
915
|
+
};
|
|
916
|
+
|
|
917
|
+
const resolveDeps = (load, seen) => {
|
|
918
|
+
if (load.b || !seen[load.u]) return;
|
|
919
|
+
seen[load.u] = 0;
|
|
920
|
+
|
|
921
|
+
for (const { l: dep, s: sourcePhase } of load.d) {
|
|
922
|
+
if (!sourcePhase) resolveDeps(dep, seen);
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
if (!load.n) load.n = load.d.some(dep => dep.l.n);
|
|
926
|
+
if (!load.N) load.N = load.d.some(dep => dep.l.N);
|
|
927
|
+
|
|
928
|
+
// use native loader whenever possible (n = needs shim) via executable subgraph passthrough
|
|
929
|
+
// so long as the module doesn't use dynamic import or unsupported URL mappings (N = should shim)
|
|
930
|
+
if (nativePassthrough && !shimMode && !load.n && !load.N) {
|
|
931
|
+
load.b = load.u;
|
|
932
|
+
load.S = undefined;
|
|
933
|
+
return;
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
console.info(`es-module-shims: polyfilling ${load.u}`);
|
|
937
|
+
|
|
938
|
+
const [imports, exports] = load.a;
|
|
939
|
+
|
|
940
|
+
// "execution"
|
|
941
|
+
let source = load.S,
|
|
942
|
+
depIndex = 0,
|
|
943
|
+
dynamicImportEndStack = [];
|
|
944
|
+
|
|
945
|
+
// once all deps have loaded we can inline the dependency resolution blobs
|
|
946
|
+
// and define this blob
|
|
947
|
+
(resolvedSource = ''), (lastIndex = 0);
|
|
948
|
+
|
|
949
|
+
for (const { s: start, e: end, ss: statementStart, se: statementEnd, d: dynamicImportIndex, t, a } of imports) {
|
|
950
|
+
// source phase
|
|
951
|
+
if (t === 4) {
|
|
952
|
+
let { l: depLoad } = load.d[depIndex++];
|
|
953
|
+
pushStringTo(load, statementStart, dynamicImportEndStack);
|
|
954
|
+
resolvedSource += `${source.slice(statementStart, start - 1).replace('source', '')}/*${source.slice(start - 1, end + 1)}*/'${createBlob(`export default importShim._s[${urlJsString(depLoad.r)}]`)}'`;
|
|
955
|
+
lastIndex = end + 1;
|
|
956
|
+
}
|
|
957
|
+
// dependency source replacements
|
|
958
|
+
else if (dynamicImportIndex === -1) {
|
|
959
|
+
let keepAssertion = false;
|
|
960
|
+
if (a > 0 && !shimMode) {
|
|
961
|
+
const assertion = source.slice(a, statementEnd - 1);
|
|
962
|
+
// strip assertions only when unsupported in polyfill mode
|
|
963
|
+
keepAssertion =
|
|
964
|
+
nativePassthrough &&
|
|
965
|
+
((supportsJsonType && assertion.includes('json')) || (supportsCssType && assertion.includes('css')));
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
// defer phase stripping
|
|
969
|
+
if (t === 6) {
|
|
970
|
+
pushStringTo(load, statementStart, dynamicImportEndStack);
|
|
971
|
+
resolvedSource += source.slice(statementStart, start - 1).replace('defer', '');
|
|
972
|
+
lastIndex = start;
|
|
973
|
+
}
|
|
974
|
+
let { l: depLoad } = load.d[depIndex++],
|
|
975
|
+
blobUrl = depLoad.b,
|
|
976
|
+
cycleShell = !blobUrl;
|
|
977
|
+
if (cycleShell) {
|
|
978
|
+
// circular shell creation
|
|
979
|
+
if (!(blobUrl = depLoad.s)) {
|
|
980
|
+
blobUrl = depLoad.s = createBlob(
|
|
981
|
+
`export function u$_(m){${depLoad.a[1]
|
|
982
|
+
.map(({ s, e }, i) => {
|
|
983
|
+
const q = depLoad.S[s] === '"' || depLoad.S[s] === "'";
|
|
984
|
+
return `e$_${i}=m${q ? `[` : '.'}${depLoad.S.slice(s, e)}${q ? `]` : ''}`;
|
|
985
|
+
})
|
|
986
|
+
.join(',')}}${
|
|
987
|
+
depLoad.a[1].length ? `let ${depLoad.a[1].map((_, i) => `e$_${i}`).join(',')};` : ''
|
|
988
|
+
}export {${depLoad.a[1]
|
|
989
|
+
.map(({ s, e }, i) => `e$_${i} as ${depLoad.S.slice(s, e)}`)
|
|
990
|
+
.join(',')}}\n//# sourceURL=${depLoad.r}?cycle`
|
|
991
|
+
);
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
|
|
995
|
+
pushStringTo(load, start - 1, dynamicImportEndStack);
|
|
996
|
+
resolvedSource += `/*${source.slice(start - 1, end + 1)}*/'${blobUrl}'`;
|
|
997
|
+
|
|
998
|
+
// circular shell execution
|
|
999
|
+
if (!cycleShell && depLoad.s) {
|
|
1000
|
+
resolvedSource += `;import*as m$_${depIndex} from'${depLoad.b}';import{u$_ as u$_${depIndex}}from'${depLoad.s}';u$_${depIndex}(m$_${depIndex})`;
|
|
1001
|
+
depLoad.s = undefined;
|
|
1002
|
+
}
|
|
1003
|
+
lastIndex = keepAssertion ? end + 1 : statementEnd;
|
|
1004
|
+
}
|
|
1005
|
+
// import.meta
|
|
1006
|
+
else if (dynamicImportIndex === -2) {
|
|
1007
|
+
load.m = { url: load.r, resolve: metaResolve };
|
|
1008
|
+
if (metaHook) metaHook(load.m, load.u);
|
|
1009
|
+
pushStringTo(load, start, dynamicImportEndStack);
|
|
1010
|
+
resolvedSource += `importShim._r[${urlJsString(load.u)}].m`;
|
|
1011
|
+
lastIndex = statementEnd;
|
|
1012
|
+
}
|
|
1013
|
+
// dynamic import
|
|
1014
|
+
else {
|
|
1015
|
+
pushStringTo(load, statementStart + 6, dynamicImportEndStack);
|
|
1016
|
+
resolvedSource += `Shim${t === 5 ? '.source' : ''}(`;
|
|
1017
|
+
dynamicImportEndStack.push(statementEnd - 1);
|
|
1018
|
+
lastIndex = start;
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
// support progressive cycle binding updates (try statement avoids tdz errors)
|
|
1023
|
+
if (load.s && (imports.length === 0 || imports[imports.length - 1].d === -1))
|
|
1024
|
+
resolvedSource += `\n;import{u$_}from'${load.s}';try{u$_({${exports
|
|
1025
|
+
.filter(e => e.ln)
|
|
1026
|
+
.map(({ s, e, ln }) => `${source.slice(s, e)}:${ln}`)
|
|
1027
|
+
.join(',')}})}catch(_){};\n`;
|
|
1028
|
+
|
|
1029
|
+
let sourceURLCommentStart = source.lastIndexOf(sourceURLCommentPrefix);
|
|
1030
|
+
let sourceMapURLCommentStart = source.lastIndexOf(sourceMapURLCommentPrefix);
|
|
1031
|
+
|
|
1032
|
+
// ignore sourceMap comments before already spliced code
|
|
1033
|
+
if (sourceURLCommentStart < lastIndex) sourceURLCommentStart = -1;
|
|
1034
|
+
if (sourceMapURLCommentStart < lastIndex) sourceMapURLCommentStart = -1;
|
|
1035
|
+
|
|
1036
|
+
// sourceURL first / only
|
|
1037
|
+
if (
|
|
1038
|
+
sourceURLCommentStart !== -1 &&
|
|
1039
|
+
(sourceMapURLCommentStart === -1 || sourceMapURLCommentStart > sourceURLCommentStart)
|
|
1040
|
+
) {
|
|
1041
|
+
pushSourceURL(load, sourceURLCommentPrefix, sourceURLCommentStart, dynamicImportEndStack);
|
|
1042
|
+
}
|
|
1043
|
+
// sourceMappingURL
|
|
1044
|
+
if (sourceMapURLCommentStart !== -1) {
|
|
1045
|
+
pushSourceURL(load, sourceMapURLCommentPrefix, sourceMapURLCommentStart, dynamicImportEndStack);
|
|
1046
|
+
// sourceURL last
|
|
1047
|
+
if (sourceURLCommentStart !== -1 && sourceURLCommentStart > sourceMapURLCommentStart)
|
|
1048
|
+
pushSourceURL(load, sourceURLCommentPrefix, sourceURLCommentStart, dynamicImportEndStack);
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
pushStringTo(load, source.length, dynamicImportEndStack);
|
|
1052
|
+
|
|
1053
|
+
if (sourceURLCommentStart === -1) resolvedSource += sourceURLCommentPrefix + load.r;
|
|
1054
|
+
|
|
1055
|
+
load.b = createBlob(resolvedSource);
|
|
1056
|
+
load.S = resolvedSource = undefined;
|
|
1057
|
+
};
|
|
1058
|
+
|
|
1059
|
+
const sourceURLCommentPrefix = '\n//# sourceURL=';
|
|
1060
|
+
const sourceMapURLCommentPrefix = '\n//# sourceMappingURL=';
|
|
1061
|
+
const cssUrlRegEx = /url\(\s*(?:(["'])((?:\\.|[^\n\\"'])+)\1|((?:\\.|[^\s,"'()\\])+))\s*\)/g;
|
|
1062
|
+
|
|
1063
|
+
// restrict in-flight fetches to a pool of 100
|
|
1064
|
+
let p = [];
|
|
1065
|
+
let c = 0;
|
|
1066
|
+
const pushFetchPool = () => {
|
|
1067
|
+
if (++c > 100) return new Promise(r => p.push(r));
|
|
1068
|
+
};
|
|
1069
|
+
const popFetchPool = () => {
|
|
1070
|
+
c--;
|
|
1071
|
+
if (p.length) p.shift()();
|
|
1072
|
+
};
|
|
1073
|
+
|
|
1074
|
+
const doFetch = async (url, fetchOpts, parent) => {
|
|
1075
|
+
if (enforceIntegrity && !fetchOpts.integrity) throw Error(`No integrity for ${url}${fromParent(parent)}.`);
|
|
1076
|
+
const poolQueue = pushFetchPool();
|
|
1077
|
+
if (poolQueue) await poolQueue;
|
|
1078
|
+
try {
|
|
1079
|
+
var res = await fetchHook(url, fetchOpts);
|
|
1080
|
+
} catch (e) {
|
|
1081
|
+
e.message = `Unable to fetch ${url}${fromParent(parent)} - see network log for details.\n` + e.message;
|
|
1082
|
+
throw e;
|
|
1083
|
+
} finally {
|
|
1084
|
+
popFetchPool();
|
|
1085
|
+
}
|
|
1086
|
+
|
|
1087
|
+
if (!res.ok) {
|
|
1088
|
+
const error = new TypeError(`${res.status} ${res.statusText} ${res.url}${fromParent(parent)}`);
|
|
1089
|
+
error.response = res;
|
|
1090
|
+
throw error;
|
|
1091
|
+
}
|
|
1092
|
+
return res;
|
|
1093
|
+
};
|
|
1094
|
+
|
|
1095
|
+
let esmsTsTransform;
|
|
1096
|
+
const initTs = async () => {
|
|
1097
|
+
const m = await import(tsTransform);
|
|
1098
|
+
if (!esmsTsTransform) esmsTsTransform = m.transform;
|
|
1099
|
+
};
|
|
1100
|
+
|
|
1101
|
+
const contentTypeRegEx = /^(text|application)\/((x-)?javascript|wasm|json|css|typescript)(;|$)/;
|
|
1102
|
+
async function defaultSourceHook(url, fetchOpts, parent) {
|
|
1103
|
+
const res = await doFetch(url, fetchOpts, parent);
|
|
1104
|
+
let [, , t] = (res.headers.get('content-type') || '').match(contentTypeRegEx) || [];
|
|
1105
|
+
if (!t) {
|
|
1106
|
+
if (url.endsWith('.ts') || url.endsWith('.mts')) t = 'ts';
|
|
1107
|
+
else
|
|
1108
|
+
throw Error(
|
|
1109
|
+
`Unsupported Content-Type "${contentType}" loading ${url}${fromParent(parent)}. Modules must be served with a valid MIME type like application/javascript.`
|
|
1110
|
+
);
|
|
1111
|
+
}
|
|
1112
|
+
return {
|
|
1113
|
+
url: res.url,
|
|
1114
|
+
source: t === 'wasm' ? await WebAssembly.compileStreaming(res) : await res.text(),
|
|
1115
|
+
type:
|
|
1116
|
+
t[0] === 'x' || (t[0] === 'j' && t[1] === 'a') ? 'js'
|
|
1117
|
+
: t[0] === 't' ? 'ts'
|
|
1118
|
+
: t
|
|
1119
|
+
};
|
|
1120
|
+
}
|
|
1121
|
+
|
|
1122
|
+
const hotPrefix = 'var h=import.meta.hot,';
|
|
1123
|
+
const fetchModule = async (reqUrl, fetchOpts, parent) => {
|
|
1124
|
+
const mapIntegrity = composedImportMap.integrity[reqUrl];
|
|
1125
|
+
fetchOpts = mapIntegrity && !fetchOpts.integrity ? { ...fetchOpts, integrity: mapIntegrity } : fetchOpts;
|
|
1126
|
+
let {
|
|
1127
|
+
url = reqUrl,
|
|
1128
|
+
source,
|
|
1129
|
+
type
|
|
1130
|
+
} = (await (sourceHook || defaultSourceHook)(reqUrl, fetchOpts, parent, defaultSourceHook)) || {};
|
|
1131
|
+
if (type === 'wasm') {
|
|
1132
|
+
const exports = WebAssembly.Module.exports((sourceCache[url] = source));
|
|
1133
|
+
const imports = WebAssembly.Module.imports(source);
|
|
1134
|
+
const rStr = urlJsString(url);
|
|
1135
|
+
source = `import*as $_ns from${rStr};`;
|
|
1136
|
+
let i = 0,
|
|
1137
|
+
obj = '';
|
|
1138
|
+
for (const { module, kind } of imports) {
|
|
1139
|
+
const specifier = urlJsString(module);
|
|
1140
|
+
source += `import*as impt${i} from${specifier};\n`;
|
|
1141
|
+
obj += `${specifier}:${kind === 'global' ? `importShim._i.get(impt${i})||impt${i++}` : `impt${i++}`},`;
|
|
1142
|
+
}
|
|
1143
|
+
source += `${hotPrefix}i=await WebAssembly.instantiate(importShim._s[${rStr}],{${obj}});importShim._i.set($_ns,i);`;
|
|
1144
|
+
obj = '';
|
|
1145
|
+
for (const { name, kind } of exports) {
|
|
1146
|
+
source += `export let ${name}=i.exports['${name}'];`;
|
|
1147
|
+
if (kind === 'global') source += `try{${name}=${name}.value}catch{${name}=undefined}`;
|
|
1148
|
+
obj += `${name},`;
|
|
1149
|
+
}
|
|
1150
|
+
source += `if(h)h.accept(m=>({${obj}}=m))`;
|
|
1151
|
+
} else if (type === 'json') {
|
|
1152
|
+
source = `${hotPrefix}j=${source};export{j as default};if(h)h.accept(m=>j=m.default)`;
|
|
1153
|
+
} else if (type === 'css') {
|
|
1154
|
+
source = `${hotPrefix}s=h&&h.data.s||new CSSStyleSheet();s.replaceSync(${JSON.stringify(
|
|
1155
|
+
source.replace(
|
|
1156
|
+
cssUrlRegEx,
|
|
1157
|
+
(_match, quotes = '', relUrl1, relUrl2) => `url(${quotes}${resolveUrl(relUrl1 || relUrl2, url)}${quotes})`
|
|
1158
|
+
)
|
|
1159
|
+
)});if(h){h.data.s=s;h.accept(()=>{})}export default s`;
|
|
1160
|
+
} else if (type === 'ts') {
|
|
1161
|
+
if (!esmsTsTransform) await initTs();
|
|
1162
|
+
console.info(`es-module-shims: Compiling TypeScript file ${url}`);
|
|
1163
|
+
const transformed = esmsTsTransform(source, url);
|
|
1164
|
+
// even if the TypeScript is valid JavaScript, unless it was a top-level inline source, it wasn't served with
|
|
1165
|
+
// a valid JS MIME here, so we must still polyfill it
|
|
1166
|
+
source = transformed === undefined ? source : transformed;
|
|
1167
|
+
}
|
|
1168
|
+
return { url, source, type };
|
|
1169
|
+
};
|
|
1170
|
+
|
|
1171
|
+
const getOrCreateLoad = (url, fetchOpts, parent, source) => {
|
|
1172
|
+
if (source && registry[url]) {
|
|
1173
|
+
let i = 0;
|
|
1174
|
+
while (registry[url + '#' + ++i]);
|
|
1175
|
+
url += '#' + i;
|
|
1176
|
+
}
|
|
1177
|
+
let load = registry[url];
|
|
1178
|
+
if (load) return load;
|
|
1179
|
+
registry[url] = load = {
|
|
1180
|
+
// url
|
|
1181
|
+
u: url,
|
|
1182
|
+
// response url
|
|
1183
|
+
r: source ? url : undefined,
|
|
1184
|
+
// fetchPromise
|
|
1185
|
+
f: undefined,
|
|
1186
|
+
// source
|
|
1187
|
+
S: source,
|
|
1188
|
+
// linkPromise
|
|
1189
|
+
L: undefined,
|
|
1190
|
+
// analysis
|
|
1191
|
+
a: undefined,
|
|
1192
|
+
// deps
|
|
1193
|
+
d: undefined,
|
|
1194
|
+
// blobUrl
|
|
1195
|
+
b: undefined,
|
|
1196
|
+
// shellUrl
|
|
1197
|
+
s: undefined,
|
|
1198
|
+
// needsShim: does it fail execution in the current native loader?
|
|
1199
|
+
n: false,
|
|
1200
|
+
// shouldShim: does it need to be loaded by the polyfill loader?
|
|
1201
|
+
N: false,
|
|
1202
|
+
// type
|
|
1203
|
+
t: null,
|
|
1204
|
+
// meta
|
|
1205
|
+
m: null
|
|
1206
|
+
};
|
|
1207
|
+
load.f = (async () => {
|
|
1208
|
+
if (load.S === undefined) {
|
|
1209
|
+
// preload fetch options override fetch options (race)
|
|
1210
|
+
({ url: load.r, source: load.S, type: load.t } = await (fetchCache[url] || fetchModule(url, fetchOpts, parent)));
|
|
1211
|
+
if (
|
|
1212
|
+
!load.n &&
|
|
1213
|
+
load.t !== 'js' &&
|
|
1214
|
+
!shimMode &&
|
|
1215
|
+
((load.t === 'css' && !supportsCssType) ||
|
|
1216
|
+
(load.t === 'json' && !supportsJsonType) ||
|
|
1217
|
+
(load.t === 'wasm' && !supportsWasmInstancePhase && !supportsWasmSourcePhase) ||
|
|
1218
|
+
load.t === 'ts')
|
|
1219
|
+
) {
|
|
1220
|
+
load.n = true;
|
|
1221
|
+
}
|
|
1222
|
+
}
|
|
1223
|
+
try {
|
|
1224
|
+
load.a = parse(load.S, load.u);
|
|
1225
|
+
} catch (e) {
|
|
1226
|
+
throwError(e);
|
|
1227
|
+
load.a = [[], [], false];
|
|
1228
|
+
}
|
|
1229
|
+
return load;
|
|
1230
|
+
})();
|
|
1231
|
+
return load;
|
|
1232
|
+
};
|
|
1233
|
+
|
|
1234
|
+
const featErr = feat =>
|
|
1235
|
+
Error(
|
|
1236
|
+
`${feat} feature must be enabled via <script type="esms-options">{ "polyfillEnable": ["${feat}"] }<${''}/script>`
|
|
1237
|
+
);
|
|
1238
|
+
|
|
1239
|
+
const linkLoad = (load, fetchOpts) => {
|
|
1240
|
+
if (load.L) return;
|
|
1241
|
+
load.L = load.f.then(async () => {
|
|
1242
|
+
let childFetchOpts = fetchOpts;
|
|
1243
|
+
load.d = load.a[0]
|
|
1244
|
+
.map(({ n, d, t, a, se }) => {
|
|
1245
|
+
const phaseImport = t >= 4;
|
|
1246
|
+
const sourcePhase = phaseImport && t < 6;
|
|
1247
|
+
if (phaseImport) {
|
|
1248
|
+
if (!shimMode && (sourcePhase ? !wasmSourcePhaseEnabled : !deferPhaseEnabled))
|
|
1249
|
+
throw featErr(sourcePhase ? 'wasm-module-sources' : 'import-defer');
|
|
1250
|
+
if (!sourcePhase || !supportsWasmSourcePhase) load.n = true;
|
|
1251
|
+
}
|
|
1252
|
+
let source = undefined;
|
|
1253
|
+
if (a > 0 && !shimMode && nativePassthrough) {
|
|
1254
|
+
const assertion = load.S.slice(a, se - 1);
|
|
1255
|
+
// no need to fetch JSON/CSS if supported, since it's a leaf node, we'll just strip the assertion syntax
|
|
1256
|
+
if (assertion.includes('json')) {
|
|
1257
|
+
if (supportsJsonType) source = '';
|
|
1258
|
+
else load.n = true;
|
|
1259
|
+
} else if (assertion.includes('css')) {
|
|
1260
|
+
if (supportsCssType) source = '';
|
|
1261
|
+
else load.n = true;
|
|
1262
|
+
}
|
|
1263
|
+
}
|
|
1264
|
+
if (d !== -1 || !n) return;
|
|
1265
|
+
const resolved = resolve(n, load.r || load.u);
|
|
1266
|
+
if (resolved.n || hasCustomizationHooks) load.n = true;
|
|
1267
|
+
if (d >= 0 || resolved.N) load.N = true;
|
|
1268
|
+
if (d !== -1) return;
|
|
1269
|
+
if (skip && skip(resolved.r) && !sourcePhase) return { l: { b: resolved.r }, s: false };
|
|
1270
|
+
if (childFetchOpts.integrity) childFetchOpts = { ...childFetchOpts, integrity: undefined };
|
|
1271
|
+
const child = { l: getOrCreateLoad(resolved.r, childFetchOpts, load.r, source), s: sourcePhase };
|
|
1272
|
+
// assertion case -> inline the CSS / JSON URL directly
|
|
1273
|
+
if (source === '') child.l.b = child.l.u;
|
|
1274
|
+
if (!child.s) linkLoad(child.l, fetchOpts);
|
|
1275
|
+
// load, sourcePhase
|
|
1276
|
+
return child;
|
|
1277
|
+
})
|
|
1278
|
+
.filter(l => l);
|
|
1279
|
+
});
|
|
1280
|
+
};
|
|
1281
|
+
|
|
1282
|
+
const processScriptsAndPreloads = () => {
|
|
1283
|
+
for (const link of document.querySelectorAll(shimMode ? 'link[rel=modulepreload-shim]' : 'link[rel=modulepreload]')) {
|
|
1284
|
+
if (!link.ep) processPreload(link);
|
|
1285
|
+
}
|
|
1286
|
+
for (const script of document.querySelectorAll('script[type]')) {
|
|
1287
|
+
if (script.type === 'importmap' + (shimMode ? '-shim' : '')) {
|
|
1288
|
+
if (!script.ep) processImportMap(script);
|
|
1289
|
+
} else if (script.type === 'module' + (shimMode ? '-shim' : '')) {
|
|
1290
|
+
legacyAcceptingImportMaps = false;
|
|
1291
|
+
if (!script.ep) processScript(script);
|
|
1292
|
+
}
|
|
1293
|
+
}
|
|
1294
|
+
};
|
|
1295
|
+
|
|
1296
|
+
const getFetchOpts = script => {
|
|
1297
|
+
const fetchOpts = {};
|
|
1298
|
+
if (script.integrity) fetchOpts.integrity = script.integrity;
|
|
1299
|
+
if (script.referrerPolicy) fetchOpts.referrerPolicy = script.referrerPolicy;
|
|
1300
|
+
if (script.fetchPriority) fetchOpts.priority = script.fetchPriority;
|
|
1301
|
+
if (script.crossOrigin === 'use-credentials') fetchOpts.credentials = 'include';
|
|
1302
|
+
else if (script.crossOrigin === 'anonymous') fetchOpts.credentials = 'omit';
|
|
1303
|
+
else fetchOpts.credentials = 'same-origin';
|
|
1304
|
+
return fetchOpts;
|
|
1305
|
+
};
|
|
1306
|
+
|
|
1307
|
+
let lastStaticLoadPromise = Promise.resolve();
|
|
1308
|
+
|
|
1309
|
+
let domContentLoaded = false;
|
|
1310
|
+
let domContentLoadedCnt = 1;
|
|
1311
|
+
const domContentLoadedCheck = m => {
|
|
1312
|
+
if (m === undefined) {
|
|
1313
|
+
if (domContentLoaded) return;
|
|
1314
|
+
domContentLoaded = true;
|
|
1315
|
+
domContentLoadedCnt--;
|
|
1316
|
+
}
|
|
1317
|
+
if (--domContentLoadedCnt === 0 && !noLoadEventRetriggers && (shimMode || !baselineSupport)) {
|
|
1318
|
+
console.info(`es-module-shims: DOMContentLoaded refire`);
|
|
1319
|
+
document.removeEventListener('DOMContentLoaded', domContentLoadedEvent);
|
|
1320
|
+
document.dispatchEvent(new Event('DOMContentLoaded'));
|
|
1321
|
+
}
|
|
1322
|
+
};
|
|
1323
|
+
let loadCnt = 1;
|
|
1324
|
+
const loadCheck = () => {
|
|
1325
|
+
if (--loadCnt === 0 && !noLoadEventRetriggers && (shimMode || !baselineSupport)) {
|
|
1326
|
+
console.info(`es-module-shims: load refire`);
|
|
1327
|
+
window.removeEventListener('load', loadEvent);
|
|
1328
|
+
window.dispatchEvent(new Event('load'));
|
|
1329
|
+
}
|
|
1330
|
+
};
|
|
1331
|
+
|
|
1332
|
+
const domContentLoadedEvent = async () => {
|
|
1333
|
+
await initPromise;
|
|
1334
|
+
domContentLoadedCheck();
|
|
1335
|
+
};
|
|
1336
|
+
const loadEvent = async () => {
|
|
1337
|
+
await initPromise;
|
|
1338
|
+
domContentLoadedCheck();
|
|
1339
|
+
loadCheck();
|
|
1340
|
+
};
|
|
1341
|
+
|
|
1342
|
+
// this should always trigger because we assume es-module-shims is itself a domcontentloaded requirement
|
|
1343
|
+
if (hasDocument) {
|
|
1344
|
+
document.addEventListener('DOMContentLoaded', domContentLoadedEvent);
|
|
1345
|
+
window.addEventListener('load', loadEvent);
|
|
1346
|
+
}
|
|
1347
|
+
|
|
1348
|
+
const readyListener = async () => {
|
|
1349
|
+
await initPromise;
|
|
1350
|
+
processScriptsAndPreloads();
|
|
1351
|
+
if (document.readyState === 'complete') {
|
|
1352
|
+
readyStateCompleteCheck();
|
|
1353
|
+
}
|
|
1354
|
+
};
|
|
1355
|
+
|
|
1356
|
+
let readyStateCompleteCnt = 1;
|
|
1357
|
+
const readyStateCompleteCheck = () => {
|
|
1358
|
+
if (--readyStateCompleteCnt === 0) {
|
|
1359
|
+
domContentLoadedCheck();
|
|
1360
|
+
if (!noLoadEventRetriggers && (shimMode || !baselineSupport)) {
|
|
1361
|
+
console.info(`es-module-shims: readystatechange complete refire`);
|
|
1362
|
+
document.removeEventListener('readystatechange', readyListener);
|
|
1363
|
+
document.dispatchEvent(new Event('readystatechange'));
|
|
1364
|
+
}
|
|
1365
|
+
}
|
|
1366
|
+
};
|
|
1367
|
+
|
|
1368
|
+
const hasNext = script => script.nextSibling || (script.parentNode && hasNext(script.parentNode));
|
|
1369
|
+
const epCheck = (script, ready) =>
|
|
1370
|
+
script.ep ||
|
|
1371
|
+
(!ready && ((!script.src && !script.innerHTML) || !hasNext(script))) ||
|
|
1372
|
+
script.getAttribute('noshim') !== null ||
|
|
1373
|
+
!(script.ep = true);
|
|
1374
|
+
|
|
1375
|
+
const processImportMap = (script, ready = readyStateCompleteCnt > 0) => {
|
|
1376
|
+
if (epCheck(script, ready)) return;
|
|
1377
|
+
console.info(`es-module-shims: reading import map`);
|
|
1378
|
+
// we dont currently support external import maps in polyfill mode to match native
|
|
1379
|
+
if (script.src) {
|
|
1380
|
+
if (!shimMode) return;
|
|
1381
|
+
importMapSrc = true;
|
|
1382
|
+
}
|
|
1383
|
+
importMapPromise = importMapPromise
|
|
1384
|
+
.then(async () => {
|
|
1385
|
+
composedImportMap = resolveAndComposeImportMap(
|
|
1386
|
+
script.src ? await (await doFetch(script.src, getFetchOpts(script))).json() : JSON.parse(script.innerHTML),
|
|
1387
|
+
script.src || baseUrl,
|
|
1388
|
+
composedImportMap
|
|
1389
|
+
);
|
|
1390
|
+
})
|
|
1391
|
+
.catch(e => {
|
|
1392
|
+
if (e instanceof SyntaxError)
|
|
1393
|
+
e = new Error(`Unable to parse import map ${e.message} in: ${script.src || script.innerHTML}`);
|
|
1394
|
+
throwError(e);
|
|
1395
|
+
});
|
|
1396
|
+
if (!firstImportMap && legacyAcceptingImportMaps) importMapPromise.then(() => (firstImportMap = composedImportMap));
|
|
1397
|
+
if (!legacyAcceptingImportMaps && !multipleImportMaps) {
|
|
1398
|
+
multipleImportMaps = true;
|
|
1399
|
+
if (!shimMode && baselineSupport && !supportsMultipleImportMaps) {
|
|
1400
|
+
console.info(`es-module-shims: disabling baseline passthrough due to multiple import maps`);
|
|
1401
|
+
baselineSupport = false;
|
|
1402
|
+
if (hasDocument) attachMutationObserver();
|
|
1403
|
+
}
|
|
1404
|
+
}
|
|
1405
|
+
legacyAcceptingImportMaps = false;
|
|
1406
|
+
};
|
|
1407
|
+
|
|
1408
|
+
const processScript = (script, ready = readyStateCompleteCnt > 0) => {
|
|
1409
|
+
if (epCheck(script, ready)) return;
|
|
1410
|
+
console.info(`es-module-shims: checking script ${script.src || '<inline>'}`);
|
|
1411
|
+
// does this load block readystate complete
|
|
1412
|
+
const isBlockingReadyScript = script.getAttribute('async') === null && readyStateCompleteCnt > 0;
|
|
1413
|
+
// does this load block DOMContentLoaded
|
|
1414
|
+
const isDomContentLoadedScript = domContentLoadedCnt > 0;
|
|
1415
|
+
const isLoadScript = loadCnt > 0;
|
|
1416
|
+
if (isLoadScript) loadCnt++;
|
|
1417
|
+
if (isBlockingReadyScript) readyStateCompleteCnt++;
|
|
1418
|
+
if (isDomContentLoadedScript) domContentLoadedCnt++;
|
|
1419
|
+
let loadPromise;
|
|
1420
|
+
const ts = script.lang === 'ts';
|
|
1421
|
+
if (ts && !script.src) {
|
|
1422
|
+
loadPromise = Promise.resolve(esmsTsTransform || initTs())
|
|
1423
|
+
.then(() => {
|
|
1424
|
+
console.info(`es-module-shims: Compiling TypeScript module script`, script);
|
|
1425
|
+
const transformed = esmsTsTransform(script.innerHTML, baseUrl);
|
|
1426
|
+
if (transformed !== undefined) {
|
|
1427
|
+
onpolyfill();
|
|
1428
|
+
firstPolyfillLoad = false;
|
|
1429
|
+
}
|
|
1430
|
+
return topLevelLoad(
|
|
1431
|
+
script.src || baseUrl,
|
|
1432
|
+
baseUrl,
|
|
1433
|
+
getFetchOpts(script),
|
|
1434
|
+
transformed === undefined ? script.innerHTML : transformed,
|
|
1435
|
+
!shimMode && transformed === undefined,
|
|
1436
|
+
isBlockingReadyScript && lastStaticLoadPromise,
|
|
1437
|
+
'ts'
|
|
1438
|
+
);
|
|
1439
|
+
})
|
|
1440
|
+
.catch(throwError);
|
|
1441
|
+
} else {
|
|
1442
|
+
loadPromise = topLevelLoad(
|
|
1443
|
+
script.src || baseUrl,
|
|
1444
|
+
baseUrl,
|
|
1445
|
+
getFetchOpts(script),
|
|
1446
|
+
!script.src ? script.innerHTML : undefined,
|
|
1447
|
+
!shimMode,
|
|
1448
|
+
isBlockingReadyScript && lastStaticLoadPromise,
|
|
1449
|
+
ts ? 'ts' : undefined
|
|
1450
|
+
).catch(throwError);
|
|
1451
|
+
}
|
|
1452
|
+
if (!noLoadEventRetriggers) loadPromise.then(() => script.dispatchEvent(new Event('load')));
|
|
1453
|
+
if (isBlockingReadyScript && !ts) {
|
|
1454
|
+
lastStaticLoadPromise = loadPromise.then(readyStateCompleteCheck);
|
|
1455
|
+
}
|
|
1456
|
+
if (isDomContentLoadedScript) loadPromise.then(domContentLoadedCheck);
|
|
1457
|
+
if (isLoadScript) loadPromise.then(loadCheck);
|
|
1458
|
+
};
|
|
1459
|
+
|
|
1460
|
+
const fetchCache = {};
|
|
1461
|
+
const processPreload = link => {
|
|
1462
|
+
link.ep = true;
|
|
1463
|
+
initPromise.then(() => {
|
|
1464
|
+
if (baselineSupport && !shimMode) return;
|
|
1465
|
+
if (fetchCache[link.href]) return;
|
|
1466
|
+
fetchCache[link.href] = fetchModule(link.href, getFetchOpts(link));
|
|
1467
|
+
});
|
|
1466
1468
|
};
|
|
1467
1469
|
|
|
1468
1470
|
})();
|