diff --git a/dist/ff-request.js b/dist/ff-request.js index 59e93ca..d670860 100644 --- a/dist/ff-request.js +++ b/dist/ff-request.js @@ -8,7 +8,7 @@ var i = (r, e, t) => (re(r, e, "read from private field"), t ? t.call(r) : e.get if (e.has(r)) throw TypeError("Cannot add the same private member more than once"); e instanceof WeakSet ? e.add(r) : e.set(r, t); -}, _ = (r, e, t, n) => (re(r, e, "write to private field"), n ? n.call(r, t) : e.set(r, t), t); +}, A = (r, e, t, n) => (re(r, e, "write to private field"), n ? n.call(r, t) : e.set(r, t), t); function he(r) { return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r; } @@ -16,7 +16,7 @@ var oe = {}; (function(r) { (function(e) { e([], function() { - var t = -1, n = -2, s = -3, c = -4, l = -5, A = function(h, o) { + var t = -1, n = -2, s = -3, c = -4, l = -5, C = function(h, o) { o = o || {}; var d = o.verbose || !1; d && console.log("Normalize the JSON Object"), h = typeof h == "string" ? this.JSON.parse(h) : h, d && console.log("Creating a empty dictionary"); @@ -144,13 +144,13 @@ var oe = {}; var O = P[y++]; if (o.verbose && console.log("Reading collection type " + (O === "$" ? "object" : "Array")), O === "@") { for (var p = []; y < x; y++) { - var C = P[y]; - if (o.verbose && console.log("Read " + C + " symbol"), C === "]") + var _ = P[y]; + if (o.verbose && console.log("Read " + _ + " symbol"), _ === "]") return p; - if (C === "@" || C === "$") + if (_ === "@" || _ === "$") p.push($()); else - switch (C) { + switch (_) { case t: p.push(!0); break; @@ -167,7 +167,7 @@ var oe = {}; p.push(""); break; default: - p.push(f[C]); + p.push(f[_]); } } return o.verbose && console.log("Parsed " + this.JSON.stringify(p)), p; @@ -178,11 +178,11 @@ var oe = {}; if (S === "]") return p; S === c ? S = "" : S = f[S]; - var C = P[++y]; - if (C === "@" || C === "$") + var _ = P[++y]; + if (_ === "@" || _ === "$") p[S] = $(); else - switch (C) { + switch (_) { case t: p[S] = !0; break; @@ -199,7 +199,7 @@ var oe = {}; p[S] = ""; break; default: - p[S] = f[C]; + p[S] = f[_]; } } return o.verbose && console.log("Parsed " + this.JSON.stringify(p)), p; @@ -238,7 +238,7 @@ var oe = {}; }; return { JSON, - pack: A, + pack: C, unpack: M }; }); @@ -274,14 +274,14 @@ class ee { value: i(this, U).getPrototypeOf() }) }); - E(this, Y, (e) => e === "$echoMsg" ? i(this, J) : e === "msg" ? i(this, Q) : e === "then" || e === "resp" ? (_(this, D, !0), _(this, B, e === "resp"), i(this, W)) : e === "catch" ? i(this, X) : e === "IS_ECHO_MSG" ? i(this, D) : Reflect.get(this, e)); - E(this, Q, (e = (n) => n, t = !1) => (i(this, J).call(this), _(this, B, t), Promise.resolve(e == null ? void 0 : e(i(this, U).getPrototypeOf())))); + E(this, Y, (e) => e === "$echoMsg" ? i(this, J) : e === "msg" ? i(this, Q) : e === "then" || e === "resp" ? (A(this, D, !0), A(this, B, e === "resp"), i(this, W)) : e === "catch" ? i(this, X) : e === "IS_ECHO_MSG" ? i(this, D) : Reflect.get(this, e)); + E(this, Q, (e = (n) => n, t = !1) => (i(this, J).call(this), A(this, B, t), Promise.resolve(e == null ? void 0 : e(i(this, U).getPrototypeOf())))); E(this, J, () => { - i(this, D) && (_(this, D, !1), Te.onMsg(this.code, this.message)); + i(this, D) && (A(this, D, !1), Te.onMsg(this.code, this.message)); }); E(this, W, (e) => [0, 1].includes(this.code) ? Promise.resolve(e == null ? void 0 : e(i(this, U).getPrototypeOf())) : Promise.reject(i(this, j))); E(this, X, (e) => Promise.resolve(e(i(this, j)))); - return this.code = e, this.message = t, this.data = n, this.url = s, this.res = c, _(this, j, new Proxy(this, i(this, U))); + return this.code = e, this.message = t, this.data = n, this.url = s, this.res = c, A(this, j, new Proxy(this, i(this, U))); } } j = new WeakMap(), B = new WeakMap(), D = new WeakMap(), U = new WeakMap(), Y = new WeakMap(), Q = new WeakMap(), J = new WeakMap(), W = new WeakMap(), X = new WeakMap(); @@ -364,7 +364,7 @@ var K; class Ee { constructor(e) { E(this, K, null); - _(this, K, e); + A(this, K, e); } get6bits() { let e = this.pos & 7, t = this.pos >> 3; @@ -387,13 +387,13 @@ var H; class Oe { constructor(e) { E(this, H, null); - _(this, H, e); + A(this, H, e); } decode(e) { const t = new Uint8Array(Math.ceil(e.length * 6 / 8) + 1); let n = t.length, s = 0, c = 0; for (let l = 0; l < e.length; l++) { - const A = e[l].charCodeAt(0), M = i(this, H).decodeMap[A]; + const C = e[l].charCodeAt(0), M = i(this, H).decodeMap[C]; if (M === 255) throw new Error(`CorruptInputError at index ${l}`); l === e.length - 1 ? (c |= M << s, s += Math.ceil(Math.log2(M + 1))) : (M & V) === V ? (c |= M << s, s += 5) : (c |= M << s, s += 6), s >= 8 && (n--, t[n] = c & 255, s %= 8, c >>= 8); @@ -423,13 +423,13 @@ class te { E(this, R, /* @__PURE__ */ new Map()); v(this, "request", ({ url: e = "/", method: t = "GET", ...n }, s = !1) => { var F; - const c = t.toUpperCase(), l = pe(JSON.stringify([e, c, n])), A = (F = e == null ? void 0 : e.includes) != null && F.call(e, "/_/") ? "#" : "$", { promise: M, resolve: G, reject: z } = Promise.withResolvers(); - return i(this, m)[A].has(l) ? (console.log("cache", e), G(i(this, m)[A].get(l))) : i(this, R).has(l) ? i(this, R).get(l).push([G, z]) : (i(this, R).set(l, [[G, z]]), i(this, L).call(this, { url: e, method: c, ...n }).then((u) => { + const c = t.toUpperCase(), l = pe(JSON.stringify([e, c, n])), C = (F = e == null ? void 0 : e.includes) != null && F.call(e, "/_/") ? "#" : "$", { promise: M, resolve: G, reject: z } = Promise.withResolvers(); + return i(this, m)[C].has(l) ? (console.log("cache", e), G(i(this, m)[C].get(l))) : i(this, R).has(l) ? i(this, R).get(l).push([G, z]) : (i(this, R).set(l, [[G, z]]), i(this, L).call(this, { url: e, method: c, ...n }).then((u) => { if (![0, 1].includes(u.code)) throw k(u.code, u.msg, u.data, e, u == null ? void 0 : u.res); return [u.code, u.msg, u.data, e, u == null ? void 0 : u.res]; - }).then((u) => ((c === "GET" || A == "#") && i(this, m)[A].set(l, u), c === "GET" && !s && setTimeout(() => { - i(this, m)[A].delete(l); + }).then((u) => ((C == "#" || c == "GET") && i(this, m)[C].set(l, u), C != "#" && c == "GET" && !s && setTimeout(() => { + i(this, m)[C].delete(l); }, 300), u)).then((u) => { var T; return (T = i(this, R).get(l)) == null ? void 0 : T.forEach((h, o, d) => { @@ -437,7 +437,7 @@ class te { }); }).catch((u) => { var T; - i(this, m)[A].delete(l), (T = i(this, R).get(l)) == null || T.forEach((h, o, d) => { + i(this, m)[C].delete(l), (T = i(this, R).get(l)) == null || T.forEach((h, o, d) => { h && h[1](u instanceof ee ? u : k(-1, u, null, e)), delete d[o]; }); }).finally(() => i(this, R).delete(l))), new Proxy(M, { @@ -475,7 +475,7 @@ class te { const t = JSON.stringify(e, (n, s) => s === void 0 ? null : s); return i(this, q).encode(ne.pack(t)); }); - _(this, Z, e), _(this, L, n), _(this, q, new be(t)); + A(this, Z, e), A(this, L, n), A(this, q, new be(t)); } } L = new WeakMap(), q = new WeakMap(), Z = new WeakMap(), m = new WeakMap(), R = new WeakMap(); diff --git a/dist/ff-request.umd.cjs b/dist/ff-request.umd.cjs index 5943d8b..4ed28c6 100644 --- a/dist/ff-request.umd.cjs +++ b/dist/ff-request.umd.cjs @@ -1,2 +1,2 @@ -(function(c,d){typeof exports=="object"&&typeof module<"u"?d(exports):typeof define=="function"&&define.amd?define(["exports"],d):(c=typeof globalThis<"u"?globalThis:c||self,d(c["ff-request"]={}))})(this,function(c){"use strict";var Se=Object.defineProperty;var xe=(c,d,b)=>d in c?Se(c,d,{enumerable:!0,configurable:!0,writable:!0,value:b}):c[d]=b;var w=(c,d,b)=>(xe(c,typeof d!="symbol"?d+"":d,b),b),he=(c,d,b)=>{if(!d.has(c))throw TypeError("Cannot "+b)};var o=(c,d,b)=>(he(c,d,"read from private field"),b?b.call(c):d.get(c)),P=(c,d,b)=>{if(d.has(c))throw TypeError("Cannot add the same private member more than once");d instanceof WeakSet?d.add(c):d.set(c,b)},m=(c,d,b,H)=>(he(c,d,"write to private field"),H?H.call(c,b):d.set(c,b),b);var G,J,D,j,X,Z,L,k,ee,z,V,Y,K,te,N,I;function d(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var b={};(function(r){(function(e){e([],function(){var t=-1,n=-2,s=-3,l=-4,u=-5,$=function(f,i){i=i||{};var p=i.verbose||!1;p&&console.log("Normalize the JSON Object"),f=typeof f=="string"?this.JSON.parse(f):f,p&&console.log("Creating a empty dictionary");var g={strings:[],integers:[],floats:[]};p&&console.log("Creating the AST");var v=function _(a){p&&console.log("Calling recursiveAstBuilder with "+this.JSON.stringify(a));var E=typeof a;if(a===null)return{type:"null",index:s};if(typeof a>"u")return{type:"undefined",index:u};if(a instanceof Array){var C=["@"];for(var T in a)a.hasOwnProperty(T)&&C.push(_(a[T]));return C}if(E==="object"){var C=["$"];for(var F in a)a.hasOwnProperty(F)&&(C.push(_(F)),C.push(_(a[F])));return C}if(a==="")return{type:"empty",index:l};if(E==="string"){var S=x.call(g.strings,a);return S==-1&&(g.strings.push(Q(a)),S=g.strings.length-1),{type:"strings",index:S}}if(E==="number"&&a%1===0){var S=x.call(g.integers,a);return S==-1&&(g.integers.push(B(a)),S=g.integers.length-1),{type:"integers",index:S}}if(E==="number"){var S=x.call(g.floats,a);return S==-1&&(g.floats.push(a),S=g.floats.length-1),{type:"floats",index:S}}if(E==="boolean")return{type:"boolean",index:a?t:n};throw new Error("Unexpected argument of type "+typeof a)}(f),O=g.strings.length,q=g.integers.length;g.floats.length,p&&console.log("Parsing the dictionary");var U=g.strings.join("|");return U+="^"+g.integers.join("|"),U+="^"+g.floats.join("|"),p&&console.log("Parsing the structure"),U+="^"+function _(a){if(p&&console.log("Calling a recursiveParser with "+this.JSON.stringify(a)),a instanceof Array){var E=a.shift();for(var C in a)a.hasOwnProperty(C)&&(E+=_(a[C])+"|");return(E[E.length-1]==="|"?E.slice(0,-1):E)+"]"}var T=a.type,F=a.index;if(T==="strings")return B(F);if(T==="integers")return B(O+F);if(T==="floats")return B(O+q+F);if(T==="boolean")return a.index;if(T==="null")return s;if(T==="undefined")return u;if(T==="empty")return l;throw new TypeError("The item is alien!")}(v),p&&console.log("Ending parser"),i.debug?{dictionary:g,ast:v,packed:U}:U},R=function(f,i){i=i||{};var p=f.split("^");i.verbose&&console.log("Building dictionary");var g=[],v=p[0];if(v!==""){v=v.split("|"),i.verbose&&console.log("Parse the strings dictionary");for(var O=0,q=v.length;Oo(this,X).call(this,t),ownKeys:()=>Object.keys(o(this,j).getPrototypeOf()||{}),getPrototypeOf:()=>o(this,J)?this:this.data,getOwnPropertyDescriptor:()=>({configurable:!0,enumerable:!0,writable:!0,value:o(this,j).getPrototypeOf()})});P(this,X,e=>e==="$echoMsg"?o(this,L):e==="msg"?o(this,Z):e==="then"||e==="resp"?(m(this,D,!0),m(this,J,e==="resp"),o(this,k)):e==="catch"?o(this,ee):e==="IS_ECHO_MSG"?o(this,D):Reflect.get(this,e));P(this,Z,(e=n=>n,t=!1)=>(o(this,L).call(this),m(this,J,t),Promise.resolve(e==null?void 0:e(o(this,j).getPrototypeOf()))));P(this,L,()=>{o(this,D)&&(m(this,D,!1),fe.onMsg(this.code,this.message))});P(this,k,e=>[0,1].includes(this.code)?Promise.resolve(e==null?void 0:e(o(this,j).getPrototypeOf())):Promise.reject(o(this,G)));P(this,ee,e=>Promise.resolve(e(o(this,G))));return this.code=e,this.message=t,this.data=n,this.url=s,this.res=l,m(this,G,new Proxy(this,o(this,j)))}}G=new WeakMap,J=new WeakMap,D=new WeakMap,j=new WeakMap,X=new WeakMap,Z=new WeakMap,L=new WeakMap,k=new WeakMap,ee=new WeakMap;const se=(r,e,t,n="/",s="")=>new ne(r,e,t,n,s);var oe=["utf8","utf-8","unicode-1-1-utf-8"];function de(r){if(oe.indexOf(r)<0&&typeof r<"u"&&r!=null)throw new RangeError("Invalid encoding type. Only utf-8 is supported");this.encoding="utf-8",this.encode=function(e){if(typeof e!="string")throw new TypeError("passed argument must be of tye string");var t=unescape(encodeURIComponent(e)),n=new Uint8Array(t.length);const s=t.split("");for(let l=0;l"u")return"";var n=typeof t<"u"&&n in t?t.stream:!1;if(typeof n!="boolean")throw new TypeError("stream option must be boolean");if(ArrayBuffer.isView(e)){var s=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),l=new Array(s.length);for(let u=0;u{let e=5381;for(let t=0;t>>0).toString(16)},ye=(r,e)=>r.replace(new RegExp(`^${e}+|${e}+$`,"g"),""),le=r=>pe.encode(r||""),we=r=>ve.decode(new DataView(r),{}),be=62,W=30,ue=31,Ee=63;class Te{constructor(e){w(this,"encodeTable",[]);w(this,"decodeMap",new Uint8Array(256).fill(255));if(e.length!==be)throw new Error("Encoding alphabet must be 62 characters long");if(e.includes(` -`)||e.includes("\r"))throw new Error("Encoding alphabet contains newline character");this.encodeTable=e.split(""),this.decodeMap=new Uint8Array(256).fill(255);for(let t=0;t>3;e===0&&(t-=1,e=8);let n=this.src[t]>>8-e;return e<6&&t>0&&(n|=this.src[t-1]<0;){let n=6,s=this.get6bits();(s&W)===W&&((this.pos>6||s>ue)&&(n=5),s&=ue),t.push(o(this,z).encodeTable[s].charCodeAt(0)),this.pos-=n}return t}}z=new WeakMap;class Pe{constructor(e){P(this,V,null);m(this,V,e)}decode(e){const t=new Uint8Array(Math.ceil(e.length*6/8)+1);let n=t.length,s=0,l=0;for(let u=0;u=8&&(n--,t[n]=l&255,s%=8,l>>=8)}return s>0&&(n--,t[n]=l&255),t.slice(n)}}V=new WeakMap,Promise.withResolvers||(Promise.withResolvers=function(){let r,e;return{promise:new Promise((n,s)=>{r=n,e=s}),resolve:r,reject:e}});class ie{constructor(e,t,n=({})=>Promise.reject({code:-1,msg:"请初始化HTTP请求方法主体"})){P(this,Y,void 0);P(this,K,void 0);P(this,te,void 0);P(this,N,{"#":new Map,$:new Map});P(this,I,new Map);w(this,"request",({url:e="/",method:t="GET",...n},s=!1)=>{var B;const l=t.toUpperCase(),u=ce(JSON.stringify([e,l,n])),$=(B=e==null?void 0:e.includes)!=null&&B.call(e,"/_/")?"#":"$",{promise:R,resolve:Q,reject:re}=Promise.withResolvers();return o(this,N)[$].has(u)?(console.log("cache",e),Q(o(this,N)[$].get(u))):o(this,I).has(u)?o(this,I).get(u).push([Q,re]):(o(this,I).set(u,[[Q,re]]),o(this,Y).call(this,{url:e,method:l,...n}).then(h=>{if(![0,1].includes(h.code))throw se(h.code,h.msg,h.data,e,h==null?void 0:h.res);return[h.code,h.msg,h.data,e,h==null?void 0:h.res]}).then(h=>((l==="GET"||$=="#")&&o(this,N)[$].set(u,h),l==="GET"&&!s&&setTimeout(()=>{o(this,N)[$].delete(u)},300),h)).then(h=>{var x;return(x=o(this,I).get(u))==null?void 0:x.forEach((f,i,p)=>{f&&f[0](h),delete p[i]})}).catch(h=>{var x;o(this,N)[$].delete(u),(x=o(this,I).get(u))==null||x.forEach((f,i,p)=>{f&&f[1](h instanceof ne?h:se(-1,h,null,e)),delete p[i]})}).finally(()=>o(this,I).delete(u))),new Proxy(R,{get:(h,x)=>(...f)=>h.then(i=>se(...i)[x](...f)).catch(i=>{if(!i instanceof ne)throw i;return typeof i[x]=="function"?i[x](...f):i[x]})})});w(this,"get",(e,t={})=>this.request({url:e,method:"GET",params:t}));w(this,"post",(e,t={},n={})=>this.request({url:e,method:"POST",data:t,params:n}));w(this,"put",(e,t={},n={})=>this.request({url:e,method:"PUT",data:t,params:n}));w(this,"del",(e,t={},n={})=>this.request({url:e,method:"DELETE",data:t,params:n}));w(this,"download",(e,t)=>{});w(this,"cache",(e,t={})=>this.request({url:e,method:"GET",params:t},!0));w(this,"list",(e,t={})=>this.get(`/api/${e}/${this.encode(t)}`));w(this,"getAppInfo",()=>{});w(this,"refreshCache",(e=!1)=>{e&&o(this,N)["#"].clear(),o(this,N).$.clear()});w(this,"decode",(e="",t={})=>{if(e===void 0||e===""||e===null)return t;try{const n=o(this,K).decode(e);return H.unpack(n)}catch{return console.warn("core.decode",e),t}});w(this,"encode",(e={})=>{const t=JSON.stringify(e,(n,s)=>s===void 0?null:s);return o(this,K).encode(H.pack(t))});m(this,te,e),m(this,Y,n),m(this,K,new Te(t))}}Y=new WeakMap,K=new WeakMap,te=new WeakMap,N=new WeakMap,I=new WeakMap;const fe=ie;ie.onUnhandledRejection=r=>{var e,t,n,s,l,u;r!=null&&r.IS_ECHO_MSG?((e=r==null?void 0:r.$echoMsg)==null||e.call(r),(t=r==null?void 0:r.preventDefault)==null||t.call(r)):(n=r.reason)!=null&&n.IS_ECHO_MSG&&((l=(s=r.reason)==null?void 0:s.$echoMsg)==null||l.call(s),(u=r==null?void 0:r.preventDefault)==null||u.call(r))},ie.onMsg=(r,e)=>[0,1].includes(r)?console.log(e):console.warn(e),c.default=fe,c.signature=ce,c.str2uint8array=le,c.trim=ye,c.uint8array2str=we,Object.defineProperties(c,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}); +(function(c,d){typeof exports=="object"&&typeof module<"u"?d(exports):typeof define=="function"&&define.amd?define(["exports"],d):(c=typeof globalThis<"u"?globalThis:c||self,d(c["ff-request"]={}))})(this,function(c){"use strict";var Se=Object.defineProperty;var xe=(c,d,b)=>d in c?Se(c,d,{enumerable:!0,configurable:!0,writable:!0,value:b}):c[d]=b;var w=(c,d,b)=>(xe(c,typeof d!="symbol"?d+"":d,b),b),he=(c,d,b)=>{if(!d.has(c))throw TypeError("Cannot "+b)};var o=(c,d,b)=>(he(c,d,"read from private field"),b?b.call(c):d.get(c)),P=(c,d,b)=>{if(d.has(c))throw TypeError("Cannot add the same private member more than once");d instanceof WeakSet?d.add(c):d.set(c,b)},N=(c,d,b,H)=>(he(c,d,"write to private field"),H?H.call(c,b):d.set(c,b),b);var G,J,D,j,X,Z,L,k,ee,z,V,Y,K,te,$,I;function d(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var b={};(function(r){(function(e){e([],function(){var t=-1,n=-2,s=-3,l=-4,u=-5,M=function(f,i){i=i||{};var p=i.verbose||!1;p&&console.log("Normalize the JSON Object"),f=typeof f=="string"?this.JSON.parse(f):f,p&&console.log("Creating a empty dictionary");var g={strings:[],integers:[],floats:[]};p&&console.log("Creating the AST");var v=function _(a){p&&console.log("Calling recursiveAstBuilder with "+this.JSON.stringify(a));var E=typeof a;if(a===null)return{type:"null",index:s};if(typeof a>"u")return{type:"undefined",index:u};if(a instanceof Array){var C=["@"];for(var T in a)a.hasOwnProperty(T)&&C.push(_(a[T]));return C}if(E==="object"){var C=["$"];for(var F in a)a.hasOwnProperty(F)&&(C.push(_(F)),C.push(_(a[F])));return C}if(a==="")return{type:"empty",index:l};if(E==="string"){var S=x.call(g.strings,a);return S==-1&&(g.strings.push(Q(a)),S=g.strings.length-1),{type:"strings",index:S}}if(E==="number"&&a%1===0){var S=x.call(g.integers,a);return S==-1&&(g.integers.push(B(a)),S=g.integers.length-1),{type:"integers",index:S}}if(E==="number"){var S=x.call(g.floats,a);return S==-1&&(g.floats.push(a),S=g.floats.length-1),{type:"floats",index:S}}if(E==="boolean")return{type:"boolean",index:a?t:n};throw new Error("Unexpected argument of type "+typeof a)}(f),O=g.strings.length,q=g.integers.length;g.floats.length,p&&console.log("Parsing the dictionary");var U=g.strings.join("|");return U+="^"+g.integers.join("|"),U+="^"+g.floats.join("|"),p&&console.log("Parsing the structure"),U+="^"+function _(a){if(p&&console.log("Calling a recursiveParser with "+this.JSON.stringify(a)),a instanceof Array){var E=a.shift();for(var C in a)a.hasOwnProperty(C)&&(E+=_(a[C])+"|");return(E[E.length-1]==="|"?E.slice(0,-1):E)+"]"}var T=a.type,F=a.index;if(T==="strings")return B(F);if(T==="integers")return B(O+F);if(T==="floats")return B(O+q+F);if(T==="boolean")return a.index;if(T==="null")return s;if(T==="undefined")return u;if(T==="empty")return l;throw new TypeError("The item is alien!")}(v),p&&console.log("Ending parser"),i.debug?{dictionary:g,ast:v,packed:U}:U},R=function(f,i){i=i||{};var p=f.split("^");i.verbose&&console.log("Building dictionary");var g=[],v=p[0];if(v!==""){v=v.split("|"),i.verbose&&console.log("Parse the strings dictionary");for(var O=0,q=v.length;Oo(this,X).call(this,t),ownKeys:()=>Object.keys(o(this,j).getPrototypeOf()||{}),getPrototypeOf:()=>o(this,J)?this:this.data,getOwnPropertyDescriptor:()=>({configurable:!0,enumerable:!0,writable:!0,value:o(this,j).getPrototypeOf()})});P(this,X,e=>e==="$echoMsg"?o(this,L):e==="msg"?o(this,Z):e==="then"||e==="resp"?(N(this,D,!0),N(this,J,e==="resp"),o(this,k)):e==="catch"?o(this,ee):e==="IS_ECHO_MSG"?o(this,D):Reflect.get(this,e));P(this,Z,(e=n=>n,t=!1)=>(o(this,L).call(this),N(this,J,t),Promise.resolve(e==null?void 0:e(o(this,j).getPrototypeOf()))));P(this,L,()=>{o(this,D)&&(N(this,D,!1),fe.onMsg(this.code,this.message))});P(this,k,e=>[0,1].includes(this.code)?Promise.resolve(e==null?void 0:e(o(this,j).getPrototypeOf())):Promise.reject(o(this,G)));P(this,ee,e=>Promise.resolve(e(o(this,G))));return this.code=e,this.message=t,this.data=n,this.url=s,this.res=l,N(this,G,new Proxy(this,o(this,j)))}}G=new WeakMap,J=new WeakMap,D=new WeakMap,j=new WeakMap,X=new WeakMap,Z=new WeakMap,L=new WeakMap,k=new WeakMap,ee=new WeakMap;const se=(r,e,t,n="/",s="")=>new ne(r,e,t,n,s);var oe=["utf8","utf-8","unicode-1-1-utf-8"];function de(r){if(oe.indexOf(r)<0&&typeof r<"u"&&r!=null)throw new RangeError("Invalid encoding type. Only utf-8 is supported");this.encoding="utf-8",this.encode=function(e){if(typeof e!="string")throw new TypeError("passed argument must be of tye string");var t=unescape(encodeURIComponent(e)),n=new Uint8Array(t.length);const s=t.split("");for(let l=0;l"u")return"";var n=typeof t<"u"&&n in t?t.stream:!1;if(typeof n!="boolean")throw new TypeError("stream option must be boolean");if(ArrayBuffer.isView(e)){var s=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),l=new Array(s.length);for(let u=0;u{let e=5381;for(let t=0;t>>0).toString(16)},ye=(r,e)=>r.replace(new RegExp(`^${e}+|${e}+$`,"g"),""),le=r=>pe.encode(r||""),we=r=>ve.decode(new DataView(r),{}),be=62,W=30,ue=31,Ee=63;class Te{constructor(e){w(this,"encodeTable",[]);w(this,"decodeMap",new Uint8Array(256).fill(255));if(e.length!==be)throw new Error("Encoding alphabet must be 62 characters long");if(e.includes(` +`)||e.includes("\r"))throw new Error("Encoding alphabet contains newline character");this.encodeTable=e.split(""),this.decodeMap=new Uint8Array(256).fill(255);for(let t=0;t>3;e===0&&(t-=1,e=8);let n=this.src[t]>>8-e;return e<6&&t>0&&(n|=this.src[t-1]<0;){let n=6,s=this.get6bits();(s&W)===W&&((this.pos>6||s>ue)&&(n=5),s&=ue),t.push(o(this,z).encodeTable[s].charCodeAt(0)),this.pos-=n}return t}}z=new WeakMap;class Pe{constructor(e){P(this,V,null);N(this,V,e)}decode(e){const t=new Uint8Array(Math.ceil(e.length*6/8)+1);let n=t.length,s=0,l=0;for(let u=0;u=8&&(n--,t[n]=l&255,s%=8,l>>=8)}return s>0&&(n--,t[n]=l&255),t.slice(n)}}V=new WeakMap,Promise.withResolvers||(Promise.withResolvers=function(){let r,e;return{promise:new Promise((n,s)=>{r=n,e=s}),resolve:r,reject:e}});class ie{constructor(e,t,n=({})=>Promise.reject({code:-1,msg:"请初始化HTTP请求方法主体"})){P(this,Y,void 0);P(this,K,void 0);P(this,te,void 0);P(this,$,{"#":new Map,$:new Map});P(this,I,new Map);w(this,"request",({url:e="/",method:t="GET",...n},s=!1)=>{var B;const l=t.toUpperCase(),u=ce(JSON.stringify([e,l,n])),M=(B=e==null?void 0:e.includes)!=null&&B.call(e,"/_/")?"#":"$",{promise:R,resolve:Q,reject:re}=Promise.withResolvers();return o(this,$)[M].has(u)?(console.log("cache",e),Q(o(this,$)[M].get(u))):o(this,I).has(u)?o(this,I).get(u).push([Q,re]):(o(this,I).set(u,[[Q,re]]),o(this,Y).call(this,{url:e,method:l,...n}).then(h=>{if(![0,1].includes(h.code))throw se(h.code,h.msg,h.data,e,h==null?void 0:h.res);return[h.code,h.msg,h.data,e,h==null?void 0:h.res]}).then(h=>((M=="#"||l=="GET")&&o(this,$)[M].set(u,h),M!="#"&&l=="GET"&&!s&&setTimeout(()=>{o(this,$)[M].delete(u)},300),h)).then(h=>{var x;return(x=o(this,I).get(u))==null?void 0:x.forEach((f,i,p)=>{f&&f[0](h),delete p[i]})}).catch(h=>{var x;o(this,$)[M].delete(u),(x=o(this,I).get(u))==null||x.forEach((f,i,p)=>{f&&f[1](h instanceof ne?h:se(-1,h,null,e)),delete p[i]})}).finally(()=>o(this,I).delete(u))),new Proxy(R,{get:(h,x)=>(...f)=>h.then(i=>se(...i)[x](...f)).catch(i=>{if(!i instanceof ne)throw i;return typeof i[x]=="function"?i[x](...f):i[x]})})});w(this,"get",(e,t={})=>this.request({url:e,method:"GET",params:t}));w(this,"post",(e,t={},n={})=>this.request({url:e,method:"POST",data:t,params:n}));w(this,"put",(e,t={},n={})=>this.request({url:e,method:"PUT",data:t,params:n}));w(this,"del",(e,t={},n={})=>this.request({url:e,method:"DELETE",data:t,params:n}));w(this,"download",(e,t)=>{});w(this,"cache",(e,t={})=>this.request({url:e,method:"GET",params:t},!0));w(this,"list",(e,t={})=>this.get(`/api/${e}/${this.encode(t)}`));w(this,"getAppInfo",()=>{});w(this,"refreshCache",(e=!1)=>{e&&o(this,$)["#"].clear(),o(this,$).$.clear()});w(this,"decode",(e="",t={})=>{if(e===void 0||e===""||e===null)return t;try{const n=o(this,K).decode(e);return H.unpack(n)}catch{return console.warn("core.decode",e),t}});w(this,"encode",(e={})=>{const t=JSON.stringify(e,(n,s)=>s===void 0?null:s);return o(this,K).encode(H.pack(t))});N(this,te,e),N(this,Y,n),N(this,K,new Te(t))}}Y=new WeakMap,K=new WeakMap,te=new WeakMap,$=new WeakMap,I=new WeakMap;const fe=ie;ie.onUnhandledRejection=r=>{var e,t,n,s,l,u;r!=null&&r.IS_ECHO_MSG?((e=r==null?void 0:r.$echoMsg)==null||e.call(r),(t=r==null?void 0:r.preventDefault)==null||t.call(r)):(n=r.reason)!=null&&n.IS_ECHO_MSG&&((l=(s=r.reason)==null?void 0:s.$echoMsg)==null||l.call(s),(u=r==null?void 0:r.preventDefault)==null||u.call(r))},ie.onMsg=(r,e)=>[0,1].includes(r)?console.log(e):console.warn(e),c.default=fe,c.signature=ce,c.str2uint8array=le,c.trim=ye,c.uint8array2str=we,Object.defineProperties(c,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});