chore: 构建产物更新 v0.11.2
This commit is contained in:
436
ff-request.js
436
ff-request.js
@@ -1,51 +1,51 @@
|
|||||||
var ue = Object.defineProperty;
|
var de = Object.defineProperty;
|
||||||
var ie = (r) => {
|
var oe = (r) => {
|
||||||
throw TypeError(r);
|
throw TypeError(r);
|
||||||
};
|
};
|
||||||
var de = (r, e, t) => e in r ? ue(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
|
var ge = (r, e, t) => e in r ? de(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), oe = (r, e, t) => e.has(r) || ie("Cannot " + t);
|
var g = (r, e, t) => ge(r, typeof e != "symbol" ? e + "" : e, t), ae = (r, e, t) => e.has(r) || oe("Cannot " + t);
|
||||||
var i = (r, e, t) => (oe(r, e, "read from private field"), t ? t.call(r) : e.get(r)), w = (r, e, t) => e.has(r) ? ie("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(r) : e.set(r, t), C = (r, e, t, n) => (oe(r, e, "write to private field"), n ? n.call(r, t) : e.set(r, t), t);
|
var s = (r, e, t) => (ae(r, e, "read from private field"), t ? t.call(r) : e.get(r)), w = (r, e, t) => e.has(r) ? oe("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(r) : e.set(r, t), C = (r, e, t, n) => (ae(r, e, "write to private field"), n ? n.call(r, t) : e.set(r, t), t);
|
||||||
function ge(r) {
|
function pe(r) {
|
||||||
return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r;
|
return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r;
|
||||||
}
|
}
|
||||||
var he = {};
|
var he = {};
|
||||||
(function(r) {
|
(function(r) {
|
||||||
(function(e) {
|
(function(e) {
|
||||||
e([], function() {
|
e([], function() {
|
||||||
var t = -1, n = -2, s = -3, o = -4, h = -5, R = function(l, u) {
|
var t = -1, n = -2, i = -3, o = -4, l = -5, R = function(u, f) {
|
||||||
u = u || {};
|
f = f || {};
|
||||||
var f = u.verbose || !1;
|
var h = f.verbose || !1;
|
||||||
f && console.log("Normalize the JSON Object"), l = typeof l == "string" ? this.JSON.parse(l) : l, f && console.log("Creating a empty dictionary");
|
h && console.log("Normalize the JSON Object"), u = typeof u == "string" ? this.JSON.parse(u) : u, h && console.log("Creating a empty dictionary");
|
||||||
var d = {
|
var d = {
|
||||||
strings: [],
|
strings: [],
|
||||||
integers: [],
|
integers: [],
|
||||||
floats: []
|
floats: []
|
||||||
};
|
};
|
||||||
f && console.log("Creating the AST");
|
h && console.log("Creating the AST");
|
||||||
var p = function S(a) {
|
var p = function P(a) {
|
||||||
f && console.log("Calling recursiveAstBuilder with " + this.JSON.stringify(a));
|
h && console.log("Calling recursiveAstBuilder with " + this.JSON.stringify(a));
|
||||||
var y = typeof a;
|
var y = typeof a;
|
||||||
if (a === null)
|
if (a === null)
|
||||||
return {
|
return {
|
||||||
type: "null",
|
type: "null",
|
||||||
index: s
|
index: i
|
||||||
};
|
};
|
||||||
if (typeof a > "u")
|
if (typeof a > "u")
|
||||||
return {
|
return {
|
||||||
type: "undefined",
|
type: "undefined",
|
||||||
index: h
|
index: l
|
||||||
};
|
};
|
||||||
if (a instanceof Array) {
|
if (a instanceof Array) {
|
||||||
var x = ["@"];
|
var S = ["@"];
|
||||||
for (var b in a)
|
for (var b in a)
|
||||||
a.hasOwnProperty(b) && x.push(S(a[b]));
|
a.hasOwnProperty(b) && S.push(P(a[b]));
|
||||||
return x;
|
return S;
|
||||||
}
|
}
|
||||||
if (y === "object") {
|
if (y === "object") {
|
||||||
var x = ["$"];
|
var S = ["$"];
|
||||||
for (var $ in a)
|
for (var m in a)
|
||||||
a.hasOwnProperty($) && (x.push(S($)), x.push(S(a[$])));
|
a.hasOwnProperty(m) && (S.push(P(m)), S.push(P(a[m])));
|
||||||
return x;
|
return S;
|
||||||
}
|
}
|
||||||
if (a === "")
|
if (a === "")
|
||||||
return {
|
return {
|
||||||
@@ -79,72 +79,72 @@ var he = {};
|
|||||||
index: a ? t : n
|
index: a ? t : n
|
||||||
};
|
};
|
||||||
throw new Error("Unexpected argument of type " + typeof a);
|
throw new Error("Unexpected argument of type " + typeof a);
|
||||||
}(l), E = d.strings.length, B = d.integers.length;
|
}(u), E = d.strings.length, j = d.integers.length;
|
||||||
d.floats.length, f && console.log("Parsing the dictionary");
|
d.floats.length, h && console.log("Parsing the dictionary");
|
||||||
var N = d.strings.join("|");
|
var N = d.strings.join("|");
|
||||||
return N += "^" + d.integers.join("|"), N += "^" + d.floats.join("|"), f && console.log("Parsing the structure"), N += "^" + function S(a) {
|
return N += "^" + d.integers.join("|"), N += "^" + d.floats.join("|"), h && console.log("Parsing the structure"), N += "^" + function P(a) {
|
||||||
if (f && console.log("Calling a recursiveParser with " + this.JSON.stringify(a)), a instanceof Array) {
|
if (h && console.log("Calling a recursiveParser with " + this.JSON.stringify(a)), a instanceof Array) {
|
||||||
var y = a.shift();
|
var y = a.shift();
|
||||||
for (var x in a)
|
for (var S in a)
|
||||||
a.hasOwnProperty(x) && (y += S(a[x]) + "|");
|
a.hasOwnProperty(S) && (y += P(a[S]) + "|");
|
||||||
return (y[y.length - 1] === "|" ? y.slice(0, -1) : y) + "]";
|
return (y[y.length - 1] === "|" ? y.slice(0, -1) : y) + "]";
|
||||||
}
|
}
|
||||||
var b = a.type, $ = a.index;
|
var b = a.type, m = a.index;
|
||||||
if (b === "strings")
|
if (b === "strings")
|
||||||
return _($);
|
return _(m);
|
||||||
if (b === "integers")
|
if (b === "integers")
|
||||||
return _(E + $);
|
return _(E + m);
|
||||||
if (b === "floats")
|
if (b === "floats")
|
||||||
return _(E + B + $);
|
return _(E + j + m);
|
||||||
if (b === "boolean")
|
if (b === "boolean")
|
||||||
return a.index;
|
return a.index;
|
||||||
if (b === "null")
|
if (b === "null")
|
||||||
return s;
|
return i;
|
||||||
if (b === "undefined")
|
if (b === "undefined")
|
||||||
return h;
|
return l;
|
||||||
if (b === "empty")
|
if (b === "empty")
|
||||||
return o;
|
return o;
|
||||||
throw new TypeError("The item is alien!");
|
throw new TypeError("The item is alien!");
|
||||||
}(p), f && console.log("Ending parser"), u.debug ? {
|
}(p), h && console.log("Ending parser"), f.debug ? {
|
||||||
dictionary: d,
|
dictionary: d,
|
||||||
ast: p,
|
ast: p,
|
||||||
packed: N
|
packed: N
|
||||||
} : N;
|
} : N;
|
||||||
}, c = function(l, u) {
|
}, c = function(u, f) {
|
||||||
u = u || {};
|
f = f || {};
|
||||||
var f = l.split("^");
|
var h = u.split("^");
|
||||||
u.verbose && console.log("Building dictionary");
|
f.verbose && console.log("Building dictionary");
|
||||||
var d = [], p = f[0];
|
var d = [], p = h[0];
|
||||||
if (p !== "") {
|
if (p !== "") {
|
||||||
p = p.split("|"), u.verbose && console.log("Parse the strings dictionary");
|
p = p.split("|"), f.verbose && console.log("Parse the strings dictionary");
|
||||||
for (var E = 0, B = p.length; E < B; E++)
|
for (var E = 0, j = p.length; E < j; E++)
|
||||||
d.push(M(p[E]));
|
d.push(M(p[E]));
|
||||||
}
|
}
|
||||||
if (p = f[1], p !== "") {
|
if (p = h[1], p !== "") {
|
||||||
p = p.split("|"), u.verbose && console.log("Parse the integers dictionary");
|
p = p.split("|"), f.verbose && console.log("Parse the integers dictionary");
|
||||||
for (var E = 0, B = p.length; E < B; E++)
|
for (var E = 0, j = p.length; E < j; E++)
|
||||||
d.push(U(p[E]));
|
d.push(U(p[E]));
|
||||||
}
|
}
|
||||||
if (p = f[2], p !== "") {
|
if (p = h[2], p !== "") {
|
||||||
p = p.split("|"), u.verbose && console.log("Parse the floats dictionary");
|
p = p.split("|"), f.verbose && console.log("Parse the floats dictionary");
|
||||||
for (var E = 0, B = p.length; E < B; E++)
|
for (var E = 0, j = p.length; E < j; E++)
|
||||||
d.push(parseFloat(p[E]));
|
d.push(parseFloat(p[E]));
|
||||||
}
|
}
|
||||||
p = null, u.verbose && console.log("Tokenizing the structure");
|
p = null, f.verbose && console.log("Tokenizing the structure");
|
||||||
for (var N = "", S = [], a = f[3].length, E = 0; E < a; E++) {
|
for (var N = "", P = [], a = h[3].length, E = 0; E < a; E++) {
|
||||||
var y = f[3].charAt(E);
|
var y = h[3].charAt(E);
|
||||||
y === "|" || y === "$" || y === "@" || y === "]" ? (N && (S.push(U(N)), N = ""), y !== "|" && S.push(y)) : N += y;
|
y === "|" || y === "$" || y === "@" || y === "]" ? (N && (P.push(U(N)), N = ""), y !== "|" && P.push(y)) : N += y;
|
||||||
}
|
}
|
||||||
var x = S.length, b = 0;
|
var S = P.length, b = 0;
|
||||||
return u.verbose && console.log("Starting recursive parser"), function $() {
|
return f.verbose && console.log("Starting recursive parser"), function m() {
|
||||||
var O = S[b++];
|
var O = P[b++];
|
||||||
if (u.verbose && console.log("Reading collection type " + (O === "$" ? "object" : "Array")), O === "@") {
|
if (f.verbose && console.log("Reading collection type " + (O === "$" ? "object" : "Array")), O === "@") {
|
||||||
for (var v = []; b < x; b++) {
|
for (var v = []; b < S; b++) {
|
||||||
var A = S[b];
|
var A = P[b];
|
||||||
if (u.verbose && console.log("Read " + A + " symbol"), A === "]")
|
if (f.verbose && console.log("Read " + A + " symbol"), A === "]")
|
||||||
return v;
|
return v;
|
||||||
if (A === "@" || A === "$")
|
if (A === "@" || A === "$")
|
||||||
v.push($());
|
v.push(m());
|
||||||
else
|
else
|
||||||
switch (A) {
|
switch (A) {
|
||||||
case t:
|
case t:
|
||||||
@@ -153,10 +153,10 @@ var he = {};
|
|||||||
case n:
|
case n:
|
||||||
v.push(!1);
|
v.push(!1);
|
||||||
break;
|
break;
|
||||||
case s:
|
case i:
|
||||||
v.push(null);
|
v.push(null);
|
||||||
break;
|
break;
|
||||||
case h:
|
case l:
|
||||||
v.push(void 0);
|
v.push(void 0);
|
||||||
break;
|
break;
|
||||||
case o:
|
case o:
|
||||||
@@ -166,70 +166,70 @@ var he = {};
|
|||||||
v.push(d[A]);
|
v.push(d[A]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return u.verbose && console.log("Parsed " + this.JSON.stringify(v)), v;
|
return f.verbose && console.log("Parsed " + this.JSON.stringify(v)), v;
|
||||||
}
|
}
|
||||||
if (O === "$") {
|
if (O === "$") {
|
||||||
for (var v = {}; b < x; b++) {
|
for (var v = {}; b < S; b++) {
|
||||||
var P = S[b];
|
var x = P[b];
|
||||||
if (P === "]")
|
if (x === "]")
|
||||||
return v;
|
return v;
|
||||||
P === o ? P = "" : P = d[P];
|
x === o ? x = "" : x = d[x];
|
||||||
var A = S[++b];
|
var A = P[++b];
|
||||||
if (A === "@" || A === "$")
|
if (A === "@" || A === "$")
|
||||||
v[P] = $();
|
v[x] = m();
|
||||||
else
|
else
|
||||||
switch (A) {
|
switch (A) {
|
||||||
case t:
|
case t:
|
||||||
v[P] = !0;
|
v[x] = !0;
|
||||||
break;
|
break;
|
||||||
case n:
|
case n:
|
||||||
v[P] = !1;
|
v[x] = !1;
|
||||||
break;
|
break;
|
||||||
case s:
|
case i:
|
||||||
v[P] = null;
|
v[x] = null;
|
||||||
break;
|
break;
|
||||||
case h:
|
case l:
|
||||||
v[P] = void 0;
|
v[x] = void 0;
|
||||||
break;
|
break;
|
||||||
case o:
|
case o:
|
||||||
v[P] = "";
|
v[x] = "";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
v[P] = d[A];
|
v[x] = d[A];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return u.verbose && console.log("Parsed " + this.JSON.stringify(v)), v;
|
return f.verbose && console.log("Parsed " + this.JSON.stringify(v)), v;
|
||||||
}
|
}
|
||||||
throw new TypeError("Bad token " + O + " isn't a type");
|
throw new TypeError("Bad token " + O + " isn't a type");
|
||||||
}();
|
}();
|
||||||
}, T = function(l) {
|
}, T = function(u) {
|
||||||
return typeof l != "string" ? l : l.replace(/[\+ \|\^\%]/g, function(u) {
|
return typeof u != "string" ? u : u.replace(/[\+ \|\^\%]/g, function(f) {
|
||||||
return {
|
return {
|
||||||
" ": "+",
|
" ": "+",
|
||||||
"+": "%2B",
|
"+": "%2B",
|
||||||
"|": "%7C",
|
"|": "%7C",
|
||||||
"^": "%5E",
|
"^": "%5E",
|
||||||
"%": "%25"
|
"%": "%25"
|
||||||
}[u];
|
}[f];
|
||||||
});
|
});
|
||||||
}, M = function(l) {
|
}, M = function(u) {
|
||||||
return typeof l != "string" ? l : l.replace(/\+|%2B|%7C|%5E|%25/g, function(u) {
|
return typeof u != "string" ? u : u.replace(/\+|%2B|%7C|%5E|%25/g, function(f) {
|
||||||
return {
|
return {
|
||||||
"+": " ",
|
"+": " ",
|
||||||
"%2B": "+",
|
"%2B": "+",
|
||||||
"%7C": "|",
|
"%7C": "|",
|
||||||
"%5E": "^",
|
"%5E": "^",
|
||||||
"%25": "%"
|
"%25": "%"
|
||||||
}[u];
|
}[f];
|
||||||
});
|
});
|
||||||
}, _ = function(l) {
|
}, _ = function(u) {
|
||||||
return Number.prototype.toString.call(l, 36).toUpperCase();
|
return Number.prototype.toString.call(u, 36).toUpperCase();
|
||||||
}, U = function(l) {
|
}, U = function(u) {
|
||||||
return parseInt(l, 36);
|
return parseInt(u, 36);
|
||||||
}, H = Array.prototype.indexOf || function(l, u) {
|
}, H = Array.prototype.indexOf || function(u, f) {
|
||||||
for (var f = u || 0, d = this.length; f < d; f++)
|
for (var h = f || 0, d = this.length; h < d; h++)
|
||||||
if (this[f] === l)
|
if (this[h] === u)
|
||||||
return f;
|
return h;
|
||||||
return -1;
|
return -1;
|
||||||
};
|
};
|
||||||
return {
|
return {
|
||||||
@@ -240,13 +240,13 @@ var he = {};
|
|||||||
});
|
});
|
||||||
})(function(e, t) {
|
})(function(e, t) {
|
||||||
var n = t();
|
var n = t();
|
||||||
for (var s in n)
|
for (var i in n)
|
||||||
r[s] = n[s];
|
r[i] = n[i];
|
||||||
});
|
});
|
||||||
})(he);
|
})(he);
|
||||||
const ae = /* @__PURE__ */ ge(he);
|
const ce = /* @__PURE__ */ pe(he);
|
||||||
var K, L, j, F, Q, W, q, X, Z;
|
var B, L, G, I, Q, W, q, X, Z, ee;
|
||||||
class ne {
|
class se {
|
||||||
/**
|
/**
|
||||||
* @param {number} code
|
* @param {number} code
|
||||||
* @param {string} message
|
* @param {string} message
|
||||||
@@ -254,7 +254,7 @@ class ne {
|
|||||||
* @param {string} url
|
* @param {string} url
|
||||||
* @param {string} res
|
* @param {string} res
|
||||||
*/
|
*/
|
||||||
constructor(e, t, n, s, o) {
|
constructor(e, t, n, i, o) {
|
||||||
/** @type {number} */
|
/** @type {number} */
|
||||||
g(this, "code", 0);
|
g(this, "code", 0);
|
||||||
/** @type {string} */
|
/** @type {string} */
|
||||||
@@ -266,77 +266,82 @@ class ne {
|
|||||||
/** @type {string} */
|
/** @type {string} */
|
||||||
g(this, "res", "");
|
g(this, "res", "");
|
||||||
/** @type {HttpResponse} */
|
/** @type {HttpResponse} */
|
||||||
w(this, K);
|
w(this, B);
|
||||||
// 判断返回 Response 对象, 还是 Response 中的 data
|
// 判断返回 Response 对象, 还是 Response 中的 data
|
||||||
/** @type {boolean} */
|
/** @type {boolean} */
|
||||||
w(this, L, !0);
|
w(this, L, !0);
|
||||||
// 判断是否已经给出错误提示
|
// 判断是否已经给出错误提示
|
||||||
/** @type {boolean} */
|
/** @type {boolean} */
|
||||||
w(this, j, !0);
|
w(this, G, !0);
|
||||||
w(this, F, {
|
w(this, I, {
|
||||||
/** @param {any} __ @param {string} key */
|
/** @param {any} __ @param {string} key */
|
||||||
get: (e, t) => i(this, Q).call(this, t),
|
get: (e, t) => s(this, Q).call(this, t),
|
||||||
/** @returns {string[]} */
|
/** @returns {string[]} */
|
||||||
ownKeys: () => Object.keys(i(this, F).getPrototypeOf() || {}),
|
ownKeys: () => Object.keys(s(this, I).getPrototypeOf() || {}),
|
||||||
/** @returns {HttpResponse | unknown} */
|
/** @returns {HttpResponse | unknown} */
|
||||||
getPrototypeOf: () => i(this, L) ? this : this.data,
|
getPrototypeOf: () => s(this, L) ? this : this.data,
|
||||||
/** @returns {PropertyDescriptor} */
|
/** @returns {PropertyDescriptor} */
|
||||||
getOwnPropertyDescriptor: () => ({
|
getOwnPropertyDescriptor: () => ({
|
||||||
configurable: !0,
|
configurable: !0,
|
||||||
enumerable: !0,
|
enumerable: !0,
|
||||||
writable: !0,
|
writable: !0,
|
||||||
value: i(this, F).getPrototypeOf()
|
value: s(this, I).getPrototypeOf()
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
/**
|
/**
|
||||||
* @param {string} key
|
* @param {string} key
|
||||||
* @returns {unknown}
|
* @returns {unknown}
|
||||||
*/
|
*/
|
||||||
w(this, Q, (e) => e === "$echoMsg" ? i(this, q) : e === "msg" ? i(this, W) : e === "then" || e === "resp" ? (C(this, j, !0), C(this, L, e === "resp"), i(this, X)) : e === "catch" ? i(this, Z) : e === "IS_ECHO_MSG" ? i(this, j) : Reflect.get(this, e));
|
w(this, Q, (e) => e === "$echoMsg" ? s(this, q) : e === "msg" ? s(this, W) : e === "then" || e === "resp" ? (C(this, G, !0), C(this, L, e === "resp"), s(this, X)) : e === "catch" ? s(this, Z) : e === "finally" ? s(this, ee) : e === "IS_ECHO_MSG" ? s(this, G) : Reflect.get(this, e));
|
||||||
/**
|
/**
|
||||||
* @param {(value: unknown) => unknown} [fn]
|
* @param {(value: unknown) => unknown} [fn]
|
||||||
* @param {boolean} [isResp]
|
* @param {boolean} [isResp]
|
||||||
* @returns {Promise<unknown>}
|
* @returns {Promise<unknown>}
|
||||||
*/
|
*/
|
||||||
w(this, W, (e = (n) => n, t = !1) => (i(this, q).call(this), C(this, L, t), Promise.resolve(e == null ? void 0 : e(i(this, F).getPrototypeOf()))));
|
w(this, W, (e = (n) => n, t = !1) => (s(this, q).call(this), C(this, L, t), Promise.resolve(e == null ? void 0 : e(s(this, I).getPrototypeOf()))));
|
||||||
w(this, q, () => {
|
w(this, q, () => {
|
||||||
i(this, j) && (C(this, j, !1), se.onMsg(this.code, this.message));
|
s(this, G) && (C(this, G, !1), ie.onMsg(this.code, this.message));
|
||||||
});
|
});
|
||||||
/**
|
/**
|
||||||
* @param {(value: unknown) => unknown} [fn]
|
* @param {(value: unknown) => unknown} [fn]
|
||||||
* @returns {Promise<unknown>}
|
* @returns {Promise<unknown>}
|
||||||
*/
|
*/
|
||||||
w(this, X, (e) => [0, 1].includes(this.code) ? Promise.resolve(e == null ? void 0 : e(i(this, F).getPrototypeOf())) : Promise.reject(i(this, K)));
|
w(this, X, (e) => [0, 1].includes(this.code) ? Promise.resolve(e == null ? void 0 : e(s(this, I).getPrototypeOf())) : Promise.reject(s(this, B)));
|
||||||
/**
|
/**
|
||||||
* @param {(reason: HttpResponse) => unknown} fn
|
* @param {(reason: HttpResponse) => unknown} fn
|
||||||
* @returns {Promise<unknown>}
|
* @returns {Promise<unknown>}
|
||||||
*/
|
*/
|
||||||
w(this, Z, (e) => Promise.resolve(e(i(this, K))));
|
w(this, Z, (e) => Promise.resolve(e(s(this, B))));
|
||||||
return this.code = e, this.message = t, this.data = n, this.url = s, this.res = o, C(this, K, new Proxy(this, i(this, F)));
|
/**
|
||||||
|
* @param {(() => void) | undefined} [fn]
|
||||||
|
* @returns {Promise<unknown>}
|
||||||
|
*/
|
||||||
|
w(this, ee, (e) => (e == null || e(), [0, 1].includes(this.code) ? Promise.resolve(s(this, I).getPrototypeOf()) : Promise.reject(s(this, B))));
|
||||||
|
return this.code = e, this.message = t, this.data = n, this.url = i, this.res = o, C(this, B, new Proxy(this, s(this, I)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
K = new WeakMap(), L = new WeakMap(), j = new WeakMap(), F = new WeakMap(), Q = new WeakMap(), W = new WeakMap(), q = new WeakMap(), X = new WeakMap(), Z = new WeakMap();
|
B = new WeakMap(), L = new WeakMap(), G = new WeakMap(), I = new WeakMap(), Q = new WeakMap(), W = new WeakMap(), q = new WeakMap(), X = new WeakMap(), Z = new WeakMap(), ee = new WeakMap();
|
||||||
const re = (r, e, t, n = "/", s = "") => new ne(r, e, t, n, s);
|
const ne = (r, e, t, n = "/", i = "") => new se(r, e, t, n, i);
|
||||||
var fe = [
|
var ue = [
|
||||||
"utf8",
|
"utf8",
|
||||||
"utf-8",
|
"utf-8",
|
||||||
"unicode-1-1-utf-8"
|
"unicode-1-1-utf-8"
|
||||||
];
|
];
|
||||||
function pe(r) {
|
function ve(r) {
|
||||||
if (fe.indexOf(r) < 0 && typeof r < "u" && r != null)
|
if (ue.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 s = t.split("");
|
const i = t.split("");
|
||||||
for (let o = 0; o < s.length; o++)
|
for (let o = 0; o < i.length; o++)
|
||||||
n[o] = s[o].charCodeAt(0);
|
n[o] = i[o].charCodeAt(0);
|
||||||
return n;
|
return n;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
function ve(r) {
|
function we(r) {
|
||||||
if (fe.indexOf(r) < 0 && typeof r < "u" && r != null)
|
if (ue.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")
|
||||||
@@ -345,35 +350,35 @@ 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 s = new Uint8Array(e.buffer, e.byteOffset, e.byteLength), o = new Array(s.length);
|
var i = new Uint8Array(e.buffer, e.byteOffset, e.byteLength), o = new Array(i.length);
|
||||||
for (let h = 0; h < s.length; h++)
|
for (let l = 0; l < i.length; l++)
|
||||||
o[h] = String.fromCharCode(s[h]);
|
o[l] = String.fromCharCode(i[l]);
|
||||||
return decodeURIComponent(escape(o.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 le = {
|
var fe = {
|
||||||
TextEncoder: pe,
|
TextEncoder: ve,
|
||||||
TextDecoder: ve
|
TextDecoder: we
|
||||||
};
|
};
|
||||||
const we = new le.TextEncoder("utf8"), ye = new le.TextDecoder("utf8");
|
const ye = new fe.TextEncoder("utf8"), be = new fe.TextDecoder("utf8");
|
||||||
function be(r) {
|
function Ee(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);
|
||||||
}
|
}
|
||||||
function Ee(r, e) {
|
function Oe(r, e) {
|
||||||
return r.replace(new RegExp(`^${e}+|${e}+$`, "g"), "");
|
return r.replace(new RegExp(`^${e}+|${e}+$`, "g"), "");
|
||||||
}
|
}
|
||||||
function Oe(r) {
|
function Te(r) {
|
||||||
return we.encode(r || "");
|
return ye.encode(r || "");
|
||||||
}
|
}
|
||||||
function Ce(r) {
|
function Me(r) {
|
||||||
return ye.decode(new DataView(r), {});
|
return be.decode(new DataView(r), {});
|
||||||
}
|
}
|
||||||
const Te = 62, Y = 30, ce = 31, Se = 63;
|
const Pe = 62, Y = 30, le = 31, Se = 63;
|
||||||
class xe {
|
class xe {
|
||||||
/**
|
/**
|
||||||
* @param {string} alphabet 62 位编码字母表
|
* @param {string} alphabet 62 位编码字母表
|
||||||
@@ -383,7 +388,7 @@ class xe {
|
|||||||
g(this, "encodeTable", []);
|
g(this, "encodeTable", []);
|
||||||
/** @type {Uint8Array} */
|
/** @type {Uint8Array} */
|
||||||
g(this, "decodeMap", new Uint8Array(256).fill(255));
|
g(this, "decodeMap", new Uint8Array(256).fill(255));
|
||||||
if (e.length !== Te)
|
if (e.length !== Pe)
|
||||||
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"))
|
||||||
@@ -399,7 +404,7 @@ class xe {
|
|||||||
*/
|
*/
|
||||||
encode(e) {
|
encode(e) {
|
||||||
if (!e || e.length === 0) return "";
|
if (!e || e.length === 0) return "";
|
||||||
const t = new Pe(this).encodeV2(e);
|
const t = new _e(this).encodeV2(e);
|
||||||
return String.fromCharCode(...t);
|
return String.fromCharCode(...t);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@@ -409,12 +414,12 @@ class xe {
|
|||||||
*/
|
*/
|
||||||
decode(e) {
|
decode(e) {
|
||||||
if (!e || e.length === 0) return "";
|
if (!e || e.length === 0) return "";
|
||||||
const t = new _e(this).decode(e);
|
const t = new Ae(this).decode(e);
|
||||||
return new TextDecoder().decode(t);
|
return new TextDecoder().decode(t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var z;
|
var z;
|
||||||
class Pe {
|
class _e {
|
||||||
/**
|
/**
|
||||||
* @param {Base62} b62
|
* @param {Base62} b62
|
||||||
*/
|
*/
|
||||||
@@ -439,25 +444,25 @@ class Pe {
|
|||||||
* @returns {number[]}
|
* @returns {number[]}
|
||||||
*/
|
*/
|
||||||
encodeV2(e) {
|
encodeV2(e) {
|
||||||
this.src = Oe(e), this.pos = this.src.length * 8;
|
this.src = Te(e), this.pos = this.src.length * 8;
|
||||||
const t = [];
|
const t = [];
|
||||||
for (; this.pos > 0; ) {
|
for (; this.pos > 0; ) {
|
||||||
let n = 6, s = this.get6bits();
|
let n = 6, i = this.get6bits();
|
||||||
(s & Y) === Y && ((this.pos > 6 || s > ce) && (n = 5), s &= ce), t.push(i(this, z).encodeTable[s].charCodeAt(0)), this.pos -= n;
|
(i & Y) === Y && ((this.pos > 6 || i > le) && (n = 5), i &= le), t.push(s(this, z).encodeTable[i].charCodeAt(0)), this.pos -= n;
|
||||||
}
|
}
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
z = new WeakMap();
|
z = new WeakMap();
|
||||||
var k;
|
var V;
|
||||||
class _e {
|
class Ae {
|
||||||
/**
|
/**
|
||||||
* @param {Base62} b62
|
* @param {Base62} b62
|
||||||
*/
|
*/
|
||||||
constructor(e) {
|
constructor(e) {
|
||||||
/** @type {Base62} */
|
/** @type {Base62} */
|
||||||
w(this, k);
|
w(this, V);
|
||||||
C(this, k, e);
|
C(this, V, e);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @param {string} src
|
* @param {string} src
|
||||||
@@ -465,26 +470,25 @@ class _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, s = 0, o = 0;
|
let n = t.length, i = 0, o = 0;
|
||||||
for (let h = 0; h < e.length; h++) {
|
for (let l = 0; l < e.length; l++) {
|
||||||
const R = e[h].charCodeAt(0), c = i(this, k).decodeMap[R];
|
const R = e[l].charCodeAt(0), c = s(this, V).decodeMap[R];
|
||||||
if (c === 255)
|
if (c === 255)
|
||||||
throw new Error(`CorruptInputError at index ${h}`);
|
throw new Error(`CorruptInputError at index ${l}`);
|
||||||
h === e.length - 1 ? (o |= c << s, s += Math.ceil(Math.log2(c + 1))) : (c & Y) === Y ? (o |= c << s, s += 5) : (o |= c << s, s += 6), s >= 8 && (n--, t[n] = o & 255, s %= 8, o >>= 8);
|
l === e.length - 1 ? (o |= c << i, i += Math.ceil(Math.log2(c + 1))) : (c & Y) === Y ? (o |= c << i, i += 5) : (o |= c << i, i += 6), i >= 8 && (n--, t[n] = o & 255, i %= 8, o >>= 8);
|
||||||
}
|
}
|
||||||
return s > 0 && (n--, t[n] = o & 255), t.slice(n);
|
return i > 0 && (n--, t[n] = o & 255), t.slice(n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
k = new WeakMap();
|
V = new WeakMap();
|
||||||
Promise.withResolvers || (Promise.withResolvers = /** @type {typeof Promise.withResolvers} */
|
Promise.withResolvers || (Promise.withResolvers = function() {
|
||||||
function() {
|
|
||||||
let r, e;
|
let r, e;
|
||||||
return { promise: new Promise((n, s) => {
|
return { promise: new Promise((n, i) => {
|
||||||
r = n, e = s;
|
r = n, e = i;
|
||||||
}), resolve: r, reject: e };
|
}), resolve: r, reject: e };
|
||||||
});
|
});
|
||||||
var G, D, ee, m, I, J, te, V;
|
var J, D, te, $, F, K, re, k;
|
||||||
class se {
|
class ie {
|
||||||
/**
|
/**
|
||||||
* @param {string} [appKey]
|
* @param {string} [appKey]
|
||||||
* @param {string} [appSecret]
|
* @param {string} [appSecret]
|
||||||
@@ -492,21 +496,21 @@ class se {
|
|||||||
*/
|
*/
|
||||||
constructor(e, t, n) {
|
constructor(e, t, n) {
|
||||||
/** @type {RequestFn | undefined} */
|
/** @type {RequestFn | undefined} */
|
||||||
w(this, G);
|
w(this, J);
|
||||||
/** @type {Base62 | undefined} */
|
/** @type {Base62 | undefined} */
|
||||||
w(this, D);
|
w(this, D);
|
||||||
/** @type {string | undefined} */
|
/** @type {string | undefined} */
|
||||||
w(this, ee);
|
w(this, te);
|
||||||
w(this, m, {
|
w(this, $, {
|
||||||
/** @type {Map<string, CacheEntry>} */
|
/** @type {Map<string, CacheEntry>} */
|
||||||
"#": /* @__PURE__ */ new Map(),
|
"#": /* @__PURE__ */ new Map(),
|
||||||
/** @type {Map<string, CacheEntry>} */
|
/** @type {Map<string, CacheEntry>} */
|
||||||
$: /* @__PURE__ */ new Map()
|
$: /* @__PURE__ */ new Map()
|
||||||
});
|
});
|
||||||
/** @type {Map<string, Array<[Function, Function] | null>>} */
|
/** @type {Map<string, Array<[Function, Function] | null>>} */
|
||||||
w(this, I, /* @__PURE__ */ new Map());
|
w(this, F, /* @__PURE__ */ new Map());
|
||||||
/** @type {Set<[string, '#' | '$', RequestOptions & { method: string }, boolean]>} */
|
/** @type {Set<[string, '#' | '$', RequestOptions & { method: string }, boolean]>} */
|
||||||
w(this, J, /* @__PURE__ */ new Set());
|
w(this, K, /* @__PURE__ */ new Set());
|
||||||
/**
|
/**
|
||||||
* 初始化请求实例
|
* 初始化请求实例
|
||||||
* @param {string} [appKey]
|
* @param {string} [appKey]
|
||||||
@@ -514,10 +518,10 @@ class se {
|
|||||||
* @param {RequestFn} [reqFn]
|
* @param {RequestFn} [reqFn]
|
||||||
*/
|
*/
|
||||||
g(this, "init", (e, t, n) => {
|
g(this, "init", (e, t, n) => {
|
||||||
e && C(this, ee, e), n && C(this, G, n), t && C(this, D, new xe(t)), i(this, te).call(this);
|
e && C(this, te, e), n && C(this, J, n), t && C(this, D, new xe(t)), s(this, re).call(this);
|
||||||
});
|
});
|
||||||
w(this, te, () => {
|
w(this, re, () => {
|
||||||
!i(this, J).size || !i(this, G) || (i(this, J).forEach((e) => i(this, V).call(this, ...e)), i(this, J).clear());
|
!s(this, K).size || !s(this, J) || (s(this, K).forEach((e) => s(this, k).call(this, ...e)), s(this, K).clear());
|
||||||
});
|
});
|
||||||
/**
|
/**
|
||||||
* @param {string} hash
|
* @param {string} hash
|
||||||
@@ -525,34 +529,34 @@ class se {
|
|||||||
* @param {RequestOptions & { method: string }} params
|
* @param {RequestOptions & { method: string }} params
|
||||||
* @param {boolean} [isCacheRequest]
|
* @param {boolean} [isCacheRequest]
|
||||||
*/
|
*/
|
||||||
w(this, V, (e, t, n, s = !1) => {
|
w(this, k, (e, t, n, i = !1) => {
|
||||||
if (!i(this, G))
|
if (!s(this, J))
|
||||||
i(this, J).add([e, t, n, s]);
|
s(this, K).add([e, t, n, i]);
|
||||||
else {
|
else {
|
||||||
const { url: o, method: h, ...R } = n || {};
|
const { url: o, method: l, ...R } = n || {};
|
||||||
i(this, G).call(this, { url: o, method: h, ...R }).then((c) => {
|
s(this, J).call(this, { url: o, method: l, ...R }).then((c) => {
|
||||||
if (![0, 1].includes(c.code))
|
if (![0, 1].includes(c.code))
|
||||||
throw re(c.code, c.msg, c.data, o, c == null ? void 0 : c.res);
|
throw ne(c.code, c.msg, c.data, o, c == null ? void 0 : c.res);
|
||||||
return [c.code, c.msg, c.data, o, (c == null ? void 0 : c.res) ?? ""];
|
return [c.code, c.msg, c.data, o, (c == null ? void 0 : c.res) ?? ""];
|
||||||
}).then((c) => {
|
}).then((c) => {
|
||||||
const T = (
|
const T = (
|
||||||
/** @type {CacheEntry} */
|
/** @type {CacheEntry} */
|
||||||
c
|
c
|
||||||
);
|
);
|
||||||
return (t == "#" || h == "GET") && i(this, m)[t].set(e, T), t != "#" && h == "GET" && !s && setTimeout(() => {
|
return (t == "#" || l == "GET") && s(this, $)[t].set(e, T), t != "#" && l == "GET" && !i && setTimeout(() => {
|
||||||
i(this, m)[t].delete(e);
|
s(this, $)[t].delete(e);
|
||||||
}, 300), T;
|
}, 300), T;
|
||||||
}).then((c) => {
|
}).then((c) => {
|
||||||
var T;
|
var T;
|
||||||
return (T = i(this, I).get(e)) == null ? void 0 : T.forEach((M, _, U) => {
|
return (T = s(this, F).get(e)) == null ? void 0 : T.forEach((M, _, U) => {
|
||||||
M && M[0](c), delete U[_];
|
M && M[0](c), delete U[_];
|
||||||
});
|
});
|
||||||
}).catch((c) => {
|
}).catch((c) => {
|
||||||
var T;
|
var T;
|
||||||
i(this, m)[t].delete(e), (T = i(this, I).get(e)) == null || T.forEach((M, _, U) => {
|
s(this, $)[t].delete(e), (T = s(this, F).get(e)) == null || T.forEach((M, _, U) => {
|
||||||
M && M[1](c instanceof ne ? c : re(-1, c, null, o)), delete U[_];
|
M && M[1](c instanceof se ? c : ne(-1, c, null, o)), delete U[_];
|
||||||
});
|
});
|
||||||
}).finally(() => i(this, I).delete(e));
|
}).finally(() => s(this, F).delete(e));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
/**
|
/**
|
||||||
@@ -561,31 +565,32 @@ class se {
|
|||||||
* @param {boolean} [isCacheRequest]
|
* @param {boolean} [isCacheRequest]
|
||||||
* @returns {any} 返回 Proxy 包裹的 Promise,支持链式调用 .then / .catch / .msg / .resp
|
* @returns {any} 返回 Proxy 包裹的 Promise,支持链式调用 .then / .catch / .msg / .resp
|
||||||
*/
|
*/
|
||||||
g(this, "request", ({ url: e = "/", method: t = "GET", ...n }, s = !1) => {
|
g(this, "request", ({ url: e = "/", method: t = "GET", ...n }, i = !1) => {
|
||||||
var _, U;
|
var _, U;
|
||||||
e = Ee(e, "/");
|
e = Oe(e, "/");
|
||||||
const o = (
|
const o = (
|
||||||
/** @type {HttpMethod} */
|
/** @type {HttpMethod} */
|
||||||
t.toUpperCase()
|
t.toUpperCase()
|
||||||
), h = be(JSON.stringify([e, o, n])), R = (
|
), l = Ee(JSON.stringify([e, o, n])), R = (
|
||||||
/** @type {'#' | '$'} */
|
/** @type {'#' | '$'} */
|
||||||
(_ = e == null ? void 0 : e.includes) != null && _.call(e, "/_/") ? "#" : "$"
|
(_ = e == null ? void 0 : e.includes) != null && _.call(e, "/_/") ? "#" : "$"
|
||||||
), { promise: c, resolve: T, reject: M } = Promise.withResolvers();
|
), { promise: c, resolve: T, reject: M } = Promise.withResolvers();
|
||||||
return i(this, m)[R].has(h) ? (console.log("cache", e), T(i(this, m)[R].get(h))) : i(this, I).has(h) ? (U = i(this, I).get(h)) == null || U.push([T, M]) : (i(this, I).set(h, [[T, M]]), i(this, V).call(this, h, R, { url: e, method: o, ...n }, s)), new Proxy(c, {
|
return s(this, $)[R].has(l) ? (console.log("cache", e), T(s(this, $)[R].get(l))) : s(this, F).has(l) ? (U = s(this, F).get(l)) == null || U.push([T, M]) : (s(this, F).set(l, [[T, M]]), s(this, k).call(this, l, R, { url: e, method: o, ...n }, i)), new Proxy(c, {
|
||||||
get: (H, l) => (...u) => H.then((f) => (
|
get: (H, u) => (...f) => H.then((h) => (
|
||||||
/** @type {any} */
|
/** @type {any} */
|
||||||
re(.../** @type {[number, string, unknown, string, string]} */
|
ne(
|
||||||
/** @type {unknown} */
|
.../** @type {[number, string, unknown, string, string]} */
|
||||||
f)[l](...u)
|
h
|
||||||
)).catch((f) => {
|
)[u](...f)
|
||||||
if (!(f instanceof ne)) throw f;
|
)).catch((h) => {
|
||||||
|
if (!(h instanceof se)) throw h;
|
||||||
return typeof /** @type {any} */
|
return typeof /** @type {any} */
|
||||||
f[l] == "function" ? (
|
h[u] == "function" ? (
|
||||||
/** @type {any} */
|
/** @type {any} */
|
||||||
f[l](...u)
|
h[u](...f)
|
||||||
) : (
|
) : (
|
||||||
/** @type {any} */
|
/** @type {any} */
|
||||||
f[l]
|
h[u]
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
@@ -633,9 +638,12 @@ class se {
|
|||||||
/**
|
/**
|
||||||
* 通过 Base62 编码参数请求列表接口
|
* 通过 Base62 编码参数请求列表接口
|
||||||
* @param {string} code
|
* @param {string} code
|
||||||
* @param {Record<string, unknown>} [base62param]
|
* @param {Base62Param} [base62param]
|
||||||
*/
|
*/
|
||||||
g(this, "list", (e, t = {}) => this.get(`/api/${e}/${this.encode(t)}`));
|
g(this, "list", (e, t = {}) => this.get(`/api/${e}/${this.encode(
|
||||||
|
/** @type {Record<string, unknown>} */
|
||||||
|
t
|
||||||
|
)}`));
|
||||||
g(this, "getAppInfo", () => {
|
g(this, "getAppInfo", () => {
|
||||||
});
|
});
|
||||||
/**
|
/**
|
||||||
@@ -643,7 +651,7 @@ class se {
|
|||||||
* @param {boolean} [isSystem] 是否同时清除系统缓存(`/_/` 路由)
|
* @param {boolean} [isSystem] 是否同时清除系统缓存(`/_/` 路由)
|
||||||
*/
|
*/
|
||||||
g(this, "refreshCache", (e = !1) => {
|
g(this, "refreshCache", (e = !1) => {
|
||||||
e && i(this, m)["#"].clear(), i(this, m).$.clear();
|
e && s(this, $)["#"].clear(), s(this, $).$.clear();
|
||||||
});
|
});
|
||||||
/**
|
/**
|
||||||
* 解码 Base62 字符串为 JSON 对象
|
* 解码 Base62 字符串为 JSON 对象
|
||||||
@@ -655,38 +663,38 @@ class se {
|
|||||||
if (e === void 0 || e === "" || e === null)
|
if (e === void 0 || e === "" || e === null)
|
||||||
return t;
|
return t;
|
||||||
try {
|
try {
|
||||||
if (!i(this, D)) throw new Error("未初始化 appSecret,请先通过 init 设置 appSecret");
|
if (!s(this, D)) throw new Error("未初始化 appSecret,请先通过 init 设置 appSecret");
|
||||||
const n = i(this, D).decode(e);
|
const n = s(this, D).decode(e);
|
||||||
return ae.unpack(n);
|
return ce.unpack(n);
|
||||||
} catch {
|
} catch {
|
||||||
return console.warn("core.decode", e), t;
|
return console.warn("core.decode", e), t;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
/**
|
/**
|
||||||
* 将 JSON 对象编码为 Base62 字符串
|
* 将 JSON 对象编码为 Base62 字符串
|
||||||
* @param {Record<string, unknown>} [json]
|
* @param {Record<string, unknown> | unknown[]} [json]
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
g(this, "encode", (e = {}) => {
|
g(this, "encode", (e = {}) => {
|
||||||
if (!i(this, D)) throw new Error("未初始化 appSecret,请先通过 init 设置 appSecret");
|
if (!s(this, D)) throw new Error("未初始化 appSecret,请先通过 init 设置 appSecret");
|
||||||
const t = JSON.stringify(e, (n, s) => s === void 0 ? null : s);
|
const t = JSON.stringify(e, (n, i) => i === void 0 ? null : i);
|
||||||
return i(this, D).encode(ae.pack(t));
|
return s(this, D).encode(ce.pack(t));
|
||||||
});
|
});
|
||||||
this.init(e, t, n);
|
this.init(e, t, n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
G = new WeakMap(), D = new WeakMap(), ee = new WeakMap(), m = new WeakMap(), I = new WeakMap(), J = new WeakMap(), te = new WeakMap(), V = new WeakMap();
|
J = new WeakMap(), D = new WeakMap(), te = new WeakMap(), $ = new WeakMap(), F = new WeakMap(), K = new WeakMap(), re = new WeakMap(), k = new WeakMap();
|
||||||
se.onUnhandledRejection = (r) => {
|
ie.onUnhandledRejection = (r) => {
|
||||||
var e, t, n, s, o, h;
|
var e, t, n, i, o, 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 && ((o = (s = r.reason) == null ? void 0 : s.$echoMsg) == null || o.call(s), (h = r == null ? void 0 : r.preventDefault) == null || h.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 = (i = r.reason) == null ? void 0 : i.$echoMsg) == null || o.call(i), (l = r == null ? void 0 : r.preventDefault) == null || l.call(r));
|
||||||
};
|
};
|
||||||
se.onMsg = (r, e) => [0, 1].includes(r) ? console.log(e) : console.warn(e);
|
ie.onMsg = (r, e) => [0, 1].includes(r) ? console.log(e) : console.warn(e);
|
||||||
export {
|
export {
|
||||||
ne as HttpResponse,
|
se as HttpResponse,
|
||||||
re as NewHttpResponse,
|
ne as NewHttpResponse,
|
||||||
se as default,
|
ie as default,
|
||||||
be as signature,
|
Ee as signature,
|
||||||
Oe as str2uint8array,
|
Te as str2uint8array,
|
||||||
Ee as trim,
|
Oe as trim,
|
||||||
Ce as uint8array2str
|
Me as uint8array2str
|
||||||
};
|
};
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ff-request",
|
"name": "ff-request",
|
||||||
"version": "0.11.1",
|
"version": "0.11.2",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "./ff-request.umd.cjs",
|
"main": "./ff-request.umd.cjs",
|
||||||
"module": "./ff-request.js",
|
"module": "./ff-request.js",
|
||||||
|
|||||||
67
types/index.d.ts
vendored
67
types/index.d.ts
vendored
@@ -1,23 +1,20 @@
|
|||||||
declare type HttpMethod = "GET" | "POST" | "PUT" | "DELETE";
|
declare interface Base62Param {
|
||||||
|
/** 当前选中的 tab 标识 */
|
||||||
|
tab?: string
|
||||||
|
/** 当前页码 */
|
||||||
|
page?: number
|
||||||
|
/** 每页条数 */
|
||||||
|
pageSize?: number
|
||||||
|
/** 筛选条件 */
|
||||||
|
condition?: Record<string, unknown>
|
||||||
|
/** 侧边栏选中项标识 */
|
||||||
|
sider?: string
|
||||||
|
/** 搜索关键词 */
|
||||||
|
keyword?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
declare type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE'
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {'GET' | 'POST' | 'PUT' | 'DELETE'} HttpMethod
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* @typedef {Object} RequestOptions@typedef {Object} RequestOptions
|
|
||||||
* @property {string} [url]
|
|
||||||
* @property {HttpMethod} [method]
|
|
||||||
* @property {Record<string, unknown>} [params]
|
|
||||||
* @property {unknown} [data]
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* 底层请求函数类型(兼容 axios 等)
|
|
||||||
* @typedef {(config: RequestOptions & Record<string, unknown>) => Promise<{ code: number, msg: string, data: unknown, res?: string }>} RequestFn
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* 缓存条目:[code, msg, data, url, res]
|
|
||||||
* @typedef {[number, string, unknown, string, string]} CacheEntry
|
|
||||||
*/
|
|
||||||
declare class HttpRequest {
|
declare class HttpRequest {
|
||||||
/**
|
/**
|
||||||
* @param {string} [appKey]
|
* @param {string} [appKey]
|
||||||
@@ -81,9 +78,9 @@ declare class HttpRequest {
|
|||||||
/**
|
/**
|
||||||
* 通过 Base62 编码参数请求列表接口
|
* 通过 Base62 编码参数请求列表接口
|
||||||
* @param {string} code
|
* @param {string} code
|
||||||
* @param {Record<string, unknown>} [base62param]
|
* @param {Base62Param} [base62param]
|
||||||
*/
|
*/
|
||||||
list: (code: string, base62param?: Record<string, unknown>) => any;
|
list: (code: string, base62param?: Base62Param) => any;
|
||||||
getAppInfo: () => void;
|
getAppInfo: () => void;
|
||||||
/**
|
/**
|
||||||
* 清除缓存
|
* 清除缓存
|
||||||
@@ -99,10 +96,10 @@ declare class HttpRequest {
|
|||||||
decode: (str?: string, defaultValue?: object) => unknown;
|
decode: (str?: string, defaultValue?: object) => unknown;
|
||||||
/**
|
/**
|
||||||
* 将 JSON 对象编码为 Base62 字符串
|
* 将 JSON 对象编码为 Base62 字符串
|
||||||
* @param {Record<string, unknown>} [json]
|
* @param {Record<string, unknown> | unknown[]} [json]
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
encode: (json?: Record<string, unknown>) => string;
|
encode: (json?: Record<string, unknown> | unknown[]) => string;
|
||||||
#private;
|
#private;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,22 +150,16 @@ export declare class HttpResponse {
|
|||||||
|
|
||||||
export declare function NewHttpResponse(code: number, message: string, data: unknown, url?: string, res?: string): HttpResponse;
|
export declare function NewHttpResponse(code: number, message: string, data: unknown, url?: string, res?: string): HttpResponse;
|
||||||
|
|
||||||
/**
|
declare type RequestFn = (
|
||||||
* 底层请求函数类型(兼容 axios 等)
|
config: RequestOptions & Record<string, unknown>
|
||||||
*/
|
) => Promise<{ code: number; msg: string; data: unknown; res?: string }>
|
||||||
declare type RequestFn = (config: RequestOptions & Record<string, unknown>) => Promise<{
|
|
||||||
code: number;
|
|
||||||
msg: string;
|
|
||||||
data: unknown;
|
|
||||||
res?: string;
|
|
||||||
}>;
|
|
||||||
|
|
||||||
declare type RequestOptions = {
|
declare interface RequestOptions {
|
||||||
url?: string | undefined;
|
url?: string
|
||||||
method?: HttpMethod | undefined;
|
method?: HttpMethod
|
||||||
params?: Record<string, unknown> | undefined;
|
params?: Record<string, unknown>
|
||||||
data?: unknown;
|
data?: unknown
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DJB2 算法 —— 将字符串散列为十六进制字符串
|
* DJB2 算法 —— 将字符串散列为十六进制字符串
|
||||||
|
|||||||
Reference in New Issue
Block a user