@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.
package/workers/main.js CHANGED
@@ -1,226 +1,226 @@
1
- import { w as b, p as Z, t as tt } from "../comlink.js";
2
- import { i as P, u as T, V as d, B as O, f as N, p as et, a as Y, t as it, b as j, c as st, d as ot, e as nt, g as rt, h as at, j as C } from "../reference.js";
1
+ import { w as y, p as tt, t as et } from "../comlink.js";
2
+ import { i as C, u as U, V as d, B as b, f as B, p as it, a as G, t as st, b as H, c as rt, d as ot, e as nt, g as at, h as lt, j } from "../reference.js";
3
3
  import { z as k } from "../index.js";
4
- let F = Symbol("clean"), y = [], lt = (e, t) => {
5
- let i = [], s = {
4
+ let F = Symbol("clean"), m = [], ct = (i, t) => {
5
+ let e = [], s = {
6
6
  get() {
7
7
  return s.lc || s.listen(() => {
8
8
  })(), s.value;
9
9
  },
10
10
  l: 0,
11
11
  lc: 0,
12
- listen(o, n) {
13
- return s.lc = i.push(o, n || s.l) / 2, () => {
14
- let r = i.indexOf(o);
15
- ~r && (i.splice(r, 2), --s.lc || s.off());
12
+ listen(r, o) {
13
+ return s.lc = e.push(r, o || s.l) / 2, () => {
14
+ let n = e.indexOf(r);
15
+ ~n && (e.splice(n, 2), --s.lc || s.off());
16
16
  };
17
17
  },
18
- notify(o) {
19
- let n = !y.length;
20
- for (let r = 0; r < i.length; r += 2)
21
- y.push(
22
- i[r],
23
- i[r + 1],
18
+ notify(r) {
19
+ let o = !m.length;
20
+ for (let n = 0; n < e.length; n += 2)
21
+ m.push(
22
+ e[n],
23
+ e[n + 1],
24
24
  s.value,
25
- o
25
+ r
26
26
  );
27
- if (n) {
28
- for (let r = 0; r < y.length; r += 4) {
27
+ if (o) {
28
+ for (let n = 0; n < m.length; n += 4) {
29
29
  let h;
30
- for (let c = r + 1; !h && (c += 4) < y.length; )
31
- y[c] < y[r + 1] && (h = y.push(
32
- y[r],
33
- y[r + 1],
34
- y[r + 2],
35
- y[r + 3]
30
+ for (let f = n + 1; !h && (f += 4) < m.length; )
31
+ m[f] < m[n + 1] && (h = m.push(
32
+ m[n],
33
+ m[n + 1],
34
+ m[n + 2],
35
+ m[n + 3]
36
36
  ));
37
- h || y[r](y[r + 2], y[r + 3]);
37
+ h || m[n](m[n + 2], m[n + 3]);
38
38
  }
39
- y.length = 0;
39
+ m.length = 0;
40
40
  }
41
41
  },
42
42
  off() {
43
43
  },
44
44
  /* It will be called on last listener unsubscribing.
45
45
  We will redefine it in onMount and onStop. */
46
- set(o) {
47
- s.value !== o && (s.value = o, s.notify());
46
+ set(r) {
47
+ s.value !== r && (s.value = r, s.notify());
48
48
  },
49
- subscribe(o, n) {
50
- let r = s.listen(o, n);
51
- return o(s.value), r;
49
+ subscribe(r, o) {
50
+ let n = s.listen(r, o);
51
+ return r(s.value), n;
52
52
  },
53
- value: e
53
+ value: i
54
54
  };
55
55
  return process.env.NODE_ENV !== "production" && (s[F] = () => {
56
- i = [], s.lc = 0, s.off();
56
+ e = [], s.lc = 0, s.off();
57
57
  }), s;
58
58
  };
59
- const ft = 5, S = 6, V = 10;
60
- let ct = (e, t, i, s) => (e.events = e.events || {}, e.events[i + V] || (e.events[i + V] = s((o) => {
61
- e.events[i].reduceRight((n, r) => (r(n), n), {
59
+ const ft = 5, R = 6, V = 10;
60
+ let ht = (i, t, e, s) => (i.events = i.events || {}, i.events[e + V] || (i.events[e + V] = s((r) => {
61
+ i.events[e].reduceRight((o, n) => (n(o), o), {
62
62
  shared: {},
63
- ...o
63
+ ...r
64
64
  });
65
- })), e.events[i] = e.events[i] || [], e.events[i].push(t), () => {
66
- let o = e.events[i], n = o.indexOf(t);
67
- o.splice(n, 1), o.length || (delete e.events[i], e.events[i + V](), delete e.events[i + V]);
68
- }), ht = 1e3, dt = (e, t) => ct(e, (s) => {
69
- let o = t(s);
70
- o && e.events[S].push(o);
65
+ })), i.events[e] = i.events[e] || [], i.events[e].push(t), () => {
66
+ let r = i.events[e], o = r.indexOf(t);
67
+ r.splice(o, 1), r.length || (delete i.events[e], i.events[e + V](), delete i.events[e + V]);
68
+ }), dt = 1e3, ut = (i, t) => ht(i, (s) => {
69
+ let r = t(s);
70
+ r && i.events[R].push(r);
71
71
  }, ft, (s) => {
72
- let o = e.listen;
73
- e.listen = (...r) => (!e.lc && !e.active && (e.active = !0, s()), o(...r));
74
- let n = e.off;
75
- if (e.events[S] = [], e.off = () => {
76
- n(), setTimeout(() => {
77
- if (e.active && !e.lc) {
78
- e.active = !1;
79
- for (let r of e.events[S]) r();
80
- e.events[S] = [];
72
+ let r = i.listen;
73
+ i.listen = (...n) => (!i.lc && !i.active && (i.active = !0, s()), r(...n));
74
+ let o = i.off;
75
+ if (i.events[R] = [], i.off = () => {
76
+ o(), setTimeout(() => {
77
+ if (i.active && !i.lc) {
78
+ i.active = !1;
79
+ for (let n of i.events[R]) n();
80
+ i.events[R] = [];
81
81
  }
82
- }, ht);
82
+ }, dt);
83
83
  }, process.env.NODE_ENV !== "production") {
84
- let r = e[F];
85
- e[F] = () => {
86
- for (let h of e.events[S]) h();
87
- e.events[S] = [], e.active = !1, r();
84
+ let n = i[F];
85
+ i[F] = () => {
86
+ for (let h of i.events[R]) h();
87
+ i.events[R] = [], i.active = !1, n();
88
88
  };
89
89
  }
90
90
  return () => {
91
- e.listen = o, e.off = n;
91
+ i.listen = r, i.off = o;
92
92
  };
93
- }), ut = (e = {}) => {
94
- let t = lt(e);
95
- return t.setKey = function(i, s) {
96
- typeof s > "u" ? i in t.value && (t.value = { ...t.value }, delete t.value[i], t.notify(i)) : t.value[i] !== s && (t.value = {
93
+ }), wt = (i = {}) => {
94
+ let t = ct(i);
95
+ return t.setKey = function(e, s) {
96
+ typeof s > "u" ? e in t.value && (t.value = { ...t.value }, delete t.value[e], t.notify(e)) : t.value[e] !== s && (t.value = {
97
97
  ...t.value,
98
- [i]: s
99
- }, t.notify(i));
98
+ [e]: s
99
+ }, t.notify(e));
100
100
  }, t;
101
- }, H = (e) => e, U = {}, v = { addEventListener() {
101
+ }, _ = (i) => i, W = {}, E = { addEventListener() {
102
102
  }, removeEventListener() {
103
103
  } };
104
- function wt() {
104
+ function pt() {
105
105
  try {
106
106
  return typeof localStorage < "u";
107
107
  } catch {
108
108
  return !1;
109
109
  }
110
110
  }
111
- wt() && (U = localStorage);
112
- let pt = {
113
- addEventListener(e, t, i) {
114
- window.addEventListener("storage", t), window.addEventListener("pageshow", i);
111
+ pt() && (W = localStorage);
112
+ let kt = {
113
+ addEventListener(i, t, e) {
114
+ window.addEventListener("storage", t), window.addEventListener("pageshow", e);
115
115
  },
116
- removeEventListener(e, t, i) {
117
- window.removeEventListener("storage", t), window.removeEventListener("pageshow", i);
116
+ removeEventListener(i, t, e) {
117
+ window.removeEventListener("storage", t), window.removeEventListener("pageshow", e);
118
118
  }
119
119
  };
120
- typeof window < "u" && (v = pt);
121
- function G(e, t = {}, i = {}) {
122
- let s = i.encode || H, o = i.decode || H, n = ut(), r = n.setKey;
123
- n.setKey = (a, l) => {
124
- typeof l > "u" ? (i.listen !== !1 && v.perKey && v.removeEventListener(e + a, c, u), delete U[e + a]) : (i.listen !== !1 && v.perKey && !(a in n.value) && v.addEventListener(e + a, c, u), U[e + a] = s(l)), r(a, l);
120
+ typeof window < "u" && (E = kt);
121
+ function J(i, t = {}, e = {}) {
122
+ let s = e.encode || _, r = e.decode || _, o = wt(), n = o.setKey;
123
+ o.setKey = (a, l) => {
124
+ typeof l > "u" ? (e.listen !== !1 && E.perKey && E.removeEventListener(i + a, f, u), delete W[i + a]) : (e.listen !== !1 && E.perKey && !(a in o.value) && E.addEventListener(i + a, f, u), W[i + a] = s(l)), n(a, l);
125
125
  };
126
- let h = n.set;
127
- n.set = function(a) {
126
+ let h = o.set;
127
+ o.set = function(a) {
128
128
  for (let l in a)
129
- n.setKey(l, a[l]);
130
- for (let l in n.value)
131
- l in a || n.setKey(l);
129
+ o.setKey(l, a[l]);
130
+ for (let l in o.value)
131
+ l in a || o.setKey(l);
132
132
  };
133
- function c(a) {
134
- a.key ? a.key.startsWith(e) && (a.newValue === null ? r(a.key.slice(e.length), void 0) : r(a.key.slice(e.length), o(a.newValue))) : h({});
133
+ function f(a) {
134
+ a.key ? a.key.startsWith(i) && (a.newValue === null ? n(a.key.slice(i.length), void 0) : n(a.key.slice(i.length), r(a.newValue))) : h({});
135
135
  }
136
136
  function u() {
137
137
  let a = { ...t };
138
- for (let l in U)
139
- l.startsWith(e) && (a[l.slice(e.length)] = o(U[l]));
140
- n.set(a);
141
- }
142
- return dt(n, () => {
143
- if (u(), i.listen !== !1)
144
- return v.addEventListener(e, c, u), () => {
145
- v.removeEventListener(e, c, u);
146
- for (let a in n.value)
147
- v.removeEventListener(e + a, c, u);
138
+ for (let l in W)
139
+ l.startsWith(i) && (a[l.slice(i.length)] = r(W[l]));
140
+ o.set(a);
141
+ }
142
+ return ut(o, () => {
143
+ if (u(), e.listen !== !1)
144
+ return E.addEventListener(i, f, u), () => {
145
+ E.removeEventListener(i, f, u);
146
+ for (let a in o.value)
147
+ E.removeEventListener(i + a, f, u);
148
148
  };
149
- }), n;
149
+ }), o;
150
150
  }
151
- async function kt(e, {
151
+ async function yt(i, {
152
152
  version: t,
153
- i18nPath: i = "https://discord.sh/i18n/db.json",
153
+ i18nPath: e = "https://discord.sh/i18n/db.json",
154
154
  locale: s = "en",
155
- defaults: o = {
155
+ defaults: r = {
156
156
  welcome: "Welcome to the app!"
157
157
  }
158
158
  }) {
159
159
  console.log("[init-worker] Initializing database...");
160
160
  try {
161
- await e.loadI18nFromJSON(i), console.log(`[init-worker] i18n loaded from ${i}`), await e.dbSet("locale", s);
162
- for (const [n, r] of Object.entries(o))
163
- await e.dbSet(n, r);
164
- await e.setVersion(t), e.loadServersFromJSON(), console.log(`[init-worker] DB initialized to version ${t}`);
165
- } catch (n) {
166
- console.error("[init-worker] Initialization failed:", n);
161
+ await i.loadI18nFromJSON(e), console.log(`[init-worker] i18n loaded from ${e}`), await i.dbSet("locale", s);
162
+ for (const [o, n] of Object.entries(r))
163
+ await i.dbSet(o, n);
164
+ await i.setVersion(t), i.loadServersFromJSON(), console.log(`[init-worker] DB initialized to version ${t}`);
165
+ } catch (o) {
166
+ console.error("[init-worker] Initialization failed:", o);
167
167
  }
168
168
  }
169
- let W = null;
170
- async function yt(e) {
171
- if (W) return W;
169
+ let N = null;
170
+ async function mt(i) {
171
+ if (N) return N;
172
172
  const t = {};
173
- async function i(r) {
174
- const h = e?.(r) ?? r, c = new Worker(h, { type: "module" }), u = b(c), a = await u.getMeta?.() ?? {
173
+ async function e(n) {
174
+ const h = i?.(n) ?? n, f = new Worker(h, { type: "module" }), u = y(f), a = await u.getMeta?.() ?? {
175
175
  name: "unknown",
176
176
  version: "0.0.1"
177
177
  }, l = `${a.name}@${a.version}`;
178
178
  console.log(`[mod-manager] ${l} is loaded.`);
179
- const f = { id: l, worker: c, instance: u, meta: a, url: r };
180
- return t[l] = f, f;
179
+ const c = { id: l, worker: f, instance: u, meta: a, url: n };
180
+ return t[l] = c, c;
181
181
  }
182
- function s(r) {
183
- t[r] && (t[r].worker.terminate(), delete t[r]);
182
+ function s(n) {
183
+ t[n] && (t[n].worker.terminate(), delete t[n]);
184
184
  }
185
- function o() {
186
- return Object.values(t).map((r) => r.meta);
185
+ function r() {
186
+ return Object.values(t).map((n) => n.meta);
187
187
  }
188
- async function n(r) {
189
- const h = t[r];
190
- if (!h) throw new Error(`Mod "${r}" not found`);
191
- return s(r), i(h.url);
188
+ async function o(n) {
189
+ const h = t[n];
190
+ if (!h) throw new Error(`Mod "${n}" not found`);
191
+ return s(n), e(h.url);
192
192
  }
193
- return W = {
193
+ return N = {
194
194
  registry: t,
195
- load: i,
195
+ load: e,
196
196
  unload: s,
197
- list: o,
198
- reload: n
199
- }, W;
197
+ list: r,
198
+ reload: o
199
+ }, N;
200
200
  }
201
- var E = /* @__PURE__ */ ((e) => (e[e.PAYLOAD_UNKNOWN = 0] = "PAYLOAD_UNKNOWN", e[e.JSON = 1] = "JSON", e[e.FLEX = 2] = "FLEX", e[e.PROTOBUF = 3] = "PROTOBUF", e[e.FLATBUFFER = 4] = "FLATBUFFER", e))(E || {}), m = /* @__PURE__ */ ((e) => (e[e.UNKNOWN = 0] = "UNKNOWN", e[e.ADD = 1] = "ADD", e[e.READ = 2] = "READ", e[e.GET = 4] = "GET", e[e.SET = 8] = "SET", e[e.DEL = 16] = "DEL", e[e.STREAM = 32] = "STREAM", e[e.GROUP = 64] = "GROUP", e[e.LIST = 128] = "LIST", e[e.ACTION = 256] = "ACTION", e[e.MESSAGE = 512] = "MESSAGE", e[e.INFO = 1024] = "INFO", e[e.DEBUG = 2048] = "DEBUG", e[e.ERROR = 4096] = "ERROR", e[e.AUTH = 8192] = "AUTH", e[e.HEARTBEAT = 16384] = "HEARTBEAT", e[e.CONFIG_UPDATE = 32768] = "CONFIG_UPDATE", e[e.REDIS = 65536] = "REDIS", e[e.SUPABASE = 131072] = "SUPABASE", e[e.FILESYSTEM = 262144] = "FILESYSTEM", e[e.WEBSOCKET = 524288] = "WEBSOCKET", e[e.HTTP_API = 1048576] = "HTTP_API", e[e.LOCAL_CACHE = 2097152] = "LOCAL_CACHE", e[e.AI = 4194304] = "AI", e))(m || {});
202
- class R {
203
- constructor(t, i, s, o = null, n = 0) {
204
- this.builder = t, this.type = i, this.width = s, this.value = o, this.offset = n;
201
+ var v = /* @__PURE__ */ ((i) => (i[i.PAYLOAD_UNKNOWN = 0] = "PAYLOAD_UNKNOWN", i[i.JSON = 1] = "JSON", i[i.FLEX = 2] = "FLEX", i[i.PROTOBUF = 3] = "PROTOBUF", i[i.FLATBUFFER = 4] = "FLATBUFFER", i))(v || {}), g = /* @__PURE__ */ ((i) => (i[i.UNKNOWN = 0] = "UNKNOWN", i[i.ADD = 1] = "ADD", i[i.READ = 2] = "READ", i[i.GET = 4] = "GET", i[i.SET = 8] = "SET", i[i.DEL = 16] = "DEL", i[i.STREAM = 32] = "STREAM", i[i.GROUP = 64] = "GROUP", i[i.LIST = 128] = "LIST", i[i.ACTION = 256] = "ACTION", i[i.MESSAGE = 512] = "MESSAGE", i[i.INFO = 1024] = "INFO", i[i.DEBUG = 2048] = "DEBUG", i[i.ERROR = 4096] = "ERROR", i[i.AUTH = 8192] = "AUTH", i[i.HEARTBEAT = 16384] = "HEARTBEAT", i[i.CONFIG_UPDATE = 32768] = "CONFIG_UPDATE", i[i.REDIS = 65536] = "REDIS", i[i.SUPABASE = 131072] = "SUPABASE", i[i.FILESYSTEM = 262144] = "FILESYSTEM", i[i.WEBSOCKET = 524288] = "WEBSOCKET", i[i.HTTP_API = 1048576] = "HTTP_API", i[i.LOCAL_CACHE = 2097152] = "LOCAL_CACHE", i[i.AI = 4194304] = "AI", i))(g || {});
202
+ class S {
203
+ constructor(t, e, s, r = null, o = 0) {
204
+ this.builder = t, this.type = e, this.width = s, this.value = r, this.offset = o;
205
205
  }
206
- elementWidth(t, i) {
207
- if (P(this.type)) return this.width;
206
+ elementWidth(t, e) {
207
+ if (C(this.type)) return this.width;
208
208
  for (let s = 0; s < 4; s++) {
209
- const o = 1 << s, r = t + Y(t, o) + i * o - this.offset, h = T(r);
210
- if (1 << h === o)
209
+ const r = 1 << s, n = t + G(t, r) + e * r - this.offset, h = U(n);
210
+ if (1 << h === r)
211
211
  return h;
212
212
  }
213
- throw `Element is unknown. Size: ${t} at index: ${i}. This might be a bug. Please create an issue https://github.com/google/flatbuffers/issues/new`;
213
+ throw `Element is unknown. Size: ${t} at index: ${e}. This might be a bug. Please create an issue https://github.com/google/flatbuffers/issues/new`;
214
214
  }
215
215
  writeToBuffer(t) {
216
- const i = this.builder.computeOffset(t);
216
+ const e = this.builder.computeOffset(t);
217
217
  if (this.type === d.FLOAT)
218
- this.width === O.WIDTH32 ? this.builder.view.setFloat32(this.builder.offset, this.value, !0) : this.builder.view.setFloat64(this.builder.offset, this.value, !0);
218
+ this.width === b.WIDTH32 ? this.builder.view.setFloat32(this.builder.offset, this.value, !0) : this.builder.view.setFloat64(this.builder.offset, this.value, !0);
219
219
  else if (this.type === d.INT) {
220
- const s = N(t);
220
+ const s = B(t);
221
221
  this.builder.pushInt(this.value, s);
222
222
  } else if (this.type === d.UINT) {
223
- const s = N(t);
223
+ const s = B(t);
224
224
  this.builder.pushUInt(this.value, s);
225
225
  } else if (this.type === d.NULL)
226
226
  this.builder.pushInt(0, this.width);
@@ -228,108 +228,108 @@ class R {
228
228
  this.builder.pushInt(this.value ? 1 : 0, this.width);
229
229
  else
230
230
  throw `Unexpected type: ${this.type}. This might be a bug. Please create an issue https://github.com/google/flatbuffers/issues/new`;
231
- this.offset = i;
231
+ this.offset = e;
232
232
  }
233
- storedWidth(t = O.WIDTH8) {
234
- return P(this.type) ? Math.max(t, this.width) : this.width;
233
+ storedWidth(t = b.WIDTH8) {
234
+ return C(this.type) ? Math.max(t, this.width) : this.width;
235
235
  }
236
- storedPackedType(t = O.WIDTH8) {
237
- return et(this.type, this.storedWidth(t));
236
+ storedPackedType(t = b.WIDTH8) {
237
+ return it(this.type, this.storedWidth(t));
238
238
  }
239
239
  isOffset() {
240
- return !P(this.type);
240
+ return !C(this.type);
241
241
  }
242
242
  }
243
- class mt {
244
- constructor(t = 2048, i = !0, s = !0, o = !0) {
245
- this.dedupStrings = i, this.dedupKeys = s, this.dedupKeyVectors = o, this.stack = [], this.stackPointers = [], this.offset = 0, this.finished = !1, this.stringLookup = {}, this.keyLookup = {}, this.keyVectorLookup = {}, this.indirectIntLookup = {}, this.indirectUIntLookup = {}, this.indirectFloatLookup = {}, this.buffer = new ArrayBuffer(t > 0 ? t : 2048), this.view = new DataView(this.buffer);
243
+ class gt {
244
+ constructor(t = 2048, e = !0, s = !0, r = !0) {
245
+ this.dedupStrings = e, this.dedupKeys = s, this.dedupKeyVectors = r, this.stack = [], this.stackPointers = [], this.offset = 0, this.finished = !1, this.stringLookup = {}, this.keyLookup = {}, this.keyVectorLookup = {}, this.indirectIntLookup = {}, this.indirectUIntLookup = {}, this.indirectFloatLookup = {}, this.buffer = new ArrayBuffer(t > 0 ? t : 2048), this.view = new DataView(this.buffer);
246
246
  }
247
247
  align(t) {
248
- const i = it(t);
249
- return this.offset += Y(this.offset, i), i;
248
+ const e = st(t);
249
+ return this.offset += G(this.offset, e), e;
250
250
  }
251
251
  computeOffset(t) {
252
- const i = this.offset + t;
252
+ const e = this.offset + t;
253
253
  let s = this.buffer.byteLength;
254
- const o = s;
255
- for (; s < i; )
254
+ const r = s;
255
+ for (; s < e; )
256
256
  s <<= 1;
257
- if (o < s) {
258
- const n = this.buffer;
259
- this.buffer = new ArrayBuffer(s), this.view = new DataView(this.buffer), new Uint8Array(this.buffer).set(new Uint8Array(n), 0);
257
+ if (r < s) {
258
+ const o = this.buffer;
259
+ this.buffer = new ArrayBuffer(s), this.view = new DataView(this.buffer), new Uint8Array(this.buffer).set(new Uint8Array(o), 0);
260
260
  }
261
- return i;
261
+ return e;
262
262
  }
263
- pushInt(t, i) {
264
- if (i === O.WIDTH8)
263
+ pushInt(t, e) {
264
+ if (e === b.WIDTH8)
265
265
  this.view.setInt8(this.offset, t);
266
- else if (i === O.WIDTH16)
266
+ else if (e === b.WIDTH16)
267
267
  this.view.setInt16(this.offset, t, !0);
268
- else if (i === O.WIDTH32)
268
+ else if (e === b.WIDTH32)
269
269
  this.view.setInt32(this.offset, t, !0);
270
- else if (i === O.WIDTH64)
270
+ else if (e === b.WIDTH64)
271
271
  this.view.setBigInt64(this.offset, BigInt(t), !0);
272
272
  else
273
- throw `Unexpected width: ${i} for value: ${t}`;
273
+ throw `Unexpected width: ${e} for value: ${t}`;
274
274
  }
275
- pushUInt(t, i) {
276
- if (i === O.WIDTH8)
275
+ pushUInt(t, e) {
276
+ if (e === b.WIDTH8)
277
277
  this.view.setUint8(this.offset, t);
278
- else if (i === O.WIDTH16)
278
+ else if (e === b.WIDTH16)
279
279
  this.view.setUint16(this.offset, t, !0);
280
- else if (i === O.WIDTH32)
280
+ else if (e === b.WIDTH32)
281
281
  this.view.setUint32(this.offset, t, !0);
282
- else if (i === O.WIDTH64)
282
+ else if (e === b.WIDTH64)
283
283
  this.view.setBigUint64(this.offset, BigInt(t), !0);
284
284
  else
285
- throw `Unexpected width: ${i} for value: ${t}`;
285
+ throw `Unexpected width: ${e} for value: ${t}`;
286
286
  }
287
- writeInt(t, i) {
288
- const s = this.computeOffset(i);
289
- this.pushInt(t, N(i)), this.offset = s;
287
+ writeInt(t, e) {
288
+ const s = this.computeOffset(e);
289
+ this.pushInt(t, B(e)), this.offset = s;
290
290
  }
291
- writeUInt(t, i) {
292
- const s = this.computeOffset(i);
293
- this.pushUInt(t, N(i)), this.offset = s;
291
+ writeUInt(t, e) {
292
+ const s = this.computeOffset(e);
293
+ this.pushUInt(t, B(e)), this.offset = s;
294
294
  }
295
295
  writeBlob(t) {
296
- const i = t.byteLength, s = T(i), o = this.align(s);
297
- this.writeUInt(i, o);
298
- const n = this.offset, r = this.computeOffset(i);
299
- new Uint8Array(this.buffer).set(new Uint8Array(t), n), this.stack.push(this.offsetStackValue(n, d.BLOB, s)), this.offset = r;
296
+ const e = t.byteLength, s = U(e), r = this.align(s);
297
+ this.writeUInt(e, r);
298
+ const o = this.offset, n = this.computeOffset(e);
299
+ new Uint8Array(this.buffer).set(new Uint8Array(t), o), this.stack.push(this.offsetStackValue(o, d.BLOB, s)), this.offset = n;
300
300
  }
301
301
  writeString(t) {
302
302
  if (this.dedupStrings && Object.prototype.hasOwnProperty.call(this.stringLookup, t)) {
303
303
  this.stack.push(this.stringLookup[t]);
304
304
  return;
305
305
  }
306
- const i = j(t), s = i.length, o = T(s), n = this.align(o);
307
- this.writeUInt(s, n);
308
- const r = this.offset, h = this.computeOffset(s + 1);
309
- new Uint8Array(this.buffer).set(i, r);
310
- const c = this.offsetStackValue(r, d.STRING, o);
311
- this.stack.push(c), this.dedupStrings && (this.stringLookup[t] = c), this.offset = h;
306
+ const e = H(t), s = e.length, r = U(s), o = this.align(r);
307
+ this.writeUInt(s, o);
308
+ const n = this.offset, h = this.computeOffset(s + 1);
309
+ new Uint8Array(this.buffer).set(e, n);
310
+ const f = this.offsetStackValue(n, d.STRING, r);
311
+ this.stack.push(f), this.dedupStrings && (this.stringLookup[t] = f), this.offset = h;
312
312
  }
313
313
  writeKey(t) {
314
314
  if (this.dedupKeys && Object.prototype.hasOwnProperty.call(this.keyLookup, t)) {
315
315
  this.stack.push(this.keyLookup[t]);
316
316
  return;
317
317
  }
318
- const i = j(t), s = i.length, o = this.computeOffset(s + 1);
319
- new Uint8Array(this.buffer).set(i, this.offset);
320
- const n = this.offsetStackValue(this.offset, d.KEY, O.WIDTH8);
321
- this.stack.push(n), this.dedupKeys && (this.keyLookup[t] = n), this.offset = o;
318
+ const e = H(t), s = e.length, r = this.computeOffset(s + 1);
319
+ new Uint8Array(this.buffer).set(e, this.offset);
320
+ const o = this.offsetStackValue(this.offset, d.KEY, b.WIDTH8);
321
+ this.stack.push(o), this.dedupKeys && (this.keyLookup[t] = o), this.offset = r;
322
322
  }
323
- writeStackValue(t, i) {
324
- const s = this.computeOffset(i);
323
+ writeStackValue(t, e) {
324
+ const s = this.computeOffset(e);
325
325
  if (t.isOffset()) {
326
- const o = this.offset - t.offset;
327
- if (i === 8 || BigInt(o) < BigInt(1) << BigInt(i * 8))
328
- this.writeUInt(o, i);
326
+ const r = this.offset - t.offset;
327
+ if (e === 8 || BigInt(r) < BigInt(1) << BigInt(e * 8))
328
+ this.writeUInt(r, e);
329
329
  else
330
- throw `Unexpected size ${i}. This might be a bug. Please create an issue https://github.com/google/flatbuffers/issues/new`;
330
+ throw `Unexpected size ${e}. This might be a bug. Please create an issue https://github.com/google/flatbuffers/issues/new`;
331
331
  } else
332
- t.writeToBuffer(i);
332
+ t.writeToBuffer(e);
333
333
  this.offset = s;
334
334
  }
335
335
  integrityCheckOnValueAddition() {
@@ -351,43 +351,43 @@ class mt {
351
351
  this.stackPointers.push({ stackPosition: this.stack.length, isVector: !1, presorted: t });
352
352
  }
353
353
  endVector(t) {
354
- const i = this.stack.length - t.stackPosition, s = this.createVector(t.stackPosition, i, 1);
355
- this.stack.splice(t.stackPosition, i), this.stack.push(s);
354
+ const e = this.stack.length - t.stackPosition, s = this.createVector(t.stackPosition, e, 1);
355
+ this.stack.splice(t.stackPosition, e), this.stack.push(s);
356
356
  }
357
357
  endMap(t) {
358
358
  t.presorted || this.sort(t);
359
- let i = "";
360
- for (let r = t.stackPosition; r < this.stack.length; r += 2)
361
- i += `,${this.stack[r].offset}`;
359
+ let e = "";
360
+ for (let n = t.stackPosition; n < this.stack.length; n += 2)
361
+ e += `,${this.stack[n].offset}`;
362
362
  const s = this.stack.length - t.stackPosition >> 1;
363
- this.dedupKeyVectors && !Object.prototype.hasOwnProperty.call(this.keyVectorLookup, i) && (this.keyVectorLookup[i] = this.createVector(t.stackPosition, s, 2));
364
- const o = this.dedupKeyVectors ? this.keyVectorLookup[i] : this.createVector(t.stackPosition, s, 2), n = this.createVector(t.stackPosition + 1, s, 2, o);
365
- this.stack.splice(t.stackPosition, s << 1), this.stack.push(n);
363
+ this.dedupKeyVectors && !Object.prototype.hasOwnProperty.call(this.keyVectorLookup, e) && (this.keyVectorLookup[e] = this.createVector(t.stackPosition, s, 2));
364
+ const r = this.dedupKeyVectors ? this.keyVectorLookup[e] : this.createVector(t.stackPosition, s, 2), o = this.createVector(t.stackPosition + 1, s, 2, r);
365
+ this.stack.splice(t.stackPosition, s << 1), this.stack.push(o);
366
366
  }
367
367
  sort(t) {
368
- const i = this.view, s = this.stack;
369
- function o(a, l) {
368
+ const e = this.view, s = this.stack;
369
+ function r(a, l) {
370
370
  if (a.type !== d.KEY || l.type !== d.KEY)
371
371
  throw `Stack values are not keys ${a} | ${l}. Check if you combined [addKey] with add... method calls properly.`;
372
- let f, w, p = 0;
372
+ let c, w, p = 0;
373
373
  do {
374
- if (f = i.getUint8(a.offset + p), w = i.getUint8(l.offset + p), w < f) return !0;
375
- if (f < w) return !1;
374
+ if (c = e.getUint8(a.offset + p), w = e.getUint8(l.offset + p), w < c) return !0;
375
+ if (c < w) return !1;
376
376
  p += 1;
377
- } while (f !== 0 && w !== 0);
377
+ } while (c !== 0 && w !== 0);
378
378
  return !1;
379
379
  }
380
- function n(a, l, f) {
381
- if (l === f) return;
380
+ function o(a, l, c) {
381
+ if (l === c) return;
382
382
  const w = a[l], p = a[l + 1];
383
- a[l] = a[f], a[l + 1] = a[f + 1], a[f] = w, a[f + 1] = p;
383
+ a[l] = a[c], a[l + 1] = a[c + 1], a[c] = w, a[c + 1] = p;
384
384
  }
385
- function r() {
385
+ function n() {
386
386
  for (let a = t.stackPosition; a < s.length; a += 2) {
387
387
  let l = a;
388
- for (let f = a + 2; f < s.length; f += 2)
389
- o(s[l], s[f]) && (l = f);
390
- l !== a && n(s, l, a);
388
+ for (let c = a + 2; c < s.length; c += 2)
389
+ r(s[l], s[c]) && (l = c);
390
+ l !== a && o(s, l, a);
391
391
  }
392
392
  }
393
393
  function h(a, l) {
@@ -395,91 +395,91 @@ class mt {
395
395
  throw `Stack values are not keys ${a} | ${l}. Check if you combined [addKey] with add... method calls properly.`;
396
396
  if (a.offset === l.offset)
397
397
  return !1;
398
- let f, w, p = 0;
398
+ let c, w, p = 0;
399
399
  do {
400
- if (f = i.getUint8(a.offset + p), w = i.getUint8(l.offset + p), f < w) return !0;
401
- if (w < f) return !1;
400
+ if (c = e.getUint8(a.offset + p), w = e.getUint8(l.offset + p), c < w) return !0;
401
+ if (w < c) return !1;
402
402
  p += 1;
403
- } while (f !== 0 && w !== 0);
403
+ } while (c !== 0 && w !== 0);
404
404
  return !1;
405
405
  }
406
- function c(a, l) {
406
+ function f(a, l) {
407
407
  if (a < l) {
408
- const f = a + (l - a >> 2) * 2, w = s[f];
408
+ const c = a + (l - a >> 2) * 2, w = s[c];
409
409
  let p = a, I = l;
410
410
  do {
411
411
  for (; h(s[p], w); )
412
412
  p += 2;
413
413
  for (; h(w, s[I]); )
414
414
  I -= 2;
415
- p <= I && (n(s, p, I), p += 2, I -= 2);
415
+ p <= I && (o(s, p, I), p += 2, I -= 2);
416
416
  } while (p <= I);
417
- c(a, I), c(p, l);
417
+ f(a, I), f(p, l);
418
418
  }
419
419
  }
420
420
  let u = !0;
421
421
  for (let a = t.stackPosition; a < this.stack.length - 2; a += 2)
422
- if (o(this.stack[a], this.stack[a + 2])) {
422
+ if (r(this.stack[a], this.stack[a + 2])) {
423
423
  u = !1;
424
424
  break;
425
425
  }
426
- u || (this.stack.length - t.stackPosition > 40 ? c(t.stackPosition, this.stack.length - 2) : r());
426
+ u || (this.stack.length - t.stackPosition > 40 ? f(t.stackPosition, this.stack.length - 2) : n());
427
427
  }
428
428
  end() {
429
429
  if (this.stackPointers.length < 1) return;
430
430
  const t = this.stackPointers.pop();
431
431
  t.isVector ? this.endVector(t) : this.endMap(t);
432
432
  }
433
- createVector(t, i, s, o = null) {
434
- let n = T(i), r = 1;
435
- if (o !== null) {
436
- const f = o.elementWidth(this.offset, 0);
437
- f > n && (n = f), r += 2;
433
+ createVector(t, e, s, r = null) {
434
+ let o = U(e), n = 1;
435
+ if (r !== null) {
436
+ const c = r.elementWidth(this.offset, 0);
437
+ c > o && (o = c), n += 2;
438
438
  }
439
- let h = d.KEY, c = o === null;
440
- for (let f = t; f < this.stack.length; f += s) {
441
- const w = this.stack[f].elementWidth(this.offset, f + r);
442
- w > n && (n = w), f === t ? (h = this.stack[f].type, c = c && st(h)) : h !== this.stack[f].type && (c = !1);
439
+ let h = d.KEY, f = r === null;
440
+ for (let c = t; c < this.stack.length; c += s) {
441
+ const w = this.stack[c].elementWidth(this.offset, c + n);
442
+ w > o && (o = w), c === t ? (h = this.stack[c].type, f = f && rt(h)) : h !== this.stack[c].type && (f = !1);
443
443
  }
444
- const u = this.align(n), a = c && ot(h) && i >= 2 && i <= 4;
445
- o !== null && (this.writeStackValue(o, u), this.writeUInt(1 << o.width, u)), a || this.writeUInt(i, u);
444
+ const u = this.align(o), a = f && ot(h) && e >= 2 && e <= 4;
445
+ r !== null && (this.writeStackValue(r, u), this.writeUInt(1 << r.width, u)), a || this.writeUInt(e, u);
446
446
  const l = this.offset;
447
- for (let f = t; f < this.stack.length; f += s)
448
- this.writeStackValue(this.stack[f], u);
449
- if (!c)
450
- for (let f = t; f < this.stack.length; f += s)
451
- this.writeUInt(this.stack[f].storedPackedType(), 1);
452
- if (o !== null)
453
- return this.offsetStackValue(l, d.MAP, n);
454
- if (c) {
455
- const f = nt(h, a ? i : 0);
456
- return this.offsetStackValue(l, f, n);
447
+ for (let c = t; c < this.stack.length; c += s)
448
+ this.writeStackValue(this.stack[c], u);
449
+ if (!f)
450
+ for (let c = t; c < this.stack.length; c += s)
451
+ this.writeUInt(this.stack[c].storedPackedType(), 1);
452
+ if (r !== null)
453
+ return this.offsetStackValue(l, d.MAP, o);
454
+ if (f) {
455
+ const c = nt(h, a ? e : 0);
456
+ return this.offsetStackValue(l, c, o);
457
457
  }
458
- return this.offsetStackValue(l, d.VECTOR, n);
458
+ return this.offsetStackValue(l, d.VECTOR, o);
459
459
  }
460
460
  nullStackValue() {
461
- return new R(this, d.NULL, O.WIDTH8);
461
+ return new S(this, d.NULL, b.WIDTH8);
462
462
  }
463
463
  boolStackValue(t) {
464
- return new R(this, d.BOOL, O.WIDTH8, t);
464
+ return new S(this, d.BOOL, b.WIDTH8, t);
465
465
  }
466
466
  intStackValue(t) {
467
- return new R(this, d.INT, rt(t), t);
467
+ return new S(this, d.INT, at(t), t);
468
468
  }
469
469
  uintStackValue(t) {
470
- return new R(this, d.UINT, T(t), t);
470
+ return new S(this, d.UINT, U(t), t);
471
471
  }
472
472
  floatStackValue(t) {
473
- return new R(this, d.FLOAT, at(t), t);
473
+ return new S(this, d.FLOAT, lt(t), t);
474
474
  }
475
- offsetStackValue(t, i, s) {
476
- return new R(this, i, s, null, t);
475
+ offsetStackValue(t, e, s) {
476
+ return new S(this, e, s, null, t);
477
477
  }
478
478
  finishBuffer() {
479
479
  if (this.stack.length !== 1)
480
480
  throw `Stack has to be exactly 1, but it is ${this.stack.length}. You have to end all started vectors and maps before calling [finish]`;
481
- const t = this.stack[0], i = this.align(t.elementWidth(this.offset, 0));
482
- this.writeStackValue(t, i), this.writeUInt(t.storedPackedType(), 1), this.writeUInt(i, 1), this.finished = !0;
481
+ const t = this.stack[0], e = this.align(t.elementWidth(this.offset, 0));
482
+ this.writeStackValue(t, e), this.writeUInt(t.storedPackedType(), 1), this.writeUInt(e, 1), this.finished = !0;
483
483
  }
484
484
  add(t) {
485
485
  if (this.integrityCheckOnValueAddition(), typeof t > "u")
@@ -498,15 +498,15 @@ class mt {
498
498
  this.writeString(t);
499
499
  else if (Array.isArray(t)) {
500
500
  this.startVector();
501
- for (let i = 0; i < t.length; i++)
502
- this.add(t[i]);
501
+ for (let e = 0; e < t.length; e++)
502
+ this.add(t[e]);
503
503
  this.end();
504
504
  } else if (typeof t == "object") {
505
- const i = Object.getOwnPropertyNames(t).sort();
505
+ const e = Object.getOwnPropertyNames(t).sort();
506
506
  this.startMap(!0);
507
- for (let s = 0; s < i.length; s++) {
508
- const o = i[s];
509
- this.addKey(o), this.add(t[o]);
507
+ for (let s = 0; s < e.length; s++) {
508
+ const r = e[s];
509
+ this.addKey(r), this.add(t[r]);
510
510
  }
511
511
  this.end();
512
512
  } else
@@ -523,8 +523,8 @@ class mt {
523
523
  addKey(t) {
524
524
  this.integrityCheckOnKeyAddition(), this.writeKey(t);
525
525
  }
526
- addInt(t, i = !1, s = !1) {
527
- if (this.integrityCheckOnValueAddition(), !i) {
526
+ addInt(t, e = !1, s = !1) {
527
+ if (this.integrityCheckOnValueAddition(), !e) {
528
528
  this.stack.push(this.intStackValue(t));
529
529
  return;
530
530
  }
@@ -532,13 +532,13 @@ class mt {
532
532
  this.stack.push(this.indirectIntLookup[t]);
533
533
  return;
534
534
  }
535
- const o = this.intStackValue(t), n = this.align(o.width), r = this.computeOffset(n), h = this.offset;
536
- o.writeToBuffer(n);
537
- const c = this.offsetStackValue(h, d.INDIRECT_INT, o.width);
538
- this.stack.push(c), this.offset = r, s && (this.indirectIntLookup[t] = c);
535
+ const r = this.intStackValue(t), o = this.align(r.width), n = this.computeOffset(o), h = this.offset;
536
+ r.writeToBuffer(o);
537
+ const f = this.offsetStackValue(h, d.INDIRECT_INT, r.width);
538
+ this.stack.push(f), this.offset = n, s && (this.indirectIntLookup[t] = f);
539
539
  }
540
- addUInt(t, i = !1, s = !1) {
541
- if (this.integrityCheckOnValueAddition(), !i) {
540
+ addUInt(t, e = !1, s = !1) {
541
+ if (this.integrityCheckOnValueAddition(), !e) {
542
542
  this.stack.push(this.uintStackValue(t));
543
543
  return;
544
544
  }
@@ -546,13 +546,13 @@ class mt {
546
546
  this.stack.push(this.indirectUIntLookup[t]);
547
547
  return;
548
548
  }
549
- const o = this.uintStackValue(t), n = this.align(o.width), r = this.computeOffset(n), h = this.offset;
550
- o.writeToBuffer(n);
551
- const c = this.offsetStackValue(h, d.INDIRECT_UINT, o.width);
552
- this.stack.push(c), this.offset = r, s && (this.indirectUIntLookup[t] = c);
549
+ const r = this.uintStackValue(t), o = this.align(r.width), n = this.computeOffset(o), h = this.offset;
550
+ r.writeToBuffer(o);
551
+ const f = this.offsetStackValue(h, d.INDIRECT_UINT, r.width);
552
+ this.stack.push(f), this.offset = n, s && (this.indirectUIntLookup[t] = f);
553
553
  }
554
- addFloat(t, i = !1, s = !1) {
555
- if (this.integrityCheckOnValueAddition(), !i) {
554
+ addFloat(t, e = !1, s = !1) {
555
+ if (this.integrityCheckOnValueAddition(), !e) {
556
556
  this.stack.push(this.floatStackValue(t));
557
557
  return;
558
558
  }
@@ -560,154 +560,154 @@ class mt {
560
560
  this.stack.push(this.indirectFloatLookup[t]);
561
561
  return;
562
562
  }
563
- const o = this.floatStackValue(t), n = this.align(o.width), r = this.computeOffset(n), h = this.offset;
564
- o.writeToBuffer(n);
565
- const c = this.offsetStackValue(h, d.INDIRECT_FLOAT, o.width);
566
- this.stack.push(c), this.offset = r, s && (this.indirectFloatLookup[t] = c);
563
+ const r = this.floatStackValue(t), o = this.align(r.width), n = this.computeOffset(o), h = this.offset;
564
+ r.writeToBuffer(o);
565
+ const f = this.offsetStackValue(h, d.INDIRECT_FLOAT, r.width);
566
+ this.stack.push(f), this.offset = n, s && (this.indirectFloatLookup[t] = f);
567
567
  }
568
568
  }
569
- function B() {
570
- return new mt();
569
+ function P() {
570
+ return new gt();
571
571
  }
572
- function gt(e) {
573
- const t = B();
572
+ function Ot(i) {
573
+ const t = P();
574
574
  t.startMap();
575
- for (const [i, s] of Object.entries(e))
576
- t.addKey(i), t.add(s);
575
+ for (const [e, s] of Object.entries(i))
576
+ t.addKey(e), t.add(s);
577
577
  return t.end(), t.finish();
578
578
  }
579
- function A(e, t, i, s, o = 1) {
580
- let n;
581
- if (i === E.FLEX)
582
- n = gt(e);
583
- else if (i === E.JSON)
584
- n = new TextEncoder().encode(JSON.stringify(e));
579
+ function A(i, t, e, s, r = 1) {
580
+ let o;
581
+ if (e === v.FLEX)
582
+ o = Ot(i);
583
+ else if (e === v.JSON)
584
+ o = new TextEncoder().encode(JSON.stringify(i));
585
585
  else
586
586
  throw new Error("Unsupported format for wrapEnvelope");
587
- const r = B();
588
- return r.startMap(), r.addKey("version"), r.add(o), r.addKey("kind"), r.add(t), r.addKey("format"), r.add(i), r.addKey("payload"), r.add(n), r.addKey("metadata"), r.add(s ?? new Uint8Array()), r.end(), r.finish();
587
+ const n = P();
588
+ return n.startMap(), n.addKey("version"), n.add(r), n.addKey("kind"), n.add(t), n.addKey("format"), n.add(e), n.addKey("payload"), n.add(o), n.addKey("metadata"), n.add(s ?? new Uint8Array()), n.end(), n.finish();
589
589
  }
590
- function J(e) {
591
- const t = e instanceof Uint8Array ? e : new Uint8Array(e), i = C(t.buffer).toObject();
592
- if (typeof i.version != "number" || typeof i.kind != "number" || typeof i.format != "number" || !i.payload)
593
- throw console.error("[unwrapEnvelope] Bad root:", i), new Error("[unwrapEnvelope] Invalid envelope structure");
590
+ function X(i) {
591
+ const t = i instanceof Uint8Array ? i : new Uint8Array(i), e = j(t.buffer).toObject();
592
+ if (typeof e.version != "number" || typeof e.kind != "number" || typeof e.format != "number" || !e.payload)
593
+ throw console.error("[unwrapEnvelope] Bad root:", e), new Error("[unwrapEnvelope] Invalid envelope structure");
594
594
  const s = {
595
- version: i.version,
596
- kind: i.kind,
597
- format: i.format,
598
- payload: new Uint8Array(i.payload),
599
- metadata: i.metadata ? new Uint8Array(i.metadata) : void 0
595
+ version: e.version,
596
+ kind: e.kind,
597
+ format: e.format,
598
+ payload: new Uint8Array(e.payload),
599
+ metadata: e.metadata ? new Uint8Array(e.metadata) : void 0
600
600
  };
601
- let o;
602
- if (s.format === E.FLEX)
603
- o = C(s.payload.buffer).toObject();
604
- else if (s.format === E.JSON)
605
- o = JSON.parse(new TextDecoder().decode(s.payload));
601
+ let r;
602
+ if (s.format === v.FLEX)
603
+ r = j(s.payload.buffer).toObject();
604
+ else if (s.format === v.JSON)
605
+ r = JSON.parse(new TextDecoder().decode(s.payload));
606
606
  else
607
607
  throw new Error(`[unwrapEnvelope] Unsupported format: ${s.format}`);
608
- return { envelope: s, payload: o };
608
+ return { envelope: s, payload: r };
609
609
  }
610
- function X(e) {
611
- return C(e.buffer).toObject();
610
+ function $(i) {
611
+ return j(i.buffer).toObject();
612
612
  }
613
- function Ot(e) {
613
+ function bt(i) {
614
614
  try {
615
- const t = e instanceof Uint8Array ? e : new Uint8Array(e), i = X(t);
616
- console.log("[FlexObject]", JSON.stringify(i, null, 2));
615
+ const t = i instanceof Uint8Array ? i : new Uint8Array(i), e = $(t);
616
+ console.log("[FlexObject]", JSON.stringify(e, null, 2));
617
617
  } catch (t) {
618
618
  console.error("[Flex Decode Error]", t);
619
619
  }
620
620
  }
621
- function $(e, t) {
622
- return (e & t) === t;
621
+ function q(i, t) {
622
+ return (i & t) === t;
623
623
  }
624
- function bt(e, t) {
624
+ function vt(i, t) {
625
625
  return A(
626
- { key: e, value: t },
627
- m.SET | m.REDIS,
628
- E.FLEX
626
+ { key: i, value: t },
627
+ g.SET | g.REDIS,
628
+ v.FLEX
629
629
  );
630
630
  }
631
- function Et(e) {
631
+ function Et(i) {
632
632
  return A(
633
- { key: e },
634
- m.GET | m.REDIS,
635
- E.FLEX
633
+ { key: i },
634
+ g.GET | g.REDIS,
635
+ v.FLEX
636
636
  );
637
637
  }
638
- function vt(e) {
638
+ function It(i) {
639
639
  return A(
640
- { key: e },
641
- m.DEL | m.REDIS,
642
- E.FLEX
640
+ { key: i },
641
+ g.DEL | g.REDIS,
642
+ v.FLEX
643
643
  );
644
644
  }
645
- function It(e) {
646
- const t = J(e);
647
- if (!$(t.envelope.kind, m.REDIS))
645
+ function Rt(i) {
646
+ const t = X(i);
647
+ if (!q(t.envelope.kind, g.REDIS))
648
648
  throw new Error("[Redis] Not a Redis envelope");
649
649
  return t;
650
650
  }
651
- function St(e, t, i = "*") {
651
+ function St(i, t, e = "*") {
652
652
  return A(
653
- { stream: e, id: i, fields: t },
654
- m.ADD | m.STREAM | m.REDIS,
655
- E.FLEX
653
+ { stream: i, id: e, fields: t },
654
+ g.ADD | g.STREAM | g.REDIS,
655
+ v.FLEX
656
656
  );
657
657
  }
658
- function Rt(e, t, i) {
659
- const s = B();
658
+ function Dt(i, t, e) {
659
+ const s = P();
660
660
  s.startMap(), s.addKey("streams"), s.startVector();
661
- for (const { stream: r, id: h } of e)
662
- s.startMap(), s.addKey("stream"), s.add(r), s.addKey("id"), s.add(h), s.end();
663
- s.end(), t !== void 0 && (s.addKey("count"), s.add(t)), i !== void 0 && (s.addKey("block"), s.add(i)), s.end();
664
- const o = s.finish(), n = B();
665
- return n.startMap(), n.addKey("version"), n.add(1), n.addKey("kind"), n.add(m.READ | m.STREAM | m.REDIS), n.addKey("format"), n.add(E.FLEX), n.addKey("payload"), n.add(o), n.addKey("metadata"), n.add(new Uint8Array()), n.end(), n.finish();
661
+ for (const { stream: n, id: h } of i)
662
+ s.startMap(), s.addKey("stream"), s.add(n), s.addKey("id"), s.add(h), s.end();
663
+ s.end(), t !== void 0 && (s.addKey("count"), s.add(t)), e !== void 0 && (s.addKey("block"), s.add(e)), s.end();
664
+ const r = s.finish(), o = P();
665
+ return o.startMap(), o.addKey("version"), o.add(1), o.addKey("kind"), o.add(g.READ | g.STREAM | g.REDIS), o.addKey("format"), o.add(v.FLEX), o.addKey("payload"), o.add(r), o.addKey("metadata"), o.add(new Uint8Array()), o.end(), o.finish();
666
666
  }
667
- const Dt = {
667
+ const Lt = {
668
668
  wrapEnvelope: A,
669
- unwrapEnvelope: J,
670
- MessageKind: m,
671
- PayloadFormat: E,
672
- unwrapFlexToJson: X,
673
- inspectFlex: Ot,
674
- hasKind: $,
669
+ unwrapEnvelope: X,
670
+ MessageKind: g,
671
+ PayloadFormat: v,
672
+ unwrapFlexToJson: $,
673
+ inspectFlex: bt,
674
+ hasKind: q,
675
675
  redis: {
676
- wrapRedisSet: bt,
676
+ wrapRedisSet: vt,
677
677
  wrapRedisGet: Et,
678
- wrapRedisDel: vt,
678
+ wrapRedisDel: It,
679
679
  wrapRedisXAdd: St,
680
- wrapRedisXRead: Rt,
681
- parseRedisPayload: It
680
+ wrapRedisXRead: Dt,
681
+ parseRedisPayload: Rt
682
682
  }
683
683
  };
684
- function q(e) {
685
- typeof queueMicrotask == "function" ? queueMicrotask(e) : setTimeout(e, 0);
684
+ function Q(i) {
685
+ typeof queueMicrotask == "function" ? queueMicrotask(i) : setTimeout(i, 0);
686
686
  }
687
- function Q(e) {
688
- const t = document.createElement(e.tag);
689
- if (e.class && (t.className = e.class), e.attrs)
690
- for (const [i, s] of Object.entries(e.attrs))
691
- if (typeof s == "function" && i.startsWith("on"))
692
- t.addEventListener(i.slice(2).toLowerCase(), s);
693
- else if (i === "style" && typeof s == "object")
687
+ function Z(i) {
688
+ const t = document.createElement(i.tag);
689
+ if (i.class && (t.className = i.class), i.attrs)
690
+ for (const [e, s] of Object.entries(i.attrs))
691
+ if (typeof s == "function" && e.startsWith("on"))
692
+ t.addEventListener(e.slice(2).toLowerCase(), s);
693
+ else if (e === "style" && typeof s == "object")
694
694
  Object.assign(t.style, s);
695
- else if (i === "dataset" && typeof s == "object")
696
- for (const [o, n] of Object.entries(s))
697
- t.dataset[o] = String(n);
695
+ else if (e === "dataset" && typeof s == "object")
696
+ for (const [r, o] of Object.entries(s))
697
+ t.dataset[r] = String(o);
698
698
  else
699
699
  try {
700
- t.setAttribute(i, String(s));
700
+ t.setAttribute(e, String(s));
701
701
  } catch {
702
702
  }
703
- if (e.style && Object.assign(t.style, e.style), e.children)
704
- for (const i of e.children) {
705
- const s = typeof i == "string" ? document.createTextNode(i) : Q(i);
703
+ if (i.style && Object.assign(t.style, i.style), i.children)
704
+ for (const e of i.children) {
705
+ const s = typeof e == "string" ? document.createTextNode(e) : Z(e);
706
706
  t.appendChild(s);
707
707
  }
708
708
  return t;
709
709
  }
710
- const Lt = k.enum(["top", "right", "bottom", "left"]), Tt = k.object({
710
+ const Tt = k.enum(["top", "right", "bottom", "left"]), Ut = k.object({
711
711
  width: k.number(),
712
712
  height: k.number(),
713
713
  mode: k.enum(["static", "animated", "dynamic"]).optional()
@@ -715,106 +715,117 @@ const Lt = k.enum(["top", "right", "bottom", "left"]), Tt = k.object({
715
715
  k.object({
716
716
  rawHtml: k.string().optional(),
717
717
  needsCanvas: k.boolean().optional(),
718
- canvasOptions: Tt.optional()
718
+ canvasOptions: Ut.optional()
719
719
  });
720
- const Ut = k.object({
720
+ const Wt = k.object({
721
721
  name: k.string(),
722
722
  version: k.string().optional()
723
723
  }), At = k.object({
724
- meta: Ut.optional(),
724
+ meta: Wt.optional(),
725
725
  timestamp: k.number()
726
- }), _ = k.object({
727
- id: Lt,
726
+ }), z = k.object({
727
+ id: Tt,
728
728
  payload: k.any().optional()
729
729
  }), Vt = k.object({
730
730
  timestamp: k.number()
731
- }), Wt = {
731
+ }), Nt = {
732
732
  "droid-ready": Vt,
733
733
  "droid-mod-ready": At,
734
- "panel-open": _,
735
- "panel-close": _
734
+ "panel-open": z,
735
+ "panel-close": z
736
736
  };
737
- class Nt {
737
+ class Bt {
738
738
  listeners = /* @__PURE__ */ new Map();
739
- on(t, i) {
739
+ on(t, e) {
740
740
  let s = this.listeners.get(t);
741
- s || (s = /* @__PURE__ */ new Set(), this.listeners.set(t, s)), s.add(i);
741
+ s || (s = /* @__PURE__ */ new Set(), this.listeners.set(t, s)), s.add(e);
742
742
  }
743
- off(t, i) {
744
- this.listeners.get(t)?.delete(i);
743
+ off(t, e) {
744
+ this.listeners.get(t)?.delete(e);
745
745
  }
746
- emit(t, i) {
747
- const s = Wt[t];
746
+ emit(t, e) {
747
+ const s = Nt[t];
748
748
  if (s)
749
749
  try {
750
- s.parse(i);
751
- } catch (o) {
752
- console.error(`[DroidEventBus] Invalid payload for ${t}:`, o);
750
+ s.parse(e);
751
+ } catch (r) {
752
+ console.error(`[DroidEventBus] Invalid payload for ${t}:`, r);
753
753
  return;
754
754
  }
755
- window.dispatchEvent(new CustomEvent(t, { detail: i }));
756
- for (const o of this.listeners.get(t) ?? [])
757
- o(i);
755
+ window.dispatchEvent(new CustomEvent(t, { detail: e }));
756
+ for (const r of this.listeners.get(t) ?? [])
757
+ r(e);
758
758
  }
759
759
  wait(t) {
760
- return new Promise((i) => {
761
- const s = (o) => {
762
- this.off(t, s), i(o);
760
+ return new Promise((e) => {
761
+ const s = (r) => {
762
+ this.off(t, s), e(r);
763
763
  };
764
764
  this.on(t, s);
765
765
  });
766
766
  }
767
767
  }
768
- const Bt = new Nt(), M = "1.0.3";
768
+ const Pt = new Bt(), M = "1.0.3";
769
769
  let x = !1;
770
- function xt(e, t) {
771
- if (!e)
770
+ function xt(i, t) {
771
+ if (!i)
772
772
  throw new Error("[resolveWorkerURL] Worker name must be defined");
773
773
  if (typeof window < "u") {
774
- const i = window.kbveWorkerURLs;
775
- if (i?.[e]) return i[e];
774
+ const e = window.kbveWorkerURLs;
775
+ if (e?.[i]) return e[i];
776
776
  }
777
- return t ?? `/workers/${e}`;
777
+ return t ?? `/workers/${i}`;
778
778
  }
779
- async function Pt(e) {
779
+ async function Ct(i) {
780
780
  let t = null;
781
- try {
782
- const i = new SharedWorker(new URL(
783
- /* @vite-ignore */
784
- "/lib/workers/ws-worker.js",
785
- import.meta.url
786
- ), {
787
- type: "module"
788
- });
789
- i.port.start(), t = b(i.port);
790
- } catch (i) {
791
- console.warn("[DROID] ws-worker import.meta fallback failed:", i);
792
- }
793
- if (!t)
781
+ if (i?.workerRef)
794
782
  try {
795
- const i = new SharedWorker("/ws-worker.js", { type: "module" });
796
- i.port.start(), t = b(i.port);
797
- } catch (i) {
798
- console.warn("[DROID] ws-worker hardcoded fallback failed:", i);
783
+ return i.workerRef.port.start(), t = y(i.workerRef.port), t;
784
+ } catch (e) {
785
+ console.warn("[DROID] ws-worker workerRef failed:", e);
799
786
  }
800
- if (!t && e?.workerRef)
787
+ if (i?.workerURL)
801
788
  try {
802
- e.workerRef.port.start(), t = b(e.workerRef.port);
803
- } catch (i) {
804
- console.warn("[DROID] ws-worker workerRef failed:", i);
789
+ const e = new SharedWorker(i.workerURL, { type: "module" });
790
+ return e.port.start(), t = y(e.port), t;
791
+ } catch (e) {
792
+ console.warn("[DROID] ws-worker workerURL failed:", e);
805
793
  }
806
- if (!t && e?.workerURL)
807
- try {
808
- const i = new SharedWorker(e.workerURL, { type: "module" });
809
- i.port.start(), t = b(i.port);
810
- } catch (i) {
811
- console.warn("[DROID] ws-worker workerURL failed:", i);
812
- }
813
- if (!t)
814
- throw console.error("[DROID] No WS Worker Comlink Initialized"), new Error("[DROID] Failed to initialize ws-worker");
815
- return t;
794
+ try {
795
+ const e = new SharedWorker(
796
+ new URL(
797
+ /* @vite-ignore */
798
+ "/lib/workers/ws-worker.js",
799
+ import.meta.url
800
+ ),
801
+ { type: "module" }
802
+ );
803
+ return e.port.start(), t = y(e.port), t;
804
+ } catch (e) {
805
+ console.warn("[DROID] ws-worker vite-style .ts import failed:", e);
806
+ }
807
+ try {
808
+ const e = new SharedWorker(
809
+ new URL(
810
+ /* @vite-ignore */
811
+ "/lib/workers/ws-worker.js",
812
+ import.meta.url
813
+ ),
814
+ { type: "module" }
815
+ );
816
+ return e.port.start(), t = y(e.port), t;
817
+ } catch (e) {
818
+ console.warn("[DROID] ws-worker ./ws-worker.js fallback failed:", e);
819
+ }
820
+ try {
821
+ const e = new SharedWorker("/ws-worker.js", { type: "module" });
822
+ return e.port.start(), t = y(e.port), t;
823
+ } catch (e) {
824
+ console.warn("[DROID] ws-worker absolute hardcoded fallback failed:", e);
825
+ }
826
+ throw console.error("[DROID] No WS Worker Comlink Initialized"), new Error("[DROID] Failed to initialize ws-worker");
816
827
  }
817
- const g = G(
828
+ const O = J(
818
829
  "uiux-state",
819
830
  {
820
831
  panelManager: {
@@ -832,9 +843,23 @@ const g = G(
832
843
  decode: JSON.parse
833
844
  }
834
845
  );
835
- async function Ct(e) {
846
+ async function jt(i) {
847
+ let t = null;
848
+ if (i?.workerRef)
849
+ try {
850
+ return t = y(i.workerRef), t;
851
+ } catch (e) {
852
+ console.warn("[DROID] Provided canvasWorkerRef failed:", e);
853
+ }
854
+ if (i?.workerURL)
855
+ try {
856
+ const e = new Worker(i.workerURL, { type: "module" });
857
+ return t = y(e), t;
858
+ } catch (e) {
859
+ console.warn("[DROID] Provided canvasWorkerURL failed:", e);
860
+ }
836
861
  try {
837
- const t = new Worker(
862
+ const e = new Worker(
838
863
  new URL(
839
864
  /* @vite-ignore */
840
865
  "/lib/workers/canvas-worker.js",
@@ -842,69 +867,69 @@ async function Ct(e) {
842
867
  ),
843
868
  { type: "module" }
844
869
  );
845
- return b(t);
846
- } catch (t) {
847
- console.warn("[DROID] Vite-style canvas-worker import failed:", t);
870
+ return t = y(e), t;
871
+ } catch (e) {
872
+ console.warn("[DROID] Vite-style canvas-worker.ts import failed:", e);
848
873
  }
849
874
  try {
850
- const t = new Worker("./canvas-worker.js", { type: "module" });
851
- return b(t);
852
- } catch (t) {
853
- console.warn("[DROID] Fallback /canvas-worker.js failed:", t);
875
+ const e = new Worker(
876
+ new URL(
877
+ /* @vite-ignore */
878
+ "/lib/workers/canvas-worker.js",
879
+ import.meta.url
880
+ ),
881
+ { type: "module" }
882
+ );
883
+ return t = y(e), t;
884
+ } catch (e) {
885
+ console.warn("[DROID] canvas-worker.js (same dir) fallback failed:", e);
886
+ }
887
+ try {
888
+ const e = new Worker("/canvas-worker.js", { type: "module" });
889
+ return t = y(e), t;
890
+ } catch (e) {
891
+ console.warn("[DROID] canvas-worker.js (absolute root) fallback failed:", e);
854
892
  }
855
- if (e?.workerRef)
856
- try {
857
- return b(e.workerRef);
858
- } catch (t) {
859
- console.warn("[DROID] Provided workerRef failed:", t);
860
- }
861
- if (e?.workerURL)
862
- try {
863
- const t = new Worker(e.workerURL, { type: "module" });
864
- return b(t);
865
- } catch (t) {
866
- console.warn("[DROID] Provided workerURL failed:", t);
867
- }
868
893
  throw console.error("[DROID] No Canvas Comlink Initialized"), new Error("[DROID] Failed to initialize canvas worker");
869
894
  }
870
- const z = {
871
- state: g,
872
- openPanel(e, t) {
873
- const i = { ...g.get().panelManager };
874
- i[e] = { open: !0, payload: t }, g.setKey("panelManager", i);
895
+ const K = {
896
+ state: O,
897
+ openPanel(i, t) {
898
+ const e = { ...O.get().panelManager };
899
+ e[i] = { open: !0, payload: t }, O.setKey("panelManager", e);
875
900
  },
876
- closePanel(e) {
877
- const t = { ...g.get().panelManager };
878
- t[e] = { open: !1, payload: void 0 }, g.setKey("panelManager", t);
901
+ closePanel(i) {
902
+ const t = { ...O.get().panelManager };
903
+ t[i] = { open: !1, payload: void 0 }, O.setKey("panelManager", t);
879
904
  },
880
- togglePanel(e, t) {
881
- const i = { ...g.get().panelManager }, s = i[e]?.open ?? !1;
882
- i[e] = { open: !s, payload: s ? void 0 : t }, g.setKey("panelManager", i);
905
+ togglePanel(i, t) {
906
+ const e = { ...O.get().panelManager }, s = e[i]?.open ?? !1;
907
+ e[i] = { open: !s, payload: s ? void 0 : t }, O.setKey("panelManager", e);
883
908
  },
884
- setTheme(e) {
885
- g.setKey("themeManager", { theme: e });
909
+ setTheme(i) {
910
+ O.setKey("themeManager", { theme: i });
886
911
  },
887
- addToast(e, t) {
888
- const i = { ...g.get().toastManager, [e]: t };
889
- g.setKey("toastManager", i);
912
+ addToast(i, t) {
913
+ const e = { ...O.get().toastManager, [i]: t };
914
+ O.setKey("toastManager", e);
890
915
  },
891
- removeToast(e) {
892
- const t = { ...g.get().toastManager };
893
- delete t[e], g.setKey("toastManager", t);
916
+ removeToast(i) {
917
+ const t = { ...O.get().toastManager };
918
+ delete t[i], O.setKey("toastManager", t);
894
919
  },
895
- async dispatchCanvasRequest(e, t, i = "animated") {
920
+ async dispatchCanvasRequest(i, t, e = "animated") {
896
921
  const s = t.transferControlToOffscreen();
897
- await window.kbve?.uiux?.worker?.bindCanvas(e, s, i);
922
+ await window.kbve?.uiux?.worker?.bindCanvas(i, s, e);
898
923
  },
899
924
  closeAllPanels() {
900
- const e = { ...g.get().panelManager };
925
+ const i = { ...O.get().panelManager };
901
926
  console.log("error panel is closing");
902
- for (const t of Object.keys(e))
903
- e[t] = { open: !1, payload: void 0 };
904
- g.setKey("panelManager", e);
927
+ for (const t of Object.keys(i))
928
+ i[t] = { open: !1, payload: void 0 };
929
+ O.setKey("panelManager", i);
905
930
  },
906
- emitFromWorker(e) {
907
- e.type === "injectVNode" && e.vnode && q(() => {
931
+ emitFromWorker(i) {
932
+ i.type === "injectVNode" && i.vnode && Q(() => {
908
933
  const t = document.getElementById("bento-grid-inject");
909
934
  if (!t) {
910
935
  console.warn(
@@ -912,15 +937,15 @@ const z = {
912
937
  );
913
938
  return;
914
939
  }
915
- const i = Q(e.vnode);
916
- if (i.classList.add("animate-fade-in"), e.vnode.id) {
917
- const s = document.getElementById(e.vnode.id);
940
+ const e = Z(i.vnode);
941
+ if (e.classList.add("animate-fade-in"), i.vnode.id) {
942
+ const s = document.getElementById(i.vnode.id);
918
943
  s && s.remove();
919
944
  }
920
- t.appendChild(i);
945
+ t.appendChild(e);
921
946
  });
922
947
  }
923
- }, D = G(
948
+ }, D = J(
924
949
  "i18n-cache",
925
950
  {},
926
951
  {
@@ -931,142 +956,151 @@ const z = {
931
956
  store: D,
932
957
  api: null,
933
958
  ready: Promise.resolve(),
934
- get(e) {
935
- return D.get()[e] ?? `[${e}]`;
959
+ get(i) {
960
+ return D.get()[i] ?? `[${i}]`;
936
961
  },
937
- async getAsync(e) {
938
- const t = D.get()[e];
962
+ async getAsync(i) {
963
+ const t = D.get()[i];
939
964
  if (t !== void 0) return t;
940
- if (!this.api) return `[${e}]`;
941
- const i = await this.api.getTranslation(e);
942
- return i !== null ? (D.setKey(e, i), i) : `[${e}]`;
965
+ if (!this.api) return `[${i}]`;
966
+ const e = await this.api.getTranslation(i);
967
+ return e !== null ? (D.setKey(i, e), e) : `[${i}]`;
943
968
  },
944
- set(e, t) {
945
- D.setKey(e, t);
969
+ set(i, t) {
970
+ D.setKey(i, t);
946
971
  },
947
- async hydrate(e, t) {
948
- this.api = e;
949
- for (const i of t) {
950
- const s = await e.getTranslation(i);
951
- s !== null && D.setKey(i, s);
972
+ async hydrate(i, t) {
973
+ this.api = i;
974
+ for (const e of t) {
975
+ const s = await i.getTranslation(e);
976
+ s !== null && D.setKey(e, s);
952
977
  }
953
978
  },
954
- async hydrateLocale(e = "en") {
979
+ async hydrateLocale(i = "en") {
955
980
  if (!this.api) return;
956
- const i = (await this.api.getAllI18nKeys()).filter(
957
- (o) => o.startsWith(`${e}:`)
958
- ), s = await this.api.getTranslations(i);
959
- for (const [o, n] of Object.entries(s))
960
- console.log(`[i18n.setKey] ${o} = ${n}`), this.store.setKey(o, n);
981
+ const e = (await this.api.getAllI18nKeys()).filter(
982
+ (r) => r.startsWith(`${i}:`)
983
+ ), s = await this.api.getTranslations(e);
984
+ for (const [r, o] of Object.entries(s))
985
+ console.log(`[i18n.setKey] ${r} = ${o}`), this.store.setKey(r, o);
961
986
  }
962
987
  };
963
- function K() {
988
+ function Y() {
964
989
  if (!navigator.serviceWorker?.controller) return;
965
- const e = new MessageChannel();
966
- navigator.serviceWorker.controller.postMessage(e.port2, [
967
- e.port2
968
- ]), e.port1.start();
990
+ const i = new MessageChannel();
991
+ navigator.serviceWorker.controller.postMessage(i.port2, [
992
+ i.port2
993
+ ]), i.port1.start();
969
994
  }
970
- async function Ft(e) {
995
+ async function Ft(i) {
971
996
  let t = null;
997
+ if (i?.workerRef)
998
+ try {
999
+ return i.workerRef.port.start(), t = y(i.workerRef.port), await T(t);
1000
+ } catch (e) {
1001
+ console.warn("[DROID] db-worker workerRef failed:", e);
1002
+ }
1003
+ if (i?.workerURL)
1004
+ try {
1005
+ const e = new SharedWorker(i.workerURL, { type: "module" });
1006
+ return e.port.start(), t = y(e.port), await T(t);
1007
+ } catch (e) {
1008
+ console.warn("[DROID] db-worker workerURL failed:", e);
1009
+ }
972
1010
  try {
973
- const s = new SharedWorker(
1011
+ const e = new SharedWorker(
974
1012
  new URL(
975
1013
  /* @vite-ignore */
976
1014
  "/lib/workers/db-worker.js",
977
1015
  import.meta.url
978
1016
  ),
979
- {
980
- type: "module"
981
- }
1017
+ { type: "module" }
982
1018
  );
983
- s.port.start(), t = b(s.port);
984
- } catch (s) {
985
- console.warn("[DROID] db-worker import.meta fallback failed:", s);
1019
+ return e.port.start(), t = y(e.port), await T(t);
1020
+ } catch (e) {
1021
+ console.warn("[DROID] db-worker .ts vite-style import failed:", e);
986
1022
  }
987
- if (!t)
988
- try {
989
- const s = new SharedWorker("/db-worker.js", {
990
- type: "module"
991
- });
992
- s.port.start(), t = b(s.port);
993
- } catch (s) {
994
- console.warn("[DROID] db-worker hardcoded fallback failed:", s);
995
- }
996
- if (!t && e?.workerRef)
997
- try {
998
- e.workerRef.port.start(), t = b(e.workerRef.port);
999
- } catch (s) {
1000
- console.warn("[DROID] db-worker workerRef failed:", s);
1001
- }
1002
- if (!t && e?.workerURL)
1003
- try {
1004
- const s = new SharedWorker(e.workerURL, { type: "module" });
1005
- s.port.start(), t = b(s.port);
1006
- } catch (s) {
1007
- console.warn("[DROID] db-worker workerURL failed:", s);
1008
- }
1009
- if (!t)
1010
- throw console.error("[DROID] No DB Worker Comlink Initialized"), new Error("[DROID] Failed to initialize db-worker");
1011
- return await t.getVersion() !== M && await kt(t, {
1023
+ try {
1024
+ const e = new SharedWorker(
1025
+ new URL(
1026
+ /* @vite-ignore */
1027
+ "/lib/workers/db-worker.js",
1028
+ import.meta.url
1029
+ ),
1030
+ { type: "module" }
1031
+ );
1032
+ return e.port.start(), t = y(e.port), await T(t);
1033
+ } catch (e) {
1034
+ console.warn("[DROID] db-worker.js same-dir fallback failed:", e);
1035
+ }
1036
+ try {
1037
+ const e = new SharedWorker("/db-worker.js", { type: "module" });
1038
+ return e.port.start(), t = y(e.port), await T(t);
1039
+ } catch (e) {
1040
+ console.warn("[DROID] db-worker.js absolute hardcoded fallback failed:", e);
1041
+ }
1042
+ throw console.error("[DROID] No DB Worker Comlink Initialized"), new Error("[DROID] Failed to initialize db-worker");
1043
+ }
1044
+ async function T(i) {
1045
+ return await i.getVersion() !== M && await yt(i, {
1012
1046
  version: M,
1013
1047
  i18nPath: "https://discord.sh/i18n/db.json",
1014
1048
  locale: "en",
1015
1049
  defaults: { welcome: "Welcome!", theme: "dark" }
1016
- }), t;
1050
+ }), i;
1017
1051
  }
1018
- function jt(e, t) {
1019
- const i = Z(async (s) => {
1020
- q(() => {
1021
- const o = `ws:${Date.now()}`;
1022
- t.storeWsMessage(o, s);
1052
+ function Ht(i, t) {
1053
+ const e = tt(async (s) => {
1054
+ Q(() => {
1055
+ const r = `ws:${Date.now()}`;
1056
+ t.storeWsMessage(r, s);
1023
1057
  });
1024
1058
  });
1025
- e.onMessage(tt(i, [0]));
1059
+ i.onMessage(et(e, [0]));
1026
1060
  }
1027
- async function zt(e) {
1028
- if (console.log("[DROID]: Main<T>"), x || (x = !0, navigator.serviceWorker?.controller ? K() : navigator.serviceWorker?.addEventListener(
1061
+ async function Kt(i) {
1062
+ if (console.log("[DROID]: Main<T>"), x || (x = !0, navigator.serviceWorker?.controller ? Y() : navigator.serviceWorker?.addEventListener(
1029
1063
  "controllerchange",
1030
- K
1031
- )), console.log("[DROID] Main<T> => Worker URLs", e?.workerURLs), !window.kbve?.api || !window.kbve?.i18n || !window.kbve?.uiux)
1064
+ Y
1065
+ )), console.log("[DROID] Main<T> => Worker URLs", i?.workerURLs), !window.kbve?.api || !window.kbve?.i18n || !window.kbve?.uiux)
1032
1066
  try {
1033
1067
  console.log("[DROID] Main<T> => Worker => CanvasComlink");
1034
- const i = await Ct({
1035
- workerRef: e?.workerRefs?.canvasWorker,
1036
- workerURL: e?.workerURLs?.canvasWorker
1068
+ const e = await jt({
1069
+ workerRef: i?.workerRefs?.canvasWorker,
1070
+ workerURL: i?.workerURLs?.canvasWorker
1037
1071
  });
1038
1072
  console.log("[DROID] Main<T> => Worker => StorageComlink");
1039
1073
  const s = await Ft({
1040
- workerURL: typeof e?.workerURLs?.dbWorker == "string" ? e.workerURLs.dbWorker : void 0,
1041
- workerRef: e?.workerRefs?.dbWorker
1074
+ workerURL: typeof i?.workerURLs?.dbWorker == "string" ? i.workerURLs.dbWorker : void 0,
1075
+ workerRef: i?.workerRefs?.dbWorker
1042
1076
  });
1043
1077
  console.log("[DROID] Main<T> => Worker => WsComlink");
1044
- const o = await Pt({
1045
- workerRef: e?.workerRefs?.wsWorker,
1046
- workerURL: e?.workerURLs?.wsWorker
1078
+ const r = await Ct({
1079
+ workerRef: i?.workerRefs?.wsWorker,
1080
+ workerURL: i?.workerURLs?.wsWorker
1047
1081
  });
1048
1082
  console.log("[DROID] Main<T> => Worker => ModManager");
1049
- const n = await yt(
1050
- (c) => e?.workerURLs?.[c] ?? c
1051
- ), r = Bt;
1052
- for (const c of Object.values(n.registry))
1053
- typeof c.instance.init == "function" && await c.instance.init({
1054
- emitFromWorker: z.emitFromWorker
1055
- }), console.log("[Event] -> Fire Mod Ready"), r.emit("droid-mod-ready", {
1056
- meta: c.meta,
1083
+ const o = await mt(
1084
+ (f) => i?.workerURLs?.[f] ?? f
1085
+ ), n = Pt;
1086
+ for (const f of Object.values(o.registry))
1087
+ typeof f.instance.init == "function" && await f.instance.init({
1088
+ emitFromWorker: K.emitFromWorker
1089
+ }), console.log("[Event] -> Fire Mod Ready"), n.emit("droid-mod-ready", {
1090
+ meta: f.meta,
1057
1091
  timestamp: Date.now()
1058
1092
  });
1059
- jt(o, s);
1060
- const h = Dt;
1093
+ Ht(r, s);
1094
+ const h = Lt;
1061
1095
  L.api = s, L.ready = L.hydrateLocale("en"), window.kbve = {
1062
1096
  ...window.kbve || {},
1063
1097
  api: s,
1064
1098
  i18n: L,
1065
- uiux: { ...z, worker: i },
1066
- ws: o,
1099
+ uiux: { ...K, worker: e },
1100
+ ws: r,
1067
1101
  data: h,
1068
- mod: n,
1069
- events: r
1102
+ mod: o,
1103
+ events: n
1070
1104
  }, await L.ready, window.kbve.events.emit("droid-ready", {
1071
1105
  timestamp: Date.now()
1072
1106
  }), document.addEventListener("astro:page-load", () => {
@@ -1076,16 +1110,16 @@ async function zt(e) {
1076
1110
  timestamp: Date.now()
1077
1111
  });
1078
1112
  }), console.log("[KBVE] Global API ready");
1079
- } catch (i) {
1080
- throw console.error("[DROID] Initialization error:", i), i;
1113
+ } catch (e) {
1114
+ throw console.error("[DROID] Initialization error:", e), e;
1081
1115
  }
1082
1116
  else
1083
1117
  console.log("[KBVE] Already initialized");
1084
1118
  }
1085
1119
  export {
1086
- jt as bridgeWsToDb,
1120
+ Ht as bridgeWsToDb,
1087
1121
  L as i18n,
1088
- zt as main,
1122
+ Kt as main,
1089
1123
  xt as resolveWorkerURL,
1090
- z as uiux
1124
+ K as uiux
1091
1125
  };