@bobtail.software/b-ssr 1.0.20 → 1.0.22
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/rpc-client.d.ts +3 -1
- package/dist/rpc-client.js +1 -1
- package/dist/vite-rpc-plugin.js +396 -397
- package/package.json +1 -1
package/dist/rpc-client.d.ts
CHANGED
package/dist/rpc-client.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var f=class extends Error{status;statusText;body;constructor(o,e,c,i){super(o),this.name="ApiClientError",this.status=e,this.statusText=c,this.body=i}};function
|
|
1
|
+
var f=class extends Error{status;statusText;body;constructor(o,e,c,i){super(o),this.name="ApiClientError",this.status=e,this.statusText=c,this.body=i}};function h(s){return s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function b(s,o){let e=s;for(let i in o)if(Object.prototype.hasOwnProperty.call(o,i)){let l=o[i];if(l==null)continue;let u=encodeURIComponent(String(l)),g=new RegExp(`:${h(i)}(\\??)`,"g");e=e.replace(g,u)}e=e.replace(/\/:[a-zA-Z0-9_]+\?/g,"");let c=e.match(/:[a-zA-Z0-9_]+/g);if(c)throw new Error(`Error al compilar la URL. Faltan par\xE1metros requeridos: ${c.join(", ")}`);return e}function m({method:s,url:o,isMultipart:e}){return async c=>{let{params:i={},query:l={},body:u,signal:g}=c,w=b(o,i),y=new URL(w,window.location.origin);l&&Object.entries(l).forEach(([r,n])=>{n!=null&&y.searchParams.append(r,String(n))});let p={method:s,headers:{},credentials:"include",signal:g};if(s==="POST")if(e){let r=new FormData,n=u?{...u}:{};"file"in n&&n.file instanceof File&&(r.append("file",n.file),delete n.file),Object.entries(n).forEach(([a,d])=>{r.append(a,String(d))}),p.body=r}else p.headers["Content-Type"]="application/json",p.headers.Accept="application/json",p.body=JSON.stringify(u||{});let t=await fetch(y.toString(),p);if(!t.ok){let r=`Request failed with status ${t.status} (${t.statusText})`,n=null,a="";try{n=await t.json(),a=n?.error?.message||n?.message}catch{try{a=await t.text(),n=a}catch{}}let d=a?`${r}: ${a}`:r;throw new f(d,t.status,t.statusText,n)}if(!(t.headers.get("Content-Length")==="0"||t.status===204))return t.json()}}export{f as ApiClientError,m as createClientRpc};
|