importmap-rails 0.5.3 → 0.6.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +17 -3
- data/app/assets/javascripts/es-module-shims.js +768 -1
- data/app/helpers/importmap/importmap_tags_helper.rb +10 -6
- data/lib/importmap/engine.rb +0 -6
- data/lib/importmap/map.rb +20 -2
- data/lib/importmap/version.rb +1 -1
- data/lib/install/install.rb +4 -2
- metadata +2 -3
- data/app/assets/javascripts/es-module-shims@0.14.0.csp.js +0 -1635
@@ -1 +1,768 @@
|
|
1
|
-
|
1
|
+
/* ES Module Shims CSP 0.15.1 */
|
2
|
+
(function () {
|
3
|
+
|
4
|
+
Promise.resolve();
|
5
|
+
|
6
|
+
const edge = navigator.userAgent.match(/Edge\/\d\d\.\d+$/);
|
7
|
+
|
8
|
+
let baseUrl;
|
9
|
+
|
10
|
+
function createBlob (source, type = 'text/javascript') {
|
11
|
+
return URL.createObjectURL(new Blob([source], { type }));
|
12
|
+
}
|
13
|
+
|
14
|
+
const noop = () => {};
|
15
|
+
|
16
|
+
const baseEl = document.querySelector('base[href]');
|
17
|
+
if (baseEl)
|
18
|
+
baseUrl = baseEl.href;
|
19
|
+
|
20
|
+
if (!baseUrl && typeof location !== 'undefined') {
|
21
|
+
baseUrl = location.href.split('#')[0].split('?')[0];
|
22
|
+
const lastSepIndex = baseUrl.lastIndexOf('/');
|
23
|
+
if (lastSepIndex !== -1)
|
24
|
+
baseUrl = baseUrl.slice(0, lastSepIndex + 1);
|
25
|
+
}
|
26
|
+
|
27
|
+
function isURL (url) {
|
28
|
+
try {
|
29
|
+
new URL(url);
|
30
|
+
return true;
|
31
|
+
}
|
32
|
+
catch {
|
33
|
+
return false;
|
34
|
+
}
|
35
|
+
}
|
36
|
+
|
37
|
+
const backslashRegEx = /\\/g;
|
38
|
+
function resolveIfNotPlainOrUrl (relUrl, parentUrl) {
|
39
|
+
// strip off any trailing query params or hashes
|
40
|
+
parentUrl = parentUrl && parentUrl.split('#')[0].split('?')[0];
|
41
|
+
if (relUrl.indexOf('\\') !== -1)
|
42
|
+
relUrl = relUrl.replace(backslashRegEx, '/');
|
43
|
+
// protocol-relative
|
44
|
+
if (relUrl[0] === '/' && relUrl[1] === '/') {
|
45
|
+
return parentUrl.slice(0, parentUrl.indexOf(':') + 1) + relUrl;
|
46
|
+
}
|
47
|
+
// relative-url
|
48
|
+
else if (relUrl[0] === '.' && (relUrl[1] === '/' || relUrl[1] === '.' && (relUrl[2] === '/' || relUrl.length === 2 && (relUrl += '/')) ||
|
49
|
+
relUrl.length === 1 && (relUrl += '/')) ||
|
50
|
+
relUrl[0] === '/') {
|
51
|
+
const parentProtocol = parentUrl.slice(0, parentUrl.indexOf(':') + 1);
|
52
|
+
// Disabled, but these cases will give inconsistent results for deep backtracking
|
53
|
+
//if (parentUrl[parentProtocol.length] !== '/')
|
54
|
+
// throw new Error('Cannot resolve');
|
55
|
+
// read pathname from parent URL
|
56
|
+
// pathname taken to be part after leading "/"
|
57
|
+
let pathname;
|
58
|
+
if (parentUrl[parentProtocol.length + 1] === '/') {
|
59
|
+
// resolving to a :// so we need to read out the auth and host
|
60
|
+
if (parentProtocol !== 'file:') {
|
61
|
+
pathname = parentUrl.slice(parentProtocol.length + 2);
|
62
|
+
pathname = pathname.slice(pathname.indexOf('/') + 1);
|
63
|
+
}
|
64
|
+
else {
|
65
|
+
pathname = parentUrl.slice(8);
|
66
|
+
}
|
67
|
+
}
|
68
|
+
else {
|
69
|
+
// resolving to :/ so pathname is the /... part
|
70
|
+
pathname = parentUrl.slice(parentProtocol.length + (parentUrl[parentProtocol.length] === '/'));
|
71
|
+
}
|
72
|
+
|
73
|
+
if (relUrl[0] === '/')
|
74
|
+
return parentUrl.slice(0, parentUrl.length - pathname.length - 1) + relUrl;
|
75
|
+
|
76
|
+
// join together and split for removal of .. and . segments
|
77
|
+
// looping the string instead of anything fancy for perf reasons
|
78
|
+
// '../../../../../z' resolved to 'x/y' is just 'z'
|
79
|
+
const segmented = pathname.slice(0, pathname.lastIndexOf('/') + 1) + relUrl;
|
80
|
+
|
81
|
+
const output = [];
|
82
|
+
let segmentIndex = -1;
|
83
|
+
for (let i = 0; i < segmented.length; i++) {
|
84
|
+
// busy reading a segment - only terminate on '/'
|
85
|
+
if (segmentIndex !== -1) {
|
86
|
+
if (segmented[i] === '/') {
|
87
|
+
output.push(segmented.slice(segmentIndex, i + 1));
|
88
|
+
segmentIndex = -1;
|
89
|
+
}
|
90
|
+
}
|
91
|
+
|
92
|
+
// new segment - check if it is relative
|
93
|
+
else if (segmented[i] === '.') {
|
94
|
+
// ../ segment
|
95
|
+
if (segmented[i + 1] === '.' && (segmented[i + 2] === '/' || i + 2 === segmented.length)) {
|
96
|
+
output.pop();
|
97
|
+
i += 2;
|
98
|
+
}
|
99
|
+
// ./ segment
|
100
|
+
else if (segmented[i + 1] === '/' || i + 1 === segmented.length) {
|
101
|
+
i += 1;
|
102
|
+
}
|
103
|
+
else {
|
104
|
+
// the start of a new segment as below
|
105
|
+
segmentIndex = i;
|
106
|
+
}
|
107
|
+
}
|
108
|
+
// it is the start of a new segment
|
109
|
+
else {
|
110
|
+
segmentIndex = i;
|
111
|
+
}
|
112
|
+
}
|
113
|
+
// finish reading out the last segment
|
114
|
+
if (segmentIndex !== -1)
|
115
|
+
output.push(segmented.slice(segmentIndex));
|
116
|
+
return parentUrl.slice(0, parentUrl.length - pathname.length) + output.join('');
|
117
|
+
}
|
118
|
+
}
|
119
|
+
|
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
|
+
let target = packages[p];
|
135
|
+
if (typeof target !== 'string')
|
136
|
+
continue;
|
137
|
+
const mapped = resolveImportMap(parentMap, resolveIfNotPlainOrUrl(target, baseUrl) || target, baseUrl);
|
138
|
+
if (mapped) {
|
139
|
+
outPackages[resolvedLhs] = mapped;
|
140
|
+
continue;
|
141
|
+
}
|
142
|
+
targetWarning(p, packages[p], 'bare specifier did not resolve');
|
143
|
+
}
|
144
|
+
}
|
145
|
+
|
146
|
+
function resolveAndComposeImportMap (json, baseUrl, parentMap) {
|
147
|
+
const outMap = { imports: Object.assign({}, parentMap.imports), scopes: Object.assign({}, parentMap.scopes) };
|
148
|
+
|
149
|
+
if (json.imports)
|
150
|
+
resolveAndComposePackages(json.imports, outMap.imports, baseUrl, parentMap);
|
151
|
+
|
152
|
+
if (json.scopes)
|
153
|
+
for (let s in json.scopes) {
|
154
|
+
const resolvedScope = resolveUrl(s, baseUrl);
|
155
|
+
resolveAndComposePackages(json.scopes[s], outMap.scopes[resolvedScope] || (outMap.scopes[resolvedScope] = {}), baseUrl, parentMap);
|
156
|
+
}
|
157
|
+
|
158
|
+
return outMap;
|
159
|
+
}
|
160
|
+
|
161
|
+
function getMatch (path, matchObj) {
|
162
|
+
if (matchObj[path])
|
163
|
+
return path;
|
164
|
+
let sepIndex = path.length;
|
165
|
+
do {
|
166
|
+
const segment = path.slice(0, sepIndex + 1);
|
167
|
+
if (segment in matchObj)
|
168
|
+
return segment;
|
169
|
+
} while ((sepIndex = path.lastIndexOf('/', sepIndex - 1)) !== -1)
|
170
|
+
}
|
171
|
+
|
172
|
+
function applyPackages (id, packages) {
|
173
|
+
const pkgName = getMatch(id, packages);
|
174
|
+
if (pkgName) {
|
175
|
+
const pkg = packages[pkgName];
|
176
|
+
if (pkg === null) return;
|
177
|
+
if (id.length > pkgName.length && pkg[pkg.length - 1] !== '/')
|
178
|
+
targetWarning(pkgName, pkg, "should have a trailing '/'");
|
179
|
+
else
|
180
|
+
return pkg + id.slice(pkgName.length);
|
181
|
+
}
|
182
|
+
}
|
183
|
+
|
184
|
+
function targetWarning (match, target, msg) {
|
185
|
+
console.warn("Package target " + msg + ", resolving target '" + target + "' for " + match);
|
186
|
+
}
|
187
|
+
|
188
|
+
function resolveImportMap (importMap, resolvedOrPlain, parentUrl) {
|
189
|
+
let scopeUrl = parentUrl && getMatch(parentUrl, importMap.scopes);
|
190
|
+
while (scopeUrl) {
|
191
|
+
const packageResolution = applyPackages(resolvedOrPlain, importMap.scopes[scopeUrl]);
|
192
|
+
if (packageResolution)
|
193
|
+
return packageResolution;
|
194
|
+
scopeUrl = getMatch(scopeUrl.slice(0, scopeUrl.lastIndexOf('/')), importMap.scopes);
|
195
|
+
}
|
196
|
+
return applyPackages(resolvedOrPlain, importMap.imports) || resolvedOrPlain.indexOf(':') !== -1 && resolvedOrPlain;
|
197
|
+
}
|
198
|
+
|
199
|
+
const optionsScript = document.querySelector('script[type=esms-options]');
|
200
|
+
|
201
|
+
const esmsInitOptions$1 = optionsScript ? JSON.parse(optionsScript.innerHTML) : self.esmsInitOptions ? self.esmsInitOptions : {};
|
202
|
+
|
203
|
+
let shimMode = !!esmsInitOptions$1.shimMode;
|
204
|
+
const resolveHook = shimMode && esmsInitOptions$1.resolve;
|
205
|
+
|
206
|
+
const skip = esmsInitOptions$1.skip ? new RegExp(esmsInitOptions$1.skip) : /^https:\/\/(cdn\.skypack\.dev|jspm\.dev)\//;
|
207
|
+
|
208
|
+
let nonce = esmsInitOptions$1.nonce;
|
209
|
+
|
210
|
+
if (!nonce) {
|
211
|
+
const nonceElement = document.querySelector('script[nonce]');
|
212
|
+
if (nonceElement)
|
213
|
+
nonce = nonceElement.getAttribute('nonce');
|
214
|
+
}
|
215
|
+
|
216
|
+
const {
|
217
|
+
fetchHook = fetch,
|
218
|
+
onerror = noop,
|
219
|
+
revokeBlobURLs,
|
220
|
+
noLoadEventRetriggers,
|
221
|
+
} = esmsInitOptions$1;
|
222
|
+
|
223
|
+
const enable = Array.isArray(esmsInitOptions$1.polyfillEnable) ? esmsInitOptions$1.polyfillEnable : [];
|
224
|
+
const cssModulesEnabled = enable.includes('css-modules');
|
225
|
+
const jsonModulesEnabled = enable.includes('json-modules');
|
226
|
+
|
227
|
+
function setShimMode () {
|
228
|
+
shimMode = true;
|
229
|
+
}
|
230
|
+
|
231
|
+
let err;
|
232
|
+
window.addEventListener('error', _err => err = _err);
|
233
|
+
function dynamicImportScript (url, { errUrl = url } = {}) {
|
234
|
+
err = undefined;
|
235
|
+
const src = createBlob(`import*as m from'${url}';self._esmsi=m`);
|
236
|
+
const s = Object.assign(document.createElement('script'), { type: 'module', src });
|
237
|
+
s.setAttribute('nonce', nonce);
|
238
|
+
s.setAttribute('noshim', '');
|
239
|
+
const p = new Promise((resolve, reject) => {
|
240
|
+
// Safari is unique in supporting module script error events
|
241
|
+
s.addEventListener('error', cb);
|
242
|
+
s.addEventListener('load', cb);
|
243
|
+
|
244
|
+
function cb () {
|
245
|
+
document.head.removeChild(s);
|
246
|
+
if (self._esmsi) {
|
247
|
+
resolve(self._esmsi, baseUrl);
|
248
|
+
self._esmsi = undefined;
|
249
|
+
}
|
250
|
+
else {
|
251
|
+
reject(err.error || new Error(`Error loading or executing the graph of ${errUrl} (check the console for ${src}).`));
|
252
|
+
err = undefined;
|
253
|
+
}
|
254
|
+
}
|
255
|
+
});
|
256
|
+
document.head.appendChild(s);
|
257
|
+
return p;
|
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);
|
267
|
+
|
268
|
+
// support browsers without dynamic import support (eg Firefox 6x)
|
269
|
+
let supportsJsonAssertions = false;
|
270
|
+
let supportsCssAssertions = false;
|
271
|
+
|
272
|
+
let supportsImportMeta = false;
|
273
|
+
let supportsImportMaps = false;
|
274
|
+
|
275
|
+
let supportsDynamicImport = false;
|
276
|
+
|
277
|
+
const featureDetectionPromise = Promise.resolve(supportsDynamicImportCheck).then(_supportsDynamicImport => {
|
278
|
+
if (!_supportsDynamicImport)
|
279
|
+
return;
|
280
|
+
supportsDynamicImport = true;
|
281
|
+
|
282
|
+
return Promise.all([
|
283
|
+
dynamicImport(createBlob('import.meta')).then(() => supportsImportMeta = true, noop),
|
284
|
+
cssModulesEnabled && dynamicImport(createBlob('import"data:text/css,{}"assert{type:"css"}')).then(() => supportsCssAssertions = true, noop),
|
285
|
+
jsonModulesEnabled && dynamicImport(createBlob('import"data:text/json,{}"assert{type:"json"}')).then(() => supportsJsonAssertions = true, noop),
|
286
|
+
new Promise(resolve => {
|
287
|
+
self._$s = v => {
|
288
|
+
document.body.removeChild(iframe);
|
289
|
+
if (v) supportsImportMaps = true;
|
290
|
+
delete self._$s;
|
291
|
+
resolve();
|
292
|
+
};
|
293
|
+
const iframe = document.createElement('iframe');
|
294
|
+
iframe.style.display = 'none';
|
295
|
+
document.body.appendChild(iframe);
|
296
|
+
// we use document.write here because eg Weixin built-in browser doesn't support setting srcdoc
|
297
|
+
iframe.contentWindow.document.write(`<script type=importmap nonce="${nonce}">{"imports":{"x":"data:text/javascript,"}}<${''}/script><script nonce="${nonce}">import('x').then(()=>1,()=>0).then(v=>parent._$s(v))<${''}/script>`);
|
298
|
+
})
|
299
|
+
]);
|
300
|
+
});
|
301
|
+
|
302
|
+
let e,r;const a=1===new Uint8Array(new Uint16Array([1]).buffer)[0];let s,i;function parse(i,f="@"){s=i,e||(r=new ArrayBuffer(16777216),e=function(e,r,a){"use asm";var s=new e.Int8Array(a),i=new e.Int16Array(a),t=new e.Int32Array(a),c=new e.Uint8Array(a),n=new e.Uint16Array(a),f=816;function u(e){e=e|0;var r=0,a=0,c=0,u=0,l=0;l=f;f=f+14336|0;u=l;s[589]=1;i[291]=0;i[292]=0;i[293]=-1;t[15]=t[2];s[590]=0;t[14]=0;s[588]=0;t[16]=l+10240;t[17]=l+2048;s[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){c=18;break}r:do{switch(i[a>>1]|0){case 9:case 10:case 11:case 12:case 13:case 32:break;case 101:{if((((i[292]|0)==0?T(a)|0:0)?j(e+4|0,120,112,111,114,116)|0:0)?(k(),(s[589]|0)==0):0){c=9;break e}else c=17;break}case 105:{if(T(a)|0?j(e+4|0,109,112,111,114,116)|0:0){b();c=17;}else c=17;break}case 59:{c=17;break}case 47:switch(i[e+4>>1]|0){case 47:{G();break r}case 42:{p(1);break r}default:{c=16;break e}}default:{c=16;break e}}}while(0);if((c|0)==17){c=0;t[15]=t[18];}e=t[18]|0;r=t[19]|0;}if((c|0)==9){e=t[18]|0;t[15]=e;c=19;}else if((c|0)==16){s[589]=0;t[18]=e;c=19;}else if((c|0)==18)if(!(s[588]|0)){e=a;c=19;}else e=0;do{if((c|0)==19){e:while(1){r=e+2|0;t[18]=r;a=r;if(e>>>0>=(t[19]|0)>>>0){c=75;break}r:do{switch(i[r>>1]|0){case 9:case 10:case 11:case 12:case 13:case 32:break;case 101:{if(((i[292]|0)==0?T(r)|0:0)?j(e+4|0,120,112,111,114,116)|0:0){k();c=74;}else c=74;break}case 105:{if(T(r)|0?j(e+4|0,109,112,111,114,116)|0:0){b();c=74;}else c=74;break}case 99:{if((T(r)|0?z(e+4|0,108,97,115,115)|0:0)?_(i[e+12>>1]|0)|0:0){s[591]=1;c=74;}else c=74;break}case 40:{r=t[15]|0;a=t[17]|0;c=i[292]|0;i[292]=c+1<<16>>16;t[a+((c&65535)<<2)>>2]=r;c=74;break}case 41:{e=i[292]|0;if(!(e<<16>>16)){c=36;break e}c=e+-1<<16>>16;i[292]=c;e=t[11]|0;if((e|0)!=0?(t[e+20>>2]|0)==(t[(t[17]|0)+((c&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;c=74;}else c=74;break}case 123:{c=t[15]|0;a=t[8]|0;e=c;do{if((i[c>>1]|0)==41&(a|0)!=0?(t[a+4>>2]|0)==(c|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=i[292]|0;c=r&65535;s[u+c>>0]=s[591]|0;s[591]=0;a=t[17]|0;i[292]=r+1<<16>>16;t[a+(c<<2)>>2]=e;c=74;break}case 125:{e=i[292]|0;if(!(e<<16>>16)){c=49;break e}a=e+-1<<16>>16;i[292]=a;r=i[293]|0;if(e<<16>>16!=r<<16>>16)if(r<<16>>16!=-1&(a&65535)<(r&65535)){c=53;break e}else {c=74;break r}else {a=t[16]|0;c=(i[291]|0)+-1<<16>>16;i[291]=c;i[293]=i[a+((c&65535)<<1)>>1]|0;h();c=74;break r}}case 39:{d();c=74;break}case 34:{v();c=74;break}case 47:switch(i[e+4>>1]|0){case 47:{G();break r}case 42:{p(1);break r}default:{r=t[15]|0;a=i[r>>1]|0;a:do{if(!(E(a)|0)){switch(a<<16>>16){case 41:if(L(t[(t[17]|0)+(n[292]<<2)>>2]|0)|0){c=71;break a}else {c=68;break a}case 125:break;default:{c=68;break a}}e=n[292]|0;if(!(g(t[(t[17]|0)+(e<<2)>>2]|0)|0)?(s[u+e>>0]|0)==0:0)c=68;else c=71;}else switch(a<<16>>16){case 46:if(((i[r+-2>>1]|0)+-48&65535)<10){c=68;break a}else {c=71;break a}case 43:if((i[r+-2>>1]|0)==43){c=68;break a}else {c=71;break a}case 45:if((i[r+-2>>1]|0)==45){c=68;break a}else {c=71;break a}default:{c=71;break a}}}while(0);a:do{if((c|0)==68){c=0;if(!(o(r)|0)){switch(a<<16>>16){case 0:{c=71;break a}case 47:break;default:{e=1;break a}}if(!(s[590]|0))e=1;else c=71;}else c=71;}}while(0);if((c|0)==71){I();e=0;}s[590]=e;c=74;break r}}case 96:{h();c=74;break}default:c=74;}}while(0);if((c|0)==74){c=0;t[15]=t[18];}e=t[18]|0;}if((c|0)==36){Z();e=0;break}else if((c|0)==49){Z();e=0;break}else if((c|0)==53){Z();e=0;break}else if((c|0)==75){e=(i[293]|0)==-1&(i[292]|0)==0&(s[588]|0)==0;break}}}while(0);f=l;return e|0}function k(){var e=0,r=0,a=0,c=0,n=0,f=0;n=t[18]|0;f=n+12|0;t[18]=f;r=w(1)|0;e=t[18]|0;if(!((e|0)==(f|0)?!(U(r)|0):0))c=3;e:do{if((c|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;c=6;break}case 102:{c=6;break}case 99:{if(z(e+2|0,108,97,115,115)|0?(a=e+10|0,F(i[a>>1]|0)|0):0){t[18]=a;n=w(1)|0;f=t[18]|0;H(n)|0;J(f,t[18]|0);t[18]=(t[18]|0)+-2;break e}e=e+4|0;t[18]=e;c=13;break}case 108:case 118:{c=13;break}case 123:{t[18]=e+2;e=w(1)|0;a=t[18]|0;while(1){H(e)|0;e=t[18]|0;w(1)|0;e=$(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){c=29;break}if((a|0)==(r|0)){c=26;break}if(a>>>0>(t[19]|0)>>>0){c=28;break}}if((c|0)==26){Z();break e}else if((c|0)==28){Z();break e}else if((c|0)==29){t[18]=a+2;c=31;break r}break}case 42:{t[18]=e+2;w(1)|0;c=t[18]|0;$(c,c)|0;c=31;break}default:{}}}while(0);if((c|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;}f=t[18]|0;H(e)|0;J(f,t[18]|0);t[18]=(t[18]|0)+-2;break}else if((c|0)==13){e=e+4|0;t[18]=e;s[589]=0;r:while(1){t[18]=e+2;f=w(1)|0;e=t[18]|0;switch((H(f)|0)<<16>>16){case 91:case 123:{c=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:{c=19;break r}case 44:break;default:{c=20;break r}}e=t[18]|0;}if((c|0)==15){t[18]=(t[18]|0)+-2;break}else if((c|0)==19){t[18]=(t[18]|0)+-2;break}else if((c|0)==20){t[18]=(t[18]|0)+-2;break}}else if((c|0)==31)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(n,w(1)|0);break}t[18]=e+-2;}}while(0);return}function b(){var e=0,r=0,a=0,c=0,n=0;n=t[18]|0;r=n+12|0;t[18]=r;e:do{switch((w(1)|0)<<16>>16){case 40:{r=t[17]|0;a=i[292]|0;i[292]=a+1<<16>>16;t[r+((a&65535)<<2)>>2]=n;if((i[t[15]>>1]|0)!=46){A(n,(t[18]|0)+2|0,0,n);t[11]=t[8];t[18]=(t[18]|0)+2;switch((w(1)|0)<<16>>16){case 39:{d();break}case 34:{v();break}default:{t[18]=(t[18]|0)+-2;break e}}t[18]=(t[18]|0)+2;switch((w(1)|0)<<16>>16){case 44:{n=t[18]|0;t[(t[8]|0)+4>>2]=n;t[18]=n+2;w(1)|0;n=t[18]|0;a=t[8]|0;t[a+16>>2]=n;s[a+24>>0]=1;t[18]=n+-2;break e}case 41:{i[292]=(i[292]|0)+-1<<16>>16;a=t[18]|0;n=t[8]|0;t[n+4>>2]=a;t[n+12>>2]=a;s[n+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)?(i[t[15]>>1]|0)!=46:0)A(n,n,e+8|0,2);break}case 42:case 123:case 39:case 34:{c=16;break}default:if((t[18]|0)!=(r|0))c=16;}}while(0);do{if((c|0)==16){if(i[292]|0){t[18]=(t[18]|0)+-2;break}e=t[19]|0;r=t[18]|0;e:while(1){if(r>>>0>=e>>>0){c=23;break}a=i[r>>1]|0;switch(a<<16>>16){case 34:case 39:{c=21;break e}default:{}}c=r+2|0;t[18]=c;r=c;}if((c|0)==21){l(n,a);break}else if((c|0)==23){Z();break}}}while(0);return}function l(e,r){e=e|0;r=r|0;var a=0,s=0;a=(t[18]|0)+2|0;switch(r<<16>>16){case 39:{d();s=5;break}case 34:{v();s=5;break}default:Z();}do{if((s|0)==5){A(e,a,t[18]|0,1);t[18]=(t[18]|0)+2;s=(w(0)|0)<<16>>16==97;r=t[18]|0;if(s?j(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();t[18]=(t[18]|0)+2;a=w(1)|0;break}case 34:{v();t[18]=(t[18]|0)+2;a=w(1)|0;break}default:a=H(a)|0;}if(a<<16>>16!=58){s=16;break}t[18]=(t[18]|0)+2;switch((w(1)|0)<<16>>16){case 39:{d();break}case 34:{v();break}default:{s=20;break e}}t[18]=(t[18]|0)+2;switch((w(1)|0)<<16>>16){case 125:{s=25;break e}case 44:break;default:{s=24;break e}}t[18]=(t[18]|0)+2;if((w(1)|0)<<16>>16==125){s=25;break}a=t[18]|0;}if((s|0)==16){t[18]=r;break}else if((s|0)==20){t[18]=r;break}else if((s|0)==24){t[18]=r;break}else if((s|0)==25){s=t[8]|0;t[s+16>>2]=e;t[s+12>>2]=(t[18]|0)+2;break}}t[18]=r+-2;}}while(0);return}function o(e){e=e|0;e:do{switch(i[e>>1]|0){case 100:switch(i[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(i[e+-2>>1]|0){case 115:break;case 116:{e=B(e+-4|0,100,101,108,101)|0;break e}default:{e=0;break e}}switch(i[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((i[e+-2>>1]|0)==111?(i[e+-4>>1]|0)==101:0)switch(i[e+-6>>1]|0){case 99:{e=m(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=O(e,114,101,116,117,114)|0;break}case 111:{e=D(e+-2|0,100)|0;break}case 114:{e=S(e+-2|0,100,101,98,117,103,103,101)|0;break}case 116:{e=B(e+-2|0,97,119,97,105)|0;break}case 119:switch(i[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(i[e>>1]|0){case 96:{r=9;break e}case 36:{if((i[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=i[293]|0;r=t[16]|0;a=i[291]|0;i[291]=a+1<<16>>16;i[r+((a&65535)<<1)>>1]=e;a=(i[292]|0)+1<<16>>16;i[292]=a;i[293]=a;}else if((r|0)==8){t[18]=e;Z();}else if((r|0)==9)t[18]=e;return}function w(e){e=e|0;var r=0,a=0,s=0;a=t[18]|0;e:do{r=i[a>>1]|0;r:do{if(r<<16>>16!=47)if(e)if(_(r)|0)break;else break e;else if(Q(r)|0)break;else break e;else switch(i[a+2>>1]|0){case 47:{G();break r}case 42:{p(e);break r}default:{r=47;break e}}}while(0);s=t[18]|0;a=s+2|0;t[18]=a;}while(s>>>0<(t[19]|0)>>>0);return r|0}function d(){var e=0,r=0,a=0,s=0;s=t[19]|0;e=t[18]|0;e:while(1){a=e+2|0;if(e>>>0>=s>>>0){e=8;break}r=i[a>>1]|0;switch(r<<16>>16){case 39:{e=9;break e}case 92:{r=e+4|0;if((i[r>>1]|0)==13){e=e+6|0;e=(i[e>>1]|0)==10?e:r;}else e=r;break}default:if(ae(r)|0){e=8;break e}else e=a;}}if((e|0)==8){t[18]=a;Z();}else if((e|0)==9)t[18]=a;return}function v(){var e=0,r=0,a=0,s=0;s=t[19]|0;e=t[18]|0;e:while(1){a=e+2|0;if(e>>>0>=s>>>0){e=8;break}r=i[a>>1]|0;switch(r<<16>>16){case 34:{e=9;break e}case 92:{r=e+4|0;if((i[r>>1]|0)==13){e=e+6|0;e=(i[e>>1]|0)==10?e:r;}else e=r;break}default:if(ae(r)|0){e=8;break e}else e=a;}}if((e|0)==8){t[18]=a;Z();}else if((e|0)==9)t[18]=a;return}function A(e,r,a,i){e=e|0;r=r|0;a=a|0;i=i|0;var c=0,n=0;c=t[13]|0;t[13]=c+32;n=t[8]|0;t[((n|0)==0?16:n+28|0)>>2]=c;t[9]=n;t[8]=c;t[c+8>>2]=e;do{if(2!=(i|0))if(1==(i|0)){t[c+12>>2]=a+2;break}else {t[c+12>>2]=t[3];break}else t[c+12>>2]=a;}while(0);t[c>>2]=r;t[c+4>>2]=a;t[c+16>>2]=0;t[c+20>>2]=i;s[c+24>>0]=1==(i|0)&1;t[c+28>>2]=0;return}function y(){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(i[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;Z();e=0;}else if((r|0)==7){t[18]=e;e=93;}return e|0}function C(e,r,a,s,t,c,n,f){e=e|0;r=r|0;a=a|0;s=s|0;t=t|0;c=c|0;n=n|0;f=f|0;if((((((i[e+12>>1]|0)==f<<16>>16?(i[e+10>>1]|0)==n<<16>>16:0)?(i[e+8>>1]|0)==c<<16>>16:0)?(i[e+6>>1]|0)==t<<16>>16:0)?(i[e+4>>1]|0)==s<<16>>16:0)?(i[e+2>>1]|0)==a<<16>>16:0)r=(i[e>>1]|0)==r<<16>>16;else r=0;return r|0}function g(e){e=e|0;switch(i[e>>1]|0){case 62:{e=(i[e+-2>>1]|0)==61;break}case 41:case 59:{e=1;break}case 104:{e=B(e+-2|0,99,97,116,99)|0;break}case 121:{e=m(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 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(i[r>>1]|0){case 13:case 10:{a=7;break e}case 47:break e;case 91:{y()|0;break}case 92:{t[18]=e+4;break}default:{}}}if((a|0)==7)Z();return}function p(e){e=e|0;var r=0,a=0,s=0,c=0,n=0;c=(t[18]|0)+2|0;t[18]=c;a=t[19]|0;while(1){r=c+2|0;if(c>>>0>=a>>>0)break;s=i[r>>1]|0;if(!e?ae(s)|0:0)break;if(s<<16>>16==42?(i[c+4>>1]|0)==47:0){n=8;break}c=r;}if((n|0)==8){t[18]=r;r=c+4|0;}t[18]=r;return}function x(e,r,a,s,t,c,n){e=e|0;r=r|0;a=a|0;s=s|0;t=t|0;c=c|0;n=n|0;if(((((i[e+10>>1]|0)==n<<16>>16?(i[e+8>>1]|0)==c<<16>>16:0)?(i[e+6>>1]|0)==t<<16>>16:0)?(i[e+4>>1]|0)==s<<16>>16:0)?(i[e+2>>1]|0)==a<<16>>16:0)r=(i[e>>1]|0)==r<<16>>16;else r=0;return r|0}function S(e,r,a,s,c,n,f,u){e=e|0;r=r|0;a=a|0;s=s|0;c=c|0;n=n|0;f=f|0;u=u|0;var k=0,b=0;b=e+-12|0;k=t[3]|0;if(b>>>0>=k>>>0?C(b,r,a,s,c,n,f,u)|0:0)if((b|0)==(k|0))k=1;else k=F(i[e+-14>>1]|0)|0;else k=0;return k|0}function U(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 E(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 m(e,r,a,s,c,n,f){e=e|0;r=r|0;a=a|0;s=s|0;c=c|0;n=n|0;f=f|0;var u=0,k=0;k=e+-10|0;u=t[3]|0;if(k>>>0>=u>>>0?x(k,r,a,s,c,n,f)|0:0)if((k|0)==(u|0))u=1;else u=F(i[e+-12>>1]|0)|0;else u=0;return u|0}function O(e,r,a,s,c,n){e=e|0;r=r|0;a=a|0;s=s|0;c=c|0;n=n|0;var f=0,u=0;u=e+-8|0;f=t[3]|0;if(u>>>0>=f>>>0?j(u,r,a,s,c,n)|0:0)if((u|0)==(f|0))f=1;else f=F(i[e+-10>>1]|0)|0;else f=0;return f|0}function $(e,r){e=e|0;r=r|0;var a=0,s=0;a=t[18]|0;s=i[a>>1]|0;if(s<<16>>16==97){t[18]=a+4;r=w(1)|0;e=t[18]|0;H(r)|0;r=t[18]|0;s=w(1)|0;a=t[18]|0;}if((a|0)!=(e|0))J(e,r);return s|0}function R(e){e=e|0;var r=0,a=0,s=0,c=0;a=f;f=f+16|0;s=a;t[s>>2]=0;t[12]=e;r=t[3]|0;c=r+(e<<1)|0;e=c+2|0;i[c>>1]=0;t[s>>2]=e;t[13]=e;t[4]=0;t[8]=0;t[6]=0;t[5]=0;t[10]=0;t[7]=0;f=a;return r|0}function j(e,r,a,s,t,c){e=e|0;r=r|0;a=a|0;s=s|0;t=t|0;c=c|0;if((((i[e+8>>1]|0)==c<<16>>16?(i[e+6>>1]|0)==t<<16>>16:0)?(i[e+4>>1]|0)==s<<16>>16:0)?(i[e+2>>1]|0)==a<<16>>16:0)r=(i[e>>1]|0)==r<<16>>16;else r=0;return r|0}function B(e,r,a,s,c){e=e|0;r=r|0;a=a|0;s=s|0;c=c|0;var n=0,f=0;f=e+-6|0;n=t[3]|0;if(f>>>0>=n>>>0?z(f,r,a,s,c)|0:0)if((f|0)==(n|0))n=1;else n=F(i[e+-8>>1]|0)|0;else n=0;return n|0}function P(e,r,a,s){e=e|0;r=r|0;a=a|0;s=s|0;var c=0,n=0;n=e+-4|0;c=t[3]|0;if(n>>>0>=c>>>0?K(n,r,a,s)|0:0)if((n|0)==(c|0))c=1;else c=F(i[e+-6>>1]|0)|0;else c=0;return c|0}function q(e,r,a){e=e|0;r=r|0;a=a|0;var s=0,c=0;c=e+-2|0;s=t[3]|0;if(c>>>0>=s>>>0?N(c,r,a)|0:0)if((c|0)==(s|0))s=1;else s=F(i[e+-4>>1]|0)|0;else s=0;return s|0}function z(e,r,a,s,t){e=e|0;r=r|0;a=a|0;s=s|0;t=t|0;if(((i[e+6>>1]|0)==t<<16>>16?(i[e+4>>1]|0)==s<<16>>16:0)?(i[e+2>>1]|0)==a<<16>>16:0)r=(i[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?(i[e>>1]|0)==r<<16>>16:0)if((a|0)==(e|0))a=1;else a=F(i[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&(U(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(i[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(_(e)|0)break;if(U(e)|0)break;e=(t[18]|0)+2|0;t[18]=e;e=i[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,s=0;a=t[13]|0;t[13]=a+12;s=t[10]|0;t[((s|0)==0?20:s+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,s){e=e|0;r=r|0;a=a|0;s=s|0;if((i[e+4>>1]|0)==s<<16>>16?(i[e+2>>1]|0)==a<<16>>16:0)r=(i[e>>1]|0)==r<<16>>16;else r=0;return r|0}function L(e){e=e|0;if(!(O(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((i[e+2>>1]|0)==a<<16>>16)r=(i[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 T(e){e=e|0;if((t[3]|0)==(e|0))e=1;else e=F(i[e+-2>>1]|0)|0;return e|0}function V(){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 W(){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 X(){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 Y(e){e=e|0;var r=0;r=f;f=f+e|0;f=f+15&-16;return r|0}function Z(){s[588]=1;t[14]=(t[18]|0)-(t[3]|0)>>1;t[18]=(t[19]|0)+2;return}function _(e){e=e|0;return (e|128)<<16>>16==160|(e+-9&65535)<5|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 se(){return (t[(t[6]|0)+4>>2]|0)-(t[3]|0)>>1|0}function ie(){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 ce(){return (t[t[7]>>2]|0)-(t[3]|0)>>1|0}function ne(){return c[(t[6]|0)+24>>0]|0|0}function fe(e){e=e|0;t[3]=e;return}function ue(e){e=e|0;f=e;}function ke(){return (s[589]|0)!=0|0}function be(){return f|0}function le(){return t[14]|0}return {ai:V,e:le,ee:ie,es:ce,f:ke,id:M,ie:se,ip:ne,is:te,parse:u,re:X,ri:W,sa:R,se:ee,setSource:fe,ss:re,stackAlloc:Y,stackRestore:ue,stackSave:be}}({Int8Array:Int8Array,Int16Array:Int16Array,Int32Array:Int32Array,Uint8Array:Uint8Array,Uint16Array:Uint16Array},{},r));const u=s.length+1,k=e.stackSave(),b=e.stackAlloc(2*s.length*4);if(e.setSource(b),e.sa(u-1),(a?c$1:t)(s,new Uint16Array(r,b,u)),!e.parse())throw Object.assign(new Error(`Parse error ${f}:${s.slice(0,e.e()).split("\n").length}:${e.e()-s.lastIndexOf("\n",e.e()-1)}`),{idx:e.e()});const l=[],o=[];for(;e.ri();){const r=e.is(),a=e.ie(),i=e.ai(),t=e.id(),c=e.ss(),f=e.se();let u;e.ip()&&(u=n(-1===t?r:r+1,s.charCodeAt(-1===t?r-1:r))),l.push({n:u,s:r,e:a,ss:c,se:f,d:t,a:i});}for(;e.re();)o.push(s.slice(e.es(),e.ee()));return e.stackRestore(k),[l,o,!!e.f()]}function t(e,r){const a=e.length;let s=0;for(;s<a;){const a=e.charCodeAt(s);r[s++]=(255&a)<<8|a>>>8;}}function c$1(e,r){const a=e.length;let s=0;for(;s<a;)r[s]=e.charCodeAt(s++);}function n(e,r){i=e;let a="",t=i;for(;;){i>=s.length&&syntaxError();const e=s.charCodeAt(i);if(e===r)break;92===e?(a+=s.slice(t,i),a+=f(),t=i):(8232===e||8233===e||k(e)&&syntaxError(),++i);}return a+=s.slice(t,i++),a}function f(){let e=s.charCodeAt(++i);switch(++i,e){case 110:return "\n";case 114:return "\r";case 120:return String.fromCharCode(u(2));case 117:return function(){let e;123===s.charCodeAt(i)?(++i,e=u(s.indexOf("}",i)-i),++i,e>1114111&&syntaxError()):e=u(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===s.charCodeAt(i)&&++i;case 10:return "";case 56:case 57:syntaxError();default:if(e>=48&&e<=55){let r=s.substr(i-1,3).match(/^[0-7]+/)[0],a=parseInt(r,8);return a>255&&(r=r.slice(0,-1),a=parseInt(r,8)),i+=r.length-1,e=s.charCodeAt(i),"0"===r&&56!==e&&57!==e||syntaxError(),String.fromCharCode(a)}return k(e)?"":String.fromCharCode(e)}}function u(e){const r=i;let a=0,t=0;for(let r=0;r<e;++r,++i){let e,c=s.charCodeAt(i);if(95!==c){if(c>=97)e=c-97+10;else if(c>=65)e=c-65+10;else {if(!(c>=48&&c<=57))break;e=c-48;}if(e>=16)break;t=c,a=16*a+e;}else 95!==t&&0!==r||syntaxError(),t=c;}return 95!==t&&i-r===e||syntaxError(),a}function k(e){return 13===e||10===e}
|
303
|
+
|
304
|
+
async function defaultResolve (id, parentUrl) {
|
305
|
+
return resolveImportMap(importMap, resolveIfNotPlainOrUrl(id, parentUrl) || id, parentUrl);
|
306
|
+
}
|
307
|
+
|
308
|
+
async function _resolve (id, parentUrl) {
|
309
|
+
const urlResolved = resolveIfNotPlainOrUrl(id, parentUrl);
|
310
|
+
return {
|
311
|
+
r: resolveImportMap(importMap, urlResolved || id, parentUrl),
|
312
|
+
// b = bare specifier
|
313
|
+
b: !urlResolved && !isURL(id)
|
314
|
+
};
|
315
|
+
}
|
316
|
+
|
317
|
+
const resolve = resolveHook ? async (id, parentUrl) => ({ r: await esmsInitOptions.resolve(id, parentUrl, defaultResolve), b: false }) : _resolve;
|
318
|
+
|
319
|
+
let id = 0;
|
320
|
+
const registry = {};
|
321
|
+
|
322
|
+
async function loadAll (load, seen) {
|
323
|
+
if (load.b || seen[load.u])
|
324
|
+
return;
|
325
|
+
seen[load.u] = 1;
|
326
|
+
await load.L;
|
327
|
+
await Promise.all(load.d.map(dep => loadAll(dep, seen)));
|
328
|
+
if (!load.n)
|
329
|
+
load.n = load.d.some(dep => dep.n);
|
330
|
+
}
|
331
|
+
|
332
|
+
let importMap = { imports: {}, scopes: {} };
|
333
|
+
let importMapSrcOrLazy = false;
|
334
|
+
let importMapPromise = featureDetectionPromise;
|
335
|
+
|
336
|
+
let acceptingImportMaps = true;
|
337
|
+
let nativeAcceptingImportMaps = true;
|
338
|
+
async function topLevelLoad (url, fetchOpts, source, nativelyLoaded, lastStaticLoadPromise) {
|
339
|
+
if (acceptingImportMaps) {
|
340
|
+
if (!shimMode) {
|
341
|
+
acceptingImportMaps = false;
|
342
|
+
}
|
343
|
+
else {
|
344
|
+
nativeAcceptingImportMaps = false;
|
345
|
+
}
|
346
|
+
}
|
347
|
+
await importMapPromise;
|
348
|
+
// early analysis opt-out - no need to even fetch if we have feature support
|
349
|
+
if (!shimMode && supportsDynamicImport && supportsImportMeta && supportsImportMaps && (!jsonModulesEnabled || supportsJsonAssertions) && (!cssModulesEnabled || supportsCssAssertions) && !importMapSrcOrLazy) {
|
350
|
+
// for polyfill case, only dynamic import needs a return value here, and dynamic import will never pass nativelyLoaded
|
351
|
+
if (nativelyLoaded)
|
352
|
+
return null;
|
353
|
+
await lastStaticLoadPromise;
|
354
|
+
return dynamicImport(source ? createBlob(source) : url, { errUrl: url || source });
|
355
|
+
}
|
356
|
+
await undefined;
|
357
|
+
const load = getOrCreateLoad(url, fetchOpts, source);
|
358
|
+
const seen = {};
|
359
|
+
await loadAll(load, seen);
|
360
|
+
lastLoad = undefined;
|
361
|
+
resolveDeps(load, seen);
|
362
|
+
await lastStaticLoadPromise;
|
363
|
+
if (source && !shimMode && !load.n) {
|
364
|
+
const module = await dynamicImport(createBlob(source), { errUrl: source });
|
365
|
+
if (revokeBlobURLs) revokeObjectURLs(Object.keys(seen));
|
366
|
+
return module;
|
367
|
+
}
|
368
|
+
const module = await dynamicImport(load.b, { errUrl: load.u });
|
369
|
+
// if the top-level load is a shell, run its update function
|
370
|
+
if (load.s)
|
371
|
+
(await dynamicImport(load.s)).u$_(module);
|
372
|
+
if (revokeBlobURLs) revokeObjectURLs(Object.keys(seen));
|
373
|
+
// when tla is supported, this should return the tla promise as an actual handle
|
374
|
+
// so readystate can still correspond to the sync subgraph exec completions
|
375
|
+
return module;
|
376
|
+
}
|
377
|
+
|
378
|
+
function revokeObjectURLs(registryKeys) {
|
379
|
+
let batch = 0;
|
380
|
+
const keysLength = registryKeys.length;
|
381
|
+
const schedule = self.requestIdleCallback ? self.requestIdleCallback : self.requestAnimationFrame;
|
382
|
+
schedule(cleanup);
|
383
|
+
function cleanup() {
|
384
|
+
const batchStartIndex = batch * 100;
|
385
|
+
if (batchStartIndex > keysLength) return
|
386
|
+
for (const key of registryKeys.slice(batchStartIndex, batchStartIndex + 100)) {
|
387
|
+
const load = registry[key];
|
388
|
+
if (load) URL.revokeObjectURL(load.b);
|
389
|
+
}
|
390
|
+
batch++;
|
391
|
+
schedule(cleanup);
|
392
|
+
}
|
393
|
+
}
|
394
|
+
|
395
|
+
async function importShim (id, parentUrl = baseUrl, _assertion) {
|
396
|
+
processScripts();
|
397
|
+
await importMapPromise;
|
398
|
+
return topLevelLoad((await resolve(id, parentUrl)).r || throwUnresolved(id, parentUrl), { credentials: 'same-origin' });
|
399
|
+
}
|
400
|
+
|
401
|
+
self.importShim = importShim;
|
402
|
+
|
403
|
+
const meta = {};
|
404
|
+
|
405
|
+
async function importMetaResolve (id, parentUrl = this.url) {
|
406
|
+
await importMapPromise;
|
407
|
+
return (await resolve(id, `${parentUrl}`)).r || throwUnresolved(id, parentUrl);
|
408
|
+
}
|
409
|
+
|
410
|
+
self._esmsm = meta;
|
411
|
+
|
412
|
+
function urlJsString (url) {
|
413
|
+
return `'${url.replace(/'/g, "\\'")}'`;
|
414
|
+
}
|
415
|
+
|
416
|
+
let lastLoad;
|
417
|
+
function resolveDeps (load, seen) {
|
418
|
+
if (load.b || !seen[load.u])
|
419
|
+
return;
|
420
|
+
seen[load.u] = 0;
|
421
|
+
|
422
|
+
for (const dep of load.d)
|
423
|
+
resolveDeps(dep, seen);
|
424
|
+
|
425
|
+
// use direct native execution when possible
|
426
|
+
// load.n is therefore conservative
|
427
|
+
if (!shimMode && !load.n) {
|
428
|
+
load.b = lastLoad = load.u;
|
429
|
+
load.S = undefined;
|
430
|
+
return;
|
431
|
+
}
|
432
|
+
|
433
|
+
const [imports] = load.a;
|
434
|
+
|
435
|
+
// "execution"
|
436
|
+
const source = load.S;
|
437
|
+
|
438
|
+
// edge doesnt execute sibling in order, so we fix this up by ensuring all previous executions are explicit dependencies
|
439
|
+
let resolvedSource = edge && lastLoad ? `import '${lastLoad}';` : '';
|
440
|
+
|
441
|
+
if (!imports.length) {
|
442
|
+
resolvedSource += source;
|
443
|
+
}
|
444
|
+
else {
|
445
|
+
// once all deps have loaded we can inline the dependency resolution blobs
|
446
|
+
// and define this blob
|
447
|
+
let lastIndex = 0, depIndex = 0;
|
448
|
+
for (const { s: start, se: end, d: dynamicImportIndex } of imports) {
|
449
|
+
// dependency source replacements
|
450
|
+
if (dynamicImportIndex === -1) {
|
451
|
+
const depLoad = load.d[depIndex++];
|
452
|
+
let blobUrl = depLoad.b;
|
453
|
+
if (!blobUrl) {
|
454
|
+
// circular shell creation
|
455
|
+
if (!(blobUrl = depLoad.s)) {
|
456
|
+
blobUrl = depLoad.s = createBlob(`export function u$_(m){${
|
457
|
+
depLoad.a[1].map(
|
458
|
+
name => name === 'default' ? `$_default=m.default` : `${name}=m.${name}`
|
459
|
+
).join(',')
|
460
|
+
}}${
|
461
|
+
depLoad.a[1].map(name =>
|
462
|
+
name === 'default' ? `let $_default;export{$_default as default}` : `export let ${name}`
|
463
|
+
).join(';')
|
464
|
+
}\n//# sourceURL=${depLoad.r}?cycle`);
|
465
|
+
}
|
466
|
+
}
|
467
|
+
// circular shell execution
|
468
|
+
else if (depLoad.s) {
|
469
|
+
resolvedSource += `${source.slice(lastIndex, start - 1)}/*${source.slice(start - 1, end)}*/${urlJsString(blobUrl)};import*as m$_${depIndex} from'${depLoad.b}';import{u$_ as u$_${depIndex}}from'${depLoad.s}';u$_${depIndex}(m$_${depIndex})`;
|
470
|
+
lastIndex = end;
|
471
|
+
depLoad.s = undefined;
|
472
|
+
continue;
|
473
|
+
}
|
474
|
+
resolvedSource += `${source.slice(lastIndex, start - 1)}/*${source.slice(start - 1, end)}*/${urlJsString(blobUrl)}`;
|
475
|
+
lastIndex = end;
|
476
|
+
}
|
477
|
+
// import.meta
|
478
|
+
else if (dynamicImportIndex === -2) {
|
479
|
+
meta[load.r] = { url: load.r, resolve: importMetaResolve };
|
480
|
+
resolvedSource += `${source.slice(lastIndex, start)}self._esmsm[${urlJsString(load.r)}]`;
|
481
|
+
lastIndex = end;
|
482
|
+
}
|
483
|
+
// dynamic import
|
484
|
+
else {
|
485
|
+
resolvedSource += `${source.slice(lastIndex, dynamicImportIndex + 6)}Shim(${source.slice(start, end)}, ${load.r && urlJsString(load.r)}`;
|
486
|
+
lastIndex = end;
|
487
|
+
}
|
488
|
+
}
|
489
|
+
|
490
|
+
resolvedSource += source.slice(lastIndex);
|
491
|
+
}
|
492
|
+
|
493
|
+
resolvedSource = resolvedSource.replace(/\/\/# sourceMappingURL=(.*)\s*$/, (match, url) => {
|
494
|
+
return match.replace(url, new URL(url, load.r));
|
495
|
+
});
|
496
|
+
let hasSourceURL = false;
|
497
|
+
resolvedSource = resolvedSource.replace(/\/\/# sourceURL=(.*)\s*$/, (match, url) => {
|
498
|
+
hasSourceURL = true;
|
499
|
+
return match.replace(url, new URL(url, load.r));
|
500
|
+
});
|
501
|
+
if (!hasSourceURL) {
|
502
|
+
resolvedSource += '\n//# sourceURL=' + load.r;
|
503
|
+
}
|
504
|
+
|
505
|
+
load.b = lastLoad = createBlob(resolvedSource);
|
506
|
+
load.S = undefined;
|
507
|
+
}
|
508
|
+
|
509
|
+
const jsContentType = /^(text|application)\/(x-)?javascript(;|$)/;
|
510
|
+
const jsonContentType = /^(text|application)\/json(;|$)/;
|
511
|
+
const cssContentType = /^(text|application)\/css(;|$)/;
|
512
|
+
const wasmContentType = /^application\/wasm(;|$)/;
|
513
|
+
|
514
|
+
const cssUrlRegEx = /url\(\s*(?:(["'])((?:\\.|[^\n\\"'])+)\1|((?:\\.|[^\s,"'()\\])+))\s*\)/g;
|
515
|
+
|
516
|
+
// restrict in-flight fetches to a pool of 100
|
517
|
+
let p = [];
|
518
|
+
let c = 0;
|
519
|
+
function pushFetchPool () {
|
520
|
+
if (++c > 100)
|
521
|
+
return new Promise(r => p.push(r));
|
522
|
+
}
|
523
|
+
function popFetchPool () {
|
524
|
+
c--;
|
525
|
+
if (p.length)
|
526
|
+
p.shift()();
|
527
|
+
}
|
528
|
+
|
529
|
+
async function doFetch (url, fetchOpts) {
|
530
|
+
const poolQueue = pushFetchPool();
|
531
|
+
if (poolQueue) await poolQueue;
|
532
|
+
try {
|
533
|
+
var res = await fetchHook(url, fetchOpts);
|
534
|
+
}
|
535
|
+
finally {
|
536
|
+
popFetchPool();
|
537
|
+
}
|
538
|
+
if (!res.ok)
|
539
|
+
throw new Error(`${res.status} ${res.statusText} ${res.url}`);
|
540
|
+
const contentType = res.headers.get('content-type');
|
541
|
+
if (jsContentType.test(contentType))
|
542
|
+
return { r: res.url, s: await res.text(), t: 'js' };
|
543
|
+
else if (jsonContentType.test(contentType))
|
544
|
+
return { r: res.url, s: `export default ${await res.text()}`, t: 'json' };
|
545
|
+
else if (cssContentType.test(contentType))
|
546
|
+
return { r: res.url, s: `var s=new CSSStyleSheet();s.replaceSync(${
|
547
|
+
JSON.stringify((await res.text()).replace(cssUrlRegEx, (_match, quotes, relUrl1, relUrl2) => `url(${quotes}${resolveUrl(relUrl1 || relUrl2, url)}${quotes})`))
|
548
|
+
});export default s;`, t: 'css' };
|
549
|
+
else if (wasmContentType.test(contentType))
|
550
|
+
throw new Error('WASM modules not yet supported');
|
551
|
+
else
|
552
|
+
throw new Error(`Unknown Content-Type "${contentType}"`);
|
553
|
+
}
|
554
|
+
|
555
|
+
function getOrCreateLoad (url, fetchOpts, source) {
|
556
|
+
let load = registry[url];
|
557
|
+
if (load)
|
558
|
+
return load;
|
559
|
+
|
560
|
+
load = registry[url] = {
|
561
|
+
// url
|
562
|
+
u: url,
|
563
|
+
// response url
|
564
|
+
r: undefined,
|
565
|
+
// fetchPromise
|
566
|
+
f: undefined,
|
567
|
+
// source
|
568
|
+
S: undefined,
|
569
|
+
// linkPromise
|
570
|
+
L: undefined,
|
571
|
+
// analysis
|
572
|
+
a: undefined,
|
573
|
+
// deps
|
574
|
+
d: undefined,
|
575
|
+
// blobUrl
|
576
|
+
b: undefined,
|
577
|
+
// shellUrl
|
578
|
+
s: undefined,
|
579
|
+
// needsShim
|
580
|
+
n: false,
|
581
|
+
// type
|
582
|
+
t: null
|
583
|
+
};
|
584
|
+
|
585
|
+
load.f = (async () => {
|
586
|
+
if (!source) {
|
587
|
+
// preload fetch options override fetch options (race)
|
588
|
+
let t;
|
589
|
+
({ r: load.r, s: source, t } = await (fetchCache[url] || doFetch(url, fetchOpts)));
|
590
|
+
if (t && !shimMode) {
|
591
|
+
if (t === 'css' && !cssModulesEnabled || t === 'json' && !jsonModulesEnabled)
|
592
|
+
throw new Error(`${t}-modules must be enabled to polyfill via: window.esmsInitOptions = { polyfillEnable: ['${t}-modules'] }`);
|
593
|
+
if (t === 'css' && !supportsCssAssertions || t === 'json' && !supportsJsonAssertions)
|
594
|
+
load.n = true;
|
595
|
+
}
|
596
|
+
}
|
597
|
+
try {
|
598
|
+
load.a = parse(source, load.u);
|
599
|
+
}
|
600
|
+
catch (e) {
|
601
|
+
console.warn(e);
|
602
|
+
load.a = [[], []];
|
603
|
+
}
|
604
|
+
load.S = source;
|
605
|
+
return load;
|
606
|
+
})();
|
607
|
+
|
608
|
+
load.L = load.f.then(async () => {
|
609
|
+
let childFetchOpts = fetchOpts;
|
610
|
+
load.d = (await Promise.all(load.a[0].map(async ({ n, d }) => {
|
611
|
+
if (d >= 0 && !supportsDynamicImport || d === 2 && !supportsImportMeta)
|
612
|
+
load.n = true;
|
613
|
+
if (!n) return;
|
614
|
+
const { r, b } = await resolve(n, load.r || load.u);
|
615
|
+
if (b && !supportsImportMaps)
|
616
|
+
load.n = true;
|
617
|
+
if (d !== -1) return;
|
618
|
+
if (!r)
|
619
|
+
throwUnresolved(n, load.r || load.u);
|
620
|
+
if (skip.test(r)) return { b: r };
|
621
|
+
if (childFetchOpts.integrity)
|
622
|
+
childFetchOpts = Object.assign({}, childFetchOpts, { integrity: undefined });
|
623
|
+
return getOrCreateLoad(r, childFetchOpts).f;
|
624
|
+
}))).filter(l => l);
|
625
|
+
});
|
626
|
+
|
627
|
+
return load;
|
628
|
+
}
|
629
|
+
|
630
|
+
const scriptQuery = 'script[type="module-shim"],script[type="importmap-shim"],script[type="module"],script[type="importmap"]';
|
631
|
+
const preloadQuery = 'link[rel="modulepreload"]';
|
632
|
+
|
633
|
+
function processScripts () {
|
634
|
+
for (const link of document.querySelectorAll(preloadQuery))
|
635
|
+
processPreload(link);
|
636
|
+
const scripts = document.querySelectorAll(scriptQuery);
|
637
|
+
// early shim mode opt-in
|
638
|
+
if (!shimMode) {
|
639
|
+
for (const script of scripts) {
|
640
|
+
if (script.type.endsWith('-shim'))
|
641
|
+
setShimMode();
|
642
|
+
}
|
643
|
+
}
|
644
|
+
for (const script of scripts)
|
645
|
+
processScript(script);
|
646
|
+
}
|
647
|
+
|
648
|
+
function getFetchOpts (script) {
|
649
|
+
const fetchOpts = {};
|
650
|
+
if (script.integrity)
|
651
|
+
fetchOpts.integrity = script.integrity;
|
652
|
+
if (script.referrerpolicy)
|
653
|
+
fetchOpts.referrerPolicy = script.referrerpolicy;
|
654
|
+
if (script.crossorigin === 'use-credentials')
|
655
|
+
fetchOpts.credentials = 'include';
|
656
|
+
else if (script.crossorigin === 'anonymous')
|
657
|
+
fetchOpts.credentials = 'omit';
|
658
|
+
else
|
659
|
+
fetchOpts.credentials = 'same-origin';
|
660
|
+
return fetchOpts;
|
661
|
+
}
|
662
|
+
|
663
|
+
let lastStaticLoadPromise = Promise.resolve();
|
664
|
+
|
665
|
+
let domContentLoadedCnt = 1;
|
666
|
+
function domContentLoadedCheck () {
|
667
|
+
if (--domContentLoadedCnt === 0 && !noLoadEventRetriggers)
|
668
|
+
document.dispatchEvent(new Event('DOMContentLoaded'));
|
669
|
+
}
|
670
|
+
// this should always trigger because we assume es-module-shims is itself a domcontentloaded requirement
|
671
|
+
document.addEventListener('DOMContentLoaded', domContentLoadedCheck);
|
672
|
+
|
673
|
+
let readyStateCompleteCnt = 1;
|
674
|
+
if (document.readyState === 'complete')
|
675
|
+
readyStateCompleteCheck();
|
676
|
+
else
|
677
|
+
document.addEventListener('readystatechange', readyStateCompleteCheck);
|
678
|
+
function readyStateCompleteCheck () {
|
679
|
+
if (--readyStateCompleteCnt === 0 && !noLoadEventRetriggers)
|
680
|
+
document.dispatchEvent(new Event('readystatechange'));
|
681
|
+
}
|
682
|
+
|
683
|
+
function processScript (script) {
|
684
|
+
if (script.ep) // ep marker = script processed
|
685
|
+
return;
|
686
|
+
const shim = script.type.endsWith('-shim');
|
687
|
+
if (shim && !shimMode) setShimMode();
|
688
|
+
const type = shimMode ? script.type.slice(0, -5) : script.type;
|
689
|
+
// dont process module scripts in shim mode or noshim module scripts in polyfill mode
|
690
|
+
if (!shim && shimMode || script.getAttribute('noshim') !== null)
|
691
|
+
return;
|
692
|
+
// empty inline scripts sometimes show before domready
|
693
|
+
if (!script.src && !script.innerHTML)
|
694
|
+
return;
|
695
|
+
script.ep = true;
|
696
|
+
if (type === 'module') {
|
697
|
+
// does this load block readystate complete
|
698
|
+
const isReadyScript = readyStateCompleteCnt > 0;
|
699
|
+
// does this load block DOMContentLoaded
|
700
|
+
const isDomContentLoadedScript = domContentLoadedCnt > 0;
|
701
|
+
if (isReadyScript) readyStateCompleteCnt++;
|
702
|
+
if (isDomContentLoadedScript) domContentLoadedCnt++;
|
703
|
+
const loadPromise = topLevelLoad(script.src || `${baseUrl}?${id++}`, getFetchOpts(script), !script.src && script.innerHTML, !shimMode, isReadyScript && lastStaticLoadPromise).then(() => {
|
704
|
+
if (!noLoadEventRetriggers)
|
705
|
+
triggerLoadEvent(script);
|
706
|
+
}).catch(e => {
|
707
|
+
if (!noLoadEventRetriggers)
|
708
|
+
triggerLoadEvent(script);
|
709
|
+
// setTimeout(() => { throw e; });
|
710
|
+
onerror(e);
|
711
|
+
});
|
712
|
+
if (isReadyScript)
|
713
|
+
lastStaticLoadPromise = loadPromise.then(readyStateCompleteCheck);
|
714
|
+
if (isDomContentLoadedScript)
|
715
|
+
loadPromise.then(domContentLoadedCheck);
|
716
|
+
}
|
717
|
+
else if (acceptingImportMaps && type === 'importmap') {
|
718
|
+
// we dont currently support multiple, external or dynamic imports maps in polyfill mode to match native
|
719
|
+
if (script.src || !nativeAcceptingImportMaps) {
|
720
|
+
if (!shimMode)
|
721
|
+
return;
|
722
|
+
importMapSrcOrLazy = true;
|
723
|
+
}
|
724
|
+
if (!shimMode) {
|
725
|
+
acceptingImportMaps = false;
|
726
|
+
}
|
727
|
+
else {
|
728
|
+
nativeAcceptingImportMaps = false;
|
729
|
+
}
|
730
|
+
importMapPromise = importMapPromise.then(async () => {
|
731
|
+
importMap = resolveAndComposeImportMap(script.src ? await (await fetchHook(script.src)).json() : JSON.parse(script.innerHTML), script.src || baseUrl, importMap);
|
732
|
+
});
|
733
|
+
}
|
734
|
+
}
|
735
|
+
|
736
|
+
function triggerLoadEvent (script) {
|
737
|
+
script.dispatchEvent(new Event('load'));
|
738
|
+
}
|
739
|
+
|
740
|
+
const fetchCache = {};
|
741
|
+
function processPreload (link) {
|
742
|
+
if (link.ep) // ep marker = processed
|
743
|
+
return;
|
744
|
+
link.ep = true;
|
745
|
+
if (fetchCache[link.href])
|
746
|
+
return;
|
747
|
+
fetchCache[link.href] = doFetch(link.href, getFetchOpts(link));
|
748
|
+
}
|
749
|
+
|
750
|
+
new MutationObserver(mutations => {
|
751
|
+
for (const mutation of mutations) {
|
752
|
+
if (mutation.type !== 'childList') continue;
|
753
|
+
for (const node of mutation.addedNodes) {
|
754
|
+
if (node.tagName === 'SCRIPT' && node.type)
|
755
|
+
processScript(node);
|
756
|
+
else if (node.tagName === 'LINK' && node.rel === 'modulepreload')
|
757
|
+
processPreload(node);
|
758
|
+
}
|
759
|
+
}
|
760
|
+
}).observe(document, { childList: true, subtree: true });
|
761
|
+
|
762
|
+
function throwUnresolved (id, parentUrl) {
|
763
|
+
throw Error("Unable to resolve specifier '" + id + (parentUrl ? "' from " + parentUrl : "'"));
|
764
|
+
}
|
765
|
+
|
766
|
+
processScripts();
|
767
|
+
|
768
|
+
}());
|