@synnaxlabs/x 0.41.0 → 0.42.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +23 -23
- package/dist/binary.cjs +1 -1
- package/dist/binary.js +2 -2
- package/dist/{bounds-M-SZ3X1Z.cjs → bounds-BQo7rvs9.cjs} +1 -1
- package/dist/{bounds-DQrjn60Q.js → bounds-Bn5_l4Z3.js} +10 -9
- package/dist/bounds.cjs +1 -1
- package/dist/bounds.js +1 -1
- package/dist/compare.cjs +1 -1
- package/dist/compare.js +1 -1
- package/dist/deep.cjs +1 -1
- package/dist/deep.js +66 -69
- package/dist/{dimensions-PWy5QZoM.cjs → dimensions-D2QGoNXO.cjs} +1 -1
- package/dist/dimensions.cjs +1 -1
- package/dist/{external-CvWr1nhS.cjs → external-DWQITF5_.cjs} +1 -1
- package/dist/index-BywOGO8U.js +1074 -0
- package/dist/index-CYYjI7Uf.cjs +1 -0
- package/dist/index-C_6NXBlg.cjs +3 -0
- package/dist/{index-BVC_8Cg9.js → index-QGplUHuy.js} +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.js +702 -243
- package/dist/record.js +3 -1
- package/dist/{scale-DL9VFGhL.cjs → scale-BtZINJ-A.cjs} +1 -1
- package/dist/{scale-DQwBWnwc.js → scale-DfJe9755.js} +1 -1
- package/dist/scale.cjs +1 -1
- package/dist/scale.js +1 -1
- package/dist/{series-D0zxMWxP.js → series-B9JERcqi.js} +571 -492
- package/dist/series-DqJ6f97G.cjs +11 -0
- package/dist/spatial.cjs +1 -1
- package/dist/spatial.js +2 -2
- package/dist/src/binary/{encoder.d.ts → codec.d.ts} +14 -8
- package/dist/src/binary/codec.d.ts.map +1 -0
- package/dist/src/binary/codec.spec.d.ts +2 -0
- package/dist/src/binary/codec.spec.d.ts.map +1 -0
- package/dist/src/binary/index.d.ts +1 -1
- package/dist/src/binary/index.d.ts.map +1 -1
- package/dist/src/breaker/breaker.d.ts +14 -21
- package/dist/src/breaker/breaker.d.ts.map +1 -1
- package/dist/src/change/change.d.ts +5 -18
- package/dist/src/change/change.d.ts.map +1 -1
- package/dist/src/color/color.d.ts +126 -0
- package/dist/src/color/color.d.ts.map +1 -0
- package/dist/src/color/color.spec.d.ts +2 -0
- package/dist/src/color/color.spec.d.ts.map +1 -0
- package/dist/src/color/external.d.ts +5 -0
- package/dist/src/color/external.d.ts.map +1 -0
- package/dist/src/color/gradient.d.ts +18 -0
- package/dist/src/color/gradient.d.ts.map +1 -0
- package/dist/src/color/index.d.ts +2 -0
- package/dist/src/color/index.d.ts.map +1 -0
- package/dist/src/color/palette.d.ts +19 -0
- package/dist/src/color/palette.d.ts.map +1 -0
- package/dist/src/color/transformColorsToHex.d.ts +6 -0
- package/dist/src/color/transformColorsToHex.d.ts.map +1 -0
- package/dist/src/control/control.d.ts +69 -74
- package/dist/src/control/control.d.ts.map +1 -1
- package/dist/src/deep/merge.d.ts +1 -1
- package/dist/src/deep/merge.d.ts.map +1 -1
- package/dist/src/errors/errors.d.ts +127 -7
- package/dist/src/errors/errors.d.ts.map +1 -1
- package/dist/src/errors/errors.spec.d.ts +2 -0
- package/dist/src/errors/errors.spec.d.ts.map +1 -0
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/jsonrpc/jsonrpc.d.ts +10 -7
- package/dist/src/jsonrpc/jsonrpc.d.ts.map +1 -1
- package/dist/src/kv/types.d.ts +1 -7
- package/dist/src/kv/types.d.ts.map +1 -1
- package/dist/src/migrate/migrate.d.ts +1 -1
- package/dist/src/notation/notation.d.ts +5 -1
- package/dist/src/notation/notation.d.ts.map +1 -1
- package/dist/src/record.d.ts +2 -1
- package/dist/src/record.d.ts.map +1 -1
- package/dist/src/replace.d.ts +2 -0
- package/dist/src/replace.d.ts.map +1 -0
- package/dist/src/runtime/os.d.ts +9 -1
- package/dist/src/runtime/os.d.ts.map +1 -1
- package/dist/src/singleton/define.d.ts +9 -0
- package/dist/src/singleton/define.d.ts.map +1 -0
- package/dist/src/singleton/define.spec.d.ts +2 -0
- package/dist/src/singleton/define.spec.d.ts.map +1 -0
- package/dist/src/singleton/index.d.ts +2 -0
- package/dist/src/singleton/index.d.ts.map +1 -0
- package/dist/src/spatial/base.d.ts +74 -70
- package/dist/src/spatial/base.d.ts.map +1 -1
- package/dist/src/spatial/box/box.d.ts +18 -76
- package/dist/src/spatial/box/box.d.ts.map +1 -1
- package/dist/src/spatial/dimensions/dimensions.d.ts +5 -29
- package/dist/src/spatial/dimensions/dimensions.d.ts.map +1 -1
- package/dist/src/spatial/direction/direction.d.ts +9 -1
- package/dist/src/spatial/direction/direction.d.ts.map +1 -1
- package/dist/src/spatial/location/location.d.ts +43 -22
- package/dist/src/spatial/location/location.d.ts.map +1 -1
- package/dist/src/spatial/scale/scale.d.ts +12 -120
- package/dist/src/spatial/scale/scale.d.ts.map +1 -1
- package/dist/src/spatial/xy/xy.d.ts +5 -29
- package/dist/src/spatial/xy/xy.d.ts.map +1 -1
- package/dist/src/sync/index.d.ts +2 -0
- package/dist/src/sync/index.d.ts.map +1 -0
- package/dist/src/sync/mutex.d.ts +8 -0
- package/dist/src/sync/mutex.d.ts.map +1 -0
- package/dist/src/telem/gl.d.ts +4 -1
- package/dist/src/telem/gl.d.ts.map +1 -1
- package/dist/src/telem/series.d.ts +46 -125
- package/dist/src/telem/series.d.ts.map +1 -1
- package/dist/src/telem/telem.d.ts +101 -86
- package/dist/src/telem/telem.d.ts.map +1 -1
- package/dist/src/toArray.d.ts +1 -1
- package/dist/src/toArray.d.ts.map +1 -1
- package/dist/src/zod/util.d.ts.map +1 -1
- package/dist/telem.cjs +1 -1
- package/dist/telem.js +1 -1
- package/dist/toArray.cjs +1 -1
- package/dist/toArray.js +1 -1
- package/dist/zod.cjs +1 -1
- package/package.json +7 -4
- package/src/binary/codec.spec.ts +370 -0
- package/src/binary/{encoder.ts → codec.ts} +55 -11
- package/src/binary/index.ts +1 -1
- package/src/breaker/breaker.spec.ts +16 -25
- package/src/breaker/breaker.ts +36 -19
- package/src/color/color.spec.ts +673 -0
- package/src/color/color.ts +317 -0
- package/src/color/external.ts +13 -0
- package/src/color/gradient.ts +78 -0
- package/src/color/index.ts +10 -0
- package/src/color/palette.ts +28 -0
- package/src/color/transformColorsToHex.ts +30 -0
- package/src/control/control.ts +30 -22
- package/src/deep/merge.ts +2 -8
- package/src/errors/errors.spec.ts +152 -0
- package/src/errors/errors.ts +225 -10
- package/src/index.ts +4 -0
- package/src/jsonrpc/jsonrpc.ts +12 -8
- package/src/migrate/migrate.ts +2 -2
- package/src/primitive.ts +1 -1
- package/src/record.ts +5 -1
- package/src/replace.ts +1 -0
- package/src/singleton/define.spec.ts +93 -0
- package/src/singleton/define.ts +27 -0
- package/src/singleton/index.ts +10 -0
- package/src/sync/index.ts +1 -0
- package/src/sync/mutex.ts +16 -0
- package/src/telem/series.spec.ts +32 -0
- package/src/telem/series.ts +54 -19
- package/src/telem/telem.spec.ts +151 -10
- package/src/telem/telem.ts +126 -73
- package/src/toArray.ts +2 -2
- package/src/zod/util.spec.ts +17 -1
- package/src/zod/util.ts +4 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/index-BG3Scw3G.cjs +0 -1
- package/dist/index-C3QzbIwt.js +0 -101
- package/dist/index-CnclyYpG.cjs +0 -3
- package/dist/series-BMma2b5q.cjs +0 -11
- package/dist/src/binary/encoder.d.ts.map +0 -1
- package/dist/src/binary/encoder.spec.d.ts +0 -2
- package/dist/src/binary/encoder.spec.d.ts.map +0 -1
- package/src/binary/encoder.spec.ts +0 -174
|
@@ -0,0 +1,1074 @@
|
|
|
1
|
+
var H = Object.defineProperty;
|
|
2
|
+
var K = (n, e, t) => e in n ? H(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
|
|
3
|
+
var u = (n, e, t) => K(n, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { s as D, b as z } from "./index-DizUWH6z.js";
|
|
5
|
+
import { isObject as T } from "./identity.js";
|
|
6
|
+
function N(n) {
|
|
7
|
+
const e = n.length;
|
|
8
|
+
let t = 0, s = 0;
|
|
9
|
+
for (; s < e; ) {
|
|
10
|
+
let i = n.charCodeAt(s++);
|
|
11
|
+
if ((i & 4294967168) === 0) {
|
|
12
|
+
t++;
|
|
13
|
+
continue;
|
|
14
|
+
} else if ((i & 4294965248) === 0)
|
|
15
|
+
t += 2;
|
|
16
|
+
else {
|
|
17
|
+
if (i >= 55296 && i <= 56319 && s < e) {
|
|
18
|
+
const r = n.charCodeAt(s);
|
|
19
|
+
(r & 64512) === 56320 && (++s, i = ((i & 1023) << 10) + (r & 1023) + 65536);
|
|
20
|
+
}
|
|
21
|
+
(i & 4294901760) === 0 ? t += 3 : t += 4;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return t;
|
|
25
|
+
}
|
|
26
|
+
function V(n, e, t) {
|
|
27
|
+
const s = n.length;
|
|
28
|
+
let i = t, r = 0;
|
|
29
|
+
for (; r < s; ) {
|
|
30
|
+
let o = n.charCodeAt(r++);
|
|
31
|
+
if ((o & 4294967168) === 0) {
|
|
32
|
+
e[i++] = o;
|
|
33
|
+
continue;
|
|
34
|
+
} else if ((o & 4294965248) === 0)
|
|
35
|
+
e[i++] = o >> 6 & 31 | 192;
|
|
36
|
+
else {
|
|
37
|
+
if (o >= 55296 && o <= 56319 && r < s) {
|
|
38
|
+
const h = n.charCodeAt(r);
|
|
39
|
+
(h & 64512) === 56320 && (++r, o = ((o & 1023) << 10) + (h & 1023) + 65536);
|
|
40
|
+
}
|
|
41
|
+
(o & 4294901760) === 0 ? (e[i++] = o >> 12 & 15 | 224, e[i++] = o >> 6 & 63 | 128) : (e[i++] = o >> 18 & 7 | 240, e[i++] = o >> 12 & 63 | 128, e[i++] = o >> 6 & 63 | 128);
|
|
42
|
+
}
|
|
43
|
+
e[i++] = o & 63 | 128;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
const W = new TextEncoder(), O = 50;
|
|
47
|
+
function X(n, e, t) {
|
|
48
|
+
W.encodeInto(n, e.subarray(t));
|
|
49
|
+
}
|
|
50
|
+
function J(n, e, t) {
|
|
51
|
+
n.length > O ? X(n, e, t) : V(n, e, t);
|
|
52
|
+
}
|
|
53
|
+
const Y = 4096;
|
|
54
|
+
function v(n, e, t) {
|
|
55
|
+
let s = e;
|
|
56
|
+
const i = s + t, r = [];
|
|
57
|
+
let o = "";
|
|
58
|
+
for (; s < i; ) {
|
|
59
|
+
const h = n[s++];
|
|
60
|
+
if ((h & 128) === 0)
|
|
61
|
+
r.push(h);
|
|
62
|
+
else if ((h & 224) === 192) {
|
|
63
|
+
const a = n[s++] & 63;
|
|
64
|
+
r.push((h & 31) << 6 | a);
|
|
65
|
+
} else if ((h & 240) === 224) {
|
|
66
|
+
const a = n[s++] & 63, l = n[s++] & 63;
|
|
67
|
+
r.push((h & 31) << 12 | a << 6 | l);
|
|
68
|
+
} else if ((h & 248) === 240) {
|
|
69
|
+
const a = n[s++] & 63, l = n[s++] & 63, S = n[s++] & 63;
|
|
70
|
+
let d = (h & 7) << 18 | a << 12 | l << 6 | S;
|
|
71
|
+
d > 65535 && (d -= 65536, r.push(d >>> 10 & 1023 | 55296), d = 56320 | d & 1023), r.push(d);
|
|
72
|
+
} else
|
|
73
|
+
r.push(h);
|
|
74
|
+
r.length >= Y && (o += String.fromCharCode(...r), r.length = 0);
|
|
75
|
+
}
|
|
76
|
+
return r.length > 0 && (o += String.fromCharCode(...r)), o;
|
|
77
|
+
}
|
|
78
|
+
const G = new TextDecoder(), q = 200;
|
|
79
|
+
function Z(n, e, t) {
|
|
80
|
+
const s = n.subarray(e, e + t);
|
|
81
|
+
return G.decode(s);
|
|
82
|
+
}
|
|
83
|
+
function Q(n, e, t) {
|
|
84
|
+
return t > q ? Z(n, e, t) : v(n, e, t);
|
|
85
|
+
}
|
|
86
|
+
class p {
|
|
87
|
+
constructor(e, t) {
|
|
88
|
+
this.type = e, this.data = t;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
class c extends Error {
|
|
92
|
+
constructor(e) {
|
|
93
|
+
super(e);
|
|
94
|
+
const t = Object.create(c.prototype);
|
|
95
|
+
Object.setPrototypeOf(this, t), Object.defineProperty(this, "name", {
|
|
96
|
+
configurable: !0,
|
|
97
|
+
enumerable: !1,
|
|
98
|
+
value: c.name
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
const x = 4294967295;
|
|
103
|
+
function j(n, e, t) {
|
|
104
|
+
const s = t / 4294967296, i = t;
|
|
105
|
+
n.setUint32(e, s), n.setUint32(e + 4, i);
|
|
106
|
+
}
|
|
107
|
+
function M(n, e, t) {
|
|
108
|
+
const s = Math.floor(t / 4294967296), i = t;
|
|
109
|
+
n.setUint32(e, s), n.setUint32(e + 4, i);
|
|
110
|
+
}
|
|
111
|
+
function _(n, e) {
|
|
112
|
+
const t = n.getInt32(e), s = n.getUint32(e + 4);
|
|
113
|
+
return t * 4294967296 + s;
|
|
114
|
+
}
|
|
115
|
+
function ee(n, e) {
|
|
116
|
+
const t = n.getUint32(e), s = n.getUint32(e + 4);
|
|
117
|
+
return t * 4294967296 + s;
|
|
118
|
+
}
|
|
119
|
+
const te = -1, ie = 4294967296 - 1, se = 17179869184 - 1;
|
|
120
|
+
function ne({ sec: n, nsec: e }) {
|
|
121
|
+
if (n >= 0 && e >= 0 && n <= se)
|
|
122
|
+
if (e === 0 && n <= ie) {
|
|
123
|
+
const t = new Uint8Array(4);
|
|
124
|
+
return new DataView(t.buffer).setUint32(0, n), t;
|
|
125
|
+
} else {
|
|
126
|
+
const t = n / 4294967296, s = n & 4294967295, i = new Uint8Array(8), r = new DataView(i.buffer);
|
|
127
|
+
return r.setUint32(0, e << 2 | t & 3), r.setUint32(4, s), i;
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
const t = new Uint8Array(12), s = new DataView(t.buffer);
|
|
131
|
+
return s.setUint32(0, e), M(s, 4, n), t;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
function re(n) {
|
|
135
|
+
const e = n.getTime(), t = Math.floor(e / 1e3), s = (e - t * 1e3) * 1e6, i = Math.floor(s / 1e9);
|
|
136
|
+
return {
|
|
137
|
+
sec: t + i,
|
|
138
|
+
nsec: s - i * 1e9
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
function oe(n) {
|
|
142
|
+
if (n instanceof Date) {
|
|
143
|
+
const e = re(n);
|
|
144
|
+
return ne(e);
|
|
145
|
+
} else
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
function he(n) {
|
|
149
|
+
const e = new DataView(n.buffer, n.byteOffset, n.byteLength);
|
|
150
|
+
switch (n.byteLength) {
|
|
151
|
+
case 4:
|
|
152
|
+
return { sec: e.getUint32(0), nsec: 0 };
|
|
153
|
+
case 8: {
|
|
154
|
+
const t = e.getUint32(0), s = e.getUint32(4), i = (t & 3) * 4294967296 + s, r = t >>> 2;
|
|
155
|
+
return { sec: i, nsec: r };
|
|
156
|
+
}
|
|
157
|
+
case 12: {
|
|
158
|
+
const t = _(e, 4), s = e.getUint32(0);
|
|
159
|
+
return { sec: t, nsec: s };
|
|
160
|
+
}
|
|
161
|
+
default:
|
|
162
|
+
throw new c(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${n.length}`);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
function ce(n) {
|
|
166
|
+
const e = he(n);
|
|
167
|
+
return new Date(e.sec * 1e3 + e.nsec / 1e6);
|
|
168
|
+
}
|
|
169
|
+
const ae = {
|
|
170
|
+
type: te,
|
|
171
|
+
encode: oe,
|
|
172
|
+
decode: ce
|
|
173
|
+
};
|
|
174
|
+
class U {
|
|
175
|
+
constructor() {
|
|
176
|
+
this.builtInEncoders = [], this.builtInDecoders = [], this.encoders = [], this.decoders = [], this.register(ae);
|
|
177
|
+
}
|
|
178
|
+
register({ type: e, encode: t, decode: s }) {
|
|
179
|
+
if (e >= 0)
|
|
180
|
+
this.encoders[e] = t, this.decoders[e] = s;
|
|
181
|
+
else {
|
|
182
|
+
const i = -1 - e;
|
|
183
|
+
this.builtInEncoders[i] = t, this.builtInDecoders[i] = s;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
tryToEncode(e, t) {
|
|
187
|
+
for (let s = 0; s < this.builtInEncoders.length; s++) {
|
|
188
|
+
const i = this.builtInEncoders[s];
|
|
189
|
+
if (i != null) {
|
|
190
|
+
const r = i(e, t);
|
|
191
|
+
if (r != null) {
|
|
192
|
+
const o = -1 - s;
|
|
193
|
+
return new p(o, r);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
for (let s = 0; s < this.encoders.length; s++) {
|
|
198
|
+
const i = this.encoders[s];
|
|
199
|
+
if (i != null) {
|
|
200
|
+
const r = i(e, t);
|
|
201
|
+
if (r != null) {
|
|
202
|
+
const o = s;
|
|
203
|
+
return new p(o, r);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
return e instanceof p ? e : null;
|
|
208
|
+
}
|
|
209
|
+
decode(e, t, s) {
|
|
210
|
+
const i = t < 0 ? this.builtInDecoders[-1 - t] : this.decoders[t];
|
|
211
|
+
return i ? i(e, t, s) : new p(t, e);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
U.defaultCodec = new U();
|
|
215
|
+
function de(n) {
|
|
216
|
+
return n instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && n instanceof SharedArrayBuffer;
|
|
217
|
+
}
|
|
218
|
+
function E(n) {
|
|
219
|
+
return n instanceof Uint8Array ? n : ArrayBuffer.isView(n) ? new Uint8Array(n.buffer, n.byteOffset, n.byteLength) : de(n) ? new Uint8Array(n) : Uint8Array.from(n);
|
|
220
|
+
}
|
|
221
|
+
const fe = 100, le = 2048;
|
|
222
|
+
class A {
|
|
223
|
+
constructor(e) {
|
|
224
|
+
this.entered = !1, this.extensionCodec = (e == null ? void 0 : e.extensionCodec) ?? U.defaultCodec, this.context = e == null ? void 0 : e.context, this.useBigInt64 = (e == null ? void 0 : e.useBigInt64) ?? !1, this.maxDepth = (e == null ? void 0 : e.maxDepth) ?? fe, this.initialBufferSize = (e == null ? void 0 : e.initialBufferSize) ?? le, this.sortKeys = (e == null ? void 0 : e.sortKeys) ?? !1, this.forceFloat32 = (e == null ? void 0 : e.forceFloat32) ?? !1, this.ignoreUndefined = (e == null ? void 0 : e.ignoreUndefined) ?? !1, this.forceIntegerToFloat = (e == null ? void 0 : e.forceIntegerToFloat) ?? !1, this.pos = 0, this.view = new DataView(new ArrayBuffer(this.initialBufferSize)), this.bytes = new Uint8Array(this.view.buffer);
|
|
225
|
+
}
|
|
226
|
+
clone() {
|
|
227
|
+
return new A({
|
|
228
|
+
extensionCodec: this.extensionCodec,
|
|
229
|
+
context: this.context,
|
|
230
|
+
useBigInt64: this.useBigInt64,
|
|
231
|
+
maxDepth: this.maxDepth,
|
|
232
|
+
initialBufferSize: this.initialBufferSize,
|
|
233
|
+
sortKeys: this.sortKeys,
|
|
234
|
+
forceFloat32: this.forceFloat32,
|
|
235
|
+
ignoreUndefined: this.ignoreUndefined,
|
|
236
|
+
forceIntegerToFloat: this.forceIntegerToFloat
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
reinitializeState() {
|
|
240
|
+
this.pos = 0;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* This is almost equivalent to {@link Encoder#encode}, but it returns an reference of the encoder's internal buffer and thus much faster than {@link Encoder#encode}.
|
|
244
|
+
*
|
|
245
|
+
* @returns Encodes the object and returns a shared reference the encoder's internal buffer.
|
|
246
|
+
*/
|
|
247
|
+
encodeSharedRef(e) {
|
|
248
|
+
if (this.entered)
|
|
249
|
+
return this.clone().encodeSharedRef(e);
|
|
250
|
+
try {
|
|
251
|
+
return this.entered = !0, this.reinitializeState(), this.doEncode(e, 1), this.bytes.subarray(0, this.pos);
|
|
252
|
+
} finally {
|
|
253
|
+
this.entered = !1;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* @returns Encodes the object and returns a copy of the encoder's internal buffer.
|
|
258
|
+
*/
|
|
259
|
+
encode(e) {
|
|
260
|
+
if (this.entered)
|
|
261
|
+
return this.clone().encode(e);
|
|
262
|
+
try {
|
|
263
|
+
return this.entered = !0, this.reinitializeState(), this.doEncode(e, 1), this.bytes.slice(0, this.pos);
|
|
264
|
+
} finally {
|
|
265
|
+
this.entered = !1;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
doEncode(e, t) {
|
|
269
|
+
if (t > this.maxDepth)
|
|
270
|
+
throw new Error(`Too deep objects in depth ${t}`);
|
|
271
|
+
e == null ? this.encodeNil() : typeof e == "boolean" ? this.encodeBoolean(e) : typeof e == "number" ? this.forceIntegerToFloat ? this.encodeNumberAsFloat(e) : this.encodeNumber(e) : typeof e == "string" ? this.encodeString(e) : this.useBigInt64 && typeof e == "bigint" ? this.encodeBigInt64(e) : this.encodeObject(e, t);
|
|
272
|
+
}
|
|
273
|
+
ensureBufferSizeToWrite(e) {
|
|
274
|
+
const t = this.pos + e;
|
|
275
|
+
this.view.byteLength < t && this.resizeBuffer(t * 2);
|
|
276
|
+
}
|
|
277
|
+
resizeBuffer(e) {
|
|
278
|
+
const t = new ArrayBuffer(e), s = new Uint8Array(t), i = new DataView(t);
|
|
279
|
+
s.set(this.bytes), this.view = i, this.bytes = s;
|
|
280
|
+
}
|
|
281
|
+
encodeNil() {
|
|
282
|
+
this.writeU8(192);
|
|
283
|
+
}
|
|
284
|
+
encodeBoolean(e) {
|
|
285
|
+
e === !1 ? this.writeU8(194) : this.writeU8(195);
|
|
286
|
+
}
|
|
287
|
+
encodeNumber(e) {
|
|
288
|
+
!this.forceIntegerToFloat && Number.isSafeInteger(e) ? e >= 0 ? e < 128 ? this.writeU8(e) : e < 256 ? (this.writeU8(204), this.writeU8(e)) : e < 65536 ? (this.writeU8(205), this.writeU16(e)) : e < 4294967296 ? (this.writeU8(206), this.writeU32(e)) : this.useBigInt64 ? this.encodeNumberAsFloat(e) : (this.writeU8(207), this.writeU64(e)) : e >= -32 ? this.writeU8(224 | e + 32) : e >= -128 ? (this.writeU8(208), this.writeI8(e)) : e >= -32768 ? (this.writeU8(209), this.writeI16(e)) : e >= -2147483648 ? (this.writeU8(210), this.writeI32(e)) : this.useBigInt64 ? this.encodeNumberAsFloat(e) : (this.writeU8(211), this.writeI64(e)) : this.encodeNumberAsFloat(e);
|
|
289
|
+
}
|
|
290
|
+
encodeNumberAsFloat(e) {
|
|
291
|
+
this.forceFloat32 ? (this.writeU8(202), this.writeF32(e)) : (this.writeU8(203), this.writeF64(e));
|
|
292
|
+
}
|
|
293
|
+
encodeBigInt64(e) {
|
|
294
|
+
e >= BigInt(0) ? (this.writeU8(207), this.writeBigUint64(e)) : (this.writeU8(211), this.writeBigInt64(e));
|
|
295
|
+
}
|
|
296
|
+
writeStringHeader(e) {
|
|
297
|
+
if (e < 32)
|
|
298
|
+
this.writeU8(160 + e);
|
|
299
|
+
else if (e < 256)
|
|
300
|
+
this.writeU8(217), this.writeU8(e);
|
|
301
|
+
else if (e < 65536)
|
|
302
|
+
this.writeU8(218), this.writeU16(e);
|
|
303
|
+
else if (e < 4294967296)
|
|
304
|
+
this.writeU8(219), this.writeU32(e);
|
|
305
|
+
else
|
|
306
|
+
throw new Error(`Too long string: ${e} bytes in UTF-8`);
|
|
307
|
+
}
|
|
308
|
+
encodeString(e) {
|
|
309
|
+
const s = N(e);
|
|
310
|
+
this.ensureBufferSizeToWrite(5 + s), this.writeStringHeader(s), J(e, this.bytes, this.pos), this.pos += s;
|
|
311
|
+
}
|
|
312
|
+
encodeObject(e, t) {
|
|
313
|
+
const s = this.extensionCodec.tryToEncode(e, this.context);
|
|
314
|
+
if (s != null)
|
|
315
|
+
this.encodeExtension(s);
|
|
316
|
+
else if (Array.isArray(e))
|
|
317
|
+
this.encodeArray(e, t);
|
|
318
|
+
else if (ArrayBuffer.isView(e))
|
|
319
|
+
this.encodeBinary(e);
|
|
320
|
+
else if (typeof e == "object")
|
|
321
|
+
this.encodeMap(e, t);
|
|
322
|
+
else
|
|
323
|
+
throw new Error(`Unrecognized object: ${Object.prototype.toString.apply(e)}`);
|
|
324
|
+
}
|
|
325
|
+
encodeBinary(e) {
|
|
326
|
+
const t = e.byteLength;
|
|
327
|
+
if (t < 256)
|
|
328
|
+
this.writeU8(196), this.writeU8(t);
|
|
329
|
+
else if (t < 65536)
|
|
330
|
+
this.writeU8(197), this.writeU16(t);
|
|
331
|
+
else if (t < 4294967296)
|
|
332
|
+
this.writeU8(198), this.writeU32(t);
|
|
333
|
+
else
|
|
334
|
+
throw new Error(`Too large binary: ${t}`);
|
|
335
|
+
const s = E(e);
|
|
336
|
+
this.writeU8a(s);
|
|
337
|
+
}
|
|
338
|
+
encodeArray(e, t) {
|
|
339
|
+
const s = e.length;
|
|
340
|
+
if (s < 16)
|
|
341
|
+
this.writeU8(144 + s);
|
|
342
|
+
else if (s < 65536)
|
|
343
|
+
this.writeU8(220), this.writeU16(s);
|
|
344
|
+
else if (s < 4294967296)
|
|
345
|
+
this.writeU8(221), this.writeU32(s);
|
|
346
|
+
else
|
|
347
|
+
throw new Error(`Too large array: ${s}`);
|
|
348
|
+
for (const i of e)
|
|
349
|
+
this.doEncode(i, t + 1);
|
|
350
|
+
}
|
|
351
|
+
countWithoutUndefined(e, t) {
|
|
352
|
+
let s = 0;
|
|
353
|
+
for (const i of t)
|
|
354
|
+
e[i] !== void 0 && s++;
|
|
355
|
+
return s;
|
|
356
|
+
}
|
|
357
|
+
encodeMap(e, t) {
|
|
358
|
+
const s = Object.keys(e);
|
|
359
|
+
this.sortKeys && s.sort();
|
|
360
|
+
const i = this.ignoreUndefined ? this.countWithoutUndefined(e, s) : s.length;
|
|
361
|
+
if (i < 16)
|
|
362
|
+
this.writeU8(128 + i);
|
|
363
|
+
else if (i < 65536)
|
|
364
|
+
this.writeU8(222), this.writeU16(i);
|
|
365
|
+
else if (i < 4294967296)
|
|
366
|
+
this.writeU8(223), this.writeU32(i);
|
|
367
|
+
else
|
|
368
|
+
throw new Error(`Too large map object: ${i}`);
|
|
369
|
+
for (const r of s) {
|
|
370
|
+
const o = e[r];
|
|
371
|
+
this.ignoreUndefined && o === void 0 || (this.encodeString(r), this.doEncode(o, t + 1));
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
encodeExtension(e) {
|
|
375
|
+
if (typeof e.data == "function") {
|
|
376
|
+
const s = e.data(this.pos + 6), i = s.length;
|
|
377
|
+
if (i >= 4294967296)
|
|
378
|
+
throw new Error(`Too large extension object: ${i}`);
|
|
379
|
+
this.writeU8(201), this.writeU32(i), this.writeI8(e.type), this.writeU8a(s);
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
const t = e.data.length;
|
|
383
|
+
if (t === 1)
|
|
384
|
+
this.writeU8(212);
|
|
385
|
+
else if (t === 2)
|
|
386
|
+
this.writeU8(213);
|
|
387
|
+
else if (t === 4)
|
|
388
|
+
this.writeU8(214);
|
|
389
|
+
else if (t === 8)
|
|
390
|
+
this.writeU8(215);
|
|
391
|
+
else if (t === 16)
|
|
392
|
+
this.writeU8(216);
|
|
393
|
+
else if (t < 256)
|
|
394
|
+
this.writeU8(199), this.writeU8(t);
|
|
395
|
+
else if (t < 65536)
|
|
396
|
+
this.writeU8(200), this.writeU16(t);
|
|
397
|
+
else if (t < 4294967296)
|
|
398
|
+
this.writeU8(201), this.writeU32(t);
|
|
399
|
+
else
|
|
400
|
+
throw new Error(`Too large extension object: ${t}`);
|
|
401
|
+
this.writeI8(e.type), this.writeU8a(e.data);
|
|
402
|
+
}
|
|
403
|
+
writeU8(e) {
|
|
404
|
+
this.ensureBufferSizeToWrite(1), this.view.setUint8(this.pos, e), this.pos++;
|
|
405
|
+
}
|
|
406
|
+
writeU8a(e) {
|
|
407
|
+
const t = e.length;
|
|
408
|
+
this.ensureBufferSizeToWrite(t), this.bytes.set(e, this.pos), this.pos += t;
|
|
409
|
+
}
|
|
410
|
+
writeI8(e) {
|
|
411
|
+
this.ensureBufferSizeToWrite(1), this.view.setInt8(this.pos, e), this.pos++;
|
|
412
|
+
}
|
|
413
|
+
writeU16(e) {
|
|
414
|
+
this.ensureBufferSizeToWrite(2), this.view.setUint16(this.pos, e), this.pos += 2;
|
|
415
|
+
}
|
|
416
|
+
writeI16(e) {
|
|
417
|
+
this.ensureBufferSizeToWrite(2), this.view.setInt16(this.pos, e), this.pos += 2;
|
|
418
|
+
}
|
|
419
|
+
writeU32(e) {
|
|
420
|
+
this.ensureBufferSizeToWrite(4), this.view.setUint32(this.pos, e), this.pos += 4;
|
|
421
|
+
}
|
|
422
|
+
writeI32(e) {
|
|
423
|
+
this.ensureBufferSizeToWrite(4), this.view.setInt32(this.pos, e), this.pos += 4;
|
|
424
|
+
}
|
|
425
|
+
writeF32(e) {
|
|
426
|
+
this.ensureBufferSizeToWrite(4), this.view.setFloat32(this.pos, e), this.pos += 4;
|
|
427
|
+
}
|
|
428
|
+
writeF64(e) {
|
|
429
|
+
this.ensureBufferSizeToWrite(8), this.view.setFloat64(this.pos, e), this.pos += 8;
|
|
430
|
+
}
|
|
431
|
+
writeU64(e) {
|
|
432
|
+
this.ensureBufferSizeToWrite(8), j(this.view, this.pos, e), this.pos += 8;
|
|
433
|
+
}
|
|
434
|
+
writeI64(e) {
|
|
435
|
+
this.ensureBufferSizeToWrite(8), M(this.view, this.pos, e), this.pos += 8;
|
|
436
|
+
}
|
|
437
|
+
writeBigUint64(e) {
|
|
438
|
+
this.ensureBufferSizeToWrite(8), this.view.setBigUint64(this.pos, e), this.pos += 8;
|
|
439
|
+
}
|
|
440
|
+
writeBigInt64(e) {
|
|
441
|
+
this.ensureBufferSizeToWrite(8), this.view.setBigInt64(this.pos, e), this.pos += 8;
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
function g(n, e) {
|
|
445
|
+
return new A(e).encodeSharedRef(n);
|
|
446
|
+
}
|
|
447
|
+
function m(n) {
|
|
448
|
+
return `${n < 0 ? "-" : ""}0x${Math.abs(n).toString(16).padStart(2, "0")}`;
|
|
449
|
+
}
|
|
450
|
+
const ue = 16, xe = 16;
|
|
451
|
+
class we {
|
|
452
|
+
constructor(e = ue, t = xe) {
|
|
453
|
+
this.hit = 0, this.miss = 0, this.maxKeyLength = e, this.maxLengthPerKey = t, this.caches = [];
|
|
454
|
+
for (let s = 0; s < this.maxKeyLength; s++)
|
|
455
|
+
this.caches.push([]);
|
|
456
|
+
}
|
|
457
|
+
canBeCached(e) {
|
|
458
|
+
return e > 0 && e <= this.maxKeyLength;
|
|
459
|
+
}
|
|
460
|
+
find(e, t, s) {
|
|
461
|
+
const i = this.caches[s - 1];
|
|
462
|
+
e: for (const r of i) {
|
|
463
|
+
const o = r.bytes;
|
|
464
|
+
for (let h = 0; h < s; h++)
|
|
465
|
+
if (o[h] !== e[t + h])
|
|
466
|
+
continue e;
|
|
467
|
+
return r.str;
|
|
468
|
+
}
|
|
469
|
+
return null;
|
|
470
|
+
}
|
|
471
|
+
store(e, t) {
|
|
472
|
+
const s = this.caches[e.length - 1], i = { bytes: e, str: t };
|
|
473
|
+
s.length >= this.maxLengthPerKey ? s[Math.random() * s.length | 0] = i : s.push(i);
|
|
474
|
+
}
|
|
475
|
+
decode(e, t, s) {
|
|
476
|
+
const i = this.find(e, t, s);
|
|
477
|
+
if (i != null)
|
|
478
|
+
return this.hit++, i;
|
|
479
|
+
this.miss++;
|
|
480
|
+
const r = v(e, t, s), o = Uint8Array.prototype.slice.call(e, t, t + s);
|
|
481
|
+
return this.store(o, r), r;
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
const B = "array", y = "map_key", L = "map_value", ge = (n) => {
|
|
485
|
+
if (typeof n == "string" || typeof n == "number")
|
|
486
|
+
return n;
|
|
487
|
+
throw new c("The type of key must be string or number but " + typeof n);
|
|
488
|
+
};
|
|
489
|
+
class ye {
|
|
490
|
+
constructor() {
|
|
491
|
+
this.stack = [], this.stackHeadPosition = -1;
|
|
492
|
+
}
|
|
493
|
+
get length() {
|
|
494
|
+
return this.stackHeadPosition + 1;
|
|
495
|
+
}
|
|
496
|
+
top() {
|
|
497
|
+
return this.stack[this.stackHeadPosition];
|
|
498
|
+
}
|
|
499
|
+
pushArrayState(e) {
|
|
500
|
+
const t = this.getUninitializedStateFromPool();
|
|
501
|
+
t.type = B, t.position = 0, t.size = e, t.array = new Array(e);
|
|
502
|
+
}
|
|
503
|
+
pushMapState(e) {
|
|
504
|
+
const t = this.getUninitializedStateFromPool();
|
|
505
|
+
t.type = y, t.readCount = 0, t.size = e, t.map = {};
|
|
506
|
+
}
|
|
507
|
+
getUninitializedStateFromPool() {
|
|
508
|
+
if (this.stackHeadPosition++, this.stackHeadPosition === this.stack.length) {
|
|
509
|
+
const e = {
|
|
510
|
+
type: void 0,
|
|
511
|
+
size: 0,
|
|
512
|
+
array: void 0,
|
|
513
|
+
position: 0,
|
|
514
|
+
readCount: 0,
|
|
515
|
+
map: void 0,
|
|
516
|
+
key: null
|
|
517
|
+
};
|
|
518
|
+
this.stack.push(e);
|
|
519
|
+
}
|
|
520
|
+
return this.stack[this.stackHeadPosition];
|
|
521
|
+
}
|
|
522
|
+
release(e) {
|
|
523
|
+
if (this.stack[this.stackHeadPosition] !== e)
|
|
524
|
+
throw new Error("Invalid stack state. Released state is not on top of the stack.");
|
|
525
|
+
if (e.type === B) {
|
|
526
|
+
const s = e;
|
|
527
|
+
s.size = 0, s.array = void 0, s.position = 0, s.type = void 0;
|
|
528
|
+
}
|
|
529
|
+
if (e.type === y || e.type === L) {
|
|
530
|
+
const s = e;
|
|
531
|
+
s.size = 0, s.map = void 0, s.readCount = 0, s.type = void 0;
|
|
532
|
+
}
|
|
533
|
+
this.stackHeadPosition--;
|
|
534
|
+
}
|
|
535
|
+
reset() {
|
|
536
|
+
this.stack.length = 0, this.stackHeadPosition = -1;
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
const w = -1, I = new DataView(new ArrayBuffer(0)), Ue = new Uint8Array(I.buffer);
|
|
540
|
+
try {
|
|
541
|
+
I.getInt8(0);
|
|
542
|
+
} catch (n) {
|
|
543
|
+
if (!(n instanceof RangeError))
|
|
544
|
+
throw new Error("This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access");
|
|
545
|
+
}
|
|
546
|
+
const C = new RangeError("Insufficient data"), pe = new we();
|
|
547
|
+
class k {
|
|
548
|
+
constructor(e) {
|
|
549
|
+
this.totalPos = 0, this.pos = 0, this.view = I, this.bytes = Ue, this.headByte = w, this.stack = new ye(), this.entered = !1, this.extensionCodec = (e == null ? void 0 : e.extensionCodec) ?? U.defaultCodec, this.context = e == null ? void 0 : e.context, this.useBigInt64 = (e == null ? void 0 : e.useBigInt64) ?? !1, this.rawStrings = (e == null ? void 0 : e.rawStrings) ?? !1, this.maxStrLength = (e == null ? void 0 : e.maxStrLength) ?? x, this.maxBinLength = (e == null ? void 0 : e.maxBinLength) ?? x, this.maxArrayLength = (e == null ? void 0 : e.maxArrayLength) ?? x, this.maxMapLength = (e == null ? void 0 : e.maxMapLength) ?? x, this.maxExtLength = (e == null ? void 0 : e.maxExtLength) ?? x, this.keyDecoder = (e == null ? void 0 : e.keyDecoder) !== void 0 ? e.keyDecoder : pe, this.mapKeyConverter = (e == null ? void 0 : e.mapKeyConverter) ?? ge;
|
|
550
|
+
}
|
|
551
|
+
clone() {
|
|
552
|
+
return new k({
|
|
553
|
+
extensionCodec: this.extensionCodec,
|
|
554
|
+
context: this.context,
|
|
555
|
+
useBigInt64: this.useBigInt64,
|
|
556
|
+
rawStrings: this.rawStrings,
|
|
557
|
+
maxStrLength: this.maxStrLength,
|
|
558
|
+
maxBinLength: this.maxBinLength,
|
|
559
|
+
maxArrayLength: this.maxArrayLength,
|
|
560
|
+
maxMapLength: this.maxMapLength,
|
|
561
|
+
maxExtLength: this.maxExtLength,
|
|
562
|
+
keyDecoder: this.keyDecoder
|
|
563
|
+
});
|
|
564
|
+
}
|
|
565
|
+
reinitializeState() {
|
|
566
|
+
this.totalPos = 0, this.headByte = w, this.stack.reset();
|
|
567
|
+
}
|
|
568
|
+
setBuffer(e) {
|
|
569
|
+
const t = E(e);
|
|
570
|
+
this.bytes = t, this.view = new DataView(t.buffer, t.byteOffset, t.byteLength), this.pos = 0;
|
|
571
|
+
}
|
|
572
|
+
appendBuffer(e) {
|
|
573
|
+
if (this.headByte === w && !this.hasRemaining(1))
|
|
574
|
+
this.setBuffer(e);
|
|
575
|
+
else {
|
|
576
|
+
const t = this.bytes.subarray(this.pos), s = E(e), i = new Uint8Array(t.length + s.length);
|
|
577
|
+
i.set(t), i.set(s, t.length), this.setBuffer(i);
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
hasRemaining(e) {
|
|
581
|
+
return this.view.byteLength - this.pos >= e;
|
|
582
|
+
}
|
|
583
|
+
createExtraByteError(e) {
|
|
584
|
+
const { view: t, pos: s } = this;
|
|
585
|
+
return new RangeError(`Extra ${t.byteLength - s} of ${t.byteLength} byte(s) found at buffer[${e}]`);
|
|
586
|
+
}
|
|
587
|
+
/**
|
|
588
|
+
* @throws {@link DecodeError}
|
|
589
|
+
* @throws {@link RangeError}
|
|
590
|
+
*/
|
|
591
|
+
decode(e) {
|
|
592
|
+
if (this.entered)
|
|
593
|
+
return this.clone().decode(e);
|
|
594
|
+
try {
|
|
595
|
+
this.entered = !0, this.reinitializeState(), this.setBuffer(e);
|
|
596
|
+
const t = this.doDecodeSync();
|
|
597
|
+
if (this.hasRemaining(1))
|
|
598
|
+
throw this.createExtraByteError(this.pos);
|
|
599
|
+
return t;
|
|
600
|
+
} finally {
|
|
601
|
+
this.entered = !1;
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
*decodeMulti(e) {
|
|
605
|
+
if (this.entered) {
|
|
606
|
+
yield* this.clone().decodeMulti(e);
|
|
607
|
+
return;
|
|
608
|
+
}
|
|
609
|
+
try {
|
|
610
|
+
for (this.entered = !0, this.reinitializeState(), this.setBuffer(e); this.hasRemaining(1); )
|
|
611
|
+
yield this.doDecodeSync();
|
|
612
|
+
} finally {
|
|
613
|
+
this.entered = !1;
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
async decodeAsync(e) {
|
|
617
|
+
if (this.entered)
|
|
618
|
+
return this.clone().decodeAsync(e);
|
|
619
|
+
try {
|
|
620
|
+
this.entered = !0;
|
|
621
|
+
let t = !1, s;
|
|
622
|
+
for await (const h of e) {
|
|
623
|
+
if (t)
|
|
624
|
+
throw this.entered = !1, this.createExtraByteError(this.totalPos);
|
|
625
|
+
this.appendBuffer(h);
|
|
626
|
+
try {
|
|
627
|
+
s = this.doDecodeSync(), t = !0;
|
|
628
|
+
} catch (a) {
|
|
629
|
+
if (!(a instanceof RangeError))
|
|
630
|
+
throw a;
|
|
631
|
+
}
|
|
632
|
+
this.totalPos += this.pos;
|
|
633
|
+
}
|
|
634
|
+
if (t) {
|
|
635
|
+
if (this.hasRemaining(1))
|
|
636
|
+
throw this.createExtraByteError(this.totalPos);
|
|
637
|
+
return s;
|
|
638
|
+
}
|
|
639
|
+
const { headByte: i, pos: r, totalPos: o } = this;
|
|
640
|
+
throw new RangeError(`Insufficient data in parsing ${m(i)} at ${o} (${r} in the current buffer)`);
|
|
641
|
+
} finally {
|
|
642
|
+
this.entered = !1;
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
decodeArrayStream(e) {
|
|
646
|
+
return this.decodeMultiAsync(e, !0);
|
|
647
|
+
}
|
|
648
|
+
decodeStream(e) {
|
|
649
|
+
return this.decodeMultiAsync(e, !1);
|
|
650
|
+
}
|
|
651
|
+
async *decodeMultiAsync(e, t) {
|
|
652
|
+
if (this.entered) {
|
|
653
|
+
yield* this.clone().decodeMultiAsync(e, t);
|
|
654
|
+
return;
|
|
655
|
+
}
|
|
656
|
+
try {
|
|
657
|
+
this.entered = !0;
|
|
658
|
+
let s = t, i = -1;
|
|
659
|
+
for await (const r of e) {
|
|
660
|
+
if (t && i === 0)
|
|
661
|
+
throw this.createExtraByteError(this.totalPos);
|
|
662
|
+
this.appendBuffer(r), s && (i = this.readArraySize(), s = !1, this.complete());
|
|
663
|
+
try {
|
|
664
|
+
for (; yield this.doDecodeSync(), --i !== 0; )
|
|
665
|
+
;
|
|
666
|
+
} catch (o) {
|
|
667
|
+
if (!(o instanceof RangeError))
|
|
668
|
+
throw o;
|
|
669
|
+
}
|
|
670
|
+
this.totalPos += this.pos;
|
|
671
|
+
}
|
|
672
|
+
} finally {
|
|
673
|
+
this.entered = !1;
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
doDecodeSync() {
|
|
677
|
+
e: for (; ; ) {
|
|
678
|
+
const e = this.readHeadByte();
|
|
679
|
+
let t;
|
|
680
|
+
if (e >= 224)
|
|
681
|
+
t = e - 256;
|
|
682
|
+
else if (e < 192)
|
|
683
|
+
if (e < 128)
|
|
684
|
+
t = e;
|
|
685
|
+
else if (e < 144) {
|
|
686
|
+
const i = e - 128;
|
|
687
|
+
if (i !== 0) {
|
|
688
|
+
this.pushMapState(i), this.complete();
|
|
689
|
+
continue e;
|
|
690
|
+
} else
|
|
691
|
+
t = {};
|
|
692
|
+
} else if (e < 160) {
|
|
693
|
+
const i = e - 144;
|
|
694
|
+
if (i !== 0) {
|
|
695
|
+
this.pushArrayState(i), this.complete();
|
|
696
|
+
continue e;
|
|
697
|
+
} else
|
|
698
|
+
t = [];
|
|
699
|
+
} else {
|
|
700
|
+
const i = e - 160;
|
|
701
|
+
t = this.decodeString(i, 0);
|
|
702
|
+
}
|
|
703
|
+
else if (e === 192)
|
|
704
|
+
t = null;
|
|
705
|
+
else if (e === 194)
|
|
706
|
+
t = !1;
|
|
707
|
+
else if (e === 195)
|
|
708
|
+
t = !0;
|
|
709
|
+
else if (e === 202)
|
|
710
|
+
t = this.readF32();
|
|
711
|
+
else if (e === 203)
|
|
712
|
+
t = this.readF64();
|
|
713
|
+
else if (e === 204)
|
|
714
|
+
t = this.readU8();
|
|
715
|
+
else if (e === 205)
|
|
716
|
+
t = this.readU16();
|
|
717
|
+
else if (e === 206)
|
|
718
|
+
t = this.readU32();
|
|
719
|
+
else if (e === 207)
|
|
720
|
+
this.useBigInt64 ? t = this.readU64AsBigInt() : t = this.readU64();
|
|
721
|
+
else if (e === 208)
|
|
722
|
+
t = this.readI8();
|
|
723
|
+
else if (e === 209)
|
|
724
|
+
t = this.readI16();
|
|
725
|
+
else if (e === 210)
|
|
726
|
+
t = this.readI32();
|
|
727
|
+
else if (e === 211)
|
|
728
|
+
this.useBigInt64 ? t = this.readI64AsBigInt() : t = this.readI64();
|
|
729
|
+
else if (e === 217) {
|
|
730
|
+
const i = this.lookU8();
|
|
731
|
+
t = this.decodeString(i, 1);
|
|
732
|
+
} else if (e === 218) {
|
|
733
|
+
const i = this.lookU16();
|
|
734
|
+
t = this.decodeString(i, 2);
|
|
735
|
+
} else if (e === 219) {
|
|
736
|
+
const i = this.lookU32();
|
|
737
|
+
t = this.decodeString(i, 4);
|
|
738
|
+
} else if (e === 220) {
|
|
739
|
+
const i = this.readU16();
|
|
740
|
+
if (i !== 0) {
|
|
741
|
+
this.pushArrayState(i), this.complete();
|
|
742
|
+
continue e;
|
|
743
|
+
} else
|
|
744
|
+
t = [];
|
|
745
|
+
} else if (e === 221) {
|
|
746
|
+
const i = this.readU32();
|
|
747
|
+
if (i !== 0) {
|
|
748
|
+
this.pushArrayState(i), this.complete();
|
|
749
|
+
continue e;
|
|
750
|
+
} else
|
|
751
|
+
t = [];
|
|
752
|
+
} else if (e === 222) {
|
|
753
|
+
const i = this.readU16();
|
|
754
|
+
if (i !== 0) {
|
|
755
|
+
this.pushMapState(i), this.complete();
|
|
756
|
+
continue e;
|
|
757
|
+
} else
|
|
758
|
+
t = {};
|
|
759
|
+
} else if (e === 223) {
|
|
760
|
+
const i = this.readU32();
|
|
761
|
+
if (i !== 0) {
|
|
762
|
+
this.pushMapState(i), this.complete();
|
|
763
|
+
continue e;
|
|
764
|
+
} else
|
|
765
|
+
t = {};
|
|
766
|
+
} else if (e === 196) {
|
|
767
|
+
const i = this.lookU8();
|
|
768
|
+
t = this.decodeBinary(i, 1);
|
|
769
|
+
} else if (e === 197) {
|
|
770
|
+
const i = this.lookU16();
|
|
771
|
+
t = this.decodeBinary(i, 2);
|
|
772
|
+
} else if (e === 198) {
|
|
773
|
+
const i = this.lookU32();
|
|
774
|
+
t = this.decodeBinary(i, 4);
|
|
775
|
+
} else if (e === 212)
|
|
776
|
+
t = this.decodeExtension(1, 0);
|
|
777
|
+
else if (e === 213)
|
|
778
|
+
t = this.decodeExtension(2, 0);
|
|
779
|
+
else if (e === 214)
|
|
780
|
+
t = this.decodeExtension(4, 0);
|
|
781
|
+
else if (e === 215)
|
|
782
|
+
t = this.decodeExtension(8, 0);
|
|
783
|
+
else if (e === 216)
|
|
784
|
+
t = this.decodeExtension(16, 0);
|
|
785
|
+
else if (e === 199) {
|
|
786
|
+
const i = this.lookU8();
|
|
787
|
+
t = this.decodeExtension(i, 1);
|
|
788
|
+
} else if (e === 200) {
|
|
789
|
+
const i = this.lookU16();
|
|
790
|
+
t = this.decodeExtension(i, 2);
|
|
791
|
+
} else if (e === 201) {
|
|
792
|
+
const i = this.lookU32();
|
|
793
|
+
t = this.decodeExtension(i, 4);
|
|
794
|
+
} else
|
|
795
|
+
throw new c(`Unrecognized type byte: ${m(e)}`);
|
|
796
|
+
this.complete();
|
|
797
|
+
const s = this.stack;
|
|
798
|
+
for (; s.length > 0; ) {
|
|
799
|
+
const i = s.top();
|
|
800
|
+
if (i.type === B)
|
|
801
|
+
if (i.array[i.position] = t, i.position++, i.position === i.size)
|
|
802
|
+
t = i.array, s.release(i);
|
|
803
|
+
else
|
|
804
|
+
continue e;
|
|
805
|
+
else if (i.type === y) {
|
|
806
|
+
if (t === "__proto__")
|
|
807
|
+
throw new c("The key __proto__ is not allowed");
|
|
808
|
+
i.key = this.mapKeyConverter(t), i.type = L;
|
|
809
|
+
continue e;
|
|
810
|
+
} else if (i.map[i.key] = t, i.readCount++, i.readCount === i.size)
|
|
811
|
+
t = i.map, s.release(i);
|
|
812
|
+
else {
|
|
813
|
+
i.key = null, i.type = y;
|
|
814
|
+
continue e;
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
return t;
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
readHeadByte() {
|
|
821
|
+
return this.headByte === w && (this.headByte = this.readU8()), this.headByte;
|
|
822
|
+
}
|
|
823
|
+
complete() {
|
|
824
|
+
this.headByte = w;
|
|
825
|
+
}
|
|
826
|
+
readArraySize() {
|
|
827
|
+
const e = this.readHeadByte();
|
|
828
|
+
switch (e) {
|
|
829
|
+
case 220:
|
|
830
|
+
return this.readU16();
|
|
831
|
+
case 221:
|
|
832
|
+
return this.readU32();
|
|
833
|
+
default: {
|
|
834
|
+
if (e < 160)
|
|
835
|
+
return e - 144;
|
|
836
|
+
throw new c(`Unrecognized array type byte: ${m(e)}`);
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
pushMapState(e) {
|
|
841
|
+
if (e > this.maxMapLength)
|
|
842
|
+
throw new c(`Max length exceeded: map length (${e}) > maxMapLengthLength (${this.maxMapLength})`);
|
|
843
|
+
this.stack.pushMapState(e);
|
|
844
|
+
}
|
|
845
|
+
pushArrayState(e) {
|
|
846
|
+
if (e > this.maxArrayLength)
|
|
847
|
+
throw new c(`Max length exceeded: array length (${e}) > maxArrayLength (${this.maxArrayLength})`);
|
|
848
|
+
this.stack.pushArrayState(e);
|
|
849
|
+
}
|
|
850
|
+
decodeString(e, t) {
|
|
851
|
+
return !this.rawStrings || this.stateIsMapKey() ? this.decodeUtf8String(e, t) : this.decodeBinary(e, t);
|
|
852
|
+
}
|
|
853
|
+
/**
|
|
854
|
+
* @throws {@link RangeError}
|
|
855
|
+
*/
|
|
856
|
+
decodeUtf8String(e, t) {
|
|
857
|
+
var r;
|
|
858
|
+
if (e > this.maxStrLength)
|
|
859
|
+
throw new c(`Max length exceeded: UTF-8 byte length (${e}) > maxStrLength (${this.maxStrLength})`);
|
|
860
|
+
if (this.bytes.byteLength < this.pos + t + e)
|
|
861
|
+
throw C;
|
|
862
|
+
const s = this.pos + t;
|
|
863
|
+
let i;
|
|
864
|
+
return this.stateIsMapKey() && ((r = this.keyDecoder) != null && r.canBeCached(e)) ? i = this.keyDecoder.decode(this.bytes, s, e) : i = Q(this.bytes, s, e), this.pos += t + e, i;
|
|
865
|
+
}
|
|
866
|
+
stateIsMapKey() {
|
|
867
|
+
return this.stack.length > 0 ? this.stack.top().type === y : !1;
|
|
868
|
+
}
|
|
869
|
+
/**
|
|
870
|
+
* @throws {@link RangeError}
|
|
871
|
+
*/
|
|
872
|
+
decodeBinary(e, t) {
|
|
873
|
+
if (e > this.maxBinLength)
|
|
874
|
+
throw new c(`Max length exceeded: bin length (${e}) > maxBinLength (${this.maxBinLength})`);
|
|
875
|
+
if (!this.hasRemaining(e + t))
|
|
876
|
+
throw C;
|
|
877
|
+
const s = this.pos + t, i = this.bytes.subarray(s, s + e);
|
|
878
|
+
return this.pos += t + e, i;
|
|
879
|
+
}
|
|
880
|
+
decodeExtension(e, t) {
|
|
881
|
+
if (e > this.maxExtLength)
|
|
882
|
+
throw new c(`Max length exceeded: ext length (${e}) > maxExtLength (${this.maxExtLength})`);
|
|
883
|
+
const s = this.view.getInt8(this.pos + t), i = this.decodeBinary(
|
|
884
|
+
e,
|
|
885
|
+
t + 1
|
|
886
|
+
/* extType */
|
|
887
|
+
);
|
|
888
|
+
return this.extensionCodec.decode(i, s, this.context);
|
|
889
|
+
}
|
|
890
|
+
lookU8() {
|
|
891
|
+
return this.view.getUint8(this.pos);
|
|
892
|
+
}
|
|
893
|
+
lookU16() {
|
|
894
|
+
return this.view.getUint16(this.pos);
|
|
895
|
+
}
|
|
896
|
+
lookU32() {
|
|
897
|
+
return this.view.getUint32(this.pos);
|
|
898
|
+
}
|
|
899
|
+
readU8() {
|
|
900
|
+
const e = this.view.getUint8(this.pos);
|
|
901
|
+
return this.pos++, e;
|
|
902
|
+
}
|
|
903
|
+
readI8() {
|
|
904
|
+
const e = this.view.getInt8(this.pos);
|
|
905
|
+
return this.pos++, e;
|
|
906
|
+
}
|
|
907
|
+
readU16() {
|
|
908
|
+
const e = this.view.getUint16(this.pos);
|
|
909
|
+
return this.pos += 2, e;
|
|
910
|
+
}
|
|
911
|
+
readI16() {
|
|
912
|
+
const e = this.view.getInt16(this.pos);
|
|
913
|
+
return this.pos += 2, e;
|
|
914
|
+
}
|
|
915
|
+
readU32() {
|
|
916
|
+
const e = this.view.getUint32(this.pos);
|
|
917
|
+
return this.pos += 4, e;
|
|
918
|
+
}
|
|
919
|
+
readI32() {
|
|
920
|
+
const e = this.view.getInt32(this.pos);
|
|
921
|
+
return this.pos += 4, e;
|
|
922
|
+
}
|
|
923
|
+
readU64() {
|
|
924
|
+
const e = ee(this.view, this.pos);
|
|
925
|
+
return this.pos += 8, e;
|
|
926
|
+
}
|
|
927
|
+
readI64() {
|
|
928
|
+
const e = _(this.view, this.pos);
|
|
929
|
+
return this.pos += 8, e;
|
|
930
|
+
}
|
|
931
|
+
readU64AsBigInt() {
|
|
932
|
+
const e = this.view.getBigUint64(this.pos);
|
|
933
|
+
return this.pos += 8, e;
|
|
934
|
+
}
|
|
935
|
+
readI64AsBigInt() {
|
|
936
|
+
const e = this.view.getBigInt64(this.pos);
|
|
937
|
+
return this.pos += 8, e;
|
|
938
|
+
}
|
|
939
|
+
readF32() {
|
|
940
|
+
const e = this.view.getFloat32(this.pos);
|
|
941
|
+
return this.pos += 4, e;
|
|
942
|
+
}
|
|
943
|
+
readF64() {
|
|
944
|
+
const e = this.view.getFloat64(this.pos);
|
|
945
|
+
return this.pos += 8, e;
|
|
946
|
+
}
|
|
947
|
+
}
|
|
948
|
+
function F(n, e) {
|
|
949
|
+
return new k(e).decode(n);
|
|
950
|
+
}
|
|
951
|
+
class P {
|
|
952
|
+
constructor() {
|
|
953
|
+
u(this, "contentType", "application/json");
|
|
954
|
+
u(this, "decoder");
|
|
955
|
+
u(this, "encoder");
|
|
956
|
+
this.decoder = new TextDecoder(), this.encoder = new TextEncoder();
|
|
957
|
+
}
|
|
958
|
+
encode(e) {
|
|
959
|
+
return this.encoder.encode(this.encodeString(e));
|
|
960
|
+
}
|
|
961
|
+
decode(e, t) {
|
|
962
|
+
return this.decodeString(this.decoder.decode(e), t);
|
|
963
|
+
}
|
|
964
|
+
decodeString(e, t) {
|
|
965
|
+
const s = JSON.parse(e), i = D(s);
|
|
966
|
+
return t != null ? t.parse(i) : i;
|
|
967
|
+
}
|
|
968
|
+
encodeString(e) {
|
|
969
|
+
const t = z(e);
|
|
970
|
+
return JSON.stringify(t, (s, i) => ArrayBuffer.isView(i) ? Array.from(i) : T(i) && "encode_value" in i ? typeof i.value == "bigint" ? i.value.toString() : i.value : typeof i == "bigint" ? i.toString() : i);
|
|
971
|
+
}
|
|
972
|
+
static registerCustomType() {
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
class b {
|
|
976
|
+
constructor() {
|
|
977
|
+
u(this, "contentType", "text/csv");
|
|
978
|
+
}
|
|
979
|
+
encode(e) {
|
|
980
|
+
const t = this.encodeString(e);
|
|
981
|
+
return new TextEncoder().encode(t);
|
|
982
|
+
}
|
|
983
|
+
decode(e, t) {
|
|
984
|
+
const s = new TextDecoder().decode(e);
|
|
985
|
+
return this.decodeString(s, t);
|
|
986
|
+
}
|
|
987
|
+
encodeString(e) {
|
|
988
|
+
if (!Array.isArray(e) || e.length === 0 || !T(e[0]))
|
|
989
|
+
throw new Error("Payload must be an array of objects");
|
|
990
|
+
const t = Object.keys(e[0]), s = [t.join(",")];
|
|
991
|
+
return e.forEach((i) => {
|
|
992
|
+
const r = t.map((o) => JSON.stringify(i[o] ?? ""));
|
|
993
|
+
s.push(r.join(","));
|
|
994
|
+
}), s.join(`
|
|
995
|
+
`);
|
|
996
|
+
}
|
|
997
|
+
decodeString(e, t) {
|
|
998
|
+
const [s, ...i] = e.trim().split(`
|
|
999
|
+
`).map((h) => h.trim());
|
|
1000
|
+
if (s.length === 0)
|
|
1001
|
+
return t != null ? t.parse({}) : {};
|
|
1002
|
+
const r = s.split(",").map((h) => h.trim()), o = {};
|
|
1003
|
+
return r.forEach((h) => {
|
|
1004
|
+
o[h] = [];
|
|
1005
|
+
}), i.forEach((h) => {
|
|
1006
|
+
const a = h.split(",").map((l) => l.trim());
|
|
1007
|
+
r.forEach((l, S) => {
|
|
1008
|
+
const d = this.parseValue(a[S]);
|
|
1009
|
+
d != null && o[l].push(d);
|
|
1010
|
+
});
|
|
1011
|
+
}), t != null ? t.parse(o) : o;
|
|
1012
|
+
}
|
|
1013
|
+
parseValue(e) {
|
|
1014
|
+
if (e == null || e.length === 0) return null;
|
|
1015
|
+
const t = Number(e);
|
|
1016
|
+
return isNaN(t) ? e.startsWith('"') && e.endsWith('"') ? e.slice(1, -1) : e : t;
|
|
1017
|
+
}
|
|
1018
|
+
static registerCustomType() {
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1021
|
+
class R {
|
|
1022
|
+
constructor() {
|
|
1023
|
+
u(this, "contentType", "text/plain");
|
|
1024
|
+
}
|
|
1025
|
+
encode(e) {
|
|
1026
|
+
return new TextEncoder().encode(e);
|
|
1027
|
+
}
|
|
1028
|
+
decode(e, t) {
|
|
1029
|
+
const s = new TextDecoder().decode(e);
|
|
1030
|
+
return t != null ? t.parse(s) : s;
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
const f = new U();
|
|
1034
|
+
f.register({
|
|
1035
|
+
type: 0,
|
|
1036
|
+
encode: (n) => {
|
|
1037
|
+
if (ArrayBuffer.isView(n)) {
|
|
1038
|
+
const e = Array.from(n);
|
|
1039
|
+
return g(e, { extensionCodec: f });
|
|
1040
|
+
}
|
|
1041
|
+
return T(n) && "encode_value" in n ? typeof n.value == "bigint" ? g(n.value.toString(), { extensionCodec: f }) : g(n.value, { extensionCodec: f }) : typeof n == "bigint" ? g(n.toString(), { extensionCodec: f }) : null;
|
|
1042
|
+
},
|
|
1043
|
+
decode: (n) => F(n, { extensionCodec: f })
|
|
1044
|
+
});
|
|
1045
|
+
class $ {
|
|
1046
|
+
constructor() {
|
|
1047
|
+
u(this, "contentType", "application/msgpack");
|
|
1048
|
+
}
|
|
1049
|
+
encode(e) {
|
|
1050
|
+
const t = z(e);
|
|
1051
|
+
return g(t, { extensionCodec: f }).slice();
|
|
1052
|
+
}
|
|
1053
|
+
decode(e, t) {
|
|
1054
|
+
const s = F(e, { extensionCodec: f }), i = D(s);
|
|
1055
|
+
return t != null ? t.parse(i) : i;
|
|
1056
|
+
}
|
|
1057
|
+
static registerCustomType() {
|
|
1058
|
+
}
|
|
1059
|
+
}
|
|
1060
|
+
const Se = new P(), me = new b(), Ee = new R(), Be = new $(), ke = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1061
|
+
__proto__: null,
|
|
1062
|
+
CSVCodec: b,
|
|
1063
|
+
CSV_CODEC: me,
|
|
1064
|
+
JSONCodec: P,
|
|
1065
|
+
JSON_CODEC: Se,
|
|
1066
|
+
MSGPACK_CODEC: Be,
|
|
1067
|
+
MsgPackCodec: $,
|
|
1068
|
+
TEXT_CODEC: Ee,
|
|
1069
|
+
TextCodec: R
|
|
1070
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
1071
|
+
export {
|
|
1072
|
+
Se as J,
|
|
1073
|
+
ke as c
|
|
1074
|
+
};
|