@kbve/droid 0.0.6 → 0.1.2
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/droid.mjs +2312 -74
- package/index.d.ts +32 -0
- package/lib/agents/api-types.d.ts +121 -0
- package/lib/agents/api-types.d.ts.map +1 -0
- package/lib/agents/auth/init.d.ts +8 -0
- package/lib/agents/auth/init.d.ts.map +1 -0
- package/lib/agents/cache.d.ts +9 -0
- package/lib/agents/cache.d.ts.map +1 -0
- package/lib/agents/client/callGuildVault.d.ts +3 -0
- package/lib/agents/client/callGuildVault.d.ts.map +1 -0
- package/lib/agents/client/callJson.d.ts +3 -0
- package/lib/agents/client/callJson.d.ts.map +1 -0
- package/lib/agents/config.d.ts +36 -0
- package/lib/agents/config.d.ts.map +1 -0
- package/lib/agents/constants.d.ts +11 -0
- package/lib/agents/constants.d.ts.map +1 -0
- package/lib/agents/createAgents.d.ts +4 -0
- package/lib/agents/createAgents.d.ts.map +1 -0
- package/lib/agents/ctx.d.ts +46 -0
- package/lib/agents/ctx.d.ts.map +1 -0
- package/lib/agents/discord/bot.d.ts +21 -0
- package/lib/agents/discord/bot.d.ts.map +1 -0
- package/lib/agents/discord/guilds.d.ts +8 -0
- package/lib/agents/discord/guilds.d.ts.map +1 -0
- package/lib/agents/formDrafts.d.ts +5 -0
- package/lib/agents/formDrafts.d.ts.map +1 -0
- package/lib/agents/generated/agents-schema.d.ts +73 -0
- package/lib/agents/generated/agents-schema.d.ts.map +1 -0
- package/lib/agents/generated/discordsh-agents-schema.d.ts +71 -0
- package/lib/agents/generated/discordsh-agents-schema.d.ts.map +1 -0
- package/lib/agents/github/backfill.d.ts +23 -0
- package/lib/agents/github/backfill.d.ts.map +1 -0
- package/lib/agents/github/events.d.ts +10 -0
- package/lib/agents/github/events.d.ts.map +1 -0
- package/lib/agents/github/pat.d.ts +13 -0
- package/lib/agents/github/pat.d.ts.map +1 -0
- package/lib/agents/github/repoConfig.d.ts +25 -0
- package/lib/agents/github/repoConfig.d.ts.map +1 -0
- package/lib/agents/github/tokens.d.ts +22 -0
- package/lib/agents/github/tokens.d.ts.map +1 -0
- package/lib/agents/github/webhook.d.ts +37 -0
- package/lib/agents/github/webhook.d.ts.map +1 -0
- package/lib/agents/index.d.ts +8 -0
- package/lib/agents/index.d.ts.map +1 -0
- package/lib/agents/state/atoms.d.ts +122 -0
- package/lib/agents/state/atoms.d.ts.map +1 -0
- package/lib/agents/types.d.ts +65 -0
- package/lib/agents/types.d.ts.map +1 -0
- package/lib/gateway/SupabaseGateway.d.ts +38 -0
- package/lib/gateway/SupabaseGateway.d.ts.map +1 -0
- package/lib/gateway/WorkerCommunication.d.ts +39 -0
- package/lib/gateway/WorkerCommunication.d.ts.map +1 -0
- package/lib/gateway/WorkerPool.d.ts +55 -0
- package/lib/gateway/WorkerPool.d.ts.map +1 -0
- package/lib/gateway/capabilities.d.ts +23 -0
- package/lib/gateway/capabilities.d.ts.map +1 -0
- package/lib/gateway/index.d.ts +9 -0
- package/lib/gateway/index.d.ts.map +1 -0
- package/lib/gateway/strategies/DirectStrategy.d.ts +52 -0
- package/lib/gateway/strategies/DirectStrategy.d.ts.map +1 -0
- package/lib/gateway/strategies/SharedWorkerStrategy.d.ts +46 -0
- package/lib/gateway/strategies/SharedWorkerStrategy.d.ts.map +1 -0
- package/lib/gateway/strategies/WebWorkerStrategy.d.ts +45 -0
- package/lib/gateway/strategies/WebWorkerStrategy.d.ts.map +1 -0
- package/lib/gateway/types.d.ts +81 -0
- package/lib/gateway/types.d.ts.map +1 -0
- package/lib/workers/canvas-ui-renderer.d.ts +25 -0
- package/lib/workers/canvas-ui-renderer.d.ts.map +1 -0
- package/lib/workers/canvas-worker.d.ts +14 -0
- package/lib/workers/canvas-worker.d.ts.map +1 -0
- package/lib/workers/canvas-worker.js +5 -302
- package/lib/workers/data.d.ts +40 -0
- package/lib/workers/data.d.ts.map +1 -0
- package/lib/workers/db-worker.d.ts +69 -0
- package/lib/workers/db-worker.d.ts.map +1 -0
- package/lib/workers/db-worker.js +13 -3636
- package/lib/workers/events.d.ts +11 -0
- package/lib/workers/events.d.ts.map +1 -0
- package/lib/workers/flexbuilder.d.ts +4 -0
- package/lib/workers/flexbuilder.d.ts.map +1 -0
- package/lib/workers/init.d.ts +11 -0
- package/lib/workers/init.d.ts.map +1 -0
- package/lib/workers/main.d.ts +105 -0
- package/lib/workers/main.d.ts.map +1 -0
- package/lib/workers/supabase-db-worker.d.ts +2 -0
- package/lib/workers/supabase-db-worker.d.ts.map +1 -0
- package/lib/workers/supabase-db-worker.js +23 -0
- package/lib/workers/supabase-shared-worker.d.ts +2 -0
- package/lib/workers/supabase-shared-worker.d.ts.map +1 -0
- package/lib/workers/supabase-shared-worker.js +25 -0
- package/lib/workers/tools.d.ts +4 -0
- package/lib/workers/tools.d.ts.map +1 -0
- package/lib/workers/validate.d.ts +15 -0
- package/lib/workers/validate.d.ts.map +1 -0
- package/lib/workers/ws-worker.d.ts +10 -0
- package/lib/workers/ws-worker.d.ts.map +1 -0
- package/lib/workers/ws-worker.js +5 -273
- package/main.js +5711 -0
- package/package.json +18 -6
- package/src/index.ts +41 -13
- package/src/lib/agents/api-types.ts +170 -0
- package/src/lib/agents/auth/init.ts +200 -0
- package/src/lib/agents/cache.ts +127 -0
- package/src/lib/agents/client/callGuildVault.ts +71 -0
- package/src/lib/agents/client/callJson.ts +64 -0
- package/src/lib/agents/config.ts +83 -0
- package/src/lib/agents/constants.ts +11 -0
- package/src/lib/agents/createAgents.ts +62 -0
- package/src/lib/agents/ctx.ts +63 -0
- package/src/lib/agents/discord/bot.ts +169 -0
- package/src/lib/agents/discord/guilds.ts +106 -0
- package/src/lib/agents/formDrafts.ts +55 -0
- package/src/lib/agents/generated/agents-schema.ts +155 -0
- package/src/lib/agents/generated/discordsh-agents-schema.ts +96 -0
- package/src/lib/agents/github/backfill.ts +126 -0
- package/src/lib/agents/github/events.ts +131 -0
- package/src/lib/agents/github/pat.ts +150 -0
- package/src/lib/agents/github/repoConfig.ts +240 -0
- package/src/lib/agents/github/tokens.ts +222 -0
- package/src/lib/agents/github/webhook.ts +349 -0
- package/src/lib/agents/index.ts +35 -0
- package/src/lib/agents/state/atoms.ts +122 -0
- package/src/lib/agents/types.ts +83 -0
- package/src/lib/api.ts +71 -0
- package/src/lib/droid.spec.ts +14 -19
- package/src/lib/droid.ts +48 -4
- package/src/lib/gateway/SupabaseGateway.ts +236 -0
- package/src/lib/gateway/WorkerCommunication.ts +132 -0
- package/src/lib/gateway/WorkerPool.ts +304 -0
- package/src/lib/gateway/capabilities.spec.ts +144 -0
- package/src/lib/gateway/capabilities.ts +80 -0
- package/src/lib/gateway/index.ts +15 -0
- package/src/lib/gateway/strategies/DirectStrategy.ts +443 -0
- package/src/lib/gateway/strategies/SharedWorkerStrategy.ts +278 -0
- package/src/lib/gateway/strategies/WebWorkerStrategy.ts +278 -0
- package/src/lib/gateway/types.ts +139 -0
- package/src/lib/mod/mod-manager.ts +13 -8
- package/src/lib/mod/module/bento/mod-bento.worker.ts +1 -1
- package/src/lib/mod/module/supabase/mod-supabase.spec.ts +21 -25
- package/src/lib/mod/module/supabase/mod-supabase.ts +73 -0
- package/src/lib/mod/module/supabase/mod-supabase.worker.ts +1 -56
- package/src/lib/state/auth.spec.ts +58 -0
- package/src/lib/state/auth.ts +148 -0
- package/src/lib/state/bento.spec.ts +76 -0
- package/src/lib/state/bento.ts +51 -0
- package/src/lib/state/index.ts +98 -0
- package/src/lib/state/overlay-manager.ts +125 -0
- package/src/lib/state/profile-sync.ts +214 -0
- package/src/lib/state/profile.ts +155 -0
- package/src/lib/state/router.ts +24 -0
- package/src/lib/state/staff.ts +128 -0
- package/src/lib/state/sync-bus.ts +109 -0
- package/src/lib/state/theme-sync.ts +75 -0
- package/src/lib/state/toasts.spec.ts +106 -0
- package/src/lib/state/toasts.ts +34 -0
- package/src/lib/state/ui.spec.ts +148 -0
- package/src/lib/state/ui.ts +45 -0
- package/src/lib/state/welcome-toast.spec.ts +101 -0
- package/src/lib/state/welcome-toast.ts +76 -0
- package/src/lib/sw-recovery.spec.ts +165 -0
- package/src/lib/sw-recovery.ts +141 -0
- package/src/lib/types/bento.spec.ts +116 -0
- package/src/lib/types/bento.ts +94 -55
- package/src/lib/types/event-schemas.spec.ts +120 -0
- package/src/lib/types/event-types.spec.ts +96 -0
- package/src/lib/types/event-types.ts +113 -3
- package/src/lib/types/modules.ts +12 -5
- package/src/lib/types/ui-event-types.ts +66 -0
- package/src/lib/workers/canvas-ui-renderer.ts +266 -0
- package/src/lib/workers/canvas-worker.ts +94 -9
- package/src/lib/workers/data.ts +64 -37
- package/src/lib/workers/db-worker.ts +105 -32
- package/src/lib/workers/events.spec.ts +208 -0
- package/src/lib/workers/events.ts +27 -14
- package/src/lib/workers/flexbuilder.ts +2 -2
- package/src/lib/workers/init.ts +25 -17
- package/src/lib/workers/main.ts +506 -327
- package/src/lib/workers/supabase-db-worker.ts +243 -0
- package/src/lib/workers/supabase-shared-worker.ts +607 -0
- package/src/lib/workers/validate.ts +64 -0
- package/src/lib/workers/ws-worker.spec.ts +41 -0
- package/src/lib/workers/ws-worker.ts +255 -31
- package/src/setup-vitest.ts +4 -2
- package/src/types.ts +30 -0
- package/src/vite-env.d.ts +1 -0
- package/workers/main.js +2 -1125
- package/comlink.js +0 -253
- package/index.js +0 -2972
- package/reference.js +0 -259
- package/src/types.d.ts +0 -31
package/workers/main.js
CHANGED
|
@@ -1,1125 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { z as k } from "../index.js";
|
|
4
|
-
let F = Symbol("clean"), m = [], ct = (i, t) => {
|
|
5
|
-
let e = [], s = {
|
|
6
|
-
get() {
|
|
7
|
-
return s.lc || s.listen(() => {
|
|
8
|
-
})(), s.value;
|
|
9
|
-
},
|
|
10
|
-
l: 0,
|
|
11
|
-
lc: 0,
|
|
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
|
-
};
|
|
17
|
-
},
|
|
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
|
-
s.value,
|
|
25
|
-
r
|
|
26
|
-
);
|
|
27
|
-
if (o) {
|
|
28
|
-
for (let n = 0; n < m.length; n += 4) {
|
|
29
|
-
let h;
|
|
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
|
-
));
|
|
37
|
-
h || m[n](m[n + 2], m[n + 3]);
|
|
38
|
-
}
|
|
39
|
-
m.length = 0;
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
off() {
|
|
43
|
-
},
|
|
44
|
-
/* It will be called on last listener unsubscribing.
|
|
45
|
-
We will redefine it in onMount and onStop. */
|
|
46
|
-
set(r) {
|
|
47
|
-
s.value !== r && (s.value = r, s.notify());
|
|
48
|
-
},
|
|
49
|
-
subscribe(r, o) {
|
|
50
|
-
let n = s.listen(r, o);
|
|
51
|
-
return r(s.value), n;
|
|
52
|
-
},
|
|
53
|
-
value: i
|
|
54
|
-
};
|
|
55
|
-
return process.env.NODE_ENV !== "production" && (s[F] = () => {
|
|
56
|
-
e = [], s.lc = 0, s.off();
|
|
57
|
-
}), s;
|
|
58
|
-
};
|
|
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
|
-
shared: {},
|
|
63
|
-
...r
|
|
64
|
-
});
|
|
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
|
-
}, ft, (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
|
-
}
|
|
82
|
-
}, dt);
|
|
83
|
-
}, process.env.NODE_ENV !== "production") {
|
|
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
|
-
};
|
|
89
|
-
}
|
|
90
|
-
return () => {
|
|
91
|
-
i.listen = r, i.off = o;
|
|
92
|
-
};
|
|
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
|
-
...t.value,
|
|
98
|
-
[e]: s
|
|
99
|
-
}, t.notify(e));
|
|
100
|
-
}, t;
|
|
101
|
-
}, _ = (i) => i, W = {}, E = { addEventListener() {
|
|
102
|
-
}, removeEventListener() {
|
|
103
|
-
} };
|
|
104
|
-
function pt() {
|
|
105
|
-
try {
|
|
106
|
-
return typeof localStorage < "u";
|
|
107
|
-
} catch {
|
|
108
|
-
return !1;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
pt() && (W = localStorage);
|
|
112
|
-
let kt = {
|
|
113
|
-
addEventListener(i, t, e) {
|
|
114
|
-
window.addEventListener("storage", t), window.addEventListener("pageshow", e);
|
|
115
|
-
},
|
|
116
|
-
removeEventListener(i, t, e) {
|
|
117
|
-
window.removeEventListener("storage", t), window.removeEventListener("pageshow", e);
|
|
118
|
-
}
|
|
119
|
-
};
|
|
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
|
-
};
|
|
126
|
-
let h = o.set;
|
|
127
|
-
o.set = function(a) {
|
|
128
|
-
for (let l in a)
|
|
129
|
-
o.setKey(l, a[l]);
|
|
130
|
-
for (let l in o.value)
|
|
131
|
-
l in a || o.setKey(l);
|
|
132
|
-
};
|
|
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
|
-
}
|
|
136
|
-
function u() {
|
|
137
|
-
let a = { ...t };
|
|
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
|
-
};
|
|
149
|
-
}), o;
|
|
150
|
-
}
|
|
151
|
-
async function yt(i, {
|
|
152
|
-
version: t,
|
|
153
|
-
i18nPath: e = "https://discord.sh/i18n/db.json",
|
|
154
|
-
locale: s = "en",
|
|
155
|
-
defaults: r = {
|
|
156
|
-
welcome: "Welcome to the app!"
|
|
157
|
-
}
|
|
158
|
-
}) {
|
|
159
|
-
console.log("[init-worker] Initializing database...");
|
|
160
|
-
try {
|
|
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
|
-
}
|
|
168
|
-
}
|
|
169
|
-
let N = null;
|
|
170
|
-
async function mt(i) {
|
|
171
|
-
if (N) return N;
|
|
172
|
-
const t = {};
|
|
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
|
-
name: "unknown",
|
|
176
|
-
version: "0.0.1"
|
|
177
|
-
}, l = `${a.name}@${a.version}`;
|
|
178
|
-
console.log(`[mod-manager] ${l} is loaded.`);
|
|
179
|
-
const c = { id: l, worker: f, instance: u, meta: a, url: n };
|
|
180
|
-
return t[l] = c, c;
|
|
181
|
-
}
|
|
182
|
-
function s(n) {
|
|
183
|
-
t[n] && (t[n].worker.terminate(), delete t[n]);
|
|
184
|
-
}
|
|
185
|
-
function r() {
|
|
186
|
-
return Object.values(t).map((n) => n.meta);
|
|
187
|
-
}
|
|
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
|
-
}
|
|
193
|
-
return N = {
|
|
194
|
-
registry: t,
|
|
195
|
-
load: e,
|
|
196
|
-
unload: s,
|
|
197
|
-
list: r,
|
|
198
|
-
reload: o
|
|
199
|
-
}, N;
|
|
200
|
-
}
|
|
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
|
-
}
|
|
206
|
-
elementWidth(t, e) {
|
|
207
|
-
if (C(this.type)) return this.width;
|
|
208
|
-
for (let s = 0; s < 4; s++) {
|
|
209
|
-
const r = 1 << s, n = t + G(t, r) + e * r - this.offset, h = U(n);
|
|
210
|
-
if (1 << h === r)
|
|
211
|
-
return h;
|
|
212
|
-
}
|
|
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
|
-
}
|
|
215
|
-
writeToBuffer(t) {
|
|
216
|
-
const e = this.builder.computeOffset(t);
|
|
217
|
-
if (this.type === d.FLOAT)
|
|
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
|
-
else if (this.type === d.INT) {
|
|
220
|
-
const s = B(t);
|
|
221
|
-
this.builder.pushInt(this.value, s);
|
|
222
|
-
} else if (this.type === d.UINT) {
|
|
223
|
-
const s = B(t);
|
|
224
|
-
this.builder.pushUInt(this.value, s);
|
|
225
|
-
} else if (this.type === d.NULL)
|
|
226
|
-
this.builder.pushInt(0, this.width);
|
|
227
|
-
else if (this.type === d.BOOL)
|
|
228
|
-
this.builder.pushInt(this.value ? 1 : 0, this.width);
|
|
229
|
-
else
|
|
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 = e;
|
|
232
|
-
}
|
|
233
|
-
storedWidth(t = b.WIDTH8) {
|
|
234
|
-
return C(this.type) ? Math.max(t, this.width) : this.width;
|
|
235
|
-
}
|
|
236
|
-
storedPackedType(t = b.WIDTH8) {
|
|
237
|
-
return it(this.type, this.storedWidth(t));
|
|
238
|
-
}
|
|
239
|
-
isOffset() {
|
|
240
|
-
return !C(this.type);
|
|
241
|
-
}
|
|
242
|
-
}
|
|
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
|
-
}
|
|
247
|
-
align(t) {
|
|
248
|
-
const e = st(t);
|
|
249
|
-
return this.offset += G(this.offset, e), e;
|
|
250
|
-
}
|
|
251
|
-
computeOffset(t) {
|
|
252
|
-
const e = this.offset + t;
|
|
253
|
-
let s = this.buffer.byteLength;
|
|
254
|
-
const r = s;
|
|
255
|
-
for (; s < e; )
|
|
256
|
-
s <<= 1;
|
|
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
|
-
}
|
|
261
|
-
return e;
|
|
262
|
-
}
|
|
263
|
-
pushInt(t, e) {
|
|
264
|
-
if (e === b.WIDTH8)
|
|
265
|
-
this.view.setInt8(this.offset, t);
|
|
266
|
-
else if (e === b.WIDTH16)
|
|
267
|
-
this.view.setInt16(this.offset, t, !0);
|
|
268
|
-
else if (e === b.WIDTH32)
|
|
269
|
-
this.view.setInt32(this.offset, t, !0);
|
|
270
|
-
else if (e === b.WIDTH64)
|
|
271
|
-
this.view.setBigInt64(this.offset, BigInt(t), !0);
|
|
272
|
-
else
|
|
273
|
-
throw `Unexpected width: ${e} for value: ${t}`;
|
|
274
|
-
}
|
|
275
|
-
pushUInt(t, e) {
|
|
276
|
-
if (e === b.WIDTH8)
|
|
277
|
-
this.view.setUint8(this.offset, t);
|
|
278
|
-
else if (e === b.WIDTH16)
|
|
279
|
-
this.view.setUint16(this.offset, t, !0);
|
|
280
|
-
else if (e === b.WIDTH32)
|
|
281
|
-
this.view.setUint32(this.offset, t, !0);
|
|
282
|
-
else if (e === b.WIDTH64)
|
|
283
|
-
this.view.setBigUint64(this.offset, BigInt(t), !0);
|
|
284
|
-
else
|
|
285
|
-
throw `Unexpected width: ${e} for value: ${t}`;
|
|
286
|
-
}
|
|
287
|
-
writeInt(t, e) {
|
|
288
|
-
const s = this.computeOffset(e);
|
|
289
|
-
this.pushInt(t, B(e)), this.offset = s;
|
|
290
|
-
}
|
|
291
|
-
writeUInt(t, e) {
|
|
292
|
-
const s = this.computeOffset(e);
|
|
293
|
-
this.pushUInt(t, B(e)), this.offset = s;
|
|
294
|
-
}
|
|
295
|
-
writeBlob(t) {
|
|
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
|
-
}
|
|
301
|
-
writeString(t) {
|
|
302
|
-
if (this.dedupStrings && Object.prototype.hasOwnProperty.call(this.stringLookup, t)) {
|
|
303
|
-
this.stack.push(this.stringLookup[t]);
|
|
304
|
-
return;
|
|
305
|
-
}
|
|
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
|
-
}
|
|
313
|
-
writeKey(t) {
|
|
314
|
-
if (this.dedupKeys && Object.prototype.hasOwnProperty.call(this.keyLookup, t)) {
|
|
315
|
-
this.stack.push(this.keyLookup[t]);
|
|
316
|
-
return;
|
|
317
|
-
}
|
|
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
|
-
}
|
|
323
|
-
writeStackValue(t, e) {
|
|
324
|
-
const s = this.computeOffset(e);
|
|
325
|
-
if (t.isOffset()) {
|
|
326
|
-
const r = this.offset - t.offset;
|
|
327
|
-
if (e === 8 || BigInt(r) < BigInt(1) << BigInt(e * 8))
|
|
328
|
-
this.writeUInt(r, e);
|
|
329
|
-
else
|
|
330
|
-
throw `Unexpected size ${e}. This might be a bug. Please create an issue https://github.com/google/flatbuffers/issues/new`;
|
|
331
|
-
} else
|
|
332
|
-
t.writeToBuffer(e);
|
|
333
|
-
this.offset = s;
|
|
334
|
-
}
|
|
335
|
-
integrityCheckOnValueAddition() {
|
|
336
|
-
if (this.finished)
|
|
337
|
-
throw "Adding values after finish is prohibited";
|
|
338
|
-
if (this.stackPointers.length !== 0 && this.stackPointers[this.stackPointers.length - 1].isVector === !1 && this.stack[this.stack.length - 1].type !== d.KEY)
|
|
339
|
-
throw "Adding value to a map before adding a key is prohibited";
|
|
340
|
-
}
|
|
341
|
-
integrityCheckOnKeyAddition() {
|
|
342
|
-
if (this.finished)
|
|
343
|
-
throw "Adding values after finish is prohibited";
|
|
344
|
-
if (this.stackPointers.length === 0 || this.stackPointers[this.stackPointers.length - 1].isVector)
|
|
345
|
-
throw "Adding key before starting a map is prohibited";
|
|
346
|
-
}
|
|
347
|
-
startVector() {
|
|
348
|
-
this.stackPointers.push({ stackPosition: this.stack.length, isVector: !0 });
|
|
349
|
-
}
|
|
350
|
-
startMap(t = !1) {
|
|
351
|
-
this.stackPointers.push({ stackPosition: this.stack.length, isVector: !1, presorted: t });
|
|
352
|
-
}
|
|
353
|
-
endVector(t) {
|
|
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
|
-
}
|
|
357
|
-
endMap(t) {
|
|
358
|
-
t.presorted || this.sort(t);
|
|
359
|
-
let e = "";
|
|
360
|
-
for (let n = t.stackPosition; n < this.stack.length; n += 2)
|
|
361
|
-
e += `,${this.stack[n].offset}`;
|
|
362
|
-
const s = this.stack.length - t.stackPosition >> 1;
|
|
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
|
-
}
|
|
367
|
-
sort(t) {
|
|
368
|
-
const e = this.view, s = this.stack;
|
|
369
|
-
function r(a, l) {
|
|
370
|
-
if (a.type !== d.KEY || l.type !== d.KEY)
|
|
371
|
-
throw `Stack values are not keys ${a} | ${l}. Check if you combined [addKey] with add... method calls properly.`;
|
|
372
|
-
let c, w, p = 0;
|
|
373
|
-
do {
|
|
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
|
-
p += 1;
|
|
377
|
-
} while (c !== 0 && w !== 0);
|
|
378
|
-
return !1;
|
|
379
|
-
}
|
|
380
|
-
function o(a, l, c) {
|
|
381
|
-
if (l === c) return;
|
|
382
|
-
const w = a[l], p = a[l + 1];
|
|
383
|
-
a[l] = a[c], a[l + 1] = a[c + 1], a[c] = w, a[c + 1] = p;
|
|
384
|
-
}
|
|
385
|
-
function n() {
|
|
386
|
-
for (let a = t.stackPosition; a < s.length; a += 2) {
|
|
387
|
-
let 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
|
-
}
|
|
392
|
-
}
|
|
393
|
-
function h(a, l) {
|
|
394
|
-
if (a.type !== d.KEY || l.type !== d.KEY)
|
|
395
|
-
throw `Stack values are not keys ${a} | ${l}. Check if you combined [addKey] with add... method calls properly.`;
|
|
396
|
-
if (a.offset === l.offset)
|
|
397
|
-
return !1;
|
|
398
|
-
let c, w, p = 0;
|
|
399
|
-
do {
|
|
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
|
-
p += 1;
|
|
403
|
-
} while (c !== 0 && w !== 0);
|
|
404
|
-
return !1;
|
|
405
|
-
}
|
|
406
|
-
function f(a, l) {
|
|
407
|
-
if (a < l) {
|
|
408
|
-
const c = a + (l - a >> 2) * 2, w = s[c];
|
|
409
|
-
let p = a, I = l;
|
|
410
|
-
do {
|
|
411
|
-
for (; h(s[p], w); )
|
|
412
|
-
p += 2;
|
|
413
|
-
for (; h(w, s[I]); )
|
|
414
|
-
I -= 2;
|
|
415
|
-
p <= I && (o(s, p, I), p += 2, I -= 2);
|
|
416
|
-
} while (p <= I);
|
|
417
|
-
f(a, I), f(p, l);
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
let u = !0;
|
|
421
|
-
for (let a = t.stackPosition; a < this.stack.length - 2; a += 2)
|
|
422
|
-
if (r(this.stack[a], this.stack[a + 2])) {
|
|
423
|
-
u = !1;
|
|
424
|
-
break;
|
|
425
|
-
}
|
|
426
|
-
u || (this.stack.length - t.stackPosition > 40 ? f(t.stackPosition, this.stack.length - 2) : n());
|
|
427
|
-
}
|
|
428
|
-
end() {
|
|
429
|
-
if (this.stackPointers.length < 1) return;
|
|
430
|
-
const t = this.stackPointers.pop();
|
|
431
|
-
t.isVector ? this.endVector(t) : this.endMap(t);
|
|
432
|
-
}
|
|
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
|
-
}
|
|
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
|
-
}
|
|
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
|
-
const l = this.offset;
|
|
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
|
-
}
|
|
458
|
-
return this.offsetStackValue(l, d.VECTOR, o);
|
|
459
|
-
}
|
|
460
|
-
nullStackValue() {
|
|
461
|
-
return new S(this, d.NULL, b.WIDTH8);
|
|
462
|
-
}
|
|
463
|
-
boolStackValue(t) {
|
|
464
|
-
return new S(this, d.BOOL, b.WIDTH8, t);
|
|
465
|
-
}
|
|
466
|
-
intStackValue(t) {
|
|
467
|
-
return new S(this, d.INT, at(t), t);
|
|
468
|
-
}
|
|
469
|
-
uintStackValue(t) {
|
|
470
|
-
return new S(this, d.UINT, U(t), t);
|
|
471
|
-
}
|
|
472
|
-
floatStackValue(t) {
|
|
473
|
-
return new S(this, d.FLOAT, lt(t), t);
|
|
474
|
-
}
|
|
475
|
-
offsetStackValue(t, e, s) {
|
|
476
|
-
return new S(this, e, s, null, t);
|
|
477
|
-
}
|
|
478
|
-
finishBuffer() {
|
|
479
|
-
if (this.stack.length !== 1)
|
|
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], 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
|
-
}
|
|
484
|
-
add(t) {
|
|
485
|
-
if (this.integrityCheckOnValueAddition(), typeof t > "u")
|
|
486
|
-
throw "You need to provide a value";
|
|
487
|
-
if (t === null)
|
|
488
|
-
this.stack.push(this.nullStackValue());
|
|
489
|
-
else if (typeof t == "boolean")
|
|
490
|
-
this.stack.push(this.boolStackValue(t));
|
|
491
|
-
else if (typeof t == "bigint")
|
|
492
|
-
this.stack.push(this.intStackValue(t));
|
|
493
|
-
else if (typeof t == "number")
|
|
494
|
-
Number.isInteger(t) ? this.stack.push(this.intStackValue(t)) : this.stack.push(this.floatStackValue(t));
|
|
495
|
-
else if (ArrayBuffer.isView(t))
|
|
496
|
-
this.writeBlob(t.buffer);
|
|
497
|
-
else if (typeof t == "string" || t instanceof String)
|
|
498
|
-
this.writeString(t);
|
|
499
|
-
else if (Array.isArray(t)) {
|
|
500
|
-
this.startVector();
|
|
501
|
-
for (let e = 0; e < t.length; e++)
|
|
502
|
-
this.add(t[e]);
|
|
503
|
-
this.end();
|
|
504
|
-
} else if (typeof t == "object") {
|
|
505
|
-
const e = Object.getOwnPropertyNames(t).sort();
|
|
506
|
-
this.startMap(!0);
|
|
507
|
-
for (let s = 0; s < e.length; s++) {
|
|
508
|
-
const r = e[s];
|
|
509
|
-
this.addKey(r), this.add(t[r]);
|
|
510
|
-
}
|
|
511
|
-
this.end();
|
|
512
|
-
} else
|
|
513
|
-
throw `Unexpected value input ${t}`;
|
|
514
|
-
}
|
|
515
|
-
finish() {
|
|
516
|
-
this.finished || this.finishBuffer();
|
|
517
|
-
const t = this.buffer.slice(0, this.offset);
|
|
518
|
-
return new Uint8Array(t);
|
|
519
|
-
}
|
|
520
|
-
isFinished() {
|
|
521
|
-
return this.finished;
|
|
522
|
-
}
|
|
523
|
-
addKey(t) {
|
|
524
|
-
this.integrityCheckOnKeyAddition(), this.writeKey(t);
|
|
525
|
-
}
|
|
526
|
-
addInt(t, e = !1, s = !1) {
|
|
527
|
-
if (this.integrityCheckOnValueAddition(), !e) {
|
|
528
|
-
this.stack.push(this.intStackValue(t));
|
|
529
|
-
return;
|
|
530
|
-
}
|
|
531
|
-
if (s && Object.prototype.hasOwnProperty.call(this.indirectIntLookup, t)) {
|
|
532
|
-
this.stack.push(this.indirectIntLookup[t]);
|
|
533
|
-
return;
|
|
534
|
-
}
|
|
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
|
-
}
|
|
540
|
-
addUInt(t, e = !1, s = !1) {
|
|
541
|
-
if (this.integrityCheckOnValueAddition(), !e) {
|
|
542
|
-
this.stack.push(this.uintStackValue(t));
|
|
543
|
-
return;
|
|
544
|
-
}
|
|
545
|
-
if (s && Object.prototype.hasOwnProperty.call(this.indirectUIntLookup, t)) {
|
|
546
|
-
this.stack.push(this.indirectUIntLookup[t]);
|
|
547
|
-
return;
|
|
548
|
-
}
|
|
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
|
-
}
|
|
554
|
-
addFloat(t, e = !1, s = !1) {
|
|
555
|
-
if (this.integrityCheckOnValueAddition(), !e) {
|
|
556
|
-
this.stack.push(this.floatStackValue(t));
|
|
557
|
-
return;
|
|
558
|
-
}
|
|
559
|
-
if (s && Object.prototype.hasOwnProperty.call(this.indirectFloatLookup, t)) {
|
|
560
|
-
this.stack.push(this.indirectFloatLookup[t]);
|
|
561
|
-
return;
|
|
562
|
-
}
|
|
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
|
-
}
|
|
568
|
-
}
|
|
569
|
-
function P() {
|
|
570
|
-
return new gt();
|
|
571
|
-
}
|
|
572
|
-
function Ot(i) {
|
|
573
|
-
const t = P();
|
|
574
|
-
t.startMap();
|
|
575
|
-
for (const [e, s] of Object.entries(i))
|
|
576
|
-
t.addKey(e), t.add(s);
|
|
577
|
-
return t.end(), t.finish();
|
|
578
|
-
}
|
|
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
|
-
else
|
|
586
|
-
throw new Error("Unsupported format for wrapEnvelope");
|
|
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
|
-
}
|
|
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
|
-
const s = {
|
|
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
|
-
};
|
|
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
|
-
else
|
|
607
|
-
throw new Error(`[unwrapEnvelope] Unsupported format: ${s.format}`);
|
|
608
|
-
return { envelope: s, payload: r };
|
|
609
|
-
}
|
|
610
|
-
function $(i) {
|
|
611
|
-
return j(i.buffer).toObject();
|
|
612
|
-
}
|
|
613
|
-
function bt(i) {
|
|
614
|
-
try {
|
|
615
|
-
const t = i instanceof Uint8Array ? i : new Uint8Array(i), e = $(t);
|
|
616
|
-
console.log("[FlexObject]", JSON.stringify(e, null, 2));
|
|
617
|
-
} catch (t) {
|
|
618
|
-
console.error("[Flex Decode Error]", t);
|
|
619
|
-
}
|
|
620
|
-
}
|
|
621
|
-
function q(i, t) {
|
|
622
|
-
return (i & t) === t;
|
|
623
|
-
}
|
|
624
|
-
function vt(i, t) {
|
|
625
|
-
return A(
|
|
626
|
-
{ key: i, value: t },
|
|
627
|
-
g.SET | g.REDIS,
|
|
628
|
-
v.FLEX
|
|
629
|
-
);
|
|
630
|
-
}
|
|
631
|
-
function Et(i) {
|
|
632
|
-
return A(
|
|
633
|
-
{ key: i },
|
|
634
|
-
g.GET | g.REDIS,
|
|
635
|
-
v.FLEX
|
|
636
|
-
);
|
|
637
|
-
}
|
|
638
|
-
function It(i) {
|
|
639
|
-
return A(
|
|
640
|
-
{ key: i },
|
|
641
|
-
g.DEL | g.REDIS,
|
|
642
|
-
v.FLEX
|
|
643
|
-
);
|
|
644
|
-
}
|
|
645
|
-
function Rt(i) {
|
|
646
|
-
const t = X(i);
|
|
647
|
-
if (!q(t.envelope.kind, g.REDIS))
|
|
648
|
-
throw new Error("[Redis] Not a Redis envelope");
|
|
649
|
-
return t;
|
|
650
|
-
}
|
|
651
|
-
function St(i, t, e = "*") {
|
|
652
|
-
return A(
|
|
653
|
-
{ stream: i, id: e, fields: t },
|
|
654
|
-
g.ADD | g.STREAM | g.REDIS,
|
|
655
|
-
v.FLEX
|
|
656
|
-
);
|
|
657
|
-
}
|
|
658
|
-
function Dt(i, t, e) {
|
|
659
|
-
const s = P();
|
|
660
|
-
s.startMap(), s.addKey("streams"), s.startVector();
|
|
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
|
-
}
|
|
667
|
-
const Lt = {
|
|
668
|
-
wrapEnvelope: A,
|
|
669
|
-
unwrapEnvelope: X,
|
|
670
|
-
MessageKind: g,
|
|
671
|
-
PayloadFormat: v,
|
|
672
|
-
unwrapFlexToJson: $,
|
|
673
|
-
inspectFlex: bt,
|
|
674
|
-
hasKind: q,
|
|
675
|
-
redis: {
|
|
676
|
-
wrapRedisSet: vt,
|
|
677
|
-
wrapRedisGet: Et,
|
|
678
|
-
wrapRedisDel: It,
|
|
679
|
-
wrapRedisXAdd: St,
|
|
680
|
-
wrapRedisXRead: Dt,
|
|
681
|
-
parseRedisPayload: Rt
|
|
682
|
-
}
|
|
683
|
-
};
|
|
684
|
-
function Q(i) {
|
|
685
|
-
typeof queueMicrotask == "function" ? queueMicrotask(i) : setTimeout(i, 0);
|
|
686
|
-
}
|
|
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
|
-
Object.assign(t.style, s);
|
|
695
|
-
else if (e === "dataset" && typeof s == "object")
|
|
696
|
-
for (const [r, o] of Object.entries(s))
|
|
697
|
-
t.dataset[r] = String(o);
|
|
698
|
-
else
|
|
699
|
-
try {
|
|
700
|
-
t.setAttribute(e, String(s));
|
|
701
|
-
} catch {
|
|
702
|
-
}
|
|
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
|
-
t.appendChild(s);
|
|
707
|
-
}
|
|
708
|
-
return t;
|
|
709
|
-
}
|
|
710
|
-
const Tt = k.enum(["top", "right", "bottom", "left"]), Ut = k.object({
|
|
711
|
-
width: k.number(),
|
|
712
|
-
height: k.number(),
|
|
713
|
-
mode: k.enum(["static", "animated", "dynamic"]).optional()
|
|
714
|
-
});
|
|
715
|
-
k.object({
|
|
716
|
-
rawHtml: k.string().optional(),
|
|
717
|
-
needsCanvas: k.boolean().optional(),
|
|
718
|
-
canvasOptions: Ut.optional()
|
|
719
|
-
});
|
|
720
|
-
const Wt = k.object({
|
|
721
|
-
name: k.string(),
|
|
722
|
-
version: k.string().optional()
|
|
723
|
-
}), At = k.object({
|
|
724
|
-
meta: Wt.optional(),
|
|
725
|
-
timestamp: k.number()
|
|
726
|
-
}), z = k.object({
|
|
727
|
-
id: Tt,
|
|
728
|
-
payload: k.any().optional()
|
|
729
|
-
}), Vt = k.object({
|
|
730
|
-
timestamp: k.number()
|
|
731
|
-
}), Nt = {
|
|
732
|
-
"droid-ready": Vt,
|
|
733
|
-
"droid-mod-ready": At,
|
|
734
|
-
"panel-open": z,
|
|
735
|
-
"panel-close": z
|
|
736
|
-
};
|
|
737
|
-
class Bt {
|
|
738
|
-
listeners = /* @__PURE__ */ new Map();
|
|
739
|
-
on(t, e) {
|
|
740
|
-
let s = this.listeners.get(t);
|
|
741
|
-
s || (s = /* @__PURE__ */ new Set(), this.listeners.set(t, s)), s.add(e);
|
|
742
|
-
}
|
|
743
|
-
off(t, e) {
|
|
744
|
-
this.listeners.get(t)?.delete(e);
|
|
745
|
-
}
|
|
746
|
-
emit(t, e) {
|
|
747
|
-
const s = Nt[t];
|
|
748
|
-
if (s)
|
|
749
|
-
try {
|
|
750
|
-
s.parse(e);
|
|
751
|
-
} catch (r) {
|
|
752
|
-
console.error(`[DroidEventBus] Invalid payload for ${t}:`, r);
|
|
753
|
-
return;
|
|
754
|
-
}
|
|
755
|
-
window.dispatchEvent(new CustomEvent(t, { detail: e }));
|
|
756
|
-
for (const r of this.listeners.get(t) ?? [])
|
|
757
|
-
r(e);
|
|
758
|
-
}
|
|
759
|
-
wait(t) {
|
|
760
|
-
return new Promise((e) => {
|
|
761
|
-
const s = (r) => {
|
|
762
|
-
this.off(t, s), e(r);
|
|
763
|
-
};
|
|
764
|
-
this.on(t, s);
|
|
765
|
-
});
|
|
766
|
-
}
|
|
767
|
-
}
|
|
768
|
-
const Pt = new Bt(), M = "1.0.3";
|
|
769
|
-
let x = !1;
|
|
770
|
-
function xt(i, t) {
|
|
771
|
-
if (!i)
|
|
772
|
-
throw new Error("[resolveWorkerURL] Worker name must be defined");
|
|
773
|
-
if (typeof window < "u") {
|
|
774
|
-
const e = window.kbveWorkerURLs;
|
|
775
|
-
if (e?.[i]) return e[i];
|
|
776
|
-
}
|
|
777
|
-
return t ?? `/workers/${i}`;
|
|
778
|
-
}
|
|
779
|
-
async function Ct(i) {
|
|
780
|
-
let t = null;
|
|
781
|
-
if (i?.workerRef)
|
|
782
|
-
try {
|
|
783
|
-
return i.workerRef.port.start(), t = y(i.workerRef.port), t;
|
|
784
|
-
} catch (e) {
|
|
785
|
-
console.warn("[DROID] ws-worker workerRef failed:", e);
|
|
786
|
-
}
|
|
787
|
-
if (i?.workerURL)
|
|
788
|
-
try {
|
|
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);
|
|
793
|
-
}
|
|
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");
|
|
827
|
-
}
|
|
828
|
-
const O = J(
|
|
829
|
-
"uiux-state",
|
|
830
|
-
{
|
|
831
|
-
panelManager: {
|
|
832
|
-
top: { open: !1 },
|
|
833
|
-
right: { open: !1 },
|
|
834
|
-
bottom: { open: !1 },
|
|
835
|
-
left: { open: !1 }
|
|
836
|
-
},
|
|
837
|
-
themeManager: { theme: "auto" },
|
|
838
|
-
toastManager: {},
|
|
839
|
-
scrollY: 0
|
|
840
|
-
},
|
|
841
|
-
{
|
|
842
|
-
encode: JSON.stringify,
|
|
843
|
-
decode: JSON.parse
|
|
844
|
-
}
|
|
845
|
-
);
|
|
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
|
-
}
|
|
861
|
-
try {
|
|
862
|
-
const e = new Worker(
|
|
863
|
-
new URL(
|
|
864
|
-
/* @vite-ignore */
|
|
865
|
-
"/lib/workers/canvas-worker.js",
|
|
866
|
-
import.meta.url
|
|
867
|
-
),
|
|
868
|
-
{ type: "module" }
|
|
869
|
-
);
|
|
870
|
-
return t = y(e), t;
|
|
871
|
-
} catch (e) {
|
|
872
|
-
console.warn("[DROID] Vite-style canvas-worker.ts import failed:", e);
|
|
873
|
-
}
|
|
874
|
-
try {
|
|
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);
|
|
892
|
-
}
|
|
893
|
-
throw console.error("[DROID] No Canvas Comlink Initialized"), new Error("[DROID] Failed to initialize canvas worker");
|
|
894
|
-
}
|
|
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);
|
|
900
|
-
},
|
|
901
|
-
closePanel(i) {
|
|
902
|
-
const t = { ...O.get().panelManager };
|
|
903
|
-
t[i] = { open: !1, payload: void 0 }, O.setKey("panelManager", t);
|
|
904
|
-
},
|
|
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);
|
|
908
|
-
},
|
|
909
|
-
setTheme(i) {
|
|
910
|
-
O.setKey("themeManager", { theme: i });
|
|
911
|
-
},
|
|
912
|
-
addToast(i, t) {
|
|
913
|
-
const e = { ...O.get().toastManager, [i]: t };
|
|
914
|
-
O.setKey("toastManager", e);
|
|
915
|
-
},
|
|
916
|
-
removeToast(i) {
|
|
917
|
-
const t = { ...O.get().toastManager };
|
|
918
|
-
delete t[i], O.setKey("toastManager", t);
|
|
919
|
-
},
|
|
920
|
-
async dispatchCanvasRequest(i, t, e = "animated") {
|
|
921
|
-
const s = t.transferControlToOffscreen();
|
|
922
|
-
await window.kbve?.uiux?.worker?.bindCanvas(i, s, e);
|
|
923
|
-
},
|
|
924
|
-
closeAllPanels() {
|
|
925
|
-
const i = { ...O.get().panelManager };
|
|
926
|
-
console.log("error panel is closing");
|
|
927
|
-
for (const t of Object.keys(i))
|
|
928
|
-
i[t] = { open: !1, payload: void 0 };
|
|
929
|
-
O.setKey("panelManager", i);
|
|
930
|
-
},
|
|
931
|
-
emitFromWorker(i) {
|
|
932
|
-
i.type === "injectVNode" && i.vnode && Q(() => {
|
|
933
|
-
const t = document.getElementById("bento-grid-inject");
|
|
934
|
-
if (!t) {
|
|
935
|
-
console.warn(
|
|
936
|
-
"[KBVE] No injection target found: #bento-grid-inject"
|
|
937
|
-
);
|
|
938
|
-
return;
|
|
939
|
-
}
|
|
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);
|
|
943
|
-
s && s.remove();
|
|
944
|
-
}
|
|
945
|
-
t.appendChild(e);
|
|
946
|
-
});
|
|
947
|
-
}
|
|
948
|
-
}, D = J(
|
|
949
|
-
"i18n-cache",
|
|
950
|
-
{},
|
|
951
|
-
{
|
|
952
|
-
encode: JSON.stringify,
|
|
953
|
-
decode: JSON.parse
|
|
954
|
-
}
|
|
955
|
-
), L = {
|
|
956
|
-
store: D,
|
|
957
|
-
api: null,
|
|
958
|
-
ready: Promise.resolve(),
|
|
959
|
-
get(i) {
|
|
960
|
-
return D.get()[i] ?? `[${i}]`;
|
|
961
|
-
},
|
|
962
|
-
async getAsync(i) {
|
|
963
|
-
const t = D.get()[i];
|
|
964
|
-
if (t !== void 0) return t;
|
|
965
|
-
if (!this.api) return `[${i}]`;
|
|
966
|
-
const e = await this.api.getTranslation(i);
|
|
967
|
-
return e !== null ? (D.setKey(i, e), e) : `[${i}]`;
|
|
968
|
-
},
|
|
969
|
-
set(i, t) {
|
|
970
|
-
D.setKey(i, t);
|
|
971
|
-
},
|
|
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);
|
|
977
|
-
}
|
|
978
|
-
},
|
|
979
|
-
async hydrateLocale(i = "en") {
|
|
980
|
-
if (!this.api) return;
|
|
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);
|
|
986
|
-
}
|
|
987
|
-
};
|
|
988
|
-
function Y() {
|
|
989
|
-
if (!navigator.serviceWorker?.controller) return;
|
|
990
|
-
const i = new MessageChannel();
|
|
991
|
-
navigator.serviceWorker.controller.postMessage(i.port2, [
|
|
992
|
-
i.port2
|
|
993
|
-
]), i.port1.start();
|
|
994
|
-
}
|
|
995
|
-
async function Ft(i) {
|
|
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
|
-
}
|
|
1010
|
-
try {
|
|
1011
|
-
const e = new SharedWorker(
|
|
1012
|
-
new URL(
|
|
1013
|
-
/* @vite-ignore */
|
|
1014
|
-
"/lib/workers/db-worker.js",
|
|
1015
|
-
import.meta.url
|
|
1016
|
-
),
|
|
1017
|
-
{ type: "module" }
|
|
1018
|
-
);
|
|
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);
|
|
1022
|
-
}
|
|
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, {
|
|
1046
|
-
version: M,
|
|
1047
|
-
i18nPath: "https://discord.sh/i18n/db.json",
|
|
1048
|
-
locale: "en",
|
|
1049
|
-
defaults: { welcome: "Welcome!", theme: "dark" }
|
|
1050
|
-
}), i;
|
|
1051
|
-
}
|
|
1052
|
-
function Ht(i, t) {
|
|
1053
|
-
const e = tt(async (s) => {
|
|
1054
|
-
Q(() => {
|
|
1055
|
-
const r = `ws:${Date.now()}`;
|
|
1056
|
-
t.storeWsMessage(r, s);
|
|
1057
|
-
});
|
|
1058
|
-
});
|
|
1059
|
-
i.onMessage(et(e, [0]));
|
|
1060
|
-
}
|
|
1061
|
-
async function Kt(i) {
|
|
1062
|
-
if (console.log("[DROID]: Main<T>"), x || (x = !0, navigator.serviceWorker?.controller ? Y() : navigator.serviceWorker?.addEventListener(
|
|
1063
|
-
"controllerchange",
|
|
1064
|
-
Y
|
|
1065
|
-
)), console.log("[DROID] Main<T> => Worker URLs", i?.workerURLs), !window.kbve?.api || !window.kbve?.i18n || !window.kbve?.uiux)
|
|
1066
|
-
try {
|
|
1067
|
-
console.log("[DROID] Main<T> => Worker => CanvasComlink");
|
|
1068
|
-
const e = await jt({
|
|
1069
|
-
workerRef: i?.workerRefs?.canvasWorker,
|
|
1070
|
-
workerURL: i?.workerURLs?.canvasWorker
|
|
1071
|
-
});
|
|
1072
|
-
console.log("[DROID] Main<T> => Worker => StorageComlink");
|
|
1073
|
-
const s = await Ft({
|
|
1074
|
-
workerURL: typeof i?.workerURLs?.dbWorker == "string" ? i.workerURLs.dbWorker : void 0,
|
|
1075
|
-
workerRef: i?.workerRefs?.dbWorker
|
|
1076
|
-
});
|
|
1077
|
-
console.log("[DROID] Main<T> => Worker => WsComlink");
|
|
1078
|
-
const r = await Ct({
|
|
1079
|
-
workerRef: i?.workerRefs?.wsWorker,
|
|
1080
|
-
workerURL: i?.workerURLs?.wsWorker
|
|
1081
|
-
});
|
|
1082
|
-
console.log("[DROID] Main<T> => Worker => ModManager");
|
|
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,
|
|
1091
|
-
timestamp: Date.now()
|
|
1092
|
-
});
|
|
1093
|
-
Ht(r, s);
|
|
1094
|
-
const h = Lt;
|
|
1095
|
-
L.api = s, L.ready = L.hydrateLocale("en"), window.kbve = {
|
|
1096
|
-
...window.kbve || {},
|
|
1097
|
-
api: s,
|
|
1098
|
-
i18n: L,
|
|
1099
|
-
uiux: { ...K, worker: e },
|
|
1100
|
-
ws: r,
|
|
1101
|
-
data: h,
|
|
1102
|
-
mod: o,
|
|
1103
|
-
events: n
|
|
1104
|
-
}, await L.ready, window.kbve.events.emit("droid-ready", {
|
|
1105
|
-
timestamp: Date.now()
|
|
1106
|
-
}), document.addEventListener("astro:page-load", () => {
|
|
1107
|
-
console.debug(
|
|
1108
|
-
"[KBVE] Re-dispatched droid-ready after astro:page-load"
|
|
1109
|
-
), window.kbve?.events.emit("droid-ready", {
|
|
1110
|
-
timestamp: Date.now()
|
|
1111
|
-
});
|
|
1112
|
-
}), console.log("[KBVE] Global API ready");
|
|
1113
|
-
} catch (e) {
|
|
1114
|
-
throw console.error("[DROID] Initialization error:", e), e;
|
|
1115
|
-
}
|
|
1116
|
-
else
|
|
1117
|
-
console.log("[KBVE] Already initialized");
|
|
1118
|
-
}
|
|
1119
|
-
export {
|
|
1120
|
-
Ht as bridgeWsToDb,
|
|
1121
|
-
L as i18n,
|
|
1122
|
-
Kt as main,
|
|
1123
|
-
xt as resolveWorkerURL,
|
|
1124
|
-
K as uiux
|
|
1125
|
-
};
|
|
1
|
+
import { a as e, i as t, n, o as r, r as i, s as a, t as o } from "../main.js";
|
|
2
|
+
export { o as downscale, n as getScaleLevel, i as i18n, t as main, e as resolveWorkerURL, r as uiux, a as upscale };
|