From 555272fbddb83965db7c6712965087fd75de0c4f Mon Sep 17 00:00:00 2001 From: Akiru Date: Sun, 28 Jan 2024 14:31:23 +0000 Subject: [PATCH 1/2] =?UTF-8?q?ui/es-module-shims.js=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This function is needed for browsers that don't have native support for import maps. --- ui/es-module-shims.js | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 ui/es-module-shims.js diff --git a/ui/es-module-shims.js b/ui/es-module-shims.js new file mode 100644 index 0000000..623611e --- /dev/null +++ b/ui/es-module-shims.js @@ -0,0 +1,4 @@ +// 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 "${e[a]}" does not resolve`)}}let $e=!t&&(0,eval)("u=>import(u)");let Se;const Oe=t&&new Promise((e=>{const t=Object.assign(document.createElement("script"),{src:createBlob("self._d=u=>import(u)"),ep:true});t.setAttribute("nonce",oe);t.addEventListener("load",(()=>{if(!(Se=!!($e=self._d))){let e;window.addEventListener("error",(t=>e=t));$e=(t,r)=>new Promise(((s,n)=>{const a=Object.assign(document.createElement("script"),{type:"module",src:createBlob(`import*as m from'${t}';self._esmsi=m`)});e=void 0;a.ep=true;oe&&a.setAttribute("nonce",oe);a.addEventListener("error",cb);a.addEventListener("load",cb);function cb(i){document.head.removeChild(a);if(self._esmsi){s(self._esmsi,we);self._esmsi=void 0}else{n(!(i instanceof Event)&&i||e&&e.error||new Error(`Error loading ${r&&r.errUrl||t} (${a.src}).`));e=void 0}}document.head.appendChild(a)}))}document.head.removeChild(t);delete self._d;e()}));document.head.appendChild(t)}));let Le=false;let xe=false;const Ae=t&&HTMLScriptElement.supports;let Ce=Ae&&Ae.name==="supports"&&Ae("importmap");let Ue=Se;const Ee="import.meta";const Pe='import"x"assert{type:"css"}';const Ie='import"x"assert{type:"json"}';let Me=Promise.resolve(Oe).then((()=>{if(Se)return t?new Promise((e=>{const t=document.createElement("iframe");t.style.display="none";t.setAttribute("nonce",oe);function cb({data:r}){const s=Array.isArray(r)&&r[0]==="esms";if(s){Ce=r[1];Ue=r[2];xe=r[3];Le=r[4];e();document.head.removeChild(t);window.removeEventListener("message",cb,false)}}window.addEventListener("message",cb,false);const r=` + Eris - + - + \ No newline at end of file -- 2.43.5