v0.9.15
This commit is contained in:
parent
1ece50e14a
commit
bd192876a6
366
dist/ff-request.js
vendored
366
dist/ff-request.js
vendored
@ -4,11 +4,11 @@ var v = (r, e, t) => (le(r, typeof e != "symbol" ? e + "" : e, t), t), re = (r,
|
||||
if (!e.has(r))
|
||||
throw TypeError("Cannot " + t);
|
||||
};
|
||||
var o = (r, e, t) => (re(r, e, "read from private field"), t ? t.call(r) : e.get(r)), E = (r, e, t) => {
|
||||
var i = (r, e, t) => (re(r, e, "read from private field"), t ? t.call(r) : e.get(r)), E = (r, e, t) => {
|
||||
if (e.has(r))
|
||||
throw TypeError("Cannot add the same private member more than once");
|
||||
e instanceof WeakSet ? e.add(r) : e.set(r, t);
|
||||
}, C = (r, e, t, n) => (re(r, e, "write to private field"), n ? n.call(r, t) : e.set(r, t), t);
|
||||
}, _ = (r, e, t, n) => (re(r, e, "write to private field"), n ? n.call(r, t) : e.set(r, t), t);
|
||||
function he(r) {
|
||||
return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r;
|
||||
}
|
||||
@ -16,63 +16,63 @@ var oe = {};
|
||||
(function(r) {
|
||||
(function(e) {
|
||||
e([], function() {
|
||||
var t = -1, n = -2, s = -3, f = -4, h = -5, $ = function(a, c) {
|
||||
c = c || {};
|
||||
var l = c.verbose || !1;
|
||||
l && console.log("Normalize the JSON Object"), a = typeof a == "string" ? this.JSON.parse(a) : a, l && console.log("Creating a empty dictionary");
|
||||
var d = {
|
||||
var t = -1, n = -2, s = -3, c = -4, l = -5, A = function(h, o) {
|
||||
o = o || {};
|
||||
var d = o.verbose || !1;
|
||||
d && console.log("Normalize the JSON Object"), h = typeof h == "string" ? this.JSON.parse(h) : h, d && console.log("Creating a empty dictionary");
|
||||
var f = {
|
||||
strings: [],
|
||||
integers: [],
|
||||
floats: []
|
||||
};
|
||||
l && console.log("Creating the AST");
|
||||
var g = function T(i) {
|
||||
l && console.log("Calling recursiveAstBuilder with " + this.JSON.stringify(i));
|
||||
var w = typeof i;
|
||||
if (i === null)
|
||||
d && console.log("Creating the AST");
|
||||
var g = function P(a) {
|
||||
d && console.log("Calling recursiveAstBuilder with " + this.JSON.stringify(a));
|
||||
var w = typeof a;
|
||||
if (a === null)
|
||||
return {
|
||||
type: "null",
|
||||
index: s
|
||||
};
|
||||
if (typeof i > "u")
|
||||
if (typeof a > "u")
|
||||
return {
|
||||
type: "undefined",
|
||||
index: h
|
||||
index: l
|
||||
};
|
||||
if (i instanceof Array) {
|
||||
var P = ["@"];
|
||||
for (var y in i)
|
||||
i.hasOwnProperty(y) && P.push(T(i[y]));
|
||||
return P;
|
||||
if (a instanceof Array) {
|
||||
var x = ["@"];
|
||||
for (var y in a)
|
||||
a.hasOwnProperty(y) && x.push(P(a[y]));
|
||||
return x;
|
||||
}
|
||||
if (w === "object") {
|
||||
var P = ["$"];
|
||||
for (var M in i)
|
||||
i.hasOwnProperty(M) && (P.push(T(M)), P.push(T(i[M])));
|
||||
return P;
|
||||
var x = ["$"];
|
||||
for (var $ in a)
|
||||
a.hasOwnProperty($) && (x.push(P($)), x.push(P(a[$])));
|
||||
return x;
|
||||
}
|
||||
if (i === "")
|
||||
if (a === "")
|
||||
return {
|
||||
type: "empty",
|
||||
index: f
|
||||
index: c
|
||||
};
|
||||
if (w === "string") {
|
||||
var O = u.call(d.strings, i);
|
||||
return O == -1 && (d.strings.push(q(i)), O = d.strings.length - 1), {
|
||||
var O = T.call(f.strings, a);
|
||||
return O == -1 && (f.strings.push(G(a)), O = f.strings.length - 1), {
|
||||
type: "strings",
|
||||
index: O
|
||||
};
|
||||
}
|
||||
if (w === "number" && i % 1 === 0) {
|
||||
var O = u.call(d.integers, i);
|
||||
return O == -1 && (d.integers.push(U(i)), O = d.integers.length - 1), {
|
||||
if (w === "number" && a % 1 === 0) {
|
||||
var O = T.call(f.integers, a);
|
||||
return O == -1 && (f.integers.push(F(a)), O = f.integers.length - 1), {
|
||||
type: "integers",
|
||||
index: O
|
||||
};
|
||||
}
|
||||
if (w === "number") {
|
||||
var O = u.call(d.floats, i);
|
||||
return O == -1 && (d.floats.push(i), O = d.floats.length - 1), {
|
||||
var O = T.call(f.floats, a);
|
||||
return O == -1 && (f.floats.push(a), O = f.floats.length - 1), {
|
||||
type: "floats",
|
||||
index: O
|
||||
};
|
||||
@ -80,77 +80,77 @@ var oe = {};
|
||||
if (w === "boolean")
|
||||
return {
|
||||
type: "boolean",
|
||||
index: i ? t : n
|
||||
index: a ? t : n
|
||||
};
|
||||
throw new Error("Unexpected argument of type " + typeof i);
|
||||
}(a), b = d.strings.length, F = d.integers.length;
|
||||
d.floats.length, l && console.log("Parsing the dictionary");
|
||||
var A = d.strings.join("|");
|
||||
return A += "^" + d.integers.join("|"), A += "^" + d.floats.join("|"), l && console.log("Parsing the structure"), A += "^" + function T(i) {
|
||||
if (l && console.log("Calling a recursiveParser with " + this.JSON.stringify(i)), i instanceof Array) {
|
||||
var w = i.shift();
|
||||
for (var P in i)
|
||||
i.hasOwnProperty(P) && (w += T(i[P]) + "|");
|
||||
throw new Error("Unexpected argument of type " + typeof a);
|
||||
}(h), b = f.strings.length, I = f.integers.length;
|
||||
f.floats.length, d && console.log("Parsing the dictionary");
|
||||
var N = f.strings.join("|");
|
||||
return N += "^" + f.integers.join("|"), N += "^" + f.floats.join("|"), d && console.log("Parsing the structure"), N += "^" + function P(a) {
|
||||
if (d && console.log("Calling a recursiveParser with " + this.JSON.stringify(a)), a instanceof Array) {
|
||||
var w = a.shift();
|
||||
for (var x in a)
|
||||
a.hasOwnProperty(x) && (w += P(a[x]) + "|");
|
||||
return (w[w.length - 1] === "|" ? w.slice(0, -1) : w) + "]";
|
||||
}
|
||||
var y = i.type, M = i.index;
|
||||
var y = a.type, $ = a.index;
|
||||
if (y === "strings")
|
||||
return U(M);
|
||||
return F($);
|
||||
if (y === "integers")
|
||||
return U(b + M);
|
||||
return F(b + $);
|
||||
if (y === "floats")
|
||||
return U(b + F + M);
|
||||
return F(b + I + $);
|
||||
if (y === "boolean")
|
||||
return i.index;
|
||||
return a.index;
|
||||
if (y === "null")
|
||||
return s;
|
||||
if (y === "undefined")
|
||||
return h;
|
||||
return l;
|
||||
if (y === "empty")
|
||||
return f;
|
||||
return c;
|
||||
throw new TypeError("The item is alien!");
|
||||
}(g), l && console.log("Ending parser"), c.debug ? {
|
||||
dictionary: d,
|
||||
}(g), d && console.log("Ending parser"), o.debug ? {
|
||||
dictionary: f,
|
||||
ast: g,
|
||||
packed: A
|
||||
} : A;
|
||||
}, _ = function(a, c) {
|
||||
c = c || {};
|
||||
var l = a.split("^");
|
||||
c.verbose && console.log("Building dictionary");
|
||||
var d = [], g = l[0];
|
||||
packed: N
|
||||
} : N;
|
||||
}, M = function(h, o) {
|
||||
o = o || {};
|
||||
var d = h.split("^");
|
||||
o.verbose && console.log("Building dictionary");
|
||||
var f = [], g = d[0];
|
||||
if (g !== "") {
|
||||
g = g.split("|"), c.verbose && console.log("Parse the strings dictionary");
|
||||
for (var b = 0, F = g.length; b < F; b++)
|
||||
d.push(z(g[b]));
|
||||
g = g.split("|"), o.verbose && console.log("Parse the strings dictionary");
|
||||
for (var b = 0, I = g.length; b < I; b++)
|
||||
f.push(z(g[b]));
|
||||
}
|
||||
if (g = l[1], g !== "") {
|
||||
g = g.split("|"), c.verbose && console.log("Parse the integers dictionary");
|
||||
for (var b = 0, F = g.length; b < F; b++)
|
||||
d.push(J(g[b]));
|
||||
if (g = d[1], g !== "") {
|
||||
g = g.split("|"), o.verbose && console.log("Parse the integers dictionary");
|
||||
for (var b = 0, I = g.length; b < I; b++)
|
||||
f.push(u(g[b]));
|
||||
}
|
||||
if (g = l[2], g !== "") {
|
||||
g = g.split("|"), c.verbose && console.log("Parse the floats dictionary");
|
||||
for (var b = 0, F = g.length; b < F; b++)
|
||||
d.push(parseFloat(g[b]));
|
||||
if (g = d[2], g !== "") {
|
||||
g = g.split("|"), o.verbose && console.log("Parse the floats dictionary");
|
||||
for (var b = 0, I = g.length; b < I; b++)
|
||||
f.push(parseFloat(g[b]));
|
||||
}
|
||||
g = null, c.verbose && console.log("Tokenizing the structure");
|
||||
for (var A = "", T = [], i = l[3].length, b = 0; b < i; b++) {
|
||||
var w = l[3].charAt(b);
|
||||
w === "|" || w === "$" || w === "@" || w === "]" ? (A && (T.push(J(A)), A = ""), w !== "|" && T.push(w)) : A += w;
|
||||
g = null, o.verbose && console.log("Tokenizing the structure");
|
||||
for (var N = "", P = [], a = d[3].length, b = 0; b < a; b++) {
|
||||
var w = d[3].charAt(b);
|
||||
w === "|" || w === "$" || w === "@" || w === "]" ? (N && (P.push(u(N)), N = ""), w !== "|" && P.push(w)) : N += w;
|
||||
}
|
||||
var P = T.length, y = 0;
|
||||
return c.verbose && console.log("Starting recursive parser"), function M() {
|
||||
var O = T[y++];
|
||||
if (c.verbose && console.log("Reading collection type " + (O === "$" ? "object" : "Array")), O === "@") {
|
||||
for (var p = []; y < P; y++) {
|
||||
var S = T[y];
|
||||
if (c.verbose && console.log("Read " + S + " symbol"), S === "]")
|
||||
var x = P.length, y = 0;
|
||||
return o.verbose && console.log("Starting recursive parser"), function $() {
|
||||
var O = P[y++];
|
||||
if (o.verbose && console.log("Reading collection type " + (O === "$" ? "object" : "Array")), O === "@") {
|
||||
for (var p = []; y < x; y++) {
|
||||
var C = P[y];
|
||||
if (o.verbose && console.log("Read " + C + " symbol"), C === "]")
|
||||
return p;
|
||||
if (S === "@" || S === "$")
|
||||
p.push(M());
|
||||
if (C === "@" || C === "$")
|
||||
p.push($());
|
||||
else
|
||||
switch (S) {
|
||||
switch (C) {
|
||||
case t:
|
||||
p.push(!0);
|
||||
break;
|
||||
@ -160,86 +160,86 @@ var oe = {};
|
||||
case s:
|
||||
p.push(null);
|
||||
break;
|
||||
case h:
|
||||
case l:
|
||||
p.push(void 0);
|
||||
break;
|
||||
case f:
|
||||
case c:
|
||||
p.push("");
|
||||
break;
|
||||
default:
|
||||
p.push(d[S]);
|
||||
p.push(f[C]);
|
||||
}
|
||||
}
|
||||
return c.verbose && console.log("Parsed " + this.JSON.stringify(p)), p;
|
||||
return o.verbose && console.log("Parsed " + this.JSON.stringify(p)), p;
|
||||
}
|
||||
if (O === "$") {
|
||||
for (var p = {}; y < P; y++) {
|
||||
var x = T[y];
|
||||
if (x === "]")
|
||||
for (var p = {}; y < x; y++) {
|
||||
var S = P[y];
|
||||
if (S === "]")
|
||||
return p;
|
||||
x === f ? x = "" : x = d[x];
|
||||
var S = T[++y];
|
||||
if (S === "@" || S === "$")
|
||||
p[x] = M();
|
||||
S === c ? S = "" : S = f[S];
|
||||
var C = P[++y];
|
||||
if (C === "@" || C === "$")
|
||||
p[S] = $();
|
||||
else
|
||||
switch (S) {
|
||||
switch (C) {
|
||||
case t:
|
||||
p[x] = !0;
|
||||
p[S] = !0;
|
||||
break;
|
||||
case n:
|
||||
p[x] = !1;
|
||||
p[S] = !1;
|
||||
break;
|
||||
case s:
|
||||
p[x] = null;
|
||||
p[S] = null;
|
||||
break;
|
||||
case h:
|
||||
p[x] = void 0;
|
||||
case l:
|
||||
p[S] = void 0;
|
||||
break;
|
||||
case f:
|
||||
p[x] = "";
|
||||
case c:
|
||||
p[S] = "";
|
||||
break;
|
||||
default:
|
||||
p[x] = d[S];
|
||||
p[S] = f[C];
|
||||
}
|
||||
}
|
||||
return c.verbose && console.log("Parsed " + this.JSON.stringify(p)), p;
|
||||
return o.verbose && console.log("Parsed " + this.JSON.stringify(p)), p;
|
||||
}
|
||||
throw new TypeError("Bad token " + O + " isn't a type");
|
||||
}();
|
||||
}, q = function(a) {
|
||||
return typeof a != "string" ? a : a.replace(/[\+ \|\^\%]/g, function(c) {
|
||||
}, G = function(h) {
|
||||
return typeof h != "string" ? h : h.replace(/[\+ \|\^\%]/g, function(o) {
|
||||
return {
|
||||
" ": "+",
|
||||
"+": "%2B",
|
||||
"|": "%7C",
|
||||
"^": "%5E",
|
||||
"%": "%25"
|
||||
}[c];
|
||||
}[o];
|
||||
});
|
||||
}, z = function(a) {
|
||||
return typeof a != "string" ? a : a.replace(/\+|%2B|%7C|%5E|%25/g, function(c) {
|
||||
}, z = function(h) {
|
||||
return typeof h != "string" ? h : h.replace(/\+|%2B|%7C|%5E|%25/g, function(o) {
|
||||
return {
|
||||
"+": " ",
|
||||
"%2B": "+",
|
||||
"%7C": "|",
|
||||
"%5E": "^",
|
||||
"%25": "%"
|
||||
}[c];
|
||||
}[o];
|
||||
});
|
||||
}, U = function(a) {
|
||||
return Number.prototype.toString.call(a, 36).toUpperCase();
|
||||
}, J = function(a) {
|
||||
return parseInt(a, 36);
|
||||
}, u = Array.prototype.indexOf || function(a, c) {
|
||||
for (var l = c || 0, d = this.length; l < d; l++)
|
||||
if (this[l] === a)
|
||||
return l;
|
||||
}, F = function(h) {
|
||||
return Number.prototype.toString.call(h, 36).toUpperCase();
|
||||
}, u = function(h) {
|
||||
return parseInt(h, 36);
|
||||
}, T = Array.prototype.indexOf || function(h, o) {
|
||||
for (var d = o || 0, f = this.length; d < f; d++)
|
||||
if (this[d] === h)
|
||||
return d;
|
||||
return -1;
|
||||
};
|
||||
return {
|
||||
JSON,
|
||||
pack: $,
|
||||
unpack: _
|
||||
pack: A,
|
||||
unpack: M
|
||||
};
|
||||
});
|
||||
})(function(e, t) {
|
||||
@ -249,42 +249,42 @@ var oe = {};
|
||||
});
|
||||
})(oe);
|
||||
const ne = /* @__PURE__ */ he(oe);
|
||||
var D, j, I, R, Y, Q, K, W, X;
|
||||
var j, B, D, U, Y, Q, J, W, X;
|
||||
class ee {
|
||||
constructor(e, t, n, s, f) {
|
||||
constructor(e, t, n, s, c) {
|
||||
v(this, "code", 0);
|
||||
v(this, "message", "操作成功");
|
||||
v(this, "data", null);
|
||||
v(this, "url", "");
|
||||
v(this, "res", "");
|
||||
// static [Symbol.hasInstance](self) { return self?.IS_ECHO_MSG !== undefined }
|
||||
E(this, D, null);
|
||||
E(this, j, null);
|
||||
// 判断返回 Response 对象, 还是 Response 中的 data
|
||||
E(this, j, !0);
|
||||
E(this, B, !0);
|
||||
// 判罚是否已经给出错误提示
|
||||
E(this, I, !0);
|
||||
E(this, R, {
|
||||
get: (e, t) => o(this, Y).call(this, t),
|
||||
ownKeys: () => Object.keys(o(this, R).getPrototypeOf() || {}),
|
||||
getPrototypeOf: () => o(this, j) ? this : this.data,
|
||||
E(this, D, !0);
|
||||
E(this, U, {
|
||||
get: (e, t) => i(this, Y).call(this, t),
|
||||
ownKeys: () => Object.keys(i(this, U).getPrototypeOf() || {}),
|
||||
getPrototypeOf: () => i(this, B) ? this : this.data,
|
||||
getOwnPropertyDescriptor: () => ({
|
||||
configurable: !0,
|
||||
enumerable: !0,
|
||||
writable: !0,
|
||||
value: o(this, R).getPrototypeOf()
|
||||
value: i(this, U).getPrototypeOf()
|
||||
})
|
||||
});
|
||||
E(this, Y, (e) => e === "$echoMsg" ? o(this, K) : e === "msg" ? o(this, Q) : e === "then" || e === "resp" ? (C(this, I, !0), C(this, j, e === "resp"), o(this, W)) : e === "catch" ? o(this, X) : e === "IS_ECHO_MSG" ? o(this, I) : Reflect.get(this, e));
|
||||
E(this, Q, (e = (n) => n, t = !1) => (o(this, K).call(this), C(this, j, t), Promise.resolve(e == null ? void 0 : e(o(this, R).getPrototypeOf()))));
|
||||
E(this, K, () => {
|
||||
o(this, I) && (C(this, I, !1), Te.onMsg(this.code, this.message));
|
||||
E(this, Y, (e) => e === "$echoMsg" ? i(this, J) : e === "msg" ? i(this, Q) : e === "then" || e === "resp" ? (_(this, D, !0), _(this, B, e === "resp"), i(this, W)) : e === "catch" ? i(this, X) : e === "IS_ECHO_MSG" ? i(this, D) : Reflect.get(this, e));
|
||||
E(this, Q, (e = (n) => n, t = !1) => (i(this, J).call(this), _(this, B, t), Promise.resolve(e == null ? void 0 : e(i(this, U).getPrototypeOf()))));
|
||||
E(this, J, () => {
|
||||
i(this, D) && (_(this, D, !1), Te.onMsg(this.code, this.message));
|
||||
});
|
||||
E(this, W, (e) => [0, 1].includes(this.code) ? Promise.resolve(e == null ? void 0 : e(o(this, R).getPrototypeOf())) : Promise.reject(o(this, D)));
|
||||
E(this, X, (e) => Promise.resolve(e(o(this, D))));
|
||||
return this.code = e, this.message = t, this.data = n, this.url = s, this.res = f, C(this, D, new Proxy(this, o(this, R)));
|
||||
E(this, W, (e) => [0, 1].includes(this.code) ? Promise.resolve(e == null ? void 0 : e(i(this, U).getPrototypeOf())) : Promise.reject(i(this, j)));
|
||||
E(this, X, (e) => Promise.resolve(e(i(this, j))));
|
||||
return this.code = e, this.message = t, this.data = n, this.url = s, this.res = c, _(this, j, new Proxy(this, i(this, U)));
|
||||
}
|
||||
}
|
||||
D = new WeakMap(), j = new WeakMap(), I = new WeakMap(), R = new WeakMap(), Y = new WeakMap(), Q = new WeakMap(), K = new WeakMap(), W = new WeakMap(), X = new WeakMap();
|
||||
j = new WeakMap(), B = new WeakMap(), D = new WeakMap(), U = new WeakMap(), Y = new WeakMap(), Q = new WeakMap(), J = new WeakMap(), W = new WeakMap(), X = new WeakMap();
|
||||
const k = (r, e, t, n = "/", s = "") => new ee(r, e, t, n, s);
|
||||
var ie = [
|
||||
"utf8",
|
||||
@ -299,8 +299,8 @@ function ue(r) {
|
||||
throw new TypeError("passed argument must be of tye string");
|
||||
var t = unescape(encodeURIComponent(e)), n = new Uint8Array(t.length);
|
||||
const s = t.split("");
|
||||
for (let f = 0; f < s.length; f++)
|
||||
n[f] = s[f].charCodeAt(0);
|
||||
for (let c = 0; c < s.length; c++)
|
||||
n[c] = s[c].charCodeAt(0);
|
||||
return n;
|
||||
};
|
||||
}
|
||||
@ -314,10 +314,10 @@ function fe(r) {
|
||||
if (typeof n != "boolean")
|
||||
throw new TypeError("stream option must be boolean");
|
||||
if (ArrayBuffer.isView(e)) {
|
||||
var s = new Uint8Array(e.buffer, e.byteOffset, e.byteLength), f = new Array(s.length);
|
||||
for (let h = 0; h < s.length; h++)
|
||||
f[h] = String.fromCharCode(s[h]);
|
||||
return decodeURIComponent(escape(f.join("")));
|
||||
var s = new Uint8Array(e.buffer, e.byteOffset, e.byteLength), c = new Array(s.length);
|
||||
for (let l = 0; l < s.length; l++)
|
||||
c[l] = String.fromCharCode(s[l]);
|
||||
return decodeURIComponent(escape(c.join("")));
|
||||
} else
|
||||
throw new TypeError("passed argument must be an array buffer view");
|
||||
};
|
||||
@ -360,11 +360,11 @@ class be {
|
||||
return new TextDecoder().decode(t);
|
||||
}
|
||||
}
|
||||
var G;
|
||||
var K;
|
||||
class Ee {
|
||||
constructor(e) {
|
||||
E(this, G, null);
|
||||
C(this, G, e);
|
||||
E(this, K, null);
|
||||
_(this, K, e);
|
||||
}
|
||||
get6bits() {
|
||||
let e = this.pos & 7, t = this.pos >> 3;
|
||||
@ -377,28 +377,28 @@ class Ee {
|
||||
const t = [];
|
||||
for (; this.pos > 0; ) {
|
||||
let n = 6, s = this.get6bits();
|
||||
(s & V) === V && ((this.pos > 6 || s > se) && (n = 5), s &= se), t.push(o(this, G).encodeTable[s].charCodeAt(0)), this.pos -= n;
|
||||
(s & V) === V && ((this.pos > 6 || s > se) && (n = 5), s &= se), t.push(i(this, K).encodeTable[s].charCodeAt(0)), this.pos -= n;
|
||||
}
|
||||
return t;
|
||||
}
|
||||
}
|
||||
G = new WeakMap();
|
||||
K = new WeakMap();
|
||||
var H;
|
||||
class Oe {
|
||||
constructor(e) {
|
||||
E(this, H, null);
|
||||
C(this, H, e);
|
||||
_(this, H, e);
|
||||
}
|
||||
decode(e) {
|
||||
const t = new Uint8Array(Math.ceil(e.length * 6 / 8) + 1);
|
||||
let n = t.length, s = 0, f = 0;
|
||||
for (let h = 0; h < e.length; h++) {
|
||||
const $ = e[h].charCodeAt(0), _ = o(this, H).decodeMap[$];
|
||||
if (_ === 255)
|
||||
throw new Error(`CorruptInputError at index ${h}`);
|
||||
h === e.length - 1 ? (f |= _ << s, s += Math.ceil(Math.log2(_ + 1))) : (_ & V) === V ? (f |= _ << s, s += 5) : (f |= _ << s, s += 6), s >= 8 && (n--, t[n] = f & 255, s %= 8, f >>= 8);
|
||||
let n = t.length, s = 0, c = 0;
|
||||
for (let l = 0; l < e.length; l++) {
|
||||
const A = e[l].charCodeAt(0), M = i(this, H).decodeMap[A];
|
||||
if (M === 255)
|
||||
throw new Error(`CorruptInputError at index ${l}`);
|
||||
l === e.length - 1 ? (c |= M << s, s += Math.ceil(Math.log2(M + 1))) : (M & V) === V ? (c |= M << s, s += 5) : (c |= M << s, s += 6), s >= 8 && (n--, t[n] = c & 255, s %= 8, c >>= 8);
|
||||
}
|
||||
return s > 0 && (n--, t[n] = f & 255), t.slice(n);
|
||||
return s > 0 && (n--, t[n] = c & 255), t.slice(n);
|
||||
}
|
||||
}
|
||||
H = new WeakMap();
|
||||
@ -408,11 +408,11 @@ Promise.withResolvers || (Promise.withResolvers = function() {
|
||||
r = n, e = s;
|
||||
}), resolve: r, reject: e };
|
||||
});
|
||||
var L, B, Z, m, N;
|
||||
var L, q, Z, m, R;
|
||||
class te {
|
||||
constructor(e, t, n = ({}) => Promise.reject({ code: -1, msg: "请初始化HTTP请求方法主体" })) {
|
||||
E(this, L, void 0);
|
||||
E(this, B, void 0);
|
||||
E(this, q, void 0);
|
||||
E(this, Z, void 0);
|
||||
E(this, m, {
|
||||
"#": /* @__PURE__ */ new Map(),
|
||||
@ -420,29 +420,31 @@ class te {
|
||||
$: /* @__PURE__ */ new Map()
|
||||
// 普通缓存
|
||||
});
|
||||
E(this, N, /* @__PURE__ */ new Map());
|
||||
E(this, R, /* @__PURE__ */ new Map());
|
||||
v(this, "request", ({ url: e = "/", method: t = "GET", ...n }, s = !1) => {
|
||||
var U, J;
|
||||
const f = t.toUpperCase(), h = pe(JSON.stringify([e, f, n])), $ = (U = e == null ? void 0 : e.includes) != null && U.call(e, "/_/") ? "#" : "$", { promise: _, resolve: q, reject: z } = Promise.withResolvers();
|
||||
return o(this, m)[$].has(h) ? (console.log("缓存命中", e), q(o(this, m)[$].get(h))) : (o(this, N).has(h) ? o(this, N).get(h).push([q, z]) : o(this, N).set(h, [[q, z]]), (J = o(this, N).get(h)) != null && J.some((u) => u) && o(this, L).call(this, { url: e, method: f, ...n }).then((u) => {
|
||||
var F;
|
||||
const c = t.toUpperCase(), l = pe(JSON.stringify([e, c, n])), A = (F = e == null ? void 0 : e.includes) != null && F.call(e, "/_/") ? "#" : "$", { promise: M, resolve: G, reject: z } = Promise.withResolvers();
|
||||
return i(this, m)[A].has(l) ? (console.log("cache", e), G(i(this, m)[A].get(l))) : i(this, R).has(l) ? i(this, R).get(l).push([G, z]) : (i(this, R).set(l, [[G, z]]), i(this, L).call(this, { url: e, method: c, ...n }).then((u) => {
|
||||
if (![0, 1].includes(u.code))
|
||||
throw k(u.code, u.msg, u.data, e, u == null ? void 0 : u.res);
|
||||
return [u.code, u.msg, u.data, e, u == null ? void 0 : u.res];
|
||||
}).then((u) => (($ == "#" || s && f === "GET") && o(this, m)[$].set(h, u), u)).then((u) => {
|
||||
var a;
|
||||
return (a = o(this, N).get(h)) == null ? void 0 : a.forEach((c, l, d) => {
|
||||
c && c[0](u), delete d[l];
|
||||
}).then((u) => ((c === "GET" || A == "#") && i(this, m)[A].set(l, u), c === "GET" && !s && setTimeout(() => {
|
||||
i(this, m)[A].delete(l);
|
||||
}, 300), u)).then((u) => {
|
||||
var T;
|
||||
return (T = i(this, R).get(l)) == null ? void 0 : T.forEach((h, o, d) => {
|
||||
h && h[0](u), delete d[o];
|
||||
});
|
||||
}).catch((u) => {
|
||||
var a;
|
||||
o(this, m)[$].delete(h), (a = o(this, N).get(h)) == null || a.forEach((c, l, d) => {
|
||||
c && c[1](u instanceof ee ? u : k(-1, u, null, e)), delete d[l];
|
||||
var T;
|
||||
i(this, m)[A].delete(l), (T = i(this, R).get(l)) == null || T.forEach((h, o, d) => {
|
||||
h && h[1](u instanceof ee ? u : k(-1, u, null, e)), delete d[o];
|
||||
});
|
||||
}).finally(() => o(this, N).delete(h))), new Proxy(_, {
|
||||
get: (u, a) => (...c) => u.then((l) => k(...l)[a](...c)).catch((l) => {
|
||||
if (!l instanceof ee)
|
||||
throw l;
|
||||
return typeof l[a] == "function" ? l[a](...c) : l[a];
|
||||
}).finally(() => i(this, R).delete(l))), new Proxy(M, {
|
||||
get: (u, T) => (...h) => u.then((o) => k(...o)[T](...h)).catch((o) => {
|
||||
if (!o instanceof ee)
|
||||
throw o;
|
||||
return typeof o[T] == "function" ? o[T](...h) : o[T];
|
||||
})
|
||||
});
|
||||
});
|
||||
@ -457,13 +459,13 @@ class te {
|
||||
v(this, "getAppInfo", () => {
|
||||
});
|
||||
v(this, "refreshCache", (e = !1) => {
|
||||
e && o(this, m)["#"].clear(), o(this, m).$.clear();
|
||||
e && i(this, m)["#"].clear(), i(this, m).$.clear();
|
||||
});
|
||||
v(this, "decode", (e = "", t = {}) => {
|
||||
if (e === void 0 || e === "" || e === null)
|
||||
return t;
|
||||
try {
|
||||
const n = o(this, B).decode(e);
|
||||
const n = i(this, q).decode(e);
|
||||
return ne.unpack(n);
|
||||
} catch {
|
||||
return console.warn("core.decode", e), t;
|
||||
@ -471,16 +473,16 @@ class te {
|
||||
});
|
||||
v(this, "encode", (e = {}) => {
|
||||
const t = JSON.stringify(e, (n, s) => s === void 0 ? null : s);
|
||||
return o(this, B).encode(ne.pack(t));
|
||||
return i(this, q).encode(ne.pack(t));
|
||||
});
|
||||
C(this, Z, e), C(this, L, n), C(this, B, new be(t));
|
||||
_(this, Z, e), _(this, L, n), _(this, q, new be(t));
|
||||
}
|
||||
}
|
||||
L = new WeakMap(), B = new WeakMap(), Z = new WeakMap(), m = new WeakMap(), N = new WeakMap();
|
||||
L = new WeakMap(), q = new WeakMap(), Z = new WeakMap(), m = new WeakMap(), R = new WeakMap();
|
||||
const Te = te;
|
||||
te.onUnhandledRejection = (r) => {
|
||||
var e, t, n, s, f, h;
|
||||
r != null && r.IS_ECHO_MSG ? ((e = r == null ? void 0 : r.$echoMsg) == null || e.call(r), (t = r == null ? void 0 : r.preventDefault) == null || t.call(r)) : (n = r.reason) != null && n.IS_ECHO_MSG && ((f = (s = r.reason) == null ? void 0 : s.$echoMsg) == null || f.call(s), (h = r == null ? void 0 : r.preventDefault) == null || h.call(r));
|
||||
var e, t, n, s, c, l;
|
||||
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 && ((c = (s = r.reason) == null ? void 0 : s.$echoMsg) == null || c.call(s), (l = r == null ? void 0 : r.preventDefault) == null || l.call(r));
|
||||
};
|
||||
te.onMsg = (r, e) => [0, 1].includes(r) ? console.log(e) : console.warn(e);
|
||||
export {
|
||||
|
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",
|
||||
"private": true,
|
||||
"version": "0.9.14",
|
||||
"version": "0.9.15",
|
||||
"type": "module",
|
||||
"files": [
|
||||
"dist"
|
||||
@ -13,7 +13,7 @@
|
||||
"require": "./dist/ff-request.umd.cjs"
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"test": "vitest",
|
||||
"build": "vite build"
|
||||
},
|
||||
"dependencies": {
|
||||
@ -21,7 +21,10 @@
|
||||
"text-encoder": "^0.0.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"axios": "1.7.2",
|
||||
"jsdom": "^25.0.1",
|
||||
"rollup-plugin-copy": "^3.5.0",
|
||||
"vite": "^5.0.10"
|
||||
"vite": "^5.0.10",
|
||||
"vitest": "^2.1.8"
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user