This commit is contained in:
what 2024-11-27 16:42:25 +08:00
parent 36957867f4
commit 1ece50e14a
3 changed files with 333 additions and 332 deletions

659
dist/ff-request.js vendored
View File

@ -1,491 +1,492 @@
var oe = Object.defineProperty; var ce = Object.defineProperty;
var ie = (r, e, t) => e in r ? oe(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t; var le = (r, e, t) => e in r ? ce(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
var P = (r, e, t) => (ie(r, typeof e != "symbol" ? e + "" : e, t), t), k = (r, e, t) => { var v = (r, e, t) => (le(r, typeof e != "symbol" ? e + "" : e, t), t), re = (r, e, t) => {
if (!e.has(r)) if (!e.has(r))
throw TypeError("Cannot " + t); throw TypeError("Cannot " + t);
}; };
var u = (r, e, t) => (k(r, e, "read from private field"), t ? t.call(r) : e.get(r)), A = (r, e, t) => { var o = (r, e, t) => (re(r, e, "read from private field"), t ? t.call(r) : e.get(r)), E = (r, e, t) => {
if (e.has(r)) if (e.has(r))
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(r) : e.set(r, t); e instanceof WeakSet ? e.add(r) : e.set(r, t);
}, M = (r, e, t, s) => (k(r, e, "write to private field"), s ? s.call(r, t) : e.set(r, t), t); }, C = (r, e, t, n) => (re(r, e, "write to private field"), n ? n.call(r, t) : e.set(r, t), t);
function re(r) { function he(r) {
return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r; return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r;
} }
function ae(r) { var oe = {};
if (r.length >= 255)
throw new TypeError("Alphabet too long");
for (var e = new Uint8Array(256), t = 0; t < e.length; t++)
e[t] = 255;
for (var s = 0; s < r.length; s++) {
var l = r.charAt(s), v = l.charCodeAt(0);
if (e[v] !== 255)
throw new TypeError(l + " is ambiguous");
e[v] = s;
}
var g = r.length, N = r.charAt(0), B = Math.log(g) / Math.log(256), I = Math.log(256) / Math.log(g);
function q(n) {
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");
if (n.length === 0)
return "";
for (var o = 0, f = 0, i = 0, h = n.length; i !== h && n[i] === 0; )
i++, o++;
for (var c = (h - i) * I + 1 >>> 0, d = new Uint8Array(c); i !== h; ) {
for (var O = n[i], b = 0, p = c - 1; (O !== 0 || b < f) && p !== -1; p--, b++)
O += 256 * d[p] >>> 0, d[p] = O % g >>> 0, O = O / g >>> 0;
if (O !== 0)
throw new Error("Non-zero carry");
f = b, i++;
}
for (var a = c - f; a !== c && d[a] === 0; )
a++;
for (var w = N.repeat(o); a < c; ++a)
w += r.charAt(d[a]);
return w;
}
function U(n) {
if (typeof n != "string")
throw new TypeError("Expected String");
if (n.length === 0)
return new Uint8Array();
for (var o = 0, f = 0, i = 0; n[o] === N; )
f++, o++;
for (var h = (n.length - o) * B + 1 >>> 0, c = new Uint8Array(h); n[o]; ) {
var d = e[n.charCodeAt(o)];
if (d === 255)
return;
for (var O = 0, b = h - 1; (d !== 0 || O < i) && b !== -1; b--, O++)
d += g * c[b] >>> 0, c[b] = d % 256 >>> 0, d = d / 256 >>> 0;
if (d !== 0)
throw new Error("Non-zero carry");
i = O, o++;
}
for (var p = h - i; p !== h && c[p] === 0; )
p++;
for (var a = new Uint8Array(f + (h - p)), w = f; p !== h; )
a[w++] = c[p++];
return a;
}
function j(n) {
var o = U(n);
if (o)
return o;
throw new Error("Non-base" + g + " character");
}
return {
encode: q,
decodeUnsafe: U,
decode: j
};
}
var fe = ae;
const he = /* @__PURE__ */ re(fe);
var te = {};
(function(r) { (function(r) {
(function(e) { (function(e) {
e([], function() { e([], function() {
var t = -1, s = -2, l = -3, v = -4, g = -5, N = function(o, f) { var t = -1, n = -2, s = -3, f = -4, h = -5, $ = function(a, c) {
f = f || {}; c = c || {};
var i = f.verbose || !1; var l = c.verbose || !1;
i && console.log("Normalize the JSON Object"), o = typeof o == "string" ? this.JSON.parse(o) : o, i && console.log("Creating a empty dictionary"); l && console.log("Normalize the JSON Object"), a = typeof a == "string" ? this.JSON.parse(a) : a, l && console.log("Creating a empty dictionary");
var h = { var d = {
strings: [], strings: [],
integers: [], integers: [],
floats: [] floats: []
}; };
i && console.log("Creating the AST"); l && console.log("Creating the AST");
var c = function p(a) { var g = function T(i) {
i && console.log("Calling recursiveAstBuilder with " + this.JSON.stringify(a)); l && console.log("Calling recursiveAstBuilder with " + this.JSON.stringify(i));
var w = typeof a; var w = typeof i;
if (a === null) if (i === null)
return { return {
type: "null", type: "null",
index: l index: s
}; };
if (typeof a > "u") if (typeof i > "u")
return { return {
type: "undefined", type: "undefined",
index: g index: h
}; };
if (a instanceof Array) { if (i instanceof Array) {
var S = ["@"]; var P = ["@"];
for (var E in a) for (var y in i)
a.hasOwnProperty(E) && S.push(p(a[E])); i.hasOwnProperty(y) && P.push(T(i[y]));
return S; return P;
} }
if (w === "object") { if (w === "object") {
var S = ["$"]; var P = ["$"];
for (var x in a) for (var M in i)
a.hasOwnProperty(x) && (S.push(p(x)), S.push(p(a[x]))); i.hasOwnProperty(M) && (P.push(T(M)), P.push(T(i[M])));
return S; return P;
} }
if (a === "") if (i === "")
return { return {
type: "empty", type: "empty",
index: v index: f
}; };
if (w === "string") { if (w === "string") {
var T = n.call(h.strings, a); var O = u.call(d.strings, i);
return T == -1 && (h.strings.push(I(a)), T = h.strings.length - 1), { return O == -1 && (d.strings.push(q(i)), O = d.strings.length - 1), {
type: "strings", type: "strings",
index: T index: O
}; };
} }
if (w === "number" && a % 1 === 0) { if (w === "number" && i % 1 === 0) {
var T = n.call(h.integers, a); var O = u.call(d.integers, i);
return T == -1 && (h.integers.push(U(a)), T = h.integers.length - 1), { return O == -1 && (d.integers.push(U(i)), O = d.integers.length - 1), {
type: "integers", type: "integers",
index: T index: O
}; };
} }
if (w === "number") { if (w === "number") {
var T = n.call(h.floats, a); var O = u.call(d.floats, i);
return T == -1 && (h.floats.push(a), T = h.floats.length - 1), { return O == -1 && (d.floats.push(i), O = d.floats.length - 1), {
type: "floats", type: "floats",
index: T index: O
}; };
} }
if (w === "boolean") if (w === "boolean")
return { return {
type: "boolean", type: "boolean",
index: a ? t : s index: i ? t : n
}; };
throw new Error("Unexpected argument of type " + typeof a); throw new Error("Unexpected argument of type " + typeof i);
}(o), d = h.strings.length, O = h.integers.length; }(a), b = d.strings.length, F = d.integers.length;
h.floats.length, i && console.log("Parsing the dictionary"); d.floats.length, l && console.log("Parsing the dictionary");
var b = h.strings.join("|"); var A = d.strings.join("|");
return b += "^" + h.integers.join("|"), b += "^" + h.floats.join("|"), i && console.log("Parsing the structure"), b += "^" + function p(a) { return A += "^" + d.integers.join("|"), A += "^" + d.floats.join("|"), l && console.log("Parsing the structure"), A += "^" + function T(i) {
if (i && console.log("Calling a recursiveParser with " + this.JSON.stringify(a)), a instanceof Array) { if (l && console.log("Calling a recursiveParser with " + this.JSON.stringify(i)), i instanceof Array) {
var w = a.shift(); var w = i.shift();
for (var S in a) for (var P in i)
a.hasOwnProperty(S) && (w += p(a[S]) + "|"); i.hasOwnProperty(P) && (w += T(i[P]) + "|");
return (w[w.length - 1] === "|" ? w.slice(0, -1) : w) + "]"; return (w[w.length - 1] === "|" ? w.slice(0, -1) : w) + "]";
} }
var E = a.type, x = a.index; var y = i.type, M = i.index;
if (E === "strings") if (y === "strings")
return U(x); return U(M);
if (E === "integers") if (y === "integers")
return U(d + x); return U(b + M);
if (E === "floats") if (y === "floats")
return U(d + O + x); return U(b + F + M);
if (E === "boolean") if (y === "boolean")
return a.index; return i.index;
if (E === "null") if (y === "null")
return l; return s;
if (E === "undefined") if (y === "undefined")
return g; return h;
if (E === "empty") if (y === "empty")
return v; return f;
throw new TypeError("The item is alien!"); throw new TypeError("The item is alien!");
}(c), i && console.log("Ending parser"), f.debug ? { }(g), l && console.log("Ending parser"), c.debug ? {
dictionary: h, dictionary: d,
ast: c, ast: g,
packed: b packed: A
} : b; } : A;
}, B = function(o, f) { }, _ = function(a, c) {
f = f || {}; c = c || {};
var i = o.split("^"); var l = a.split("^");
f.verbose && console.log("Building dictionary"); c.verbose && console.log("Building dictionary");
var h = [], c = i[0]; var d = [], g = l[0];
if (c !== "") { if (g !== "") {
c = c.split("|"), f.verbose && console.log("Parse the strings dictionary"); g = g.split("|"), c.verbose && console.log("Parse the strings dictionary");
for (var d = 0, O = c.length; d < O; d++) for (var b = 0, F = g.length; b < F; b++)
h.push(q(c[d])); d.push(z(g[b]));
} }
if (c = i[1], c !== "") { if (g = l[1], g !== "") {
c = c.split("|"), f.verbose && console.log("Parse the integers dictionary"); g = g.split("|"), c.verbose && console.log("Parse the integers dictionary");
for (var d = 0, O = c.length; d < O; d++) for (var b = 0, F = g.length; b < F; b++)
h.push(j(c[d])); d.push(J(g[b]));
} }
if (c = i[2], c !== "") { if (g = l[2], g !== "") {
c = c.split("|"), f.verbose && console.log("Parse the floats dictionary"); g = g.split("|"), c.verbose && console.log("Parse the floats dictionary");
for (var d = 0, O = c.length; d < O; d++) for (var b = 0, F = g.length; b < F; b++)
h.push(parseFloat(c[d])); d.push(parseFloat(g[b]));
} }
c = null, f.verbose && console.log("Tokenizing the structure"); g = null, c.verbose && console.log("Tokenizing the structure");
for (var b = "", p = [], a = i[3].length, d = 0; d < a; d++) { for (var A = "", T = [], i = l[3].length, b = 0; b < i; b++) {
var w = i[3].charAt(d); var w = l[3].charAt(b);
w === "|" || w === "$" || w === "@" || w === "]" ? (b && (p.push(j(b)), b = ""), w !== "|" && p.push(w)) : b += w; w === "|" || w === "$" || w === "@" || w === "]" ? (A && (T.push(J(A)), A = ""), w !== "|" && T.push(w)) : A += w;
} }
var S = p.length, E = 0; var P = T.length, y = 0;
return f.verbose && console.log("Starting recursive parser"), function x() { return c.verbose && console.log("Starting recursive parser"), function M() {
var T = p[E++]; var O = T[y++];
if (f.verbose && console.log("Reading collection type " + (T === "$" ? "object" : "Array")), T === "@") { if (c.verbose && console.log("Reading collection type " + (O === "$" ? "object" : "Array")), O === "@") {
for (var y = []; E < S; E++) { for (var p = []; y < P; y++) {
var C = p[E]; var S = T[y];
if (f.verbose && console.log("Read " + C + " symbol"), C === "]") if (c.verbose && console.log("Read " + S + " symbol"), S === "]")
return y; return p;
if (C === "@" || C === "$") if (S === "@" || S === "$")
y.push(x()); p.push(M());
else else
switch (C) { switch (S) {
case t: case t:
y.push(!0); p.push(!0);
break;
case n:
p.push(!1);
break; break;
case s: case s:
y.push(!1); p.push(null);
break; break;
case l: case h:
y.push(null); p.push(void 0);
break; break;
case g: case f:
y.push(void 0); p.push("");
break;
case v:
y.push("");
break; break;
default: default:
y.push(h[C]); p.push(d[S]);
} }
} }
return f.verbose && console.log("Parsed " + this.JSON.stringify(y)), y; return c.verbose && console.log("Parsed " + this.JSON.stringify(p)), p;
} }
if (T === "$") { if (O === "$") {
for (var y = {}; E < S; E++) { for (var p = {}; y < P; y++) {
var _ = p[E]; var x = T[y];
if (_ === "]") if (x === "]")
return y; return p;
_ === v ? _ = "" : _ = h[_]; x === f ? x = "" : x = d[x];
var C = p[++E]; var S = T[++y];
if (C === "@" || C === "$") if (S === "@" || S === "$")
y[_] = x(); p[x] = M();
else else
switch (C) { switch (S) {
case t: case t:
y[_] = !0; p[x] = !0;
break;
case n:
p[x] = !1;
break; break;
case s: case s:
y[_] = !1; p[x] = null;
break; break;
case l: case h:
y[_] = null; p[x] = void 0;
break; break;
case g: case f:
y[_] = void 0; p[x] = "";
break;
case v:
y[_] = "";
break; break;
default: default:
y[_] = h[C]; p[x] = d[S];
} }
} }
return f.verbose && console.log("Parsed " + this.JSON.stringify(y)), y; return c.verbose && console.log("Parsed " + this.JSON.stringify(p)), p;
} }
throw new TypeError("Bad token " + T + " isn't a type"); throw new TypeError("Bad token " + O + " isn't a type");
}(); }();
}, I = function(o) { }, q = function(a) {
return typeof o != "string" ? o : o.replace(/[\+ \|\^\%]/g, function(f) { return typeof a != "string" ? a : a.replace(/[\+ \|\^\%]/g, function(c) {
return { return {
" ": "+", " ": "+",
"+": "%2B", "+": "%2B",
"|": "%7C", "|": "%7C",
"^": "%5E", "^": "%5E",
"%": "%25" "%": "%25"
}[f]; }[c];
}); });
}, q = function(o) { }, z = function(a) {
return typeof o != "string" ? o : o.replace(/\+|%2B|%7C|%5E|%25/g, function(f) { return typeof a != "string" ? a : a.replace(/\+|%2B|%7C|%5E|%25/g, function(c) {
return { return {
"+": " ", "+": " ",
"%2B": "+", "%2B": "+",
"%7C": "|", "%7C": "|",
"%5E": "^", "%5E": "^",
"%25": "%" "%25": "%"
}[f]; }[c];
}); });
}, U = function(o) { }, U = function(a) {
return Number.prototype.toString.call(o, 36).toUpperCase(); return Number.prototype.toString.call(a, 36).toUpperCase();
}, j = function(o) { }, J = function(a) {
return parseInt(o, 36); return parseInt(a, 36);
}, n = Array.prototype.indexOf || function(o, f) { }, u = Array.prototype.indexOf || function(a, c) {
for (var i = f || 0, h = this.length; i < h; i++) for (var l = c || 0, d = this.length; l < d; l++)
if (this[i] === o) if (this[l] === a)
return i; return l;
return -1; return -1;
}; };
return { return {
JSON, JSON,
pack: N, pack: $,
unpack: B unpack: _
}; };
}); });
})(function(e, t) { })(function(e, t) {
var s = t(); var n = t();
for (var l in s) for (var s in n)
r[l] = s[l]; r[s] = n[s];
}); });
})(te); })(oe);
const ee = /* @__PURE__ */ re(te); const ne = /* @__PURE__ */ he(oe);
var J, z, D, $, L, H, K, V, Y; var D, j, I, R, Y, Q, K, W, X;
class X { class ee {
constructor(e, t, s, l, v) { constructor(e, t, n, s, f) {
P(this, "code", 0); v(this, "code", 0);
P(this, "message", "操作成功"); v(this, "message", "操作成功");
P(this, "data", null); v(this, "data", null);
P(this, "url", ""); v(this, "url", "");
P(this, "res", ""); v(this, "res", "");
// static [Symbol.hasInstance](self) { return self?.IS_ECHO_MSG !== undefined } // static [Symbol.hasInstance](self) { return self?.IS_ECHO_MSG !== undefined }
A(this, J, null); E(this, D, null);
// 判断返回 Response 对象, 还是 Response 中的 data // 判断返回 Response 对象, 还是 Response 中的 data
A(this, z, !0); E(this, j, !0);
// 判罚是否已经给出错误提示 // 判罚是否已经给出错误提示
A(this, D, !0); E(this, I, !0);
A(this, $, { E(this, R, {
get: (e, t) => u(this, L).call(this, t), get: (e, t) => o(this, Y).call(this, t),
ownKeys: () => Object.keys(u(this, $).getPrototypeOf() || {}), ownKeys: () => Object.keys(o(this, R).getPrototypeOf() || {}),
getPrototypeOf: () => u(this, z) ? this : this.data, getPrototypeOf: () => o(this, j) ? this : this.data,
getOwnPropertyDescriptor: () => ({ getOwnPropertyDescriptor: () => ({
configurable: !0, configurable: !0,
enumerable: !0, enumerable: !0,
writable: !0, writable: !0,
value: u(this, $).getPrototypeOf() value: o(this, R).getPrototypeOf()
}) })
}); });
A(this, L, (e) => e === "$echoMsg" ? u(this, K) : e === "msg" ? u(this, H) : e === "then" || e === "resp" ? (M(this, D, !0), M(this, z, e === "resp"), u(this, V)) : e === "catch" ? u(this, Y) : e === "IS_ECHO_MSG" ? u(this, D) : Reflect.get(this, e)); E(this, Y, (e) => e === "$echoMsg" ? o(this, K) : e === "msg" ? o(this, Q) : e === "then" || e === "resp" ? (C(this, I, !0), C(this, j, e === "resp"), o(this, W)) : e === "catch" ? o(this, X) : e === "IS_ECHO_MSG" ? o(this, I) : Reflect.get(this, e));
A(this, H, (e = (s) => s, t = !1) => (u(this, K).call(this), M(this, z, t), Promise.resolve(e == null ? void 0 : e(u(this, $).getPrototypeOf())))); E(this, Q, (e = (n) => n, t = !1) => (o(this, K).call(this), C(this, j, t), Promise.resolve(e == null ? void 0 : e(o(this, R).getPrototypeOf()))));
A(this, K, () => { E(this, K, () => {
u(this, D) && (M(this, D, !1), we.onMsg(this.code, this.message)); o(this, I) && (C(this, I, !1), Te.onMsg(this.code, this.message));
}); });
A(this, V, (e) => [0, 1].includes(this.code) ? Promise.resolve(e == null ? void 0 : e(u(this, $).getPrototypeOf())) : Promise.reject(u(this, J))); E(this, W, (e) => [0, 1].includes(this.code) ? Promise.resolve(e == null ? void 0 : e(o(this, R).getPrototypeOf())) : Promise.reject(o(this, D)));
A(this, Y, (e) => Promise.resolve(e(u(this, J)))); E(this, X, (e) => Promise.resolve(e(o(this, D))));
return this.code = e, this.message = t, this.data = s, this.url = l, this.res = v, M(this, J, new Proxy(this, u(this, $))); return this.code = e, this.message = t, this.data = n, this.url = s, this.res = f, C(this, D, new Proxy(this, o(this, R)));
} }
} }
J = new WeakMap(), z = new WeakMap(), D = new WeakMap(), $ = new WeakMap(), L = new WeakMap(), H = new WeakMap(), K = new WeakMap(), V = new WeakMap(), Y = new WeakMap(); D = new WeakMap(), j = new WeakMap(), I = new WeakMap(), R = new WeakMap(), Y = new WeakMap(), Q = new WeakMap(), K = new WeakMap(), W = new WeakMap(), X = new WeakMap();
const W = (r, e, t, s = "/", l = "") => new X(r, e, t, s, l); const k = (r, e, t, n = "/", s = "") => new ee(r, e, t, n, s);
var ne = [ var ie = [
"utf8", "utf8",
"utf-8", "utf-8",
"unicode-1-1-utf-8" "unicode-1-1-utf-8"
]; ];
function le(r) { function ue(r) {
if (ne.indexOf(r) < 0 && typeof r < "u" && r != null) if (ie.indexOf(r) < 0 && typeof r < "u" && r != null)
throw new RangeError("Invalid encoding type. Only utf-8 is supported"); throw new RangeError("Invalid encoding type. Only utf-8 is supported");
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 t = unescape(encodeURIComponent(e)), s = new Uint8Array(t.length); var t = unescape(encodeURIComponent(e)), n = new Uint8Array(t.length);
const l = t.split(""); const s = t.split("");
for (let v = 0; v < l.length; v++) for (let f = 0; f < s.length; f++)
s[v] = l[v].charCodeAt(0); n[f] = s[f].charCodeAt(0);
return s; return n;
}; };
} }
function ue(r) { function fe(r) {
if (ne.indexOf(r) < 0 && typeof r < "u" && r != null) if (ie.indexOf(r) < 0 && typeof r < "u" && r != null)
throw new RangeError("Invalid encoding type. Only utf-8 is supported"); throw new RangeError("Invalid encoding type. Only utf-8 is supported");
this.encoding = "utf-8", this.decode = function(e, t) { this.encoding = "utf-8", this.decode = function(e, t) {
if (typeof e > "u") if (typeof e > "u")
return ""; return "";
var s = typeof t < "u" && s in t ? t.stream : !1; var n = typeof t < "u" && n in t ? t.stream : !1;
if (typeof s != "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 l = new Uint8Array(e.buffer, e.byteOffset, e.byteLength), v = new Array(l.length); var s = new Uint8Array(e.buffer, e.byteOffset, e.byteLength), f = new Array(s.length);
for (let g = 0; g < l.length; g++) for (let h = 0; h < s.length; h++)
v[g] = String.fromCharCode(l[g]); f[h] = String.fromCharCode(s[h]);
return decodeURIComponent(escape(v.join(""))); return decodeURIComponent(escape(f.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");
}; };
} }
var se = { var ae = {
TextEncoder: le, TextEncoder: ue,
TextDecoder: ue TextDecoder: fe
}; };
const ce = new se.TextEncoder("utf8"), ge = new se.TextDecoder("utf8"), de = (r) => { const de = new ae.TextEncoder("utf8"), ge = new ae.TextDecoder("utf8"), pe = (r) => {
let e = 5381; let e = 5381;
for (let t = 0; t < r.length; t++) for (let t = 0; t < r.length; t++)
e = e * 33 ^ r.charCodeAt(t); e = e * 33 ^ r.charCodeAt(t);
return (e >>> 0).toString(16); return (e >>> 0).toString(16);
}, be = (r, e) => r.replace(new RegExp(`^${e}+|${e}+$`, "g"), ""), ve = (r) => ce.encode(r || ""), pe = (r) => ge.decode(new DataView(r), {}); }, xe = (r, e) => r.replace(new RegExp(`^${e}+|${e}+$`, "g"), ""), ve = (r) => de.encode(r || ""), Se = (r) => ge.decode(new DataView(r), {}), we = 62, V = 30, se = 31, ye = 63;
class be {
constructor(e) {
v(this, "encodeTable", []);
v(this, "decodeMap", new Uint8Array(256).fill(255));
if (e.length !== we)
throw new Error("Encoding alphabet must be 62 characters long");
if (e.includes(`
`) || e.includes("\r"))
throw new Error("Encoding alphabet contains newline character");
this.encodeTable = e.split(""), this.decodeMap = new Uint8Array(256).fill(255);
for (let t = 0; t < e.length; t++)
this.decodeMap[e.charCodeAt(t)] = t;
}
// 编码方法
encode(e) {
if (!e || e.length === 0)
return [];
const t = new Ee(this).encodeV2(e);
return String.fromCharCode(...t);
}
// 解码方法
decode(e) {
if (!e || e.length === 0)
return new Uint8Array();
const t = new Oe(this).decode(e);
return new TextDecoder().decode(t);
}
}
var G;
class Ee {
constructor(e) {
E(this, G, null);
C(this, G, e);
}
get6bits() {
let e = this.pos & 7, t = this.pos >> 3;
e === 0 && (t -= 1, e = 8);
let n = this.src[t] >> 8 - e;
return e < 6 && t > 0 && (n |= this.src[t - 1] << e), n & ye;
}
encodeV2(e) {
this.src = ve(e), this.pos = this.src.length * 8;
const t = [];
for (; this.pos > 0; ) {
let n = 6, s = this.get6bits();
(s & V) === V && ((this.pos > 6 || s > se) && (n = 5), s &= se), t.push(o(this, G).encodeTable[s].charCodeAt(0)), this.pos -= n;
}
return t;
}
}
G = new WeakMap();
var H;
class Oe {
constructor(e) {
E(this, H, null);
C(this, H, e);
}
decode(e) {
const t = new Uint8Array(Math.ceil(e.length * 6 / 8) + 1);
let n = t.length, s = 0, f = 0;
for (let h = 0; h < e.length; h++) {
const $ = e[h].charCodeAt(0), _ = o(this, H).decodeMap[$];
if (_ === 255)
throw new Error(`CorruptInputError at index ${h}`);
h === e.length - 1 ? (f |= _ << s, s += Math.ceil(Math.log2(_ + 1))) : (_ & V) === V ? (f |= _ << s, s += 5) : (f |= _ << s, s += 6), s >= 8 && (n--, t[n] = f & 255, s %= 8, f >>= 8);
}
return s > 0 && (n--, t[n] = f & 255), t.slice(n);
}
}
H = new WeakMap();
Promise.withResolvers || (Promise.withResolvers = function() { Promise.withResolvers || (Promise.withResolvers = function() {
let r, e; let r, e;
return { promise: new Promise((s, l) => { return { promise: new Promise((n, s) => {
r = s, e = l; r = n, e = s;
}), resolve: r, reject: e }; }), resolve: r, reject: e };
}); });
var F, G, Q, m, R; var L, B, Z, m, N;
class Z { class te {
constructor(e, t, s = ({}) => Promise.reject({ code: -1, msg: "请初始化HTTP请求方法主体" })) { constructor(e, t, n = ({}) => Promise.reject({ code: -1, msg: "请初始化HTTP请求方法主体" })) {
A(this, F, void 0); E(this, L, void 0);
A(this, G, void 0); E(this, B, void 0);
A(this, Q, void 0); E(this, Z, void 0);
A(this, m, { E(this, m, {
"#": /* @__PURE__ */ new Map(), "#": /* @__PURE__ */ new Map(),
// 系统缓存 // 系统缓存
$: /* @__PURE__ */ new Map() $: /* @__PURE__ */ new Map()
// 普通缓存 // 普通缓存
}); });
A(this, R, /* @__PURE__ */ new Map()); E(this, N, /* @__PURE__ */ new Map());
P(this, "request", ({ url: e = "/", method: t = "GET", ...s }, l = !1) => { v(this, "request", ({ url: e = "/", method: t = "GET", ...n }, s = !1) => {
var U, j; var U, J;
const v = t.toUpperCase(), g = de(JSON.stringify([e, v, s])), N = (U = e == null ? void 0 : e.includes) != null && U.call(e, "/_/") ? "#" : "$", { promise: B, resolve: I, reject: q } = Promise.withResolvers(); const f = t.toUpperCase(), h = pe(JSON.stringify([e, f, n])), $ = (U = e == null ? void 0 : e.includes) != null && U.call(e, "/_/") ? "#" : "$", { promise: _, resolve: q, reject: z } = Promise.withResolvers();
return u(this, m)[N].has(g) ? (console.log("缓存命中", e), I(u(this, m)[N].get(g))) : (u(this, R).has(g) ? u(this, R).get(g).push([I, q]) : u(this, R).set(g, [[I, q]]), (j = u(this, R).get(g)) != null && j.some((n) => n) && u(this, F).call(this, { url: e, method: v, ...s }).then((n) => { return o(this, m)[$].has(h) ? (console.log("缓存命中", e), q(o(this, m)[$].get(h))) : (o(this, N).has(h) ? o(this, N).get(h).push([q, z]) : o(this, N).set(h, [[q, z]]), (J = o(this, N).get(h)) != null && J.some((u) => u) && o(this, L).call(this, { url: e, method: f, ...n }).then((u) => {
if (![0, 1].includes(n.code)) if (![0, 1].includes(u.code))
throw W(n.code, n.msg, n.data, e, n == null ? void 0 : n.res); throw k(u.code, u.msg, u.data, e, u == null ? void 0 : u.res);
return [n.code, n.msg, n.data, e, n == null ? void 0 : n.res]; return [u.code, u.msg, u.data, e, u == null ? void 0 : u.res];
}).then((n) => ((N == "#" || l && v === "GET") && u(this, m)[N].set(g, n), n)).then((n) => { }).then((u) => (($ == "#" || s && f === "GET") && o(this, m)[$].set(h, u), u)).then((u) => {
var o; var a;
return (o = u(this, R).get(g)) == null ? void 0 : o.forEach((f, i, h) => { return (a = o(this, N).get(h)) == null ? void 0 : a.forEach((c, l, d) => {
f && f[0](n), delete h[i]; c && c[0](u), delete d[l];
}); });
}).catch((n) => { }).catch((u) => {
var o; var a;
u(this, m)[N].delete(g), (o = u(this, R).get(g)) == null || o.forEach((f, i, h) => { o(this, m)[$].delete(h), (a = o(this, N).get(h)) == null || a.forEach((c, l, d) => {
f && f[1](n instanceof X ? n : W(-1, n, null, e)), delete h[i]; c && c[1](u instanceof ee ? u : k(-1, u, null, e)), delete d[l];
}); });
}).finally(() => u(this, R).delete(g))), new Proxy(B, { }).finally(() => o(this, N).delete(h))), new Proxy(_, {
get: (n, o) => (...f) => n.then((i) => W(...i)[o](...f)).catch((i) => { get: (u, a) => (...c) => u.then((l) => k(...l)[a](...c)).catch((l) => {
if (!i instanceof X) if (!l instanceof ee)
throw i; throw l;
return typeof i[o] == "function" ? i[o](...f) : i[o]; return typeof l[a] == "function" ? l[a](...c) : l[a];
}) })
}); });
}); });
P(this, "get", (e, t = {}) => this.request({ url: e, method: "GET", params: t })); v(this, "get", (e, t = {}) => this.request({ url: e, method: "GET", params: t }));
P(this, "post", (e, t = {}, s = {}) => this.request({ url: e, method: "POST", data: t, params: s })); v(this, "post", (e, t = {}, n = {}) => this.request({ url: e, method: "POST", data: t, params: n }));
P(this, "put", (e, t = {}, s = {}) => this.request({ url: e, method: "PUT", data: t, params: s })); v(this, "put", (e, t = {}, n = {}) => this.request({ url: e, method: "PUT", data: t, params: n }));
P(this, "del", (e, t = {}, s = {}) => this.request({ url: e, method: "DELETE", data: t, params: s })); v(this, "del", (e, t = {}, n = {}) => this.request({ url: e, method: "DELETE", data: t, params: n }));
P(this, "download", (e, t) => { v(this, "download", (e, t) => {
}); });
P(this, "cache", (e, t = {}) => this.request({ url: e, method: "GET", params: t }, !0)); v(this, "cache", (e, t = {}) => this.request({ url: e, method: "GET", params: t }, !0));
P(this, "list", (e, t = {}) => this.get(`/api/${e}/${this.encode(t)}`)); v(this, "list", (e, t = {}) => this.get(`/api/${e}/${this.encode(t)}`));
P(this, "getAppInfo", () => { v(this, "getAppInfo", () => {
}); });
P(this, "refreshCache", (e = !1) => { v(this, "refreshCache", (e = !1) => {
e && u(this, m)["#"].clear(), u(this, m).$.clear(); e && o(this, m)["#"].clear(), o(this, m).$.clear();
}); });
P(this, "decode", (e = "", t = {}) => { v(this, "decode", (e = "", t = {}) => {
if (e === void 0 || e === "" || e === null) if (e === void 0 || e === "" || e === null)
return t; return t;
try { try {
const s = u(this, G).decode(e).buffer; const n = o(this, B).decode(e);
return ee.unpack(pe(s)); return ne.unpack(n);
} catch { } catch {
return console.warn("core.decode", e), t; return console.warn("core.decode", e), t;
} }
}); });
P(this, "encode", (e = {}) => { v(this, "encode", (e = {}) => {
const t = JSON.stringify(e, (s, l) => l === void 0 ? null : l); const t = JSON.stringify(e, (n, s) => s === void 0 ? null : s);
return u(this, G).encode(ve(ee.pack(t))); return o(this, B).encode(ne.pack(t));
}); });
M(this, Q, e), M(this, F, s), M(this, G, he(t)); C(this, Z, e), C(this, L, n), C(this, B, new be(t));
} }
} }
F = new WeakMap(), G = new WeakMap(), Q = new WeakMap(), m = new WeakMap(), R = new WeakMap(); L = new WeakMap(), B = new WeakMap(), Z = new WeakMap(), m = new WeakMap(), N = new WeakMap();
const we = Z; const Te = te;
Z.onUnhandledRejection = (r) => { te.onUnhandledRejection = (r) => {
var e, t, s, l, v, g; var e, t, n, s, f, h;
r != null && r.IS_ECHO_MSG ? ((e = r == null ? void 0 : r.$echoMsg) == null || e.call(r), (t = r == null ? void 0 : r.preventDefault) == null || t.call(r)) : (s = r.reason) != null && s.IS_ECHO_MSG && ((v = (l = r.reason) == null ? void 0 : l.$echoMsg) == null || v.call(l), (g = r == null ? void 0 : r.preventDefault) == null || g.call(r)); r != null && r.IS_ECHO_MSG ? ((e = r == null ? void 0 : r.$echoMsg) == null || e.call(r), (t = r == null ? void 0 : r.preventDefault) == null || t.call(r)) : (n = r.reason) != null && n.IS_ECHO_MSG && ((f = (s = r.reason) == null ? void 0 : s.$echoMsg) == null || f.call(s), (h = r == null ? void 0 : r.preventDefault) == null || h.call(r));
}; };
Z.onMsg = (r, e) => [0, 1].includes(r) ? console.log(e) : console.warn(e); te.onMsg = (r, e) => [0, 1].includes(r) ? console.log(e) : console.warn(e);
export { export {
we as default, Te as default,
de as signature, pe as signature,
ve as str2uint8array, ve as str2uint8array,
be as trim, xe as trim,
pe as uint8array2str Se 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.13", "version": "0.9.14",
"type": "module", "type": "module",
"files": [ "files": [
"dist" "dist"
@ -17,7 +17,6 @@
"build": "vite build" "build": "vite build"
}, },
"dependencies": { "dependencies": {
"base-x": "^4.0.0",
"jsonpack": "^1.1.5", "jsonpack": "^1.1.5",
"text-encoder": "^0.0.4" "text-encoder": "^0.0.4"
}, },