-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Standardize error reporting code (#53)
Co-authored-by: huang yao <[email protected]>
- Loading branch information
Showing
9 changed files
with
20 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
//! drill.js - v5.3.5 https://github.com/kirakiray/drill.js (c) 2018-2024 YAO | ||
class t{constructor(){this._middlewares=new Map}use(t){const e=Math.random().toString(32).slice(2);return this._middlewares.set(e,t),e}unuse(t){return this._middlewares.delete(t)}async run(t){let e=-1;const s=Array.from(this._middlewares.values()),n=async()=>{e++,e<s.length&&await s[e](t,n)};await n()}}const e=new Map,s=async(t,s)=>{const n=new URL(t),a=s.includes("-direct")?t:`${n.origin}${n.pathname}`;let r=e.get(a);r||(r=fetch(a),e.set(a,r));return(await r).clone()},n={},a=(e,s)=>{(n[e]||(n[e]=new t)).use(s)},r=(t,e)=>{t instanceof Function&&(e=t,t=["js","mjs"]),t instanceof Array?t.forEach((t=>{a(t,e)})):a(t,e)};r(["mjs","js"],(async(t,e)=>{if(!t.result){const{url:e,params:s}=t,n=new URL(e),a=/^blob:/.test(e)||/^data:/.test(e);try{a||s.includes("-direct")?t.result=await import(e):t.result=await import(`${n.origin}${n.pathname}`)}catch(s){const n=i(`Failed to load module ${t.realUrl||e}`,s);throw a&&console.log("Failed to load module:",t),n}}await e()})),r(["txt","html","htm"],(async(t,e)=>{if(!t.result){const{url:e,params:n}=t;let a;try{a=await s(e,n)}catch(t){throw i(`Load ${e} failed`,t)}if(!/^2.{2}$/.test(a.status))throw new Error(`Load ${e} failed: status code ${a.status}`);t.result=await a.text()}await e()})),r("json",(async(t,e)=>{if(!t.result){const{url:e,params:n}=t;t.result=await s(e,n).then((t=>t.json()))}await e()})),r("wasm",(async(t,e)=>{if(!t.result){const{url:e,params:n}=t,a=await s(e,n).then((t=>t.arrayBuffer())),r=await WebAssembly.compile(a),i=new WebAssembly.Instance(r);t.result=i.exports}await e()})),r("css",(async(t,e)=>{if(!t.result){const{url:e,element:n,params:a}=t;if(n){const t=document.createElement("link");t.rel="stylesheet",t.href=e;const s=n.getRootNode();let a;s===document?s.head.append(t):s.appendChild(t),n.addEventListener("disconnected",a=e=>{t.remove(),n.removeEventListener("disconnected",a)})}else t.result=await s(e,a).then((t=>t.text()))}await e()}));const i=(t,e)=>{const s=new Error(`${t} \n ${e.toString()}`);return s.error=e,s},o={};const l=(t,e)=>{if(t.startsWith("http://")||t.startsWith("https://"))return t;const[s,...n]=t.split(" ");let a=s;if(/^@/.test(s)){const[t,...e]=s.split("/");if(!o[t])throw`No alias defined ${t}`;a=[o[t].replace(/\/$/,""),...e].join("/")}if("undefined"!=typeof location){const t=e?new URL(e,location.href):location.href;a=new URL(a,t).href}return n.length?`${a} ${n.join(" ")}`:a},c=Symbol("loaded"),d=async(t,e)=>{const s=new URL(t),{pathname:a}=s;let r,i=null;e.params&&e.params.forEach((t=>{/^\..+/.test(t)?r=t.replace(/^\.(.+)/,"$1"):/^\-\-real/.test(t)&&(i=t.replace(/^\-\-real\:/,""))})),r||(r=a.slice(2+(a.lastIndexOf(".")-1>>>0)));const o={url:t,result:null,realUrl:i,...e},l=n[r];if(l?await l.run(o):o.result=fetch(t),e&&e.element){const{element:t}=e;t[c]=!0;const s=new Event("load");t.dispatchEvent(s)}return e.params&&e.params.includes("-ctx")?o:o.result};function u(t,e){return((t,e)=>(t||(t={url:document.location.href}),s=>{let[n,...a]=s.split(" ");const r=l(n,t.url);return d(r,{params:a,...e})}))(t,e)}Object.assign(u,{use:r});class h extends HTMLElement{constructor(...t){super(...t),this[c]=!1,Object.defineProperties(this,{loaded:{get:()=>this[c]}}),this._init()}_init(){if(this.__initSrc||this.attributes.hasOwnProperty("pause"))return;let t=this.getAttribute("src");if(!t)return;this.__initSrc=t;lm(void 0,{element:this})(t),Object.defineProperties(this,{src:{configurable:!0,value:t}})}connectedCallback(){const t=new CustomEvent("connected");t.root=this._root=this.getRootNode(),this.dispatchEvent(t)}disconnectedCallback(){const t=new CustomEvent("disconnected");t.root=this._root,delete this._root,this.dispatchEvent(t)}attributeChangedCallback(t,e,s){"src"===t?s&&null===e?this._init():this.__initSrc&&e&&s!==this.__initSrc&&(console.warn(`${this.tagName.toLowerCase()} change src is invalid, only the first change will be loaded`),this.setAttribute("src",this.__initSrc)):"pause"===t&&null===s&&this._init()}static get observedAttributes(){return["src","pause"]}}class m extends h{constructor(...t){super(...t)}}const w=()=>{customElements.define("load-module",h),customElements.define("l-m",m),window.removeEventListener("load",w)};"complete"===document.readyState?w():window.addEventListener("load",w),u.config=async function(t){const{alias:e}=t;return e&&Object.entries(e).forEach((([t,e])=>{if(/^@.+/.test(t)){if(o[t])throw`Alias already exists: '${t}'`;if(/^\./.test(e))throw`The address does not match the specification, please use '/' or or the beginning of the protocol: '${e}'`;o[t]=e}})),!0},u.path=l,Object.freeze(u),window.lm=u;export{u as default}; | ||
//! drill.js - v5.3.6 https://github.com/kirakiray/drill.js (c) 2018-2024 YAO | ||
class t{constructor(){this._middlewares=new Map}use(t){const e=Math.random().toString(32).slice(2);return this._middlewares.set(e,t),e}unuse(t){return this._middlewares.delete(t)}async run(t){let e=-1;const s=Array.from(this._middlewares.values()),n=async()=>{e++,e<s.length&&await s[e](t,n)};await n()}}const e=new Map,s=async(t,s)=>{const n=new URL(t),a=s.includes("-direct")?t:`${n.origin}${n.pathname}`;let r=e.get(a);r||(r=fetch(a),e.set(a,r));return(await r).clone()},n={},a=(e,s)=>{(n[e]||(n[e]=new t)).use(s)},r=(t,e)=>{t instanceof Function&&(e=t,t=["js","mjs"]),t instanceof Array?t.forEach((t=>{a(t,e)})):a(t,e)};r(["mjs","js"],(async(t,e)=>{if(!t.result){const{url:e,params:s}=t,n=new URL(e),a=/^blob:/.test(e)||/^data:/.test(e);try{a||s.includes("-direct")?t.result=await import(e):t.result=await import(`${n.origin}${n.pathname}`)}catch(s){const n=i(`Failed to load module ${t.realUrl||e}`,s);throw a&&console.log("Failed to load module:",t),n}}await e()})),r(["txt","html","htm"],(async(t,e)=>{if(!t.result){const{url:e,params:n}=t;let a;try{a=await s(e,n)}catch(t){throw i(`Load ${e} failed`,t)}if(!/^2.{2}$/.test(a.status))throw new Error(`Load ${e} failed: status code ${a.status}`);t.result=await a.text()}await e()})),r("json",(async(t,e)=>{if(!t.result){const{url:e,params:n}=t;t.result=await s(e,n).then((t=>t.json()))}await e()})),r("wasm",(async(t,e)=>{if(!t.result){const{url:e,params:n}=t,a=await s(e,n).then((t=>t.arrayBuffer())),r=await WebAssembly.compile(a),i=new WebAssembly.Instance(r);t.result=i.exports}await e()})),r("css",(async(t,e)=>{if(!t.result){const{url:e,element:n,params:a}=t;if(n){const t=document.createElement("link");t.rel="stylesheet",t.href=e;const s=n.getRootNode();let a;s===document?s.head.append(t):s.appendChild(t),n.addEventListener("disconnected",a=e=>{t.remove(),n.removeEventListener("disconnected",a)})}else t.result=await s(e,a).then((t=>t.text()))}await e()}));const i=(t,e)=>new Error(`${t} \n ${e.toString()}`,{cause:e}),o={};const l=(t,e)=>{if(t.startsWith("http://")||t.startsWith("https://"))return t;const[s,...n]=t.split(" ");let a=s;if(/^@/.test(s)){const[t,...e]=s.split("/");if(!o[t])throw`No alias defined ${t}`;a=[o[t].replace(/\/$/,""),...e].join("/")}if("undefined"!=typeof location){const t=e?new URL(e,location.href):location.href;a=new URL(a,t).href}return n.length?`${a} ${n.join(" ")}`:a},c=Symbol("loaded"),d=async(t,e)=>{const s=new URL(t),{pathname:a}=s;let r,i=null;e.params&&e.params.forEach((t=>{/^\..+/.test(t)?r=t.replace(/^\.(.+)/,"$1"):/^\-\-real/.test(t)&&(i=t.replace(/^\-\-real\:/,""))})),r||(r=a.slice(2+(a.lastIndexOf(".")-1>>>0)));const o={url:t,result:null,realUrl:i,...e},l=n[r];if(l?await l.run(o):o.result=fetch(t),e&&e.element){const{element:t}=e;t[c]=!0;const s=new Event("load");t.dispatchEvent(s)}return e.params&&e.params.includes("-ctx")?o:o.result};function u(t,e){return((t,e)=>(t||(t={url:document.location.href}),s=>{let[n,...a]=s.split(" ");const r=l(n,t.url);return d(r,{params:a,...e})}))(t,e)}Object.assign(u,{use:r});class h extends HTMLElement{constructor(...t){super(...t),this[c]=!1,Object.defineProperties(this,{loaded:{get:()=>this[c]}}),this._init()}_init(){if(this.__initSrc||this.attributes.hasOwnProperty("pause"))return;let t=this.getAttribute("src");if(!t)return;this.__initSrc=t;lm(void 0,{element:this})(t),Object.defineProperties(this,{src:{configurable:!0,value:t}})}connectedCallback(){const t=new CustomEvent("connected");t.root=this._root=this.getRootNode(),this.dispatchEvent(t)}disconnectedCallback(){const t=new CustomEvent("disconnected");t.root=this._root,delete this._root,this.dispatchEvent(t)}attributeChangedCallback(t,e,s){"src"===t?s&&null===e?this._init():this.__initSrc&&e&&s!==this.__initSrc&&(console.warn(`${this.tagName.toLowerCase()} change src is invalid, only the first change will be loaded`),this.setAttribute("src",this.__initSrc)):"pause"===t&&null===s&&this._init()}static get observedAttributes(){return["src","pause"]}}class m extends h{constructor(...t){super(...t)}}const w=()=>{customElements.define("load-module",h),customElements.define("l-m",m),window.removeEventListener("load",w)};"complete"===document.readyState?w():window.addEventListener("load",w),u.config=async function(t){const{alias:e}=t;return e&&Object.entries(e).forEach((([t,e])=>{if(/^@.+/.test(t)){if(o[t])throw`Alias already exists: '${t}'`;if(/^\./.test(e))throw`The address does not match the specification, please use '/' or or the beginning of the protocol: '${e}'`;o[t]=e}})),!0},u.path=l,Object.freeze(u),window.lm=u;export{u as default}; | ||
//# sourceMappingURL=drill.min.mjs.map |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.