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