Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

xior

Package Overview
Dependencies
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xior - npm Package Compare versions

Comparing version 0.2.6 to 0.3.0

37

dist/index.esm.d.ts

@@ -10,4 +10,2 @@ export { merge } from 'ts-deepmerge';

timeout?: number;
/** @deprecated use paramsSerializer */
encode?: (params: Record<string, any>) => string;
paramsSerializer?: (params: Record<string, any>) => string;

@@ -22,6 +20,4 @@ /** Use encodeURIComponent, default: true */

data?: any;
_data?: any;
/** encoded url with params */
_url?: string;
/** useless now, compitable axios */
withCredentials?: boolean;

@@ -38,3 +34,2 @@ /**

url: string;
_url: string;
method: string;

@@ -63,3 +58,3 @@ };

declare function buildSortedURL(_url: string, data: any, encode: (obj: Record<string, any>) => string): string;
declare function buildSortedURL(url: string, data: any, paramsSerializer: (obj: Record<string, any>) => string): string;

@@ -115,2 +110,3 @@ declare function delay(ms: number): Promise<unknown>;

data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;

@@ -120,2 +116,3 @@ response: Response;

data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;

@@ -125,2 +122,3 @@ response: Response;

data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;

@@ -140,2 +138,3 @@ response: Response;

data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;

@@ -145,2 +144,3 @@ response: Response;

data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;

@@ -150,2 +150,3 @@ response: Response;

data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;

@@ -155,2 +156,3 @@ response: Response;

data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;

@@ -160,2 +162,3 @@ response: Response;

data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;

@@ -165,2 +168,3 @@ response: Response;

data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;

@@ -171,2 +175,3 @@ response: Response;

data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;

@@ -176,2 +181,3 @@ response: Response;

data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;

@@ -181,2 +187,3 @@ response: Response;

data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;

@@ -188,3 +195,4 @@ response: Response;

};
_plugins: XiorPlugin[];
/** plugins */
P: XiorPlugin[];
get plugins(): {

@@ -199,4 +207,10 @@ use: (plugin: XiorPlugin) => XiorPlugin;

createPost<T>(method: string): (url: string, data?: any, options?: XiorRequestConfig) => Promise<XiorResponse<T>>;
get<T = any>(url: string, options?: XiorRequestConfig): Promise<XiorResponse<T>>;
head<T = any>(url: string, options?: XiorRequestConfig): Promise<XiorResponse<T>>;
get<T = any>(url: string, options?: XiorRequestConfig & {
/** @deprecated No `data` in `GET` method */
data?: any;
}): Promise<XiorResponse<T>>;
head<T = any>(url: string, options?: XiorRequestConfig & {
/** @deprecated No `data` in `HEAD` method */
data?: any;
}): Promise<XiorResponse<T>>;
post<T = any>(url: string, data?: any, options?: XiorRequestConfig): Promise<XiorResponse<T>>;

@@ -206,3 +220,6 @@ put<T = any>(url: string, data?: any, options?: XiorRequestConfig): Promise<XiorResponse<T>>;

delete<T = any>(url: string, options?: XiorRequestConfig): Promise<XiorResponse<T>>;
options<T = any>(url: string, options?: XiorRequestConfig): Promise<XiorResponse<T>>;
options<T = any>(url: string, options?: XiorRequestConfig & {
/** @deprecated No `data` in `OPTIONS` method */
data?: any;
}): Promise<XiorResponse<T>>;
}

@@ -209,0 +226,0 @@

@@ -1,1 +0,1 @@

import{merge as e}from"ts-deepmerge";export{merge}from"ts-deepmerge";function t(e,t){let r=new globalThis.AbortController;function n(e){r.abort(e),i()}let s=[];for(let t of e){if((null==t?void 0:t.aborted)===!0){n(t.reason);break}if((null==t?void 0:t.addEventListener)!=null){let e=()=>{n(t.reason)};s.push(()=>{(null==t?void 0:t.removeEventListener)!=null&&t.removeEventListener("abort",e)}),t.addEventListener("abort",e)}}function i(){s.forEach(e=>{e()}),null==t||t()}let o=r.signal;return o.clear=i,o}function r(e,t,r){let n=t?r(t):"";n&&(n=e+(e.includes("?")?"&"+n:"?"+n));let[s,i]=n.split("?");if(i){let e=i.split("&");return`${s}?${e.sort().join("&")}`}return n||e}function n(e){return new Promise(t=>{setTimeout(()=>{t("ok")},e)})}function s(e,t=!0,r=null){if(null==e)return"";let n=[],i=t?encodeURIComponent:e=>e;for(let o in e)if(Object.prototype.hasOwnProperty.call(e,o)){let a=e[o],l=r?`${r}[${i(o)}]`:i(o);if("object"==typeof a){let e=s(a,t,l);""!==e&&n.push(e)}else Array.isArray(a)?a.forEach((e,t)=>{let r=`${l}[${t}]`;n.push(`${i(r)}=${i(e)}`)}):n.push(`${i(l)}=${i(a)}`)}return n.join("&")}function i(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function o(e,t){return t?(e.endsWith("/")?e:e+"/")+(t.startsWith("/")?t.slice(1):t):e}class a extends Error{constructor(e,t,r){super(e),this.name="XiorError",this.request=t,this.config=t,this.response=r}}class l extends a{constructor(e,t,r){super(e),this.name="XiorTimeoutError",this.request=t,this.config=t,this.response=r}}function u(e){return"XiorError"===e.name||"XiorTimeoutError"===e.name}function c(e,t,r,n,s,i,o){try{var a=e[i](o),l=a.value}catch(e){r(e);return}a.done?t(l):Promise.resolve(l).then(n,s)}function h(){return(h=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}let f="application/x-www-form-urlencoded",d="application/json";function p(e="GET"){return["HEAD","GET","DELETE","OPTIONS"].includes(e)}function m(e){return E.apply(this,arguments)}function E(){var t;return t=function*(t){let r=t.encode||t.paramsSerializer||s,n=!1!==t.encodeURI,i=t.method?t.method.toUpperCase():"GET",o=t.url||"",a=o,l=t.data,u=l,c=!1,m=(null==t?void 0:t.headers)||{};if(l&&!(l instanceof FormData)){let s="";if(null==t?void 0:t.headers){let e=Object.keys(t.headers).find(e=>"content-type"===e.toLowerCase());e&&(s=t.headers[e],t.headers["Content-Type"]=s,delete t.headers[e])}if(s||(s=p(i)?f:d,m["Content-Type"]=s),s===f&&("object"==typeof l||t.params)){c=!0;let s=r(e(l||{},t.params||{}),n);s&&(o+=o.includes("?")?`&${s}`:`?${s}`)}else s===d&&(u=JSON.stringify(l))}return!c&&t.params&&Object.keys(t.params).length>0&&(o+=o.includes("?")?`&${r(t.params,n)}`:`?${r(t.params,n)}`),h({},t,{data:l,_data:u,url:a,_url:o,method:i,headers:m,encode:r,paramsSerializer:r})},(E=function(){var e=this,r=arguments;return new Promise(function(n,s){var i=t.apply(e,r);function o(e){c(i,n,s,o,a,"next",e)}function a(e){c(i,n,s,o,a,"throw",e)}o(void 0)})}).apply(this,arguments)}function v(e,t,r,n,s,i,o){try{var a=e[i](o),l=a.value}catch(e){r(e);return}a.done?t(l):Promise.resolve(l).then(n,s)}function y(e){return function(){var t=this,r=arguments;return new Promise(function(n,s){var i=e.apply(t,r);function o(e){v(i,n,s,o,a,"next",e)}function a(e){v(i,n,s,o,a,"throw",e)}o(void 0)})}}function g(){return(g=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}let b="undefined"!=typeof AbortController;class R{static create(e){return new R(e)}get interceptors(){return{request:{use:(e,t)=>(this.REQI.push(e),e),eject:e=>{this.REQI=this.REQI.filter(t=>t!==e)},clear:()=>{this.REQI=[this.REQI[0]]}},response:{use:(e,t)=>(this.RESI.push({fn:e,onRejected:t}),e),eject:e=>{this.RESI=this.RESI.filter(t=>t.fn!==e)},clear:()=>{this.RESI=[]}}}}get plugins(){return{use:e=>(this._plugins.push(e),e),eject:e=>{this._plugins=this._plugins.filter(t=>t!==e)},clear:()=>{this._plugins=[]}}}request(t){var r=this;return y(function*(){let n=e({},r.config||{},r.defaults||{},"string"==typeof t?{url:t}:t||{},{headers:{},params:{}});for(let e of r.REQI)n=yield e(n);let s=r.fetch.bind(r);return r._plugins.forEach(e=>{s=e(s)}),s(n)})()}fetch(e){var r=this;return y(function*(){var n,s,u;let c,h;if(r._plugins.length>0)for(let t of r.REQI.slice(1))e=yield t(e);let{url:d,method:m,headers:E,timeout:v,signal:y,data:R,_data:O}=e,T=function(e,t){if(null==e)return{};var r,n,s={},i=Object.keys(e);for(n=0;n<i.length;n++)t.indexOf(r=i[n])>=0||(s[r]=e[r]);return s}(e,["url","method","headers","timeout","signal","data","_data"]),j=[];if(v&&b){let t=new AbortController;h=setTimeout(()=>{t.abort(new l(`timeout of ${v}ms exceeded`,e))},v),j.push(t.signal)}y&&j.push(y),c=j[0],j.length>1&&(c=t(j,()=>{clearTimeout(h)}));let I=e._url||d||"";e.baseURL&&!i(I)&&(I=o(e.baseURL,I));let w=yield fetch(I,g({body:p(e.method)||(null==(n=e.headers)?void 0:n["Content-Type"])===f?void 0:O},T,{signal:c,method:m,headers:E}));h&&clearTimeout(h),null==c||null==(s=c.clear)||s.call(c);let S={response:w,config:e,status:w.status,statusText:w.statusText,headers:w.headers};if(!w.ok){let t;try{(t=yield w.text())&&(t=JSON.parse(t))}catch(e){}let n=new a(w.status?`Request failed with status code ${w.status}`:"Network error",e,g({data:t},S));for(let e of r.RESI)if(e.onRejected){let t=yield e.onRejected(n);if(null==t?void 0:null==(u=t.response)?void 0:u.ok)return t}throw n}if("HEAD"===e.method)return g({data:void 0,request:e},S);let{responseType:P}=e;if(!P||"json"===P||"text"===P){let t;try{(t=yield w.text())&&"text"!==P&&(t=JSON.parse(t))}catch(e){}let n={data:t,request:e,response:w};for(let e of r.RESI)n=yield e.fn(n);return g({data:n.data,request:e},S)}return g({data:void 0,request:e},S)})()}createGet(e){return(t,r)=>this.request(r?g({},r,{method:e,url:t}):{method:e,url:t})}createPost(e){return(t,r,n)=>this.request(n?g({},n,{method:e,url:t,data:r}):{method:e,url:t,data:r})}get(e,t){return this.createGet("GET")(e,t)}head(e,t){return this.createGet("HEAD")(e,t)}post(e,t,r){return this.createPost("POST")(e,t,r)}put(e,t,r){return this.createPost("PUT")(e,t,r)}patch(e,t,r){return this.createPost("PATCH")(e,t,r)}delete(e,t){return this.createGet("DELETE")(e,t)}options(e,t){return this.createGet("OPTIONS")(e,t)}constructor(e){this.REQI=[m],this.RESI=[],this._plugins=[],this.config=e,this.defaults={params:{},headers:{}}}}R.VERSION="0.2.6";let O=Object.assign(R.create(),{create:R.create,VERSION:R.VERSION});export{a as XiorError,l as XiorTimeoutError,t as anySignal,r as buildSortedURL,O as default,n as delay,s as encodeParams,i as isAbsoluteURL,u as isXiorError,o as joinPath,R as xior};
import{merge as e}from"ts-deepmerge";export{merge}from"ts-deepmerge";function t(e,t){let r=new globalThis.AbortController;function n(e){r.abort(e),i()}let o=[];for(let t of e){if((null==t?void 0:t.aborted)===!0){n(t.reason);break}if((null==t?void 0:t.addEventListener)!=null){let e=()=>{n(t.reason)};o.push(()=>{(null==t?void 0:t.removeEventListener)!=null&&t.removeEventListener("abort",e)}),t.addEventListener("abort",e)}}function i(){o.forEach(e=>{e()}),null==t||t()}let s=r.signal;return s.clear=i,s}function r(e,t,r){let n=t?r(t):"";n&&(n=e+(e.includes("?")?"&"+n:"?"+n));let[o,i]=n.split("?");if(i){let e=i.split("&");return`${o}?${e.sort().join("&")}`}return n||e}function n(e){return new Promise(t=>{setTimeout(()=>{t("ok")},e)})}function o(e,t=!0,r=null){if(null==e)return"";let n=[],i=t?encodeURIComponent:e=>e;for(let s in e)if(Object.prototype.hasOwnProperty.call(e,s)){let a=e[s],u=r?`${r}[${i(s)}]`:i(s);if("object"==typeof a){let e=o(a,t,u);""!==e&&n.push(e)}else Array.isArray(a)?a.forEach((e,t)=>{let r=`${u}[${t}]`;n.push(`${i(r)}=${i(e)}`)}):n.push(`${i(u)}=${i(a)}`)}return n.join("&")}function i(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function s(e,t){return t?(e.endsWith("/")?e:e+"/")+(t.startsWith("/")?t.slice(1):t):e}class a extends Error{constructor(e,t,r){super(e),this.name="XiorError",this.request=t,this.config=t,this.response=r}}class u extends a{constructor(e,t,r){super(e),this.name="XiorTimeoutError",this.request=t,this.config=t,this.response=r}}function l(e){return"XiorError"===e.name||"XiorTimeoutError"===e.name}function c(e,t,r,n,o,i,s){try{var a=e[i](s),u=a.value}catch(e){r(e);return}a.done?t(u):Promise.resolve(u).then(n,o)}function h(){return(h=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}let f="application/",d=`${f}x-www-form-urlencoded`,p=`${f}json`;function m(e="GET"){return["HEAD","GET","OPTIONS"].includes(e)}function E(){var t;return t=function*(t){let r=t.paramsSerializer||o,n=!1!==t.encodeURI,i=t.method?t.method.toUpperCase():"GET",s=t.url||"",a=s,u=t.data,l=u,c=(null==t?void 0:t.headers)||{},f=t.params||{};if(u&&!(u instanceof FormData)){let n="";if(null==t?void 0:t.headers){let e=Object.keys(t.headers).find(e=>"content-type"===e.toLowerCase());e&&(n=t.headers[e],t.headers["Content-Type"]=n,"Content-Type"!==e&&delete t.headers[e])}let o=m(i);n||(n=o?d:p,c["Content-Type"]=n),o&&t.params&&(f=e({},u||{},f)),n===p?l=JSON.stringify(u):!o&&n===d&&u&&"object"==typeof u&&(l=r(u))}return Object.keys(f).length>0&&(s+=s.includes("?")?`&${r(f,n)}`:`?${r(f,n)}`),h({},t,{data:u,_data:l,url:a,_url:s,method:i,headers:c,paramsSerializer:r})},(E=function(){var e=this,r=arguments;return new Promise(function(n,o){var i=t.apply(e,r);function s(e){c(i,n,o,s,a,"next",e)}function a(e){c(i,n,o,s,a,"throw",e)}s(void 0)})}).apply(this,arguments)}function y(e,t,r,n,o,i,s){try{var a=e[i](s),u=a.value}catch(e){r(e);return}a.done?t(u):Promise.resolve(u).then(n,o)}function v(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function s(e){y(i,n,o,s,a,"next",e)}function a(e){y(i,n,o,s,a,"throw",e)}s(void 0)})}}function g(){return(g=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}let b="undefined"!=typeof AbortController;class O{static create(e){return new O(e)}get interceptors(){return{request:{use:(e,t)=>(this.REQI.push(e),e),eject:e=>{this.REQI=this.REQI.filter(t=>t!==e)},clear:()=>{this.REQI=[]}},response:{use:(e,t)=>(this.RESI.push({fn:e,onRejected:t}),e),eject:e=>{this.RESI=this.RESI.filter(t=>t.fn!==e)},clear:()=>{this.RESI=[]}}}}get plugins(){return{use:e=>(this.P.push(e),e),eject:e=>{this.P=this.P.filter(t=>t!==e)},clear:()=>{this.P=[]}}}request(t){var r=this;return v(function*(){let n=e({},r.config||{},r.defaults||{},"string"==typeof t?{url:t}:t||{},{headers:{},params:{}});for(let e of(n.paramsSerializer||(n.paramsSerializer=o),r.REQI))n=yield e(n);let i=r.fetch.bind(r);return r.P.forEach(e=>{i=e(i)}),i(n)})()}fetch(e){var r=this;return v(function*(){var n,o;let l,c;let h=yield function(e){return E.apply(this,arguments)}(e),{url:f,method:d,headers:p,timeout:y,signal:v,data:O,_data:P,_url:R}=h,T=function(e,t){if(null==e)return{};var r,n,o={},i=Object.keys(e);for(n=0;n<i.length;n++)t.indexOf(r=i[n])>=0||(o[r]=e[r]);return o}(h,["url","method","headers","timeout","signal","data","_data","_url"]);e._url=R;let j=[];if(y&&b){let t=new AbortController;c=setTimeout(()=>{t.abort(new u(`timeout of ${y}ms exceeded`,e))},y),j.push(t.signal)}v&&j.push(v),l=j[0],j.length>1&&(l=t(j,()=>{clearTimeout(c)}));let S=R||f||"";e.baseURL&&!i(S)&&(S=s(e.baseURL,S));let w=yield fetch(S,g({body:m(d)?void 0:P},T,{signal:l,method:d,headers:p}));c&&clearTimeout(c),null==l||null==(n=l.clear)||n.call(l);let I={response:w,config:e,status:w.status,statusText:w.statusText,headers:w.headers};if(!w.ok){let t;try{(t=yield w.text())&&(t=JSON.parse(t))}catch(e){}let n=new a(w.status?`Request failed with status code ${w.status}`:"Network error",e,g({data:t},I));for(let e of r.RESI)if(e.onRejected){let t=yield e.onRejected(n);if(null==t?void 0:null==(o=t.response)?void 0:o.ok)return t}throw n}if("HEAD"===d)return g({data:void 0,request:e},I);let{responseType:x}=e;if(!x||["json","text"].includes(x)){let t;try{(t=yield w.text())&&"text"!==x&&(t=JSON.parse(t))}catch(e){}let n={data:t,config:e,request:e,response:w};for(let e of r.RESI)n=yield e.fn(n);return g({data:n.data,request:e},I)}return g({data:void 0,request:e},I)})()}createGet(e){return(t,r)=>this.request(r?g({},r,{method:e,url:t}):{method:e,url:t})}createPost(e){return(t,r,n)=>this.request(n?g({},n,{method:e,url:t,data:r}):{method:e,url:t,data:r})}get(e,t){return this.createGet("GET")(e,t)}head(e,t){return this.createGet("HEAD")(e,t)}post(e,t,r){return this.createPost("POST")(e,t,r)}put(e,t,r){return this.createPost("PUT")(e,t,r)}patch(e,t,r){return this.createPost("PATCH")(e,t,r)}delete(e,t){return this.createGet("DELETE")(e,t)}options(e,t){return this.createGet("OPTIONS")(e,t)}constructor(e){this.REQI=[],this.RESI=[],this.P=[],this.config=e,this.defaults={params:{},headers:{}}}}O.VERSION="0.3.0";let P=Object.assign(O.create(),{create:O.create,VERSION:O.VERSION});export{a as XiorError,u as XiorTimeoutError,t as anySignal,r as buildSortedURL,P as default,n as delay,o as encodeParams,i as isAbsoluteURL,l as isXiorError,s as joinPath,O as xior};

@@ -10,4 +10,2 @@ export { merge } from 'ts-deepmerge';

timeout?: number;
/** @deprecated use paramsSerializer */
encode?: (params: Record<string, any>) => string;
paramsSerializer?: (params: Record<string, any>) => string;

@@ -22,6 +20,4 @@ /** Use encodeURIComponent, default: true */

data?: any;
_data?: any;
/** encoded url with params */
_url?: string;
/** useless now, compitable axios */
withCredentials?: boolean;

@@ -38,3 +34,2 @@ /**

url: string;
_url: string;
method: string;

@@ -63,3 +58,3 @@ };

declare function buildSortedURL(_url: string, data: any, encode: (obj: Record<string, any>) => string): string;
declare function buildSortedURL(url: string, data: any, paramsSerializer: (obj: Record<string, any>) => string): string;

@@ -115,2 +110,3 @@ declare function delay(ms: number): Promise<unknown>;

data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;

@@ -120,2 +116,3 @@ response: Response;

data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;

@@ -125,2 +122,3 @@ response: Response;

data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;

@@ -140,2 +138,3 @@ response: Response;

data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;

@@ -145,2 +144,3 @@ response: Response;

data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;

@@ -150,2 +150,3 @@ response: Response;

data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;

@@ -155,2 +156,3 @@ response: Response;

data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;

@@ -160,2 +162,3 @@ response: Response;

data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;

@@ -165,2 +168,3 @@ response: Response;

data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;

@@ -171,2 +175,3 @@ response: Response;

data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;

@@ -176,2 +181,3 @@ response: Response;

data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;

@@ -181,2 +187,3 @@ response: Response;

data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;

@@ -188,3 +195,4 @@ response: Response;

};
_plugins: XiorPlugin[];
/** plugins */
P: XiorPlugin[];
get plugins(): {

@@ -199,4 +207,10 @@ use: (plugin: XiorPlugin) => XiorPlugin;

createPost<T>(method: string): (url: string, data?: any, options?: XiorRequestConfig) => Promise<XiorResponse<T>>;
get<T = any>(url: string, options?: XiorRequestConfig): Promise<XiorResponse<T>>;
head<T = any>(url: string, options?: XiorRequestConfig): Promise<XiorResponse<T>>;
get<T = any>(url: string, options?: XiorRequestConfig & {
/** @deprecated No `data` in `GET` method */
data?: any;
}): Promise<XiorResponse<T>>;
head<T = any>(url: string, options?: XiorRequestConfig & {
/** @deprecated No `data` in `HEAD` method */
data?: any;
}): Promise<XiorResponse<T>>;
post<T = any>(url: string, data?: any, options?: XiorRequestConfig): Promise<XiorResponse<T>>;

@@ -206,3 +220,6 @@ put<T = any>(url: string, data?: any, options?: XiorRequestConfig): Promise<XiorResponse<T>>;

delete<T = any>(url: string, options?: XiorRequestConfig): Promise<XiorResponse<T>>;
options<T = any>(url: string, options?: XiorRequestConfig): Promise<XiorResponse<T>>;
options<T = any>(url: string, options?: XiorRequestConfig & {
/** @deprecated No `data` in `OPTIONS` method */
data?: any;
}): Promise<XiorResponse<T>>;
}

@@ -209,0 +226,0 @@

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.xior=t():e.xior=t()}(this,(()=>(()=>{"use strict";var e={699:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.anySignal=void 0,t.anySignal=function(e,t){const r=new globalThis.AbortController;function o(e){r.abort(e),i()}const n=[];for(const t of e){if(!0===(null==t?void 0:t.aborted)){o(t.reason);break}if(null!=(null==t?void 0:t.addEventListener)){const e=()=>{o(t.reason)};n.push((()=>{null!=(null==t?void 0:t.removeEventListener)&&t.removeEventListener("abort",e)})),t.addEventListener("abort",e)}}function i(){n.forEach((e=>{e()})),null==t||t()}const s=r.signal;return s.clear=i,s}},509:function(e,t,r){var o=this&&this.__createBinding||(Object.create?function(e,t,r,o){void 0===o&&(o=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,o,n)}:function(e,t,r,o){void 0===o&&(o=r),e[o]=t[r]}),n=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||o(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0});const i=r(895);n(r(895),t),n(r(340),t),n(r(976),t);const s=Object.assign(i.xior.create(),{create:i.xior.create,VERSION:i.xior.VERSION});t.default=s},393:function(e,t,r){var o=this&&this.__awaiter||function(e,t,r,o){return new(r||(r=Promise))((function(n,i){function s(e){try{c(o.next(e))}catch(e){i(e)}}function a(e){try{c(o.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}c((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.likeGET=t.formUrl=void 0;const n=r(976);t.formUrl="application/x-www-form-urlencoded";const i="application/json";function s(e="GET"){return["HEAD","GET","DELETE","OPTIONS"].includes(e)}t.likeGET=s,t.default=function(e){return o(this,void 0,void 0,(function*(){const r=e.encode||e.paramsSerializer||n.encodeParams,o=!1!==e.encodeURI,a=e.method?e.method.toUpperCase():"GET";let c=e.url||"";const u=c,l=e.data;let d=l,f=!1;const p=(null==e?void 0:e.headers)||{};if(l&&!(l instanceof FormData)){let u="";if(null==e?void 0:e.headers){const t=Object.keys(e.headers).find((e=>"content-type"===e.toLowerCase()));t&&(u=e.headers[t],e.headers["Content-Type"]=u,delete e.headers[t])}if(u||(u=s(a)?t.formUrl:i,p["Content-Type"]=u),u!==t.formUrl||"object"!=typeof l&&!e.params)u===i&&(d=JSON.stringify(l));else{f=!0;const t=r((0,n.merge)(l||{},e.params||{}),o);t&&(c+=c.includes("?")?`&${t}`:`?${t}`)}}return!f&&e.params&&Object.keys(e.params).length>0&&(c+=c.includes("?")?`&${r(e.params,o)}`:`?${r(e.params,o)}`),Object.assign(Object.assign({},e),{data:l,_data:d,url:u,_url:c,method:a,headers:p,encode:r,paramsSerializer:r})}))}},729:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.merge=void 0;const o=r(602);Object.defineProperty(t,"merge",{enumerable:!0,get:function(){return o.merge}})},629:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r){let o=t?r(t):"";o&&(o=e+(e.includes("?")?"&"+o:"?"+o));const[n,i]=o.split("?");return i?`${n}?${i.split("&").sort().join("&")}`:o||e}},99:function(e,t,r){var o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.delay=t.buildSortedURL=void 0;const n=o(r(629));t.buildSortedURL=n.default,t.delay=function(e){return new Promise((t=>{setTimeout((()=>{t("ok")}),e)}))}},340:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},976:function(e,t,r){var o=this&&this.__createBinding||(Object.create?function(e,t,r,o){void 0===o&&(o=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,o,n)}:function(e,t,r,o){void 0===o&&(o=r),e[o]=t[r]}),n=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||o(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),t.isXiorError=t.XiorTimeoutError=t.XiorError=t.joinPath=t.isAbsoluteURL=t.encodeParams=void 0,n(r(699),t),n(r(729),t),n(r(99),t),t.encodeParams=function e(t,r=!0,o=null){if(null==t)return"";const n=[],i=r?encodeURIComponent:e=>e;for(const s in t)if(Object.prototype.hasOwnProperty.call(t,s)){const a=t[s],c=o?`${o}[${i(s)}]`:i(s);if("object"==typeof a){const t=e(a,r,c);""!==t&&n.push(t)}else Array.isArray(a)?a.forEach(((e,t)=>{const r=`${c}[${t}]`;n.push(`${i(r)}=${i(e)}`)})):n.push(`${i(c)}=${i(a)}`)}return n.join("&")},t.isAbsoluteURL=function(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)},t.joinPath=function(e,t){return t?(e.endsWith("/")?e:e+"/")+(t.startsWith("/")?t.slice(1):t):e};class i extends Error{constructor(e,t,r){super(e),this.name="XiorError",this.request=t,this.config=t,this.response=r}}t.XiorError=i,t.XiorTimeoutError=class extends i{constructor(e,t,r){super(e),this.name="XiorTimeoutError",this.request=t,this.config=t,this.response=r}},t.isXiorError=function(e){return"XiorError"===e.name||"XiorTimeoutError"===e.name}},895:function(e,t,r){var o=this&&this.__createBinding||(Object.create?function(e,t,r,o){void 0===o&&(o=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,o,n)}:function(e,t,r,o){void 0===o&&(o=r),e[o]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&o(t,e,r);return n(t,e),t},s=this&&this.__awaiter||function(e,t,r,o){return new(r||(r=Promise))((function(n,i){function s(e){try{c(o.next(e))}catch(e){i(e)}}function a(e){try{c(o.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}c((o=o.apply(e,t||[])).next())}))},a=this&&this.__rest||function(e,t){var r={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(r[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(o=Object.getOwnPropertySymbols(e);n<o.length;n++)t.indexOf(o[n])<0&&Object.prototype.propertyIsEnumerable.call(e,o[n])&&(r[o[n]]=e[o[n]])}return r};Object.defineProperty(t,"__esModule",{value:!0}),t.xior=void 0;const c=i(r(393)),u=r(976),l="undefined"!=typeof AbortController;class d{static create(e){return new d(e)}constructor(e){this.REQI=[c.default],this.RESI=[],this._plugins=[],this.config=e,this.defaults={params:{},headers:{}}}get interceptors(){return{request:{use:(e,t)=>(this.REQI.push(e),e),eject:e=>{this.REQI=this.REQI.filter((t=>t!==e))},clear:()=>{this.REQI=[this.REQI[0]]}},response:{use:(e,t)=>(this.RESI.push({fn:e,onRejected:t}),e),eject:e=>{this.RESI=this.RESI.filter((t=>t.fn!==e))},clear:()=>{this.RESI=[]}}}}get plugins(){return{use:e=>(this._plugins.push(e),e),eject:e=>{this._plugins=this._plugins.filter((t=>t!==e))},clear:()=>{this._plugins=[]}}}request(e){return s(this,void 0,void 0,(function*(){let t=(0,u.merge)({},this.config||{},this.defaults||{},"string"==typeof e?{url:e}:e||{},{headers:{},params:{}});for(const e of this.REQI)t=yield e(t);let r=this.fetch.bind(this);return this._plugins.forEach((e=>{r=e(r)})),r(t)}))}fetch(e){var t,r,o;return s(this,void 0,void 0,(function*(){if(this._plugins.length>0)for(const t of this.REQI.slice(1))e=yield t(e);const{url:n,method:i,headers:s,timeout:d,signal:f,data:p,_data:h}=e,b=a(e,["url","method","headers","timeout","signal","data","_data"]);let y;const m=[];let g;if(d&&l){const t=new AbortController;g=setTimeout((()=>{t.abort(new u.XiorTimeoutError(`timeout of ${d}ms exceeded`,e))}),d),m.push(t.signal)}f&&m.push(f),y=m[0],m.length>1&&(y=(0,u.anySignal)(m,(()=>{clearTimeout(g)})));let v=e._url||n||"";e.baseURL&&!(0,u.isAbsoluteURL)(v)&&(v=(0,u.joinPath)(e.baseURL,v));const O=yield fetch(v,Object.assign(Object.assign({body:(0,c.likeGET)(e.method)||(null===(t=e.headers)||void 0===t?void 0:t["Content-Type"])===c.formUrl?void 0:h},b),{signal:y,method:i,headers:s}));g&&clearTimeout(g),null===(r=null==y?void 0:y.clear)||void 0===r||r.call(y);const j={response:O,config:e,status:O.status,statusText:O.statusText,headers:O.headers};if(!O.ok){let t;try{t=yield O.text(),t&&(t=JSON.parse(t))}catch(e){}const r=new u.XiorError(O.status?`Request failed with status code ${O.status}`:"Network error",e,Object.assign({data:t},j));for(const e of this.RESI)if(e.onRejected){const t=yield e.onRejected(r);if(null===(o=null==t?void 0:t.response)||void 0===o?void 0:o.ok)return t}throw r}if("HEAD"===e.method)return Object.assign({data:void 0,request:e},j);const{responseType:_}=e;if(!_||"json"===_||"text"===_){let t;try{t=yield O.text(),t&&"text"!==_&&(t=JSON.parse(t))}catch(e){}let r={data:t,request:e,response:O};for(const e of this.RESI)r=yield e.fn(r);return Object.assign({data:r.data,request:e},j)}return Object.assign({data:void 0,request:e},j)}))}createGet(e){return(t,r)=>this.request(r?Object.assign(Object.assign({},r),{method:e,url:t}):{method:e,url:t})}createPost(e){return(t,r,o)=>this.request(o?Object.assign(Object.assign({},o),{method:e,url:t,data:r}):{method:e,url:t,data:r})}get(e,t){return this.createGet("GET")(e,t)}head(e,t){return this.createGet("HEAD")(e,t)}post(e,t,r){return this.createPost("POST")(e,t,r)}put(e,t,r){return this.createPost("PUT")(e,t,r)}patch(e,t,r){return this.createPost("PATCH")(e,t,r)}delete(e,t){return this.createGet("DELETE")(e,t)}options(e,t){return this.createGet("OPTIONS")(e,t)}}t.xior=d,d.VERSION="0.2.6"},602:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.merge=void 0;const r=e=>{if("object"==typeof e&&null!==e){if("function"==typeof Object.getPrototypeOf){const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}return"[object Object]"===Object.prototype.toString.call(e)}return!1};t.merge=(...e)=>e.reduce(((e,o)=>{if(Array.isArray(o))throw new TypeError("Arguments provided to ts-deepmerge must be objects, not arrays.");return Object.keys(o).forEach((n=>{["__proto__","constructor","prototype"].includes(n)||(Array.isArray(e[n])&&Array.isArray(o[n])?e[n]=t.merge.options.mergeArrays?t.merge.options.uniqueArrayItems?Array.from(new Set(e[n].concat(o[n]))):[...e[n],...o[n]]:o[n]:r(e[n])&&r(o[n])?e[n]=(0,t.merge)(e[n],o[n]):e[n]=void 0===o[n]?t.merge.options.allowUndefinedOverrides?o[n]:e[n]:o[n])})),e}),{});const o={allowUndefinedOverrides:!0,mergeArrays:!0,uniqueArrayItems:!0};t.merge.options=o,t.merge.withOptions=(e,...r)=>{t.merge.options=Object.assign(Object.assign({},o),e);const n=(0,t.merge)(...r);return t.merge.options=o,n}}},t={},r=function r(o){var n=t[o];if(void 0!==n)return n.exports;var i=t[o]={exports:{}};return e[o].call(i.exports,i,i.exports,r),i.exports}(509);return r.default})()));
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.xior=t():e.xior=t()}(this,(()=>(()=>{"use strict";var e={699:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.anySignal=void 0,t.anySignal=function(e,t){const r=new globalThis.AbortController;function o(e){r.abort(e),i()}const n=[];for(const t of e){if(!0===(null==t?void 0:t.aborted)){o(t.reason);break}if(null!=(null==t?void 0:t.addEventListener)){const e=()=>{o(t.reason)};n.push((()=>{null!=(null==t?void 0:t.removeEventListener)&&t.removeEventListener("abort",e)})),t.addEventListener("abort",e)}}function i(){n.forEach((e=>{e()})),null==t||t()}const s=r.signal;return s.clear=i,s}},509:function(e,t,r){var o=this&&this.__createBinding||(Object.create?function(e,t,r,o){void 0===o&&(o=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,o,n)}:function(e,t,r,o){void 0===o&&(o=r),e[o]=t[r]}),n=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||o(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0});const i=r(895);n(r(895),t),n(r(340),t),n(r(976),t);const s=Object.assign(i.xior.create(),{create:i.xior.create,VERSION:i.xior.VERSION});t.default=s},393:function(e,t,r){var o=this&&this.__awaiter||function(e,t,r,o){return new(r||(r=Promise))((function(n,i){function s(e){try{c(o.next(e))}catch(e){i(e)}}function a(e){try{c(o.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}c((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.likeGET=void 0;const n=r(976),i="application/",s=`${i}x-www-form-urlencoded`,a=`${i}json`;function c(e="GET"){return["HEAD","GET","OPTIONS"].includes(e)}t.likeGET=c,t.default=function(e){return o(this,void 0,void 0,(function*(){const t=e.paramsSerializer||n.encodeParams,r=!1!==e.encodeURI,o=e.method?e.method.toUpperCase():"GET";let i=e.url||"";const u=i,l=e.data;let d=l;const f=(null==e?void 0:e.headers)||{};let h=e.params||{};if(l&&!(l instanceof FormData)){let r="";if(null==e?void 0:e.headers){const t=Object.keys(e.headers).find((e=>"content-type"===e.toLowerCase()));t&&(r=e.headers[t],e.headers["Content-Type"]=r,"Content-Type"!==t&&delete e.headers[t])}const i=c(o);r||(r=i?s:a,f["Content-Type"]=r),i&&e.params&&(h=(0,n.merge)({},l||{},h)),r===a?d=JSON.stringify(l):!i&&r===s&&l&&"object"==typeof l&&(d=t(l))}return Object.keys(h).length>0&&(i+=i.includes("?")?`&${t(h,r)}`:`?${t(h,r)}`),Object.assign(Object.assign({},e),{data:l,_data:d,url:u,_url:i,method:o,headers:f,paramsSerializer:t})}))}},729:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.merge=void 0;const o=r(602);Object.defineProperty(t,"merge",{enumerable:!0,get:function(){return o.merge}})},629:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r){let o=t?r(t):"";o&&(o=e+(e.includes("?")?"&"+o:"?"+o));const[n,i]=o.split("?");return i?`${n}?${i.split("&").sort().join("&")}`:o||e}},99:function(e,t,r){var o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.delay=t.buildSortedURL=void 0;const n=o(r(629));t.buildSortedURL=n.default,t.delay=function(e){return new Promise((t=>{setTimeout((()=>{t("ok")}),e)}))}},340:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},976:function(e,t,r){var o=this&&this.__createBinding||(Object.create?function(e,t,r,o){void 0===o&&(o=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,o,n)}:function(e,t,r,o){void 0===o&&(o=r),e[o]=t[r]}),n=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||o(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),t.isXiorError=t.XiorTimeoutError=t.XiorError=t.joinPath=t.isAbsoluteURL=t.encodeParams=void 0,n(r(699),t),n(r(729),t),n(r(99),t),t.encodeParams=function e(t,r=!0,o=null){if(null==t)return"";const n=[],i=r?encodeURIComponent:e=>e;for(const s in t)if(Object.prototype.hasOwnProperty.call(t,s)){const a=t[s],c=o?`${o}[${i(s)}]`:i(s);if("object"==typeof a){const t=e(a,r,c);""!==t&&n.push(t)}else Array.isArray(a)?a.forEach(((e,t)=>{const r=`${c}[${t}]`;n.push(`${i(r)}=${i(e)}`)})):n.push(`${i(c)}=${i(a)}`)}return n.join("&")},t.isAbsoluteURL=function(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)},t.joinPath=function(e,t){return t?(e.endsWith("/")?e:e+"/")+(t.startsWith("/")?t.slice(1):t):e};class i extends Error{constructor(e,t,r){super(e),this.name="XiorError",this.request=t,this.config=t,this.response=r}}t.XiorError=i,t.XiorTimeoutError=class extends i{constructor(e,t,r){super(e),this.name="XiorTimeoutError",this.request=t,this.config=t,this.response=r}},t.isXiorError=function(e){return"XiorError"===e.name||"XiorTimeoutError"===e.name}},895:function(e,t,r){var o=this&&this.__createBinding||(Object.create?function(e,t,r,o){void 0===o&&(o=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,o,n)}:function(e,t,r,o){void 0===o&&(o=r),e[o]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&o(t,e,r);return n(t,e),t},s=this&&this.__awaiter||function(e,t,r,o){return new(r||(r=Promise))((function(n,i){function s(e){try{c(o.next(e))}catch(e){i(e)}}function a(e){try{c(o.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}c((o=o.apply(e,t||[])).next())}))},a=this&&this.__rest||function(e,t){var r={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(r[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(o=Object.getOwnPropertySymbols(e);n<o.length;n++)t.indexOf(o[n])<0&&Object.prototype.propertyIsEnumerable.call(e,o[n])&&(r[o[n]]=e[o[n]])}return r};Object.defineProperty(t,"__esModule",{value:!0}),t.xior=void 0;const c=i(r(393)),u=r(976),l="undefined"!=typeof AbortController;class d{static create(e){return new d(e)}constructor(e){this.REQI=[],this.RESI=[],this.P=[],this.config=e,this.defaults={params:{},headers:{}}}get interceptors(){return{request:{use:(e,t)=>(this.REQI.push(e),e),eject:e=>{this.REQI=this.REQI.filter((t=>t!==e))},clear:()=>{this.REQI=[]}},response:{use:(e,t)=>(this.RESI.push({fn:e,onRejected:t}),e),eject:e=>{this.RESI=this.RESI.filter((t=>t.fn!==e))},clear:()=>{this.RESI=[]}}}}get plugins(){return{use:e=>(this.P.push(e),e),eject:e=>{this.P=this.P.filter((t=>t!==e))},clear:()=>{this.P=[]}}}request(e){return s(this,void 0,void 0,(function*(){let t=(0,u.merge)({},this.config||{},this.defaults||{},"string"==typeof e?{url:e}:e||{},{headers:{},params:{}});t.paramsSerializer||(t.paramsSerializer=u.encodeParams);for(const e of this.REQI)t=yield e(t);let r=this.fetch.bind(this);return this.P.forEach((e=>{r=e(r)})),r(t)}))}fetch(e){var t,r;return s(this,void 0,void 0,(function*(){const o=yield(0,c.default)(e),{url:n,method:i,headers:s,timeout:d,signal:f,data:h,_data:p,_url:b}=o,y=a(o,["url","method","headers","timeout","signal","data","_data","_url"]);let m;e._url=b;const O=[];let g;if(d&&l){const t=new AbortController;g=setTimeout((()=>{t.abort(new u.XiorTimeoutError(`timeout of ${d}ms exceeded`,e))}),d),O.push(t.signal)}f&&O.push(f),m=O[0],O.length>1&&(m=(0,u.anySignal)(O,(()=>{clearTimeout(g)})));let v=b||n||"";e.baseURL&&!(0,u.isAbsoluteURL)(v)&&(v=(0,u.joinPath)(e.baseURL,v));const j=yield fetch(v,Object.assign(Object.assign({body:(0,c.likeGET)(i)?void 0:p},y),{signal:m,method:i,headers:s}));g&&clearTimeout(g),null===(t=null==m?void 0:m.clear)||void 0===t||t.call(m);const _={response:j,config:e,status:j.status,statusText:j.statusText,headers:j.headers};if(!j.ok){let t;try{t=yield j.text(),t&&(t=JSON.parse(t))}catch(e){}const o=new u.XiorError(j.status?`Request failed with status code ${j.status}`:"Network error",e,Object.assign({data:t},_));for(const e of this.RESI)if(e.onRejected){const t=yield e.onRejected(o);if(null===(r=null==t?void 0:t.response)||void 0===r?void 0:r.ok)return t}throw o}if("HEAD"===i)return Object.assign({data:void 0,request:e},_);const{responseType:E}=e;if(!E||["json","text"].includes(E)){let t;try{t=yield j.text(),t&&"text"!==E&&(t=JSON.parse(t))}catch(e){}let r={data:t,config:e,request:e,response:j};for(const e of this.RESI)r=yield e.fn(r);return Object.assign({data:r.data,request:e},_)}return Object.assign({data:void 0,request:e},_)}))}createGet(e){return(t,r)=>this.request(r?Object.assign(Object.assign({},r),{method:e,url:t}):{method:e,url:t})}createPost(e){return(t,r,o)=>this.request(o?Object.assign(Object.assign({},o),{method:e,url:t,data:r}):{method:e,url:t,data:r})}get(e,t){return this.createGet("GET")(e,t)}head(e,t){return this.createGet("HEAD")(e,t)}post(e,t,r){return this.createPost("POST")(e,t,r)}put(e,t,r){return this.createPost("PUT")(e,t,r)}patch(e,t,r){return this.createPost("PATCH")(e,t,r)}delete(e,t){return this.createGet("DELETE")(e,t)}options(e,t){return this.createGet("OPTIONS")(e,t)}}t.xior=d,d.VERSION="0.3.0"},602:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.merge=void 0;const r=e=>{if("object"==typeof e&&null!==e){if("function"==typeof Object.getPrototypeOf){const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}return"[object Object]"===Object.prototype.toString.call(e)}return!1};t.merge=(...e)=>e.reduce(((e,o)=>{if(Array.isArray(o))throw new TypeError("Arguments provided to ts-deepmerge must be objects, not arrays.");return Object.keys(o).forEach((n=>{["__proto__","constructor","prototype"].includes(n)||(Array.isArray(e[n])&&Array.isArray(o[n])?e[n]=t.merge.options.mergeArrays?t.merge.options.uniqueArrayItems?Array.from(new Set(e[n].concat(o[n]))):[...e[n],...o[n]]:o[n]:r(e[n])&&r(o[n])?e[n]=(0,t.merge)(e[n],o[n]):e[n]=void 0===o[n]?t.merge.options.allowUndefinedOverrides?o[n]:e[n]:o[n])})),e}),{});const o={allowUndefinedOverrides:!0,mergeArrays:!0,uniqueArrayItems:!0};t.merge.options=o,t.merge.withOptions=(e,...r)=>{t.merge.options=Object.assign(Object.assign({},o),e);const n=(0,t.merge)(...r);return t.merge.options=o,n}}},t={},r=function r(o){var n=t[o];if(void 0!==n)return n.exports;var i=t[o]={exports:{}};return e[o].call(i.exports,i,i.exports,r),i.exports}(509);return r.default})()));
{
"name": "xior",
"version": "0.2.6",
"version": "0.3.0",
"description": "A lite request lib based on fetch with plugins support, and axios similar API",

@@ -5,0 +5,0 @@ "repository": "suhaotian/xior",

/*! For license information please see cache.umd.js.LICENSE.txt */
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.xiorCache=e():t.xiorCache=e()}(this,(()=>(()=>{"use strict";var t={629:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t,e,i){let s=e?i(e):"";s&&(s=t+(t.includes("?")?"&"+s:"?"+s));const[n,r]=s.split("?");return r?`${n}?${r.split("&").sort().join("&")}`:s||t}},523:function(t,e,i){var s=this&&this.__awaiter||function(t,e,i,s){return new(i||(i=Promise))((function(n,r){function l(t){try{o(s.next(t))}catch(t){r(t)}}function h(t){try{o(s.throw(t))}catch(t){r(t)}}function o(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(l,h)}o((s=s.apply(t,e||[])).next())}))},n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=i(455),l=n(i(629));e.default=function(t={}){const{enableCache:e,defaultCache:i=(0,r.lru)(100,3e5)}=t;return function(t){return n=>s(this,void 0,void 0,(function*(){const{enableCache:r=e,forceUpdate:h,defaultCache:o=i,_url:u,encode:a,data:f}=n,c="GET"===n.method||n.isGet,p=typeof r;if("undefined"===p?c:"function"===p?r(n):Boolean(r)){const e=o,i=(0,l.default)(u,f,a);let r=e.get(i);return!r||h?(r=(()=>s(this,void 0,void 0,(function*(){try{return yield t(n)}catch(t){throw"delete"in e?e.delete(i):e.del(i),t}})))(),e.set(i,r),r):r.then((t=>(t.fromCache=!0,t)))}return t(n)}))}}},455:(t,e)=>{class i{constructor(t=0,e=0,i=!1){this.first=null,this.items=Object.create(null),this.last=null,this.max=t,this.resetTtl=i,this.size=0,this.ttl=e}clear(){return this.first=null,this.items=Object.create(null),this.last=null,this.size=0,this}delete(t){if(this.has(t)){const e=this.items[t];delete this.items[t],this.size--,null!==e.prev&&(e.prev.next=e.next),null!==e.next&&(e.next.prev=e.prev),this.first===e&&(this.first=e.next),this.last===e&&(this.last=e.prev)}return this}entries(t=this.keys()){return t.map((t=>[t,this.get(t)]))}evict(t=!1){if(t||this.size>0){const t=this.first;delete this.items[t.key],0==--this.size?(this.first=null,this.last=null):(this.first=t.next,this.first.prev=null)}return this}expiresAt(t){let e;return this.has(t)&&(e=this.items[t].expiry),e}get(t){let e;if(this.has(t)){const i=this.items[t];this.ttl>0&&i.expiry<=Date.now()?this.delete(t):(e=i.value,this.set(t,e,!0))}return e}has(t){return t in this.items}keys(){const t=[];let e=this.first;for(;null!==e;)t.push(e.key),e=e.next;return t}set(t,e,i=!1,s=this.resetTtl){let n;if(i||this.has(t)){if(n=this.items[t],n.value=e,!1===i&&s&&(n.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.last!==n){const t=this.last,e=n.next,i=n.prev;this.first===n&&(this.first=n.next),n.next=null,n.prev=this.last,t.next=n,null!==i&&(i.next=e),null!==e&&(e.prev=i)}}else this.max>0&&this.size===this.max&&this.evict(!0),n=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e},1==++this.size?this.first=n:this.last.next=n;return this.last=n,this}values(t=this.keys()){return t.map((t=>this.get(t)))}}e.LRU=i,e.lru=function(t=1e3,e=0,s=!1){if(isNaN(t)||t<0)throw new TypeError("Invalid max value");if(isNaN(e)||e<0)throw new TypeError("Invalid ttl value");if("boolean"!=typeof s)throw new TypeError("Invalid resetTtl value");return new i(t,e,s)}}},e={},i=function i(s){var n=e[s];if(void 0!==n)return n.exports;var r=e[s]={exports:{}};return t[s].call(r.exports,r,r.exports,i),r.exports}(523);return i.default})()));
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.xiorCache=e():t.xiorCache=e()}(this,(()=>(()=>{"use strict";var t={699:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.anySignal=void 0,e.anySignal=function(t,e){const r=new globalThis.AbortController;function i(t){r.abort(t),s()}const n=[];for(const e of t){if(!0===(null==e?void 0:e.aborted)){i(e.reason);break}if(null!=(null==e?void 0:e.addEventListener)){const t=()=>{i(e.reason)};n.push((()=>{null!=(null==e?void 0:e.removeEventListener)&&e.removeEventListener("abort",t)})),e.addEventListener("abort",t)}}function s(){n.forEach((t=>{t()})),null==e||e()}const o=r.signal;return o.clear=s,o}},729:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.merge=void 0;const i=r(602);Object.defineProperty(e,"merge",{enumerable:!0,get:function(){return i.merge}})},629:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t,e,r){let i=e?r(e):"";i&&(i=t+(t.includes("?")?"&"+i:"?"+i));const[n,s]=i.split("?");return s?`${n}?${s.split("&").sort().join("&")}`:i||t}},523:function(t,e,r){var i=this&&this.__awaiter||function(t,e,r,i){return new(r||(r=Promise))((function(n,s){function o(t){try{u(i.next(t))}catch(t){s(t)}}function l(t){try{u(i.throw(t))}catch(t){s(t)}}function u(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(o,l)}u((i=i.apply(t,e||[])).next())}))},n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const s=r(455),o=n(r(629)),l=r(976);e.default=function(t={}){const{enableCache:e,defaultCache:r=(0,s.lru)(100,3e5)}=t;return function(t){return n=>i(this,void 0,void 0,(function*(){const{enableCache:s=e,forceUpdate:u,defaultCache:a=r,paramsSerializer:c}=n,h="GET"===n.method||n.isGet,f=typeof s;if("undefined"===f?h:"function"===f?s(n):Boolean(s)){const e=a,r=(0,o.default)(n.url&&(0,l.isAbsoluteURL)(n.url)?n.url:(0,l.joinPath)(n.baseURL||"",n.url||""),{a:n.data,b:n.params},c);let s=e.get(r);return!s||u?(s=(()=>i(this,void 0,void 0,(function*(){try{return yield t(n)}catch(t){throw"delete"in e?e.delete(r):e.del(r),t}})))(),e.set(r,s),s):s.then((t=>(t.fromCache=!0,t)))}return t(n)}))}}},99:function(t,e,r){var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.delay=e.buildSortedURL=void 0;const n=i(r(629));e.buildSortedURL=n.default,e.delay=function(t){return new Promise((e=>{setTimeout((()=>{e("ok")}),t)}))}},976:function(t,e,r){var i=this&&this.__createBinding||(Object.create?function(t,e,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(e,r);n&&!("get"in n?!e.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,i,n)}:function(t,e,r,i){void 0===i&&(i=r),t[i]=e[r]}),n=this&&this.__exportStar||function(t,e){for(var r in t)"default"===r||Object.prototype.hasOwnProperty.call(e,r)||i(e,t,r)};Object.defineProperty(e,"__esModule",{value:!0}),e.isXiorError=e.XiorTimeoutError=e.XiorError=e.joinPath=e.isAbsoluteURL=e.encodeParams=void 0,n(r(699),e),n(r(729),e),n(r(99),e),e.encodeParams=function t(e,r=!0,i=null){if(null==e)return"";const n=[],s=r?encodeURIComponent:t=>t;for(const o in e)if(Object.prototype.hasOwnProperty.call(e,o)){const l=e[o],u=i?`${i}[${s(o)}]`:s(o);if("object"==typeof l){const e=t(l,r,u);""!==e&&n.push(e)}else Array.isArray(l)?l.forEach(((t,e)=>{const r=`${u}[${e}]`;n.push(`${s(r)}=${s(t)}`)})):n.push(`${s(u)}=${s(l)}`)}return n.join("&")},e.isAbsoluteURL=function(t){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)},e.joinPath=function(t,e){return e?(t.endsWith("/")?t:t+"/")+(e.startsWith("/")?e.slice(1):e):t};class s extends Error{constructor(t,e,r){super(t),this.name="XiorError",this.request=e,this.config=e,this.response=r}}e.XiorError=s,e.XiorTimeoutError=class extends s{constructor(t,e,r){super(t),this.name="XiorTimeoutError",this.request=e,this.config=e,this.response=r}},e.isXiorError=function(t){return"XiorError"===t.name||"XiorTimeoutError"===t.name}},455:(t,e)=>{class r{constructor(t=0,e=0,r=!1){this.first=null,this.items=Object.create(null),this.last=null,this.max=t,this.resetTtl=r,this.size=0,this.ttl=e}clear(){return this.first=null,this.items=Object.create(null),this.last=null,this.size=0,this}delete(t){if(this.has(t)){const e=this.items[t];delete this.items[t],this.size--,null!==e.prev&&(e.prev.next=e.next),null!==e.next&&(e.next.prev=e.prev),this.first===e&&(this.first=e.next),this.last===e&&(this.last=e.prev)}return this}entries(t=this.keys()){return t.map((t=>[t,this.get(t)]))}evict(t=!1){if(t||this.size>0){const t=this.first;delete this.items[t.key],0==--this.size?(this.first=null,this.last=null):(this.first=t.next,this.first.prev=null)}return this}expiresAt(t){let e;return this.has(t)&&(e=this.items[t].expiry),e}get(t){let e;if(this.has(t)){const r=this.items[t];this.ttl>0&&r.expiry<=Date.now()?this.delete(t):(e=r.value,this.set(t,e,!0))}return e}has(t){return t in this.items}keys(){const t=[];let e=this.first;for(;null!==e;)t.push(e.key),e=e.next;return t}set(t,e,r=!1,i=this.resetTtl){let n;if(r||this.has(t)){if(n=this.items[t],n.value=e,!1===r&&i&&(n.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.last!==n){const t=this.last,e=n.next,r=n.prev;this.first===n&&(this.first=n.next),n.next=null,n.prev=this.last,t.next=n,null!==r&&(r.next=e),null!==e&&(e.prev=r)}}else this.max>0&&this.size===this.max&&this.evict(!0),n=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e},1==++this.size?this.first=n:this.last.next=n;return this.last=n,this}values(t=this.keys()){return t.map((t=>this.get(t)))}}e.LRU=r,e.lru=function(t=1e3,e=0,i=!1){if(isNaN(t)||t<0)throw new TypeError("Invalid max value");if(isNaN(e)||e<0)throw new TypeError("Invalid ttl value");if("boolean"!=typeof i)throw new TypeError("Invalid resetTtl value");return new r(t,e,i)}},602:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.merge=void 0;const r=t=>{if("object"==typeof t&&null!==t){if("function"==typeof Object.getPrototypeOf){const e=Object.getPrototypeOf(t);return e===Object.prototype||null===e}return"[object Object]"===Object.prototype.toString.call(t)}return!1};e.merge=(...t)=>t.reduce(((t,i)=>{if(Array.isArray(i))throw new TypeError("Arguments provided to ts-deepmerge must be objects, not arrays.");return Object.keys(i).forEach((n=>{["__proto__","constructor","prototype"].includes(n)||(Array.isArray(t[n])&&Array.isArray(i[n])?t[n]=e.merge.options.mergeArrays?e.merge.options.uniqueArrayItems?Array.from(new Set(t[n].concat(i[n]))):[...t[n],...i[n]]:i[n]:r(t[n])&&r(i[n])?t[n]=(0,e.merge)(t[n],i[n]):t[n]=void 0===i[n]?e.merge.options.allowUndefinedOverrides?i[n]:t[n]:i[n])})),t}),{});const i={allowUndefinedOverrides:!0,mergeArrays:!0,uniqueArrayItems:!0};e.merge.options=i,e.merge.withOptions=(t,...r)=>{e.merge.options=Object.assign(Object.assign({},i),t);const n=(0,e.merge)(...r);return e.merge.options=i,n}}},e={},r=function r(i){var n=e[i];if(void 0!==n)return n.exports;var s=e[i]={exports:{}};return t[i].call(s.exports,s,s.exports,r),s.exports}(523);return r.default})()));

@@ -17,4 +17,2 @@ type ICacheLike<T> = {

timeout?: number;
/** @deprecated use paramsSerializer */
encode?: (params: Record<string, any>) => string;
paramsSerializer?: (params: Record<string, any>) => string;

@@ -29,6 +27,4 @@ /** Use encodeURIComponent, default: true */

data?: any;
_data?: any;
/** encoded url with params */
_url?: string;
/** useless now, compitable axios */
withCredentials?: boolean;

@@ -45,3 +41,2 @@ /**

url: string;
_url: string;
method: string;

@@ -48,0 +43,0 @@ };

@@ -17,4 +17,2 @@ type ICacheLike<T> = {

timeout?: number;
/** @deprecated use paramsSerializer */
encode?: (params: Record<string, any>) => string;
paramsSerializer?: (params: Record<string, any>) => string;

@@ -29,6 +27,4 @@ /** Use encodeURIComponent, default: true */

data?: any;
_data?: any;
/** encoded url with params */
_url?: string;
/** useless now, compitable axios */
withCredentials?: boolean;

@@ -45,3 +41,2 @@ /**

url: string;
_url: string;
method: string;

@@ -48,0 +43,0 @@ };

@@ -1,1 +0,1 @@

import{lru as t}from"tiny-lru";function e(t,e,n,r,i,u,o){try{var c=t[u](o),l=c.value}catch(t){n(t);return}c.done?e(l):Promise.resolve(l).then(r,i)}function n(t){return function(){var n=this,r=arguments;return new Promise(function(i,u){var o=t.apply(n,r);function c(t){e(o,i,u,c,l,"next",t)}function l(t){e(o,i,u,c,l,"throw",t)}c(void 0)})}}function r(e={}){let{enableCache:r,defaultCache:i=t(100,3e5)}=e;return function(t){return n(function*(e){let{enableCache:u=r,forceUpdate:o,defaultCache:c=i,_url:l,encode:f,data:a}=e,d="GET"===e.method||e.isGet,h=typeof u;if("undefined"===h?d:"function"===h?u(e):!!u){let r=function(t,e,n){let r=e?n(e):"";r&&(r=t+(t.includes("?")?"&"+r:"?"+r));let[i,u]=r.split("?");if(u){let t=u.split("&");return`${i}?${t.sort().join("&")}`}return r||t}(l,a,f),i=c.get(r);return!i||o?(i=n(function*(){try{return yield t(e)}catch(t){throw"delete"in c?c.delete(r):c.del(r),t}})(),c.set(r,i),i):i.then(t=>(t.fromCache=!0,t))}return t(e)})}}export{r as default};
import{lru as t}from"tiny-lru";import"ts-deepmerge";function e(t,e,n,r,i,u,o){try{var l=t[u](o),a=l.value}catch(t){n(t);return}l.done?e(a):Promise.resolve(a).then(r,i)}function n(t){return function(){var n=this,r=arguments;return new Promise(function(i,u){var o=t.apply(n,r);function l(t){e(o,i,u,l,a,"next",t)}function a(t){e(o,i,u,l,a,"throw",t)}l(void 0)})}}function r(e={}){let{enableCache:r,defaultCache:i=t(100,3e5)}=e;return function(t){return n(function*(e){let{enableCache:u=r,forceUpdate:o,defaultCache:l=i,paramsSerializer:a}=e,c="GET"===e.method||e.isGet,f=typeof u;if("undefined"===f?c:"function"===f?u(e):!!u){var s,d,h;let r=function(t,e,n){let r=e?n(e):"";r&&(r=t+(t.includes("?")?"&"+r:"?"+r));let[i,u]=r.split("?");if(u){let t=u.split("&");return`${i}?${t.sort().join("&")}`}return r||t}(e.url&&(s=e.url,/^([a-z][a-z\d+\-.]*:)?\/\//i.test(s))?e.url:(d=e.baseURL||"",(h=e.url||"")?(d.endsWith("/")?d:d+"/")+(h.startsWith("/")?h.slice(1):h):d),{a:e.data,b:e.params},a),i=l.get(r);return!i||o?(i=n(function*(){try{return yield t(e)}catch(t){throw"delete"in l?l.delete(r):l.del(r),t}})(),l.set(r,i),i):i.then(t=>(t.fromCache=!0,t))}return t(e)})}}export{r as default};

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.xiorDedupe=t():e.xiorDedupe=t()}(this,(()=>(()=>{"use strict";var e={629:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,n){let i=t?n(t):"";i&&(i=e+(e.includes("?")?"&"+i:"?"+i));const[o,r]=i.split("?");return r?`${o}?${r.split("&").sort().join("&")}`:i||e}},91:function(e,t,n){var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(o,r){function u(e){try{l(i.next(e))}catch(e){r(e)}}function f(e){try{l(i.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(u,f)}l((i=i.apply(e,t||[])).next())}))},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.inflight=void 0;const r=o(n(629));t.inflight=new Map,t.default=function(e={}){const{enableDedupe:n}=e;return function(e){return o=>i(this,void 0,void 0,(function*(){var i,u;const{_url:f,encode:l,enableDedupe:c=n,data:d}=o,s="GET"===o.method||o.isGet,a=typeof c;if(!("undefined"===a?s:"function"===a?c(o):Boolean(c)))return e(o);const p=(0,r.default)(f,d,l);if(t.inflight.has(p))return new Promise(((e,n)=>{var i;null===(i=t.inflight.get(p))||void 0===i||i.push([e,n])}));t.inflight.set(p,[]);try{const n=yield e(o);return null===(i=t.inflight.get(p))||void 0===i||i.forEach((([e])=>e(n))),t.inflight.delete(p),n}catch(e){throw null===(u=t.inflight.get(p))||void 0===u||u.forEach((([,t])=>t(e))),t.inflight.delete(p),e}}))}}}},t={},n=function n(i){var o=t[i];if(void 0!==o)return o.exports;var r=t[i]={exports:{}};return e[i].call(r.exports,r,r.exports,n),r.exports}(91);return n.default})()));
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.xiorDedupe=t():e.xiorDedupe=t()}(this,(()=>(()=>{"use strict";var e={699:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.anySignal=void 0,t.anySignal=function(e,t){const r=new globalThis.AbortController;function o(e){r.abort(e),i()}const n=[];for(const t of e){if(!0===(null==t?void 0:t.aborted)){o(t.reason);break}if(null!=(null==t?void 0:t.addEventListener)){const e=()=>{o(t.reason)};n.push((()=>{null!=(null==t?void 0:t.removeEventListener)&&t.removeEventListener("abort",e)})),t.addEventListener("abort",e)}}function i(){n.forEach((e=>{e()})),null==t||t()}const s=r.signal;return s.clear=i,s}},729:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.merge=void 0;const o=r(602);Object.defineProperty(t,"merge",{enumerable:!0,get:function(){return o.merge}})},629:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r){let o=t?r(t):"";o&&(o=e+(e.includes("?")?"&"+o:"?"+o));const[n,i]=o.split("?");return i?`${n}?${i.split("&").sort().join("&")}`:o||e}},91:function(e,t,r){var o=this&&this.__awaiter||function(e,t,r,o){return new(r||(r=Promise))((function(n,i){function s(e){try{a(o.next(e))}catch(e){i(e)}}function u(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,u)}a((o=o.apply(e,t||[])).next())}))},n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.inflight=void 0;const i=n(r(629)),s=r(976);t.inflight=new Map,t.default=function(e={}){const{enableDedupe:r}=e;return function(e){return n=>o(this,void 0,void 0,(function*(){var o,u;const{paramsSerializer:a,enableDedupe:c=r}=n,l="GET"===n.method||n.isGet,f=typeof c;if(!("undefined"===f?l:"function"===f?c(n):Boolean(c)))return e(n);const d=(0,i.default)(n.url&&(0,s.isAbsoluteURL)(n.url)?n.url:(0,s.joinPath)(n.baseURL||"",n.url||""),{a:n.data,b:n.params},a);if(t.inflight.has(d))return new Promise(((e,r)=>{var o;null===(o=t.inflight.get(d))||void 0===o||o.push([e,r])}));t.inflight.set(d,[]);try{const r=yield e(n);return null===(o=t.inflight.get(d))||void 0===o||o.forEach((([e])=>e(r))),t.inflight.delete(d),r}catch(e){throw null===(u=t.inflight.get(d))||void 0===u||u.forEach((([,t])=>t(e))),t.inflight.delete(d),e}}))}}},99:function(e,t,r){var o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.delay=t.buildSortedURL=void 0;const n=o(r(629));t.buildSortedURL=n.default,t.delay=function(e){return new Promise((t=>{setTimeout((()=>{t("ok")}),e)}))}},976:function(e,t,r){var o=this&&this.__createBinding||(Object.create?function(e,t,r,o){void 0===o&&(o=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,o,n)}:function(e,t,r,o){void 0===o&&(o=r),e[o]=t[r]}),n=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||o(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),t.isXiorError=t.XiorTimeoutError=t.XiorError=t.joinPath=t.isAbsoluteURL=t.encodeParams=void 0,n(r(699),t),n(r(729),t),n(r(99),t),t.encodeParams=function e(t,r=!0,o=null){if(null==t)return"";const n=[],i=r?encodeURIComponent:e=>e;for(const s in t)if(Object.prototype.hasOwnProperty.call(t,s)){const u=t[s],a=o?`${o}[${i(s)}]`:i(s);if("object"==typeof u){const t=e(u,r,a);""!==t&&n.push(t)}else Array.isArray(u)?u.forEach(((e,t)=>{const r=`${a}[${t}]`;n.push(`${i(r)}=${i(e)}`)})):n.push(`${i(a)}=${i(u)}`)}return n.join("&")},t.isAbsoluteURL=function(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)},t.joinPath=function(e,t){return t?(e.endsWith("/")?e:e+"/")+(t.startsWith("/")?t.slice(1):t):e};class i extends Error{constructor(e,t,r){super(e),this.name="XiorError",this.request=t,this.config=t,this.response=r}}t.XiorError=i,t.XiorTimeoutError=class extends i{constructor(e,t,r){super(e),this.name="XiorTimeoutError",this.request=t,this.config=t,this.response=r}},t.isXiorError=function(e){return"XiorError"===e.name||"XiorTimeoutError"===e.name}},602:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.merge=void 0;const r=e=>{if("object"==typeof e&&null!==e){if("function"==typeof Object.getPrototypeOf){const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}return"[object Object]"===Object.prototype.toString.call(e)}return!1};t.merge=(...e)=>e.reduce(((e,o)=>{if(Array.isArray(o))throw new TypeError("Arguments provided to ts-deepmerge must be objects, not arrays.");return Object.keys(o).forEach((n=>{["__proto__","constructor","prototype"].includes(n)||(Array.isArray(e[n])&&Array.isArray(o[n])?e[n]=t.merge.options.mergeArrays?t.merge.options.uniqueArrayItems?Array.from(new Set(e[n].concat(o[n]))):[...e[n],...o[n]]:o[n]:r(e[n])&&r(o[n])?e[n]=(0,t.merge)(e[n],o[n]):e[n]=void 0===o[n]?t.merge.options.allowUndefinedOverrides?o[n]:e[n]:o[n])})),e}),{});const o={allowUndefinedOverrides:!0,mergeArrays:!0,uniqueArrayItems:!0};t.merge.options=o,t.merge.withOptions=(e,...r)=>{t.merge.options=Object.assign(Object.assign({},o),e);const n=(0,t.merge)(...r);return t.merge.options=o,n}}},t={},r=function r(o){var n=t[o];if(void 0!==n)return n.exports;var i=t[o]={exports:{}};return e[o].call(i.exports,i,i.exports,r),i.exports}(91);return r.default})()));

@@ -8,4 +8,2 @@ interface XiorRequestConfig<T = any> extends Omit<RequestInit, 'body'> {

timeout?: number;
/** @deprecated use paramsSerializer */
encode?: (params: Record<string, any>) => string;
paramsSerializer?: (params: Record<string, any>) => string;

@@ -20,6 +18,4 @@ /** Use encodeURIComponent, default: true */

data?: any;
_data?: any;
/** encoded url with params */
_url?: string;
/** useless now, compitable axios */
withCredentials?: boolean;

@@ -36,3 +32,2 @@ /**

url: string;
_url: string;
method: string;

@@ -39,0 +34,0 @@ };

@@ -8,4 +8,2 @@ interface XiorRequestConfig<T = any> extends Omit<RequestInit, 'body'> {

timeout?: number;
/** @deprecated use paramsSerializer */
encode?: (params: Record<string, any>) => string;
paramsSerializer?: (params: Record<string, any>) => string;

@@ -20,6 +18,4 @@ /** Use encodeURIComponent, default: true */

data?: any;
_data?: any;
/** encoded url with params */
_url?: string;
/** useless now, compitable axios */
withCredentials?: boolean;

@@ -36,3 +32,2 @@ /**

url: string;
_url: string;
method: string;

@@ -39,0 +34,0 @@ };

@@ -1,1 +0,1 @@

function e(e,t,n,r,u,i,l){try{var o=e[i](l),f=o.value}catch(e){n(e);return}o.done?t(f):Promise.resolve(f).then(r,u)}let t=new Map;function n(n={}){let{enableDedupe:r}=n;return function(n){var u;return u=function*(e){var u,i;let{_url:l,encode:o,enableDedupe:f=r,data:a}=e,c="GET"===e.method||e.isGet,s=typeof f;if(!("undefined"===s?c:"function"===s?f(e):!!f))return n(e);let d=function(e,t,n){let r=t?n(t):"";r&&(r=e+(e.includes("?")?"&"+r:"?"+r));let[u,i]=r.split("?");if(i){let e=i.split("&");return`${u}?${e.sort().join("&")}`}return r||e}(l,a,o);if(t.has(d))return new Promise((e,n)=>{var r;null==(r=t.get(d))||r.push([e,n])});t.set(d,[]);try{let r=yield n(e);return null==(u=t.get(d))||u.forEach(([e])=>e(r)),t.delete(d),r}catch(e){throw null==(i=t.get(d))||i.forEach(([,t])=>t(e)),t.delete(d),e}},function(){var t=this,n=arguments;return new Promise(function(r,i){var l=u.apply(t,n);function o(t){e(l,r,i,o,f,"next",t)}function f(t){e(l,r,i,o,f,"throw",t)}o(void 0)})}}}export{n as default,t as inflight};
import"ts-deepmerge";function e(e,t,n,r,i,u,l){try{var o=e[u](l),a=o.value}catch(e){n(e);return}o.done?t(a):Promise.resolve(a).then(r,i)}let t=new Map;function n(n={}){let{enableDedupe:r}=n;return function(n){var i;return i=function*(e){var i,u,l,o,a;let{paramsSerializer:s,enableDedupe:f=r}=e,c="GET"===e.method||e.isGet,d=typeof f;if(!("undefined"===d?c:"function"===d?f(e):!!f))return n(e);let h=function(e,t,n){let r=t?n(t):"";r&&(r=e+(e.includes("?")?"&"+r:"?"+r));let[i,u]=r.split("?");if(u){let e=u.split("&");return`${i}?${e.sort().join("&")}`}return r||e}(e.url&&(l=e.url,/^([a-z][a-z\d+\-.]*:)?\/\//i.test(l))?e.url:(o=e.baseURL||"",(a=e.url||"")?(o.endsWith("/")?o:o+"/")+(a.startsWith("/")?a.slice(1):a):o),{a:e.data,b:e.params},s);if(t.has(h))return new Promise((e,n)=>{var r;null==(r=t.get(h))||r.push([e,n])});t.set(h,[]);try{let r=yield n(e);return null==(i=t.get(h))||i.forEach(([e])=>e(r)),t.delete(h),r}catch(e){throw null==(u=t.get(h))||u.forEach(([,t])=>t(e)),t.delete(h),e}},function(){var t=this,n=arguments;return new Promise(function(r,u){var l=i.apply(t,n);function o(t){e(l,r,u,o,a,"next",t)}function a(t){e(l,r,u,o,a,"throw",t)}o(void 0)})}}}export{n as default,t as inflight};

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.xiorErrorCache=t():e.xiorErrorCache=t()}(this,(()=>(()=>{"use strict";var e={629:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,n){let o=t?n(t):"";o&&(o=e+(e.includes("?")?"&"+o:"?"+o));const[r,u]=o.split("?");return u?`${r}?${u.split("&").sort().join("&")}`:o||e}},431:function(e,t,n){var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(r,u){function i(e){try{f(o.next(e))}catch(e){u(e)}}function c(e){try{f(o.throw(e))}catch(e){u(e)}}function f(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,c)}f((o=o.apply(e,t||[])).next())}))},r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const u=r(n(629)),i={},c={get:e=>i[e],set(e,t){i[e]=t}};t.default=function(e={}){const{enableCache:t,defaultCache:n=c}=e;return function(e){return r=>o(this,void 0,void 0,(function*(){const{enableCache:o=t,defaultCache:i=n,_url:c,encode:f,data:a}=r,s="GET"===r.method||r.isGet,d=typeof o;if(!("undefined"===d?s:"function"===d?o(r):Boolean(o)))return e(r);const l=i,p=(0,u.default)(c,a,f);try{const t=yield e(r);return l.set(p,t),t}catch(e){const t=l.get(p);if(t)return t.fromCache=!0,t.error=e,t;throw e}}))}}}},t={},n=function n(o){var r=t[o];if(void 0!==r)return r.exports;var u=t[o]={exports:{}};return e[o].call(u.exports,u,u.exports,n),u.exports}(431);return n.default})()));
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.xiorErrorCache=t():e.xiorErrorCache=t()}(this,(()=>(()=>{"use strict";var e={699:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.anySignal=void 0,t.anySignal=function(e,t){const r=new globalThis.AbortController;function o(e){r.abort(e),i()}const n=[];for(const t of e){if(!0===(null==t?void 0:t.aborted)){o(t.reason);break}if(null!=(null==t?void 0:t.addEventListener)){const e=()=>{o(t.reason)};n.push((()=>{null!=(null==t?void 0:t.removeEventListener)&&t.removeEventListener("abort",e)})),t.addEventListener("abort",e)}}function i(){n.forEach((e=>{e()})),null==t||t()}const s=r.signal;return s.clear=i,s}},729:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.merge=void 0;const o=r(602);Object.defineProperty(t,"merge",{enumerable:!0,get:function(){return o.merge}})},629:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r){let o=t?r(t):"";o&&(o=e+(e.includes("?")?"&"+o:"?"+o));const[n,i]=o.split("?");return i?`${n}?${i.split("&").sort().join("&")}`:o||e}},431:function(e,t,r){var o=this&&this.__awaiter||function(e,t,r,o){return new(r||(r=Promise))((function(n,i){function s(e){try{c(o.next(e))}catch(e){i(e)}}function u(e){try{c(o.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,u)}c((o=o.apply(e,t||[])).next())}))},n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const i=n(r(629)),s=r(976),u={},c={get:e=>u[e],set(e,t){u[e]=t}};t.default=function(e={}){const{enableCache:t,defaultCache:r=c}=e;return function(e){return n=>o(this,void 0,void 0,(function*(){const{enableCache:o=t,defaultCache:u=r,paramsSerializer:c}=n,a="GET"===n.method||n.isGet,l=typeof o;if(!("undefined"===l?a:"function"===l?o(n):Boolean(o)))return e(n);const f=u,d=(0,i.default)(n.url&&(0,s.isAbsoluteURL)(n.url)?n.url:(0,s.joinPath)(n.baseURL||"",n.url||""),{a:n.data,b:n.params},c);try{const t=yield e(n);return f.set(d,t),t}catch(e){const t=f.get(d);if(t)return t.fromCache=!0,t.error=e,t;throw e}}))}}},99:function(e,t,r){var o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.delay=t.buildSortedURL=void 0;const n=o(r(629));t.buildSortedURL=n.default,t.delay=function(e){return new Promise((t=>{setTimeout((()=>{t("ok")}),e)}))}},976:function(e,t,r){var o=this&&this.__createBinding||(Object.create?function(e,t,r,o){void 0===o&&(o=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,o,n)}:function(e,t,r,o){void 0===o&&(o=r),e[o]=t[r]}),n=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||o(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),t.isXiorError=t.XiorTimeoutError=t.XiorError=t.joinPath=t.isAbsoluteURL=t.encodeParams=void 0,n(r(699),t),n(r(729),t),n(r(99),t),t.encodeParams=function e(t,r=!0,o=null){if(null==t)return"";const n=[],i=r?encodeURIComponent:e=>e;for(const s in t)if(Object.prototype.hasOwnProperty.call(t,s)){const u=t[s],c=o?`${o}[${i(s)}]`:i(s);if("object"==typeof u){const t=e(u,r,c);""!==t&&n.push(t)}else Array.isArray(u)?u.forEach(((e,t)=>{const r=`${c}[${t}]`;n.push(`${i(r)}=${i(e)}`)})):n.push(`${i(c)}=${i(u)}`)}return n.join("&")},t.isAbsoluteURL=function(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)},t.joinPath=function(e,t){return t?(e.endsWith("/")?e:e+"/")+(t.startsWith("/")?t.slice(1):t):e};class i extends Error{constructor(e,t,r){super(e),this.name="XiorError",this.request=t,this.config=t,this.response=r}}t.XiorError=i,t.XiorTimeoutError=class extends i{constructor(e,t,r){super(e),this.name="XiorTimeoutError",this.request=t,this.config=t,this.response=r}},t.isXiorError=function(e){return"XiorError"===e.name||"XiorTimeoutError"===e.name}},602:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.merge=void 0;const r=e=>{if("object"==typeof e&&null!==e){if("function"==typeof Object.getPrototypeOf){const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}return"[object Object]"===Object.prototype.toString.call(e)}return!1};t.merge=(...e)=>e.reduce(((e,o)=>{if(Array.isArray(o))throw new TypeError("Arguments provided to ts-deepmerge must be objects, not arrays.");return Object.keys(o).forEach((n=>{["__proto__","constructor","prototype"].includes(n)||(Array.isArray(e[n])&&Array.isArray(o[n])?e[n]=t.merge.options.mergeArrays?t.merge.options.uniqueArrayItems?Array.from(new Set(e[n].concat(o[n]))):[...e[n],...o[n]]:o[n]:r(e[n])&&r(o[n])?e[n]=(0,t.merge)(e[n],o[n]):e[n]=void 0===o[n]?t.merge.options.allowUndefinedOverrides?o[n]:e[n]:o[n])})),e}),{});const o={allowUndefinedOverrides:!0,mergeArrays:!0,uniqueArrayItems:!0};t.merge.options=o,t.merge.withOptions=(e,...r)=>{t.merge.options=Object.assign(Object.assign({},o),e);const n=(0,t.merge)(...r);return t.merge.options=o,n}}},t={},r=function r(o){var n=t[o];if(void 0!==n)return n.exports;var i=t[o]={exports:{}};return e[o].call(i.exports,i,i.exports,r),i.exports}(431);return r.default})()));

@@ -17,4 +17,2 @@ type ICacheLike<T> = {

timeout?: number;
/** @deprecated use paramsSerializer */
encode?: (params: Record<string, any>) => string;
paramsSerializer?: (params: Record<string, any>) => string;

@@ -29,6 +27,4 @@ /** Use encodeURIComponent, default: true */

data?: any;
_data?: any;
/** encoded url with params */
_url?: string;
/** useless now, compitable axios */
withCredentials?: boolean;

@@ -45,3 +41,2 @@ /**

url: string;
_url: string;
method: string;

@@ -48,0 +43,0 @@ };

@@ -17,4 +17,2 @@ type ICacheLike<T> = {

timeout?: number;
/** @deprecated use paramsSerializer */
encode?: (params: Record<string, any>) => string;
paramsSerializer?: (params: Record<string, any>) => string;

@@ -29,6 +27,4 @@ /** Use encodeURIComponent, default: true */

data?: any;
_data?: any;
/** encoded url with params */
_url?: string;
/** useless now, compitable axios */
withCredentials?: boolean;

@@ -45,3 +41,2 @@ /**

url: string;
_url: string;
method: string;

@@ -48,0 +43,0 @@ };

@@ -1,1 +0,1 @@

function t(t,e,n,r,i,o,u){try{var l=t[o](u),c=l.value}catch(t){n(t);return}l.done?e(c):Promise.resolve(c).then(r,i)}let e={},n={get:t=>e[t],set(t,n){e[t]=n}};function r(e={}){let{enableCache:r,defaultCache:i=n}=e;return function(e){var n;return n=function*(t){let{enableCache:n=r,defaultCache:o=i,_url:u,encode:l,data:c}=t,f="GET"===t.method||t.isGet,a=typeof n;if(!("undefined"===a?f:"function"===a?n(t):!!n))return e(t);let s=function(t,e,n){let r=e?n(e):"";r&&(r=t+(t.includes("?")?"&"+r:"?"+r));let[i,o]=r.split("?");if(o){let t=o.split("&");return`${i}?${t.sort().join("&")}`}return r||t}(u,c,l);try{let n=yield e(t);return o.set(s,n),n}catch(e){let t=o.get(s);if(t)return t.fromCache=!0,t.error=e,t;throw e}},function(){var e=this,r=arguments;return new Promise(function(i,o){var u=n.apply(e,r);function l(e){t(u,i,o,l,c,"next",e)}function c(e){t(u,i,o,l,c,"throw",e)}l(void 0)})}}}export{r as default};
import"ts-deepmerge";function t(t,e,r,n,i,u,o){try{var a=t[u](o),l=a.value}catch(t){r(t);return}a.done?e(l):Promise.resolve(l).then(n,i)}let e={},r={get:t=>e[t],set(t,r){e[t]=r}};function n(e={}){let{enableCache:n,defaultCache:i=r}=e;return function(e){var r;return r=function*(t){var r,u,o;let{enableCache:a=n,defaultCache:l=i,paramsSerializer:c}=t,s="GET"===t.method||t.isGet,f=typeof a;if(!("undefined"===f?s:"function"===f?a(t):!!a))return e(t);let d=function(t,e,r){let n=e?r(e):"";n&&(n=t+(t.includes("?")?"&"+n:"?"+n));let[i,u]=n.split("?");if(u){let t=u.split("&");return`${i}?${t.sort().join("&")}`}return n||t}(t.url&&(r=t.url,/^([a-z][a-z\d+\-.]*:)?\/\//i.test(r))?t.url:(u=t.baseURL||"",(o=t.url||"")?(u.endsWith("/")?u:u+"/")+(o.startsWith("/")?o.slice(1):o):u),{a:t.data,b:t.params},c);try{let r=yield e(t);return l.set(d,r),r}catch(e){let t=l.get(d);if(t)return t.fromCache=!0,t.error=e,t;throw e}},function(){var e=this,n=arguments;return new Promise(function(i,u){var o=r.apply(e,n);function a(e){t(o,i,u,a,l,"next",e)}function l(e){t(o,i,u,a,l,"throw",e)}a(void 0)})}}}export{n as default};

@@ -8,4 +8,2 @@ interface XiorRequestConfig<T = any> extends Omit<RequestInit, 'body'> {

timeout?: number;
/** @deprecated use paramsSerializer */
encode?: (params: Record<string, any>) => string;
paramsSerializer?: (params: Record<string, any>) => string;

@@ -20,6 +18,4 @@ /** Use encodeURIComponent, default: true */

data?: any;
_data?: any;
/** encoded url with params */
_url?: string;
/** useless now, compitable axios */
withCredentials?: boolean;

@@ -36,3 +32,2 @@ /**

url: string;
_url: string;
method: string;

@@ -39,0 +34,0 @@ };

@@ -8,4 +8,2 @@ interface XiorRequestConfig<T = any> extends Omit<RequestInit, 'body'> {

timeout?: number;
/** @deprecated use paramsSerializer */
encode?: (params: Record<string, any>) => string;
paramsSerializer?: (params: Record<string, any>) => string;

@@ -20,6 +18,4 @@ /** Use encodeURIComponent, default: true */

data?: any;
_data?: any;
/** encoded url with params */
_url?: string;
/** useless now, compitable axios */
withCredentials?: boolean;

@@ -36,3 +32,2 @@ /**

url: string;
_url: string;
method: string;

@@ -39,0 +34,0 @@ };

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.xiorMock=t():e.xiorMock=t()}(this,(()=>(()=>{"use strict";var e={699:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.anySignal=void 0,t.anySignal=function(e,t){const r=new globalThis.AbortController;function n(e){r.abort(e),i()}const o=[];for(const t of e){if(!0===(null==t?void 0:t.aborted)){n(t.reason);break}if(null!=(null==t?void 0:t.addEventListener)){const e=()=>{n(t.reason)};o.push((()=>{null!=(null==t?void 0:t.removeEventListener)&&t.removeEventListener("abort",e)})),t.addEventListener("abort",e)}}function i(){o.forEach((e=>{e()})),null==t||t()}const s=r.signal;return s.clear=i,s}},729:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.merge=void 0;const n=r(602);Object.defineProperty(t,"merge",{enumerable:!0,get:function(){return n.merge}})},629:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r){let n=t?r(t):"";n&&(n=e+(e.includes("?")?"&"+n:"?"+n));const[o,i]=n.split("?");return i?`${o}?${i.split("&").sort().join("&")}`:n||e}},437:function(e,t,r){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{d(n.next(e))}catch(e){i(e)}}function a(e){try{d(n.throw(e))}catch(e){i(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}d((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.MockError=void 0;const o=r(732),i=r(976),s="undefined"!=typeof AbortController;class a extends Error{constructor(e,t){super(e),this.request=t,this.config=t}}function d(e){const t=e.filter((e=>{const[,t]=e;return"function"==typeof(null==t?void 0:t.asymmetricMatch)})),r=t.filter((e=>{const[t,r]=e;return r.asymmetricMatch(t)}));return r.length>0&&r.length===t.length}function u(e){e||(e={});const t={},r="undefined"==typeof Headers?{append(e,r){t[e]=r+""},get:e=>t[e]||null}:new Headers;return Object.keys(e).forEach((t=>{r.append(t,e[t])})),r}function l(e,t){if(e.status>=300)throw new i.XiorError(`Request failed with status code ${e.status}`,t,e);return e}t.MockError=a,t.default=class{constructor(e,t){this.handlers={},this.history={},this.options=t,this.instance=e,this.plugin=this._mockPlugin.bind(this),e.plugins.use(this.plugin)}_mockPlugin(e){return t=>n(this,void 0,void 0,(function*(){var r,n,o,d,c;const h=(null===(r=t.method)||void 0===r?void 0:r.toLowerCase())||"get";this.history[h]||(this.history[h]=[]),this.handlers[h]||(this.handlers[h]=[]),null===(n=this.history[h])||void 0===n||n.push(t);const f=this.findHandler(t);if(f){const r=f[6]||(null===(o=this.options)||void 0===o?void 0:o.delayResponse);6===f.length&&Object.keys(this.handlers).forEach((e=>{var t,r;let n=null===(t=this.handlers[e])||void 0===t?void 0:t.indexOf(f);n=void 0===n?-1:n,n>-1&&(null===(r=this.handlers[e])||void 0===r||r.splice(n,1))}));const n=[];let a;if(2!==f.length){let e,r;if(t.timeout&&s){const e=new AbortController;r=setTimeout((()=>{e.abort(new i.XiorTimeoutError(`timeout of ${t.timeout}ms exceeded`,t))}),t.timeout),n.push(e.signal)}t.signal&&n.push(t.signal),e=n[0],n.length>1&&(e=(0,i.anySignal)(n,(()=>{r&&clearTimeout(r)}))),a=()=>{var t;r&&clearTimeout(r),null===(t=null==e?void 0:e.clear)||void 0===t||t.call(e)}}r&&r>0&&(yield(0,i.delay)(r));const d=n.find((e=>e.aborted));if(d)return null==a||a(),Promise.reject(d.reason);if(2===f.length)return e(t);if("function"!=typeof f[2]){const e=f.slice(2),r=l({data:e[1],status:e[0],statusText:"ok",headers:e[2],request:t,config:t},t);return null==a||a(),r}const c=f[2](t);if("function"!=typeof(null==c?void 0:c.then)){const e=l({data:c[1],status:c[0],statusText:"ok",headers:u(c[2]),request:t,config:t},t);return null==a||a(),e}{const e=yield c;return null==a||a(),e.config&&e.status?e:l({data:e[1],status:e[0],statusText:"ok",headers:u(e[2]),request:t,config:t},t)}}if("passthrough"===(null===(d=this.options)||void 0===d?void 0:d.onNoMatch))return e(t);if("throwException"===(null===(c=this.options)||void 0===c?void 0:c.onNoMatch)){const e="Could not find mock for: \n"+JSON.stringify(t,["method","url"],2);throw new a(e,t)}{const e="Request failed with status code 404";throw new i.XiorError(e,t,{status:404,statusText:e,config:t})}}))}resetHandlers(){this.handlers={}}resetHistory(){this.history={}}reset(){this.resetHandlers(),this.resetHistory()}restore(){var e;this.reset(),null===(e=this.instance)||void 0===e||e.plugins.eject(this.plugin)}onGet(e,t){return this.createHandler("get").bind(this)(e,t)}onDelete(e,t){return this.createHandler("delete").bind(this)(e,t)}onHead(e,t){return this.createHandler("head").bind(this)(e,t)}onAny(e,t){return this.createHandler("any").bind(this)(e,t)}onPost(e,t,r){return this.createHandler("post").bind(this)(e,(0,i.merge)({},r||{},{data:t||{}}))}onPut(e,t,r){return this.createHandler("put").bind(this)(e,(0,i.merge)({},r||{},{data:t||{}}))}onPatch(e,t,r){return this.createHandler("patch").bind(this)(e,(0,i.merge)({},r||{},{data:t||{}}))}onOptions(e,t){return this.createHandler("options").bind(this)(e,t)}createHandler(e){return(t,r)=>{var n,o,s,a,d,u;r=r?(0,i.merge)({},{headers:null===(o=null===(n=this.instance)||void 0===n?void 0:n.config)||void 0===o?void 0:o.headers,params:null===(a=null===(s=this.instance)||void 0===s?void 0:s.config)||void 0===a?void 0:a.params,data:null===(u=null===(d=this.instance)||void 0===d?void 0:d.config)||void 0===u?void 0:u.data},r||{}):{},t=void 0===t?/.*/:t;const l=(n,o,i)=>{const s=[t,r,n,o,i];return this.addHandler(e,s),this},c=(n,o,i)=>{const s=[t,r,n,o,i,!0];return this.addHandler(e,s),this},h=(n,o,i,s)=>{const a=[t,r,o,i,s,!1,n];return this.addHandler(e,a),this};return{reply:l,replyOnce:c,withDelayInMs:function(e){return function(t,r,n){return h(e,t,r,n)}},passThrough:()=>{const n=[t,r];return this.addHandler(e,n),this},abortRequest:()=>l((e=>Promise.reject(new i.XiorError("Request aborted",e)))),abortRequestOnce:()=>c((e=>Promise.reject(new i.XiorError("Request aborted",e,{})))),networkError:()=>l((e=>Promise.reject(new i.XiorError("Network Error",e,{})))),networkErrorOnce:()=>c((e=>Promise.reject(new i.XiorError("Network Error",e,{})))),timeout:()=>l((e=>Promise.reject(new i.XiorTimeoutError("timeout of 0ms exceeded",e)))),timeoutOnce:()=>c((e=>Promise.reject(new i.XiorTimeoutError("timeout of 0ms exceeded",e))))}}}addHandler(e,t){var r,n,s;const a=[...t];if(a[3])try{a[3]=JSON.parse(JSON.stringify(a[3]))}catch(e){}if(a[4]){const e="undefined"==typeof Headers?(()=>{const e={};return{append(t,r){e[t]=r+""},get:t=>e[t]||null}})():new Headers;Object.keys(a[4]).forEach((t=>{e.append(t,a[4][t])})),a[4]=e}if("any"===e)o.VERBS.forEach((e=>{var t;this.handlers[e]||(this.handlers[e]=[]),null===(t=this.handlers[e])||void 0===t||t.push(a)}));else{this.handlers[e]||(this.handlers[e]=[]);let t=null===(r=this.handlers[e])||void 0===r?void 0:r.findIndex((e=>6!==e.length&&(0,i.buildSortedURL)(String(e[0]),e[1],i.encodeParams)===(0,i.buildSortedURL)(String(a[0]),a[1],i.encodeParams)));t=void 0===t?-1:t,t>-1&&a.length<6?null===(n=this.handlers[e])||void 0===n||n.splice(t,1,a):null===(s=this.handlers[e])||void 0===s||s.push(a)}}findHandler(e){var t;const{method:r,url:n,_url:o,headers:s,params:a,data:u={},baseURL:l}=e,c=null==r?void 0:r.toLowerCase();return null===(t=this.handlers[c])||void 0===t?void 0:t.find((t=>{var r;const h=Object.assign({},t[1].headers||{});if((null===(r=e.headers)||void 0===r?void 0:r["Content-Type"])&&(Object.keys(h).find((e=>"content-type"===e.toLowerCase()))||(h["Content-Type"]=e.headers["Content-Type"])),"string"==typeof t[0]){const e=l&&t[0].startsWith(l),r=(0,i.buildSortedURL)(e?(0,i.joinPath)(l,n):(0,i.joinPath)("/",n),{b:a,c:u,a:s},i.encodeParams),o=(0,i.buildSortedURL)(e?t[0]:(0,i.joinPath)("/",t[0]),{b:t[1].params||{},c:t[1].data||{},a:h},i.encodeParams);return r===o||r.startsWith(o)||d([[a,t[1].params],[u,t[1].data],[s,h]])}if(t[0]instanceof RegExp)return(t[0].test(n)||t[0].test((0,i.joinPath)(l||"",n))||t[0].test(o))&&((0,i.buildSortedURL)(c,{b:a,c:u,a:s},i.encodeParams)===(0,i.buildSortedURL)(c,{b:t[1].params||{},c:t[1].data||{},a:h},i.encodeParams)||d([[a,t[1].params],[u,t[1].data],[s,h]]))}))}}},732:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.VERBS=void 0,t.VERBS=["get","post","head","delete","patch","put","options"]},99:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.delay=t.buildSortedURL=void 0;const o=n(r(629));t.buildSortedURL=o.default,t.delay=function(e){return new Promise((t=>{setTimeout((()=>{t("ok")}),e)}))}},976:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),t.isXiorError=t.XiorTimeoutError=t.XiorError=t.joinPath=t.isAbsoluteURL=t.encodeParams=void 0,o(r(699),t),o(r(729),t),o(r(99),t),t.encodeParams=function e(t,r=!0,n=null){if(null==t)return"";const o=[],i=r?encodeURIComponent:e=>e;for(const s in t)if(Object.prototype.hasOwnProperty.call(t,s)){const a=t[s],d=n?`${n}[${i(s)}]`:i(s);if("object"==typeof a){const t=e(a,r,d);""!==t&&o.push(t)}else Array.isArray(a)?a.forEach(((e,t)=>{const r=`${d}[${t}]`;o.push(`${i(r)}=${i(e)}`)})):o.push(`${i(d)}=${i(a)}`)}return o.join("&")},t.isAbsoluteURL=function(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)},t.joinPath=function(e,t){return t?(e.endsWith("/")?e:e+"/")+(t.startsWith("/")?t.slice(1):t):e};class i extends Error{constructor(e,t,r){super(e),this.name="XiorError",this.request=t,this.config=t,this.response=r}}t.XiorError=i,t.XiorTimeoutError=class extends i{constructor(e,t,r){super(e),this.name="XiorTimeoutError",this.request=t,this.config=t,this.response=r}},t.isXiorError=function(e){return"XiorError"===e.name||"XiorTimeoutError"===e.name}},602:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.merge=void 0;const r=e=>{if("object"==typeof e&&null!==e){if("function"==typeof Object.getPrototypeOf){const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}return"[object Object]"===Object.prototype.toString.call(e)}return!1};t.merge=(...e)=>e.reduce(((e,n)=>{if(Array.isArray(n))throw new TypeError("Arguments provided to ts-deepmerge must be objects, not arrays.");return Object.keys(n).forEach((o=>{["__proto__","constructor","prototype"].includes(o)||(Array.isArray(e[o])&&Array.isArray(n[o])?e[o]=t.merge.options.mergeArrays?t.merge.options.uniqueArrayItems?Array.from(new Set(e[o].concat(n[o]))):[...e[o],...n[o]]:n[o]:r(e[o])&&r(n[o])?e[o]=(0,t.merge)(e[o],n[o]):e[o]=void 0===n[o]?t.merge.options.allowUndefinedOverrides?n[o]:e[o]:n[o])})),e}),{});const n={allowUndefinedOverrides:!0,mergeArrays:!0,uniqueArrayItems:!0};t.merge.options=n,t.merge.withOptions=(e,...r)=>{t.merge.options=Object.assign(Object.assign({},n),e);const o=(0,t.merge)(...r);return t.merge.options=n,o}}},t={},r=function r(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={exports:{}};return e[n].call(i.exports,i,i.exports,r),i.exports}(437);return r.default})()));
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.xiorMock=t():e.xiorMock=t()}(this,(()=>(()=>{"use strict";var e={699:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.anySignal=void 0,t.anySignal=function(e,t){const r=new globalThis.AbortController;function n(e){r.abort(e),i()}const o=[];for(const t of e){if(!0===(null==t?void 0:t.aborted)){n(t.reason);break}if(null!=(null==t?void 0:t.addEventListener)){const e=()=>{n(t.reason)};o.push((()=>{null!=(null==t?void 0:t.removeEventListener)&&t.removeEventListener("abort",e)})),t.addEventListener("abort",e)}}function i(){o.forEach((e=>{e()})),null==t||t()}const s=r.signal;return s.clear=i,s}},729:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.merge=void 0;const n=r(602);Object.defineProperty(t,"merge",{enumerable:!0,get:function(){return n.merge}})},629:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r){let n=t?r(t):"";n&&(n=e+(e.includes("?")?"&"+n:"?"+n));const[o,i]=n.split("?");return i?`${o}?${i.split("&").sort().join("&")}`:n||e}},437:function(e,t,r){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{d(n.next(e))}catch(e){i(e)}}function a(e){try{d(n.throw(e))}catch(e){i(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}d((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.MockError=void 0;const o=r(732),i=r(976),s="undefined"!=typeof AbortController;class a extends Error{constructor(e,t){super(e),this.request=t,this.config=t}}function d(e){const t=e.filter((e=>{const[,t]=e;return"function"==typeof(null==t?void 0:t.asymmetricMatch)})),r=t.filter((e=>{const[t,r]=e;return r.asymmetricMatch(t)}));return r.length>0&&r.length===t.length}function u(e){e||(e={});const t={},r="undefined"==typeof Headers?{append(e,r){t[e]=r+""},get:e=>t[e]||null}:new Headers;return Object.keys(e).forEach((t=>{r.append(t,e[t])})),r}function l(e,t){if(e.status>=300)throw new i.XiorError(`Request failed with status code ${e.status}`,t,e);return e}t.MockError=a,t.default=class{constructor(e,t){this.handlers={},this.history={},this.options=t,this.instance=e,this.plugin=this._mockPlugin.bind(this),e.plugins.use(this.plugin)}_mockPlugin(e){return t=>n(this,void 0,void 0,(function*(){var r,n,o,d,c;const h=(null===(r=t.method)||void 0===r?void 0:r.toLowerCase())||"get";this.history[h]||(this.history[h]=[]),this.handlers[h]||(this.handlers[h]=[]),null===(n=this.history[h])||void 0===n||n.push(t);const f=this.findHandler(t);if(f){const r=f[6]||(null===(o=this.options)||void 0===o?void 0:o.delayResponse);6===f.length&&Object.keys(this.handlers).forEach((e=>{var t,r;let n=null===(t=this.handlers[e])||void 0===t?void 0:t.indexOf(f);n=void 0===n?-1:n,n>-1&&(null===(r=this.handlers[e])||void 0===r||r.splice(n,1))}));const n=[];let a;if(2!==f.length){let e,r;if(t.timeout&&s){const e=new AbortController;r=setTimeout((()=>{e.abort(new i.XiorTimeoutError(`timeout of ${t.timeout}ms exceeded`,t))}),t.timeout),n.push(e.signal)}t.signal&&n.push(t.signal),e=n[0],n.length>1&&(e=(0,i.anySignal)(n,(()=>{r&&clearTimeout(r)}))),a=()=>{var t;r&&clearTimeout(r),null===(t=null==e?void 0:e.clear)||void 0===t||t.call(e)}}r&&r>0&&(yield(0,i.delay)(r));const d=n.find((e=>e.aborted));if(d)return null==a||a(),Promise.reject(d.reason);if(2===f.length)return e(t);if("function"!=typeof f[2]){const e=f.slice(2),r=l({data:e[1],status:e[0],statusText:"ok",headers:e[2],request:t,config:t},t);return null==a||a(),r}const c=f[2](t);if("function"!=typeof(null==c?void 0:c.then)){const e=l({data:c[1],status:c[0],statusText:"ok",headers:u(c[2]),request:t,config:t},t);return null==a||a(),e}{const e=yield c;return null==a||a(),e.config&&e.status?e:l({data:e[1],status:e[0],statusText:"ok",headers:u(e[2]),request:t,config:t},t)}}if("passthrough"===(null===(d=this.options)||void 0===d?void 0:d.onNoMatch))return e(t);if("throwException"===(null===(c=this.options)||void 0===c?void 0:c.onNoMatch)){const e="Could not find mock for: \n"+JSON.stringify(t,["method","url"],2);throw new a(e,t)}{const e="Request failed with status code 404";throw new i.XiorError(e,t,{status:404,statusText:e,config:t})}}))}resetHandlers(){this.handlers={}}resetHistory(){this.history={}}reset(){this.resetHandlers(),this.resetHistory()}restore(){var e;this.reset(),null===(e=this.instance)||void 0===e||e.plugins.eject(this.plugin)}onGet(e,t){return this.createHandler("get").bind(this)(e,t)}onDelete(e,t){return this.createHandler("delete").bind(this)(e,t)}onHead(e,t){return this.createHandler("head").bind(this)(e,t)}onAny(e,t){return this.createHandler("any").bind(this)(e,t)}onPost(e,t,r){return this.createHandler("post").bind(this)(e,(0,i.merge)({},r||{},{data:t||{}}))}onPut(e,t,r){return this.createHandler("put").bind(this)(e,(0,i.merge)({},r||{},{data:t||{}}))}onPatch(e,t,r){return this.createHandler("patch").bind(this)(e,(0,i.merge)({},r||{},{data:t||{}}))}onOptions(e,t){return this.createHandler("options").bind(this)(e,t)}createHandler(e){return(t,r)=>{var n,o,s,a,d,u;r=r?(0,i.merge)({},{headers:null===(o=null===(n=this.instance)||void 0===n?void 0:n.config)||void 0===o?void 0:o.headers,params:null===(a=null===(s=this.instance)||void 0===s?void 0:s.config)||void 0===a?void 0:a.params,data:null===(u=null===(d=this.instance)||void 0===d?void 0:d.config)||void 0===u?void 0:u.data},r||{}):{},t=void 0===t?/.*/:t;const l=(n,o,i)=>{const s=[t,r,n,o,i];return this.addHandler(e,s),this},c=(n,o,i)=>{const s=[t,r,n,o,i,!0];return this.addHandler(e,s),this},h=(n,o,i,s)=>{const a=[t,r,o,i,s,!1,n];return this.addHandler(e,a),this};return{reply:l,replyOnce:c,withDelayInMs:function(e){return function(t,r,n){return h(e,t,r,n)}},passThrough:()=>{const n=[t,r];return this.addHandler(e,n),this},abortRequest:()=>l((e=>Promise.reject(new i.XiorError("Request aborted",e)))),abortRequestOnce:()=>c((e=>Promise.reject(new i.XiorError("Request aborted",e,{})))),networkError:()=>l((e=>Promise.reject(new i.XiorError("Network Error",e,{})))),networkErrorOnce:()=>c((e=>Promise.reject(new i.XiorError("Network Error",e,{})))),timeout:()=>l((e=>Promise.reject(new i.XiorTimeoutError("timeout of 0ms exceeded",e)))),timeoutOnce:()=>c((e=>Promise.reject(new i.XiorTimeoutError("timeout of 0ms exceeded",e))))}}}addHandler(e,t){var r,n,s;const a=[...t];if(a[3])try{a[3]=JSON.parse(JSON.stringify(a[3]))}catch(e){}if(a[4]){const e="undefined"==typeof Headers?(()=>{const e={};return{append(t,r){e[t]=r+""},get:t=>e[t]||null}})():new Headers;Object.keys(a[4]).forEach((t=>{e.append(t,a[4][t])})),a[4]=e}if("any"===e)o.VERBS.forEach((e=>{var t;this.handlers[e]||(this.handlers[e]=[]),null===(t=this.handlers[e])||void 0===t||t.push(a)}));else{this.handlers[e]||(this.handlers[e]=[]);let t=null===(r=this.handlers[e])||void 0===r?void 0:r.findIndex((e=>6!==e.length&&(0,i.buildSortedURL)(String(e[0]),e[1],i.encodeParams)===(0,i.buildSortedURL)(String(a[0]),a[1],i.encodeParams)));t=void 0===t?-1:t,t>-1&&a.length<6?null===(n=this.handlers[e])||void 0===n||n.splice(t,1,a):null===(s=this.handlers[e])||void 0===s||s.push(a)}}findHandler(e){var t;const{method:r,url:n,headers:o,params:s,data:a={},baseURL:u}=e,l=null==r?void 0:r.toLowerCase();return null===(t=this.handlers[l])||void 0===t?void 0:t.find((t=>{var r;const c=Object.assign({},t[1].headers||{});if((null===(r=e.headers)||void 0===r?void 0:r["Content-Type"])&&(Object.keys(c).find((e=>"content-type"===e.toLowerCase()))||(c["Content-Type"]=e.headers["Content-Type"])),"string"==typeof t[0]){const e=u&&t[0].startsWith(u),r=(0,i.buildSortedURL)(e?(0,i.joinPath)(u,n):(0,i.joinPath)("/",n),{b:s,c:a,a:o},i.encodeParams),l=(0,i.buildSortedURL)(e?t[0]:(0,i.joinPath)("/",t[0]),{b:t[1].params||{},c:t[1].data||{},a:c},i.encodeParams);return r===l||r.startsWith(l)||d([[s,t[1].params],[a,t[1].data],[o,c]])}if(t[0]instanceof RegExp)return(t[0].test(n)||t[0].test((0,i.joinPath)(u||"",n)))&&((0,i.buildSortedURL)(l,{b:s,c:a,a:o},i.encodeParams)===(0,i.buildSortedURL)(l,{b:t[1].params||{},c:t[1].data||{},a:c},i.encodeParams)||d([[s,t[1].params],[a,t[1].data],[o,c]]))}))}}},732:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.VERBS=void 0,t.VERBS=["get","post","head","delete","patch","put","options"]},99:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.delay=t.buildSortedURL=void 0;const o=n(r(629));t.buildSortedURL=o.default,t.delay=function(e){return new Promise((t=>{setTimeout((()=>{t("ok")}),e)}))}},976:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),t.isXiorError=t.XiorTimeoutError=t.XiorError=t.joinPath=t.isAbsoluteURL=t.encodeParams=void 0,o(r(699),t),o(r(729),t),o(r(99),t),t.encodeParams=function e(t,r=!0,n=null){if(null==t)return"";const o=[],i=r?encodeURIComponent:e=>e;for(const s in t)if(Object.prototype.hasOwnProperty.call(t,s)){const a=t[s],d=n?`${n}[${i(s)}]`:i(s);if("object"==typeof a){const t=e(a,r,d);""!==t&&o.push(t)}else Array.isArray(a)?a.forEach(((e,t)=>{const r=`${d}[${t}]`;o.push(`${i(r)}=${i(e)}`)})):o.push(`${i(d)}=${i(a)}`)}return o.join("&")},t.isAbsoluteURL=function(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)},t.joinPath=function(e,t){return t?(e.endsWith("/")?e:e+"/")+(t.startsWith("/")?t.slice(1):t):e};class i extends Error{constructor(e,t,r){super(e),this.name="XiorError",this.request=t,this.config=t,this.response=r}}t.XiorError=i,t.XiorTimeoutError=class extends i{constructor(e,t,r){super(e),this.name="XiorTimeoutError",this.request=t,this.config=t,this.response=r}},t.isXiorError=function(e){return"XiorError"===e.name||"XiorTimeoutError"===e.name}},602:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.merge=void 0;const r=e=>{if("object"==typeof e&&null!==e){if("function"==typeof Object.getPrototypeOf){const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}return"[object Object]"===Object.prototype.toString.call(e)}return!1};t.merge=(...e)=>e.reduce(((e,n)=>{if(Array.isArray(n))throw new TypeError("Arguments provided to ts-deepmerge must be objects, not arrays.");return Object.keys(n).forEach((o=>{["__proto__","constructor","prototype"].includes(o)||(Array.isArray(e[o])&&Array.isArray(n[o])?e[o]=t.merge.options.mergeArrays?t.merge.options.uniqueArrayItems?Array.from(new Set(e[o].concat(n[o]))):[...e[o],...n[o]]:n[o]:r(e[o])&&r(n[o])?e[o]=(0,t.merge)(e[o],n[o]):e[o]=void 0===n[o]?t.merge.options.allowUndefinedOverrides?n[o]:e[o]:n[o])})),e}),{});const n={allowUndefinedOverrides:!0,mergeArrays:!0,uniqueArrayItems:!0};t.merge.options=n,t.merge.withOptions=(e,...r)=>{t.merge.options=Object.assign(Object.assign({},n),e);const o=(0,t.merge)(...r);return t.merge.options=n,o}}},t={},r=function r(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={exports:{}};return e[n].call(i.exports,i,i.exports,r),i.exports}(437);return r.default})()));

@@ -8,4 +8,2 @@ interface XiorRequestConfig<T = any> extends Omit<RequestInit, 'body'> {

timeout?: number;
/** @deprecated use paramsSerializer */
encode?: (params: Record<string, any>) => string;
paramsSerializer?: (params: Record<string, any>) => string;

@@ -20,6 +18,4 @@ /** Use encodeURIComponent, default: true */

data?: any;
_data?: any;
/** encoded url with params */
_url?: string;
/** useless now, compitable axios */
withCredentials?: boolean;

@@ -36,3 +32,2 @@ /**

url: string;
_url: string;
method: string;

@@ -83,2 +78,3 @@ };

data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;

@@ -88,2 +84,3 @@ response: Response;

data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;

@@ -93,2 +90,3 @@ response: Response;

data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;

@@ -108,2 +106,3 @@ response: Response;

data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;

@@ -113,2 +112,3 @@ response: Response;

data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;

@@ -118,2 +118,3 @@ response: Response;

data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;

@@ -123,2 +124,3 @@ response: Response;

data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;

@@ -128,2 +130,3 @@ response: Response;

data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;

@@ -133,2 +136,3 @@ response: Response;

data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;

@@ -139,2 +143,3 @@ response: Response;

data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;

@@ -144,2 +149,3 @@ response: Response;

data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;

@@ -149,2 +155,3 @@ response: Response;

data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;

@@ -156,3 +163,4 @@ response: Response;

};
_plugins: XiorPlugin[];
/** plugins */
P: XiorPlugin[];
get plugins(): {

@@ -167,4 +175,10 @@ use: (plugin: XiorPlugin) => XiorPlugin;

createPost<T>(method: string): (url: string, data?: any, options?: XiorRequestConfig) => Promise<XiorResponse<T>>;
get<T = any>(url: string, options?: XiorRequestConfig): Promise<XiorResponse<T>>;
head<T = any>(url: string, options?: XiorRequestConfig): Promise<XiorResponse<T>>;
get<T = any>(url: string, options?: XiorRequestConfig & {
/** @deprecated No `data` in `GET` method */
data?: any;
}): Promise<XiorResponse<T>>;
head<T = any>(url: string, options?: XiorRequestConfig & {
/** @deprecated No `data` in `HEAD` method */
data?: any;
}): Promise<XiorResponse<T>>;
post<T = any>(url: string, data?: any, options?: XiorRequestConfig): Promise<XiorResponse<T>>;

@@ -174,3 +188,6 @@ put<T = any>(url: string, data?: any, options?: XiorRequestConfig): Promise<XiorResponse<T>>;

delete<T = any>(url: string, options?: XiorRequestConfig): Promise<XiorResponse<T>>;
options<T = any>(url: string, options?: XiorRequestConfig): Promise<XiorResponse<T>>;
options<T = any>(url: string, options?: XiorRequestConfig & {
/** @deprecated No `data` in `OPTIONS` method */
data?: any;
}): Promise<XiorResponse<T>>;
}

@@ -177,0 +194,0 @@

@@ -8,4 +8,2 @@ interface XiorRequestConfig<T = any> extends Omit<RequestInit, 'body'> {

timeout?: number;
/** @deprecated use paramsSerializer */
encode?: (params: Record<string, any>) => string;
paramsSerializer?: (params: Record<string, any>) => string;

@@ -20,6 +18,4 @@ /** Use encodeURIComponent, default: true */

data?: any;
_data?: any;
/** encoded url with params */
_url?: string;
/** useless now, compitable axios */
withCredentials?: boolean;

@@ -36,3 +32,2 @@ /**

url: string;
_url: string;
method: string;

@@ -83,2 +78,3 @@ };

data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;

@@ -88,2 +84,3 @@ response: Response;

data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;

@@ -93,2 +90,3 @@ response: Response;

data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;

@@ -108,2 +106,3 @@ response: Response;

data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;

@@ -113,2 +112,3 @@ response: Response;

data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;

@@ -118,2 +118,3 @@ response: Response;

data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;

@@ -123,2 +124,3 @@ response: Response;

data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;

@@ -128,2 +130,3 @@ response: Response;

data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;

@@ -133,2 +136,3 @@ response: Response;

data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;

@@ -139,2 +143,3 @@ response: Response;

data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;

@@ -144,2 +149,3 @@ response: Response;

data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;

@@ -149,2 +155,3 @@ response: Response;

data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;

@@ -156,3 +163,4 @@ response: Response;

};
_plugins: XiorPlugin[];
/** plugins */
P: XiorPlugin[];
get plugins(): {

@@ -167,4 +175,10 @@ use: (plugin: XiorPlugin) => XiorPlugin;

createPost<T>(method: string): (url: string, data?: any, options?: XiorRequestConfig) => Promise<XiorResponse<T>>;
get<T = any>(url: string, options?: XiorRequestConfig): Promise<XiorResponse<T>>;
head<T = any>(url: string, options?: XiorRequestConfig): Promise<XiorResponse<T>>;
get<T = any>(url: string, options?: XiorRequestConfig & {
/** @deprecated No `data` in `GET` method */
data?: any;
}): Promise<XiorResponse<T>>;
head<T = any>(url: string, options?: XiorRequestConfig & {
/** @deprecated No `data` in `HEAD` method */
data?: any;
}): Promise<XiorResponse<T>>;
post<T = any>(url: string, data?: any, options?: XiorRequestConfig): Promise<XiorResponse<T>>;

@@ -174,3 +188,6 @@ put<T = any>(url: string, data?: any, options?: XiorRequestConfig): Promise<XiorResponse<T>>;

delete<T = any>(url: string, options?: XiorRequestConfig): Promise<XiorResponse<T>>;
options<T = any>(url: string, options?: XiorRequestConfig): Promise<XiorResponse<T>>;
options<T = any>(url: string, options?: XiorRequestConfig & {
/** @deprecated No `data` in `OPTIONS` method */
data?: any;
}): Promise<XiorResponse<T>>;
}

@@ -177,0 +194,0 @@

@@ -1,1 +0,1 @@

import{merge as e}from"ts-deepmerge";let t=["get","post","head","delete","patch","put","options"];function r(e,t,r){let n=t?r(t):"";n&&(n=e+(e.includes("?")?"&"+n:"?"+n));let[s,i]=n.split("?");if(i){let e=i.split("&");return`${s}?${e.sort().join("&")}`}return n||e}function n(e,t=!0,r=null){if(null==e)return"";let s=[],i=t?encodeURIComponent:e=>e;for(let o in e)if(Object.prototype.hasOwnProperty.call(e,o)){let l=e[o],a=r?`${r}[${i(o)}]`:i(o);if("object"==typeof l){let e=n(l,t,a);""!==e&&s.push(e)}else Array.isArray(l)?l.forEach((e,t)=>{let r=`${a}[${t}]`;s.push(`${i(r)}=${i(e)}`)}):s.push(`${i(a)}=${i(l)}`)}return s.join("&")}function s(e,t){return t?(e.endsWith("/")?e:e+"/")+(t.startsWith("/")?t.slice(1):t):e}class i extends Error{constructor(e,t,r){super(e),this.name="XiorError",this.request=t,this.config=t,this.response=r}}class o extends i{constructor(e,t,r){super(e),this.name="XiorTimeoutError",this.request=t,this.config=t,this.response=r}}function l(e,t,r,n,s,i,o){try{var l=e[i](o),a=l.value}catch(e){r(e);return}l.done?t(a):Promise.resolve(a).then(n,s)}function a(){return(a=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}let u="undefined"!=typeof AbortController;class d extends Error{constructor(e,t){super(e),this.request=t,this.config=t}}class h{_mockPlugin(e){var t,r=this;return t=function*(t){var n,s,l,a,h;let c=(null==(n=t.method)?void 0:n.toLowerCase())||"get";r.history[c]||(r.history[c]=[]),r.handlers[c]||(r.handlers[c]=[]),null==(s=r.history[c])||s.push(t);let m=r.findHandler(t);if(m){let n;let s=m[6]||(null==(l=r.options)?void 0:l.delayResponse);6===m.length&&Object.keys(r.handlers).forEach(e=>{var t,n;let s=null==(t=r.handlers[e])?void 0:t.indexOf(m);(s=void 0===s?-1:s)>-1&&(null==(n=r.handlers[e])||n.splice(s,1))});let i=[];if(2!==m.length){let e,r;if(t.timeout&&u){let e=new AbortController;r=setTimeout(()=>{e.abort(new o(`timeout of ${t.timeout}ms exceeded`,t))},t.timeout),i.push(e.signal)}t.signal&&i.push(t.signal),e=i[0],i.length>1&&(e=function(e,t){let r=new globalThis.AbortController;function n(e){r.abort(e),i()}let s=[];for(let t of e){if((null==t?void 0:t.aborted)===!0){n(t.reason);break}if((null==t?void 0:t.addEventListener)!=null){let e=()=>{n(t.reason)};s.push(()=>{(null==t?void 0:t.removeEventListener)!=null&&t.removeEventListener("abort",e)}),t.addEventListener("abort",e)}}function i(){s.forEach(e=>{e()}),null==t||t()}let o=r.signal;return o.clear=i,o}(i,()=>{r&&clearTimeout(r)})),n=()=>{var t;r&&clearTimeout(r),null==e||null==(t=e.clear)||t.call(e)}}s&&s>0&&(yield new Promise(e=>{setTimeout(()=>{e("ok")},s)}));let a=i.find(e=>e.aborted);if(a)return null==n||n(),Promise.reject(a.reason);if(2===m.length)return e(t);if("function"!=typeof m[2]){let e=m.slice(2),r=p({data:e[1],status:e[0],statusText:"ok",headers:e[2],request:t,config:t},t);return null==n||n(),r}let d=m[2](t);if("function"!=typeof(null==d?void 0:d.then)){let e=p({data:d[1],status:d[0],statusText:"ok",headers:f(d[2]),request:t,config:t},t);return null==n||n(),e}{let e=yield d;return(null==n||n(),e.config&&e.status)?e:p({data:e[1],status:e[0],statusText:"ok",headers:f(e[2]),request:t,config:t},t)}}if((null==(a=r.options)?void 0:a.onNoMatch)==="passthrough")return e(t);if((null==(h=r.options)?void 0:h.onNoMatch)==="throwException")throw new d("Could not find mock for: \n"+JSON.stringify(t,["method","url"],2),t);{let e="Request failed with status code 404";throw new i(e,t,{status:404,statusText:e,config:t})}},function(){var e=this,r=arguments;return new Promise(function(n,s){var i=t.apply(e,r);function o(e){l(i,n,s,o,a,"next",e)}function a(e){l(i,n,s,o,a,"throw",e)}o(void 0)})}}resetHandlers(){this.handlers={}}resetHistory(){this.history={}}reset(){this.resetHandlers(),this.resetHistory()}restore(){var e;this.reset(),null==(e=this.instance)||e.plugins.eject(this.plugin)}onGet(e,t){return this.createHandler("get").bind(this)(e,t)}onDelete(e,t){return this.createHandler("delete").bind(this)(e,t)}onHead(e,t){return this.createHandler("head").bind(this)(e,t)}onAny(e,t){return this.createHandler("any").bind(this)(e,t)}onPost(t,r,n){return this.createHandler("post").bind(this)(t,e({},n||{},{data:r||{}}))}onPut(t,r,n){return this.createHandler("put").bind(this)(t,e({},n||{},{data:r||{}}))}onPatch(t,r,n){return this.createHandler("patch").bind(this)(t,e({},n||{},{data:r||{}}))}onOptions(e,t){return this.createHandler("options").bind(this)(e,t)}createHandler(t){return(r,n)=>{var s,l,a,u,d,h;n=n?e({},{headers:null==(l=this.instance)?void 0:null==(s=l.config)?void 0:s.headers,params:null==(u=this.instance)?void 0:null==(a=u.config)?void 0:a.params,data:null==(h=this.instance)?void 0:null==(d=h.config)?void 0:d.data},n||{}):{},r=void 0===r?/.*/:r;let c=(e,s,i)=>{let o=[r,n,e,s,i];return this.addHandler(t,o),this},f=(e,s,i)=>{let o=[r,n,e,s,i,!0];return this.addHandler(t,o),this},p=(e,s,i,o)=>{let l=[r,n,s,i,o,!1,e];return this.addHandler(t,l),this};return{reply:c,replyOnce:f,withDelayInMs:function(e){return function(t,r,n){return p(e,t,r,n)}},passThrough:()=>{let e=[r,n];return this.addHandler(t,e),this},abortRequest:()=>c(e=>Promise.reject(new i("Request aborted",e))),abortRequestOnce:()=>f(e=>Promise.reject(new i("Request aborted",e,{}))),networkError:()=>c(e=>Promise.reject(new i("Network Error",e,{}))),networkErrorOnce:()=>f(e=>Promise.reject(new i("Network Error",e,{}))),timeout:()=>c(e=>Promise.reject(new o("timeout of 0ms exceeded",e))),timeoutOnce:()=>f(e=>Promise.reject(new o("timeout of 0ms exceeded",e)))}}}addHandler(e,s){let i=[...s];if(i[3])try{i[3]=JSON.parse(JSON.stringify(i[3]))}catch(e){}if(i[4]){let e="undefined"==typeof Headers?(()=>{let e={};return{append(t,r){e[t]=r+""},get:t=>e[t]||null}})():new Headers;Object.keys(i[4]).forEach(t=>{e.append(t,i[4][t])}),i[4]=e}if("any"===e)t.forEach(e=>{var t;this.handlers[e]||(this.handlers[e]=[]),null==(t=this.handlers[e])||t.push(i)});else{var o,l,a;this.handlers[e]||(this.handlers[e]=[]);let t=null==(o=this.handlers[e])?void 0:o.findIndex(e=>6!==e.length&&r(String(e[0]),e[1],n)===r(String(i[0]),i[1],n));(t=void 0===t?-1:t)>-1&&i.length<6?null==(l=this.handlers[e])||l.splice(t,1,i):null==(a=this.handlers[e])||a.push(i)}}findHandler(e){var t;let{method:i,url:o,_url:l,headers:u,params:d,data:h={},baseURL:f}=e,p=null==i?void 0:i.toLowerCase();return null==(t=this.handlers[p])?void 0:t.find(t=>{var i;let m=a({},t[1].headers||{});if((null==(i=e.headers)?void 0:i["Content-Type"])&&!Object.keys(m).find(e=>"content-type"===e.toLowerCase())&&(m["Content-Type"]=e.headers["Content-Type"]),"string"==typeof t[0]){let e=f&&t[0].startsWith(f),i=r(e?s(f,o):s("/",o),{b:d,c:h,a:u},n),l=r(e?t[0]:s("/",t[0]),{b:t[1].params||{},c:t[1].data||{},a:m},n);return i===l||i.startsWith(l)||c([[d,t[1].params],[h,t[1].data],[u,m]])}if(t[0]instanceof RegExp)return(t[0].test(o)||t[0].test(s(f||"",o))||t[0].test(l))&&(r(p,{b:d,c:h,a:u},n)===r(p,{b:t[1].params||{},c:t[1].data||{},a:m},n)||c([[d,t[1].params],[h,t[1].data],[u,m]]))})}constructor(e,t){this.handlers={},this.history={},this.options=t,this.instance=e,this.plugin=this._mockPlugin.bind(this),e.plugins.use(this.plugin)}}function c(e){let t=e.filter(e=>{let[,t]=e;return"function"==typeof(null==t?void 0:t.asymmetricMatch)}),r=t.filter(e=>{let[t,r]=e;return r.asymmetricMatch(t)});return r.length>0&&r.length===t.length}function f(e){e||(e={});let t={},r="undefined"==typeof Headers?{append(e,r){t[e]=r+""},get:e=>t[e]||null}:new Headers;return Object.keys(e).forEach(t=>{r.append(t,e[t])}),r}function p(e,t){if(e.status>=300)throw new i(`Request failed with status code ${e.status}`,t,e);return e}export{d as MockError,h as default};
import{merge as e}from"ts-deepmerge";let t=["get","post","head","delete","patch","put","options"];function r(e,t,r){let n=t?r(t):"";n&&(n=e+(e.includes("?")?"&"+n:"?"+n));let[s,i]=n.split("?");if(i){let e=i.split("&");return`${s}?${e.sort().join("&")}`}return n||e}function n(e,t=!0,r=null){if(null==e)return"";let s=[],i=t?encodeURIComponent:e=>e;for(let o in e)if(Object.prototype.hasOwnProperty.call(e,o)){let l=e[o],a=r?`${r}[${i(o)}]`:i(o);if("object"==typeof l){let e=n(l,t,a);""!==e&&s.push(e)}else Array.isArray(l)?l.forEach((e,t)=>{let r=`${a}[${t}]`;s.push(`${i(r)}=${i(e)}`)}):s.push(`${i(a)}=${i(l)}`)}return s.join("&")}function s(e,t){return t?(e.endsWith("/")?e:e+"/")+(t.startsWith("/")?t.slice(1):t):e}class i extends Error{constructor(e,t,r){super(e),this.name="XiorError",this.request=t,this.config=t,this.response=r}}class o extends i{constructor(e,t,r){super(e),this.name="XiorTimeoutError",this.request=t,this.config=t,this.response=r}}function l(e,t,r,n,s,i,o){try{var l=e[i](o),a=l.value}catch(e){r(e);return}l.done?t(a):Promise.resolve(a).then(n,s)}function a(){return(a=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}let u="undefined"!=typeof AbortController;class d extends Error{constructor(e,t){super(e),this.request=t,this.config=t}}class h{_mockPlugin(e){var t,r=this;return t=function*(t){var n,s,l,a,h;let c=(null==(n=t.method)?void 0:n.toLowerCase())||"get";r.history[c]||(r.history[c]=[]),r.handlers[c]||(r.handlers[c]=[]),null==(s=r.history[c])||s.push(t);let m=r.findHandler(t);if(m){let n;let s=m[6]||(null==(l=r.options)?void 0:l.delayResponse);6===m.length&&Object.keys(r.handlers).forEach(e=>{var t,n;let s=null==(t=r.handlers[e])?void 0:t.indexOf(m);(s=void 0===s?-1:s)>-1&&(null==(n=r.handlers[e])||n.splice(s,1))});let i=[];if(2!==m.length){let e,r;if(t.timeout&&u){let e=new AbortController;r=setTimeout(()=>{e.abort(new o(`timeout of ${t.timeout}ms exceeded`,t))},t.timeout),i.push(e.signal)}t.signal&&i.push(t.signal),e=i[0],i.length>1&&(e=function(e,t){let r=new globalThis.AbortController;function n(e){r.abort(e),i()}let s=[];for(let t of e){if((null==t?void 0:t.aborted)===!0){n(t.reason);break}if((null==t?void 0:t.addEventListener)!=null){let e=()=>{n(t.reason)};s.push(()=>{(null==t?void 0:t.removeEventListener)!=null&&t.removeEventListener("abort",e)}),t.addEventListener("abort",e)}}function i(){s.forEach(e=>{e()}),null==t||t()}let o=r.signal;return o.clear=i,o}(i,()=>{r&&clearTimeout(r)})),n=()=>{var t;r&&clearTimeout(r),null==e||null==(t=e.clear)||t.call(e)}}s&&s>0&&(yield new Promise(e=>{setTimeout(()=>{e("ok")},s)}));let a=i.find(e=>e.aborted);if(a)return null==n||n(),Promise.reject(a.reason);if(2===m.length)return e(t);if("function"!=typeof m[2]){let e=m.slice(2),r=p({data:e[1],status:e[0],statusText:"ok",headers:e[2],request:t,config:t},t);return null==n||n(),r}let d=m[2](t);if("function"!=typeof(null==d?void 0:d.then)){let e=p({data:d[1],status:d[0],statusText:"ok",headers:f(d[2]),request:t,config:t},t);return null==n||n(),e}{let e=yield d;return(null==n||n(),e.config&&e.status)?e:p({data:e[1],status:e[0],statusText:"ok",headers:f(e[2]),request:t,config:t},t)}}if((null==(a=r.options)?void 0:a.onNoMatch)==="passthrough")return e(t);if((null==(h=r.options)?void 0:h.onNoMatch)==="throwException")throw new d("Could not find mock for: \n"+JSON.stringify(t,["method","url"],2),t);{let e="Request failed with status code 404";throw new i(e,t,{status:404,statusText:e,config:t})}},function(){var e=this,r=arguments;return new Promise(function(n,s){var i=t.apply(e,r);function o(e){l(i,n,s,o,a,"next",e)}function a(e){l(i,n,s,o,a,"throw",e)}o(void 0)})}}resetHandlers(){this.handlers={}}resetHistory(){this.history={}}reset(){this.resetHandlers(),this.resetHistory()}restore(){var e;this.reset(),null==(e=this.instance)||e.plugins.eject(this.plugin)}onGet(e,t){return this.createHandler("get").bind(this)(e,t)}onDelete(e,t){return this.createHandler("delete").bind(this)(e,t)}onHead(e,t){return this.createHandler("head").bind(this)(e,t)}onAny(e,t){return this.createHandler("any").bind(this)(e,t)}onPost(t,r,n){return this.createHandler("post").bind(this)(t,e({},n||{},{data:r||{}}))}onPut(t,r,n){return this.createHandler("put").bind(this)(t,e({},n||{},{data:r||{}}))}onPatch(t,r,n){return this.createHandler("patch").bind(this)(t,e({},n||{},{data:r||{}}))}onOptions(e,t){return this.createHandler("options").bind(this)(e,t)}createHandler(t){return(r,n)=>{var s,l,a,u,d,h;n=n?e({},{headers:null==(l=this.instance)?void 0:null==(s=l.config)?void 0:s.headers,params:null==(u=this.instance)?void 0:null==(a=u.config)?void 0:a.params,data:null==(h=this.instance)?void 0:null==(d=h.config)?void 0:d.data},n||{}):{},r=void 0===r?/.*/:r;let c=(e,s,i)=>{let o=[r,n,e,s,i];return this.addHandler(t,o),this},f=(e,s,i)=>{let o=[r,n,e,s,i,!0];return this.addHandler(t,o),this},p=(e,s,i,o)=>{let l=[r,n,s,i,o,!1,e];return this.addHandler(t,l),this};return{reply:c,replyOnce:f,withDelayInMs:function(e){return function(t,r,n){return p(e,t,r,n)}},passThrough:()=>{let e=[r,n];return this.addHandler(t,e),this},abortRequest:()=>c(e=>Promise.reject(new i("Request aborted",e))),abortRequestOnce:()=>f(e=>Promise.reject(new i("Request aborted",e,{}))),networkError:()=>c(e=>Promise.reject(new i("Network Error",e,{}))),networkErrorOnce:()=>f(e=>Promise.reject(new i("Network Error",e,{}))),timeout:()=>c(e=>Promise.reject(new o("timeout of 0ms exceeded",e))),timeoutOnce:()=>f(e=>Promise.reject(new o("timeout of 0ms exceeded",e)))}}}addHandler(e,s){let i=[...s];if(i[3])try{i[3]=JSON.parse(JSON.stringify(i[3]))}catch(e){}if(i[4]){let e="undefined"==typeof Headers?(()=>{let e={};return{append(t,r){e[t]=r+""},get:t=>e[t]||null}})():new Headers;Object.keys(i[4]).forEach(t=>{e.append(t,i[4][t])}),i[4]=e}if("any"===e)t.forEach(e=>{var t;this.handlers[e]||(this.handlers[e]=[]),null==(t=this.handlers[e])||t.push(i)});else{var o,l,a;this.handlers[e]||(this.handlers[e]=[]);let t=null==(o=this.handlers[e])?void 0:o.findIndex(e=>6!==e.length&&r(String(e[0]),e[1],n)===r(String(i[0]),i[1],n));(t=void 0===t?-1:t)>-1&&i.length<6?null==(l=this.handlers[e])||l.splice(t,1,i):null==(a=this.handlers[e])||a.push(i)}}findHandler(e){var t;let{method:i,url:o,headers:l,params:u,data:d={},baseURL:h}=e,f=null==i?void 0:i.toLowerCase();return null==(t=this.handlers[f])?void 0:t.find(t=>{var i;let p=a({},t[1].headers||{});if((null==(i=e.headers)?void 0:i["Content-Type"])&&!Object.keys(p).find(e=>"content-type"===e.toLowerCase())&&(p["Content-Type"]=e.headers["Content-Type"]),"string"==typeof t[0]){let e=h&&t[0].startsWith(h),i=r(e?s(h,o):s("/",o),{b:u,c:d,a:l},n),a=r(e?t[0]:s("/",t[0]),{b:t[1].params||{},c:t[1].data||{},a:p},n);return i===a||i.startsWith(a)||c([[u,t[1].params],[d,t[1].data],[l,p]])}if(t[0]instanceof RegExp)return(t[0].test(o)||t[0].test(s(h||"",o)))&&(r(f,{b:u,c:d,a:l},n)===r(f,{b:t[1].params||{},c:t[1].data||{},a:p},n)||c([[u,t[1].params],[d,t[1].data],[l,p]]))})}constructor(e,t){this.handlers={},this.history={},this.options=t,this.instance=e,this.plugin=this._mockPlugin.bind(this),e.plugins.use(this.plugin)}}function c(e){let t=e.filter(e=>{let[,t]=e;return"function"==typeof(null==t?void 0:t.asymmetricMatch)}),r=t.filter(e=>{let[t,r]=e;return r.asymmetricMatch(t)});return r.length>0&&r.length===t.length}function f(e){e||(e={});let t={},r="undefined"==typeof Headers?{append(e,r){t[e]=r+""},get:e=>t[e]||null}:new Headers;return Object.keys(e).forEach(t=>{r.append(t,e[t])}),r}function p(e,t){if(e.status>=300)throw new i(`Request failed with status code ${e.status}`,t,e);return e}export{d as MockError,h as default};

@@ -8,4 +8,2 @@ interface XiorRequestConfig<T = any> extends Omit<RequestInit, 'body'> {

timeout?: number;
/** @deprecated use paramsSerializer */
encode?: (params: Record<string, any>) => string;
paramsSerializer?: (params: Record<string, any>) => string;

@@ -20,6 +18,4 @@ /** Use encodeURIComponent, default: true */

data?: any;
_data?: any;
/** encoded url with params */
_url?: string;
/** useless now, compitable axios */
withCredentials?: boolean;

@@ -36,3 +32,2 @@ /**

url: string;
_url: string;
method: string;

@@ -39,0 +34,0 @@ };

@@ -8,4 +8,2 @@ interface XiorRequestConfig<T = any> extends Omit<RequestInit, 'body'> {

timeout?: number;
/** @deprecated use paramsSerializer */
encode?: (params: Record<string, any>) => string;
paramsSerializer?: (params: Record<string, any>) => string;

@@ -20,6 +18,4 @@ /** Use encodeURIComponent, default: true */

data?: any;
_data?: any;
/** encoded url with params */
_url?: string;
/** useless now, compitable axios */
withCredentials?: boolean;

@@ -36,3 +32,2 @@ /**

url: string;
_url: string;
method: string;

@@ -39,0 +34,0 @@ };

/*! For license information please see throttle.umd.js.LICENSE.txt */
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.xiorThrottle=e():t.xiorThrottle=e()}(this,(()=>(()=>{"use strict";var t={629:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t,e,s){let i=e?s(e):"";i&&(i=t+(t.includes("?")?"&"+i:"?"+i));const[n,r]=i.split("?");return r?`${n}?${r.split("&").sort().join("&")}`:i||t}},272:function(t,e,s){var i=this&&this.__awaiter||function(t,e,s,i){return new(s||(s=Promise))((function(n,r){function l(t){try{h(i.next(t))}catch(t){r(t)}}function o(t){try{h(i.throw(t))}catch(t){r(t)}}function h(t){var e;t.done?n(t.value):(e=t.value,e instanceof s?e:new s((function(t){t(e)}))).then(l,o)}h((i=i.apply(t,e||[])).next())}))},n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=s(455),l=n(s(629));e.default=function(t={}){const{enableThrottle:e,threshold:s=1e3,throttleCache:n=(0,r.lru)(10)}=t,o=n;return function(t){const n=(e,s)=>{const n=(()=>i(this,void 0,void 0,(function*(){try{const i=yield t(s);return o.set(e,{timestamp:Date.now(),value:Promise.resolve(i)}),i}catch(t){throw"delete"in o?o.delete(e):o.del(e),t}})))();return o.set(e,{timestamp:Date.now(),value:n}),n};return r=>i(this,void 0,void 0,(function*(){const{_url:i,encode:h,threshold:u=s,enableThrottle:a=e,data:f}=r,c="GET"===r.method||r.isGet,p=typeof a;if("undefined"===p?c:"function"===p?a(r):Boolean(a)){const t=(0,l.default)(i,f,h),e=Date.now(),s=o.get(t)||{timestamp:e};if(e-s.timestamp<=u){const t=s.value;if(t)return t}return n(t,r)}return t(r)}))}}},455:(t,e)=>{class s{constructor(t=0,e=0,s=!1){this.first=null,this.items=Object.create(null),this.last=null,this.max=t,this.resetTtl=s,this.size=0,this.ttl=e}clear(){return this.first=null,this.items=Object.create(null),this.last=null,this.size=0,this}delete(t){if(this.has(t)){const e=this.items[t];delete this.items[t],this.size--,null!==e.prev&&(e.prev.next=e.next),null!==e.next&&(e.next.prev=e.prev),this.first===e&&(this.first=e.next),this.last===e&&(this.last=e.prev)}return this}entries(t=this.keys()){return t.map((t=>[t,this.get(t)]))}evict(t=!1){if(t||this.size>0){const t=this.first;delete this.items[t.key],0==--this.size?(this.first=null,this.last=null):(this.first=t.next,this.first.prev=null)}return this}expiresAt(t){let e;return this.has(t)&&(e=this.items[t].expiry),e}get(t){let e;if(this.has(t)){const s=this.items[t];this.ttl>0&&s.expiry<=Date.now()?this.delete(t):(e=s.value,this.set(t,e,!0))}return e}has(t){return t in this.items}keys(){const t=[];let e=this.first;for(;null!==e;)t.push(e.key),e=e.next;return t}set(t,e,s=!1,i=this.resetTtl){let n;if(s||this.has(t)){if(n=this.items[t],n.value=e,!1===s&&i&&(n.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.last!==n){const t=this.last,e=n.next,s=n.prev;this.first===n&&(this.first=n.next),n.next=null,n.prev=this.last,t.next=n,null!==s&&(s.next=e),null!==e&&(e.prev=s)}}else this.max>0&&this.size===this.max&&this.evict(!0),n=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e},1==++this.size?this.first=n:this.last.next=n;return this.last=n,this}values(t=this.keys()){return t.map((t=>this.get(t)))}}e.LRU=s,e.lru=function(t=1e3,e=0,i=!1){if(isNaN(t)||t<0)throw new TypeError("Invalid max value");if(isNaN(e)||e<0)throw new TypeError("Invalid ttl value");if("boolean"!=typeof i)throw new TypeError("Invalid resetTtl value");return new s(t,e,i)}}},e={},s=function s(i){var n=e[i];if(void 0!==n)return n.exports;var r=e[i]={exports:{}};return t[i].call(r.exports,r,r.exports,s),r.exports}(272);return s.default})()));
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.xiorThrottle=e():t.xiorThrottle=e()}(this,(()=>(()=>{"use strict";var t={699:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.anySignal=void 0,e.anySignal=function(t,e){const r=new globalThis.AbortController;function i(t){r.abort(t),n()}const s=[];for(const e of t){if(!0===(null==e?void 0:e.aborted)){i(e.reason);break}if(null!=(null==e?void 0:e.addEventListener)){const t=()=>{i(e.reason)};s.push((()=>{null!=(null==e?void 0:e.removeEventListener)&&e.removeEventListener("abort",t)})),e.addEventListener("abort",t)}}function n(){s.forEach((t=>{t()})),null==e||e()}const o=r.signal;return o.clear=n,o}},729:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.merge=void 0;const i=r(602);Object.defineProperty(e,"merge",{enumerable:!0,get:function(){return i.merge}})},629:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t,e,r){let i=e?r(e):"";i&&(i=t+(t.includes("?")?"&"+i:"?"+i));const[s,n]=i.split("?");return n?`${s}?${n.split("&").sort().join("&")}`:i||t}},272:function(t,e,r){var i=this&&this.__awaiter||function(t,e,r,i){return new(r||(r=Promise))((function(s,n){function o(t){try{u(i.next(t))}catch(t){n(t)}}function l(t){try{u(i.throw(t))}catch(t){n(t)}}function u(t){var e;t.done?s(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(o,l)}u((i=i.apply(t,e||[])).next())}))},s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const n=r(455),o=s(r(629)),l=r(976);e.default=function(t={}){const{enableThrottle:e,threshold:r=1e3,throttleCache:s=(0,n.lru)(10)}=t,u=s;return function(t){const s=(e,r)=>{const s=(()=>i(this,void 0,void 0,(function*(){try{const i=yield t(r);return u.set(e,{timestamp:Date.now(),value:Promise.resolve(i)}),i}catch(t){throw"delete"in u?u.delete(e):u.del(e),t}})))();return u.set(e,{timestamp:Date.now(),value:s}),s};return n=>i(this,void 0,void 0,(function*(){const{paramsSerializer:i,threshold:a=r,enableThrottle:c=e}=n,h="GET"===n.method||n.isGet,f=typeof c;if("undefined"===f?h:"function"===f?c(n):Boolean(c)){const t=(0,o.default)(n.url&&(0,l.isAbsoluteURL)(n.url)?n.url:(0,l.joinPath)(n.baseURL||"",n.url||""),{a:n.data,b:n.params},i),e=Date.now(),r=u.get(t)||{timestamp:e};if(e-r.timestamp<=a){const t=r.value;if(t)return t}return s(t,n)}return t(n)}))}}},99:function(t,e,r){var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.delay=e.buildSortedURL=void 0;const s=i(r(629));e.buildSortedURL=s.default,e.delay=function(t){return new Promise((e=>{setTimeout((()=>{e("ok")}),t)}))}},976:function(t,e,r){var i=this&&this.__createBinding||(Object.create?function(t,e,r,i){void 0===i&&(i=r);var s=Object.getOwnPropertyDescriptor(e,r);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,i,s)}:function(t,e,r,i){void 0===i&&(i=r),t[i]=e[r]}),s=this&&this.__exportStar||function(t,e){for(var r in t)"default"===r||Object.prototype.hasOwnProperty.call(e,r)||i(e,t,r)};Object.defineProperty(e,"__esModule",{value:!0}),e.isXiorError=e.XiorTimeoutError=e.XiorError=e.joinPath=e.isAbsoluteURL=e.encodeParams=void 0,s(r(699),e),s(r(729),e),s(r(99),e),e.encodeParams=function t(e,r=!0,i=null){if(null==e)return"";const s=[],n=r?encodeURIComponent:t=>t;for(const o in e)if(Object.prototype.hasOwnProperty.call(e,o)){const l=e[o],u=i?`${i}[${n(o)}]`:n(o);if("object"==typeof l){const e=t(l,r,u);""!==e&&s.push(e)}else Array.isArray(l)?l.forEach(((t,e)=>{const r=`${u}[${e}]`;s.push(`${n(r)}=${n(t)}`)})):s.push(`${n(u)}=${n(l)}`)}return s.join("&")},e.isAbsoluteURL=function(t){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)},e.joinPath=function(t,e){return e?(t.endsWith("/")?t:t+"/")+(e.startsWith("/")?e.slice(1):e):t};class n extends Error{constructor(t,e,r){super(t),this.name="XiorError",this.request=e,this.config=e,this.response=r}}e.XiorError=n,e.XiorTimeoutError=class extends n{constructor(t,e,r){super(t),this.name="XiorTimeoutError",this.request=e,this.config=e,this.response=r}},e.isXiorError=function(t){return"XiorError"===t.name||"XiorTimeoutError"===t.name}},455:(t,e)=>{class r{constructor(t=0,e=0,r=!1){this.first=null,this.items=Object.create(null),this.last=null,this.max=t,this.resetTtl=r,this.size=0,this.ttl=e}clear(){return this.first=null,this.items=Object.create(null),this.last=null,this.size=0,this}delete(t){if(this.has(t)){const e=this.items[t];delete this.items[t],this.size--,null!==e.prev&&(e.prev.next=e.next),null!==e.next&&(e.next.prev=e.prev),this.first===e&&(this.first=e.next),this.last===e&&(this.last=e.prev)}return this}entries(t=this.keys()){return t.map((t=>[t,this.get(t)]))}evict(t=!1){if(t||this.size>0){const t=this.first;delete this.items[t.key],0==--this.size?(this.first=null,this.last=null):(this.first=t.next,this.first.prev=null)}return this}expiresAt(t){let e;return this.has(t)&&(e=this.items[t].expiry),e}get(t){let e;if(this.has(t)){const r=this.items[t];this.ttl>0&&r.expiry<=Date.now()?this.delete(t):(e=r.value,this.set(t,e,!0))}return e}has(t){return t in this.items}keys(){const t=[];let e=this.first;for(;null!==e;)t.push(e.key),e=e.next;return t}set(t,e,r=!1,i=this.resetTtl){let s;if(r||this.has(t)){if(s=this.items[t],s.value=e,!1===r&&i&&(s.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.last!==s){const t=this.last,e=s.next,r=s.prev;this.first===s&&(this.first=s.next),s.next=null,s.prev=this.last,t.next=s,null!==r&&(r.next=e),null!==e&&(e.prev=r)}}else this.max>0&&this.size===this.max&&this.evict(!0),s=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e},1==++this.size?this.first=s:this.last.next=s;return this.last=s,this}values(t=this.keys()){return t.map((t=>this.get(t)))}}e.LRU=r,e.lru=function(t=1e3,e=0,i=!1){if(isNaN(t)||t<0)throw new TypeError("Invalid max value");if(isNaN(e)||e<0)throw new TypeError("Invalid ttl value");if("boolean"!=typeof i)throw new TypeError("Invalid resetTtl value");return new r(t,e,i)}},602:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.merge=void 0;const r=t=>{if("object"==typeof t&&null!==t){if("function"==typeof Object.getPrototypeOf){const e=Object.getPrototypeOf(t);return e===Object.prototype||null===e}return"[object Object]"===Object.prototype.toString.call(t)}return!1};e.merge=(...t)=>t.reduce(((t,i)=>{if(Array.isArray(i))throw new TypeError("Arguments provided to ts-deepmerge must be objects, not arrays.");return Object.keys(i).forEach((s=>{["__proto__","constructor","prototype"].includes(s)||(Array.isArray(t[s])&&Array.isArray(i[s])?t[s]=e.merge.options.mergeArrays?e.merge.options.uniqueArrayItems?Array.from(new Set(t[s].concat(i[s]))):[...t[s],...i[s]]:i[s]:r(t[s])&&r(i[s])?t[s]=(0,e.merge)(t[s],i[s]):t[s]=void 0===i[s]?e.merge.options.allowUndefinedOverrides?i[s]:t[s]:i[s])})),t}),{});const i={allowUndefinedOverrides:!0,mergeArrays:!0,uniqueArrayItems:!0};e.merge.options=i,e.merge.withOptions=(t,...r)=>{e.merge.options=Object.assign(Object.assign({},i),t);const s=(0,e.merge)(...r);return e.merge.options=i,s}}},e={},r=function r(i){var s=e[i];if(void 0!==s)return s.exports;var n=e[i]={exports:{}};return t[i].call(n.exports,n,n.exports,r),n.exports}(272);return r.default})()));

@@ -17,4 +17,2 @@ type ICacheLike<T> = {

timeout?: number;
/** @deprecated use paramsSerializer */
encode?: (params: Record<string, any>) => string;
paramsSerializer?: (params: Record<string, any>) => string;

@@ -29,6 +27,4 @@ /** Use encodeURIComponent, default: true */

data?: any;
_data?: any;
/** encoded url with params */
_url?: string;
/** useless now, compitable axios */
withCredentials?: boolean;

@@ -45,3 +41,2 @@ /**

url: string;
_url: string;
method: string;

@@ -48,0 +43,0 @@ };

@@ -17,4 +17,2 @@ type ICacheLike<T> = {

timeout?: number;
/** @deprecated use paramsSerializer */
encode?: (params: Record<string, any>) => string;
paramsSerializer?: (params: Record<string, any>) => string;

@@ -29,6 +27,4 @@ /** Use encodeURIComponent, default: true */

data?: any;
_data?: any;
/** encoded url with params */
_url?: string;
/** useless now, compitable axios */
withCredentials?: boolean;

@@ -45,3 +41,2 @@ /**

url: string;
_url: string;
method: string;

@@ -48,0 +43,0 @@ };

@@ -1,1 +0,1 @@

import{lru as t}from"tiny-lru";function e(t,e,n,r,i,o,u){try{var l=t[o](u),a=l.value}catch(t){n(t);return}l.done?e(a):Promise.resolve(a).then(r,i)}function n(t){return function(){var n=this,r=arguments;return new Promise(function(i,o){var u=t.apply(n,r);function l(t){e(u,i,o,l,a,"next",t)}function a(t){e(u,i,o,l,a,"throw",t)}l(void 0)})}}function r(e={}){let{enableThrottle:r,threshold:i=1e3,throttleCache:o=t(10)}=e;return function(t){let e=(e,r)=>{let i=n(function*(){try{let n=yield t(r);return o.set(e,{timestamp:Date.now(),value:Promise.resolve(n)}),n}catch(t){throw"delete"in o?o.delete(e):o.del(e),t}})();return o.set(e,{timestamp:Date.now(),value:i}),i};return n(function*(n){let{_url:u,encode:l,threshold:a=i,enableThrottle:f=r,data:s}=n,c="GET"===n.method||n.isGet,m=typeof f;if("undefined"===m?c:"function"===m?f(n):!!f){let t=function(t,e,n){let r=e?n(e):"";r&&(r=t+(t.includes("?")?"&"+r:"?"+r));let[i,o]=r.split("?");if(o){let t=o.split("&");return`${i}?${t.sort().join("&")}`}return r||t}(u,s,l),r=Date.now(),i=o.get(t)||{timestamp:r};if(r-i.timestamp<=a){let t=i.value;if(t)return t}return e(t,n)}return t(n)})}}export{r as default};
import{lru as t}from"tiny-lru";import"ts-deepmerge";function e(t,e,r,n,i,u,l){try{var o=t[u](l),a=o.value}catch(t){r(t);return}o.done?e(a):Promise.resolve(a).then(n,i)}function r(t){return function(){var r=this,n=arguments;return new Promise(function(i,u){var l=t.apply(r,n);function o(t){e(l,i,u,o,a,"next",t)}function a(t){e(l,i,u,o,a,"throw",t)}o(void 0)})}}function n(e={}){let{enableThrottle:n,threshold:i=1e3,throttleCache:u=t(10)}=e;return function(t){let e=(e,n)=>{let i=r(function*(){try{let r=yield t(n);return u.set(e,{timestamp:Date.now(),value:Promise.resolve(r)}),r}catch(t){throw"delete"in u?u.delete(e):u.del(e),t}})();return u.set(e,{timestamp:Date.now(),value:i}),i};return r(function*(r){let{paramsSerializer:l,threshold:o=i,enableThrottle:a=n}=r,s="GET"===r.method||r.isGet,f=typeof a;if("undefined"===f?s:"function"===f?a(r):!!a){var c,m,d;let t=function(t,e,r){let n=e?r(e):"";n&&(n=t+(t.includes("?")?"&"+n:"?"+n));let[i,u]=n.split("?");if(u){let t=u.split("&");return`${i}?${t.sort().join("&")}`}return n||t}(r.url&&(c=r.url,/^([a-z][a-z\d+\-.]*:)?\/\//i.test(c))?r.url:(m=r.baseURL||"",(d=r.url||"")?(m.endsWith("/")?m:m+"/")+(d.startsWith("/")?d.slice(1):d):m),{a:r.data,b:r.params},l),n=Date.now(),i=u.get(t)||{timestamp:n};if(n-i.timestamp<=o){let t=i.value;if(t)return t}return e(t,r)}return t(r)})}}export{n as default};

@@ -39,2 +39,3 @@ [![Build](https://github.com/suhaotian/xior/actions/workflows/check.yml/badge.svg)](https://github.com/suhaotian/xior/actions/workflows/check.yml)

- [Timeout and Cancel request](#timeout-and-cancel-request)
- [Encrypt and Decrypt Example](#encrypt-and-decrypt-example)
- [Plugins](#plugins)

@@ -355,2 +356,57 @@ - [Error retry plugin](#error-retry-plugin)

### Encrypt and Decrypt Example
We can use interceptors easily to handle encrypt/decrypt.
Create `encryption.ts`:
```ts
// encryption.ts
export const SECRET = '&*&*^SDxsdasdas776';
export function encrypt(data: string) {
return data + '____' + SECRET;
}
export function decrypt(data: string, s?: string) {
return data.replace('____' + (s || SECRET), '');
}
```
Create `xior-instance.ts`:
```ts
import xior from 'xior';
import { SECRET, encrypt, decrypt } from './encryption';
export const instance = xior.create();
instance.interceptors.request.use((req) => {
req.headers['X'] = SECRET;
if (req.url && req.data) {
const result = JSON.stringify(req.data);
const blob = encrypt(result);
req.data = { blob };
}
return req;
});
instance.interceptors.response.use((res) => {
if (res.request.url && res.data?.blob) {
res.data = decrypt(res.data.blob);
try {
res.data = JSON.parse(res.data);
} catch (e) {
console.error(e);
}
}
return res;
});
```
> Check test code in `tests/src/tests/encrypt-decrypt/`
## Plugins

@@ -357,0 +413,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc