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

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,7 @@
{
"name": "ff-request",
"private": true,
"version": "0.9.13",
"version": "0.9.14",
"type": "module",
"files": [
"dist"
@ -17,7 +17,6 @@
"build": "vite build"
},
"dependencies": {
"base-x": "^4.0.0",
"jsonpack": "^1.1.5",
"text-encoder": "^0.0.4"
},