importmap-rails 1.0.2 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/MIT-LICENSE +1 -1
- data/README.md +47 -7
- data/app/assets/javascripts/es-module-shims.js +468 -337
- data/app/assets/javascripts/es-module-shims.js.map +1 -1
- data/app/assets/javascripts/es-module-shims.min.js +2 -2
- data/app/helpers/importmap/importmap_tags_helper.rb +11 -11
- data/lib/importmap/commands.rb +65 -1
- data/lib/importmap/engine.rb +7 -5
- data/lib/importmap/map.rb +19 -24
- data/lib/importmap/npm.rb +122 -0
- data/lib/importmap/packager.rb +2 -2
- data/lib/importmap/version.rb +1 -1
- metadata +4 -3
@@ -1,43 +1,121 @@
|
|
1
|
-
/* ES Module Shims 1.
|
1
|
+
/* ES Module Shims 1.7.2 */
|
2
2
|
(function () {
|
3
3
|
|
4
|
-
const
|
5
|
-
const
|
6
|
-
const safari = uaMatch && uaMatch[1] === 'Safari';
|
4
|
+
const hasWindow = typeof window !== 'undefined';
|
5
|
+
const hasDocument = typeof document !== 'undefined';
|
7
6
|
|
8
|
-
|
7
|
+
const noop = () => {};
|
8
|
+
|
9
|
+
const optionsScript = hasDocument ? document.querySelector('script[type=esms-options]') : undefined;
|
10
|
+
|
11
|
+
const esmsInitOptions = optionsScript ? JSON.parse(optionsScript.innerHTML) : {};
|
12
|
+
Object.assign(esmsInitOptions, self.esmsInitOptions || {});
|
13
|
+
|
14
|
+
let shimMode = hasDocument ? !!esmsInitOptions.shimMode : true;
|
15
|
+
|
16
|
+
const importHook = globalHook(shimMode && esmsInitOptions.onimport);
|
17
|
+
const resolveHook = globalHook(shimMode && esmsInitOptions.resolve);
|
18
|
+
let fetchHook = esmsInitOptions.fetch ? globalHook(esmsInitOptions.fetch) : fetch;
|
19
|
+
const metaHook = esmsInitOptions.meta ? globalHook(shimMode && esmsInitOptions.meta) : noop;
|
20
|
+
|
21
|
+
const mapOverrides = esmsInitOptions.mapOverrides;
|
9
22
|
|
10
|
-
|
11
|
-
|
23
|
+
let nonce = esmsInitOptions.nonce;
|
24
|
+
if (!nonce && hasDocument) {
|
25
|
+
const nonceElement = document.querySelector('script[nonce]');
|
26
|
+
if (nonceElement)
|
27
|
+
nonce = nonceElement.nonce || nonceElement.getAttribute('nonce');
|
12
28
|
}
|
13
29
|
|
14
|
-
const
|
30
|
+
const onerror = globalHook(esmsInitOptions.onerror || noop);
|
31
|
+
const onpolyfill = esmsInitOptions.onpolyfill ? globalHook(esmsInitOptions.onpolyfill) : () => {
|
32
|
+
console.log('%c^^ Module TypeError above is polyfilled and can be ignored ^^', 'font-weight:900;color:#391');
|
33
|
+
};
|
34
|
+
|
35
|
+
const { revokeBlobURLs, noLoadEventRetriggers, enforceIntegrity } = esmsInitOptions;
|
36
|
+
|
37
|
+
function globalHook (name) {
|
38
|
+
return typeof name === 'string' ? self[name] : name;
|
39
|
+
}
|
40
|
+
|
41
|
+
const enable = Array.isArray(esmsInitOptions.polyfillEnable) ? esmsInitOptions.polyfillEnable : [];
|
42
|
+
const cssModulesEnabled = enable.includes('css-modules');
|
43
|
+
const jsonModulesEnabled = enable.includes('json-modules');
|
44
|
+
|
45
|
+
const edge = !navigator.userAgentData && !!navigator.userAgent.match(/Edge\/\d+\.\d+/);
|
46
|
+
|
47
|
+
const baseUrl = hasDocument
|
48
|
+
? document.baseURI
|
49
|
+
: `${location.protocol}//${location.host}${location.pathname.includes('/')
|
50
|
+
? location.pathname.slice(0, location.pathname.lastIndexOf('/') + 1)
|
51
|
+
: location.pathname}`;
|
52
|
+
|
53
|
+
const createBlob = (source, type = 'text/javascript') => URL.createObjectURL(new Blob([source], { type }));
|
54
|
+
let { skip } = esmsInitOptions;
|
55
|
+
if (Array.isArray(skip)) {
|
56
|
+
const l = skip.map(s => new URL(s, baseUrl).href);
|
57
|
+
skip = s => l.some(i => i[i.length - 1] === '/' && s.startsWith(i) || s === i);
|
58
|
+
}
|
59
|
+
else if (typeof skip === 'string') {
|
60
|
+
const r = new RegExp(skip);
|
61
|
+
skip = s => r.test(s);
|
62
|
+
}
|
15
63
|
|
16
|
-
const
|
17
|
-
if (baseEl)
|
18
|
-
baseUrl = baseEl.href;
|
64
|
+
const eoop = err => setTimeout(() => { throw err });
|
19
65
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
baseUrl = baseUrl.slice(0, lastSepIndex + 1);
|
66
|
+
const throwError = err => { (self.reportError || hasWindow && window.safari && console.error || eoop)(err), void onerror(err); };
|
67
|
+
|
68
|
+
function fromParent (parent) {
|
69
|
+
return parent ? ` imported from ${parent}` : '';
|
25
70
|
}
|
26
71
|
|
72
|
+
let importMapSrcOrLazy = false;
|
73
|
+
|
74
|
+
function setImportMapSrcOrLazy () {
|
75
|
+
importMapSrcOrLazy = true;
|
76
|
+
}
|
77
|
+
|
78
|
+
// shim mode is determined on initialization, no late shim mode
|
79
|
+
if (!shimMode) {
|
80
|
+
if (document.querySelectorAll('script[type=module-shim],script[type=importmap-shim],link[rel=modulepreload-shim]').length) {
|
81
|
+
shimMode = true;
|
82
|
+
}
|
83
|
+
else {
|
84
|
+
let seenScript = false;
|
85
|
+
for (const script of document.querySelectorAll('script[type=module],script[type=importmap]')) {
|
86
|
+
if (!seenScript) {
|
87
|
+
if (script.type === 'module' && !script.ep)
|
88
|
+
seenScript = true;
|
89
|
+
}
|
90
|
+
else if (script.type === 'importmap' && seenScript) {
|
91
|
+
importMapSrcOrLazy = true;
|
92
|
+
break;
|
93
|
+
}
|
94
|
+
}
|
95
|
+
}
|
96
|
+
}
|
97
|
+
|
98
|
+
const backslashRegEx = /\\/g;
|
99
|
+
|
27
100
|
function isURL (url) {
|
101
|
+
if (url.indexOf(':') === -1) return false;
|
28
102
|
try {
|
29
103
|
new URL(url);
|
30
104
|
return true;
|
31
105
|
}
|
32
|
-
catch {
|
106
|
+
catch (_) {
|
33
107
|
return false;
|
34
108
|
}
|
35
109
|
}
|
36
110
|
|
37
|
-
|
111
|
+
function resolveUrl (relUrl, parentUrl) {
|
112
|
+
return resolveIfNotPlainOrUrl(relUrl, parentUrl) || (isURL(relUrl) ? relUrl : resolveIfNotPlainOrUrl('./' + relUrl, parentUrl));
|
113
|
+
}
|
114
|
+
|
38
115
|
function resolveIfNotPlainOrUrl (relUrl, parentUrl) {
|
39
|
-
|
40
|
-
|
116
|
+
const hIdx = parentUrl.indexOf('#'), qIdx = parentUrl.indexOf('?');
|
117
|
+
if (hIdx + qIdx > -2)
|
118
|
+
parentUrl = parentUrl.slice(0, hIdx === -1 ? qIdx : qIdx === -1 || qIdx > hIdx ? hIdx : qIdx);
|
41
119
|
if (relUrl.indexOf('\\') !== -1)
|
42
120
|
relUrl = relUrl.replace(backslashRegEx, '/');
|
43
121
|
// protocol-relative
|
@@ -87,28 +165,25 @@
|
|
87
165
|
output.push(segmented.slice(segmentIndex, i + 1));
|
88
166
|
segmentIndex = -1;
|
89
167
|
}
|
168
|
+
continue;
|
90
169
|
}
|
91
|
-
|
92
170
|
// new segment - check if it is relative
|
93
171
|
else if (segmented[i] === '.') {
|
94
172
|
// ../ segment
|
95
173
|
if (segmented[i + 1] === '.' && (segmented[i + 2] === '/' || i + 2 === segmented.length)) {
|
96
174
|
output.pop();
|
97
175
|
i += 2;
|
176
|
+
continue;
|
98
177
|
}
|
99
178
|
// ./ segment
|
100
179
|
else if (segmented[i + 1] === '/' || i + 1 === segmented.length) {
|
101
180
|
i += 1;
|
102
|
-
|
103
|
-
else {
|
104
|
-
// the start of a new segment as below
|
105
|
-
segmentIndex = i;
|
181
|
+
continue;
|
106
182
|
}
|
107
183
|
}
|
108
184
|
// it is the start of a new segment
|
109
|
-
|
110
|
-
|
111
|
-
}
|
185
|
+
while (segmented[i] === '/') i++;
|
186
|
+
segmentIndex = i;
|
112
187
|
}
|
113
188
|
// finish reading out the last segment
|
114
189
|
if (segmentIndex !== -1)
|
@@ -117,35 +192,6 @@
|
|
117
192
|
}
|
118
193
|
}
|
119
194
|
|
120
|
-
/*
|
121
|
-
* Import maps implementation
|
122
|
-
*
|
123
|
-
* To make lookups fast we pre-resolve the entire import map
|
124
|
-
* and then match based on backtracked hash lookups
|
125
|
-
*
|
126
|
-
*/
|
127
|
-
function resolveUrl (relUrl, parentUrl) {
|
128
|
-
return resolveIfNotPlainOrUrl(relUrl, parentUrl) || (relUrl.indexOf(':') !== -1 ? relUrl : resolveIfNotPlainOrUrl('./' + relUrl, parentUrl));
|
129
|
-
}
|
130
|
-
|
131
|
-
function resolveAndComposePackages (packages, outPackages, baseUrl, parentMap) {
|
132
|
-
for (let p in packages) {
|
133
|
-
const resolvedLhs = resolveIfNotPlainOrUrl(p, baseUrl) || p;
|
134
|
-
if (outPackages[resolvedLhs]) {
|
135
|
-
throw Error(`Rejected map override "${resolvedLhs}" from ${outPackages[resolvedLhs]} to ${packages[resolvedLhs]}.`);
|
136
|
-
}
|
137
|
-
let target = packages[p];
|
138
|
-
if (typeof target !== 'string')
|
139
|
-
continue;
|
140
|
-
const mapped = resolveImportMap(parentMap, resolveIfNotPlainOrUrl(target, baseUrl) || target, baseUrl);
|
141
|
-
if (mapped) {
|
142
|
-
outPackages[resolvedLhs] = mapped;
|
143
|
-
continue;
|
144
|
-
}
|
145
|
-
console.warn(`Mapping "${p}" -> "${packages[p]}" does not resolve`);
|
146
|
-
}
|
147
|
-
}
|
148
|
-
|
149
195
|
function resolveAndComposeImportMap (json, baseUrl, parentMap) {
|
150
196
|
const outMap = { imports: Object.assign({}, parentMap.imports), scopes: Object.assign({}, parentMap.scopes) };
|
151
197
|
|
@@ -181,6 +227,7 @@
|
|
181
227
|
}
|
182
228
|
}
|
183
229
|
|
230
|
+
|
184
231
|
function resolveImportMap (importMap, resolvedOrPlain, parentUrl) {
|
185
232
|
let scopeUrl = parentUrl && getMatch(parentUrl, importMap.scopes);
|
186
233
|
while (scopeUrl) {
|
@@ -190,133 +237,227 @@
|
|
190
237
|
scopeUrl = getMatch(scopeUrl.slice(0, scopeUrl.lastIndexOf('/')), importMap.scopes);
|
191
238
|
}
|
192
239
|
return applyPackages(resolvedOrPlain, importMap.imports) || resolvedOrPlain.indexOf(':') !== -1 && resolvedOrPlain;
|
193
|
-
}
|
194
|
-
|
195
|
-
const optionsScript = document.querySelector('script[type=esms-options]');
|
196
|
-
|
197
|
-
const esmsInitOptions = optionsScript ? JSON.parse(optionsScript.innerHTML) : self.esmsInitOptions ? self.esmsInitOptions : {};
|
198
|
-
|
199
|
-
let shimMode = !!esmsInitOptions.shimMode;
|
200
|
-
const resolveHook = globalHook(shimMode && esmsInitOptions.resolve);
|
201
|
-
|
202
|
-
const skip = esmsInitOptions.skip ? new RegExp(esmsInitOptions.skip) : null;
|
203
|
-
|
204
|
-
let nonce = esmsInitOptions.nonce;
|
205
|
-
|
206
|
-
if (!nonce) {
|
207
|
-
const nonceElement = document.querySelector('script[nonce]');
|
208
|
-
if (nonceElement)
|
209
|
-
nonce = nonceElement.nonce || nonceElement.getAttribute('nonce');
|
210
|
-
}
|
211
|
-
|
212
|
-
const onerror = globalHook(esmsInitOptions.onerror || noop);
|
213
|
-
const onpolyfill = esmsInitOptions.onpolyfill ? globalHook(esmsInitOptions.onpolyfill) : () => console.info(`OK: "Uncaught TypeError" module failure has been polyfilled`);
|
214
|
-
|
215
|
-
const { revokeBlobURLs, noLoadEventRetriggers, enforceIntegrity } = esmsInitOptions;
|
216
|
-
|
217
|
-
const fetchHook = esmsInitOptions.fetch ? globalHook(esmsInitOptions.fetch) : fetch;
|
218
|
-
|
219
|
-
function globalHook (name) {
|
220
|
-
return typeof name === 'string' ? self[name] : name;
|
221
240
|
}
|
222
241
|
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
242
|
+
function resolveAndComposePackages (packages, outPackages, baseUrl, parentMap) {
|
243
|
+
for (let p in packages) {
|
244
|
+
const resolvedLhs = resolveIfNotPlainOrUrl(p, baseUrl) || p;
|
245
|
+
if ((!shimMode || !mapOverrides) && outPackages[resolvedLhs] && (outPackages[resolvedLhs] !== packages[resolvedLhs])) {
|
246
|
+
throw Error(`Rejected map override "${resolvedLhs}" from ${outPackages[resolvedLhs]} to ${packages[resolvedLhs]}.`);
|
247
|
+
}
|
248
|
+
let target = packages[p];
|
249
|
+
if (typeof target !== 'string')
|
250
|
+
continue;
|
251
|
+
const mapped = resolveImportMap(parentMap, resolveIfNotPlainOrUrl(target, baseUrl) || target, baseUrl);
|
252
|
+
if (mapped) {
|
253
|
+
outPackages[resolvedLhs] = mapped;
|
254
|
+
continue;
|
255
|
+
}
|
256
|
+
console.warn(`Mapping "${p}" -> "${packages[p]}" does not resolve`);
|
257
|
+
}
|
229
258
|
}
|
230
259
|
|
231
|
-
let
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
const s = Object.assign(document.createElement('script'), {
|
260
|
+
let dynamicImport = !hasDocument && (0, eval)('u=>import(u)');
|
261
|
+
|
262
|
+
let supportsDynamicImport;
|
263
|
+
|
264
|
+
const dynamicImportCheck = hasDocument && new Promise(resolve => {
|
265
|
+
const s = Object.assign(document.createElement('script'), {
|
266
|
+
src: createBlob('self._d=u=>import(u)'),
|
267
|
+
ep: true
|
268
|
+
});
|
237
269
|
s.setAttribute('nonce', nonce);
|
238
|
-
s.
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
resolve(self._esmsi, baseUrl);
|
248
|
-
self._esmsi = undefined;
|
249
|
-
}
|
250
|
-
else {
|
251
|
-
reject(!(_err instanceof Event) && _err || err && err.error || new Error(`Error loading or executing the graph of ${errUrl} (check the console for ${src}).`));
|
270
|
+
s.addEventListener('load', () => {
|
271
|
+
if (!(supportsDynamicImport = !!(dynamicImport = self._d))) {
|
272
|
+
let err;
|
273
|
+
window.addEventListener('error', _err => err = _err);
|
274
|
+
dynamicImport = (url, opts) => new Promise((resolve, reject) => {
|
275
|
+
const s = Object.assign(document.createElement('script'), {
|
276
|
+
type: 'module',
|
277
|
+
src: createBlob(`import*as m from'${url}';self._esmsi=m`)
|
278
|
+
});
|
252
279
|
err = undefined;
|
253
|
-
|
280
|
+
s.ep = true;
|
281
|
+
if (nonce)
|
282
|
+
s.setAttribute('nonce', nonce);
|
283
|
+
// Safari is unique in supporting module script error events
|
284
|
+
s.addEventListener('error', cb);
|
285
|
+
s.addEventListener('load', cb);
|
286
|
+
function cb (_err) {
|
287
|
+
document.head.removeChild(s);
|
288
|
+
if (self._esmsi) {
|
289
|
+
resolve(self._esmsi, baseUrl);
|
290
|
+
self._esmsi = undefined;
|
291
|
+
}
|
292
|
+
else {
|
293
|
+
reject(!(_err instanceof Event) && _err || err && err.error || new Error(`Error loading ${opts && opts.errUrl || url} (${s.src}).`));
|
294
|
+
err = undefined;
|
295
|
+
}
|
296
|
+
}
|
297
|
+
document.head.appendChild(s);
|
298
|
+
});
|
254
299
|
}
|
300
|
+
document.head.removeChild(s);
|
301
|
+
delete self._d;
|
302
|
+
resolve();
|
255
303
|
});
|
256
304
|
document.head.appendChild(s);
|
257
|
-
|
258
|
-
}
|
259
|
-
|
260
|
-
let dynamicImport = dynamicImportScript;
|
261
|
-
|
262
|
-
const supportsDynamicImportCheck = dynamicImportScript(createBlob('export default u=>import(u)')).then(_dynamicImport => {
|
263
|
-
if (_dynamicImport)
|
264
|
-
dynamicImport = _dynamicImport.default;
|
265
|
-
return !!_dynamicImport;
|
266
|
-
}, noop);
|
305
|
+
});
|
267
306
|
|
268
307
|
// support browsers without dynamic import support (eg Firefox 6x)
|
269
308
|
let supportsJsonAssertions = false;
|
270
309
|
let supportsCssAssertions = false;
|
271
310
|
|
272
|
-
|
273
|
-
|
311
|
+
const supports = hasDocument && HTMLScriptElement.supports;
|
312
|
+
|
313
|
+
let supportsImportMaps = supports && supports.name === 'supports' && supports('importmap');
|
314
|
+
let supportsImportMeta = supportsDynamicImport;
|
274
315
|
|
275
|
-
|
316
|
+
const importMetaCheck = 'import.meta';
|
317
|
+
const cssModulesCheck = `import"x"assert{type:"css"}`;
|
318
|
+
const jsonModulesCheck = `import"x"assert{type:"json"}`;
|
276
319
|
|
277
|
-
|
278
|
-
if (!
|
320
|
+
let featureDetectionPromise = Promise.resolve(dynamicImportCheck).then(() => {
|
321
|
+
if (!supportsDynamicImport)
|
279
322
|
return;
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
const
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
323
|
+
|
324
|
+
if (!hasDocument)
|
325
|
+
return Promise.all([
|
326
|
+
supportsImportMaps || dynamicImport(createBlob(importMetaCheck)).then(() => supportsImportMeta = true, noop),
|
327
|
+
cssModulesEnabled && dynamicImport(createBlob(cssModulesCheck.replace('x', createBlob('', 'text/css')))).then(() => supportsCssAssertions = true, noop),
|
328
|
+
jsonModulesEnabled && dynamicImport(createBlob(jsonModulescheck.replace('x', createBlob('{}', 'text/json')))).then(() => supportsJsonAssertions = true, noop),
|
329
|
+
]);
|
330
|
+
|
331
|
+
return new Promise(resolve => {
|
332
|
+
const iframe = document.createElement('iframe');
|
333
|
+
iframe.style.display = 'none';
|
334
|
+
iframe.setAttribute('nonce', nonce);
|
335
|
+
function cb ({ data }) {
|
336
|
+
const isFeatureDetectionMessage = Array.isArray(data) && data[0] === 'esms';
|
337
|
+
if (!isFeatureDetectionMessage) {
|
338
|
+
return;
|
339
|
+
}
|
340
|
+
supportsImportMaps = data[1];
|
341
|
+
supportsImportMeta = data[2];
|
342
|
+
supportsCssAssertions = data[3];
|
343
|
+
supportsJsonAssertions = data[4];
|
344
|
+
resolve();
|
345
|
+
document.head.removeChild(iframe);
|
346
|
+
window.removeEventListener('message', cb, false);
|
347
|
+
}
|
348
|
+
window.addEventListener('message', cb, false);
|
349
|
+
|
350
|
+
const importMapTest = `<script nonce=${nonce || ''}>b=(s,type='text/javascript')=>URL.createObjectURL(new Blob([s],{type}));document.head.appendChild(Object.assign(document.createElement('script'),{type:'importmap',nonce:"${nonce}",innerText:\`{"imports":{"x":"\${b('')}"}}\`}));Promise.all([${
|
351
|
+
supportsImportMaps ? 'true,true' : `'x',b('${importMetaCheck}')`}, ${cssModulesEnabled ? `b('${cssModulesCheck}'.replace('x',b('','text/css')))` : 'false'}, ${
|
352
|
+
jsonModulesEnabled ? `b('${jsonModulesCheck}'.replace('x',b('{}','text/json')))` : 'false'}].map(x =>typeof x==='string'?import(x).then(x =>!!x,()=>false):x)).then(a=>parent.postMessage(['esms'].concat(a),'*'))<${''}/script>`;
|
353
|
+
|
354
|
+
// Safari will call onload eagerly on head injection, but we don't want the Wechat
|
355
|
+
// path to trigger before setting srcdoc, therefore we track the timing
|
356
|
+
let readyForOnload = false, onloadCalledWhileNotReady = false;
|
357
|
+
function doOnload () {
|
358
|
+
if (!readyForOnload) {
|
359
|
+
onloadCalledWhileNotReady = true;
|
360
|
+
return;
|
361
|
+
}
|
362
|
+
// WeChat browser doesn't support setting srcdoc scripts
|
363
|
+
// But iframe sandboxes don't support contentDocument so we do this as a fallback
|
364
|
+
const doc = iframe.contentDocument;
|
365
|
+
if (doc && doc.head.childNodes.length === 0) {
|
366
|
+
const s = doc.createElement('script');
|
367
|
+
if (nonce)
|
368
|
+
s.setAttribute('nonce', nonce);
|
369
|
+
s.innerHTML = importMapTest.slice(15 + (nonce ? nonce.length : 0), -9);
|
370
|
+
doc.head.appendChild(s);
|
371
|
+
}
|
372
|
+
}
|
373
|
+
|
374
|
+
iframe.onload = doOnload;
|
375
|
+
// WeChat browser requires append before setting srcdoc
|
376
|
+
document.head.appendChild(iframe);
|
377
|
+
|
378
|
+
// setting srcdoc is not supported in React native webviews on iOS
|
379
|
+
// setting src to a blob URL results in a navigation event in webviews
|
380
|
+
// document.write gives usability warnings
|
381
|
+
readyForOnload = true;
|
382
|
+
if ('srcdoc' in iframe)
|
383
|
+
iframe.srcdoc = importMapTest;
|
384
|
+
else
|
385
|
+
iframe.contentDocument.write(importMapTest);
|
386
|
+
// retrigger onload for Safari only if necessary
|
387
|
+
if (onloadCalledWhileNotReady) doOnload();
|
388
|
+
});
|
299
389
|
});
|
300
390
|
|
301
|
-
let e,r,a,i=4194304;const s=1===new Uint8Array(new Uint16Array([1]).buffer)[0];let t,f,c$1;function parse(k,l="@"){if(t=k,f=l,t.length>i||!e){for(;t.length>i;)i*=2;r=new ArrayBuffer(4*i),e=function(e,r,a){"use asm";var i=new e.Int8Array(a),s=new e.Int16Array(a),t=new e.Int32Array(a),f=new e.Uint8Array(a),c=new e.Uint16Array(a),n=816;function b(e){e=e|0;var r=0,a=0,f=0,b=0,l=0;l=n;n=n+14336|0;b=l;i[589]=1;s[291]=0;s[292]=0;s[293]=-1;t[15]=t[2];i[590]=0;t[14]=0;i[588]=0;t[16]=l+10240;t[17]=l+2048;i[591]=0;e=(t[3]|0)+-2|0;t[18]=e;r=e+(t[12]<<1)|0;t[19]=r;e:while(1){a=e+2|0;t[18]=a;if(e>>>0>=r>>>0){f=18;break}r:do{switch(s[a>>1]|0){case 9:case 10:case 11:case 12:case 13:case 32:break;case 101:{if((((s[292]|0)==0?R(a)|0:0)?B(e+4|0,120,112,111,114,116)|0:0)?(u(),(i[589]|0)==0):0){f=9;break e}else f=17;break}case 105:{if(R(a)|0?B(e+4|0,109,112,111,114,116)|0:0){k();f=17;}else f=17;break}case 59:{f=17;break}case 47:switch(s[e+4>>1]|0){case 47:{G();break r}case 42:{p(1);break r}default:{f=16;break e}}default:{f=16;break e}}}while(0);if((f|0)==17){f=0;t[15]=t[18];}e=t[18]|0;r=t[19]|0;}if((f|0)==9){e=t[18]|0;t[15]=e;f=19;}else if((f|0)==16){i[589]=0;t[18]=e;f=19;}else if((f|0)==18)if(!(i[588]|0)){e=a;f=19;}else e=0;do{if((f|0)==19){e:while(1){r=e+2|0;t[18]=r;a=r;if(e>>>0>=(t[19]|0)>>>0){f=75;break}r:do{switch(s[r>>1]|0){case 9:case 10:case 11:case 12:case 13:case 32:break;case 101:{if(((s[292]|0)==0?R(r)|0:0)?B(e+4|0,120,112,111,114,116)|0:0){u();f=74;}else f=74;break}case 105:{if(R(r)|0?B(e+4|0,109,112,111,114,116)|0:0){k();f=74;}else f=74;break}case 99:{if((R(r)|0?z(e+4|0,108,97,115,115)|0:0)?Z(s[e+12>>1]|0)|0:0){i[591]=1;f=74;}else f=74;break}case 40:{r=t[15]|0;a=t[17]|0;f=s[292]|0;s[292]=f+1<<16>>16;t[a+((f&65535)<<2)>>2]=r;f=74;break}case 41:{e=s[292]|0;if(!(e<<16>>16)){f=36;break e}f=e+-1<<16>>16;s[292]=f;e=t[11]|0;if((e|0)!=0?(t[e+20>>2]|0)==(t[(t[17]|0)+((f&65535)<<2)>>2]|0):0){r=e+4|0;if(!(t[r>>2]|0))t[r>>2]=a;t[e+12>>2]=a;t[11]=0;f=74;}else f=74;break}case 123:{f=t[15]|0;a=t[8]|0;e=f;do{if((s[f>>1]|0)==41&(a|0)!=0?(t[a+4>>2]|0)==(f|0):0){r=t[9]|0;t[8]=r;if(!r){t[4]=0;break}else {t[r+28>>2]=0;break}}}while(0);r=s[292]|0;f=r&65535;i[b+f>>0]=i[591]|0;i[591]=0;a=t[17]|0;s[292]=r+1<<16>>16;t[a+(f<<2)>>2]=e;f=74;break}case 125:{e=s[292]|0;if(!(e<<16>>16)){f=49;break e}a=e+-1<<16>>16;s[292]=a;r=s[293]|0;if(e<<16>>16!=r<<16>>16)if(r<<16>>16!=-1&(a&65535)<(r&65535)){f=53;break e}else {f=74;break r}else {a=t[16]|0;f=(s[291]|0)+-1<<16>>16;s[291]=f;s[293]=s[a+((f&65535)<<1)>>1]|0;h();f=74;break r}}case 39:{d(39);f=74;break}case 34:{d(34);f=74;break}case 47:switch(s[e+4>>1]|0){case 47:{G();break r}case 42:{p(1);break r}default:{r=t[15]|0;a=s[r>>1]|0;a:do{if(!(x(a)|0)){switch(a<<16>>16){case 41:if(L(t[(t[17]|0)+(c[292]<<2)>>2]|0)|0){f=71;break a}else {f=68;break a}case 125:break;default:{f=68;break a}}e=c[292]|0;if(!(y(t[(t[17]|0)+(e<<2)>>2]|0)|0)?(i[b+e>>0]|0)==0:0)f=68;else f=71;}else switch(a<<16>>16){case 46:if(((s[r+-2>>1]|0)+-48&65535)<10){f=68;break a}else {f=71;break a}case 43:if((s[r+-2>>1]|0)==43){f=68;break a}else {f=71;break a}case 45:if((s[r+-2>>1]|0)==45){f=68;break a}else {f=71;break a}default:{f=71;break a}}}while(0);a:do{if((f|0)==68){f=0;if(!(o(r)|0)){switch(a<<16>>16){case 0:{f=71;break a}case 47:break;default:{e=1;break a}}if(!(i[590]|0))e=1;else f=71;}else f=71;}}while(0);if((f|0)==71){I();e=0;}i[590]=e;f=74;break r}}case 96:{h();f=74;break}default:f=74;}}while(0);if((f|0)==74){f=0;t[15]=t[18];}e=t[18]|0;}if((f|0)==36){Y();e=0;break}else if((f|0)==49){Y();e=0;break}else if((f|0)==53){Y();e=0;break}else if((f|0)==75){e=(s[293]|0)==-1&(s[292]|0)==0&(i[588]|0)==0;break}}}while(0);n=l;return e|0}function u(){var e=0,r=0,a=0,f=0,c=0,n=0;c=t[18]|0;n=c+12|0;t[18]=n;r=w(1)|0;e=t[18]|0;if(!((e|0)==(n|0)?!(S(r)|0):0))f=3;e:do{if((f|0)==3){r:do{switch(r<<16>>16){case 100:{J(e,e+14|0);break e}case 97:{t[18]=e+10;w(1)|0;e=t[18]|0;f=6;break}case 102:{f=6;break}case 99:{if(z(e+2|0,108,97,115,115)|0?(a=e+10|0,F(s[a>>1]|0)|0):0){t[18]=a;c=w(1)|0;n=t[18]|0;H(c)|0;J(n,t[18]|0);t[18]=(t[18]|0)+-2;break e}e=e+4|0;t[18]=e;f=13;break}case 108:case 118:{f=13;break}case 123:{t[18]=e+2;e=w(1)|0;a=t[18]|0;while(1){if(_(e)|0){d(e);e=(t[18]|0)+2|0;t[18]=e;}else {H(e)|0;e=t[18]|0;}w(1)|0;e=g(a,e)|0;if(e<<16>>16==44){t[18]=(t[18]|0)+2;e=w(1)|0;}r=a;a=t[18]|0;if(e<<16>>16==125){f=32;break}if((a|0)==(r|0)){f=29;break}if(a>>>0>(t[19]|0)>>>0){f=31;break}}if((f|0)==29){Y();break e}else if((f|0)==31){Y();break e}else if((f|0)==32){t[18]=a+2;f=34;break r}break}case 42:{t[18]=e+2;w(1)|0;f=t[18]|0;g(f,f)|0;f=34;break}default:{}}}while(0);if((f|0)==6){t[18]=e+16;e=w(1)|0;if(e<<16>>16==42){t[18]=(t[18]|0)+2;e=w(1)|0;}n=t[18]|0;H(e)|0;J(n,t[18]|0);t[18]=(t[18]|0)+-2;break}else if((f|0)==13){e=e+4|0;t[18]=e;i[589]=0;r:while(1){t[18]=e+2;n=w(1)|0;e=t[18]|0;switch((H(n)|0)<<16>>16){case 91:case 123:{f=15;break r}default:{}}r=t[18]|0;if((r|0)==(e|0))break e;J(e,r);switch((w(1)|0)<<16>>16){case 61:{f=19;break r}case 44:break;default:{f=20;break r}}e=t[18]|0;}if((f|0)==15){t[18]=(t[18]|0)+-2;break}else if((f|0)==19){t[18]=(t[18]|0)+-2;break}else if((f|0)==20){t[18]=(t[18]|0)+-2;break}}else if((f|0)==34)r=w(1)|0;e=t[18]|0;if(r<<16>>16==102?K(e+2|0,114,111,109)|0:0){t[18]=e+8;l(c,w(1)|0);break}t[18]=e+-2;}}while(0);return}function k(){var e=0,r=0,a=0,f=0,c=0;c=t[18]|0;r=c+12|0;t[18]=r;e:do{switch((w(1)|0)<<16>>16){case 40:{r=t[17]|0;a=s[292]|0;s[292]=a+1<<16>>16;t[r+((a&65535)<<2)>>2]=c;if((s[t[15]>>1]|0)!=46){v(c,(t[18]|0)+2|0,0,c);t[11]=t[8];t[18]=(t[18]|0)+2;switch((w(1)|0)<<16>>16){case 39:{d(39);break}case 34:{d(34);break}default:{t[18]=(t[18]|0)+-2;break e}}t[18]=(t[18]|0)+2;switch((w(1)|0)<<16>>16){case 44:{c=t[18]|0;t[(t[8]|0)+4>>2]=c;t[18]=c+2;w(1)|0;c=t[18]|0;a=t[8]|0;t[a+16>>2]=c;i[a+24>>0]=1;t[18]=c+-2;break e}case 41:{s[292]=(s[292]|0)+-1<<16>>16;a=t[18]|0;c=t[8]|0;t[c+4>>2]=a;t[c+12>>2]=a;i[c+24>>0]=1;break e}default:{t[18]=(t[18]|0)+-2;break e}}}break}case 46:{t[18]=(t[18]|0)+2;if(((w(1)|0)<<16>>16==109?(e=t[18]|0,K(e+2|0,101,116,97)|0):0)?(s[t[15]>>1]|0)!=46:0)v(c,c,e+8|0,2);break}case 42:case 39:case 34:{f=16;break}case 123:{e=t[18]|0;if(s[292]|0){t[18]=e+-2;break e}while(1){if(e>>>0>=(t[19]|0)>>>0)break;e=w(1)|0;if(!(_(e)|0)){if(e<<16>>16==125){f=31;break}}else d(e);e=(t[18]|0)+2|0;t[18]=e;}if((f|0)==31)t[18]=(t[18]|0)+2;w(1)|0;e=t[18]|0;if(!(z(e,102,114,111,109)|0)){Y();break e}t[18]=e+8;e=w(1)|0;if(_(e)|0){l(c,e);break e}else {Y();break e}}default:if((t[18]|0)!=(r|0))f=16;}}while(0);do{if((f|0)==16){if(s[292]|0){t[18]=(t[18]|0)+-2;break}e=t[19]|0;r=t[18]|0;while(1){if(r>>>0>=e>>>0){f=23;break}a=s[r>>1]|0;if(_(a)|0){f=21;break}f=r+2|0;t[18]=f;r=f;}if((f|0)==21){l(c,a);break}else if((f|0)==23){Y();break}}}while(0);return}function l(e,r){e=e|0;r=r|0;var a=0,i=0;a=(t[18]|0)+2|0;switch(r<<16>>16){case 39:{d(39);i=5;break}case 34:{d(34);i=5;break}default:Y();}do{if((i|0)==5){v(e,a,t[18]|0,1);t[18]=(t[18]|0)+2;i=(w(0)|0)<<16>>16==97;r=t[18]|0;if(i?B(r+2|0,115,115,101,114,116)|0:0){t[18]=r+12;if((w(1)|0)<<16>>16!=123){t[18]=r;break}e=t[18]|0;a=e;e:while(1){t[18]=a+2;a=w(1)|0;switch(a<<16>>16){case 39:{d(39);t[18]=(t[18]|0)+2;a=w(1)|0;break}case 34:{d(34);t[18]=(t[18]|0)+2;a=w(1)|0;break}default:a=H(a)|0;}if(a<<16>>16!=58){i=16;break}t[18]=(t[18]|0)+2;switch((w(1)|0)<<16>>16){case 39:{d(39);break}case 34:{d(34);break}default:{i=20;break e}}t[18]=(t[18]|0)+2;switch((w(1)|0)<<16>>16){case 125:{i=25;break e}case 44:break;default:{i=24;break e}}t[18]=(t[18]|0)+2;if((w(1)|0)<<16>>16==125){i=25;break}a=t[18]|0;}if((i|0)==16){t[18]=r;break}else if((i|0)==20){t[18]=r;break}else if((i|0)==24){t[18]=r;break}else if((i|0)==25){i=t[8]|0;t[i+16>>2]=e;t[i+12>>2]=(t[18]|0)+2;break}}t[18]=r+-2;}}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=q(e+-4|0,118,111)|0;break e}case 108:{e=P(e+-4|0,121,105,101)|0;break e}default:{e=0;break e}}case 101:{switch(s[e+-2>>1]|0){case 115:break;case 116:{e=E(e+-4|0,100,101,108,101)|0;break e}default:{e=0;break e}}switch(s[e+-4>>1]|0){case 108:{e=D(e+-6|0,101)|0;break e}case 97:{e=D(e+-6|0,99)|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=O(e+-8|0,105,110,115,116,97,110)|0;break e}case 112:{e=q(e+-8|0,116,121)|0;break e}default:{e=0;break e}}else e=0;break}case 110:{e=e+-2|0;if(D(e,105)|0)e=1;else e=$(e,114,101,116,117,114)|0;break}case 111:{e=D(e+-2|0,100)|0;break}case 114:{e=m(e+-2|0,100,101,98,117,103,103,101)|0;break}case 116:{e=E(e+-2|0,97,119,97,105)|0;break}case 119:switch(s[e+-2>>1]|0){case 101:{e=D(e+-4|0,110)|0;break e}case 111:{e=P(e+-4|0,116,104,114)|0;break e}default:{e=0;break e}}default:e=0;}}while(0);return e|0}function h(){var e=0,r=0,a=0;r=t[19]|0;a=t[18]|0;e:while(1){e=a+2|0;if(a>>>0>=r>>>0){r=8;break}switch(s[e>>1]|0){case 96:{r=9;break e}case 36:{if((s[a+4>>1]|0)==123){r=6;break e}break}case 92:{e=a+4|0;break}default:{}}a=e;}if((r|0)==6){t[18]=a+4;e=s[293]|0;r=t[16]|0;a=s[291]|0;s[291]=a+1<<16>>16;s[r+((a&65535)<<1)>>1]=e;a=(s[292]|0)+1<<16>>16;s[292]=a;s[293]=a;}else if((r|0)==8){t[18]=e;Y();}else if((r|0)==9)t[18]=e;return}function w(e){e=e|0;var r=0,a=0,i=0;a=t[18]|0;e:do{r=s[a>>1]|0;r:do{if(r<<16>>16!=47)if(e)if(Z(r)|0)break;else break e;else if(Q(r)|0)break;else break e;else switch(s[a+2>>1]|0){case 47:{G();break r}case 42:{p(e);break r}default:{r=47;break e}}}while(0);i=t[18]|0;a=i+2|0;t[18]=a;}while(i>>>0<(t[19]|0)>>>0);return r|0}function d(e){e=e|0;var r=0,a=0,i=0,f=0;f=t[19]|0;r=t[18]|0;while(1){i=r+2|0;if(r>>>0>=f>>>0){r=9;break}a=s[i>>1]|0;if(a<<16>>16==e<<16>>16){r=10;break}if(a<<16>>16==92){a=r+4|0;if((s[a>>1]|0)==13){r=r+6|0;r=(s[r>>1]|0)==10?r:a;}else r=a;}else if(ae(a)|0){r=9;break}else r=i;}if((r|0)==9){t[18]=i;Y();}else if((r|0)==10)t[18]=i;return}function v(e,r,a,s){e=e|0;r=r|0;a=a|0;s=s|0;var f=0,c=0;f=t[13]|0;t[13]=f+32;c=t[8]|0;t[((c|0)==0?16:c+28|0)>>2]=f;t[9]=c;t[8]=f;t[f+8>>2]=e;do{if(2!=(s|0))if(1==(s|0)){t[f+12>>2]=a+2;break}else {t[f+12>>2]=t[3];break}else t[f+12>>2]=a;}while(0);t[f>>2]=r;t[f+4>>2]=a;t[f+16>>2]=0;t[f+20>>2]=s;i[f+24>>0]=1==(s|0)&1;t[f+28>>2]=0;return}function A(){var e=0,r=0,a=0;a=t[19]|0;r=t[18]|0;e:while(1){e=r+2|0;if(r>>>0>=a>>>0){r=6;break}switch(s[e>>1]|0){case 13:case 10:{r=6;break e}case 93:{r=7;break e}case 92:{e=r+4|0;break}default:{}}r=e;}if((r|0)==6){t[18]=e;Y();e=0;}else if((r|0)==7){t[18]=e;e=93;}return e|0}function C(e,r,a,i,t,f,c,n){e=e|0;r=r|0;a=a|0;i=i|0;t=t|0;f=f|0;c=c|0;n=n|0;if((((((s[e+12>>1]|0)==n<<16>>16?(s[e+10>>1]|0)==c<<16>>16:0)?(s[e+8>>1]|0)==f<<16>>16:0)?(s[e+6>>1]|0)==t<<16>>16:0)?(s[e+4>>1]|0)==i<<16>>16:0)?(s[e+2>>1]|0)==a<<16>>16:0)r=(s[e>>1]|0)==r<<16>>16;else r=0;return r|0}function y(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(e+-2|0,99,97,116,99)|0;break}case 121:{e=O(e+-2|0,102,105,110,97,108,108)|0;break}case 101:{e=P(e+-2|0,101,108,115)|0;break}default:e=0;}return e|0}function g(e,r){e=e|0;r=r|0;var a=0,i=0;a=t[18]|0;i=s[a>>1]|0;if(i<<16>>16==97){t[18]=a+4;a=w(1)|0;e=t[18]|0;if(_(a)|0){d(a);r=(t[18]|0)+2|0;t[18]=r;}else {H(a)|0;r=t[18]|0;}i=w(1)|0;a=t[18]|0;}if((a|0)!=(e|0))J(e,r);return i|0}function I(){var e=0,r=0,a=0;e:while(1){e=t[18]|0;r=e+2|0;t[18]=r;if(e>>>0>=(t[19]|0)>>>0){a=7;break}switch(s[r>>1]|0){case 13:case 10:{a=7;break e}case 47:break e;case 91:{A()|0;break}case 92:{t[18]=e+4;break}default:{}}}if((a|0)==7)Y();return}function p(e){e=e|0;var r=0,a=0,i=0,f=0,c=0;f=(t[18]|0)+2|0;t[18]=f;a=t[19]|0;while(1){r=f+2|0;if(f>>>0>=a>>>0)break;i=s[r>>1]|0;if(!e?ae(i)|0:0)break;if(i<<16>>16==42?(s[f+4>>1]|0)==47:0){c=8;break}f=r;}if((c|0)==8){t[18]=r;r=f+4|0;}t[18]=r;return}function U(e,r,a,i,t,f,c){e=e|0;r=r|0;a=a|0;i=i|0;t=t|0;f=f|0;c=c|0;if(((((s[e+10>>1]|0)==c<<16>>16?(s[e+8>>1]|0)==f<<16>>16:0)?(s[e+6>>1]|0)==t<<16>>16:0)?(s[e+4>>1]|0)==i<<16>>16:0)?(s[e+2>>1]|0)==a<<16>>16:0)r=(s[e>>1]|0)==r<<16>>16;else r=0;return r|0}function m(e,r,a,i,f,c,n,b){e=e|0;r=r|0;a=a|0;i=i|0;f=f|0;c=c|0;n=n|0;b=b|0;var u=0,k=0;k=e+-12|0;u=t[3]|0;if(k>>>0>=u>>>0?C(k,r,a,i,f,c,n,b)|0:0)if((k|0)==(u|0))u=1;else u=F(s[e+-14>>1]|0)|0;else u=0;return u|0}function S(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 x(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 O(e,r,a,i,f,c,n){e=e|0;r=r|0;a=a|0;i=i|0;f=f|0;c=c|0;n=n|0;var b=0,u=0;u=e+-10|0;b=t[3]|0;if(u>>>0>=b>>>0?U(u,r,a,i,f,c,n)|0:0)if((u|0)==(b|0))b=1;else b=F(s[e+-12>>1]|0)|0;else b=0;return b|0}function $(e,r,a,i,f,c){e=e|0;r=r|0;a=a|0;i=i|0;f=f|0;c=c|0;var n=0,b=0;b=e+-8|0;n=t[3]|0;if(b>>>0>=n>>>0?B(b,r,a,i,f,c)|0:0)if((b|0)==(n|0))n=1;else n=F(s[e+-10>>1]|0)|0;else n=0;return n|0}function j(e){e=e|0;var r=0,a=0,i=0,f=0;a=n;n=n+16|0;i=a;t[i>>2]=0;t[12]=e;r=t[3]|0;f=r+(e<<1)|0;e=f+2|0;s[f>>1]=0;t[i>>2]=e;t[13]=e;t[4]=0;t[8]=0;t[6]=0;t[5]=0;t[10]=0;t[7]=0;n=a;return r|0}function B(e,r,a,i,t,f){e=e|0;r=r|0;a=a|0;i=i|0;t=t|0;f=f|0;if((((s[e+8>>1]|0)==f<<16>>16?(s[e+6>>1]|0)==t<<16>>16:0)?(s[e+4>>1]|0)==i<<16>>16:0)?(s[e+2>>1]|0)==a<<16>>16:0)r=(s[e>>1]|0)==r<<16>>16;else r=0;return r|0}function E(e,r,a,i,f){e=e|0;r=r|0;a=a|0;i=i|0;f=f|0;var c=0,n=0;n=e+-6|0;c=t[3]|0;if(n>>>0>=c>>>0?z(n,r,a,i,f)|0:0)if((n|0)==(c|0))c=1;else c=F(s[e+-8>>1]|0)|0;else c=0;return c|0}function P(e,r,a,i){e=e|0;r=r|0;a=a|0;i=i|0;var f=0,c=0;c=e+-4|0;f=t[3]|0;if(c>>>0>=f>>>0?K(c,r,a,i)|0:0)if((c|0)==(f|0))f=1;else f=F(s[e+-6>>1]|0)|0;else f=0;return f|0}function q(e,r,a){e=e|0;r=r|0;a=a|0;var i=0,f=0;f=e+-2|0;i=t[3]|0;if(f>>>0>=i>>>0?N(f,r,a)|0:0)if((f|0)==(i|0))i=1;else i=F(s[e+-4>>1]|0)|0;else i=0;return i|0}function z(e,r,a,i,t){e=e|0;r=r|0;a=a|0;i=i|0;t=t|0;if(((s[e+6>>1]|0)==t<<16>>16?(s[e+4>>1]|0)==i<<16>>16:0)?(s[e+2>>1]|0)==a<<16>>16:0)r=(s[e>>1]|0)==r<<16>>16;else r=0;return r|0}function D(e,r){e=e|0;r=r|0;var a=0;a=t[3]|0;if(a>>>0<=e>>>0?(s[e>>1]|0)==r<<16>>16:0)if((a|0)==(e|0))a=1;else a=F(s[e+-2>>1]|0)|0;else a=0;return a|0}function F(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&(S(e)|0);}}while(0);return e|0}function G(){var e=0,r=0,a=0;e=t[19]|0;a=t[18]|0;e:while(1){r=a+2|0;if(a>>>0>=e>>>0)break;switch(s[r>>1]|0){case 13:case 10:break e;default:a=r;}}t[18]=r;return}function H(e){e=e|0;while(1){if(Z(e)|0)break;if(S(e)|0)break;e=(t[18]|0)+2|0;t[18]=e;e=s[e>>1]|0;if(!(e<<16>>16)){e=0;break}}return e|0}function J(e,r){e=e|0;r=r|0;var a=0,i=0;a=t[13]|0;t[13]=a+12;i=t[10]|0;t[((i|0)==0?20:i+8|0)>>2]=a;t[10]=a;t[a>>2]=e;t[a+4>>2]=r;t[a+8>>2]=0;return}function K(e,r,a,i){e=e|0;r=r|0;a=a|0;i=i|0;if((s[e+4>>1]|0)==i<<16>>16?(s[e+2>>1]|0)==a<<16>>16:0)r=(s[e>>1]|0)==r<<16>>16;else r=0;return r|0}function L(e){e=e|0;if(!($(e,119,104,105,108,101)|0)?!(P(e,102,111,114)|0):0)e=q(e,105,102)|0;else e=1;return e|0}function M(){var e=0;e=t[(t[6]|0)+20>>2]|0;switch(e|0){case 1:{e=-1;break}case 2:{e=-2;break}default:e=e-(t[3]|0)>>1;}return e|0}function N(e,r,a){e=e|0;r=r|0;a=a|0;if((s[e+2>>1]|0)==a<<16>>16)r=(s[e>>1]|0)==r<<16>>16;else r=0;return r|0}function Q(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 R(e){e=e|0;if((t[3]|0)==(e|0))e=1;else e=F(s[e+-2>>1]|0)|0;return e|0}function T(){var e=0;e=t[(t[6]|0)+16>>2]|0;if(!e)e=-1;else e=e-(t[3]|0)>>1;return e|0}function V(){var e=0;e=t[6]|0;e=t[((e|0)==0?16:e+28|0)>>2]|0;t[6]=e;return (e|0)!=0|0}function W(){var e=0;e=t[7]|0;e=t[((e|0)==0?20:e+8|0)>>2]|0;t[7]=e;return (e|0)!=0|0}function X(e){e=e|0;var r=0;r=n;n=n+e|0;n=n+15&-16;return r|0}function Y(){i[588]=1;t[14]=(t[18]|0)-(t[3]|0)>>1;t[18]=(t[19]|0)+2;return}function Z(e){e=e|0;return (e|128)<<16>>16==160|(e+-9&65535)<5|0}function _(e){e=e|0;return e<<16>>16==39|e<<16>>16==34|0}function ee(){return (t[(t[6]|0)+12>>2]|0)-(t[3]|0)>>1|0}function re(){return (t[(t[6]|0)+8>>2]|0)-(t[3]|0)>>1|0}function ae(e){e=e|0;return e<<16>>16==13|e<<16>>16==10|0}function ie(){return (t[(t[6]|0)+4>>2]|0)-(t[3]|0)>>1|0}function se(){return (t[(t[7]|0)+4>>2]|0)-(t[3]|0)>>1|0}function te(){return (t[t[6]>>2]|0)-(t[3]|0)>>1|0}function fe(){return (t[t[7]>>2]|0)-(t[3]|0)>>1|0}function ce(){return f[(t[6]|0)+24>>0]|0|0}function ne(e){e=e|0;t[3]=e;return}function be(){return (i[589]|0)!=0|0}function ue(){return t[14]|0}return {ai:T,e:ue,ee:se,es:fe,f:be,id:M,ie:ie,ip:ce,is:te,p:b,re:W,ri:V,sa:j,se:ee,ses:ne,ss:re,sta:X}}({Int8Array:Int8Array,Int16Array:Int16Array,Int32Array:Int32Array,Uint8Array:Uint8Array,Uint16Array:Uint16Array},{},r),a=e.sta(2*i);}const o=t.length+1;e.ses(a),e.sa(o-1),(s?b:n)(t,new Uint16Array(r,a,o)),e.p()||(c$1=e.e(),h());const w=[],d=[];for(;e.ri();){const r=e.is(),a=e.ie(),i=e.ai(),s=e.id(),f=e.ss(),c=e.se();let n;e.ip()&&(n=u(-1===s?r:r+1,t.charCodeAt(-1===s?r-1:r))),w.push({n:n,s:r,e:a,ss:f,se:c,d:s,a:i});}for(;e.re();){const r=e.es(),a=t.charCodeAt(r);d.push(34===a||39===a?u(r+1,a):t.slice(e.es(),e.ee()));}return [w,d,!!e.f()]}function n(e,r){const a=e.length;let i=0;for(;i<a;){const a=e.charCodeAt(i);r[i++]=(255&a)<<8|a>>>8;}}function b(e,r){const a=e.length;let i=0;for(;i<a;)r[i]=e.charCodeAt(i++);}function u(e,r){c$1=e;let a="",i=c$1;for(;;){c$1>=t.length&&h();const e=t.charCodeAt(c$1);if(e===r)break;92===e?(a+=t.slice(i,c$1),a+=k(),i=c$1):(8232===e||8233===e||o(e)&&h(),++c$1);}return a+=t.slice(i,c$1++),a}function k(){let e=t.charCodeAt(++c$1);switch(++c$1,e){case 110:return "\n";case 114:return "\r";case 120:return String.fromCharCode(l(2));case 117:return function(){let e;123===t.charCodeAt(c$1)?(++c$1,e=l(t.indexOf("}",c$1)-c$1),++c$1,e>1114111&&h()):e=l(4);return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode(55296+(e>>10),56320+(1023&e)))}();case 116:return "\t";case 98:return "\b";case 118:return "\v";case 102:return "\f";case 13:10===t.charCodeAt(c$1)&&++c$1;case 10:return "";case 56:case 57:h();default:if(e>=48&&e<=55){let r=t.substr(c$1-1,3).match(/^[0-7]+/)[0],a=parseInt(r,8);return a>255&&(r=r.slice(0,-1),a=parseInt(r,8)),c$1+=r.length-1,e=t.charCodeAt(c$1),"0"===r&&56!==e&&57!==e||h(),String.fromCharCode(a)}return o(e)?"":String.fromCharCode(e)}}function l(e){const r=c$1;let a=0,i=0;for(let r=0;r<e;++r,++c$1){let e,s=t.charCodeAt(c$1);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,a=16*a+e;}else 95!==i&&0!==r||h(),i=s;}return 95!==i&&c$1-r===e||h(),a}function o(e){return 13===e||10===e}function h(){throw Object.assign(new Error(`Parse error ${f}:${t.slice(0,c$1).split("\n").length}:${c$1-t.lastIndexOf("\n",c$1-1)}`),{idx:c$1})}
|
391
|
+
/* es-module-lexer 1.2.1 */
|
392
|
+
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;}},t="xportmportlassetaromsyncunctionssertvoyiedelecontininstantybreareturdebuggeawaithrwhileforifcatcfinallels";let c$1,f,n;function parse(l,k="@"){c$1=l,f=k;const u=2*c$1.length+(2<<18);if(u>i||!e){for(;u>i;)i*=2;a=new ArrayBuffer(i),s(t,new Uint16Array(a,16,105)),e=function(e,a,r){"use asm";var i=new e.Int8Array(r),s=new e.Int16Array(r),t=new e.Int32Array(r),c=new e.Uint8Array(r),f=new e.Uint16Array(r),n=1024;function b(){var e=0,a=0,r=0,c=0,b=0,u=0,w=0;w=n;n=n+10240|0;i[795]=1;s[395]=0;s[396]=0;t[67]=t[2];i[796]=0;t[66]=0;i[794]=0;t[68]=w+2048;t[69]=w;i[797]=0;e=(t[3]|0)+-2|0;t[70]=e;a=e+(t[64]<<1)|0;t[71]=a;e:while(1){r=e+2|0;t[70]=r;if(e>>>0>=a>>>0){b=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[396]|0)==0?H(r)|0:0)?(m(e+4|0,16,10)|0)==0:0)?(l(),(i[795]|0)==0):0){b=9;break e}else b=17;break}case 105:{if(H(r)|0?(m(e+4|0,26,10)|0)==0:0){k();b=17;}else b=17;break}case 59:{b=17;break}case 47:switch(s[e+4>>1]|0){case 47:{P();break a}case 42:{y(1);break a}default:{b=16;break e}}default:{b=16;break e}}}while(0);if((b|0)==17){b=0;t[67]=t[70];}e=t[70]|0;a=t[71]|0;}if((b|0)==9){e=t[70]|0;t[67]=e;b=19;}else if((b|0)==16){i[795]=0;t[70]=e;b=19;}else if((b|0)==18)if(!(i[794]|0)){e=r;b=19;}else e=0;do{if((b|0)==19){e:while(1){a=e+2|0;t[70]=a;c=a;if(e>>>0>=(t[71]|0)>>>0){b=82;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[396]|0)==0?H(a)|0:0)?(m(e+4|0,16,10)|0)==0:0){l();b=81;}else b=81;break}case 105:{if(H(a)|0?(m(e+4|0,26,10)|0)==0:0){k();b=81;}else b=81;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[797]=1;b=81;}else b=81;break}case 40:{c=t[68]|0;a=s[396]|0;b=a&65535;t[c+(b<<3)>>2]=1;r=t[67]|0;s[396]=a+1<<16>>16;t[c+(b<<3)+4>>2]=r;b=81;break}case 41:{a=s[396]|0;if(!(a<<16>>16)){b=36;break e}a=a+-1<<16>>16;s[396]=a;r=s[395]|0;if(r<<16>>16!=0?(u=t[(t[69]|0)+((r&65535)+-1<<2)>>2]|0,(t[u+20>>2]|0)==(t[(t[68]|0)+((a&65535)<<3)+4>>2]|0)):0){a=u+4|0;if(!(t[a>>2]|0))t[a>>2]=c;t[u+12>>2]=e+4;s[395]=r+-1<<16>>16;b=81;}else b=81;break}case 123:{b=t[67]|0;c=t[61]|0;e=b;do{if((s[b>>1]|0)==41&(c|0)!=0?(t[c+4>>2]|0)==(b|0):0){a=t[62]|0;t[61]=a;if(!a){t[57]=0;break}else {t[a+28>>2]=0;break}}}while(0);c=t[68]|0;r=s[396]|0;b=r&65535;t[c+(b<<3)>>2]=(i[797]|0)==0?2:6;s[396]=r+1<<16>>16;t[c+(b<<3)+4>>2]=e;i[797]=0;b=81;break}case 125:{e=s[396]|0;if(!(e<<16>>16)){b=49;break e}c=t[68]|0;b=e+-1<<16>>16;s[396]=b;if((t[c+((b&65535)<<3)>>2]|0)==4){h();b=81;}else b=81;break}case 39:{d(39);b=81;break}case 34:{d(34);b=81;break}case 47:switch(s[e+4>>1]|0){case 47:{P();break a}case 42:{y(1);break a}default:{e=t[67]|0;c=s[e>>1]|0;r:do{if(!(U(c)|0)){switch(c<<16>>16){case 41:if(D(t[(t[68]|0)+(f[396]<<3)+4>>2]|0)|0){b=69;break r}else {b=66;break r}case 125:break;default:{b=66;break r}}a=t[68]|0;r=f[396]|0;if(!(p(t[a+(r<<3)+4>>2]|0)|0)?(t[a+(r<<3)>>2]|0)!=6:0)b=66;else b=69;}else switch(c<<16>>16){case 46:if(((s[e+-2>>1]|0)+-48&65535)<10){b=66;break r}else {b=69;break r}case 43:if((s[e+-2>>1]|0)==43){b=66;break r}else {b=69;break r}case 45:if((s[e+-2>>1]|0)==45){b=66;break r}else {b=69;break r}default:{b=69;break r}}}while(0);r:do{if((b|0)==66){b=0;if(!(o(e)|0)){switch(c<<16>>16){case 0:{b=69;break r}case 47:{if(i[796]|0){b=69;break r}break}default:{}}r=t[3]|0;a=c;do{if(e>>>0<=r>>>0)break;e=e+-2|0;t[67]=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;t[67]=e;}while(F(s[e>>1]|0)|0);if(j(e)|0){g();i[796]=0;b=81;break a}else e=1;}else e=1;}else b=69;}}while(0);if((b|0)==69){g();e=0;}i[796]=e;b=81;break a}}case 96:{c=t[68]|0;r=s[396]|0;b=r&65535;t[c+(b<<3)+4>>2]=t[67];s[396]=r+1<<16>>16;t[c+(b<<3)>>2]=3;h();b=81;break}default:b=81;}}while(0);if((b|0)==81){b=0;t[67]=t[70];}e=t[70]|0;}if((b|0)==36){T();e=0;break}else if((b|0)==49){T();e=0;break}else if((b|0)==82){e=(i[794]|0)==0?(s[395]|s[396])<<16>>16==0:0;break}}}while(0);n=w;return e|0}function l(){var e=0,a=0,r=0,c=0,f=0,n=0,b=0,l=0,k=0,o=0,h=0,A=0,C=0,g=0;l=t[70]|0;k=t[63]|0;g=l+12|0;t[70]=g;r=w(1)|0;e=t[70]|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:{t[70]=e+2;e=w(1)|0;r=t[70]|0;while(1){if(W(e)|0){d(e);e=(t[70]|0)+2|0;t[70]=e;}else {q(e)|0;e=t[70]|0;}w(1)|0;e=v(r,e)|0;if(e<<16>>16==44){t[70]=(t[70]|0)+2;e=w(1)|0;}a=r;r=t[70]|0;if(e<<16>>16==125){C=15;break}if((r|0)==(a|0)){C=12;break}if(r>>>0>(t[71]|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){t[70]=r+2;break a}break}case 42:{t[70]=e+2;w(1)|0;g=t[70]|0;v(g,g)|0;break}default:{i[795]=0;switch(r<<16>>16){case 100:{l=e+14|0;t[70]=l;switch((w(1)|0)<<16>>16){case 97:{a=t[70]|0;if((m(a+2|0,56,8)|0)==0?(f=a+10|0,F(s[f>>1]|0)|0):0){t[70]=f;w(0)|0;C=22;}break}case 102:{C=22;break}case 99:{a=t[70]|0;if(((m(a+2|0,36,8)|0)==0?(c=a+10|0,g=s[c>>1]|0,V(g)|0|g<<16>>16==123):0)?(t[70]=c,n=w(1)|0,n<<16>>16!=123):0){A=n;C=31;}break}default:{}}r:do{if((C|0)==22?(b=t[70]|0,(m(b+2|0,64,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}t[70]=r;a=w(1)|0;if(a<<16>>16==42){t[70]=(t[70]|0)+2;a=w(1)|0;}if(a<<16>>16!=40){A=a;C=31;}}}while(0);if((C|0)==31?(o=t[70]|0,q(A)|0,h=t[70]|0,h>>>0>o>>>0):0){$(e,l,o,h);t[70]=(t[70]|0)+-2;break e}$(e,l,0,0);t[70]=e+12;break e}case 97:{t[70]=e+10;w(0)|0;e=t[70]|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){t[70]=a;g=w(1)|0;C=t[70]|0;q(g)|0;g=t[70]|0;$(C,g,C,g);t[70]=(t[70]|0)+-2;break e}e=e+4|0;t[70]=e;break}case 108:case 118:break;default:break e}if((C|0)==35){t[70]=e+16;e=w(1)|0;if(e<<16>>16==42){t[70]=(t[70]|0)+2;e=w(1)|0;}C=t[70]|0;q(e)|0;g=t[70]|0;$(C,g,C,g);t[70]=(t[70]|0)+-2;break e}e=e+4|0;t[70]=e;i[795]=0;r:while(1){t[70]=e+2;g=w(1)|0;e=t[70]|0;switch((q(g)|0)<<16>>16){case 91:case 123:break r;default:{}}a=t[70]|0;if((a|0)==(e|0))break e;$(e,a,e,a);if((w(1)|0)<<16>>16!=44)break;e=t[70]|0;}t[70]=(t[70]|0)+-2;break e}}}while(0);g=(w(1)|0)<<16>>16==102;e=t[70]|0;if(g?(m(e+2|0,50,6)|0)==0:0){t[70]=e+8;u(l,w(1)|0);e=(k|0)==0?232:k+16|0;while(1){e=t[e>>2]|0;if(!e)break e;t[e+12>>2]=0;t[e+8>>2]=0;e=e+16|0;}}t[70]=e+-2;}}while(0);return}function k(){var e=0,a=0,r=0,c=0,f=0,n=0;f=t[70]|0;e=f+12|0;t[70]=e;e:do{switch((w(1)|0)<<16>>16){case 40:{a=t[68]|0;n=s[396]|0;r=n&65535;t[a+(r<<3)>>2]=5;e=t[70]|0;s[396]=n+1<<16>>16;t[a+(r<<3)+4>>2]=e;if((s[t[67]>>1]|0)!=46){t[70]=e+2;n=w(1)|0;A(f,t[70]|0,0,e);a=t[61]|0;r=t[69]|0;f=s[395]|0;s[395]=f+1<<16>>16;t[r+((f&65535)<<2)>>2]=a;switch(n<<16>>16){case 39:{d(39);break}case 34:{d(34);break}default:{t[70]=(t[70]|0)+-2;break e}}e=(t[70]|0)+2|0;t[70]=e;switch((w(1)|0)<<16>>16){case 44:{t[70]=(t[70]|0)+2;w(1)|0;f=t[61]|0;t[f+4>>2]=e;n=t[70]|0;t[f+16>>2]=n;i[f+24>>0]=1;t[70]=n+-2;break e}case 41:{s[396]=(s[396]|0)+-1<<16>>16;n=t[61]|0;t[n+4>>2]=e;t[n+12>>2]=(t[70]|0)+2;i[n+24>>0]=1;s[395]=(s[395]|0)+-1<<16>>16;break e}default:{t[70]=(t[70]|0)+-2;break e}}}break}case 46:{t[70]=(t[70]|0)+2;if((w(1)|0)<<16>>16==109?(a=t[70]|0,(m(a+2|0,44,6)|0)==0):0){e=t[67]|0;if(!(G(e)|0)?(s[e>>1]|0)==46:0)break e;A(f,f,a+8|0,2);}break}case 42:case 39:case 34:{c=18;break}case 123:{e=t[70]|0;if(s[396]|0){t[70]=e+-2;break e}while(1){if(e>>>0>=(t[71]|0)>>>0)break;e=w(1)|0;if(!(W(e)|0)){if(e<<16>>16==125){c=33;break}}else d(e);e=(t[70]|0)+2|0;t[70]=e;}if((c|0)==33)t[70]=(t[70]|0)+2;n=(w(1)|0)<<16>>16==102;e=t[70]|0;if(n?m(e+2|0,50,6)|0:0){T();break e}t[70]=e+8;e=w(1)|0;if(W(e)|0){u(f,e);break e}else {T();break e}}default:if((t[70]|0)==(e|0))t[70]=f+10;else c=18;}}while(0);do{if((c|0)==18){if(s[396]|0){t[70]=(t[70]|0)+-2;break}e=t[71]|0;a=t[70]|0;while(1){if(a>>>0>=e>>>0){c=25;break}r=s[a>>1]|0;if(W(r)|0){c=23;break}n=a+2|0;t[70]=n;a=n;}if((c|0)==23){u(f,r);break}else if((c|0)==25){T();break}}}while(0);return}function u(e,a){e=e|0;a=a|0;var r=0,i=0;r=(t[70]|0)+2|0;switch(a<<16>>16){case 39:{d(39);i=5;break}case 34:{d(34);i=5;break}default:T();}do{if((i|0)==5){A(e,r,t[70]|0,1);t[70]=(t[70]|0)+2;a=w(0)|0;e=a<<16>>16==97;if(e){r=t[70]|0;if(m(r+2|0,78,10)|0)i=11;}else {r=t[70]|0;if(!(((a<<16>>16==119?(s[r+2>>1]|0)==105:0)?(s[r+4>>1]|0)==116:0)?(s[r+6>>1]|0)==104:0))i=11;}if((i|0)==11){t[70]=r+-2;break}t[70]=r+((e?6:4)<<1);if((w(1)|0)<<16>>16!=123){t[70]=r;break}e=t[70]|0;a=e;e:while(1){t[70]=a+2;a=w(1)|0;switch(a<<16>>16){case 39:{d(39);t[70]=(t[70]|0)+2;a=w(1)|0;break}case 34:{d(34);t[70]=(t[70]|0)+2;a=w(1)|0;break}default:a=q(a)|0;}if(a<<16>>16!=58){i=20;break}t[70]=(t[70]|0)+2;switch((w(1)|0)<<16>>16){case 39:{d(39);break}case 34:{d(34);break}default:{i=24;break e}}t[70]=(t[70]|0)+2;switch((w(1)|0)<<16>>16){case 125:{i=29;break e}case 44:break;default:{i=28;break e}}t[70]=(t[70]|0)+2;if((w(1)|0)<<16>>16==125){i=29;break}a=t[70]|0;}if((i|0)==20){t[70]=r;break}else if((i|0)==24){t[70]=r;break}else if((i|0)==28){t[70]=r;break}else if((i|0)==29){i=t[61]|0;t[i+16>>2]=e;t[i+12>>2]=(t[70]|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=O(e+-4|0,88,2)|0;break e}case 108:{e=O(e+-4|0,92,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=O(e+-4|0,98,4)|0;break e}case 117:{e=O(e+-4|0,106,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=O(e+-8|0,118,6)|0;break e}case 112:{e=O(e+-8|0,130,2)|0;break e}default:{e=0;break e}}else e=0;break}case 107:{e=O(e+-2|0,134,4)|0;break}case 110:{e=e+-2|0;if(B(e,105)|0)e=1;else e=O(e,142,5)|0;break}case 111:{e=B(e+-2|0,100)|0;break}case 114:{e=O(e+-2|0,152,7)|0;break}case 116:{e=O(e+-2|0,166,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=O(e+-4|0,174,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=t[71]|0;r=t[70]|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;t[70]=e;a=t[68]|0;i=s[396]|0;r=i&65535;t[a+(r<<3)>>2]=4;s[396]=i+1<<16>>16;t[a+(r<<3)+4>>2]=e;}else if((a|0)==7){t[70]=e;r=t[68]|0;i=(s[396]|0)+-1<<16>>16;s[396]=i;if((t[r+((i&65535)<<3)>>2]|0)!=3)T();}else if((a|0)==10){t[70]=e;T();}return}function w(e){e=e|0;var a=0,r=0,i=0;r=t[70]|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=t[70]|0;r=i+2|0;t[70]=r;}while(i>>>0<(t[71]|0)>>>0);return a|0}function d(e){e=e|0;var a=0,r=0,i=0,c=0;c=t[71]|0;a=t[70]|0;while(1){i=a+2|0;if(a>>>0>=c>>>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){t[70]=i;T();}else if((a|0)==10)t[70]=i;return}function v(e,a){e=e|0;a=a|0;var r=0,i=0,c=0,f=0;r=t[70]|0;i=s[r>>1]|0;f=(e|0)==(a|0);c=f?0:e;f=f?0:a;if(i<<16>>16==97){t[70]=r+4;r=w(1)|0;e=t[70]|0;if(W(r)|0){d(r);a=(t[70]|0)+2|0;t[70]=a;}else {q(r)|0;a=t[70]|0;}i=w(1)|0;r=t[70]|0;}if((r|0)!=(e|0))$(e,a,c,f);return i|0}function A(e,a,r,s){e=e|0;a=a|0;r=r|0;s=s|0;var c=0,f=0;c=t[65]|0;t[65]=c+32;f=t[61]|0;t[((f|0)==0?228:f+28|0)>>2]=c;t[62]=f;t[61]=c;t[c+8>>2]=e;if(2==(s|0))e=r;else e=1==(s|0)?r+2|0:0;t[c+12>>2]=e;t[c>>2]=a;t[c+4>>2]=r;t[c+16>>2]=0;t[c+20>>2]=s;i[c+24>>0]=1==(s|0)&1;t[c+28>>2]=0;return}function C(){var e=0,a=0,r=0;r=t[71]|0;a=t[70]|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){t[70]=e;T();e=0;}else if((a|0)==7){t[70]=e;e=93;}return e|0}function g(){var e=0,a=0,r=0;e:while(1){e=t[70]|0;a=e+2|0;t[70]=a;if(e>>>0>=(t[71]|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:{t[70]=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=O(e+-2|0,200,4)|0;break}case 121:{e=O(e+-2|0,208,6)|0;break}case 101:{e=O(e+-2|0,220,3)|0;break}default:e=0;}return e|0}function y(e){e=e|0;var a=0,r=0,i=0,c=0,f=0;c=(t[70]|0)+2|0;t[70]=c;r=t[71]|0;while(1){a=c+2|0;if(c>>>0>=r>>>0)break;i=s[a>>1]|0;if(!e?Z(i)|0:0)break;if(i<<16>>16==42?(s[c+4>>1]|0)==47:0){f=8;break}c=a;}if((f|0)==8){t[70]=a;a=c+4|0;}t[70]=a;return}function m(e,a,r){e=e|0;a=a|0;r=r|0;var s=0,t=0;e:do{if(!r)e=0;else {while(1){s=i[e>>0]|0;t=i[a>>0]|0;if(s<<24>>24!=t<<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)-(t&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,c=0;r=n;n=n+16|0;i=r;t[i>>2]=0;t[64]=e;a=t[3]|0;c=a+(e<<1)|0;e=c+2|0;s[c>>1]=0;t[i>>2]=e;t[65]=e;t[57]=0;t[61]=0;t[59]=0;t[58]=0;t[63]=0;t[60]=0;n=r;return a|0}function O(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=t[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 $(e,a,r,i){e=e|0;a=a|0;r=r|0;i=i|0;var s=0,c=0;s=t[65]|0;t[65]=s+20;c=t[63]|0;t[((c|0)==0?232:c+16|0)>>2]=s;t[63]=s;t[s>>2]=e;t[s+4>>2]=a;t[s+8>>2]=r;t[s+12>>2]=i;t[s+16>>2]=0;return}function j(e){e=e|0;switch(s[e>>1]|0){case 107:{e=O(e+-2|0,134,4)|0;break}case 101:{if((s[e+-2>>1]|0)==117)e=O(e+-4|0,106,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=t[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=t[71]|0;r=t[70]|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;}}t[70]=a;return}function q(e){e=e|0;while(1){if(V(e)|0)break;if(I(e)|0)break;e=(t[70]|0)+2|0;t[70]=e;e=s[e>>1]|0;if(!(e<<16>>16)){e=0;break}}return e|0}function z(){var e=0;e=t[(t[59]|0)+20>>2]|0;switch(e|0){case 1:{e=-1;break}case 2:{e=-2;break}default:e=e-(t[3]|0)>>1;}return e|0}function D(e){e=e|0;if(!(O(e,180,5)|0)?!(O(e,190,3)|0):0)e=O(e,196,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((t[3]|0)==(e|0))e=1;else e=x(e+-2|0)|0;return e|0}function J(){var e=0;e=t[(t[60]|0)+12>>2]|0;if(!e)e=-1;else e=e-(t[3]|0)>>1;return e|0}function K(){var e=0;e=t[(t[59]|0)+12>>2]|0;if(!e)e=-1;else e=e-(t[3]|0)>>1;return e|0}function L(){var e=0;e=t[(t[60]|0)+8>>2]|0;if(!e)e=-1;else e=e-(t[3]|0)>>1;return e|0}function M(){var e=0;e=t[(t[59]|0)+16>>2]|0;if(!e)e=-1;else e=e-(t[3]|0)>>1;return e|0}function N(){var e=0;e=t[(t[59]|0)+4>>2]|0;if(!e)e=-1;else e=e-(t[3]|0)>>1;return e|0}function Q(){var e=0;e=t[59]|0;e=t[((e|0)==0?228:e+28|0)>>2]|0;t[59]=e;return (e|0)!=0|0}function R(){var e=0;e=t[60]|0;e=t[((e|0)==0?232:e+16|0)>>2]|0;t[60]=e;return (e|0)!=0|0}function T(){i[794]=1;t[66]=(t[70]|0)-(t[3]|0)>>1;t[70]=(t[71]|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 (t[(t[59]|0)+8>>2]|0)-(t[3]|0)>>1|0}function Y(){return (t[(t[60]|0)+4>>2]|0)-(t[3]|0)>>1|0}function Z(e){e=e|0;return e<<16>>16==13|e<<16>>16==10|0}function _(){return (t[t[59]>>2]|0)-(t[3]|0)>>1|0}function ee(){return (t[t[60]>>2]|0)-(t[3]|0)>>1|0}function ae(){return c[(t[59]|0)+24>>0]|0|0}function re(e){e=e|0;t[3]=e;return}function ie(){return (i[795]|0)!=0|0}function se(){return t[66]|0}function te(e){e=e|0;n=e+992+15&-16;return 992}return {su:te,ai:M,e:se,ee:Y,ele:J,els:L,es:ee,f:ie,id:z,ie:N,ip:ae,is:_,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=c$1.length+1;e.ses(r),e.sa(h-1),s(c$1,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(),t=e.ss(),f=e.se();let n;e.ip()&&(n=b(-1===s?a:a+1,c$1.charCodeAt(-1===s?a-1:a))),w.push({n:n,s:a,e:r,ss:t,se:f,d:s,a:i});}for(;e.re();){const a=e.es(),r=e.ee(),i=e.els(),s=e.ele(),t=c$1.charCodeAt(a),f=i>=0?c$1.charCodeAt(i):-1;d.push({s:a,e:r,ls:i,le:s,n:34===t||39===t?b(a+1,t):c$1.slice(a,r),ln:i<0?void 0:34===f||39===f?b(i+1,f):c$1.slice(i,s)});}return [w,d,!!e.f()]}function b(e,a){n=e;let r="",i=n;for(;;){n>=c$1.length&&o();const e=c$1.charCodeAt(n);if(e===a)break;92===e?(r+=c$1.slice(i,n),r+=l(),i=n):(8232===e||8233===e||u(e)&&o(),++n);}return r+=c$1.slice(i,n++),r}function l(){let e=c$1.charCodeAt(++n);switch(++n,e){case 110:return "\n";case 114:return "\r";case 120:return String.fromCharCode(k(2));case 117:return function(){const e=c$1.charCodeAt(n);let a;123===e?(++n,a=k(c$1.indexOf("}",n)-n),++n,a>1114111&&o()):a=k(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===c$1.charCodeAt(n)&&++n;case 10:return "";case 56:case 57:o();default:if(e>=48&&e<=55){let a=c$1.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=c$1.charCodeAt(n),"0"===a&&56!==e&&57!==e||o(),String.fromCharCode(r)}return u(e)?"":String.fromCharCode(e)}}function k(e){const a=n;let r=0,i=0;for(let a=0;a<e;++a,++n){let e,s=c$1.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 ${f}:${c$1.slice(0,n).split("\n").length}:${n-c$1.lastIndexOf("\n",n-1)}`),{idx:n})}
|
302
393
|
|
303
|
-
async function defaultResolve (id, parentUrl) {
|
304
|
-
return resolveImportMap(importMap, resolveIfNotPlainOrUrl(id, parentUrl) || id, parentUrl);
|
305
|
-
}
|
306
|
-
|
307
394
|
async function _resolve (id, parentUrl) {
|
308
395
|
const urlResolved = resolveIfNotPlainOrUrl(id, parentUrl);
|
309
396
|
return {
|
310
|
-
r: resolveImportMap(importMap, urlResolved || id, parentUrl),
|
397
|
+
r: resolveImportMap(importMap, urlResolved || id, parentUrl) || throwUnresolved(id, parentUrl),
|
311
398
|
// b = bare specifier
|
312
399
|
b: !urlResolved && !isURL(id)
|
313
400
|
};
|
314
401
|
}
|
315
402
|
|
316
|
-
const resolve = resolveHook ? async (id, parentUrl) =>
|
403
|
+
const resolve = resolveHook ? async (id, parentUrl) => {
|
404
|
+
let result = resolveHook(id, parentUrl, defaultResolve);
|
405
|
+
// will be deprecated in next major
|
406
|
+
if (result && result.then)
|
407
|
+
result = await result;
|
408
|
+
return result ? { r: result, b: !resolveIfNotPlainOrUrl(id, parentUrl) && !isURL(id) } : _resolve(id, parentUrl);
|
409
|
+
} : _resolve;
|
410
|
+
|
411
|
+
// importShim('mod');
|
412
|
+
// importShim('mod', { opts });
|
413
|
+
// importShim('mod', { opts }, parentUrl);
|
414
|
+
// importShim('mod', parentUrl);
|
415
|
+
async function importShim (id, ...args) {
|
416
|
+
// parentUrl if present will be the last argument
|
417
|
+
let parentUrl = args[args.length - 1];
|
418
|
+
if (typeof parentUrl !== 'string')
|
419
|
+
parentUrl = baseUrl;
|
420
|
+
// needed for shim check
|
421
|
+
await initPromise;
|
422
|
+
if (importHook) await importHook(id, typeof args[1] !== 'string' ? args[1] : {}, parentUrl);
|
423
|
+
if (acceptingImportMaps || shimMode || !baselinePassthrough) {
|
424
|
+
if (hasDocument)
|
425
|
+
processScriptsAndPreloads(true);
|
426
|
+
if (!shimMode)
|
427
|
+
acceptingImportMaps = false;
|
428
|
+
}
|
429
|
+
await importMapPromise;
|
430
|
+
return topLevelLoad((await resolve(id, parentUrl)).r, { credentials: 'same-origin' });
|
431
|
+
}
|
432
|
+
|
433
|
+
self.importShim = importShim;
|
434
|
+
|
435
|
+
function defaultResolve (id, parentUrl) {
|
436
|
+
return resolveImportMap(importMap, resolveIfNotPlainOrUrl(id, parentUrl) || id, parentUrl) || throwUnresolved(id, parentUrl);
|
437
|
+
}
|
438
|
+
|
439
|
+
function throwUnresolved (id, parentUrl) {
|
440
|
+
throw Error(`Unable to resolve specifier '${id}'${fromParent(parentUrl)}`);
|
441
|
+
}
|
317
442
|
|
318
|
-
|
319
|
-
|
443
|
+
const resolveSync = (id, parentUrl = baseUrl) => {
|
444
|
+
parentUrl = `${parentUrl}`;
|
445
|
+
const result = resolveHook && resolveHook(id, parentUrl, defaultResolve);
|
446
|
+
return result && !result.then ? result : defaultResolve(id, parentUrl);
|
447
|
+
};
|
448
|
+
|
449
|
+
function metaResolve (id, parentUrl = this.url) {
|
450
|
+
return resolveSync(id, parentUrl);
|
451
|
+
}
|
452
|
+
|
453
|
+
importShim.resolve = resolveSync;
|
454
|
+
importShim.getImportMap = () => JSON.parse(JSON.stringify(importMap));
|
455
|
+
importShim.addImportMap = importMapIn => {
|
456
|
+
if (!shimMode) throw new Error('Unsupported in polyfill mode.');
|
457
|
+
importMap = resolveAndComposeImportMap(importMapIn, baseUrl, importMap);
|
458
|
+
};
|
459
|
+
|
460
|
+
const registry = importShim._r = {};
|
320
461
|
|
321
462
|
async function loadAll (load, seen) {
|
322
463
|
if (load.b || seen[load.u])
|
@@ -329,50 +470,50 @@
|
|
329
470
|
}
|
330
471
|
|
331
472
|
let importMap = { imports: {}, scopes: {} };
|
332
|
-
let importMapSrcOrLazy = false;
|
333
473
|
let baselinePassthrough;
|
334
474
|
|
335
475
|
const initPromise = featureDetectionPromise.then(() => {
|
336
|
-
|
337
|
-
if (
|
338
|
-
if (
|
339
|
-
|
476
|
+
baselinePassthrough = esmsInitOptions.polyfillEnable !== true && supportsDynamicImport && supportsImportMeta && supportsImportMaps && (!jsonModulesEnabled || supportsJsonAssertions) && (!cssModulesEnabled || supportsCssAssertions) && !importMapSrcOrLazy;
|
477
|
+
if (hasDocument) {
|
478
|
+
if (!supportsImportMaps) {
|
479
|
+
const supports = HTMLScriptElement.supports || (type => type === 'classic' || type === 'module');
|
480
|
+
HTMLScriptElement.supports = type => type === 'importmap' || supports(type);
|
340
481
|
}
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
482
|
+
if (shimMode || !baselinePassthrough) {
|
483
|
+
new MutationObserver(mutations => {
|
484
|
+
for (const mutation of mutations) {
|
485
|
+
if (mutation.type !== 'childList') continue;
|
486
|
+
for (const node of mutation.addedNodes) {
|
487
|
+
if (node.tagName === 'SCRIPT') {
|
488
|
+
if (node.type === (shimMode ? 'module-shim' : 'module'))
|
489
|
+
processScript(node, true);
|
490
|
+
if (node.type === (shimMode ? 'importmap-shim' : 'importmap'))
|
491
|
+
processImportMap(node, true);
|
492
|
+
}
|
493
|
+
else if (node.tagName === 'LINK' && node.rel === (shimMode ? 'modulepreload-shim' : 'modulepreload')) {
|
494
|
+
processPreload(node);
|
495
|
+
}
|
496
|
+
}
|
351
497
|
}
|
498
|
+
}).observe(document, {childList: true, subtree: true});
|
499
|
+
processScriptsAndPreloads();
|
500
|
+
if (document.readyState === 'complete') {
|
501
|
+
readyStateCompleteCheck();
|
352
502
|
}
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
for (const node of mutation.addedNodes) {
|
361
|
-
if (node.tagName === 'SCRIPT') {
|
362
|
-
if (node.type === (shimMode ? 'module-shim' : 'module'))
|
363
|
-
processScript(node);
|
364
|
-
if (node.type === (shimMode ? 'importmap-shim' : 'importmap'))
|
365
|
-
processImportMap(node);
|
503
|
+
else {
|
504
|
+
async function readyListener() {
|
505
|
+
await initPromise;
|
506
|
+
processScriptsAndPreloads();
|
507
|
+
if (document.readyState === 'complete') {
|
508
|
+
readyStateCompleteCheck();
|
509
|
+
document.removeEventListener('readystatechange', readyListener);
|
366
510
|
}
|
367
|
-
else if (node.tagName === 'LINK' && node.rel === (shimMode ? 'modulepreload-shim' : 'modulepreload'))
|
368
|
-
processPreload(node);
|
369
511
|
}
|
512
|
+
document.addEventListener('readystatechange', readyListener);
|
370
513
|
}
|
371
|
-
}
|
372
|
-
processImportMaps();
|
373
|
-
processScriptsAndPreloads();
|
374
|
-
return undefined;
|
514
|
+
}
|
375
515
|
}
|
516
|
+
return undefined;
|
376
517
|
});
|
377
518
|
let importMapPromise = initPromise;
|
378
519
|
let firstPolyfillLoad = true;
|
@@ -381,7 +522,9 @@
|
|
381
522
|
async function topLevelLoad (url, fetchOpts, source, nativelyLoaded, lastStaticLoadPromise) {
|
382
523
|
if (!shimMode)
|
383
524
|
acceptingImportMaps = false;
|
525
|
+
await initPromise;
|
384
526
|
await importMapPromise;
|
527
|
+
if (importHook) await importHook(url, typeof fetchOpts !== 'string' ? fetchOpts : {}, '');
|
385
528
|
// early analysis opt-out - no need to even fetch if we have feature support
|
386
529
|
if (!shimMode && baselinePassthrough) {
|
387
530
|
// for polyfill case, only dynamic import needs a return value here, and dynamic import will never pass nativelyLoaded
|
@@ -390,16 +533,16 @@
|
|
390
533
|
await lastStaticLoadPromise;
|
391
534
|
return dynamicImport(source ? createBlob(source) : url, { errUrl: url || source });
|
392
535
|
}
|
393
|
-
const load = getOrCreateLoad(url, fetchOpts, source);
|
536
|
+
const load = getOrCreateLoad(url, fetchOpts, null, source);
|
394
537
|
const seen = {};
|
395
538
|
await loadAll(load, seen);
|
396
539
|
lastLoad = undefined;
|
397
540
|
resolveDeps(load, seen);
|
398
541
|
await lastStaticLoadPromise;
|
399
|
-
if (source && !shimMode && !load.n
|
400
|
-
|
542
|
+
if (source && !shimMode && !load.n) {
|
543
|
+
if (nativelyLoaded) return;
|
401
544
|
if (revokeBlobURLs) revokeObjectURLs(Object.keys(seen));
|
402
|
-
return
|
545
|
+
return await dynamicImport(createBlob(source), { errUrl: source });
|
403
546
|
}
|
404
547
|
if (firstPolyfillLoad && !shimMode && load.n && nativelyLoaded) {
|
405
548
|
onpolyfill();
|
@@ -432,32 +575,6 @@
|
|
432
575
|
}
|
433
576
|
}
|
434
577
|
|
435
|
-
async function importShim (id, parentUrl = baseUrl, _assertion) {
|
436
|
-
// needed for shim check
|
437
|
-
await initPromise;
|
438
|
-
if (acceptingImportMaps || shimMode || !baselinePassthrough) {
|
439
|
-
processImportMaps();
|
440
|
-
if (!shimMode)
|
441
|
-
acceptingImportMaps = false;
|
442
|
-
}
|
443
|
-
await importMapPromise;
|
444
|
-
return topLevelLoad((await resolve(id, parentUrl)).r || throwUnresolved(id, parentUrl), { credentials: 'same-origin' });
|
445
|
-
}
|
446
|
-
|
447
|
-
self.importShim = importShim;
|
448
|
-
|
449
|
-
if (shimMode) {
|
450
|
-
importShim.getImportMap = () => JSON.parse(JSON.stringify(importMap));
|
451
|
-
}
|
452
|
-
|
453
|
-
const meta = {};
|
454
|
-
|
455
|
-
async function importMetaResolve (id, parentUrl = this.url) {
|
456
|
-
return (await resolve(id, `${parentUrl}`)).r || throwUnresolved(id, parentUrl);
|
457
|
-
}
|
458
|
-
|
459
|
-
self._esmsm = meta;
|
460
|
-
|
461
578
|
function urlJsString (url) {
|
462
579
|
return `'${url.replace(/'/g, "\\'")}'`;
|
463
580
|
}
|
@@ -471,7 +588,7 @@
|
|
471
588
|
for (const dep of load.d)
|
472
589
|
resolveDeps(dep, seen);
|
473
590
|
|
474
|
-
const [imports] = load.a;
|
591
|
+
const [imports, exports] = load.a;
|
475
592
|
|
476
593
|
// "execution"
|
477
594
|
const source = load.S;
|
@@ -485,53 +602,70 @@
|
|
485
602
|
else {
|
486
603
|
// once all deps have loaded we can inline the dependency resolution blobs
|
487
604
|
// and define this blob
|
488
|
-
let lastIndex = 0, depIndex = 0;
|
489
|
-
|
605
|
+
let lastIndex = 0, depIndex = 0, dynamicImportEndStack = [];
|
606
|
+
function pushStringTo (originalIndex) {
|
607
|
+
while (dynamicImportEndStack[dynamicImportEndStack.length - 1] < originalIndex) {
|
608
|
+
const dynamicImportEnd = dynamicImportEndStack.pop();
|
609
|
+
resolvedSource += `${source.slice(lastIndex, dynamicImportEnd)}, ${urlJsString(load.r)}`;
|
610
|
+
lastIndex = dynamicImportEnd;
|
611
|
+
}
|
612
|
+
resolvedSource += source.slice(lastIndex, originalIndex);
|
613
|
+
lastIndex = originalIndex;
|
614
|
+
}
|
615
|
+
for (const { s: start, ss: statementStart, se: statementEnd, d: dynamicImportIndex } of imports) {
|
490
616
|
// dependency source replacements
|
491
617
|
if (dynamicImportIndex === -1) {
|
492
|
-
|
493
|
-
|
494
|
-
if (!blobUrl) {
|
618
|
+
let depLoad = load.d[depIndex++], blobUrl = depLoad.b, cycleShell = !blobUrl;
|
619
|
+
if (cycleShell) {
|
495
620
|
// circular shell creation
|
496
621
|
if (!(blobUrl = depLoad.s)) {
|
497
622
|
blobUrl = depLoad.s = createBlob(`export function u$_(m){${
|
498
|
-
depLoad.a[1].map(
|
499
|
-
|
500
|
-
|
623
|
+
depLoad.a[1].map(({ s, e }, i) => {
|
624
|
+
const q = depLoad.S[s] === '"' || depLoad.S[s] === "'";
|
625
|
+
return `e$_${i}=m${q ? `[` : '.'}${depLoad.S.slice(s, e)}${q ? `]` : ''}`;
|
626
|
+
}).join(',')
|
501
627
|
}}${
|
502
|
-
depLoad.a[1].map(
|
503
|
-
|
504
|
-
).join('
|
505
|
-
}\n//# sourceURL=${depLoad.r}?cycle`);
|
628
|
+
depLoad.a[1].length ? `let ${depLoad.a[1].map((_, i) => `e$_${i}`).join(',')};` : ''
|
629
|
+
}export {${
|
630
|
+
depLoad.a[1].map(({ s, e }, i) => `e$_${i} as ${depLoad.S.slice(s, e)}`).join(',')
|
631
|
+
}}\n//# sourceURL=${depLoad.r}?cycle`);
|
506
632
|
}
|
507
633
|
}
|
634
|
+
|
635
|
+
pushStringTo(start - 1);
|
636
|
+
resolvedSource += `/*${source.slice(start - 1, statementEnd)}*/${urlJsString(blobUrl)}`;
|
637
|
+
|
508
638
|
// circular shell execution
|
509
|
-
|
510
|
-
resolvedSource +=
|
511
|
-
lastIndex = end;
|
639
|
+
if (!cycleShell && depLoad.s) {
|
640
|
+
resolvedSource += `;import*as m$_${depIndex} from'${depLoad.b}';import{u$_ as u$_${depIndex}}from'${depLoad.s}';u$_${depIndex}(m$_${depIndex})`;
|
512
641
|
depLoad.s = undefined;
|
513
|
-
continue;
|
514
642
|
}
|
515
|
-
|
516
|
-
lastIndex = end;
|
643
|
+
lastIndex = statementEnd;
|
517
644
|
}
|
518
645
|
// import.meta
|
519
646
|
else if (dynamicImportIndex === -2) {
|
520
|
-
|
521
|
-
|
522
|
-
|
647
|
+
load.m = { url: load.r, resolve: metaResolve };
|
648
|
+
metaHook(load.m, load.u);
|
649
|
+
pushStringTo(start);
|
650
|
+
resolvedSource += `importShim._r[${urlJsString(load.u)}].m`;
|
651
|
+
lastIndex = statementEnd;
|
523
652
|
}
|
524
653
|
// dynamic import
|
525
654
|
else {
|
526
|
-
|
527
|
-
|
655
|
+
pushStringTo(statementStart + 6);
|
656
|
+
resolvedSource += `Shim(`;
|
657
|
+
dynamicImportEndStack.push(statementEnd - 1);
|
658
|
+
lastIndex = start;
|
528
659
|
}
|
529
660
|
}
|
530
661
|
|
531
|
-
|
662
|
+
// support progressive cycle binding updates (try statement avoids tdz errors)
|
663
|
+
if (load.s)
|
664
|
+
resolvedSource += `\n;import{u$_}from'${load.s}';try{u$_({${exports.filter(e => e.ln).map(({ s, e, ln }) => `${source.slice(s, e)}:${ln}`).join(',')}})}catch(_){};\n`;
|
665
|
+
|
666
|
+
pushStringTo(source.length);
|
532
667
|
}
|
533
668
|
|
534
|
-
// ; and // trailer support added for Ruby 7 source maps compatibility
|
535
669
|
let hasSourceURL = false;
|
536
670
|
resolvedSource = resolvedSource.replace(sourceMapURLRegEx, (match, isMapping, url) => (hasSourceURL = !isMapping, match.replace(url, () => new URL(url, load.r))));
|
537
671
|
if (!hasSourceURL)
|
@@ -541,6 +675,8 @@
|
|
541
675
|
load.S = undefined;
|
542
676
|
}
|
543
677
|
|
678
|
+
// ; and // trailer support added for Ruby on Rails 7 source maps compatibility
|
679
|
+
// https://github.com/guybedford/es-module-shims/issues/228
|
544
680
|
const sourceMapURLRegEx = /\n\/\/# source(Mapping)?URL=([^\n]+)\s*((;|\/\/[^#][^\n]*)\s*)*$/;
|
545
681
|
|
546
682
|
const jsContentType = /^(text|application)\/(x-)?javascript(;|$)/;
|
@@ -562,42 +698,52 @@
|
|
562
698
|
p.shift()();
|
563
699
|
}
|
564
700
|
|
565
|
-
async function doFetch (url, fetchOpts) {
|
701
|
+
async function doFetch (url, fetchOpts, parent) {
|
566
702
|
if (enforceIntegrity && !fetchOpts.integrity)
|
567
|
-
throw Error(`No integrity for ${url}
|
703
|
+
throw Error(`No integrity for ${url}${fromParent(parent)}.`);
|
568
704
|
const poolQueue = pushFetchPool();
|
569
705
|
if (poolQueue) await poolQueue;
|
570
706
|
try {
|
571
707
|
var res = await fetchHook(url, fetchOpts);
|
572
708
|
}
|
709
|
+
catch (e) {
|
710
|
+
e.message = `Unable to fetch ${url}${fromParent(parent)} - see network log for details.\n` + e.message;
|
711
|
+
throw e;
|
712
|
+
}
|
573
713
|
finally {
|
574
714
|
popFetchPool();
|
575
715
|
}
|
576
716
|
if (!res.ok)
|
577
|
-
throw Error(`${res.status} ${res.statusText} ${res.url}`);
|
717
|
+
throw Error(`${res.status} ${res.statusText} ${res.url}${fromParent(parent)}`);
|
718
|
+
return res;
|
719
|
+
}
|
720
|
+
|
721
|
+
async function fetchModule (url, fetchOpts, parent) {
|
722
|
+
const res = await doFetch(url, fetchOpts, parent);
|
578
723
|
const contentType = res.headers.get('content-type');
|
579
724
|
if (jsContentType.test(contentType))
|
580
725
|
return { r: res.url, s: await res.text(), t: 'js' };
|
581
726
|
else if (jsonContentType.test(contentType))
|
582
727
|
return { r: res.url, s: `export default ${await res.text()}`, t: 'json' };
|
583
|
-
else if (cssContentType.test(contentType))
|
728
|
+
else if (cssContentType.test(contentType)) {
|
584
729
|
return { r: res.url, s: `var s=new CSSStyleSheet();s.replaceSync(${
|
585
|
-
|
586
|
-
|
730
|
+
JSON.stringify((await res.text()).replace(cssUrlRegEx, (_match, quotes = '', relUrl1, relUrl2) => `url(${quotes}${resolveUrl(relUrl1 || relUrl2, url)}${quotes})`))
|
731
|
+
});export default s;`, t: 'css' };
|
732
|
+
}
|
587
733
|
else
|
588
|
-
throw Error(`Unsupported Content-Type "${contentType}"
|
734
|
+
throw Error(`Unsupported Content-Type "${contentType}" loading ${url}${fromParent(parent)}. Modules must be served with a valid MIME type like application/javascript.`);
|
589
735
|
}
|
590
736
|
|
591
|
-
function getOrCreateLoad (url, fetchOpts, source) {
|
737
|
+
function getOrCreateLoad (url, fetchOpts, parent, source) {
|
592
738
|
let load = registry[url];
|
593
|
-
if (load)
|
739
|
+
if (load && !source)
|
594
740
|
return load;
|
595
741
|
|
596
|
-
load =
|
742
|
+
load = {
|
597
743
|
// url
|
598
744
|
u: url,
|
599
745
|
// response url
|
600
|
-
r: undefined,
|
746
|
+
r: source ? url : undefined,
|
601
747
|
// fetchPromise
|
602
748
|
f: undefined,
|
603
749
|
// source
|
@@ -615,14 +761,22 @@
|
|
615
761
|
// needsShim
|
616
762
|
n: false,
|
617
763
|
// type
|
618
|
-
t: null
|
764
|
+
t: null,
|
765
|
+
// meta
|
766
|
+
m: null
|
619
767
|
};
|
768
|
+
if (registry[url]) {
|
769
|
+
let i = 0;
|
770
|
+
while (registry[load.u + ++i]);
|
771
|
+
load.u += i;
|
772
|
+
}
|
773
|
+
registry[load.u] = load;
|
620
774
|
|
621
775
|
load.f = (async () => {
|
622
776
|
if (!source) {
|
623
777
|
// preload fetch options override fetch options (race)
|
624
778
|
let t;
|
625
|
-
({ r: load.r, s: source, t } = await (fetchCache[url] ||
|
779
|
+
({ r: load.r, s: source, t } = await (fetchCache[url] || fetchModule(url, fetchOpts, parent)));
|
626
780
|
if (t && !shimMode) {
|
627
781
|
if (t === 'css' && !cssModulesEnabled || t === 'json' && !jsonModulesEnabled)
|
628
782
|
throw Error(`${t}-modules require <script type="esms-options">{ "polyfillEnable": ["${t}-modules"] }<${''}/script>`);
|
@@ -634,8 +788,8 @@
|
|
634
788
|
load.a = parse(source, load.u);
|
635
789
|
}
|
636
790
|
catch (e) {
|
637
|
-
|
638
|
-
load.a = [[], []];
|
791
|
+
throwError(e);
|
792
|
+
load.a = [[], [], false];
|
639
793
|
}
|
640
794
|
load.S = source;
|
641
795
|
return load;
|
@@ -644,46 +798,43 @@
|
|
644
798
|
load.L = load.f.then(async () => {
|
645
799
|
let childFetchOpts = fetchOpts;
|
646
800
|
load.d = (await Promise.all(load.a[0].map(async ({ n, d }) => {
|
647
|
-
if (d >= 0 && !supportsDynamicImport || d === 2 && !supportsImportMeta)
|
801
|
+
if (d >= 0 && !supportsDynamicImport || d === -2 && !supportsImportMeta)
|
648
802
|
load.n = true;
|
649
|
-
if (!n) return;
|
803
|
+
if (d !== -1 || !n) return;
|
650
804
|
const { r, b } = await resolve(n, load.r || load.u);
|
651
805
|
if (b && (!supportsImportMaps || importMapSrcOrLazy))
|
652
806
|
load.n = true;
|
653
807
|
if (d !== -1) return;
|
654
|
-
if (
|
655
|
-
throwUnresolved(n, load.r || load.u);
|
656
|
-
if (skip && skip.test(r)) return { b: r };
|
808
|
+
if (skip && skip(r)) return { b: r };
|
657
809
|
if (childFetchOpts.integrity)
|
658
810
|
childFetchOpts = Object.assign({}, childFetchOpts, { integrity: undefined });
|
659
|
-
return getOrCreateLoad(r, childFetchOpts).f;
|
811
|
+
return getOrCreateLoad(r, childFetchOpts, load.r).f;
|
660
812
|
}))).filter(l => l);
|
661
813
|
});
|
662
814
|
|
663
815
|
return load;
|
664
816
|
}
|
665
817
|
|
666
|
-
function processScriptsAndPreloads () {
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
}
|
672
|
-
|
673
|
-
function processImportMaps () {
|
674
|
-
for (const script of document.querySelectorAll(shimMode ? 'script[type="importmap-shim"]' : 'script[type="importmap"]'))
|
818
|
+
function processScriptsAndPreloads (mapsOnly = false) {
|
819
|
+
if (!mapsOnly)
|
820
|
+
for (const link of document.querySelectorAll(shimMode ? 'link[rel=modulepreload-shim]' : 'link[rel=modulepreload]'))
|
821
|
+
processPreload(link);
|
822
|
+
for (const script of document.querySelectorAll(shimMode ? 'script[type=importmap-shim]' : 'script[type=importmap]'))
|
675
823
|
processImportMap(script);
|
824
|
+
if (!mapsOnly)
|
825
|
+
for (const script of document.querySelectorAll(shimMode ? 'script[type=module-shim]' : 'script[type=module]'))
|
826
|
+
processScript(script);
|
676
827
|
}
|
677
828
|
|
678
829
|
function getFetchOpts (script) {
|
679
830
|
const fetchOpts = {};
|
680
831
|
if (script.integrity)
|
681
832
|
fetchOpts.integrity = script.integrity;
|
682
|
-
if (script.
|
683
|
-
fetchOpts.referrerPolicy = script.
|
684
|
-
if (script.
|
833
|
+
if (script.referrerPolicy)
|
834
|
+
fetchOpts.referrerPolicy = script.referrerPolicy;
|
835
|
+
if (script.crossOrigin === 'use-credentials')
|
685
836
|
fetchOpts.credentials = 'include';
|
686
|
-
else if (script.
|
837
|
+
else if (script.crossOrigin === 'anonymous')
|
687
838
|
fetchOpts.credentials = 'omit';
|
688
839
|
else
|
689
840
|
fetchOpts.credentials = 'same-origin';
|
@@ -694,85 +845,70 @@
|
|
694
845
|
|
695
846
|
let domContentLoadedCnt = 1;
|
696
847
|
function domContentLoadedCheck () {
|
697
|
-
if (--domContentLoadedCnt === 0 && !noLoadEventRetriggers)
|
848
|
+
if (--domContentLoadedCnt === 0 && !noLoadEventRetriggers && (shimMode || !baselinePassthrough)) {
|
698
849
|
document.dispatchEvent(new Event('DOMContentLoaded'));
|
699
|
-
}
|
700
|
-
// this should always trigger because we assume es-module-shims is itself a domcontentloaded requirement
|
701
|
-
document.addEventListener('DOMContentLoaded', async () => {
|
702
|
-
await initPromise;
|
703
|
-
domContentLoadedCheck();
|
704
|
-
if (shimMode || !baselinePassthrough) {
|
705
|
-
processImportMaps();
|
706
|
-
processScriptsAndPreloads();
|
707
850
|
}
|
708
|
-
});
|
709
|
-
|
710
|
-
let readyStateCompleteCnt = 1;
|
711
|
-
if (document.readyState === 'complete') {
|
712
|
-
readyStateCompleteCheck();
|
713
851
|
}
|
714
|
-
|
715
|
-
|
716
|
-
|
852
|
+
// this should always trigger because we assume es-module-shims is itself a domcontentloaded requirement
|
853
|
+
if (hasDocument) {
|
854
|
+
document.addEventListener('DOMContentLoaded', async () => {
|
717
855
|
await initPromise;
|
718
|
-
|
856
|
+
domContentLoadedCheck();
|
719
857
|
});
|
720
858
|
}
|
859
|
+
|
860
|
+
let readyStateCompleteCnt = 1;
|
721
861
|
function readyStateCompleteCheck () {
|
722
|
-
if (--readyStateCompleteCnt === 0 && !noLoadEventRetriggers)
|
862
|
+
if (--readyStateCompleteCnt === 0 && !noLoadEventRetriggers && (shimMode || !baselinePassthrough)) {
|
723
863
|
document.dispatchEvent(new Event('readystatechange'));
|
864
|
+
}
|
724
865
|
}
|
725
866
|
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
if (
|
731
|
-
return;
|
732
|
-
script.ep = true;
|
867
|
+
const hasNext = script => script.nextSibling || script.parentNode && hasNext(script.parentNode);
|
868
|
+
const epCheck = (script, ready) => script.ep || !ready && (!script.src && !script.innerHTML || !hasNext(script)) || script.getAttribute('noshim') !== null || !(script.ep = true);
|
869
|
+
|
870
|
+
function processImportMap (script, ready = readyStateCompleteCnt > 0) {
|
871
|
+
if (epCheck(script, ready)) return;
|
733
872
|
// we dont currently support multiple, external or dynamic imports maps in polyfill mode to match native
|
734
873
|
if (script.src) {
|
735
874
|
if (!shimMode)
|
736
875
|
return;
|
737
|
-
|
876
|
+
setImportMapSrcOrLazy();
|
738
877
|
}
|
739
878
|
if (acceptingImportMaps) {
|
740
879
|
importMapPromise = importMapPromise
|
741
880
|
.then(async () => {
|
742
|
-
importMap = resolveAndComposeImportMap(script.src ? await (await
|
881
|
+
importMap = resolveAndComposeImportMap(script.src ? await (await doFetch(script.src, getFetchOpts(script))).json() : JSON.parse(script.innerHTML), script.src || baseUrl, importMap);
|
743
882
|
})
|
744
|
-
.catch(
|
883
|
+
.catch(e => {
|
884
|
+
console.log(e);
|
885
|
+
if (e instanceof SyntaxError)
|
886
|
+
e = new Error(`Unable to parse import map ${e.message} in: ${script.src || script.innerHTML}`);
|
887
|
+
throwError(e);
|
888
|
+
});
|
745
889
|
if (!shimMode)
|
746
890
|
acceptingImportMaps = false;
|
747
891
|
}
|
748
892
|
}
|
749
893
|
|
750
|
-
function processScript (script) {
|
751
|
-
if (script
|
752
|
-
return;
|
753
|
-
if (script.getAttribute('noshim') !== null)
|
754
|
-
return;
|
755
|
-
// empty inline scripts sometimes show before domready
|
756
|
-
if (!script.src && !script.innerHTML)
|
757
|
-
return;
|
758
|
-
script.ep = true;
|
894
|
+
function processScript (script, ready = readyStateCompleteCnt > 0) {
|
895
|
+
if (epCheck(script, ready)) return;
|
759
896
|
// does this load block readystate complete
|
760
|
-
const
|
897
|
+
const isBlockingReadyScript = script.getAttribute('async') === null && readyStateCompleteCnt > 0;
|
761
898
|
// does this load block DOMContentLoaded
|
762
899
|
const isDomContentLoadedScript = domContentLoadedCnt > 0;
|
763
|
-
if (
|
900
|
+
if (isBlockingReadyScript) readyStateCompleteCnt++;
|
764
901
|
if (isDomContentLoadedScript) domContentLoadedCnt++;
|
765
|
-
const
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
if (blocks)
|
902
|
+
const loadPromise = topLevelLoad(script.src || baseUrl, getFetchOpts(script), !script.src && script.innerHTML, !shimMode, isBlockingReadyScript && lastStaticLoadPromise)
|
903
|
+
.then(() => {
|
904
|
+
// if the type of the script tag "module-shim", browser does not dispatch a "load" event
|
905
|
+
// see https://github.com/guybedford/es-module-shims/issues/346
|
906
|
+
if (shimMode) {
|
907
|
+
script.dispatchEvent(new Event('load'));
|
908
|
+
}
|
909
|
+
})
|
910
|
+
.catch(throwError);
|
911
|
+
if (isBlockingReadyScript)
|
776
912
|
lastStaticLoadPromise = loadPromise.then(readyStateCompleteCheck);
|
777
913
|
if (isDomContentLoadedScript)
|
778
914
|
loadPromise.then(domContentLoadedCheck);
|
@@ -780,16 +916,11 @@
|
|
780
916
|
|
781
917
|
const fetchCache = {};
|
782
918
|
function processPreload (link) {
|
783
|
-
if (link.ep)
|
784
|
-
return;
|
919
|
+
if (link.ep) return;
|
785
920
|
link.ep = true;
|
786
921
|
if (fetchCache[link.href])
|
787
922
|
return;
|
788
|
-
fetchCache[link.href] =
|
789
|
-
}
|
790
|
-
|
791
|
-
function throwUnresolved (id, parentUrl) {
|
792
|
-
throw Error("Unable to resolve specifier '" + id + (parentUrl ? "' from " + parentUrl : "'"));
|
923
|
+
fetchCache[link.href] = fetchModule(link.href, getFetchOpts(link));
|
793
924
|
}
|
794
925
|
|
795
926
|
})();
|