ff-request-dist/dist/ff-request.js

484 lines
18 KiB
JavaScript
Raw Normal View History

2024-05-25 21:26:25 +08:00
var oe = Object.defineProperty;
2024-05-25 22:42:00 +08:00
var ae = (t, e, r) => e in t ? oe(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
var A = (t, e, r) => (ae(t, typeof e != "symbol" ? e + "" : e, r), r), k = (t, e, r) => {
2024-04-04 11:47:06 +08:00
if (!e.has(t))
throw TypeError("Cannot " + r);
};
2024-05-25 22:16:06 +08:00
var h = (t, e, r) => (k(t, e, "read from private field"), r ? r.call(t) : e.get(t)), S = (t, e, r) => {
2024-04-04 11:47:06 +08:00
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);
2024-05-25 22:42:00 +08:00
}, M = (t, e, r, n) => (k(t, e, "write to private field"), n ? n.call(t, r) : e.set(t, r), r);
2024-04-04 11:47:06 +08:00
function te(t) {
return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
}
2024-05-25 22:42:00 +08:00
function ie(t) {
2024-04-04 11:47:06 +08:00
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++) {
2024-05-25 21:26:25 +08:00
var u = t.charAt(n), v = u.charCodeAt(0);
if (e[v] !== 255)
2024-05-25 21:16:42 +08:00
throw new TypeError(u + " is ambiguous");
2024-05-25 21:26:25 +08:00
e[v] = n;
2024-04-04 11:47:06 +08:00
}
2024-05-25 22:16:06 +08:00
var c = t.length, U = t.charAt(0), B = Math.log(c) / Math.log(256), D = Math.log(256) / Math.log(c);
2024-05-25 22:42:00 +08:00
function q(i) {
if (i instanceof Uint8Array || (ArrayBuffer.isView(i) ? i = new Uint8Array(i.buffer, i.byteOffset, i.byteLength) : Array.isArray(i) && (i = Uint8Array.from(i))), !(i instanceof Uint8Array))
2024-04-04 11:47:06 +08:00
throw new TypeError("Expected Uint8Array");
2024-05-25 22:42:00 +08:00
if (i.length === 0)
2024-04-04 11:47:06 +08:00
return "";
2024-05-25 22:42:00 +08:00
for (var a = 0, s = 0, g = 0, f = i.length; g !== f && i[g] === 0; )
g++, a++;
for (var l = (f - g) * D + 1 >>> 0, d = new Uint8Array(l); g !== f; ) {
for (var T = i[g], E = 0, w = l - 1; (T !== 0 || E < s) && w !== -1; w--, E++)
2024-05-25 22:16:06 +08:00
T += 256 * d[w] >>> 0, d[w] = T % c >>> 0, T = T / c >>> 0;
2024-04-04 11:47:06 +08:00
if (T !== 0)
throw new Error("Non-zero carry");
2024-05-25 22:42:00 +08:00
s = E, g++;
2024-04-04 11:47:06 +08:00
}
2024-05-25 22:42:00 +08:00
for (var o = l - s; o !== l && d[o] === 0; )
o++;
for (var y = U.repeat(a); o < l; ++o)
y += t.charAt(d[o]);
2024-04-04 11:47:06 +08:00
return y;
}
2024-05-25 22:42:00 +08:00
function x(i) {
if (typeof i != "string")
2024-04-04 11:47:06 +08:00
throw new TypeError("Expected String");
2024-05-25 22:42:00 +08:00
if (i.length === 0)
2024-04-04 11:47:06 +08:00
return new Uint8Array();
2024-05-25 22:42:00 +08:00
for (var a = 0, s = 0, g = 0; i[a] === U; )
s++, a++;
for (var f = (i.length - a) * B + 1 >>> 0, l = new Uint8Array(f); i[a]; ) {
var d = e[i.charCodeAt(a)];
2024-05-25 22:16:06 +08:00
if (d === 255)
2024-04-04 11:47:06 +08:00
return;
2024-05-25 22:42:00 +08:00
for (var T = 0, E = f - 1; (d !== 0 || T < g) && E !== -1; E--, T++)
2024-05-25 22:16:06 +08:00
d += c * l[E] >>> 0, l[E] = d % 256 >>> 0, d = d / 256 >>> 0;
if (d !== 0)
2024-04-04 11:47:06 +08:00
throw new Error("Non-zero carry");
2024-05-25 22:42:00 +08:00
g = T, a++;
2024-04-04 11:47:06 +08:00
}
2024-05-25 22:42:00 +08:00
for (var w = f - g; w !== f && l[w] === 0; )
2024-04-04 11:47:06 +08:00
w++;
2024-05-25 22:42:00 +08:00
for (var o = new Uint8Array(s + (f - w)), y = s; w !== f; )
o[y++] = l[w++];
return o;
2024-04-04 11:47:06 +08:00
}
2024-05-25 22:42:00 +08:00
function p(i) {
var a = x(i);
if (a)
return a;
2024-05-25 22:16:06 +08:00
throw new Error("Non-base" + c + " character");
2024-04-04 11:47:06 +08:00
}
return {
2024-05-25 21:16:42 +08:00
encode: q,
decodeUnsafe: x,
2024-05-25 21:26:25 +08:00
decode: p
2024-04-04 11:47:06 +08:00
};
}
2024-05-25 22:42:00 +08:00
var fe = ie;
2024-04-04 11:47:06 +08:00
const he = /* @__PURE__ */ te(fe);
var re = {};
(function(t) {
(function(e) {
e([], function() {
2024-05-25 22:42:00 +08:00
var r = -1, n = -2, u = -3, v = -4, c = -5, U = function(a, s) {
s = s || {};
var g = s.verbose || !1;
g && console.log("Normalize the JSON Object"), a = typeof a == "string" ? this.JSON.parse(a) : a, g && console.log("Creating a empty dictionary");
var f = {
2024-04-04 11:47:06 +08:00
strings: [],
integers: [],
floats: []
};
2024-05-25 22:16:06 +08:00
g && console.log("Creating the AST");
2024-05-25 22:42:00 +08:00
var l = function w(o) {
g && console.log("Calling recursiveAstBuilder with " + this.JSON.stringify(o));
var y = typeof o;
if (o === null)
2024-04-04 11:47:06 +08:00
return {
type: "null",
2024-05-25 21:16:42 +08:00
index: u
2024-04-04 11:47:06 +08:00
};
2024-05-25 22:42:00 +08:00
if (typeof o > "u")
2024-04-04 11:47:06 +08:00
return {
type: "undefined",
2024-05-25 22:16:06 +08:00
index: c
2024-04-04 11:47:06 +08:00
};
2024-05-25 22:42:00 +08:00
if (o instanceof Array) {
2024-05-25 21:16:42 +08:00
var _ = ["@"];
2024-05-25 22:42:00 +08:00
for (var O in o)
o.hasOwnProperty(O) && _.push(w(o[O]));
2024-05-25 21:16:42 +08:00
return _;
2024-04-04 11:47:06 +08:00
}
if (y === "object") {
2024-05-25 21:16:42 +08:00
var _ = ["$"];
2024-05-25 22:42:00 +08:00
for (var R in o)
o.hasOwnProperty(R) && (_.push(w(R)), _.push(w(o[R])));
2024-05-25 21:16:42 +08:00
return _;
2024-04-04 11:47:06 +08:00
}
2024-05-25 22:42:00 +08:00
if (o === "")
2024-04-04 11:47:06 +08:00
return {
type: "empty",
2024-05-25 21:26:25 +08:00
index: v
2024-04-04 11:47:06 +08:00
};
if (y === "string") {
2024-05-25 22:42:00 +08:00
var P = i.call(f.strings, o);
return P == -1 && (f.strings.push(D(o)), P = f.strings.length - 1), {
2024-04-04 11:47:06 +08:00
type: "strings",
index: P
};
}
2024-05-25 22:42:00 +08:00
if (y === "number" && o % 1 === 0) {
var P = i.call(f.integers, o);
return P == -1 && (f.integers.push(x(o)), P = f.integers.length - 1), {
2024-04-04 11:47:06 +08:00
type: "integers",
index: P
};
}
if (y === "number") {
2024-05-25 22:42:00 +08:00
var P = i.call(f.floats, o);
return P == -1 && (f.floats.push(o), P = f.floats.length - 1), {
2024-04-04 11:47:06 +08:00
type: "floats",
index: P
};
}
if (y === "boolean")
return {
type: "boolean",
2024-05-25 22:42:00 +08:00
index: o ? r : n
2024-04-04 11:47:06 +08:00
};
2024-05-25 22:42:00 +08:00
throw new Error("Unexpected argument of type " + typeof o);
}(a), d = f.strings.length, T = f.integers.length;
f.floats.length, g && console.log("Parsing the dictionary");
var E = f.strings.join("|");
return E += "^" + f.integers.join("|"), E += "^" + f.floats.join("|"), g && console.log("Parsing the structure"), E += "^" + function w(o) {
if (g && console.log("Calling a recursiveParser with " + this.JSON.stringify(o)), o instanceof Array) {
var y = o.shift();
for (var _ in o)
o.hasOwnProperty(_) && (y += w(o[_]) + "|");
2024-04-04 11:47:06 +08:00
return (y[y.length - 1] === "|" ? y.slice(0, -1) : y) + "]";
}
2024-05-25 22:42:00 +08:00
var O = o.type, R = o.index;
2024-04-04 11:47:06 +08:00
if (O === "strings")
2024-05-25 21:16:42 +08:00
return x(R);
2024-04-04 11:47:06 +08:00
if (O === "integers")
2024-05-25 22:16:06 +08:00
return x(d + R);
2024-04-04 11:47:06 +08:00
if (O === "floats")
2024-05-25 22:16:06 +08:00
return x(d + T + R);
2024-04-04 11:47:06 +08:00
if (O === "boolean")
2024-05-25 22:42:00 +08:00
return o.index;
2024-04-04 11:47:06 +08:00
if (O === "null")
return u;
2024-05-25 21:16:42 +08:00
if (O === "undefined")
2024-05-25 22:16:06 +08:00
return c;
2024-04-04 11:47:06 +08:00
if (O === "empty")
2024-05-25 21:26:25 +08:00
return v;
2024-04-04 11:47:06 +08:00
throw new TypeError("The item is alien!");
2024-05-25 22:42:00 +08:00
}(l), g && console.log("Ending parser"), s.debug ? {
dictionary: f,
2024-05-25 22:16:06 +08:00
ast: l,
2024-04-04 11:47:06 +08:00
packed: E
} : E;
2024-05-25 22:42:00 +08:00
}, B = function(a, s) {
s = s || {};
var g = a.split("^");
s.verbose && console.log("Building dictionary");
var f = [], l = g[0];
2024-05-25 22:16:06 +08:00
if (l !== "") {
2024-05-25 22:42:00 +08:00
l = l.split("|"), s.verbose && console.log("Parse the strings dictionary");
2024-05-25 22:16:06 +08:00
for (var d = 0, T = l.length; d < T; d++)
2024-05-25 22:42:00 +08:00
f.push(q(l[d]));
2024-04-04 11:47:06 +08:00
}
2024-05-25 22:16:06 +08:00
if (l = g[1], l !== "") {
2024-05-25 22:42:00 +08:00
l = l.split("|"), s.verbose && console.log("Parse the integers dictionary");
2024-05-25 22:16:06 +08:00
for (var d = 0, T = l.length; d < T; d++)
2024-05-25 22:42:00 +08:00
f.push(p(l[d]));
2024-04-04 11:47:06 +08:00
}
2024-05-25 22:16:06 +08:00
if (l = g[2], l !== "") {
2024-05-25 22:42:00 +08:00
l = l.split("|"), s.verbose && console.log("Parse the floats dictionary");
2024-05-25 22:16:06 +08:00
for (var d = 0, T = l.length; d < T; d++)
2024-05-25 22:42:00 +08:00
f.push(parseFloat(l[d]));
2024-04-04 11:47:06 +08:00
}
2024-05-25 22:42:00 +08:00
l = null, s.verbose && console.log("Tokenizing the structure");
for (var E = "", w = [], o = g[3].length, d = 0; d < o; d++) {
2024-05-25 22:16:06 +08:00
var y = g[3].charAt(d);
2024-05-25 21:26:25 +08:00
y === "|" || y === "$" || y === "@" || y === "]" ? (E && (w.push(p(E)), E = ""), y !== "|" && w.push(y)) : E += y;
2024-04-04 11:47:06 +08:00
}
2024-05-25 21:16:42 +08:00
var _ = w.length, O = 0;
2024-05-25 22:42:00 +08:00
return s.verbose && console.log("Starting recursive parser"), function R() {
2024-04-04 11:47:06 +08:00
var P = w[O++];
2024-05-25 22:42:00 +08:00
if (s.verbose && console.log("Reading collection type " + (P === "$" ? "object" : "Array")), P === "@") {
2024-05-25 21:16:42 +08:00
for (var b = []; O < _; O++) {
var N = w[O];
2024-05-25 22:42:00 +08:00
if (s.verbose && console.log("Read " + N + " symbol"), N === "]")
2024-04-04 11:47:06 +08:00
return b;
2024-05-25 21:16:42 +08:00
if (N === "@" || N === "$")
2024-04-04 11:47:06 +08:00
b.push(R());
else
2024-05-25 21:16:42 +08:00
switch (N) {
2024-04-04 11:47:06 +08:00
case r:
b.push(!0);
break;
case n:
b.push(!1);
break;
2024-05-25 21:16:42 +08:00
case u:
2024-04-04 11:47:06 +08:00
b.push(null);
break;
2024-05-25 22:16:06 +08:00
case c:
2024-04-04 11:47:06 +08:00
b.push(void 0);
break;
2024-05-25 21:26:25 +08:00
case v:
2024-04-04 11:47:06 +08:00
b.push("");
break;
default:
2024-05-25 22:42:00 +08:00
b.push(f[N]);
2024-04-04 11:47:06 +08:00
}
}
2024-05-25 22:42:00 +08:00
return s.verbose && console.log("Parsed " + this.JSON.stringify(b)), b;
2024-04-04 11:47:06 +08:00
}
if (P === "$") {
2024-05-25 21:16:42 +08:00
for (var b = {}; O < _; O++) {
var C = w[O];
if (C === "]")
2024-04-04 11:47:06 +08:00
return b;
2024-05-25 22:42:00 +08:00
C === v ? C = "" : C = f[C];
2024-05-25 21:16:42 +08:00
var N = w[++O];
if (N === "@" || N === "$")
b[C] = R();
2024-04-04 11:47:06 +08:00
else
2024-05-25 21:16:42 +08:00
switch (N) {
2024-04-04 11:47:06 +08:00
case r:
2024-05-25 21:16:42 +08:00
b[C] = !0;
2024-04-04 11:47:06 +08:00
break;
case n:
2024-05-25 21:16:42 +08:00
b[C] = !1;
2024-04-04 11:47:06 +08:00
break;
case u:
2024-05-25 21:16:42 +08:00
b[C] = null;
2024-04-04 11:47:06 +08:00
break;
2024-05-25 22:16:06 +08:00
case c:
2024-05-25 21:16:42 +08:00
b[C] = void 0;
break;
2024-05-25 21:26:25 +08:00
case v:
2024-05-25 21:16:42 +08:00
b[C] = "";
2024-04-04 11:47:06 +08:00
break;
default:
2024-05-25 22:42:00 +08:00
b[C] = f[N];
2024-04-04 11:47:06 +08:00
}
}
2024-05-25 22:42:00 +08:00
return s.verbose && console.log("Parsed " + this.JSON.stringify(b)), b;
2024-04-04 11:47:06 +08:00
}
throw new TypeError("Bad token " + P + " isn't a type");
}();
2024-05-25 22:42:00 +08:00
}, D = function(a) {
return typeof a != "string" ? a : a.replace(/[\+ \|\^\%]/g, function(s) {
2024-04-04 11:47:06 +08:00
return {
" ": "+",
"+": "%2B",
"|": "%7C",
"^": "%5E",
"%": "%25"
2024-05-25 22:42:00 +08:00
}[s];
2024-04-04 11:47:06 +08:00
});
2024-05-25 22:42:00 +08:00
}, q = function(a) {
return typeof a != "string" ? a : a.replace(/\+|%2B|%7C|%5E|%25/g, function(s) {
2024-04-04 11:47:06 +08:00
return {
"+": " ",
"%2B": "+",
"%7C": "|",
"%5E": "^",
"%25": "%"
2024-05-25 22:42:00 +08:00
}[s];
2024-04-04 11:47:06 +08:00
});
2024-05-25 22:42:00 +08:00
}, x = function(a) {
return Number.prototype.toString.call(a, 36).toUpperCase();
}, p = function(a) {
return parseInt(a, 36);
}, i = Array.prototype.indexOf || function(a, s) {
for (var g = s || 0, f = this.length; g < f; g++)
if (this[g] === a)
2024-05-25 22:16:06 +08:00
return g;
2024-04-04 11:47:06 +08:00
return -1;
};
return {
JSON,
2024-05-25 21:16:42 +08:00
pack: U,
2024-04-04 11:47:06 +08:00
unpack: B
};
});
})(function(e, r) {
var n = r();
2024-05-25 21:16:42 +08:00
for (var u in n)
t[u] = n[u];
2024-04-04 11:47:06 +08:00
});
})(re);
const ee = /* @__PURE__ */ te(re);
2024-05-25 21:16:42 +08:00
var J, z, j, I, L, H, K, V, Y;
2024-05-12 01:15:30 +08:00
class X {
2024-05-25 21:26:25 +08:00
constructor(e, r, n, u, v) {
2024-04-04 11:47:06 +08:00
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 }
2024-05-25 21:16:42 +08:00
S(this, J, null);
2024-04-04 11:47:06 +08:00
// 判断返回 Response 对象, 还是 Response 中的 data
2024-05-25 21:16:42 +08:00
S(this, z, !0);
2024-04-04 11:47:06 +08:00
// 判罚是否已经给出错误提示
2024-05-25 21:16:42 +08:00
S(this, j, !0);
S(this, I, {
2024-05-25 22:16:06 +08:00
get: (e, r) => h(this, L).call(this, r),
ownKeys: () => Object.keys(h(this, I).getPrototypeOf() || {}),
getPrototypeOf: () => h(this, z) ? this : this.data,
2024-04-04 11:47:06 +08:00
getOwnPropertyDescriptor: () => ({
configurable: !0,
enumerable: !0,
writable: !0,
2024-05-25 22:16:06 +08:00
value: h(this, I).getPrototypeOf()
2024-04-04 11:47:06 +08:00
})
});
2024-05-25 22:42:00 +08:00
S(this, L, (e) => e === "$toast" ? h(this, K) : e === "msg" ? h(this, H) : e === "then" || e === "resp" ? (M(this, j, !0), M(this, z, e === "resp"), h(this, V)) : e === "catch" ? h(this, Y) : e === "IS_ECHO_MSG" ? h(this, j) : Reflect.get(this, e));
S(this, H, (e = (n) => n, r = !1) => (h(this, K).call(this), M(this, z, r), Promise.resolve(e == null ? void 0 : e(h(this, I).getPrototypeOf()))));
2024-05-25 21:16:42 +08:00
S(this, K, () => {
2024-05-25 22:42:00 +08:00
h(this, j) && (M(this, j, !1), we.onToast(this.code, this.message));
2024-04-04 11:47:06 +08:00
});
2024-05-25 22:16:06 +08:00
S(this, V, (e) => [0, 1].includes(this.code) ? Promise.resolve(e == null ? void 0 : e(h(this, I).getPrototypeOf())) : Promise.reject(h(this, J)));
S(this, Y, (e) => Promise.resolve(e(h(this, J))));
2024-05-25 22:42:00 +08:00
return this.code = e, this.message = r, this.data = n, this.url = u, this.res = v, M(this, J, new Proxy(this, h(this, I)));
2024-04-04 11:47:06 +08:00
}
}
2024-05-25 21:16:42 +08:00
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);
2024-04-04 11:47:06 +08:00
var ne = [
"utf8",
"utf-8",
"unicode-1-1-utf-8"
];
function le(t) {
if (ne.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)), n = new Uint8Array(r.length);
2024-05-25 21:16:42 +08:00
const u = r.split("");
2024-05-25 21:26:25 +08:00
for (let v = 0; v < u.length; v++)
n[v] = u[v].charCodeAt(0);
2024-04-04 11:47:06 +08:00
return n;
};
}
function ue(t) {
if (ne.indexOf(t) < 0 && typeof t < "u" && t != null)
throw new RangeError("Invalid encoding type. Only utf-8 is supported");
this.encoding = "utf-8", this.decode = function(e, r) {
if (typeof e > "u")
return "";
var n = typeof r < "u" && n in r ? r.stream : !1;
if (typeof n != "boolean")
throw new TypeError("stream option must be boolean");
if (ArrayBuffer.isView(e)) {
2024-05-25 21:26:25 +08:00
var u = new Uint8Array(e.buffer, e.byteOffset, e.byteLength), v = new Array(u.length);
2024-05-25 22:16:06 +08:00
for (let c = 0; c < u.length; c++)
v[c] = String.fromCharCode(u[c]);
2024-05-25 21:26:25 +08:00
return decodeURIComponent(escape(v.join("")));
2024-04-04 11:47:06 +08:00
} else
throw new TypeError("passed argument must be an array buffer view");
};
}
var se = {
TextEncoder: le,
TextDecoder: ue
};
const ce = new se.TextEncoder("utf8"), ge = new se.TextDecoder("utf8"), de = (t) => {
let e = 5381;
for (let r = 0; r < t.length; r++)
e = e * 33 ^ t.charCodeAt(r);
return (e >>> 0).toString(16);
2024-05-25 21:26:25 +08:00
}, be = (t, e) => t.replace(new RegExp(`^${e}+|${e}+$`, "g"), ""), pe = (t) => ce.encode(t || ""), ve = (t) => ge.decode(new DataView(t), {});
2024-05-25 22:42:00 +08:00
var F, G, Q, m, $;
2024-05-12 01:15:30 +08:00
class Z {
2024-04-04 11:47:06 +08:00
constructor(e, r, n = ({}) => Promise.reject({ code: -1, msg: "请初始化HTTP请求方法主体" })) {
2024-05-25 21:16:42 +08:00
S(this, F, void 0);
S(this, G, void 0);
S(this, Q, void 0);
2024-05-25 22:42:00 +08:00
S(this, m, {
2024-04-04 11:47:06 +08:00
"#": /* @__PURE__ */ new Map(),
// 系统缓存
$: /* @__PURE__ */ new Map()
// 普通缓存
});
2024-05-25 22:16:06 +08:00
S(this, $, /* @__PURE__ */ new Map());
2024-05-25 21:16:42 +08:00
A(this, "request", ({ url: e = "/", method: r = "GET", ...n }, u = !1) => {
var x;
2024-05-25 22:16:06 +08:00
const v = r.toUpperCase(), c = de(JSON.stringify([e, v, n])), U = (x = e == null ? void 0 : e.includes) != null && x.call(e, "/_/") ? "#" : "$", { promise: B, resolve: D, reject: q } = Promise.withResolvers();
2024-05-25 22:47:20 +08:00
return h(this, m)[U].has(c) ? (console.log("缓存命中", e), D(h(this, m)[U].get(c))) : h(this, $).has(c) ? h(this, $).get(c).push([D, q]) : (h(this, $).set(c, [[D, q]]), h(this, F).call(this, { url: e, method: v, ...n }).then((p) => {
2024-05-25 21:26:25 +08:00
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];
2024-05-25 22:42:00 +08:00
}).then((p) => ((U == "#" || u && v === "GET") && h(this, m)[U].set(c, p), p)).then((p) => h(this, $).get(c).forEach((i, a, s) => {
i && i[0](p), delete s[a];
})).catch((p) => {
h(this, m)[U].delete(c), h(this, $).get(c).forEach((i, a, s) => {
i && i[1](p instanceof X ? p : W(-1, p, null, e)), delete s[a];
});
}).finally(() => {
2024-05-25 22:47:20 +08:00
console.log(1111, h(this, $).get(c)), h(this, $).delete(c);
})), new Proxy(B, {
2024-05-25 22:42:00 +08:00
get: (p, i) => (...a) => p.then((s) => W(...s)[i](...a)).catch((s) => {
if (!s instanceof X)
throw s;
return typeof s[i] == "function" ? s[i](...a) : s[i];
2024-04-04 11:47:06 +08:00
})
});
});
A(this, "get", (e, r = {}) => this.request({ url: e, method: "GET", params: r }));
A(this, "post", (e, r = {}, n = {}) => this.request({ url: e, method: "POST", data: r, params: n }));
A(this, "put", (e, r = {}, n = {}) => this.request({ url: e, method: "PUT", data: r, params: n }));
A(this, "del", (e, r = {}, n = {}) => this.request({ url: e, method: "DELETE", data: r, params: n }));
A(this, "download", (e, r) => {
});
A(this, "cache", (e, r = {}) => this.request({ url: e, method: "GET", params: r }, !0));
A(this, "list", (e, r = {}) => this.get(`/api/${e}/${this.encode(r)}`));
A(this, "getAppInfo", () => {
});
A(this, "refreshCache", (e = !1) => {
2024-05-25 22:42:00 +08:00
e && h(this, m)["#"].clear(), h(this, m).$.clear();
2024-04-04 11:47:06 +08:00
});
A(this, "decode", (e = "", r = {}) => {
if (e === void 0 || e === "" || e === null)
return r;
try {
2024-05-25 22:16:06 +08:00
const n = h(this, G).decode(e).buffer;
2024-05-25 21:26:25 +08:00
return ee.unpack(ve(n));
2024-04-04 11:47:06 +08:00
} catch {
return console.warn("core.decode", e), r;
}
});
A(this, "encode", (e = {}) => {
2024-05-25 21:16:42 +08:00
const r = JSON.stringify(e, (n, u) => u === void 0 ? null : u);
2024-05-25 22:16:06 +08:00
return h(this, G).encode(pe(ee.pack(r)));
2024-04-04 11:47:06 +08:00
});
2024-05-25 22:42:00 +08:00
M(this, Q, e), M(this, F, n), M(this, G, he(r));
2024-04-04 11:47:06 +08:00
}
}
2024-05-25 22:42:00 +08:00
F = new WeakMap(), G = new WeakMap(), Q = new WeakMap(), m = new WeakMap(), $ = new WeakMap();
2024-05-12 01:15:30 +08:00
const we = Z;
Z.onUnhandledRejection = (t) => {
2024-05-25 22:16:06 +08:00
var e, r, n, u, v, c;
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 = (u = t.reason) == null ? void 0 : u.$toast) == null || v.call(u), (c = t == null ? void 0 : t.preventDefault) == null || c.call(t));
2024-04-04 11:47:06 +08:00
};
2024-05-12 01:15:30 +08:00
Z.onToast = (t, e) => [0, 1].includes(t) ? console.log(e) : console.warn(e);
2024-04-04 11:47:06 +08:00
export {
we as default,
de as signature,
2024-05-25 21:26:25 +08:00
pe as str2uint8array,
2024-04-04 11:47:06 +08:00
be as trim,
2024-05-25 21:26:25 +08:00
ve as uint8array2str
2024-04-04 11:47:06 +08:00
};