es-module-shims 2.2.0 → 2.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +60 -8
- package/dist/es-module-shims.debug.js +594 -374
- package/dist/es-module-shims.js +581 -364
- package/dist/es-module-shims.wasm.js +581 -364
- package/package.json +1 -1
|
@@ -1,10 +1,180 @@
|
|
|
1
|
-
|
|
2
|
-
(function () {
|
|
1
|
+
/** ES Module Shims Wasm 2.3.1 */
|
|
2
|
+
(function (exports) {
|
|
3
3
|
|
|
4
|
+
let invalidate;
|
|
5
|
+
const hotReload$1 = url => invalidate(new URL(url, baseUrl).href);
|
|
6
|
+
const initHotReload = () => {
|
|
7
|
+
let _importHook = importHook,
|
|
8
|
+
_resolveHook = resolveHook,
|
|
9
|
+
_metaHook = metaHook;
|
|
10
|
+
|
|
11
|
+
let defaultResolve;
|
|
12
|
+
let hotResolveHook = (id, parent, _defaultResolve) => {
|
|
13
|
+
if (!defaultResolve) defaultResolve = _defaultResolve;
|
|
14
|
+
const originalParent = stripVersion(parent);
|
|
15
|
+
const url = stripVersion(defaultResolve(id, originalParent));
|
|
16
|
+
const parents = getHotState(url).p;
|
|
17
|
+
if (!parents.includes(originalParent)) parents.push(originalParent);
|
|
18
|
+
return toVersioned(url);
|
|
19
|
+
};
|
|
20
|
+
const hotImportHook = (url, _, __, source, sourceType) => {
|
|
21
|
+
const hotState = getHotState(url);
|
|
22
|
+
hotState.e = typeof source === 'string' ? source : true;
|
|
23
|
+
hotState.t = sourceType;
|
|
24
|
+
};
|
|
25
|
+
const hotMetaHook = (metaObj, url) => {
|
|
26
|
+
metaObj.hot = new Hot(url);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const Hot = class Hot {
|
|
30
|
+
constructor(url) {
|
|
31
|
+
this.data = getHotState((this.url = stripVersion(url))).d;
|
|
32
|
+
}
|
|
33
|
+
accept(deps, cb) {
|
|
34
|
+
if (typeof deps === 'function') {
|
|
35
|
+
cb = deps;
|
|
36
|
+
deps = null;
|
|
37
|
+
}
|
|
38
|
+
const hotState = getHotState(this.url);
|
|
39
|
+
if (!hotState.A) return;
|
|
40
|
+
(hotState.a = hotState.a || []).push([
|
|
41
|
+
typeof deps === 'string' ? defaultResolve(deps, this.url)
|
|
42
|
+
: deps ? deps.map(d => defaultResolve(d, this.url))
|
|
43
|
+
: null,
|
|
44
|
+
cb
|
|
45
|
+
]);
|
|
46
|
+
}
|
|
47
|
+
dispose(cb) {
|
|
48
|
+
getHotState(this.url).u = cb;
|
|
49
|
+
}
|
|
50
|
+
invalidate() {
|
|
51
|
+
const hotState = getHotState(this.url);
|
|
52
|
+
hotState.a = null;
|
|
53
|
+
hotState.A = true;
|
|
54
|
+
const seen = [this.url];
|
|
55
|
+
for (const p of hotState.p) invalidate(p, this.url, seen);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const versionedRegEx = /\?v=\d+$/;
|
|
60
|
+
const stripVersion = url => {
|
|
61
|
+
const versionMatch = url.match(versionedRegEx);
|
|
62
|
+
return versionMatch ? url.slice(0, -versionMatch[0].length) : url;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const toVersioned = url => {
|
|
66
|
+
const v = getHotState(url).v;
|
|
67
|
+
return url + (v ? '?v=' + v : '');
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
let hotRegistry = {},
|
|
71
|
+
curInvalidationRoots = new Set(),
|
|
72
|
+
curInvalidationInterval;
|
|
73
|
+
const getHotState = url =>
|
|
74
|
+
hotRegistry[url] ||
|
|
75
|
+
(hotRegistry[url] = {
|
|
76
|
+
// version
|
|
77
|
+
v: 0,
|
|
78
|
+
// accept list ([deps, cb] pairs)
|
|
79
|
+
a: null,
|
|
80
|
+
// accepting acceptors
|
|
81
|
+
A: true,
|
|
82
|
+
// unload callback
|
|
83
|
+
u: null,
|
|
84
|
+
// entry point or inline script source
|
|
85
|
+
e: false,
|
|
86
|
+
// hot data
|
|
87
|
+
d: {},
|
|
88
|
+
// parents
|
|
89
|
+
p: [],
|
|
90
|
+
// source type
|
|
91
|
+
t: undefined
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
invalidate = (url, fromUrl, seen = []) => {
|
|
95
|
+
if (!seen.includes(url)) {
|
|
96
|
+
seen.push(url);
|
|
97
|
+
const hotState = hotRegistry[url];
|
|
98
|
+
if (hotState) {
|
|
99
|
+
hotState.A = false;
|
|
100
|
+
if (
|
|
101
|
+
hotState.a &&
|
|
102
|
+
hotState.a.some(([d]) => d && (typeof d === 'string' ? d === fromUrl : d.includes(fromUrl)))
|
|
103
|
+
) {
|
|
104
|
+
curInvalidationRoots.add(fromUrl);
|
|
105
|
+
} else {
|
|
106
|
+
if (hotState.e || hotState.a) curInvalidationRoots.add(url);
|
|
107
|
+
hotState.v++;
|
|
108
|
+
if (!hotState.a) for (const parent of hotState.p) invalidate(parent, url, seen);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
if (!curInvalidationInterval)
|
|
113
|
+
curInvalidationInterval = setTimeout(() => {
|
|
114
|
+
curInvalidationInterval = null;
|
|
115
|
+
const earlyRoots = new Set();
|
|
116
|
+
for (const root of curInvalidationRoots) {
|
|
117
|
+
const hotState = hotRegistry[root];
|
|
118
|
+
topLevelLoad(
|
|
119
|
+
toVersioned(root),
|
|
120
|
+
baseUrl,
|
|
121
|
+
defaultFetchOpts,
|
|
122
|
+
typeof hotState.e === 'string' ? hotState.e : undefined,
|
|
123
|
+
false,
|
|
124
|
+
undefined,
|
|
125
|
+
hotState.t
|
|
126
|
+
).then(m => {
|
|
127
|
+
if (hotState.a) {
|
|
128
|
+
hotState.a.every(([d, c]) => d === null && !earlyRoots.has(c) && c(m));
|
|
129
|
+
// unload should be the latest unload handler from the just loaded module
|
|
130
|
+
if (hotState.u) {
|
|
131
|
+
hotState.u(hotState.d);
|
|
132
|
+
hotState.u = null;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
for (const parent of hotState.p) {
|
|
136
|
+
const hotState = hotRegistry[parent];
|
|
137
|
+
if (hotState && hotState.a)
|
|
138
|
+
hotState.a.every(async ([d, c]) => {
|
|
139
|
+
return (
|
|
140
|
+
d &&
|
|
141
|
+
!earlyRoots.has(c) &&
|
|
142
|
+
(typeof d === 'string' ?
|
|
143
|
+
d === root && c(m)
|
|
144
|
+
: c(await Promise.all(d.map(d => (earlyRoots.push(c), importShim(toVersioned(d)))))))
|
|
145
|
+
);
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
}, throwError);
|
|
149
|
+
}
|
|
150
|
+
curInvalidationRoots = new Set();
|
|
151
|
+
}, hotReloadInterval);
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
return [
|
|
155
|
+
_importHook ? chain(_importHook, hotImportHook) : hotImportHook,
|
|
156
|
+
_resolveHook ?
|
|
157
|
+
(id, parent, defaultResolve) =>
|
|
158
|
+
hotResolveHook(id, parent, (id, parent) => _resolveHook(id, parent, defaultResolve))
|
|
159
|
+
: hotResolveHook,
|
|
160
|
+
_metaHook ? chain(_metaHook, hotMetaHook) : hotMetaHook
|
|
161
|
+
];
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
if (self.importShim) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
|
|
4
168
|
const hasDocument = typeof document !== 'undefined';
|
|
5
169
|
|
|
6
170
|
const noop = () => {};
|
|
7
171
|
|
|
172
|
+
const chain = (a, b) =>
|
|
173
|
+
function () {
|
|
174
|
+
a.apply(this, arguments);
|
|
175
|
+
b.apply(this, arguments);
|
|
176
|
+
};
|
|
177
|
+
|
|
8
178
|
const dynamicImport = (u, errUrl) => import(u);
|
|
9
179
|
|
|
10
180
|
const optionsScript = hasDocument ? document.querySelector('script[type=esms-options]') : undefined;
|
|
@@ -14,22 +184,39 @@
|
|
|
14
184
|
|
|
15
185
|
// shim mode is determined on initialization, no late shim mode
|
|
16
186
|
const shimMode =
|
|
17
|
-
|
|
18
|
-
esmsInitOptions.shimMode ||
|
|
19
|
-
document.querySelectorAll('script[type=module-shim],script[type=importmap-shim],link[rel=modulepreload-shim]')
|
|
20
|
-
.length > 0
|
|
21
|
-
: true;
|
|
22
|
-
|
|
23
|
-
const importHook = globalHook(shimMode && esmsInitOptions.onimport);
|
|
24
|
-
const resolveHook = globalHook(shimMode && esmsInitOptions.resolve);
|
|
25
|
-
let fetchHook = esmsInitOptions.fetch ? globalHook(esmsInitOptions.fetch) : fetch;
|
|
26
|
-
const metaHook = esmsInitOptions.meta ? globalHook(shimMode && esmsInitOptions.meta) : noop;
|
|
27
|
-
const tsTransform =
|
|
28
|
-
esmsInitOptions.tsTransform ||
|
|
187
|
+
esmsInitOptions.shimMode ||
|
|
29
188
|
(hasDocument &&
|
|
30
|
-
document.
|
|
31
|
-
|
|
32
|
-
|
|
189
|
+
document.querySelectorAll('script[type=module-shim],script[type=importmap-shim],link[rel=modulepreload-shim]')
|
|
190
|
+
.length > 0);
|
|
191
|
+
|
|
192
|
+
let importHook,
|
|
193
|
+
resolveHook,
|
|
194
|
+
fetchHook = fetch,
|
|
195
|
+
metaHook,
|
|
196
|
+
tsTransform =
|
|
197
|
+
esmsInitOptions.tsTransform ||
|
|
198
|
+
(hasDocument && document.currentScript && document.currentScript.src.replace(/(\.\w+)?\.js$/, '-typescript.js')) ||
|
|
199
|
+
'./es-module-shims-typescript.js';
|
|
200
|
+
|
|
201
|
+
const defaultFetchOpts = { credentials: 'same-origin' };
|
|
202
|
+
|
|
203
|
+
const {
|
|
204
|
+
revokeBlobURLs,
|
|
205
|
+
noLoadEventRetriggers,
|
|
206
|
+
enforceIntegrity,
|
|
207
|
+
hotReload,
|
|
208
|
+
hotReloadInterval = 100,
|
|
209
|
+
nativePassthrough = !hotReload
|
|
210
|
+
} = esmsInitOptions;
|
|
211
|
+
|
|
212
|
+
const globalHook = name => (typeof name === 'string' ? self[name] : name);
|
|
213
|
+
|
|
214
|
+
if (esmsInitOptions.onimport) importHook = globalHook(esmsInitOptions.onimport);
|
|
215
|
+
if (esmsInitOptions.resolve) resolveHook = globalHook(esmsInitOptions.resolve);
|
|
216
|
+
if (esmsInitOptions.fetch) fetchHook = globalHook(esmsInitOptions.fetch);
|
|
217
|
+
if (esmsInitOptions.meta) metaHook = globalHook(esmsInitOptions.meta);
|
|
218
|
+
|
|
219
|
+
if (hotReload) [importHook, resolveHook, metaHook] = initHotReload();
|
|
33
220
|
|
|
34
221
|
const mapOverrides = esmsInitOptions.mapOverrides;
|
|
35
222
|
|
|
@@ -39,13 +226,7 @@
|
|
|
39
226
|
if (nonceElement) nonce = nonceElement.nonce || nonceElement.getAttribute('nonce');
|
|
40
227
|
}
|
|
41
228
|
|
|
42
|
-
const onerror = globalHook(esmsInitOptions.onerror ||
|
|
43
|
-
|
|
44
|
-
const { revokeBlobURLs, noLoadEventRetriggers, enforceIntegrity } = esmsInitOptions;
|
|
45
|
-
|
|
46
|
-
function globalHook(name) {
|
|
47
|
-
return typeof name === 'string' ? self[name] : name;
|
|
48
|
-
}
|
|
229
|
+
const onerror = globalHook(esmsInitOptions.onerror || console.error.bind(console));
|
|
49
230
|
|
|
50
231
|
const enable = Array.isArray(esmsInitOptions.polyfillEnable) ? esmsInitOptions.polyfillEnable : [];
|
|
51
232
|
const enableAll = esmsInitOptions.polyfillEnable === 'all' || enable.includes('all');
|
|
@@ -89,23 +270,20 @@
|
|
|
89
270
|
(self.reportError || dispatchError)(err), void onerror(err);
|
|
90
271
|
};
|
|
91
272
|
|
|
92
|
-
|
|
93
|
-
return parent ? ` imported from ${parent}` : '';
|
|
94
|
-
}
|
|
273
|
+
const fromParent = parent => (parent ? ` imported from ${parent}` : '');
|
|
95
274
|
|
|
96
275
|
const backslashRegEx = /\\/g;
|
|
97
276
|
|
|
98
|
-
|
|
277
|
+
const asURL = url => {
|
|
99
278
|
try {
|
|
100
279
|
if (url.indexOf(':') !== -1) return new URL(url).href;
|
|
101
280
|
} catch (_) {}
|
|
102
|
-
}
|
|
281
|
+
};
|
|
103
282
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
283
|
+
const resolveUrl = (relUrl, parentUrl) =>
|
|
284
|
+
resolveIfNotPlainOrUrl(relUrl, parentUrl) || asURL(relUrl) || resolveIfNotPlainOrUrl('./' + relUrl, parentUrl);
|
|
107
285
|
|
|
108
|
-
|
|
286
|
+
const resolveIfNotPlainOrUrl = (relUrl, parentUrl) => {
|
|
109
287
|
const hIdx = parentUrl.indexOf('#'),
|
|
110
288
|
qIdx = parentUrl.indexOf('?');
|
|
111
289
|
if (hIdx + qIdx > -2)
|
|
@@ -193,9 +371,9 @@
|
|
|
193
371
|
if (segmentIndex !== -1) output.push(segmented.slice(segmentIndex));
|
|
194
372
|
return parentUrl.slice(0, parentUrl.length - pathname.length) + output.join('');
|
|
195
373
|
}
|
|
196
|
-
}
|
|
374
|
+
};
|
|
197
375
|
|
|
198
|
-
|
|
376
|
+
const resolveAndComposeImportMap = (json, baseUrl, parentMap) => {
|
|
199
377
|
const outMap = {
|
|
200
378
|
imports: Object.assign({}, parentMap.imports),
|
|
201
379
|
scopes: Object.assign({}, parentMap.scopes),
|
|
@@ -218,27 +396,27 @@
|
|
|
218
396
|
if (json.integrity) resolveAndComposeIntegrity(json.integrity, outMap.integrity, baseUrl);
|
|
219
397
|
|
|
220
398
|
return outMap;
|
|
221
|
-
}
|
|
399
|
+
};
|
|
222
400
|
|
|
223
|
-
|
|
401
|
+
const getMatch = (path, matchObj) => {
|
|
224
402
|
if (matchObj[path]) return path;
|
|
225
403
|
let sepIndex = path.length;
|
|
226
404
|
do {
|
|
227
405
|
const segment = path.slice(0, sepIndex + 1);
|
|
228
406
|
if (segment in matchObj) return segment;
|
|
229
407
|
} while ((sepIndex = path.lastIndexOf('/', sepIndex - 1)) !== -1);
|
|
230
|
-
}
|
|
408
|
+
};
|
|
231
409
|
|
|
232
|
-
|
|
410
|
+
const applyPackages = (id, packages) => {
|
|
233
411
|
const pkgName = getMatch(id, packages);
|
|
234
412
|
if (pkgName) {
|
|
235
413
|
const pkg = packages[pkgName];
|
|
236
414
|
if (pkg === null) return;
|
|
237
415
|
return pkg + id.slice(pkgName.length);
|
|
238
416
|
}
|
|
239
|
-
}
|
|
417
|
+
};
|
|
240
418
|
|
|
241
|
-
|
|
419
|
+
const resolveImportMap = (importMap, resolvedOrPlain, parentUrl) => {
|
|
242
420
|
let scopeUrl = parentUrl && getMatch(parentUrl, importMap.scopes);
|
|
243
421
|
while (scopeUrl) {
|
|
244
422
|
const packageResolution = applyPackages(resolvedOrPlain, importMap.scopes[scopeUrl]);
|
|
@@ -246,9 +424,9 @@
|
|
|
246
424
|
scopeUrl = getMatch(scopeUrl.slice(0, scopeUrl.lastIndexOf('/')), importMap.scopes);
|
|
247
425
|
}
|
|
248
426
|
return applyPackages(resolvedOrPlain, importMap.imports) || (resolvedOrPlain.indexOf(':') !== -1 && resolvedOrPlain);
|
|
249
|
-
}
|
|
427
|
+
};
|
|
250
428
|
|
|
251
|
-
|
|
429
|
+
const resolveAndComposePackages = (packages, outPackages, baseUrl, parentMap) => {
|
|
252
430
|
for (let p in packages) {
|
|
253
431
|
const resolvedLhs = resolveIfNotPlainOrUrl(p, baseUrl) || p;
|
|
254
432
|
if (
|
|
@@ -270,9 +448,9 @@
|
|
|
270
448
|
}
|
|
271
449
|
console.warn(`es-module-shims: Mapping "${p}" -> "${packages[p]}" does not resolve`);
|
|
272
450
|
}
|
|
273
|
-
}
|
|
451
|
+
};
|
|
274
452
|
|
|
275
|
-
|
|
453
|
+
const resolveAndComposeIntegrity = (integrity, outIntegrity, baseUrl) => {
|
|
276
454
|
for (let p in integrity) {
|
|
277
455
|
const resolvedLhs = resolveIfNotPlainOrUrl(p, baseUrl) || p;
|
|
278
456
|
if (
|
|
@@ -286,122 +464,122 @@
|
|
|
286
464
|
}
|
|
287
465
|
outIntegrity[resolvedLhs] = integrity[p];
|
|
288
466
|
}
|
|
289
|
-
}
|
|
467
|
+
};
|
|
290
468
|
|
|
291
|
-
// support browsers without dynamic import support (eg Firefox 6x)
|
|
292
|
-
let supportsJsonType = false;
|
|
293
|
-
let supportsCssType = false;
|
|
294
|
-
|
|
295
|
-
const supports = hasDocument && HTMLScriptElement.supports;
|
|
296
|
-
|
|
297
|
-
let supportsImportMaps = supports && supports.name === 'supports' && supports('importmap');
|
|
298
|
-
let supportsWasmInstancePhase = false;
|
|
299
|
-
let supportsWasmSourcePhase = false;
|
|
300
|
-
let supportsMultipleImportMaps = false;
|
|
301
|
-
|
|
302
|
-
const wasmBytes = [0, 97, 115, 109, 1, 0, 0, 0];
|
|
303
|
-
|
|
304
|
-
let featureDetectionPromise = (async function () {
|
|
305
|
-
if (!hasDocument)
|
|
306
|
-
return Promise.all([
|
|
307
|
-
import(createBlob(`import"${createBlob('{}', 'text/json')}"with{type:"json"}`)).then(
|
|
308
|
-
() => (
|
|
309
|
-
(supportsJsonType = true),
|
|
310
|
-
import(createBlob(`import"${createBlob('', 'text/css')}"with{type:"css"}`)).then(
|
|
311
|
-
() => (supportsCssType = true),
|
|
312
|
-
noop
|
|
313
|
-
)
|
|
314
|
-
),
|
|
315
|
-
noop
|
|
316
|
-
),
|
|
317
|
-
wasmInstancePhaseEnabled &&
|
|
318
|
-
import(createBlob(`import"${createBlob(new Uint8Array(wasmBytes), 'application/wasm')}"`)).then(
|
|
319
|
-
() => (supportsWasmInstancePhase = true),
|
|
320
|
-
noop
|
|
321
|
-
),
|
|
322
|
-
wasmSourcePhaseEnabled &&
|
|
323
|
-
import(createBlob(`import source x from"${createBlob(new Uint8Array(wasmBytes), 'application/wasm')}"`)).then(
|
|
324
|
-
() => (supportsWasmSourcePhase = true),
|
|
325
|
-
noop
|
|
326
|
-
)
|
|
327
|
-
]);
|
|
328
|
-
|
|
329
|
-
return new Promise(resolve => {
|
|
330
|
-
const iframe = document.createElement('iframe');
|
|
331
|
-
iframe.style.display = 'none';
|
|
332
|
-
iframe.setAttribute('nonce', nonce);
|
|
333
|
-
function cb({ data }) {
|
|
334
|
-
const isFeatureDetectionMessage = Array.isArray(data) && data[0] === 'esms';
|
|
335
|
-
if (!isFeatureDetectionMessage) return;
|
|
336
|
-
[
|
|
337
|
-
,
|
|
338
|
-
supportsImportMaps,
|
|
339
|
-
supportsMultipleImportMaps,
|
|
340
|
-
supportsJsonType,
|
|
341
|
-
supportsCssType,
|
|
342
|
-
supportsWasmSourcePhase,
|
|
343
|
-
supportsWasmInstancePhase
|
|
344
|
-
] = data;
|
|
345
|
-
resolve();
|
|
346
|
-
document.head.removeChild(iframe);
|
|
347
|
-
window.removeEventListener('message', cb, false);
|
|
348
|
-
}
|
|
349
|
-
window.addEventListener('message', cb, false);
|
|
350
|
-
|
|
351
|
-
// 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.
|
|
352
|
-
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=${
|
|
353
|
-
supportsImportMaps ? `c(b(\`import"\${b('{}','text/json')}"with{type:"json"}\`))` : 'false'
|
|
354
|
-
};sp=${
|
|
355
|
-
supportsImportMaps && wasmSourcePhaseEnabled ?
|
|
356
|
-
`c(b(\`import source x from "\${b(new Uint8Array(${JSON.stringify(wasmBytes)}),'application/wasm')\}"\`))`
|
|
357
|
-
: 'false'
|
|
358
|
-
};Promise.all([${supportsImportMaps ? 'true' : "c('x')"},${supportsImportMaps ? "c('y')" : false},cm,${
|
|
359
|
-
supportsImportMaps ? `cm.then(s=>s?c(b(\`import"\${b('','text/css')\}"with{type:"css"}\`)):false)` : 'false'
|
|
360
|
-
},sp,${
|
|
361
|
-
supportsImportMaps && wasmInstancePhaseEnabled ?
|
|
362
|
-
`${wasmSourcePhaseEnabled ? 'sp.then(s=>s?' : ''}c(b(\`import"\${b(new Uint8Array(${JSON.stringify(wasmBytes)}),'application/wasm')\}"\`))${wasmSourcePhaseEnabled ? ':false)' : ''}`
|
|
363
|
-
: 'false'
|
|
364
|
-
}]).then(a=>parent.postMessage(['esms'].concat(a),'*'))<${''}/script>`;
|
|
365
|
-
|
|
366
|
-
// Safari will call onload eagerly on head injection, but we don't want the Wechat
|
|
367
|
-
// path to trigger before setting srcdoc, therefore we track the timing
|
|
368
|
-
let readyForOnload = false,
|
|
369
|
-
onloadCalledWhileNotReady = false;
|
|
370
|
-
function doOnload() {
|
|
371
|
-
if (!readyForOnload) {
|
|
372
|
-
onloadCalledWhileNotReady = true;
|
|
373
|
-
return;
|
|
374
|
-
}
|
|
375
|
-
// WeChat browser doesn't support setting srcdoc scripts
|
|
376
|
-
// But iframe sandboxes don't support contentDocument so we do this as a fallback
|
|
377
|
-
const doc = iframe.contentDocument;
|
|
378
|
-
if (doc && doc.head.childNodes.length === 0) {
|
|
379
|
-
const s = doc.createElement('script');
|
|
380
|
-
if (nonce) s.setAttribute('nonce', nonce);
|
|
381
|
-
s.innerHTML = importMapTest.slice(15 + (nonce ? nonce.length : 0), -9);
|
|
382
|
-
doc.head.appendChild(s);
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
iframe.onload = doOnload;
|
|
387
|
-
// WeChat browser requires append before setting srcdoc
|
|
388
|
-
document.head.appendChild(iframe);
|
|
389
|
-
|
|
390
|
-
// setting srcdoc is not supported in React native webviews on iOS
|
|
391
|
-
// setting src to a blob URL results in a navigation event in webviews
|
|
392
|
-
// document.write gives usability warnings
|
|
393
|
-
readyForOnload = true;
|
|
394
|
-
if ('srcdoc' in iframe) iframe.srcdoc = importMapTest;
|
|
395
|
-
else iframe.contentDocument.write(importMapTest);
|
|
396
|
-
// retrigger onload for Safari only if necessary
|
|
397
|
-
if (onloadCalledWhileNotReady) doOnload();
|
|
398
|
-
});
|
|
469
|
+
// support browsers without dynamic import support (eg Firefox 6x)
|
|
470
|
+
let supportsJsonType = false;
|
|
471
|
+
let supportsCssType = false;
|
|
472
|
+
|
|
473
|
+
const supports = hasDocument && HTMLScriptElement.supports;
|
|
474
|
+
|
|
475
|
+
let supportsImportMaps = supports && supports.name === 'supports' && supports('importmap');
|
|
476
|
+
let supportsWasmInstancePhase = false;
|
|
477
|
+
let supportsWasmSourcePhase = false;
|
|
478
|
+
let supportsMultipleImportMaps = false;
|
|
479
|
+
|
|
480
|
+
const wasmBytes = [0, 97, 115, 109, 1, 0, 0, 0];
|
|
481
|
+
|
|
482
|
+
let featureDetectionPromise = (async function () {
|
|
483
|
+
if (!hasDocument)
|
|
484
|
+
return Promise.all([
|
|
485
|
+
import(createBlob(`import"${createBlob('{}', 'text/json')}"with{type:"json"}`)).then(
|
|
486
|
+
() => (
|
|
487
|
+
(supportsJsonType = true),
|
|
488
|
+
import(createBlob(`import"${createBlob('', 'text/css')}"with{type:"css"}`)).then(
|
|
489
|
+
() => (supportsCssType = true),
|
|
490
|
+
noop
|
|
491
|
+
)
|
|
492
|
+
),
|
|
493
|
+
noop
|
|
494
|
+
),
|
|
495
|
+
wasmInstancePhaseEnabled &&
|
|
496
|
+
import(createBlob(`import"${createBlob(new Uint8Array(wasmBytes), 'application/wasm')}"`)).then(
|
|
497
|
+
() => (supportsWasmInstancePhase = true),
|
|
498
|
+
noop
|
|
499
|
+
),
|
|
500
|
+
wasmSourcePhaseEnabled &&
|
|
501
|
+
import(createBlob(`import source x from"${createBlob(new Uint8Array(wasmBytes), 'application/wasm')}"`)).then(
|
|
502
|
+
() => (supportsWasmSourcePhase = true),
|
|
503
|
+
noop
|
|
504
|
+
)
|
|
505
|
+
]);
|
|
506
|
+
|
|
507
|
+
return new Promise(resolve => {
|
|
508
|
+
const iframe = document.createElement('iframe');
|
|
509
|
+
iframe.style.display = 'none';
|
|
510
|
+
iframe.setAttribute('nonce', nonce);
|
|
511
|
+
function cb({ data }) {
|
|
512
|
+
const isFeatureDetectionMessage = Array.isArray(data) && data[0] === 'esms';
|
|
513
|
+
if (!isFeatureDetectionMessage) return;
|
|
514
|
+
[
|
|
515
|
+
,
|
|
516
|
+
supportsImportMaps,
|
|
517
|
+
supportsMultipleImportMaps,
|
|
518
|
+
supportsJsonType,
|
|
519
|
+
supportsCssType,
|
|
520
|
+
supportsWasmSourcePhase,
|
|
521
|
+
supportsWasmInstancePhase
|
|
522
|
+
] = data;
|
|
523
|
+
resolve();
|
|
524
|
+
document.head.removeChild(iframe);
|
|
525
|
+
window.removeEventListener('message', cb, false);
|
|
526
|
+
}
|
|
527
|
+
window.addEventListener('message', cb, false);
|
|
528
|
+
|
|
529
|
+
// 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.
|
|
530
|
+
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=${
|
|
531
|
+
supportsImportMaps ? `c(b(\`import"\${b('{}','text/json')}"with{type:"json"}\`))` : 'false'
|
|
532
|
+
};sp=${
|
|
533
|
+
supportsImportMaps && wasmSourcePhaseEnabled ?
|
|
534
|
+
`c(b(\`import source x from "\${b(new Uint8Array(${JSON.stringify(wasmBytes)}),'application/wasm')\}"\`))`
|
|
535
|
+
: 'false'
|
|
536
|
+
};Promise.all([${supportsImportMaps ? 'true' : "c('x')"},${supportsImportMaps ? "c('y')" : false},cm,${
|
|
537
|
+
supportsImportMaps ? `cm.then(s=>s?c(b(\`import"\${b('','text/css')\}"with{type:"css"}\`)):false)` : 'false'
|
|
538
|
+
},sp,${
|
|
539
|
+
supportsImportMaps && wasmInstancePhaseEnabled ?
|
|
540
|
+
`${wasmSourcePhaseEnabled ? 'sp.then(s=>s?' : ''}c(b(\`import"\${b(new Uint8Array(${JSON.stringify(wasmBytes)}),'application/wasm')\}"\`))${wasmSourcePhaseEnabled ? ':false)' : ''}`
|
|
541
|
+
: 'false'
|
|
542
|
+
}]).then(a=>parent.postMessage(['esms'].concat(a),'*'))<${''}/script>`;
|
|
543
|
+
|
|
544
|
+
// Safari will call onload eagerly on head injection, but we don't want the Wechat
|
|
545
|
+
// path to trigger before setting srcdoc, therefore we track the timing
|
|
546
|
+
let readyForOnload = false,
|
|
547
|
+
onloadCalledWhileNotReady = false;
|
|
548
|
+
function doOnload() {
|
|
549
|
+
if (!readyForOnload) {
|
|
550
|
+
onloadCalledWhileNotReady = true;
|
|
551
|
+
return;
|
|
552
|
+
}
|
|
553
|
+
// WeChat browser doesn't support setting srcdoc scripts
|
|
554
|
+
// But iframe sandboxes don't support contentDocument so we do this as a fallback
|
|
555
|
+
const doc = iframe.contentDocument;
|
|
556
|
+
if (doc && doc.head.childNodes.length === 0) {
|
|
557
|
+
const s = doc.createElement('script');
|
|
558
|
+
if (nonce) s.setAttribute('nonce', nonce);
|
|
559
|
+
s.innerHTML = importMapTest.slice(15 + (nonce ? nonce.length : 0), -9);
|
|
560
|
+
doc.head.appendChild(s);
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
iframe.onload = doOnload;
|
|
565
|
+
// WeChat browser requires append before setting srcdoc
|
|
566
|
+
document.head.appendChild(iframe);
|
|
567
|
+
|
|
568
|
+
// setting srcdoc is not supported in React native webviews on iOS
|
|
569
|
+
// setting src to a blob URL results in a navigation event in webviews
|
|
570
|
+
// document.write gives usability warnings
|
|
571
|
+
readyForOnload = true;
|
|
572
|
+
if ('srcdoc' in iframe) iframe.srcdoc = importMapTest;
|
|
573
|
+
else iframe.contentDocument.write(importMapTest);
|
|
574
|
+
// retrigger onload for Safari only if necessary
|
|
575
|
+
if (onloadCalledWhileNotReady) doOnload();
|
|
576
|
+
});
|
|
399
577
|
})();
|
|
400
578
|
|
|
401
579
|
/* es-module-lexer 1.7.0 */
|
|
402
580
|
var ImportType;!function(A){A[A.Static=1]="Static",A[A.Dynamic=2]="Dynamic",A[A.ImportMeta=3]="ImportMeta",A[A.StaticSourcePhase=4]="StaticSourcePhase",A[A.DynamicSourcePhase=5]="DynamicSourcePhase",A[A.StaticDeferPhase=6]="StaticDeferPhase",A[A.DynamicDeferPhase=7]="DynamicDeferPhase";}(ImportType||(ImportType={}));const A=1===new Uint8Array(new Uint16Array([1]).buffer)[0];function parse(E,g="@"){if(!C)return init.then((()=>parse(E)));const I=E.length+1,w=(C.__heap_base.value||C.__heap_base)+4*I-C.memory.buffer.byteLength;w>0&&C.memory.grow(Math.ceil(w/65536));const K=C.sa(I-1);if((A?B:Q)(E,new Uint16Array(C.memory.buffer,K,I)),!C.parse())throw Object.assign(new Error(`Parse error ${g}:${E.slice(0,C.e()).split("\n").length}:${C.e()-E.lastIndexOf("\n",C.e()-1)}`),{idx:C.e()});const o=[],D=[];for(;C.ri();){const A=C.is(),Q=C.ie(),B=C.it(),g=C.ai(),I=C.id(),w=C.ss(),K=C.se();let D;C.ip()&&(D=k(E.slice(-1===I?A-1:A,-1===I?Q+1:Q))),o.push({n:D,t:B,s:A,e:Q,ss:w,se:K,d:I,a:g});}for(;C.re();){const A=C.es(),Q=C.ee(),B=C.els(),g=C.ele(),I=E.slice(A,Q),w=I[0],K=B<0?void 0:E.slice(B,g),o=K?K[0]:"";D.push({s:A,e:Q,ls:B,le:g,n:'"'===w||"'"===w?k(I):I,ln:'"'===o||"'"===o?k(K):K});}function k(A){try{return (0,eval)(A)}catch(A){}}return [o,D,!!C.f(),!!C.ms()]}function Q(A,Q){const B=A.length;let C=0;for(;C<B;){const B=A.charCodeAt(C);Q[C++]=(255&B)<<8|B>>>8;}}function B(A,Q){const B=A.length;let C=0;for(;C<B;)Q[C]=A.charCodeAt(C++);}let C;const E=()=>{return A="AGF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wB1AHIAYwBlAHIAbwBtAHUAbgBjAHQAaQBvAG4AcwBzAGUAcgB0AHYAbwB5AGkAZQBkAGUAbABlAGMAbwBuAHQAaQBuAGkAbgBzAHQAYQBuAHQAeQBiAHIAZQBhAHIAZQB0AHUAcgBkAGUAYgB1AGcAZwBlAGEAdwBhAGkAdABoAHIAdwBoAGkAbABlAGkAZgBjAGEAdABjAGYAaQBuAGEAbABsAGUAbABzAABB0AkLEAEAAAACAAAAAAQAAEA5AAA=","undefined"!=typeof Buffer?Buffer.from(A,"base64"):Uint8Array.from(atob(A),(A=>A.charCodeAt(0)));var A;};const init=WebAssembly.compile(E()).then(WebAssembly.instantiate).then((({exports:A})=>{C=A;}));
|
|
403
581
|
|
|
404
|
-
|
|
582
|
+
const _resolve = (id, parentUrl = baseUrl) => {
|
|
405
583
|
const urlResolved = resolveIfNotPlainOrUrl(id, parentUrl) || asURL(id);
|
|
406
584
|
const firstResolved = firstImportMap && resolveImportMap(firstImportMap, urlResolved || id, parentUrl);
|
|
407
585
|
const composedResolved =
|
|
@@ -424,97 +602,95 @@
|
|
|
424
602
|
if (firstResolved && resolved !== firstResolved) N = true;
|
|
425
603
|
}
|
|
426
604
|
return { r: resolved, n, N };
|
|
427
|
-
}
|
|
605
|
+
};
|
|
428
606
|
|
|
429
|
-
const resolve =
|
|
430
|
-
resolveHook
|
|
431
|
-
|
|
432
|
-
const result = resolveHook(id, parentUrl, defaultResolve);
|
|
433
|
-
return result ? { r: result, n: true, N: true } : _resolve(id, parentUrl);
|
|
434
|
-
}
|
|
435
|
-
: _resolve;
|
|
607
|
+
const resolve = (id, parentUrl) => {
|
|
608
|
+
if (!resolveHook) return _resolve(id, parentUrl);
|
|
609
|
+
const result = resolveHook(id, parentUrl, defaultResolve);
|
|
436
610
|
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
if (importHook) await importHook(id, opts, parentUrl);
|
|
440
|
-
if (shimMode || !baselinePassthrough) {
|
|
441
|
-
if (hasDocument) processScriptsAndPreloads();
|
|
442
|
-
legacyAcceptingImportMaps = false;
|
|
443
|
-
}
|
|
444
|
-
await importMapPromise;
|
|
445
|
-
return resolve(id, parentUrl).r;
|
|
446
|
-
}
|
|
611
|
+
return result ? { r: result, n: true, N: true } : _resolve(id, parentUrl);
|
|
612
|
+
};
|
|
447
613
|
|
|
448
614
|
// import()
|
|
449
|
-
async function importShim(id, opts, parentUrl) {
|
|
615
|
+
async function importShim$1(id, opts, parentUrl) {
|
|
450
616
|
if (typeof opts === 'string') {
|
|
451
617
|
parentUrl = opts;
|
|
452
618
|
opts = undefined;
|
|
453
619
|
}
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
620
|
+
await initPromise; // needed for shim check
|
|
621
|
+
if (shimMode || !baselinePassthrough) {
|
|
622
|
+
if (hasDocument) processScriptsAndPreloads();
|
|
623
|
+
legacyAcceptingImportMaps = false;
|
|
624
|
+
}
|
|
625
|
+
let sourceType = undefined;
|
|
459
626
|
if (typeof opts === 'object') {
|
|
460
|
-
|
|
627
|
+
if (opts.lang === 'ts') sourceType = 'ts';
|
|
461
628
|
if (typeof opts.with === 'object' && typeof opts.with.type === 'string') {
|
|
462
|
-
|
|
463
|
-
url += '?entry';
|
|
629
|
+
sourceType = opts.with.type;
|
|
464
630
|
}
|
|
465
631
|
}
|
|
466
|
-
return topLevelLoad(
|
|
632
|
+
return topLevelLoad(id, parentUrl || baseUrl, defaultFetchOpts, undefined, undefined, undefined, sourceType);
|
|
467
633
|
}
|
|
468
634
|
|
|
469
635
|
// import.source()
|
|
470
636
|
// (opts not currently supported as no use cases yet)
|
|
471
637
|
if (shimMode || wasmSourcePhaseEnabled)
|
|
472
|
-
importShim.source = async
|
|
638
|
+
importShim$1.source = async (id, opts, parentUrl) => {
|
|
473
639
|
if (typeof opts === 'string') {
|
|
474
640
|
parentUrl = opts;
|
|
475
641
|
opts = undefined;
|
|
476
642
|
}
|
|
477
|
-
|
|
478
|
-
|
|
643
|
+
await initPromise; // needed for shim check
|
|
644
|
+
if (shimMode || !baselinePassthrough) {
|
|
645
|
+
if (hasDocument) processScriptsAndPreloads();
|
|
646
|
+
legacyAcceptingImportMaps = false;
|
|
647
|
+
}
|
|
648
|
+
await importMapPromise;
|
|
649
|
+
const url = resolve(id, parentUrl || baseUrl).r;
|
|
650
|
+
const load = getOrCreateLoad(url, defaultFetchOpts, undefined, undefined);
|
|
479
651
|
if (firstPolyfillLoad && !shimMode && load.n && nativelyLoaded) {
|
|
480
652
|
onpolyfill();
|
|
481
653
|
firstPolyfillLoad = false;
|
|
482
654
|
}
|
|
483
655
|
await load.f;
|
|
484
|
-
return importShim._s[load.r];
|
|
656
|
+
return importShim$1._s[load.r];
|
|
485
657
|
};
|
|
486
658
|
|
|
487
659
|
// import.defer() is just a proxy for import(), since we can't actually defer
|
|
488
|
-
if (shimMode || deferPhaseEnabled) importShim.defer = importShim;
|
|
660
|
+
if (shimMode || deferPhaseEnabled) importShim$1.defer = importShim$1;
|
|
661
|
+
|
|
662
|
+
if (hotReload) importShim$1.hotReload = hotReload$1;
|
|
489
663
|
|
|
490
|
-
self.importShim = importShim;
|
|
664
|
+
self.importShim = importShim$1;
|
|
491
665
|
|
|
492
|
-
|
|
666
|
+
const defaultResolve = (id, parentUrl) => {
|
|
493
667
|
return (
|
|
494
668
|
resolveImportMap(composedImportMap, resolveIfNotPlainOrUrl(id, parentUrl) || id, parentUrl) ||
|
|
495
669
|
throwUnresolved(id, parentUrl)
|
|
496
670
|
);
|
|
497
|
-
}
|
|
671
|
+
};
|
|
498
672
|
|
|
499
|
-
|
|
673
|
+
const throwUnresolved = (id, parentUrl) => {
|
|
500
674
|
throw Error(`Unable to resolve specifier '${id}'${fromParent(parentUrl)}`);
|
|
501
|
-
}
|
|
675
|
+
};
|
|
502
676
|
|
|
503
|
-
function
|
|
677
|
+
const metaResolve = function (id, parentUrl = this.url) {
|
|
504
678
|
return resolve(id, `${parentUrl}`).r;
|
|
505
|
-
}
|
|
679
|
+
};
|
|
506
680
|
|
|
507
|
-
importShim.resolve = (id, parentUrl) => resolve(id, parentUrl).r;
|
|
508
|
-
importShim.getImportMap = () => JSON.parse(JSON.stringify(composedImportMap));
|
|
509
|
-
importShim.addImportMap = importMapIn => {
|
|
681
|
+
importShim$1.resolve = (id, parentUrl) => resolve(id, parentUrl).r;
|
|
682
|
+
importShim$1.getImportMap = () => JSON.parse(JSON.stringify(composedImportMap));
|
|
683
|
+
importShim$1.addImportMap = importMapIn => {
|
|
510
684
|
if (!shimMode) throw new Error('Unsupported in polyfill mode.');
|
|
511
685
|
composedImportMap = resolveAndComposeImportMap(importMapIn, baseUrl, composedImportMap);
|
|
512
686
|
};
|
|
513
687
|
|
|
514
|
-
const registry = (importShim._r = {});
|
|
515
|
-
|
|
688
|
+
const registry = (importShim$1._r = {});
|
|
689
|
+
// Wasm caches
|
|
690
|
+
const sourceCache = (importShim$1._s = {});
|
|
691
|
+
(importShim$1._i = new WeakMap());
|
|
516
692
|
|
|
517
|
-
async
|
|
693
|
+
const loadAll = async (load, seen) => {
|
|
518
694
|
seen[load.u] = 1;
|
|
519
695
|
await load.L;
|
|
520
696
|
await Promise.all(
|
|
@@ -524,7 +700,7 @@
|
|
|
524
700
|
return loadAll(dep, seen);
|
|
525
701
|
})
|
|
526
702
|
);
|
|
527
|
-
}
|
|
703
|
+
};
|
|
528
704
|
|
|
529
705
|
let importMapSrc = false;
|
|
530
706
|
let multipleImportMaps = false;
|
|
@@ -544,35 +720,32 @@
|
|
|
544
720
|
!deferPhaseEnabled &&
|
|
545
721
|
(!multipleImportMaps || supportsMultipleImportMaps) &&
|
|
546
722
|
!importMapSrc;
|
|
547
|
-
if (
|
|
548
|
-
!
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
get [Symbol.toStringTag]() {
|
|
558
|
-
if (this[s]) return this[s];
|
|
559
|
-
throw new TypeError('Not an AbstractModuleSource');
|
|
723
|
+
if (!shimMode && typeof WebAssembly !== 'undefined') {
|
|
724
|
+
if (wasmSourcePhaseEnabled && !Object.getPrototypeOf(WebAssembly.Module).name) {
|
|
725
|
+
const s = Symbol();
|
|
726
|
+
const brand = m =>
|
|
727
|
+
Object.defineProperty(m, s, { writable: false, configurable: false, value: 'WebAssembly.Module' });
|
|
728
|
+
class AbstractModuleSource {
|
|
729
|
+
get [Symbol.toStringTag]() {
|
|
730
|
+
if (this[s]) return this[s];
|
|
731
|
+
throw new TypeError('Not an AbstractModuleSource');
|
|
732
|
+
}
|
|
560
733
|
}
|
|
734
|
+
const { Module: wasmModule, compile: wasmCompile, compileStreaming: wasmCompileStreaming } = WebAssembly;
|
|
735
|
+
WebAssembly.Module = Object.setPrototypeOf(
|
|
736
|
+
Object.assign(function Module(...args) {
|
|
737
|
+
return brand(new wasmModule(...args));
|
|
738
|
+
}, wasmModule),
|
|
739
|
+
AbstractModuleSource
|
|
740
|
+
);
|
|
741
|
+
WebAssembly.Module.prototype = Object.setPrototypeOf(wasmModule.prototype, AbstractModuleSource.prototype);
|
|
742
|
+
WebAssembly.compile = function compile(...args) {
|
|
743
|
+
return wasmCompile(...args).then(brand);
|
|
744
|
+
};
|
|
745
|
+
WebAssembly.compileStreaming = function compileStreaming(...args) {
|
|
746
|
+
return wasmCompileStreaming(...args).then(brand);
|
|
747
|
+
};
|
|
561
748
|
}
|
|
562
|
-
const { Module: wasmModule, compile: wasmCompile, compileStreaming: wasmCompileStreaming } = WebAssembly;
|
|
563
|
-
WebAssembly.Module = Object.setPrototypeOf(
|
|
564
|
-
Object.assign(function Module(...args) {
|
|
565
|
-
return brand(new wasmModule(...args));
|
|
566
|
-
}, wasmModule),
|
|
567
|
-
AbstractModuleSource
|
|
568
|
-
);
|
|
569
|
-
WebAssembly.Module.prototype = Object.setPrototypeOf(wasmModule.prototype, AbstractModuleSource.prototype);
|
|
570
|
-
WebAssembly.compile = function compile(...args) {
|
|
571
|
-
return wasmCompile(...args).then(brand);
|
|
572
|
-
};
|
|
573
|
-
WebAssembly.compileStreaming = function compileStreaming(...args) {
|
|
574
|
-
return wasmCompileStreaming(...args).then(brand);
|
|
575
|
-
};
|
|
576
749
|
}
|
|
577
750
|
if (hasDocument) {
|
|
578
751
|
if (!supportsImportMaps) {
|
|
@@ -584,14 +757,6 @@
|
|
|
584
757
|
if (document.readyState === 'complete') {
|
|
585
758
|
readyStateCompleteCheck();
|
|
586
759
|
} else {
|
|
587
|
-
async function readyListener() {
|
|
588
|
-
await initPromise;
|
|
589
|
-
processScriptsAndPreloads();
|
|
590
|
-
if (document.readyState === 'complete') {
|
|
591
|
-
readyStateCompleteCheck();
|
|
592
|
-
document.removeEventListener('readystatechange', readyListener);
|
|
593
|
-
}
|
|
594
|
-
}
|
|
595
760
|
document.addEventListener('readystatechange', readyListener);
|
|
596
761
|
}
|
|
597
762
|
}
|
|
@@ -600,7 +765,7 @@
|
|
|
600
765
|
return init;
|
|
601
766
|
});
|
|
602
767
|
|
|
603
|
-
|
|
768
|
+
const attachMutationObserver = () => {
|
|
604
769
|
const observer = new MutationObserver(mutations => {
|
|
605
770
|
for (const mutation of mutations) {
|
|
606
771
|
if (mutation.type !== 'childList') continue;
|
|
@@ -621,18 +786,35 @@
|
|
|
621
786
|
observer.observe(document, { childList: true });
|
|
622
787
|
observer.observe(document.head, { childList: true });
|
|
623
788
|
processScriptsAndPreloads();
|
|
624
|
-
}
|
|
789
|
+
};
|
|
625
790
|
|
|
626
791
|
let importMapPromise = initPromise;
|
|
627
792
|
let firstPolyfillLoad = true;
|
|
628
793
|
let legacyAcceptingImportMaps = true;
|
|
629
794
|
|
|
630
|
-
|
|
795
|
+
const topLevelLoad = async (
|
|
796
|
+
url,
|
|
797
|
+
parentUrl,
|
|
798
|
+
fetchOpts,
|
|
799
|
+
source,
|
|
800
|
+
nativelyLoaded,
|
|
801
|
+
lastStaticLoadPromise,
|
|
802
|
+
sourceType
|
|
803
|
+
) => {
|
|
631
804
|
await initPromise;
|
|
632
805
|
await importMapPromise;
|
|
633
|
-
|
|
806
|
+
url = (await resolve(url, parentUrl)).r;
|
|
807
|
+
|
|
808
|
+
// we mock import('./x.css', { with: { type: 'css' }}) support via an inline static reexport
|
|
809
|
+
// because we can't syntactically pass through to dynamic import with a second argument
|
|
810
|
+
if (sourceType === 'css' || sourceType === 'json') {
|
|
811
|
+
source = `export{default}from'${url}'with{type:"${sourceType}"}`;
|
|
812
|
+
url += '?entry';
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
if (importHook) await importHook(url, typeof fetchOpts !== 'string' ? fetchOpts : {}, parentUrl, source, sourceType);
|
|
634
816
|
// early analysis opt-out - no need to even fetch if we have feature support
|
|
635
|
-
if (!shimMode && baselinePassthrough &&
|
|
817
|
+
if (!shimMode && baselinePassthrough && nativePassthrough && sourceType !== 'ts') {
|
|
636
818
|
// for polyfill case, only dynamic import needs a return value here, and dynamic import will never pass nativelyLoaded
|
|
637
819
|
if (nativelyLoaded) return null;
|
|
638
820
|
await lastStaticLoadPromise;
|
|
@@ -656,37 +838,55 @@
|
|
|
656
838
|
onpolyfill();
|
|
657
839
|
firstPolyfillLoad = false;
|
|
658
840
|
}
|
|
659
|
-
const module = await (shimMode || load.n || load.N || (!nativelyLoaded && source) ?
|
|
841
|
+
const module = await (shimMode || load.n || load.N || !nativePassthrough || (!nativelyLoaded && source) ?
|
|
660
842
|
dynamicImport(load.b, load.u)
|
|
661
843
|
: import(load.u));
|
|
662
844
|
// if the top-level load is a shell, run its update function
|
|
663
845
|
if (load.s) (await dynamicImport(load.s, load.u)).u$_(module);
|
|
664
846
|
if (revokeBlobURLs) revokeObjectURLs(Object.keys(seen));
|
|
665
847
|
return module;
|
|
666
|
-
}
|
|
848
|
+
};
|
|
667
849
|
|
|
668
|
-
|
|
669
|
-
let
|
|
670
|
-
const
|
|
671
|
-
|
|
672
|
-
schedule(cleanup);
|
|
850
|
+
const revokeObjectURLs = registryKeys => {
|
|
851
|
+
let curIdx = 0;
|
|
852
|
+
const handler = self.requestIdleCallback || self.requestAnimationFrame;
|
|
853
|
+
handler(cleanup);
|
|
673
854
|
function cleanup() {
|
|
674
|
-
const
|
|
675
|
-
if (batchStartIndex > keysLength) return;
|
|
676
|
-
for (const key of registryKeys.slice(batchStartIndex, batchStartIndex + 100)) {
|
|
855
|
+
for (const key of registryKeys.slice(curIdx, (curIdx += 100))) {
|
|
677
856
|
const load = registry[key];
|
|
678
857
|
if (load && load.b && load.b !== load.u) URL.revokeObjectURL(load.b);
|
|
679
858
|
}
|
|
680
|
-
|
|
681
|
-
schedule(cleanup);
|
|
859
|
+
if (curIdx < registryKeys.length) handler(cleanup);
|
|
682
860
|
}
|
|
683
|
-
}
|
|
861
|
+
};
|
|
684
862
|
|
|
685
|
-
|
|
686
|
-
return `'${url.replace(/'/g, "\\'")}'`;
|
|
687
|
-
}
|
|
863
|
+
const urlJsString = url => `'${url.replace(/'/g, "\\'")}'`;
|
|
688
864
|
|
|
689
|
-
|
|
865
|
+
let resolvedSource, lastIndex;
|
|
866
|
+
const pushStringTo = (load, originalIndex, dynamicImportEndStack) => {
|
|
867
|
+
while (dynamicImportEndStack[dynamicImportEndStack.length - 1] < originalIndex) {
|
|
868
|
+
const dynamicImportEnd = dynamicImportEndStack.pop();
|
|
869
|
+
resolvedSource += `${load.S.slice(lastIndex, dynamicImportEnd)}, ${urlJsString(load.r)}`;
|
|
870
|
+
lastIndex = dynamicImportEnd;
|
|
871
|
+
}
|
|
872
|
+
resolvedSource += load.S.slice(lastIndex, originalIndex);
|
|
873
|
+
lastIndex = originalIndex;
|
|
874
|
+
};
|
|
875
|
+
|
|
876
|
+
const pushSourceURL = (load, commentPrefix, commentStart, dynamicImportEndStack) => {
|
|
877
|
+
const urlStart = commentStart + commentPrefix.length;
|
|
878
|
+
const commentEnd = load.S.indexOf('\n', urlStart);
|
|
879
|
+
const urlEnd = commentEnd !== -1 ? commentEnd : load.S.length;
|
|
880
|
+
let sourceUrl = load.S.slice(urlStart, urlEnd);
|
|
881
|
+
try {
|
|
882
|
+
sourceUrl = new URL(sourceUrl, load.r).href;
|
|
883
|
+
} catch {}
|
|
884
|
+
pushStringTo(load, urlStart, dynamicImportEndStack);
|
|
885
|
+
resolvedSource += sourceUrl;
|
|
886
|
+
lastIndex = urlEnd;
|
|
887
|
+
};
|
|
888
|
+
|
|
889
|
+
const resolveDeps = (load, seen) => {
|
|
690
890
|
if (load.b || !seen[load.u]) return;
|
|
691
891
|
seen[load.u] = 0;
|
|
692
892
|
|
|
@@ -699,7 +899,7 @@
|
|
|
699
899
|
|
|
700
900
|
// use native loader whenever possible (n = needs shim) via executable subgraph passthrough
|
|
701
901
|
// so long as the module doesn't use dynamic import or unsupported URL mappings (N = should shim)
|
|
702
|
-
if (!shimMode && !load.n && !load.N) {
|
|
902
|
+
if (nativePassthrough && !shimMode && !load.n && !load.N) {
|
|
703
903
|
load.b = load.u;
|
|
704
904
|
load.S = undefined;
|
|
705
905
|
return;
|
|
@@ -708,30 +908,19 @@
|
|
|
708
908
|
const [imports, exports] = load.a;
|
|
709
909
|
|
|
710
910
|
// "execution"
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
911
|
+
let source = load.S,
|
|
912
|
+
depIndex = 0,
|
|
913
|
+
dynamicImportEndStack = [];
|
|
714
914
|
|
|
715
915
|
// once all deps have loaded we can inline the dependency resolution blobs
|
|
716
916
|
// and define this blob
|
|
717
|
-
|
|
718
|
-
depIndex = 0,
|
|
719
|
-
dynamicImportEndStack = [];
|
|
720
|
-
function pushStringTo(originalIndex) {
|
|
721
|
-
while (dynamicImportEndStack[dynamicImportEndStack.length - 1] < originalIndex) {
|
|
722
|
-
const dynamicImportEnd = dynamicImportEndStack.pop();
|
|
723
|
-
resolvedSource += `${source.slice(lastIndex, dynamicImportEnd)}, ${urlJsString(load.r)}`;
|
|
724
|
-
lastIndex = dynamicImportEnd;
|
|
725
|
-
}
|
|
726
|
-
resolvedSource += source.slice(lastIndex, originalIndex);
|
|
727
|
-
lastIndex = originalIndex;
|
|
728
|
-
}
|
|
917
|
+
(resolvedSource = ''), (lastIndex = 0);
|
|
729
918
|
|
|
730
919
|
for (const { s: start, e: end, ss: statementStart, se: statementEnd, d: dynamicImportIndex, t, a } of imports) {
|
|
731
920
|
// source phase
|
|
732
921
|
if (t === 4) {
|
|
733
922
|
let { l: depLoad } = load.d[depIndex++];
|
|
734
|
-
pushStringTo(statementStart);
|
|
923
|
+
pushStringTo(load, statementStart, dynamicImportEndStack);
|
|
735
924
|
resolvedSource += `${source.slice(statementStart, start - 1).replace('source', '')}/*${source.slice(start - 1, end + 1)}*/'${createBlob(`export default importShim._s[${urlJsString(depLoad.r)}]`)}'`;
|
|
736
925
|
lastIndex = end + 1;
|
|
737
926
|
}
|
|
@@ -742,12 +931,13 @@
|
|
|
742
931
|
const assertion = source.slice(a, statementEnd - 1);
|
|
743
932
|
// strip assertions only when unsupported in polyfill mode
|
|
744
933
|
keepAssertion =
|
|
745
|
-
|
|
934
|
+
nativePassthrough &&
|
|
935
|
+
((supportsJsonType && assertion.includes('json')) || (supportsCssType && assertion.includes('css')));
|
|
746
936
|
}
|
|
747
937
|
|
|
748
938
|
// defer phase stripping
|
|
749
939
|
if (t === 6) {
|
|
750
|
-
pushStringTo(statementStart);
|
|
940
|
+
pushStringTo(load, statementStart, dynamicImportEndStack);
|
|
751
941
|
resolvedSource += source.slice(statementStart, start - 1).replace('defer', '');
|
|
752
942
|
lastIndex = start;
|
|
753
943
|
}
|
|
@@ -772,7 +962,7 @@
|
|
|
772
962
|
}
|
|
773
963
|
}
|
|
774
964
|
|
|
775
|
-
pushStringTo(start - 1);
|
|
965
|
+
pushStringTo(load, start - 1, dynamicImportEndStack);
|
|
776
966
|
resolvedSource += `/*${source.slice(start - 1, end + 1)}*/'${blobUrl}'`;
|
|
777
967
|
|
|
778
968
|
// circular shell execution
|
|
@@ -785,14 +975,14 @@
|
|
|
785
975
|
// import.meta
|
|
786
976
|
else if (dynamicImportIndex === -2) {
|
|
787
977
|
load.m = { url: load.r, resolve: metaResolve };
|
|
788
|
-
metaHook(load.m, load.u);
|
|
789
|
-
pushStringTo(start);
|
|
978
|
+
if (metaHook) metaHook(load.m, load.u);
|
|
979
|
+
pushStringTo(load, start, dynamicImportEndStack);
|
|
790
980
|
resolvedSource += `importShim._r[${urlJsString(load.u)}].m`;
|
|
791
981
|
lastIndex = statementEnd;
|
|
792
982
|
}
|
|
793
983
|
// dynamic import
|
|
794
984
|
else {
|
|
795
|
-
pushStringTo(statementStart + 6);
|
|
985
|
+
pushStringTo(load, statementStart + 6, dynamicImportEndStack);
|
|
796
986
|
resolvedSource += `Shim${t === 5 ? '.source' : ''}(`;
|
|
797
987
|
dynamicImportEndStack.push(statementEnd - 1);
|
|
798
988
|
lastIndex = start;
|
|
@@ -806,19 +996,6 @@
|
|
|
806
996
|
.map(({ s, e, ln }) => `${source.slice(s, e)}:${ln}`)
|
|
807
997
|
.join(',')}})}catch(_){};\n`;
|
|
808
998
|
|
|
809
|
-
function pushSourceURL(commentPrefix, commentStart) {
|
|
810
|
-
const urlStart = commentStart + commentPrefix.length;
|
|
811
|
-
const commentEnd = source.indexOf('\n', urlStart);
|
|
812
|
-
const urlEnd = commentEnd !== -1 ? commentEnd : source.length;
|
|
813
|
-
let sourceUrl = source.slice(urlStart, urlEnd);
|
|
814
|
-
try {
|
|
815
|
-
sourceUrl = new URL(sourceUrl, load.r).href;
|
|
816
|
-
} catch {}
|
|
817
|
-
pushStringTo(urlStart);
|
|
818
|
-
resolvedSource += sourceUrl;
|
|
819
|
-
lastIndex = urlEnd;
|
|
820
|
-
}
|
|
821
|
-
|
|
822
999
|
let sourceURLCommentStart = source.lastIndexOf(sourceURLCommentPrefix);
|
|
823
1000
|
let sourceMapURLCommentStart = source.lastIndexOf(sourceMapURLCommentPrefix);
|
|
824
1001
|
|
|
@@ -831,23 +1008,23 @@
|
|
|
831
1008
|
sourceURLCommentStart !== -1 &&
|
|
832
1009
|
(sourceMapURLCommentStart === -1 || sourceMapURLCommentStart > sourceURLCommentStart)
|
|
833
1010
|
) {
|
|
834
|
-
pushSourceURL(sourceURLCommentPrefix, sourceURLCommentStart);
|
|
1011
|
+
pushSourceURL(load, sourceURLCommentPrefix, sourceURLCommentStart, dynamicImportEndStack);
|
|
835
1012
|
}
|
|
836
1013
|
// sourceMappingURL
|
|
837
1014
|
if (sourceMapURLCommentStart !== -1) {
|
|
838
|
-
pushSourceURL(sourceMapURLCommentPrefix, sourceMapURLCommentStart);
|
|
1015
|
+
pushSourceURL(load, sourceMapURLCommentPrefix, sourceMapURLCommentStart, dynamicImportEndStack);
|
|
839
1016
|
// sourceURL last
|
|
840
1017
|
if (sourceURLCommentStart !== -1 && sourceURLCommentStart > sourceMapURLCommentStart)
|
|
841
|
-
pushSourceURL(sourceURLCommentPrefix, sourceURLCommentStart);
|
|
1018
|
+
pushSourceURL(load, sourceURLCommentPrefix, sourceURLCommentStart, dynamicImportEndStack);
|
|
842
1019
|
}
|
|
843
1020
|
|
|
844
|
-
pushStringTo(source.length);
|
|
1021
|
+
pushStringTo(load, source.length, dynamicImportEndStack);
|
|
845
1022
|
|
|
846
1023
|
if (sourceURLCommentStart === -1) resolvedSource += sourceURLCommentPrefix + load.r;
|
|
847
1024
|
|
|
848
1025
|
load.b = createBlob(resolvedSource);
|
|
849
|
-
load.S = undefined;
|
|
850
|
-
}
|
|
1026
|
+
load.S = resolvedSource = undefined;
|
|
1027
|
+
};
|
|
851
1028
|
|
|
852
1029
|
const sourceURLCommentPrefix = '\n//# sourceURL=';
|
|
853
1030
|
const sourceMapURLCommentPrefix = '\n//# sourceMappingURL=';
|
|
@@ -863,15 +1040,15 @@
|
|
|
863
1040
|
// restrict in-flight fetches to a pool of 100
|
|
864
1041
|
let p = [];
|
|
865
1042
|
let c = 0;
|
|
866
|
-
|
|
1043
|
+
const pushFetchPool = () => {
|
|
867
1044
|
if (++c > 100) return new Promise(r => p.push(r));
|
|
868
|
-
}
|
|
869
|
-
|
|
1045
|
+
};
|
|
1046
|
+
const popFetchPool = () => {
|
|
870
1047
|
c--;
|
|
871
1048
|
if (p.length) p.shift()();
|
|
872
|
-
}
|
|
1049
|
+
};
|
|
873
1050
|
|
|
874
|
-
async
|
|
1051
|
+
const doFetch = async (url, fetchOpts, parent) => {
|
|
875
1052
|
if (enforceIntegrity && !fetchOpts.integrity) throw Error(`No integrity for ${url}${fromParent(parent)}.`);
|
|
876
1053
|
const poolQueue = pushFetchPool();
|
|
877
1054
|
if (poolQueue) await poolQueue;
|
|
@@ -890,15 +1067,16 @@
|
|
|
890
1067
|
throw error;
|
|
891
1068
|
}
|
|
892
1069
|
return res;
|
|
893
|
-
}
|
|
1070
|
+
};
|
|
894
1071
|
|
|
895
1072
|
let esmsTsTransform;
|
|
896
|
-
async
|
|
1073
|
+
const initTs = async () => {
|
|
897
1074
|
const m = await import(tsTransform);
|
|
898
1075
|
if (!esmsTsTransform) esmsTsTransform = m.transform;
|
|
899
|
-
}
|
|
1076
|
+
};
|
|
900
1077
|
|
|
901
|
-
|
|
1078
|
+
const hotPrefix = 'var h=import.meta.hot,';
|
|
1079
|
+
const fetchModule = async (url, fetchOpts, parent) => {
|
|
902
1080
|
const mapIntegrity = composedImportMap.integrity[url];
|
|
903
1081
|
const res = await doFetch(
|
|
904
1082
|
url,
|
|
@@ -909,32 +1087,38 @@
|
|
|
909
1087
|
const contentType = res.headers.get('content-type');
|
|
910
1088
|
if (jsContentType.test(contentType)) return { r, s: await res.text(), t: 'js' };
|
|
911
1089
|
else if (wasmContentType.test(contentType)) {
|
|
912
|
-
const
|
|
913
|
-
|
|
914
|
-
|
|
1090
|
+
const wasmModule = await (sourceCache[r] || (sourceCache[r] = WebAssembly.compileStreaming(res)));
|
|
1091
|
+
const exports = WebAssembly.Module.exports(wasmModule);
|
|
1092
|
+
sourceCache[r] = wasmModule;
|
|
1093
|
+
const rStr = urlJsString(r);
|
|
1094
|
+
let s = `import*as $_ns from${rStr};`,
|
|
915
1095
|
i = 0,
|
|
916
|
-
|
|
917
|
-
for (const
|
|
918
|
-
const specifier = urlJsString(
|
|
919
|
-
s += `import
|
|
920
|
-
|
|
1096
|
+
obj = '';
|
|
1097
|
+
for (const { module, kind } of WebAssembly.Module.imports(wasmModule)) {
|
|
1098
|
+
const specifier = urlJsString(module);
|
|
1099
|
+
s += `import*as impt${i} from${specifier};\n`;
|
|
1100
|
+
obj += `${specifier}:${kind === 'global' ? `importShim._i.get(impt${i})||impt${i++}` : `impt${i++}`},`;
|
|
921
1101
|
}
|
|
922
|
-
i
|
|
923
|
-
|
|
924
|
-
for (const
|
|
925
|
-
s += `export
|
|
1102
|
+
s += `${hotPrefix}i=await WebAssembly.instantiate(importShim._s[${rStr}],{${obj}});importShim._i.set($_ns,i);`;
|
|
1103
|
+
obj = '';
|
|
1104
|
+
for (const { name, kind } of exports) {
|
|
1105
|
+
s += `export let ${name}=i.exports['${name}'];`;
|
|
1106
|
+
if (kind === 'global') s += `try{${name}=${name}.value}catch{${name}=undefined}`;
|
|
1107
|
+
obj += `${name},`;
|
|
926
1108
|
}
|
|
1109
|
+
s += `if(h)h.accept(m=>({${obj}}=m))`;
|
|
927
1110
|
return { r, s, t: 'wasm' };
|
|
928
|
-
} else if (jsonContentType.test(contentType))
|
|
1111
|
+
} else if (jsonContentType.test(contentType))
|
|
1112
|
+
return { r, s: `${hotPrefix}j=${await res.text()};export{j as default};if(h)h.accept(m=>j=m.default)`, t: 'json' };
|
|
929
1113
|
else if (cssContentType.test(contentType)) {
|
|
930
1114
|
return {
|
|
931
1115
|
r,
|
|
932
|
-
s:
|
|
1116
|
+
s: `${hotPrefix}s=h&&h.data.s||new CSSStyleSheet();s.replaceSync(${JSON.stringify(
|
|
933
1117
|
(await res.text()).replace(
|
|
934
1118
|
cssUrlRegEx,
|
|
935
1119
|
(_match, quotes = '', relUrl1, relUrl2) => `url(${quotes}${resolveUrl(relUrl1 || relUrl2, url)}${quotes})`
|
|
936
1120
|
)
|
|
937
|
-
)});export default s
|
|
1121
|
+
)});if(h){h.data.s=s;h.accept(()=>{})}export default s`,
|
|
938
1122
|
t: 'css'
|
|
939
1123
|
};
|
|
940
1124
|
} else if (tsContentType.test(contentType) || url.endsWith('.ts') || url.endsWith('.mts')) {
|
|
@@ -948,9 +1132,9 @@
|
|
|
948
1132
|
throw Error(
|
|
949
1133
|
`Unsupported Content-Type "${contentType}" loading ${url}${fromParent(parent)}. Modules must be served with a valid MIME type like application/javascript.`
|
|
950
1134
|
);
|
|
951
|
-
}
|
|
1135
|
+
};
|
|
952
1136
|
|
|
953
|
-
|
|
1137
|
+
const isUnsupportedType = type => {
|
|
954
1138
|
if (type === 'wasm' && !wasmInstancePhaseEnabled && !wasmSourcePhaseEnabled) throw featErr(`wasm-modules`);
|
|
955
1139
|
return (
|
|
956
1140
|
(type === 'css' && !supportsCssType) ||
|
|
@@ -958,13 +1142,13 @@
|
|
|
958
1142
|
(type === 'wasm' && !supportsWasmInstancePhase && !supportsWasmSourcePhase) ||
|
|
959
1143
|
type === 'ts'
|
|
960
1144
|
);
|
|
961
|
-
}
|
|
1145
|
+
};
|
|
962
1146
|
|
|
963
|
-
|
|
1147
|
+
const getOrCreateLoad = (url, fetchOpts, parent, source) => {
|
|
964
1148
|
if (source && registry[url]) {
|
|
965
1149
|
let i = 0;
|
|
966
|
-
while (registry[url + ++i]);
|
|
967
|
-
url += i;
|
|
1150
|
+
while (registry[url + '#' + ++i]);
|
|
1151
|
+
url += '#' + i;
|
|
968
1152
|
}
|
|
969
1153
|
let load = registry[url];
|
|
970
1154
|
if (load) return load;
|
|
@@ -1013,14 +1197,14 @@
|
|
|
1013
1197
|
return load;
|
|
1014
1198
|
})();
|
|
1015
1199
|
return load;
|
|
1016
|
-
}
|
|
1200
|
+
};
|
|
1017
1201
|
|
|
1018
1202
|
const featErr = feat =>
|
|
1019
1203
|
Error(
|
|
1020
1204
|
`${feat} feature must be enabled via <script type="esms-options">{ "polyfillEnable": ["${feat}"] }<${''}/script>`
|
|
1021
1205
|
);
|
|
1022
1206
|
|
|
1023
|
-
|
|
1207
|
+
const linkLoad = (load, fetchOpts) => {
|
|
1024
1208
|
if (load.L) return;
|
|
1025
1209
|
load.L = load.f.then(async () => {
|
|
1026
1210
|
let childFetchOpts = fetchOpts;
|
|
@@ -1034,7 +1218,7 @@
|
|
|
1034
1218
|
if (!sourcePhase || !supportsWasmSourcePhase) load.n = true;
|
|
1035
1219
|
}
|
|
1036
1220
|
let source = undefined;
|
|
1037
|
-
if (a > 0 && !shimMode) {
|
|
1221
|
+
if (a > 0 && !shimMode && nativePassthrough) {
|
|
1038
1222
|
const assertion = load.S.slice(a, se - 1);
|
|
1039
1223
|
// no need to fetch JSON/CSS if supported, since it's a leaf node, we'll just strip the assertion syntax
|
|
1040
1224
|
if (assertion.includes('json')) {
|
|
@@ -1061,9 +1245,9 @@
|
|
|
1061
1245
|
})
|
|
1062
1246
|
.filter(l => l);
|
|
1063
1247
|
});
|
|
1064
|
-
}
|
|
1248
|
+
};
|
|
1065
1249
|
|
|
1066
|
-
|
|
1250
|
+
const processScriptsAndPreloads = () => {
|
|
1067
1251
|
for (const link of document.querySelectorAll(shimMode ? 'link[rel=modulepreload-shim]' : 'link[rel=modulepreload]')) {
|
|
1068
1252
|
if (!link.ep) processPreload(link);
|
|
1069
1253
|
}
|
|
@@ -1075,9 +1259,9 @@
|
|
|
1075
1259
|
if (!script.ep) processScript(script);
|
|
1076
1260
|
}
|
|
1077
1261
|
}
|
|
1078
|
-
}
|
|
1262
|
+
};
|
|
1079
1263
|
|
|
1080
|
-
|
|
1264
|
+
const getFetchOpts = script => {
|
|
1081
1265
|
const fetchOpts = {};
|
|
1082
1266
|
if (script.integrity) fetchOpts.integrity = script.integrity;
|
|
1083
1267
|
if (script.referrerPolicy) fetchOpts.referrerPolicy = script.referrerPolicy;
|
|
@@ -1086,40 +1270,65 @@
|
|
|
1086
1270
|
else if (script.crossOrigin === 'anonymous') fetchOpts.credentials = 'omit';
|
|
1087
1271
|
else fetchOpts.credentials = 'same-origin';
|
|
1088
1272
|
return fetchOpts;
|
|
1089
|
-
}
|
|
1273
|
+
};
|
|
1090
1274
|
|
|
1091
1275
|
let lastStaticLoadPromise = Promise.resolve();
|
|
1092
1276
|
|
|
1277
|
+
let domContentLoaded = false;
|
|
1093
1278
|
let domContentLoadedCnt = 1;
|
|
1094
|
-
|
|
1279
|
+
const domContentLoadedCheck = m => {
|
|
1280
|
+
if (m === undefined) {
|
|
1281
|
+
if (domContentLoaded) return;
|
|
1282
|
+
domContentLoaded = true;
|
|
1283
|
+
domContentLoadedCnt--;
|
|
1284
|
+
}
|
|
1095
1285
|
if (--domContentLoadedCnt === 0 && !noLoadEventRetriggers && (shimMode || !baselinePassthrough)) {
|
|
1286
|
+
document.removeEventListener('DOMContentLoaded', domContentLoadedEvent);
|
|
1096
1287
|
document.dispatchEvent(new Event('DOMContentLoaded'));
|
|
1097
1288
|
}
|
|
1098
|
-
}
|
|
1289
|
+
};
|
|
1099
1290
|
let loadCnt = 1;
|
|
1100
|
-
|
|
1291
|
+
const loadCheck = () => {
|
|
1101
1292
|
if (--loadCnt === 0 && !noLoadEventRetriggers && (shimMode || !baselinePassthrough)) {
|
|
1293
|
+
window.removeEventListener('load', loadEvent);
|
|
1102
1294
|
window.dispatchEvent(new Event('load'));
|
|
1103
1295
|
}
|
|
1104
|
-
}
|
|
1296
|
+
};
|
|
1297
|
+
|
|
1298
|
+
const domContentLoadedEvent = async () => {
|
|
1299
|
+
await initPromise;
|
|
1300
|
+
domContentLoadedCheck();
|
|
1301
|
+
};
|
|
1302
|
+
const loadEvent = async () => {
|
|
1303
|
+
await initPromise;
|
|
1304
|
+
domContentLoadedCheck();
|
|
1305
|
+
loadCheck();
|
|
1306
|
+
};
|
|
1307
|
+
|
|
1105
1308
|
// this should always trigger because we assume es-module-shims is itself a domcontentloaded requirement
|
|
1106
1309
|
if (hasDocument) {
|
|
1107
|
-
document.addEventListener('DOMContentLoaded',
|
|
1108
|
-
|
|
1109
|
-
domContentLoadedCheck();
|
|
1110
|
-
});
|
|
1111
|
-
window.addEventListener('load', async () => {
|
|
1112
|
-
await initPromise;
|
|
1113
|
-
loadCheck();
|
|
1114
|
-
});
|
|
1310
|
+
document.addEventListener('DOMContentLoaded', domContentLoadedEvent);
|
|
1311
|
+
window.addEventListener('load', loadEvent);
|
|
1115
1312
|
}
|
|
1116
1313
|
|
|
1314
|
+
const readyListener = async () => {
|
|
1315
|
+
await initPromise;
|
|
1316
|
+
processScriptsAndPreloads();
|
|
1317
|
+
if (document.readyState === 'complete') {
|
|
1318
|
+
readyStateCompleteCheck();
|
|
1319
|
+
}
|
|
1320
|
+
};
|
|
1321
|
+
|
|
1117
1322
|
let readyStateCompleteCnt = 1;
|
|
1118
|
-
|
|
1119
|
-
if (--readyStateCompleteCnt === 0
|
|
1120
|
-
|
|
1323
|
+
const readyStateCompleteCheck = () => {
|
|
1324
|
+
if (--readyStateCompleteCnt === 0) {
|
|
1325
|
+
domContentLoadedCheck();
|
|
1326
|
+
if (!noLoadEventRetriggers && (shimMode || !baselinePassthrough)) {
|
|
1327
|
+
document.removeEventListener('readystatechange', readyListener);
|
|
1328
|
+
document.dispatchEvent(new Event('readystatechange'));
|
|
1329
|
+
}
|
|
1121
1330
|
}
|
|
1122
|
-
}
|
|
1331
|
+
};
|
|
1123
1332
|
|
|
1124
1333
|
const hasNext = script => script.nextSibling || (script.parentNode && hasNext(script.parentNode));
|
|
1125
1334
|
const epCheck = (script, ready) =>
|
|
@@ -1128,7 +1337,7 @@
|
|
|
1128
1337
|
script.getAttribute('noshim') !== null ||
|
|
1129
1338
|
!(script.ep = true);
|
|
1130
1339
|
|
|
1131
|
-
|
|
1340
|
+
const processImportMap = (script, ready = readyStateCompleteCnt > 0) => {
|
|
1132
1341
|
if (epCheck(script, ready)) return;
|
|
1133
1342
|
// we dont currently support external import maps in polyfill mode to match native
|
|
1134
1343
|
if (script.src) {
|
|
@@ -1157,9 +1366,9 @@
|
|
|
1157
1366
|
}
|
|
1158
1367
|
}
|
|
1159
1368
|
legacyAcceptingImportMaps = false;
|
|
1160
|
-
}
|
|
1369
|
+
};
|
|
1161
1370
|
|
|
1162
|
-
|
|
1371
|
+
const processScript = (script, ready = readyStateCompleteCnt > 0) => {
|
|
1163
1372
|
if (epCheck(script, ready)) return;
|
|
1164
1373
|
// does this load block readystate complete
|
|
1165
1374
|
const isBlockingReadyScript = script.getAttribute('async') === null && readyStateCompleteCnt > 0;
|
|
@@ -1181,22 +1390,24 @@
|
|
|
1181
1390
|
}
|
|
1182
1391
|
return topLevelLoad(
|
|
1183
1392
|
script.src || baseUrl,
|
|
1393
|
+
baseUrl,
|
|
1184
1394
|
getFetchOpts(script),
|
|
1185
1395
|
transformed === undefined ? script.innerHTML : transformed,
|
|
1186
1396
|
!shimMode && transformed === undefined,
|
|
1187
1397
|
isBlockingReadyScript && lastStaticLoadPromise,
|
|
1188
|
-
|
|
1398
|
+
'ts'
|
|
1189
1399
|
);
|
|
1190
1400
|
})
|
|
1191
1401
|
.catch(throwError);
|
|
1192
1402
|
} else {
|
|
1193
1403
|
loadPromise = topLevelLoad(
|
|
1194
1404
|
script.src || baseUrl,
|
|
1405
|
+
baseUrl,
|
|
1195
1406
|
getFetchOpts(script),
|
|
1196
1407
|
!script.src ? script.innerHTML : undefined,
|
|
1197
1408
|
!shimMode,
|
|
1198
1409
|
isBlockingReadyScript && lastStaticLoadPromise,
|
|
1199
|
-
ts
|
|
1410
|
+
ts ? 'ts' : undefined
|
|
1200
1411
|
).catch(throwError);
|
|
1201
1412
|
}
|
|
1202
1413
|
if (!noLoadEventRetriggers) loadPromise.then(() => script.dispatchEvent(new Event('load')));
|
|
@@ -1205,13 +1416,19 @@
|
|
|
1205
1416
|
}
|
|
1206
1417
|
if (isDomContentLoadedScript) loadPromise.then(domContentLoadedCheck);
|
|
1207
1418
|
if (isLoadScript) loadPromise.then(loadCheck);
|
|
1208
|
-
}
|
|
1419
|
+
};
|
|
1209
1420
|
|
|
1210
1421
|
const fetchCache = {};
|
|
1211
|
-
|
|
1422
|
+
const processPreload = link => {
|
|
1212
1423
|
link.ep = true;
|
|
1213
1424
|
if (fetchCache[link.href]) return;
|
|
1214
1425
|
fetchCache[link.href] = fetchModule(link.href, getFetchOpts(link));
|
|
1215
|
-
}
|
|
1426
|
+
};
|
|
1427
|
+
|
|
1428
|
+
exports.topLevelLoad = topLevelLoad;
|
|
1429
|
+
|
|
1430
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
1431
|
+
|
|
1432
|
+
return exports;
|
|
1216
1433
|
|
|
1217
|
-
})();
|
|
1434
|
+
})({});
|