This commit is contained in:
what 2024-05-25 21:16:42 +08:00
parent 2ee9324e76
commit e1dcde17b5
3 changed files with 212 additions and 214 deletions

422
dist/ff-request.js vendored
View File

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

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,7 @@
{ {
"name": "ff-request", "name": "ff-request",
"private": true, "private": true,
"version": "0.9.2", "version": "0.9.3",
"type": "module", "type": "module",
"files": [ "files": [
"dist" "dist"