v0.11.3
This commit is contained in:
515
ff-request.js
515
ff-request.js
@@ -1,209 +1,209 @@
|
|||||||
var de = Object.defineProperty;
|
var pe = Object.defineProperty;
|
||||||
var oe = (r) => {
|
var ce = (r) => {
|
||||||
throw TypeError(r);
|
throw TypeError(r);
|
||||||
};
|
};
|
||||||
var ge = (r, e, t) => e in r ? de(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
|
var ve = (r, e, t) => e in r ? pe(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
|
||||||
var g = (r, e, t) => ge(r, typeof e != "symbol" ? e + "" : e, t), ae = (r, e, t) => e.has(r) || oe("Cannot " + t);
|
var g = (r, e, t) => ve(r, typeof e != "symbol" ? e + "" : e, t), he = (r, e, t) => e.has(r) || ce("Cannot " + t);
|
||||||
var s = (r, e, t) => (ae(r, e, "read from private field"), t ? t.call(r) : e.get(r)), w = (r, e, t) => e.has(r) ? oe("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(r) : e.set(r, t), C = (r, e, t, n) => (ae(r, e, "write to private field"), n ? n.call(r, t) : e.set(r, t), t);
|
var s = (r, e, t) => (he(r, e, "read from private field"), t ? t.call(r) : e.get(r)), p = (r, e, t) => e.has(r) ? ce("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(r) : e.set(r, t), _ = (r, e, t, n) => (he(r, e, "write to private field"), n ? n.call(r, t) : e.set(r, t), t);
|
||||||
function pe(r) {
|
function we(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;
|
||||||
}
|
}
|
||||||
var he = {};
|
var fe = {};
|
||||||
(function(r) {
|
(function(r) {
|
||||||
(function(e) {
|
(function(e) {
|
||||||
e([], function() {
|
e([], function() {
|
||||||
var t = -1, n = -2, i = -3, o = -4, l = -5, R = function(u, f) {
|
var t = -1, n = -2, i = -3, c = -4, u = -5, U = function(h, f) {
|
||||||
f = f || {};
|
f = f || {};
|
||||||
var h = f.verbose || !1;
|
var l = f.verbose || !1;
|
||||||
h && console.log("Normalize the JSON Object"), u = typeof u == "string" ? this.JSON.parse(u) : u, h && console.log("Creating a empty dictionary");
|
l && console.log("Normalize the JSON Object"), h = typeof h == "string" ? this.JSON.parse(h) : h, l && console.log("Creating a empty dictionary");
|
||||||
var d = {
|
var d = {
|
||||||
strings: [],
|
strings: [],
|
||||||
integers: [],
|
integers: [],
|
||||||
floats: []
|
floats: []
|
||||||
};
|
};
|
||||||
h && console.log("Creating the AST");
|
l && console.log("Creating the AST");
|
||||||
var p = function P(a) {
|
var v = function O(o) {
|
||||||
h && console.log("Calling recursiveAstBuilder with " + this.JSON.stringify(a));
|
l && console.log("Calling recursiveAstBuilder with " + this.JSON.stringify(o));
|
||||||
var y = typeof a;
|
var y = typeof o;
|
||||||
if (a === null)
|
if (o === null)
|
||||||
return {
|
return {
|
||||||
type: "null",
|
type: "null",
|
||||||
index: i
|
index: i
|
||||||
};
|
};
|
||||||
if (typeof a > "u")
|
if (typeof o > "u")
|
||||||
return {
|
return {
|
||||||
type: "undefined",
|
type: "undefined",
|
||||||
index: l
|
index: u
|
||||||
};
|
};
|
||||||
if (a instanceof Array) {
|
if (o instanceof Array) {
|
||||||
var S = ["@"];
|
var S = ["@"];
|
||||||
for (var b in a)
|
for (var b in o)
|
||||||
a.hasOwnProperty(b) && S.push(P(a[b]));
|
o.hasOwnProperty(b) && S.push(O(o[b]));
|
||||||
return S;
|
return S;
|
||||||
}
|
}
|
||||||
if (y === "object") {
|
if (y === "object") {
|
||||||
var S = ["$"];
|
var S = ["$"];
|
||||||
for (var m in a)
|
for (var N in o)
|
||||||
a.hasOwnProperty(m) && (S.push(P(m)), S.push(P(a[m])));
|
o.hasOwnProperty(N) && (S.push(O(N)), S.push(O(o[N])));
|
||||||
return S;
|
return S;
|
||||||
}
|
}
|
||||||
if (a === "")
|
if (o === "")
|
||||||
return {
|
return {
|
||||||
type: "empty",
|
type: "empty",
|
||||||
index: o
|
index: c
|
||||||
};
|
};
|
||||||
if (y === "string") {
|
if (y === "string") {
|
||||||
var O = H.call(d.strings, a);
|
var P = H.call(d.strings, o);
|
||||||
return O == -1 && (d.strings.push(T(a)), O = d.strings.length - 1), {
|
return P == -1 && (d.strings.push(T(o)), P = d.strings.length - 1), {
|
||||||
type: "strings",
|
type: "strings",
|
||||||
index: O
|
index: P
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (y === "number" && a % 1 === 0) {
|
if (y === "number" && o % 1 === 0) {
|
||||||
var O = H.call(d.integers, a);
|
var P = H.call(d.integers, o);
|
||||||
return O == -1 && (d.integers.push(_(a)), O = d.integers.length - 1), {
|
return P == -1 && (d.integers.push(m(o)), P = d.integers.length - 1), {
|
||||||
type: "integers",
|
type: "integers",
|
||||||
index: O
|
index: P
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (y === "number") {
|
if (y === "number") {
|
||||||
var O = H.call(d.floats, a);
|
var P = H.call(d.floats, o);
|
||||||
return O == -1 && (d.floats.push(a), O = d.floats.length - 1), {
|
return P == -1 && (d.floats.push(o), P = d.floats.length - 1), {
|
||||||
type: "floats",
|
type: "floats",
|
||||||
index: O
|
index: P
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (y === "boolean")
|
if (y === "boolean")
|
||||||
return {
|
return {
|
||||||
type: "boolean",
|
type: "boolean",
|
||||||
index: a ? t : n
|
index: o ? t : n
|
||||||
};
|
};
|
||||||
throw new Error("Unexpected argument of type " + typeof a);
|
throw new Error("Unexpected argument of type " + typeof o);
|
||||||
}(u), E = d.strings.length, j = d.integers.length;
|
}(h), E = d.strings.length, J = d.integers.length;
|
||||||
d.floats.length, h && console.log("Parsing the dictionary");
|
d.floats.length, l && console.log("Parsing the dictionary");
|
||||||
var N = d.strings.join("|");
|
var M = d.strings.join("|");
|
||||||
return N += "^" + d.integers.join("|"), N += "^" + d.floats.join("|"), h && console.log("Parsing the structure"), N += "^" + function P(a) {
|
return M += "^" + d.integers.join("|"), M += "^" + d.floats.join("|"), l && console.log("Parsing the structure"), M += "^" + function O(o) {
|
||||||
if (h && console.log("Calling a recursiveParser with " + this.JSON.stringify(a)), a instanceof Array) {
|
if (l && console.log("Calling a recursiveParser with " + this.JSON.stringify(o)), o instanceof Array) {
|
||||||
var y = a.shift();
|
var y = o.shift();
|
||||||
for (var S in a)
|
for (var S in o)
|
||||||
a.hasOwnProperty(S) && (y += P(a[S]) + "|");
|
o.hasOwnProperty(S) && (y += O(o[S]) + "|");
|
||||||
return (y[y.length - 1] === "|" ? y.slice(0, -1) : y) + "]";
|
return (y[y.length - 1] === "|" ? y.slice(0, -1) : y) + "]";
|
||||||
}
|
}
|
||||||
var b = a.type, m = a.index;
|
var b = o.type, N = o.index;
|
||||||
if (b === "strings")
|
if (b === "strings")
|
||||||
return _(m);
|
return m(N);
|
||||||
if (b === "integers")
|
if (b === "integers")
|
||||||
return _(E + m);
|
return m(E + N);
|
||||||
if (b === "floats")
|
if (b === "floats")
|
||||||
return _(E + j + m);
|
return m(E + J + N);
|
||||||
if (b === "boolean")
|
if (b === "boolean")
|
||||||
return a.index;
|
return o.index;
|
||||||
if (b === "null")
|
if (b === "null")
|
||||||
return i;
|
return i;
|
||||||
if (b === "undefined")
|
if (b === "undefined")
|
||||||
return l;
|
return u;
|
||||||
if (b === "empty")
|
if (b === "empty")
|
||||||
return o;
|
return c;
|
||||||
throw new TypeError("The item is alien!");
|
throw new TypeError("The item is alien!");
|
||||||
}(p), h && console.log("Ending parser"), f.debug ? {
|
}(v), l && console.log("Ending parser"), f.debug ? {
|
||||||
dictionary: d,
|
dictionary: d,
|
||||||
ast: p,
|
ast: v,
|
||||||
packed: N
|
packed: M
|
||||||
} : N;
|
} : M;
|
||||||
}, c = function(u, f) {
|
}, a = function(h, f) {
|
||||||
f = f || {};
|
f = f || {};
|
||||||
var h = u.split("^");
|
var l = h.split("^");
|
||||||
f.verbose && console.log("Building dictionary");
|
f.verbose && console.log("Building dictionary");
|
||||||
var d = [], p = h[0];
|
var d = [], v = l[0];
|
||||||
if (p !== "") {
|
if (v !== "") {
|
||||||
p = p.split("|"), f.verbose && console.log("Parse the strings dictionary");
|
v = v.split("|"), f.verbose && console.log("Parse the strings dictionary");
|
||||||
for (var E = 0, j = p.length; E < j; E++)
|
for (var E = 0, J = v.length; E < J; E++)
|
||||||
d.push(M(p[E]));
|
d.push(C(v[E]));
|
||||||
}
|
}
|
||||||
if (p = h[1], p !== "") {
|
if (v = l[1], v !== "") {
|
||||||
p = p.split("|"), f.verbose && console.log("Parse the integers dictionary");
|
v = v.split("|"), f.verbose && console.log("Parse the integers dictionary");
|
||||||
for (var E = 0, j = p.length; E < j; E++)
|
for (var E = 0, J = v.length; E < J; E++)
|
||||||
d.push(U(p[E]));
|
d.push(I(v[E]));
|
||||||
}
|
}
|
||||||
if (p = h[2], p !== "") {
|
if (v = l[2], v !== "") {
|
||||||
p = p.split("|"), f.verbose && console.log("Parse the floats dictionary");
|
v = v.split("|"), f.verbose && console.log("Parse the floats dictionary");
|
||||||
for (var E = 0, j = p.length; E < j; E++)
|
for (var E = 0, J = v.length; E < J; E++)
|
||||||
d.push(parseFloat(p[E]));
|
d.push(parseFloat(v[E]));
|
||||||
}
|
}
|
||||||
p = null, f.verbose && console.log("Tokenizing the structure");
|
v = null, f.verbose && console.log("Tokenizing the structure");
|
||||||
for (var N = "", P = [], a = h[3].length, E = 0; E < a; E++) {
|
for (var M = "", O = [], o = l[3].length, E = 0; E < o; E++) {
|
||||||
var y = h[3].charAt(E);
|
var y = l[3].charAt(E);
|
||||||
y === "|" || y === "$" || y === "@" || y === "]" ? (N && (P.push(U(N)), N = ""), y !== "|" && P.push(y)) : N += y;
|
y === "|" || y === "$" || y === "@" || y === "]" ? (M && (O.push(I(M)), M = ""), y !== "|" && O.push(y)) : M += y;
|
||||||
}
|
}
|
||||||
var S = P.length, b = 0;
|
var S = O.length, b = 0;
|
||||||
return f.verbose && console.log("Starting recursive parser"), function m() {
|
return f.verbose && console.log("Starting recursive parser"), function N() {
|
||||||
var O = P[b++];
|
var P = O[b++];
|
||||||
if (f.verbose && console.log("Reading collection type " + (O === "$" ? "object" : "Array")), O === "@") {
|
if (f.verbose && console.log("Reading collection type " + (P === "$" ? "object" : "Array")), P === "@") {
|
||||||
for (var v = []; b < S; b++) {
|
for (var w = []; b < S; b++) {
|
||||||
var A = P[b];
|
var A = O[b];
|
||||||
if (f.verbose && console.log("Read " + A + " symbol"), A === "]")
|
if (f.verbose && console.log("Read " + A + " symbol"), A === "]")
|
||||||
return v;
|
return w;
|
||||||
if (A === "@" || A === "$")
|
if (A === "@" || A === "$")
|
||||||
v.push(m());
|
w.push(N());
|
||||||
else
|
else
|
||||||
switch (A) {
|
switch (A) {
|
||||||
case t:
|
case t:
|
||||||
v.push(!0);
|
w.push(!0);
|
||||||
break;
|
break;
|
||||||
case n:
|
case n:
|
||||||
v.push(!1);
|
w.push(!1);
|
||||||
break;
|
break;
|
||||||
case i:
|
case i:
|
||||||
v.push(null);
|
w.push(null);
|
||||||
break;
|
break;
|
||||||
case l:
|
case u:
|
||||||
v.push(void 0);
|
w.push(void 0);
|
||||||
break;
|
break;
|
||||||
case o:
|
case c:
|
||||||
v.push("");
|
w.push("");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
v.push(d[A]);
|
w.push(d[A]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return f.verbose && console.log("Parsed " + this.JSON.stringify(v)), v;
|
return f.verbose && console.log("Parsed " + this.JSON.stringify(w)), w;
|
||||||
}
|
}
|
||||||
if (O === "$") {
|
if (P === "$") {
|
||||||
for (var v = {}; b < S; b++) {
|
for (var w = {}; b < S; b++) {
|
||||||
var x = P[b];
|
var x = O[b];
|
||||||
if (x === "]")
|
if (x === "]")
|
||||||
return v;
|
return w;
|
||||||
x === o ? x = "" : x = d[x];
|
x === c ? x = "" : x = d[x];
|
||||||
var A = P[++b];
|
var A = O[++b];
|
||||||
if (A === "@" || A === "$")
|
if (A === "@" || A === "$")
|
||||||
v[x] = m();
|
w[x] = N();
|
||||||
else
|
else
|
||||||
switch (A) {
|
switch (A) {
|
||||||
case t:
|
case t:
|
||||||
v[x] = !0;
|
w[x] = !0;
|
||||||
break;
|
break;
|
||||||
case n:
|
case n:
|
||||||
v[x] = !1;
|
w[x] = !1;
|
||||||
break;
|
break;
|
||||||
case i:
|
case i:
|
||||||
v[x] = null;
|
w[x] = null;
|
||||||
break;
|
break;
|
||||||
case l:
|
case u:
|
||||||
v[x] = void 0;
|
w[x] = void 0;
|
||||||
break;
|
break;
|
||||||
case o:
|
case c:
|
||||||
v[x] = "";
|
w[x] = "";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
v[x] = d[A];
|
w[x] = d[A];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return f.verbose && console.log("Parsed " + this.JSON.stringify(v)), v;
|
return f.verbose && console.log("Parsed " + this.JSON.stringify(w)), w;
|
||||||
}
|
}
|
||||||
throw new TypeError("Bad token " + O + " isn't a type");
|
throw new TypeError("Bad token " + P + " isn't a type");
|
||||||
}();
|
}();
|
||||||
}, T = function(u) {
|
}, T = function(h) {
|
||||||
return typeof u != "string" ? u : u.replace(/[\+ \|\^\%]/g, function(f) {
|
return typeof h != "string" ? h : h.replace(/[\+ \|\^\%]/g, function(f) {
|
||||||
return {
|
return {
|
||||||
" ": "+",
|
" ": "+",
|
||||||
"+": "%2B",
|
"+": "%2B",
|
||||||
@@ -212,8 +212,8 @@ var he = {};
|
|||||||
"%": "%25"
|
"%": "%25"
|
||||||
}[f];
|
}[f];
|
||||||
});
|
});
|
||||||
}, M = function(u) {
|
}, C = function(h) {
|
||||||
return typeof u != "string" ? u : u.replace(/\+|%2B|%7C|%5E|%25/g, function(f) {
|
return typeof h != "string" ? h : h.replace(/\+|%2B|%7C|%5E|%25/g, function(f) {
|
||||||
return {
|
return {
|
||||||
"+": " ",
|
"+": " ",
|
||||||
"%2B": "+",
|
"%2B": "+",
|
||||||
@@ -222,20 +222,20 @@ var he = {};
|
|||||||
"%25": "%"
|
"%25": "%"
|
||||||
}[f];
|
}[f];
|
||||||
});
|
});
|
||||||
}, _ = function(u) {
|
}, m = function(h) {
|
||||||
return Number.prototype.toString.call(u, 36).toUpperCase();
|
return Number.prototype.toString.call(h, 36).toUpperCase();
|
||||||
}, U = function(u) {
|
}, I = function(h) {
|
||||||
return parseInt(u, 36);
|
return parseInt(h, 36);
|
||||||
}, H = Array.prototype.indexOf || function(u, f) {
|
}, H = Array.prototype.indexOf || function(h, f) {
|
||||||
for (var h = f || 0, d = this.length; h < d; h++)
|
for (var l = f || 0, d = this.length; l < d; l++)
|
||||||
if (this[h] === u)
|
if (this[l] === h)
|
||||||
return h;
|
return l;
|
||||||
return -1;
|
return -1;
|
||||||
};
|
};
|
||||||
return {
|
return {
|
||||||
JSON,
|
JSON,
|
||||||
pack: R,
|
pack: U,
|
||||||
unpack: c
|
unpack: a
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
})(function(e, t) {
|
})(function(e, t) {
|
||||||
@@ -243,10 +243,10 @@ var he = {};
|
|||||||
for (var i in n)
|
for (var i in n)
|
||||||
r[i] = n[i];
|
r[i] = n[i];
|
||||||
});
|
});
|
||||||
})(he);
|
})(fe);
|
||||||
const ce = /* @__PURE__ */ pe(he);
|
const le = /* @__PURE__ */ we(fe);
|
||||||
var B, L, G, I, Q, W, q, X, Z, ee;
|
var $, q, B, D, W, X, z, Z, ee, te, re;
|
||||||
class se {
|
const ae = class ae {
|
||||||
/**
|
/**
|
||||||
* @param {number} code
|
* @param {number} code
|
||||||
* @param {string} message
|
* @param {string} message
|
||||||
@@ -254,7 +254,7 @@ class se {
|
|||||||
* @param {string} url
|
* @param {string} url
|
||||||
* @param {string} res
|
* @param {string} res
|
||||||
*/
|
*/
|
||||||
constructor(e, t, n, i, o) {
|
constructor(e, t, n, i, c) {
|
||||||
/** @type {number} */
|
/** @type {number} */
|
||||||
g(this, "code", 0);
|
g(this, "code", 0);
|
||||||
/** @type {string} */
|
/** @type {string} */
|
||||||
@@ -266,82 +266,99 @@ class se {
|
|||||||
/** @type {string} */
|
/** @type {string} */
|
||||||
g(this, "res", "");
|
g(this, "res", "");
|
||||||
/** @type {HttpResponse} */
|
/** @type {HttpResponse} */
|
||||||
w(this, B);
|
p(this, $);
|
||||||
// 判断返回 Response 对象, 还是 Response 中的 data
|
// 判断返回 Response 对象, 还是 Response 中的 data
|
||||||
/** @type {boolean} */
|
/** @type {boolean} */
|
||||||
w(this, L, !0);
|
p(this, q, !0);
|
||||||
// 判断是否已经给出错误提示
|
// 判断是否已经给出错误提示
|
||||||
/** @type {boolean} */
|
/** @type {boolean} */
|
||||||
w(this, G, !0);
|
p(this, B, !0);
|
||||||
w(this, I, {
|
p(this, D, {
|
||||||
/** @param {any} __ @param {string} key */
|
/** @param {any} __ @param {string} key */
|
||||||
get: (e, t) => s(this, Q).call(this, t),
|
get: (e, t) => s(this, W).call(this, t),
|
||||||
|
/** @param {any} __ @param {string} key */
|
||||||
|
set: (e, t) => {
|
||||||
|
throw new TypeError(`HttpResponse 是只读的,不能设置属性 "${t}"`);
|
||||||
|
},
|
||||||
/** @returns {string[]} */
|
/** @returns {string[]} */
|
||||||
ownKeys: () => Object.keys(s(this, I).getPrototypeOf() || {}),
|
ownKeys: () => Object.keys(s(this, D).getPrototypeOf() || {}),
|
||||||
/** @returns {HttpResponse | unknown} */
|
/** @returns {HttpResponse | unknown} */
|
||||||
getPrototypeOf: () => s(this, L) ? this : this.data,
|
getPrototypeOf: () => s(this, q) ? this : this.data,
|
||||||
/** @returns {PropertyDescriptor} */
|
/** @returns {PropertyDescriptor} */
|
||||||
getOwnPropertyDescriptor: () => ({
|
getOwnPropertyDescriptor: () => ({
|
||||||
configurable: !0,
|
configurable: !0,
|
||||||
enumerable: !0,
|
enumerable: !0,
|
||||||
writable: !0,
|
writable: !0,
|
||||||
value: s(this, I).getPrototypeOf()
|
value: s(this, D).getPrototypeOf()
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
/**
|
/**
|
||||||
* @param {string} key
|
* @param {string} key
|
||||||
* @returns {unknown}
|
* @returns {unknown}
|
||||||
*/
|
*/
|
||||||
w(this, Q, (e) => e === "$echoMsg" ? s(this, q) : e === "msg" ? s(this, W) : e === "then" || e === "resp" ? (C(this, G, !0), C(this, L, e === "resp"), s(this, X)) : e === "catch" ? s(this, Z) : e === "finally" ? s(this, ee) : e === "IS_ECHO_MSG" ? s(this, G) : Reflect.get(this, e));
|
p(this, W, (e) => e === "$echoMsg" ? s(this, z) : e === "msg" ? s(this, X) : e === "then" ? (_(this, B, !0), s(this, Z)) : e === "resp" ? (_(this, B, !0), s(this, ee)) : e === "catch" ? s(this, te) : e === "finally" ? s(this, re) : e === "IS_ECHO_MSG" ? s(this, B) : Reflect.get(this, e));
|
||||||
/**
|
/**
|
||||||
* @param {(value: unknown) => unknown} [fn]
|
* @param {(value: unknown) => unknown} [fn]
|
||||||
* @param {boolean} [isResp]
|
* @param {boolean} [isResp]
|
||||||
* @returns {Promise<unknown>}
|
* @returns {Promise<unknown>}
|
||||||
*/
|
*/
|
||||||
w(this, W, (e = (n) => n, t = !1) => (s(this, q).call(this), C(this, L, t), Promise.resolve(e == null ? void 0 : e(s(this, I).getPrototypeOf()))));
|
p(this, X, (e = (n) => n, t = !1) => (s(this, z).call(this), _(this, q, t), Promise.resolve(e == null ? void 0 : e(s(this, D).getPrototypeOf()))));
|
||||||
w(this, q, () => {
|
g(this, "toJSON", () => ({ code: this.code, message: this.message, data: this.data, url: this.url, res: this.res }));
|
||||||
s(this, G) && (C(this, G, !1), ie.onMsg(this.code, this.message));
|
g(this, "toString", () => this.message);
|
||||||
|
p(this, z, () => {
|
||||||
|
s(this, B) && (_(this, B, !1), oe.onMsg(this.code, this.message));
|
||||||
});
|
});
|
||||||
/**
|
/**
|
||||||
* @param {(value: unknown) => unknown} [fn]
|
* @param {(value: unknown) => unknown} [fn]
|
||||||
|
* @param {((reason: unknown) => unknown) | undefined} [onrejected]
|
||||||
* @returns {Promise<unknown>}
|
* @returns {Promise<unknown>}
|
||||||
*/
|
*/
|
||||||
w(this, X, (e) => [0, 1].includes(this.code) ? Promise.resolve(e == null ? void 0 : e(s(this, I).getPrototypeOf())) : Promise.reject(s(this, B)));
|
p(this, Z, (e, t) => [0, 1].includes(this.code) ? Promise.resolve(e == null ? void 0 : e(this.data)) : t ? Promise.resolve(t(s(this, $))) : Promise.reject(s(this, $)));
|
||||||
|
/**
|
||||||
|
* @param {(value: HttpResponse) => unknown} [fn]
|
||||||
|
* @param {((reason: unknown) => unknown) | undefined} [onrejected]
|
||||||
|
* @returns {Promise<unknown>}
|
||||||
|
*/
|
||||||
|
p(this, ee, (e, t) => [0, 1].includes(this.code) ? Promise.resolve(e == null ? void 0 : e(this)) : t ? Promise.resolve(t(s(this, $))) : Promise.reject(s(this, $)));
|
||||||
/**
|
/**
|
||||||
* @param {(reason: HttpResponse) => unknown} fn
|
* @param {(reason: HttpResponse) => unknown} fn
|
||||||
* @returns {Promise<unknown>}
|
* @returns {Promise<unknown>}
|
||||||
*/
|
*/
|
||||||
w(this, Z, (e) => Promise.resolve(e(s(this, B))));
|
p(this, te, (e) => Promise.resolve(e(s(this, $))));
|
||||||
/**
|
/**
|
||||||
* @param {(() => void) | undefined} [fn]
|
* @param {(() => void) | undefined} [fn]
|
||||||
* @returns {Promise<unknown>}
|
* @returns {Promise<unknown>}
|
||||||
*/
|
*/
|
||||||
w(this, ee, (e) => (e == null || e(), [0, 1].includes(this.code) ? Promise.resolve(s(this, I).getPrototypeOf()) : Promise.reject(s(this, B))));
|
p(this, re, (e) => (e == null || e(), [0, 1].includes(this.code) ? Promise.resolve(s(this, D).getPrototypeOf()) : Promise.reject(s(this, $))));
|
||||||
return this.code = e, this.message = t, this.data = n, this.url = i, this.res = o, C(this, B, new Proxy(this, s(this, I)));
|
return this.code = e, this.message = t, this.data = n, this.url = i, this.res = c, _(this, $, new Proxy(this, s(this, D)));
|
||||||
}
|
}
|
||||||
|
static [Symbol.hasInstance](e) {
|
||||||
|
return (e == null ? void 0 : e.constructor) === ae || (e == null ? void 0 : e[Symbol.for("HttpResponse")]) === !0;
|
||||||
}
|
}
|
||||||
B = new WeakMap(), L = new WeakMap(), G = new WeakMap(), I = new WeakMap(), Q = new WeakMap(), W = new WeakMap(), q = new WeakMap(), X = new WeakMap(), Z = new WeakMap(), ee = new WeakMap();
|
};
|
||||||
const ne = (r, e, t, n = "/", i = "") => new se(r, e, t, n, i);
|
$ = new WeakMap(), q = new WeakMap(), B = new WeakMap(), D = new WeakMap(), W = new WeakMap(), X = new WeakMap(), z = new WeakMap(), Z = new WeakMap(), ee = new WeakMap(), te = new WeakMap(), re = new WeakMap();
|
||||||
var ue = [
|
let L = ae;
|
||||||
|
const ie = (r, e, t, n = "/", i = "") => new L(r, e, t, n, i);
|
||||||
|
var de = [
|
||||||
"utf8",
|
"utf8",
|
||||||
"utf-8",
|
"utf-8",
|
||||||
"unicode-1-1-utf-8"
|
"unicode-1-1-utf-8"
|
||||||
];
|
];
|
||||||
function ve(r) {
|
function ye(r) {
|
||||||
if (ue.indexOf(r) < 0 && typeof r < "u" && r != null)
|
if (de.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)), n = new Uint8Array(t.length);
|
var t = unescape(encodeURIComponent(e)), n = new Uint8Array(t.length);
|
||||||
const i = t.split("");
|
const i = t.split("");
|
||||||
for (let o = 0; o < i.length; o++)
|
for (let c = 0; c < i.length; c++)
|
||||||
n[o] = i[o].charCodeAt(0);
|
n[c] = i[c].charCodeAt(0);
|
||||||
return n;
|
return n;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
function we(r) {
|
function be(r) {
|
||||||
if (ue.indexOf(r) < 0 && typeof r < "u" && r != null)
|
if (de.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")
|
||||||
@@ -350,20 +367,20 @@ function we(r) {
|
|||||||
if (typeof n != "boolean")
|
if (typeof n != "boolean")
|
||||||
throw new TypeError("stream option must be boolean");
|
throw new TypeError("stream option must be boolean");
|
||||||
if (ArrayBuffer.isView(e)) {
|
if (ArrayBuffer.isView(e)) {
|
||||||
var i = new Uint8Array(e.buffer, e.byteOffset, e.byteLength), o = new Array(i.length);
|
var i = new Uint8Array(e.buffer, e.byteOffset, e.byteLength), c = new Array(i.length);
|
||||||
for (let l = 0; l < i.length; l++)
|
for (let u = 0; u < i.length; u++)
|
||||||
o[l] = String.fromCharCode(i[l]);
|
c[u] = String.fromCharCode(i[u]);
|
||||||
return decodeURIComponent(escape(o.join("")));
|
return decodeURIComponent(escape(c.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 fe = {
|
var ge = {
|
||||||
TextEncoder: ve,
|
TextEncoder: ye,
|
||||||
TextDecoder: we
|
TextDecoder: be
|
||||||
};
|
};
|
||||||
const ye = new fe.TextEncoder("utf8"), be = new fe.TextDecoder("utf8");
|
const Ee = new ge.TextEncoder("utf8"), Pe = new ge.TextDecoder("utf8");
|
||||||
function Ee(r) {
|
function Te(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);
|
||||||
@@ -372,14 +389,14 @@ function Ee(r) {
|
|||||||
function Oe(r, e) {
|
function Oe(r, e) {
|
||||||
return r.replace(new RegExp(`^${e}+|${e}+$`, "g"), "");
|
return r.replace(new RegExp(`^${e}+|${e}+$`, "g"), "");
|
||||||
}
|
}
|
||||||
function Te(r) {
|
function Se(r) {
|
||||||
return ye.encode(r || "");
|
return Ee.encode(r || "");
|
||||||
}
|
}
|
||||||
function Me(r) {
|
function Ne(r) {
|
||||||
return be.decode(new DataView(r), {});
|
return Pe.decode(new DataView(r), {});
|
||||||
}
|
}
|
||||||
const Pe = 62, Y = 30, le = 31, Se = 63;
|
const xe = 62, Q = 30, ue = 31, me = 63;
|
||||||
class xe {
|
class Ae {
|
||||||
/**
|
/**
|
||||||
* @param {string} alphabet 62 位编码字母表
|
* @param {string} alphabet 62 位编码字母表
|
||||||
*/
|
*/
|
||||||
@@ -388,7 +405,7 @@ class xe {
|
|||||||
g(this, "encodeTable", []);
|
g(this, "encodeTable", []);
|
||||||
/** @type {Uint8Array} */
|
/** @type {Uint8Array} */
|
||||||
g(this, "decodeMap", new Uint8Array(256).fill(255));
|
g(this, "decodeMap", new Uint8Array(256).fill(255));
|
||||||
if (e.length !== Pe)
|
if (e.length !== xe)
|
||||||
throw new Error("Encoding alphabet must be 62 characters long");
|
throw new Error("Encoding alphabet must be 62 characters long");
|
||||||
if (e.includes(`
|
if (e.includes(`
|
||||||
`) || e.includes("\r"))
|
`) || e.includes("\r"))
|
||||||
@@ -414,55 +431,55 @@ class xe {
|
|||||||
*/
|
*/
|
||||||
decode(e) {
|
decode(e) {
|
||||||
if (!e || e.length === 0) return "";
|
if (!e || e.length === 0) return "";
|
||||||
const t = new Ae(this).decode(e);
|
const t = new Ce(this).decode(e);
|
||||||
return new TextDecoder().decode(t);
|
return new TextDecoder().decode(t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var z;
|
var V;
|
||||||
class _e {
|
class _e {
|
||||||
/**
|
/**
|
||||||
* @param {Base62} b62
|
* @param {Base62} b62
|
||||||
*/
|
*/
|
||||||
constructor(e) {
|
constructor(e) {
|
||||||
/** @type {Base62} */
|
/** @type {Base62} */
|
||||||
w(this, z);
|
p(this, V);
|
||||||
/** @type {Uint8Array} */
|
/** @type {Uint8Array} */
|
||||||
g(this, "src", new Uint8Array());
|
g(this, "src", new Uint8Array());
|
||||||
/** @type {number} */
|
/** @type {number} */
|
||||||
g(this, "pos", 0);
|
g(this, "pos", 0);
|
||||||
C(this, z, e);
|
_(this, V, e);
|
||||||
}
|
}
|
||||||
/** @returns {number} */
|
/** @returns {number} */
|
||||||
get6bits() {
|
get6bits() {
|
||||||
let e = this.pos & 7, t = this.pos >> 3;
|
let e = this.pos & 7, t = this.pos >> 3;
|
||||||
e === 0 && (t -= 1, e = 8);
|
e === 0 && (t -= 1, e = 8);
|
||||||
let n = this.src[t] >> 8 - e;
|
let n = this.src[t] >> 8 - e;
|
||||||
return e < 6 && t > 0 && (n |= this.src[t - 1] << e), n & Se;
|
return e < 6 && t > 0 && (n |= this.src[t - 1] << e), n & me;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @param {string} src
|
* @param {string} src
|
||||||
* @returns {number[]}
|
* @returns {number[]}
|
||||||
*/
|
*/
|
||||||
encodeV2(e) {
|
encodeV2(e) {
|
||||||
this.src = Te(e), this.pos = this.src.length * 8;
|
this.src = Se(e), this.pos = this.src.length * 8;
|
||||||
const t = [];
|
const t = [];
|
||||||
for (; this.pos > 0; ) {
|
for (; this.pos > 0; ) {
|
||||||
let n = 6, i = this.get6bits();
|
let n = 6, i = this.get6bits();
|
||||||
(i & Y) === Y && ((this.pos > 6 || i > le) && (n = 5), i &= le), t.push(s(this, z).encodeTable[i].charCodeAt(0)), this.pos -= n;
|
(i & Q) === Q && ((this.pos > 6 || i > ue) && (n = 5), i &= ue), t.push(s(this, V).encodeTable[i].charCodeAt(0)), this.pos -= n;
|
||||||
}
|
}
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
z = new WeakMap();
|
V = new WeakMap();
|
||||||
var V;
|
var k;
|
||||||
class Ae {
|
class Ce {
|
||||||
/**
|
/**
|
||||||
* @param {Base62} b62
|
* @param {Base62} b62
|
||||||
*/
|
*/
|
||||||
constructor(e) {
|
constructor(e) {
|
||||||
/** @type {Base62} */
|
/** @type {Base62} */
|
||||||
w(this, V);
|
p(this, k);
|
||||||
C(this, V, e);
|
_(this, k, e);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @param {string} src
|
* @param {string} src
|
||||||
@@ -470,25 +487,25 @@ class Ae {
|
|||||||
*/
|
*/
|
||||||
decode(e) {
|
decode(e) {
|
||||||
const t = new Uint8Array(Math.ceil(e.length * 6 / 8) + 1);
|
const t = new Uint8Array(Math.ceil(e.length * 6 / 8) + 1);
|
||||||
let n = t.length, i = 0, o = 0;
|
let n = t.length, i = 0, c = 0;
|
||||||
for (let l = 0; l < e.length; l++) {
|
for (let u = 0; u < e.length; u++) {
|
||||||
const R = e[l].charCodeAt(0), c = s(this, V).decodeMap[R];
|
const U = e[u].charCodeAt(0), a = s(this, k).decodeMap[U];
|
||||||
if (c === 255)
|
if (a === 255)
|
||||||
throw new Error(`CorruptInputError at index ${l}`);
|
throw new Error(`CorruptInputError at index ${u}`);
|
||||||
l === e.length - 1 ? (o |= c << i, i += Math.ceil(Math.log2(c + 1))) : (c & Y) === Y ? (o |= c << i, i += 5) : (o |= c << i, i += 6), i >= 8 && (n--, t[n] = o & 255, i %= 8, o >>= 8);
|
u === e.length - 1 ? (c |= a << i, i += Math.ceil(Math.log2(a + 1))) : (a & Q) === Q ? (c |= a << i, i += 5) : (c |= a << i, i += 6), i >= 8 && (n--, t[n] = c & 255, i %= 8, c >>= 8);
|
||||||
}
|
}
|
||||||
return i > 0 && (n--, t[n] = o & 255), t.slice(n);
|
return i > 0 && (n--, t[n] = c & 255), t.slice(n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
V = new WeakMap();
|
k = new WeakMap();
|
||||||
Promise.withResolvers || (Promise.withResolvers = function() {
|
Promise.withResolvers || (Promise.withResolvers = function() {
|
||||||
let r, e;
|
let r, e;
|
||||||
return { promise: new Promise((n, i) => {
|
return { promise: new Promise((n, i) => {
|
||||||
r = n, e = i;
|
r = n, e = i;
|
||||||
}), resolve: r, reject: e };
|
}), resolve: r, reject: e };
|
||||||
});
|
});
|
||||||
var J, D, te, $, F, K, re, k;
|
var G, j, ne, R, F, K, se, Y;
|
||||||
class ie {
|
class oe {
|
||||||
/**
|
/**
|
||||||
* @param {string} [appKey]
|
* @param {string} [appKey]
|
||||||
* @param {string} [appSecret]
|
* @param {string} [appSecret]
|
||||||
@@ -496,21 +513,21 @@ class ie {
|
|||||||
*/
|
*/
|
||||||
constructor(e, t, n) {
|
constructor(e, t, n) {
|
||||||
/** @type {RequestFn | undefined} */
|
/** @type {RequestFn | undefined} */
|
||||||
w(this, J);
|
p(this, G);
|
||||||
/** @type {Base62 | undefined} */
|
/** @type {Base62 | undefined} */
|
||||||
w(this, D);
|
p(this, j);
|
||||||
/** @type {string | undefined} */
|
/** @type {string | undefined} */
|
||||||
w(this, te);
|
p(this, ne);
|
||||||
w(this, $, {
|
p(this, R, {
|
||||||
/** @type {Map<string, CacheEntry>} */
|
/** @type {Map<string, CacheEntry>} */
|
||||||
"#": /* @__PURE__ */ new Map(),
|
"#": /* @__PURE__ */ new Map(),
|
||||||
/** @type {Map<string, CacheEntry>} */
|
/** @type {Map<string, CacheEntry>} */
|
||||||
$: /* @__PURE__ */ new Map()
|
$: /* @__PURE__ */ new Map()
|
||||||
});
|
});
|
||||||
/** @type {Map<string, Array<[Function, Function] | null>>} */
|
/** @type {Map<string, Array<[Function, Function] | null>>} */
|
||||||
w(this, F, /* @__PURE__ */ new Map());
|
p(this, F, /* @__PURE__ */ new Map());
|
||||||
/** @type {Set<[string, '#' | '$', RequestOptions & { method: string }, boolean]>} */
|
/** @type {Set<[string, '#' | '$', RequestOptions & { method: string }, boolean]>} */
|
||||||
w(this, K, /* @__PURE__ */ new Set());
|
p(this, K, /* @__PURE__ */ new Set());
|
||||||
/**
|
/**
|
||||||
* 初始化请求实例
|
* 初始化请求实例
|
||||||
* @param {string} [appKey]
|
* @param {string} [appKey]
|
||||||
@@ -518,10 +535,10 @@ class ie {
|
|||||||
* @param {RequestFn} [reqFn]
|
* @param {RequestFn} [reqFn]
|
||||||
*/
|
*/
|
||||||
g(this, "init", (e, t, n) => {
|
g(this, "init", (e, t, n) => {
|
||||||
e && C(this, te, e), n && C(this, J, n), t && C(this, D, new xe(t)), s(this, re).call(this);
|
e && _(this, ne, e), n && _(this, G, n), t && _(this, j, new Ae(t)), s(this, se).call(this);
|
||||||
});
|
});
|
||||||
w(this, re, () => {
|
p(this, se, () => {
|
||||||
!s(this, K).size || !s(this, J) || (s(this, K).forEach((e) => s(this, k).call(this, ...e)), s(this, K).clear());
|
!s(this, K).size || !s(this, G) || (s(this, K).forEach((e) => s(this, Y).call(this, ...e)), s(this, K).clear());
|
||||||
});
|
});
|
||||||
/**
|
/**
|
||||||
* @param {string} hash
|
* @param {string} hash
|
||||||
@@ -529,32 +546,32 @@ class ie {
|
|||||||
* @param {RequestOptions & { method: string }} params
|
* @param {RequestOptions & { method: string }} params
|
||||||
* @param {boolean} [isCacheRequest]
|
* @param {boolean} [isCacheRequest]
|
||||||
*/
|
*/
|
||||||
w(this, k, (e, t, n, i = !1) => {
|
p(this, Y, (e, t, n, i = !1) => {
|
||||||
if (!s(this, J))
|
if (!s(this, G))
|
||||||
s(this, K).add([e, t, n, i]);
|
s(this, K).add([e, t, n, i]);
|
||||||
else {
|
else {
|
||||||
const { url: o, method: l, ...R } = n || {};
|
const { url: c, method: u, ...U } = n || {};
|
||||||
s(this, J).call(this, { url: o, method: l, ...R }).then((c) => {
|
s(this, G).call(this, { url: c, method: u, ...U }).then((a) => {
|
||||||
if (![0, 1].includes(c.code))
|
if (![0, 1].includes(a.code))
|
||||||
throw ne(c.code, c.msg, c.data, o, c == null ? void 0 : c.res);
|
throw ie(a.code ?? -1, a.msg ?? "响应格式错误", a.data, c, a == null ? void 0 : a.res);
|
||||||
return [c.code, c.msg, c.data, o, (c == null ? void 0 : c.res) ?? ""];
|
return [a.code, a.msg, a.data, c, (a == null ? void 0 : a.res) ?? ""];
|
||||||
}).then((c) => {
|
}).then((a) => {
|
||||||
const T = (
|
const T = (
|
||||||
/** @type {CacheEntry} */
|
/** @type {CacheEntry} */
|
||||||
c
|
a
|
||||||
);
|
);
|
||||||
return (t == "#" || l == "GET") && s(this, $)[t].set(e, T), t != "#" && l == "GET" && !i && setTimeout(() => {
|
return (t == "#" || u == "GET") && s(this, R)[t].set(e, T), t != "#" && u == "GET" && !i && setTimeout(() => {
|
||||||
s(this, $)[t].delete(e);
|
s(this, R)[t].delete(e);
|
||||||
}, 300), T;
|
}, 300), T;
|
||||||
}).then((c) => {
|
}).then((a) => {
|
||||||
var T;
|
var T;
|
||||||
return (T = s(this, F).get(e)) == null ? void 0 : T.forEach((M, _, U) => {
|
return (T = s(this, F).get(e)) == null ? void 0 : T.forEach((C, m, I) => {
|
||||||
M && M[0](c), delete U[_];
|
C && C[0](a), delete I[m];
|
||||||
});
|
});
|
||||||
}).catch((c) => {
|
}).catch((a) => {
|
||||||
var T;
|
var T;
|
||||||
s(this, $)[t].delete(e), (T = s(this, F).get(e)) == null || T.forEach((M, _, U) => {
|
s(this, R)[t].delete(e), (T = s(this, F).get(e)) == null || T.forEach((C, m, I) => {
|
||||||
M && M[1](c instanceof se ? c : ne(-1, c, null, o)), delete U[_];
|
C && C[1](a instanceof L ? a : ie(-1, a, null, c)), delete I[m];
|
||||||
});
|
});
|
||||||
}).finally(() => s(this, F).delete(e));
|
}).finally(() => s(this, F).delete(e));
|
||||||
}
|
}
|
||||||
@@ -566,31 +583,32 @@ class ie {
|
|||||||
* @returns {any} 返回 Proxy 包裹的 Promise,支持链式调用 .then / .catch / .msg / .resp
|
* @returns {any} 返回 Proxy 包裹的 Promise,支持链式调用 .then / .catch / .msg / .resp
|
||||||
*/
|
*/
|
||||||
g(this, "request", ({ url: e = "/", method: t = "GET", ...n }, i = !1) => {
|
g(this, "request", ({ url: e = "/", method: t = "GET", ...n }, i = !1) => {
|
||||||
var _, U;
|
var m, I;
|
||||||
e = Oe(e, "/");
|
e = Oe(e, "/");
|
||||||
const o = (
|
const c = (
|
||||||
/** @type {HttpMethod} */
|
/** @type {HttpMethod} */
|
||||||
t.toUpperCase()
|
t.toUpperCase()
|
||||||
), l = Ee(JSON.stringify([e, o, n])), R = (
|
), u = Te(JSON.stringify([e, c, n])), U = (
|
||||||
/** @type {'#' | '$'} */
|
/** @type {'#' | '$'} */
|
||||||
(_ = e == null ? void 0 : e.includes) != null && _.call(e, "/_/") ? "#" : "$"
|
(m = e == null ? void 0 : e.includes) != null && m.call(e, "/_/") ? "#" : "$"
|
||||||
), { promise: c, resolve: T, reject: M } = Promise.withResolvers();
|
), { promise: a, resolve: T, reject: C } = Promise.withResolvers();
|
||||||
return s(this, $)[R].has(l) ? (console.log("cache", e), T(s(this, $)[R].get(l))) : s(this, F).has(l) ? (U = s(this, F).get(l)) == null || U.push([T, M]) : (s(this, F).set(l, [[T, M]]), s(this, k).call(this, l, R, { url: e, method: o, ...n }, i)), new Proxy(c, {
|
return s(this, R)[U].has(u) ? (console.log("cache", e), T(s(this, R)[U].get(u))) : s(this, F).has(u) ? (I = s(this, F).get(u)) == null || I.push([T, C]) : (s(this, F).set(u, [[T, C]]), s(this, Y).call(this, u, U, { url: e, method: c, ...n }, i)), new Proxy(a, {
|
||||||
get: (H, u) => (...f) => H.then((h) => (
|
// Symbol.for('HttpResponse') 是标记,用于外部 instanceof 识别此 Proxy 为 HttpResponse 类型
|
||||||
|
get: (H, h) => h === Symbol.for("HttpResponse") ? !0 : (...f) => H.then((l) => (
|
||||||
/** @type {any} */
|
/** @type {any} */
|
||||||
ne(
|
ie(
|
||||||
.../** @type {[number, string, unknown, string, string]} */
|
.../** @type {[number, string, unknown, string, string]} */
|
||||||
h
|
l
|
||||||
)[u](...f)
|
)[h](...f)
|
||||||
)).catch((h) => {
|
)).catch((l) => {
|
||||||
if (!(h instanceof se)) throw h;
|
if (!(l instanceof L)) throw l;
|
||||||
return typeof /** @type {any} */
|
return typeof /** @type {any} */
|
||||||
h[u] == "function" ? (
|
l[h] == "function" ? (
|
||||||
/** @type {any} */
|
/** @type {any} */
|
||||||
h[u](...f)
|
l[h](...f)
|
||||||
) : (
|
) : (
|
||||||
/** @type {any} */
|
/** @type {any} */
|
||||||
h[u]
|
l[h]
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
@@ -651,7 +669,7 @@ class ie {
|
|||||||
* @param {boolean} [isSystem] 是否同时清除系统缓存(`/_/` 路由)
|
* @param {boolean} [isSystem] 是否同时清除系统缓存(`/_/` 路由)
|
||||||
*/
|
*/
|
||||||
g(this, "refreshCache", (e = !1) => {
|
g(this, "refreshCache", (e = !1) => {
|
||||||
e && s(this, $)["#"].clear(), s(this, $).$.clear();
|
e && s(this, R)["#"].clear(), s(this, R).$.clear();
|
||||||
});
|
});
|
||||||
/**
|
/**
|
||||||
* 解码 Base62 字符串为 JSON 对象
|
* 解码 Base62 字符串为 JSON 对象
|
||||||
@@ -663,9 +681,9 @@ class ie {
|
|||||||
if (e === void 0 || e === "" || e === null)
|
if (e === void 0 || e === "" || e === null)
|
||||||
return t;
|
return t;
|
||||||
try {
|
try {
|
||||||
if (!s(this, D)) throw new Error("未初始化 appSecret,请先通过 init 设置 appSecret");
|
if (!s(this, j)) throw new Error("未初始化 appSecret,请先通过 init 设置 appSecret");
|
||||||
const n = s(this, D).decode(e);
|
const n = s(this, j).decode(e);
|
||||||
return ce.unpack(n);
|
return le.unpack(n);
|
||||||
} catch {
|
} catch {
|
||||||
return console.warn("core.decode", e), t;
|
return console.warn("core.decode", e), t;
|
||||||
}
|
}
|
||||||
@@ -676,25 +694,26 @@ class ie {
|
|||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
g(this, "encode", (e = {}) => {
|
g(this, "encode", (e = {}) => {
|
||||||
if (!s(this, D)) throw new Error("未初始化 appSecret,请先通过 init 设置 appSecret");
|
if (!s(this, j)) throw new Error("未初始化 appSecret,请先通过 init 设置 appSecret");
|
||||||
const t = JSON.stringify(e, (n, i) => i === void 0 ? null : i);
|
const t = JSON.stringify(e, (n, i) => i === void 0 ? null : i);
|
||||||
return s(this, D).encode(ce.pack(t));
|
return s(this, j).encode(le.pack(t));
|
||||||
});
|
});
|
||||||
this.init(e, t, n);
|
this.init(e, t, n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
J = new WeakMap(), D = new WeakMap(), te = new WeakMap(), $ = new WeakMap(), F = new WeakMap(), K = new WeakMap(), re = new WeakMap(), k = new WeakMap();
|
G = new WeakMap(), j = new WeakMap(), ne = new WeakMap(), R = new WeakMap(), F = new WeakMap(), K = new WeakMap(), se = new WeakMap(), Y = new WeakMap();
|
||||||
ie.onUnhandledRejection = (r) => {
|
oe.onUnhandledRejection = (r) => {
|
||||||
var e, t, n, i, o, l;
|
var 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)) : (n = r.reason) != null && n.IS_ECHO_MSG && ((o = (i = r.reason) == null ? void 0 : i.$echoMsg) == null || o.call(i), (l = r == null ? void 0 : r.preventDefault) == null || l.call(r));
|
const e = r instanceof L ? r : (r == null ? void 0 : r.reason) instanceof L ? r.reason : null;
|
||||||
|
e != null && e.IS_ECHO_MSG && (e.$echoMsg(), (t = r == null ? void 0 : r.preventDefault) == null || t.call(r));
|
||||||
};
|
};
|
||||||
ie.onMsg = (r, e) => [0, 1].includes(r) ? console.log(e) : console.warn(e);
|
oe.onMsg = (r, e) => [0, 1].includes(r) ? console.log(e) : console.warn(e);
|
||||||
export {
|
export {
|
||||||
se as HttpResponse,
|
L as HttpResponse,
|
||||||
ne as NewHttpResponse,
|
ie as NewHttpResponse,
|
||||||
ie as default,
|
oe as default,
|
||||||
Ee as signature,
|
Te as signature,
|
||||||
Te as str2uint8array,
|
Se as str2uint8array,
|
||||||
Oe as trim,
|
Oe as trim,
|
||||||
Me as uint8array2str
|
Ne as uint8array2str
|
||||||
};
|
};
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ff-request",
|
"name": "ff-request",
|
||||||
"version": "0.11.2",
|
"version": "0.11.3",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "./ff-request.umd.cjs",
|
"main": "./ff-request.umd.cjs",
|
||||||
"module": "./ff-request.js",
|
"module": "./ff-request.js",
|
||||||
|
|||||||
9
types/index.d.ts
vendored
9
types/index.d.ts
vendored
@@ -127,6 +127,7 @@ export default HttpRequest;
|
|||||||
* @property {string} res
|
* @property {string} res
|
||||||
*/
|
*/
|
||||||
export declare class HttpResponse {
|
export declare class HttpResponse {
|
||||||
|
static [Symbol.hasInstance](instance: any): boolean;
|
||||||
/**
|
/**
|
||||||
* @param {number} code
|
* @param {number} code
|
||||||
* @param {string} message
|
* @param {string} message
|
||||||
@@ -145,6 +146,14 @@ export declare class HttpResponse {
|
|||||||
url: string;
|
url: string;
|
||||||
/** @type {string} */
|
/** @type {string} */
|
||||||
res: string;
|
res: string;
|
||||||
|
toJSON: () => {
|
||||||
|
code: number;
|
||||||
|
message: string;
|
||||||
|
data: unknown;
|
||||||
|
url: string;
|
||||||
|
res: string;
|
||||||
|
};
|
||||||
|
toString: () => string;
|
||||||
#private;
|
#private;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user