v0.10.2
This commit is contained in:
parent
4fa89dfb3c
commit
b9aeab9a6e
591
dist/ff-request.js
vendored
591
dist/ff-request.js
vendored
@ -1,213 +1,213 @@
|
|||||||
var fe = Object.defineProperty;
|
var ue = Object.defineProperty;
|
||||||
var de = (r, e, t) => e in r ? fe(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
|
var fe = (r, e, t) => e in r ? ue(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
|
||||||
var g = (r, e, t) => (de(r, typeof e != "symbol" ? e + "" : e, t), t), oe = (r, e, t) => {
|
var p = (r, e, t) => (fe(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);
|
||||||
};
|
};
|
||||||
var o = (r, e, t) => (oe(r, e, "read from private field"), t ? t.call(r) : e.get(r)), p = (r, e, t) => {
|
var i = (r, e, t) => (ie(r, e, "read from private field"), t ? t.call(r) : e.get(r)), v = (r, e, t) => {
|
||||||
if (e.has(r))
|
if (e.has(r))
|
||||||
throw TypeError("Cannot add the same private member more than once");
|
throw TypeError("Cannot add the same private member more than once");
|
||||||
e instanceof WeakSet ? e.add(r) : e.set(r, t);
|
e instanceof WeakSet ? e.add(r) : e.set(r, t);
|
||||||
}, A = (r, e, t, n) => (oe(r, e, "write to private field"), n ? n.call(r, t) : e.set(r, t), t);
|
}, C = (r, e, t, n) => (ie(r, e, "write to private field"), n ? n.call(r, t) : e.set(r, t), t);
|
||||||
function ge(r) {
|
function de(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 le = {};
|
var ce = {};
|
||||||
(function(r) {
|
(function(r) {
|
||||||
(function(e) {
|
(function(e) {
|
||||||
e([], function() {
|
e([], function() {
|
||||||
var t = -1, n = -2, i = -3, s = -4, c = -5, T = function(h, l) {
|
var t = -1, n = -2, s = -3, o = -4, h = -5, R = function(f, l) {
|
||||||
l = l || {};
|
l = l || {};
|
||||||
var v = l.verbose || !1;
|
var w = l.verbose || !1;
|
||||||
v && console.log("Normalize the JSON Object"), h = typeof h == "string" ? this.JSON.parse(h) : h, v && console.log("Creating a empty dictionary");
|
w && console.log("Normalize the JSON Object"), f = typeof f == "string" ? this.JSON.parse(f) : f, w && console.log("Creating a empty dictionary");
|
||||||
var u = {
|
var u = {
|
||||||
strings: [],
|
strings: [],
|
||||||
integers: [],
|
integers: [],
|
||||||
floats: []
|
floats: []
|
||||||
};
|
};
|
||||||
v && console.log("Creating the AST");
|
w && console.log("Creating the AST");
|
||||||
var f = function x(a) {
|
var d = function T(c) {
|
||||||
v && console.log("Calling recursiveAstBuilder with " + this.JSON.stringify(a));
|
w && console.log("Calling recursiveAstBuilder with " + this.JSON.stringify(c));
|
||||||
var w = typeof a;
|
var y = typeof c;
|
||||||
if (a === null)
|
if (c === null)
|
||||||
return {
|
return {
|
||||||
type: "null",
|
type: "null",
|
||||||
index: i
|
|
||||||
};
|
|
||||||
if (typeof a > "u")
|
|
||||||
return {
|
|
||||||
type: "undefined",
|
|
||||||
index: c
|
|
||||||
};
|
|
||||||
if (a instanceof Array) {
|
|
||||||
var P = ["@"];
|
|
||||||
for (var y in a)
|
|
||||||
a.hasOwnProperty(y) && P.push(x(a[y]));
|
|
||||||
return P;
|
|
||||||
}
|
|
||||||
if (w === "object") {
|
|
||||||
var P = ["$"];
|
|
||||||
for (var M in a)
|
|
||||||
a.hasOwnProperty(M) && (P.push(x(M)), P.push(x(a[M])));
|
|
||||||
return P;
|
|
||||||
}
|
|
||||||
if (a === "")
|
|
||||||
return {
|
|
||||||
type: "empty",
|
|
||||||
index: s
|
index: s
|
||||||
};
|
};
|
||||||
if (w === "string") {
|
if (typeof c > "u")
|
||||||
var E = U.call(u.strings, a);
|
return {
|
||||||
return E == -1 && (u.strings.push($(a)), E = u.strings.length - 1), {
|
type: "undefined",
|
||||||
|
index: h
|
||||||
|
};
|
||||||
|
if (c instanceof Array) {
|
||||||
|
var x = ["@"];
|
||||||
|
for (var b in c)
|
||||||
|
c.hasOwnProperty(b) && x.push(T(c[b]));
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
if (y === "object") {
|
||||||
|
var x = ["$"];
|
||||||
|
for (var $ in c)
|
||||||
|
c.hasOwnProperty($) && (x.push(T($)), x.push(T(c[$])));
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
if (c === "")
|
||||||
|
return {
|
||||||
|
type: "empty",
|
||||||
|
index: o
|
||||||
|
};
|
||||||
|
if (y === "string") {
|
||||||
|
var O = I.call(u.strings, c);
|
||||||
|
return O == -1 && (u.strings.push(S(c)), O = u.strings.length - 1), {
|
||||||
type: "strings",
|
type: "strings",
|
||||||
index: E
|
index: O
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (w === "number" && a % 1 === 0) {
|
if (y === "number" && c % 1 === 0) {
|
||||||
var E = U.call(u.integers, a);
|
var O = I.call(u.integers, c);
|
||||||
return E == -1 && (u.integers.push(I(a)), E = u.integers.length - 1), {
|
return O == -1 && (u.integers.push(_(c)), O = u.integers.length - 1), {
|
||||||
type: "integers",
|
type: "integers",
|
||||||
index: E
|
index: O
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (w === "number") {
|
if (y === "number") {
|
||||||
var E = U.call(u.floats, a);
|
var O = I.call(u.floats, c);
|
||||||
return E == -1 && (u.floats.push(a), E = u.floats.length - 1), {
|
return O == -1 && (u.floats.push(c), O = u.floats.length - 1), {
|
||||||
type: "floats",
|
type: "floats",
|
||||||
index: E
|
index: O
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (w === "boolean")
|
if (y === "boolean")
|
||||||
return {
|
return {
|
||||||
type: "boolean",
|
type: "boolean",
|
||||||
index: a ? t : n
|
index: c ? t : n
|
||||||
};
|
};
|
||||||
throw new Error("Unexpected argument of type " + typeof a);
|
throw new Error("Unexpected argument of type " + typeof c);
|
||||||
}(h), b = u.strings.length, D = u.integers.length;
|
}(f), E = u.strings.length, B = u.integers.length;
|
||||||
u.floats.length, v && console.log("Parsing the dictionary");
|
u.floats.length, w && console.log("Parsing the dictionary");
|
||||||
var C = u.strings.join("|");
|
var N = u.strings.join("|");
|
||||||
return C += "^" + u.integers.join("|"), C += "^" + u.floats.join("|"), v && console.log("Parsing the structure"), C += "^" + function x(a) {
|
return N += "^" + u.integers.join("|"), N += "^" + u.floats.join("|"), w && console.log("Parsing the structure"), N += "^" + function T(c) {
|
||||||
if (v && console.log("Calling a recursiveParser with " + this.JSON.stringify(a)), a instanceof Array) {
|
if (w && console.log("Calling a recursiveParser with " + this.JSON.stringify(c)), c instanceof Array) {
|
||||||
var w = a.shift();
|
var y = c.shift();
|
||||||
for (var P in a)
|
for (var x in c)
|
||||||
a.hasOwnProperty(P) && (w += x(a[P]) + "|");
|
c.hasOwnProperty(x) && (y += T(c[x]) + "|");
|
||||||
return (w[w.length - 1] === "|" ? w.slice(0, -1) : w) + "]";
|
return (y[y.length - 1] === "|" ? y.slice(0, -1) : y) + "]";
|
||||||
}
|
}
|
||||||
var y = a.type, M = a.index;
|
var b = c.type, $ = c.index;
|
||||||
if (y === "strings")
|
if (b === "strings")
|
||||||
return I(M);
|
return _($);
|
||||||
if (y === "integers")
|
if (b === "integers")
|
||||||
return I(b + M);
|
return _(E + $);
|
||||||
if (y === "floats")
|
if (b === "floats")
|
||||||
return I(b + D + M);
|
return _(E + B + $);
|
||||||
if (y === "boolean")
|
if (b === "boolean")
|
||||||
return a.index;
|
return c.index;
|
||||||
if (y === "null")
|
if (b === "null")
|
||||||
return i;
|
|
||||||
if (y === "undefined")
|
|
||||||
return c;
|
|
||||||
if (y === "empty")
|
|
||||||
return s;
|
return s;
|
||||||
|
if (b === "undefined")
|
||||||
|
return h;
|
||||||
|
if (b === "empty")
|
||||||
|
return o;
|
||||||
throw new TypeError("The item is alien!");
|
throw new TypeError("The item is alien!");
|
||||||
}(f), v && console.log("Ending parser"), l.debug ? {
|
}(d), w && console.log("Ending parser"), l.debug ? {
|
||||||
dictionary: u,
|
dictionary: u,
|
||||||
ast: f,
|
ast: d,
|
||||||
packed: C
|
packed: N
|
||||||
} : C;
|
} : N;
|
||||||
}, O = function(h, l) {
|
}, a = function(f, l) {
|
||||||
l = l || {};
|
l = l || {};
|
||||||
var v = h.split("^");
|
var w = f.split("^");
|
||||||
l.verbose && console.log("Building dictionary");
|
l.verbose && console.log("Building dictionary");
|
||||||
var u = [], f = v[0];
|
var u = [], d = w[0];
|
||||||
if (f !== "") {
|
if (d !== "") {
|
||||||
f = f.split("|"), l.verbose && console.log("Parse the strings dictionary");
|
d = d.split("|"), l.verbose && console.log("Parse the strings dictionary");
|
||||||
for (var b = 0, D = f.length; b < D; b++)
|
for (var E = 0, B = d.length; E < B; E++)
|
||||||
u.push(V(f[b]));
|
u.push(M(d[E]));
|
||||||
}
|
}
|
||||||
if (f = v[1], f !== "") {
|
if (d = w[1], d !== "") {
|
||||||
f = f.split("|"), l.verbose && console.log("Parse the integers dictionary");
|
d = d.split("|"), l.verbose && console.log("Parse the integers dictionary");
|
||||||
for (var b = 0, D = f.length; b < D; b++)
|
for (var E = 0, B = d.length; E < B; E++)
|
||||||
u.push(Y(f[b]));
|
u.push(F(d[E]));
|
||||||
}
|
}
|
||||||
if (f = v[2], f !== "") {
|
if (d = w[2], d !== "") {
|
||||||
f = f.split("|"), l.verbose && console.log("Parse the floats dictionary");
|
d = d.split("|"), l.verbose && console.log("Parse the floats dictionary");
|
||||||
for (var b = 0, D = f.length; b < D; b++)
|
for (var E = 0, B = d.length; E < B; E++)
|
||||||
u.push(parseFloat(f[b]));
|
u.push(parseFloat(d[E]));
|
||||||
}
|
}
|
||||||
f = null, l.verbose && console.log("Tokenizing the structure");
|
d = null, l.verbose && console.log("Tokenizing the structure");
|
||||||
for (var C = "", x = [], a = v[3].length, b = 0; b < a; b++) {
|
for (var N = "", T = [], c = w[3].length, E = 0; E < c; E++) {
|
||||||
var w = v[3].charAt(b);
|
var y = w[3].charAt(E);
|
||||||
w === "|" || w === "$" || w === "@" || w === "]" ? (C && (x.push(Y(C)), C = ""), w !== "|" && x.push(w)) : C += w;
|
y === "|" || y === "$" || y === "@" || y === "]" ? (N && (T.push(F(N)), N = ""), y !== "|" && T.push(y)) : N += y;
|
||||||
}
|
}
|
||||||
var P = x.length, y = 0;
|
var x = T.length, b = 0;
|
||||||
return l.verbose && console.log("Starting recursive parser"), function M() {
|
return l.verbose && console.log("Starting recursive parser"), function $() {
|
||||||
var E = x[y++];
|
var O = T[b++];
|
||||||
if (l.verbose && console.log("Reading collection type " + (E === "$" ? "object" : "Array")), E === "@") {
|
if (l.verbose && console.log("Reading collection type " + (O === "$" ? "object" : "Array")), O === "@") {
|
||||||
for (var d = []; y < P; y++) {
|
for (var g = []; b < x; b++) {
|
||||||
var _ = x[y];
|
var A = T[b];
|
||||||
if (l.verbose && console.log("Read " + _ + " symbol"), _ === "]")
|
if (l.verbose && console.log("Read " + A + " symbol"), A === "]")
|
||||||
return d;
|
return g;
|
||||||
if (_ === "@" || _ === "$")
|
if (A === "@" || A === "$")
|
||||||
d.push(M());
|
g.push($());
|
||||||
else
|
else
|
||||||
switch (_) {
|
switch (A) {
|
||||||
case t:
|
case t:
|
||||||
d.push(!0);
|
g.push(!0);
|
||||||
break;
|
break;
|
||||||
case n:
|
case n:
|
||||||
d.push(!1);
|
g.push(!1);
|
||||||
break;
|
|
||||||
case i:
|
|
||||||
d.push(null);
|
|
||||||
break;
|
|
||||||
case c:
|
|
||||||
d.push(void 0);
|
|
||||||
break;
|
break;
|
||||||
case s:
|
case s:
|
||||||
d.push("");
|
g.push(null);
|
||||||
|
break;
|
||||||
|
case h:
|
||||||
|
g.push(void 0);
|
||||||
|
break;
|
||||||
|
case o:
|
||||||
|
g.push("");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
d.push(u[_]);
|
g.push(u[A]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return l.verbose && console.log("Parsed " + this.JSON.stringify(d)), d;
|
return l.verbose && console.log("Parsed " + this.JSON.stringify(g)), g;
|
||||||
}
|
}
|
||||||
if (E === "$") {
|
if (O === "$") {
|
||||||
for (var d = {}; y < P; y++) {
|
for (var g = {}; b < x; b++) {
|
||||||
var S = x[y];
|
var P = T[b];
|
||||||
if (S === "]")
|
if (P === "]")
|
||||||
return d;
|
return g;
|
||||||
S === s ? S = "" : S = u[S];
|
P === o ? P = "" : P = u[P];
|
||||||
var _ = x[++y];
|
var A = T[++b];
|
||||||
if (_ === "@" || _ === "$")
|
if (A === "@" || A === "$")
|
||||||
d[S] = M();
|
g[P] = $();
|
||||||
else
|
else
|
||||||
switch (_) {
|
switch (A) {
|
||||||
case t:
|
case t:
|
||||||
d[S] = !0;
|
g[P] = !0;
|
||||||
break;
|
break;
|
||||||
case n:
|
case n:
|
||||||
d[S] = !1;
|
g[P] = !1;
|
||||||
break;
|
|
||||||
case i:
|
|
||||||
d[S] = null;
|
|
||||||
break;
|
|
||||||
case c:
|
|
||||||
d[S] = void 0;
|
|
||||||
break;
|
break;
|
||||||
case s:
|
case s:
|
||||||
d[S] = "";
|
g[P] = null;
|
||||||
|
break;
|
||||||
|
case h:
|
||||||
|
g[P] = void 0;
|
||||||
|
break;
|
||||||
|
case o:
|
||||||
|
g[P] = "";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
d[S] = u[_];
|
g[P] = u[A];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return l.verbose && console.log("Parsed " + this.JSON.stringify(d)), d;
|
return l.verbose && console.log("Parsed " + this.JSON.stringify(g)), g;
|
||||||
}
|
}
|
||||||
throw new TypeError("Bad token " + E + " isn't a type");
|
throw new TypeError("Bad token " + O + " isn't a type");
|
||||||
}();
|
}();
|
||||||
}, $ = function(h) {
|
}, S = function(f) {
|
||||||
return typeof h != "string" ? h : h.replace(/[\+ \|\^\%]/g, function(l) {
|
return typeof f != "string" ? f : f.replace(/[\+ \|\^\%]/g, function(l) {
|
||||||
return {
|
return {
|
||||||
" ": "+",
|
" ": "+",
|
||||||
"+": "%2B",
|
"+": "%2B",
|
||||||
@ -216,8 +216,8 @@ var le = {};
|
|||||||
"%": "%25"
|
"%": "%25"
|
||||||
}[l];
|
}[l];
|
||||||
});
|
});
|
||||||
}, V = function(h) {
|
}, M = function(f) {
|
||||||
return typeof h != "string" ? h : h.replace(/\+|%2B|%7C|%5E|%25/g, function(l) {
|
return typeof f != "string" ? f : f.replace(/\+|%2B|%7C|%5E|%25/g, function(l) {
|
||||||
return {
|
return {
|
||||||
"+": " ",
|
"+": " ",
|
||||||
"%2B": "+",
|
"%2B": "+",
|
||||||
@ -226,86 +226,86 @@ var le = {};
|
|||||||
"%25": "%"
|
"%25": "%"
|
||||||
}[l];
|
}[l];
|
||||||
});
|
});
|
||||||
}, I = function(h) {
|
}, _ = function(f) {
|
||||||
return Number.prototype.toString.call(h, 36).toUpperCase();
|
return Number.prototype.toString.call(f, 36).toUpperCase();
|
||||||
}, Y = function(h) {
|
}, F = function(f) {
|
||||||
return parseInt(h, 36);
|
return parseInt(f, 36);
|
||||||
}, U = Array.prototype.indexOf || function(h, l) {
|
}, I = Array.prototype.indexOf || function(f, l) {
|
||||||
for (var v = l || 0, u = this.length; v < u; v++)
|
for (var w = l || 0, u = this.length; w < u; w++)
|
||||||
if (this[v] === h)
|
if (this[w] === f)
|
||||||
return v;
|
return w;
|
||||||
return -1;
|
return -1;
|
||||||
};
|
};
|
||||||
return {
|
return {
|
||||||
JSON,
|
JSON,
|
||||||
pack: T,
|
pack: R,
|
||||||
unpack: O
|
unpack: a
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
})(function(e, t) {
|
})(function(e, t) {
|
||||||
var n = t();
|
var n = t();
|
||||||
for (var i in n)
|
for (var s in n)
|
||||||
r[i] = n[i];
|
r[s] = n[s];
|
||||||
});
|
});
|
||||||
})(le);
|
})(ce);
|
||||||
const ae = /* @__PURE__ */ ge(le);
|
const oe = /* @__PURE__ */ de(ce);
|
||||||
var J, K, B, F, W, X, H, Z, ee;
|
var K, q, j, D, Q, W, L, X, Z;
|
||||||
class se {
|
class ne {
|
||||||
constructor(e, t, n, i, s) {
|
constructor(e, t, n, s, o) {
|
||||||
g(this, "code", 0);
|
p(this, "code", 0);
|
||||||
g(this, "message", "操作成功");
|
p(this, "message", "操作成功");
|
||||||
g(this, "data", null);
|
p(this, "data", null);
|
||||||
g(this, "url", "");
|
p(this, "url", "");
|
||||||
g(this, "res", "");
|
p(this, "res", "");
|
||||||
// static [Symbol.hasInstance](self) { return self?.IS_ECHO_MSG !== undefined }
|
// static [Symbol.hasInstance](self) { return self?.IS_ECHO_MSG !== undefined }
|
||||||
p(this, J, null);
|
v(this, K, null);
|
||||||
// 判断返回 Response 对象, 还是 Response 中的 data
|
// 判断返回 Response 对象, 还是 Response 中的 data
|
||||||
p(this, K, !0);
|
v(this, q, !0);
|
||||||
// 判罚是否已经给出错误提示
|
// 判罚是否已经给出错误提示
|
||||||
p(this, B, !0);
|
v(this, j, !0);
|
||||||
p(this, F, {
|
v(this, D, {
|
||||||
get: (e, t) => o(this, W).call(this, t),
|
get: (e, t) => i(this, Q).call(this, t),
|
||||||
ownKeys: () => Object.keys(o(this, F).getPrototypeOf() || {}),
|
ownKeys: () => Object.keys(i(this, D).getPrototypeOf() || {}),
|
||||||
getPrototypeOf: () => o(this, K) ? this : this.data,
|
getPrototypeOf: () => i(this, q) ? this : this.data,
|
||||||
getOwnPropertyDescriptor: () => ({
|
getOwnPropertyDescriptor: () => ({
|
||||||
configurable: !0,
|
configurable: !0,
|
||||||
enumerable: !0,
|
enumerable: !0,
|
||||||
writable: !0,
|
writable: !0,
|
||||||
value: o(this, F).getPrototypeOf()
|
value: i(this, D).getPrototypeOf()
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
p(this, W, (e) => e === "$echoMsg" ? o(this, H) : e === "msg" ? o(this, X) : e === "then" || e === "resp" ? (A(this, B, !0), A(this, K, e === "resp"), o(this, Z)) : e === "catch" ? o(this, ee) : e === "IS_ECHO_MSG" ? o(this, B) : Reflect.get(this, e));
|
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));
|
||||||
p(this, X, (e = (n) => n, t = !1) => (o(this, H).call(this), A(this, K, t), Promise.resolve(e == null ? void 0 : e(o(this, F).getPrototypeOf()))));
|
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()))));
|
||||||
p(this, H, () => {
|
v(this, L, () => {
|
||||||
o(this, B) && (A(this, B, !1), Ae.onMsg(this.code, this.message));
|
i(this, j) && (C(this, j, !1), _e.onMsg(this.code, this.message));
|
||||||
});
|
});
|
||||||
p(this, Z, (e) => [0, 1].includes(this.code) ? Promise.resolve(e == null ? void 0 : e(o(this, F).getPrototypeOf())) : Promise.reject(o(this, J)));
|
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)));
|
||||||
p(this, ee, (e) => Promise.resolve(e(o(this, J))));
|
v(this, Z, (e) => Promise.resolve(e(i(this, K))));
|
||||||
return this.code = e, this.message = t, this.data = n, this.url = i, this.res = s, A(this, J, new Proxy(this, o(this, F)));
|
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)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
J = new WeakMap(), K = new WeakMap(), B = new WeakMap(), F = new WeakMap(), W = new WeakMap(), X = new WeakMap(), H = new WeakMap(), Z = new WeakMap(), ee = new WeakMap();
|
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();
|
||||||
const ne = (r, e, t, n = "/", i = "") => new se(r, e, t, n, i);
|
const re = (r, e, t, n = "/", s = "") => new ne(r, e, t, n, s);
|
||||||
var ue = [
|
var le = [
|
||||||
"utf8",
|
"utf8",
|
||||||
"utf-8",
|
"utf-8",
|
||||||
"unicode-1-1-utf-8"
|
"unicode-1-1-utf-8"
|
||||||
];
|
];
|
||||||
function pe(r) {
|
function ge(r) {
|
||||||
if (ue.indexOf(r) < 0 && typeof r < "u" && r != null)
|
if (le.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 s = t.split("");
|
||||||
for (let s = 0; s < i.length; s++)
|
for (let o = 0; o < s.length; o++)
|
||||||
n[s] = i[s].charCodeAt(0);
|
n[o] = s[o].charCodeAt(0);
|
||||||
return n;
|
return n;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
function ve(r) {
|
function pe(r) {
|
||||||
if (ue.indexOf(r) < 0 && typeof r < "u" && r != null)
|
if (le.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")
|
||||||
@ -314,29 +314,29 @@ function ve(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), s = new Array(i.length);
|
var s = new Uint8Array(e.buffer, e.byteOffset, e.byteLength), o = new Array(s.length);
|
||||||
for (let c = 0; c < i.length; c++)
|
for (let h = 0; h < s.length; h++)
|
||||||
s[c] = String.fromCharCode(i[c]);
|
o[h] = String.fromCharCode(s[h]);
|
||||||
return decodeURIComponent(escape(s.join("")));
|
return decodeURIComponent(escape(o.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 he = {
|
var he = {
|
||||||
TextEncoder: pe,
|
TextEncoder: ge,
|
||||||
TextDecoder: ve
|
TextDecoder: pe
|
||||||
};
|
};
|
||||||
const we = new he.TextEncoder("utf8"), ye = new he.TextDecoder("utf8"), be = (r) => {
|
const ve = new he.TextEncoder("utf8"), we = new he.TextDecoder("utf8"), ye = (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);
|
||||||
return (e >>> 0).toString(16);
|
return (e >>> 0).toString(16);
|
||||||
}, Ee = (r, e) => r.replace(new RegExp(`^${e}+|${e}+$`, "g"), ""), Oe = (r) => we.encode(r || ""), Me = (r) => ye.decode(new DataView(r), {}), Te = 62, Q = 30, ce = 31, xe = 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 Pe {
|
class xe {
|
||||||
constructor(e) {
|
constructor(e) {
|
||||||
g(this, "encodeTable", []);
|
p(this, "encodeTable", []);
|
||||||
g(this, "decodeMap", new Uint8Array(256).fill(255));
|
p(this, "decodeMap", new Uint8Array(256).fill(255));
|
||||||
if (e.length !== Te)
|
if (e.length !== Oe)
|
||||||
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"))
|
||||||
@ -349,157 +349,162 @@ class Pe {
|
|||||||
encode(e) {
|
encode(e) {
|
||||||
if (!e || e.length === 0)
|
if (!e || e.length === 0)
|
||||||
return [];
|
return [];
|
||||||
const t = new Se(this).encodeV2(e);
|
const t = new Pe(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 _e(this).decode(e);
|
const t = new Se(this).decode(e);
|
||||||
return new TextDecoder().decode(t);
|
return new TextDecoder().decode(t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var L;
|
var z;
|
||||||
class Se {
|
class Pe {
|
||||||
constructor(e) {
|
constructor(e) {
|
||||||
p(this, L, null);
|
v(this, z, null);
|
||||||
A(this, L, e);
|
C(this, z, e);
|
||||||
}
|
}
|
||||||
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 & xe;
|
return e < 6 && t > 0 && (n |= this.src[t - 1] << e), n & Te;
|
||||||
}
|
}
|
||||||
encodeV2(e) {
|
encodeV2(e) {
|
||||||
this.src = Oe(e), this.pos = this.src.length * 8;
|
this.src = Ee(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, s = this.get6bits();
|
||||||
(i & Q) === Q && ((this.pos > 6 || i > ce) && (n = 5), i &= ce), t.push(o(this, L).encodeTable[i].charCodeAt(0)), this.pos -= n;
|
(s & Y) === Y && ((this.pos > 6 || s > ae) && (n = 5), s &= ae), t.push(i(this, z).encodeTable[s].charCodeAt(0)), this.pos -= n;
|
||||||
}
|
}
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
L = new WeakMap();
|
z = new WeakMap();
|
||||||
var z;
|
var k;
|
||||||
class _e {
|
class Se {
|
||||||
constructor(e) {
|
constructor(e) {
|
||||||
p(this, z, null);
|
v(this, k, null);
|
||||||
A(this, z, e);
|
C(this, k, e);
|
||||||
}
|
}
|
||||||
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, s = 0;
|
let n = t.length, s = 0, o = 0;
|
||||||
for (let c = 0; c < e.length; c++) {
|
for (let h = 0; h < e.length; h++) {
|
||||||
const T = e[c].charCodeAt(0), O = o(this, z).decodeMap[T];
|
const R = e[h].charCodeAt(0), a = i(this, k).decodeMap[R];
|
||||||
if (O === 255)
|
if (a === 255)
|
||||||
throw new Error(`CorruptInputError at index ${c}`);
|
throw new Error(`CorruptInputError at index ${h}`);
|
||||||
c === e.length - 1 ? (s |= O << i, i += Math.ceil(Math.log2(O + 1))) : (O & Q) === Q ? (s |= O << i, i += 5) : (s |= O << i, i += 6), i >= 8 && (n--, t[n] = s & 255, i %= 8, s >>= 8);
|
h === e.length - 1 ? (o |= a << s, s += Math.ceil(Math.log2(a + 1))) : (a & Y) === Y ? (o |= a << s, s += 5) : (o |= a << s, s += 6), s >= 8 && (n--, t[n] = o & 255, s %= 8, o >>= 8);
|
||||||
}
|
}
|
||||||
return i > 0 && (n--, t[n] = s & 255), t.slice(n);
|
return s > 0 && (n--, t[n] = o & 255), t.slice(n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
z = 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, s) => {
|
||||||
r = n, e = i;
|
r = n, e = s;
|
||||||
}), resolve: r, reject: e };
|
}), resolve: r, reject: e };
|
||||||
});
|
});
|
||||||
var j, q, te, N, R, G, re, k;
|
var G, H, ee, m, U, J, te, V;
|
||||||
class ie {
|
class se {
|
||||||
constructor(e, t, n) {
|
constructor(e, t, n) {
|
||||||
p(this, j, void 0);
|
v(this, G, void 0);
|
||||||
p(this, q, void 0);
|
v(this, H, void 0);
|
||||||
p(this, te, void 0);
|
v(this, ee, void 0);
|
||||||
p(this, N, {
|
v(this, m, {
|
||||||
"#": /* @__PURE__ */ new Map(),
|
"#": /* @__PURE__ */ new Map(),
|
||||||
// 系统缓存
|
// 系统缓存
|
||||||
$: /* @__PURE__ */ new Map()
|
$: /* @__PURE__ */ new Map()
|
||||||
// 普通缓存
|
// 普通缓存
|
||||||
});
|
});
|
||||||
p(this, R, /* @__PURE__ */ new Map());
|
v(this, U, /* @__PURE__ */ new Map());
|
||||||
p(this, G, /* @__PURE__ */ new Set());
|
v(this, J, /* @__PURE__ */ new Set());
|
||||||
g(this, "init", (e, t, n) => {
|
p(this, "init", (e, t, n) => {
|
||||||
A(this, te, e), A(this, j, n), A(this, q, new Pe(t)), o(this, re).call(this);
|
C(this, ee, e), C(this, G, n), C(this, H, new xe(t)), i(this, te).call(this);
|
||||||
});
|
});
|
||||||
p(this, re, () => {
|
v(this, te, () => {
|
||||||
!o(this, G).size || !o(this, j) || (o(this, G).forEach((e) => o(this, k).call(this, ...e)), o(this, G).clear());
|
!i(this, J).size || !i(this, G) || (i(this, J).forEach((e) => i(this, V).call(this, ...e)), i(this, J).clear());
|
||||||
});
|
});
|
||||||
p(this, k, (e, t, n, i = !1) => {
|
v(this, V, (e, t, n, s = !1) => {
|
||||||
o(this, j) ? o(this, j).call(this, n || {}).then((s) => {
|
if (!i(this, G))
|
||||||
if (![0, 1].includes(s.code))
|
i(this, J).add([e, t, n, s]);
|
||||||
throw ne(s.code, s.msg, s.data, url, s == null ? void 0 : s.res);
|
else {
|
||||||
return [s.code, s.msg, s.data, url, s == null ? void 0 : s.res];
|
const { url: o, method: h, ...R } = n || {};
|
||||||
}).then((s) => ((t == "#" || m == "GET") && o(this, N)[t].set(e, s), t != "#" && m == "GET" && !i && setTimeout(() => {
|
i(this, G).call(this, { url: o, method: h, ...R }).then((a) => {
|
||||||
o(this, N)[t].delete(e);
|
if (![0, 1].includes(a.code))
|
||||||
}, 300), s)).then((s) => {
|
throw re(a.code, a.msg, a.data, o, a == null ? void 0 : a.res);
|
||||||
var c;
|
return [a.code, a.msg, a.data, o, a == null ? void 0 : a.res];
|
||||||
return (c = o(this, R).get(e)) == null ? void 0 : c.forEach((T, O, $) => {
|
}).then((a) => ((t == "#" || h == "GET") && i(this, m)[t].set(e, a), t != "#" && h == "GET" && !s && setTimeout(() => {
|
||||||
T && T[0](s), delete $[O];
|
i(this, m)[t].delete(e);
|
||||||
|
}, 300), a)).then((a) => {
|
||||||
|
var S;
|
||||||
|
return (S = i(this, U).get(e)) == null ? void 0 : S.forEach((M, _, F) => {
|
||||||
|
M && M[0](a), delete F[_];
|
||||||
});
|
});
|
||||||
}).catch((s) => {
|
}).catch((a) => {
|
||||||
var c;
|
var S;
|
||||||
o(this, N)[t].delete(e), (c = o(this, R).get(e)) == null || c.forEach((T, O, $) => {
|
i(this, m)[t].delete(e), (S = i(this, U).get(e)) == null || S.forEach((M, _, F) => {
|
||||||
T && T[1](s instanceof se ? s : ne(-1, s, null, url)), delete $[O];
|
M && M[1](a instanceof ne ? a : re(-1, a, null, o)), delete F[_];
|
||||||
});
|
});
|
||||||
}).finally(() => o(this, R).delete(e)) : o(this, G).add([e, t, n, i]);
|
}).finally(() => i(this, U).delete(e));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
g(this, "request", ({ url: e = "/", method: t = "GET", ...n }, i = !1) => {
|
p(this, "request", ({ url: e = "/", method: t = "GET", ...n }, s = !1) => {
|
||||||
var I;
|
var _;
|
||||||
e = Ee(e, "/");
|
e = be(e, "/");
|
||||||
const s = t.toUpperCase(), c = be(JSON.stringify([e, s, n])), T = (I = e == null ? void 0 : e.includes) != null && I.call(e, "/_/") ? "#" : "$", { promise: O, resolve: $, reject: V } = 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: S, reject: M } = Promise.withResolvers();
|
||||||
return o(this, N)[T].has(c) ? (console.log("cache", e), $(o(this, N)[T].get(c))) : o(this, R).has(c) ? o(this, R).get(c).push([$, V]) : (o(this, R).set(c, [[$, V]]), o(this, k).call(this, c, T, { url: e, method: s, ...n }, i)), new Proxy(O, {
|
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, {
|
||||||
get: (Y, U) => (...h) => Y.then((l) => ne(...l)[U](...h)).catch((l) => {
|
get: (F, I) => (...f) => F.then((l) => re(...l)[I](...f)).catch((l) => {
|
||||||
if (!l instanceof se)
|
if (!l instanceof ne)
|
||||||
throw l;
|
throw l;
|
||||||
return typeof l[U] == "function" ? l[U](...h) : l[U];
|
return typeof l[I] == "function" ? l[I](...f) : l[I];
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
g(this, "get", (e, t = {}) => this.request({ url: e, method: "GET", params: t }));
|
p(this, "get", (e, t = {}) => this.request({ url: e, method: "GET", params: t }));
|
||||||
g(this, "post", (e, t = {}, n = {}) => this.request({ url: e, method: "POST", data: t, params: n }));
|
p(this, "post", (e, t = {}, n = {}) => this.request({ url: e, method: "POST", data: t, params: n }));
|
||||||
g(this, "put", (e, t = {}, n = {}) => this.request({ url: e, method: "PUT", data: t, params: n }));
|
p(this, "put", (e, t = {}, n = {}) => this.request({ url: e, method: "PUT", data: t, params: n }));
|
||||||
g(this, "del", (e, t = {}, n = {}) => this.request({ url: e, method: "DELETE", data: t, params: n }));
|
p(this, "del", (e, t = {}, n = {}) => this.request({ url: e, method: "DELETE", data: t, params: n }));
|
||||||
g(this, "download", (e, t) => {
|
p(this, "download", (e, t) => {
|
||||||
});
|
});
|
||||||
g(this, "cache", (e, t = {}) => this.request({ url: e, method: "GET", params: t }, !0));
|
p(this, "cache", (e, t = {}) => this.request({ url: e, method: "GET", params: t }, !0));
|
||||||
g(this, "list", (e, t = {}) => this.get(`/api/${e}/${this.encode(t)}`));
|
p(this, "list", (e, t = {}) => this.get(`/api/${e}/${this.encode(t)}`));
|
||||||
g(this, "getAppInfo", () => {
|
p(this, "getAppInfo", () => {
|
||||||
});
|
});
|
||||||
g(this, "refreshCache", (e = !1) => {
|
p(this, "refreshCache", (e = !1) => {
|
||||||
e && o(this, N)["#"].clear(), o(this, N).$.clear();
|
e && i(this, m)["#"].clear(), i(this, m).$.clear();
|
||||||
});
|
});
|
||||||
g(this, "decode", (e = "", t = {}) => {
|
p(this, "decode", (e = "", t = {}) => {
|
||||||
if (e === void 0 || e === "" || e === null)
|
if (e === void 0 || e === "" || e === null)
|
||||||
return t;
|
return t;
|
||||||
try {
|
try {
|
||||||
const n = o(this, q).decode(e);
|
const n = i(this, H).decode(e);
|
||||||
return ae.unpack(n);
|
return oe.unpack(n);
|
||||||
} catch {
|
} catch {
|
||||||
return console.warn("core.decode", e), t;
|
return console.warn("core.decode", e), t;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
g(this, "encode", (e = {}) => {
|
p(this, "encode", (e = {}) => {
|
||||||
const t = JSON.stringify(e, (n, i) => i === void 0 ? null : i);
|
const t = JSON.stringify(e, (n, s) => s === void 0 ? null : s);
|
||||||
return o(this, q).encode(ae.pack(t));
|
return i(this, H).encode(oe.pack(t));
|
||||||
});
|
});
|
||||||
this.init(e, t, n);
|
this.init(e, t, n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
j = new WeakMap(), q = new WeakMap(), te = new WeakMap(), N = new WeakMap(), R = new WeakMap(), G = new WeakMap(), re = new WeakMap(), k = new WeakMap();
|
G = new WeakMap(), H = new WeakMap(), ee = new WeakMap(), m = new WeakMap(), U = new WeakMap(), J = new WeakMap(), te = new WeakMap(), V = new WeakMap();
|
||||||
const Ae = ie;
|
const _e = se;
|
||||||
ie.onUnhandledRejection = (r) => {
|
se.onUnhandledRejection = (r) => {
|
||||||
var e, t, n, i, s, c;
|
var e, t, n, s, o, 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 && ((s = (i = r.reason) == null ? void 0 : i.$echoMsg) == null || s.call(i), (c = r == null ? void 0 : r.preventDefault) == null || c.call(r));
|
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 = (s = r.reason) == null ? void 0 : s.$echoMsg) == null || o.call(s), (h = r == null ? void 0 : r.preventDefault) == null || h.call(r));
|
||||||
};
|
};
|
||||||
ie.onMsg = (r, e) => [0, 1].includes(r) ? console.log(e) : console.warn(e);
|
se.onMsg = (r, e) => [0, 1].includes(r) ? console.log(e) : console.warn(e);
|
||||||
export {
|
export {
|
||||||
Ae as default,
|
_e as default,
|
||||||
be as signature,
|
ye as signature,
|
||||||
Oe as str2uint8array,
|
Ee as str2uint8array,
|
||||||
Ee as trim,
|
be as trim,
|
||||||
Me as uint8array2str
|
Ce as uint8array2str
|
||||||
};
|
};
|
||||||
|
|||||||
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.1",
|
"version": "0.10.2",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"files": [
|
"files": [
|
||||||
"dist"
|
"dist"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user