@elysiajs/eden
Advanced tools
Comparing version 1.0.13 to 1.0.14
@@ -1,1 +0,1 @@ | ||
"use strict";var Eden=(()=>{var p=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var E=(e,t)=>{for(var n in t)p(e,n,{get:t[n],enumerable:!0})},$=(e,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of x(t))!b.call(e,s)&&s!==n&&p(e,s,{get:()=>t[s],enumerable:!(a=m(t,s))||a.enumerable});return e};var S=e=>$(p({},"__esModule",{value:!0}),e);var N={};E(N,{edenFetch:()=>j});var l=class extends Error{constructor(n,a){super(a+"");this.status=n;this.value=a}};var y=e=>e.trim().length!==0&&!Number.isNaN(Number(e));var j=(e,t)=>(n,{query:a,params:s,body:u,...c}={})=>{s&&Object.entries(s).forEach(([r,i])=>{n=n.replace(`:${r}`,i)});let f=c.headers?.["Content-Type"];if(!f||f==="application/json")try{u=JSON.stringify(u)}catch{}let d=t?.fetcher||globalThis.fetch,g=a?`?${new URLSearchParams(a).toString()}`:"",h=()=>d(e+n+g,{...c,method:c.method?.toUpperCase()||"GET",headers:u?{"content-type":"application/json",...c.headers}:c.headers,body:u}).then(async r=>{let i;switch(r.headers.get("Content-Type")?.split(";")[0]){case"application/json":i=await r.json();break;default:i=await r.text().then(o=>y(o)?parseInt(o):o==="true"?!0:o==="false"?!1:o);break}return r.status>300?{data:null,status:r.status,headers:r.headers,retry:h,error:new l(r.status,i)}:{data:i,error:null,status:r.status,headers:r.headers,retry:h}});return h()};return S(N);})(); | ||
"use strict";var Eden=(()=>{var p=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var T=(t,r)=>{for(var s in r)p(t,s,{get:r[s],enumerable:!0})},F=(t,r,s,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let a of A(r))!x.call(t,a)&&a!==s&&p(t,a,{get:()=>r[a],enumerable:!(o=k(r,a))||o.enumerable});return t};var N=t=>F(p({},"__esModule",{value:!0}),t);var j={};T(j,{edenFetch:()=>O});var y=t=>t.trim().length!==0&&!Number.isNaN(Number(t));var u=class extends Error{constructor(s,o){super(o+"");this.status=s;this.value=o}};var m=/(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))/,w=/(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)\s(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{2}\s\d{4}\s\d{2}:\d{2}:\d{2}\sGMT(?:\+|-)\d{4}\s\([^)]+\)/,b=/^(?:(?:(?:(?:0?[1-9]|[12][0-9]|3[01])[/\s-](?:0?[1-9]|1[0-2])[/\s-](?:19|20)\d{2})|(?:(?:19|20)\d{2}[/\s-](?:0?[1-9]|1[0-2])[/\s-](?:0?[1-9]|[12][0-9]|3[01]))))(?:\s(?:1[012]|0?[1-9]):[0-5][0-9](?::[0-5][0-9])?(?:\s[AP]M)?)?$/;var O=(t,r)=>(s,{query:o,params:a,body:l,...f}={})=>{a&&Object.entries(a).forEach(([e,i])=>{s=s.replace(`:${e}`,i)});let h=f.headers?.["Content-Type"];if(!h||h==="application/json")try{l=JSON.stringify(l)}catch{}let S=r?.fetcher||globalThis.fetch,E=o?`?${new URLSearchParams(o).toString()}`:"",d=()=>S(t+s+E,{...f,method:f.method?.toUpperCase()||"GET",headers:l?{"content-type":"application/json",...f.headers}:f.headers,body:l}).then(async e=>{let i;switch(e.headers.get("Content-Type")?.split(";")[0]){case"application/json":i=await e.json();break;case"application/octet-stream":i=await e.arrayBuffer();break;case"multipart/form-data":let v=await e.formData();i={},v.forEach((n,c)=>{i[c]=n});break;default:i=await e.text().then(n=>{if(y(n))return+n;if(n==="true")return!0;if(n==="false")return!1;if(!n)return n;let c=n.replace(/"/g,"");if(m.test(c)||w.test(c)||b.test(c)){let g=new Date(c);if(!Number.isNaN(g.getTime()))return g}return n})}return e.status>300?{data:null,status:e.status,headers:e.headers,retry:d,error:new u(e.status,i)}:{data:i,error:null,status:e.status,headers:e.headers,retry:d}});return d()};return N(j);})(); |
@@ -1,1 +0,1 @@ | ||
"use strict";var p=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var E=(e,t)=>{for(var n in t)p(e,n,{get:t[n],enumerable:!0})},$=(e,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of x(t))!b.call(e,s)&&s!==n&&p(e,s,{get:()=>t[s],enumerable:!(a=m(t,s))||a.enumerable});return e};var S=e=>$(p({},"__esModule",{value:!0}),e);var N={};E(N,{edenFetch:()=>j});module.exports=S(N);var l=class extends Error{constructor(n,a){super(a+"");this.status=n;this.value=a}};var y=e=>e.trim().length!==0&&!Number.isNaN(Number(e));var j=(e,t)=>(n,{query:a,params:s,body:u,...c}={})=>{s&&Object.entries(s).forEach(([r,i])=>{n=n.replace(`:${r}`,i)});let f=c.headers?.["Content-Type"];if(!f||f==="application/json")try{u=JSON.stringify(u)}catch{}let d=t?.fetcher||globalThis.fetch,g=a?`?${new URLSearchParams(a).toString()}`:"",h=()=>d(e+n+g,{...c,method:c.method?.toUpperCase()||"GET",headers:u?{"content-type":"application/json",...c.headers}:c.headers,body:u}).then(async r=>{let i;switch(r.headers.get("Content-Type")?.split(";")[0]){case"application/json":i=await r.json();break;default:i=await r.text().then(o=>y(o)?parseInt(o):o==="true"?!0:o==="false"?!1:o);break}return r.status>300?{data:null,status:r.status,headers:r.headers,retry:h,error:new l(r.status,i)}:{data:i,error:null,status:r.status,headers:r.headers,retry:h}});return h()};0&&(module.exports={edenFetch}); | ||
"use strict";var p=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var T=(t,r)=>{for(var s in r)p(t,s,{get:r[s],enumerable:!0})},F=(t,r,s,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let a of A(r))!x.call(t,a)&&a!==s&&p(t,a,{get:()=>r[a],enumerable:!(o=k(r,a))||o.enumerable});return t};var N=t=>F(p({},"__esModule",{value:!0}),t);var j={};T(j,{edenFetch:()=>O});module.exports=N(j);var y=t=>t.trim().length!==0&&!Number.isNaN(Number(t));var u=class extends Error{constructor(s,o){super(o+"");this.status=s;this.value=o}};var m=/(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))/,w=/(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)\s(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{2}\s\d{4}\s\d{2}:\d{2}:\d{2}\sGMT(?:\+|-)\d{4}\s\([^)]+\)/,b=/^(?:(?:(?:(?:0?[1-9]|[12][0-9]|3[01])[/\s-](?:0?[1-9]|1[0-2])[/\s-](?:19|20)\d{2})|(?:(?:19|20)\d{2}[/\s-](?:0?[1-9]|1[0-2])[/\s-](?:0?[1-9]|[12][0-9]|3[01]))))(?:\s(?:1[012]|0?[1-9]):[0-5][0-9](?::[0-5][0-9])?(?:\s[AP]M)?)?$/;var O=(t,r)=>(s,{query:o,params:a,body:l,...f}={})=>{a&&Object.entries(a).forEach(([e,i])=>{s=s.replace(`:${e}`,i)});let h=f.headers?.["Content-Type"];if(!h||h==="application/json")try{l=JSON.stringify(l)}catch{}let S=r?.fetcher||globalThis.fetch,E=o?`?${new URLSearchParams(o).toString()}`:"",d=()=>S(t+s+E,{...f,method:f.method?.toUpperCase()||"GET",headers:l?{"content-type":"application/json",...f.headers}:f.headers,body:l}).then(async e=>{let i;switch(e.headers.get("Content-Type")?.split(";")[0]){case"application/json":i=await e.json();break;case"application/octet-stream":i=await e.arrayBuffer();break;case"multipart/form-data":let v=await e.formData();i={},v.forEach((n,c)=>{i[c]=n});break;default:i=await e.text().then(n=>{if(y(n))return+n;if(n==="true")return!0;if(n==="false")return!1;if(!n)return n;let c=n.replace(/"/g,"");if(m.test(c)||w.test(c)||b.test(c)){let g=new Date(c);if(!Number.isNaN(g.getTime()))return g}return n})}return e.status>300?{data:null,status:e.status,headers:e.headers,retry:d,error:new u(e.status,i)}:{data:i,error:null,status:e.status,headers:e.headers,retry:d}});return d()};0&&(module.exports={edenFetch}); |
@@ -1,1 +0,1 @@ | ||
"use strict";var Eden=(()=>{var D=Object.defineProperty;var te=Object.getOwnPropertyDescriptor;var ne=Object.getOwnPropertyNames;var re=Object.prototype.hasOwnProperty;var se=(t,e)=>{for(var n in e)D(t,n,{get:e[n],enumerable:!0})},ae=(t,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of ne(e))!re.call(t,o)&&o!==n&&D(t,o,{get:()=>e[o],enumerable:!(s=te(e,o))||s.enumerable});return t};var ie=t=>ae(D({},"__esModule",{value:!0}),t);var de={};se(de,{edenFetch:()=>ee,edenTreaty:()=>Y,treaty:()=>z});var _=(t,e,n)=>{if(t.endsWith("/")||(t+="/"),e==="index"&&(e=""),!n||!Object.keys(n).length)return`${t}${e}`;let s="";for(let[o,r]of Object.entries(n))s+=`${o}=${r}&`;return`${t}${e}?${s.slice(0,-1)}`},L=t=>t.trim().length!==0&&!Number.isNaN(Number(t));var T=class extends Error{constructor(n,s){super(s+"");this.status=n;this.value=s}};var G=/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z/,I=class{constructor(e){this.url=e;this.ws=new WebSocket(e)}ws;send(e){return Array.isArray(e)?(e.forEach(n=>this.send(n)),this):(this.ws.send(typeof e=="object"?JSON.stringify(e):e.toString()),this)}on(e,n,s){return this.addEventListener(e,n,s)}off(e,n,s){return this.ws.removeEventListener(e,n,s),this}subscribe(e,n){return this.addEventListener("message",e,n)}addEventListener(e,n,s){return this.ws.addEventListener(e,o=>{if(e==="message"){let r=o.data.toString(),a=r.charCodeAt(0),u=r.charCodeAt(r.length-1);if(a===91||a===123)try{r=JSON.parse(r,(R,g)=>{if(typeof g=="string"&&G.test(g)){let m=new Date(g);if(!Number.isNaN(m.getTime()))return m}return g})}catch{}else L(r)?r=+r:r==="true"?r=!0:r==="false"?r=!1:r==="null"?r=null:a===34&&u===34&&G.test(r)&&(r=new Date(r.substring(1,r.length-1)));n({...o,data:r})}else n(o)},s),this}removeEventListener(e,n,s){return this.off(e,n,s),this}close(){return this.ws.close(),this}};var oe=["get","post","put","delete","patch","options","head","connect","subscribe"],V=["localhost","127.0.0.1","0.0.0.0"],J=typeof FileList>"u",ce=/(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))/,fe=/(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)\s(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{2}\s\d{4}\s\d{2}:\d{2}:\d{2}\sGMT(?:\+|-)\d{4}\s\([^)]+\)/,ye=/^(?:(?:(?:(?:0?[1-9]|[12][0-9]|3[01])[/\s-](?:0?[1-9]|1[0-2])[/\s-](?:19|20)\d{2})|(?:(?:19|20)\d{2}[/\s-](?:0?[1-9]|1[0-2])[/\s-](?:0?[1-9]|[12][0-9]|3[01]))))(?:\s(?:1[012]|0?[1-9]):[0-5][0-9](?::[0-5][0-9])?(?:\s[AP]M)?)?$/,Z=t=>J?t instanceof Blob:t instanceof FileList||t instanceof File,ue=t=>{if(!t)return!1;for(let e in t)if(Z(t[e])||Array.isArray(t[e])&&t[e].find(Z))return!0;return!1},q=t=>J?t:new Promise(e=>{let n=new FileReader;n.onload=()=>{let s=new File([n.result],t.name,{lastModified:t.lastModified,type:t.type});e(s)},n.readAsArrayBuffer(t)}),N=(t,e,n={},s={})=>{if(Array.isArray(t)){for(let o of t)if(!Array.isArray(o))s=N(o,e,n,s);else{let r=o[0];if(typeof r=="string")s[r.toLowerCase()]=o[1];else for(let[a,u]of r)s[a.toLowerCase()]=u}return s}if(!t)return s;switch(typeof t){case"function":let o=t(e,n);return o?N(o,e,n,s):s;case"object":if(t instanceof Headers)return t.forEach((r,a)=>{s[a.toLowerCase()]=r}),s;for(let[r,a]of Object.entries(t))s[r.toLowerCase()]=a;default:return s}},$=(t,e,n=[],s)=>new Proxy(()=>{},{get(o,r){return $(t,e,r==="index"?n:[...n,r],s)},apply(o,r,[a,u]){if(!a||u||typeof a=="object"&&Object.keys(a).length!==1||oe.includes(n.at(-1))){let R=[...n],g=R.pop(),m="/"+R.join("/"),{fetcher:l=fetch,headers:w,onRequest:p,onResponse:F,fetch:j}=e,A=g==="get"||g==="head"||g==="subscribe";w=N(w,m,u);let K=A?a?.query:u?.query,b="";if(K){let i=(O,k)=>{b+=(b?"&":"?")+`${encodeURIComponent(O)}=${encodeURIComponent(k)}`};for(let[O,k]of Object.entries(K)){if(Array.isArray(k)){for(let y of k)i(O,y);continue}i(O,`${k}`)}}if(g==="subscribe"){let i=t.replace(/^([^]+):\/\//,t.startsWith("https://")?"wss://":t.startsWith("http://")||V.find(O=>t.includes(O))?"ws://":"wss://")+m+b;return new I(i)}return(async()=>{let i={method:g?.toUpperCase(),body:a,...j,headers:w};i.headers={...w,...N(A?a?.headers:u?.headers,m,i)};let O=A&&typeof a=="object"?a.fetch:u?.fetch;if(i={...i,...O},A&&delete i.body,p){Array.isArray(p)||(p=[p]);for(let f of p){let c=await f(m,i);typeof c=="object"&&(i={...i,...c,headers:{...i.headers,...N(c.headers,m,i)}})}}if(A&&delete i.body,ue(a)){let f=new FormData;for(let[c,h]of Object.entries(i.body)){if(J){f.append(c,h);continue}if(h instanceof File){f.append(c,await q(h));continue}if(h instanceof FileList){for(let d=0;d<h.length;d++)f.append(c,await q(h[d]));continue}if(Array.isArray(h)){for(let d=0;d<h.length;d++){let v=h[d];f.append(c,v instanceof File?await q(v):v)}continue}f.append(c,h)}i.body=f}else typeof a=="object"?(i.headers["content-type"]="application/json",i.body=JSON.stringify(a)):a!=null&&(i.headers["content-type"]="text/plain");if(A&&delete i.body,p){Array.isArray(p)||(p=[p]);for(let f of p){let c=await f(m,i);typeof c=="object"&&(i={...i,...c,headers:{...i.headers,...c.headers}})}}let k=t+m+b,y=await(s?.handle(new Request(k,i))??l(k,i)),S=null,E=null;if(F){Array.isArray(F)||(F=[F]);for(let f of F)try{let c=await f(y.clone());if(c!=null){S=c;break}}catch(c){c instanceof T?E=c:E=new T(422,c);break}}if(S===null){switch(y.headers.get("Content-Type")?.split(";")[0]){case"application/json":S=await y.json();break;case"application/octet-stream":S=await y.arrayBuffer();break;default:S=await y.text().then(f=>{if(L(f))return+f;if(f==="true")return!0;if(f==="false")return!1;if(!f)return f;let c=f.replace(/"/g,"");if(ce.test(c)||fe.test(c)||ye.test(c)){let h=new Date(c);if(!Number.isNaN(h.getTime()))return h}return f})}(y.status>=300||y.status<200)&&(E=new T(y.status,S),S=null)}return{data:S,error:E,response:y,status:y.status,headers:y.headers}})()}return typeof a=="object"?$(t,e,[...n,Object.values(a)[0]],s):$(t,e,n)}}),z=(t,e={})=>typeof t=="string"?(e.keepDomain||(t.includes("://")||(t=(V.find(n=>t.includes(n))?"http://":"https://")+t),t.endsWith("/")&&(t=t.slice(0,-1))),$(t,e)):(typeof window<"u"&&console.warn("Elysia instance server found on client side, this is not recommended for security reason. Use generic type instead."),$("http://e.ly",e,[],t));var H=typeof FileList>"u",Q=t=>H?t instanceof Blob:t instanceof FileList||t instanceof File,le=t=>{if(!t)return!1;for(let e in t){if(Q(t[e]))return!0;if(Array.isArray(t[e])&&t[e].find(n=>Q(n)))return!0}return!1},U=t=>H?t:new Promise(e=>{let n=new FileReader;n.onload=()=>{let s=new File([n.result],t.name,{lastModified:t.lastModified,type:t.type});e(s)},n.readAsArrayBuffer(t)}),B=class{ws;url;constructor(e){this.ws=new WebSocket(e),this.url=e}send(e){return Array.isArray(e)?(e.forEach(n=>this.send(n)),this):(this.ws.send(typeof e=="object"?JSON.stringify(e):e.toString()),this)}on(e,n,s){return this.addEventListener(e,n,s)}off(e,n,s){return this.ws.removeEventListener(e,n,s),this}subscribe(e,n){return this.addEventListener("message",e,n)}addEventListener(e,n,s){return this.ws.addEventListener(e,o=>{if(e==="message"){let r=o.data.toString(),a=r.charCodeAt(0);if(a===47||a===123)try{r=JSON.parse(r)}catch{}else L(r)?r=+r:r==="true"?r=!0:r==="false"&&(r=!1);n({...o,data:r})}else n(o)},s),this}removeEventListener(e,n,s){return this.off(e,n,s),this}close(){return this.ws.close(),this}},X=(t,e="",n)=>new Proxy(()=>{},{get(s,o,r){return X(t,`${e}/${o.toString()}`,n)},apply(s,o,[r,a={}]=[{},{}]){let u=r!==void 0&&(typeof r!="object"||Array.isArray(r))?r:void 0,{$query:R,$fetch:g,$headers:m,$transform:l,getRaw:w,...p}=r??{};u??=p;let F=e.lastIndexOf("/"),j=e.slice(F+1).toUpperCase(),A=_(t,F===-1?"/":e.slice(0,F),Object.assign(a.query??{},R)),K=n.fetcher??fetch,b=n.transform?Array.isArray(n.transform)?n.transform:[n.transform]:void 0,i=l?Array.isArray(l)?l:[l]:void 0;return i&&(b?b=i.concat(b):b=i),j==="SUBSCRIBE"?new B(A.replace(/^([^]+):\/\//,A.startsWith("https://")?"wss://":"ws://")):(async k=>{let y,S={...n.$fetch?.headers,...g?.headers,...a.headers,...m};if(j!=="GET"&&j!=="HEAD"){y=Object.keys(u).length||Array.isArray(u)?u:void 0;let d=y&&(typeof y=="object"||Array.isArray(u));if(d&&le(y)){let C=new FormData;for(let[M,x]of Object.entries(y))if(H)C.append(M,x);else if(x instanceof File)C.append(M,await U(x));else if(x instanceof FileList)for(let W=0;W<x.length;W++)C.append(M,await U(x[W]));else if(Array.isArray(x))for(let W=0;W<x.length;W++){let P=x[W];C.append(M,P instanceof File?await U(P):P)}else C.append(M,x);y=C}else y!=null&&(S["content-type"]=d?"application/json":"text/plain",y=d?JSON.stringify(y):u)}let E=await K(A,{method:j,body:y,...n.$fetch,...a.fetch,...g,headers:S}),f;if(k.getRaw)return E;switch(E.headers.get("Content-Type")?.split(";")[0]){case"application/json":f=await E.json();break;default:f=await E.text().then(d=>L(d)?+d:d==="true"?!0:d==="false"?!1:d)}let c=E.status>=300||E.status<200?new T(E.status,f):null,h={data:f,error:c,response:E,status:E.status,headers:E.headers};if(b)for(let d of b){let v=d(h);v instanceof Promise&&(v=await v),v!=null&&(h=v)}return h})({getRaw:w})}}),Y=(t,e={fetcher:fetch})=>new Proxy({},{get(n,s){return X(t,s,e)}});var ee=(t,e)=>(n,{query:s,params:o,body:r,...a}={})=>{o&&Object.entries(o).forEach(([l,w])=>{n=n.replace(`:${l}`,w)});let u=a.headers?.["Content-Type"];if(!u||u==="application/json")try{r=JSON.stringify(r)}catch{}let R=e?.fetcher||globalThis.fetch,g=s?`?${new URLSearchParams(s).toString()}`:"",m=()=>R(t+n+g,{...a,method:a.method?.toUpperCase()||"GET",headers:r?{"content-type":"application/json",...a.headers}:a.headers,body:r}).then(async l=>{let w;switch(l.headers.get("Content-Type")?.split(";")[0]){case"application/json":w=await l.json();break;default:w=await l.text().then(p=>L(p)?parseInt(p):p==="true"?!0:p==="false"?!1:p);break}return l.status>300?{data:null,status:l.status,headers:l.headers,retry:m,error:new T(l.status,w)}:{data:w,error:null,status:l.status,headers:l.headers,retry:m}});return m()};return ie(de);})(); | ||
"use strict";var Eden=(()=>{var P=Object.defineProperty;var se=Object.getOwnPropertyDescriptor;var ae=Object.getOwnPropertyNames;var ie=Object.prototype.hasOwnProperty;var oe=(t,e)=>{for(var r in e)P(t,r,{get:e[r],enumerable:!0})},ce=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let c of ae(e))!ie.call(t,c)&&c!==r&&P(t,c,{get:()=>e[c],enumerable:!(s=se(e,c))||s.enumerable});return t};var fe=t=>ce(P({},"__esModule",{value:!0}),t);var de={};oe(de,{edenFetch:()=>ne,edenTreaty:()=>re,treaty:()=>Y});var V=(t,e,r)=>{if(t.endsWith("/")||(t+="/"),e==="index"&&(e=""),!r||!Object.keys(r).length)return`${t}${e}`;let s="";for(let[c,n]of Object.entries(r))s+=`${c}=${n}&`;return`${t}${e}?${s.slice(0,-1)}`},R=t=>t.trim().length!==0&&!Number.isNaN(Number(t));var O=class extends Error{constructor(r,s){super(s+"");this.status=r;this.value=s}};var z=/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z/,D=class{constructor(e){this.url=e;this.ws=new WebSocket(e)}ws;send(e){return Array.isArray(e)?(e.forEach(r=>this.send(r)),this):(this.ws.send(typeof e=="object"?JSON.stringify(e):e.toString()),this)}on(e,r,s){return this.addEventListener(e,r,s)}off(e,r,s){return this.ws.removeEventListener(e,r,s),this}subscribe(e,r){return this.addEventListener("message",e,r)}addEventListener(e,r,s){return this.ws.addEventListener(e,c=>{if(e==="message"){let n=c.data.toString(),a=n.charCodeAt(0),d=n.charCodeAt(n.length-1);if(a===91||a===123)try{n=JSON.parse(n,(W,w)=>{if(typeof w=="string"&&z.test(w)){let m=new Date(w);if(!Number.isNaN(m.getTime()))return m}return w})}catch{}else R(n)?n=+n:n==="true"?n=!0:n==="false"?n=!1:n==="null"?n=null:a===34&&d===34&&z.test(n)&&(n=new Date(n.substring(1,n.length-1)));r({...c,data:n})}else r(c)},s),this}removeEventListener(e,r,s){return this.off(e,r,s),this}close(){return this.ws.close(),this}};var ye=["get","post","put","delete","patch","options","head","connect","subscribe"],X=["localhost","127.0.0.1","0.0.0.0"],J=typeof FileList>"u",U=/(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))/,B=/(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)\s(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{2}\s\d{4}\s\d{2}:\d{2}:\d{2}\sGMT(?:\+|-)\d{4}\s\([^)]+\)/,H=/^(?:(?:(?:(?:0?[1-9]|[12][0-9]|3[01])[/\s-](?:0?[1-9]|1[0-2])[/\s-](?:19|20)\d{2})|(?:(?:19|20)\d{2}[/\s-](?:0?[1-9]|1[0-2])[/\s-](?:0?[1-9]|[12][0-9]|3[01]))))(?:\s(?:1[012]|0?[1-9]):[0-5][0-9](?::[0-5][0-9])?(?:\s[AP]M)?)?$/,Q=t=>J?t instanceof Blob:t instanceof FileList||t instanceof File,ue=t=>{if(!t)return!1;for(let e in t)if(Q(t[e])||Array.isArray(t[e])&&t[e].find(Q))return!0;return!1},q=t=>J?t:new Promise(e=>{let r=new FileReader;r.onload=()=>{let s=new File([r.result],t.name,{lastModified:t.lastModified,type:t.type});e(s)},r.readAsArrayBuffer(t)}),M=(t,e,r={},s={})=>{if(Array.isArray(t)){for(let c of t)if(!Array.isArray(c))s=M(c,e,r,s);else{let n=c[0];if(typeof n=="string")s[n.toLowerCase()]=c[1];else for(let[a,d]of n)s[a.toLowerCase()]=d}return s}if(!t)return s;switch(typeof t){case"function":let c=t(e,r);return c?M(c,e,r,s):s;case"object":if(t instanceof Headers)return t.forEach((n,a)=>{s[a.toLowerCase()]=n}),s;for(let[n,a]of Object.entries(t))s[n.toLowerCase()]=a;default:return s}},$=(t,e,r=[],s)=>new Proxy(()=>{},{get(c,n){return $(t,e,n==="index"?r:[...r,n],s)},apply(c,n,[a,d]){if(!a||d||typeof a=="object"&&Object.keys(a).length!==1||ye.includes(r.at(-1))){let W=[...r],w=W.pop(),m="/"+W.join("/"),{fetcher:u=fetch,headers:g,onRequest:b,onResponse:p,fetch:S}=e,v=w==="get"||w==="head"||w==="subscribe";g=M(g,m,d);let K=v?a?.query:d?.query,k="";if(K){let o=(L,T)=>{k+=(k?"&":"?")+`${encodeURIComponent(L)}=${encodeURIComponent(T)}`};for(let[L,T]of Object.entries(K)){if(Array.isArray(T)){for(let f of T)o(L,f);continue}o(L,`${T}`)}}if(w==="subscribe"){let o=t.replace(/^([^]+):\/\//,t.startsWith("https://")?"wss://":t.startsWith("http://")||X.find(L=>t.includes(L))?"ws://":"wss://")+m+k;return new D(o)}return(async()=>{let o={method:w?.toUpperCase(),body:a,...S,headers:g};o.headers={...g,...M(v?a?.headers:d?.headers,m,o)};let L=v&&typeof a=="object"?a.fetch:d?.fetch;if(o={...o,...L},v&&delete o.body,b){Array.isArray(b)||(b=[b]);for(let h of b){let i=await h(m,o);typeof i=="object"&&(o={...o,...i,headers:{...o.headers,...M(i.headers,m,o)}})}}if(v&&delete o.body,ue(a)){let h=new FormData;for(let[i,l]of Object.entries(o.body)){if(J){h.append(i,l);continue}if(l instanceof File){h.append(i,await q(l));continue}if(l instanceof FileList){for(let y=0;y<l.length;y++)h.append(i,await q(l[y]));continue}if(Array.isArray(l)){for(let y=0;y<l.length;y++){let x=l[y];h.append(i,x instanceof File?await q(x):x)}continue}h.append(i,l)}o.body=h}else typeof a=="object"?(o.headers["content-type"]="application/json",o.body=JSON.stringify(a)):a!=null&&(o.headers["content-type"]="text/plain");if(v&&delete o.body,b){Array.isArray(b)||(b=[b]);for(let h of b){let i=await h(m,o);typeof i=="object"&&(o={...o,...i,headers:{...o.headers,...i.headers}})}}let T=t+m+k,f=await(s?.handle(new Request(T,o))??u(T,o)),A=null,E=null;if(p){Array.isArray(p)||(p=[p]);for(let h of p)try{let i=await h(f.clone());if(i!=null){A=i;break}}catch(i){i instanceof O?E=i:E=new O(422,i);break}}if(A===null){switch(f.headers.get("Content-Type")?.split(";")[0]){case"application/json":A=await f.json();break;case"application/octet-stream":A=await f.arrayBuffer();break;case"multipart/form-data":let h=await f.formData();A={},h.forEach((i,l)=>{A[l]=i});break;default:A=await f.text().then(i=>{if(R(i))return+i;if(i==="true")return!0;if(i==="false")return!1;if(!i)return i;let l=i.replace(/"/g,"");if(U.test(l)||B.test(l)||H.test(l)){let y=new Date(l);if(!Number.isNaN(y.getTime()))return y}return i})}(f.status>=300||f.status<200)&&(E=new O(f.status,A),A=null)}return{data:A,error:E,response:f,status:f.status,headers:f.headers}})()}return typeof a=="object"?$(t,e,[...r,Object.values(a)[0]],s):$(t,e,r)}}),Y=(t,e={})=>typeof t=="string"?(e.keepDomain||(t.includes("://")||(t=(X.find(r=>t.includes(r))?"http://":"https://")+t),t.endsWith("/")&&(t=t.slice(0,-1))),$(t,e)):(typeof window<"u"&&console.warn("Elysia instance server found on client side, this is not recommended for security reason. Use generic type instead."),$("http://e.ly",e,[],t));var Z=typeof FileList>"u",ee=t=>Z?t instanceof Blob:t instanceof FileList||t instanceof File,le=t=>{if(!t)return!1;for(let e in t){if(ee(t[e]))return!0;if(Array.isArray(t[e])&&t[e].find(r=>ee(r)))return!0}return!1},_=t=>Z?t:new Promise(e=>{let r=new FileReader;r.onload=()=>{let s=new File([r.result],t.name,{lastModified:t.lastModified,type:t.type});e(s)},r.readAsArrayBuffer(t)}),G=class{ws;url;constructor(e){this.ws=new WebSocket(e),this.url=e}send(e){return Array.isArray(e)?(e.forEach(r=>this.send(r)),this):(this.ws.send(typeof e=="object"?JSON.stringify(e):e.toString()),this)}on(e,r,s){return this.addEventListener(e,r,s)}off(e,r,s){return this.ws.removeEventListener(e,r,s),this}subscribe(e,r){return this.addEventListener("message",e,r)}addEventListener(e,r,s){return this.ws.addEventListener(e,c=>{if(e==="message"){let n=c.data.toString(),a=n.charCodeAt(0);if(a===47||a===123)try{n=JSON.parse(n)}catch{}else R(n)?n=+n:n==="true"?n=!0:n==="false"&&(n=!1);r({...c,data:n})}else r(c)},s),this}removeEventListener(e,r,s){return this.off(e,r,s),this}close(){return this.ws.close(),this}},te=(t,e="",r)=>new Proxy(()=>{},{get(s,c,n){return te(t,`${e}/${c.toString()}`,r)},apply(s,c,[n,a={}]=[{},{}]){let d=n!==void 0&&(typeof n!="object"||Array.isArray(n))?n:void 0,{$query:W,$fetch:w,$headers:m,$transform:u,getRaw:g,...b}=n??{};d??=b;let p=e.lastIndexOf("/"),S=e.slice(p+1).toUpperCase(),v=V(t,p===-1?"/":e.slice(0,p),Object.assign(a.query??{},W)),K=r.fetcher??fetch,k=r.transform?Array.isArray(r.transform)?r.transform:[r.transform]:void 0,o=u?Array.isArray(u)?u:[u]:void 0;return o&&(k?k=o.concat(k):k=o),S==="SUBSCRIBE"?new G(v.replace(/^([^]+):\/\//,v.startsWith("https://")?"wss://":"ws://")):(async T=>{let f,A={...r.$fetch?.headers,...w?.headers,...a.headers,...m};if(S!=="GET"&&S!=="HEAD"){f=Object.keys(d).length||Array.isArray(d)?d:void 0;let y=f&&(typeof f=="object"||Array.isArray(d));if(y&&le(f)){let j=new FormData;for(let[C,F]of Object.entries(f))if(Z)j.append(C,F);else if(F instanceof File)j.append(C,await _(F));else if(F instanceof FileList)for(let N=0;N<F.length;N++)j.append(C,await _(F[N]));else if(Array.isArray(F))for(let N=0;N<F.length;N++){let I=F[N];j.append(C,I instanceof File?await _(I):I)}else j.append(C,F);f=j}else f!=null&&(A["content-type"]=y?"application/json":"text/plain",f=y?JSON.stringify(f):d)}let E=await K(v,{method:S,body:f,...r.$fetch,...a.fetch,...w,headers:A}),h;if(T.getRaw)return E;switch(E.headers.get("Content-Type")?.split(";")[0]){case"application/json":h=await E.json();break;default:h=await E.text().then(y=>R(y)?+y:y==="true"?!0:y==="false"?!1:y)}let i=E.status>=300||E.status<200?new O(E.status,h):null,l={data:h,error:i,response:E,status:E.status,headers:E.headers};if(k)for(let y of k){let x=y(l);x instanceof Promise&&(x=await x),x!=null&&(l=x)}return l})({getRaw:g})}}),re=(t,e={fetcher:fetch})=>new Proxy({},{get(r,s){return te(t,s,e)}});var ne=(t,e)=>(r,{query:s,params:c,body:n,...a}={})=>{c&&Object.entries(c).forEach(([u,g])=>{r=r.replace(`:${u}`,g)});let d=a.headers?.["Content-Type"];if(!d||d==="application/json")try{n=JSON.stringify(n)}catch{}let W=e?.fetcher||globalThis.fetch,w=s?`?${new URLSearchParams(s).toString()}`:"",m=()=>W(t+r+w,{...a,method:a.method?.toUpperCase()||"GET",headers:n?{"content-type":"application/json",...a.headers}:a.headers,body:n}).then(async u=>{let g;switch(u.headers.get("Content-Type")?.split(";")[0]){case"application/json":g=await u.json();break;case"application/octet-stream":g=await u.arrayBuffer();break;case"multipart/form-data":let b=await u.formData();g={},b.forEach((p,S)=>{g[S]=p});break;default:g=await u.text().then(p=>{if(R(p))return+p;if(p==="true")return!0;if(p==="false")return!1;if(!p)return p;let S=p.replace(/"/g,"");if(U.test(S)||B.test(S)||H.test(S)){let v=new Date(S);if(!Number.isNaN(v.getTime()))return v}return p})}return u.status>300?{data:null,status:u.status,headers:u.headers,retry:m,error:new O(u.status,g)}:{data:g,error:null,status:u.status,headers:u.headers,retry:m}});return m()};return fe(de);})(); |
@@ -1,1 +0,1 @@ | ||
"use strict";var D=Object.defineProperty;var te=Object.getOwnPropertyDescriptor;var ne=Object.getOwnPropertyNames;var re=Object.prototype.hasOwnProperty;var se=(t,e)=>{for(var n in e)D(t,n,{get:e[n],enumerable:!0})},ae=(t,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of ne(e))!re.call(t,o)&&o!==n&&D(t,o,{get:()=>e[o],enumerable:!(s=te(e,o))||s.enumerable});return t};var ie=t=>ae(D({},"__esModule",{value:!0}),t);var de={};se(de,{edenFetch:()=>ee,edenTreaty:()=>Y,treaty:()=>z});module.exports=ie(de);var _=(t,e,n)=>{if(t.endsWith("/")||(t+="/"),e==="index"&&(e=""),!n||!Object.keys(n).length)return`${t}${e}`;let s="";for(let[o,r]of Object.entries(n))s+=`${o}=${r}&`;return`${t}${e}?${s.slice(0,-1)}`},L=t=>t.trim().length!==0&&!Number.isNaN(Number(t));var T=class extends Error{constructor(n,s){super(s+"");this.status=n;this.value=s}};var G=/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z/,I=class{constructor(e){this.url=e;this.ws=new WebSocket(e)}ws;send(e){return Array.isArray(e)?(e.forEach(n=>this.send(n)),this):(this.ws.send(typeof e=="object"?JSON.stringify(e):e.toString()),this)}on(e,n,s){return this.addEventListener(e,n,s)}off(e,n,s){return this.ws.removeEventListener(e,n,s),this}subscribe(e,n){return this.addEventListener("message",e,n)}addEventListener(e,n,s){return this.ws.addEventListener(e,o=>{if(e==="message"){let r=o.data.toString(),a=r.charCodeAt(0),u=r.charCodeAt(r.length-1);if(a===91||a===123)try{r=JSON.parse(r,(R,g)=>{if(typeof g=="string"&&G.test(g)){let m=new Date(g);if(!Number.isNaN(m.getTime()))return m}return g})}catch{}else L(r)?r=+r:r==="true"?r=!0:r==="false"?r=!1:r==="null"?r=null:a===34&&u===34&&G.test(r)&&(r=new Date(r.substring(1,r.length-1)));n({...o,data:r})}else n(o)},s),this}removeEventListener(e,n,s){return this.off(e,n,s),this}close(){return this.ws.close(),this}};var oe=["get","post","put","delete","patch","options","head","connect","subscribe"],V=["localhost","127.0.0.1","0.0.0.0"],J=typeof FileList>"u",ce=/(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))/,fe=/(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)\s(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{2}\s\d{4}\s\d{2}:\d{2}:\d{2}\sGMT(?:\+|-)\d{4}\s\([^)]+\)/,ye=/^(?:(?:(?:(?:0?[1-9]|[12][0-9]|3[01])[/\s-](?:0?[1-9]|1[0-2])[/\s-](?:19|20)\d{2})|(?:(?:19|20)\d{2}[/\s-](?:0?[1-9]|1[0-2])[/\s-](?:0?[1-9]|[12][0-9]|3[01]))))(?:\s(?:1[012]|0?[1-9]):[0-5][0-9](?::[0-5][0-9])?(?:\s[AP]M)?)?$/,Z=t=>J?t instanceof Blob:t instanceof FileList||t instanceof File,ue=t=>{if(!t)return!1;for(let e in t)if(Z(t[e])||Array.isArray(t[e])&&t[e].find(Z))return!0;return!1},q=t=>J?t:new Promise(e=>{let n=new FileReader;n.onload=()=>{let s=new File([n.result],t.name,{lastModified:t.lastModified,type:t.type});e(s)},n.readAsArrayBuffer(t)}),N=(t,e,n={},s={})=>{if(Array.isArray(t)){for(let o of t)if(!Array.isArray(o))s=N(o,e,n,s);else{let r=o[0];if(typeof r=="string")s[r.toLowerCase()]=o[1];else for(let[a,u]of r)s[a.toLowerCase()]=u}return s}if(!t)return s;switch(typeof t){case"function":let o=t(e,n);return o?N(o,e,n,s):s;case"object":if(t instanceof Headers)return t.forEach((r,a)=>{s[a.toLowerCase()]=r}),s;for(let[r,a]of Object.entries(t))s[r.toLowerCase()]=a;default:return s}},$=(t,e,n=[],s)=>new Proxy(()=>{},{get(o,r){return $(t,e,r==="index"?n:[...n,r],s)},apply(o,r,[a,u]){if(!a||u||typeof a=="object"&&Object.keys(a).length!==1||oe.includes(n.at(-1))){let R=[...n],g=R.pop(),m="/"+R.join("/"),{fetcher:l=fetch,headers:w,onRequest:p,onResponse:F,fetch:j}=e,A=g==="get"||g==="head"||g==="subscribe";w=N(w,m,u);let K=A?a?.query:u?.query,b="";if(K){let i=(O,k)=>{b+=(b?"&":"?")+`${encodeURIComponent(O)}=${encodeURIComponent(k)}`};for(let[O,k]of Object.entries(K)){if(Array.isArray(k)){for(let y of k)i(O,y);continue}i(O,`${k}`)}}if(g==="subscribe"){let i=t.replace(/^([^]+):\/\//,t.startsWith("https://")?"wss://":t.startsWith("http://")||V.find(O=>t.includes(O))?"ws://":"wss://")+m+b;return new I(i)}return(async()=>{let i={method:g?.toUpperCase(),body:a,...j,headers:w};i.headers={...w,...N(A?a?.headers:u?.headers,m,i)};let O=A&&typeof a=="object"?a.fetch:u?.fetch;if(i={...i,...O},A&&delete i.body,p){Array.isArray(p)||(p=[p]);for(let f of p){let c=await f(m,i);typeof c=="object"&&(i={...i,...c,headers:{...i.headers,...N(c.headers,m,i)}})}}if(A&&delete i.body,ue(a)){let f=new FormData;for(let[c,h]of Object.entries(i.body)){if(J){f.append(c,h);continue}if(h instanceof File){f.append(c,await q(h));continue}if(h instanceof FileList){for(let d=0;d<h.length;d++)f.append(c,await q(h[d]));continue}if(Array.isArray(h)){for(let d=0;d<h.length;d++){let v=h[d];f.append(c,v instanceof File?await q(v):v)}continue}f.append(c,h)}i.body=f}else typeof a=="object"?(i.headers["content-type"]="application/json",i.body=JSON.stringify(a)):a!=null&&(i.headers["content-type"]="text/plain");if(A&&delete i.body,p){Array.isArray(p)||(p=[p]);for(let f of p){let c=await f(m,i);typeof c=="object"&&(i={...i,...c,headers:{...i.headers,...c.headers}})}}let k=t+m+b,y=await(s?.handle(new Request(k,i))??l(k,i)),S=null,E=null;if(F){Array.isArray(F)||(F=[F]);for(let f of F)try{let c=await f(y.clone());if(c!=null){S=c;break}}catch(c){c instanceof T?E=c:E=new T(422,c);break}}if(S===null){switch(y.headers.get("Content-Type")?.split(";")[0]){case"application/json":S=await y.json();break;case"application/octet-stream":S=await y.arrayBuffer();break;default:S=await y.text().then(f=>{if(L(f))return+f;if(f==="true")return!0;if(f==="false")return!1;if(!f)return f;let c=f.replace(/"/g,"");if(ce.test(c)||fe.test(c)||ye.test(c)){let h=new Date(c);if(!Number.isNaN(h.getTime()))return h}return f})}(y.status>=300||y.status<200)&&(E=new T(y.status,S),S=null)}return{data:S,error:E,response:y,status:y.status,headers:y.headers}})()}return typeof a=="object"?$(t,e,[...n,Object.values(a)[0]],s):$(t,e,n)}}),z=(t,e={})=>typeof t=="string"?(e.keepDomain||(t.includes("://")||(t=(V.find(n=>t.includes(n))?"http://":"https://")+t),t.endsWith("/")&&(t=t.slice(0,-1))),$(t,e)):(typeof window<"u"&&console.warn("Elysia instance server found on client side, this is not recommended for security reason. Use generic type instead."),$("http://e.ly",e,[],t));var H=typeof FileList>"u",Q=t=>H?t instanceof Blob:t instanceof FileList||t instanceof File,le=t=>{if(!t)return!1;for(let e in t){if(Q(t[e]))return!0;if(Array.isArray(t[e])&&t[e].find(n=>Q(n)))return!0}return!1},U=t=>H?t:new Promise(e=>{let n=new FileReader;n.onload=()=>{let s=new File([n.result],t.name,{lastModified:t.lastModified,type:t.type});e(s)},n.readAsArrayBuffer(t)}),B=class{ws;url;constructor(e){this.ws=new WebSocket(e),this.url=e}send(e){return Array.isArray(e)?(e.forEach(n=>this.send(n)),this):(this.ws.send(typeof e=="object"?JSON.stringify(e):e.toString()),this)}on(e,n,s){return this.addEventListener(e,n,s)}off(e,n,s){return this.ws.removeEventListener(e,n,s),this}subscribe(e,n){return this.addEventListener("message",e,n)}addEventListener(e,n,s){return this.ws.addEventListener(e,o=>{if(e==="message"){let r=o.data.toString(),a=r.charCodeAt(0);if(a===47||a===123)try{r=JSON.parse(r)}catch{}else L(r)?r=+r:r==="true"?r=!0:r==="false"&&(r=!1);n({...o,data:r})}else n(o)},s),this}removeEventListener(e,n,s){return this.off(e,n,s),this}close(){return this.ws.close(),this}},X=(t,e="",n)=>new Proxy(()=>{},{get(s,o,r){return X(t,`${e}/${o.toString()}`,n)},apply(s,o,[r,a={}]=[{},{}]){let u=r!==void 0&&(typeof r!="object"||Array.isArray(r))?r:void 0,{$query:R,$fetch:g,$headers:m,$transform:l,getRaw:w,...p}=r??{};u??=p;let F=e.lastIndexOf("/"),j=e.slice(F+1).toUpperCase(),A=_(t,F===-1?"/":e.slice(0,F),Object.assign(a.query??{},R)),K=n.fetcher??fetch,b=n.transform?Array.isArray(n.transform)?n.transform:[n.transform]:void 0,i=l?Array.isArray(l)?l:[l]:void 0;return i&&(b?b=i.concat(b):b=i),j==="SUBSCRIBE"?new B(A.replace(/^([^]+):\/\//,A.startsWith("https://")?"wss://":"ws://")):(async k=>{let y,S={...n.$fetch?.headers,...g?.headers,...a.headers,...m};if(j!=="GET"&&j!=="HEAD"){y=Object.keys(u).length||Array.isArray(u)?u:void 0;let d=y&&(typeof y=="object"||Array.isArray(u));if(d&&le(y)){let C=new FormData;for(let[M,x]of Object.entries(y))if(H)C.append(M,x);else if(x instanceof File)C.append(M,await U(x));else if(x instanceof FileList)for(let W=0;W<x.length;W++)C.append(M,await U(x[W]));else if(Array.isArray(x))for(let W=0;W<x.length;W++){let P=x[W];C.append(M,P instanceof File?await U(P):P)}else C.append(M,x);y=C}else y!=null&&(S["content-type"]=d?"application/json":"text/plain",y=d?JSON.stringify(y):u)}let E=await K(A,{method:j,body:y,...n.$fetch,...a.fetch,...g,headers:S}),f;if(k.getRaw)return E;switch(E.headers.get("Content-Type")?.split(";")[0]){case"application/json":f=await E.json();break;default:f=await E.text().then(d=>L(d)?+d:d==="true"?!0:d==="false"?!1:d)}let c=E.status>=300||E.status<200?new T(E.status,f):null,h={data:f,error:c,response:E,status:E.status,headers:E.headers};if(b)for(let d of b){let v=d(h);v instanceof Promise&&(v=await v),v!=null&&(h=v)}return h})({getRaw:w})}}),Y=(t,e={fetcher:fetch})=>new Proxy({},{get(n,s){return X(t,s,e)}});var ee=(t,e)=>(n,{query:s,params:o,body:r,...a}={})=>{o&&Object.entries(o).forEach(([l,w])=>{n=n.replace(`:${l}`,w)});let u=a.headers?.["Content-Type"];if(!u||u==="application/json")try{r=JSON.stringify(r)}catch{}let R=e?.fetcher||globalThis.fetch,g=s?`?${new URLSearchParams(s).toString()}`:"",m=()=>R(t+n+g,{...a,method:a.method?.toUpperCase()||"GET",headers:r?{"content-type":"application/json",...a.headers}:a.headers,body:r}).then(async l=>{let w;switch(l.headers.get("Content-Type")?.split(";")[0]){case"application/json":w=await l.json();break;default:w=await l.text().then(p=>L(p)?parseInt(p):p==="true"?!0:p==="false"?!1:p);break}return l.status>300?{data:null,status:l.status,headers:l.headers,retry:m,error:new T(l.status,w)}:{data:w,error:null,status:l.status,headers:l.headers,retry:m}});return m()};0&&(module.exports={edenFetch,edenTreaty,treaty}); | ||
"use strict";var P=Object.defineProperty;var se=Object.getOwnPropertyDescriptor;var ae=Object.getOwnPropertyNames;var ie=Object.prototype.hasOwnProperty;var oe=(t,e)=>{for(var r in e)P(t,r,{get:e[r],enumerable:!0})},ce=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let c of ae(e))!ie.call(t,c)&&c!==r&&P(t,c,{get:()=>e[c],enumerable:!(s=se(e,c))||s.enumerable});return t};var fe=t=>ce(P({},"__esModule",{value:!0}),t);var de={};oe(de,{edenFetch:()=>ne,edenTreaty:()=>re,treaty:()=>Y});module.exports=fe(de);var V=(t,e,r)=>{if(t.endsWith("/")||(t+="/"),e==="index"&&(e=""),!r||!Object.keys(r).length)return`${t}${e}`;let s="";for(let[c,n]of Object.entries(r))s+=`${c}=${n}&`;return`${t}${e}?${s.slice(0,-1)}`},R=t=>t.trim().length!==0&&!Number.isNaN(Number(t));var O=class extends Error{constructor(r,s){super(s+"");this.status=r;this.value=s}};var z=/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z/,D=class{constructor(e){this.url=e;this.ws=new WebSocket(e)}ws;send(e){return Array.isArray(e)?(e.forEach(r=>this.send(r)),this):(this.ws.send(typeof e=="object"?JSON.stringify(e):e.toString()),this)}on(e,r,s){return this.addEventListener(e,r,s)}off(e,r,s){return this.ws.removeEventListener(e,r,s),this}subscribe(e,r){return this.addEventListener("message",e,r)}addEventListener(e,r,s){return this.ws.addEventListener(e,c=>{if(e==="message"){let n=c.data.toString(),a=n.charCodeAt(0),d=n.charCodeAt(n.length-1);if(a===91||a===123)try{n=JSON.parse(n,(W,w)=>{if(typeof w=="string"&&z.test(w)){let m=new Date(w);if(!Number.isNaN(m.getTime()))return m}return w})}catch{}else R(n)?n=+n:n==="true"?n=!0:n==="false"?n=!1:n==="null"?n=null:a===34&&d===34&&z.test(n)&&(n=new Date(n.substring(1,n.length-1)));r({...c,data:n})}else r(c)},s),this}removeEventListener(e,r,s){return this.off(e,r,s),this}close(){return this.ws.close(),this}};var ye=["get","post","put","delete","patch","options","head","connect","subscribe"],X=["localhost","127.0.0.1","0.0.0.0"],J=typeof FileList>"u",U=/(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))/,B=/(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)\s(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{2}\s\d{4}\s\d{2}:\d{2}:\d{2}\sGMT(?:\+|-)\d{4}\s\([^)]+\)/,H=/^(?:(?:(?:(?:0?[1-9]|[12][0-9]|3[01])[/\s-](?:0?[1-9]|1[0-2])[/\s-](?:19|20)\d{2})|(?:(?:19|20)\d{2}[/\s-](?:0?[1-9]|1[0-2])[/\s-](?:0?[1-9]|[12][0-9]|3[01]))))(?:\s(?:1[012]|0?[1-9]):[0-5][0-9](?::[0-5][0-9])?(?:\s[AP]M)?)?$/,Q=t=>J?t instanceof Blob:t instanceof FileList||t instanceof File,ue=t=>{if(!t)return!1;for(let e in t)if(Q(t[e])||Array.isArray(t[e])&&t[e].find(Q))return!0;return!1},q=t=>J?t:new Promise(e=>{let r=new FileReader;r.onload=()=>{let s=new File([r.result],t.name,{lastModified:t.lastModified,type:t.type});e(s)},r.readAsArrayBuffer(t)}),M=(t,e,r={},s={})=>{if(Array.isArray(t)){for(let c of t)if(!Array.isArray(c))s=M(c,e,r,s);else{let n=c[0];if(typeof n=="string")s[n.toLowerCase()]=c[1];else for(let[a,d]of n)s[a.toLowerCase()]=d}return s}if(!t)return s;switch(typeof t){case"function":let c=t(e,r);return c?M(c,e,r,s):s;case"object":if(t instanceof Headers)return t.forEach((n,a)=>{s[a.toLowerCase()]=n}),s;for(let[n,a]of Object.entries(t))s[n.toLowerCase()]=a;default:return s}},$=(t,e,r=[],s)=>new Proxy(()=>{},{get(c,n){return $(t,e,n==="index"?r:[...r,n],s)},apply(c,n,[a,d]){if(!a||d||typeof a=="object"&&Object.keys(a).length!==1||ye.includes(r.at(-1))){let W=[...r],w=W.pop(),m="/"+W.join("/"),{fetcher:u=fetch,headers:g,onRequest:b,onResponse:p,fetch:S}=e,v=w==="get"||w==="head"||w==="subscribe";g=M(g,m,d);let K=v?a?.query:d?.query,k="";if(K){let o=(L,T)=>{k+=(k?"&":"?")+`${encodeURIComponent(L)}=${encodeURIComponent(T)}`};for(let[L,T]of Object.entries(K)){if(Array.isArray(T)){for(let f of T)o(L,f);continue}o(L,`${T}`)}}if(w==="subscribe"){let o=t.replace(/^([^]+):\/\//,t.startsWith("https://")?"wss://":t.startsWith("http://")||X.find(L=>t.includes(L))?"ws://":"wss://")+m+k;return new D(o)}return(async()=>{let o={method:w?.toUpperCase(),body:a,...S,headers:g};o.headers={...g,...M(v?a?.headers:d?.headers,m,o)};let L=v&&typeof a=="object"?a.fetch:d?.fetch;if(o={...o,...L},v&&delete o.body,b){Array.isArray(b)||(b=[b]);for(let h of b){let i=await h(m,o);typeof i=="object"&&(o={...o,...i,headers:{...o.headers,...M(i.headers,m,o)}})}}if(v&&delete o.body,ue(a)){let h=new FormData;for(let[i,l]of Object.entries(o.body)){if(J){h.append(i,l);continue}if(l instanceof File){h.append(i,await q(l));continue}if(l instanceof FileList){for(let y=0;y<l.length;y++)h.append(i,await q(l[y]));continue}if(Array.isArray(l)){for(let y=0;y<l.length;y++){let x=l[y];h.append(i,x instanceof File?await q(x):x)}continue}h.append(i,l)}o.body=h}else typeof a=="object"?(o.headers["content-type"]="application/json",o.body=JSON.stringify(a)):a!=null&&(o.headers["content-type"]="text/plain");if(v&&delete o.body,b){Array.isArray(b)||(b=[b]);for(let h of b){let i=await h(m,o);typeof i=="object"&&(o={...o,...i,headers:{...o.headers,...i.headers}})}}let T=t+m+k,f=await(s?.handle(new Request(T,o))??u(T,o)),A=null,E=null;if(p){Array.isArray(p)||(p=[p]);for(let h of p)try{let i=await h(f.clone());if(i!=null){A=i;break}}catch(i){i instanceof O?E=i:E=new O(422,i);break}}if(A===null){switch(f.headers.get("Content-Type")?.split(";")[0]){case"application/json":A=await f.json();break;case"application/octet-stream":A=await f.arrayBuffer();break;case"multipart/form-data":let h=await f.formData();A={},h.forEach((i,l)=>{A[l]=i});break;default:A=await f.text().then(i=>{if(R(i))return+i;if(i==="true")return!0;if(i==="false")return!1;if(!i)return i;let l=i.replace(/"/g,"");if(U.test(l)||B.test(l)||H.test(l)){let y=new Date(l);if(!Number.isNaN(y.getTime()))return y}return i})}(f.status>=300||f.status<200)&&(E=new O(f.status,A),A=null)}return{data:A,error:E,response:f,status:f.status,headers:f.headers}})()}return typeof a=="object"?$(t,e,[...r,Object.values(a)[0]],s):$(t,e,r)}}),Y=(t,e={})=>typeof t=="string"?(e.keepDomain||(t.includes("://")||(t=(X.find(r=>t.includes(r))?"http://":"https://")+t),t.endsWith("/")&&(t=t.slice(0,-1))),$(t,e)):(typeof window<"u"&&console.warn("Elysia instance server found on client side, this is not recommended for security reason. Use generic type instead."),$("http://e.ly",e,[],t));var Z=typeof FileList>"u",ee=t=>Z?t instanceof Blob:t instanceof FileList||t instanceof File,le=t=>{if(!t)return!1;for(let e in t){if(ee(t[e]))return!0;if(Array.isArray(t[e])&&t[e].find(r=>ee(r)))return!0}return!1},_=t=>Z?t:new Promise(e=>{let r=new FileReader;r.onload=()=>{let s=new File([r.result],t.name,{lastModified:t.lastModified,type:t.type});e(s)},r.readAsArrayBuffer(t)}),G=class{ws;url;constructor(e){this.ws=new WebSocket(e),this.url=e}send(e){return Array.isArray(e)?(e.forEach(r=>this.send(r)),this):(this.ws.send(typeof e=="object"?JSON.stringify(e):e.toString()),this)}on(e,r,s){return this.addEventListener(e,r,s)}off(e,r,s){return this.ws.removeEventListener(e,r,s),this}subscribe(e,r){return this.addEventListener("message",e,r)}addEventListener(e,r,s){return this.ws.addEventListener(e,c=>{if(e==="message"){let n=c.data.toString(),a=n.charCodeAt(0);if(a===47||a===123)try{n=JSON.parse(n)}catch{}else R(n)?n=+n:n==="true"?n=!0:n==="false"&&(n=!1);r({...c,data:n})}else r(c)},s),this}removeEventListener(e,r,s){return this.off(e,r,s),this}close(){return this.ws.close(),this}},te=(t,e="",r)=>new Proxy(()=>{},{get(s,c,n){return te(t,`${e}/${c.toString()}`,r)},apply(s,c,[n,a={}]=[{},{}]){let d=n!==void 0&&(typeof n!="object"||Array.isArray(n))?n:void 0,{$query:W,$fetch:w,$headers:m,$transform:u,getRaw:g,...b}=n??{};d??=b;let p=e.lastIndexOf("/"),S=e.slice(p+1).toUpperCase(),v=V(t,p===-1?"/":e.slice(0,p),Object.assign(a.query??{},W)),K=r.fetcher??fetch,k=r.transform?Array.isArray(r.transform)?r.transform:[r.transform]:void 0,o=u?Array.isArray(u)?u:[u]:void 0;return o&&(k?k=o.concat(k):k=o),S==="SUBSCRIBE"?new G(v.replace(/^([^]+):\/\//,v.startsWith("https://")?"wss://":"ws://")):(async T=>{let f,A={...r.$fetch?.headers,...w?.headers,...a.headers,...m};if(S!=="GET"&&S!=="HEAD"){f=Object.keys(d).length||Array.isArray(d)?d:void 0;let y=f&&(typeof f=="object"||Array.isArray(d));if(y&&le(f)){let j=new FormData;for(let[C,F]of Object.entries(f))if(Z)j.append(C,F);else if(F instanceof File)j.append(C,await _(F));else if(F instanceof FileList)for(let N=0;N<F.length;N++)j.append(C,await _(F[N]));else if(Array.isArray(F))for(let N=0;N<F.length;N++){let I=F[N];j.append(C,I instanceof File?await _(I):I)}else j.append(C,F);f=j}else f!=null&&(A["content-type"]=y?"application/json":"text/plain",f=y?JSON.stringify(f):d)}let E=await K(v,{method:S,body:f,...r.$fetch,...a.fetch,...w,headers:A}),h;if(T.getRaw)return E;switch(E.headers.get("Content-Type")?.split(";")[0]){case"application/json":h=await E.json();break;default:h=await E.text().then(y=>R(y)?+y:y==="true"?!0:y==="false"?!1:y)}let i=E.status>=300||E.status<200?new O(E.status,h):null,l={data:h,error:i,response:E,status:E.status,headers:E.headers};if(k)for(let y of k){let x=y(l);x instanceof Promise&&(x=await x),x!=null&&(l=x)}return l})({getRaw:g})}}),re=(t,e={fetcher:fetch})=>new Proxy({},{get(r,s){return te(t,s,e)}});var ne=(t,e)=>(r,{query:s,params:c,body:n,...a}={})=>{c&&Object.entries(c).forEach(([u,g])=>{r=r.replace(`:${u}`,g)});let d=a.headers?.["Content-Type"];if(!d||d==="application/json")try{n=JSON.stringify(n)}catch{}let W=e?.fetcher||globalThis.fetch,w=s?`?${new URLSearchParams(s).toString()}`:"",m=()=>W(t+r+w,{...a,method:a.method?.toUpperCase()||"GET",headers:n?{"content-type":"application/json",...a.headers}:a.headers,body:n}).then(async u=>{let g;switch(u.headers.get("Content-Type")?.split(";")[0]){case"application/json":g=await u.json();break;case"application/octet-stream":g=await u.arrayBuffer();break;case"multipart/form-data":let b=await u.formData();g={},b.forEach((p,S)=>{g[S]=p});break;default:g=await u.text().then(p=>{if(R(p))return+p;if(p==="true")return!0;if(p==="false")return!1;if(!p)return p;let S=p.replace(/"/g,"");if(U.test(S)||B.test(S)||H.test(S)){let v=new Date(S);if(!Number.isNaN(v.getTime()))return v}return p})}return u.status>300?{data:null,status:u.status,headers:u.headers,retry:m,error:new O(u.status,g)}:{data:g,error:null,status:u.status,headers:u.headers,retry:m}});return m()};0&&(module.exports={edenFetch,edenTreaty,treaty}); |
import type { Elysia } from 'elysia'; | ||
import type { Treaty } from './types'; | ||
export declare const isISO8601: RegExp; | ||
export declare const isFormalDate: RegExp; | ||
export declare const isShortenDate: RegExp; | ||
export declare const treaty: <const App extends Elysia<any, any, any, any, any, any, any, any>>(domain: string | App, config?: Treaty.Config) => Treaty.Create<App>; | ||
export type { Treaty }; |
{ | ||
"name": "@elysiajs/eden", | ||
"version": "1.0.13", | ||
"version": "1.0.14", | ||
"description": "Fully type-safe Elysia client", | ||
@@ -57,3 +57,3 @@ "author": { | ||
"peerDependencies": { | ||
"elysia": ">= 1.0.2" | ||
"elysia": ">= 1.0.22" | ||
}, | ||
@@ -64,3 +64,3 @@ "devDependencies": { | ||
"@types/node": "^18.15.5", | ||
"elysia": "^1.0.2", | ||
"elysia": "^1.0.22", | ||
"esbuild": "^0.19.3", | ||
@@ -71,3 +71,3 @@ "eslint": "^8.26.0", | ||
"tsup": "^7.2.0", | ||
"typescript": "^5.3.2" | ||
"typescript": "^5.4.5" | ||
}, | ||
@@ -81,4 +81,4 @@ "prettier": { | ||
"dependencies": { | ||
"@elysiajs/stream": "rc" | ||
"@elysiajs/stream": "^1.0.2" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
92024
788
+ Added@elysiajs/stream@1.1.0(transitive)
- Removed@elysiajs/stream@1.1.0-rc.0(transitive)
- Removedcookie@0.6.0(transitive)
- Removedelysia@1.1.0-rc.2(transitive)
- Removedfast-querystring@1.1.2(transitive)
Updated@elysiajs/stream@^1.0.2