This commit is contained in:
what 2025-01-03 17:37:03 +08:00
parent 550ac157dd
commit 976818ed46
3 changed files with 55 additions and 54 deletions

103
dist/ff-request.js vendored
View File

@ -20,7 +20,7 @@ var oe = {};
o = o || {}; o = o || {};
var d = o.verbose || !1; 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"); d && console.log("Normalize the JSON Object"), h = typeof h == "string" ? this.JSON.parse(h) : h, d && console.log("Creating a empty dictionary");
var f = { var u = {
strings: [], strings: [],
integers: [], integers: [],
floats: [] floats: []
@ -57,22 +57,22 @@ var oe = {};
index: c index: c
}; };
if (w === "string") { if (w === "string") {
var O = T.call(f.strings, a); var O = T.call(u.strings, a);
return O == -1 && (f.strings.push(G(a)), O = f.strings.length - 1), { return O == -1 && (u.strings.push(G(a)), O = u.strings.length - 1), {
type: "strings", type: "strings",
index: O index: O
}; };
} }
if (w === "number" && a % 1 === 0) { if (w === "number" && a % 1 === 0) {
var O = T.call(f.integers, a); var O = T.call(u.integers, a);
return O == -1 && (f.integers.push(F(a)), O = f.integers.length - 1), { return O == -1 && (u.integers.push(F(a)), O = u.integers.length - 1), {
type: "integers", type: "integers",
index: O index: O
}; };
} }
if (w === "number") { if (w === "number") {
var O = T.call(f.floats, a); var O = T.call(u.floats, a);
return O == -1 && (f.floats.push(a), O = f.floats.length - 1), { return O == -1 && (u.floats.push(a), O = u.floats.length - 1), {
type: "floats", type: "floats",
index: O index: O
}; };
@ -83,10 +83,10 @@ var oe = {};
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);
}(h), b = f.strings.length, I = f.integers.length; }(h), b = u.strings.length, I = u.integers.length;
f.floats.length, d && console.log("Parsing the dictionary"); u.floats.length, d && console.log("Parsing the dictionary");
var N = f.strings.join("|"); var N = u.strings.join("|");
return N += "^" + f.integers.join("|"), N += "^" + f.floats.join("|"), d && console.log("Parsing the structure"), N += "^" + function P(a) { return N += "^" + u.integers.join("|"), N += "^" + u.floats.join("|"), d && console.log("Parsing the structure"), N += "^" + function P(a) {
if (d && console.log("Calling a recursiveParser with " + this.JSON.stringify(a)), a instanceof Array) { if (d && console.log("Calling a recursiveParser with " + this.JSON.stringify(a)), a instanceof Array) {
var w = a.shift(); var w = a.shift();
for (var x in a) for (var x in a)
@ -110,7 +110,7 @@ var oe = {};
return c; return c;
throw new TypeError("The item is alien!"); throw new TypeError("The item is alien!");
}(g), d && console.log("Ending parser"), o.debug ? { }(g), d && console.log("Ending parser"), o.debug ? {
dictionary: f, dictionary: u,
ast: g, ast: g,
packed: N packed: N
} : N; } : N;
@ -118,26 +118,26 @@ var oe = {};
o = o || {}; o = o || {};
var d = h.split("^"); var d = h.split("^");
o.verbose && console.log("Building dictionary"); o.verbose && console.log("Building dictionary");
var f = [], g = d[0]; var u = [], g = d[0];
if (g !== "") { if (g !== "") {
g = g.split("|"), o.verbose && console.log("Parse the strings dictionary"); g = g.split("|"), o.verbose && console.log("Parse the strings dictionary");
for (var b = 0, I = g.length; b < I; b++) for (var b = 0, I = g.length; b < I; b++)
f.push(z(g[b])); u.push(z(g[b]));
} }
if (g = d[1], g !== "") { if (g = d[1], g !== "") {
g = g.split("|"), o.verbose && console.log("Parse the integers dictionary"); g = g.split("|"), o.verbose && console.log("Parse the integers dictionary");
for (var b = 0, I = g.length; b < I; b++) for (var b = 0, I = g.length; b < I; b++)
f.push(u(g[b])); u.push(f(g[b]));
} }
if (g = d[2], g !== "") { if (g = d[2], g !== "") {
g = g.split("|"), o.verbose && console.log("Parse the floats dictionary"); g = g.split("|"), o.verbose && console.log("Parse the floats dictionary");
for (var b = 0, I = g.length; b < I; b++) for (var b = 0, I = g.length; b < I; b++)
f.push(parseFloat(g[b])); u.push(parseFloat(g[b]));
} }
g = null, o.verbose && console.log("Tokenizing the structure"); g = null, o.verbose && console.log("Tokenizing the structure");
for (var N = "", P = [], a = d[3].length, b = 0; b < a; b++) { for (var N = "", P = [], a = d[3].length, b = 0; b < a; b++) {
var w = d[3].charAt(b); var w = d[3].charAt(b);
w === "|" || w === "$" || w === "@" || w === "]" ? (N && (P.push(u(N)), N = ""), w !== "|" && P.push(w)) : N += w; w === "|" || w === "$" || w === "@" || w === "]" ? (N && (P.push(f(N)), N = ""), w !== "|" && P.push(w)) : N += w;
} }
var x = P.length, y = 0; var x = P.length, y = 0;
return o.verbose && console.log("Starting recursive parser"), function $() { return o.verbose && console.log("Starting recursive parser"), function $() {
@ -167,7 +167,7 @@ var oe = {};
p.push(""); p.push("");
break; break;
default: default:
p.push(f[_]); p.push(u[_]);
} }
} }
return o.verbose && console.log("Parsed " + this.JSON.stringify(p)), p; return o.verbose && console.log("Parsed " + this.JSON.stringify(p)), p;
@ -177,7 +177,7 @@ var oe = {};
var S = P[y]; var S = P[y];
if (S === "]") if (S === "]")
return p; return p;
S === c ? S = "" : S = f[S]; S === c ? S = "" : S = u[S];
var _ = P[++y]; var _ = P[++y];
if (_ === "@" || _ === "$") if (_ === "@" || _ === "$")
p[S] = $(); p[S] = $();
@ -199,7 +199,7 @@ var oe = {};
p[S] = ""; p[S] = "";
break; break;
default: default:
p[S] = f[_]; p[S] = u[_];
} }
} }
return o.verbose && console.log("Parsed " + this.JSON.stringify(p)), p; return o.verbose && console.log("Parsed " + this.JSON.stringify(p)), p;
@ -228,10 +228,10 @@ var oe = {};
}); });
}, F = function(h) { }, F = function(h) {
return Number.prototype.toString.call(h, 36).toUpperCase(); return Number.prototype.toString.call(h, 36).toUpperCase();
}, u = function(h) { }, f = function(h) {
return parseInt(h, 36); return parseInt(h, 36);
}, T = Array.prototype.indexOf || function(h, o) { }, T = Array.prototype.indexOf || function(h, o) {
for (var d = o || 0, f = this.length; d < f; d++) for (var d = o || 0, u = this.length; d < u; d++)
if (this[d] === h) if (this[d] === h)
return d; return d;
return -1; return -1;
@ -277,7 +277,7 @@ class ee {
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, 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())))); 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()))));
E(this, J, () => { E(this, J, () => {
i(this, D) && (A(this, D, !1), Te.onMsg(this.code, this.message)); i(this, D) && (A(this, D, !1), Pe.onMsg(this.code, this.message));
}); });
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, 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)))); E(this, X, (e) => Promise.resolve(e(i(this, j))));
@ -291,7 +291,7 @@ var ie = [
"utf-8", "utf-8",
"unicode-1-1-utf-8" "unicode-1-1-utf-8"
]; ];
function ue(r) { function fe(r) {
if (ie.indexOf(r) < 0 && typeof r < "u" && r != null) if (ie.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) {
@ -304,7 +304,7 @@ function ue(r) {
return n; return n;
}; };
} }
function fe(r) { function ue(r) {
if (ie.indexOf(r) < 0 && typeof r < "u" && r != null) if (ie.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) {
@ -323,20 +323,20 @@ function fe(r) {
}; };
} }
var ae = { var ae = {
TextEncoder: ue, TextEncoder: fe,
TextDecoder: fe TextDecoder: ue
}; };
const de = new ae.TextEncoder("utf8"), ge = new ae.TextDecoder("utf8"), pe = (r) => { const de = new ae.TextEncoder("utf8"), ge = new ae.TextDecoder("utf8"), pe = (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);
}, 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; }, 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 be { class Ee {
constructor(e) { constructor(e) {
v(this, "encodeTable", []); v(this, "encodeTable", []);
v(this, "decodeMap", new Uint8Array(256).fill(255)); v(this, "decodeMap", new Uint8Array(256).fill(255));
if (e.length !== we) if (e.length !== ye)
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"))
@ -349,19 +349,19 @@ class be {
encode(e) { encode(e) {
if (!e || e.length === 0) if (!e || e.length === 0)
return []; return [];
const t = new Ee(this).encodeV2(e); const t = new Oe(this).encodeV2(e);
return String.fromCharCode(...t); return String.fromCharCode(...t);
} }
// 解码方法 // 解码方法
decode(e) { decode(e) {
if (!e || e.length === 0) if (!e || e.length === 0)
return new Uint8Array(); return new Uint8Array();
const t = new Oe(this).decode(e); const t = new Te(this).decode(e);
return new TextDecoder().decode(t); return new TextDecoder().decode(t);
} }
} }
var K; var K;
class Ee { class Oe {
constructor(e) { constructor(e) {
E(this, K, null); E(this, K, null);
A(this, K, e); A(this, K, e);
@ -370,10 +370,10 @@ class Ee {
let e = this.pos & 7, t = this.pos >> 3; let e = this.pos & 7, t = this.pos >> 3;
e === 0 && (t -= 1, e = 8); e === 0 && (t -= 1, e = 8);
let n = this.src[t] >> 8 - e; let n = this.src[t] >> 8 - e;
return e < 6 && t > 0 && (n |= this.src[t - 1] << e), n & ye; return e < 6 && t > 0 && (n |= this.src[t - 1] << e), n & be;
} }
encodeV2(e) { encodeV2(e) {
this.src = ve(e), this.pos = this.src.length * 8; this.src = we(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, s = this.get6bits();
@ -384,7 +384,7 @@ class Ee {
} }
K = new WeakMap(); K = new WeakMap();
var H; var H;
class Oe { class Te {
constructor(e) { constructor(e) {
E(this, H, null); E(this, H, null);
A(this, H, e); A(this, H, e);
@ -423,25 +423,26 @@ class te {
E(this, R, /* @__PURE__ */ new Map()); E(this, R, /* @__PURE__ */ new Map());
v(this, "request", ({ url: e = "/", method: t = "GET", ...n }, s = !1) => { v(this, "request", ({ url: e = "/", method: t = "GET", ...n }, s = !1) => {
var F; var F;
e = ve(e, "/");
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(); 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();
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((u) => { 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(u.code)) if (![0, 1].includes(f.code))
throw k(u.code, u.msg, u.data, e, u == null ? void 0 : u.res); throw k(f.code, f.msg, f.data, e, f == null ? void 0 : f.res);
return [u.code, u.msg, u.data, e, u == null ? void 0 : u.res]; return [f.code, f.msg, f.data, e, f == null ? void 0 : f.res];
}).then((u) => ((C == "#" || c == "GET") && i(this, m)[C].set(l, u), C != "#" && c == "GET" && !s && setTimeout(() => { }).then((f) => ((C == "#" || c == "GET") && i(this, m)[C].set(l, f), C != "#" && c == "GET" && !s && setTimeout(() => {
i(this, m)[C].delete(l); i(this, m)[C].delete(l);
}, 300), u)).then((u) => { }, 300), f)).then((f) => {
var T; var T;
return (T = i(this, R).get(l)) == null ? void 0 : T.forEach((h, o, d) => { return (T = i(this, R).get(l)) == null ? void 0 : T.forEach((h, o, d) => {
h && h[0](u), delete d[o]; h && h[0](f), delete d[o];
}); });
}).catch((u) => { }).catch((f) => {
var T; var T;
i(this, m)[C].delete(l), (T = i(this, R).get(l)) == null || T.forEach((h, o, d) => { i(this, m)[C].delete(l), (T = i(this, R).get(l)) == null || T.forEach((h, o, d) => {
h && h[1](u instanceof ee ? u : k(-1, u, null, e)), delete d[o]; h && h[1](f instanceof ee ? f : k(-1, f, null, e)), delete d[o];
}); });
}).finally(() => i(this, R).delete(l))), new Proxy(M, { }).finally(() => i(this, R).delete(l))), new Proxy(M, {
get: (u, T) => (...h) => u.then((o) => k(...o)[T](...h)).catch((o) => { get: (f, T) => (...h) => f.then((o) => k(...o)[T](...h)).catch((o) => {
if (!o instanceof ee) if (!o instanceof ee)
throw o; throw o;
return typeof o[T] == "function" ? o[T](...h) : o[T]; return typeof o[T] == "function" ? o[T](...h) : o[T];
@ -475,20 +476,20 @@ class te {
const t = JSON.stringify(e, (n, s) => s === void 0 ? null : s); const t = JSON.stringify(e, (n, s) => s === void 0 ? null : s);
return i(this, q).encode(ne.pack(t)); return i(this, q).encode(ne.pack(t));
}); });
A(this, Z, e), A(this, L, n), A(this, q, new be(t)); A(this, Z, e), A(this, L, n), A(this, q, new Ee(t));
} }
} }
L = new WeakMap(), q = new WeakMap(), Z = new WeakMap(), m = new WeakMap(), R = new WeakMap(); L = new WeakMap(), q = new WeakMap(), Z = new WeakMap(), m = new WeakMap(), R = new WeakMap();
const Te = te; const Pe = te;
te.onUnhandledRejection = (r) => { te.onUnhandledRejection = (r) => {
var e, t, n, s, c, l; 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)); 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));
}; };
te.onMsg = (r, e) => [0, 1].includes(r) ? console.log(e) : console.warn(e); te.onMsg = (r, e) => [0, 1].includes(r) ? console.log(e) : console.warn(e);
export { export {
Te as default, Pe as default,
pe as signature, pe as signature,
ve as str2uint8array, we as str2uint8array,
xe as trim, ve as trim,
Se as uint8array2str Se as uint8array2str
}; };

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,7 @@
{ {
"name": "ff-request", "name": "ff-request",
"private": true, "private": true,
"version": "0.9.15", "version": "0.9.16",
"type": "module", "type": "module",
"files": [ "files": [
"dist" "dist"