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