forked from pinks/eris
4 lines
36 KiB
JavaScript
4 lines
36 KiB
JavaScript
|
// https://github.com/guybedford/es-module-shims
|
||
|
// This function is needed for browsers that don't have native support for import maps.
|
||
|
(function(){const e=typeof window!=="undefined";const t=typeof document!=="undefined";const noop=()=>{};const r=t?document.querySelector("script[type=esms-options]"):void 0;const s=r?JSON.parse(r.innerHTML):{};Object.assign(s,self.esmsInitOptions||{});let n=!t||!!s.shimMode;const a=globalHook(n&&s.onimport);const i=globalHook(n&&s.resolve);let c=s.fetch?globalHook(s.fetch):fetch;const f=s.meta?globalHook(n&&s.meta):noop;const ne=s.mapOverrides;let oe=s.nonce;if(!oe&&t){const e=document.querySelector("script[nonce]");e&&(oe=e.nonce||e.getAttribute("nonce"))}const ce=globalHook(s.onerror||noop);const le=s.onpolyfill?globalHook(s.onpolyfill):()=>{console.log("%c^^ Module TypeError above is polyfilled and can be ignored ^^","font-weight:900;color:#391")};const{revokeBlobURLs:ue,noLoadEventRetriggers:de,enforceIntegrity:pe}=s;function globalHook(e){return typeof e==="string"?self[e]:e}const he=Array.isArray(s.polyfillEnable)?s.polyfillEnable:[];const me=he.includes("css-modules");const be=he.includes("json-modules");const ke=!navigator.userAgentData&&!!navigator.userAgent.match(/Edge\/\d+\.\d+/);const we=t?document.baseURI:`${location.protocol}//${location.host}${location.pathname.includes("/")?location.pathname.slice(0,location.pathname.lastIndexOf("/")+1):location.pathname}`;const createBlob=(e,t="text/javascript")=>URL.createObjectURL(new Blob([e],{type:t}));let{skip:ge}=s;if(Array.isArray(ge)){const e=ge.map((e=>new URL(e,we).href));ge=t=>e.some((e=>e[e.length-1]==="/"&&t.startsWith(e)||t===e))}else if(typeof ge==="string"){const e=new RegExp(ge);ge=t=>e.test(t)}else ge instanceof RegExp&&(ge=e=>ge.test(e));const eoop=e=>setTimeout((()=>{throw e}));const throwError=t=>{(self.reportError||e&&window.safari&&console.error||eoop)(t),void ce(t)};function fromParent(e){return e?` imported from ${e}`:""}let ve=false;function setImportMapSrcOrLazy(){ve=true}if(!n)if(document.querySelectorAll("script[type=module-shim],script[type=importmap-shim],link[rel=modulepreload-shim]").length)n=true;else{let e=false;for(const t of document.querySelectorAll("script[type=module],script[type=importmap]"))if(e){if(t.type==="importmap"&&e){ve=true;break}}else t.type!=="module"||t.ep||(e=true)}const ye=/\\/g;function asURL(e){try{if(e.indexOf(":")!==-1)return new URL(e).href}catch(e){}}function resolveUrl(e,t){return resolveIfNotPlainOrUrl(e,t)||asURL(e)||resolveIfNotPlainOrUrl("./"+e,t)}function resolveIfNotPlainOrUrl(e,t){const r=t.indexOf("#"),s=t.indexOf("?");r+s>-2&&(t=t.slice(0,r===-1?s:s===-1||s>r?r:s));e.indexOf("\\")!==-1&&(e=e.replace(ye,"/"));if(e[0]==="/"&&e[1]==="/")return t.slice(0,t.indexOf(":")+1)+e;if(e[0]==="."&&(e[1]==="/"||e[1]==="."&&(e[2]==="/"||e.length===2&&(e+="/"))||e.length===1&&(e+="/"))||e[0]==="/"){const r=t.slice(0,t.indexOf(":")+1);if(r==="blob:")throw new TypeError(`Failed to resolve module specifier "${e}". Invalid relative url or base scheme isn't hierarchical.`);let s;if(t[r.length+1]==="/")if(r!=="file:"){s=t.slice(r.length+2);s=s.slice(s.indexOf("/")+1)}else s=t.slice(8);else s=t.slice(r.length+(t[r.length]==="/"));if(e[0]==="/")return t.slice(0,t.length-s.length-1)+e;const n=s.slice(0,s.lastIndexOf("/")+1)+e;const a=[];let i=-1;for(let e=0;e<n.length;e++)if(i===-1){if(n[e]==="."){if(n[e+1]==="."&&(n[e+2]==="/"||e+2===n.length)){a.pop();e+=2;continue}if(n[e+1]==="/"||e+1===n.length){e+=1;continue}}while(n[e]==="/")e++;i=e}else if(n[e]==="/"){a.push(n.slice(i,e+1));i=-1}i!==-1&&a.push(n.slice(i));return t.slice(0,t.length-s.length)+a.join("")}}function resolveAndComposeImportMap(e,t,r){const s={imports:Object.assign({},r.imports),scopes:Object.assign({},r.scopes)};e.imports&&resolveAndComposePackages(e.imports,s.imports,t,r);if(e.scopes)for(let n in e.scopes){const a=resolveUrl(n,t);resolveAndComposePackages(e.scopes[n],s.scopes[a]||(s.scopes[a]={}),t,r)}return s}function getMatch(e,t){if(t[e])return e;let r=e.length;do{const s=e.slice(0,r+1);if(s in t)return s}while((r=e.lastIndexOf("/",r-1))!==-1)}function applyPackages(e,t){const r=getMatch(e,t);if(r){const s=t[r];if(s===null)return;return s+e.slice(r.leng
|
||
|
//# sourceMappingURL=es-module-shims.js.map
|