@elysiajs/eden 1.4.6 → 1.4.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elysiajs/eden",
3
- "version": "1.4.6",
3
+ "version": "1.4.7",
4
4
  "description": "Fully type-safe Elysia client",
5
5
  "author": {
6
6
  "name": "saltyAom",
@@ -12,24 +12,24 @@
12
12
  "exports": {
13
13
  "./package.json": "./package.json",
14
14
  ".": {
15
- "require": "./dist/index.js",
15
+ "types": "./dist/index.d.ts",
16
16
  "import": "./dist/index.mjs",
17
- "types": "./dist/index.d.ts"
17
+ "require": "./dist/index.js"
18
18
  },
19
19
  "./treaty": {
20
- "require": "./dist/treaty.js",
20
+ "types": "./dist/treaty/index.d.ts",
21
21
  "import": "./dist/treaty.mjs",
22
- "types": "./dist/treaty/index.d.ts"
22
+ "require": "./dist/treaty.js"
23
23
  },
24
24
  "./treaty2": {
25
- "require": "./dist/2.js",
25
+ "types": "./dist/treaty2/index.d.ts",
26
26
  "import": "./dist/treaty2.mjs",
27
- "types": "./dist/treaty2/index.d.ts"
27
+ "require": "./dist/treaty2.js"
28
28
  },
29
29
  "./fetch": {
30
- "require": "./dist/fetch.js",
30
+ "types": "./dist/fetch/index.d.ts",
31
31
  "import": "./dist/fetch.mjs",
32
- "types": "./dist/fetch/index.d.ts"
32
+ "require": "./dist/fetch.js"
33
33
  }
34
34
  },
35
35
  "types": "./dist/index.d.ts",
@@ -59,7 +59,7 @@
59
59
  "@elysiajs/cors": "1.3.3",
60
60
  "@types/bun": "^1.2.20",
61
61
  "@types/node": "^24.3.0",
62
- "elysia": "^1.4.19",
62
+ "elysia": "^1.4.23",
63
63
  "esbuild": "^0.25.9",
64
64
  "eslint": "^9.34.0",
65
65
  "expect-type": "^1.2.2",
@@ -1,4 +0,0 @@
1
- import{a as R,b as D,c as T,d as I}from"./chunk-QSLHAOSM.mjs";var C=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,a=>{if(t==="message"){let l=I(a);n({...a,data:l})}else n(a)},r),this}removeEventListener(t,n,r){return this.off(t,n,r),this}close(){return this.ws.close(),this}};var $=["get","post","put","delete","patch","options","head","connect","subscribe"],P=["localhost","127.0.0.1","0.0.0.0"],N=typeof FileList>"u",K=e=>N?e instanceof Blob:e instanceof FileList||e instanceof File,G=e=>{if(!e)return!1;for(let t in e)if(K(e[t])||Array.isArray(e[t])&&e[t].find(K))return!0;return!1},M=e=>N?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)}),k=async(e,t,n={},r={})=>{if(Array.isArray(e)){for(let a of e)if(!Array.isArray(a))r=await k(a,t,n,r);else{let l=a[0];if(typeof l=="string")r[l.toLowerCase()]=a[1];else for(let[i,p]of l)r[i.toLowerCase()]=p}return r}if(!e)return r;switch(typeof e){case"function":if(e instanceof Headers)return k(e,t,n,r);let a=await e(t,n);return a?k(a,t,n,r):r;case"object":if(e instanceof Headers)return e.forEach((l,i)=>{r[i.toLowerCase()]=l}),r;for(let[l,i]of Object.entries(e))r[l.toLowerCase()]=i;return r;default:return r}};function B(e){let t=e.split(`
2
- `),n={};for(let r of t){if(!r||r.startsWith(":"))continue;let a=r.indexOf(":");if(a>0){let l=r.slice(0,a).trim(),i=r.slice(a+1).replace(/^ /,"");n[l]=i&&T(i)}}return Object.keys(n).length>0?n:null}function*J(e){let t;for(;(t=e.value.indexOf(`
3
-
4
- `))!==-1;){let n=e.value.slice(0,t);if(e.value=e.value.slice(t+2),n.trim()){let r=B(n);r&&(yield r)}}}async function*z(e){let t=e.body;if(!t)return;let n=t.getReader(),r=new TextDecoder("utf-8"),a={value:""};try{for(;;){let{done:i,value:p}=await n.read();if(i)break;let j=typeof p=="string"?p:r.decode(p,{stream:!0});a.value+=j,yield*J(a)}let l=r.decode();if(l&&(a.value+=l),yield*J(a),a.value.trim()){let i=B(a.value);i&&(yield i)}}finally{n.releaseLock()}}var L=(e,t,n=[],r)=>new Proxy(()=>{},{get(a,l){return L(e,t,l==="index"?n:[...n,l],r)},apply(a,l,[i,p]){if(!i||p||typeof i=="object"&&Object.keys(i).length!==1||$.includes(n.at(-1))){let j=[...n],A=j.pop(),b="/"+j.join("/"),{fetcher:H=fetch,headers:F,onRequest:w,onResponse:O,fetch:U}=t,E=A==="get"||A==="head"||A==="subscribe",q=E?i?.query:p?.query,W="";if(q){let s=(v,d)=>{W+=(W?"&":"?")+`${encodeURIComponent(v)}=${encodeURIComponent(d)}`};for(let[v,d]of Object.entries(q)){if(Array.isArray(d)){for(let f of d)s(v,f);continue}if(d!=null){if(typeof d=="object"){s(v,JSON.stringify(d));continue}s(v,`${d}`)}}}if(A==="subscribe"){let s=e.replace(/^([^]+):\/\//,e.startsWith("https://")?"wss://":e.startsWith("http://")||P.find(v=>e.includes(v))?"ws://":"wss://")+b+W;return new C(s)}return(async()=>{F=await k(F,b,p);let s={method:A?.toUpperCase(),body:i,...U,headers:F};s.headers={...F,...await k(E?i?.headers:p?.headers,b,s)};let v=E&&typeof i=="object"?i.fetch:p?.fetch;if(s={...s,...v},E&&delete s.body,w){Array.isArray(w)||(w=[w]);for(let u of w){let c=await u(b,s);typeof c=="object"&&(s={...s,...c,headers:{...s.headers,...await k(c.headers,b,s)}})}}if(E&&delete s.body,G(i)){let u=new FormData,c=o=>{if(typeof o=="string"||K(o))return!1;if(typeof o=="object"){if(o!==null)return!0;if(o instanceof Date)return!1}return!1},g=async o=>o instanceof File?await M(o):c(o)?JSON.stringify(o):o;for(let[o,y]of Object.entries(s.body)){if(Array.isArray(y)){if(y.some(m=>typeof m=="object"&&m!==null&&!K(m)))u.append(o,JSON.stringify(y));else for(let m=0;m<y.length;m++){let _=y[m],V=await g(_);u.append(o,V)}continue}if(N){if(Array.isArray(y))for(let S of y)u.append(o,await g(S));else u.append(o,await g(y));continue}if(y instanceof File){u.append(o,await M(y));continue}if(y instanceof FileList){for(let S=0;S<y.length;S++)u.append(o,await M(y[S]));continue}u.append(o,await g(y))}s.body=u}else typeof i=="object"?(s.headers["content-type"]="application/json",s.body=JSON.stringify(i)):i!=null&&(s.headers["content-type"]="text/plain");if(E&&delete s.body,w){Array.isArray(w)||(w=[w]);for(let u of w){let c=await u(b,s);typeof c=="object"&&(s={...s,...c,headers:{...s.headers,...await k(c.headers,b,s)}})}}p?.headers?.["content-type"]&&(s.headers["content-type"]=p?.headers["content-type"]);let d=e+b+W,f;try{f=await(r?.handle(new Request(d,s))??H(d,s))}catch(u){return{data:null,error:new R(503,u),response:void 0,status:503,headers:void 0}}let h=null,x=null;if(O){Array.isArray(O)||(O=[O]);for(let u of O)try{let c=await u(f.clone());if(c!=null){h=c;break}}catch(c){c instanceof R?x=c:x=new R(422,c);break}}if(h!==null)return{data:h,error:x,response:f,status:f.status,headers:f.headers};switch(f.headers.get("Content-Type")?.split(";")[0]){case"text/event-stream":h=z(f);break;case"application/json":h=JSON.parse(await f.text(),(c,g)=>{if(typeof g!="string")return g;let o=D(g);return o||g});break;case"application/octet-stream":h=await f.arrayBuffer();break;case"multipart/form-data":let u=await f.formData();h={},u.forEach((c,g)=>{h[g]=c});break;default:h=await f.text().then(T)}return(f.status>=300||f.status<200)&&(x=new R(f.status,h),h=null),{data:h,error:x,response:f,status:f.status,headers:f.headers}})()}return typeof i=="object"?L(e,t,[...n,Object.values(i)[0]],r):L(e,t,n)}}),te=(e,t={})=>typeof e=="string"?(t.keepDomain||(e.includes("://")||(e=(P.find(n=>e.includes(n))?"http://":"https://")+e),e.endsWith("/")&&(e=e.slice(0,-1))),L(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."),L("http://e.ly",t,[],e));export{z as a,te as b};
@@ -1 +0,0 @@
1
- var s=class extends Error{constructor(e,n){super(n+"");this.status=e;this.value=n}};var i=/(\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))/,o=/(?: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\([^)]+\)/,c=/^(?:(?:(?:(?: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)?)?$/,u=t=>t.trim().length!==0&&!Number.isNaN(Number(t)),d=t=>{if(typeof t!="string")return null;let r=t.replace(/"/g,"");if(i.test(r)||o.test(r)||c.test(r)){let e=new Date(r);if(!Number.isNaN(e.getTime()))return e}return null},a=t=>{let r=t.charCodeAt(0),e=t.charCodeAt(t.length-1);return r===123&&e===125||r===91&&e===93},p=t=>JSON.parse(t,(r,e)=>{let n=d(e);return n||e}),g=t=>{if(!t)return t;if(u(t))return+t;if(t==="true")return!0;if(t==="false")return!1;let r=d(t);if(r)return r;if(a(t))try{return p(t)}catch{}return t},S=t=>{let r=t.data.toString();return r==="null"?null:g(r)};export{s as a,d as b,g as c,S as d};
@@ -1 +0,0 @@
1
- import{a as l,c as p}from"./chunk-QSLHAOSM.mjs";var j=async t=>{switch(t.headers.get("Content-Type")?.split(";")[0]){case"application/json":return t.json();case"application/octet-stream":return t.arrayBuffer();case"multipart/form-data":{let e=await t.formData(),s={};return e.forEach((c,a)=>{s[a]=c}),s}}return t.text().then(p)},w=async(t,r)=>{let e=await j(t);return t.status>300?{data:null,status:t.status,headers:t.headers,retry:r,error:new l(t.status,e)}:{data:e,error:null,status:t.status,headers:t.headers,retry:r}},S=(t,r)=>(e,{query:s,params:c,body:a,...i}={})=>{c&&Object.entries(c).forEach(([n,o])=>{e=e.replace(`:${n}`,o)});let d=r?.fetcher||globalThis.fetch,y=s?Object.fromEntries(Object.entries(s).filter(([n,o])=>o!=null)):null,m=y?`?${new URLSearchParams(y).toString()}`:"",E=`${t}${e}${m}`,h=new Headers(i.headers||{}),f=h.get("content-type");if(!(a instanceof FormData)&&!(a instanceof URLSearchParams)&&(!f||f==="application/json"))try{a=JSON.stringify(a),f||h.set("content-type","application/json")}catch{}let g={...i,method:i.method?.toUpperCase()||"GET",headers:h,body:a},u=()=>d(E,g).then(n=>w(n,u)).catch(n=>({data:null,error:new l(503,n),status:503,headers:void 0,retry:u}));return u()};export{S as a};
@@ -1,6 +0,0 @@
1
- export declare const isNumericString: (message: string) => boolean;
2
- export declare const parseStringifiedDate: (value: any) => Date | null;
3
- export declare const isStringifiedObject: (value: string) => boolean;
4
- export declare const parseStringifiedObject: (data: string) => any;
5
- export declare const parseStringifiedValue: (value: string) => any;
6
- export declare const parseMessageEvent: (event: MessageEvent) => any;