@elysiajs/eden 0.6.4 → 0.6.5

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.
@@ -0,0 +1 @@
1
+ import{a as S}from"./chunk-Y6SMVGJX.mjs";var k=(n,e,t)=>{if(n.endsWith("/")||(n+="/"),e==="index"&&(e=""),!t||!Object.keys(t).length)return`${n}${e}`;let r="";for(let[o,s]of Object.entries(t))r+=`${o}=${s}&`;return`${n}${e}?${r.slice(0,-1)}`};var v=typeof FileList>"u",x=n=>v?n instanceof Blob:n instanceof FileList||n instanceof File,A=n=>{if(!n)return!1;for(let e in n){if(x(n[e]))return!0;if(Array.isArray(n[e])&&n[e].find(t=>x(t)))return!0}return!1},$=n=>v?n:new Promise(e=>{let t=new FileReader;t.onload=()=>{e(new Blob([t.result],{type:n.type}))},t.readAsArrayBuffer(n)}),b=class{ws;url;constructor(e){this.ws=new WebSocket(e),this.url=e}send(e){return Array.isArray(e)?(e.forEach(t=>this.send(t)),this):(this.ws.send(typeof e=="object"?JSON.stringify(e):e.toString()),this)}on(e,t,r){return this.addEventListener(e,t,r)}off(e,t,r){return this.ws.removeEventListener(e,t,r),this}subscribe(e,t){return this.addEventListener("message",e,t)}addEventListener(e,t,r){return this.ws.addEventListener(e,o=>{if(e==="message"){let s=o.data.toString(),d=s.charCodeAt(0);if(d===47||d===123)try{s=JSON.parse(s)}catch{}else Number.isNaN(+s)?s==="true"?s=!0:s==="fase"&&(s=!1):s=+s;t({...o,data:s})}else t(o)},r),this}removeEventListener(e,t,r){return this.off(e,t,r),this}close(){return this.ws.close(),this}},T=(n,e="",t)=>new Proxy(()=>{},{get(r,o,s){return T(n,`${e}/${o.toString()}`,t)},apply(r,o,[{$query:s,$fetch:d,$headers:L,...m}={$fetch:void 0,$headers:void 0,$query:void 0}]=[{}]){let h=e.lastIndexOf("/"),u=e.slice(h+1),g=k(n,h===-1?"/":e.slice(0,h),s),W=t.fetcher??fetch;return u==="subscribe"?new b(g.replace(/^([^]+):\/\//,g.startsWith("https://")?"wss://":"ws://")):(async()=>{let c,w={...t.$fetch?.headers,...d?.headers,...L};if(u!=="GET"&&u!=="HEAD"){c=Object.keys(m).length?m:void 0;let a=typeof c=="object";if(a&&A(c)){let y=new FormData;for(let[p,f]of Object.entries(c))if(v)y.append(p,f);else if(f instanceof File)y.append(p,await $(f));else if(f instanceof FileList)for(let E=0;E<f.length;E++)y.append(p,await $(f[E]));else y.append(p,f);c=y}else w["content-type"]=a?"application/json":"text/plain",a&&(c=JSON.stringify(c))}let i=await W(g,{method:u,body:c,...t.$fetch,...d,headers:w}),l;switch(i.headers.get("Content-Type")?.split(";")[0]){case"application/json":l=await i.json();break;default:l=await i.text().then(a=>Number.isNaN(+a)?a==="true"?!0:a==="false"?!1:a:+a)}return i.status>300?{data:l,error:new S(i.status,await l),status:i.status,raw:i,headers:i.headers}:{data:l,status:i.status,response:i,headers:i.headers,error:null}})()}}),M=(n,e={fetcher:fetch})=>new Proxy({},{get(t,r){return T(n,r,e)}});export{b as a,M as b};
@@ -1,3 +1,4 @@
1
+ /// <reference types="bun-types" />
1
2
  import type { Elysia } from 'elysia';
2
3
  import type { EdenFetchError } from '../errors';
3
4
  import type { MapError, IsUnknown, IsNever } from '../types';
@@ -11,10 +12,10 @@ export declare namespace EdenFetch {
11
12
  interface Config {
12
13
  fetcher?: typeof globalThis.fetch;
13
14
  }
14
- type Fn<Schema extends Record<string, any>> = <Endpoint extends keyof Schema, Method extends Extract<keyof Schema[Endpoint], string>, Route extends Schema[Endpoint][Method]>(endpoint: Endpoint, options: Omit<RequestInit, 'body' | 'method' | 'headers'> & ('get' extends Method ? {
15
- method?: Uppercase<Method>;
15
+ type Fn<Schema extends Record<string, any>> = <Endpoint extends keyof Schema, Method extends Uppercase<Extract<keyof Schema[Endpoint], string>>, Route extends Schema[Endpoint][Lowercase<Method>]>(endpoint: Endpoint, options: Omit<RequestInit, 'body' | 'method' | 'headers'> & ('GET' extends Method ? {
16
+ method?: Method;
16
17
  } : {
17
- method: Uppercase<Method>;
18
+ method: Method;
18
19
  }) & (IsNever<keyof Route['params']> extends true ? {
19
20
  params?: Record<never, string>;
20
21
  } : {
@@ -0,0 +1 @@
1
+ "use strict";var Eden=(()=>{var p=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var E=(r,e)=>{for(var a in e)p(r,a,{get:e[a],enumerable:!0})},S=(r,e,a,u)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of g(e))!x.call(r,s)&&s!==a&&p(r,s,{get:()=>e[s],enumerable:!(u=m(e,s))||u.enumerable});return r};var j=r=>S(p({},"__esModule",{value:!0}),r);var b={};E(b,{edenFetch:()=>w});var h=class extends Error{status;value;constructor(e,a){super(),this.status=e,this.value=a}};var w=(r,e)=>(a,{query:u,params:s,body:c,...o}={})=>{s&&Object.entries(s).forEach(([t,n])=>{a=a.replace(`:${t}`,n)});let f=o.headers?.["Content-Type"];if(!f||f==="application/json")try{c=JSON.stringify(c)}catch{}let y=e?.fetcher||globalThis.fetch,d=u?`?${new URLSearchParams(u).toString()}`:"",l=()=>y(r+a+d,{...o,headers:c?{"content-type":"application/json",...o.headers}:o.headers,body:c}).then(async t=>{let n;switch(t.headers.get("Content-Type")?.split(";")[0]){case"application/json":n=await t.json();break;default:n=await t.text().then(i=>Number.isNaN(+i)?i==="true"?!0:i==="false"?!1:i:+i);break}return t.status>300?{data:null,status:t.status,headers:t.headers,retry:l,error:new h(t.status,n)}:{data:n,error:null,status:t.status,headers:t.headers,retry:l}});return l()};return j(b);})();
package/dist/fetch.js CHANGED
@@ -1 +1 @@
1
- var p=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var E=(r,e)=>{for(var a in e)p(r,a,{get:e[a],enumerable:!0})},S=(r,e,a,u)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of g(e))!x.call(r,s)&&s!==a&&p(r,s,{get:()=>e[s],enumerable:!(u=m(e,s))||u.enumerable});return r};var j=r=>S(p({},"__esModule",{value:!0}),r);var b={};E(b,{edenFetch:()=>w});module.exports=j(b);var h=class extends Error{status;value;constructor(e,a){super(),this.status=e,this.value=a}};var w=(r,e)=>(a,{query:u,params:s,body:c,...o}={})=>{s&&Object.entries(s).forEach(([t,n])=>{a=a.replace(`:${t}`,n)});let f=o.headers?.["Content-Type"];if(!f||f==="application/json")try{c=JSON.stringify(c)}catch{}let y=e?.fetcher||globalThis.fetch,d=u?`?${new URLSearchParams(u).toString()}`:"",l=()=>y(r+a+d,{...o,headers:c?{"content-type":"application/json",...o.headers}:o.headers,body:c}).then(async t=>{let n;switch(t.headers.get("Content-Type")?.split(";")[0]){case"application/json":n=await t.json();break;default:n=await t.text().then(i=>Number.isNaN(+i)?i==="true"?!0:i==="false"?!1:i:+i);break}return t.status>300?{data:null,status:t.status,headers:t.headers,retry:l,error:new h(t.status,n)}:{data:n,error:null,status:t.status,headers:t.headers,retry:l}});return l()};0&&(module.exports={edenFetch});
1
+ "use strict";var p=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var E=(r,e)=>{for(var a in e)p(r,a,{get:e[a],enumerable:!0})},S=(r,e,a,u)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of g(e))!x.call(r,s)&&s!==a&&p(r,s,{get:()=>e[s],enumerable:!(u=m(e,s))||u.enumerable});return r};var j=r=>S(p({},"__esModule",{value:!0}),r);var b={};E(b,{edenFetch:()=>w});module.exports=j(b);var h=class extends Error{status;value;constructor(e,a){super(),this.status=e,this.value=a}};var w=(r,e)=>(a,{query:u,params:s,body:c,...o}={})=>{s&&Object.entries(s).forEach(([t,n])=>{a=a.replace(`:${t}`,n)});let f=o.headers?.["Content-Type"];if(!f||f==="application/json")try{c=JSON.stringify(c)}catch{}let y=e?.fetcher||globalThis.fetch,d=u?`?${new URLSearchParams(u).toString()}`:"",l=()=>y(r+a+d,{...o,headers:c?{"content-type":"application/json",...o.headers}:o.headers,body:c}).then(async t=>{let n;switch(t.headers.get("Content-Type")?.split(";")[0]){case"application/json":n=await t.json();break;default:n=await t.text().then(i=>Number.isNaN(+i)?i==="true"?!0:i==="false"?!1:i:+i);break}return t.status>300?{data:null,status:t.status,headers:t.headers,retry:l,error:new h(t.status,n)}:{data:n,error:null,status:t.status,headers:t.headers,retry:l}});return l()};0&&(module.exports={edenFetch});
@@ -1,3 +1,4 @@
1
+ /// <reference types="bun-types" />
1
2
  import type { Elysia } from 'elysia';
2
3
  export declare namespace EdenFn {
3
4
  type Create<App extends Elysia<any, any>> = App['meta'] extends {
@@ -0,0 +1 @@
1
+ "use strict";var Eden=(()=>{var U=Object.defineProperty;var Dr=Object.getOwnPropertyDescriptor;var Ur=Object.getOwnPropertyNames;var Mr=Object.prototype.hasOwnProperty;var f=(r,t)=>()=>(r&&(t=r(r=0)),t);var ir=(r,t)=>{for(var e in t)U(r,e,{get:t[e],enumerable:!0})},Kr=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Ur(t))!Mr.call(r,i)&&i!==e&&U(r,i,{get:()=>t[i],enumerable:!(n=Dr(t,i))||n.enumerable});return r};var qr=r=>Kr(U({},"__esModule",{value:!0}),r);var or,sr=f(()=>{"use strict";or=function(){function r(){this.keyToValue=new Map,this.valueToKey=new Map}return r.prototype.set=function(t,e){this.keyToValue.set(t,e),this.valueToKey.set(e,t)},r.prototype.getByKey=function(t){return this.keyToValue.get(t)},r.prototype.getByValue=function(t){return this.valueToKey.get(t)},r.prototype.clear=function(){this.keyToValue.clear(),this.valueToKey.clear()},r}()});var T,M=f(()=>{"use strict";sr();T=function(){function r(t){this.generateIdentifier=t,this.kv=new or}return r.prototype.register=function(t,e){this.kv.getByValue(t)||(e||(e=this.generateIdentifier(t)),this.kv.set(e,t))},r.prototype.clear=function(){this.kv.clear()},r.prototype.getIdentifier=function(t){return this.kv.getByValue(t)},r.prototype.getValue=function(t){return this.kv.getByKey(t)},r}()});var Lr,ar,ur=f(()=>{"use strict";M();Lr=function(){var r=function(t,e){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(n[o]=i[o])},r(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");r(t,e);function n(){this.constructor=t}t.prototype=e===null?Object.create(e):(n.prototype=e.prototype,new n)}}(),ar=function(r){Lr(t,r);function t(){var e=r.call(this,function(n){return n.name})||this;return e.classToAllowedProps=new Map,e}return t.prototype.register=function(e,n){typeof n=="object"?(n.allowProps&&this.classToAllowedProps.set(e,n.allowProps),r.prototype.register.call(this,e,n.identifier)):r.prototype.register.call(this,e,n)},t.prototype.getAllowedProps=function(e){return this.classToAllowedProps.get(e)},t}(T)});function $r(r){if("values"in Object)return Object.values(r);var t=[];for(var e in r)r.hasOwnProperty(e)&&t.push(r[e]);return t}function fr(r,t){var e=$r(r);if("find"in e)return e.find(t);for(var n=e,i=0;i<n.length;i++){var o=n[i];if(t(o))return o}}function O(r,t){Object.entries(r).forEach(function(e){var n=Wr(e,2),i=n[0],o=n[1];return t(o,i)})}function S(r,t){return r.indexOf(t)!==-1}function K(r,t){for(var e=0;e<r.length;e++){var n=r[e];if(t(n))return n}}var Wr,N=f(()=>{"use strict";Wr=function(r,t){var e=typeof Symbol=="function"&&r[Symbol.iterator];if(!e)return r;var n=e.call(r),i,o=[],s;try{for(;(t===void 0||t-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(e=n.return)&&e.call(n)}finally{if(s)throw s.error}}return o}});var lr,cr=f(()=>{"use strict";N();lr=function(){function r(){this.transfomers={}}return r.prototype.register=function(t){this.transfomers[t.name]=t},r.prototype.findApplicable=function(t){return fr(this.transfomers,function(e){return e.isApplicable(t)})},r.prototype.findByName=function(t){return this.transfomers[t]},r}()});var Gr,q,Hr,A,V,c,Qr,Xr,Yr,pr,w,x,L,yr,mr,W,$,vr,gr,hr,dr,z=f(()=>{"use strict";Gr=function(r){return Object.prototype.toString.call(r).slice(8,-1)},q=function(r){return typeof r>"u"},Hr=function(r){return r===null},A=function(r){return typeof r!="object"||r===null||r===Object.prototype?!1:Object.getPrototypeOf(r)===null?!0:r.constructor===Object&&Object.getPrototypeOf(r)===Object.prototype},V=function(r){return A(r)&&Object.keys(r).length===0},c=function(r){return Array.isArray(r)},Qr=function(r){return typeof r=="string"},Xr=function(r){return typeof r=="number"&&!isNaN(r)},Yr=function(r){return typeof r=="boolean"},pr=function(r){return r instanceof RegExp},w=function(r){return r instanceof Map},x=function(r){return r instanceof Set},L=function(r){return Gr(r)==="Symbol"},yr=function(r){return r instanceof Date&&!isNaN(r.valueOf())},mr=function(r){return r instanceof Error},W=function(r){return typeof r=="number"&&isNaN(r)},$=function(r){return Yr(r)||Hr(r)||q(r)||Xr(r)||Qr(r)||L(r)},vr=function(r){return typeof r=="bigint"},gr=function(r){return r===1/0||r===-1/0},hr=function(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)},dr=function(r){return r instanceof URL}});var G,k,P,H=f(()=>{"use strict";G=function(r){return r.replace(/\./g,"\\.")},k=function(r){return r.map(String).map(G).join(".")},P=function(r){for(var t=[],e="",n=0;n<r.length;n++){var i=r.charAt(n),o=i==="\\"&&r.charAt(n+1)===".";if(o){e+=".",n++;continue}var s=i===".";if(s){t.push(e),e="";continue}e+=i}var a=e;return t.push(a),t}});function m(r,t,e,n){return{isApplicable:r,annotation:t,transform:e,untransform:n}}function C(r,t,e,n){return{isApplicable:r,annotation:t,transform:e,untransform:n}}function Z(r,t){if(r?.constructor){var e=!!t.classRegistry.getIdentifier(r.constructor);return e}return!1}var Q,X,Y,br,wr,Zr,xr,Er,Or,Jr,J,Ar,_r,Sr=f(()=>{"use strict";z();N();Q=function(){return Q=Object.assign||function(r){for(var t,e=1,n=arguments.length;e<n;e++){t=arguments[e];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(r[i]=t[i])}return r},Q.apply(this,arguments)},X=function(r,t){var e=typeof Symbol=="function"&&r[Symbol.iterator];if(!e)return r;var n=e.call(r),i,o=[],s;try{for(;(t===void 0||t-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(e=n.return)&&e.call(n)}finally{if(s)throw s.error}}return o},Y=function(r,t){for(var e=0,n=t.length,i=r.length;e<n;e++,i++)r[i]=t[e];return r};br=[m(q,"undefined",function(){return null},function(){}),m(vr,"bigint",function(r){return r.toString()},function(r){return typeof BigInt<"u"?BigInt(r):(console.error("Please add a BigInt polyfill."),r)}),m(yr,"Date",function(r){return r.toISOString()},function(r){return new Date(r)}),m(mr,"Error",function(r,t){var e={name:r.name,message:r.message};return t.allowedErrorProps.forEach(function(n){e[n]=r[n]}),e},function(r,t){var e=new Error(r.message);return e.name=r.name,e.stack=r.stack,t.allowedErrorProps.forEach(function(n){e[n]=r[n]}),e}),m(pr,"regexp",function(r){return""+r},function(r){var t=r.slice(1,r.lastIndexOf("/")),e=r.slice(r.lastIndexOf("/")+1);return new RegExp(t,e)}),m(x,"set",function(r){return Y([],X(r.values()))},function(r){return new Set(r)}),m(w,"map",function(r){return Y([],X(r.entries()))},function(r){return new Map(r)}),m(function(r){return W(r)||gr(r)},"number",function(r){return W(r)?"NaN":r>0?"Infinity":"-Infinity"},Number),m(function(r){return r===0&&1/r===-1/0},"number",function(){return"-0"},Number),m(dr,"URL",function(r){return r.toString()},function(r){return new URL(r)})];wr=C(function(r,t){if(L(r)){var e=!!t.symbolRegistry.getIdentifier(r);return e}return!1},function(r,t){var e=t.symbolRegistry.getIdentifier(r);return["symbol",e]},function(r){return r.description},function(r,t,e){var n=e.symbolRegistry.getValue(t[1]);if(!n)throw new Error("Trying to deserialize unknown symbol");return n}),Zr=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,Uint8ClampedArray].reduce(function(r,t){return r[t.name]=t,r},{}),xr=C(hr,function(r){return["typed-array",r.constructor.name]},function(r){return Y([],X(r))},function(r,t){var e=Zr[t[1]];if(!e)throw new Error("Trying to deserialize unknown typed array");return new e(r)});Er=C(Z,function(r,t){var e=t.classRegistry.getIdentifier(r.constructor);return["class",e]},function(r,t){var e=t.classRegistry.getAllowedProps(r.constructor);if(!e)return Q({},r);var n={};return e.forEach(function(i){n[i]=r[i]}),n},function(r,t,e){var n=e.classRegistry.getValue(t[1]);if(!n)throw new Error("Trying to deserialize unknown class - check https://github.com/blitz-js/superjson/issues/116#issuecomment-773996564");return Object.assign(Object.create(n.prototype),r)}),Or=C(function(r,t){return!!t.customTransformerRegistry.findApplicable(r)},function(r,t){var e=t.customTransformerRegistry.findApplicable(r);return["custom",e.name]},function(r,t){var e=t.customTransformerRegistry.findApplicable(r);return e.serialize(r)},function(r,t,e){var n=e.customTransformerRegistry.findByName(t[1]);if(!n)throw new Error("Trying to deserialize unknown custom value");return n.deserialize(r)}),Jr=[Er,wr,Or,xr],J=function(r,t){var e=K(Jr,function(i){return i.isApplicable(r,t)});if(e)return{value:e.transform(r,t),type:e.annotation(r,t)};var n=K(br,function(i){return i.isApplicable(r,t)});if(n)return{value:n.transform(r,t),type:n.annotation}},Ar={};br.forEach(function(r){Ar[r.annotation]=r});_r=function(r,t,e){if(c(t))switch(t[0]){case"symbol":return wr.untransform(r,t,e);case"class":return Er.untransform(r,t,e);case"custom":return Or.untransform(r,t,e);case"typed-array":return xr.untransform(r,t,e);default:throw new Error("Unknown transformation: "+t)}else{var n=Ar[t];if(!n)throw new Error("Unknown transformation: "+t);return n.untransform(r,e)}}});function Pr(r){if(S(r,"__proto__"))throw new Error("__proto__ is not allowed as a property");if(S(r,"prototype"))throw new Error("prototype is not allowed as a property");if(S(r,"constructor"))throw new Error("constructor is not allowed as a property")}var R,Rr,F,Nr=f(()=>{"use strict";z();N();R=function(r,t){for(var e=r.keys();t>0;)e.next(),t--;return e.next().value};Rr=function(r,t){Pr(t);for(var e=0;e<t.length;e++){var n=t[e];if(x(r))r=R(r,+n);else if(w(r)){var i=+n,o=+t[++e]==0?"key":"value",s=R(r,i);switch(o){case"key":r=s;break;case"value":r=r.get(s);break}}else r=r[n]}return r},F=function(r,t,e){if(Pr(t),t.length===0)return e(r);for(var n=r,i=0;i<t.length-1;i++){var o=t[i];if(c(n)){var s=+o;n=n[s]}else if(A(n))n=n[o];else if(x(n)){var a=+o;n=R(n,a)}else if(w(n)){var u=i===t.length-2;if(u)break;var a=+o,p=+t[++i]==0?"key":"value",l=R(n,a);switch(p){case"key":n=l;break;case"value":n=n.get(l);break}}}var y=t[t.length-1];if(c(n)?n[+y]=e(n[+y]):A(n)&&(n[y]=e(n[y])),x(n)){var h=R(n,+y),d=e(h);h!==d&&(n.delete(h),n.add(d))}if(w(n)){var a=+t[t.length-2],b=R(n,a),p=+y==0?"key":"value";switch(p){case"key":{var I=e(b);n.set(I,n.get(b)),I!==b&&n.delete(b);break}case"value":{n.set(b,e(n.get(b)));break}}}return r}});function rr(r,t,e){if(e===void 0&&(e=[]),!!r){if(!c(r)){O(r,function(s,a){return rr(s,t,E(E([],v(e)),v(P(a))))});return}var n=v(r,2),i=n[0],o=n[1];o&&O(o,function(s,a){rr(s,t,E(E([],v(e)),v(P(a))))}),t(i,e)}}function Ir(r,t,e){return rr(t,function(n,i){r=F(r,i,function(o){return _r(o,n,e)})}),r}function Tr(r,t){function e(s,a){var u=Rr(r,P(a));s.map(P).forEach(function(p){r=F(r,p,function(){return u})})}if(c(t)){var n=v(t,2),i=n[0],o=n[1];i.forEach(function(s){r=F(r,P(s),function(){return r})}),o&&O(o,e)}else O(t,e);return r}function tt(r,t,e){var n=e.get(r);n?n.push(t):e.set(r,[t])}function Vr(r){var t={},e=void 0;return r.forEach(function(n){if(!(n.length<=1)){var i=v(n.map(function(a){return a.map(String)}).sort(function(a,u){return a.length-u.length})),o=i[0],s=i.slice(1);o.length===0?e=s.map(k):t[k(o)]=s.map(k)}}),e?V(t)?[e]:[e,t]:V(t)?void 0:t}var v,E,rt,tr,zr=f(()=>{"use strict";z();H();Sr();N();H();Nr();v=function(r,t){var e=typeof Symbol=="function"&&r[Symbol.iterator];if(!e)return r;var n=e.call(r),i,o=[],s;try{for(;(t===void 0||t-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(e=n.return)&&e.call(n)}finally{if(s)throw s.error}}return o},E=function(r,t){for(var e=0,n=t.length,i=r.length;e<n;e++,i++)r[i]=t[e];return r};rt=function(r,t){return A(r)||c(r)||w(r)||x(r)||Z(r,t)};tr=function(r,t,e,n,i){var o;if(n===void 0&&(n=[]),i===void 0&&(i=[]),$(r)||tt(r,n,t),!rt(r,e)){var s=J(r,e);return s?{transformedValue:s.value,annotations:[s.type]}:{transformedValue:r}}if(S(i,r))return{transformedValue:null};var a=J(r,e),u=(o=a?.value)!==null&&o!==void 0?o:r;$(r)||(i=E(E([],v(i)),[r]));var p=c(u)?[]:{},l={};return O(u,function(y,h){var d=tr(y,t,e,E(E([],v(n)),[h]),i);p[h]=d.transformedValue,c(d.annotations)?l[h]=d.annotations:A(d.annotations)&&O(d.annotations,function(b,I){l[G(h)+"."+I]=b})}),V(l)?{transformedValue:p,annotations:a?[a.type]:void 0}:{transformedValue:p,annotations:a?[a.type,l]:l}}});function B(r){return Object.prototype.toString.call(r).slice(8,-1)}function et(r){return B(r)==="Undefined"}function nt(r){return B(r)==="Null"}function kr(r){if(B(r)!=="Object")return!1;let t=Object.getPrototypeOf(r);return t.constructor===Object&&t===Object.prototype}function er(r){return B(r)==="Array"}function it(r,t,e,n,i){return o=>r(o)||t(o)||!!e&&e(o)||!!n&&n(o)||!!i&&i(o)}var qt,Cr=f(()=>{"use strict";qt=it(nt,et)});function ot(r,t,e,n,i){let o={}.propertyIsEnumerable.call(n,t)?"enumerable":"nonenumerable";o==="enumerable"&&(r[t]=e),i&&o==="nonenumerable"&&Object.defineProperty(r,t,{value:e,enumerable:!1,writable:!0,configurable:!0})}function j(r,t={}){if(er(r))return r.map(i=>j(i,t));if(!kr(r))return r;let e=Object.getOwnPropertyNames(r),n=Object.getOwnPropertySymbols(r);return[...e,...n].reduce((i,o)=>{if(er(t.props)&&!t.props.includes(o))return i;let s=r[o],a=j(s,t);return ot(i,o,a,r,t.nonenumerable),i},{})}var Fr=f(()=>{"use strict";Cr()});var Br={};ir(Br,{allowErrorProps:()=>gt,default:()=>ut,deserialize:()=>lt,parse:()=>pt,registerClass:()=>yt,registerCustom:()=>mt,registerSymbol:()=>vt,serialize:()=>ft,stringify:()=>ct});var _,st,at,g,ut,ft,lt,ct,pt,yt,mt,vt,gt,jr=f(()=>{"use strict";ur();M();cr();zr();Fr();_=function(){return _=Object.assign||function(r){for(var t,e=1,n=arguments.length;e<n;e++){t=arguments[e];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(r[i]=t[i])}return r},_.apply(this,arguments)},st=function(r,t){var e=typeof Symbol=="function"&&r[Symbol.iterator];if(!e)return r;var n=e.call(r),i,o=[],s;try{for(;(t===void 0||t-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(e=n.return)&&e.call(n)}finally{if(s)throw s.error}}return o},at=function(r,t){for(var e=0,n=t.length,i=r.length;e<n;e++,i++)r[i]=t[e];return r},g=function(){function r(){this.classRegistry=new ar,this.symbolRegistry=new T(function(t){var e;return(e=t.description)!==null&&e!==void 0?e:""}),this.customTransformerRegistry=new lr,this.allowedErrorProps=[]}return r.prototype.serialize=function(t){var e=new Map,n=tr(t,e,this),i={json:n.transformedValue};n.annotations&&(i.meta=_(_({},i.meta),{values:n.annotations}));var o=Vr(e);return o&&(i.meta=_(_({},i.meta),{referentialEqualities:o})),i},r.prototype.deserialize=function(t){var e=t.json,n=t.meta,i=j(e);return n?.values&&(i=Ir(i,n.values,this)),n?.referentialEqualities&&(i=Tr(i,n.referentialEqualities)),i},r.prototype.stringify=function(t){return JSON.stringify(this.serialize(t))},r.prototype.parse=function(t){return this.deserialize(JSON.parse(t))},r.prototype.registerClass=function(t,e){this.classRegistry.register(t,e)},r.prototype.registerSymbol=function(t,e){this.symbolRegistry.register(t,e)},r.prototype.registerCustom=function(t,e){this.customTransformerRegistry.register(_({name:e},t))},r.prototype.allowErrorProps=function(){for(var t,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];(t=this.allowedErrorProps).push.apply(t,at([],st(e)))},r.defaultInstance=new r,r.serialize=r.defaultInstance.serialize.bind(r.defaultInstance),r.deserialize=r.defaultInstance.deserialize.bind(r.defaultInstance),r.stringify=r.defaultInstance.stringify.bind(r.defaultInstance),r.parse=r.defaultInstance.parse.bind(r.defaultInstance),r.registerClass=r.defaultInstance.registerClass.bind(r.defaultInstance),r.registerSymbol=r.defaultInstance.registerSymbol.bind(r.defaultInstance),r.registerCustom=r.defaultInstance.registerCustom.bind(r.defaultInstance),r.allowErrorProps=r.defaultInstance.allowErrorProps.bind(r.defaultInstance),r}(),ut=g,ft=g.serialize,lt=g.deserialize,ct=g.stringify,pt=g.parse,yt=g.registerClass,mt=g.registerCustom,vt=g.registerSymbol,gt=g.allowErrorProps});var dt={};ir(dt,{edenFn:()=>ht});var D=class r{url;config;pendings=[];operation=null;isFetching=!1;sJson;constructor(t,e={}){this.url=t,this.config=e,this.sJson=Promise.resolve().then(()=>(jr(),Br)).then(n=>({serialize:n.serialize,deserialize:n.deserialize}))}setConfig(t){this.config=t}clone(t){return new r(this.url,t??this.config)}async run(t,e){let n=+this.pendings.length;if(this.pendings.push(e!==void 0?{n:t,p:e}:{n:t}),this.isFetching)return this.operation?.then(o=>o[n]);this.isFetching=!0,this.operation=new Promise(o=>{setTimeout(async()=>{let s=[...this.pendings];this.pendings=[];let{serialize:a,deserialize:u}=await this.sJson,l=await(this.config?.fetcher||globalThis.fetch)(`${this.url}${this.config.fn??"/~fn"}`,{method:"POST",...this.config.fetch,headers:{"content-type":"elysia/fn",...this.config.fetch?.headers},body:JSON.stringify(a(s))});l.status===200?o(l.json().then(y=>u(y))):o(Array(s.length).fill(new Error(await l.text())))},33)});let i=await this.operation.then(o=>o[n]);return this.operation=null,this.isFetching=!1,i}};var nr=(r,t,e)=>new Proxy((...n)=>{},{get(n,i,o){return nr(r,[...t,i],e)},apply(n,i,o){let s=o[0],a=t[0];if(t.length===1){if(a in Object.prototype||a in Promise.prototype)return n(...o);switch(a){case"toJSON":return n(...o);case"$set":return e.setConfig(s);case"$clone":return nr(r,[],e.clone(s))}}return e.run(t,o).then(u=>{if(u instanceof Error)throw u;return u})}}),ht=(r,t)=>nr(r,[],new D(r,t));return qr(dt);})();
package/dist/fn.js CHANGED
@@ -1 +1 @@
1
- var u=Object.create;var c=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var m=Object.getPrototypeOf,E=Object.prototype.hasOwnProperty;var w=(n,e)=>{for(var t in e)c(n,t,{get:e[t],enumerable:!0})},g=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of F(e))!E.call(n,r)&&r!==t&&c(n,r,{get:()=>e[r],enumerable:!(i=d(e,r))||i.enumerable});return n};var z=(n,e,t)=>(t=n!=null?u(m(n)):{},g(e||!n||!n.__esModule?c(t,"default",{value:n,enumerable:!0}):t,n)),C=n=>g(c({},"__esModule",{value:!0}),n);var P={};w(P,{edenFn:()=>x});module.exports=C(P);var f=class n{url;config;pendings=[];operation=null;isFetching=!1;sJson;constructor(e,t={}){this.url=e,this.config=t,this.sJson=import("superjson").then(i=>({serialize:i.serialize,deserialize:i.deserialize}))}setConfig(e){this.config=e}clone(e){return new n(this.url,e??this.config)}async run(e,t){let i=+this.pendings.length;if(this.pendings.push(t!==void 0?{n:e,p:t}:{n:e}),this.isFetching)return this.operation?.then(s=>s[i]);this.isFetching=!0,this.operation=new Promise(s=>{setTimeout(async()=>{let o=[...this.pendings];this.pendings=[];let{serialize:a,deserialize:h}=await this.sJson,p=await(this.config?.fetcher||globalThis.fetch)(`${this.url}${this.config.fn??"/~fn"}`,{method:"POST",...this.config.fetch,headers:{"content-type":"elysia/fn",...this.config.fetch?.headers},body:JSON.stringify(a(o))});p.status===200?s(p.json().then(y=>h(y))):s(Array(o.length).fill(new Error(await p.text())))},33)});let r=await this.operation.then(s=>s[i]);return this.operation=null,this.isFetching=!1,r}};var l=(n,e,t)=>new Proxy((...i)=>{},{get(i,r,s){return l(n,[...e,r],t)},apply(i,r,s){let o=s[0],a=e[0];if(e.length===1){if(a in Object.prototype||a in Promise.prototype)return i(...s);switch(a){case"toJSON":return i(...s);case"$set":return t.setConfig(o);case"$clone":return l(n,[],t.clone(o))}}return t.run(e,s).then(h=>{if(h instanceof Error)throw h;return h})}}),x=(n,e)=>l(n,[],new f(n,e));0&&(module.exports={edenFn});
1
+ "use strict";var u=Object.create;var c=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var m=Object.getPrototypeOf,E=Object.prototype.hasOwnProperty;var w=(n,e)=>{for(var t in e)c(n,t,{get:e[t],enumerable:!0})},g=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of F(e))!E.call(n,r)&&r!==t&&c(n,r,{get:()=>e[r],enumerable:!(i=d(e,r))||i.enumerable});return n};var z=(n,e,t)=>(t=n!=null?u(m(n)):{},g(e||!n||!n.__esModule?c(t,"default",{value:n,enumerable:!0}):t,n)),C=n=>g(c({},"__esModule",{value:!0}),n);var P={};w(P,{edenFn:()=>x});module.exports=C(P);var f=class n{url;config;pendings=[];operation=null;isFetching=!1;sJson;constructor(e,t={}){this.url=e,this.config=t,this.sJson=import("superjson").then(i=>({serialize:i.serialize,deserialize:i.deserialize}))}setConfig(e){this.config=e}clone(e){return new n(this.url,e??this.config)}async run(e,t){let i=+this.pendings.length;if(this.pendings.push(t!==void 0?{n:e,p:t}:{n:e}),this.isFetching)return this.operation?.then(s=>s[i]);this.isFetching=!0,this.operation=new Promise(s=>{setTimeout(async()=>{let o=[...this.pendings];this.pendings=[];let{serialize:a,deserialize:h}=await this.sJson,p=await(this.config?.fetcher||globalThis.fetch)(`${this.url}${this.config.fn??"/~fn"}`,{method:"POST",...this.config.fetch,headers:{"content-type":"elysia/fn",...this.config.fetch?.headers},body:JSON.stringify(a(o))});p.status===200?s(p.json().then(y=>h(y))):s(Array(o.length).fill(new Error(await p.text())))},33)});let r=await this.operation.then(s=>s[i]);return this.operation=null,this.isFetching=!1,r}};var l=(n,e,t)=>new Proxy((...i)=>{},{get(i,r,s){return l(n,[...e,r],t)},apply(i,r,s){let o=s[0],a=e[0];if(e.length===1){if(a in Object.prototype||a in Promise.prototype)return i(...s);switch(a){case"toJSON":return i(...s);case"$set":return t.setConfig(o);case"$clone":return l(n,[],t.clone(o))}}return t.run(e,s).then(h=>{if(h instanceof Error)throw h;return h})}}),x=(n,e)=>l(n,[],new f(n,e));0&&(module.exports={edenFn});
@@ -0,0 +1 @@
1
+ "use strict";var Eden=(()=>{var G=Object.defineProperty;var tr=Object.getOwnPropertyDescriptor;var nr=Object.getOwnPropertyNames;var ir=Object.prototype.hasOwnProperty;var d=(e,r)=>()=>(e&&(r=e(e=0)),r);var me=(e,r)=>{for(var t in r)G(e,t,{get:r[t],enumerable:!0})},sr=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of nr(r))!ir.call(e,i)&&i!==t&&G(e,i,{get:()=>r[i],enumerable:!(n=tr(r,i))||n.enumerable});return e};var or=e=>sr(G({},"__esModule",{value:!0}),e);var Ee,xe=d(()=>{"use strict";Ee=function(){function e(){this.keyToValue=new Map,this.valueToKey=new Map}return e.prototype.set=function(r,t){this.keyToValue.set(r,t),this.valueToKey.set(t,r)},e.prototype.getByKey=function(r){return this.keyToValue.get(r)},e.prototype.getByValue=function(r){return this.valueToKey.get(r)},e.prototype.clear=function(){this.keyToValue.clear(),this.valueToKey.clear()},e}()});var B,X=d(()=>{"use strict";xe();B=function(){function e(r){this.generateIdentifier=r,this.kv=new Ee}return e.prototype.register=function(r,t){this.kv.getByValue(r)||(t||(t=this.generateIdentifier(r)),this.kv.set(t,r))},e.prototype.clear=function(){this.kv.clear()},e.prototype.getIdentifier=function(r){return this.kv.getByValue(r)},e.prototype.getValue=function(r){return this.kv.getByKey(r)},e}()});var ur,Se,Oe=d(()=>{"use strict";X();ur=function(){var e=function(r,t){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(n[s]=i[s])},e(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");e(r,t);function n(){this.constructor=r}r.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),Se=function(e){ur(r,e);function r(){var t=e.call(this,function(n){return n.name})||this;return t.classToAllowedProps=new Map,t}return r.prototype.register=function(t,n){typeof n=="object"?(n.allowProps&&this.classToAllowedProps.set(t,n.allowProps),e.prototype.register.call(this,t,n.identifier)):e.prototype.register.call(this,t,n)},r.prototype.getAllowedProps=function(t){return this.classToAllowedProps.get(t)},r}(B)});function cr(e){if("values"in Object)return Object.values(e);var r=[];for(var t in e)e.hasOwnProperty(t)&&r.push(e[t]);return r}function Ae(e,r){var t=cr(e);if("find"in t)return t.find(r);for(var n=t,i=0;i<n.length;i++){var s=n[i];if(r(s))return s}}function P(e,r){Object.entries(e).forEach(function(t){var n=fr(t,2),i=n[0],s=n[1];return r(s,i)})}function T(e,r){return e.indexOf(r)!==-1}function Y(e,r){for(var t=0;t<e.length;t++){var n=e[t];if(r(n))return n}}var fr,z=d(()=>{"use strict";fr=function(e,r){var t=typeof Symbol=="function"&&e[Symbol.iterator];if(!t)return e;var n=t.call(e),i,s=[],o;try{for(;(r===void 0||r-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(a){o={error:a}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(o)throw o.error}}return s}});var Ne,Pe=d(()=>{"use strict";z();Ne=function(){function e(){this.transfomers={}}return e.prototype.register=function(r){this.transfomers[r.name]=r},e.prototype.findApplicable=function(r){return Ae(this.transfomers,function(t){return t.isApplicable(r)})},e.prototype.findByName=function(r){return this.transfomers[r]},e}()});var lr,Z,pr,_,K,g,yr,mr,dr,_e,x,S,ee,Re,ke,re,te,Te,Fe,Ie,Ce,$=d(()=>{"use strict";lr=function(e){return Object.prototype.toString.call(e).slice(8,-1)},Z=function(e){return typeof e>"u"},pr=function(e){return e===null},_=function(e){return typeof e!="object"||e===null||e===Object.prototype?!1:Object.getPrototypeOf(e)===null?!0:e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype},K=function(e){return _(e)&&Object.keys(e).length===0},g=function(e){return Array.isArray(e)},yr=function(e){return typeof e=="string"},mr=function(e){return typeof e=="number"&&!isNaN(e)},dr=function(e){return typeof e=="boolean"},_e=function(e){return e instanceof RegExp},x=function(e){return e instanceof Map},S=function(e){return e instanceof Set},ee=function(e){return lr(e)==="Symbol"},Re=function(e){return e instanceof Date&&!isNaN(e.valueOf())},ke=function(e){return e instanceof Error},re=function(e){return typeof e=="number"&&isNaN(e)},te=function(e){return dr(e)||pr(e)||Z(e)||mr(e)||yr(e)||ee(e)},Te=function(e){return typeof e=="bigint"},Fe=function(e){return e===1/0||e===-1/0},Ie=function(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)},Ce=function(e){return e instanceof URL}});var ne,L,F,ie=d(()=>{"use strict";ne=function(e){return e.replace(/\./g,"\\.")},L=function(e){return e.map(String).map(ne).join(".")},F=function(e){for(var r=[],t="",n=0;n<e.length;n++){var i=e.charAt(n),s=i==="\\"&&e.charAt(n+1)===".";if(s){t+=".",n++;continue}var o=i===".";if(o){r.push(t),t="";continue}t+=i}var a=t;return r.push(a),r}});function v(e,r,t,n){return{isApplicable:e,annotation:r,transform:t,untransform:n}}function M(e,r,t,n){return{isApplicable:e,annotation:r,transform:t,untransform:n}}function ue(e,r){if(e?.constructor){var t=!!r.classRegistry.getIdentifier(e.constructor);return t}return!1}var se,oe,ae,Ve,ze,hr,je,Be,Ke,gr,fe,$e,Le,Me=d(()=>{"use strict";$();z();se=function(){return se=Object.assign||function(e){for(var r,t=1,n=arguments.length;t<n;t++){r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},se.apply(this,arguments)},oe=function(e,r){var t=typeof Symbol=="function"&&e[Symbol.iterator];if(!t)return e;var n=t.call(e),i,s=[],o;try{for(;(r===void 0||r-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(a){o={error:a}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(o)throw o.error}}return s},ae=function(e,r){for(var t=0,n=r.length,i=e.length;t<n;t++,i++)e[i]=r[t];return e};Ve=[v(Z,"undefined",function(){return null},function(){}),v(Te,"bigint",function(e){return e.toString()},function(e){return typeof BigInt<"u"?BigInt(e):(console.error("Please add a BigInt polyfill."),e)}),v(Re,"Date",function(e){return e.toISOString()},function(e){return new Date(e)}),v(ke,"Error",function(e,r){var t={name:e.name,message:e.message};return r.allowedErrorProps.forEach(function(n){t[n]=e[n]}),t},function(e,r){var t=new Error(e.message);return t.name=e.name,t.stack=e.stack,r.allowedErrorProps.forEach(function(n){t[n]=e[n]}),t}),v(_e,"regexp",function(e){return""+e},function(e){var r=e.slice(1,e.lastIndexOf("/")),t=e.slice(e.lastIndexOf("/")+1);return new RegExp(r,t)}),v(S,"set",function(e){return ae([],oe(e.values()))},function(e){return new Set(e)}),v(x,"map",function(e){return ae([],oe(e.entries()))},function(e){return new Map(e)}),v(function(e){return re(e)||Fe(e)},"number",function(e){return re(e)?"NaN":e>0?"Infinity":"-Infinity"},Number),v(function(e){return e===0&&1/e===-1/0},"number",function(){return"-0"},Number),v(Ce,"URL",function(e){return e.toString()},function(e){return new URL(e)})];ze=M(function(e,r){if(ee(e)){var t=!!r.symbolRegistry.getIdentifier(e);return t}return!1},function(e,r){var t=r.symbolRegistry.getIdentifier(e);return["symbol",t]},function(e){return e.description},function(e,r,t){var n=t.symbolRegistry.getValue(r[1]);if(!n)throw new Error("Trying to deserialize unknown symbol");return n}),hr=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,Uint8ClampedArray].reduce(function(e,r){return e[r.name]=r,e},{}),je=M(Ie,function(e){return["typed-array",e.constructor.name]},function(e){return ae([],oe(e))},function(e,r){var t=hr[r[1]];if(!t)throw new Error("Trying to deserialize unknown typed array");return new t(e)});Be=M(ue,function(e,r){var t=r.classRegistry.getIdentifier(e.constructor);return["class",t]},function(e,r){var t=r.classRegistry.getAllowedProps(e.constructor);if(!t)return se({},e);var n={};return t.forEach(function(i){n[i]=e[i]}),n},function(e,r,t){var n=t.classRegistry.getValue(r[1]);if(!n)throw new Error("Trying to deserialize unknown class - check https://github.com/blitz-js/superjson/issues/116#issuecomment-773996564");return Object.assign(Object.create(n.prototype),e)}),Ke=M(function(e,r){return!!r.customTransformerRegistry.findApplicable(e)},function(e,r){var t=r.customTransformerRegistry.findApplicable(e);return["custom",t.name]},function(e,r){var t=r.customTransformerRegistry.findApplicable(e);return t.serialize(e)},function(e,r,t){var n=t.customTransformerRegistry.findByName(r[1]);if(!n)throw new Error("Trying to deserialize unknown custom value");return n.deserialize(e)}),gr=[Be,ze,Ke,je],fe=function(e,r){var t=Y(gr,function(i){return i.isApplicable(e,r)});if(t)return{value:t.transform(e,r),type:t.annotation(e,r)};var n=Y(Ve,function(i){return i.isApplicable(e,r)});if(n)return{value:n.transform(e,r),type:n.annotation}},$e={};Ve.forEach(function(e){$e[e.annotation]=e});Le=function(e,r,t){if(g(r))switch(r[0]){case"symbol":return ze.untransform(e,r,t);case"class":return Be.untransform(e,r,t);case"custom":return Ke.untransform(e,r,t);case"typed-array":return je.untransform(e,r,t);default:throw new Error("Unknown transformation: "+r)}else{var n=$e[r];if(!n)throw new Error("Unknown transformation: "+r);return n.untransform(e,t)}}});function De(e){if(T(e,"__proto__"))throw new Error("__proto__ is not allowed as a property");if(T(e,"prototype"))throw new Error("prototype is not allowed as a property");if(T(e,"constructor"))throw new Error("constructor is not allowed as a property")}var I,We,D,Ue=d(()=>{"use strict";$();z();I=function(e,r){for(var t=e.keys();r>0;)t.next(),r--;return t.next().value};We=function(e,r){De(r);for(var t=0;t<r.length;t++){var n=r[t];if(S(e))e=I(e,+n);else if(x(e)){var i=+n,s=+r[++t]==0?"key":"value",o=I(e,i);switch(s){case"key":e=o;break;case"value":e=e.get(o);break}}else e=e[n]}return e},D=function(e,r,t){if(De(r),r.length===0)return t(e);for(var n=e,i=0;i<r.length-1;i++){var s=r[i];if(g(n)){var o=+s;n=n[o]}else if(_(n))n=n[s];else if(S(n)){var a=+s;n=I(n,a)}else if(x(n)){var c=i===r.length-2;if(c)break;var a=+s,y=+r[++i]==0?"key":"value",f=I(n,a);switch(y){case"key":n=f;break;case"value":n=n.get(f);break}}}var u=r[r.length-1];if(g(n)?n[+u]=t(n[+u]):_(n)&&(n[u]=t(n[u])),S(n)){var l=I(n,+u),m=t(l);l!==m&&(n.delete(l),n.add(m))}if(x(n)){var a=+r[r.length-2],p=I(n,a),y=+u==0?"key":"value";switch(y){case"key":{var A=t(p);n.set(A,n.get(p)),A!==p&&n.delete(p);break}case"value":{n.set(p,t(n.get(p)));break}}}return e}});function ce(e,r,t){if(t===void 0&&(t=[]),!!e){if(!g(e)){P(e,function(o,a){return ce(o,r,O(O([],w(t)),w(F(a))))});return}var n=w(e,2),i=n[0],s=n[1];s&&P(s,function(o,a){ce(o,r,O(O([],w(t)),w(F(a))))}),r(i,t)}}function qe(e,r,t){return ce(r,function(n,i){e=D(e,i,function(s){return Le(s,n,t)})}),e}function He(e,r){function t(o,a){var c=We(e,F(a));o.map(F).forEach(function(y){e=D(e,y,function(){return c})})}if(g(r)){var n=w(r,2),i=n[0],s=n[1];i.forEach(function(o){e=D(e,F(o),function(){return e})}),s&&P(s,t)}else P(r,t);return e}function br(e,r,t){var n=t.get(e);n?n.push(r):t.set(e,[r])}function Ge(e){var r={},t=void 0;return e.forEach(function(n){if(!(n.length<=1)){var i=w(n.map(function(a){return a.map(String)}).sort(function(a,c){return a.length-c.length})),s=i[0],o=i.slice(1);s.length===0?t=o.map(L):r[L(s)]=o.map(L)}}),t?K(r)?[t]:[t,r]:K(r)?void 0:r}var w,O,vr,le,Je=d(()=>{"use strict";$();ie();Me();z();ie();Ue();w=function(e,r){var t=typeof Symbol=="function"&&e[Symbol.iterator];if(!t)return e;var n=t.call(e),i,s=[],o;try{for(;(r===void 0||r-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(a){o={error:a}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(o)throw o.error}}return s},O=function(e,r){for(var t=0,n=r.length,i=e.length;t<n;t++,i++)e[i]=r[t];return e};vr=function(e,r){return _(e)||g(e)||x(e)||S(e)||ue(e,r)};le=function(e,r,t,n,i){var s;if(n===void 0&&(n=[]),i===void 0&&(i=[]),te(e)||br(e,n,r),!vr(e,t)){var o=fe(e,t);return o?{transformedValue:o.value,annotations:[o.type]}:{transformedValue:e}}if(T(i,e))return{transformedValue:null};var a=fe(e,t),c=(s=a?.value)!==null&&s!==void 0?s:e;te(e)||(i=O(O([],w(i)),[e]));var y=g(c)?[]:{},f={};return P(c,function(u,l){var m=le(u,r,t,O(O([],w(n)),[l]),i);y[l]=m.transformedValue,g(m.annotations)?f[l]=m.annotations:_(m.annotations)&&P(m.annotations,function(p,A){f[ne(l)+"."+A]=p})}),K(f)?{transformedValue:y,annotations:a?[a.type]:void 0}:{transformedValue:y,annotations:a?[a.type,f]:f}}});function W(e){return Object.prototype.toString.call(e).slice(8,-1)}function wr(e){return W(e)==="Undefined"}function Er(e){return W(e)==="Null"}function Qe(e){if(W(e)!=="Object")return!1;let r=Object.getPrototypeOf(e);return r.constructor===Object&&r===Object.prototype}function pe(e){return W(e)==="Array"}function xr(e,r,t,n,i){return s=>e(s)||r(s)||!!t&&t(s)||!!n&&n(s)||!!i&&i(s)}var mt,Xe=d(()=>{"use strict";mt=xr(Er,wr)});function Sr(e,r,t,n,i){let s={}.propertyIsEnumerable.call(n,r)?"enumerable":"nonenumerable";s==="enumerable"&&(e[r]=t),i&&s==="nonenumerable"&&Object.defineProperty(e,r,{value:t,enumerable:!1,writable:!0,configurable:!0})}function U(e,r={}){if(pe(e))return e.map(i=>U(i,r));if(!Qe(e))return e;let t=Object.getOwnPropertyNames(e),n=Object.getOwnPropertySymbols(e);return[...t,...n].reduce((i,s)=>{if(pe(r.props)&&!r.props.includes(s))return i;let o=e[s],a=U(o,r);return Sr(i,s,a,e,r.nonenumerable),i},{})}var Ye=d(()=>{"use strict";Xe()});var Ze={};me(Ze,{allowErrorProps:()=>Cr,default:()=>Nr,deserialize:()=>_r,parse:()=>kr,registerClass:()=>Tr,registerCustom:()=>Fr,registerSymbol:()=>Ir,serialize:()=>Pr,stringify:()=>Rr});var R,Or,Ar,E,Nr,Pr,_r,Rr,kr,Tr,Fr,Ir,Cr,er=d(()=>{"use strict";Oe();X();Pe();Je();Ye();R=function(){return R=Object.assign||function(e){for(var r,t=1,n=arguments.length;t<n;t++){r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},R.apply(this,arguments)},Or=function(e,r){var t=typeof Symbol=="function"&&e[Symbol.iterator];if(!t)return e;var n=t.call(e),i,s=[],o;try{for(;(r===void 0||r-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(a){o={error:a}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(o)throw o.error}}return s},Ar=function(e,r){for(var t=0,n=r.length,i=e.length;t<n;t++,i++)e[i]=r[t];return e},E=function(){function e(){this.classRegistry=new Se,this.symbolRegistry=new B(function(r){var t;return(t=r.description)!==null&&t!==void 0?t:""}),this.customTransformerRegistry=new Ne,this.allowedErrorProps=[]}return e.prototype.serialize=function(r){var t=new Map,n=le(r,t,this),i={json:n.transformedValue};n.annotations&&(i.meta=R(R({},i.meta),{values:n.annotations}));var s=Ge(t);return s&&(i.meta=R(R({},i.meta),{referentialEqualities:s})),i},e.prototype.deserialize=function(r){var t=r.json,n=r.meta,i=U(t);return n?.values&&(i=qe(i,n.values,this)),n?.referentialEqualities&&(i=He(i,n.referentialEqualities)),i},e.prototype.stringify=function(r){return JSON.stringify(this.serialize(r))},e.prototype.parse=function(r){return this.deserialize(JSON.parse(r))},e.prototype.registerClass=function(r,t){this.classRegistry.register(r,t)},e.prototype.registerSymbol=function(r,t){this.symbolRegistry.register(r,t)},e.prototype.registerCustom=function(r,t){this.customTransformerRegistry.register(R({name:t},r))},e.prototype.allowErrorProps=function(){for(var r,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];(r=this.allowedErrorProps).push.apply(r,Ar([],Or(t)))},e.defaultInstance=new e,e.serialize=e.defaultInstance.serialize.bind(e.defaultInstance),e.deserialize=e.defaultInstance.deserialize.bind(e.defaultInstance),e.stringify=e.defaultInstance.stringify.bind(e.defaultInstance),e.parse=e.defaultInstance.parse.bind(e.defaultInstance),e.registerClass=e.defaultInstance.registerClass.bind(e.defaultInstance),e.registerSymbol=e.defaultInstance.registerSymbol.bind(e.defaultInstance),e.registerCustom=e.defaultInstance.registerCustom.bind(e.defaultInstance),e.allowErrorProps=e.defaultInstance.allowErrorProps.bind(e.defaultInstance),e}(),Nr=E,Pr=E.serialize,_r=E.deserialize,Rr=E.stringify,kr=E.parse,Tr=E.registerClass,Fr=E.registerCustom,Ir=E.registerSymbol,Cr=E.allowErrorProps});var Vr={};me(Vr,{edenFetch:()=>we,edenFn:()=>rr,edenTreaty:()=>be});var k=class extends Error{status;value;constructor(r,t){super(),this.status=r,this.value=t}};var de=(e,r,t)=>{if(e.endsWith("/")||(e+="/"),r==="index"&&(r=""),!t||!Object.keys(t).length)return`${e}${r}`;let n="";for(let[i,s]of Object.entries(t))n+=`${i}=${s}&`;return`${e}${r}?${n.slice(0,-1)}`};var Q=typeof FileList>"u",he=e=>Q?e instanceof Blob:e instanceof FileList||e instanceof File,ar=e=>{if(!e)return!1;for(let r in e){if(he(e[r]))return!0;if(Array.isArray(e[r])&&e[r].find(t=>he(t)))return!0}return!1},ge=e=>Q?e:new Promise(r=>{let t=new FileReader;t.onload=()=>{r(new Blob([t.result],{type:e.type}))},t.readAsArrayBuffer(e)}),J=class{ws;url;constructor(r){this.ws=new WebSocket(r),this.url=r}send(r){return Array.isArray(r)?(r.forEach(t=>this.send(t)),this):(this.ws.send(typeof r=="object"?JSON.stringify(r):r.toString()),this)}on(r,t,n){return this.addEventListener(r,t,n)}off(r,t,n){return this.ws.removeEventListener(r,t,n),this}subscribe(r,t){return this.addEventListener("message",r,t)}addEventListener(r,t,n){return this.ws.addEventListener(r,i=>{if(r==="message"){let s=i.data.toString(),o=s.charCodeAt(0);if(o===47||o===123)try{s=JSON.parse(s)}catch{}else Number.isNaN(+s)?s==="true"?s=!0:s==="fase"&&(s=!1):s=+s;t({...i,data:s})}else t(i)},n),this}removeEventListener(r,t,n){return this.off(r,t,n),this}close(){return this.ws.close(),this}},ve=(e,r="",t)=>new Proxy(()=>{},{get(n,i,s){return ve(e,`${r}/${i.toString()}`,t)},apply(n,i,[{$query:s,$fetch:o,$headers:a,...c}={$fetch:void 0,$headers:void 0,$query:void 0}]=[{}]){let y=r.lastIndexOf("/"),f=r.slice(y+1),u=de(e,y===-1?"/":r.slice(0,y),s),l=t.fetcher??fetch;return f==="subscribe"?new J(u.replace(/^([^]+):\/\//,u.startsWith("https://")?"wss://":"ws://")):(async()=>{let p,A={...t.$fetch?.headers,...o?.headers,...a};if(f!=="GET"&&f!=="HEAD"){p=Object.keys(c).length?c:void 0;let b=typeof p=="object";if(b&&ar(p)){let V=new FormData;for(let[j,N]of Object.entries(p))if(Q)V.append(j,N);else if(N instanceof File)V.append(j,await ge(N));else if(N instanceof FileList)for(let H=0;H<N.length;H++)V.append(j,await ge(N[H]));else V.append(j,N);p=V}else A["content-type"]=b?"application/json":"text/plain",b&&(p=JSON.stringify(p))}let h=await l(u,{method:f,body:p,...t.$fetch,...o,headers:A}),C;switch(h.headers.get("Content-Type")?.split(";")[0]){case"application/json":C=await h.json();break;default:C=await h.text().then(b=>Number.isNaN(+b)?b==="true"?!0:b==="false"?!1:b:+b)}return h.status>300?{data:C,error:new k(h.status,await C),status:h.status,raw:h,headers:h.headers}:{data:C,status:h.status,response:h,headers:h.headers,error:null}})()}}),be=(e,r={fetcher:fetch})=>new Proxy({},{get(t,n){return ve(e,n,r)}});var we=(e,r)=>(t,{query:n,params:i,body:s,...o}={})=>{i&&Object.entries(i).forEach(([u,l])=>{t=t.replace(`:${u}`,l)});let a=o.headers?.["Content-Type"];if(!a||a==="application/json")try{s=JSON.stringify(s)}catch{}let c=r?.fetcher||globalThis.fetch,y=n?`?${new URLSearchParams(n).toString()}`:"",f=()=>c(e+t+y,{...o,headers:s?{"content-type":"application/json",...o.headers}:o.headers,body:s}).then(async u=>{let l;switch(u.headers.get("Content-Type")?.split(";")[0]){case"application/json":l=await u.json();break;default:l=await u.text().then(m=>Number.isNaN(+m)?m==="true"?!0:m==="false"?!1:m:+m);break}return u.status>300?{data:null,status:u.status,headers:u.headers,retry:f,error:new k(u.status,l)}:{data:l,error:null,status:u.status,headers:u.headers,retry:f}});return f()};var q=class e{url;config;pendings=[];operation=null;isFetching=!1;sJson;constructor(r,t={}){this.url=r,this.config=t,this.sJson=Promise.resolve().then(()=>(er(),Ze)).then(n=>({serialize:n.serialize,deserialize:n.deserialize}))}setConfig(r){this.config=r}clone(r){return new e(this.url,r??this.config)}async run(r,t){let n=+this.pendings.length;if(this.pendings.push(t!==void 0?{n:r,p:t}:{n:r}),this.isFetching)return this.operation?.then(s=>s[n]);this.isFetching=!0,this.operation=new Promise(s=>{setTimeout(async()=>{let o=[...this.pendings];this.pendings=[];let{serialize:a,deserialize:c}=await this.sJson,f=await(this.config?.fetcher||globalThis.fetch)(`${this.url}${this.config.fn??"/~fn"}`,{method:"POST",...this.config.fetch,headers:{"content-type":"elysia/fn",...this.config.fetch?.headers},body:JSON.stringify(a(o))});f.status===200?s(f.json().then(u=>c(u))):s(Array(o.length).fill(new Error(await f.text())))},33)});let i=await this.operation.then(s=>s[n]);return this.operation=null,this.isFetching=!1,i}};var ye=(e,r,t)=>new Proxy((...n)=>{},{get(n,i,s){return ye(e,[...r,i],t)},apply(n,i,s){let o=s[0],a=r[0];if(r.length===1){if(a in Object.prototype||a in Promise.prototype)return n(...s);switch(a){case"toJSON":return n(...s);case"$set":return t.setConfig(o);case"$clone":return ye(e,[],t.clone(o))}}return t.run(r,s).then(c=>{if(c instanceof Error)throw c;return c})}}),rr=(e,r)=>ye(e,[],new q(e,r));return or(Vr);})();
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- var W=Object.create;var b=Object.defineProperty;var K=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var J=Object.getPrototypeOf,M=Object.prototype.hasOwnProperty;var B=(n,e)=>{for(var t in e)b(n,t,{get:e[t],enumerable:!0})},A=(n,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of R(e))!M.call(n,i)&&i!==t&&b(n,i,{get:()=>e[i],enumerable:!(s=K(e,i))||s.enumerable});return n};var D=(n,e,t)=>(t=n!=null?W(J(n)):{},A(e||!n||!n.__esModule?b(t,"default",{value:n,enumerable:!0}):t,n)),q=n=>A(b({},"__esModule",{value:!0}),n);var V={};B(V,{edenFetch:()=>z,edenFn:()=>P,edenTreaty:()=>j});module.exports=q(V);var g=class extends Error{status;value;constructor(e,t){super(),this.status=e,this.value=t}};var O=(n,e,t)=>{if(n.endsWith("/")||(n+="/"),e==="index"&&(e=""),!t||!Object.keys(t).length)return`${n}${e}`;let s="";for(let[i,r]of Object.entries(t))s+=`${i}=${r}&`;return`${n}${e}?${s.slice(0,-1)}`};var k=typeof FileList>"u",C=n=>k?n instanceof Blob:n instanceof FileList||n instanceof File,I=n=>{if(!n)return!1;for(let e in n){if(C(n[e]))return!0;if(Array.isArray(n[e])&&n[e].find(t=>C(t)))return!0}return!1},L=n=>k?n:new Promise(e=>{let t=new FileReader;t.onload=()=>{e(new Blob([t.result],{type:n.type}))},t.readAsArrayBuffer(n)}),F=class{ws;url;constructor(e){this.ws=new WebSocket(e),this.url=e}send(e){return Array.isArray(e)?(e.forEach(t=>this.send(t)),this):(this.ws.send(typeof e=="object"?JSON.stringify(e):e.toString()),this)}on(e,t,s){return this.addEventListener(e,t,s)}off(e,t,s){return this.ws.removeEventListener(e,t,s),this}subscribe(e,t){return this.addEventListener("message",e,t)}addEventListener(e,t,s){return this.ws.addEventListener(e,i=>{if(e==="message"){let r=i.data.toString(),o=r.charCodeAt(0);if(o===47||o===123)try{r=JSON.parse(r)}catch{}else Number.isNaN(+r)?r==="true"?r=!0:r==="fase"&&(r=!1):r=+r;t({...i,data:r})}else t(i)},s),this}removeEventListener(e,t,s){return this.off(e,t,s),this}close(){return this.ws.close(),this}},N=(n,e="",t)=>new Proxy(()=>{},{get(s,i,r){return N(n,`${e}/${i.toString()}`,t)},apply(s,i,[{$query:r,$fetch:o,$headers:p,...h}={$fetch:void 0,$headers:void 0,$query:void 0}]=[{}]){let m=e.lastIndexOf("/"),f=e.slice(m+1),a=O(n,e.slice(0,m),r);return f==="subscribe"?new F(a.replace(/^([^]+):\/\//,a.startsWith("https://")?"wss://":"ws://")):(async()=>{let c,$={...t.$fetch?.headers,...o?.headers,...p};if(f!=="GET"&&f!=="HEAD"){c=Object.keys(h).length?h:void 0;let y=typeof c=="object";if(y&&I(c)){let w=new FormData;for(let[S,d]of Object.entries(c))if(k)w.append(S,d);else if(d instanceof File)w.append(S,await L(d));else if(d instanceof FileList)for(let x=0;x<d.length;x++)w.append(S,await L(d[x]));else w.append(S,d);c=w}else $["content-type"]=y?"application/json":"text/plain",y&&(c=JSON.stringify(c))}let l=await(t.fetcher??fetch)(a,{method:f,body:c,...t.$fetch,...o,headers:$}),E;switch(l.headers.get("Content-Type")?.split(";")[0]){case"application/json":E=await l.json();break;default:E=await l.text().then(y=>Number.isNaN(+y)?y==="true"?!0:y==="false"?!1:y:+y)}return l.status>300?{data:E,error:new g(l.status,await E),status:l.status,raw:l,headers:l.headers}:{data:E,status:l.status,response:l,headers:l.headers,error:null}})()}}),j=(n,e={fetcher:fetch})=>new Proxy({},{get(t,s){return N(n,s,e)}});var z=(n,e)=>(t,{query:s,params:i,body:r,...o}={})=>{i&&Object.entries(i).forEach(([a,u])=>{t=t.replace(`:${a}`,u)});let p=o.headers?.["Content-Type"];if(!p||p==="application/json")try{r=JSON.stringify(r)}catch{}let h=e?.fetcher||globalThis.fetch,m=s?`?${new URLSearchParams(s).toString()}`:"",f=()=>h(n+t+m,{...o,headers:r?{"content-type":"application/json",...o.headers}:o.headers,body:r}).then(async a=>{let u;switch(a.headers.get("Content-Type")?.split(";")[0]){case"application/json":u=await a.json();break;default:u=await a.text().then(c=>Number.isNaN(+c)?c==="true"?!0:c==="false"?!1:c:+c);break}return a.status>300?{data:null,status:a.status,headers:a.headers,retry:f,error:new g(a.status,u)}:{data:u,error:null,status:a.status,headers:a.headers,retry:f}});return f()};var v=class n{url;config;pendings=[];operation=null;isFetching=!1;sJson;constructor(e,t={}){this.url=e,this.config=t,this.sJson=import("superjson").then(s=>({serialize:s.serialize,deserialize:s.deserialize}))}setConfig(e){this.config=e}clone(e){return new n(this.url,e??this.config)}async run(e,t){let s=+this.pendings.length;if(this.pendings.push(t!==void 0?{n:e,p:t}:{n:e}),this.isFetching)return this.operation?.then(r=>r[s]);this.isFetching=!0,this.operation=new Promise(r=>{setTimeout(async()=>{let o=[...this.pendings];this.pendings=[];let{serialize:p,deserialize:h}=await this.sJson,f=await(this.config?.fetcher||globalThis.fetch)(`${this.url}${this.config.fn??"/~fn"}`,{method:"POST",...this.config.fetch,headers:{"content-type":"elysia/fn",...this.config.fetch?.headers},body:JSON.stringify(p(o))});f.status===200?r(f.json().then(a=>h(a))):r(Array(o.length).fill(new Error(await f.text())))},33)});let i=await this.operation.then(r=>r[s]);return this.operation=null,this.isFetching=!1,i}};var T=(n,e,t)=>new Proxy((...s)=>{},{get(s,i,r){return T(n,[...e,i],t)},apply(s,i,r){let o=r[0],p=e[0];if(e.length===1){if(p in Object.prototype||p in Promise.prototype)return s(...r);switch(p){case"toJSON":return s(...r);case"$set":return t.setConfig(o);case"$clone":return T(n,[],t.clone(o))}}return t.run(e,r).then(h=>{if(h instanceof Error)throw h;return h})}}),P=(n,e)=>T(n,[],new v(n,e));0&&(module.exports={edenFetch,edenFn,edenTreaty});
1
+ "use strict";var K=Object.create;var v=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames;var M=Object.getPrototypeOf,B=Object.prototype.hasOwnProperty;var D=(n,e)=>{for(var t in e)v(n,t,{get:e[t],enumerable:!0})},O=(n,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of J(e))!B.call(n,i)&&i!==t&&v(n,i,{get:()=>e[i],enumerable:!(s=R(e,i))||s.enumerable});return n};var q=(n,e,t)=>(t=n!=null?K(M(n)):{},O(e||!n||!n.__esModule?v(t,"default",{value:n,enumerable:!0}):t,n)),I=n=>O(v({},"__esModule",{value:!0}),n);var H={};D(H,{edenFetch:()=>P,edenFn:()=>W,edenTreaty:()=>z});module.exports=I(H);var E=class extends Error{status;value;constructor(e,t){super(),this.status=e,this.value=t}};var C=(n,e,t)=>{if(n.endsWith("/")||(n+="/"),e==="index"&&(e=""),!t||!Object.keys(t).length)return`${n}${e}`;let s="";for(let[i,r]of Object.entries(t))s+=`${i}=${r}&`;return`${n}${e}?${s.slice(0,-1)}`};var T=typeof FileList>"u",L=n=>T?n instanceof Blob:n instanceof FileList||n instanceof File,V=n=>{if(!n)return!1;for(let e in n){if(L(n[e]))return!0;if(Array.isArray(n[e])&&n[e].find(t=>L(t)))return!0}return!1},N=n=>T?n:new Promise(e=>{let t=new FileReader;t.onload=()=>{e(new Blob([t.result],{type:n.type}))},t.readAsArrayBuffer(n)}),k=class{ws;url;constructor(e){this.ws=new WebSocket(e),this.url=e}send(e){return Array.isArray(e)?(e.forEach(t=>this.send(t)),this):(this.ws.send(typeof e=="object"?JSON.stringify(e):e.toString()),this)}on(e,t,s){return this.addEventListener(e,t,s)}off(e,t,s){return this.ws.removeEventListener(e,t,s),this}subscribe(e,t){return this.addEventListener("message",e,t)}addEventListener(e,t,s){return this.ws.addEventListener(e,i=>{if(e==="message"){let r=i.data.toString(),o=r.charCodeAt(0);if(o===47||o===123)try{r=JSON.parse(r)}catch{}else Number.isNaN(+r)?r==="true"?r=!0:r==="fase"&&(r=!1):r=+r;t({...i,data:r})}else t(i)},s),this}removeEventListener(e,t,s){return this.off(e,t,s),this}close(){return this.ws.close(),this}},j=(n,e="",t)=>new Proxy(()=>{},{get(s,i,r){return j(n,`${e}/${i.toString()}`,t)},apply(s,i,[{$query:r,$fetch:o,$headers:l,...p}={$fetch:void 0,$headers:void 0,$query:void 0}]=[{}]){let g=e.lastIndexOf("/"),c=e.slice(g+1),a=C(n,g===-1?"/":e.slice(0,g),r),y=t.fetcher??fetch;return c==="subscribe"?new k(a.replace(/^([^]+):\/\//,a.startsWith("https://")?"wss://":"ws://")):(async()=>{let u,A={...t.$fetch?.headers,...o?.headers,...l};if(c!=="GET"&&c!=="HEAD"){u=Object.keys(p).length?p:void 0;let h=typeof u=="object";if(h&&V(u)){let S=new FormData;for(let[b,d]of Object.entries(u))if(T)S.append(b,d);else if(d instanceof File)S.append(b,await N(d));else if(d instanceof FileList)for(let F=0;F<d.length;F++)S.append(b,await N(d[F]));else S.append(b,d);u=S}else A["content-type"]=h?"application/json":"text/plain",h&&(u=JSON.stringify(u))}let f=await y(a,{method:c,body:u,...t.$fetch,...o,headers:A}),w;switch(f.headers.get("Content-Type")?.split(";")[0]){case"application/json":w=await f.json();break;default:w=await f.text().then(h=>Number.isNaN(+h)?h==="true"?!0:h==="false"?!1:h:+h)}return f.status>300?{data:w,error:new E(f.status,await w),status:f.status,raw:f,headers:f.headers}:{data:w,status:f.status,response:f,headers:f.headers,error:null}})()}}),z=(n,e={fetcher:fetch})=>new Proxy({},{get(t,s){return j(n,s,e)}});var P=(n,e)=>(t,{query:s,params:i,body:r,...o}={})=>{i&&Object.entries(i).forEach(([a,y])=>{t=t.replace(`:${a}`,y)});let l=o.headers?.["Content-Type"];if(!l||l==="application/json")try{r=JSON.stringify(r)}catch{}let p=e?.fetcher||globalThis.fetch,g=s?`?${new URLSearchParams(s).toString()}`:"",c=()=>p(n+t+g,{...o,headers:r?{"content-type":"application/json",...o.headers}:o.headers,body:r}).then(async a=>{let y;switch(a.headers.get("Content-Type")?.split(";")[0]){case"application/json":y=await a.json();break;default:y=await a.text().then(m=>Number.isNaN(+m)?m==="true"?!0:m==="false"?!1:m:+m);break}return a.status>300?{data:null,status:a.status,headers:a.headers,retry:c,error:new E(a.status,y)}:{data:y,error:null,status:a.status,headers:a.headers,retry:c}});return c()};var x=class n{url;config;pendings=[];operation=null;isFetching=!1;sJson;constructor(e,t={}){this.url=e,this.config=t,this.sJson=import("superjson").then(s=>({serialize:s.serialize,deserialize:s.deserialize}))}setConfig(e){this.config=e}clone(e){return new n(this.url,e??this.config)}async run(e,t){let s=+this.pendings.length;if(this.pendings.push(t!==void 0?{n:e,p:t}:{n:e}),this.isFetching)return this.operation?.then(r=>r[s]);this.isFetching=!0,this.operation=new Promise(r=>{setTimeout(async()=>{let o=[...this.pendings];this.pendings=[];let{serialize:l,deserialize:p}=await this.sJson,c=await(this.config?.fetcher||globalThis.fetch)(`${this.url}${this.config.fn??"/~fn"}`,{method:"POST",...this.config.fetch,headers:{"content-type":"elysia/fn",...this.config.fetch?.headers},body:JSON.stringify(l(o))});c.status===200?r(c.json().then(a=>p(a))):r(Array(o.length).fill(new Error(await c.text())))},33)});let i=await this.operation.then(r=>r[s]);return this.operation=null,this.isFetching=!1,i}};var $=(n,e,t)=>new Proxy((...s)=>{},{get(s,i,r){return $(n,[...e,i],t)},apply(s,i,r){let o=r[0],l=e[0];if(e.length===1){if(l in Object.prototype||l in Promise.prototype)return s(...r);switch(l){case"toJSON":return s(...r);case"$set":return t.setConfig(o);case"$clone":return $(n,[],t.clone(o))}}return t.run(e,r).then(p=>{if(p instanceof Error)throw p;return p})}}),W=(n,e)=>$(n,[],new x(n,e));0&&(module.exports={edenFetch,edenFn,edenTreaty});
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{b as e}from"./chunk-X77HNZQV.mjs";import{a as t}from"./chunk-TUC2YNFX.mjs";import"./chunk-Y6SMVGJX.mjs";import{a as r}from"./chunk-G4C5WHQF.mjs";export{t as edenFetch,r as edenFn,e as edenTreaty};
1
+ import{b as e}from"./chunk-FY4RFSUV.mjs";import{a as t}from"./chunk-TUC2YNFX.mjs";import"./chunk-Y6SMVGJX.mjs";import{a as r}from"./chunk-G4C5WHQF.mjs";export{t as edenFetch,r as edenFn,e as edenTreaty};
@@ -1,3 +1,4 @@
1
+ /// <reference types="bun-types" />
1
2
  import type { Elysia, TypedSchema } from 'elysia';
2
3
  import type { EdenTreaty } from './types';
3
4
  export type { EdenTreaty } from './types';
@@ -0,0 +1 @@
1
+ "use strict";var Eden=(()=>{var v=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var K=Object.prototype.hasOwnProperty;var N=(s,e)=>{for(var t in e)v(s,t,{get:e[t],enumerable:!0})},R=(s,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of F(e))!K.call(s,i)&&i!==t&&v(s,i,{get:()=>e[i],enumerable:!(n=O(e,i))||n.enumerable});return s};var M=s=>R(v({},"__esModule",{value:!0}),s);var P={};N(P,{EdenWS:()=>g,edenTreaty:()=>B});var h=class extends Error{status;value;constructor(e,t){super(),this.status=e,this.value=t}};var x=(s,e,t)=>{if(s.endsWith("/")||(s+="/"),e==="index"&&(e=""),!t||!Object.keys(t).length)return`${s}${e}`;let n="";for(let[i,r]of Object.entries(t))n+=`${i}=${r}&`;return`${s}${e}?${n.slice(0,-1)}`};var S=typeof FileList>"u",$=s=>S?s instanceof Blob:s instanceof FileList||s instanceof File,j=s=>{if(!s)return!1;for(let e in s){if($(s[e]))return!0;if(Array.isArray(s[e])&&s[e].find(t=>$(t)))return!0}return!1},T=s=>S?s:new Promise(e=>{let t=new FileReader;t.onload=()=>{e(new Blob([t.result],{type:s.type}))},t.readAsArrayBuffer(s)}),g=class{ws;url;constructor(e){this.ws=new WebSocket(e),this.url=e}send(e){return Array.isArray(e)?(e.forEach(t=>this.send(t)),this):(this.ws.send(typeof e=="object"?JSON.stringify(e):e.toString()),this)}on(e,t,n){return this.addEventListener(e,t,n)}off(e,t,n){return this.ws.removeEventListener(e,t,n),this}subscribe(e,t){return this.addEventListener("message",e,t)}addEventListener(e,t,n){return this.ws.addEventListener(e,i=>{if(e==="message"){let r=i.data.toString(),u=r.charCodeAt(0);if(u===47||u===123)try{r=JSON.parse(r)}catch{}else Number.isNaN(+r)?r==="true"?r=!0:r==="fase"&&(r=!1):r=+r;t({...i,data:r})}else t(i)},n),this}removeEventListener(e,t,n){return this.off(e,t,n),this}close(){return this.ws.close(),this}},L=(s,e="",t)=>new Proxy(()=>{},{get(n,i,r){return L(s,`${e}/${i.toString()}`,t)},apply(n,i,[{$query:r,$fetch:u,$headers:W,...w}={$fetch:void 0,$headers:void 0,$query:void 0}]=[{}]){let E=e.lastIndexOf("/"),y=e.slice(E+1),b=x(s,E===-1?"/":e.slice(0,E),r),A=t.fetcher??fetch;return y==="subscribe"?new g(b.replace(/^([^]+):\/\//,b.startsWith("https://")?"wss://":"ws://")):(async()=>{let c,k={...t.$fetch?.headers,...u?.headers,...W};if(y!=="GET"&&y!=="HEAD"){c=Object.keys(w).length?w:void 0;let o=typeof c=="object";if(o&&j(c)){let l=new FormData;for(let[p,f]of Object.entries(c))if(S)l.append(p,f);else if(f instanceof File)l.append(p,await T(f));else if(f instanceof FileList)for(let m=0;m<f.length;m++)l.append(p,await T(f[m]));else l.append(p,f);c=l}else k["content-type"]=o?"application/json":"text/plain",o&&(c=JSON.stringify(c))}let a=await A(b,{method:y,body:c,...t.$fetch,...u,headers:k}),d;switch(a.headers.get("Content-Type")?.split(";")[0]){case"application/json":d=await a.json();break;default:d=await a.text().then(o=>Number.isNaN(+o)?o==="true"?!0:o==="false"?!1:o:+o)}return a.status>300?{data:d,error:new h(a.status,await d),status:a.status,raw:a,headers:a.headers}:{data:d,status:a.status,response:a,headers:a.headers,error:null}})()}}),B=(s,e={fetcher:fetch})=>new Proxy({},{get(t,n){return L(s,n,e)}});return M(P);})();
package/dist/treaty.js CHANGED
@@ -1 +1 @@
1
- var m=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var F=Object.prototype.hasOwnProperty;var K=(s,e)=>{for(var t in e)m(s,t,{get:e[t],enumerable:!0})},N=(s,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of O(e))!F.call(s,i)&&i!==t&&m(s,i,{get:()=>e[i],enumerable:!(n=A(e,i))||n.enumerable});return s};var R=s=>N(m({},"__esModule",{value:!0}),s);var B={};K(B,{EdenWS:()=>g,edenTreaty:()=>j});module.exports=R(B);var h=class extends Error{status;value;constructor(e,t){super(),this.status=e,this.value=t}};var x=(s,e,t)=>{if(s.endsWith("/")||(s+="/"),e==="index"&&(e=""),!t||!Object.keys(t).length)return`${s}${e}`;let n="";for(let[i,r]of Object.entries(t))n+=`${i}=${r}&`;return`${s}${e}?${n.slice(0,-1)}`};var v=typeof FileList>"u",$=s=>v?s instanceof Blob:s instanceof FileList||s instanceof File,M=s=>{if(!s)return!1;for(let e in s){if($(s[e]))return!0;if(Array.isArray(s[e])&&s[e].find(t=>$(t)))return!0}return!1},T=s=>v?s:new Promise(e=>{let t=new FileReader;t.onload=()=>{e(new Blob([t.result],{type:s.type}))},t.readAsArrayBuffer(s)}),g=class{ws;url;constructor(e){this.ws=new WebSocket(e),this.url=e}send(e){return Array.isArray(e)?(e.forEach(t=>this.send(t)),this):(this.ws.send(typeof e=="object"?JSON.stringify(e):e.toString()),this)}on(e,t,n){return this.addEventListener(e,t,n)}off(e,t,n){return this.ws.removeEventListener(e,t,n),this}subscribe(e,t){return this.addEventListener("message",e,t)}addEventListener(e,t,n){return this.ws.addEventListener(e,i=>{if(e==="message"){let r=i.data.toString(),f=r.charCodeAt(0);if(f===47||f===123)try{r=JSON.parse(r)}catch{}else Number.isNaN(+r)?r==="true"?r=!0:r==="fase"&&(r=!1):r=+r;t({...i,data:r})}else t(i)},n),this}removeEventListener(e,t,n){return this.off(e,t,n),this}close(){return this.ws.close(),this}},L=(s,e="",t)=>new Proxy(()=>{},{get(n,i,r){return L(s,`${e}/${i.toString()}`,t)},apply(n,i,[{$query:r,$fetch:f,$headers:W,...S}={$fetch:void 0,$headers:void 0,$query:void 0}]=[{}]){let w=e.lastIndexOf("/"),y=e.slice(w+1),E=x(s,e.slice(0,w),r);return y==="subscribe"?new g(E.replace(/^([^]+):\/\//,E.startsWith("https://")?"wss://":"ws://")):(async()=>{let c,k={...t.$fetch?.headers,...f?.headers,...W};if(y!=="GET"&&y!=="HEAD"){c=Object.keys(S).length?S:void 0;let o=typeof c=="object";if(o&&M(c)){let l=new FormData;for(let[p,u]of Object.entries(c))if(v)l.append(p,u);else if(u instanceof File)l.append(p,await T(u));else if(u instanceof FileList)for(let b=0;b<u.length;b++)l.append(p,await T(u[b]));else l.append(p,u);c=l}else k["content-type"]=o?"application/json":"text/plain",o&&(c=JSON.stringify(c))}let a=await(t.fetcher??fetch)(E,{method:y,body:c,...t.$fetch,...f,headers:k}),d;switch(a.headers.get("Content-Type")?.split(";")[0]){case"application/json":d=await a.json();break;default:d=await a.text().then(o=>Number.isNaN(+o)?o==="true"?!0:o==="false"?!1:o:+o)}return a.status>300?{data:d,error:new h(a.status,await d),status:a.status,raw:a,headers:a.headers}:{data:d,status:a.status,response:a,headers:a.headers,error:null}})()}}),j=(s,e={fetcher:fetch})=>new Proxy({},{get(t,n){return L(s,n,e)}});0&&(module.exports={EdenWS,edenTreaty});
1
+ "use strict";var v=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var K=Object.prototype.hasOwnProperty;var N=(s,e)=>{for(var t in e)v(s,t,{get:e[t],enumerable:!0})},R=(s,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of F(e))!K.call(s,i)&&i!==t&&v(s,i,{get:()=>e[i],enumerable:!(n=O(e,i))||n.enumerable});return s};var M=s=>R(v({},"__esModule",{value:!0}),s);var P={};N(P,{EdenWS:()=>g,edenTreaty:()=>B});module.exports=M(P);var h=class extends Error{status;value;constructor(e,t){super(),this.status=e,this.value=t}};var x=(s,e,t)=>{if(s.endsWith("/")||(s+="/"),e==="index"&&(e=""),!t||!Object.keys(t).length)return`${s}${e}`;let n="";for(let[i,r]of Object.entries(t))n+=`${i}=${r}&`;return`${s}${e}?${n.slice(0,-1)}`};var S=typeof FileList>"u",$=s=>S?s instanceof Blob:s instanceof FileList||s instanceof File,j=s=>{if(!s)return!1;for(let e in s){if($(s[e]))return!0;if(Array.isArray(s[e])&&s[e].find(t=>$(t)))return!0}return!1},T=s=>S?s:new Promise(e=>{let t=new FileReader;t.onload=()=>{e(new Blob([t.result],{type:s.type}))},t.readAsArrayBuffer(s)}),g=class{ws;url;constructor(e){this.ws=new WebSocket(e),this.url=e}send(e){return Array.isArray(e)?(e.forEach(t=>this.send(t)),this):(this.ws.send(typeof e=="object"?JSON.stringify(e):e.toString()),this)}on(e,t,n){return this.addEventListener(e,t,n)}off(e,t,n){return this.ws.removeEventListener(e,t,n),this}subscribe(e,t){return this.addEventListener("message",e,t)}addEventListener(e,t,n){return this.ws.addEventListener(e,i=>{if(e==="message"){let r=i.data.toString(),u=r.charCodeAt(0);if(u===47||u===123)try{r=JSON.parse(r)}catch{}else Number.isNaN(+r)?r==="true"?r=!0:r==="fase"&&(r=!1):r=+r;t({...i,data:r})}else t(i)},n),this}removeEventListener(e,t,n){return this.off(e,t,n),this}close(){return this.ws.close(),this}},L=(s,e="",t)=>new Proxy(()=>{},{get(n,i,r){return L(s,`${e}/${i.toString()}`,t)},apply(n,i,[{$query:r,$fetch:u,$headers:W,...w}={$fetch:void 0,$headers:void 0,$query:void 0}]=[{}]){let E=e.lastIndexOf("/"),y=e.slice(E+1),b=x(s,E===-1?"/":e.slice(0,E),r),A=t.fetcher??fetch;return y==="subscribe"?new g(b.replace(/^([^]+):\/\//,b.startsWith("https://")?"wss://":"ws://")):(async()=>{let c,k={...t.$fetch?.headers,...u?.headers,...W};if(y!=="GET"&&y!=="HEAD"){c=Object.keys(w).length?w:void 0;let o=typeof c=="object";if(o&&j(c)){let l=new FormData;for(let[p,f]of Object.entries(c))if(S)l.append(p,f);else if(f instanceof File)l.append(p,await T(f));else if(f instanceof FileList)for(let m=0;m<f.length;m++)l.append(p,await T(f[m]));else l.append(p,f);c=l}else k["content-type"]=o?"application/json":"text/plain",o&&(c=JSON.stringify(c))}let a=await A(b,{method:y,body:c,...t.$fetch,...u,headers:k}),d;switch(a.headers.get("Content-Type")?.split(";")[0]){case"application/json":d=await a.json();break;default:d=await a.text().then(o=>Number.isNaN(+o)?o==="true"?!0:o==="false"?!1:o:+o)}return a.status>300?{data:d,error:new h(a.status,await d),status:a.status,raw:a,headers:a.headers}:{data:d,status:a.status,response:a,headers:a.headers,error:null}})()}}),B=(s,e={fetcher:fetch})=>new Proxy({},{get(t,n){return L(s,n,e)}});0&&(module.exports={EdenWS,edenTreaty});
package/dist/treaty.mjs CHANGED
@@ -1 +1 @@
1
- import{a,b}from"./chunk-X77HNZQV.mjs";import"./chunk-Y6SMVGJX.mjs";export{a as EdenWS,b as edenTreaty};
1
+ import{a,b}from"./chunk-FY4RFSUV.mjs";import"./chunk-Y6SMVGJX.mjs";export{a as EdenWS,b as edenTreaty};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elysiajs/eden",
3
- "version": "0.6.4",
3
+ "version": "0.6.5",
4
4
  "description": "Fully type-safe Elysia client",
5
5
  "author": {
6
6
  "name": "saltyAom",
@@ -52,8 +52,8 @@
52
52
  "bugs": "https://github.com/elysiajs/elysia-eden/issues",
53
53
  "license": "MIT",
54
54
  "scripts": {
55
- "dev": "bun run --hot example/index.ts",
56
- "test": "bun wiptest",
55
+ "dev": "bun run --watch example/index.ts",
56
+ "test": "bun test",
57
57
  "build": "tsup",
58
58
  "release": "npm run build && npm run test && npm publish --access public"
59
59
  },
@@ -70,7 +70,8 @@
70
70
  "@elysiajs/fn": "^0.6.1",
71
71
  "@sinclair/typebox": "^0.26.8",
72
72
  "@types/node": "^18.15.5",
73
- "elysia": "0.6.10",
73
+ "bun-types": "^1.0.1",
74
+ "elysia": "0.6.22",
74
75
  "esbuild": "^0.19.2",
75
76
  "eslint": "^8.26.0",
76
77
  "rimraf": "^4.4.1",
@@ -19,17 +19,17 @@ export namespace EdenFetch {
19
19
 
20
20
  export type Fn<Schema extends Record<string, any>> = <
21
21
  Endpoint extends keyof Schema,
22
- Method extends Extract<keyof Schema[Endpoint], string>,
23
- Route extends Schema[Endpoint][Method]
22
+ Method extends Uppercase<Extract<keyof Schema[Endpoint], string>>,
23
+ Route extends Schema[Endpoint][Lowercase<Method>]
24
24
  >(
25
25
  endpoint: Endpoint,
26
26
  options: Omit<RequestInit, 'body' | 'method' | 'headers'> &
27
- ('get' extends Method
27
+ ('GET' extends Method
28
28
  ? {
29
- method?: Uppercase<Method>
29
+ method?: Method
30
30
  }
31
31
  : {
32
- method: Uppercase<Method>
32
+ method: Method
33
33
  }) &
34
34
  (IsNever<keyof Route['params']> extends true
35
35
  ? {
package/src/index.ts CHANGED
@@ -7,28 +7,3 @@ import type { EdenFn } from './fn'
7
7
  export { edenTreaty } from './treaty'
8
8
  export { edenFetch } from './fetch'
9
9
  export { edenFn } from './fn'
10
-
11
- // @ts-ignore
12
- // export const eden: Eden = (domain: string) => ({
13
- // treaty(config) {
14
- // return import('./treaty').then((x) => x.edenTreaty(domain, config))
15
- // },
16
- // fn(config) {
17
- // return import('./fn').then((x) => x.edenFn(domain, config))
18
- // },
19
- // fetch(config) {
20
- // return import('./fetch').then((x) => x.edenFetch(domain, config))
21
- // }
22
- // })
23
-
24
- // type Eden = (domain: string) => {
25
- // treaty<App extends Elysia<any>>(
26
- // config?: EdenTreaty.Config
27
- // ): EdenTreaty.Create<App>
28
-
29
- // fetch<App extends Elysia<any>>(
30
- // config?: EdenFetch.Config
31
- // ): EdenFetch.Create<App>
32
-
33
- // fn<App extends Elysia<any>>(config?: EdenFn.Config): EdenFn.Create<App>
34
- // }
@@ -179,7 +179,9 @@ const createProxy = (
179
179
  ) {
180
180
  const i = path.lastIndexOf('/'),
181
181
  method = path.slice(i + 1),
182
- url = composePath(domain, path.slice(0, i), $query)
182
+ url = composePath(domain, i === -1 ? '/' : path.slice(0, i), $query)
183
+
184
+ const fetcher = config.fetcher ?? fetch
183
185
 
184
186
  if (method === 'subscribe')
185
187
  return new EdenWS(
@@ -240,7 +242,7 @@ const createProxy = (
240
242
  }
241
243
  }
242
244
 
243
- const response = await (config.fetcher ?? fetch)(url, {
245
+ const response = await fetcher(url, {
244
246
  method,
245
247
  body,
246
248
  ...config.$fetch,
package/tsup.config.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { defineConfig } from 'tsup';
2
- import { resolve } from 'path';
3
- import {exec} from 'child_process'
1
+ import { defineConfig } from 'tsup'
2
+ import { resolve } from 'path'
3
+ import { exec } from 'child_process'
4
4
 
5
5
  export default defineConfig({
6
6
  entry: {
@@ -9,12 +9,13 @@ export default defineConfig({
9
9
  fetch: resolve(__dirname, 'src/fetch/index.ts'),
10
10
  fn: resolve(__dirname, 'src/fn/index.ts')
11
11
  },
12
- format: ['cjs', 'esm'],
12
+ format: ['cjs', 'esm', 'iife'],
13
+ globalName: 'Eden',
13
14
  minify: true,
14
15
  external: ['elysia', 'superjson'],
15
16
  async onSuccess() {
16
17
  exec('tsc --emitDeclarationOnly --declaration', {
17
- cwd: resolve(__dirname, 'dist'),
18
+ cwd: resolve(__dirname, 'dist')
18
19
  })
19
20
  }
20
- })
21
+ })