diff --git a/dist/ff-request.js b/dist/ff-request.js index 6e1d4e8..3d192ed 100644 --- a/dist/ff-request.js +++ b/dist/ff-request.js @@ -1,147 +1,147 @@ var ae = Object.defineProperty; -var ie = (t, e, r) => e in t ? ae(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r; -var A = (t, e, r) => (ie(t, typeof e != "symbol" ? e + "" : e, r), r), k = (t, e, r) => { +var oe = (t, e, r) => e in t ? ae(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r; +var A = (t, e, r) => (oe(t, typeof e != "symbol" ? e + "" : e, r), r), k = (t, e, r) => { if (!e.has(t)) throw TypeError("Cannot " + r); }; -var f = (t, e, r) => (k(t, e, "read from private field"), r ? r.call(t) : e.get(t)), _ = (t, e, r) => { +var l = (t, e, r) => (k(t, e, "read from private field"), r ? r.call(t) : e.get(t)), S = (t, e, r) => { if (e.has(t)) throw TypeError("Cannot add the same private member more than once"); e instanceof WeakSet ? e.add(t) : e.set(t, r); -}, M = (t, e, r, n) => (k(t, e, "write to private field"), n ? n.call(t, r) : e.set(t, r), r); +}, $ = (t, e, r, n) => (k(t, e, "write to private field"), n ? n.call(t, r) : e.set(t, r), r); function te(t) { return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t; } -function oe(t) { +function ie(t) { if (t.length >= 255) throw new TypeError("Alphabet too long"); for (var e = new Uint8Array(256), r = 0; r < e.length; r++) e[r] = 255; for (var n = 0; n < t.length; n++) { - var h = t.charAt(n), v = h.charCodeAt(0); - if (e[v] !== 255) - throw new TypeError(h + " is ambiguous"); - e[v] = n; + var u = t.charAt(n), p = u.charCodeAt(0); + if (e[p] !== 255) + throw new TypeError(u + " is ambiguous"); + e[p] = n; } - var u = t.length, N = t.charAt(0), B = Math.log(u) / Math.log(256), j = Math.log(256) / Math.log(u); - function m(a) { - if (a instanceof Uint8Array || (ArrayBuffer.isView(a) ? a = new Uint8Array(a.buffer, a.byteOffset, a.byteLength) : Array.isArray(a) && (a = Uint8Array.from(a))), !(a instanceof Uint8Array)) + var d = t.length, U = t.charAt(0), B = Math.log(d) / Math.log(256), D = Math.log(256) / Math.log(d); + function q(f) { + if (f instanceof Uint8Array || (ArrayBuffer.isView(f) ? f = new Uint8Array(f.buffer, f.byteOffset, f.byteLength) : Array.isArray(f) && (f = Uint8Array.from(f))), !(f instanceof Uint8Array)) throw new TypeError("Expected Uint8Array"); - if (a.length === 0) + if (f.length === 0) return ""; - for (var i = 0, c = 0, g = 0, o = a.length; g !== o && a[g] === 0; ) - g++, i++; - for (var l = (o - g) * j + 1 >>> 0, d = new Uint8Array(l); g !== o; ) { - for (var T = a[g], E = 0, w = l - 1; (T !== 0 || E < c) && w !== -1; w--, E++) - T += 256 * d[w] >>> 0, d[w] = T % u >>> 0, T = T / u >>> 0; + for (var a = 0, o = 0, c = 0, i = f.length; c !== i && f[c] === 0; ) + c++, a++; + for (var h = (i - c) * D + 1 >>> 0, g = new Uint8Array(h); c !== i; ) { + for (var T = f[c], E = 0, w = h - 1; (T !== 0 || E < o) && w !== -1; w--, E++) + T += 256 * g[w] >>> 0, g[w] = T % d >>> 0, T = T / d >>> 0; if (T !== 0) throw new Error("Non-zero carry"); - c = E, g++; + o = E, c++; } - for (var s = l - c; s !== l && d[s] === 0; ) + for (var s = h - o; s !== h && g[s] === 0; ) s++; - for (var y = N.repeat(i); s < l; ++s) - y += t.charAt(d[s]); + for (var y = U.repeat(a); s < h; ++s) + y += t.charAt(g[s]); return y; } - function S(a) { - if (typeof a != "string") + function x(f) { + if (typeof f != "string") throw new TypeError("Expected String"); - if (a.length === 0) + if (f.length === 0) return new Uint8Array(); - for (var i = 0, c = 0, g = 0; a[i] === N; ) - c++, i++; - for (var o = (a.length - i) * B + 1 >>> 0, l = new Uint8Array(o); a[i]; ) { - var d = e[a.charCodeAt(i)]; - if (d === 255) + for (var a = 0, o = 0, c = 0; f[a] === U; ) + o++, a++; + for (var i = (f.length - a) * B + 1 >>> 0, h = new Uint8Array(i); f[a]; ) { + var g = e[f.charCodeAt(a)]; + if (g === 255) return; - for (var T = 0, E = o - 1; (d !== 0 || T < g) && E !== -1; E--, T++) - d += u * l[E] >>> 0, l[E] = d % 256 >>> 0, d = d / 256 >>> 0; - if (d !== 0) + for (var T = 0, E = i - 1; (g !== 0 || T < c) && E !== -1; E--, T++) + g += d * h[E] >>> 0, h[E] = g % 256 >>> 0, g = g / 256 >>> 0; + if (g !== 0) throw new Error("Non-zero carry"); - g = T, i++; + c = T, a++; } - for (var w = o - g; w !== o && l[w] === 0; ) + for (var w = i - c; w !== i && h[w] === 0; ) w++; - for (var s = new Uint8Array(c + (o - w)), y = c; w !== o; ) - s[y++] = l[w++]; + for (var s = new Uint8Array(o + (i - w)), y = o; w !== i; ) + s[y++] = h[w++]; return s; } - function p(a) { - var i = S(a); - if (i) - return i; - throw new Error("Non-base" + u + " character"); + function v(f) { + var a = x(f); + if (a) + return a; + throw new Error("Non-base" + d + " character"); } return { - encode: m, - decodeUnsafe: S, - decode: p + encode: q, + decodeUnsafe: x, + decode: v }; } -var fe = oe; +var fe = ie; const he = /* @__PURE__ */ te(fe); var re = {}; (function(t) { (function(e) { e([], function() { - var r = -1, n = -2, h = -3, v = -4, u = -5, N = function(i, c) { - c = c || {}; - var g = c.verbose || !1; - g && console.log("Normalize the JSON Object"), i = typeof i == "string" ? this.JSON.parse(i) : i, g && console.log("Creating a empty dictionary"); - var o = { + var r = -1, n = -2, u = -3, p = -4, d = -5, U = function(a, o) { + o = o || {}; + var c = o.verbose || !1; + c && console.log("Normalize the JSON Object"), a = typeof a == "string" ? this.JSON.parse(a) : a, c && console.log("Creating a empty dictionary"); + var i = { strings: [], integers: [], floats: [] }; - g && console.log("Creating the AST"); - var l = function w(s) { - g && console.log("Calling recursiveAstBuilder with " + this.JSON.stringify(s)); + c && console.log("Creating the AST"); + var h = function w(s) { + c && console.log("Calling recursiveAstBuilder with " + this.JSON.stringify(s)); var y = typeof s; if (s === null) return { type: "null", - index: h + index: u }; if (typeof s > "u") return { type: "undefined", - index: u + index: d }; if (s instanceof Array) { - var U = ["@"]; + var _ = ["@"]; for (var O in s) - s.hasOwnProperty(O) && U.push(w(s[O])); - return U; + s.hasOwnProperty(O) && _.push(w(s[O])); + return _; } if (y === "object") { - var U = ["$"]; + var _ = ["$"]; for (var R in s) - s.hasOwnProperty(R) && (U.push(w(R)), U.push(w(s[R]))); - return U; + s.hasOwnProperty(R) && (_.push(w(R)), _.push(w(s[R]))); + return _; } if (s === "") return { type: "empty", - index: v + index: p }; if (y === "string") { - var P = a.call(o.strings, s); - return P == -1 && (o.strings.push(j(s)), P = o.strings.length - 1), { + var P = f.call(i.strings, s); + return P == -1 && (i.strings.push(D(s)), P = i.strings.length - 1), { type: "strings", index: P }; } if (y === "number" && s % 1 === 0) { - var P = a.call(o.integers, s); - return P == -1 && (o.integers.push(S(s)), P = o.integers.length - 1), { + var P = f.call(i.integers, s); + return P == -1 && (i.integers.push(x(s)), P = i.integers.length - 1), { type: "integers", index: P }; } if (y === "number") { - var P = a.call(o.floats, s); - return P == -1 && (o.floats.push(s), P = o.floats.length - 1), { + var P = f.call(i.floats, s); + return P == -1 && (i.floats.push(s), P = i.floats.length - 1), { type: "floats", index: P }; @@ -152,209 +152,209 @@ var re = {}; index: s ? r : n }; throw new Error("Unexpected argument of type " + typeof s); - }(i), d = o.strings.length, T = o.integers.length; - o.floats.length, g && console.log("Parsing the dictionary"); - var E = o.strings.join("|"); - return E += "^" + o.integers.join("|"), E += "^" + o.floats.join("|"), g && console.log("Parsing the structure"), E += "^" + function w(s) { - if (g && console.log("Calling a recursiveParser with " + this.JSON.stringify(s)), s instanceof Array) { + }(a), g = i.strings.length, T = i.integers.length; + i.floats.length, c && console.log("Parsing the dictionary"); + var E = i.strings.join("|"); + return E += "^" + i.integers.join("|"), E += "^" + i.floats.join("|"), c && console.log("Parsing the structure"), E += "^" + function w(s) { + if (c && console.log("Calling a recursiveParser with " + this.JSON.stringify(s)), s instanceof Array) { var y = s.shift(); - for (var U in s) - s.hasOwnProperty(U) && (y += w(s[U]) + "|"); + for (var _ in s) + s.hasOwnProperty(_) && (y += w(s[_]) + "|"); return (y[y.length - 1] === "|" ? y.slice(0, -1) : y) + "]"; } var O = s.type, R = s.index; if (O === "strings") - return S(R); + return x(R); if (O === "integers") - return S(d + R); + return x(g + R); if (O === "floats") - return S(d + T + R); + return x(g + T + R); if (O === "boolean") return s.index; if (O === "null") - return h; - if (O === "undefined") return u; + if (O === "undefined") + return d; if (O === "empty") - return v; + return p; throw new TypeError("The item is alien!"); - }(l), g && console.log("Ending parser"), c.debug ? { - dictionary: o, - ast: l, + }(h), c && console.log("Ending parser"), o.debug ? { + dictionary: i, + ast: h, packed: E } : E; - }, B = function(i, c) { - c = c || {}; - var g = i.split("^"); - c.verbose && console.log("Building dictionary"); - var o = [], l = g[0]; - if (l !== "") { - l = l.split("|"), c.verbose && console.log("Parse the strings dictionary"); - for (var d = 0, T = l.length; d < T; d++) - o.push(m(l[d])); + }, B = function(a, o) { + o = o || {}; + var c = a.split("^"); + o.verbose && console.log("Building dictionary"); + var i = [], h = c[0]; + if (h !== "") { + h = h.split("|"), o.verbose && console.log("Parse the strings dictionary"); + for (var g = 0, T = h.length; g < T; g++) + i.push(q(h[g])); } - if (l = g[1], l !== "") { - l = l.split("|"), c.verbose && console.log("Parse the integers dictionary"); - for (var d = 0, T = l.length; d < T; d++) - o.push(p(l[d])); + if (h = c[1], h !== "") { + h = h.split("|"), o.verbose && console.log("Parse the integers dictionary"); + for (var g = 0, T = h.length; g < T; g++) + i.push(v(h[g])); } - if (l = g[2], l !== "") { - l = l.split("|"), c.verbose && console.log("Parse the floats dictionary"); - for (var d = 0, T = l.length; d < T; d++) - o.push(parseFloat(l[d])); + if (h = c[2], h !== "") { + h = h.split("|"), o.verbose && console.log("Parse the floats dictionary"); + for (var g = 0, T = h.length; g < T; g++) + i.push(parseFloat(h[g])); } - l = null, c.verbose && console.log("Tokenizing the structure"); - for (var E = "", w = [], s = g[3].length, d = 0; d < s; d++) { - var y = g[3].charAt(d); - y === "|" || y === "$" || y === "@" || y === "]" ? (E && (w.push(p(E)), E = ""), y !== "|" && w.push(y)) : E += y; + h = null, o.verbose && console.log("Tokenizing the structure"); + for (var E = "", w = [], s = c[3].length, g = 0; g < s; g++) { + var y = c[3].charAt(g); + y === "|" || y === "$" || y === "@" || y === "]" ? (E && (w.push(v(E)), E = ""), y !== "|" && w.push(y)) : E += y; } - var U = w.length, O = 0; - return c.verbose && console.log("Starting recursive parser"), function R() { + var _ = w.length, O = 0; + return o.verbose && console.log("Starting recursive parser"), function R() { var P = w[O++]; - if (c.verbose && console.log("Reading collection type " + (P === "$" ? "object" : "Array")), P === "@") { - for (var b = []; O < U; O++) { - var C = w[O]; - if (c.verbose && console.log("Read " + C + " symbol"), C === "]") + if (o.verbose && console.log("Reading collection type " + (P === "$" ? "object" : "Array")), P === "@") { + for (var b = []; O < _; O++) { + var N = w[O]; + if (o.verbose && console.log("Read " + N + " symbol"), N === "]") return b; - if (C === "@" || C === "$") + if (N === "@" || N === "$") b.push(R()); else - switch (C) { + switch (N) { case r: b.push(!0); break; case n: b.push(!1); break; - case h: + case u: b.push(null); break; - case u: + case d: b.push(void 0); break; - case v: + case p: b.push(""); break; default: - b.push(o[C]); + b.push(i[N]); } } - return c.verbose && console.log("Parsed " + this.JSON.stringify(b)), b; + return o.verbose && console.log("Parsed " + this.JSON.stringify(b)), b; } if (P === "$") { - for (var b = {}; O < U; O++) { - var x = w[O]; - if (x === "]") + for (var b = {}; O < _; O++) { + var C = w[O]; + if (C === "]") return b; - x === v ? x = "" : x = o[x]; - var C = w[++O]; - if (C === "@" || C === "$") - b[x] = R(); + C === p ? C = "" : C = i[C]; + var N = w[++O]; + if (N === "@" || N === "$") + b[C] = R(); else - switch (C) { + switch (N) { case r: - b[x] = !0; + b[C] = !0; break; case n: - b[x] = !1; - break; - case h: - b[x] = null; + b[C] = !1; break; case u: - b[x] = void 0; + b[C] = null; break; - case v: - b[x] = ""; + case d: + b[C] = void 0; + break; + case p: + b[C] = ""; break; default: - b[x] = o[C]; + b[C] = i[N]; } } - return c.verbose && console.log("Parsed " + this.JSON.stringify(b)), b; + return o.verbose && console.log("Parsed " + this.JSON.stringify(b)), b; } throw new TypeError("Bad token " + P + " isn't a type"); }(); - }, j = function(i) { - return typeof i != "string" ? i : i.replace(/[\+ \|\^\%]/g, function(c) { + }, D = function(a) { + return typeof a != "string" ? a : a.replace(/[\+ \|\^\%]/g, function(o) { return { " ": "+", "+": "%2B", "|": "%7C", "^": "%5E", "%": "%25" - }[c]; + }[o]; }); - }, m = function(i) { - return typeof i != "string" ? i : i.replace(/\+|%2B|%7C|%5E|%25/g, function(c) { + }, q = function(a) { + return typeof a != "string" ? a : a.replace(/\+|%2B|%7C|%5E|%25/g, function(o) { return { "+": " ", "%2B": "+", "%7C": "|", "%5E": "^", "%25": "%" - }[c]; + }[o]; }); - }, S = function(i) { - return Number.prototype.toString.call(i, 36).toUpperCase(); - }, p = function(i) { - return parseInt(i, 36); - }, a = Array.prototype.indexOf || function(i, c) { - for (var g = c || 0, o = this.length; g < o; g++) - if (this[g] === i) - return g; + }, x = function(a) { + return Number.prototype.toString.call(a, 36).toUpperCase(); + }, v = function(a) { + return parseInt(a, 36); + }, f = Array.prototype.indexOf || function(a, o) { + for (var c = o || 0, i = this.length; c < i; c++) + if (this[c] === a) + return c; return -1; }; return { JSON, - pack: N, + pack: U, unpack: B }; }); })(function(e, r) { var n = r(); - for (var h in n) - t[h] = n[h]; + for (var u in n) + t[u] = n[u]; }); })(re); const ee = /* @__PURE__ */ te(re); -var q, z, J, D, L, H, K, V, Y; +var J, z, j, I, L, H, K, V, Y; class X { - constructor(e, r, n, h, v) { + constructor(e, r, n, u, p) { A(this, "code", 0); A(this, "message", "操作成功"); A(this, "data", null); A(this, "url", ""); A(this, "res", ""); // static [Symbol.hasInstance](self) { return self?.IS_ECHO_MSG !== undefined } - _(this, q, null); + S(this, J, null); // 判断返回 Response 对象, 还是 Response 中的 data - _(this, z, !0); + S(this, z, !0); // 判罚是否已经给出错误提示 - _(this, J, !0); - _(this, D, { - get: (e, r) => f(this, L).call(this, r), - ownKeys: () => Object.keys(f(this, D).getPrototypeOf() || {}), - getPrototypeOf: () => f(this, z) ? this : this.data, + S(this, j, !0); + S(this, I, { + get: (e, r) => l(this, L).call(this, r), + ownKeys: () => Object.keys(l(this, I).getPrototypeOf() || {}), + getPrototypeOf: () => l(this, z) ? this : this.data, getOwnPropertyDescriptor: () => ({ configurable: !0, enumerable: !0, writable: !0, - value: f(this, D).getPrototypeOf() + value: l(this, I).getPrototypeOf() }) }); - _(this, L, (e) => e === "$toast" ? f(this, K) : e === "msg" ? f(this, H) : e === "then" || e === "resp" ? (M(this, J, !0), M(this, z, e === "resp"), f(this, V)) : e === "catch" ? f(this, Y) : e === "IS_ECHO_MSG" ? f(this, J) : Reflect.get(this, e)); - _(this, H, (e = (n) => n, r = !1) => (f(this, K).call(this), M(this, z, r), Promise.resolve(e == null ? void 0 : e(f(this, D).getPrototypeOf())))); - _(this, K, () => { - f(this, J) && (M(this, J, !1), we.onToast(this.code, this.message)); + S(this, L, (e) => e === "$toast" ? l(this, K) : e === "msg" ? l(this, H) : e === "then" || e === "resp" ? ($(this, j, !0), $(this, z, e === "resp"), l(this, V)) : e === "catch" ? l(this, Y) : e === "IS_ECHO_MSG" ? l(this, j) : Reflect.get(this, e)); + S(this, H, (e = (n) => n, r = !1) => (l(this, K).call(this), $(this, z, r), Promise.resolve(e == null ? void 0 : e(l(this, I).getPrototypeOf())))); + S(this, K, () => { + l(this, j) && ($(this, j, !1), we.onToast(this.code, this.message)); }); - _(this, V, (e) => [0, 1].includes(this.code) ? Promise.resolve(e == null ? void 0 : e(f(this, D).getPrototypeOf())) : Promise.reject(f(this, q))); - _(this, Y, (e) => Promise.resolve(e(f(this, q)))); - return this.code = e, this.message = r, this.data = n, this.url = h, this.res = v, M(this, q, new Proxy(this, f(this, D))); + S(this, V, (e) => [0, 1].includes(this.code) ? Promise.resolve(e == null ? void 0 : e(l(this, I).getPrototypeOf())) : Promise.reject(l(this, J))); + S(this, Y, (e) => Promise.resolve(e(l(this, J)))); + return this.code = e, this.message = r, this.data = n, this.url = u, this.res = p, $(this, J, new Proxy(this, l(this, I))); } } -q = new WeakMap(), z = new WeakMap(), J = new WeakMap(), D = new WeakMap(), L = new WeakMap(), H = new WeakMap(), K = new WeakMap(), V = new WeakMap(), Y = new WeakMap(); -const W = (t, e, r, n = "/", h = "") => new X(t, e, r, n, h); +J = new WeakMap(), z = new WeakMap(), j = new WeakMap(), I = new WeakMap(), L = new WeakMap(), H = new WeakMap(), K = new WeakMap(), V = new WeakMap(), Y = new WeakMap(); +const W = (t, e, r, n = "/", u = "") => new X(t, e, r, n, u); var ne = [ "utf8", "utf-8", @@ -367,9 +367,9 @@ function le(t) { if (typeof e != "string") throw new TypeError("passed argument must be of tye string"); var r = unescape(encodeURIComponent(e)), n = new Uint8Array(r.length); - const h = r.split(""); - for (let v = 0; v < h.length; v++) - n[v] = h[v].charCodeAt(0); + const u = r.split(""); + for (let p = 0; p < u.length; p++) + n[p] = u[p].charCodeAt(0); return n; }; } @@ -383,10 +383,10 @@ function ue(t) { if (typeof n != "boolean") throw new TypeError("stream option must be boolean"); if (ArrayBuffer.isView(e)) { - var h = new Uint8Array(e.buffer, e.byteOffset, e.byteLength), v = new Array(h.length); - for (let u = 0; u < h.length; u++) - v[u] = String.fromCharCode(h[u]); - return decodeURIComponent(escape(v.join(""))); + var u = new Uint8Array(e.buffer, e.byteOffset, e.byteLength), p = new Array(u.length); + for (let d = 0; d < u.length; d++) + p[d] = String.fromCharCode(u[d]); + return decodeURIComponent(escape(p.join(""))); } else throw new TypeError("passed argument must be an array buffer view"); }; @@ -400,34 +400,32 @@ const ce = new se.TextEncoder("utf8"), ge = new se.TextDecoder("utf8"), de = (t) for (let r = 0; r < t.length; r++) e = e * 33 ^ t.charCodeAt(r); return (e >>> 0).toString(16); -}, be = (t, e) => t.replace(new RegExp(`^${e}+|${e}+$`, "g"), ""), pe = (t) => ce.encode(t || ""), ve = (t) => ge.decode(new DataView(t), {}); -var F, G, Q, $, I; +}, be = (t, e) => t.replace(new RegExp(`^${e}+|${e}+$`, "g"), ""), ve = (t) => ce.encode(t || ""), pe = (t) => ge.decode(new DataView(t), {}); +var F, G, Q, m, M; class Z { constructor(e, r, n = ({}) => Promise.reject({ code: -1, msg: "请初始化HTTP请求方法主体" })) { - _(this, F, void 0); - _(this, G, void 0); - _(this, Q, void 0); - _(this, $, { + S(this, F, void 0); + S(this, G, void 0); + S(this, Q, void 0); + S(this, m, { "#": /* @__PURE__ */ new Map(), // 系统缓存 $: /* @__PURE__ */ new Map() // 普通缓存 }); - _(this, I, /* @__PURE__ */ new Map()); - A(this, "request", ({ url: e = "/", method: r = "GET", ...n }, h = !1) => { - var j; - const v = r.toUpperCase(), u = de(JSON.stringify([e, v, n])), N = (j = e == null ? void 0 : e.includes) != null && j.call(e, "/_/") ? "#" : "$", B = new Promise((m, S) => { - !h && N !== "#" && f(this, $)[N].delete(u), f(this, $)[N].has(u) ? (console.log("缓存命中", e), m(f(this, $)[N].get(u))) : f(this, I).has(u) ? f(this, I).get(u).push([m, S]) : (f(this, I).set(u, [[m, S]]), f(this, F).call(this, { url: e, method: v, ...n }).then((p) => { - if (![0, 1].includes(p.code)) - throw W(p.code, p.msg, p.data, e, p == null ? void 0 : p.res); - return [p.code, p.msg, p.data, e, p == null ? void 0 : p.res]; - }).then((p) => ((N == "#" || h && v === "GET") && f(this, $)[N].set(u, p), p)).then((p) => f(this, I).get(u).forEach(([a, i]) => a(p))).catch((p) => (f(this, $)[N].delete(u), f(this, I).get(u).forEach(([a, i]) => i(p instanceof X ? p : W(-1, p, null, e))))).finally(() => f(this, I).delete(u))); - }); - return new Proxy(B, { - get: (m, S) => (...p) => m.then((a) => W(...a)[S](...p)).catch((a) => { - if (!a instanceof X) - throw a; - return typeof a[S] == "function" ? a[S](...p) : a[S]; + S(this, M, /* @__PURE__ */ new Map()); + A(this, "request", ({ url: e = "/", method: r = "GET", ...n }, u = !1) => { + var x; + const p = r.toUpperCase(), d = de(JSON.stringify([e, p, n])), U = (x = e == null ? void 0 : e.includes) != null && x.call(e, "/_/") ? "#" : "$", { p: B, resolve: D, reject: q } = Promise.withResolvers(); + return l(this, m)[U].has(d) ? (console.log("缓存命中", e), D(l(this, m)[U].get(d))) : l(this, M).has(d) ? l(this, M).get(d).push([D, q]) : (l(this, M).set(d, [[D, q]]), l(this, F).call(this, { url: e, method: p, ...n }).then((v) => { + if (![0, 1].includes(v.code)) + throw W(v.code, v.msg, v.data, e, v == null ? void 0 : v.res); + return [v.code, v.msg, v.data, e, v == null ? void 0 : v.res]; + }).then((v) => ((U == "#" || u && p === "GET") && l(this, m)[U].set(d, v), v)).then((v) => l(this, M).get(d).forEach(([f, a]) => f(v))).catch((v) => (l(this, m)[U].delete(d), l(this, M).get(d).forEach(([f, a]) => a(v instanceof X ? v : W(-1, v, null, e))))).finally(() => l(this, M).delete(d))), new Proxy(B, { + get: (v, f) => (...a) => v.then((o) => W(...o)[f](...a)).catch((o) => { + if (!o instanceof X) + throw o; + return typeof o[f] == "function" ? o[f](...a) : o[f]; }) }); }); @@ -442,36 +440,36 @@ class Z { A(this, "getAppInfo", () => { }); A(this, "refreshCache", (e = !1) => { - e && f(this, $)["#"].clear(), f(this, $).$.clear(); + e && l(this, m)["#"].clear(), l(this, m).$.clear(); }); A(this, "decode", (e = "", r = {}) => { if (e === void 0 || e === "" || e === null) return r; try { - const n = f(this, G).decode(e).buffer; - return ee.unpack(ve(n)); + const n = l(this, G).decode(e).buffer; + return ee.unpack(pe(n)); } catch { return console.warn("core.decode", e), r; } }); A(this, "encode", (e = {}) => { - const r = JSON.stringify(e, (n, h) => h === void 0 ? null : h); - return f(this, G).encode(pe(ee.pack(r))); + const r = JSON.stringify(e, (n, u) => u === void 0 ? null : u); + return l(this, G).encode(ve(ee.pack(r))); }); - M(this, Q, e), M(this, F, n), M(this, G, he(r)); + $(this, Q, e), $(this, F, n), $(this, G, he(r)); } } -F = new WeakMap(), G = new WeakMap(), Q = new WeakMap(), $ = new WeakMap(), I = new WeakMap(); +F = new WeakMap(), G = new WeakMap(), Q = new WeakMap(), m = new WeakMap(), M = new WeakMap(); const we = Z; Z.onUnhandledRejection = (t) => { - var e, r, n, h, v, u; - t != null && t.IS_ECHO_MSG ? ((e = t == null ? void 0 : t.$toast) == null || e.call(t), (r = t == null ? void 0 : t.preventDefault) == null || r.call(t)) : (n = t.reason) != null && n.IS_ECHO_MSG && ((v = (h = t.reason) == null ? void 0 : h.$toast) == null || v.call(h), (u = t == null ? void 0 : t.preventDefault) == null || u.call(t)); + var e, r, n, u, p, d; + t != null && t.IS_ECHO_MSG ? ((e = t == null ? void 0 : t.$toast) == null || e.call(t), (r = t == null ? void 0 : t.preventDefault) == null || r.call(t)) : (n = t.reason) != null && n.IS_ECHO_MSG && ((p = (u = t.reason) == null ? void 0 : u.$toast) == null || p.call(u), (d = t == null ? void 0 : t.preventDefault) == null || d.call(t)); }; Z.onToast = (t, e) => [0, 1].includes(t) ? console.log(e) : console.warn(e); export { we as default, de as signature, - pe as str2uint8array, + ve as str2uint8array, be as trim, - ve as uint8array2str + pe as uint8array2str }; diff --git a/dist/ff-request.umd.cjs b/dist/ff-request.umd.cjs index 7cd54d5..f9affea 100644 --- a/dist/ff-request.umd.cjs +++ b/dist/ff-request.umd.cjs @@ -1 +1 @@ -(function(p,w){typeof exports=="object"&&typeof module<"u"?w(exports):typeof define=="function"&&define.amd?define(["exports"],w):(p=typeof globalThis<"u"?globalThis:p||self,w(p["ff-request"]={}))})(this,function(p){"use strict";var ye=Object.defineProperty;var be=(p,w,_)=>w in p?ye(p,w,{enumerable:!0,configurable:!0,writable:!0,value:_}):p[w]=_;var P=(p,w,_)=>(be(p,typeof w!="symbol"?w+"":w,_),_),le=(p,w,_)=>{if(!w.has(p))throw TypeError("Cannot "+_)};var f=(p,w,_)=>(le(p,w,"read from private field"),_?_.call(p):w.get(p)),C=(p,w,_)=>{if(w.has(p))throw TypeError("Cannot add the same private member more than once");w instanceof WeakSet?w.add(p):w.set(p,_)},q=(p,w,_,Y)=>(le(p,w,"write to private field"),Y?Y.call(p,_):w.set(p,_),_);var G,B,z,J,Q,W,L,X,Z,H,K,k,M,D;function w(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function _(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r>>0,g=new Uint8Array(u);d!==o;){for(var A=s[d],T=0,b=u-1;(A!==0||T>>0,g[b]=A%l>>>0,A=A/l>>>0;if(A!==0)throw new Error("Non-zero carry");c=T,d++}for(var n=u-c;n!==u&&g[n]===0;)n++;for(var E=x.repeat(a);n>>0,u=new Uint8Array(o);s[a];){var g=e[s.charCodeAt(a)];if(g===255)return;for(var A=0,T=o-1;(g!==0||A>>0,u[T]=g%256>>>0,g=g/256>>>0;if(g!==0)throw new Error("Non-zero carry");d=A,a++}for(var b=o-d;b!==o&&u[b]===0;)b++;for(var n=new Uint8Array(c+(o-b)),E=c;b!==o;)n[E++]=u[b++];return n}function v(s){var a=U(s);if(a)return a;throw new Error("Non-base"+l+" character")}return{encode:j,decodeUnsafe:U,decode:v}}var Y=_;const ce=w(Y);var ne={};(function(t){(function(e){e([],function(){var r=-1,i=-2,h=-3,y=-4,l=-5,x=function(a,c){c=c||{};var d=c.verbose||!1;d&&console.log("Normalize the JSON Object"),a=typeof a=="string"?this.JSON.parse(a):a,d&&console.log("Creating a empty dictionary");var o={strings:[],integers:[],floats:[]};d&&console.log("Creating the AST");var u=function b(n){d&&console.log("Calling recursiveAstBuilder with "+this.JSON.stringify(n));var E=typeof n;if(n===null)return{type:"null",index:h};if(typeof n>"u")return{type:"undefined",index:l};if(n instanceof Array){var m=["@"];for(var S in n)n.hasOwnProperty(S)&&m.push(b(n[S]));return m}if(E==="object"){var m=["$"];for(var I in n)n.hasOwnProperty(I)&&(m.push(b(I)),m.push(b(n[I])));return m}if(n==="")return{type:"empty",index:y};if(E==="string"){var N=s.call(o.strings,n);return N==-1&&(o.strings.push(F(n)),N=o.strings.length-1),{type:"strings",index:N}}if(E==="number"&&n%1===0){var N=s.call(o.integers,n);return N==-1&&(o.integers.push(U(n)),N=o.integers.length-1),{type:"integers",index:N}}if(E==="number"){var N=s.call(o.floats,n);return N==-1&&(o.floats.push(n),N=o.floats.length-1),{type:"floats",index:N}}if(E==="boolean")return{type:"boolean",index:n?r:i};throw new Error("Unexpected argument of type "+typeof n)}(a),g=o.strings.length,A=o.integers.length;o.floats.length,d&&console.log("Parsing the dictionary");var T=o.strings.join("|");return T+="^"+o.integers.join("|"),T+="^"+o.floats.join("|"),d&&console.log("Parsing the structure"),T+="^"+function b(n){if(d&&console.log("Calling a recursiveParser with "+this.JSON.stringify(n)),n instanceof Array){var E=n.shift();for(var m in n)n.hasOwnProperty(m)&&(E+=b(n[m])+"|");return(E[E.length-1]==="|"?E.slice(0,-1):E)+"]"}var S=n.type,I=n.index;if(S==="strings")return U(I);if(S==="integers")return U(g+I);if(S==="floats")return U(g+A+I);if(S==="boolean")return n.index;if(S==="null")return h;if(S==="undefined")return l;if(S==="empty")return y;throw new TypeError("The item is alien!")}(u),d&&console.log("Ending parser"),c.debug?{dictionary:o,ast:u,packed:T}:T},V=function(a,c){c=c||{};var d=a.split("^");c.verbose&&console.log("Building dictionary");var o=[],u=d[0];if(u!==""){u=u.split("|"),c.verbose&&console.log("Parse the strings dictionary");for(var g=0,A=u.length;gf(this,Q).call(this,r),ownKeys:()=>Object.keys(f(this,J).getPrototypeOf()||{}),getPrototypeOf:()=>f(this,B)?this:this.data,getOwnPropertyDescriptor:()=>({configurable:!0,enumerable:!0,writable:!0,value:f(this,J).getPrototypeOf()})});C(this,Q,e=>e==="$toast"?f(this,L):e==="msg"?f(this,W):e==="then"||e==="resp"?(q(this,z,!0),q(this,B,e==="resp"),f(this,X)):e==="catch"?f(this,Z):e==="IS_ECHO_MSG"?f(this,z):Reflect.get(this,e));C(this,W,(e=i=>i,r=!1)=>(f(this,L).call(this),q(this,B,r),Promise.resolve(e==null?void 0:e(f(this,J).getPrototypeOf()))));C(this,L,()=>{f(this,z)&&(q(this,z,!1),ue.onToast(this.code,this.message))});C(this,X,e=>[0,1].includes(this.code)?Promise.resolve(e==null?void 0:e(f(this,J).getPrototypeOf())):Promise.reject(f(this,G)));C(this,Z,e=>Promise.resolve(e(f(this,G))));return this.code=e,this.message=r,this.data=i,this.url=h,this.res=y,q(this,G,new Proxy(this,f(this,J)))}}G=new WeakMap,B=new WeakMap,z=new WeakMap,J=new WeakMap,Q=new WeakMap,W=new WeakMap,L=new WeakMap,X=new WeakMap,Z=new WeakMap;const te=(t,e,r,i="/",h="")=>new ee(t,e,r,i,h);var se=["utf8","utf-8","unicode-1-1-utf-8"];function de(t){if(se.indexOf(t)<0&&typeof t<"u"&&t!=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 r=unescape(encodeURIComponent(e)),i=new Uint8Array(r.length);const h=r.split("");for(let y=0;y"u")return"";var i=typeof r<"u"&&i in r?r.stream:!1;if(typeof i!="boolean")throw new TypeError("stream option must be boolean");if(ArrayBuffer.isView(e)){var h=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),y=new Array(h.length);for(let l=0;l{let e=5381;for(let r=0;r>>0).toString(16)},we=(t,e)=>t.replace(new RegExp(`^${e}+|${e}+$`,"g"),""),fe=t=>pe.encode(t||""),he=t=>ve.decode(new DataView(t),{});class re{constructor(e,r,i=({})=>Promise.reject({code:-1,msg:"请初始化HTTP请求方法主体"})){C(this,H,void 0);C(this,K,void 0);C(this,k,void 0);C(this,M,{"#":new Map,$:new Map});C(this,D,new Map);P(this,"request",({url:e="/",method:r="GET",...i},h=!1)=>{var F;const y=r.toUpperCase(),l=oe(JSON.stringify([e,y,i])),x=(F=e==null?void 0:e.includes)!=null&&F.call(e,"/_/")?"#":"$",V=new Promise((j,U)=>{!h&&x!=="#"&&f(this,M)[x].delete(l),f(this,M)[x].has(l)?(console.log("缓存命中",e),j(f(this,M)[x].get(l))):f(this,D).has(l)?f(this,D).get(l).push([j,U]):(f(this,D).set(l,[[j,U]]),f(this,H).call(this,{url:e,method:y,...i}).then(v=>{if(![0,1].includes(v.code))throw te(v.code,v.msg,v.data,e,v==null?void 0:v.res);return[v.code,v.msg,v.data,e,v==null?void 0:v.res]}).then(v=>((x=="#"||h&&y==="GET")&&f(this,M)[x].set(l,v),v)).then(v=>f(this,D).get(l).forEach(([s,a])=>s(v))).catch(v=>(f(this,M)[x].delete(l),f(this,D).get(l).forEach(([s,a])=>a(v instanceof ee?v:te(-1,v,null,e))))).finally(()=>f(this,D).delete(l)))});return new Proxy(V,{get:(j,U)=>(...v)=>j.then(s=>te(...s)[U](...v)).catch(s=>{if(!s instanceof ee)throw s;return typeof s[U]=="function"?s[U](...v):s[U]})})});P(this,"get",(e,r={})=>this.request({url:e,method:"GET",params:r}));P(this,"post",(e,r={},i={})=>this.request({url:e,method:"POST",data:r,params:i}));P(this,"put",(e,r={},i={})=>this.request({url:e,method:"PUT",data:r,params:i}));P(this,"del",(e,r={},i={})=>this.request({url:e,method:"DELETE",data:r,params:i}));P(this,"download",(e,r)=>{});P(this,"cache",(e,r={})=>this.request({url:e,method:"GET",params:r},!0));P(this,"list",(e,r={})=>this.get(`/api/${e}/${this.encode(r)}`));P(this,"getAppInfo",()=>{});P(this,"refreshCache",(e=!1)=>{e&&f(this,M)["#"].clear(),f(this,M).$.clear()});P(this,"decode",(e="",r={})=>{if(e===void 0||e===""||e===null)return r;try{const i=f(this,K).decode(e).buffer;return ie.unpack(he(i))}catch{return console.warn("core.decode",e),r}});P(this,"encode",(e={})=>{const r=JSON.stringify(e,(i,h)=>h===void 0?null:h);return f(this,K).encode(fe(ie.pack(r)))});q(this,k,e),q(this,H,i),q(this,K,ce(r))}}H=new WeakMap,K=new WeakMap,k=new WeakMap,M=new WeakMap,D=new WeakMap;const ue=re;re.onUnhandledRejection=t=>{var e,r,i,h,y,l;t!=null&&t.IS_ECHO_MSG?((e=t==null?void 0:t.$toast)==null||e.call(t),(r=t==null?void 0:t.preventDefault)==null||r.call(t)):(i=t.reason)!=null&&i.IS_ECHO_MSG&&((y=(h=t.reason)==null?void 0:h.$toast)==null||y.call(h),(l=t==null?void 0:t.preventDefault)==null||l.call(t))},re.onToast=(t,e)=>[0,1].includes(t)?console.log(e):console.warn(e),p.default=ue,p.signature=oe,p.str2uint8array=fe,p.trim=we,p.uint8array2str=he,Object.defineProperties(p,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}); +(function(g,w){typeof exports=="object"&&typeof module<"u"?w(exports):typeof define=="function"&&define.amd?define(["exports"],w):(g=typeof globalThis<"u"?globalThis:g||self,w(g["ff-request"]={}))})(this,function(g){"use strict";var ye=Object.defineProperty;var be=(g,w,_)=>w in g?ye(g,w,{enumerable:!0,configurable:!0,writable:!0,value:_}):g[w]=_;var P=(g,w,_)=>(be(g,typeof w!="symbol"?w+"":w,_),_),le=(g,w,_)=>{if(!w.has(g))throw TypeError("Cannot "+_)};var u=(g,w,_)=>(le(g,w,"read from private field"),_?_.call(g):w.get(g)),N=(g,w,_)=>{if(w.has(g))throw TypeError("Cannot add the same private member more than once");w instanceof WeakSet?w.add(g):w.set(g,_)},D=(g,w,_,Y)=>(le(g,w,"write to private field"),Y?Y.call(g,_):w.set(g,_),_);var G,B,J,q,Q,W,L,X,Z,H,K,k,j,I;function w(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function _(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r>>0,d=new Uint8Array(h);c!==a;){for(var A=f[c],T=0,b=h-1;(A!==0||T>>0,d[b]=A%v>>>0,A=A/v>>>0;if(A!==0)throw new Error("Non-zero carry");o=T,c++}for(var n=h-o;n!==h&&d[n]===0;)n++;for(var E=m.repeat(i);n>>0,h=new Uint8Array(a);f[i];){var d=e[f.charCodeAt(i)];if(d===255)return;for(var A=0,T=a-1;(d!==0||A>>0,h[T]=d%256>>>0,d=d/256>>>0;if(d!==0)throw new Error("Non-zero carry");c=A,i++}for(var b=a-c;b!==a&&h[b]===0;)b++;for(var n=new Uint8Array(o+(a-b)),E=o;b!==a;)n[E++]=h[b++];return n}function p(f){var i=$(f);if(i)return i;throw new Error("Non-base"+v+" character")}return{encode:F,decodeUnsafe:$,decode:p}}var Y=_;const ce=w(Y);var ne={};(function(t){(function(e){e([],function(){var r=-1,s=-2,l=-3,y=-4,v=-5,m=function(i,o){o=o||{};var c=o.verbose||!1;c&&console.log("Normalize the JSON Object"),i=typeof i=="string"?this.JSON.parse(i):i,c&&console.log("Creating a empty dictionary");var a={strings:[],integers:[],floats:[]};c&&console.log("Creating the AST");var h=function b(n){c&&console.log("Calling recursiveAstBuilder with "+this.JSON.stringify(n));var E=typeof n;if(n===null)return{type:"null",index:l};if(typeof n>"u")return{type:"undefined",index:v};if(n instanceof Array){var U=["@"];for(var S in n)n.hasOwnProperty(S)&&U.push(b(n[S]));return U}if(E==="object"){var U=["$"];for(var M in n)n.hasOwnProperty(M)&&(U.push(b(M)),U.push(b(n[M])));return U}if(n==="")return{type:"empty",index:y};if(E==="string"){var C=f.call(a.strings,n);return C==-1&&(a.strings.push(z(n)),C=a.strings.length-1),{type:"strings",index:C}}if(E==="number"&&n%1===0){var C=f.call(a.integers,n);return C==-1&&(a.integers.push($(n)),C=a.integers.length-1),{type:"integers",index:C}}if(E==="number"){var C=f.call(a.floats,n);return C==-1&&(a.floats.push(n),C=a.floats.length-1),{type:"floats",index:C}}if(E==="boolean")return{type:"boolean",index:n?r:s};throw new Error("Unexpected argument of type "+typeof n)}(i),d=a.strings.length,A=a.integers.length;a.floats.length,c&&console.log("Parsing the dictionary");var T=a.strings.join("|");return T+="^"+a.integers.join("|"),T+="^"+a.floats.join("|"),c&&console.log("Parsing the structure"),T+="^"+function b(n){if(c&&console.log("Calling a recursiveParser with "+this.JSON.stringify(n)),n instanceof Array){var E=n.shift();for(var U in n)n.hasOwnProperty(U)&&(E+=b(n[U])+"|");return(E[E.length-1]==="|"?E.slice(0,-1):E)+"]"}var S=n.type,M=n.index;if(S==="strings")return $(M);if(S==="integers")return $(d+M);if(S==="floats")return $(d+A+M);if(S==="boolean")return n.index;if(S==="null")return l;if(S==="undefined")return v;if(S==="empty")return y;throw new TypeError("The item is alien!")}(h),c&&console.log("Ending parser"),o.debug?{dictionary:a,ast:h,packed:T}:T},V=function(i,o){o=o||{};var c=i.split("^");o.verbose&&console.log("Building dictionary");var a=[],h=c[0];if(h!==""){h=h.split("|"),o.verbose&&console.log("Parse the strings dictionary");for(var d=0,A=h.length;du(this,Q).call(this,r),ownKeys:()=>Object.keys(u(this,q).getPrototypeOf()||{}),getPrototypeOf:()=>u(this,B)?this:this.data,getOwnPropertyDescriptor:()=>({configurable:!0,enumerable:!0,writable:!0,value:u(this,q).getPrototypeOf()})});N(this,Q,e=>e==="$toast"?u(this,L):e==="msg"?u(this,W):e==="then"||e==="resp"?(D(this,J,!0),D(this,B,e==="resp"),u(this,X)):e==="catch"?u(this,Z):e==="IS_ECHO_MSG"?u(this,J):Reflect.get(this,e));N(this,W,(e=s=>s,r=!1)=>(u(this,L).call(this),D(this,B,r),Promise.resolve(e==null?void 0:e(u(this,q).getPrototypeOf()))));N(this,L,()=>{u(this,J)&&(D(this,J,!1),ue.onToast(this.code,this.message))});N(this,X,e=>[0,1].includes(this.code)?Promise.resolve(e==null?void 0:e(u(this,q).getPrototypeOf())):Promise.reject(u(this,G)));N(this,Z,e=>Promise.resolve(e(u(this,G))));return this.code=e,this.message=r,this.data=s,this.url=l,this.res=y,D(this,G,new Proxy(this,u(this,q)))}}G=new WeakMap,B=new WeakMap,J=new WeakMap,q=new WeakMap,Q=new WeakMap,W=new WeakMap,L=new WeakMap,X=new WeakMap,Z=new WeakMap;const te=(t,e,r,s="/",l="")=>new ee(t,e,r,s,l);var ie=["utf8","utf-8","unicode-1-1-utf-8"];function de(t){if(ie.indexOf(t)<0&&typeof t<"u"&&t!=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 r=unescape(encodeURIComponent(e)),s=new Uint8Array(r.length);const l=r.split("");for(let y=0;y"u")return"";var s=typeof r<"u"&&s in r?r.stream:!1;if(typeof s!="boolean")throw new TypeError("stream option must be boolean");if(ArrayBuffer.isView(e)){var l=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),y=new Array(l.length);for(let v=0;v{let e=5381;for(let r=0;r>>0).toString(16)},we=(t,e)=>t.replace(new RegExp(`^${e}+|${e}+$`,"g"),""),fe=t=>ve.encode(t||""),he=t=>pe.decode(new DataView(t),{});class re{constructor(e,r,s=({})=>Promise.reject({code:-1,msg:"请初始化HTTP请求方法主体"})){N(this,H,void 0);N(this,K,void 0);N(this,k,void 0);N(this,j,{"#":new Map,$:new Map});N(this,I,new Map);P(this,"request",({url:e="/",method:r="GET",...s},l=!1)=>{var $;const y=r.toUpperCase(),v=ae(JSON.stringify([e,y,s])),m=($=e==null?void 0:e.includes)!=null&&$.call(e,"/_/")?"#":"$",{p:V,resolve:z,reject:F}=Promise.withResolvers();return u(this,j)[m].has(v)?(console.log("缓存命中",e),z(u(this,j)[m].get(v))):u(this,I).has(v)?u(this,I).get(v).push([z,F]):(u(this,I).set(v,[[z,F]]),u(this,H).call(this,{url:e,method:y,...s}).then(p=>{if(![0,1].includes(p.code))throw te(p.code,p.msg,p.data,e,p==null?void 0:p.res);return[p.code,p.msg,p.data,e,p==null?void 0:p.res]}).then(p=>((m=="#"||l&&y==="GET")&&u(this,j)[m].set(v,p),p)).then(p=>u(this,I).get(v).forEach(([f,i])=>f(p))).catch(p=>(u(this,j)[m].delete(v),u(this,I).get(v).forEach(([f,i])=>i(p instanceof ee?p:te(-1,p,null,e))))).finally(()=>u(this,I).delete(v))),new Proxy(V,{get:(p,f)=>(...i)=>p.then(o=>te(...o)[f](...i)).catch(o=>{if(!o instanceof ee)throw o;return typeof o[f]=="function"?o[f](...i):o[f]})})});P(this,"get",(e,r={})=>this.request({url:e,method:"GET",params:r}));P(this,"post",(e,r={},s={})=>this.request({url:e,method:"POST",data:r,params:s}));P(this,"put",(e,r={},s={})=>this.request({url:e,method:"PUT",data:r,params:s}));P(this,"del",(e,r={},s={})=>this.request({url:e,method:"DELETE",data:r,params:s}));P(this,"download",(e,r)=>{});P(this,"cache",(e,r={})=>this.request({url:e,method:"GET",params:r},!0));P(this,"list",(e,r={})=>this.get(`/api/${e}/${this.encode(r)}`));P(this,"getAppInfo",()=>{});P(this,"refreshCache",(e=!1)=>{e&&u(this,j)["#"].clear(),u(this,j).$.clear()});P(this,"decode",(e="",r={})=>{if(e===void 0||e===""||e===null)return r;try{const s=u(this,K).decode(e).buffer;return se.unpack(he(s))}catch{return console.warn("core.decode",e),r}});P(this,"encode",(e={})=>{const r=JSON.stringify(e,(s,l)=>l===void 0?null:l);return u(this,K).encode(fe(se.pack(r)))});D(this,k,e),D(this,H,s),D(this,K,ce(r))}}H=new WeakMap,K=new WeakMap,k=new WeakMap,j=new WeakMap,I=new WeakMap;const ue=re;re.onUnhandledRejection=t=>{var e,r,s,l,y,v;t!=null&&t.IS_ECHO_MSG?((e=t==null?void 0:t.$toast)==null||e.call(t),(r=t==null?void 0:t.preventDefault)==null||r.call(t)):(s=t.reason)!=null&&s.IS_ECHO_MSG&&((y=(l=t.reason)==null?void 0:l.$toast)==null||y.call(l),(v=t==null?void 0:t.preventDefault)==null||v.call(t))},re.onToast=(t,e)=>[0,1].includes(t)?console.log(e):console.warn(e),g.default=ue,g.signature=ae,g.str2uint8array=fe,g.trim=we,g.uint8array2str=he,Object.defineProperties(g,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}); diff --git a/package.json b/package.json index 7456006..477fce3 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "ff-request", "private": true, - "version": "0.9.2", + "version": "0.9.3", "type": "module", "files": [ "dist"