ff-request-dist/dist/ff-request.js

493 lines
18 KiB
JavaScript
Raw Normal View History

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
};
2024-11-27 16:42:25 +08:00
var o = (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);
2024-11-27 16:42:25 +08:00
}, C = (r, e, t, n) => (re(r, e, "write to private field"), n ? n.call(r, t) : e.set(r, t), t);
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() {
2024-11-27 16:42:25 +08:00
var t = -1, n = -2, s = -3, f = -4, h = -5, $ = function(a, c) {
c = c || {};
var l = c.verbose || !1;
l && console.log("Normalize the JSON Object"), a = typeof a == "string" ? this.JSON.parse(a) : a, l && console.log("Creating a empty dictionary");
var d = {
2024-04-04 11:47:06 +08:00
strings: [],
integers: [],
floats: []
};
2024-11-27 16:42:25 +08:00
l && console.log("Creating the AST");
var g = function T(i) {
l && console.log("Calling recursiveAstBuilder with " + this.JSON.stringify(i));
var w = typeof i;
if (i === 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
};
2024-11-27 16:42:25 +08:00
if (typeof i > "u")
2024-04-04 11:47:06 +08:00
return {
type: "undefined",
2024-11-27 16:42:25 +08:00
index: h
2024-04-04 11:47:06 +08:00
};
2024-11-27 16:42:25 +08:00
if (i instanceof Array) {
var P = ["@"];
for (var y in i)
i.hasOwnProperty(y) && P.push(T(i[y]));
return P;
2024-04-04 11:47:06 +08:00
}
2024-05-25 23:24:11 +08:00
if (w === "object") {
2024-11-27 16:42:25 +08:00
var P = ["$"];
for (var M in i)
i.hasOwnProperty(M) && (P.push(T(M)), P.push(T(i[M])));
return P;
2024-04-04 11:47:06 +08:00
}
2024-11-27 16:42:25 +08:00
if (i === "")
2024-04-04 11:47:06 +08:00
return {
type: "empty",
2024-11-27 16:42:25 +08:00
index: f
2024-04-04 11:47:06 +08:00
};
2024-05-25 23:24:11 +08:00
if (w === "string") {
2024-11-27 16:42:25 +08:00
var O = u.call(d.strings, i);
return O == -1 && (d.strings.push(q(i)), O = d.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
};
}
2024-11-27 16:42:25 +08:00
if (w === "number" && i % 1 === 0) {
var O = u.call(d.integers, i);
return O == -1 && (d.integers.push(U(i)), O = d.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") {
2024-11-27 16:42:25 +08:00
var O = u.call(d.floats, i);
return O == -1 && (d.floats.push(i), O = d.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",
2024-11-27 16:42:25 +08:00
index: i ? t : n
2024-04-04 11:47:06 +08:00
};
2024-11-27 16:42:25 +08:00
throw new Error("Unexpected argument of type " + typeof i);
}(a), b = d.strings.length, F = d.integers.length;
d.floats.length, l && console.log("Parsing the dictionary");
var A = d.strings.join("|");
return A += "^" + d.integers.join("|"), A += "^" + d.floats.join("|"), l && console.log("Parsing the structure"), A += "^" + function T(i) {
if (l && console.log("Calling a recursiveParser with " + this.JSON.stringify(i)), i instanceof Array) {
var w = i.shift();
for (var P in i)
i.hasOwnProperty(P) && (w += T(i[P]) + "|");
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
}
2024-11-27 16:42:25 +08:00
var y = i.type, M = i.index;
if (y === "strings")
return U(M);
if (y === "integers")
return U(b + M);
if (y === "floats")
return U(b + F + M);
if (y === "boolean")
return i.index;
if (y === "null")
return s;
if (y === "undefined")
return h;
if (y === "empty")
return f;
2024-04-04 11:47:06 +08:00
throw new TypeError("The item is alien!");
2024-11-27 16:42:25 +08:00
}(g), l && console.log("Ending parser"), c.debug ? {
dictionary: d,
ast: g,
packed: A
} : A;
}, _ = function(a, c) {
c = c || {};
var l = a.split("^");
c.verbose && console.log("Building dictionary");
var d = [], g = l[0];
if (g !== "") {
g = g.split("|"), c.verbose && console.log("Parse the strings dictionary");
for (var b = 0, F = g.length; b < F; b++)
d.push(z(g[b]));
2024-04-04 11:47:06 +08:00
}
2024-11-27 16:42:25 +08:00
if (g = l[1], g !== "") {
g = g.split("|"), c.verbose && console.log("Parse the integers dictionary");
for (var b = 0, F = g.length; b < F; b++)
d.push(J(g[b]));
2024-04-04 11:47:06 +08:00
}
2024-11-27 16:42:25 +08:00
if (g = l[2], g !== "") {
g = g.split("|"), c.verbose && console.log("Parse the floats dictionary");
for (var b = 0, F = g.length; b < F; b++)
d.push(parseFloat(g[b]));
2024-04-04 11:47:06 +08:00
}
2024-11-27 16:42:25 +08:00
g = null, c.verbose && console.log("Tokenizing the structure");
for (var A = "", T = [], i = l[3].length, b = 0; b < i; b++) {
var w = l[3].charAt(b);
w === "|" || w === "$" || w === "@" || w === "]" ? (A && (T.push(J(A)), A = ""), w !== "|" && T.push(w)) : A += w;
2024-04-04 11:47:06 +08:00
}
2024-11-27 16:42:25 +08:00
var P = T.length, y = 0;
return c.verbose && console.log("Starting recursive parser"), function M() {
var O = T[y++];
if (c.verbose && console.log("Reading collection type " + (O === "$" ? "object" : "Array")), O === "@") {
for (var p = []; y < P; y++) {
var S = T[y];
if (c.verbose && console.log("Read " + S + " symbol"), S === "]")
return p;
if (S === "@" || S === "$")
p.push(M());
2024-04-04 11:47:06 +08:00
else
2024-11-27 16:42:25 +08:00
switch (S) {
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;
2024-11-27 16:42:25 +08:00
case h:
p.push(void 0);
2024-05-25 23:24:11 +08:00
break;
2024-11-27 16:42:25 +08:00
case f:
p.push("");
2024-04-04 11:47:06 +08:00
break;
default:
2024-11-27 16:42:25 +08:00
p.push(d[S]);
2024-04-04 11:47:06 +08:00
}
}
2024-11-27 16:42:25 +08:00
return c.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 === "$") {
for (var p = {}; y < P; y++) {
var x = T[y];
if (x === "]")
return p;
x === f ? x = "" : x = d[x];
var S = T[++y];
if (S === "@" || S === "$")
p[x] = M();
2024-04-04 11:47:06 +08:00
else
2024-11-27 16:42:25 +08:00
switch (S) {
2024-07-23 11:16:38 +08:00
case t:
2024-11-27 16:42:25 +08:00
p[x] = !0;
2024-04-04 11:47:06 +08:00
break;
2024-11-27 16:42:25 +08:00
case n:
p[x] = !1;
2024-04-04 11:47:06 +08:00
break;
2024-11-27 16:42:25 +08:00
case s:
p[x] = null;
2024-05-25 23:24:11 +08:00
break;
2024-11-27 16:42:25 +08:00
case h:
p[x] = void 0;
2024-05-25 21:16:42 +08:00
break;
2024-11-27 16:42:25 +08:00
case f:
p[x] = "";
2024-04-04 11:47:06 +08:00
break;
default:
2024-11-27 16:42:25 +08:00
p[x] = d[S];
2024-04-04 11:47:06 +08:00
}
}
2024-11-27 16:42:25 +08:00
return c.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
}();
2024-11-27 16:42:25 +08:00
}, q = function(a) {
return typeof a != "string" ? a : a.replace(/[\+ \|\^\%]/g, function(c) {
2024-04-04 11:47:06 +08:00
return {
" ": "+",
"+": "%2B",
"|": "%7C",
"^": "%5E",
"%": "%25"
2024-11-27 16:42:25 +08:00
}[c];
2024-04-04 11:47:06 +08:00
});
2024-11-27 16:42:25 +08:00
}, z = function(a) {
return typeof a != "string" ? a : a.replace(/\+|%2B|%7C|%5E|%25/g, function(c) {
2024-04-04 11:47:06 +08:00
return {
"+": " ",
"%2B": "+",
"%7C": "|",
"%5E": "^",
"%25": "%"
2024-11-27 16:42:25 +08:00
}[c];
2024-04-04 11:47:06 +08:00
});
2024-11-27 16:42:25 +08:00
}, U = function(a) {
return Number.prototype.toString.call(a, 36).toUpperCase();
}, J = function(a) {
return parseInt(a, 36);
}, u = Array.prototype.indexOf || function(a, c) {
for (var l = c || 0, d = this.length; l < d; l++)
if (this[l] === a)
return l;
2024-04-04 11:47:06 +08:00
return -1;
};
return {
JSON,
2024-11-27 16:42:25 +08:00
pack: $,
unpack: _
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);
var D, j, I, R, Y, Q, K, W, X;
class ee {
constructor(e, t, n, s, f) {
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 }
2024-11-27 16:42:25 +08:00
E(this, D, null);
2024-04-04 11:47:06 +08:00
// 判断返回 Response 对象, 还是 Response 中的 data
2024-11-27 16:42:25 +08:00
E(this, j, !0);
2024-04-04 11:47:06 +08:00
// 判罚是否已经给出错误提示
2024-11-27 16:42:25 +08:00
E(this, I, !0);
E(this, R, {
get: (e, t) => o(this, Y).call(this, t),
ownKeys: () => Object.keys(o(this, R).getPrototypeOf() || {}),
getPrototypeOf: () => o(this, j) ? this : this.data,
2024-04-04 11:47:06 +08:00
getOwnPropertyDescriptor: () => ({
configurable: !0,
enumerable: !0,
writable: !0,
2024-11-27 16:42:25 +08:00
value: o(this, R).getPrototypeOf()
2024-04-04 11:47:06 +08:00
})
});
2024-11-27 16:42:25 +08:00
E(this, Y, (e) => e === "$echoMsg" ? o(this, K) : e === "msg" ? o(this, Q) : e === "then" || e === "resp" ? (C(this, I, !0), C(this, j, e === "resp"), o(this, W)) : e === "catch" ? o(this, X) : e === "IS_ECHO_MSG" ? o(this, I) : Reflect.get(this, e));
E(this, Q, (e = (n) => n, t = !1) => (o(this, K).call(this), C(this, j, t), Promise.resolve(e == null ? void 0 : e(o(this, R).getPrototypeOf()))));
E(this, K, () => {
o(this, I) && (C(this, I, !1), Te.onMsg(this.code, this.message));
2024-04-04 11:47:06 +08:00
});
2024-11-27 16:42:25 +08:00
E(this, W, (e) => [0, 1].includes(this.code) ? Promise.resolve(e == null ? void 0 : e(o(this, R).getPrototypeOf())) : Promise.reject(o(this, D)));
E(this, X, (e) => Promise.resolve(e(o(this, D))));
return this.code = e, this.message = t, this.data = n, this.url = s, this.res = f, C(this, D, new Proxy(this, o(this, R)));
2024-04-04 11:47:06 +08:00
}
}
2024-11-27 16:42:25 +08:00
D = new WeakMap(), j = new WeakMap(), I = new WeakMap(), R = new WeakMap(), Y = new WeakMap(), Q = new WeakMap(), K = new WeakMap(), W = new WeakMap(), X = new WeakMap();
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"
];
2024-11-27 16:42:25 +08:00
function ue(r) {
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("");
for (let f = 0; f < s.length; f++)
n[f] = s[f].charCodeAt(0);
return n;
2024-04-04 11:47:06 +08:00
};
}
2024-11-27 16:42:25 +08:00
function fe(r) {
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)) {
2024-11-27 16:42:25 +08:00
var s = new Uint8Array(e.buffer, e.byteOffset, e.byteLength), f = new Array(s.length);
for (let h = 0; h < s.length; h++)
f[h] = String.fromCharCode(s[h]);
return decodeURIComponent(escape(f.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 = {
TextEncoder: ue,
TextDecoder: fe
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);
2024-11-27 16:42:25 +08:00
}, xe = (r, e) => r.replace(new RegExp(`^${e}+|${e}+$`, "g"), ""), ve = (r) => de.encode(r || ""), Se = (r) => ge.decode(new DataView(r), {}), we = 62, V = 30, se = 31, ye = 63;
class be {
constructor(e) {
v(this, "encodeTable", []);
v(this, "decodeMap", new Uint8Array(256).fill(255));
if (e.length !== we)
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 [];
const t = new Ee(this).encodeV2(e);
return String.fromCharCode(...t);
}
// 解码方法
decode(e) {
if (!e || e.length === 0)
return new Uint8Array();
const t = new Oe(this).decode(e);
return new TextDecoder().decode(t);
}
}
var G;
class Ee {
constructor(e) {
E(this, G, null);
C(this, G, e);
}
get6bits() {
let e = this.pos & 7, t = this.pos >> 3;
e === 0 && (t -= 1, e = 8);
let n = this.src[t] >> 8 - e;
return e < 6 && t > 0 && (n |= this.src[t - 1] << e), n & ye;
}
encodeV2(e) {
this.src = ve(e), this.pos = this.src.length * 8;
const t = [];
for (; this.pos > 0; ) {
let n = 6, s = this.get6bits();
(s & V) === V && ((this.pos > 6 || s > se) && (n = 5), s &= se), t.push(o(this, G).encodeTable[s].charCodeAt(0)), this.pos -= n;
}
return t;
}
}
G = new WeakMap();
var H;
class Oe {
constructor(e) {
E(this, H, null);
C(this, H, e);
}
decode(e) {
const t = new Uint8Array(Math.ceil(e.length * 6 / 8) + 1);
let n = t.length, s = 0, f = 0;
for (let h = 0; h < e.length; h++) {
const $ = e[h].charCodeAt(0), _ = o(this, H).decodeMap[$];
if (_ === 255)
throw new Error(`CorruptInputError at index ${h}`);
h === e.length - 1 ? (f |= _ << s, s += Math.ceil(Math.log2(_ + 1))) : (_ & V) === V ? (f |= _ << s, s += 5) : (f |= _ << s, s += 6), s >= 8 && (n--, t[n] = f & 255, s %= 8, f >>= 8);
}
return s > 0 && (n--, t[n] = f & 255), t.slice(n);
}
}
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 };
});
2024-11-27 16:42:25 +08:00
var L, B, Z, m, N;
class te {
constructor(e, t, n = ({}) => Promise.reject({ code: -1, msg: "请初始化HTTP请求方法主体" })) {
E(this, L, void 0);
E(this, B, void 0);
E(this, Z, void 0);
E(this, m, {
2024-04-04 11:47:06 +08:00
"#": /* @__PURE__ */ new Map(),
// 系统缓存
$: /* @__PURE__ */ new Map()
// 普通缓存
});
2024-11-27 16:42:25 +08:00
E(this, N, /* @__PURE__ */ new Map());
v(this, "request", ({ url: e = "/", method: t = "GET", ...n }, s = !1) => {
var U, J;
const f = t.toUpperCase(), h = pe(JSON.stringify([e, f, n])), $ = (U = e == null ? void 0 : e.includes) != null && U.call(e, "/_/") ? "#" : "$", { promise: _, resolve: q, reject: z } = Promise.withResolvers();
return o(this, m)[$].has(h) ? (console.log("缓存命中", e), q(o(this, m)[$].get(h))) : (o(this, N).has(h) ? o(this, N).get(h).push([q, z]) : o(this, N).set(h, [[q, z]]), (J = o(this, N).get(h)) != null && J.some((u) => u) && o(this, L).call(this, { url: e, method: f, ...n }).then((u) => {
if (![0, 1].includes(u.code))
throw k(u.code, u.msg, u.data, e, u == null ? void 0 : u.res);
return [u.code, u.msg, u.data, e, u == null ? void 0 : u.res];
}).then((u) => (($ == "#" || s && f === "GET") && o(this, m)[$].set(h, u), u)).then((u) => {
var a;
return (a = o(this, N).get(h)) == null ? void 0 : a.forEach((c, l, d) => {
c && c[0](u), delete d[l];
2024-05-28 11:41:59 +08:00
});
2024-11-27 16:42:25 +08:00
}).catch((u) => {
var a;
o(this, m)[$].delete(h), (a = o(this, N).get(h)) == null || a.forEach((c, l, d) => {
c && c[1](u instanceof ee ? u : k(-1, u, null, e)), delete d[l];
2024-05-25 22:42:00 +08:00
});
2024-11-27 16:42:25 +08:00
}).finally(() => o(this, N).delete(h))), new Proxy(_, {
get: (u, a) => (...c) => u.then((l) => k(...l)[a](...c)).catch((l) => {
if (!l instanceof ee)
throw l;
return typeof l[a] == "function" ? l[a](...c) : l[a];
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) => {
e && o(this, m)["#"].clear(), o(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 {
2024-11-27 16:42:25 +08:00
const n = o(this, B).decode(e);
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);
return o(this, B).encode(ne.pack(t));
2024-04-04 11:47:06 +08:00
});
2024-11-27 16:42:25 +08:00
C(this, Z, e), C(this, L, n), C(this, B, new be(t));
2024-04-04 11:47:06 +08:00
}
}
2024-11-27 16:42:25 +08:00
L = new WeakMap(), B = new WeakMap(), Z = new WeakMap(), m = new WeakMap(), N = new WeakMap();
const Te = te;
te.onUnhandledRejection = (r) => {
var e, t, n, s, f, h;
r != null && r.IS_ECHO_MSG ? ((e = r == null ? void 0 : r.$echoMsg) == null || e.call(r), (t = r == null ? void 0 : r.preventDefault) == null || t.call(r)) : (n = r.reason) != null && n.IS_ECHO_MSG && ((f = (s = r.reason) == null ? void 0 : s.$echoMsg) == null || f.call(s), (h = r == null ? void 0 : r.preventDefault) == null || h.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 {
2024-11-27 16:42:25 +08:00
Te as default,
pe as signature,
2024-07-23 11:16:38 +08:00
ve as str2uint8array,
2024-11-27 16:42:25 +08:00
xe as trim,
Se as uint8array2str
2024-04-04 11:47:06 +08:00
};