|
1 /* ES Module Shims Wasm 1.8.2 */ |
|
2 (function () { |
|
3 |
|
4 const hasWindow = typeof window !== 'undefined'; |
|
5 const hasDocument = typeof document !== 'undefined'; |
|
6 |
|
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; |
|
22 |
|
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'); |
|
28 } |
|
29 |
|
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 } else if (skip instanceof RegExp) { |
|
63 skip = s => skip.test(s); |
|
64 } |
|
65 |
|
66 const eoop = err => setTimeout(() => { throw err }); |
|
67 |
|
68 const throwError = err => { (self.reportError || hasWindow && window.safari && console.error || eoop)(err), void onerror(err); }; |
|
69 |
|
70 function fromParent (parent) { |
|
71 return parent ? ` imported from ${parent}` : ''; |
|
72 } |
|
73 |
|
74 let importMapSrcOrLazy = false; |
|
75 |
|
76 function setImportMapSrcOrLazy () { |
|
77 importMapSrcOrLazy = true; |
|
78 } |
|
79 |
|
80 // shim mode is determined on initialization, no late shim mode |
|
81 if (!shimMode) { |
|
82 if (document.querySelectorAll('script[type=module-shim],script[type=importmap-shim],link[rel=modulepreload-shim]').length) { |
|
83 shimMode = true; |
|
84 } |
|
85 else { |
|
86 let seenScript = false; |
|
87 for (const script of document.querySelectorAll('script[type=module],script[type=importmap]')) { |
|
88 if (!seenScript) { |
|
89 if (script.type === 'module' && !script.ep) |
|
90 seenScript = true; |
|
91 } |
|
92 else if (script.type === 'importmap' && seenScript) { |
|
93 importMapSrcOrLazy = true; |
|
94 break; |
|
95 } |
|
96 } |
|
97 } |
|
98 } |
|
99 |
|
100 const backslashRegEx = /\\/g; |
|
101 |
|
102 function asURL (url) { |
|
103 try { |
|
104 if (url.indexOf(':') !== -1) |
|
105 return new URL(url).href; |
|
106 } |
|
107 catch (_) {} |
|
108 } |
|
109 |
|
110 function resolveUrl (relUrl, parentUrl) { |
|
111 return resolveIfNotPlainOrUrl(relUrl, parentUrl) || (asURL(relUrl) || resolveIfNotPlainOrUrl('./' + relUrl, parentUrl)); |
|
112 } |
|
113 |
|
114 function resolveIfNotPlainOrUrl (relUrl, parentUrl) { |
|
115 const hIdx = parentUrl.indexOf('#'), qIdx = parentUrl.indexOf('?'); |
|
116 if (hIdx + qIdx > -2) |
|
117 parentUrl = parentUrl.slice(0, hIdx === -1 ? qIdx : qIdx === -1 || qIdx > hIdx ? hIdx : qIdx); |
|
118 if (relUrl.indexOf('\\') !== -1) |
|
119 relUrl = relUrl.replace(backslashRegEx, '/'); |
|
120 // protocol-relative |
|
121 if (relUrl[0] === '/' && relUrl[1] === '/') { |
|
122 return parentUrl.slice(0, parentUrl.indexOf(':') + 1) + relUrl; |
|
123 } |
|
124 // relative-url |
|
125 else if (relUrl[0] === '.' && (relUrl[1] === '/' || relUrl[1] === '.' && (relUrl[2] === '/' || relUrl.length === 2 && (relUrl += '/')) || |
|
126 relUrl.length === 1 && (relUrl += '/')) || |
|
127 relUrl[0] === '/') { |
|
128 const parentProtocol = parentUrl.slice(0, parentUrl.indexOf(':') + 1); |
|
129 if (parentProtocol === 'blob:') { |
|
130 throw new TypeError(`Failed to resolve module specifier "${relUrl}". Invalid relative url or base scheme isn't hierarchical.`); |
|
131 } |
|
132 // Disabled, but these cases will give inconsistent results for deep backtracking |
|
133 //if (parentUrl[parentProtocol.length] !== '/') |
|
134 // throw new Error('Cannot resolve'); |
|
135 // read pathname from parent URL |
|
136 // pathname taken to be part after leading "/" |
|
137 let pathname; |
|
138 if (parentUrl[parentProtocol.length + 1] === '/') { |
|
139 // resolving to a :// so we need to read out the auth and host |
|
140 if (parentProtocol !== 'file:') { |
|
141 pathname = parentUrl.slice(parentProtocol.length + 2); |
|
142 pathname = pathname.slice(pathname.indexOf('/') + 1); |
|
143 } |
|
144 else { |
|
145 pathname = parentUrl.slice(8); |
|
146 } |
|
147 } |
|
148 else { |
|
149 // resolving to :/ so pathname is the /... part |
|
150 pathname = parentUrl.slice(parentProtocol.length + (parentUrl[parentProtocol.length] === '/')); |
|
151 } |
|
152 |
|
153 if (relUrl[0] === '/') |
|
154 return parentUrl.slice(0, parentUrl.length - pathname.length - 1) + relUrl; |
|
155 |
|
156 // join together and split for removal of .. and . segments |
|
157 // looping the string instead of anything fancy for perf reasons |
|
158 // '../../../../../z' resolved to 'x/y' is just 'z' |
|
159 const segmented = pathname.slice(0, pathname.lastIndexOf('/') + 1) + relUrl; |
|
160 |
|
161 const output = []; |
|
162 let segmentIndex = -1; |
|
163 for (let i = 0; i < segmented.length; i++) { |
|
164 // busy reading a segment - only terminate on '/' |
|
165 if (segmentIndex !== -1) { |
|
166 if (segmented[i] === '/') { |
|
167 output.push(segmented.slice(segmentIndex, i + 1)); |
|
168 segmentIndex = -1; |
|
169 } |
|
170 continue; |
|
171 } |
|
172 // new segment - check if it is relative |
|
173 else if (segmented[i] === '.') { |
|
174 // ../ segment |
|
175 if (segmented[i + 1] === '.' && (segmented[i + 2] === '/' || i + 2 === segmented.length)) { |
|
176 output.pop(); |
|
177 i += 2; |
|
178 continue; |
|
179 } |
|
180 // ./ segment |
|
181 else if (segmented[i + 1] === '/' || i + 1 === segmented.length) { |
|
182 i += 1; |
|
183 continue; |
|
184 } |
|
185 } |
|
186 // it is the start of a new segment |
|
187 while (segmented[i] === '/') i++; |
|
188 segmentIndex = i; |
|
189 } |
|
190 // finish reading out the last segment |
|
191 if (segmentIndex !== -1) |
|
192 output.push(segmented.slice(segmentIndex)); |
|
193 return parentUrl.slice(0, parentUrl.length - pathname.length) + output.join(''); |
|
194 } |
|
195 } |
|
196 |
|
197 function resolveAndComposeImportMap (json, baseUrl, parentMap) { |
|
198 const outMap = { imports: Object.assign({}, parentMap.imports), scopes: Object.assign({}, parentMap.scopes) }; |
|
199 |
|
200 if (json.imports) |
|
201 resolveAndComposePackages(json.imports, outMap.imports, baseUrl, parentMap); |
|
202 |
|
203 if (json.scopes) |
|
204 for (let s in json.scopes) { |
|
205 const resolvedScope = resolveUrl(s, baseUrl); |
|
206 resolveAndComposePackages(json.scopes[s], outMap.scopes[resolvedScope] || (outMap.scopes[resolvedScope] = {}), baseUrl, parentMap); |
|
207 } |
|
208 |
|
209 return outMap; |
|
210 } |
|
211 |
|
212 function getMatch (path, matchObj) { |
|
213 if (matchObj[path]) |
|
214 return path; |
|
215 let sepIndex = path.length; |
|
216 do { |
|
217 const segment = path.slice(0, sepIndex + 1); |
|
218 if (segment in matchObj) |
|
219 return segment; |
|
220 } while ((sepIndex = path.lastIndexOf('/', sepIndex - 1)) !== -1) |
|
221 } |
|
222 |
|
223 function applyPackages (id, packages) { |
|
224 const pkgName = getMatch(id, packages); |
|
225 if (pkgName) { |
|
226 const pkg = packages[pkgName]; |
|
227 if (pkg === null) return; |
|
228 return pkg + id.slice(pkgName.length); |
|
229 } |
|
230 } |
|
231 |
|
232 |
|
233 function resolveImportMap (importMap, resolvedOrPlain, parentUrl) { |
|
234 let scopeUrl = parentUrl && getMatch(parentUrl, importMap.scopes); |
|
235 while (scopeUrl) { |
|
236 const packageResolution = applyPackages(resolvedOrPlain, importMap.scopes[scopeUrl]); |
|
237 if (packageResolution) |
|
238 return packageResolution; |
|
239 scopeUrl = getMatch(scopeUrl.slice(0, scopeUrl.lastIndexOf('/')), importMap.scopes); |
|
240 } |
|
241 return applyPackages(resolvedOrPlain, importMap.imports) || resolvedOrPlain.indexOf(':') !== -1 && resolvedOrPlain; |
|
242 } |
|
243 |
|
244 function resolveAndComposePackages (packages, outPackages, baseUrl, parentMap) { |
|
245 for (let p in packages) { |
|
246 const resolvedLhs = resolveIfNotPlainOrUrl(p, baseUrl) || p; |
|
247 if ((!shimMode || !mapOverrides) && outPackages[resolvedLhs] && (outPackages[resolvedLhs] !== packages[resolvedLhs])) { |
|
248 throw Error(`Rejected map override "${resolvedLhs}" from ${outPackages[resolvedLhs]} to ${packages[resolvedLhs]}.`); |
|
249 } |
|
250 let target = packages[p]; |
|
251 if (typeof target !== 'string') |
|
252 continue; |
|
253 const mapped = resolveImportMap(parentMap, resolveIfNotPlainOrUrl(target, baseUrl) || target, baseUrl); |
|
254 if (mapped) { |
|
255 outPackages[resolvedLhs] = mapped; |
|
256 continue; |
|
257 } |
|
258 console.warn(`Mapping "${p}" -> "${packages[p]}" does not resolve`); |
|
259 } |
|
260 } |
|
261 |
|
262 let dynamicImport = !hasDocument && (0, eval)('u=>import(u)'); |
|
263 |
|
264 let supportsDynamicImport; |
|
265 |
|
266 const dynamicImportCheck = hasDocument && new Promise(resolve => { |
|
267 const s = Object.assign(document.createElement('script'), { |
|
268 src: createBlob('self._d=u=>import(u)'), |
|
269 ep: true |
|
270 }); |
|
271 s.setAttribute('nonce', nonce); |
|
272 s.addEventListener('load', () => { |
|
273 if (!(supportsDynamicImport = !!(dynamicImport = self._d))) { |
|
274 let err; |
|
275 window.addEventListener('error', _err => err = _err); |
|
276 dynamicImport = (url, opts) => new Promise((resolve, reject) => { |
|
277 const s = Object.assign(document.createElement('script'), { |
|
278 type: 'module', |
|
279 src: createBlob(`import*as m from'${url}';self._esmsi=m`) |
|
280 }); |
|
281 err = undefined; |
|
282 s.ep = true; |
|
283 if (nonce) |
|
284 s.setAttribute('nonce', nonce); |
|
285 // Safari is unique in supporting module script error events |
|
286 s.addEventListener('error', cb); |
|
287 s.addEventListener('load', cb); |
|
288 function cb (_err) { |
|
289 document.head.removeChild(s); |
|
290 if (self._esmsi) { |
|
291 resolve(self._esmsi, baseUrl); |
|
292 self._esmsi = undefined; |
|
293 } |
|
294 else { |
|
295 reject(!(_err instanceof Event) && _err || err && err.error || new Error(`Error loading ${opts && opts.errUrl || url} (${s.src}).`)); |
|
296 err = undefined; |
|
297 } |
|
298 } |
|
299 document.head.appendChild(s); |
|
300 }); |
|
301 } |
|
302 document.head.removeChild(s); |
|
303 delete self._d; |
|
304 resolve(); |
|
305 }); |
|
306 document.head.appendChild(s); |
|
307 }); |
|
308 |
|
309 // support browsers without dynamic import support (eg Firefox 6x) |
|
310 let supportsJsonAssertions = false; |
|
311 let supportsCssAssertions = false; |
|
312 |
|
313 const supports = hasDocument && HTMLScriptElement.supports; |
|
314 |
|
315 let supportsImportMaps = supports && supports.name === 'supports' && supports('importmap'); |
|
316 let supportsImportMeta = supportsDynamicImport; |
|
317 |
|
318 const importMetaCheck = 'import.meta'; |
|
319 const cssModulesCheck = `import"x"assert{type:"css"}`; |
|
320 const jsonModulesCheck = `import"x"assert{type:"json"}`; |
|
321 |
|
322 let featureDetectionPromise = Promise.resolve(dynamicImportCheck).then(() => { |
|
323 if (!supportsDynamicImport) |
|
324 return; |
|
325 |
|
326 if (!hasDocument) |
|
327 return Promise.all([ |
|
328 supportsImportMaps || dynamicImport(createBlob(importMetaCheck)).then(() => supportsImportMeta = true, noop), |
|
329 cssModulesEnabled && dynamicImport(createBlob(cssModulesCheck.replace('x', createBlob('', 'text/css')))).then(() => supportsCssAssertions = true, noop), |
|
330 jsonModulesEnabled && dynamicImport(createBlob(jsonModulescheck.replace('x', createBlob('{}', 'text/json')))).then(() => supportsJsonAssertions = true, noop), |
|
331 ]); |
|
332 |
|
333 return new Promise(resolve => { |
|
334 const iframe = document.createElement('iframe'); |
|
335 iframe.style.display = 'none'; |
|
336 iframe.setAttribute('nonce', nonce); |
|
337 function cb ({ data }) { |
|
338 const isFeatureDetectionMessage = Array.isArray(data) && data[0] === 'esms'; |
|
339 if (!isFeatureDetectionMessage) { |
|
340 return; |
|
341 } |
|
342 supportsImportMaps = data[1]; |
|
343 supportsImportMeta = data[2]; |
|
344 supportsCssAssertions = data[3]; |
|
345 supportsJsonAssertions = data[4]; |
|
346 resolve(); |
|
347 document.head.removeChild(iframe); |
|
348 window.removeEventListener('message', cb, false); |
|
349 } |
|
350 window.addEventListener('message', cb, false); |
|
351 |
|
352 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([${ |
|
353 supportsImportMaps ? 'true,true' : `'x',b('${importMetaCheck}')`}, ${cssModulesEnabled ? `b('${cssModulesCheck}'.replace('x',b('','text/css')))` : 'false'}, ${ |
|
354 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>`; |
|
355 |
|
356 // Safari will call onload eagerly on head injection, but we don't want the Wechat |
|
357 // path to trigger before setting srcdoc, therefore we track the timing |
|
358 let readyForOnload = false, onloadCalledWhileNotReady = false; |
|
359 function doOnload () { |
|
360 if (!readyForOnload) { |
|
361 onloadCalledWhileNotReady = true; |
|
362 return; |
|
363 } |
|
364 // WeChat browser doesn't support setting srcdoc scripts |
|
365 // But iframe sandboxes don't support contentDocument so we do this as a fallback |
|
366 const doc = iframe.contentDocument; |
|
367 if (doc && doc.head.childNodes.length === 0) { |
|
368 const s = doc.createElement('script'); |
|
369 if (nonce) |
|
370 s.setAttribute('nonce', nonce); |
|
371 s.innerHTML = importMapTest.slice(15 + (nonce ? nonce.length : 0), -9); |
|
372 doc.head.appendChild(s); |
|
373 } |
|
374 } |
|
375 |
|
376 iframe.onload = doOnload; |
|
377 // WeChat browser requires append before setting srcdoc |
|
378 document.head.appendChild(iframe); |
|
379 |
|
380 // setting srcdoc is not supported in React native webviews on iOS |
|
381 // setting src to a blob URL results in a navigation event in webviews |
|
382 // document.write gives usability warnings |
|
383 readyForOnload = true; |
|
384 if ('srcdoc' in iframe) |
|
385 iframe.srcdoc = importMapTest; |
|
386 else |
|
387 iframe.contentDocument.write(importMapTest); |
|
388 // retrigger onload for Safari only if necessary |
|
389 if (onloadCalledWhileNotReady) doOnload(); |
|
390 }); |
|
391 }); |
|
392 |
|
393 /* es-module-lexer 1.4.1 */ |
|
394 const A=1===new Uint8Array(new Uint16Array([1]).buffer)[0];function parse(E,g="@"){if(!C)return init.then((()=>parse(E)));const I=E.length+1,k=(C.__heap_base.value||C.__heap_base)+4*I-C.memory.buffer.byteLength;k>0&&C.memory.grow(Math.ceil(k/65536));const K=C.sa(I-1);if((A?B:Q)(E,new Uint16Array(C.memory.buffer,K,I)),!C.parse())throw Object.assign(new Error(`Parse error ${g}:${E.slice(0,C.e()).split("\n").length}:${C.e()-E.lastIndexOf("\n",C.e()-1)}`),{idx:C.e()});const o=[],D=[];for(;C.ri();){const A=C.is(),Q=C.ie(),B=C.ai(),g=C.id(),I=C.ss(),k=C.se();let K;C.ip()&&(K=w(E.slice(-1===g?A-1:A,-1===g?Q+1:Q))),o.push({n:K,s:A,e:Q,ss:I,se:k,d:g,a:B});}for(;C.re();){const A=C.es(),Q=C.ee(),B=C.els(),g=C.ele(),I=E.slice(A,Q),k=I[0],K=B<0?void 0:E.slice(B,g),o=K?K[0]:"";D.push({s:A,e:Q,ls:B,le:g,n:'"'===k||"'"===k?w(I):I,ln:'"'===o||"'"===o?w(K):K});}function w(A){try{return (0,eval)(A)}catch(A){}}return [o,D,!!C.f(),!!C.ms()]}function Q(A,Q){const B=A.length;let C=0;for(;C<B;){const B=A.charCodeAt(C);Q[C++]=(255&B)<<8|B>>>8;}}function B(A,Q){const B=A.length;let C=0;for(;C<B;)Q[C]=A.charCodeAt(C++);}let C;const init=WebAssembly.compile((E="AGFzbQEAAAABKghgAX8Bf2AEf39/fwBgAAF/YAAAYAF/AGADf39/AX9gAn9/AX9gAn9/AAMwLwABAQICAgICAgICAgICAgICAgICAAMDAwQEAAAAAwAAAAADAwAFBgAAAAcABgIFBAUBcAEBAQUDAQABBg8CfwFBsPIAC38AQbDyAAsHdRQGbWVtb3J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AMDkAAA==","undefined"!=typeof Buffer?Buffer.from(E,"base64"):Uint8Array.from(atob(E),(A=>A.charCodeAt(0))))).then(WebAssembly.instantiate).then((({exports:A})=>{C=A;}));var E; |
|
395 |
|
396 async function _resolve (id, parentUrl) { |
|
397 const urlResolved = resolveIfNotPlainOrUrl(id, parentUrl) || asURL(id); |
|
398 return { |
|
399 r: resolveImportMap(importMap, urlResolved || id, parentUrl) || throwUnresolved(id, parentUrl), |
|
400 // b = bare specifier |
|
401 b: !urlResolved && !asURL(id) |
|
402 }; |
|
403 } |
|
404 |
|
405 const resolve = resolveHook ? async (id, parentUrl) => { |
|
406 let result = resolveHook(id, parentUrl, defaultResolve); |
|
407 // will be deprecated in next major |
|
408 if (result && result.then) |
|
409 result = await result; |
|
410 return result ? { r: result, b: !resolveIfNotPlainOrUrl(id, parentUrl) && !asURL(id) } : _resolve(id, parentUrl); |
|
411 } : _resolve; |
|
412 |
|
413 // importShim('mod'); |
|
414 // importShim('mod', { opts }); |
|
415 // importShim('mod', { opts }, parentUrl); |
|
416 // importShim('mod', parentUrl); |
|
417 async function importShim (id, ...args) { |
|
418 // parentUrl if present will be the last argument |
|
419 let parentUrl = args[args.length - 1]; |
|
420 if (typeof parentUrl !== 'string') |
|
421 parentUrl = baseUrl; |
|
422 // needed for shim check |
|
423 await initPromise; |
|
424 if (importHook) await importHook(id, typeof args[1] !== 'string' ? args[1] : {}, parentUrl); |
|
425 if (acceptingImportMaps || shimMode || !baselinePassthrough) { |
|
426 if (hasDocument) |
|
427 processScriptsAndPreloads(true); |
|
428 if (!shimMode) |
|
429 acceptingImportMaps = false; |
|
430 } |
|
431 await importMapPromise; |
|
432 return topLevelLoad((await resolve(id, parentUrl)).r, { credentials: 'same-origin' }); |
|
433 } |
|
434 |
|
435 self.importShim = importShim; |
|
436 |
|
437 function defaultResolve (id, parentUrl) { |
|
438 return resolveImportMap(importMap, resolveIfNotPlainOrUrl(id, parentUrl) || id, parentUrl) || throwUnresolved(id, parentUrl); |
|
439 } |
|
440 |
|
441 function throwUnresolved (id, parentUrl) { |
|
442 throw Error(`Unable to resolve specifier '${id}'${fromParent(parentUrl)}`); |
|
443 } |
|
444 |
|
445 const resolveSync = (id, parentUrl = baseUrl) => { |
|
446 parentUrl = `${parentUrl}`; |
|
447 const result = resolveHook && resolveHook(id, parentUrl, defaultResolve); |
|
448 return result && !result.then ? result : defaultResolve(id, parentUrl); |
|
449 }; |
|
450 |
|
451 function metaResolve (id, parentUrl = this.url) { |
|
452 return resolveSync(id, parentUrl); |
|
453 } |
|
454 |
|
455 importShim.resolve = resolveSync; |
|
456 importShim.getImportMap = () => JSON.parse(JSON.stringify(importMap)); |
|
457 importShim.addImportMap = importMapIn => { |
|
458 if (!shimMode) throw new Error('Unsupported in polyfill mode.'); |
|
459 importMap = resolveAndComposeImportMap(importMapIn, baseUrl, importMap); |
|
460 }; |
|
461 |
|
462 const registry = importShim._r = {}; |
|
463 importShim._w = {}; |
|
464 |
|
465 async function loadAll (load, seen) { |
|
466 if (load.b || seen[load.u]) |
|
467 return; |
|
468 seen[load.u] = 1; |
|
469 await load.L; |
|
470 await Promise.all(load.d.map(dep => loadAll(dep, seen))); |
|
471 if (!load.n) |
|
472 load.n = load.d.some(dep => dep.n); |
|
473 } |
|
474 |
|
475 let importMap = { imports: {}, scopes: {} }; |
|
476 let baselinePassthrough; |
|
477 |
|
478 const initPromise = featureDetectionPromise.then(() => { |
|
479 baselinePassthrough = esmsInitOptions.polyfillEnable !== true && supportsDynamicImport && supportsImportMeta && supportsImportMaps && (!jsonModulesEnabled || supportsJsonAssertions) && (!cssModulesEnabled || supportsCssAssertions) && !importMapSrcOrLazy; |
|
480 if (hasDocument) { |
|
481 if (!supportsImportMaps) { |
|
482 const supports = HTMLScriptElement.supports || (type => type === 'classic' || type === 'module'); |
|
483 HTMLScriptElement.supports = type => type === 'importmap' || supports(type); |
|
484 } |
|
485 if (shimMode || !baselinePassthrough) { |
|
486 new MutationObserver(mutations => { |
|
487 for (const mutation of mutations) { |
|
488 if (mutation.type !== 'childList') continue; |
|
489 for (const node of mutation.addedNodes) { |
|
490 if (node.tagName === 'SCRIPT') { |
|
491 if (node.type === (shimMode ? 'module-shim' : 'module')) |
|
492 processScript(node, true); |
|
493 if (node.type === (shimMode ? 'importmap-shim' : 'importmap')) |
|
494 processImportMap(node, true); |
|
495 } |
|
496 else if (node.tagName === 'LINK' && node.rel === (shimMode ? 'modulepreload-shim' : 'modulepreload')) { |
|
497 processPreload(node); |
|
498 } |
|
499 } |
|
500 } |
|
501 }).observe(document, {childList: true, subtree: true}); |
|
502 processScriptsAndPreloads(); |
|
503 if (document.readyState === 'complete') { |
|
504 readyStateCompleteCheck(); |
|
505 } |
|
506 else { |
|
507 async function readyListener() { |
|
508 await initPromise; |
|
509 processScriptsAndPreloads(); |
|
510 if (document.readyState === 'complete') { |
|
511 readyStateCompleteCheck(); |
|
512 document.removeEventListener('readystatechange', readyListener); |
|
513 } |
|
514 } |
|
515 document.addEventListener('readystatechange', readyListener); |
|
516 } |
|
517 } |
|
518 } |
|
519 return init; |
|
520 }); |
|
521 let importMapPromise = initPromise; |
|
522 let firstPolyfillLoad = true; |
|
523 let acceptingImportMaps = true; |
|
524 |
|
525 async function topLevelLoad (url, fetchOpts, source, nativelyLoaded, lastStaticLoadPromise) { |
|
526 if (!shimMode) |
|
527 acceptingImportMaps = false; |
|
528 await initPromise; |
|
529 await importMapPromise; |
|
530 if (importHook) await importHook(url, typeof fetchOpts !== 'string' ? fetchOpts : {}, ''); |
|
531 // early analysis opt-out - no need to even fetch if we have feature support |
|
532 if (!shimMode && baselinePassthrough) { |
|
533 // for polyfill case, only dynamic import needs a return value here, and dynamic import will never pass nativelyLoaded |
|
534 if (nativelyLoaded) |
|
535 return null; |
|
536 await lastStaticLoadPromise; |
|
537 return dynamicImport(source ? createBlob(source) : url, { errUrl: url || source }); |
|
538 } |
|
539 const load = getOrCreateLoad(url, fetchOpts, null, source); |
|
540 const seen = {}; |
|
541 await loadAll(load, seen); |
|
542 lastLoad = undefined; |
|
543 resolveDeps(load, seen); |
|
544 await lastStaticLoadPromise; |
|
545 if (source && !shimMode && !load.n) { |
|
546 if (nativelyLoaded) return; |
|
547 if (revokeBlobURLs) revokeObjectURLs(Object.keys(seen)); |
|
548 return await dynamicImport(createBlob(source), { errUrl: source }); |
|
549 } |
|
550 if (firstPolyfillLoad && !shimMode && load.n && nativelyLoaded) { |
|
551 onpolyfill(); |
|
552 firstPolyfillLoad = false; |
|
553 } |
|
554 const module = await dynamicImport(!shimMode && !load.n && nativelyLoaded ? load.u : load.b, { errUrl: load.u }); |
|
555 // if the top-level load is a shell, run its update function |
|
556 if (load.s) |
|
557 (await dynamicImport(load.s)).u$_(module); |
|
558 if (revokeBlobURLs) revokeObjectURLs(Object.keys(seen)); |
|
559 // when tla is supported, this should return the tla promise as an actual handle |
|
560 // so readystate can still correspond to the sync subgraph exec completions |
|
561 return module; |
|
562 } |
|
563 |
|
564 function revokeObjectURLs(registryKeys) { |
|
565 let batch = 0; |
|
566 const keysLength = registryKeys.length; |
|
567 const schedule = self.requestIdleCallback ? self.requestIdleCallback : self.requestAnimationFrame; |
|
568 schedule(cleanup); |
|
569 function cleanup() { |
|
570 const batchStartIndex = batch * 100; |
|
571 if (batchStartIndex > keysLength) return |
|
572 for (const key of registryKeys.slice(batchStartIndex, batchStartIndex + 100)) { |
|
573 const load = registry[key]; |
|
574 if (load) URL.revokeObjectURL(load.b); |
|
575 } |
|
576 batch++; |
|
577 schedule(cleanup); |
|
578 } |
|
579 } |
|
580 |
|
581 function urlJsString (url) { |
|
582 return `'${url.replace(/'/g, "\\'")}'`; |
|
583 } |
|
584 |
|
585 let lastLoad; |
|
586 function resolveDeps (load, seen) { |
|
587 if (load.b || !seen[load.u]) |
|
588 return; |
|
589 seen[load.u] = 0; |
|
590 |
|
591 for (const dep of load.d) |
|
592 resolveDeps(dep, seen); |
|
593 |
|
594 const [imports, exports] = load.a; |
|
595 |
|
596 // "execution" |
|
597 const source = load.S; |
|
598 |
|
599 // edge doesnt execute sibling in order, so we fix this up by ensuring all previous executions are explicit dependencies |
|
600 let resolvedSource = edge && lastLoad ? `import '${lastLoad}';` : ''; |
|
601 |
|
602 // once all deps have loaded we can inline the dependency resolution blobs |
|
603 // and define this blob |
|
604 let lastIndex = 0, depIndex = 0, dynamicImportEndStack = []; |
|
605 function pushStringTo (originalIndex) { |
|
606 while (dynamicImportEndStack[dynamicImportEndStack.length - 1] < originalIndex) { |
|
607 const dynamicImportEnd = dynamicImportEndStack.pop(); |
|
608 resolvedSource += `${source.slice(lastIndex, dynamicImportEnd)}, ${urlJsString(load.r)}`; |
|
609 lastIndex = dynamicImportEnd; |
|
610 } |
|
611 resolvedSource += source.slice(lastIndex, originalIndex); |
|
612 lastIndex = originalIndex; |
|
613 } |
|
614 |
|
615 for (const { s: start, ss: statementStart, se: statementEnd, d: dynamicImportIndex } of imports) { |
|
616 // dependency source replacements |
|
617 if (dynamicImportIndex === -1) { |
|
618 let depLoad = load.d[depIndex++], blobUrl = depLoad.b, cycleShell = !blobUrl; |
|
619 if (cycleShell) { |
|
620 // circular shell creation |
|
621 if (!(blobUrl = depLoad.s)) { |
|
622 blobUrl = depLoad.s = createBlob(`export function u$_(m){${ |
|
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(',') |
|
627 }}${ |
|
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`); |
|
632 } |
|
633 } |
|
634 |
|
635 pushStringTo(start - 1); |
|
636 resolvedSource += `/*${source.slice(start - 1, statementEnd)}*/${urlJsString(blobUrl)}`; |
|
637 |
|
638 // circular shell execution |
|
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})`; |
|
641 depLoad.s = undefined; |
|
642 } |
|
643 lastIndex = statementEnd; |
|
644 } |
|
645 // import.meta |
|
646 else if (dynamicImportIndex === -2) { |
|
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; |
|
652 } |
|
653 // dynamic import |
|
654 else { |
|
655 pushStringTo(statementStart + 6); |
|
656 resolvedSource += `Shim(`; |
|
657 dynamicImportEndStack.push(statementEnd - 1); |
|
658 lastIndex = start; |
|
659 } |
|
660 } |
|
661 |
|
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 function pushSourceURL (commentPrefix, commentStart) { |
|
667 const urlStart = commentStart + commentPrefix.length; |
|
668 const commentEnd = source.indexOf('\n', urlStart); |
|
669 const urlEnd = commentEnd !== -1 ? commentEnd : source.length; |
|
670 pushStringTo(urlStart); |
|
671 resolvedSource += new URL(source.slice(urlStart, urlEnd), load.r).href; |
|
672 lastIndex = urlEnd; |
|
673 } |
|
674 |
|
675 let sourceURLCommentStart = source.lastIndexOf(sourceURLCommentPrefix); |
|
676 let sourceMapURLCommentStart = source.lastIndexOf(sourceMapURLCommentPrefix); |
|
677 |
|
678 // ignore sourceMap comments before already spliced code |
|
679 if (sourceURLCommentStart < lastIndex) sourceURLCommentStart = -1; |
|
680 if (sourceMapURLCommentStart < lastIndex) sourceMapURLCommentStart = -1; |
|
681 |
|
682 // sourceURL first / only |
|
683 if (sourceURLCommentStart !== -1 && (sourceMapURLCommentStart === -1 || sourceMapURLCommentStart > sourceURLCommentStart)) { |
|
684 pushSourceURL(sourceURLCommentPrefix, sourceURLCommentStart); |
|
685 } |
|
686 // sourceMappingURL |
|
687 if (sourceMapURLCommentStart !== -1) { |
|
688 pushSourceURL(sourceMapURLCommentPrefix, sourceMapURLCommentStart); |
|
689 // sourceURL last |
|
690 if (sourceURLCommentStart !== -1 && (sourceURLCommentStart > sourceMapURLCommentStart)) |
|
691 pushSourceURL(sourceURLCommentPrefix, sourceURLCommentStart); |
|
692 } |
|
693 |
|
694 pushStringTo(source.length); |
|
695 |
|
696 if (sourceURLCommentStart === -1) |
|
697 resolvedSource += sourceURLCommentPrefix + load.r; |
|
698 |
|
699 load.b = lastLoad = createBlob(resolvedSource); |
|
700 load.S = undefined; |
|
701 } |
|
702 |
|
703 const sourceURLCommentPrefix = '\n//# sourceURL='; |
|
704 const sourceMapURLCommentPrefix = '\n//# sourceMappingURL='; |
|
705 |
|
706 const jsContentType = /^(text|application)\/(x-)?javascript(;|$)/; |
|
707 const wasmContentType = /^(application)\/wasm(;|$)/; |
|
708 const jsonContentType = /^(text|application)\/json(;|$)/; |
|
709 const cssContentType = /^(text|application)\/css(;|$)/; |
|
710 |
|
711 const cssUrlRegEx = /url\(\s*(?:(["'])((?:\\.|[^\n\\"'])+)\1|((?:\\.|[^\s,"'()\\])+))\s*\)/g; |
|
712 |
|
713 // restrict in-flight fetches to a pool of 100 |
|
714 let p = []; |
|
715 let c = 0; |
|
716 function pushFetchPool () { |
|
717 if (++c > 100) |
|
718 return new Promise(r => p.push(r)); |
|
719 } |
|
720 function popFetchPool () { |
|
721 c--; |
|
722 if (p.length) |
|
723 p.shift()(); |
|
724 } |
|
725 |
|
726 async function doFetch (url, fetchOpts, parent) { |
|
727 if (enforceIntegrity && !fetchOpts.integrity) |
|
728 throw Error(`No integrity for ${url}${fromParent(parent)}.`); |
|
729 const poolQueue = pushFetchPool(); |
|
730 if (poolQueue) await poolQueue; |
|
731 try { |
|
732 var res = await fetchHook(url, fetchOpts); |
|
733 } |
|
734 catch (e) { |
|
735 e.message = `Unable to fetch ${url}${fromParent(parent)} - see network log for details.\n` + e.message; |
|
736 throw e; |
|
737 } |
|
738 finally { |
|
739 popFetchPool(); |
|
740 } |
|
741 |
|
742 if (!res.ok) { |
|
743 const error = new TypeError(`${res.status} ${res.statusText} ${res.url}${fromParent(parent)}`); |
|
744 error.response = res; |
|
745 throw error; |
|
746 } |
|
747 return res; |
|
748 } |
|
749 |
|
750 async function fetchModule (url, fetchOpts, parent) { |
|
751 const res = await doFetch(url, fetchOpts, parent); |
|
752 const contentType = res.headers.get('content-type'); |
|
753 if (jsContentType.test(contentType)) |
|
754 return { r: res.url, s: await res.text(), t: 'js' }; |
|
755 else if (wasmContentType.test(contentType)) { |
|
756 const module = importShim._w[url] = await WebAssembly.compileStreaming(res); |
|
757 let s = '', i = 0, importObj = ''; |
|
758 for (const impt of WebAssembly.Module.imports(module)) { |
|
759 s += `import * as impt${i} from '${impt.module}';\n`; |
|
760 importObj += `'${impt.module}':impt${i++},`; |
|
761 } |
|
762 i = 0; |
|
763 s += `const instance = await WebAssembly.instantiate(importShim._w['${url}'], {${importObj}});\n`; |
|
764 for (const expt of WebAssembly.Module.exports(module)) { |
|
765 s += `const expt${i} = instance['${expt.name}'];\n`; |
|
766 s += `export { expt${i++} as "${expt.name}" };\n`; |
|
767 } |
|
768 return { r: res.url, s, t: 'wasm' }; |
|
769 } |
|
770 else if (jsonContentType.test(contentType)) |
|
771 return { r: res.url, s: `export default ${await res.text()}`, t: 'json' }; |
|
772 else if (cssContentType.test(contentType)) { |
|
773 return { r: res.url, s: `var s=new CSSStyleSheet();s.replaceSync(${ |
|
774 JSON.stringify((await res.text()).replace(cssUrlRegEx, (_match, quotes = '', relUrl1, relUrl2) => `url(${quotes}${resolveUrl(relUrl1 || relUrl2, url)}${quotes})`)) |
|
775 });export default s;`, t: 'css' }; |
|
776 } |
|
777 else |
|
778 throw Error(`Unsupported Content-Type "${contentType}" loading ${url}${fromParent(parent)}. Modules must be served with a valid MIME type like application/javascript.`); |
|
779 } |
|
780 |
|
781 function getOrCreateLoad (url, fetchOpts, parent, source) { |
|
782 let load = registry[url]; |
|
783 if (load && !source) |
|
784 return load; |
|
785 |
|
786 load = { |
|
787 // url |
|
788 u: url, |
|
789 // response url |
|
790 r: source ? url : undefined, |
|
791 // fetchPromise |
|
792 f: undefined, |
|
793 // source |
|
794 S: undefined, |
|
795 // linkPromise |
|
796 L: undefined, |
|
797 // analysis |
|
798 a: undefined, |
|
799 // deps |
|
800 d: undefined, |
|
801 // blobUrl |
|
802 b: undefined, |
|
803 // shellUrl |
|
804 s: undefined, |
|
805 // needsShim |
|
806 n: false, |
|
807 // type |
|
808 t: null, |
|
809 // meta |
|
810 m: null |
|
811 }; |
|
812 if (registry[url]) { |
|
813 let i = 0; |
|
814 while (registry[load.u + ++i]); |
|
815 load.u += i; |
|
816 } |
|
817 registry[load.u] = load; |
|
818 |
|
819 load.f = (async () => { |
|
820 if (!source) { |
|
821 // preload fetch options override fetch options (race) |
|
822 let t; |
|
823 ({ r: load.r, s: source, t } = await (fetchCache[url] || fetchModule(url, fetchOpts, parent))); |
|
824 if (t && !shimMode) { |
|
825 if (t === 'css' && !cssModulesEnabled || t === 'json' && !jsonModulesEnabled) |
|
826 throw Error(`${t}-modules require <script type="esms-options">{ "polyfillEnable": ["${t}-modules"] }<${''}/script>`); |
|
827 if (t === 'css' && !supportsCssAssertions || t === 'json' && !supportsJsonAssertions) |
|
828 load.n = true; |
|
829 } |
|
830 } |
|
831 try { |
|
832 load.a = parse(source, load.u); |
|
833 } |
|
834 catch (e) { |
|
835 throwError(e); |
|
836 load.a = [[], [], false]; |
|
837 } |
|
838 load.S = source; |
|
839 return load; |
|
840 })(); |
|
841 |
|
842 load.L = load.f.then(async () => { |
|
843 let childFetchOpts = fetchOpts; |
|
844 load.d = (await Promise.all(load.a[0].map(async ({ n, d }) => { |
|
845 if (d >= 0 && !supportsDynamicImport || d === -2 && !supportsImportMeta) |
|
846 load.n = true; |
|
847 if (d !== -1 || !n) return; |
|
848 const { r, b } = await resolve(n, load.r || load.u); |
|
849 if (b && (!supportsImportMaps || importMapSrcOrLazy)) |
|
850 load.n = true; |
|
851 if (d !== -1) return; |
|
852 if (skip && skip(r)) return { b: r }; |
|
853 if (childFetchOpts.integrity) |
|
854 childFetchOpts = Object.assign({}, childFetchOpts, { integrity: undefined }); |
|
855 return getOrCreateLoad(r, childFetchOpts, load.r).f; |
|
856 }))).filter(l => l); |
|
857 }); |
|
858 |
|
859 return load; |
|
860 } |
|
861 |
|
862 function processScriptsAndPreloads (mapsOnly = false) { |
|
863 if (!mapsOnly) |
|
864 for (const link of document.querySelectorAll(shimMode ? 'link[rel=modulepreload-shim]' : 'link[rel=modulepreload]')) |
|
865 processPreload(link); |
|
866 for (const script of document.querySelectorAll(shimMode ? 'script[type=importmap-shim]' : 'script[type=importmap]')) |
|
867 processImportMap(script); |
|
868 if (!mapsOnly) |
|
869 for (const script of document.querySelectorAll(shimMode ? 'script[type=module-shim]' : 'script[type=module]')) |
|
870 processScript(script); |
|
871 } |
|
872 |
|
873 function getFetchOpts (script) { |
|
874 const fetchOpts = {}; |
|
875 if (script.integrity) |
|
876 fetchOpts.integrity = script.integrity; |
|
877 if (script.referrerPolicy) |
|
878 fetchOpts.referrerPolicy = script.referrerPolicy; |
|
879 if (script.crossOrigin === 'use-credentials') |
|
880 fetchOpts.credentials = 'include'; |
|
881 else if (script.crossOrigin === 'anonymous') |
|
882 fetchOpts.credentials = 'omit'; |
|
883 else |
|
884 fetchOpts.credentials = 'same-origin'; |
|
885 return fetchOpts; |
|
886 } |
|
887 |
|
888 let lastStaticLoadPromise = Promise.resolve(); |
|
889 |
|
890 let domContentLoadedCnt = 1; |
|
891 function domContentLoadedCheck () { |
|
892 if (--domContentLoadedCnt === 0 && !noLoadEventRetriggers && (shimMode || !baselinePassthrough)) { |
|
893 document.dispatchEvent(new Event('DOMContentLoaded')); |
|
894 } |
|
895 } |
|
896 // this should always trigger because we assume es-module-shims is itself a domcontentloaded requirement |
|
897 if (hasDocument) { |
|
898 document.addEventListener('DOMContentLoaded', async () => { |
|
899 await initPromise; |
|
900 domContentLoadedCheck(); |
|
901 }); |
|
902 } |
|
903 |
|
904 let readyStateCompleteCnt = 1; |
|
905 function readyStateCompleteCheck () { |
|
906 if (--readyStateCompleteCnt === 0 && !noLoadEventRetriggers && (shimMode || !baselinePassthrough)) { |
|
907 document.dispatchEvent(new Event('readystatechange')); |
|
908 } |
|
909 } |
|
910 |
|
911 const hasNext = script => script.nextSibling || script.parentNode && hasNext(script.parentNode); |
|
912 const epCheck = (script, ready) => script.ep || !ready && (!script.src && !script.innerHTML || !hasNext(script)) || script.getAttribute('noshim') !== null || !(script.ep = true); |
|
913 |
|
914 function processImportMap (script, ready = readyStateCompleteCnt > 0) { |
|
915 if (epCheck(script, ready)) return; |
|
916 // we dont currently support multiple, external or dynamic imports maps in polyfill mode to match native |
|
917 if (script.src) { |
|
918 if (!shimMode) |
|
919 return; |
|
920 setImportMapSrcOrLazy(); |
|
921 } |
|
922 if (acceptingImportMaps) { |
|
923 importMapPromise = importMapPromise |
|
924 .then(async () => { |
|
925 importMap = resolveAndComposeImportMap(script.src ? await (await doFetch(script.src, getFetchOpts(script))).json() : JSON.parse(script.innerHTML), script.src || baseUrl, importMap); |
|
926 }) |
|
927 .catch(e => { |
|
928 console.log(e); |
|
929 if (e instanceof SyntaxError) |
|
930 e = new Error(`Unable to parse import map ${e.message} in: ${script.src || script.innerHTML}`); |
|
931 throwError(e); |
|
932 }); |
|
933 if (!shimMode) |
|
934 acceptingImportMaps = false; |
|
935 } |
|
936 } |
|
937 |
|
938 function processScript (script, ready = readyStateCompleteCnt > 0) { |
|
939 if (epCheck(script, ready)) return; |
|
940 // does this load block readystate complete |
|
941 const isBlockingReadyScript = script.getAttribute('async') === null && readyStateCompleteCnt > 0; |
|
942 // does this load block DOMContentLoaded |
|
943 const isDomContentLoadedScript = domContentLoadedCnt > 0; |
|
944 if (isBlockingReadyScript) readyStateCompleteCnt++; |
|
945 if (isDomContentLoadedScript) domContentLoadedCnt++; |
|
946 const loadPromise = topLevelLoad(script.src || baseUrl, getFetchOpts(script), !script.src && script.innerHTML, !shimMode, isBlockingReadyScript && lastStaticLoadPromise) |
|
947 .then(() => { |
|
948 // if the type of the script tag "module-shim", browser does not dispatch a "load" event |
|
949 // see https://github.com/guybedford/es-module-shims/issues/346 |
|
950 if (shimMode) { |
|
951 script.dispatchEvent(new Event('load')); |
|
952 } |
|
953 }) |
|
954 .catch(throwError); |
|
955 if (isBlockingReadyScript) |
|
956 lastStaticLoadPromise = loadPromise.then(readyStateCompleteCheck); |
|
957 if (isDomContentLoadedScript) |
|
958 loadPromise.then(domContentLoadedCheck); |
|
959 } |
|
960 |
|
961 const fetchCache = {}; |
|
962 function processPreload (link) { |
|
963 if (link.ep) return; |
|
964 link.ep = true; |
|
965 if (fetchCache[link.href]) |
|
966 return; |
|
967 fetchCache[link.href] = fetchModule(link.href, getFetchOpts(link)); |
|
968 } |
|
969 |
|
970 })(); |