This commit is contained in:
what 2024-05-25 23:24:11 +08:00
parent 0a688d3d9f
commit fab62e0aa9
3 changed files with 280 additions and 282 deletions

558
dist/ff-request.js vendored
View File

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

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.9", "version": "0.9.10",
"type": "module", "type": "module",
"files": [ "files": [
"dist" "dist"