@kbve/droid 0.0.4 → 0.0.6

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.
@@ -0,0 +1,274 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2019 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ const T = Symbol("Comlink.proxy"), N = Symbol("Comlink.endpoint"), H = Symbol("Comlink.releaseProxy"), k = Symbol("Comlink.finalizer"), h = Symbol("Comlink.thrown"), C = (e) => typeof e == "object" && e !== null || typeof e == "function", I = {
7
+ canHandle: (e) => C(e) && e[T],
8
+ serialize(e) {
9
+ const { port1: t, port2: n } = new MessageChannel();
10
+ return M(e, t), [n, [n]];
11
+ },
12
+ deserialize(e) {
13
+ return e.start(), D(e);
14
+ }
15
+ }, L = {
16
+ canHandle: (e) => C(e) && h in e,
17
+ serialize({ value: e }) {
18
+ let t;
19
+ return e instanceof Error ? t = {
20
+ isError: !0,
21
+ value: {
22
+ message: e.message,
23
+ name: e.name,
24
+ stack: e.stack
25
+ }
26
+ } : t = { isError: !1, value: e }, [t, []];
27
+ },
28
+ deserialize(e) {
29
+ throw e.isError ? Object.assign(new Error(e.value.message), e.value) : e.value;
30
+ }
31
+ }, R = /* @__PURE__ */ new Map([
32
+ ["proxy", I],
33
+ ["throw", L]
34
+ ]);
35
+ function V(e, t) {
36
+ for (const n of e)
37
+ if (t === n || n === "*" || n instanceof RegExp && n.test(t))
38
+ return !0;
39
+ return !1;
40
+ }
41
+ function M(e, t = globalThis, n = ["*"]) {
42
+ t.addEventListener("message", function y(r) {
43
+ if (!r || !r.data)
44
+ return;
45
+ if (!V(n, r.origin)) {
46
+ console.warn(`Invalid origin '${r.origin}' for comlink proxy`);
47
+ return;
48
+ }
49
+ const { id: a, type: g, path: c } = Object.assign({ path: [] }, r.data), u = (r.data.argumentList || []).map(d);
50
+ let s;
51
+ try {
52
+ const o = c.slice(0, -1).reduce((i, w) => i[w], e), f = c.reduce((i, w) => i[w], e);
53
+ switch (g) {
54
+ case "GET":
55
+ s = f;
56
+ break;
57
+ case "SET":
58
+ o[c.slice(-1)[0]] = d(r.data.value), s = !0;
59
+ break;
60
+ case "APPLY":
61
+ s = f.apply(o, u);
62
+ break;
63
+ case "CONSTRUCT":
64
+ {
65
+ const i = new f(...u);
66
+ s = Y(i);
67
+ }
68
+ break;
69
+ case "ENDPOINT":
70
+ {
71
+ const { port1: i, port2: w } = new MessageChannel();
72
+ M(e, w), s = G(i, [i]);
73
+ }
74
+ break;
75
+ case "RELEASE":
76
+ s = void 0;
77
+ break;
78
+ default:
79
+ return;
80
+ }
81
+ } catch (o) {
82
+ s = { value: o, [h]: 0 };
83
+ }
84
+ Promise.resolve(s).catch((o) => ({ value: o, [h]: 0 })).then((o) => {
85
+ const [f, i] = S(o);
86
+ t.postMessage(Object.assign(Object.assign({}, f), { id: a }), i), g === "RELEASE" && (t.removeEventListener("message", y), O(t), k in e && typeof e[k] == "function" && e[k]());
87
+ }).catch((o) => {
88
+ const [f, i] = S({
89
+ value: new TypeError("Unserializable return value"),
90
+ [h]: 0
91
+ });
92
+ t.postMessage(Object.assign(Object.assign({}, f), { id: a }), i);
93
+ });
94
+ }), t.start && t.start();
95
+ }
96
+ function _(e) {
97
+ return e.constructor.name === "MessagePort";
98
+ }
99
+ function O(e) {
100
+ _(e) && e.close();
101
+ }
102
+ function D(e, t) {
103
+ const n = /* @__PURE__ */ new Map();
104
+ return e.addEventListener("message", function(r) {
105
+ const { data: a } = r;
106
+ if (!a || !a.id)
107
+ return;
108
+ const g = n.get(a.id);
109
+ if (g)
110
+ try {
111
+ g(a);
112
+ } finally {
113
+ n.delete(a.id);
114
+ }
115
+ }), P(e, n, [], t);
116
+ }
117
+ function b(e) {
118
+ if (e)
119
+ throw new Error("Proxy has been released and is not useable");
120
+ }
121
+ function W(e) {
122
+ return m(e, /* @__PURE__ */ new Map(), {
123
+ type: "RELEASE"
124
+ }).then(() => {
125
+ O(e);
126
+ });
127
+ }
128
+ const E = /* @__PURE__ */ new WeakMap(), p = "FinalizationRegistry" in globalThis && new FinalizationRegistry((e) => {
129
+ const t = (E.get(e) || 0) - 1;
130
+ E.set(e, t), t === 0 && W(e);
131
+ });
132
+ function F(e, t) {
133
+ const n = (E.get(t) || 0) + 1;
134
+ E.set(t, n), p && p.register(e, t, e);
135
+ }
136
+ function j(e) {
137
+ p && p.unregister(e);
138
+ }
139
+ function P(e, t, n = [], y = function() {
140
+ }) {
141
+ let r = !1;
142
+ const a = new Proxy(y, {
143
+ get(g, c) {
144
+ if (b(r), c === H)
145
+ return () => {
146
+ j(a), W(e), t.clear(), r = !0;
147
+ };
148
+ if (c === "then") {
149
+ if (n.length === 0)
150
+ return { then: () => a };
151
+ const u = m(e, t, {
152
+ type: "GET",
153
+ path: n.map((s) => s.toString())
154
+ }).then(d);
155
+ return u.then.bind(u);
156
+ }
157
+ return P(e, t, [...n, c]);
158
+ },
159
+ set(g, c, u) {
160
+ b(r);
161
+ const [s, o] = S(u);
162
+ return m(e, t, {
163
+ type: "SET",
164
+ path: [...n, c].map((f) => f.toString()),
165
+ value: s
166
+ }, o).then(d);
167
+ },
168
+ apply(g, c, u) {
169
+ b(r);
170
+ const s = n[n.length - 1];
171
+ if (s === N)
172
+ return m(e, t, {
173
+ type: "ENDPOINT"
174
+ }).then(d);
175
+ if (s === "bind")
176
+ return P(e, t, n.slice(0, -1));
177
+ const [o, f] = x(u);
178
+ return m(e, t, {
179
+ type: "APPLY",
180
+ path: n.map((i) => i.toString()),
181
+ argumentList: o
182
+ }, f).then(d);
183
+ },
184
+ construct(g, c) {
185
+ b(r);
186
+ const [u, s] = x(c);
187
+ return m(e, t, {
188
+ type: "CONSTRUCT",
189
+ path: n.map((o) => o.toString()),
190
+ argumentList: u
191
+ }, s).then(d);
192
+ }
193
+ });
194
+ return F(a, e), a;
195
+ }
196
+ function U(e) {
197
+ return Array.prototype.concat.apply([], e);
198
+ }
199
+ function x(e) {
200
+ const t = e.map(S);
201
+ return [t.map((n) => n[0]), U(t.map((n) => n[1]))];
202
+ }
203
+ const z = /* @__PURE__ */ new WeakMap();
204
+ function G(e, t) {
205
+ return z.set(e, t), e;
206
+ }
207
+ function Y(e) {
208
+ return Object.assign(e, { [T]: !0 });
209
+ }
210
+ function S(e) {
211
+ for (const [t, n] of R)
212
+ if (n.canHandle(e)) {
213
+ const [y, r] = n.serialize(e);
214
+ return [
215
+ {
216
+ type: "HANDLER",
217
+ name: t,
218
+ value: y
219
+ },
220
+ r
221
+ ];
222
+ }
223
+ return [
224
+ {
225
+ type: "RAW",
226
+ value: e
227
+ },
228
+ z.get(e) || []
229
+ ];
230
+ }
231
+ function d(e) {
232
+ switch (e.type) {
233
+ case "HANDLER":
234
+ return R.get(e.name).deserialize(e.value);
235
+ case "RAW":
236
+ return e.value;
237
+ }
238
+ }
239
+ function m(e, t, n, y) {
240
+ return new Promise((r) => {
241
+ const a = q();
242
+ t.set(a, r), e.start && e.start(), e.postMessage(Object.assign({ id: a }, n), y);
243
+ });
244
+ }
245
+ function q() {
246
+ return new Array(4).fill(0).map(() => Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(16)).join("-");
247
+ }
248
+ let l = null, A = null;
249
+ const v = {
250
+ async connect(e) {
251
+ l || (l = new WebSocket(e), l.binaryType = "arraybuffer", l.onopen = () => console.log("[WS] Connected:", e), l.onmessage = (t) => {
252
+ try {
253
+ console.log("[WS] Received binary message"), t.data instanceof ArrayBuffer && A?.(t.data);
254
+ } catch (n) {
255
+ console.error("[WS] Failed to forward message", n);
256
+ }
257
+ }, l.onerror = (t) => console.error("[WS] Error:", t), l.onclose = () => {
258
+ console.log("[WS] Disconnected"), l = null;
259
+ });
260
+ },
261
+ async send(e) {
262
+ l?.readyState === WebSocket.OPEN ? l.send(e) : console.warn("[WS] Tried to send while disconnected");
263
+ },
264
+ async close() {
265
+ l?.close(), l = null;
266
+ },
267
+ onMessage(e) {
268
+ A = e;
269
+ }
270
+ };
271
+ self.onconnect = (e) => {
272
+ const t = e.ports[0];
273
+ t.start(), M(v, t);
274
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kbve/droid",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "description": "A manager for web, shared and service workers, aimming to make it as modular and upgradable.",
5
5
  "keywords": [
6
6
  "workers",
@@ -17,24 +17,28 @@
17
17
  "author": "KBVE <hello@kbve.com>",
18
18
  "license": "MIT",
19
19
  "type": "module",
20
- "main": "./droid.cjs.js",
21
- "module": "./droid.es.js",
20
+ "main": "./droid.mjs",
21
+ "module": "./droid.mjs",
22
22
  "types": "./index.d.ts",
23
23
  "exports": {
24
24
  ".": {
25
- "import": "./droid.es.js",
26
- "require": "./droid.cjs.js"
27
- }
25
+ "import": "./droid.mjs",
26
+ "require": "./droid.mjs"
27
+ },
28
+ "./lib/workers/canvas-worker": "./lib/workers/canvas-worker.js",
29
+ "./lib/workers/db-worker": "./lib/workers/db-worker.js",
30
+ "./lib/workers/ws-worker": "./lib/workers/ws-worker.js"
28
31
  },
29
32
  "files": [
30
33
  "workers/",
34
+ "lib/workers/",
31
35
  "assets/",
32
36
  "src/",
33
37
  "comlink*.js",
34
- "reference-*.js",
35
- "droid.*.js",
38
+ "reference*.js",
39
+ "droid.mjs",
36
40
  "main.js",
37
- "index.*.js",
41
+ "index.js",
38
42
  "index.d.ts",
39
43
  "*.md",
40
44
  "LICENSE",
package/reference.js ADDED
@@ -0,0 +1,259 @@
1
+ var T = /* @__PURE__ */ ((t) => (t[t.WIDTH8 = 0] = "WIDTH8", t[t.WIDTH16 = 1] = "WIDTH16", t[t.WIDTH32 = 2] = "WIDTH32", t[t.WIDTH64 = 3] = "WIDTH64", t))(T || {});
2
+ function S(t) {
3
+ return 1 << t;
4
+ }
5
+ function K(t) {
6
+ return t >= -128 && t <= 127 ? T.WIDTH8 : t >= -32768 && t <= 32767 ? T.WIDTH16 : t >= -2147483648 && t <= 2147483647 ? T.WIDTH32 : T.WIDTH64;
7
+ }
8
+ function $(t) {
9
+ return t === Math.fround(t) ? T.WIDTH32 : T.WIDTH64;
10
+ }
11
+ function x(t) {
12
+ return t <= 255 ? T.WIDTH8 : t <= 65535 ? T.WIDTH16 : t <= 4294967295 ? T.WIDTH32 : T.WIDTH64;
13
+ }
14
+ function f(t) {
15
+ return t === 1 ? T.WIDTH8 : t === 2 ? T.WIDTH16 : t === 4 ? T.WIDTH32 : T.WIDTH64;
16
+ }
17
+ function G(t, i) {
18
+ return ~t + 1 & i - 1;
19
+ }
20
+ function U(t) {
21
+ return new TextDecoder().decode(t);
22
+ }
23
+ function p(t) {
24
+ return new TextEncoder().encode(t);
25
+ }
26
+ var e = /* @__PURE__ */ ((t) => (t[t.NULL = 0] = "NULL", t[t.INT = 1] = "INT", t[t.UINT = 2] = "UINT", t[t.FLOAT = 3] = "FLOAT", t[t.KEY = 4] = "KEY", t[t.STRING = 5] = "STRING", t[t.INDIRECT_INT = 6] = "INDIRECT_INT", t[t.INDIRECT_UINT = 7] = "INDIRECT_UINT", t[t.INDIRECT_FLOAT = 8] = "INDIRECT_FLOAT", t[t.MAP = 9] = "MAP", t[t.VECTOR = 10] = "VECTOR", t[t.VECTOR_INT = 11] = "VECTOR_INT", t[t.VECTOR_UINT = 12] = "VECTOR_UINT", t[t.VECTOR_FLOAT = 13] = "VECTOR_FLOAT", t[t.VECTOR_KEY = 14] = "VECTOR_KEY", t[t.VECTOR_STRING_DEPRECATED = 15] = "VECTOR_STRING_DEPRECATED", t[t.VECTOR_INT2 = 16] = "VECTOR_INT2", t[t.VECTOR_UINT2 = 17] = "VECTOR_UINT2", t[t.VECTOR_FLOAT2 = 18] = "VECTOR_FLOAT2", t[t.VECTOR_INT3 = 19] = "VECTOR_INT3", t[t.VECTOR_UINT3 = 20] = "VECTOR_UINT3", t[t.VECTOR_FLOAT3 = 21] = "VECTOR_FLOAT3", t[t.VECTOR_INT4 = 22] = "VECTOR_INT4", t[t.VECTOR_UINT4 = 23] = "VECTOR_UINT4", t[t.VECTOR_FLOAT4 = 24] = "VECTOR_FLOAT4", t[t.BLOB = 25] = "BLOB", t[t.BOOL = 26] = "BOOL", t[t.VECTOR_BOOL = 36] = "VECTOR_BOOL", t))(e || {});
27
+ function M(t) {
28
+ return t === e.BOOL || t <= e.FLOAT;
29
+ }
30
+ function B(t) {
31
+ return t >= e.INT && t <= e.FLOAT;
32
+ }
33
+ function F(t) {
34
+ return t >= e.INDIRECT_INT && t <= e.INDIRECT_FLOAT;
35
+ }
36
+ function P(t) {
37
+ return t === e.BOOL || t >= e.INT && t <= e.STRING;
38
+ }
39
+ function A(t) {
40
+ return t === e.VECTOR_BOOL || t >= e.VECTOR_INT && t <= e.VECTOR_STRING_DEPRECATED;
41
+ }
42
+ function a(t) {
43
+ return t >= e.VECTOR_INT2 && t <= e.VECTOR_FLOAT4;
44
+ }
45
+ function g(t) {
46
+ return A(t) || a(t) || t === e.VECTOR;
47
+ }
48
+ function Y(t, i) {
49
+ if (i === 0) return t - e.INT + e.VECTOR_INT;
50
+ if (i === 2) return t - e.INT + e.VECTOR_INT2;
51
+ if (i === 3) return t - e.INT + e.VECTOR_INT3;
52
+ if (i === 4) return t - e.INT + e.VECTOR_INT4;
53
+ throw "Unexpected length " + i;
54
+ }
55
+ function H(t) {
56
+ return t - e.VECTOR_INT + e.INT;
57
+ }
58
+ function m(t) {
59
+ return (t - e.VECTOR_INT2) % 3 + e.INT;
60
+ }
61
+ function w(t) {
62
+ return ((t - e.VECTOR_INT2) / 3 >> 0) + 2;
63
+ }
64
+ function b(t, i) {
65
+ return i | t << 2;
66
+ }
67
+ function C(t, i, n) {
68
+ return n < 2 ? n < 1 ? t.getInt8(i) : t.getInt16(i, !0) : n < 3 ? t.getInt32(i, !0) : t.setBigInt64 === void 0 ? BigInt(t.getUint32(i, !0)) + (BigInt(t.getUint32(i + 4, !0)) << BigInt(32)) : t.getBigInt64(i, !0);
69
+ }
70
+ function c(t, i, n) {
71
+ return n < 2 ? n < 1 ? t.getUint8(i) : t.getUint16(i, !0) : n < 3 ? t.getUint32(i, !0) : t.getBigUint64 === void 0 ? BigInt(t.getUint32(i, !0)) + (BigInt(t.getUint32(i + 4, !0)) << BigInt(32)) : t.getBigUint64(i, !0);
72
+ }
73
+ function D(t, i, n) {
74
+ if (n < T.WIDTH32)
75
+ throw "Bad width: " + n;
76
+ return n === T.WIDTH32 ? t.getFloat32(i, !0) : t.getFloat64(i, !0);
77
+ }
78
+ function I(t, i, n) {
79
+ const r = c(t, i, n);
80
+ return i - r;
81
+ }
82
+ function V(t, i, n, r, s, h) {
83
+ const o = p(t), u = I(i, n, r) - s * 3, O = f(s), N = u - Number(c(i, u, O)), E = Number(c(i, u + s, O));
84
+ let d = 0, l = h - 1;
85
+ for (; d <= l; ) {
86
+ const _ = l + d >> 1, W = v(o, _, i, N, E);
87
+ if (W === 0) return _;
88
+ W < 0 ? l = _ - 1 : d = _ + 1;
89
+ }
90
+ return null;
91
+ }
92
+ function v(t, i, n, r, s) {
93
+ const h = r + i * s, o = h - Number(c(n, h, f(s)));
94
+ for (let u = 0; u < t.length; u++) {
95
+ const O = t[u] - n.getUint8(o + u);
96
+ if (O !== 0)
97
+ return O;
98
+ }
99
+ return n.getUint8(o + t.length) === 0 ? 0 : -1;
100
+ }
101
+ function y(t, i, n, r, s) {
102
+ const h = I(i, n, r) - s * 3, o = f(s), u = h - Number(c(i, h, o)), O = Number(c(i, h + s, o)), N = u + t * O, E = N - Number(c(i, N, f(O)));
103
+ let d = 0;
104
+ for (; i.getUint8(E + d) !== 0; )
105
+ d++;
106
+ return U(new Uint8Array(i.buffer, E, d));
107
+ }
108
+ function j(t) {
109
+ const i = t.byteLength;
110
+ if (i < 3)
111
+ throw "Buffer needs to be bigger than 3";
112
+ const n = new DataView(t), r = n.getUint8(i - 1), s = n.getUint8(i - 2), h = f(r), o = i - r - 2;
113
+ return new R(n, o, h, s, "/");
114
+ }
115
+ function L(t, i, n, r, s, h, o, u) {
116
+ const O = I(n, r, s), N = O + t * h, E = n.getUint8(O + o * h + t);
117
+ return new R(n, N, f(h), E, `${u}/${i}`);
118
+ }
119
+ class R {
120
+ constructor(i, n, r, s, h) {
121
+ this.dataView = i, this.offset = n, this.parentWidth = r, this.packedType = s, this.path = h, this._length = -1, this.byteWidth = 1 << (s & 3), this.valueType = s >> 2;
122
+ }
123
+ isNull() {
124
+ return this.valueType === e.NULL;
125
+ }
126
+ isNumber() {
127
+ return B(this.valueType) || F(this.valueType);
128
+ }
129
+ isFloat() {
130
+ return e.FLOAT === this.valueType || e.INDIRECT_FLOAT === this.valueType;
131
+ }
132
+ isInt() {
133
+ return this.isNumber() && !this.isFloat();
134
+ }
135
+ isString() {
136
+ return e.STRING === this.valueType || e.KEY === this.valueType;
137
+ }
138
+ isBool() {
139
+ return e.BOOL === this.valueType;
140
+ }
141
+ isBlob() {
142
+ return e.BLOB === this.valueType;
143
+ }
144
+ isVector() {
145
+ return g(this.valueType);
146
+ }
147
+ isMap() {
148
+ return e.MAP === this.valueType;
149
+ }
150
+ boolValue() {
151
+ return this.isBool() ? C(this.dataView, this.offset, this.parentWidth) > 0 : null;
152
+ }
153
+ intValue() {
154
+ return this.valueType === e.INT ? C(this.dataView, this.offset, this.parentWidth) : this.valueType === e.UINT ? c(this.dataView, this.offset, this.parentWidth) : this.valueType === e.INDIRECT_INT ? C(this.dataView, I(this.dataView, this.offset, this.parentWidth), f(this.byteWidth)) : this.valueType === e.INDIRECT_UINT ? c(this.dataView, I(this.dataView, this.offset, this.parentWidth), f(this.byteWidth)) : null;
155
+ }
156
+ floatValue() {
157
+ return this.valueType === e.FLOAT ? D(this.dataView, this.offset, this.parentWidth) : this.valueType === e.INDIRECT_FLOAT ? D(this.dataView, I(this.dataView, this.offset, this.parentWidth), f(this.byteWidth)) : null;
158
+ }
159
+ numericValue() {
160
+ return this.floatValue() || this.intValue();
161
+ }
162
+ stringValue() {
163
+ if (this.valueType === e.STRING || this.valueType === e.KEY) {
164
+ const i = I(this.dataView, this.offset, this.parentWidth);
165
+ return U(new Uint8Array(this.dataView.buffer, i, this.length()));
166
+ }
167
+ return null;
168
+ }
169
+ blobValue() {
170
+ if (this.isBlob()) {
171
+ const i = I(this.dataView, this.offset, this.parentWidth);
172
+ return new Uint8Array(this.dataView.buffer, i, this.length());
173
+ }
174
+ return null;
175
+ }
176
+ get(i) {
177
+ const n = this.length();
178
+ if (Number.isInteger(i) && g(this.valueType)) {
179
+ if (i >= n || i < 0)
180
+ throw `Key: [${i}] is not applicable on ${this.path} of ${this.valueType} length: ${n}`;
181
+ const r = I(this.dataView, this.offset, this.parentWidth), s = r + i * this.byteWidth;
182
+ let h = this.dataView.getUint8(r + n * this.byteWidth + i);
183
+ if (A(this.valueType)) {
184
+ const o = H(this.valueType);
185
+ h = b(o, T.WIDTH8);
186
+ } else if (a(this.valueType)) {
187
+ const o = m(this.valueType);
188
+ h = b(o, T.WIDTH8);
189
+ }
190
+ return new R(this.dataView, s, f(this.byteWidth), h, `${this.path}[${i}]`);
191
+ }
192
+ if (typeof i == "string") {
193
+ const r = V(i, this.dataView, this.offset, this.parentWidth, this.byteWidth, n);
194
+ if (r !== null)
195
+ return L(r, i, this.dataView, this.offset, this.parentWidth, this.byteWidth, n, this.path);
196
+ }
197
+ throw `Key [${i}] is not applicable on ${this.path} of ${this.valueType}`;
198
+ }
199
+ length() {
200
+ let i;
201
+ if (this._length > -1)
202
+ return this._length;
203
+ if (a(this.valueType))
204
+ this._length = w(this.valueType);
205
+ else if (this.valueType === e.BLOB || this.valueType === e.MAP || g(this.valueType))
206
+ this._length = c(this.dataView, I(this.dataView, this.offset, this.parentWidth) - this.byteWidth, f(this.byteWidth));
207
+ else if (this.valueType === e.NULL)
208
+ this._length = 0;
209
+ else if (this.valueType === e.STRING) {
210
+ const n = I(this.dataView, this.offset, this.parentWidth);
211
+ let r = this.byteWidth;
212
+ for (i = c(this.dataView, n - r, f(this.byteWidth)); this.dataView.getInt8(n + i) !== 0; )
213
+ r <<= 1, i = c(this.dataView, n - r, f(this.byteWidth));
214
+ this._length = i;
215
+ } else if (this.valueType === e.KEY) {
216
+ const n = I(this.dataView, this.offset, this.parentWidth);
217
+ for (i = 1; this.dataView.getInt8(n + i) !== 0; )
218
+ i++;
219
+ this._length = i;
220
+ } else
221
+ this._length = 1;
222
+ return Number(this._length);
223
+ }
224
+ toObject() {
225
+ const i = this.length();
226
+ if (this.isVector()) {
227
+ const n = [];
228
+ for (let r = 0; r < i; r++)
229
+ n.push(this.get(r).toObject());
230
+ return n;
231
+ }
232
+ if (this.isMap()) {
233
+ const n = {};
234
+ for (let r = 0; r < i; r++) {
235
+ const s = y(r, this.dataView, this.offset, this.parentWidth, this.byteWidth);
236
+ n[s] = L(r, s, this.dataView, this.offset, this.parentWidth, this.byteWidth, i, this.path).toObject();
237
+ }
238
+ return n;
239
+ }
240
+ return this.isNull() ? null : this.isBool() ? this.boolValue() : this.isNumber() ? this.numericValue() : this.blobValue() || this.stringValue();
241
+ }
242
+ }
243
+ export {
244
+ T as B,
245
+ e as V,
246
+ G as a,
247
+ p as b,
248
+ P as c,
249
+ B as d,
250
+ Y as e,
251
+ f,
252
+ K as g,
253
+ $ as h,
254
+ M as i,
255
+ j,
256
+ b as p,
257
+ S as t,
258
+ x as u
259
+ };