物管理前端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

890 lines
45 KiB

  1. /* ES Module Shims Wasm 1.5.18 */
  2. (function () {
  3. const hasWindow = typeof window !== 'undefined';
  4. const hasDocument = typeof document !== 'undefined';
  5. const noop = () => {};
  6. const optionsScript = hasDocument ? document.querySelector('script[type=esms-options]') : undefined;
  7. const esmsInitOptions = optionsScript ? JSON.parse(optionsScript.innerHTML) : {};
  8. Object.assign(esmsInitOptions, self.esmsInitOptions || {});
  9. let shimMode = hasDocument ? !!esmsInitOptions.shimMode : true;
  10. const importHook = globalHook(shimMode && esmsInitOptions.onimport);
  11. const resolveHook = globalHook(shimMode && esmsInitOptions.resolve);
  12. let fetchHook = esmsInitOptions.fetch ? globalHook(esmsInitOptions.fetch) : fetch;
  13. const metaHook = esmsInitOptions.meta ? globalHook(shimMode && esmsInitOptions.meta) : noop;
  14. const skip = esmsInitOptions.skip ? new RegExp(esmsInitOptions.skip) : null;
  15. const mapOverrides = esmsInitOptions.mapOverrides;
  16. let nonce = esmsInitOptions.nonce;
  17. if (!nonce && hasDocument) {
  18. const nonceElement = document.querySelector('script[nonce]');
  19. if (nonceElement)
  20. nonce = nonceElement.nonce || nonceElement.getAttribute('nonce');
  21. }
  22. const onerror = globalHook(esmsInitOptions.onerror || noop);
  23. const onpolyfill = esmsInitOptions.onpolyfill ? globalHook(esmsInitOptions.onpolyfill) : () => {
  24. console.log('%c^^ Module TypeError above is polyfilled and can be ignored ^^', 'font-weight:900;color:#391');
  25. };
  26. const { revokeBlobURLs, noLoadEventRetriggers, enforceIntegrity } = esmsInitOptions;
  27. function globalHook (name) {
  28. return typeof name === 'string' ? self[name] : name;
  29. }
  30. const enable = Array.isArray(esmsInitOptions.polyfillEnable) ? esmsInitOptions.polyfillEnable : [];
  31. const cssModulesEnabled = enable.includes('css-modules');
  32. const jsonModulesEnabled = enable.includes('json-modules');
  33. const edge = !navigator.userAgentData && !!navigator.userAgent.match(/Edge\/\d+\.\d+/);
  34. const baseUrl = hasDocument
  35. ? document.baseURI
  36. : `${location.protocol}//${location.host}${location.pathname.includes('/')
  37. ? location.pathname.slice(0, location.pathname.lastIndexOf('/') + 1)
  38. : location.pathname}`;
  39. const createBlob = (source, type = 'text/javascript') => URL.createObjectURL(new Blob([source], { type }));
  40. const eoop = err => setTimeout(() => { throw err });
  41. const throwError = err => { (self.reportError || hasWindow && window.safari && console.error || eoop)(err), void onerror(err); };
  42. function fromParent (parent) {
  43. return parent ? ` imported from ${parent}` : '';
  44. }
  45. let importMapSrcOrLazy = false;
  46. function setImportMapSrcOrLazy () {
  47. importMapSrcOrLazy = true;
  48. }
  49. // shim mode is determined on initialization, no late shim mode
  50. if (!shimMode) {
  51. if (document.querySelectorAll('script[type=module-shim],script[type=importmap-shim],link[rel=modulepreload-shim]').length) {
  52. shimMode = true;
  53. }
  54. else {
  55. let seenScript = false;
  56. for (const script of document.querySelectorAll('script[type=module],script[type=importmap]')) {
  57. if (!seenScript) {
  58. if (script.type === 'module' && !script.ep)
  59. seenScript = true;
  60. }
  61. else if (script.type === 'importmap' && seenScript) {
  62. importMapSrcOrLazy = true;
  63. break;
  64. }
  65. }
  66. }
  67. }
  68. const backslashRegEx = /\\/g;
  69. function isURL (url) {
  70. if (url.indexOf(':') === -1) return false;
  71. try {
  72. new URL(url);
  73. return true;
  74. }
  75. catch (_) {
  76. return false;
  77. }
  78. }
  79. function resolveUrl (relUrl, parentUrl) {
  80. return resolveIfNotPlainOrUrl(relUrl, parentUrl) || (isURL(relUrl) ? relUrl : resolveIfNotPlainOrUrl('./' + relUrl, parentUrl));
  81. }
  82. function resolveIfNotPlainOrUrl (relUrl, parentUrl) {
  83. const hIdx = parentUrl.indexOf('#'), qIdx = parentUrl.indexOf('?');
  84. if (hIdx + qIdx > -2)
  85. parentUrl = parentUrl.slice(0, hIdx === -1 ? qIdx : qIdx === -1 || qIdx > hIdx ? hIdx : qIdx);
  86. if (relUrl.indexOf('\\') !== -1)
  87. relUrl = relUrl.replace(backslashRegEx, '/');
  88. // protocol-relative
  89. if (relUrl[0] === '/' && relUrl[1] === '/') {
  90. return parentUrl.slice(0, parentUrl.indexOf(':') + 1) + relUrl;
  91. }
  92. // relative-url
  93. else if (relUrl[0] === '.' && (relUrl[1] === '/' || relUrl[1] === '.' && (relUrl[2] === '/' || relUrl.length === 2 && (relUrl += '/')) ||
  94. relUrl.length === 1 && (relUrl += '/')) ||
  95. relUrl[0] === '/') {
  96. const parentProtocol = parentUrl.slice(0, parentUrl.indexOf(':') + 1);
  97. // Disabled, but these cases will give inconsistent results for deep backtracking
  98. //if (parentUrl[parentProtocol.length] !== '/')
  99. // throw new Error('Cannot resolve');
  100. // read pathname from parent URL
  101. // pathname taken to be part after leading "/"
  102. let pathname;
  103. if (parentUrl[parentProtocol.length + 1] === '/') {
  104. // resolving to a :// so we need to read out the auth and host
  105. if (parentProtocol !== 'file:') {
  106. pathname = parentUrl.slice(parentProtocol.length + 2);
  107. pathname = pathname.slice(pathname.indexOf('/') + 1);
  108. }
  109. else {
  110. pathname = parentUrl.slice(8);
  111. }
  112. }
  113. else {
  114. // resolving to :/ so pathname is the /... part
  115. pathname = parentUrl.slice(parentProtocol.length + (parentUrl[parentProtocol.length] === '/'));
  116. }
  117. if (relUrl[0] === '/')
  118. return parentUrl.slice(0, parentUrl.length - pathname.length - 1) + relUrl;
  119. // join together and split for removal of .. and . segments
  120. // looping the string instead of anything fancy for perf reasons
  121. // '../../../../../z' resolved to 'x/y' is just 'z'
  122. const segmented = pathname.slice(0, pathname.lastIndexOf('/') + 1) + relUrl;
  123. const output = [];
  124. let segmentIndex = -1;
  125. for (let i = 0; i < segmented.length; i++) {
  126. // busy reading a segment - only terminate on '/'
  127. if (segmentIndex !== -1) {
  128. if (segmented[i] === '/') {
  129. output.push(segmented.slice(segmentIndex, i + 1));
  130. segmentIndex = -1;
  131. }
  132. continue;
  133. }
  134. // new segment - check if it is relative
  135. else if (segmented[i] === '.') {
  136. // ../ segment
  137. if (segmented[i + 1] === '.' && (segmented[i + 2] === '/' || i + 2 === segmented.length)) {
  138. output.pop();
  139. i += 2;
  140. continue;
  141. }
  142. // ./ segment
  143. else if (segmented[i + 1] === '/' || i + 1 === segmented.length) {
  144. i += 1;
  145. continue;
  146. }
  147. }
  148. // it is the start of a new segment
  149. while (segmented[i] === '/') i++;
  150. segmentIndex = i;
  151. }
  152. // finish reading out the last segment
  153. if (segmentIndex !== -1)
  154. output.push(segmented.slice(segmentIndex));
  155. return parentUrl.slice(0, parentUrl.length - pathname.length) + output.join('');
  156. }
  157. }
  158. function resolveAndComposeImportMap (json, baseUrl, parentMap) {
  159. const outMap = { imports: Object.assign({}, parentMap.imports), scopes: Object.assign({}, parentMap.scopes) };
  160. if (json.imports)
  161. resolveAndComposePackages(json.imports, outMap.imports, baseUrl, parentMap);
  162. if (json.scopes)
  163. for (let s in json.scopes) {
  164. const resolvedScope = resolveUrl(s, baseUrl);
  165. resolveAndComposePackages(json.scopes[s], outMap.scopes[resolvedScope] || (outMap.scopes[resolvedScope] = {}), baseUrl, parentMap);
  166. }
  167. return outMap;
  168. }
  169. function getMatch (path, matchObj) {
  170. if (matchObj[path])
  171. return path;
  172. let sepIndex = path.length;
  173. do {
  174. const segment = path.slice(0, sepIndex + 1);
  175. if (segment in matchObj)
  176. return segment;
  177. } while ((sepIndex = path.lastIndexOf('/', sepIndex - 1)) !== -1)
  178. }
  179. function applyPackages (id, packages) {
  180. const pkgName = getMatch(id, packages);
  181. if (pkgName) {
  182. const pkg = packages[pkgName];
  183. if (pkg === null) return;
  184. return pkg + id.slice(pkgName.length);
  185. }
  186. }
  187. function resolveImportMap (importMap, resolvedOrPlain, parentUrl) {
  188. let scopeUrl = parentUrl && getMatch(parentUrl, importMap.scopes);
  189. while (scopeUrl) {
  190. const packageResolution = applyPackages(resolvedOrPlain, importMap.scopes[scopeUrl]);
  191. if (packageResolution)
  192. return packageResolution;
  193. scopeUrl = getMatch(scopeUrl.slice(0, scopeUrl.lastIndexOf('/')), importMap.scopes);
  194. }
  195. return applyPackages(resolvedOrPlain, importMap.imports) || resolvedOrPlain.indexOf(':') !== -1 && resolvedOrPlain;
  196. }
  197. function resolveAndComposePackages (packages, outPackages, baseUrl, parentMap) {
  198. for (let p in packages) {
  199. const resolvedLhs = resolveIfNotPlainOrUrl(p, baseUrl) || p;
  200. if ((!shimMode || !mapOverrides) && outPackages[resolvedLhs] && (outPackages[resolvedLhs] !== packages[resolvedLhs])) {
  201. throw Error(`Rejected map override "${resolvedLhs}" from ${outPackages[resolvedLhs]} to ${packages[resolvedLhs]}.`);
  202. }
  203. let target = packages[p];
  204. if (typeof target !== 'string')
  205. continue;
  206. const mapped = resolveImportMap(parentMap, resolveIfNotPlainOrUrl(target, baseUrl) || target, baseUrl);
  207. if (mapped) {
  208. outPackages[resolvedLhs] = mapped;
  209. continue;
  210. }
  211. console.warn(`Mapping "${p}" -> "${packages[p]}" does not resolve`);
  212. }
  213. }
  214. let dynamicImport = !hasDocument && (0, eval)('u=>import(u)');
  215. let supportsDynamicImport;
  216. const dynamicImportCheck = hasDocument && new Promise(resolve => {
  217. const s = Object.assign(document.createElement('script'), {
  218. src: createBlob('self._d=u=>import(u)'),
  219. ep: true
  220. });
  221. s.setAttribute('nonce', nonce);
  222. s.addEventListener('load', () => {
  223. if (!(supportsDynamicImport = !!(dynamicImport = self._d))) {
  224. let err;
  225. window.addEventListener('error', _err => err = _err);
  226. dynamicImport = (url, opts) => new Promise((resolve, reject) => {
  227. const s = Object.assign(document.createElement('script'), {
  228. type: 'module',
  229. src: createBlob(`import*as m from'${url}';self._esmsi=m`)
  230. });
  231. err = undefined;
  232. s.ep = true;
  233. if (nonce)
  234. s.setAttribute('nonce', nonce);
  235. // Safari is unique in supporting module script error events
  236. s.addEventListener('error', cb);
  237. s.addEventListener('load', cb);
  238. function cb (_err) {
  239. document.head.removeChild(s);
  240. if (self._esmsi) {
  241. resolve(self._esmsi, baseUrl);
  242. self._esmsi = undefined;
  243. }
  244. else {
  245. reject(!(_err instanceof Event) && _err || err && err.error || new Error(`Error loading ${opts && opts.errUrl || url} (${s.src}).`));
  246. err = undefined;
  247. }
  248. }
  249. document.head.appendChild(s);
  250. });
  251. }
  252. document.head.removeChild(s);
  253. delete self._d;
  254. resolve();
  255. });
  256. document.head.appendChild(s);
  257. });
  258. // support browsers without dynamic import support (eg Firefox 6x)
  259. let supportsJsonAssertions = false;
  260. let supportsCssAssertions = false;
  261. let supportsImportMaps = hasDocument && HTMLScriptElement.supports ? HTMLScriptElement.supports('importmap') : false;
  262. let supportsImportMeta = supportsImportMaps;
  263. const importMetaCheck = 'import.meta';
  264. const cssModulesCheck = `import"x"assert{type:"css"}`;
  265. const jsonModulesCheck = `import"x"assert{type:"json"}`;
  266. const featureDetectionPromise = Promise.resolve(dynamicImportCheck).then(() => {
  267. if (!supportsDynamicImport || supportsImportMaps && !cssModulesEnabled && !jsonModulesEnabled)
  268. return;
  269. if (!hasDocument)
  270. return Promise.all([
  271. supportsImportMaps || dynamicImport(createBlob(importMetaCheck)).then(() => supportsImportMeta = true, noop),
  272. cssModulesEnabled && dynamicImport(createBlob(cssModulesCheck.replace('x', createBlob('', 'text/css')))).then(() => supportsCssAssertions = true, noop),
  273. jsonModulesEnabled && dynamicImport(createBlob(jsonModulescheck.replace('x', createBlob('{}', 'text/json')))).then(() => supportsJsonAssertions = true, noop),
  274. ]);
  275. return new Promise(resolve => {
  276. const iframe = document.createElement('iframe');
  277. iframe.style.display = 'none';
  278. iframe.setAttribute('nonce', nonce);
  279. function cb ({ data: [a, b, c, d] }) {
  280. supportsImportMaps = a;
  281. supportsImportMeta = b;
  282. supportsCssAssertions = c;
  283. supportsJsonAssertions = d;
  284. resolve();
  285. document.head.removeChild(iframe);
  286. window.removeEventListener('message', cb, false);
  287. }
  288. window.addEventListener('message', cb, false);
  289. 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([${
  290. supportsImportMaps ? 'true,true' : `'x',b('${importMetaCheck}')`}, ${cssModulesEnabled ? `b('${cssModulesCheck}'.replace('x',b('','text/css')))` : 'false'}, ${
  291. 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(a,'*'))<${''}/script>`;
  292. iframe.onload = () => {
  293. // WeChat browser doesn't support setting srcdoc scripts
  294. // But iframe sandboxes don't support contentDocument so we do this as a fallback
  295. const doc = iframe.contentDocument;
  296. if (doc && doc.head.childNodes.length === 0) {
  297. const s = doc.createElement('script');
  298. if (nonce)
  299. s.setAttribute('nonce', nonce);
  300. s.innerHTML = importMapTest.slice(15 + (nonce ? nonce.length : 0), -9);
  301. doc.head.appendChild(s);
  302. }
  303. };
  304. // WeChat browser requires append before setting srcdoc
  305. document.head.appendChild(iframe);
  306. // setting srcdoc is not supported in React native webviews on iOS
  307. // setting src to a blob URL results in a navigation event in webviews
  308. // document.write gives usability warnings
  309. if ('srcdoc' in iframe)
  310. iframe.srcdoc = importMapTest;
  311. else
  312. iframe.contentDocument.write(importMapTest);
  313. });
  314. });
  315. /* es-module-lexer 1.0.3 */
  316. 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,o=(C.__heap_base.value||C.__heap_base)+4*I-C.memory.buffer.byteLength;o>0&&C.memory.grow(Math.ceil(o/65536));const D=C.sa(I-1);if((A?B:Q)(E,new Uint16Array(C.memory.buffer,D,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 J=[],K=[];for(;C.ri();){const A=C.is(),Q=C.ie(),B=C.ai(),g=C.id(),I=C.ss(),o=C.se();let D;C.ip()&&(D=w(E.slice(-1===g?A-1:A,-1===g?Q+1:Q))),J.push({n:D,s:A,e:Q,ss:I,se:o,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),o=I[0],D=B<0?void 0:E.slice(B,g),J=D?D[0]:"";K.push({s:A,e:Q,ls:B,le:g,n:'"'===o||"'"===o?w(I):I,ln:'"'===J||"'"===J?w(D):D});}function w(A){try{return (0,eval)(A)}catch(A){}}return [J,K,!!C.f()]}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/AAMtLAABAQICAgICAgICAgICAgICAgAAAwMDBAQAAAADAAAAAAMDBQYAAAcABgIFBAUBcAEBAQUDAQABBg8CfwFBoPIAC38AQaDyAAsHcBMGbWVtb3J5AgACc2EAAAFlAAMCaXMABAJpZQAFAnNzAAYCc2UABwJhaQAIAmlkAAkCaXAACgJlcwALAmVlAAwDZWxzAA0DZWxlAA4CcmkADwJyZQAQAWYAEQVwYXJzZQASC19faGVhcF9iYXNlAwEKsTcsaAEBf0EAIAA2AugJQQAoAsQJIgEgAEEBdGoiAEEAOwEAQQAgAEECaiIANgLsCUEAIAA2AvAJQQBBADYCyAlBAEEANgLYCUEAQQA2AtAJQQBBADYCzAlBAEEANgLgCUEAQQA2AtQJIAELnwEBA39BACgC2AkhBEEAQQAoAvAJIgU2AtgJQQAgBDYC3AlBACAFQSBqNgLwCSAEQRxqQcgJIAQbIAU2AgBBACgCvAkhBEEAKAK4CSEGIAUgATYCACAFIAA2AgggBSACIAJBAmpBACAGIANGGyAEIANGGzYCDCAFIAM2AhQgBUEANgIQIAUgAjYCBCAFQQA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LIAJBfmovAQBBK0YNBgwHCyACQX5qLwEAQS1GDQUMBgsCQCAEQf0ARg0AIARBKUcNBUEAKAKICkEALwH8CUEDdGooAg
  317. async function _resolve (id, parentUrl) {
  318. const urlResolved = resolveIfNotPlainOrUrl(id, parentUrl);
  319. return {
  320. r: resolveImportMap(importMap, urlResolved || id, parentUrl) || throwUnresolved(id, parentUrl),
  321. // b = bare specifier
  322. b: !urlResolved && !isURL(id)
  323. };
  324. }
  325. const resolve = resolveHook ? async (id, parentUrl) => {
  326. let result = resolveHook(id, parentUrl, defaultResolve);
  327. // will be deprecated in next major
  328. if (result && result.then)
  329. result = await result;
  330. return result ? { r: result, b: !resolveIfNotPlainOrUrl(id, parentUrl) && !isURL(id) } : _resolve(id, parentUrl);
  331. } : _resolve;
  332. // importShim('mod');
  333. // importShim('mod', { opts });
  334. // importShim('mod', { opts }, parentUrl);
  335. // importShim('mod', parentUrl);
  336. async function importShim (id, ...args) {
  337. // parentUrl if present will be the last argument
  338. let parentUrl = args[args.length - 1];
  339. if (typeof parentUrl !== 'string')
  340. parentUrl = baseUrl;
  341. // needed for shim check
  342. await initPromise;
  343. if (importHook) await importHook(id, typeof args[1] !== 'string' ? args[1] : {}, parentUrl);
  344. if (acceptingImportMaps || shimMode || !baselinePassthrough) {
  345. if (hasDocument)
  346. processScriptsAndPreloads(true);
  347. if (!shimMode)
  348. acceptingImportMaps = false;
  349. }
  350. await importMapPromise;
  351. return topLevelLoad((await resolve(id, parentUrl)).r, { credentials: 'same-origin' });
  352. }
  353. self.importShim = importShim;
  354. function defaultResolve (id, parentUrl) {
  355. return resolveImportMap(importMap, resolveIfNotPlainOrUrl(id, parentUrl) || id, parentUrl) || throwUnresolved(id, parentUrl);
  356. }
  357. function throwUnresolved (id, parentUrl) {
  358. throw Error(`Unable to resolve specifier '${id}'${fromParent(parentUrl)}`);
  359. }
  360. const resolveSync = (id, parentUrl = baseUrl) => {
  361. parentUrl = `${parentUrl}`;
  362. const result = resolveHook && resolveHook(id, parentUrl, defaultResolve);
  363. return result && !result.then ? result : defaultResolve(id, parentUrl);
  364. };
  365. function metaResolve (id, parentUrl = this.url) {
  366. return resolveSync(id, parentUrl);
  367. }
  368. importShim.resolve = resolveSync;
  369. importShim.getImportMap = () => JSON.parse(JSON.stringify(importMap));
  370. importShim.addImportMap = importMapIn => {
  371. if (!shimMode) throw new Error('Unsupported in polyfill mode.');
  372. importMap = resolveAndComposeImportMap(importMapIn, baseUrl, importMap);
  373. };
  374. const registry = importShim._r = {};
  375. async function loadAll (load, seen) {
  376. if (load.b || seen[load.u])
  377. return;
  378. seen[load.u] = 1;
  379. await load.L;
  380. await Promise.all(load.d.map(dep => loadAll(dep, seen)));
  381. if (!load.n)
  382. load.n = load.d.some(dep => dep.n);
  383. }
  384. let importMap = { imports: {}, scopes: {} };
  385. let baselinePassthrough;
  386. const initPromise = featureDetectionPromise.then(() => {
  387. baselinePassthrough = esmsInitOptions.polyfillEnable !== true && supportsDynamicImport && supportsImportMeta && supportsImportMaps && (!jsonModulesEnabled || supportsJsonAssertions) && (!cssModulesEnabled || supportsCssAssertions) && !importMapSrcOrLazy && !false;
  388. if (hasDocument) {
  389. if (!supportsImportMaps) {
  390. const supports = HTMLScriptElement.supports || (type => type === 'classic' || type === 'module');
  391. HTMLScriptElement.supports = type => type === 'importmap' || supports(type);
  392. }
  393. if (shimMode || !baselinePassthrough) {
  394. new MutationObserver(mutations => {
  395. for (const mutation of mutations) {
  396. if (mutation.type !== 'childList') continue;
  397. for (const node of mutation.addedNodes) {
  398. if (node.tagName === 'SCRIPT') {
  399. if (node.type === (shimMode ? 'module-shim' : 'module'))
  400. processScript(node, true);
  401. if (node.type === (shimMode ? 'importmap-shim' : 'importmap'))
  402. processImportMap(node, true);
  403. }
  404. else if (node.tagName === 'LINK' && node.rel === (shimMode ? 'modulepreload-shim' : 'modulepreload')) {
  405. processPreload(node);
  406. }
  407. }
  408. }
  409. }).observe(document, {childList: true, subtree: true});
  410. processScriptsAndPreloads();
  411. if (document.readyState === 'complete') {
  412. readyStateCompleteCheck();
  413. }
  414. else {
  415. async function readyListener() {
  416. await initPromise;
  417. processScriptsAndPreloads();
  418. if (document.readyState === 'complete') {
  419. readyStateCompleteCheck();
  420. document.removeEventListener('readystatechange', readyListener);
  421. }
  422. }
  423. document.addEventListener('readystatechange', readyListener);
  424. }
  425. }
  426. }
  427. return init;
  428. });
  429. let importMapPromise = initPromise;
  430. let firstPolyfillLoad = true;
  431. let acceptingImportMaps = true;
  432. async function topLevelLoad (url, fetchOpts, source, nativelyLoaded, lastStaticLoadPromise) {
  433. if (!shimMode)
  434. acceptingImportMaps = false;
  435. await initPromise;
  436. await importMapPromise;
  437. if (importHook) await importHook(url, typeof fetchOpts !== 'string' ? fetchOpts : {}, '');
  438. // early analysis opt-out - no need to even fetch if we have feature support
  439. if (!shimMode && baselinePassthrough) {
  440. // for polyfill case, only dynamic import needs a return value here, and dynamic import will never pass nativelyLoaded
  441. if (nativelyLoaded)
  442. return null;
  443. await lastStaticLoadPromise;
  444. return dynamicImport(source ? createBlob(source) : url, { errUrl: url || source });
  445. }
  446. const load = getOrCreateLoad(url, fetchOpts, null, source);
  447. const seen = {};
  448. await loadAll(load, seen);
  449. lastLoad = undefined;
  450. resolveDeps(load, seen);
  451. await lastStaticLoadPromise;
  452. if (source && !shimMode && !load.n && !false) {
  453. const module = await dynamicImport(createBlob(source), { errUrl: source });
  454. if (revokeBlobURLs) revokeObjectURLs(Object.keys(seen));
  455. return module;
  456. }
  457. if (firstPolyfillLoad && !shimMode && load.n && nativelyLoaded) {
  458. onpolyfill();
  459. firstPolyfillLoad = false;
  460. }
  461. const module = await dynamicImport(!shimMode && !load.n && nativelyLoaded ? load.u : load.b, { errUrl: load.u });
  462. // if the top-level load is a shell, run its update function
  463. if (load.s)
  464. (await dynamicImport(load.s)).u$_(module);
  465. if (revokeBlobURLs) revokeObjectURLs(Object.keys(seen));
  466. // when tla is supported, this should return the tla promise as an actual handle
  467. // so readystate can still correspond to the sync subgraph exec completions
  468. return module;
  469. }
  470. function revokeObjectURLs(registryKeys) {
  471. let batch = 0;
  472. const keysLength = registryKeys.length;
  473. const schedule = self.requestIdleCallback ? self.requestIdleCallback : self.requestAnimationFrame;
  474. schedule(cleanup);
  475. function cleanup() {
  476. const batchStartIndex = batch * 100;
  477. if (batchStartIndex > keysLength) return
  478. for (const key of registryKeys.slice(batchStartIndex, batchStartIndex + 100)) {
  479. const load = registry[key];
  480. if (load) URL.revokeObjectURL(load.b);
  481. }
  482. batch++;
  483. schedule(cleanup);
  484. }
  485. }
  486. function urlJsString (url) {
  487. return `'${url.replace(/'/g, "\\'")}'`;
  488. }
  489. let lastLoad;
  490. function resolveDeps (load, seen) {
  491. if (load.b || !seen[load.u])
  492. return;
  493. seen[load.u] = 0;
  494. for (const dep of load.d)
  495. resolveDeps(dep, seen);
  496. const [imports, exports] = load.a;
  497. // "execution"
  498. const source = load.S;
  499. // edge doesnt execute sibling in order, so we fix this up by ensuring all previous executions are explicit dependencies
  500. let resolvedSource = edge && lastLoad ? `import '${lastLoad}';` : '';
  501. if (!imports.length) {
  502. resolvedSource += source;
  503. }
  504. else {
  505. // once all deps have loaded we can inline the dependency resolution blobs
  506. // and define this blob
  507. let lastIndex = 0, depIndex = 0, dynamicImportEndStack = [];
  508. function pushStringTo (originalIndex) {
  509. while (dynamicImportEndStack[dynamicImportEndStack.length - 1] < originalIndex) {
  510. const dynamicImportEnd = dynamicImportEndStack.pop();
  511. resolvedSource += `${source.slice(lastIndex, dynamicImportEnd)}, ${urlJsString(load.r)}`;
  512. lastIndex = dynamicImportEnd;
  513. }
  514. resolvedSource += source.slice(lastIndex, originalIndex);
  515. lastIndex = originalIndex;
  516. }
  517. for (const { s: start, ss: statementStart, se: statementEnd, d: dynamicImportIndex } of imports) {
  518. // dependency source replacements
  519. if (dynamicImportIndex === -1) {
  520. let depLoad = load.d[depIndex++], blobUrl = depLoad.b, cycleShell = !blobUrl;
  521. if (cycleShell) {
  522. // circular shell creation
  523. if (!(blobUrl = depLoad.s)) {
  524. blobUrl = depLoad.s = createBlob(`export function u$_(m){${
  525. depLoad.a[1].map(({ s, e }, i) => {
  526. const q = depLoad.S[s] === '"' || depLoad.S[s] === "'";
  527. return `e$_${i}=m${q ? `[` : '.'}${depLoad.S.slice(s, e)}${q ? `]` : ''}`;
  528. }).join(',')
  529. }}${
  530. depLoad.a[1].length ? `let ${depLoad.a[1].map((_, i) => `e$_${i}`).join(',')};` : ''
  531. }export {${
  532. depLoad.a[1].map(({ s, e }, i) => `e$_${i} as ${depLoad.S.slice(s, e)}`).join(',')
  533. }}\n//# sourceURL=${depLoad.r}?cycle`);
  534. }
  535. }
  536. pushStringTo(start - 1);
  537. resolvedSource += `/*${source.slice(start - 1, statementEnd)}*/${urlJsString(blobUrl)}`;
  538. // circular shell execution
  539. if (!cycleShell && depLoad.s) {
  540. resolvedSource += `;import*as m$_${depIndex} from'${depLoad.b}';import{u$_ as u$_${depIndex}}from'${depLoad.s}';u$_${depIndex}(m$_${depIndex})`;
  541. depLoad.s = undefined;
  542. }
  543. lastIndex = statementEnd;
  544. }
  545. // import.meta
  546. else if (dynamicImportIndex === -2) {
  547. load.m = { url: load.r, resolve: metaResolve };
  548. metaHook(load.m, load.u);
  549. pushStringTo(start);
  550. resolvedSource += `importShim._r[${urlJsString(load.u)}].m`;
  551. lastIndex = statementEnd;
  552. }
  553. // dynamic import
  554. else {
  555. pushStringTo(statementStart + 6);
  556. resolvedSource += `Shim(`;
  557. dynamicImportEndStack.push(statementEnd - 1);
  558. lastIndex = start;
  559. }
  560. }
  561. // support progressive cycle binding updates (try statement avoids tdz errors)
  562. if (load.s)
  563. 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`;
  564. pushStringTo(source.length);
  565. }
  566. let hasSourceURL = false;
  567. resolvedSource = resolvedSource.replace(sourceMapURLRegEx, (match, isMapping, url) => (hasSourceURL = !isMapping, match.replace(url, () => new URL(url, load.r))));
  568. if (!hasSourceURL)
  569. resolvedSource += '\n//# sourceURL=' + load.r;
  570. load.b = lastLoad = createBlob(resolvedSource);
  571. load.S = undefined;
  572. }
  573. // ; and // trailer support added for Ruby on Rails 7 source maps compatibility
  574. // https://github.com/guybedford/es-module-shims/issues/228
  575. const sourceMapURLRegEx = /\n\/\/# source(Mapping)?URL=([^\n]+)\s*((;|\/\/[^#][^\n]*)\s*)*$/;
  576. const jsContentType = /^(text|application)\/(x-)?javascript(;|$)/;
  577. const jsonContentType = /^(text|application)\/json(;|$)/;
  578. const cssContentType = /^(text|application)\/css(;|$)/;
  579. const cssUrlRegEx = /url\(\s*(?:(["'])((?:\\.|[^\n\\"'])+)\1|((?:\\.|[^\s,"'()\\])+))\s*\)/g;
  580. // restrict in-flight fetches to a pool of 100
  581. let p = [];
  582. let c = 0;
  583. function pushFetchPool () {
  584. if (++c > 100)
  585. return new Promise(r => p.push(r));
  586. }
  587. function popFetchPool () {
  588. c--;
  589. if (p.length)
  590. p.shift()();
  591. }
  592. async function doFetch (url, fetchOpts, parent) {
  593. if (enforceIntegrity && !fetchOpts.integrity)
  594. throw Error(`No integrity for ${url}${fromParent(parent)}.`);
  595. const poolQueue = pushFetchPool();
  596. if (poolQueue) await poolQueue;
  597. try {
  598. var res = await fetchHook(url, fetchOpts);
  599. }
  600. catch (e) {
  601. e.message = `Unable to fetch ${url}${fromParent(parent)} - see network log for details.\n` + e.message;
  602. throw e;
  603. }
  604. finally {
  605. popFetchPool();
  606. }
  607. if (!res.ok)
  608. throw Error(`${res.status} ${res.statusText} ${res.url}${fromParent(parent)}`);
  609. return res;
  610. }
  611. async function fetchModule (url, fetchOpts, parent) {
  612. const res = await doFetch(url, fetchOpts, parent);
  613. const contentType = res.headers.get('content-type');
  614. if (jsContentType.test(contentType))
  615. return { r: res.url, s: await res.text(), t: 'js' };
  616. else if (jsonContentType.test(contentType))
  617. return { r: res.url, s: `export default ${await res.text()}`, t: 'json' };
  618. else if (cssContentType.test(contentType)) {
  619. return { r: res.url, s: `var s=new CSSStyleSheet();s.replaceSync(${
  620. JSON.stringify((await res.text()).replace(cssUrlRegEx, (_match, quotes = '', relUrl1, relUrl2) => `url(${quotes}${resolveUrl(relUrl1 || relUrl2, url)}${quotes})`))
  621. });export default s;`, t: 'css' };
  622. }
  623. else
  624. throw Error(`Unsupported Content-Type "${contentType}" loading ${url}${fromParent(parent)}. Modules must be served with a valid MIME type like application/javascript.`);
  625. }
  626. function getOrCreateLoad (url, fetchOpts, parent, source) {
  627. let load = registry[url];
  628. if (load && !source)
  629. return load;
  630. load = {
  631. // url
  632. u: url,
  633. // response url
  634. r: source ? url : undefined,
  635. // fetchPromise
  636. f: undefined,
  637. // source
  638. S: undefined,
  639. // linkPromise
  640. L: undefined,
  641. // analysis
  642. a: undefined,
  643. // deps
  644. d: undefined,
  645. // blobUrl
  646. b: undefined,
  647. // shellUrl
  648. s: undefined,
  649. // needsShim
  650. n: false,
  651. // type
  652. t: null,
  653. // meta
  654. m: null
  655. };
  656. if (registry[url]) {
  657. let i = 0;
  658. while (registry[load.u + ++i]);
  659. load.u += i;
  660. }
  661. registry[load.u] = load;
  662. load.f = (async () => {
  663. if (!source) {
  664. // preload fetch options override fetch options (race)
  665. let t;
  666. ({ r: load.r, s: source, t } = await (fetchCache[url] || fetchModule(url, fetchOpts, parent)));
  667. if (t && !shimMode) {
  668. if (t === 'css' && !cssModulesEnabled || t === 'json' && !jsonModulesEnabled)
  669. throw Error(`${t}-modules require <script type="esms-options">{ "polyfillEnable": ["${t}-modules"] }<${''}/script>`);
  670. if (t === 'css' && !supportsCssAssertions || t === 'json' && !supportsJsonAssertions)
  671. load.n = true;
  672. }
  673. }
  674. try {
  675. load.a = parse(source, load.u);
  676. }
  677. catch (e) {
  678. throwError(e);
  679. load.a = [[], [], false];
  680. }
  681. load.S = source;
  682. return load;
  683. })();
  684. load.L = load.f.then(async () => {
  685. let childFetchOpts = fetchOpts;
  686. load.d = (await Promise.all(load.a[0].map(async ({ n, d }) => {
  687. if (d >= 0 && !supportsDynamicImport || d === -2 && !supportsImportMeta)
  688. load.n = true;
  689. if (d !== -1 || !n) return;
  690. const { r, b } = await resolve(n, load.r || load.u);
  691. if (b && (!supportsImportMaps || importMapSrcOrLazy))
  692. load.n = true;
  693. if (skip && skip.test(r)) return { b: r };
  694. if (childFetchOpts.integrity)
  695. childFetchOpts = Object.assign({}, childFetchOpts, { integrity: undefined });
  696. return getOrCreateLoad(r, childFetchOpts, load.r).f;
  697. }))).filter(l => l);
  698. });
  699. return load;
  700. }
  701. function processScriptsAndPreloads (mapsOnly = false) {
  702. if (!mapsOnly)
  703. for (const link of document.querySelectorAll(shimMode ? 'link[rel=modulepreload-shim]' : 'link[rel=modulepreload]'))
  704. processPreload(link);
  705. for (const script of document.querySelectorAll(shimMode ? 'script[type=importmap-shim]' : 'script[type=importmap]'))
  706. processImportMap(script);
  707. if (!mapsOnly)
  708. for (const script of document.querySelectorAll(shimMode ? 'script[type=module-shim]' : 'script[type=module]'))
  709. processScript(script);
  710. }
  711. function getFetchOpts (script) {
  712. const fetchOpts = {};
  713. if (script.integrity)
  714. fetchOpts.integrity = script.integrity;
  715. if (script.referrerpolicy)
  716. fetchOpts.referrerPolicy = script.referrerpolicy;
  717. if (script.crossorigin === 'use-credentials')
  718. fetchOpts.credentials = 'include';
  719. else if (script.crossorigin === 'anonymous')
  720. fetchOpts.credentials = 'omit';
  721. else
  722. fetchOpts.credentials = 'same-origin';
  723. return fetchOpts;
  724. }
  725. let lastStaticLoadPromise = Promise.resolve();
  726. let domContentLoadedCnt = 1;
  727. function domContentLoadedCheck () {
  728. if (--domContentLoadedCnt === 0 && !noLoadEventRetriggers)
  729. document.dispatchEvent(new Event('DOMContentLoaded'));
  730. }
  731. // this should always trigger because we assume es-module-shims is itself a domcontentloaded requirement
  732. if (hasDocument) {
  733. document.addEventListener('DOMContentLoaded', async () => {
  734. await initPromise;
  735. if (shimMode || !baselinePassthrough)
  736. domContentLoadedCheck();
  737. });
  738. }
  739. let readyStateCompleteCnt = 1;
  740. function readyStateCompleteCheck () {
  741. if (--readyStateCompleteCnt === 0 && !noLoadEventRetriggers)
  742. document.dispatchEvent(new Event('readystatechange'));
  743. }
  744. const hasNext = script => script.nextSibling || script.parentNode && hasNext(script.parentNode);
  745. const epCheck = (script, ready) => script.ep || !ready && (!script.src && !script.innerHTML || !hasNext(script)) || script.getAttribute('noshim') !== null || !(script.ep = true);
  746. function processImportMap (script, ready = readyStateCompleteCnt > 0) {
  747. if (epCheck(script, ready)) return;
  748. // we dont currently support multiple, external or dynamic imports maps in polyfill mode to match native
  749. if (script.src) {
  750. if (!shimMode)
  751. return;
  752. setImportMapSrcOrLazy();
  753. }
  754. if (acceptingImportMaps) {
  755. importMapPromise = importMapPromise
  756. .then(async () => {
  757. importMap = resolveAndComposeImportMap(script.src ? await (await doFetch(script.src, getFetchOpts(script))).json() : JSON.parse(script.innerHTML), script.src || baseUrl, importMap);
  758. })
  759. .catch(e => {
  760. console.log(e);
  761. if (e instanceof SyntaxError)
  762. e = new Error(`Unable to parse import map ${e.message} in: ${script.src || script.innerHTML}`);
  763. throwError(e);
  764. });
  765. if (!shimMode)
  766. acceptingImportMaps = false;
  767. }
  768. }
  769. function processScript (script, ready = readyStateCompleteCnt > 0) {
  770. if (epCheck(script, ready)) return;
  771. // does this load block readystate complete
  772. const isBlockingReadyScript = script.getAttribute('async') === null && readyStateCompleteCnt > 0;
  773. // does this load block DOMContentLoaded
  774. const isDomContentLoadedScript = domContentLoadedCnt > 0;
  775. if (isBlockingReadyScript) readyStateCompleteCnt++;
  776. if (isDomContentLoadedScript) domContentLoadedCnt++;
  777. const loadPromise = topLevelLoad(script.src || baseUrl, getFetchOpts(script), !script.src && script.innerHTML, !shimMode, isBlockingReadyScript && lastStaticLoadPromise).catch(throwError);
  778. if (isBlockingReadyScript)
  779. lastStaticLoadPromise = loadPromise.then(readyStateCompleteCheck);
  780. if (isDomContentLoadedScript)
  781. loadPromise.then(domContentLoadedCheck);
  782. }
  783. const fetchCache = {};
  784. function processPreload (link) {
  785. if (link.ep) return;
  786. link.ep = true;
  787. if (fetchCache[link.href])
  788. return;
  789. fetchCache[link.href] = fetchModule(link.href, getFetchOpts(link));
  790. }
  791. })();