This commit is contained in:
2026-10-14 10:46:32 +08:00
parent d8cc3ec655
commit 40fe1509a0
4 changed files with 107 additions and 104 deletions
+101 -99
View File
@@ -4,7 +4,7 @@ var oe = (r) => {
};
var ge = (r, e, t) => e in r ? de(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
var l = (r, e, t) => ge(r, typeof e != "symbol" ? e + "" : e, t), ae = (r, e, t) => e.has(r) || oe("Cannot " + 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);
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), A = (r, e, t, n) => (ae(r, e, "write to private field"), n ? n.call(r, t) : e.set(r, t), t);
function pe(r) {
return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r;
}
@@ -12,7 +12,7 @@ var ue = {};
(function(r) {
(function(e) {
e([], function() {
var t = -1, n = -2, i = -3, c = -4, f = -5, U = function(h, d) {
var t = -1, n = -2, i = -3, o = -4, f = -5, U = function(h, d) {
d = d || {};
var u = d.verbose || !1;
u && console.log("Normalize the JSON Object"), h = typeof h == "string" ? this.JSON.parse(h) : h, u && console.log("Creating a empty dictionary");
@@ -22,53 +22,53 @@ var ue = {};
floats: []
};
u && console.log("Creating the AST");
var p = function S(o) {
u && console.log("Calling recursiveAstBuilder with " + this.JSON.stringify(o));
var y = typeof o;
if (o === null)
var p = function S(a) {
u && console.log("Calling recursiveAstBuilder with " + this.JSON.stringify(a));
var y = typeof a;
if (a === null)
return {
type: "null",
index: i
};
if (typeof o > "u")
if (typeof a > "u")
return {
type: "undefined",
index: f
};
if (o instanceof Array) {
if (a instanceof Array) {
var O = ["@"];
for (var b in o)
o.hasOwnProperty(b) && O.push(S(o[b]));
for (var b in a)
a.hasOwnProperty(b) && O.push(S(a[b]));
return O;
}
if (y === "object") {
var O = ["$"];
for (var N in o)
o.hasOwnProperty(N) && (O.push(S(N)), O.push(S(o[N])));
for (var N in a)
a.hasOwnProperty(N) && (O.push(S(N)), O.push(S(a[N])));
return O;
}
if (o === "")
if (a === "")
return {
type: "empty",
index: c
index: o
};
if (y === "string") {
var P = q.call(g.strings, o);
return P == -1 && (g.strings.push(T(o)), P = g.strings.length - 1), {
var P = q.call(g.strings, a);
return P == -1 && (g.strings.push(T(a)), P = g.strings.length - 1), {
type: "strings",
index: P
};
}
if (y === "number" && o % 1 === 0) {
var P = q.call(g.integers, o);
return P == -1 && (g.integers.push(m(o)), P = g.integers.length - 1), {
if (y === "number" && a % 1 === 0) {
var P = q.call(g.integers, a);
return P == -1 && (g.integers.push(m(a)), P = g.integers.length - 1), {
type: "integers",
index: P
};
}
if (y === "number") {
var P = q.call(g.floats, o);
return P == -1 && (g.floats.push(o), P = g.floats.length - 1), {
var P = q.call(g.floats, a);
return P == -1 && (g.floats.push(a), P = g.floats.length - 1), {
type: "floats",
index: P
};
@@ -76,20 +76,20 @@ var ue = {};
if (y === "boolean")
return {
type: "boolean",
index: o ? t : n
index: a ? t : n
};
throw new Error("Unexpected argument of type " + typeof o);
throw new Error("Unexpected argument of type " + typeof a);
}(h), E = g.strings.length, J = g.integers.length;
g.floats.length, u && console.log("Parsing the dictionary");
var M = g.strings.join("|");
return M += "^" + g.integers.join("|"), M += "^" + g.floats.join("|"), u && console.log("Parsing the structure"), M += "^" + function S(o) {
if (u && console.log("Calling a recursiveParser with " + this.JSON.stringify(o)), o instanceof Array) {
var y = o.shift();
for (var O in o)
o.hasOwnProperty(O) && (y += S(o[O]) + "|");
var _ = g.strings.join("|");
return _ += "^" + g.integers.join("|"), _ += "^" + g.floats.join("|"), u && console.log("Parsing the structure"), _ += "^" + function S(a) {
if (u && console.log("Calling a recursiveParser with " + this.JSON.stringify(a)), a instanceof Array) {
var y = a.shift();
for (var O in a)
a.hasOwnProperty(O) && (y += S(a[O]) + "|");
return (y[y.length - 1] === "|" ? y.slice(0, -1) : y) + "]";
}
var b = o.type, N = o.index;
var b = a.type, N = a.index;
if (b === "strings")
return m(N);
if (b === "integers")
@@ -97,20 +97,20 @@ var ue = {};
if (b === "floats")
return m(E + J + N);
if (b === "boolean")
return o.index;
return a.index;
if (b === "null")
return i;
if (b === "undefined")
return f;
if (b === "empty")
return c;
return o;
throw new TypeError("The item is alien!");
}(p), u && console.log("Ending parser"), d.debug ? {
dictionary: g,
ast: p,
packed: M
} : M;
}, a = function(h, d) {
packed: _
} : _;
}, c = function(h, d) {
d = d || {};
var u = h.split("^");
d.verbose && console.log("Building dictionary");
@@ -118,7 +118,7 @@ var ue = {};
if (p !== "") {
p = p.split("|"), d.verbose && console.log("Parse the strings dictionary");
for (var E = 0, J = p.length; E < J; E++)
g.push(_(p[E]));
g.push(C(p[E]));
}
if (p = u[1], p !== "") {
p = p.split("|"), d.verbose && console.log("Parse the integers dictionary");
@@ -131,22 +131,22 @@ var ue = {};
g.push(parseFloat(p[E]));
}
p = null, d.verbose && console.log("Tokenizing the structure");
for (var M = "", S = [], o = u[3].length, E = 0; E < o; E++) {
for (var _ = "", S = [], a = u[3].length, E = 0; E < a; E++) {
var y = u[3].charAt(E);
y === "|" || y === "$" || y === "@" || y === "]" ? (M && (S.push(I(M)), M = ""), y !== "|" && S.push(y)) : M += y;
y === "|" || y === "$" || y === "@" || y === "]" ? (_ && (S.push(I(_)), _ = ""), y !== "|" && S.push(y)) : _ += y;
}
var O = S.length, b = 0;
return d.verbose && console.log("Starting recursive parser"), function N() {
var P = S[b++];
if (d.verbose && console.log("Reading collection type " + (P === "$" ? "object" : "Array")), P === "@") {
for (var v = []; b < O; b++) {
var A = S[b];
if (d.verbose && console.log("Read " + A + " symbol"), A === "]")
var M = S[b];
if (d.verbose && console.log("Read " + M + " symbol"), M === "]")
return v;
if (A === "@" || A === "$")
if (M === "@" || M === "$")
v.push(N());
else
switch (A) {
switch (M) {
case t:
v.push(!0);
break;
@@ -159,11 +159,11 @@ var ue = {};
case f:
v.push(void 0);
break;
case c:
case o:
v.push("");
break;
default:
v.push(g[A]);
v.push(g[M]);
}
}
return d.verbose && console.log("Parsed " + this.JSON.stringify(v)), v;
@@ -173,12 +173,12 @@ var ue = {};
var x = S[b];
if (x === "]")
return v;
x === c ? x = "" : x = g[x];
var A = S[++b];
if (A === "@" || A === "$")
x === o ? x = "" : x = g[x];
var M = S[++b];
if (M === "@" || M === "$")
v[x] = N();
else
switch (A) {
switch (M) {
case t:
v[x] = !0;
break;
@@ -191,11 +191,11 @@ var ue = {};
case f:
v[x] = void 0;
break;
case c:
case o:
v[x] = "";
break;
default:
v[x] = g[A];
v[x] = g[M];
}
}
return d.verbose && console.log("Parsed " + this.JSON.stringify(v)), v;
@@ -212,7 +212,7 @@ var ue = {};
"%": "%25"
}[d];
});
}, _ = function(h) {
}, C = function(h) {
return typeof h != "string" ? h : h.replace(/\+|%2B|%7C|%5E|%25/g, function(d) {
return {
"+": " ",
@@ -235,7 +235,7 @@ var ue = {};
return {
JSON,
pack: U,
unpack: a
unpack: c
};
});
})(function(e, t) {
@@ -254,7 +254,7 @@ const ie = class ie {
* @param {string} url
* @param {string} res
*/
constructor(e, t, n, i, c) {
constructor(e, t, n, i, o) {
/** @type {number} */
l(this, "code", 0);
/** @type {string} */
@@ -330,7 +330,7 @@ const ie = class ie {
* @param {string | symbol} key
* @returns {unknown}
*/
w(this, W, (e) => e === "$echoMsg" ? s(this, k) : e === "then" ? (C(this, j, !0), s(this, X)) : e === "catch" ? s(this, Z) : e === "finally" ? s(this, ee) : e === "IS_ECHO_MSG" ? s(this, j) : Reflect.get(this, e));
w(this, W, (e) => e === "$echoMsg" ? s(this, k) : e === "then" ? (A(this, j, !0), s(this, X)) : e === "catch" ? s(this, Z) : e === "finally" ? s(this, ee) : e === "IS_ECHO_MSG" ? s(this, j) : Reflect.get(this, e));
/**
* message 消息弹窗后回调
*
@@ -354,7 +354,7 @@ const ie = class ie {
* fn 内部抛出的异常会变成 reject,而不是同步抛出。
*/
l(this, "msg", (e = (n) => n, t = !1) => {
s(this, k).call(this), C(this, H, t);
s(this, k).call(this), A(this, H, t);
try {
return Promise.resolve(
e == null ? void 0 : e(s(this, B).getPrototypeOf())
@@ -390,7 +390,7 @@ const ie = class ie {
* @param {(reason: HttpResponse) => unknown} [onrejected]
* @returns {Promise<unknown>}
*/
l(this, "resp", (e, t) => (C(this, j, !0), [0, 1].includes(this.code) ? Promise.resolve(e == null ? void 0 : e(this)) : t ? Promise.resolve(t(s(this, $))) : Promise.reject(s(this, $))));
l(this, "resp", (e, t) => (A(this, j, !0), [0, 1].includes(this.code) ? Promise.resolve(e == null ? void 0 : e(this)) : t ? Promise.resolve(t(s(this, $))) : Promise.reject(s(this, $))));
/**
* 转换成 JSON
*
@@ -415,7 +415,7 @@ const ie = class ie {
* @returns {void}
*/
w(this, k, () => {
s(this, j) && (C(this, j, !1), se.onMsg(this.code, this.message));
s(this, j) && (A(this, j, !1), se.onMsg(this.code, this.message));
});
/**
* Promise then
@@ -431,7 +431,7 @@ const ie = class ie {
* @param {HttpResponseRejectCallback} fn
* @returns {Promise<unknown>}
*/
w(this, Z, (e) => Promise.resolve(e(s(this, $))));
w(this, Z, (e) => [0, 1].includes(this.code) ? Promise.resolve(this.data) : Promise.resolve(e(s(this, $))));
/**
* Promise finally
*
@@ -439,7 +439,7 @@ const ie = class ie {
* @returns {Promise<unknown>}
*/
w(this, ee, (e) => (e == null || e(), [0, 1].includes(this.code) ? Promise.resolve(s(this, B).getPrototypeOf()) : Promise.reject(s(this, $))));
return this.code = e, this.message = t, this.data = n, this.url = i, this.res = c, C(this, $, new Proxy(this, s(this, B)));
return this.code = e, this.message = t, this.data = n, this.url = i, this.res = o, A(this, $, new Proxy(this, s(this, B)));
}
static [Symbol.hasInstance](e) {
return (e == null ? void 0 : e.constructor) === ie || (e == null ? void 0 : e[Symbol.for("HttpResponse")]) === !0;
@@ -464,8 +464,8 @@ function ve(r) {
throw new TypeError("passed argument must be of tye string");
var t = unescape(encodeURIComponent(e)), n = new Uint8Array(t.length);
const i = t.split("");
for (let c = 0; c < i.length; c++)
n[c] = i[c].charCodeAt(0);
for (let o = 0; o < i.length; o++)
n[o] = i[o].charCodeAt(0);
return n;
};
}
@@ -479,10 +479,10 @@ function we(r) {
if (typeof n != "boolean")
throw new TypeError("stream option must be boolean");
if (ArrayBuffer.isView(e)) {
var i = new Uint8Array(e.buffer, e.byteOffset, e.byteLength), c = new Array(i.length);
var i = new Uint8Array(e.buffer, e.byteOffset, e.byteLength), o = new Array(i.length);
for (let f = 0; f < i.length; f++)
c[f] = String.fromCharCode(i[f]);
return decodeURIComponent(escape(c.join("")));
o[f] = String.fromCharCode(i[f]);
return decodeURIComponent(escape(o.join("")));
} else
throw new TypeError("passed argument must be an array buffer view");
};
@@ -492,11 +492,13 @@ var fe = {
TextDecoder: we
};
const ye = new fe.TextEncoder("utf8"), be = new fe.TextDecoder("utf8");
function Ee(r) {
let e = 5381;
for (let t = 0; t < r.length; t++)
e = e * 33 ^ r.charCodeAt(t);
return (e >>> 0).toString(16);
function Ee(r, e = 0) {
let t = 3735928559 ^ e, n = 1103547991 ^ e;
for (let i = 0; i < r.length; i++) {
const o = r.charCodeAt(i);
t = Math.imul(t ^ o, 2654435761), n = Math.imul(n ^ o, 1597334677);
}
return t = Math.imul(t ^ t >>> 16, 2246822507), t ^= Math.imul(n ^ n >>> 13, 3266489909), n = Math.imul(n ^ n >>> 16, 2246822507), n ^= Math.imul(t ^ t >>> 13, 3266489909), (4294967296 * (2097151 & n) + (t >>> 0)).toString(16);
}
function Pe(r, e) {
return r.replace(new RegExp(`^${e}+|${e}+$`, "g"), "");
@@ -504,7 +506,7 @@ function Pe(r, e) {
function Te(r) {
return ye.encode(r || "");
}
function _e(r) {
function Ce(r) {
return be.decode(new DataView(r), {});
}
const Se = 62, Q = 30, he = 31, Oe = 63;
@@ -543,7 +545,7 @@ class xe {
*/
decode(e) {
if (!e || e.length === 0) return "";
const t = new Ae(this).decode(e);
const t = new Me(this).decode(e);
return new TextDecoder().decode(t);
}
}
@@ -559,7 +561,7 @@ class me {
l(this, "src", new Uint8Array());
/** @type {number} */
l(this, "pos", 0);
C(this, z, e);
A(this, z, e);
}
/** @returns {number} */
get6bits() {
@@ -584,14 +586,14 @@ class me {
}
z = new WeakMap();
var V;
class Ae {
class Me {
/**
* @param {Base62} b62
*/
constructor(e) {
/** @type {Base62} */
w(this, V);
C(this, V, e);
A(this, V, e);
}
/**
* @param {string} src
@@ -599,14 +601,14 @@ class Ae {
*/
decode(e) {
const t = new Uint8Array(Math.ceil(e.length * 6 / 8) + 1);
let n = t.length, i = 0, c = 0;
let n = t.length, i = 0, o = 0;
for (let f = 0; f < e.length; f++) {
const U = e[f].charCodeAt(0), a = s(this, V).decodeMap[U];
if (a === 255)
const U = e[f].charCodeAt(0), c = s(this, V).decodeMap[U];
if (c === 255)
throw new Error(`CorruptInputError at index ${f}`);
f === e.length - 1 ? (c |= a << i, i += Math.ceil(Math.log2(a + 1))) : (a & Q) === Q ? (c |= a << i, i += 5) : (c |= a << i, i += 6), i >= 8 && (n--, t[n] = c & 255, i %= 8, c >>= 8);
f === e.length - 1 ? (o |= c << i, i += Math.ceil(Math.log2(c + 1))) : (c & Q) === Q ? (o |= c << i, i += 5) : (o |= c << i, i += 6), i >= 8 && (n--, t[n] = o & 255, i %= 8, o >>= 8);
}
return i > 0 && (n--, t[n] = c & 255), t.slice(n);
return i > 0 && (n--, t[n] = o & 255), t.slice(n);
}
}
V = new WeakMap();
@@ -647,7 +649,7 @@ class se {
* @param {RequestFn} [reqFn]
*/
l(this, "init", (e, t, n) => {
e && C(this, te, e), n && C(this, G, n), t && C(this, D, new xe(t)), s(this, re).call(this);
e && A(this, te, e), n && A(this, G, n), t && A(this, D, new xe(t)), s(this, re).call(this);
});
w(this, re, () => {
!s(this, K).size || !s(this, G) || (s(this, K).forEach((e) => s(this, Y).call(this, ...e)), s(this, K).clear());
@@ -662,28 +664,28 @@ class se {
if (!s(this, G))
s(this, K).add([e, t, n, i]);
else {
const { url: c, method: f, ...U } = n || {};
s(this, G).call(this, { url: c, method: f, ...U }).then((a) => {
if (![0, 1].includes(a.code))
throw ne(a.code ?? -1, a.msg ?? "响应格式错误", a.data, c, a == null ? void 0 : a.res);
return [a.code, a.msg, a.data, c, (a == null ? void 0 : a.res) ?? ""];
}).then((a) => {
const { url: o, method: f, ...U } = n || {};
s(this, G).call(this, { url: o, method: f, ...U }).then((c) => {
if (![0, 1].includes(c.code))
throw ne(c.code ?? -1, 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) => {
const T = (
/** @type {CacheEntry} */
a
c
);
return (t == "#" || f == "GET") && s(this, R)[t].set(e, T), t != "#" && f == "GET" && !i && setTimeout(() => {
s(this, R)[t].delete(e);
}, 300), T;
}).then((a) => {
}).then((c) => {
var T;
return (T = s(this, F).get(e)) == null ? void 0 : T.forEach((_, m, I) => {
_ && _[0](a), delete I[m];
return (T = s(this, F).get(e)) == null ? void 0 : T.forEach((C, m, I) => {
C && C[0](c), delete I[m];
});
}).catch((a) => {
}).catch((c) => {
var T;
s(this, R)[t].delete(e), (T = s(this, F).get(e)) == null || T.forEach((_, m, I) => {
_ && _[1](a instanceof L ? a : ne(-1, a, null, c)), delete I[m];
s(this, R)[t].delete(e), (T = s(this, F).get(e)) == null || T.forEach((C, m, I) => {
C && C[1](c instanceof L ? c : ne(-1, c, null, o)), delete I[m];
});
}).finally(() => s(this, F).delete(e));
}
@@ -697,16 +699,16 @@ class se {
l(this, "request", ({ url: e = "/", method: t = "GET", ...n }, i = !1) => {
var m, I;
e = Pe(e, "/");
const c = (
const o = (
/** @type {HttpMethod} */
t.toUpperCase()
), f = Ee(JSON.stringify([e, c, n])), U = (
), f = Ee(JSON.stringify([e, o, n])), U = (
/** @type {'#' | '$'} */
(m = e == null ? void 0 : e.includes) != null && m.call(e, "/_/") ? "#" : "$"
), { promise: a, resolve: T, reject: _ } = Promise.withResolvers();
return s(this, R)[U].has(f) ? (console.log("cache", e), T(s(this, R)[U].get(f))) : s(this, F).has(f) ? (I = s(this, F).get(f)) == null || I.push([T, _]) : (s(this, F).set(f, [[T, _]]), s(this, Y).call(this, f, U, { url: e, method: c, ...n }, i)), /** @type {HttpResponseChainable} */
), { promise: c, resolve: T, reject: C } = Promise.withResolvers();
return s(this, R)[U].has(f) ? (console.log("cache", e), T(s(this, R)[U].get(f))) : s(this, F).has(f) ? (I = s(this, F).get(f)) == null || I.push([T, C]) : (s(this, F).set(f, [[T, C]]), s(this, Y).call(this, f, U, { url: e, method: o, ...n }, i)), /** @type {HttpResponseChainable} */
/** @type {unknown} */
new Proxy(a, {
new Proxy(c, {
// Symbol.for('HttpResponse') 是标记,用于外部 instanceof 识别此 Proxy 为 HttpResponse 类型
get: (q, h) => h === Symbol.for("HttpResponse") ? !0 : (...d) => q.then((u) => (
/** @type {any} */
@@ -835,5 +837,5 @@ export {
Ee as signature,
Te as str2uint8array,
Pe as trim,
_e as uint8array2str
Ce as uint8array2str
};