@elysiajs/eden 1.1.1 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-7WO4HTSU.mjs +1 -0
- package/dist/index.global.js +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/treaty2.global.js +1 -1
- package/dist/treaty2.js +1 -1
- package/dist/treaty2.mjs +1 -1
- package/package.json +1 -1
- package/dist/chunk-RPZULI5W.mjs +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as x,b as O,c as M}from"./chunk-XYW4OUFN.mjs";var F=class{constructor(t){this.url=t;this.ws=new WebSocket(t)}ws;send(t){return Array.isArray(t)?(t.forEach(n=>this.send(n)),this):(this.ws.send(typeof t=="object"?JSON.stringify(t):t.toString()),this)}on(t,n,s){return this.addEventListener(t,n,s)}off(t,n,s){return this.ws.removeEventListener(t,n,s),this}subscribe(t,n){return this.addEventListener("message",t,n)}addEventListener(t,n,s){return this.ws.addEventListener(t,c=>{if(t==="message"){let f=M(c);n({...c,data:f})}else n(c)},s),this}removeEventListener(t,n,s){return this.off(t,n,s),this}close(){return this.ws.close(),this}};var N=["get","post","put","delete","patch","options","head","connect","subscribe"],I=["localhost","127.0.0.1","0.0.0.0"],C=typeof FileList>"u",q=e=>C?e instanceof Blob:e instanceof FileList||e instanceof File,P=e=>{if(!e)return!1;for(let t in e)if(q(e[t])||Array.isArray(e[t])&&e[t].find(q))return!0;return!1},j=e=>C?e:new Promise(t=>{let n=new FileReader;n.onload=()=>{let s=new File([n.result],e.name,{lastModified:e.lastModified,type:e.type});t(s)},n.readAsArrayBuffer(e)}),b=(e,t,n={},s={})=>{if(Array.isArray(e)){for(let c of e)if(!Array.isArray(c))s=b(c,t,n,s);else{let f=c[0];if(typeof f=="string")s[f.toLowerCase()]=c[1];else for(let[a,w]of f)s[a.toLowerCase()]=w}return s}if(!e)return s;switch(typeof e){case"function":if(e instanceof Headers)return b(e,t,n,s);let c=e(t,n);return c?b(c,t,n,s):s;case"object":if(e instanceof Headers)return e.forEach((f,a)=>{s[a.toLowerCase()]=f}),s;for(let[f,a]of Object.entries(e))s[f.toLowerCase()]=a;return s;default:return s}};async function*U(e){let t=e.body;if(!t)return;let n=t.getReader(),s=new TextDecoder;try{for(;;){let{done:c,value:f}=await n.read();if(c)break;let a=s.decode(f);yield O(a)}}finally{n.releaseLock()}}var A=(e,t,n=[],s)=>new Proxy(()=>{},{get(c,f){return A(e,t,f==="index"?n:[...n,f],s)},apply(c,f,[a,w]){if(!a||w||typeof a=="object"&&Object.keys(a).length!==1||N.includes(n.at(-1))){let K=[...n],k=K.pop(),g="/"+K.join("/"),{fetcher:D=fetch,headers:L,onRequest:p,onResponse:E,fetch:H}=t,m=k==="get"||k==="head"||k==="subscribe";L=b(L,g,w);let T=m?a?.query:w?.query,R="";if(T){let r=(h,d)=>{R+=(R?"&":"?")+`${encodeURIComponent(h)}=${encodeURIComponent(d)}`};for(let[h,d]of Object.entries(T)){if(Array.isArray(d)){for(let o of d)r(h,o);continue}if(typeof d=="object"){r(h,JSON.stringify(d));continue}r(h,`${d}`)}}if(k==="subscribe"){let r=e.replace(/^([^]+):\/\//,e.startsWith("https://")?"wss://":e.startsWith("http://")||I.find(h=>e.includes(h))?"ws://":"wss://")+g+R;return new F(r)}return(async()=>{let r={method:k?.toUpperCase(),body:a,...H,headers:L};r.headers={...L,...b(m?a?.headers:w?.headers,g,r)};let h=m&&typeof a=="object"?a.fetch:w?.fetch;if(r={...r,...h},m&&delete r.body,p){Array.isArray(p)||(p=[p]);for(let y of p){let i=await y(g,r);typeof i=="object"&&(r={...r,...i,headers:{...r.headers,...b(i.headers,g,r)}})}}if(m&&delete r.body,P(a)){let y=new FormData;for(let[i,u]of Object.entries(r.body)){if(C){y.append(i,u);continue}if(u instanceof File){y.append(i,await j(u));continue}if(u instanceof FileList){for(let v=0;v<u.length;v++)y.append(i,await j(u[v]));continue}if(Array.isArray(u)){for(let v=0;v<u.length;v++){let W=u[v];y.append(i,W instanceof File?await j(W):W)}continue}y.append(i,u)}r.body=y}else typeof a=="object"?(r.headers["content-type"]="application/json",r.body=JSON.stringify(a)):a!=null&&(r.headers["content-type"]="text/plain");if(m&&delete r.body,p){Array.isArray(p)||(p=[p]);for(let y of p){let i=await y(g,r);typeof i=="object"&&(r={...r,...i,headers:{...r.headers,...b(i.headers,g,r)}})}}let d=e+g+R,o=await(s?.handle(new Request(d,r))??D(d,r)),l=null,S=null;if(E){Array.isArray(E)||(E=[E]);for(let y of E)try{let i=await y(o.clone());if(i!=null){l=i;break}}catch(i){i instanceof x?S=i:S=new x(422,i);break}}if(l!==null)return{data:l,error:S,response:o,status:o.status,headers:o.headers};switch(o.headers.get("Content-Type")?.split(";")[0]){case"text/event-stream":l=U(o);break;case"application/json":l=await o.json();break;case"application/octet-stream":l=await o.arrayBuffer();break;case"multipart/form-data":let y=await o.formData();l={},y.forEach((i,u)=>{l[u]=i});break;default:l=await o.text().then(O)}return(o.status>=300||o.status<200)&&(S=new x(o.status,l),l=null),{data:l,error:S,response:o,status:o.status,headers:o.headers}})()}return typeof a=="object"?A(e,t,[...n,Object.values(a)[0]],s):A(e,t,n)}}),V=(e,t={})=>typeof e=="string"?(t.keepDomain||(e.includes("://")||(e=(I.find(n=>e.includes(n))?"http://":"https://")+e),e.endsWith("/")&&(e=e.slice(0,-1))),A(e,t)):(typeof window<"u"&&console.warn("Elysia instance server found on client side, this is not recommended for security reason. Use generic type instead."),A("http://e.ly",t,[],e));export{U as a,V as b};
|
package/dist/index.global.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var Eden=(()=>{var P=Object.defineProperty;var ne=Object.getOwnPropertyDescriptor;var re=Object.getOwnPropertyNames;var se=Object.prototype.hasOwnProperty;var ae=(e,t)=>{for(var n in t)P(e,n,{get:t[n],enumerable:!0})},ie=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of re(t))!se.call(e,s)&&s!==n&&P(e,s,{get:()=>t[s],enumerable:!(r=ne(t,s))||r.enumerable});return e};var oe=e=>ie(P({},"__esModule",{value:!0}),e);var be={};ae(be,{edenFetch:()=>te,edenTreaty:()=>ee,treaty:()=>z});var k=class extends Error{constructor(n,r){super(r+"");this.status=n;this.value=r}};var 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\([^)]+\)/,de=/^(?:(?:(?:(?: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)?)?$/,ye=e=>e.trim().length!==0&&!Number.isNaN(Number(e)),_=e=>{if(typeof e!="string")return null;let t=e.replace(/"/g,"");if(ce.test(t)||fe.test(t)||de.test(t)){let n=new Date(t);if(!Number.isNaN(n.getTime()))return n}return null},ue=e=>{let t=e.charCodeAt(0),n=e.charCodeAt(e.length-1);return t===123&&n===125||t===91&&n===93},le=e=>JSON.parse(e,(t,n)=>{let r=_(n);return r||n}),L=e=>{if(!e)return e;if(ye(e))return+e;if(e==="true")return!0;if(e==="false")return!1;let t=_(e);if(t)return t;if(ue(e))try{return le(e)}catch{}return e},D=e=>{let t=e.data.toString();return t==="null"?null:L(t)};var I=class{constructor(t){this.url=t;this.ws=new WebSocket(t)}ws;send(t){return Array.isArray(t)?(t.forEach(n=>this.send(n)),this):(this.ws.send(typeof t=="object"?JSON.stringify(t):t.toString()),this)}on(t,n,r){return this.addEventListener(t,n,r)}off(t,n,r){return this.ws.removeEventListener(t,n,r),this}subscribe(t,n){return this.addEventListener("message",t,n)}addEventListener(t,n,r){return this.ws.addEventListener(t,s=>{if(t==="message"){let a=D(s);n({...s,data:a})}else n(s)},r),this}removeEventListener(t,n,r){return this.off(t,n,r),this}close(){return this.ws.close(),this}};var pe=["get","post","put","delete","patch","options","head","connect","subscribe"],Z=["localhost","127.0.0.1","0.0.0.0"],U=typeof FileList>"u",G=e=>U?e instanceof Blob:e instanceof FileList||e instanceof File,he=e=>{if(!e)return!1;for(let t in e)if(G(e[t])||Array.isArray(e[t])&&e[t].find(G))return!0;return!1},J=e=>U?e:new Promise(t=>{let n=new FileReader;n.onload=()=>{let r=new File([n.result],e.name,{lastModified:e.lastModified,type:e.type});t(r)},n.readAsArrayBuffer(e)}),j=(e,t,n={},r={})=>{if(Array.isArray(e)){for(let s of e)if(!Array.isArray(s))r=j(s,t,n,r);else{let a=s[0];if(typeof a=="string")r[a.toLowerCase()]=s[1];else for(let[i,y]of a)r[i.toLowerCase()]=y}return r}if(!e)return r;switch(typeof e){case"function":if(e instanceof Headers)return j(e,t,n,r);let s=e(t,n);return s?j(s,t,n,r):r;case"object":if(e instanceof Headers)return e.forEach((a,i)=>{r[i.toLowerCase()]=a}),r;for(let[a,i]of Object.entries(e))r[a.toLowerCase()]=i;return r;default:return r}};async function*ge(e){let t=e.body;if(!t)return;let n=t.getReader(),r=new TextDecoder;try{for(;;){let{done:s,value:a}=await n.read();if(s)break;let i=r.decode(a);yield L(i)}}finally{n.releaseLock()}}var K=(e,t,n=[],r)=>new Proxy(()=>{},{get(s,a){return K(e,t,a==="index"?n:[...n,a],r)},apply(s,a,[i,y]){if(!i||y||typeof i=="object"&&Object.keys(i).length!==1||pe.includes(n.at(-1))){let M=[...n],S=M.pop(),E="/"+M.join("/"),{fetcher:F=fetch,headers:R,onRequest:p,onResponse:g,fetch:O}=t,v=S==="get"||S==="head"||S==="subscribe";R=j(R,E,y);let N=v?i?.query:y?.query,w="";if(N){let o=(T,x)=>{w+=(w?"&":"?")+`${encodeURIComponent(T)}=${encodeURIComponent(x)}`};for(let[T,x]of Object.entries(N)){if(Array.isArray(x)){for(let c of x)o(T,c);continue}o(T,`${x}`)}}if(S==="subscribe"){let o=e.replace(/^([^]+):\/\//,e.startsWith("https://")?"wss://":e.startsWith("http://")||Z.find(T=>e.includes(T))?"ws://":"wss://")+E+w;return new I(o)}return(async()=>{let o={method:S?.toUpperCase(),body:i,...O,headers:R};o.headers={...R,...j(v?i?.headers:y?.headers,E,o)};let T=v&&typeof i=="object"?i.fetch:y?.fetch;if(o={...o,...T},v&&delete o.body,p){Array.isArray(p)||(p=[p]);for(let d of p){let f=await d(E,o);typeof f=="object"&&(o={...o,...f,headers:{...o.headers,...j(f.headers,E,o)}})}}if(v&&delete o.body,he(i)){let d=new FormData;for(let[f,l]of Object.entries(o.body)){if(U){d.append(f,l);continue}if(l instanceof File){d.append(f,await J(l));continue}if(l instanceof FileList){for(let m=0;m<l.length;m++)d.append(f,await J(l[m]));continue}if(Array.isArray(l)){for(let m=0;m<l.length;m++){let b=l[m];d.append(f,b instanceof File?await J(b):b)}continue}d.append(f,l)}o.body=d}else typeof i=="object"?(o.headers["content-type"]="application/json",o.body=JSON.stringify(i)):i!=null&&(o.headers["content-type"]="text/plain");if(v&&delete o.body,p){Array.isArray(p)||(p=[p]);for(let d of p){let f=await d(E,o);typeof f=="object"&&(o={...o,...f,headers:{...o.headers,...j(f.headers,E,o)}})}}let x=e+E+w,c=await(r?.handle(new Request(x,o))??F(x,o)),h=null,u=null;if(g){Array.isArray(g)||(g=[g]);for(let d of g)try{let f=await d(c.clone());if(f!=null){h=f;break}}catch(f){f instanceof k?u=f:u=new k(422,f);break}}if(h!==null)return{data:h,error:u,response:c,status:c.status,headers:c.headers};switch(c.headers.get("Content-Type")?.split(";")[0]){case"text/event-stream":h=ge(c);break;case"application/json":h=await c.json();break;case"application/octet-stream":h=await c.arrayBuffer();break;case"multipart/form-data":let d=await c.formData();h={},d.forEach((f,l)=>{h[l]=f});break;default:h=await c.text().then(L)}return(c.status>=300||c.status<200)&&(u=new k(c.status,h),h=null),{data:h,error:u,response:c,status:c.status,headers:c.headers}})()}return typeof i=="object"?K(e,t,[...n,Object.values(i)[0]],r):K(e,t,n)}}),z=(e,t={})=>typeof e=="string"?(t.keepDomain||(e.includes("://")||(e=(Z.find(n=>e.includes(n))?"http://":"https://")+e),e.endsWith("/")&&(e=e.slice(0,-1))),K(e,t)):(typeof window<"u"&&console.warn("Elysia instance server found on client side, this is not recommended for security reason. Use generic type instead."),K("http://e.ly",t,[],e));var Q=(e,t,n)=>{if(e.endsWith("/")||(e+="/"),t==="index"&&(t=""),!n||!Object.keys(n).length)return`${e}${t}`;let r="";for(let[s,a]of Object.entries(n))r+=`${s}=${a}&`;return`${e}${t}?${r.slice(0,-1)}`};var V=typeof FileList>"u",X=e=>V?e instanceof Blob:e instanceof FileList||e instanceof File,me=e=>{if(!e)return!1;for(let t in e){if(X(e[t]))return!0;if(Array.isArray(e[t])&&e[t].find(n=>X(n)))return!0}return!1},B=e=>V?e:new Promise(t=>{let n=new FileReader;n.onload=()=>{let r=new File([n.result],e.name,{lastModified:e.lastModified,type:e.type});t(r)},n.readAsArrayBuffer(e)}),H=class{ws;url;constructor(t){this.ws=new WebSocket(t),this.url=t}send(t){return Array.isArray(t)?(t.forEach(n=>this.send(n)),this):(this.ws.send(typeof t=="object"?JSON.stringify(t):t.toString()),this)}on(t,n,r){return this.addEventListener(t,n,r)}off(t,n,r){return this.ws.removeEventListener(t,n,r),this}subscribe(t,n){return this.addEventListener("message",t,n)}addEventListener(t,n,r){return this.ws.addEventListener(t,s=>{if(t==="message"){let a=D(s);n({...s,data:a})}else n(s)},r),this}removeEventListener(t,n,r){return this.off(t,n,r),this}close(){return this.ws.close(),this}},Y=(e,t="",n)=>new Proxy(()=>{},{get(r,s,a){return Y(e,`${t}/${s.toString()}`,n)},apply(r,s,[a,i={}]=[{},{}]){let y=a!==void 0&&(typeof a!="object"||Array.isArray(a))?a:void 0,{$query:M,$fetch:S,$headers:E,$transform:F,getRaw:R,...p}=a??{};y??=p;let g=t.lastIndexOf("/"),O=t.slice(g+1).toUpperCase(),v=Q(e,g===-1?"/":t.slice(0,g),Object.assign(i.query??{},M)),N=n.fetcher??fetch,w=n.transform?Array.isArray(n.transform)?n.transform:[n.transform]:void 0,o=F?Array.isArray(F)?F:[F]:void 0;return o&&(w?w=o.concat(w):w=o),O==="SUBSCRIBE"?new H(v.replace(/^([^]+):\/\//,v.startsWith("https://")?"wss://":"ws://")):(async x=>{let c,h={...n.$fetch?.headers,...S?.headers,...i.headers,...E};if(O!=="GET"&&O!=="HEAD"){c=Object.keys(y).length||Array.isArray(y)?y:void 0;let m=c&&(typeof c=="object"||Array.isArray(y));if(m&&me(c)){let $=new FormData;for(let[C,A]of Object.entries(c))if(V)$.append(C,A);else if(A instanceof File)$.append(C,await B(A));else if(A instanceof FileList)for(let W=0;W<A.length;W++)$.append(C,await B(A[W]));else if(Array.isArray(A))for(let W=0;W<A.length;W++){let q=A[W];$.append(C,q instanceof File?await B(q):q)}else $.append(C,A);c=$}else c!=null&&(h["content-type"]=m?"application/json":"text/plain",c=m?JSON.stringify(c):y)}let u=await N(v,{method:O,body:c,...n.$fetch,...i.fetch,...S,headers:h}),d;if(x.getRaw)return u;switch(u.headers.get("Content-Type")?.split(";")[0]){case"application/json":d=await u.json();break;default:d=await u.text().then(L)}let f=u.status>=300||u.status<200?new k(u.status,d):null,l={data:d,error:f,response:u,status:u.status,headers:u.headers};if(w)for(let m of w){let b=m(l);b instanceof Promise&&(b=await b),b!=null&&(l=b)}return l})({getRaw:R})}}),ee=(e,t={fetcher:fetch})=>new Proxy({},{get(n,r){return Y(e,r,t)}});var Ee=async e=>{switch(e.headers.get("Content-Type")?.split(";")[0]){case"application/json":return e.json();case"application/octet-stream":return e.arrayBuffer();case"multipart/form-data":{let n=await e.formData(),r={};return n.forEach((s,a)=>{r[a]=s}),r}}return e.text().then(L)},we=async(e,t)=>{let n=await Ee(e);return e.status>300?{data:null,status:e.status,headers:e.headers,retry:t,error:new k(e.status,n)}:{data:n,error:null,status:e.status,headers:e.headers,retry:t}},te=(e,t)=>(n,{query:r,params:s,body:a,...i}={})=>{s&&Object.entries(s).forEach(([g,O])=>{n=n.replace(`:${g}`,O)});let y=i.headers?.["Content-Type"];if(!y||y==="application/json")try{a=JSON.stringify(a)}catch{}let M=t?.fetcher||globalThis.fetch,S=r?`?${new URLSearchParams(r).toString()}`:"",E=`${e}${n}${S}`,F=a?{"content-type":"application/json",...i.headers}:i.headers,R={...i,method:i.method?.toUpperCase()||"GET",headers:F,body:a},p=()=>M(E,R).then(g=>we(g,p));return p()};return oe(be);})();
|
|
1
|
+
"use strict";var Eden=(()=>{var P=Object.defineProperty;var ne=Object.getOwnPropertyDescriptor;var re=Object.getOwnPropertyNames;var se=Object.prototype.hasOwnProperty;var ae=(e,t)=>{for(var n in t)P(e,n,{get:t[n],enumerable:!0})},ie=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of re(t))!se.call(e,s)&&s!==n&&P(e,s,{get:()=>t[s],enumerable:!(r=ne(t,s))||r.enumerable});return e};var oe=e=>ie(P({},"__esModule",{value:!0}),e);var be={};ae(be,{edenFetch:()=>te,edenTreaty:()=>ee,treaty:()=>z});var T=class extends Error{constructor(n,r){super(r+"");this.status=n;this.value=r}};var 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\([^)]+\)/,de=/^(?:(?:(?:(?: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)?)?$/,ye=e=>e.trim().length!==0&&!Number.isNaN(Number(e)),_=e=>{if(typeof e!="string")return null;let t=e.replace(/"/g,"");if(ce.test(t)||fe.test(t)||de.test(t)){let n=new Date(t);if(!Number.isNaN(n.getTime()))return n}return null},ue=e=>{let t=e.charCodeAt(0),n=e.charCodeAt(e.length-1);return t===123&&n===125||t===91&&n===93},pe=e=>JSON.parse(e,(t,n)=>{let r=_(n);return r||n}),L=e=>{if(!e)return e;if(ye(e))return+e;if(e==="true")return!0;if(e==="false")return!1;let t=_(e);if(t)return t;if(ue(e))try{return pe(e)}catch{}return e},D=e=>{let t=e.data.toString();return t==="null"?null:L(t)};var I=class{constructor(t){this.url=t;this.ws=new WebSocket(t)}ws;send(t){return Array.isArray(t)?(t.forEach(n=>this.send(n)),this):(this.ws.send(typeof t=="object"?JSON.stringify(t):t.toString()),this)}on(t,n,r){return this.addEventListener(t,n,r)}off(t,n,r){return this.ws.removeEventListener(t,n,r),this}subscribe(t,n){return this.addEventListener("message",t,n)}addEventListener(t,n,r){return this.ws.addEventListener(t,s=>{if(t==="message"){let i=D(s);n({...s,data:i})}else n(s)},r),this}removeEventListener(t,n,r){return this.off(t,n,r),this}close(){return this.ws.close(),this}};var le=["get","post","put","delete","patch","options","head","connect","subscribe"],Z=["localhost","127.0.0.1","0.0.0.0"],U=typeof FileList>"u",G=e=>U?e instanceof Blob:e instanceof FileList||e instanceof File,he=e=>{if(!e)return!1;for(let t in e)if(G(e[t])||Array.isArray(e[t])&&e[t].find(G))return!0;return!1},J=e=>U?e:new Promise(t=>{let n=new FileReader;n.onload=()=>{let r=new File([n.result],e.name,{lastModified:e.lastModified,type:e.type});t(r)},n.readAsArrayBuffer(e)}),j=(e,t,n={},r={})=>{if(Array.isArray(e)){for(let s of e)if(!Array.isArray(s))r=j(s,t,n,r);else{let i=s[0];if(typeof i=="string")r[i.toLowerCase()]=s[1];else for(let[o,y]of i)r[o.toLowerCase()]=y}return r}if(!e)return r;switch(typeof e){case"function":if(e instanceof Headers)return j(e,t,n,r);let s=e(t,n);return s?j(s,t,n,r):r;case"object":if(e instanceof Headers)return e.forEach((i,o)=>{r[o.toLowerCase()]=i}),r;for(let[i,o]of Object.entries(e))r[i.toLowerCase()]=o;return r;default:return r}};async function*ge(e){let t=e.body;if(!t)return;let n=t.getReader(),r=new TextDecoder;try{for(;;){let{done:s,value:i}=await n.read();if(s)break;let o=r.decode(i);yield L(o)}}finally{n.releaseLock()}}var K=(e,t,n=[],r)=>new Proxy(()=>{},{get(s,i){return K(e,t,i==="index"?n:[...n,i],r)},apply(s,i,[o,y]){if(!o||y||typeof o=="object"&&Object.keys(o).length!==1||le.includes(n.at(-1))){let M=[...n],v=M.pop(),E="/"+M.join("/"),{fetcher:F=fetch,headers:R,onRequest:l,onResponse:g,fetch:O}=t,x=v==="get"||v==="head"||v==="subscribe";R=j(R,E,y);let N=x?o?.query:y?.query,b="";if(N){let a=(A,w)=>{b+=(b?"&":"?")+`${encodeURIComponent(A)}=${encodeURIComponent(w)}`};for(let[A,w]of Object.entries(N)){if(Array.isArray(w)){for(let c of w)a(A,c);continue}if(typeof w=="object"){a(A,JSON.stringify(w));continue}a(A,`${w}`)}}if(v==="subscribe"){let a=e.replace(/^([^]+):\/\//,e.startsWith("https://")?"wss://":e.startsWith("http://")||Z.find(A=>e.includes(A))?"ws://":"wss://")+E+b;return new I(a)}return(async()=>{let a={method:v?.toUpperCase(),body:o,...O,headers:R};a.headers={...R,...j(x?o?.headers:y?.headers,E,a)};let A=x&&typeof o=="object"?o.fetch:y?.fetch;if(a={...a,...A},x&&delete a.body,l){Array.isArray(l)||(l=[l]);for(let d of l){let f=await d(E,a);typeof f=="object"&&(a={...a,...f,headers:{...a.headers,...j(f.headers,E,a)}})}}if(x&&delete a.body,he(o)){let d=new FormData;for(let[f,p]of Object.entries(a.body)){if(U){d.append(f,p);continue}if(p instanceof File){d.append(f,await J(p));continue}if(p instanceof FileList){for(let m=0;m<p.length;m++)d.append(f,await J(p[m]));continue}if(Array.isArray(p)){for(let m=0;m<p.length;m++){let S=p[m];d.append(f,S instanceof File?await J(S):S)}continue}d.append(f,p)}a.body=d}else typeof o=="object"?(a.headers["content-type"]="application/json",a.body=JSON.stringify(o)):o!=null&&(a.headers["content-type"]="text/plain");if(x&&delete a.body,l){Array.isArray(l)||(l=[l]);for(let d of l){let f=await d(E,a);typeof f=="object"&&(a={...a,...f,headers:{...a.headers,...j(f.headers,E,a)}})}}let w=e+E+b,c=await(r?.handle(new Request(w,a))??F(w,a)),h=null,u=null;if(g){Array.isArray(g)||(g=[g]);for(let d of g)try{let f=await d(c.clone());if(f!=null){h=f;break}}catch(f){f instanceof T?u=f:u=new T(422,f);break}}if(h!==null)return{data:h,error:u,response:c,status:c.status,headers:c.headers};switch(c.headers.get("Content-Type")?.split(";")[0]){case"text/event-stream":h=ge(c);break;case"application/json":h=await c.json();break;case"application/octet-stream":h=await c.arrayBuffer();break;case"multipart/form-data":let d=await c.formData();h={},d.forEach((f,p)=>{h[p]=f});break;default:h=await c.text().then(L)}return(c.status>=300||c.status<200)&&(u=new T(c.status,h),h=null),{data:h,error:u,response:c,status:c.status,headers:c.headers}})()}return typeof o=="object"?K(e,t,[...n,Object.values(o)[0]],r):K(e,t,n)}}),z=(e,t={})=>typeof e=="string"?(t.keepDomain||(e.includes("://")||(e=(Z.find(n=>e.includes(n))?"http://":"https://")+e),e.endsWith("/")&&(e=e.slice(0,-1))),K(e,t)):(typeof window<"u"&&console.warn("Elysia instance server found on client side, this is not recommended for security reason. Use generic type instead."),K("http://e.ly",t,[],e));var Q=(e,t,n)=>{if(e.endsWith("/")||(e+="/"),t==="index"&&(t=""),!n||!Object.keys(n).length)return`${e}${t}`;let r="";for(let[s,i]of Object.entries(n))r+=`${s}=${i}&`;return`${e}${t}?${r.slice(0,-1)}`};var V=typeof FileList>"u",X=e=>V?e instanceof Blob:e instanceof FileList||e instanceof File,me=e=>{if(!e)return!1;for(let t in e){if(X(e[t]))return!0;if(Array.isArray(e[t])&&e[t].find(n=>X(n)))return!0}return!1},B=e=>V?e:new Promise(t=>{let n=new FileReader;n.onload=()=>{let r=new File([n.result],e.name,{lastModified:e.lastModified,type:e.type});t(r)},n.readAsArrayBuffer(e)}),H=class{ws;url;constructor(t){this.ws=new WebSocket(t),this.url=t}send(t){return Array.isArray(t)?(t.forEach(n=>this.send(n)),this):(this.ws.send(typeof t=="object"?JSON.stringify(t):t.toString()),this)}on(t,n,r){return this.addEventListener(t,n,r)}off(t,n,r){return this.ws.removeEventListener(t,n,r),this}subscribe(t,n){return this.addEventListener("message",t,n)}addEventListener(t,n,r){return this.ws.addEventListener(t,s=>{if(t==="message"){let i=D(s);n({...s,data:i})}else n(s)},r),this}removeEventListener(t,n,r){return this.off(t,n,r),this}close(){return this.ws.close(),this}},Y=(e,t="",n)=>new Proxy(()=>{},{get(r,s,i){return Y(e,`${t}/${s.toString()}`,n)},apply(r,s,[i,o={}]=[{},{}]){let y=i!==void 0&&(typeof i!="object"||Array.isArray(i))?i:void 0,{$query:M,$fetch:v,$headers:E,$transform:F,getRaw:R,...l}=i??{};y??=l;let g=t.lastIndexOf("/"),O=t.slice(g+1).toUpperCase(),x=Q(e,g===-1?"/":t.slice(0,g),Object.assign(o.query??{},M)),N=n.fetcher??fetch,b=n.transform?Array.isArray(n.transform)?n.transform:[n.transform]:void 0,a=F?Array.isArray(F)?F:[F]:void 0;return a&&(b?b=a.concat(b):b=a),O==="SUBSCRIBE"?new H(x.replace(/^([^]+):\/\//,x.startsWith("https://")?"wss://":"ws://")):(async w=>{let c,h={...n.$fetch?.headers,...v?.headers,...o.headers,...E};if(O!=="GET"&&O!=="HEAD"){c=Object.keys(y).length||Array.isArray(y)?y:void 0;let m=c&&(typeof c=="object"||Array.isArray(y));if(m&&me(c)){let $=new FormData;for(let[C,k]of Object.entries(c))if(V)$.append(C,k);else if(k instanceof File)$.append(C,await B(k));else if(k instanceof FileList)for(let W=0;W<k.length;W++)$.append(C,await B(k[W]));else if(Array.isArray(k))for(let W=0;W<k.length;W++){let q=k[W];$.append(C,q instanceof File?await B(q):q)}else $.append(C,k);c=$}else c!=null&&(h["content-type"]=m?"application/json":"text/plain",c=m?JSON.stringify(c):y)}let u=await N(x,{method:O,body:c,...n.$fetch,...o.fetch,...v,headers:h}),d;if(w.getRaw)return u;switch(u.headers.get("Content-Type")?.split(";")[0]){case"application/json":d=await u.json();break;default:d=await u.text().then(L)}let f=u.status>=300||u.status<200?new T(u.status,d):null,p={data:d,error:f,response:u,status:u.status,headers:u.headers};if(b)for(let m of b){let S=m(p);S instanceof Promise&&(S=await S),S!=null&&(p=S)}return p})({getRaw:R})}}),ee=(e,t={fetcher:fetch})=>new Proxy({},{get(n,r){return Y(e,r,t)}});var Ee=async e=>{switch(e.headers.get("Content-Type")?.split(";")[0]){case"application/json":return e.json();case"application/octet-stream":return e.arrayBuffer();case"multipart/form-data":{let n=await e.formData(),r={};return n.forEach((s,i)=>{r[i]=s}),r}}return e.text().then(L)},we=async(e,t)=>{let n=await Ee(e);return e.status>300?{data:null,status:e.status,headers:e.headers,retry:t,error:new T(e.status,n)}:{data:n,error:null,status:e.status,headers:e.headers,retry:t}},te=(e,t)=>(n,{query:r,params:s,body:i,...o}={})=>{s&&Object.entries(s).forEach(([g,O])=>{n=n.replace(`:${g}`,O)});let y=o.headers?.["Content-Type"];if(!y||y==="application/json")try{i=JSON.stringify(i)}catch{}let M=t?.fetcher||globalThis.fetch,v=r?`?${new URLSearchParams(r).toString()}`:"",E=`${e}${n}${v}`,F=i?{"content-type":"application/json",...o.headers}:o.headers,R={...o,method:o.method?.toUpperCase()||"GET",headers:F,body:i},l=()=>M(E,R).then(g=>we(g,l));return l()};return oe(be);})();
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var P=Object.defineProperty;var ne=Object.getOwnPropertyDescriptor;var re=Object.getOwnPropertyNames;var se=Object.prototype.hasOwnProperty;var ae=(e,t)=>{for(var n in t)P(e,n,{get:t[n],enumerable:!0})},ie=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of re(t))!se.call(e,s)&&s!==n&&P(e,s,{get:()=>t[s],enumerable:!(r=ne(t,s))||r.enumerable});return e};var oe=e=>ie(P({},"__esModule",{value:!0}),e);var be={};ae(be,{edenFetch:()=>te,edenTreaty:()=>ee,treaty:()=>z});module.exports=oe(be);var k=class extends Error{constructor(n,r){super(r+"");this.status=n;this.value=r}};var 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\([^)]+\)/,de=/^(?:(?:(?:(?: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)?)?$/,ye=e=>e.trim().length!==0&&!Number.isNaN(Number(e)),_=e=>{if(typeof e!="string")return null;let t=e.replace(/"/g,"");if(ce.test(t)||fe.test(t)||de.test(t)){let n=new Date(t);if(!Number.isNaN(n.getTime()))return n}return null},ue=e=>{let t=e.charCodeAt(0),n=e.charCodeAt(e.length-1);return t===123&&n===125||t===91&&n===93},le=e=>JSON.parse(e,(t,n)=>{let r=_(n);return r||n}),L=e=>{if(!e)return e;if(ye(e))return+e;if(e==="true")return!0;if(e==="false")return!1;let t=_(e);if(t)return t;if(ue(e))try{return le(e)}catch{}return e},D=e=>{let t=e.data.toString();return t==="null"?null:L(t)};var I=class{constructor(t){this.url=t;this.ws=new WebSocket(t)}ws;send(t){return Array.isArray(t)?(t.forEach(n=>this.send(n)),this):(this.ws.send(typeof t=="object"?JSON.stringify(t):t.toString()),this)}on(t,n,r){return this.addEventListener(t,n,r)}off(t,n,r){return this.ws.removeEventListener(t,n,r),this}subscribe(t,n){return this.addEventListener("message",t,n)}addEventListener(t,n,r){return this.ws.addEventListener(t,s=>{if(t==="message"){let a=D(s);n({...s,data:a})}else n(s)},r),this}removeEventListener(t,n,r){return this.off(t,n,r),this}close(){return this.ws.close(),this}};var pe=["get","post","put","delete","patch","options","head","connect","subscribe"],Z=["localhost","127.0.0.1","0.0.0.0"],U=typeof FileList>"u",G=e=>U?e instanceof Blob:e instanceof FileList||e instanceof File,he=e=>{if(!e)return!1;for(let t in e)if(G(e[t])||Array.isArray(e[t])&&e[t].find(G))return!0;return!1},J=e=>U?e:new Promise(t=>{let n=new FileReader;n.onload=()=>{let r=new File([n.result],e.name,{lastModified:e.lastModified,type:e.type});t(r)},n.readAsArrayBuffer(e)}),j=(e,t,n={},r={})=>{if(Array.isArray(e)){for(let s of e)if(!Array.isArray(s))r=j(s,t,n,r);else{let a=s[0];if(typeof a=="string")r[a.toLowerCase()]=s[1];else for(let[i,y]of a)r[i.toLowerCase()]=y}return r}if(!e)return r;switch(typeof e){case"function":if(e instanceof Headers)return j(e,t,n,r);let s=e(t,n);return s?j(s,t,n,r):r;case"object":if(e instanceof Headers)return e.forEach((a,i)=>{r[i.toLowerCase()]=a}),r;for(let[a,i]of Object.entries(e))r[a.toLowerCase()]=i;return r;default:return r}};async function*ge(e){let t=e.body;if(!t)return;let n=t.getReader(),r=new TextDecoder;try{for(;;){let{done:s,value:a}=await n.read();if(s)break;let i=r.decode(a);yield L(i)}}finally{n.releaseLock()}}var K=(e,t,n=[],r)=>new Proxy(()=>{},{get(s,a){return K(e,t,a==="index"?n:[...n,a],r)},apply(s,a,[i,y]){if(!i||y||typeof i=="object"&&Object.keys(i).length!==1||pe.includes(n.at(-1))){let M=[...n],S=M.pop(),E="/"+M.join("/"),{fetcher:F=fetch,headers:R,onRequest:p,onResponse:g,fetch:O}=t,v=S==="get"||S==="head"||S==="subscribe";R=j(R,E,y);let N=v?i?.query:y?.query,w="";if(N){let o=(T,x)=>{w+=(w?"&":"?")+`${encodeURIComponent(T)}=${encodeURIComponent(x)}`};for(let[T,x]of Object.entries(N)){if(Array.isArray(x)){for(let c of x)o(T,c);continue}o(T,`${x}`)}}if(S==="subscribe"){let o=e.replace(/^([^]+):\/\//,e.startsWith("https://")?"wss://":e.startsWith("http://")||Z.find(T=>e.includes(T))?"ws://":"wss://")+E+w;return new I(o)}return(async()=>{let o={method:S?.toUpperCase(),body:i,...O,headers:R};o.headers={...R,...j(v?i?.headers:y?.headers,E,o)};let T=v&&typeof i=="object"?i.fetch:y?.fetch;if(o={...o,...T},v&&delete o.body,p){Array.isArray(p)||(p=[p]);for(let d of p){let f=await d(E,o);typeof f=="object"&&(o={...o,...f,headers:{...o.headers,...j(f.headers,E,o)}})}}if(v&&delete o.body,he(i)){let d=new FormData;for(let[f,l]of Object.entries(o.body)){if(U){d.append(f,l);continue}if(l instanceof File){d.append(f,await J(l));continue}if(l instanceof FileList){for(let m=0;m<l.length;m++)d.append(f,await J(l[m]));continue}if(Array.isArray(l)){for(let m=0;m<l.length;m++){let b=l[m];d.append(f,b instanceof File?await J(b):b)}continue}d.append(f,l)}o.body=d}else typeof i=="object"?(o.headers["content-type"]="application/json",o.body=JSON.stringify(i)):i!=null&&(o.headers["content-type"]="text/plain");if(v&&delete o.body,p){Array.isArray(p)||(p=[p]);for(let d of p){let f=await d(E,o);typeof f=="object"&&(o={...o,...f,headers:{...o.headers,...j(f.headers,E,o)}})}}let x=e+E+w,c=await(r?.handle(new Request(x,o))??F(x,o)),h=null,u=null;if(g){Array.isArray(g)||(g=[g]);for(let d of g)try{let f=await d(c.clone());if(f!=null){h=f;break}}catch(f){f instanceof k?u=f:u=new k(422,f);break}}if(h!==null)return{data:h,error:u,response:c,status:c.status,headers:c.headers};switch(c.headers.get("Content-Type")?.split(";")[0]){case"text/event-stream":h=ge(c);break;case"application/json":h=await c.json();break;case"application/octet-stream":h=await c.arrayBuffer();break;case"multipart/form-data":let d=await c.formData();h={},d.forEach((f,l)=>{h[l]=f});break;default:h=await c.text().then(L)}return(c.status>=300||c.status<200)&&(u=new k(c.status,h),h=null),{data:h,error:u,response:c,status:c.status,headers:c.headers}})()}return typeof i=="object"?K(e,t,[...n,Object.values(i)[0]],r):K(e,t,n)}}),z=(e,t={})=>typeof e=="string"?(t.keepDomain||(e.includes("://")||(e=(Z.find(n=>e.includes(n))?"http://":"https://")+e),e.endsWith("/")&&(e=e.slice(0,-1))),K(e,t)):(typeof window<"u"&&console.warn("Elysia instance server found on client side, this is not recommended for security reason. Use generic type instead."),K("http://e.ly",t,[],e));var Q=(e,t,n)=>{if(e.endsWith("/")||(e+="/"),t==="index"&&(t=""),!n||!Object.keys(n).length)return`${e}${t}`;let r="";for(let[s,a]of Object.entries(n))r+=`${s}=${a}&`;return`${e}${t}?${r.slice(0,-1)}`};var V=typeof FileList>"u",X=e=>V?e instanceof Blob:e instanceof FileList||e instanceof File,me=e=>{if(!e)return!1;for(let t in e){if(X(e[t]))return!0;if(Array.isArray(e[t])&&e[t].find(n=>X(n)))return!0}return!1},B=e=>V?e:new Promise(t=>{let n=new FileReader;n.onload=()=>{let r=new File([n.result],e.name,{lastModified:e.lastModified,type:e.type});t(r)},n.readAsArrayBuffer(e)}),H=class{ws;url;constructor(t){this.ws=new WebSocket(t),this.url=t}send(t){return Array.isArray(t)?(t.forEach(n=>this.send(n)),this):(this.ws.send(typeof t=="object"?JSON.stringify(t):t.toString()),this)}on(t,n,r){return this.addEventListener(t,n,r)}off(t,n,r){return this.ws.removeEventListener(t,n,r),this}subscribe(t,n){return this.addEventListener("message",t,n)}addEventListener(t,n,r){return this.ws.addEventListener(t,s=>{if(t==="message"){let a=D(s);n({...s,data:a})}else n(s)},r),this}removeEventListener(t,n,r){return this.off(t,n,r),this}close(){return this.ws.close(),this}},Y=(e,t="",n)=>new Proxy(()=>{},{get(r,s,a){return Y(e,`${t}/${s.toString()}`,n)},apply(r,s,[a,i={}]=[{},{}]){let y=a!==void 0&&(typeof a!="object"||Array.isArray(a))?a:void 0,{$query:M,$fetch:S,$headers:E,$transform:F,getRaw:R,...p}=a??{};y??=p;let g=t.lastIndexOf("/"),O=t.slice(g+1).toUpperCase(),v=Q(e,g===-1?"/":t.slice(0,g),Object.assign(i.query??{},M)),N=n.fetcher??fetch,w=n.transform?Array.isArray(n.transform)?n.transform:[n.transform]:void 0,o=F?Array.isArray(F)?F:[F]:void 0;return o&&(w?w=o.concat(w):w=o),O==="SUBSCRIBE"?new H(v.replace(/^([^]+):\/\//,v.startsWith("https://")?"wss://":"ws://")):(async x=>{let c,h={...n.$fetch?.headers,...S?.headers,...i.headers,...E};if(O!=="GET"&&O!=="HEAD"){c=Object.keys(y).length||Array.isArray(y)?y:void 0;let m=c&&(typeof c=="object"||Array.isArray(y));if(m&&me(c)){let $=new FormData;for(let[C,A]of Object.entries(c))if(V)$.append(C,A);else if(A instanceof File)$.append(C,await B(A));else if(A instanceof FileList)for(let W=0;W<A.length;W++)$.append(C,await B(A[W]));else if(Array.isArray(A))for(let W=0;W<A.length;W++){let q=A[W];$.append(C,q instanceof File?await B(q):q)}else $.append(C,A);c=$}else c!=null&&(h["content-type"]=m?"application/json":"text/plain",c=m?JSON.stringify(c):y)}let u=await N(v,{method:O,body:c,...n.$fetch,...i.fetch,...S,headers:h}),d;if(x.getRaw)return u;switch(u.headers.get("Content-Type")?.split(";")[0]){case"application/json":d=await u.json();break;default:d=await u.text().then(L)}let f=u.status>=300||u.status<200?new k(u.status,d):null,l={data:d,error:f,response:u,status:u.status,headers:u.headers};if(w)for(let m of w){let b=m(l);b instanceof Promise&&(b=await b),b!=null&&(l=b)}return l})({getRaw:R})}}),ee=(e,t={fetcher:fetch})=>new Proxy({},{get(n,r){return Y(e,r,t)}});var Ee=async e=>{switch(e.headers.get("Content-Type")?.split(";")[0]){case"application/json":return e.json();case"application/octet-stream":return e.arrayBuffer();case"multipart/form-data":{let n=await e.formData(),r={};return n.forEach((s,a)=>{r[a]=s}),r}}return e.text().then(L)},we=async(e,t)=>{let n=await Ee(e);return e.status>300?{data:null,status:e.status,headers:e.headers,retry:t,error:new k(e.status,n)}:{data:n,error:null,status:e.status,headers:e.headers,retry:t}},te=(e,t)=>(n,{query:r,params:s,body:a,...i}={})=>{s&&Object.entries(s).forEach(([g,O])=>{n=n.replace(`:${g}`,O)});let y=i.headers?.["Content-Type"];if(!y||y==="application/json")try{a=JSON.stringify(a)}catch{}let M=t?.fetcher||globalThis.fetch,S=r?`?${new URLSearchParams(r).toString()}`:"",E=`${e}${n}${S}`,F=a?{"content-type":"application/json",...i.headers}:i.headers,R={...i,method:i.method?.toUpperCase()||"GET",headers:F,body:a},p=()=>M(E,R).then(g=>we(g,p));return p()};0&&(module.exports={edenFetch,edenTreaty,treaty});
|
|
1
|
+
"use strict";var P=Object.defineProperty;var ne=Object.getOwnPropertyDescriptor;var re=Object.getOwnPropertyNames;var se=Object.prototype.hasOwnProperty;var ae=(e,t)=>{for(var n in t)P(e,n,{get:t[n],enumerable:!0})},ie=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of re(t))!se.call(e,s)&&s!==n&&P(e,s,{get:()=>t[s],enumerable:!(r=ne(t,s))||r.enumerable});return e};var oe=e=>ie(P({},"__esModule",{value:!0}),e);var be={};ae(be,{edenFetch:()=>te,edenTreaty:()=>ee,treaty:()=>z});module.exports=oe(be);var T=class extends Error{constructor(n,r){super(r+"");this.status=n;this.value=r}};var 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\([^)]+\)/,de=/^(?:(?:(?:(?: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)?)?$/,ye=e=>e.trim().length!==0&&!Number.isNaN(Number(e)),_=e=>{if(typeof e!="string")return null;let t=e.replace(/"/g,"");if(ce.test(t)||fe.test(t)||de.test(t)){let n=new Date(t);if(!Number.isNaN(n.getTime()))return n}return null},ue=e=>{let t=e.charCodeAt(0),n=e.charCodeAt(e.length-1);return t===123&&n===125||t===91&&n===93},pe=e=>JSON.parse(e,(t,n)=>{let r=_(n);return r||n}),L=e=>{if(!e)return e;if(ye(e))return+e;if(e==="true")return!0;if(e==="false")return!1;let t=_(e);if(t)return t;if(ue(e))try{return pe(e)}catch{}return e},D=e=>{let t=e.data.toString();return t==="null"?null:L(t)};var I=class{constructor(t){this.url=t;this.ws=new WebSocket(t)}ws;send(t){return Array.isArray(t)?(t.forEach(n=>this.send(n)),this):(this.ws.send(typeof t=="object"?JSON.stringify(t):t.toString()),this)}on(t,n,r){return this.addEventListener(t,n,r)}off(t,n,r){return this.ws.removeEventListener(t,n,r),this}subscribe(t,n){return this.addEventListener("message",t,n)}addEventListener(t,n,r){return this.ws.addEventListener(t,s=>{if(t==="message"){let i=D(s);n({...s,data:i})}else n(s)},r),this}removeEventListener(t,n,r){return this.off(t,n,r),this}close(){return this.ws.close(),this}};var le=["get","post","put","delete","patch","options","head","connect","subscribe"],Z=["localhost","127.0.0.1","0.0.0.0"],U=typeof FileList>"u",G=e=>U?e instanceof Blob:e instanceof FileList||e instanceof File,he=e=>{if(!e)return!1;for(let t in e)if(G(e[t])||Array.isArray(e[t])&&e[t].find(G))return!0;return!1},J=e=>U?e:new Promise(t=>{let n=new FileReader;n.onload=()=>{let r=new File([n.result],e.name,{lastModified:e.lastModified,type:e.type});t(r)},n.readAsArrayBuffer(e)}),j=(e,t,n={},r={})=>{if(Array.isArray(e)){for(let s of e)if(!Array.isArray(s))r=j(s,t,n,r);else{let i=s[0];if(typeof i=="string")r[i.toLowerCase()]=s[1];else for(let[o,y]of i)r[o.toLowerCase()]=y}return r}if(!e)return r;switch(typeof e){case"function":if(e instanceof Headers)return j(e,t,n,r);let s=e(t,n);return s?j(s,t,n,r):r;case"object":if(e instanceof Headers)return e.forEach((i,o)=>{r[o.toLowerCase()]=i}),r;for(let[i,o]of Object.entries(e))r[i.toLowerCase()]=o;return r;default:return r}};async function*ge(e){let t=e.body;if(!t)return;let n=t.getReader(),r=new TextDecoder;try{for(;;){let{done:s,value:i}=await n.read();if(s)break;let o=r.decode(i);yield L(o)}}finally{n.releaseLock()}}var K=(e,t,n=[],r)=>new Proxy(()=>{},{get(s,i){return K(e,t,i==="index"?n:[...n,i],r)},apply(s,i,[o,y]){if(!o||y||typeof o=="object"&&Object.keys(o).length!==1||le.includes(n.at(-1))){let M=[...n],v=M.pop(),E="/"+M.join("/"),{fetcher:F=fetch,headers:R,onRequest:l,onResponse:g,fetch:O}=t,x=v==="get"||v==="head"||v==="subscribe";R=j(R,E,y);let N=x?o?.query:y?.query,b="";if(N){let a=(A,w)=>{b+=(b?"&":"?")+`${encodeURIComponent(A)}=${encodeURIComponent(w)}`};for(let[A,w]of Object.entries(N)){if(Array.isArray(w)){for(let c of w)a(A,c);continue}if(typeof w=="object"){a(A,JSON.stringify(w));continue}a(A,`${w}`)}}if(v==="subscribe"){let a=e.replace(/^([^]+):\/\//,e.startsWith("https://")?"wss://":e.startsWith("http://")||Z.find(A=>e.includes(A))?"ws://":"wss://")+E+b;return new I(a)}return(async()=>{let a={method:v?.toUpperCase(),body:o,...O,headers:R};a.headers={...R,...j(x?o?.headers:y?.headers,E,a)};let A=x&&typeof o=="object"?o.fetch:y?.fetch;if(a={...a,...A},x&&delete a.body,l){Array.isArray(l)||(l=[l]);for(let d of l){let f=await d(E,a);typeof f=="object"&&(a={...a,...f,headers:{...a.headers,...j(f.headers,E,a)}})}}if(x&&delete a.body,he(o)){let d=new FormData;for(let[f,p]of Object.entries(a.body)){if(U){d.append(f,p);continue}if(p instanceof File){d.append(f,await J(p));continue}if(p instanceof FileList){for(let m=0;m<p.length;m++)d.append(f,await J(p[m]));continue}if(Array.isArray(p)){for(let m=0;m<p.length;m++){let S=p[m];d.append(f,S instanceof File?await J(S):S)}continue}d.append(f,p)}a.body=d}else typeof o=="object"?(a.headers["content-type"]="application/json",a.body=JSON.stringify(o)):o!=null&&(a.headers["content-type"]="text/plain");if(x&&delete a.body,l){Array.isArray(l)||(l=[l]);for(let d of l){let f=await d(E,a);typeof f=="object"&&(a={...a,...f,headers:{...a.headers,...j(f.headers,E,a)}})}}let w=e+E+b,c=await(r?.handle(new Request(w,a))??F(w,a)),h=null,u=null;if(g){Array.isArray(g)||(g=[g]);for(let d of g)try{let f=await d(c.clone());if(f!=null){h=f;break}}catch(f){f instanceof T?u=f:u=new T(422,f);break}}if(h!==null)return{data:h,error:u,response:c,status:c.status,headers:c.headers};switch(c.headers.get("Content-Type")?.split(";")[0]){case"text/event-stream":h=ge(c);break;case"application/json":h=await c.json();break;case"application/octet-stream":h=await c.arrayBuffer();break;case"multipart/form-data":let d=await c.formData();h={},d.forEach((f,p)=>{h[p]=f});break;default:h=await c.text().then(L)}return(c.status>=300||c.status<200)&&(u=new T(c.status,h),h=null),{data:h,error:u,response:c,status:c.status,headers:c.headers}})()}return typeof o=="object"?K(e,t,[...n,Object.values(o)[0]],r):K(e,t,n)}}),z=(e,t={})=>typeof e=="string"?(t.keepDomain||(e.includes("://")||(e=(Z.find(n=>e.includes(n))?"http://":"https://")+e),e.endsWith("/")&&(e=e.slice(0,-1))),K(e,t)):(typeof window<"u"&&console.warn("Elysia instance server found on client side, this is not recommended for security reason. Use generic type instead."),K("http://e.ly",t,[],e));var Q=(e,t,n)=>{if(e.endsWith("/")||(e+="/"),t==="index"&&(t=""),!n||!Object.keys(n).length)return`${e}${t}`;let r="";for(let[s,i]of Object.entries(n))r+=`${s}=${i}&`;return`${e}${t}?${r.slice(0,-1)}`};var V=typeof FileList>"u",X=e=>V?e instanceof Blob:e instanceof FileList||e instanceof File,me=e=>{if(!e)return!1;for(let t in e){if(X(e[t]))return!0;if(Array.isArray(e[t])&&e[t].find(n=>X(n)))return!0}return!1},B=e=>V?e:new Promise(t=>{let n=new FileReader;n.onload=()=>{let r=new File([n.result],e.name,{lastModified:e.lastModified,type:e.type});t(r)},n.readAsArrayBuffer(e)}),H=class{ws;url;constructor(t){this.ws=new WebSocket(t),this.url=t}send(t){return Array.isArray(t)?(t.forEach(n=>this.send(n)),this):(this.ws.send(typeof t=="object"?JSON.stringify(t):t.toString()),this)}on(t,n,r){return this.addEventListener(t,n,r)}off(t,n,r){return this.ws.removeEventListener(t,n,r),this}subscribe(t,n){return this.addEventListener("message",t,n)}addEventListener(t,n,r){return this.ws.addEventListener(t,s=>{if(t==="message"){let i=D(s);n({...s,data:i})}else n(s)},r),this}removeEventListener(t,n,r){return this.off(t,n,r),this}close(){return this.ws.close(),this}},Y=(e,t="",n)=>new Proxy(()=>{},{get(r,s,i){return Y(e,`${t}/${s.toString()}`,n)},apply(r,s,[i,o={}]=[{},{}]){let y=i!==void 0&&(typeof i!="object"||Array.isArray(i))?i:void 0,{$query:M,$fetch:v,$headers:E,$transform:F,getRaw:R,...l}=i??{};y??=l;let g=t.lastIndexOf("/"),O=t.slice(g+1).toUpperCase(),x=Q(e,g===-1?"/":t.slice(0,g),Object.assign(o.query??{},M)),N=n.fetcher??fetch,b=n.transform?Array.isArray(n.transform)?n.transform:[n.transform]:void 0,a=F?Array.isArray(F)?F:[F]:void 0;return a&&(b?b=a.concat(b):b=a),O==="SUBSCRIBE"?new H(x.replace(/^([^]+):\/\//,x.startsWith("https://")?"wss://":"ws://")):(async w=>{let c,h={...n.$fetch?.headers,...v?.headers,...o.headers,...E};if(O!=="GET"&&O!=="HEAD"){c=Object.keys(y).length||Array.isArray(y)?y:void 0;let m=c&&(typeof c=="object"||Array.isArray(y));if(m&&me(c)){let $=new FormData;for(let[C,k]of Object.entries(c))if(V)$.append(C,k);else if(k instanceof File)$.append(C,await B(k));else if(k instanceof FileList)for(let W=0;W<k.length;W++)$.append(C,await B(k[W]));else if(Array.isArray(k))for(let W=0;W<k.length;W++){let q=k[W];$.append(C,q instanceof File?await B(q):q)}else $.append(C,k);c=$}else c!=null&&(h["content-type"]=m?"application/json":"text/plain",c=m?JSON.stringify(c):y)}let u=await N(x,{method:O,body:c,...n.$fetch,...o.fetch,...v,headers:h}),d;if(w.getRaw)return u;switch(u.headers.get("Content-Type")?.split(";")[0]){case"application/json":d=await u.json();break;default:d=await u.text().then(L)}let f=u.status>=300||u.status<200?new T(u.status,d):null,p={data:d,error:f,response:u,status:u.status,headers:u.headers};if(b)for(let m of b){let S=m(p);S instanceof Promise&&(S=await S),S!=null&&(p=S)}return p})({getRaw:R})}}),ee=(e,t={fetcher:fetch})=>new Proxy({},{get(n,r){return Y(e,r,t)}});var Ee=async e=>{switch(e.headers.get("Content-Type")?.split(";")[0]){case"application/json":return e.json();case"application/octet-stream":return e.arrayBuffer();case"multipart/form-data":{let n=await e.formData(),r={};return n.forEach((s,i)=>{r[i]=s}),r}}return e.text().then(L)},we=async(e,t)=>{let n=await Ee(e);return e.status>300?{data:null,status:e.status,headers:e.headers,retry:t,error:new T(e.status,n)}:{data:n,error:null,status:e.status,headers:e.headers,retry:t}},te=(e,t)=>(n,{query:r,params:s,body:i,...o}={})=>{s&&Object.entries(s).forEach(([g,O])=>{n=n.replace(`:${g}`,O)});let y=o.headers?.["Content-Type"];if(!y||y==="application/json")try{i=JSON.stringify(i)}catch{}let M=t?.fetcher||globalThis.fetch,v=r?`?${new URLSearchParams(r).toString()}`:"",E=`${e}${n}${v}`,F=i?{"content-type":"application/json",...o.headers}:o.headers,R={...o,method:o.method?.toUpperCase()||"GET",headers:F,body:i},l=()=>M(E,R).then(g=>we(g,l));return l()};0&&(module.exports={edenFetch,edenTreaty,treaty});
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as r}from"./chunk-2IHGLN7W.mjs";import{b as e}from"./chunk-
|
|
1
|
+
import{b as r}from"./chunk-2IHGLN7W.mjs";import{b as e}from"./chunk-7WO4HTSU.mjs";import{a as t}from"./chunk-YAG46HFR.mjs";import"./chunk-XYW4OUFN.mjs";export{t as edenFetch,r as edenTreaty,e as treaty};
|
package/dist/treaty2.global.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var Eden=(()=>{var M=Object.defineProperty;var H=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var V=Object.prototype.hasOwnProperty;var $=(e,t)=>{for(var n in t)M(e,n,{get:t[n],enumerable:!0})},B=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of U(t))!V.call(e,o)&&o!==n&&M(e,o,{get:()=>t[o],enumerable:!(s=H(t,o))||s.enumerable});return e};var Z=e=>B(M({},"__esModule",{value:!0}),e);var re={};$(re,{streamResponse:()=>J,treaty:()=>se});var k=class extends Error{constructor(n,s){super(s+"");this.status=n;this.value=s}};var G=/(\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))/,z=/(?: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\([^)]+\)/,Q=/^(?:(?:(?:(?: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)?)?$/,X=e=>e.trim().length!==0&&!Number.isNaN(Number(e)),K=e=>{if(typeof e!="string")return null;let t=e.replace(/"/g,"");if(G.test(t)||z.test(t)||Q.test(t)){let n=new Date(t);if(!Number.isNaN(n.getTime()))return n}return null},Y=e=>{let t=e.charCodeAt(0),n=e.charCodeAt(e.length-1);return t===123&&n===125||t===91&&n===93},ee=e=>JSON.parse(e,(t,n)=>{let s=K(n);return s||n}),T=e=>{if(!e)return e;if(X(e))return+e;if(e==="true")return!0;if(e==="false")return!1;let t=K(e);if(t)return t;if(Y(e))try{return ee(e)}catch{}return e},D=e=>{let t=e.data.toString();return t==="null"?null:T(t)};var F=class{constructor(t){this.url=t;this.ws=new WebSocket(t)}ws;send(t){return Array.isArray(t)?(t.forEach(n=>this.send(n)),this):(this.ws.send(typeof t=="object"?JSON.stringify(t):t.toString()),this)}on(t,n,s){return this.addEventListener(t,n,s)}off(t,n,s){return this.ws.removeEventListener(t,n,s),this}subscribe(t,n){return this.addEventListener("message",t,n)}addEventListener(t,n,s){return this.ws.addEventListener(t,o=>{if(t==="message"){let f=D(o);n({...o,data:f})}else n(o)},s),this}removeEventListener(t,n,s){return this.off(t,n,s),this}close(){return this.ws.close(),this}};var te=["get","post","put","delete","patch","options","head","connect","subscribe"],I=["localhost","127.0.0.1","0.0.0.0"],j=typeof FileList>"u",q=e=>j?e instanceof Blob:e instanceof FileList||e instanceof File,ne=e=>{if(!e)return!1;for(let t in e)if(q(e[t])||Array.isArray(e[t])&&e[t].find(q))return!0;return!1},W=e=>j?e:new Promise(t=>{let n=new FileReader;n.onload=()=>{let s=new File([n.result],e.name,{lastModified:e.lastModified,type:e.type});t(s)},n.readAsArrayBuffer(e)}),w=(e,t,n={},s={})=>{if(Array.isArray(e)){for(let o of e)if(!Array.isArray(o))s=w(o,t,n,s);else{let f=o[0];if(typeof f=="string")s[f.toLowerCase()]=o[1];else for(let[i,b]of f)s[i.toLowerCase()]=b}return s}if(!e)return s;switch(typeof e){case"function":if(e instanceof Headers)return w(e,t,n,s);let o=e(t,n);return o?w(o,t,n,s):s;case"object":if(e instanceof Headers)return e.forEach((f,i)=>{s[i.toLowerCase()]=f}),s;for(let[f,i]of Object.entries(e))s[f.toLowerCase()]=i;return s;default:return s}};async function*J(e){let t=e.body;if(!t)return;let n=t.getReader(),s=new TextDecoder;try{for(;;){let{done:o,value:f}=await n.read();if(o)break;let i=s.decode(f);yield T(i)}}finally{n.releaseLock()}}var x=(e,t,n=[],s)=>new Proxy(()=>{},{get(o,f){return x(e,t,f==="index"?n:[...n,f],s)},apply(o,f,[i,b]){if(!i||b||typeof i=="object"&&Object.keys(i).length!==1||te.includes(n.at(-1))){let C=[...n],E=C.pop(),
|
|
1
|
+
"use strict";var Eden=(()=>{var M=Object.defineProperty;var H=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var V=Object.prototype.hasOwnProperty;var $=(e,t)=>{for(var n in t)M(e,n,{get:t[n],enumerable:!0})},B=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of U(t))!V.call(e,o)&&o!==n&&M(e,o,{get:()=>t[o],enumerable:!(s=H(t,o))||s.enumerable});return e};var Z=e=>B(M({},"__esModule",{value:!0}),e);var re={};$(re,{streamResponse:()=>J,treaty:()=>se});var k=class extends Error{constructor(n,s){super(s+"");this.status=n;this.value=s}};var G=/(\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))/,z=/(?: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\([^)]+\)/,Q=/^(?:(?:(?:(?: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)?)?$/,X=e=>e.trim().length!==0&&!Number.isNaN(Number(e)),K=e=>{if(typeof e!="string")return null;let t=e.replace(/"/g,"");if(G.test(t)||z.test(t)||Q.test(t)){let n=new Date(t);if(!Number.isNaN(n.getTime()))return n}return null},Y=e=>{let t=e.charCodeAt(0),n=e.charCodeAt(e.length-1);return t===123&&n===125||t===91&&n===93},ee=e=>JSON.parse(e,(t,n)=>{let s=K(n);return s||n}),T=e=>{if(!e)return e;if(X(e))return+e;if(e==="true")return!0;if(e==="false")return!1;let t=K(e);if(t)return t;if(Y(e))try{return ee(e)}catch{}return e},D=e=>{let t=e.data.toString();return t==="null"?null:T(t)};var F=class{constructor(t){this.url=t;this.ws=new WebSocket(t)}ws;send(t){return Array.isArray(t)?(t.forEach(n=>this.send(n)),this):(this.ws.send(typeof t=="object"?JSON.stringify(t):t.toString()),this)}on(t,n,s){return this.addEventListener(t,n,s)}off(t,n,s){return this.ws.removeEventListener(t,n,s),this}subscribe(t,n){return this.addEventListener("message",t,n)}addEventListener(t,n,s){return this.ws.addEventListener(t,o=>{if(t==="message"){let f=D(o);n({...o,data:f})}else n(o)},s),this}removeEventListener(t,n,s){return this.off(t,n,s),this}close(){return this.ws.close(),this}};var te=["get","post","put","delete","patch","options","head","connect","subscribe"],I=["localhost","127.0.0.1","0.0.0.0"],j=typeof FileList>"u",q=e=>j?e instanceof Blob:e instanceof FileList||e instanceof File,ne=e=>{if(!e)return!1;for(let t in e)if(q(e[t])||Array.isArray(e[t])&&e[t].find(q))return!0;return!1},W=e=>j?e:new Promise(t=>{let n=new FileReader;n.onload=()=>{let s=new File([n.result],e.name,{lastModified:e.lastModified,type:e.type});t(s)},n.readAsArrayBuffer(e)}),w=(e,t,n={},s={})=>{if(Array.isArray(e)){for(let o of e)if(!Array.isArray(o))s=w(o,t,n,s);else{let f=o[0];if(typeof f=="string")s[f.toLowerCase()]=o[1];else for(let[i,b]of f)s[i.toLowerCase()]=b}return s}if(!e)return s;switch(typeof e){case"function":if(e instanceof Headers)return w(e,t,n,s);let o=e(t,n);return o?w(o,t,n,s):s;case"object":if(e instanceof Headers)return e.forEach((f,i)=>{s[i.toLowerCase()]=f}),s;for(let[f,i]of Object.entries(e))s[f.toLowerCase()]=i;return s;default:return s}};async function*J(e){let t=e.body;if(!t)return;let n=t.getReader(),s=new TextDecoder;try{for(;;){let{done:o,value:f}=await n.read();if(o)break;let i=s.decode(f);yield T(i)}}finally{n.releaseLock()}}var x=(e,t,n=[],s)=>new Proxy(()=>{},{get(o,f){return x(e,t,f==="index"?n:[...n,f],s)},apply(o,f,[i,b]){if(!i||b||typeof i=="object"&&Object.keys(i).length!==1||te.includes(n.at(-1))){let C=[...n],E=C.pop(),h="/"+C.join("/"),{fetcher:P=fetch,headers:O,onRequest:p,onResponse:v,fetch:_}=t,S=E==="get"||E==="head"||E==="subscribe";O=w(O,h,b);let N=S?i?.query:b?.query,L="";if(N){let r=(g,l)=>{L+=(L?"&":"?")+`${encodeURIComponent(g)}=${encodeURIComponent(l)}`};for(let[g,l]of Object.entries(N)){if(Array.isArray(l)){for(let c of l)r(g,c);continue}if(typeof l=="object"){r(g,JSON.stringify(l));continue}r(g,`${l}`)}}if(E==="subscribe"){let r=e.replace(/^([^]+):\/\//,e.startsWith("https://")?"wss://":e.startsWith("http://")||I.find(g=>e.includes(g))?"ws://":"wss://")+h+L;return new F(r)}return(async()=>{let r={method:E?.toUpperCase(),body:i,..._,headers:O};r.headers={...O,...w(S?i?.headers:b?.headers,h,r)};let g=S&&typeof i=="object"?i.fetch:b?.fetch;if(r={...r,...g},S&&delete r.body,p){Array.isArray(p)||(p=[p]);for(let d of p){let a=await d(h,r);typeof a=="object"&&(r={...r,...a,headers:{...r.headers,...w(a.headers,h,r)}})}}if(S&&delete r.body,ne(i)){let d=new FormData;for(let[a,y]of Object.entries(r.body)){if(j){d.append(a,y);continue}if(y instanceof File){d.append(a,await W(y));continue}if(y instanceof FileList){for(let m=0;m<y.length;m++)d.append(a,await W(y[m]));continue}if(Array.isArray(y)){for(let m=0;m<y.length;m++){let R=y[m];d.append(a,R instanceof File?await W(R):R)}continue}d.append(a,y)}r.body=d}else typeof i=="object"?(r.headers["content-type"]="application/json",r.body=JSON.stringify(i)):i!=null&&(r.headers["content-type"]="text/plain");if(S&&delete r.body,p){Array.isArray(p)||(p=[p]);for(let d of p){let a=await d(h,r);typeof a=="object"&&(r={...r,...a,headers:{...r.headers,...w(a.headers,h,r)}})}}let l=e+h+L,c=await(s?.handle(new Request(l,r))??P(l,r)),u=null,A=null;if(v){Array.isArray(v)||(v=[v]);for(let d of v)try{let a=await d(c.clone());if(a!=null){u=a;break}}catch(a){a instanceof k?A=a:A=new k(422,a);break}}if(u!==null)return{data:u,error:A,response:c,status:c.status,headers:c.headers};switch(c.headers.get("Content-Type")?.split(";")[0]){case"text/event-stream":u=J(c);break;case"application/json":u=await c.json();break;case"application/octet-stream":u=await c.arrayBuffer();break;case"multipart/form-data":let d=await c.formData();u={},d.forEach((a,y)=>{u[y]=a});break;default:u=await c.text().then(T)}return(c.status>=300||c.status<200)&&(A=new k(c.status,u),u=null),{data:u,error:A,response:c,status:c.status,headers:c.headers}})()}return typeof i=="object"?x(e,t,[...n,Object.values(i)[0]],s):x(e,t,n)}}),se=(e,t={})=>typeof e=="string"?(t.keepDomain||(e.includes("://")||(e=(I.find(n=>e.includes(n))?"http://":"https://")+e),e.endsWith("/")&&(e=e.slice(0,-1))),x(e,t)):(typeof window<"u"&&console.warn("Elysia instance server found on client side, this is not recommended for security reason. Use generic type instead."),x("http://e.ly",t,[],e));return Z(re);})();
|
package/dist/treaty2.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var M=Object.defineProperty;var H=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var V=Object.prototype.hasOwnProperty;var $=(e,t)=>{for(var n in t)M(e,n,{get:t[n],enumerable:!0})},B=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of U(t))!V.call(e,o)&&o!==n&&M(e,o,{get:()=>t[o],enumerable:!(s=H(t,o))||s.enumerable});return e};var Z=e=>B(M({},"__esModule",{value:!0}),e);var re={};$(re,{streamResponse:()=>J,treaty:()=>se});module.exports=Z(re);var k=class extends Error{constructor(n,s){super(s+"");this.status=n;this.value=s}};var G=/(\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))/,z=/(?: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\([^)]+\)/,Q=/^(?:(?:(?:(?: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)?)?$/,X=e=>e.trim().length!==0&&!Number.isNaN(Number(e)),K=e=>{if(typeof e!="string")return null;let t=e.replace(/"/g,"");if(G.test(t)||z.test(t)||Q.test(t)){let n=new Date(t);if(!Number.isNaN(n.getTime()))return n}return null},Y=e=>{let t=e.charCodeAt(0),n=e.charCodeAt(e.length-1);return t===123&&n===125||t===91&&n===93},ee=e=>JSON.parse(e,(t,n)=>{let s=K(n);return s||n}),T=e=>{if(!e)return e;if(X(e))return+e;if(e==="true")return!0;if(e==="false")return!1;let t=K(e);if(t)return t;if(Y(e))try{return ee(e)}catch{}return e},D=e=>{let t=e.data.toString();return t==="null"?null:T(t)};var F=class{constructor(t){this.url=t;this.ws=new WebSocket(t)}ws;send(t){return Array.isArray(t)?(t.forEach(n=>this.send(n)),this):(this.ws.send(typeof t=="object"?JSON.stringify(t):t.toString()),this)}on(t,n,s){return this.addEventListener(t,n,s)}off(t,n,s){return this.ws.removeEventListener(t,n,s),this}subscribe(t,n){return this.addEventListener("message",t,n)}addEventListener(t,n,s){return this.ws.addEventListener(t,o=>{if(t==="message"){let f=D(o);n({...o,data:f})}else n(o)},s),this}removeEventListener(t,n,s){return this.off(t,n,s),this}close(){return this.ws.close(),this}};var te=["get","post","put","delete","patch","options","head","connect","subscribe"],I=["localhost","127.0.0.1","0.0.0.0"],j=typeof FileList>"u",q=e=>j?e instanceof Blob:e instanceof FileList||e instanceof File,ne=e=>{if(!e)return!1;for(let t in e)if(q(e[t])||Array.isArray(e[t])&&e[t].find(q))return!0;return!1},W=e=>j?e:new Promise(t=>{let n=new FileReader;n.onload=()=>{let s=new File([n.result],e.name,{lastModified:e.lastModified,type:e.type});t(s)},n.readAsArrayBuffer(e)}),w=(e,t,n={},s={})=>{if(Array.isArray(e)){for(let o of e)if(!Array.isArray(o))s=w(o,t,n,s);else{let f=o[0];if(typeof f=="string")s[f.toLowerCase()]=o[1];else for(let[i,b]of f)s[i.toLowerCase()]=b}return s}if(!e)return s;switch(typeof e){case"function":if(e instanceof Headers)return w(e,t,n,s);let o=e(t,n);return o?w(o,t,n,s):s;case"object":if(e instanceof Headers)return e.forEach((f,i)=>{s[i.toLowerCase()]=f}),s;for(let[f,i]of Object.entries(e))s[f.toLowerCase()]=i;return s;default:return s}};async function*J(e){let t=e.body;if(!t)return;let n=t.getReader(),s=new TextDecoder;try{for(;;){let{done:o,value:f}=await n.read();if(o)break;let i=s.decode(f);yield T(i)}}finally{n.releaseLock()}}var x=(e,t,n=[],s)=>new Proxy(()=>{},{get(o,f){return x(e,t,f==="index"?n:[...n,f],s)},apply(o,f,[i,b]){if(!i||b||typeof i=="object"&&Object.keys(i).length!==1||te.includes(n.at(-1))){let C=[...n],E=C.pop(),
|
|
1
|
+
"use strict";var M=Object.defineProperty;var H=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var V=Object.prototype.hasOwnProperty;var $=(e,t)=>{for(var n in t)M(e,n,{get:t[n],enumerable:!0})},B=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of U(t))!V.call(e,o)&&o!==n&&M(e,o,{get:()=>t[o],enumerable:!(s=H(t,o))||s.enumerable});return e};var Z=e=>B(M({},"__esModule",{value:!0}),e);var re={};$(re,{streamResponse:()=>J,treaty:()=>se});module.exports=Z(re);var k=class extends Error{constructor(n,s){super(s+"");this.status=n;this.value=s}};var G=/(\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))/,z=/(?: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\([^)]+\)/,Q=/^(?:(?:(?:(?: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)?)?$/,X=e=>e.trim().length!==0&&!Number.isNaN(Number(e)),K=e=>{if(typeof e!="string")return null;let t=e.replace(/"/g,"");if(G.test(t)||z.test(t)||Q.test(t)){let n=new Date(t);if(!Number.isNaN(n.getTime()))return n}return null},Y=e=>{let t=e.charCodeAt(0),n=e.charCodeAt(e.length-1);return t===123&&n===125||t===91&&n===93},ee=e=>JSON.parse(e,(t,n)=>{let s=K(n);return s||n}),T=e=>{if(!e)return e;if(X(e))return+e;if(e==="true")return!0;if(e==="false")return!1;let t=K(e);if(t)return t;if(Y(e))try{return ee(e)}catch{}return e},D=e=>{let t=e.data.toString();return t==="null"?null:T(t)};var F=class{constructor(t){this.url=t;this.ws=new WebSocket(t)}ws;send(t){return Array.isArray(t)?(t.forEach(n=>this.send(n)),this):(this.ws.send(typeof t=="object"?JSON.stringify(t):t.toString()),this)}on(t,n,s){return this.addEventListener(t,n,s)}off(t,n,s){return this.ws.removeEventListener(t,n,s),this}subscribe(t,n){return this.addEventListener("message",t,n)}addEventListener(t,n,s){return this.ws.addEventListener(t,o=>{if(t==="message"){let f=D(o);n({...o,data:f})}else n(o)},s),this}removeEventListener(t,n,s){return this.off(t,n,s),this}close(){return this.ws.close(),this}};var te=["get","post","put","delete","patch","options","head","connect","subscribe"],I=["localhost","127.0.0.1","0.0.0.0"],j=typeof FileList>"u",q=e=>j?e instanceof Blob:e instanceof FileList||e instanceof File,ne=e=>{if(!e)return!1;for(let t in e)if(q(e[t])||Array.isArray(e[t])&&e[t].find(q))return!0;return!1},W=e=>j?e:new Promise(t=>{let n=new FileReader;n.onload=()=>{let s=new File([n.result],e.name,{lastModified:e.lastModified,type:e.type});t(s)},n.readAsArrayBuffer(e)}),w=(e,t,n={},s={})=>{if(Array.isArray(e)){for(let o of e)if(!Array.isArray(o))s=w(o,t,n,s);else{let f=o[0];if(typeof f=="string")s[f.toLowerCase()]=o[1];else for(let[i,b]of f)s[i.toLowerCase()]=b}return s}if(!e)return s;switch(typeof e){case"function":if(e instanceof Headers)return w(e,t,n,s);let o=e(t,n);return o?w(o,t,n,s):s;case"object":if(e instanceof Headers)return e.forEach((f,i)=>{s[i.toLowerCase()]=f}),s;for(let[f,i]of Object.entries(e))s[f.toLowerCase()]=i;return s;default:return s}};async function*J(e){let t=e.body;if(!t)return;let n=t.getReader(),s=new TextDecoder;try{for(;;){let{done:o,value:f}=await n.read();if(o)break;let i=s.decode(f);yield T(i)}}finally{n.releaseLock()}}var x=(e,t,n=[],s)=>new Proxy(()=>{},{get(o,f){return x(e,t,f==="index"?n:[...n,f],s)},apply(o,f,[i,b]){if(!i||b||typeof i=="object"&&Object.keys(i).length!==1||te.includes(n.at(-1))){let C=[...n],E=C.pop(),h="/"+C.join("/"),{fetcher:P=fetch,headers:O,onRequest:p,onResponse:v,fetch:_}=t,S=E==="get"||E==="head"||E==="subscribe";O=w(O,h,b);let N=S?i?.query:b?.query,L="";if(N){let r=(g,l)=>{L+=(L?"&":"?")+`${encodeURIComponent(g)}=${encodeURIComponent(l)}`};for(let[g,l]of Object.entries(N)){if(Array.isArray(l)){for(let c of l)r(g,c);continue}if(typeof l=="object"){r(g,JSON.stringify(l));continue}r(g,`${l}`)}}if(E==="subscribe"){let r=e.replace(/^([^]+):\/\//,e.startsWith("https://")?"wss://":e.startsWith("http://")||I.find(g=>e.includes(g))?"ws://":"wss://")+h+L;return new F(r)}return(async()=>{let r={method:E?.toUpperCase(),body:i,..._,headers:O};r.headers={...O,...w(S?i?.headers:b?.headers,h,r)};let g=S&&typeof i=="object"?i.fetch:b?.fetch;if(r={...r,...g},S&&delete r.body,p){Array.isArray(p)||(p=[p]);for(let d of p){let a=await d(h,r);typeof a=="object"&&(r={...r,...a,headers:{...r.headers,...w(a.headers,h,r)}})}}if(S&&delete r.body,ne(i)){let d=new FormData;for(let[a,y]of Object.entries(r.body)){if(j){d.append(a,y);continue}if(y instanceof File){d.append(a,await W(y));continue}if(y instanceof FileList){for(let m=0;m<y.length;m++)d.append(a,await W(y[m]));continue}if(Array.isArray(y)){for(let m=0;m<y.length;m++){let R=y[m];d.append(a,R instanceof File?await W(R):R)}continue}d.append(a,y)}r.body=d}else typeof i=="object"?(r.headers["content-type"]="application/json",r.body=JSON.stringify(i)):i!=null&&(r.headers["content-type"]="text/plain");if(S&&delete r.body,p){Array.isArray(p)||(p=[p]);for(let d of p){let a=await d(h,r);typeof a=="object"&&(r={...r,...a,headers:{...r.headers,...w(a.headers,h,r)}})}}let l=e+h+L,c=await(s?.handle(new Request(l,r))??P(l,r)),u=null,A=null;if(v){Array.isArray(v)||(v=[v]);for(let d of v)try{let a=await d(c.clone());if(a!=null){u=a;break}}catch(a){a instanceof k?A=a:A=new k(422,a);break}}if(u!==null)return{data:u,error:A,response:c,status:c.status,headers:c.headers};switch(c.headers.get("Content-Type")?.split(";")[0]){case"text/event-stream":u=J(c);break;case"application/json":u=await c.json();break;case"application/octet-stream":u=await c.arrayBuffer();break;case"multipart/form-data":let d=await c.formData();u={},d.forEach((a,y)=>{u[y]=a});break;default:u=await c.text().then(T)}return(c.status>=300||c.status<200)&&(A=new k(c.status,u),u=null),{data:u,error:A,response:c,status:c.status,headers:c.headers}})()}return typeof i=="object"?x(e,t,[...n,Object.values(i)[0]],s):x(e,t,n)}}),se=(e,t={})=>typeof e=="string"?(t.keepDomain||(e.includes("://")||(e=(I.find(n=>e.includes(n))?"http://":"https://")+e),e.endsWith("/")&&(e=e.slice(0,-1))),x(e,t)):(typeof window<"u"&&console.warn("Elysia instance server found on client side, this is not recommended for security reason. Use generic type instead."),x("http://e.ly",t,[],e));0&&(module.exports={streamResponse,treaty});
|
package/dist/treaty2.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b}from"./chunk-
|
|
1
|
+
import{a,b}from"./chunk-7WO4HTSU.mjs";import"./chunk-XYW4OUFN.mjs";export{a as streamResponse,b as treaty};
|
package/package.json
CHANGED
package/dist/chunk-RPZULI5W.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as x,b as O,c as M}from"./chunk-XYW4OUFN.mjs";var F=class{constructor(t){this.url=t;this.ws=new WebSocket(t)}ws;send(t){return Array.isArray(t)?(t.forEach(n=>this.send(n)),this):(this.ws.send(typeof t=="object"?JSON.stringify(t):t.toString()),this)}on(t,n,s){return this.addEventListener(t,n,s)}off(t,n,s){return this.ws.removeEventListener(t,n,s),this}subscribe(t,n){return this.addEventListener("message",t,n)}addEventListener(t,n,s){return this.ws.addEventListener(t,c=>{if(t==="message"){let f=M(c);n({...c,data:f})}else n(c)},s),this}removeEventListener(t,n,s){return this.off(t,n,s),this}close(){return this.ws.close(),this}};var P=["get","post","put","delete","patch","options","head","connect","subscribe"],I=["localhost","127.0.0.1","0.0.0.0"],C=typeof FileList>"u",q=e=>C?e instanceof Blob:e instanceof FileList||e instanceof File,U=e=>{if(!e)return!1;for(let t in e)if(q(e[t])||Array.isArray(e[t])&&e[t].find(q))return!0;return!1},j=e=>C?e:new Promise(t=>{let n=new FileReader;n.onload=()=>{let s=new File([n.result],e.name,{lastModified:e.lastModified,type:e.type});t(s)},n.readAsArrayBuffer(e)}),b=(e,t,n={},s={})=>{if(Array.isArray(e)){for(let c of e)if(!Array.isArray(c))s=b(c,t,n,s);else{let f=c[0];if(typeof f=="string")s[f.toLowerCase()]=c[1];else for(let[a,w]of f)s[a.toLowerCase()]=w}return s}if(!e)return s;switch(typeof e){case"function":if(e instanceof Headers)return b(e,t,n,s);let c=e(t,n);return c?b(c,t,n,s):s;case"object":if(e instanceof Headers)return e.forEach((f,a)=>{s[a.toLowerCase()]=f}),s;for(let[f,a]of Object.entries(e))s[f.toLowerCase()]=a;return s;default:return s}};async function*_(e){let t=e.body;if(!t)return;let n=t.getReader(),s=new TextDecoder;try{for(;;){let{done:c,value:f}=await n.read();if(c)break;let a=s.decode(f);yield O(a)}}finally{n.releaseLock()}}var S=(e,t,n=[],s)=>new Proxy(()=>{},{get(c,f){return S(e,t,f==="index"?n:[...n,f],s)},apply(c,f,[a,w]){if(!a||w||typeof a=="object"&&Object.keys(a).length!==1||P.includes(n.at(-1))){let K=[...n],k=K.pop(),d="/"+K.join("/"),{fetcher:D=fetch,headers:L,onRequest:p,onResponse:E,fetch:H}=t,m=k==="get"||k==="head"||k==="subscribe";L=b(L,d,w);let T=m?a?.query:w?.query,R="";if(T){let r=(h,g)=>{R+=(R?"&":"?")+`${encodeURIComponent(h)}=${encodeURIComponent(g)}`};for(let[h,g]of Object.entries(T)){if(Array.isArray(g)){for(let o of g)r(h,o);continue}r(h,`${g}`)}}if(k==="subscribe"){let r=e.replace(/^([^]+):\/\//,e.startsWith("https://")?"wss://":e.startsWith("http://")||I.find(h=>e.includes(h))?"ws://":"wss://")+d+R;return new F(r)}return(async()=>{let r={method:k?.toUpperCase(),body:a,...H,headers:L};r.headers={...L,...b(m?a?.headers:w?.headers,d,r)};let h=m&&typeof a=="object"?a.fetch:w?.fetch;if(r={...r,...h},m&&delete r.body,p){Array.isArray(p)||(p=[p]);for(let y of p){let i=await y(d,r);typeof i=="object"&&(r={...r,...i,headers:{...r.headers,...b(i.headers,d,r)}})}}if(m&&delete r.body,U(a)){let y=new FormData;for(let[i,u]of Object.entries(r.body)){if(C){y.append(i,u);continue}if(u instanceof File){y.append(i,await j(u));continue}if(u instanceof FileList){for(let v=0;v<u.length;v++)y.append(i,await j(u[v]));continue}if(Array.isArray(u)){for(let v=0;v<u.length;v++){let W=u[v];y.append(i,W instanceof File?await j(W):W)}continue}y.append(i,u)}r.body=y}else typeof a=="object"?(r.headers["content-type"]="application/json",r.body=JSON.stringify(a)):a!=null&&(r.headers["content-type"]="text/plain");if(m&&delete r.body,p){Array.isArray(p)||(p=[p]);for(let y of p){let i=await y(d,r);typeof i=="object"&&(r={...r,...i,headers:{...r.headers,...b(i.headers,d,r)}})}}let g=e+d+R,o=await(s?.handle(new Request(g,r))??D(g,r)),l=null,A=null;if(E){Array.isArray(E)||(E=[E]);for(let y of E)try{let i=await y(o.clone());if(i!=null){l=i;break}}catch(i){i instanceof x?A=i:A=new x(422,i);break}}if(l!==null)return{data:l,error:A,response:o,status:o.status,headers:o.headers};switch(o.headers.get("Content-Type")?.split(";")[0]){case"text/event-stream":l=_(o);break;case"application/json":l=await o.json();break;case"application/octet-stream":l=await o.arrayBuffer();break;case"multipart/form-data":let y=await o.formData();l={},y.forEach((i,u)=>{l[u]=i});break;default:l=await o.text().then(O)}return(o.status>=300||o.status<200)&&(A=new x(o.status,l),l=null),{data:l,error:A,response:o,status:o.status,headers:o.headers}})()}return typeof a=="object"?S(e,t,[...n,Object.values(a)[0]],s):S(e,t,n)}}),V=(e,t={})=>typeof e=="string"?(t.keepDomain||(e.includes("://")||(e=(I.find(n=>e.includes(n))?"http://":"https://")+e),e.endsWith("/")&&(e=e.slice(0,-1))),S(e,t)):(typeof window<"u"&&console.warn("Elysia instance server found on client side, this is not recommended for security reason. Use generic type instead."),S("http://e.ly",t,[],e));export{_ as a,V as b};
|