2024-11-27 16:42:25 +08:00
|
|
|
var ce = Object.defineProperty;
|
|
|
|
var le = (r, e, t) => e in r ? ce(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
|
|
|
|
var v = (r, e, t) => (le(r, typeof e != "symbol" ? e + "" : e, t), t), re = (r, e, t) => {
|
2024-07-23 11:16:38 +08:00
|
|
|
if (!e.has(r))
|
|
|
|
throw TypeError("Cannot " + t);
|
2024-04-04 11:47:06 +08:00
|
|
|
};
|
2025-01-03 17:14:00 +08:00
|
|
|
var i = (r, e, t) => (re(r, e, "read from private field"), t ? t.call(r) : e.get(r)), E = (r, e, t) => {
|
2024-07-23 11:16:38 +08:00
|
|
|
if (e.has(r))
|
2024-04-04 11:47:06 +08:00
|
|
|
throw TypeError("Cannot add the same private member more than once");
|
2024-07-23 11:16:38 +08:00
|
|
|
e instanceof WeakSet ? e.add(r) : e.set(r, t);
|
2025-01-03 17:15:08 +08:00
|
|
|
}, A = (r, e, t, n) => (re(r, e, "write to private field"), n ? n.call(r, t) : e.set(r, t), t);
|
2024-11-27 16:42:25 +08:00
|
|
|
function he(r) {
|
2024-07-23 11:16:38 +08:00
|
|
|
return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r;
|
2024-04-04 11:47:06 +08:00
|
|
|
}
|
2024-11-27 16:42:25 +08:00
|
|
|
var oe = {};
|
2024-07-23 11:16:38 +08:00
|
|
|
(function(r) {
|
2024-04-04 11:47:06 +08:00
|
|
|
(function(e) {
|
|
|
|
e([], function() {
|
2025-01-03 17:15:08 +08:00
|
|
|
var t = -1, n = -2, s = -3, c = -4, l = -5, C = function(h, o) {
|
2025-01-03 17:14:00 +08:00
|
|
|
o = o || {};
|
|
|
|
var d = o.verbose || !1;
|
|
|
|
d && console.log("Normalize the JSON Object"), h = typeof h == "string" ? this.JSON.parse(h) : h, d && console.log("Creating a empty dictionary");
|
2025-01-03 17:37:03 +08:00
|
|
|
var u = {
|
2024-04-04 11:47:06 +08:00
|
|
|
strings: [],
|
|
|
|
integers: [],
|
|
|
|
floats: []
|
|
|
|
};
|
2025-01-03 17:14:00 +08:00
|
|
|
d && console.log("Creating the AST");
|
|
|
|
var g = function P(a) {
|
|
|
|
d && console.log("Calling recursiveAstBuilder with " + this.JSON.stringify(a));
|
|
|
|
var w = typeof a;
|
|
|
|
if (a === null)
|
2024-04-04 11:47:06 +08:00
|
|
|
return {
|
|
|
|
type: "null",
|
2024-11-27 16:42:25 +08:00
|
|
|
index: s
|
2024-04-04 11:47:06 +08:00
|
|
|
};
|
2025-01-03 17:14:00 +08:00
|
|
|
if (typeof a > "u")
|
2024-04-04 11:47:06 +08:00
|
|
|
return {
|
|
|
|
type: "undefined",
|
2025-01-03 17:14:00 +08:00
|
|
|
index: l
|
2024-04-04 11:47:06 +08:00
|
|
|
};
|
2025-01-03 17:14:00 +08:00
|
|
|
if (a instanceof Array) {
|
|
|
|
var x = ["@"];
|
|
|
|
for (var y in a)
|
|
|
|
a.hasOwnProperty(y) && x.push(P(a[y]));
|
|
|
|
return x;
|
2024-04-04 11:47:06 +08:00
|
|
|
}
|
2024-05-25 23:24:11 +08:00
|
|
|
if (w === "object") {
|
2025-01-03 17:14:00 +08:00
|
|
|
var x = ["$"];
|
|
|
|
for (var $ in a)
|
|
|
|
a.hasOwnProperty($) && (x.push(P($)), x.push(P(a[$])));
|
|
|
|
return x;
|
2024-04-04 11:47:06 +08:00
|
|
|
}
|
2025-01-03 17:14:00 +08:00
|
|
|
if (a === "")
|
2024-04-04 11:47:06 +08:00
|
|
|
return {
|
|
|
|
type: "empty",
|
2025-01-03 17:14:00 +08:00
|
|
|
index: c
|
2024-04-04 11:47:06 +08:00
|
|
|
};
|
2024-05-25 23:24:11 +08:00
|
|
|
if (w === "string") {
|
2025-01-03 17:37:03 +08:00
|
|
|
var O = T.call(u.strings, a);
|
|
|
|
return O == -1 && (u.strings.push(G(a)), O = u.strings.length - 1), {
|
2024-04-04 11:47:06 +08:00
|
|
|
type: "strings",
|
2024-11-27 16:42:25 +08:00
|
|
|
index: O
|
2024-04-04 11:47:06 +08:00
|
|
|
};
|
|
|
|
}
|
2025-01-03 17:14:00 +08:00
|
|
|
if (w === "number" && a % 1 === 0) {
|
2025-01-03 17:37:03 +08:00
|
|
|
var O = T.call(u.integers, a);
|
|
|
|
return O == -1 && (u.integers.push(F(a)), O = u.integers.length - 1), {
|
2024-04-04 11:47:06 +08:00
|
|
|
type: "integers",
|
2024-11-27 16:42:25 +08:00
|
|
|
index: O
|
2024-04-04 11:47:06 +08:00
|
|
|
};
|
|
|
|
}
|
2024-05-25 23:24:11 +08:00
|
|
|
if (w === "number") {
|
2025-01-03 17:37:03 +08:00
|
|
|
var O = T.call(u.floats, a);
|
|
|
|
return O == -1 && (u.floats.push(a), O = u.floats.length - 1), {
|
2024-04-04 11:47:06 +08:00
|
|
|
type: "floats",
|
2024-11-27 16:42:25 +08:00
|
|
|
index: O
|
2024-04-04 11:47:06 +08:00
|
|
|
};
|
|
|
|
}
|
2024-05-25 23:24:11 +08:00
|
|
|
if (w === "boolean")
|
2024-04-04 11:47:06 +08:00
|
|
|
return {
|
|
|
|
type: "boolean",
|
2025-01-03 17:14:00 +08:00
|
|
|
index: a ? t : n
|
2024-04-04 11:47:06 +08:00
|
|
|
};
|
2025-01-03 17:14:00 +08:00
|
|
|
throw new Error("Unexpected argument of type " + typeof a);
|
2025-01-03 17:37:03 +08:00
|
|
|
}(h), b = u.strings.length, I = u.integers.length;
|
|
|
|
u.floats.length, d && console.log("Parsing the dictionary");
|
|
|
|
var N = u.strings.join("|");
|
|
|
|
return N += "^" + u.integers.join("|"), N += "^" + u.floats.join("|"), d && console.log("Parsing the structure"), N += "^" + function P(a) {
|
2025-01-03 17:14:00 +08:00
|
|
|
if (d && console.log("Calling a recursiveParser with " + this.JSON.stringify(a)), a instanceof Array) {
|
|
|
|
var w = a.shift();
|
|
|
|
for (var x in a)
|
|
|
|
a.hasOwnProperty(x) && (w += P(a[x]) + "|");
|
2024-05-25 23:24:11 +08:00
|
|
|
return (w[w.length - 1] === "|" ? w.slice(0, -1) : w) + "]";
|
2024-04-04 11:47:06 +08:00
|
|
|
}
|
2025-01-03 17:14:00 +08:00
|
|
|
var y = a.type, $ = a.index;
|
2024-11-27 16:42:25 +08:00
|
|
|
if (y === "strings")
|
2025-01-03 17:14:00 +08:00
|
|
|
return F($);
|
2024-11-27 16:42:25 +08:00
|
|
|
if (y === "integers")
|
2025-01-03 17:14:00 +08:00
|
|
|
return F(b + $);
|
2024-11-27 16:42:25 +08:00
|
|
|
if (y === "floats")
|
2025-01-03 17:14:00 +08:00
|
|
|
return F(b + I + $);
|
2024-11-27 16:42:25 +08:00
|
|
|
if (y === "boolean")
|
2025-01-03 17:14:00 +08:00
|
|
|
return a.index;
|
2024-11-27 16:42:25 +08:00
|
|
|
if (y === "null")
|
|
|
|
return s;
|
|
|
|
if (y === "undefined")
|
2025-01-03 17:14:00 +08:00
|
|
|
return l;
|
2024-11-27 16:42:25 +08:00
|
|
|
if (y === "empty")
|
2025-01-03 17:14:00 +08:00
|
|
|
return c;
|
2024-04-04 11:47:06 +08:00
|
|
|
throw new TypeError("The item is alien!");
|
2025-01-03 17:14:00 +08:00
|
|
|
}(g), d && console.log("Ending parser"), o.debug ? {
|
2025-01-03 17:37:03 +08:00
|
|
|
dictionary: u,
|
2024-11-27 16:42:25 +08:00
|
|
|
ast: g,
|
2025-01-03 17:14:00 +08:00
|
|
|
packed: N
|
|
|
|
} : N;
|
|
|
|
}, M = function(h, o) {
|
|
|
|
o = o || {};
|
|
|
|
var d = h.split("^");
|
|
|
|
o.verbose && console.log("Building dictionary");
|
2025-01-03 17:37:03 +08:00
|
|
|
var u = [], g = d[0];
|
2024-11-27 16:42:25 +08:00
|
|
|
if (g !== "") {
|
2025-01-03 17:14:00 +08:00
|
|
|
g = g.split("|"), o.verbose && console.log("Parse the strings dictionary");
|
|
|
|
for (var b = 0, I = g.length; b < I; b++)
|
2025-01-03 17:37:03 +08:00
|
|
|
u.push(z(g[b]));
|
2024-04-04 11:47:06 +08:00
|
|
|
}
|
2025-01-03 17:14:00 +08:00
|
|
|
if (g = d[1], g !== "") {
|
|
|
|
g = g.split("|"), o.verbose && console.log("Parse the integers dictionary");
|
|
|
|
for (var b = 0, I = g.length; b < I; b++)
|
2025-01-03 17:37:03 +08:00
|
|
|
u.push(f(g[b]));
|
2024-04-04 11:47:06 +08:00
|
|
|
}
|
2025-01-03 17:14:00 +08:00
|
|
|
if (g = d[2], g !== "") {
|
|
|
|
g = g.split("|"), o.verbose && console.log("Parse the floats dictionary");
|
|
|
|
for (var b = 0, I = g.length; b < I; b++)
|
2025-01-03 17:37:03 +08:00
|
|
|
u.push(parseFloat(g[b]));
|
2024-04-04 11:47:06 +08:00
|
|
|
}
|
2025-01-03 17:14:00 +08:00
|
|
|
g = null, o.verbose && console.log("Tokenizing the structure");
|
|
|
|
for (var N = "", P = [], a = d[3].length, b = 0; b < a; b++) {
|
|
|
|
var w = d[3].charAt(b);
|
2025-01-03 17:37:03 +08:00
|
|
|
w === "|" || w === "$" || w === "@" || w === "]" ? (N && (P.push(f(N)), N = ""), w !== "|" && P.push(w)) : N += w;
|
2024-04-04 11:47:06 +08:00
|
|
|
}
|
2025-01-03 17:14:00 +08:00
|
|
|
var x = P.length, y = 0;
|
|
|
|
return o.verbose && console.log("Starting recursive parser"), function $() {
|
|
|
|
var O = P[y++];
|
|
|
|
if (o.verbose && console.log("Reading collection type " + (O === "$" ? "object" : "Array")), O === "@") {
|
|
|
|
for (var p = []; y < x; y++) {
|
2025-01-03 17:15:08 +08:00
|
|
|
var _ = P[y];
|
|
|
|
if (o.verbose && console.log("Read " + _ + " symbol"), _ === "]")
|
2024-11-27 16:42:25 +08:00
|
|
|
return p;
|
2025-01-03 17:15:08 +08:00
|
|
|
if (_ === "@" || _ === "$")
|
2025-01-03 17:14:00 +08:00
|
|
|
p.push($());
|
2024-04-04 11:47:06 +08:00
|
|
|
else
|
2025-01-03 17:15:08 +08:00
|
|
|
switch (_) {
|
2024-07-23 11:16:38 +08:00
|
|
|
case t:
|
2024-11-27 16:42:25 +08:00
|
|
|
p.push(!0);
|
2024-04-04 11:47:06 +08:00
|
|
|
break;
|
2024-11-27 16:42:25 +08:00
|
|
|
case n:
|
|
|
|
p.push(!1);
|
2024-04-04 11:47:06 +08:00
|
|
|
break;
|
2024-11-27 16:42:25 +08:00
|
|
|
case s:
|
|
|
|
p.push(null);
|
2024-04-04 11:47:06 +08:00
|
|
|
break;
|
2025-01-03 17:14:00 +08:00
|
|
|
case l:
|
2024-11-27 16:42:25 +08:00
|
|
|
p.push(void 0);
|
2024-05-25 23:24:11 +08:00
|
|
|
break;
|
2025-01-03 17:14:00 +08:00
|
|
|
case c:
|
2024-11-27 16:42:25 +08:00
|
|
|
p.push("");
|
2024-04-04 11:47:06 +08:00
|
|
|
break;
|
|
|
|
default:
|
2025-01-03 17:37:03 +08:00
|
|
|
p.push(u[_]);
|
2024-04-04 11:47:06 +08:00
|
|
|
}
|
|
|
|
}
|
2025-01-03 17:14:00 +08:00
|
|
|
return o.verbose && console.log("Parsed " + this.JSON.stringify(p)), p;
|
2024-04-04 11:47:06 +08:00
|
|
|
}
|
2024-11-27 16:42:25 +08:00
|
|
|
if (O === "$") {
|
2025-01-03 17:14:00 +08:00
|
|
|
for (var p = {}; y < x; y++) {
|
|
|
|
var S = P[y];
|
|
|
|
if (S === "]")
|
2024-11-27 16:42:25 +08:00
|
|
|
return p;
|
2025-01-03 17:37:03 +08:00
|
|
|
S === c ? S = "" : S = u[S];
|
2025-01-03 17:15:08 +08:00
|
|
|
var _ = P[++y];
|
|
|
|
if (_ === "@" || _ === "$")
|
2025-01-03 17:14:00 +08:00
|
|
|
p[S] = $();
|
2024-04-04 11:47:06 +08:00
|
|
|
else
|
2025-01-03 17:15:08 +08:00
|
|
|
switch (_) {
|
2024-07-23 11:16:38 +08:00
|
|
|
case t:
|
2025-01-03 17:14:00 +08:00
|
|
|
p[S] = !0;
|
2024-04-04 11:47:06 +08:00
|
|
|
break;
|
2024-11-27 16:42:25 +08:00
|
|
|
case n:
|
2025-01-03 17:14:00 +08:00
|
|
|
p[S] = !1;
|
2024-04-04 11:47:06 +08:00
|
|
|
break;
|
2024-11-27 16:42:25 +08:00
|
|
|
case s:
|
2025-01-03 17:14:00 +08:00
|
|
|
p[S] = null;
|
2024-05-25 23:24:11 +08:00
|
|
|
break;
|
2025-01-03 17:14:00 +08:00
|
|
|
case l:
|
|
|
|
p[S] = void 0;
|
2024-05-25 21:16:42 +08:00
|
|
|
break;
|
2025-01-03 17:14:00 +08:00
|
|
|
case c:
|
|
|
|
p[S] = "";
|
2024-04-04 11:47:06 +08:00
|
|
|
break;
|
|
|
|
default:
|
2025-01-03 17:37:03 +08:00
|
|
|
p[S] = u[_];
|
2024-04-04 11:47:06 +08:00
|
|
|
}
|
|
|
|
}
|
2025-01-03 17:14:00 +08:00
|
|
|
return o.verbose && console.log("Parsed " + this.JSON.stringify(p)), p;
|
2024-04-04 11:47:06 +08:00
|
|
|
}
|
2024-11-27 16:42:25 +08:00
|
|
|
throw new TypeError("Bad token " + O + " isn't a type");
|
2024-04-04 11:47:06 +08:00
|
|
|
}();
|
2025-01-03 17:14:00 +08:00
|
|
|
}, G = function(h) {
|
|
|
|
return typeof h != "string" ? h : h.replace(/[\+ \|\^\%]/g, function(o) {
|
2024-04-04 11:47:06 +08:00
|
|
|
return {
|
|
|
|
" ": "+",
|
|
|
|
"+": "%2B",
|
|
|
|
"|": "%7C",
|
|
|
|
"^": "%5E",
|
|
|
|
"%": "%25"
|
2025-01-03 17:14:00 +08:00
|
|
|
}[o];
|
2024-04-04 11:47:06 +08:00
|
|
|
});
|
2025-01-03 17:14:00 +08:00
|
|
|
}, z = function(h) {
|
|
|
|
return typeof h != "string" ? h : h.replace(/\+|%2B|%7C|%5E|%25/g, function(o) {
|
2024-04-04 11:47:06 +08:00
|
|
|
return {
|
|
|
|
"+": " ",
|
|
|
|
"%2B": "+",
|
|
|
|
"%7C": "|",
|
|
|
|
"%5E": "^",
|
|
|
|
"%25": "%"
|
2025-01-03 17:14:00 +08:00
|
|
|
}[o];
|
2024-04-04 11:47:06 +08:00
|
|
|
});
|
2025-01-03 17:14:00 +08:00
|
|
|
}, F = function(h) {
|
|
|
|
return Number.prototype.toString.call(h, 36).toUpperCase();
|
2025-01-03 17:37:03 +08:00
|
|
|
}, f = function(h) {
|
2025-01-03 17:14:00 +08:00
|
|
|
return parseInt(h, 36);
|
|
|
|
}, T = Array.prototype.indexOf || function(h, o) {
|
2025-01-03 17:37:03 +08:00
|
|
|
for (var d = o || 0, u = this.length; d < u; d++)
|
2025-01-03 17:14:00 +08:00
|
|
|
if (this[d] === h)
|
|
|
|
return d;
|
2024-04-04 11:47:06 +08:00
|
|
|
return -1;
|
|
|
|
};
|
|
|
|
return {
|
|
|
|
JSON,
|
2025-01-03 17:15:08 +08:00
|
|
|
pack: C,
|
2025-01-03 17:14:00 +08:00
|
|
|
unpack: M
|
2024-04-04 11:47:06 +08:00
|
|
|
};
|
|
|
|
});
|
2024-07-23 11:16:38 +08:00
|
|
|
})(function(e, t) {
|
2024-11-27 16:42:25 +08:00
|
|
|
var n = t();
|
|
|
|
for (var s in n)
|
|
|
|
r[s] = n[s];
|
2024-04-04 11:47:06 +08:00
|
|
|
});
|
2024-11-27 16:42:25 +08:00
|
|
|
})(oe);
|
|
|
|
const ne = /* @__PURE__ */ he(oe);
|
2025-01-03 17:14:00 +08:00
|
|
|
var j, B, D, U, Y, Q, J, W, X;
|
2024-11-27 16:42:25 +08:00
|
|
|
class ee {
|
2025-01-03 17:14:00 +08:00
|
|
|
constructor(e, t, n, s, c) {
|
2024-11-27 16:42:25 +08:00
|
|
|
v(this, "code", 0);
|
|
|
|
v(this, "message", "操作成功");
|
|
|
|
v(this, "data", null);
|
|
|
|
v(this, "url", "");
|
|
|
|
v(this, "res", "");
|
2024-04-04 11:47:06 +08:00
|
|
|
// static [Symbol.hasInstance](self) { return self?.IS_ECHO_MSG !== undefined }
|
2025-01-03 17:14:00 +08:00
|
|
|
E(this, j, null);
|
2024-04-04 11:47:06 +08:00
|
|
|
// 判断返回 Response 对象, 还是 Response 中的 data
|
2025-01-03 17:14:00 +08:00
|
|
|
E(this, B, !0);
|
2024-04-04 11:47:06 +08:00
|
|
|
// 判罚是否已经给出错误提示
|
2025-01-03 17:14:00 +08:00
|
|
|
E(this, D, !0);
|
|
|
|
E(this, U, {
|
|
|
|
get: (e, t) => i(this, Y).call(this, t),
|
|
|
|
ownKeys: () => Object.keys(i(this, U).getPrototypeOf() || {}),
|
|
|
|
getPrototypeOf: () => i(this, B) ? this : this.data,
|
2024-04-04 11:47:06 +08:00
|
|
|
getOwnPropertyDescriptor: () => ({
|
|
|
|
configurable: !0,
|
|
|
|
enumerable: !0,
|
|
|
|
writable: !0,
|
2025-01-03 17:14:00 +08:00
|
|
|
value: i(this, U).getPrototypeOf()
|
2024-04-04 11:47:06 +08:00
|
|
|
})
|
|
|
|
});
|
2025-01-03 17:15:08 +08:00
|
|
|
E(this, Y, (e) => e === "$echoMsg" ? i(this, J) : e === "msg" ? i(this, Q) : e === "then" || e === "resp" ? (A(this, D, !0), A(this, B, e === "resp"), i(this, W)) : e === "catch" ? i(this, X) : e === "IS_ECHO_MSG" ? i(this, D) : Reflect.get(this, e));
|
|
|
|
E(this, Q, (e = (n) => n, t = !1) => (i(this, J).call(this), A(this, B, t), Promise.resolve(e == null ? void 0 : e(i(this, U).getPrototypeOf()))));
|
2025-01-03 17:14:00 +08:00
|
|
|
E(this, J, () => {
|
2025-01-03 17:37:03 +08:00
|
|
|
i(this, D) && (A(this, D, !1), Pe.onMsg(this.code, this.message));
|
2024-04-04 11:47:06 +08:00
|
|
|
});
|
2025-01-03 17:14:00 +08:00
|
|
|
E(this, W, (e) => [0, 1].includes(this.code) ? Promise.resolve(e == null ? void 0 : e(i(this, U).getPrototypeOf())) : Promise.reject(i(this, j)));
|
|
|
|
E(this, X, (e) => Promise.resolve(e(i(this, j))));
|
2025-01-03 17:15:08 +08:00
|
|
|
return this.code = e, this.message = t, this.data = n, this.url = s, this.res = c, A(this, j, new Proxy(this, i(this, U)));
|
2024-04-04 11:47:06 +08:00
|
|
|
}
|
|
|
|
}
|
2025-01-03 17:14:00 +08:00
|
|
|
j = new WeakMap(), B = new WeakMap(), D = new WeakMap(), U = new WeakMap(), Y = new WeakMap(), Q = new WeakMap(), J = new WeakMap(), W = new WeakMap(), X = new WeakMap();
|
2024-11-27 16:42:25 +08:00
|
|
|
const k = (r, e, t, n = "/", s = "") => new ee(r, e, t, n, s);
|
|
|
|
var ie = [
|
2024-04-04 11:47:06 +08:00
|
|
|
"utf8",
|
|
|
|
"utf-8",
|
|
|
|
"unicode-1-1-utf-8"
|
|
|
|
];
|
2025-01-03 17:37:03 +08:00
|
|
|
function fe(r) {
|
2024-11-27 16:42:25 +08:00
|
|
|
if (ie.indexOf(r) < 0 && typeof r < "u" && r != null)
|
2024-04-04 11:47:06 +08:00
|
|
|
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");
|
2024-11-27 16:42:25 +08:00
|
|
|
var t = unescape(encodeURIComponent(e)), n = new Uint8Array(t.length);
|
|
|
|
const s = t.split("");
|
2025-01-03 17:14:00 +08:00
|
|
|
for (let c = 0; c < s.length; c++)
|
|
|
|
n[c] = s[c].charCodeAt(0);
|
2024-11-27 16:42:25 +08:00
|
|
|
return n;
|
2024-04-04 11:47:06 +08:00
|
|
|
};
|
|
|
|
}
|
2025-01-03 17:37:03 +08:00
|
|
|
function ue(r) {
|
2024-11-27 16:42:25 +08:00
|
|
|
if (ie.indexOf(r) < 0 && typeof r < "u" && r != null)
|
2024-04-04 11:47:06 +08:00
|
|
|
throw new RangeError("Invalid encoding type. Only utf-8 is supported");
|
2024-07-23 11:16:38 +08:00
|
|
|
this.encoding = "utf-8", this.decode = function(e, t) {
|
2024-04-04 11:47:06 +08:00
|
|
|
if (typeof e > "u")
|
|
|
|
return "";
|
2024-11-27 16:42:25 +08:00
|
|
|
var n = typeof t < "u" && n in t ? t.stream : !1;
|
|
|
|
if (typeof n != "boolean")
|
2024-04-04 11:47:06 +08:00
|
|
|
throw new TypeError("stream option must be boolean");
|
|
|
|
if (ArrayBuffer.isView(e)) {
|
2025-01-03 17:14:00 +08:00
|
|
|
var s = new Uint8Array(e.buffer, e.byteOffset, e.byteLength), c = new Array(s.length);
|
|
|
|
for (let l = 0; l < s.length; l++)
|
|
|
|
c[l] = String.fromCharCode(s[l]);
|
|
|
|
return decodeURIComponent(escape(c.join("")));
|
2024-04-04 11:47:06 +08:00
|
|
|
} else
|
|
|
|
throw new TypeError("passed argument must be an array buffer view");
|
|
|
|
};
|
|
|
|
}
|
2024-11-27 16:42:25 +08:00
|
|
|
var ae = {
|
2025-01-03 17:37:03 +08:00
|
|
|
TextEncoder: fe,
|
|
|
|
TextDecoder: ue
|
2024-04-04 11:47:06 +08:00
|
|
|
};
|
2024-11-27 16:42:25 +08:00
|
|
|
const de = new ae.TextEncoder("utf8"), ge = new ae.TextDecoder("utf8"), pe = (r) => {
|
2024-04-04 11:47:06 +08:00
|
|
|
let e = 5381;
|
2024-07-23 11:16:38 +08:00
|
|
|
for (let t = 0; t < r.length; t++)
|
|
|
|
e = e * 33 ^ r.charCodeAt(t);
|
2024-04-04 11:47:06 +08:00
|
|
|
return (e >>> 0).toString(16);
|
2025-01-03 17:37:03 +08:00
|
|
|
}, ve = (r, e) => r.replace(new RegExp(`^${e}+|${e}+$`, "g"), ""), we = (r) => de.encode(r || ""), Se = (r) => ge.decode(new DataView(r), {}), ye = 62, V = 30, se = 31, be = 63;
|
|
|
|
class Ee {
|
2024-11-27 16:42:25 +08:00
|
|
|
constructor(e) {
|
|
|
|
v(this, "encodeTable", []);
|
|
|
|
v(this, "decodeMap", new Uint8Array(256).fill(255));
|
2025-01-03 17:37:03 +08:00
|
|
|
if (e.length !== ye)
|
2024-11-27 16:42:25 +08:00
|
|
|
throw new Error("Encoding alphabet must be 62 characters long");
|
|
|
|
if (e.includes(`
|
|
|
|
`) || e.includes("\r"))
|
|
|
|
throw new Error("Encoding alphabet contains newline character");
|
|
|
|
this.encodeTable = e.split(""), this.decodeMap = new Uint8Array(256).fill(255);
|
|
|
|
for (let t = 0; t < e.length; t++)
|
|
|
|
this.decodeMap[e.charCodeAt(t)] = t;
|
|
|
|
}
|
|
|
|
// 编码方法
|
|
|
|
encode(e) {
|
|
|
|
if (!e || e.length === 0)
|
|
|
|
return [];
|
2025-01-03 17:37:03 +08:00
|
|
|
const t = new Oe(this).encodeV2(e);
|
2024-11-27 16:42:25 +08:00
|
|
|
return String.fromCharCode(...t);
|
|
|
|
}
|
|
|
|
// 解码方法
|
|
|
|
decode(e) {
|
|
|
|
if (!e || e.length === 0)
|
|
|
|
return new Uint8Array();
|
2025-01-03 17:37:03 +08:00
|
|
|
const t = new Te(this).decode(e);
|
2024-11-27 16:42:25 +08:00
|
|
|
return new TextDecoder().decode(t);
|
|
|
|
}
|
|
|
|
}
|
2025-01-03 17:14:00 +08:00
|
|
|
var K;
|
2025-01-03 17:37:03 +08:00
|
|
|
class Oe {
|
2024-11-27 16:42:25 +08:00
|
|
|
constructor(e) {
|
2025-01-03 17:14:00 +08:00
|
|
|
E(this, K, null);
|
2025-01-03 17:15:08 +08:00
|
|
|
A(this, K, e);
|
2024-11-27 16:42:25 +08:00
|
|
|
}
|
|
|
|
get6bits() {
|
|
|
|
let e = this.pos & 7, t = this.pos >> 3;
|
|
|
|
e === 0 && (t -= 1, e = 8);
|
|
|
|
let n = this.src[t] >> 8 - e;
|
2025-01-03 17:37:03 +08:00
|
|
|
return e < 6 && t > 0 && (n |= this.src[t - 1] << e), n & be;
|
2024-11-27 16:42:25 +08:00
|
|
|
}
|
|
|
|
encodeV2(e) {
|
2025-01-03 17:37:03 +08:00
|
|
|
this.src = we(e), this.pos = this.src.length * 8;
|
2024-11-27 16:42:25 +08:00
|
|
|
const t = [];
|
|
|
|
for (; this.pos > 0; ) {
|
|
|
|
let n = 6, s = this.get6bits();
|
2025-01-03 17:14:00 +08:00
|
|
|
(s & V) === V && ((this.pos > 6 || s > se) && (n = 5), s &= se), t.push(i(this, K).encodeTable[s].charCodeAt(0)), this.pos -= n;
|
2024-11-27 16:42:25 +08:00
|
|
|
}
|
|
|
|
return t;
|
|
|
|
}
|
|
|
|
}
|
2025-01-03 17:14:00 +08:00
|
|
|
K = new WeakMap();
|
2024-11-27 16:42:25 +08:00
|
|
|
var H;
|
2025-01-03 17:37:03 +08:00
|
|
|
class Te {
|
2024-11-27 16:42:25 +08:00
|
|
|
constructor(e) {
|
|
|
|
E(this, H, null);
|
2025-01-03 17:15:08 +08:00
|
|
|
A(this, H, e);
|
2024-11-27 16:42:25 +08:00
|
|
|
}
|
|
|
|
decode(e) {
|
|
|
|
const t = new Uint8Array(Math.ceil(e.length * 6 / 8) + 1);
|
2025-01-03 17:14:00 +08:00
|
|
|
let n = t.length, s = 0, c = 0;
|
|
|
|
for (let l = 0; l < e.length; l++) {
|
2025-01-03 17:15:08 +08:00
|
|
|
const C = e[l].charCodeAt(0), M = i(this, H).decodeMap[C];
|
2025-01-03 17:14:00 +08:00
|
|
|
if (M === 255)
|
|
|
|
throw new Error(`CorruptInputError at index ${l}`);
|
|
|
|
l === e.length - 1 ? (c |= M << s, s += Math.ceil(Math.log2(M + 1))) : (M & V) === V ? (c |= M << s, s += 5) : (c |= M << s, s += 6), s >= 8 && (n--, t[n] = c & 255, s %= 8, c >>= 8);
|
2024-11-27 16:42:25 +08:00
|
|
|
}
|
2025-01-03 17:14:00 +08:00
|
|
|
return s > 0 && (n--, t[n] = c & 255), t.slice(n);
|
2024-11-27 16:42:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
H = new WeakMap();
|
2024-07-23 11:16:38 +08:00
|
|
|
Promise.withResolvers || (Promise.withResolvers = function() {
|
|
|
|
let r, e;
|
2024-11-27 16:42:25 +08:00
|
|
|
return { promise: new Promise((n, s) => {
|
|
|
|
r = n, e = s;
|
2024-07-23 11:16:38 +08:00
|
|
|
}), resolve: r, reject: e };
|
|
|
|
});
|
2025-01-03 17:14:00 +08:00
|
|
|
var L, q, Z, m, R;
|
2024-11-27 16:42:25 +08:00
|
|
|
class te {
|
|
|
|
constructor(e, t, n = ({}) => Promise.reject({ code: -1, msg: "请初始化HTTP请求方法主体" })) {
|
|
|
|
E(this, L, void 0);
|
2025-01-03 17:14:00 +08:00
|
|
|
E(this, q, void 0);
|
2024-11-27 16:42:25 +08:00
|
|
|
E(this, Z, void 0);
|
|
|
|
E(this, m, {
|
2024-04-04 11:47:06 +08:00
|
|
|
"#": /* @__PURE__ */ new Map(),
|
|
|
|
// 系统缓存
|
|
|
|
$: /* @__PURE__ */ new Map()
|
|
|
|
// 普通缓存
|
|
|
|
});
|
2025-01-03 17:14:00 +08:00
|
|
|
E(this, R, /* @__PURE__ */ new Map());
|
2024-11-27 16:42:25 +08:00
|
|
|
v(this, "request", ({ url: e = "/", method: t = "GET", ...n }, s = !1) => {
|
2025-01-03 17:14:00 +08:00
|
|
|
var F;
|
2025-01-03 17:37:03 +08:00
|
|
|
e = ve(e, "/");
|
2025-01-03 17:15:08 +08:00
|
|
|
const c = t.toUpperCase(), l = pe(JSON.stringify([e, c, n])), C = (F = e == null ? void 0 : e.includes) != null && F.call(e, "/_/") ? "#" : "$", { promise: M, resolve: G, reject: z } = Promise.withResolvers();
|
2025-01-03 17:37:03 +08:00
|
|
|
return i(this, m)[C].has(l) ? (console.log("cache", e), G(i(this, m)[C].get(l))) : i(this, R).has(l) ? i(this, R).get(l).push([G, z]) : (i(this, R).set(l, [[G, z]]), i(this, L).call(this, { url: e, method: c, ...n }).then((f) => {
|
|
|
|
if (![0, 1].includes(f.code))
|
|
|
|
throw k(f.code, f.msg, f.data, e, f == null ? void 0 : f.res);
|
|
|
|
return [f.code, f.msg, f.data, e, f == null ? void 0 : f.res];
|
|
|
|
}).then((f) => ((C == "#" || c == "GET") && i(this, m)[C].set(l, f), C != "#" && c == "GET" && !s && setTimeout(() => {
|
2025-01-03 17:15:08 +08:00
|
|
|
i(this, m)[C].delete(l);
|
2025-01-03 17:37:03 +08:00
|
|
|
}, 300), f)).then((f) => {
|
2025-01-03 17:14:00 +08:00
|
|
|
var T;
|
|
|
|
return (T = i(this, R).get(l)) == null ? void 0 : T.forEach((h, o, d) => {
|
2025-01-03 17:37:03 +08:00
|
|
|
h && h[0](f), delete d[o];
|
2024-05-28 11:41:59 +08:00
|
|
|
});
|
2025-01-03 17:37:03 +08:00
|
|
|
}).catch((f) => {
|
2025-01-03 17:14:00 +08:00
|
|
|
var T;
|
2025-01-03 17:15:08 +08:00
|
|
|
i(this, m)[C].delete(l), (T = i(this, R).get(l)) == null || T.forEach((h, o, d) => {
|
2025-01-03 17:37:03 +08:00
|
|
|
h && h[1](f instanceof ee ? f : k(-1, f, null, e)), delete d[o];
|
2024-05-25 22:42:00 +08:00
|
|
|
});
|
2025-01-03 17:14:00 +08:00
|
|
|
}).finally(() => i(this, R).delete(l))), new Proxy(M, {
|
2025-01-03 17:37:03 +08:00
|
|
|
get: (f, T) => (...h) => f.then((o) => k(...o)[T](...h)).catch((o) => {
|
2025-01-03 17:14:00 +08:00
|
|
|
if (!o instanceof ee)
|
|
|
|
throw o;
|
|
|
|
return typeof o[T] == "function" ? o[T](...h) : o[T];
|
2024-04-04 11:47:06 +08:00
|
|
|
})
|
|
|
|
});
|
|
|
|
});
|
2024-11-27 16:42:25 +08:00
|
|
|
v(this, "get", (e, t = {}) => this.request({ url: e, method: "GET", params: t }));
|
|
|
|
v(this, "post", (e, t = {}, n = {}) => this.request({ url: e, method: "POST", data: t, params: n }));
|
|
|
|
v(this, "put", (e, t = {}, n = {}) => this.request({ url: e, method: "PUT", data: t, params: n }));
|
|
|
|
v(this, "del", (e, t = {}, n = {}) => this.request({ url: e, method: "DELETE", data: t, params: n }));
|
|
|
|
v(this, "download", (e, t) => {
|
2024-04-04 11:47:06 +08:00
|
|
|
});
|
2024-11-27 16:42:25 +08:00
|
|
|
v(this, "cache", (e, t = {}) => this.request({ url: e, method: "GET", params: t }, !0));
|
|
|
|
v(this, "list", (e, t = {}) => this.get(`/api/${e}/${this.encode(t)}`));
|
|
|
|
v(this, "getAppInfo", () => {
|
2024-04-04 11:47:06 +08:00
|
|
|
});
|
2024-11-27 16:42:25 +08:00
|
|
|
v(this, "refreshCache", (e = !1) => {
|
2025-01-03 17:14:00 +08:00
|
|
|
e && i(this, m)["#"].clear(), i(this, m).$.clear();
|
2024-04-04 11:47:06 +08:00
|
|
|
});
|
2024-11-27 16:42:25 +08:00
|
|
|
v(this, "decode", (e = "", t = {}) => {
|
2024-04-04 11:47:06 +08:00
|
|
|
if (e === void 0 || e === "" || e === null)
|
2024-07-23 11:16:38 +08:00
|
|
|
return t;
|
2024-04-04 11:47:06 +08:00
|
|
|
try {
|
2025-01-03 17:14:00 +08:00
|
|
|
const n = i(this, q).decode(e);
|
2024-11-27 16:42:25 +08:00
|
|
|
return ne.unpack(n);
|
2024-04-04 11:47:06 +08:00
|
|
|
} catch {
|
2024-07-23 11:16:38 +08:00
|
|
|
return console.warn("core.decode", e), t;
|
2024-04-04 11:47:06 +08:00
|
|
|
}
|
|
|
|
});
|
2024-11-27 16:42:25 +08:00
|
|
|
v(this, "encode", (e = {}) => {
|
|
|
|
const t = JSON.stringify(e, (n, s) => s === void 0 ? null : s);
|
2025-01-03 17:14:00 +08:00
|
|
|
return i(this, q).encode(ne.pack(t));
|
2024-04-04 11:47:06 +08:00
|
|
|
});
|
2025-01-03 17:37:03 +08:00
|
|
|
A(this, Z, e), A(this, L, n), A(this, q, new Ee(t));
|
2024-04-04 11:47:06 +08:00
|
|
|
}
|
|
|
|
}
|
2025-01-03 17:14:00 +08:00
|
|
|
L = new WeakMap(), q = new WeakMap(), Z = new WeakMap(), m = new WeakMap(), R = new WeakMap();
|
2025-01-03 17:37:03 +08:00
|
|
|
const Pe = te;
|
2024-11-27 16:42:25 +08:00
|
|
|
te.onUnhandledRejection = (r) => {
|
2025-01-03 17:14:00 +08:00
|
|
|
var e, t, n, s, c, l;
|
|
|
|
r != null && r.IS_ECHO_MSG ? ((e = r == null ? void 0 : r.$echoMsg) == null || e.call(r), (t = r == null ? void 0 : r.preventDefault) == null || t.call(r)) : (n = r.reason) != null && n.IS_ECHO_MSG && ((c = (s = r.reason) == null ? void 0 : s.$echoMsg) == null || c.call(s), (l = r == null ? void 0 : r.preventDefault) == null || l.call(r));
|
2024-04-04 11:47:06 +08:00
|
|
|
};
|
2024-11-27 16:42:25 +08:00
|
|
|
te.onMsg = (r, e) => [0, 1].includes(r) ? console.log(e) : console.warn(e);
|
2024-04-04 11:47:06 +08:00
|
|
|
export {
|
2025-01-03 17:37:03 +08:00
|
|
|
Pe as default,
|
2024-11-27 16:42:25 +08:00
|
|
|
pe as signature,
|
2025-01-03 17:37:03 +08:00
|
|
|
we as str2uint8array,
|
|
|
|
ve as trim,
|
2024-11-27 16:42:25 +08:00
|
|
|
Se as uint8array2str
|
2024-04-04 11:47:06 +08:00
|
|
|
};
|