amis-rpc-design/node_modules/@reduxjs/toolkit/dist/query/rtk-query.modern.production.min.js

2 lines
31 KiB
JavaScript
Raw Normal View History

2023-10-07 19:42:30 +08:00
var e,t,n=Object.defineProperty,r=Object.defineProperties,i=Object.getOwnPropertyDescriptors,a=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,s=Object.prototype.propertyIsEnumerable,u=(e,t,r)=>t in e?n(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,c=(e,t)=>{for(var n in t||(t={}))o.call(t,n)&&u(e,n,t[n]);if(a)for(var n of a(t))s.call(t,n)&&u(e,n,t[n]);return e},d=(e,t)=>r(e,i(t)),l=(e,t)=>{var n={};for(var r in e)o.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&a)for(var r of a(e))t.indexOf(r)<0&&s.call(e,r)&&(n[r]=e[r]);return n};(t=e||(e={})).uninitialized="uninitialized",t.pending="pending",t.fulfilled="fulfilled",t.rejected="rejected";var p=e=>[].concat(...e);import{isPlainObject as f}from"@reduxjs/toolkit";var y=f;function m(e,t){if(e===t||!(y(e)&&y(t)||Array.isArray(e)&&Array.isArray(t)))return t;const n=Object.keys(t),r=Object.keys(e);let i=n.length===r.length;const a=Array.isArray(t)?[]:{};for(const r of n)a[r]=m(e[r],t[r]),i&&(i=e[r]===a[r]);return i?e:a}import{isPlainObject as h}from"@reduxjs/toolkit";var g=(...e)=>fetch(...e),v=e=>e.status>=200&&e.status<=299,b=e=>/ion\/(vnd\.api\+)?json/.test(e.get("content-type")||"");function q(e){if(!h(e))return e;const t=c({},e);for(const[e,n]of Object.entries(t))void 0===n&&delete t[e];return t}function S(e={}){var t=e,{baseUrl:n,prepareHeaders:r=(e=>e),fetchFn:i=g,paramsSerializer:a,isJsonContentType:o=b,jsonContentType:s="application/json",jsonReplacer:u,timeout:p,responseHandler:f,validateStatus:y}=t,m=l(t,["baseUrl","prepareHeaders","fetchFn","paramsSerializer","isJsonContentType","jsonContentType","jsonReplacer","timeout","responseHandler","validateStatus"]);return"undefined"==typeof fetch&&i===g&&console.warn("Warning: `fetch` is not available. Please supply a custom `fetchFn` property to use `fetchBaseQuery` on SSR environments."),async(e,t)=>{const{signal:g,getState:b,extra:R,endpoint:O,forced:T,type:w}=t;let j,A="string"==typeof e?{url:e}:e,{url:k,headers:x=new Headers(m.headers),params:Q,responseHandler:I=(null!=f?f:"json"),validateStatus:C=(null!=y?y:v),timeout:P=p}=A,M=l(A,["url","headers","params","responseHandler","validateStatus","timeout"]),D=c(d(c({},m),{signal:g}),M);x=new Headers(q(x)),D.headers=await r(x,{getState:b,extra:R,endpoint:O,forced:T,type:w})||x;const N=e=>"object"==typeof e&&(h(e)||Array.isArray(e)||"function"==typeof e.toJSON);if(!D.headers.has("content-type")&&N(D.body)&&D.headers.set("content-type",s),N(D.body)&&o(D.headers)&&(D.body=JSON.stringify(D.body,u)),Q){const e=~k.indexOf("?")?"&":"?";k+=e+(a?a(Q):new URLSearchParams(q(Q)))}k=function(e,t){if(!e)return t;if(!t)return e;if(function(e){return new RegExp("(^|:)//").test(e)}(t))return t;const n=e.endsWith("/")||!t.startsWith("?")?"/":"";return e=(e=>e.replace(/\/$/,""))(e),`${e}${n}${t=(e=>e.replace(/^\//,""))(t)}`}(n,k);const K=new Request(k,D);j={request:new Request(k,D)};let E,F=!1,z=P&&setTimeout((()=>{F=!0,t.abort()}),P);try{E=await i(K)}catch(e){return{error:{status:F?"TIMEOUT_ERROR":"FETCH_ERROR",error:String(e)},meta:j}}finally{z&&clearTimeout(z)}const _=E.clone();let $;j.response=_;let U="";try{let e;if(await Promise.all([S(E,I).then((e=>$=e),(t=>e=t)),_.text().then((e=>U=e),(()=>{}))]),e)throw e}catch(e){return{error:{status:"PARSING_ERROR",originalStatus:E.status,data:U,error:String(e)},meta:j}}return C(E,$)?{data:$,meta:j}:{error:{status:E.status,data:$},meta:j}};async function S(e,t){if("function"==typeof t)return t(e);if("content-type"===t&&(t=o(e.headers)?"json":"text"),"json"===t){const t=await e.text();return t.length?JSON.parse(t):null}return e.text()}}var R=class{constructor(e,t){this.value=e,this.meta=t}};async function O(e=0,t=5){const n=Math.min(e,t),r=~~((Math.random()+.4)*(300<<n));await new Promise((e=>setTimeout((t=>e(t)),r)))}var T={},w=Object.assign(((e,t)=>async(n,r,i)=>{const a=[5,(t||T).maxRetries,(i||T).maxRetries].filter((e=>void 0!==e)),[o]=a.slice(-1),s=c(c({maxRetries:o,backoff:O,retryCondition:(e,t,{attempt:n})=>n<=o},t),i);let u=0;for(;;)try{const t=await e(n,r,i);if(t.error)throw new R(t);return t}catch(e)
//# sourceMappingURL=rtk-query.modern.production.min.js.map