v0.10.3
This commit is contained in:
parent
b9aeab9a6e
commit
ef2a90987c
206
dist/ff-request.js
vendored
206
dist/ff-request.js
vendored
@ -1,6 +1,6 @@
|
|||||||
var ue = Object.defineProperty;
|
var fe = Object.defineProperty;
|
||||||
var fe = (r, e, t) => e in r ? ue(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
|
var ue = (r, e, t) => e in r ? fe(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
|
||||||
var p = (r, e, t) => (fe(r, typeof e != "symbol" ? e + "" : e, t), t), ie = (r, e, t) => {
|
var p = (r, e, t) => (ue(r, typeof e != "symbol" ? e + "" : e, t), t), ie = (r, e, t) => {
|
||||||
if (!e.has(r))
|
if (!e.has(r))
|
||||||
throw TypeError("Cannot " + t);
|
throw TypeError("Cannot " + t);
|
||||||
};
|
};
|
||||||
@ -16,11 +16,11 @@ var ce = {};
|
|||||||
(function(r) {
|
(function(r) {
|
||||||
(function(e) {
|
(function(e) {
|
||||||
e([], function() {
|
e([], function() {
|
||||||
var t = -1, n = -2, s = -3, o = -4, h = -5, R = function(f, l) {
|
var t = -1, n = -2, s = -3, o = -4, h = -5, R = function(u, l) {
|
||||||
l = l || {};
|
l = l || {};
|
||||||
var w = l.verbose || !1;
|
var w = l.verbose || !1;
|
||||||
w && console.log("Normalize the JSON Object"), f = typeof f == "string" ? this.JSON.parse(f) : f, w && console.log("Creating a empty dictionary");
|
w && console.log("Normalize the JSON Object"), u = typeof u == "string" ? this.JSON.parse(u) : u, w && console.log("Creating a empty dictionary");
|
||||||
var u = {
|
var f = {
|
||||||
strings: [],
|
strings: [],
|
||||||
integers: [],
|
integers: [],
|
||||||
floats: []
|
floats: []
|
||||||
@ -40,16 +40,16 @@ var ce = {};
|
|||||||
index: h
|
index: h
|
||||||
};
|
};
|
||||||
if (c instanceof Array) {
|
if (c instanceof Array) {
|
||||||
var x = ["@"];
|
var S = ["@"];
|
||||||
for (var b in c)
|
for (var b in c)
|
||||||
c.hasOwnProperty(b) && x.push(T(c[b]));
|
c.hasOwnProperty(b) && S.push(T(c[b]));
|
||||||
return x;
|
return S;
|
||||||
}
|
}
|
||||||
if (y === "object") {
|
if (y === "object") {
|
||||||
var x = ["$"];
|
var S = ["$"];
|
||||||
for (var $ in c)
|
for (var $ in c)
|
||||||
c.hasOwnProperty($) && (x.push(T($)), x.push(T(c[$])));
|
c.hasOwnProperty($) && (S.push(T($)), S.push(T(c[$])));
|
||||||
return x;
|
return S;
|
||||||
}
|
}
|
||||||
if (c === "")
|
if (c === "")
|
||||||
return {
|
return {
|
||||||
@ -57,22 +57,22 @@ var ce = {};
|
|||||||
index: o
|
index: o
|
||||||
};
|
};
|
||||||
if (y === "string") {
|
if (y === "string") {
|
||||||
var O = I.call(u.strings, c);
|
var O = F.call(f.strings, c);
|
||||||
return O == -1 && (u.strings.push(S(c)), O = u.strings.length - 1), {
|
return O == -1 && (f.strings.push(P(c)), O = f.strings.length - 1), {
|
||||||
type: "strings",
|
type: "strings",
|
||||||
index: O
|
index: O
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (y === "number" && c % 1 === 0) {
|
if (y === "number" && c % 1 === 0) {
|
||||||
var O = I.call(u.integers, c);
|
var O = F.call(f.integers, c);
|
||||||
return O == -1 && (u.integers.push(_(c)), O = u.integers.length - 1), {
|
return O == -1 && (f.integers.push(_(c)), O = f.integers.length - 1), {
|
||||||
type: "integers",
|
type: "integers",
|
||||||
index: O
|
index: O
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (y === "number") {
|
if (y === "number") {
|
||||||
var O = I.call(u.floats, c);
|
var O = F.call(f.floats, c);
|
||||||
return O == -1 && (u.floats.push(c), O = u.floats.length - 1), {
|
return O == -1 && (f.floats.push(c), O = f.floats.length - 1), {
|
||||||
type: "floats",
|
type: "floats",
|
||||||
index: O
|
index: O
|
||||||
};
|
};
|
||||||
@ -83,14 +83,14 @@ var ce = {};
|
|||||||
index: c ? t : n
|
index: c ? t : n
|
||||||
};
|
};
|
||||||
throw new Error("Unexpected argument of type " + typeof c);
|
throw new Error("Unexpected argument of type " + typeof c);
|
||||||
}(f), E = u.strings.length, B = u.integers.length;
|
}(u), E = f.strings.length, j = f.integers.length;
|
||||||
u.floats.length, w && console.log("Parsing the dictionary");
|
f.floats.length, w && console.log("Parsing the dictionary");
|
||||||
var N = u.strings.join("|");
|
var N = f.strings.join("|");
|
||||||
return N += "^" + u.integers.join("|"), N += "^" + u.floats.join("|"), w && console.log("Parsing the structure"), N += "^" + function T(c) {
|
return N += "^" + f.integers.join("|"), N += "^" + f.floats.join("|"), w && console.log("Parsing the structure"), N += "^" + function T(c) {
|
||||||
if (w && console.log("Calling a recursiveParser with " + this.JSON.stringify(c)), c instanceof Array) {
|
if (w && console.log("Calling a recursiveParser with " + this.JSON.stringify(c)), c instanceof Array) {
|
||||||
var y = c.shift();
|
var y = c.shift();
|
||||||
for (var x in c)
|
for (var S in c)
|
||||||
c.hasOwnProperty(x) && (y += T(c[x]) + "|");
|
c.hasOwnProperty(S) && (y += T(c[S]) + "|");
|
||||||
return (y[y.length - 1] === "|" ? y.slice(0, -1) : y) + "]";
|
return (y[y.length - 1] === "|" ? y.slice(0, -1) : y) + "]";
|
||||||
}
|
}
|
||||||
var b = c.type, $ = c.index;
|
var b = c.type, $ = c.index;
|
||||||
@ -99,7 +99,7 @@ var ce = {};
|
|||||||
if (b === "integers")
|
if (b === "integers")
|
||||||
return _(E + $);
|
return _(E + $);
|
||||||
if (b === "floats")
|
if (b === "floats")
|
||||||
return _(E + B + $);
|
return _(E + j + $);
|
||||||
if (b === "boolean")
|
if (b === "boolean")
|
||||||
return c.index;
|
return c.index;
|
||||||
if (b === "null")
|
if (b === "null")
|
||||||
@ -110,40 +110,40 @@ var ce = {};
|
|||||||
return o;
|
return o;
|
||||||
throw new TypeError("The item is alien!");
|
throw new TypeError("The item is alien!");
|
||||||
}(d), w && console.log("Ending parser"), l.debug ? {
|
}(d), w && console.log("Ending parser"), l.debug ? {
|
||||||
dictionary: u,
|
dictionary: f,
|
||||||
ast: d,
|
ast: d,
|
||||||
packed: N
|
packed: N
|
||||||
} : N;
|
} : N;
|
||||||
}, a = function(f, l) {
|
}, a = function(u, l) {
|
||||||
l = l || {};
|
l = l || {};
|
||||||
var w = f.split("^");
|
var w = u.split("^");
|
||||||
l.verbose && console.log("Building dictionary");
|
l.verbose && console.log("Building dictionary");
|
||||||
var u = [], d = w[0];
|
var f = [], d = w[0];
|
||||||
if (d !== "") {
|
if (d !== "") {
|
||||||
d = d.split("|"), l.verbose && console.log("Parse the strings dictionary");
|
d = d.split("|"), l.verbose && console.log("Parse the strings dictionary");
|
||||||
for (var E = 0, B = d.length; E < B; E++)
|
for (var E = 0, j = d.length; E < j; E++)
|
||||||
u.push(M(d[E]));
|
f.push(M(d[E]));
|
||||||
}
|
}
|
||||||
if (d = w[1], d !== "") {
|
if (d = w[1], d !== "") {
|
||||||
d = d.split("|"), l.verbose && console.log("Parse the integers dictionary");
|
d = d.split("|"), l.verbose && console.log("Parse the integers dictionary");
|
||||||
for (var E = 0, B = d.length; E < B; E++)
|
for (var E = 0, j = d.length; E < j; E++)
|
||||||
u.push(F(d[E]));
|
f.push(I(d[E]));
|
||||||
}
|
}
|
||||||
if (d = w[2], d !== "") {
|
if (d = w[2], d !== "") {
|
||||||
d = d.split("|"), l.verbose && console.log("Parse the floats dictionary");
|
d = d.split("|"), l.verbose && console.log("Parse the floats dictionary");
|
||||||
for (var E = 0, B = d.length; E < B; E++)
|
for (var E = 0, j = d.length; E < j; E++)
|
||||||
u.push(parseFloat(d[E]));
|
f.push(parseFloat(d[E]));
|
||||||
}
|
}
|
||||||
d = null, l.verbose && console.log("Tokenizing the structure");
|
d = null, l.verbose && console.log("Tokenizing the structure");
|
||||||
for (var N = "", T = [], c = w[3].length, E = 0; E < c; E++) {
|
for (var N = "", T = [], c = w[3].length, E = 0; E < c; E++) {
|
||||||
var y = w[3].charAt(E);
|
var y = w[3].charAt(E);
|
||||||
y === "|" || y === "$" || y === "@" || y === "]" ? (N && (T.push(F(N)), N = ""), y !== "|" && T.push(y)) : N += y;
|
y === "|" || y === "$" || y === "@" || y === "]" ? (N && (T.push(I(N)), N = ""), y !== "|" && T.push(y)) : N += y;
|
||||||
}
|
}
|
||||||
var x = T.length, b = 0;
|
var S = T.length, b = 0;
|
||||||
return l.verbose && console.log("Starting recursive parser"), function $() {
|
return l.verbose && console.log("Starting recursive parser"), function $() {
|
||||||
var O = T[b++];
|
var O = T[b++];
|
||||||
if (l.verbose && console.log("Reading collection type " + (O === "$" ? "object" : "Array")), O === "@") {
|
if (l.verbose && console.log("Reading collection type " + (O === "$" ? "object" : "Array")), O === "@") {
|
||||||
for (var g = []; b < x; b++) {
|
for (var g = []; b < S; b++) {
|
||||||
var A = T[b];
|
var A = T[b];
|
||||||
if (l.verbose && console.log("Read " + A + " symbol"), A === "]")
|
if (l.verbose && console.log("Read " + A + " symbol"), A === "]")
|
||||||
return g;
|
return g;
|
||||||
@ -167,47 +167,47 @@ var ce = {};
|
|||||||
g.push("");
|
g.push("");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
g.push(u[A]);
|
g.push(f[A]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return l.verbose && console.log("Parsed " + this.JSON.stringify(g)), g;
|
return l.verbose && console.log("Parsed " + this.JSON.stringify(g)), g;
|
||||||
}
|
}
|
||||||
if (O === "$") {
|
if (O === "$") {
|
||||||
for (var g = {}; b < x; b++) {
|
for (var g = {}; b < S; b++) {
|
||||||
var P = T[b];
|
var x = T[b];
|
||||||
if (P === "]")
|
if (x === "]")
|
||||||
return g;
|
return g;
|
||||||
P === o ? P = "" : P = u[P];
|
x === o ? x = "" : x = f[x];
|
||||||
var A = T[++b];
|
var A = T[++b];
|
||||||
if (A === "@" || A === "$")
|
if (A === "@" || A === "$")
|
||||||
g[P] = $();
|
g[x] = $();
|
||||||
else
|
else
|
||||||
switch (A) {
|
switch (A) {
|
||||||
case t:
|
case t:
|
||||||
g[P] = !0;
|
g[x] = !0;
|
||||||
break;
|
break;
|
||||||
case n:
|
case n:
|
||||||
g[P] = !1;
|
g[x] = !1;
|
||||||
break;
|
break;
|
||||||
case s:
|
case s:
|
||||||
g[P] = null;
|
g[x] = null;
|
||||||
break;
|
break;
|
||||||
case h:
|
case h:
|
||||||
g[P] = void 0;
|
g[x] = void 0;
|
||||||
break;
|
break;
|
||||||
case o:
|
case o:
|
||||||
g[P] = "";
|
g[x] = "";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
g[P] = u[A];
|
g[x] = f[A];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return l.verbose && console.log("Parsed " + this.JSON.stringify(g)), g;
|
return l.verbose && console.log("Parsed " + this.JSON.stringify(g)), g;
|
||||||
}
|
}
|
||||||
throw new TypeError("Bad token " + O + " isn't a type");
|
throw new TypeError("Bad token " + O + " isn't a type");
|
||||||
}();
|
}();
|
||||||
}, S = function(f) {
|
}, P = function(u) {
|
||||||
return typeof f != "string" ? f : f.replace(/[\+ \|\^\%]/g, function(l) {
|
return typeof u != "string" ? u : u.replace(/[\+ \|\^\%]/g, function(l) {
|
||||||
return {
|
return {
|
||||||
" ": "+",
|
" ": "+",
|
||||||
"+": "%2B",
|
"+": "%2B",
|
||||||
@ -216,8 +216,8 @@ var ce = {};
|
|||||||
"%": "%25"
|
"%": "%25"
|
||||||
}[l];
|
}[l];
|
||||||
});
|
});
|
||||||
}, M = function(f) {
|
}, M = function(u) {
|
||||||
return typeof f != "string" ? f : f.replace(/\+|%2B|%7C|%5E|%25/g, function(l) {
|
return typeof u != "string" ? u : u.replace(/\+|%2B|%7C|%5E|%25/g, function(l) {
|
||||||
return {
|
return {
|
||||||
"+": " ",
|
"+": " ",
|
||||||
"%2B": "+",
|
"%2B": "+",
|
||||||
@ -226,13 +226,13 @@ var ce = {};
|
|||||||
"%25": "%"
|
"%25": "%"
|
||||||
}[l];
|
}[l];
|
||||||
});
|
});
|
||||||
}, _ = function(f) {
|
}, _ = function(u) {
|
||||||
return Number.prototype.toString.call(f, 36).toUpperCase();
|
return Number.prototype.toString.call(u, 36).toUpperCase();
|
||||||
}, F = function(f) {
|
}, I = function(u) {
|
||||||
return parseInt(f, 36);
|
return parseInt(u, 36);
|
||||||
}, I = Array.prototype.indexOf || function(f, l) {
|
}, F = Array.prototype.indexOf || function(u, l) {
|
||||||
for (var w = l || 0, u = this.length; w < u; w++)
|
for (var w = l || 0, f = this.length; w < f; w++)
|
||||||
if (this[w] === f)
|
if (this[w] === u)
|
||||||
return w;
|
return w;
|
||||||
return -1;
|
return -1;
|
||||||
};
|
};
|
||||||
@ -249,7 +249,7 @@ var ce = {};
|
|||||||
});
|
});
|
||||||
})(ce);
|
})(ce);
|
||||||
const oe = /* @__PURE__ */ de(ce);
|
const oe = /* @__PURE__ */ de(ce);
|
||||||
var K, q, j, D, Q, W, L, X, Z;
|
var H, L, G, D, Q, W, q, X, Z;
|
||||||
class ne {
|
class ne {
|
||||||
constructor(e, t, n, s, o) {
|
constructor(e, t, n, s, o) {
|
||||||
p(this, "code", 0);
|
p(this, "code", 0);
|
||||||
@ -258,15 +258,15 @@ class ne {
|
|||||||
p(this, "url", "");
|
p(this, "url", "");
|
||||||
p(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 }
|
||||||
v(this, K, null);
|
v(this, H, null);
|
||||||
// 判断返回 Response 对象, 还是 Response 中的 data
|
// 判断返回 Response 对象, 还是 Response 中的 data
|
||||||
v(this, q, !0);
|
v(this, L, !0);
|
||||||
// 判罚是否已经给出错误提示
|
// 判罚是否已经给出错误提示
|
||||||
v(this, j, !0);
|
v(this, G, !0);
|
||||||
v(this, D, {
|
v(this, D, {
|
||||||
get: (e, t) => i(this, Q).call(this, t),
|
get: (e, t) => i(this, Q).call(this, t),
|
||||||
ownKeys: () => Object.keys(i(this, D).getPrototypeOf() || {}),
|
ownKeys: () => Object.keys(i(this, D).getPrototypeOf() || {}),
|
||||||
getPrototypeOf: () => i(this, q) ? this : this.data,
|
getPrototypeOf: () => i(this, L) ? this : this.data,
|
||||||
getOwnPropertyDescriptor: () => ({
|
getOwnPropertyDescriptor: () => ({
|
||||||
configurable: !0,
|
configurable: !0,
|
||||||
enumerable: !0,
|
enumerable: !0,
|
||||||
@ -274,17 +274,17 @@ class ne {
|
|||||||
value: i(this, D).getPrototypeOf()
|
value: i(this, D).getPrototypeOf()
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
v(this, Q, (e) => e === "$echoMsg" ? i(this, L) : e === "msg" ? i(this, W) : e === "then" || e === "resp" ? (C(this, j, !0), C(this, q, e === "resp"), i(this, X)) : e === "catch" ? i(this, Z) : e === "IS_ECHO_MSG" ? i(this, j) : Reflect.get(this, e));
|
v(this, Q, (e) => e === "$echoMsg" ? i(this, q) : e === "msg" ? i(this, W) : e === "then" || e === "resp" ? (C(this, G, !0), C(this, L, e === "resp"), i(this, X)) : e === "catch" ? i(this, Z) : e === "IS_ECHO_MSG" ? i(this, G) : Reflect.get(this, e));
|
||||||
v(this, W, (e = (n) => n, t = !1) => (i(this, L).call(this), C(this, q, t), Promise.resolve(e == null ? void 0 : e(i(this, D).getPrototypeOf()))));
|
v(this, W, (e = (n) => n, t = !1) => (i(this, q).call(this), C(this, L, t), Promise.resolve(e == null ? void 0 : e(i(this, D).getPrototypeOf()))));
|
||||||
v(this, L, () => {
|
v(this, q, () => {
|
||||||
i(this, j) && (C(this, j, !1), _e.onMsg(this.code, this.message));
|
i(this, G) && (C(this, G, !1), _e.onMsg(this.code, this.message));
|
||||||
});
|
});
|
||||||
v(this, X, (e) => [0, 1].includes(this.code) ? Promise.resolve(e == null ? void 0 : e(i(this, D).getPrototypeOf())) : Promise.reject(i(this, K)));
|
v(this, X, (e) => [0, 1].includes(this.code) ? Promise.resolve(e == null ? void 0 : e(i(this, D).getPrototypeOf())) : Promise.reject(i(this, H)));
|
||||||
v(this, Z, (e) => Promise.resolve(e(i(this, K))));
|
v(this, Z, (e) => Promise.resolve(e(i(this, H))));
|
||||||
return this.code = e, this.message = t, this.data = n, this.url = s, this.res = o, C(this, K, new Proxy(this, i(this, D)));
|
return this.code = e, this.message = t, this.data = n, this.url = s, this.res = o, C(this, H, new Proxy(this, i(this, D)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
K = new WeakMap(), q = new WeakMap(), j = new WeakMap(), D = new WeakMap(), Q = new WeakMap(), W = new WeakMap(), L = new WeakMap(), X = new WeakMap(), Z = new WeakMap();
|
H = new WeakMap(), L = new WeakMap(), G = new WeakMap(), D = new WeakMap(), Q = new WeakMap(), W = new WeakMap(), q = new WeakMap(), X = new WeakMap(), Z = new WeakMap();
|
||||||
const re = (r, e, t, n = "/", s = "") => new ne(r, e, t, n, s);
|
const re = (r, e, t, n = "/", s = "") => new ne(r, e, t, n, s);
|
||||||
var le = [
|
var le = [
|
||||||
"utf8",
|
"utf8",
|
||||||
@ -332,7 +332,7 @@ const ve = new he.TextEncoder("utf8"), we = new he.TextDecoder("utf8"), ye = (r)
|
|||||||
e = e * 33 ^ r.charCodeAt(t);
|
e = e * 33 ^ r.charCodeAt(t);
|
||||||
return (e >>> 0).toString(16);
|
return (e >>> 0).toString(16);
|
||||||
}, be = (r, e) => r.replace(new RegExp(`^${e}+|${e}+$`, "g"), ""), Ee = (r) => ve.encode(r || ""), Ce = (r) => we.decode(new DataView(r), {}), Oe = 62, Y = 30, ae = 31, Te = 63;
|
}, be = (r, e) => r.replace(new RegExp(`^${e}+|${e}+$`, "g"), ""), Ee = (r) => ve.encode(r || ""), Ce = (r) => we.decode(new DataView(r), {}), Oe = 62, Y = 30, ae = 31, Te = 63;
|
||||||
class xe {
|
class Se {
|
||||||
constructor(e) {
|
constructor(e) {
|
||||||
p(this, "encodeTable", []);
|
p(this, "encodeTable", []);
|
||||||
p(this, "decodeMap", new Uint8Array(256).fill(255));
|
p(this, "decodeMap", new Uint8Array(256).fill(255));
|
||||||
@ -349,19 +349,19 @@ class xe {
|
|||||||
encode(e) {
|
encode(e) {
|
||||||
if (!e || e.length === 0)
|
if (!e || e.length === 0)
|
||||||
return [];
|
return [];
|
||||||
const t = new Pe(this).encodeV2(e);
|
const t = new xe(this).encodeV2(e);
|
||||||
return String.fromCharCode(...t);
|
return String.fromCharCode(...t);
|
||||||
}
|
}
|
||||||
// 解码方法
|
// 解码方法
|
||||||
decode(e) {
|
decode(e) {
|
||||||
if (!e || e.length === 0)
|
if (!e || e.length === 0)
|
||||||
return new Uint8Array();
|
return new Uint8Array();
|
||||||
const t = new Se(this).decode(e);
|
const t = new Pe(this).decode(e);
|
||||||
return new TextDecoder().decode(t);
|
return new TextDecoder().decode(t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var z;
|
var z;
|
||||||
class Pe {
|
class xe {
|
||||||
constructor(e) {
|
constructor(e) {
|
||||||
v(this, z, null);
|
v(this, z, null);
|
||||||
C(this, z, e);
|
C(this, z, e);
|
||||||
@ -384,7 +384,7 @@ class Pe {
|
|||||||
}
|
}
|
||||||
z = new WeakMap();
|
z = new WeakMap();
|
||||||
var k;
|
var k;
|
||||||
class Se {
|
class Pe {
|
||||||
constructor(e) {
|
constructor(e) {
|
||||||
v(this, k, null);
|
v(this, k, null);
|
||||||
C(this, k, e);
|
C(this, k, e);
|
||||||
@ -408,11 +408,11 @@ Promise.withResolvers || (Promise.withResolvers = function() {
|
|||||||
r = n, e = s;
|
r = n, e = s;
|
||||||
}), resolve: r, reject: e };
|
}), resolve: r, reject: e };
|
||||||
});
|
});
|
||||||
var G, H, ee, m, U, J, te, V;
|
var J, B, ee, m, U, K, te, V;
|
||||||
class se {
|
class se {
|
||||||
constructor(e, t, n) {
|
constructor(e, t, n) {
|
||||||
v(this, G, void 0);
|
v(this, J, void 0);
|
||||||
v(this, H, void 0);
|
v(this, B, void 0);
|
||||||
v(this, ee, void 0);
|
v(this, ee, void 0);
|
||||||
v(this, m, {
|
v(this, m, {
|
||||||
"#": /* @__PURE__ */ new Map(),
|
"#": /* @__PURE__ */ new Map(),
|
||||||
@ -421,33 +421,33 @@ class se {
|
|||||||
// 普通缓存
|
// 普通缓存
|
||||||
});
|
});
|
||||||
v(this, U, /* @__PURE__ */ new Map());
|
v(this, U, /* @__PURE__ */ new Map());
|
||||||
v(this, J, /* @__PURE__ */ new Set());
|
v(this, K, /* @__PURE__ */ new Set());
|
||||||
p(this, "init", (e, t, n) => {
|
p(this, "init", (e, t, n) => {
|
||||||
C(this, ee, e), C(this, G, n), C(this, H, new xe(t)), i(this, te).call(this);
|
e && C(this, ee, e), n && C(this, J, n), t && C(this, B, new Se(t)), i(this, te).call(this);
|
||||||
});
|
});
|
||||||
v(this, te, () => {
|
v(this, te, () => {
|
||||||
!i(this, J).size || !i(this, G) || (i(this, J).forEach((e) => i(this, V).call(this, ...e)), i(this, J).clear());
|
!i(this, K).size || !i(this, J) || (i(this, K).forEach((e) => i(this, V).call(this, ...e)), i(this, K).clear());
|
||||||
});
|
});
|
||||||
v(this, V, (e, t, n, s = !1) => {
|
v(this, V, (e, t, n, s = !1) => {
|
||||||
if (!i(this, G))
|
if (!i(this, J))
|
||||||
i(this, J).add([e, t, n, s]);
|
i(this, K).add([e, t, n, s]);
|
||||||
else {
|
else {
|
||||||
const { url: o, method: h, ...R } = n || {};
|
const { url: o, method: h, ...R } = n || {};
|
||||||
i(this, G).call(this, { url: o, method: h, ...R }).then((a) => {
|
i(this, J).call(this, { url: o, method: h, ...R }).then((a) => {
|
||||||
if (![0, 1].includes(a.code))
|
if (![0, 1].includes(a.code))
|
||||||
throw re(a.code, a.msg, a.data, o, a == null ? void 0 : a.res);
|
throw re(a.code, a.msg, a.data, o, a == null ? void 0 : a.res);
|
||||||
return [a.code, a.msg, a.data, o, a == null ? void 0 : a.res];
|
return [a.code, a.msg, a.data, o, a == null ? void 0 : a.res];
|
||||||
}).then((a) => ((t == "#" || h == "GET") && i(this, m)[t].set(e, a), t != "#" && h == "GET" && !s && setTimeout(() => {
|
}).then((a) => ((t == "#" || h == "GET") && i(this, m)[t].set(e, a), t != "#" && h == "GET" && !s && setTimeout(() => {
|
||||||
i(this, m)[t].delete(e);
|
i(this, m)[t].delete(e);
|
||||||
}, 300), a)).then((a) => {
|
}, 300), a)).then((a) => {
|
||||||
var S;
|
var P;
|
||||||
return (S = i(this, U).get(e)) == null ? void 0 : S.forEach((M, _, F) => {
|
return (P = i(this, U).get(e)) == null ? void 0 : P.forEach((M, _, I) => {
|
||||||
M && M[0](a), delete F[_];
|
M && M[0](a), delete I[_];
|
||||||
});
|
});
|
||||||
}).catch((a) => {
|
}).catch((a) => {
|
||||||
var S;
|
var P;
|
||||||
i(this, m)[t].delete(e), (S = i(this, U).get(e)) == null || S.forEach((M, _, F) => {
|
i(this, m)[t].delete(e), (P = i(this, U).get(e)) == null || P.forEach((M, _, I) => {
|
||||||
M && M[1](a instanceof ne ? a : re(-1, a, null, o)), delete F[_];
|
M && M[1](a instanceof ne ? a : re(-1, a, null, o)), delete I[_];
|
||||||
});
|
});
|
||||||
}).finally(() => i(this, U).delete(e));
|
}).finally(() => i(this, U).delete(e));
|
||||||
}
|
}
|
||||||
@ -455,12 +455,12 @@ class se {
|
|||||||
p(this, "request", ({ url: e = "/", method: t = "GET", ...n }, s = !1) => {
|
p(this, "request", ({ url: e = "/", method: t = "GET", ...n }, s = !1) => {
|
||||||
var _;
|
var _;
|
||||||
e = be(e, "/");
|
e = be(e, "/");
|
||||||
const o = t.toUpperCase(), h = ye(JSON.stringify([e, o, n])), R = (_ = e == null ? void 0 : e.includes) != null && _.call(e, "/_/") ? "#" : "$", { promise: a, resolve: S, reject: M } = Promise.withResolvers();
|
const o = t.toUpperCase(), h = ye(JSON.stringify([e, o, n])), R = (_ = e == null ? void 0 : e.includes) != null && _.call(e, "/_/") ? "#" : "$", { promise: a, resolve: P, reject: M } = Promise.withResolvers();
|
||||||
return i(this, m)[R].has(h) ? (console.log("cache", e), S(i(this, m)[R].get(h))) : i(this, U).has(h) ? i(this, U).get(h).push([S, M]) : (i(this, U).set(h, [[S, M]]), i(this, V).call(this, h, R, { url: e, method: o, ...n }, s)), new Proxy(a, {
|
return i(this, m)[R].has(h) ? (console.log("cache", e), P(i(this, m)[R].get(h))) : i(this, U).has(h) ? i(this, U).get(h).push([P, M]) : (i(this, U).set(h, [[P, M]]), i(this, V).call(this, h, R, { url: e, method: o, ...n }, s)), new Proxy(a, {
|
||||||
get: (F, I) => (...f) => F.then((l) => re(...l)[I](...f)).catch((l) => {
|
get: (I, F) => (...u) => I.then((l) => re(...l)[F](...u)).catch((l) => {
|
||||||
if (!l instanceof ne)
|
if (!l instanceof ne)
|
||||||
throw l;
|
throw l;
|
||||||
return typeof l[I] == "function" ? l[I](...f) : l[I];
|
return typeof l[F] == "function" ? l[F](...u) : l[F];
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -481,20 +481,24 @@ class se {
|
|||||||
if (e === void 0 || e === "" || e === null)
|
if (e === void 0 || e === "" || e === null)
|
||||||
return t;
|
return t;
|
||||||
try {
|
try {
|
||||||
const n = i(this, H).decode(e);
|
if (!i(this, B))
|
||||||
|
throw new Error("未初始化 appSecret,请先通过 init 设置 appSecret");
|
||||||
|
const n = i(this, B).decode(e);
|
||||||
return oe.unpack(n);
|
return oe.unpack(n);
|
||||||
} catch {
|
} catch {
|
||||||
return console.warn("core.decode", e), t;
|
return console.warn("core.decode", e), t;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
p(this, "encode", (e = {}) => {
|
p(this, "encode", (e = {}) => {
|
||||||
|
if (!i(this, B))
|
||||||
|
throw new Error("未初始化 appSecret,请先通过 init 设置 appSecret");
|
||||||
const t = JSON.stringify(e, (n, s) => s === void 0 ? null : s);
|
const t = JSON.stringify(e, (n, s) => s === void 0 ? null : s);
|
||||||
return i(this, H).encode(oe.pack(t));
|
return i(this, B).encode(oe.pack(t));
|
||||||
});
|
});
|
||||||
this.init(e, t, n);
|
this.init(e, t, n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
G = new WeakMap(), H = new WeakMap(), ee = new WeakMap(), m = new WeakMap(), U = new WeakMap(), J = new WeakMap(), te = new WeakMap(), V = new WeakMap();
|
J = new WeakMap(), B = new WeakMap(), ee = new WeakMap(), m = new WeakMap(), U = new WeakMap(), K = new WeakMap(), te = new WeakMap(), V = new WeakMap();
|
||||||
const _e = se;
|
const _e = se;
|
||||||
se.onUnhandledRejection = (r) => {
|
se.onUnhandledRejection = (r) => {
|
||||||
var e, t, n, s, o, h;
|
var e, t, n, s, o, h;
|
||||||
|
|||||||
4
dist/ff-request.umd.cjs
vendored
4
dist/ff-request.umd.cjs
vendored
File diff suppressed because one or more lines are too long
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "ff-request",
|
"name": "ff-request",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.10.2",
|
"version": "0.10.3",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"files": [
|
"files": [
|
||||||
"dist"
|
"dist"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user