This commit is contained in:
what 2024-07-23 11:16:38 +08:00
parent 287d3fda40
commit 36957867f4
3 changed files with 233 additions and 227 deletions

456
dist/ff-request.js vendored
View File

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