@phantomclient/plugin 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -0
- package/dist/lib/chunks/api-B2tHXZiJ.js +9 -0
- package/dist/lib/chunks/sdk-permissions-BnKU1K9D.js +43 -0
- package/dist/lib/chunks/state-kAlKf5xt.js +33 -0
- package/dist/lib/guest.js +4490 -0
- package/dist/lib/index.js +77 -0
- package/dist/lib/styles.css +1 -0
- package/dist/lib/styles.js +1 -0
- package/dist/lib/vue.js +149 -0
- package/dist/runtime/assets/dm-mono-latin-400-normal--0xN8mdc.woff +0 -0
- package/dist/runtime/assets/dm-mono-latin-400-normal-4GdczIuU.woff2 +0 -0
- package/dist/runtime/assets/ibm-plex-sans-latin-400-normal-CDDApCn2.woff2 +0 -0
- package/dist/runtime/assets/ibm-plex-sans-latin-400-normal-CYLoc0-x.woff +0 -0
- package/dist/runtime/assets/ibm-plex-sans-latin-500-normal-6ng42L7E.woff2 +0 -0
- package/dist/runtime/assets/ibm-plex-sans-latin-500-normal-BgVn5rGT.woff +0 -0
- package/dist/runtime/assets/ibm-plex-sans-latin-600-normal-Cu4Hd6ag.woff +0 -0
- package/dist/runtime/assets/ibm-plex-sans-latin-600-normal-CuJfVYMP.woff2 +0 -0
- package/dist/runtime/assets/instrument-sans-latin-600-normal-B7fBEWYG.woff2 +0 -0
- package/dist/runtime/assets/instrument-sans-latin-600-normal-B9e8oLYv.woff +0 -0
- package/dist/runtime/chunks/api-Bj1J6wAH.js +1 -0
- package/dist/runtime/chunks/runtime-dom.esm-bundler-BbCcCl6A.js +4 -0
- package/dist/runtime/chunks/sdk-permissions-D_NYB67a.js +1 -0
- package/dist/runtime/chunks/state-CFbUQLzX.js +1 -0
- package/dist/runtime/frame.html +18 -0
- package/dist/runtime/runtime.css +1 -0
- package/dist/runtime/runtime.js +1 -0
- package/dist/runtime/sdk-vue.js +1 -0
- package/dist/runtime/sdk.js +1 -0
- package/dist/runtime/vue.js +1 -0
- package/dist/types/index.d.ts +9156 -0
- package/dist/types/vue.d.ts +6425 -0
- package/package.json +24 -0
|
@@ -0,0 +1,4490 @@
|
|
|
1
|
+
import { S as On, i as $n, P as F, a as Pn } from "./chunks/sdk-permissions-BnKU1K9D.js";
|
|
2
|
+
import { isRef as Ln, toRaw as Un, defineComponent as Fn, computed as Bn, openBlock as ye, createElementBlock as we, createElementVNode as te, toDisplayString as Le, createCommentVNode as wt, createApp as vt, h as bt } from "vue";
|
|
3
|
+
import { P as C } from "./chunks/api-B2tHXZiJ.js";
|
|
4
|
+
import { f as I, b as Rn, r as zn, s as It, P as Vn } from "./chunks/state-kAlKf5xt.js";
|
|
5
|
+
import { c as ns } from "./chunks/state-kAlKf5xt.js";
|
|
6
|
+
function Ne(e) {
|
|
7
|
+
return e instanceof C ? { code: e.code, message: e.message, ...e.stack ? { stack: e.stack } : {} } : e instanceof Error ? { code: "FAILED", message: e.message || e.name, ...e.stack ? { stack: e.stack } : {} } : { code: "FAILED", message: $(e) };
|
|
8
|
+
}
|
|
9
|
+
function Hn(e) {
|
|
10
|
+
const t = e && typeof e.code == "string" && e.code ? e.code : "FAILED";
|
|
11
|
+
return new C(t, (e == null ? void 0 : e.message) || "Phantom could not do this");
|
|
12
|
+
}
|
|
13
|
+
function qe(e) {
|
|
14
|
+
return X(e, /* @__PURE__ */ new WeakMap());
|
|
15
|
+
}
|
|
16
|
+
function X(e, t) {
|
|
17
|
+
if (Ln(e)) return X(e.value, t);
|
|
18
|
+
if (typeof e == "function" || typeof e == "symbol") return;
|
|
19
|
+
if (typeof e != "object" || e === null) return e;
|
|
20
|
+
const n = Un(e);
|
|
21
|
+
if (t.has(n)) return t.get(n);
|
|
22
|
+
if (n instanceof Date || n instanceof RegExp || n instanceof ArrayBuffer || ArrayBuffer.isView(n)) return n;
|
|
23
|
+
if (Array.isArray(n)) {
|
|
24
|
+
const i = [];
|
|
25
|
+
t.set(n, i);
|
|
26
|
+
for (const a of n) i.push(X(a, t));
|
|
27
|
+
return i;
|
|
28
|
+
}
|
|
29
|
+
if (n instanceof Map) {
|
|
30
|
+
const i = /* @__PURE__ */ new Map();
|
|
31
|
+
t.set(n, i);
|
|
32
|
+
for (const [a, s] of n) i.set(X(a, t), X(s, t));
|
|
33
|
+
return i;
|
|
34
|
+
}
|
|
35
|
+
if (n instanceof Set) {
|
|
36
|
+
const i = /* @__PURE__ */ new Set();
|
|
37
|
+
t.set(n, i);
|
|
38
|
+
for (const a of n) i.add(X(a, t));
|
|
39
|
+
return i;
|
|
40
|
+
}
|
|
41
|
+
if (n instanceof Error) return Ne(n);
|
|
42
|
+
const r = {};
|
|
43
|
+
t.set(n, r);
|
|
44
|
+
for (const [i, a] of Object.entries(n)) {
|
|
45
|
+
const s = X(a, t);
|
|
46
|
+
s !== void 0 && (r[i] = s);
|
|
47
|
+
}
|
|
48
|
+
return r;
|
|
49
|
+
}
|
|
50
|
+
function $(e) {
|
|
51
|
+
if (typeof e == "string") return e;
|
|
52
|
+
if (e instanceof Error) return e.stack || `${e.name}: ${e.message}`;
|
|
53
|
+
if (e === void 0) return "undefined";
|
|
54
|
+
if (typeof e == "function") return `[Function ${e.name || "anonymous"}]`;
|
|
55
|
+
if (typeof e == "symbol" || typeof e == "bigint") return e.toString();
|
|
56
|
+
try {
|
|
57
|
+
const t = /* @__PURE__ */ new WeakSet(), n = JSON.stringify(qe(e), (r, i) => {
|
|
58
|
+
if (typeof i == "object" && i !== null) {
|
|
59
|
+
if (t.has(i)) return "[Circular]";
|
|
60
|
+
t.add(i);
|
|
61
|
+
}
|
|
62
|
+
return typeof i == "bigint" ? `${i}n` : i;
|
|
63
|
+
});
|
|
64
|
+
return kt(n ?? String(e));
|
|
65
|
+
} catch {
|
|
66
|
+
return kt(String(e));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
const Ue = 1e4;
|
|
70
|
+
function kt(e) {
|
|
71
|
+
return e.length > Ue ? `${e.slice(0, Ue)}… (${e.length - Ue} more)` : e;
|
|
72
|
+
}
|
|
73
|
+
const Wn = ["log", "info", "warn", "error"];
|
|
74
|
+
function _n(e, t) {
|
|
75
|
+
const n = /* @__PURE__ */ new Map();
|
|
76
|
+
let r = !1;
|
|
77
|
+
for (const i of Wn) {
|
|
78
|
+
const a = e[i].bind(e);
|
|
79
|
+
n.set(i, a), e[i] = (...s) => {
|
|
80
|
+
if (a(...s), !r) {
|
|
81
|
+
r = !0;
|
|
82
|
+
try {
|
|
83
|
+
t(i, s.map($));
|
|
84
|
+
} finally {
|
|
85
|
+
r = !1;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
return () => {
|
|
91
|
+
for (const [i, a] of n) e[i] = a;
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
class D extends Error {
|
|
95
|
+
constructor(t, n, r = null) {
|
|
96
|
+
super(Kn(n, r, t)), this.code = t, this.flash = r, this.name = "BridgeError";
|
|
97
|
+
}
|
|
98
|
+
code;
|
|
99
|
+
flash;
|
|
100
|
+
}
|
|
101
|
+
function Kn(e, t, n) {
|
|
102
|
+
if (typeof e == "string" && e.trim() !== "") return Xn(e, t);
|
|
103
|
+
const r = Yn(e);
|
|
104
|
+
return r || (typeof (t == null ? void 0 : t.name) == "string" ? t.name.trim() : "") || `The game answered with no reason (${n})`;
|
|
105
|
+
}
|
|
106
|
+
const Gn = { 1006: "that member is not a method", 1009: "something the call reached was null", 1010: "that member is not there", 1034: "a value was not of the type the member takes", 1056: "that object has nowhere to put the value", 1063: "the call was given the wrong number of arguments", 1069: "the object has no member of that name", 1502: "a script in the game ran for longer than the player allows", 2007: "a value the call needs was null" };
|
|
107
|
+
function Xn(e, t) {
|
|
108
|
+
const n = typeof (t == null ? void 0 : t.errorId) == "number" ? t.errorId : 0, r = Gn[n];
|
|
109
|
+
return !r || !/^\s*Error #\d+\s*$/.test(e) ? e : `${e.trim()}: ${r}`;
|
|
110
|
+
}
|
|
111
|
+
function Yn(e) {
|
|
112
|
+
if (e == null) return "";
|
|
113
|
+
if (typeof e == "string") return e.trim();
|
|
114
|
+
if (typeof e != "object") return String(e);
|
|
115
|
+
const t = e;
|
|
116
|
+
if (typeof t.message == "string" && t.message.trim() !== "") return t.message;
|
|
117
|
+
try {
|
|
118
|
+
const n = JSON.stringify(e);
|
|
119
|
+
return n && n !== "{}" ? n : "";
|
|
120
|
+
} catch {
|
|
121
|
+
return "";
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
const xt = 2;
|
|
125
|
+
function re(e) {
|
|
126
|
+
return encodeURIComponent(JSON.stringify(e));
|
|
127
|
+
}
|
|
128
|
+
function un(e) {
|
|
129
|
+
return JSON.parse(decodeURIComponent(e));
|
|
130
|
+
}
|
|
131
|
+
function Jn(e) {
|
|
132
|
+
return typeof e == "object" && e !== null && "$handle" in e;
|
|
133
|
+
}
|
|
134
|
+
function Qn(e) {
|
|
135
|
+
switch (e.kind) {
|
|
136
|
+
case "result":
|
|
137
|
+
return e.id;
|
|
138
|
+
case "event":
|
|
139
|
+
return e.listener;
|
|
140
|
+
case "callback":
|
|
141
|
+
return e.callback;
|
|
142
|
+
case "hook":
|
|
143
|
+
case "override":
|
|
144
|
+
case "hook-dropped":
|
|
145
|
+
case "hook-failed":
|
|
146
|
+
return e.registration;
|
|
147
|
+
case "watch":
|
|
148
|
+
return e.watch;
|
|
149
|
+
case "tick":
|
|
150
|
+
return e.tick;
|
|
151
|
+
case "overlay":
|
|
152
|
+
return e.node;
|
|
153
|
+
case "key":
|
|
154
|
+
return e.key;
|
|
155
|
+
case "drive-failed":
|
|
156
|
+
return e.drive;
|
|
157
|
+
case "track":
|
|
158
|
+
return e.track;
|
|
159
|
+
default:
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
class ct {
|
|
164
|
+
constructor(t, n = []) {
|
|
165
|
+
this.className = t, this.args = n;
|
|
166
|
+
}
|
|
167
|
+
className;
|
|
168
|
+
args;
|
|
169
|
+
}
|
|
170
|
+
class L {
|
|
171
|
+
constructor(t, n, r) {
|
|
172
|
+
this.bridge = t, this.handle = n, this.className = r;
|
|
173
|
+
}
|
|
174
|
+
bridge;
|
|
175
|
+
handle;
|
|
176
|
+
className;
|
|
177
|
+
at(...t) {
|
|
178
|
+
return new J(this.bridge, { kind: "handle", handle: this.handle }, t);
|
|
179
|
+
}
|
|
180
|
+
release() {
|
|
181
|
+
return this.bridge.release([this]);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
class J {
|
|
185
|
+
constructor(t, n, r = []) {
|
|
186
|
+
this.bridge = t, this.target = n, this.path = r;
|
|
187
|
+
}
|
|
188
|
+
bridge;
|
|
189
|
+
target;
|
|
190
|
+
path;
|
|
191
|
+
at(...t) {
|
|
192
|
+
return new J(this.bridge, this.target, [...this.path, ...t]);
|
|
193
|
+
}
|
|
194
|
+
get() {
|
|
195
|
+
return this.bridge.request({ op: "get", target: this.target, path: [...this.path] });
|
|
196
|
+
}
|
|
197
|
+
set(t) {
|
|
198
|
+
return this.bridge.request({ op: "set", target: this.target, path: [...this.path], value: this.bridge.encode(t) }).then(() => {
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
call(...t) {
|
|
202
|
+
return this.bridge.request({ op: "call", target: this.target, path: [...this.path], args: t.map((n) => this.bridge.encode(n)) });
|
|
203
|
+
}
|
|
204
|
+
describe() {
|
|
205
|
+
return this.bridge.request({ op: "describe", target: this.target, path: [...this.path] });
|
|
206
|
+
}
|
|
207
|
+
listen(t, n) {
|
|
208
|
+
return this.bridge.listen(this, t, n);
|
|
209
|
+
}
|
|
210
|
+
get entry() {
|
|
211
|
+
return { target: this.target, path: [...this.path] };
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
const Zn = /* @__PURE__ */ new Set(["drive-failed", "track", "hook", "override", "hook-dropped", "hook-failed", "watch", "tick", "overlay", "key"]);
|
|
215
|
+
class er {
|
|
216
|
+
constructor(t, n = {}) {
|
|
217
|
+
this.transport = t, this.timeoutMs = n.timeoutMs ?? 5e3, this.firstId = n.firstId ?? 1, this.nextId = this.firstId, this.batchOption = n.batch, this.stopReceiving = t.onMessage((r) => this.receive(r));
|
|
218
|
+
}
|
|
219
|
+
transport;
|
|
220
|
+
stateValue = "waiting";
|
|
221
|
+
nextId;
|
|
222
|
+
pending = /* @__PURE__ */ new Map();
|
|
223
|
+
listeners = /* @__PURE__ */ new Map();
|
|
224
|
+
callbacks = /* @__PURE__ */ new Map();
|
|
225
|
+
readyWaiters = [];
|
|
226
|
+
clientListeners = /* @__PURE__ */ new Set();
|
|
227
|
+
uncaughtListeners = /* @__PURE__ */ new Set();
|
|
228
|
+
timeoutMs;
|
|
229
|
+
stopReceiving;
|
|
230
|
+
clientVersion = null;
|
|
231
|
+
featureList = [];
|
|
232
|
+
firstId;
|
|
233
|
+
batchOption;
|
|
234
|
+
queue = [];
|
|
235
|
+
batches = /* @__PURE__ */ new Map();
|
|
236
|
+
subscriptions = /* @__PURE__ */ new Map();
|
|
237
|
+
ticks = /* @__PURE__ */ new Map();
|
|
238
|
+
get state() {
|
|
239
|
+
return this.stateValue;
|
|
240
|
+
}
|
|
241
|
+
get client() {
|
|
242
|
+
return this.clientVersion;
|
|
243
|
+
}
|
|
244
|
+
get features() {
|
|
245
|
+
return this.featureList;
|
|
246
|
+
}
|
|
247
|
+
allocate() {
|
|
248
|
+
return this.nextId++;
|
|
249
|
+
}
|
|
250
|
+
whenReady() {
|
|
251
|
+
return this.stateValue === "ready" ? Promise.resolve() : this.stateValue === "closed" ? Promise.reject(new D("CLOSED", "The game is closed")) : new Promise((t, n) => this.readyWaiters.push({ resolve: t, reject: n }));
|
|
252
|
+
}
|
|
253
|
+
definition(t) {
|
|
254
|
+
return new J(this, { kind: "definition", name: t });
|
|
255
|
+
}
|
|
256
|
+
gameClient() {
|
|
257
|
+
return new J(this, { kind: "client" });
|
|
258
|
+
}
|
|
259
|
+
stage() {
|
|
260
|
+
return new J(this, { kind: "stage" });
|
|
261
|
+
}
|
|
262
|
+
construct(t, ...n) {
|
|
263
|
+
return this.request({ op: "construct", className: t, args: n.map((r) => this.encode(r)) });
|
|
264
|
+
}
|
|
265
|
+
onClient(t) {
|
|
266
|
+
return this.clientListeners.add(t), () => this.clientListeners.delete(t);
|
|
267
|
+
}
|
|
268
|
+
onUncaught(t) {
|
|
269
|
+
return this.uncaughtListeners.add(t), () => this.uncaughtListeners.delete(t);
|
|
270
|
+
}
|
|
271
|
+
async listen(t, n, r) {
|
|
272
|
+
const i = this.nextId++;
|
|
273
|
+
this.listeners.set(i, r);
|
|
274
|
+
try {
|
|
275
|
+
await this.request({ op: "listen", target: t.target, path: [...t.path], event: n, listener: i });
|
|
276
|
+
} catch (a) {
|
|
277
|
+
throw this.listeners.delete(i), a;
|
|
278
|
+
}
|
|
279
|
+
return async () => {
|
|
280
|
+
!this.listeners.delete(i) || this.stateValue === "closed" || await this.request({ op: "unlisten", listener: i });
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
async subscribe(t, n, r) {
|
|
284
|
+
const i = this.nextId++;
|
|
285
|
+
this.subscriptions.set(i, r);
|
|
286
|
+
try {
|
|
287
|
+
await this.request(t(i));
|
|
288
|
+
} catch (a) {
|
|
289
|
+
throw this.subscriptions.delete(i), a;
|
|
290
|
+
}
|
|
291
|
+
return async () => {
|
|
292
|
+
!this.subscriptions.delete(i) || this.stateValue === "closed" || await this.request(n(i));
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
onSubscription(t, n) {
|
|
296
|
+
return this.subscriptions.set(t, n), () => {
|
|
297
|
+
this.subscriptions.get(t) === n && this.subscriptions.delete(t);
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
async hookTable(t) {
|
|
301
|
+
return await this.request(t === void 0 ? { op: "hookTable" } : { op: "hookTable", url: t });
|
|
302
|
+
}
|
|
303
|
+
async hook(t, n, r) {
|
|
304
|
+
let i = 0;
|
|
305
|
+
const a = await this.subscribe((s) => (i = s, { op: "hook", registration: s, hook: t, rules: n }), (s) => ({ op: "unhook", registration: s }), r);
|
|
306
|
+
return { registration: i, stop: a };
|
|
307
|
+
}
|
|
308
|
+
watch(t, n, r) {
|
|
309
|
+
return this.subscribe((i) => ({ op: "watch", watch: i, entries: t.map((a) => ({ target: a.target, path: [...a.path] })), everyFrames: Math.max(1, Math.floor(n.everyFrames ?? 1)), handles: n.handles ?? !1 }), (i) => ({ op: "unwatch", watch: i }), (i) => {
|
|
310
|
+
i.kind === "watch" && r(i.values.map((a) => this.decode(a)), i.errors ?? null);
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
async tick(t, n) {
|
|
314
|
+
const r = Math.max(1, Math.floor(t));
|
|
315
|
+
let i = this.ticks.get(r);
|
|
316
|
+
if (!i) {
|
|
317
|
+
const o = /* @__PURE__ */ new Set(), d = this.subscribe((c) => ({ op: "tick", tick: c, everyFrames: r }), (c) => ({ op: "untick", tick: c }), (c) => {
|
|
318
|
+
if (c.kind === "tick") for (const h of [...o]) h(c.frame, c.time);
|
|
319
|
+
});
|
|
320
|
+
i = { listeners: o, started: d }, this.ticks.set(r, i), d.catch(() => {
|
|
321
|
+
this.ticks.get(r) === i && this.ticks.delete(r);
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
const a = i;
|
|
325
|
+
a.listeners.add(n);
|
|
326
|
+
try {
|
|
327
|
+
await a.started;
|
|
328
|
+
} catch (o) {
|
|
329
|
+
throw a.listeners.delete(n), o;
|
|
330
|
+
}
|
|
331
|
+
let s = !1;
|
|
332
|
+
return async () => {
|
|
333
|
+
s || (s = !0, a.listeners.delete(n), !(a.listeners.size > 0 || this.ticks.get(r) !== a) && (this.ticks.delete(r), await (await a.started)()));
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
highlight(t, n) {
|
|
337
|
+
return this.subscribe((r) => ({ op: "highlight", highlight: r, target: t.target, path: [...t.path], effect: n }), (r) => ({ op: "unhighlight", highlight: r }), () => {
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
style(t, n) {
|
|
341
|
+
return this.subscribe((r) => ({ op: "style", style: r, target: t.target, path: [...t.path], format: n }), (r) => ({ op: "unstyle", style: r }), () => {
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
invokeOriginal(t, n, r) {
|
|
345
|
+
return this.request({ op: "invokeOriginal", registration: t, token: n, arguments: r === null ? null : r.map((i) => this.encode(i)) });
|
|
346
|
+
}
|
|
347
|
+
async overrideDone(t, n) {
|
|
348
|
+
this.stateValue !== "closed" && await this.request({ op: "overrideDone", registration: t, token: n });
|
|
349
|
+
}
|
|
350
|
+
onKey(t, n) {
|
|
351
|
+
return this.subscribe((r) => ({ op: "key", key: r, spec: t }), (r) => ({ op: "unkey", key: r }), (r) => {
|
|
352
|
+
r.kind === "key" && n(r);
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
async draw(t, n) {
|
|
356
|
+
await this.request({ op: "draw", node: t, spec: n });
|
|
357
|
+
}
|
|
358
|
+
async erase(t) {
|
|
359
|
+
if (!(t.length === 0 || this.stateValue === "closed")) {
|
|
360
|
+
for (const n of t) this.subscriptions.delete(n);
|
|
361
|
+
await this.request({ op: "erase", nodes: [...t] });
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
drive(t, n) {
|
|
365
|
+
return this.subscribe((r) => ({ op: "drive", drive: r, spec: t }), (r) => ({ op: "undrive", drive: r }), (r) => {
|
|
366
|
+
r.kind === "drive-failed" && (n == null || n(r.error));
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
async collect(t, n) {
|
|
370
|
+
const r = await this.request({ op: "collect", target: t.target, path: [...t.path], spec: n });
|
|
371
|
+
return { items: Array.isArray(r == null ? void 0 : r.items) ? r.items : [], total: typeof (r == null ? void 0 : r.total) == "number" ? r.total : 0 };
|
|
372
|
+
}
|
|
373
|
+
track(t, n, { mode: r = "displayList", everyFrames: i = 15 } = {}, a) {
|
|
374
|
+
return this.subscribe((s) => ({ op: "track", track: s, target: t.target, path: [...t.path], className: n, mode: r, everyFrames: i }), (s) => ({ op: "untrack", track: s }), (s) => {
|
|
375
|
+
s.kind === "track" && a({ added: s.added.map((o) => this.decode(o)), removed: s.removed.map((o) => this.decode(o)) });
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
async snapshot(t, { scale: n = 1, background: r = null, maxSize: i = 0 } = {}) {
|
|
379
|
+
const a = await this.request({ op: "snapshot", target: t.target, path: [...t.path], scale: n, background: r, maxSize: i });
|
|
380
|
+
if (typeof a != "string") throw new D("FLASH", "The picture came back empty");
|
|
381
|
+
return a;
|
|
382
|
+
}
|
|
383
|
+
note(t, n, r, i) {
|
|
384
|
+
if (n === "keys" || n === "clear") return this.request({ op: "note", table: t, verb: n });
|
|
385
|
+
if (!r) throw new TypeError(`A note to ${n} is kept beside an object; name the place`);
|
|
386
|
+
const a = { target: r.target, path: [...r.path] };
|
|
387
|
+
return n === "write" ? this.request({ op: "note", table: t, verb: n, ...a, value: this.encode(i) }) : this.request({ op: "note", table: t, verb: n, ...a });
|
|
388
|
+
}
|
|
389
|
+
async find(t, n) {
|
|
390
|
+
const r = await this.request({ op: "find", target: t.target, path: [...t.path], spec: n });
|
|
391
|
+
return (Array.isArray(r) ? r : []).filter((i) => i instanceof L);
|
|
392
|
+
}
|
|
393
|
+
async answer(t, n) {
|
|
394
|
+
this.stateValue !== "closed" && await this.request({ op: "answer", callback: t, ...n === void 0 ? {} : { value: this.encode(n) } });
|
|
395
|
+
}
|
|
396
|
+
async release(t) {
|
|
397
|
+
t.length === 0 || this.stateValue === "closed" || await this.request({ op: "release", handles: t.map((n) => n.handle) });
|
|
398
|
+
}
|
|
399
|
+
close() {
|
|
400
|
+
if (this.stateValue === "closed") return;
|
|
401
|
+
if (this.stateValue === "ready" && this.featureList.includes("dispose")) {
|
|
402
|
+
const n = this.nextId++;
|
|
403
|
+
try {
|
|
404
|
+
this.transport.send(re({ id: n, op: "dispose", from: this.firstId, to: this.nextId }));
|
|
405
|
+
} catch {
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
this.stateValue = "closed", this.stopReceiving();
|
|
409
|
+
const t = new D("CLOSED", "The game was closed");
|
|
410
|
+
for (const n of this.pending.values()) clearTimeout(n.timer), n.reject(t);
|
|
411
|
+
this.pending.clear();
|
|
412
|
+
for (const n of this.batches.values()) clearTimeout(n.timer);
|
|
413
|
+
this.batches.clear(), this.queue = [], this.listeners.clear(), this.callbacks.clear(), this.subscriptions.clear(), this.ticks.clear(), this.readyWaiters.splice(0).forEach((n) => n.reject(t));
|
|
414
|
+
}
|
|
415
|
+
readyWithin(t) {
|
|
416
|
+
return new Promise((n, r) => {
|
|
417
|
+
const i = setTimeout(() => r(new D("NOT_READY", "The game has not started yet")), t);
|
|
418
|
+
this.whenReady().then(() => {
|
|
419
|
+
clearTimeout(i), n();
|
|
420
|
+
}, (a) => {
|
|
421
|
+
clearTimeout(i), r(a);
|
|
422
|
+
});
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
encodeRequest(t) {
|
|
426
|
+
return re({ ...t, id: this.nextId++ });
|
|
427
|
+
}
|
|
428
|
+
request(t) {
|
|
429
|
+
if (this.stateValue === "closed") return Promise.reject(new D("CLOSED", "The game is closed"));
|
|
430
|
+
if (this.stateValue !== "ready") return this.readyWithin(this.timeoutMs).then(() => this.request(t));
|
|
431
|
+
const n = this.nextId++;
|
|
432
|
+
return new Promise((r, i) => {
|
|
433
|
+
const a = setTimeout(() => {
|
|
434
|
+
this.pending.delete(n), i(new D("TIMEOUT", `The game did not answer "${t.op}" in ${this.timeoutMs}ms`));
|
|
435
|
+
}, this.timeoutMs);
|
|
436
|
+
this.pending.set(n, { resolve: r, reject: i, timer: a });
|
|
437
|
+
const s = { ...t, id: n };
|
|
438
|
+
if (!this.batching || s.op === "hookTable" || s.op === "batch") {
|
|
439
|
+
this.transport.send(re(s));
|
|
440
|
+
return;
|
|
441
|
+
}
|
|
442
|
+
this.queue.push(s), this.queue.length === 1 && queueMicrotask(() => this.flush());
|
|
443
|
+
});
|
|
444
|
+
}
|
|
445
|
+
get batching() {
|
|
446
|
+
return this.batchOption ?? this.featureList.includes("batch");
|
|
447
|
+
}
|
|
448
|
+
flush() {
|
|
449
|
+
const t = this.queue;
|
|
450
|
+
if (this.queue = [], t.length === 0 || this.stateValue !== "ready") return;
|
|
451
|
+
if (t.length === 1) {
|
|
452
|
+
this.transport.send(re(t[0]));
|
|
453
|
+
return;
|
|
454
|
+
}
|
|
455
|
+
const n = this.nextId++, r = t.map((a) => a.id), i = setTimeout(() => this.batches.delete(n), this.timeoutMs + 1e3);
|
|
456
|
+
this.batches.set(n, { ids: r, timer: i }), this.transport.send(re({ id: n, op: "batch", requests: t }));
|
|
457
|
+
}
|
|
458
|
+
settle(t, n) {
|
|
459
|
+
const r = this.pending.get(t);
|
|
460
|
+
r && (this.pending.delete(t), clearTimeout(r.timer), n.ok ? r.resolve(this.decode(n.value)) : r.reject(new D("FLASH", n.error.message, n.error)));
|
|
461
|
+
}
|
|
462
|
+
encode(t) {
|
|
463
|
+
if (t === void 0) return { $undefined: !0 };
|
|
464
|
+
if (t === null || typeof t != "object") {
|
|
465
|
+
if (typeof t == "function") {
|
|
466
|
+
const n = this.nextId++;
|
|
467
|
+
return this.callbacks.set(n, t), { $callback: n };
|
|
468
|
+
}
|
|
469
|
+
return t;
|
|
470
|
+
}
|
|
471
|
+
return t instanceof L ? { $handle: t.handle } : t instanceof ct ? { $new: t.className, args: t.args.map((n) => this.encode(n)) } : Array.isArray(t) ? t.map((n) => this.encode(n)) : Object.fromEntries(Object.entries(t).map(([n, r]) => [n, this.encode(r)]));
|
|
472
|
+
}
|
|
473
|
+
decode(t) {
|
|
474
|
+
if (t === null || typeof t != "object") return t;
|
|
475
|
+
if (Array.isArray(t)) return t.map((n) => this.decode(n));
|
|
476
|
+
if (Jn(t)) return new L(this, t.$handle, t.className);
|
|
477
|
+
if (!("$undefined" in t)) return Object.fromEntries(Object.entries(t).map(([n, r]) => [n, this.decode(r)]));
|
|
478
|
+
}
|
|
479
|
+
receive(t) {
|
|
480
|
+
var n, r, i;
|
|
481
|
+
if (this.stateValue === "closed") return;
|
|
482
|
+
let a;
|
|
483
|
+
try {
|
|
484
|
+
a = un(t);
|
|
485
|
+
} catch {
|
|
486
|
+
return;
|
|
487
|
+
}
|
|
488
|
+
switch (a.kind) {
|
|
489
|
+
case "ready":
|
|
490
|
+
if (a.version !== xt) {
|
|
491
|
+
const s = new D("VERSION", `The loader speaks bridge ${a.version}; this Phantom speaks ${xt}`);
|
|
492
|
+
this.readyWaiters.splice(0).forEach((o) => o.reject(s)), this.close();
|
|
493
|
+
return;
|
|
494
|
+
}
|
|
495
|
+
this.stateValue = "ready", this.clientVersion = a.client, this.featureList = Array.isArray(a.features) ? [...a.features] : [], this.readyWaiters.splice(0).forEach((s) => s.resolve());
|
|
496
|
+
return;
|
|
497
|
+
case "client-loaded":
|
|
498
|
+
this.clientListeners.forEach((s) => s(!0, null));
|
|
499
|
+
return;
|
|
500
|
+
case "client-failed":
|
|
501
|
+
this.clientListeners.forEach((s) => s(!1, a.message));
|
|
502
|
+
return;
|
|
503
|
+
case "result": {
|
|
504
|
+
const s = this.batches.get(a.id);
|
|
505
|
+
if (s) {
|
|
506
|
+
this.batches.delete(a.id), clearTimeout(s.timer);
|
|
507
|
+
const o = a.ok && Array.isArray(a.value) ? a.value : null;
|
|
508
|
+
s.ids.forEach((d, c) => {
|
|
509
|
+
a.ok ? o && c < o.length && this.settle(d, o[c]) : this.settle(d, a);
|
|
510
|
+
});
|
|
511
|
+
return;
|
|
512
|
+
}
|
|
513
|
+
this.settle(a.id, a.ok ? { ok: !0, value: a.value } : a);
|
|
514
|
+
return;
|
|
515
|
+
}
|
|
516
|
+
case "event":
|
|
517
|
+
(n = this.listeners.get(a.listener)) == null || n(this.decode(a.event));
|
|
518
|
+
return;
|
|
519
|
+
case "callback":
|
|
520
|
+
(r = this.callbacks.get(a.callback)) == null || r(...a.args.map((s) => this.decode(s)));
|
|
521
|
+
return;
|
|
522
|
+
case "uncaught": {
|
|
523
|
+
const s = new D("FLASH", a.error.message, a.error);
|
|
524
|
+
this.uncaughtListeners.forEach((o) => o(s));
|
|
525
|
+
return;
|
|
526
|
+
}
|
|
527
|
+
default:
|
|
528
|
+
if (Zn.has(a.kind)) {
|
|
529
|
+
const s = Qn(a);
|
|
530
|
+
s !== null && ((i = this.subscriptions.get(s)) == null || i(a));
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
const tr = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0], hn = { r: 0.3086, g: 0.6094, b: 0.082 };
|
|
536
|
+
function ve(e, t) {
|
|
537
|
+
const n = new Array(20).fill(0);
|
|
538
|
+
for (let r = 0; r < 4; r++) for (let i = 0; i < 5; i++) {
|
|
539
|
+
let a = i === 4 ? t[r * 5 + 4] : 0;
|
|
540
|
+
for (let s = 0; s < 4; s++) a += t[r * 5 + s] * e[s * 5 + i];
|
|
541
|
+
n[r * 5 + i] = a;
|
|
542
|
+
}
|
|
543
|
+
return n;
|
|
544
|
+
}
|
|
545
|
+
function mn(e) {
|
|
546
|
+
const t = e, { r: n, g: r, b: i } = hn;
|
|
547
|
+
return [n * (1 - t) + t, r * (1 - t), i * (1 - t), 0, 0, n * (1 - t), r * (1 - t) + t, i * (1 - t), 0, 0, n * (1 - t), r * (1 - t), i * (1 - t) + t, 0, 0, 0, 0, 0, 1, 0];
|
|
548
|
+
}
|
|
549
|
+
function nr(e) {
|
|
550
|
+
const t = e * 255;
|
|
551
|
+
return [1, 0, 0, 0, t, 0, 1, 0, 0, t, 0, 0, 1, 0, t, 0, 0, 0, 1, 0];
|
|
552
|
+
}
|
|
553
|
+
function rr(e) {
|
|
554
|
+
const t = e + 1, n = 128 * (1 - t);
|
|
555
|
+
return [t, 0, 0, 0, n, 0, t, 0, 0, n, 0, 0, t, 0, n, 0, 0, 0, 1, 0];
|
|
556
|
+
}
|
|
557
|
+
function ir(e) {
|
|
558
|
+
const t = e * Math.PI / 180, n = Math.cos(t), r = Math.sin(t), { r: i, g: a, b: s } = hn;
|
|
559
|
+
return [i + n * (1 - i) + r * -i, a + n * -a + r * -a, s + n * -s + r * (1 - s), 0, 0, i + n * -i + r * 0.143, a + n * (1 - a) + r * 0.14, s + n * -s + r * -0.283, 0, 0, i + n * -i + r * -0.6914, a + n * -a + r * a, s + n * (1 - s) + r * s, 0, 0, 0, 0, 0, 1, 0];
|
|
560
|
+
}
|
|
561
|
+
const ar = { grayscale: mn(0), sepia: [0.393, 0.769, 0.189, 0, 0, 0.349, 0.686, 0.168, 0, 0, 0.272, 0.534, 0.131, 0, 0, 0, 0, 0, 1, 0], invert: [-1, 0, 0, 0, 255, 0, -1, 0, 0, 255, 0, 0, -1, 0, 255, 0, 0, 0, 1, 0], night: [0.45, 0, 0, 0, 0, 0, 0.5, 0, 0, 0, 0, 0, 0.8, 0, 20, 0, 0, 0, 1, 0] };
|
|
562
|
+
function pn(e) {
|
|
563
|
+
if (typeof e == "string") {
|
|
564
|
+
const n = ar[e];
|
|
565
|
+
if (!n) throw new TypeError(`Unknown colour look "${String(e)}"`);
|
|
566
|
+
return { matrix: [...n], colorTransform: null };
|
|
567
|
+
}
|
|
568
|
+
if ("matrix" in e) {
|
|
569
|
+
if (e.matrix.length !== 20) throw new TypeError("A colour matrix has twenty numbers");
|
|
570
|
+
return { matrix: [...e.matrix], colorTransform: null };
|
|
571
|
+
}
|
|
572
|
+
if ("tint" in e) {
|
|
573
|
+
const n = Math.max(0, Math.min(1, e.amount ?? 0.5)), r = (i) => (e.tint >> i & 255) * n;
|
|
574
|
+
return { matrix: null, colorTransform: Tt({ redMultiplier: 1 - n, greenMultiplier: 1 - n, blueMultiplier: 1 - n, redOffset: r(16), greenOffset: r(8), blueOffset: r(0) }) };
|
|
575
|
+
}
|
|
576
|
+
if ("transform" in e) return { matrix: null, colorTransform: Tt(e.transform) };
|
|
577
|
+
let t = [...tr];
|
|
578
|
+
return e.saturation !== void 0 && (t = ve(t, mn(e.saturation))), e.hue !== void 0 && (t = ve(t, ir(e.hue))), e.contrast !== void 0 && (t = ve(t, rr(e.contrast))), e.brightness !== void 0 && (t = ve(t, nr(e.brightness))), { matrix: t, colorTransform: null };
|
|
579
|
+
}
|
|
580
|
+
function Tt(e) {
|
|
581
|
+
return { redMultiplier: e.redMultiplier ?? 1, greenMultiplier: e.greenMultiplier ?? 1, blueMultiplier: e.blueMultiplier ?? 1, alphaMultiplier: e.alphaMultiplier ?? 1, redOffset: e.redOffset ?? 0, greenOffset: e.greenOffset ?? 0, blueOffset: e.blueOffset ?? 0, alphaOffset: e.alphaOffset ?? 0 };
|
|
582
|
+
}
|
|
583
|
+
function ue(e = {}) {
|
|
584
|
+
const t = e.recolor ? pn(e.recolor) : { matrix: null, colorTransform: null }, n = e.glow ?? !(e.recolor || e.hide) ? { color: e.color ?? 9133302, alpha: e.alpha ?? 1, blur: e.blur ?? 8, strength: e.strength ?? 2, inner: e.inner ?? !1, knockout: e.knockout ?? !1 } : null;
|
|
585
|
+
if (n && t.matrix) throw new TypeError("A highlight is a glow or a colour matrix, not both: use two highlights");
|
|
586
|
+
const r = e.pulse === void 0 || e.pulse === !1 ? null : e.pulse === !0 ? { frames: 60, from: 0.6, to: 1 } : { frames: e.pulse.frames ?? 60, from: e.pulse.from ?? 0.6, to: e.pulse.to ?? 1 };
|
|
587
|
+
return { glow: n, matrix: t.matrix, colorTransform: t.colorTransform, hide: e.hide ?? !1, pulse: r };
|
|
588
|
+
}
|
|
589
|
+
const Ee = /* @__PURE__ */ Symbol.for("phantom.typedFlash");
|
|
590
|
+
function gn(e) {
|
|
591
|
+
return typeof e == "function" && e[Ee] !== void 0;
|
|
592
|
+
}
|
|
593
|
+
function q(e, t, n = {}) {
|
|
594
|
+
const r = { reference: t, handle: n.handle ?? null, className: n.className ?? null }, i = (o) => S(e, o), a = { $get: () => t.get().then(i), $set: async (o) => t.set((await Q(e, [o]))[0]), $listen: (o, d) => t.listen(o, (c) => d(i(c))), $describe: () => t.describe(), $at: (...o) => q(e, t.at(...o)), $as: () => q(e, t, { ...r.handle ? { handle: r.handle } : {} }), $release: () => r.handle ? r.handle.release() : Promise.resolve(), $reference: t, $new: async (...o) => {
|
|
595
|
+
if (!r.className) throw new TypeError("Only a class can make objects with $new");
|
|
596
|
+
return i(await e.construct(r.className, ...await Q(e, o)));
|
|
597
|
+
}, toJSON: () => `[Flash ${sr(r)}]` }, s = (() => {
|
|
598
|
+
});
|
|
599
|
+
return new Proxy(s, { get: (o, d) => {
|
|
600
|
+
if (d === Ee) return r;
|
|
601
|
+
if (typeof d != "symbol" && d !== "then") return Object.prototype.hasOwnProperty.call(a, d) ? a[d] : q(e, t.at(d));
|
|
602
|
+
}, apply: async (o, d, c) => i(await t.call(...await Q(e, c))) });
|
|
603
|
+
}
|
|
604
|
+
function he(e) {
|
|
605
|
+
return gn(e) ? e[Ee].reference : e instanceof L ? e.at() : e && typeof e == "object" && "target" in e && "path" in e && typeof e.at == "function" ? e : null;
|
|
606
|
+
}
|
|
607
|
+
function S(e, t) {
|
|
608
|
+
if (t instanceof L) return q(e, t.at(), { handle: t });
|
|
609
|
+
if (Array.isArray(t)) return t.map((n) => S(e, n));
|
|
610
|
+
if (t && typeof t == "object") {
|
|
611
|
+
const n = {};
|
|
612
|
+
for (const [r, i] of Object.entries(t)) n[r] = S(e, i);
|
|
613
|
+
return n;
|
|
614
|
+
}
|
|
615
|
+
return t;
|
|
616
|
+
}
|
|
617
|
+
async function Q(e, t) {
|
|
618
|
+
return Promise.all(t.map((n) => Ze(e, n)));
|
|
619
|
+
}
|
|
620
|
+
async function Ze(e, t) {
|
|
621
|
+
if (gn(t)) {
|
|
622
|
+
const n = t[Ee];
|
|
623
|
+
return n.handle && n.reference.path.length === 0 ? n.handle : n.reference.get();
|
|
624
|
+
}
|
|
625
|
+
if (typeof t == "function") {
|
|
626
|
+
const n = t;
|
|
627
|
+
return (...r) => n(...r.map((i) => S(e, i)));
|
|
628
|
+
}
|
|
629
|
+
if (Array.isArray(t)) return Promise.all(t.map((n) => Ze(e, n)));
|
|
630
|
+
if (t && typeof t == "object" && Object.getPrototypeOf(t) === Object.prototype) {
|
|
631
|
+
const n = {};
|
|
632
|
+
for (const [r, i] of Object.entries(t)) n[r] = await Ze(e, i);
|
|
633
|
+
return n;
|
|
634
|
+
}
|
|
635
|
+
return t;
|
|
636
|
+
}
|
|
637
|
+
function sr({ reference: e, className: t }) {
|
|
638
|
+
const n = e.target, r = n.kind === "definition" ? n.name : n.kind === "handle" ? `object ${n.handle}` : n.kind, i = e.path.join(".");
|
|
639
|
+
return t ?? (i ? `${r}.${i}` : r);
|
|
640
|
+
}
|
|
641
|
+
class or {
|
|
642
|
+
constructor(t, n, r) {
|
|
643
|
+
this.bridge = t;
|
|
644
|
+
const i = t.encode(n);
|
|
645
|
+
this.callback = i.$callback, r !== void 0 && this.answers(r);
|
|
646
|
+
}
|
|
647
|
+
bridge;
|
|
648
|
+
callback;
|
|
649
|
+
stopped = !1;
|
|
650
|
+
get argument() {
|
|
651
|
+
return { $callback: this.callback };
|
|
652
|
+
}
|
|
653
|
+
async answers(t) {
|
|
654
|
+
if (this.stopped) return;
|
|
655
|
+
await this.ready();
|
|
656
|
+
const [n] = await Q(this.bridge, [t]);
|
|
657
|
+
await this.bridge.answer(this.callback, n);
|
|
658
|
+
}
|
|
659
|
+
async answersNothing() {
|
|
660
|
+
this.stopped || (await this.ready(), await this.bridge.answer(this.callback));
|
|
661
|
+
}
|
|
662
|
+
async stop() {
|
|
663
|
+
this.stopped || (this.stopped = !0, await this.bridge.answer(this.callback));
|
|
664
|
+
}
|
|
665
|
+
async ready() {
|
|
666
|
+
if (await this.bridge.whenReady(), !this.bridge.features.includes("answer")) throw new Error("This game is running a loader from before answers; a function of yours gives the game nothing back");
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
function A(e) {
|
|
670
|
+
const t = he(e);
|
|
671
|
+
if (!t) throw new TypeError("Expected a place in Flash: a typed place, an object read from Flash, or a reference");
|
|
672
|
+
return { target: t.target, path: [...t.path] };
|
|
673
|
+
}
|
|
674
|
+
async function cr(e, t, n, r) {
|
|
675
|
+
if (await e.whenReady(), !e.features.includes("collect")) throw new Error("This game is running a loader from before collects; read the items one by one");
|
|
676
|
+
const i = { fields: dr(n) };
|
|
677
|
+
r.skip !== void 0 && (i.skip = Math.max(0, Math.trunc(r.skip))), r.limit !== void 0 && (i.limit = Math.max(1, Math.trunc(r.limit))), r.handles !== void 0 && (i.handles = r.handles);
|
|
678
|
+
const a = await e.collect(A(t), i);
|
|
679
|
+
return { rows: a.items.map((s) => S(e, s)), total: a.total };
|
|
680
|
+
}
|
|
681
|
+
function dr(e) {
|
|
682
|
+
const t = Array.isArray(e) ? e.map((n) => [n, n]) : Object.entries(e);
|
|
683
|
+
if (t.length === 0) throw new TypeError("A collect needs the members to read");
|
|
684
|
+
return t.map(([n, r]) => ({ name: n, path: (Array.isArray(r) ? r : String(r).split(".")).filter((i) => i.length > 0) }));
|
|
685
|
+
}
|
|
686
|
+
function ge(e) {
|
|
687
|
+
const t = `${e.className}.${e.member}`;
|
|
688
|
+
return e.kind === "getter" ? `${t}@get` : e.kind === "setter" ? `${t}@set` : t;
|
|
689
|
+
}
|
|
690
|
+
const je = /* @__PURE__ */ Symbol.for("phantom.hookRead"), Z = /* @__PURE__ */ Symbol.for("phantom.hookTest");
|
|
691
|
+
class lr {
|
|
692
|
+
constructor(t) {
|
|
693
|
+
this.table = t;
|
|
694
|
+
for (const n of t.hooks) {
|
|
695
|
+
this.byId.set(n.id, n);
|
|
696
|
+
const r = ge(n);
|
|
697
|
+
this.byKey.has(r) || this.byKey.set(r, n);
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
table;
|
|
701
|
+
byKey = /* @__PURE__ */ new Map();
|
|
702
|
+
byId = /* @__PURE__ */ new Map();
|
|
703
|
+
get size() {
|
|
704
|
+
return this.byId.size;
|
|
705
|
+
}
|
|
706
|
+
names() {
|
|
707
|
+
return [...this.byKey.keys()];
|
|
708
|
+
}
|
|
709
|
+
find(t) {
|
|
710
|
+
return t.startsWith("#") ? this.byId.get(Number(t.slice(1))) ?? null : this.byKey.get(t) ?? this.byKey.get(`${t}@get`) ?? this.byKey.get(`${t}@set`) ?? null;
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
function Y(e) {
|
|
714
|
+
return e.flatMap((t) => Array.isArray(t) ? t : t.includes("::") ? [t] : t.split(".").filter(Boolean));
|
|
715
|
+
}
|
|
716
|
+
function G(e) {
|
|
717
|
+
return Object.freeze({ [je]: e });
|
|
718
|
+
}
|
|
719
|
+
function U(e, t, n) {
|
|
720
|
+
return Object.freeze({ [Z]: n === void 0 && e === "exists" ? { test: e, left: t } : { test: e, left: t, right: n } });
|
|
721
|
+
}
|
|
722
|
+
const ur = { self: (...e) => G({ from: "self", path: Y(e) }), arg: (e, ...t) => G({ from: "arg", arg: e, path: Y(t) }), returned: (...e) => G({ from: "return", path: Y(e) }), fromClass: (e, ...t) => G({ from: "class", name: e, path: Y(t) }), place: (e, ...t) => G({ from: "place", place: e, path: Y(t) }), calls: () => G({ from: "calls" }), constant: (e) => G({ from: "constant", value: e }), equals: (e, t) => U("equals", e, t), notEquals: (e, t) => U("notEquals", e, t), less: (e, t) => U("less", e, t), lessOrEqual: (e, t) => U("lessOrEqual", e, t), greater: (e, t) => U("greater", e, t), greaterOrEqual: (e, t) => U("greaterOrEqual", e, t), contains: (e, t) => U("contains", e, t), startsWith: (e, t) => U("startsWith", e, t), endsWith: (e, t) => U("endsWith", e, t), oneOf: (e, t) => U("in", e, t), exists: (e) => U("exists", e), all: (...e) => Object.freeze({ [Z]: { all: e } }), any: (...e) => Object.freeze({ [Z]: { any: e } }), not: (e) => Object.freeze({ [Z]: { not: e } }) };
|
|
723
|
+
function fn(e) {
|
|
724
|
+
return typeof e == "object" && e !== null && je in e;
|
|
725
|
+
}
|
|
726
|
+
function yn(e) {
|
|
727
|
+
return typeof e == "object" && e !== null && Z in e;
|
|
728
|
+
}
|
|
729
|
+
function et(e, t, n, r) {
|
|
730
|
+
const i = (m) => {
|
|
731
|
+
if (typeof m == "number") return Nt(t, m);
|
|
732
|
+
const u = t.parameters.findIndex((y) => y.name === m);
|
|
733
|
+
if (u >= 0) return u;
|
|
734
|
+
if (/^\d+$/.test(m)) return Nt(t, Number(m));
|
|
735
|
+
const f = t.parameters.map((y) => y.name).join(", ") || "none";
|
|
736
|
+
throw new TypeError(`${ge(t)} has no argument "${m}" (its arguments: ${f})`);
|
|
737
|
+
}, a = (m) => {
|
|
738
|
+
if (!fn(m)) return Me(m) ?? { from: "constant", value: ae(e, m) };
|
|
739
|
+
const u = m[je];
|
|
740
|
+
switch (u.from) {
|
|
741
|
+
case "constant":
|
|
742
|
+
return { from: "constant", value: ae(e, u.value) };
|
|
743
|
+
case "arg":
|
|
744
|
+
return { from: "arg", index: i(u.arg), path: u.path };
|
|
745
|
+
case "self":
|
|
746
|
+
return { from: "self", path: u.path };
|
|
747
|
+
case "return":
|
|
748
|
+
return { from: "return", path: u.path };
|
|
749
|
+
case "class":
|
|
750
|
+
return { from: "class", name: u.name, path: u.path };
|
|
751
|
+
case "calls":
|
|
752
|
+
return { from: "calls" };
|
|
753
|
+
case "place": {
|
|
754
|
+
const f = Me(u.place, u.path);
|
|
755
|
+
if (!f) throw new TypeError("rules.place takes a place in the game");
|
|
756
|
+
return f;
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
}, s = (m) => {
|
|
760
|
+
if (!yn(m)) {
|
|
761
|
+
const f = Object.entries(m).map(([y, p]) => ({ test: "equals", left: { from: "arg", index: i(y), path: [] }, right: a(p) }));
|
|
762
|
+
if (f.length === 0) throw new TypeError("A hook condition names nothing to compare");
|
|
763
|
+
return f.length === 1 ? f[0] : { all: f };
|
|
764
|
+
}
|
|
765
|
+
const u = m[Z];
|
|
766
|
+
return "all" in u ? { all: u.all.map(s) } : "any" in u ? { any: u.any.map(s) } : "not" in u ? { not: s(u.not) } : u.test === "exists" ? { test: u.test, left: a(u.left) } : { test: u.test, left: a(u.left), right: a(u.right) };
|
|
767
|
+
}, o = n.phase ?? (r ? "enter" : "none"), d = n.capture ?? {}, c = t.parameters.map((m, u) => u), h = d.args === !0 || d.args === void 0 && r ? c : (d.args ?? []).map(i);
|
|
768
|
+
return { observe: o === "both" ? ["enter", "exit"] : o === "none" ? [] : [o], capture: { args: h, self: tt(d.self).map(([, m]) => m), value: d.value ?? !1, handles: d.handles ?? !1 }, when: n.when === void 0 ? null : s(n.when), first: n.first ?? null, every: n.every ?? null, skip: n.skip === void 0 || n.skip === !1 ? null : n.skip === !0 ? { from: "constant", value: { $undefined: !0 } } : a(n.skip.returns), replaceArgs: Object.entries(n.replaceArgs ?? {}).map(([m, u]) => ({ index: i(m), value: a(u) })), replaceReturn: "replaceReturn" in n ? a(n.replaceReturn) : null, perFrame: n.perFrame ?? 20 };
|
|
769
|
+
}
|
|
770
|
+
function Nt(e, t) {
|
|
771
|
+
if (!Number.isInteger(t) || t < 0 || e.parameters.length > 0 && t >= e.parameters.length) throw new RangeError(`${ge(e)} has no argument ${t}`);
|
|
772
|
+
return t;
|
|
773
|
+
}
|
|
774
|
+
function tt(e) {
|
|
775
|
+
return e ? Array.isArray(e) ? e.map((t) => [t, Y([t])]) : Object.entries(e).map(([t, n]) => [t, Y([n])]) : [];
|
|
776
|
+
}
|
|
777
|
+
function wn(e, t) {
|
|
778
|
+
const n = (r) => {
|
|
779
|
+
if (!yn(r)) throw new TypeError("A condition between calls has no call to read: compare with rules.equals and its like");
|
|
780
|
+
const i = r[Z];
|
|
781
|
+
return "all" in i ? { all: i.all.map(n) } : "any" in i ? { any: i.any.map(n) } : "not" in i ? { not: n(i.not) } : i.test === "exists" ? { test: i.test, left: de(e, i.left) } : { test: i.test, left: de(e, i.left), right: de(e, i.right) };
|
|
782
|
+
};
|
|
783
|
+
return n(t);
|
|
784
|
+
}
|
|
785
|
+
function Me(e, t = []) {
|
|
786
|
+
const n = he(e);
|
|
787
|
+
return n ? { from: "place", target: n.target, path: [...n.path, ...t] } : null;
|
|
788
|
+
}
|
|
789
|
+
function de(e, t) {
|
|
790
|
+
if (!fn(t)) return Me(t) ?? { from: "constant", value: ae(e, t) };
|
|
791
|
+
const n = t[je];
|
|
792
|
+
switch (n.from) {
|
|
793
|
+
case "constant":
|
|
794
|
+
return { from: "constant", value: ae(e, n.value) };
|
|
795
|
+
case "class":
|
|
796
|
+
return { from: "class", name: n.name, path: n.path };
|
|
797
|
+
case "place": {
|
|
798
|
+
const r = Me(n.place, n.path);
|
|
799
|
+
if (!r) throw new TypeError("rules.place takes a place in the game");
|
|
800
|
+
return r;
|
|
801
|
+
}
|
|
802
|
+
default:
|
|
803
|
+
throw new TypeError(`rules.${n.from} reads the call it is in; a value held between calls is a constant, rules.fromClass or a place`);
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
function ae(e, t) {
|
|
807
|
+
if (t === void 0) return { $undefined: !0 };
|
|
808
|
+
if (t instanceof L || t instanceof ct) return e.encode(t);
|
|
809
|
+
const n = he(t);
|
|
810
|
+
if (n) {
|
|
811
|
+
if (n.target.kind === "handle" && n.path.length === 0) return { $handle: n.target.handle };
|
|
812
|
+
throw new TypeError("A place inside a list or object in a rule cannot be read there: pass the place on its own, or read it first");
|
|
813
|
+
}
|
|
814
|
+
if (typeof t == "function") throw new TypeError("A hook rule cannot call a function");
|
|
815
|
+
return Array.isArray(t) ? t.map((r) => ae(e, r)) : t !== null && typeof t == "object" ? Object.fromEntries(Object.entries(t).map(([r, i]) => [r, ae(e, i)])) : t;
|
|
816
|
+
}
|
|
817
|
+
async function hr(e, t, n, r, i) {
|
|
818
|
+
var a;
|
|
819
|
+
const s = t.find(n);
|
|
820
|
+
if (!s) throw new TypeError(`There is no hook "${n}" in the hook table`);
|
|
821
|
+
let o = r, d = tt((a = r.capture) == null ? void 0 : a.self).map(([u]) => u), c = et(e, s, r, i !== void 0);
|
|
822
|
+
const { registration: h, stop: m } = await e.hook(s.id, c, (u) => {
|
|
823
|
+
var f;
|
|
824
|
+
switch (u.kind) {
|
|
825
|
+
case "hook": {
|
|
826
|
+
if (!i) return;
|
|
827
|
+
const y = (u.args ?? []).map((v) => S(e, e.decode(v))), p = {};
|
|
828
|
+
c.capture.args.forEach((v, k) => {
|
|
829
|
+
var T;
|
|
830
|
+
p[((T = s.parameters[v]) == null ? void 0 : T.name) ?? String(v)] = y[k];
|
|
831
|
+
});
|
|
832
|
+
const g = {};
|
|
833
|
+
(u.self ?? []).forEach((v, k) => {
|
|
834
|
+
g[d[k] ?? String(k)] = S(e, e.decode(v));
|
|
835
|
+
}), i({ phase: u.phase, call: u.call, args: p, argList: y, self: g, ..."value" in u ? { value: S(e, e.decode(u.value)) } : {}, skipped: u.skipped === !0, hook: s });
|
|
836
|
+
return;
|
|
837
|
+
}
|
|
838
|
+
case "hook-dropped":
|
|
839
|
+
(f = o.onDropped) == null || f.call(o, u.dropped);
|
|
840
|
+
return;
|
|
841
|
+
case "hook-failed": {
|
|
842
|
+
const y = new D("FLASH", `The hook on ${ge(s)} failed and is off: ${u.error.message}`, u.error);
|
|
843
|
+
o.onError ? o.onError(y) : console.error(y.message);
|
|
844
|
+
return;
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
});
|
|
848
|
+
return Object.assign(() => m(), { registration: h, hook: s, update: async (u, f = {}) => {
|
|
849
|
+
var y;
|
|
850
|
+
const p = et(e, s, u, i !== void 0);
|
|
851
|
+
await e.request({ op: "rehook", registration: h, rules: p, resetCounts: f.resetCounts ?? !1 }), o = u, c = p, d = tt((y = u.capture) == null ? void 0 : y.self).map(([g]) => g);
|
|
852
|
+
}, stats: async () => (await e.request({ op: "hookStats" })).find((u) => u.registration === h) ?? null });
|
|
853
|
+
}
|
|
854
|
+
async function mr(e, t, n) {
|
|
855
|
+
if (await e.whenReady(), !e.features.includes("drive")) throw new Error("This game is running a loader from before repeated calls; call it yourself each frame");
|
|
856
|
+
const r = A(t);
|
|
857
|
+
if (r.path.length === 0) throw new TypeError("A repeat calls a method, so name one: `place.method`, not the object");
|
|
858
|
+
const i = n.while ? wn(e, n.while) : null;
|
|
859
|
+
return e.drive({ writes: [], calls: [{ target: r.target, path: r.path, args: (n.args ?? []).map((a) => de(e, a)), times: Math.max(1, Math.trunc(n.times ?? 1)) }], everyFrames: Math.max(1, Math.trunc(n.everyFrames ?? 1)), while: i, restore: !1, once: n.once === !0 }, n.onFailed);
|
|
860
|
+
}
|
|
861
|
+
async function At(e, t, n) {
|
|
862
|
+
if (await e.whenReady(), !e.features.includes("drive")) throw new Error("This game is running a loader from before held values; write it yourself each frame");
|
|
863
|
+
if (t.length === 0) throw new TypeError("A hold needs a value to keep");
|
|
864
|
+
const r = t.map(({ place: a, value: s }) => {
|
|
865
|
+
const o = A(a);
|
|
866
|
+
if (o.path.length === 0) throw new TypeError("A hold writes to a member, so name one: `place.member`, not the object");
|
|
867
|
+
return { target: o.target, path: o.path, value: de(e, s) };
|
|
868
|
+
}), i = n.while ? wn(e, n.while) : null;
|
|
869
|
+
return e.drive({ writes: r, everyFrames: Math.max(1, Math.trunc(n.everyFrames ?? 1)), while: i, restore: n.restore !== !1, once: n.once === !0 }, n.onFailed);
|
|
870
|
+
}
|
|
871
|
+
class Fe {
|
|
872
|
+
constructor(t, n, r, i, a, s, o) {
|
|
873
|
+
this.host = t, this.kind = n, this.id = r, this.name = i, this.tagY = s, this.handle = o, this.place = a;
|
|
874
|
+
}
|
|
875
|
+
host;
|
|
876
|
+
kind;
|
|
877
|
+
id;
|
|
878
|
+
name;
|
|
879
|
+
tagY;
|
|
880
|
+
handle;
|
|
881
|
+
place;
|
|
882
|
+
highlight(t = {}) {
|
|
883
|
+
return this.host.bridge.highlight(this.entry(), ue(t));
|
|
884
|
+
}
|
|
885
|
+
tag(t, n = {}) {
|
|
886
|
+
const { anchorX: r, anchorY: i, ...a } = n;
|
|
887
|
+
return this.host.overlay.text(t, { centered: !0, font: { size: 12, bold: !0, color: 16777215 }, outline: 0, ...a, anchor: { place: this.place, x: r ?? 0, y: i ?? this.tagY } });
|
|
888
|
+
}
|
|
889
|
+
onClick(t) {
|
|
890
|
+
const n = this.host.bridge;
|
|
891
|
+
return this.kind !== "object" ? this.place.$listen("mouseDown", () => t(this)) : n.stage().listen("mouseDown", (r) => {
|
|
892
|
+
const { stageX: i, stageY: a } = r ?? {};
|
|
893
|
+
typeof i != "number" || typeof a != "number" || this.place.$reference.at("hitTestPoint").call(i, a, !0).then((s) => {
|
|
894
|
+
s === !0 && t(this);
|
|
895
|
+
}).catch(() => {
|
|
896
|
+
});
|
|
897
|
+
});
|
|
898
|
+
}
|
|
899
|
+
async release() {
|
|
900
|
+
this.handle && await this.handle.release();
|
|
901
|
+
}
|
|
902
|
+
entry() {
|
|
903
|
+
const t = this.place.$reference;
|
|
904
|
+
return { target: t.target, path: [...t.path] };
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
class pr {
|
|
908
|
+
constructor(t) {
|
|
909
|
+
this.host = t;
|
|
910
|
+
}
|
|
911
|
+
host;
|
|
912
|
+
async players() {
|
|
913
|
+
const t = this.host.bridge, n = t.definition("avatar.AvatarManager").at("avatarViewList"), r = await n.get(), i = r && typeof r == "object" && !(r instanceof L) ? Object.keys(r) : [], a = i.map((s) => r[s]).filter((s) => s instanceof L);
|
|
914
|
+
try {
|
|
915
|
+
const s = await Promise.all(i.map((o) => H(n.at(o, "userName").get())));
|
|
916
|
+
return i.map((o, d) => new Fe(this.host, "player", o, typeof s[d] == "string" ? s[d] : null, q(t, n.at(o)), -80, null));
|
|
917
|
+
} finally {
|
|
918
|
+
await t.release(a);
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
async npcs() {
|
|
922
|
+
const t = this.host.bridge, n = t.definition("quest.QuestManager").at("_questActors"), r = await H(n.at("length").get());
|
|
923
|
+
if (typeof r != "number" || r <= 0) return [];
|
|
924
|
+
const i = Array.from({ length: Math.min(r, 500) }, (c, h) => String(h)), [a, s, o] = await Promise.all([Promise.all(i.map((c) => H(n.at(c).get()))), Promise.all(i.map((c) => H(n.at(c, "_actorId").get()))), Promise.all(i.map((c) => H(n.at(c, "currAvatar", "avName").get())))]), d = [];
|
|
925
|
+
return i.forEach((c, h) => {
|
|
926
|
+
const m = a[h];
|
|
927
|
+
if (!(m instanceof L)) return;
|
|
928
|
+
const u = o[h];
|
|
929
|
+
d.push(new Fe(this.host, "npc", typeof s[h] == "string" ? s[h] : c, typeof u == "string" && u ? u : null, q(t, m.at(), { handle: m }), -90, m));
|
|
930
|
+
}), d;
|
|
931
|
+
}
|
|
932
|
+
async objects() {
|
|
933
|
+
const t = this.host.bridge, n = t.definition("room.RoomManagerWorld").at("instance", "volumeManager", "_volumeActors");
|
|
934
|
+
let r;
|
|
935
|
+
try {
|
|
936
|
+
r = await n.at("length").get();
|
|
937
|
+
} catch (h) {
|
|
938
|
+
throw h instanceof D && h.code === "FLASH" ? new D("FLASH", `The room's objects are private to the client, and this client does not reach them: ${h.message}`, h.flash) : h;
|
|
939
|
+
}
|
|
940
|
+
if (typeof r != "number" || r <= 0) return [];
|
|
941
|
+
const i = Array.from({ length: Math.min(r, 500) }, (h, m) => String(m)), [a, s] = await Promise.all([Promise.all(i.map((h) => H(n.at(h, "name").get()))), Promise.all(i.map((h) => H(n.at(h, "interactiveObjs", "length").get())))]), o = [];
|
|
942
|
+
i.forEach((h, m) => {
|
|
943
|
+
const u = s[m], f = a[m];
|
|
944
|
+
for (let y = 0; typeof u == "number" && y < Math.min(u, 50); y++) o.push([h, String(y), typeof f == "string" ? f : null]);
|
|
945
|
+
});
|
|
946
|
+
const d = await Promise.all(o.map(([h, m]) => H(n.at(h, "interactiveObjs", m, "mc").get()))), c = [];
|
|
947
|
+
return o.forEach(([h, m, u], f) => {
|
|
948
|
+
const y = d[f];
|
|
949
|
+
y instanceof L && c.push(new Fe(this.host, "object", `${u ?? h}#${m}`, u, q(t, y.at(), { handle: y }), 0, y));
|
|
950
|
+
}), c;
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
function H(e) {
|
|
954
|
+
return e.catch(() => null);
|
|
955
|
+
}
|
|
956
|
+
async function gr(e, t, n) {
|
|
957
|
+
if (await e.whenReady(), !e.features.includes("find")) throw new Error("This game is running a loader from before searches; only a path reaches an object");
|
|
958
|
+
const r = t === void 0 ? { target: { kind: "stage" }, path: [] } : A(t);
|
|
959
|
+
return (await e.find(r, fr(n))).map((i) => q(e, i.at(), { handle: i }));
|
|
960
|
+
}
|
|
961
|
+
function fr(e) {
|
|
962
|
+
const t = {};
|
|
963
|
+
return e.ofClass !== void 0 && (t.ofClass = e.ofClass), e.named !== void 0 && (t.named = e.named), e.containing !== void 0 && (t.containing = e.containing), e.visibleOnly !== void 0 && (t.visibleOnly = e.visibleOnly), e.through !== void 0 && (t.through = e.through), e.depth !== void 0 && (t.depth = e.depth), e.limit !== void 0 && (t.limit = e.limit), t;
|
|
964
|
+
}
|
|
965
|
+
const St = { backspace: 8, tab: 9, enter: 13, return: 13, shift: 16, control: 17, ctrl: 17, alt: 18, pause: 19, capslock: 20, escape: 27, esc: 27, space: 32, pageup: 33, pagedown: 34, end: 35, home: 36, left: 37, arrowleft: 37, up: 38, arrowup: 38, right: 39, arrowright: 39, down: 40, arrowdown: 40, insert: 45, delete: 46, ";": 186, "=": 187, ",": 188, "-": 189, ".": 190, "/": 191, "`": 192, "[": 219, "\\": 220, "]": 221, "'": 222 };
|
|
966
|
+
function yr(e, t = {}) {
|
|
967
|
+
const n = { phase: t.phase ?? "down", consume: t.consume ?? !1, whileTyping: t.whileTyping ?? !1, repeat: t.repeat ?? !1 };
|
|
968
|
+
if (typeof e == "number") return { code: e, ctrl: null, shift: null, alt: null, ...n };
|
|
969
|
+
const r = e === "+" || e.endsWith("++"), i = (r ? e.slice(0, -1) : e).split("+").map((o) => o.trim()).filter(Boolean);
|
|
970
|
+
r && i.push("+");
|
|
971
|
+
const a = { ctrl: !1, shift: !1, alt: !1 };
|
|
972
|
+
let s = null;
|
|
973
|
+
for (const o of i) {
|
|
974
|
+
const d = o.toLowerCase();
|
|
975
|
+
d === "ctrl" || d === "control" || d === "cmd" || d === "meta" ? a.ctrl = !0 : d === "shift" ? a.shift = !0 : d === "alt" || d === "option" ? a.alt = !0 : d === "any" ? s = null : s = wr(o);
|
|
976
|
+
}
|
|
977
|
+
if (s === null && !i.some((o) => o.toLowerCase() === "any")) throw new TypeError(`"${e}" names no key`);
|
|
978
|
+
return { code: s, ...a, ...n };
|
|
979
|
+
}
|
|
980
|
+
function wr(e) {
|
|
981
|
+
const t = e.toLowerCase();
|
|
982
|
+
if (t in St) return St[t];
|
|
983
|
+
if (/^[a-z0-9]$/i.test(e)) return e.toUpperCase().charCodeAt(0);
|
|
984
|
+
const n = /^f([1-9]|1[0-5])$/i.exec(e);
|
|
985
|
+
if (n) return 111 + Number(n[1]);
|
|
986
|
+
const r = /^num(?:pad)?([0-9])$/i.exec(e);
|
|
987
|
+
if (r) return 96 + Number(r[1]);
|
|
988
|
+
if (e === "+") return 187;
|
|
989
|
+
throw new TypeError(`Unknown key "${e}"`);
|
|
990
|
+
}
|
|
991
|
+
class vr {
|
|
992
|
+
constructor(t) {
|
|
993
|
+
this.bridge = t;
|
|
994
|
+
}
|
|
995
|
+
bridge;
|
|
996
|
+
table = null;
|
|
997
|
+
async set(t, n) {
|
|
998
|
+
const [r] = await Q(this.bridge, [n]);
|
|
999
|
+
await this.bridge.note(await this.number(), "write", A(t), r);
|
|
1000
|
+
}
|
|
1001
|
+
async get(t) {
|
|
1002
|
+
const n = await this.bridge.note(await this.number(), "read", A(t));
|
|
1003
|
+
return n == null ? void 0 : S(this.bridge, n);
|
|
1004
|
+
}
|
|
1005
|
+
async has(t) {
|
|
1006
|
+
return await this.bridge.note(await this.number(), "has", A(t)) === !0;
|
|
1007
|
+
}
|
|
1008
|
+
async forget(t) {
|
|
1009
|
+
return await this.bridge.note(await this.number(), "forget", A(t)) === !0;
|
|
1010
|
+
}
|
|
1011
|
+
async objects() {
|
|
1012
|
+
const t = await this.bridge.note(await this.number(), "keys");
|
|
1013
|
+
return Array.isArray(t) ? t.filter((n) => n instanceof L).map((n) => q(this.bridge, n.at(), { handle: n })) : [];
|
|
1014
|
+
}
|
|
1015
|
+
async clear() {
|
|
1016
|
+
this.table !== null && await this.bridge.note(this.table, "clear");
|
|
1017
|
+
}
|
|
1018
|
+
async number() {
|
|
1019
|
+
if (await this.bridge.whenReady(), !this.bridge.features.includes("notes")) throw new Error("This game is running a loader from before notes; nothing can be kept beside its objects");
|
|
1020
|
+
return this.table ??= this.bridge.allocate(), this.table;
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
1023
|
+
const br = 127;
|
|
1024
|
+
function vn(e) {
|
|
1025
|
+
const t = [], n = [];
|
|
1026
|
+
let r = "", i = 0;
|
|
1027
|
+
const a = () => {
|
|
1028
|
+
const o = {};
|
|
1029
|
+
for (const d of n) Object.assign(o, d.look);
|
|
1030
|
+
return o;
|
|
1031
|
+
}, s = () => {
|
|
1032
|
+
if (r === "") return;
|
|
1033
|
+
const o = { text: r, ...a() }, d = t[t.length - 1];
|
|
1034
|
+
d && Ar(d, o) ? d.text += r : t.push(o), r = "";
|
|
1035
|
+
};
|
|
1036
|
+
for (; i < e.length; ) {
|
|
1037
|
+
const o = e[i];
|
|
1038
|
+
if (o !== "[") {
|
|
1039
|
+
r += o, i++;
|
|
1040
|
+
continue;
|
|
1041
|
+
}
|
|
1042
|
+
if (e[i + 1] === "[") {
|
|
1043
|
+
r += "[", i += 2;
|
|
1044
|
+
continue;
|
|
1045
|
+
}
|
|
1046
|
+
const d = e.indexOf("]", i + 1), c = d < 0 ? null : Ir(e.slice(i + 1, d));
|
|
1047
|
+
if (c === null) {
|
|
1048
|
+
r += o, i++;
|
|
1049
|
+
continue;
|
|
1050
|
+
}
|
|
1051
|
+
if (c.closing) {
|
|
1052
|
+
const h = Nr(n, c.name);
|
|
1053
|
+
h < 0 ? r += e.slice(i, d + 1) : (s(), n.splice(h));
|
|
1054
|
+
} else s(), n.push({ tag: c.name, look: c.look });
|
|
1055
|
+
i = d + 1;
|
|
1056
|
+
}
|
|
1057
|
+
return s(), t;
|
|
1058
|
+
}
|
|
1059
|
+
function Ir(e) {
|
|
1060
|
+
if (e.startsWith("/")) {
|
|
1061
|
+
const i = e.slice(1);
|
|
1062
|
+
return kr.has(i) ? { name: i, closing: !0 } : null;
|
|
1063
|
+
}
|
|
1064
|
+
const t = e.indexOf("="), n = t < 0 ? e : e.slice(0, t), r = t < 0 ? null : e.slice(t + 1);
|
|
1065
|
+
switch (n) {
|
|
1066
|
+
case "b":
|
|
1067
|
+
return r === null ? { name: n, closing: !1, look: { bold: !0 } } : null;
|
|
1068
|
+
case "i":
|
|
1069
|
+
return r === null ? { name: n, closing: !1, look: { italic: !0 } } : null;
|
|
1070
|
+
case "u":
|
|
1071
|
+
return r === null ? { name: n, closing: !1, look: { underline: !0 } } : null;
|
|
1072
|
+
case "color": {
|
|
1073
|
+
const i = r === null ? null : Tr(r);
|
|
1074
|
+
return i === null ? null : { name: n, closing: !1, look: { color: i } };
|
|
1075
|
+
}
|
|
1076
|
+
case "size": {
|
|
1077
|
+
const i = r === null ? NaN : Number(r);
|
|
1078
|
+
return Number.isInteger(i) && i >= 1 && i <= br ? { name: n, closing: !1, look: { size: i } } : null;
|
|
1079
|
+
}
|
|
1080
|
+
case "link":
|
|
1081
|
+
return r === null || r === "" ? null : { name: n, closing: !1, look: { link: r } };
|
|
1082
|
+
default:
|
|
1083
|
+
return null;
|
|
1084
|
+
}
|
|
1085
|
+
}
|
|
1086
|
+
const kr = /* @__PURE__ */ new Set(["b", "i", "u", "color", "size", "link"]), xr = "0123456789abcdef";
|
|
1087
|
+
function Tr(e) {
|
|
1088
|
+
const t = e.toLowerCase(), n = t.startsWith("#") ? t.slice(1) : t.startsWith("0x") ? t.slice(2) : null;
|
|
1089
|
+
if (n === null || n.length !== 6) return null;
|
|
1090
|
+
let r = 0;
|
|
1091
|
+
for (const i of n) {
|
|
1092
|
+
const a = xr.indexOf(i);
|
|
1093
|
+
if (a < 0) return null;
|
|
1094
|
+
r = r * 16 + a;
|
|
1095
|
+
}
|
|
1096
|
+
return r;
|
|
1097
|
+
}
|
|
1098
|
+
function Nr(e, t) {
|
|
1099
|
+
for (let n = e.length - 1; n >= 0; n--) if (e[n].tag === t) return n;
|
|
1100
|
+
return -1;
|
|
1101
|
+
}
|
|
1102
|
+
function Ar(e, t) {
|
|
1103
|
+
return ["color", "bold", "italic", "underline", "size", "font", "link"].every((n) => e[n] === t[n]);
|
|
1104
|
+
}
|
|
1105
|
+
const Be = { className: "avatar.AvatarManager", path: ["playerAvatarWorldView", "parent"] }, Ct = /* @__PURE__ */ new Set(["click", "down", "up", "over", "out"]);
|
|
1106
|
+
class Sr {
|
|
1107
|
+
constructor(t) {
|
|
1108
|
+
this.bridge = t;
|
|
1109
|
+
}
|
|
1110
|
+
bridge;
|
|
1111
|
+
nodes = /* @__PURE__ */ new Map();
|
|
1112
|
+
async draw(t, n = {}) {
|
|
1113
|
+
const { handle: r } = await this.make(t, n);
|
|
1114
|
+
return r;
|
|
1115
|
+
}
|
|
1116
|
+
world(t = { x: 0, y: 0 }, n = {}) {
|
|
1117
|
+
return { place: this.bridge.definition(Be.className).at(Be.path[0], Be.path[1]), x: t.x, y: t.y, ...n };
|
|
1118
|
+
}
|
|
1119
|
+
marker(t, n = {}) {
|
|
1120
|
+
const { kind: r = "circle", ...i } = n;
|
|
1121
|
+
return this.draw(r, { radius: 8, ...i, anchor: this.world(t) });
|
|
1122
|
+
}
|
|
1123
|
+
group(t = {}) {
|
|
1124
|
+
return this.draw("group", t);
|
|
1125
|
+
}
|
|
1126
|
+
text(t, n = {}) {
|
|
1127
|
+
return this.draw("text", { ...n, text: t });
|
|
1128
|
+
}
|
|
1129
|
+
rich(t, n = {}) {
|
|
1130
|
+
return this.draw("text", { ...n, rich: t });
|
|
1131
|
+
}
|
|
1132
|
+
rect(t) {
|
|
1133
|
+
return this.draw("rect", t);
|
|
1134
|
+
}
|
|
1135
|
+
circle(t) {
|
|
1136
|
+
return this.draw("circle", t);
|
|
1137
|
+
}
|
|
1138
|
+
line(t) {
|
|
1139
|
+
return this.draw("line", t);
|
|
1140
|
+
}
|
|
1141
|
+
image(t, n = {}) {
|
|
1142
|
+
return this.draw("image", { ...n, url: t });
|
|
1143
|
+
}
|
|
1144
|
+
async input(t = {}) {
|
|
1145
|
+
const { handle: n, state: r } = await this.make("input", { width: 200, height: 24, fill: 16777215, stroke: 10265519, padding: 4, ...t, font: { color: 1120295, ...t.font } });
|
|
1146
|
+
return r.value = t.value ?? "", Object.assign(n, { value: () => r.value, setValue: async (i) => {
|
|
1147
|
+
r.value = i, r.removed || await this.bridge.draw(n.node, { value: i });
|
|
1148
|
+
}, focus: async () => {
|
|
1149
|
+
r.removed || await this.bridge.draw(n.node, { focus: !0 });
|
|
1150
|
+
} });
|
|
1151
|
+
}
|
|
1152
|
+
async button(t, n = {}) {
|
|
1153
|
+
const { handle: r, state: i } = await this.make("button", { width: 72, height: 24, fill: 8141549, hoverFill: 9133302, pressedFill: 7153881, cornerRadius: 4, ...n, font: { color: 16777215, bold: !0, ...n.font }, label: t });
|
|
1154
|
+
return Object.assign(r, { setLabel: (a) => i.removed ? Promise.resolve() : this.bridge.draw(r.node, { label: a }), setDisabled: (a) => i.removed ? Promise.resolve() : this.bridge.draw(r.node, { disabled: a }) });
|
|
1155
|
+
}
|
|
1156
|
+
async panel(t = {}) {
|
|
1157
|
+
const { onMove: n, onResize: r, ...i } = t, { handle: a } = await this.make("panel", { width: 260, height: 200, fill: { color: 1120295, alpha: 0.92 }, stroke: 3621201, titleFill: 2042167, titleHeight: 22, cornerRadius: 6, ...i, titleFont: { color: 16777215, bold: !0, ...i.titleFont } }), s = a;
|
|
1158
|
+
return n && s.on("move", n), r && s.on("resize", r), s;
|
|
1159
|
+
}
|
|
1160
|
+
async list(t = {}) {
|
|
1161
|
+
const { handle: n, state: r } = await this.make("list", { width: 240, height: 160, fill: { color: 0, alpha: 0.55 }, padding: 4, ...t, font: { color: 16777215, ...t.font } });
|
|
1162
|
+
return Object.assign(n, { append: (...i) => r.removed || i.length === 0 ? Promise.resolve() : this.bridge.draw(n.node, { append: i.map(Re) }), setRows: (i) => r.removed ? Promise.resolve() : this.bridge.draw(n.node, { rows: i.map(Re) }) });
|
|
1163
|
+
}
|
|
1164
|
+
async replace(t, n) {
|
|
1165
|
+
return await n.update({ parent: null, host: null, replaces: t }), () => n.remove();
|
|
1166
|
+
}
|
|
1167
|
+
async attach(t, n) {
|
|
1168
|
+
return await n.update({ parent: null, replaces: null, host: t }), () => n.remove();
|
|
1169
|
+
}
|
|
1170
|
+
async focusGame() {
|
|
1171
|
+
await this.bridge.stage().at("focus").set(null);
|
|
1172
|
+
}
|
|
1173
|
+
async clear() {
|
|
1174
|
+
const t = [...this.nodes.entries()].filter(([, n]) => n.parent === null || !this.nodes.has(n.parent)).map(([n]) => n);
|
|
1175
|
+
await this.remove(t);
|
|
1176
|
+
}
|
|
1177
|
+
async make(t, n) {
|
|
1178
|
+
var r;
|
|
1179
|
+
const i = this.bridge.allocate(), a = { type: t, ...this.specOf(n) }, s = { parent: n.parent ? n.parent.node : null, children: /* @__PURE__ */ new Set(), listeners: /* @__PURE__ */ new Map(), failed: /* @__PURE__ */ new Set(), stopHearing: () => {
|
|
1180
|
+
}, removed: !1, value: "" };
|
|
1181
|
+
s.stopHearing = this.bridge.onSubscription(i, (o) => {
|
|
1182
|
+
var d;
|
|
1183
|
+
if (o.kind === "overlay") {
|
|
1184
|
+
if (o.event === "failed") {
|
|
1185
|
+
s.failed.forEach((c) => c(o.message ?? "The image did not load"));
|
|
1186
|
+
return;
|
|
1187
|
+
}
|
|
1188
|
+
(o.event === "change" || o.event === "submit") && o.value !== void 0 && (s.value = o.value), (d = s.listeners.get(o.event)) == null || d.forEach((c) => c(o));
|
|
1189
|
+
}
|
|
1190
|
+
}), this.nodes.set(i, s);
|
|
1191
|
+
try {
|
|
1192
|
+
await this.bridge.draw(i, a);
|
|
1193
|
+
} catch (o) {
|
|
1194
|
+
throw s.stopHearing(), this.nodes.delete(i), o;
|
|
1195
|
+
}
|
|
1196
|
+
return s.parent !== null && ((r = this.nodes.get(s.parent)) == null || r.children.add(i)), { handle: this.handle(i, t, s), state: s };
|
|
1197
|
+
}
|
|
1198
|
+
handle(t, n, r) {
|
|
1199
|
+
const i = () => this.remove([t]);
|
|
1200
|
+
return Object.assign(i, { node: t, type: n, update: async (a) => {
|
|
1201
|
+
var s, o;
|
|
1202
|
+
if (r.removed) return;
|
|
1203
|
+
const d = this.specOf(a);
|
|
1204
|
+
"parent" in a && (r.parent !== null && ((s = this.nodes.get(r.parent)) == null || s.children.delete(t)), r.parent = a.parent ? a.parent.node : null, r.parent !== null && ((o = this.nodes.get(r.parent)) == null || o.children.add(t))), await this.bridge.draw(t, d);
|
|
1205
|
+
}, show: () => r.removed ? Promise.resolve() : this.bridge.draw(t, { visible: !0 }), hide: () => r.removed ? Promise.resolve() : this.bridge.draw(t, { visible: !1 }), remove: i, on: (a, s) => {
|
|
1206
|
+
const o = s, d = (f) => {
|
|
1207
|
+
switch (f.event) {
|
|
1208
|
+
case "change":
|
|
1209
|
+
case "submit":
|
|
1210
|
+
case "link":
|
|
1211
|
+
o(f.value ?? "");
|
|
1212
|
+
return;
|
|
1213
|
+
case "focus":
|
|
1214
|
+
case "blur":
|
|
1215
|
+
o(void 0);
|
|
1216
|
+
return;
|
|
1217
|
+
case "row":
|
|
1218
|
+
o(f.index ?? -1);
|
|
1219
|
+
return;
|
|
1220
|
+
case "move":
|
|
1221
|
+
o({ x: f.x, y: f.y });
|
|
1222
|
+
return;
|
|
1223
|
+
case "resize":
|
|
1224
|
+
o({ width: f.width ?? 0, height: f.height ?? 0 });
|
|
1225
|
+
return;
|
|
1226
|
+
default:
|
|
1227
|
+
o({ x: f.x, y: f.y });
|
|
1228
|
+
}
|
|
1229
|
+
};
|
|
1230
|
+
let c = r.listeners.get(a);
|
|
1231
|
+
const h = !c || c.size === 0;
|
|
1232
|
+
c || (c = /* @__PURE__ */ new Set(), r.listeners.set(a, c)), c.add(d);
|
|
1233
|
+
const m = Ct.has(a);
|
|
1234
|
+
h && m && this.sendMouse(t, r);
|
|
1235
|
+
let u = !1;
|
|
1236
|
+
return async () => {
|
|
1237
|
+
u || (u = !0, c.delete(d), m && c.size === 0 && !r.removed && await this.sendMouse(t, r));
|
|
1238
|
+
};
|
|
1239
|
+
}, onFailed: (a) => (r.failed.add(a), () => {
|
|
1240
|
+
r.failed.delete(a);
|
|
1241
|
+
}) });
|
|
1242
|
+
}
|
|
1243
|
+
async sendMouse(t, n) {
|
|
1244
|
+
const r = [...n.listeners.entries()].filter(([i, a]) => Ct.has(i) && a.size > 0).map(([i]) => i);
|
|
1245
|
+
await this.bridge.draw(t, { mouse: r });
|
|
1246
|
+
}
|
|
1247
|
+
async remove(t) {
|
|
1248
|
+
const n = [], r = (a) => {
|
|
1249
|
+
var s;
|
|
1250
|
+
const o = this.nodes.get(a);
|
|
1251
|
+
!o || o.removed || (o.removed = !0, o.stopHearing(), this.nodes.delete(a), n.push(a), o.children.forEach(r), o.parent !== null && ((s = this.nodes.get(o.parent)) == null || s.children.delete(a)));
|
|
1252
|
+
};
|
|
1253
|
+
t.forEach(r);
|
|
1254
|
+
const i = t.filter((a) => n.includes(a));
|
|
1255
|
+
await this.bridge.erase(i);
|
|
1256
|
+
}
|
|
1257
|
+
specOf(t) {
|
|
1258
|
+
const n = {};
|
|
1259
|
+
for (const [r, i] of Object.entries(t)) if (i !== void 0) switch (r) {
|
|
1260
|
+
case "parent":
|
|
1261
|
+
n.parent = i === null ? null : i.node;
|
|
1262
|
+
break;
|
|
1263
|
+
case "anchor":
|
|
1264
|
+
n.anchor = i === null ? null : qr(i);
|
|
1265
|
+
break;
|
|
1266
|
+
case "host":
|
|
1267
|
+
case "replaces":
|
|
1268
|
+
n[r] = i === null ? null : Mr(i);
|
|
1269
|
+
break;
|
|
1270
|
+
case "fill":
|
|
1271
|
+
case "background":
|
|
1272
|
+
case "hoverFill":
|
|
1273
|
+
case "pressedFill":
|
|
1274
|
+
case "titleFill":
|
|
1275
|
+
n[r] = i === null ? null : Er(i);
|
|
1276
|
+
break;
|
|
1277
|
+
case "stroke":
|
|
1278
|
+
n.stroke = i === null ? null : jr(i);
|
|
1279
|
+
break;
|
|
1280
|
+
case "font":
|
|
1281
|
+
case "titleFont":
|
|
1282
|
+
n[r] = Cr(i);
|
|
1283
|
+
break;
|
|
1284
|
+
case "rich":
|
|
1285
|
+
n.spans = i === null ? null : typeof i == "string" ? vn(i) : i;
|
|
1286
|
+
break;
|
|
1287
|
+
case "rows":
|
|
1288
|
+
case "append":
|
|
1289
|
+
n[r] = i.map(Re);
|
|
1290
|
+
break;
|
|
1291
|
+
default:
|
|
1292
|
+
n[r] = i;
|
|
1293
|
+
}
|
|
1294
|
+
return n;
|
|
1295
|
+
}
|
|
1296
|
+
}
|
|
1297
|
+
function Cr(e) {
|
|
1298
|
+
return { family: "_sans", size: 12, color: 16777215, bold: !1, italic: !1, ...e };
|
|
1299
|
+
}
|
|
1300
|
+
function Re(e) {
|
|
1301
|
+
if (typeof e == "string") return e || " ";
|
|
1302
|
+
const t = (Array.isArray(e) ? e : vn(e.markup)).filter((n) => n.text.length > 0);
|
|
1303
|
+
return t.length ? t : " ";
|
|
1304
|
+
}
|
|
1305
|
+
function qr(e) {
|
|
1306
|
+
const t = typeof e == "object" && e !== null && "place" in e ? e : { place: e }, n = A(t.place);
|
|
1307
|
+
return { target: n.target, path: n.path, x: t.x ?? 0, y: t.y ?? 0, refreshFrames: t.refreshFrames ?? 12, hideWhenGone: t.hideWhenGone ?? !0 };
|
|
1308
|
+
}
|
|
1309
|
+
function Mr(e) {
|
|
1310
|
+
const t = typeof e == "object" && e !== null && "place" in e ? e : { place: e }, n = A(t.place);
|
|
1311
|
+
return { target: n.target, path: n.path, refreshFrames: t.refreshFrames ?? 12 };
|
|
1312
|
+
}
|
|
1313
|
+
function Er(e) {
|
|
1314
|
+
return typeof e == "number" ? { color: e, alpha: 1 } : { color: e.color, alpha: e.alpha ?? 1 };
|
|
1315
|
+
}
|
|
1316
|
+
function jr(e) {
|
|
1317
|
+
return typeof e == "number" ? { color: e, alpha: 1, width: 1 } : { color: e.color, alpha: e.alpha ?? 1, width: e.width ?? 1 };
|
|
1318
|
+
}
|
|
1319
|
+
async function Dr(e, t, n, r, i = {}) {
|
|
1320
|
+
const a = t.find(n);
|
|
1321
|
+
if (!a) throw new TypeError(`There is no hook "${n}" in the hook table`);
|
|
1322
|
+
const s = { perFrame: i.perFrame ?? 50 };
|
|
1323
|
+
i.when !== void 0 && (s.when = i.when), i.first !== void 0 && (s.first = i.first), i.every !== void 0 && (s.every = i.every), i.replaceArgs !== void 0 && (s.replaceArgs = i.replaceArgs), "returns" in i && (s.skip = { returns: i.returns });
|
|
1324
|
+
const o = { ...et(e, a, s, !1), override: !0 };
|
|
1325
|
+
let d = 0, c = Promise.resolve();
|
|
1326
|
+
const h = ge(a), m = async (p) => {
|
|
1327
|
+
d++;
|
|
1328
|
+
let g = !1, v = !1;
|
|
1329
|
+
const k = p.args.map((E) => S(e, e.decode(E))), T = {};
|
|
1330
|
+
k.forEach((E, w) => {
|
|
1331
|
+
var b;
|
|
1332
|
+
T[((b = a.parameters[w]) == null ? void 0 : b.name) ?? String(w)] = E;
|
|
1333
|
+
});
|
|
1334
|
+
const j = a.isStatic ? q(e, e.definition(a.className), { className: a.className }) : S(e, e.decode(p.self)), z = { hook: a, call: p.call, self: j, args: T, argList: k, original: async (...E) => {
|
|
1335
|
+
if (v) throw new D("FLASH", `The call of ${h} has ended: its handler finished`);
|
|
1336
|
+
g = !0;
|
|
1337
|
+
const w = await e.invokeOriginal(u, p.token, E.length === 0 ? null : await Q(e, E));
|
|
1338
|
+
return S(e, w);
|
|
1339
|
+
} };
|
|
1340
|
+
try {
|
|
1341
|
+
await r(z);
|
|
1342
|
+
} catch (E) {
|
|
1343
|
+
if (console.error(`The override of ${h} failed: ${E instanceof Error ? E.message : String(E)}`), !g && (i.onError ?? "original") === "original") try {
|
|
1344
|
+
await e.invokeOriginal(u, p.token, null);
|
|
1345
|
+
} catch (w) {
|
|
1346
|
+
console.error(`The original ${h} failed after its override did: ${w instanceof Error ? w.message : String(w)}`);
|
|
1347
|
+
}
|
|
1348
|
+
} finally {
|
|
1349
|
+
v = !0, d--;
|
|
1350
|
+
try {
|
|
1351
|
+
await e.overrideDone(u, p.token);
|
|
1352
|
+
} catch {
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
1355
|
+
}, { registration: u, stop: f } = await e.hook(a.id, o, (p) => {
|
|
1356
|
+
var g;
|
|
1357
|
+
switch (p.kind) {
|
|
1358
|
+
case "override":
|
|
1359
|
+
i.sequential ? c = c.then(() => m(p)) : m(p);
|
|
1360
|
+
return;
|
|
1361
|
+
case "hook-dropped":
|
|
1362
|
+
(g = i.onDropped) == null || g.call(i, p.dropped);
|
|
1363
|
+
return;
|
|
1364
|
+
case "hook-failed":
|
|
1365
|
+
console.error(`The override of ${h} failed and is off: ${p.error.message}`);
|
|
1366
|
+
return;
|
|
1367
|
+
}
|
|
1368
|
+
}), y = Object.assign(() => f(), { registration: u, hook: a, stats: async () => (await e.request({ op: "hookStats" })).find((p) => p.registration === u) ?? null });
|
|
1369
|
+
return Object.defineProperty(y, "running", { get: () => d, enumerable: !0 }), y;
|
|
1370
|
+
}
|
|
1371
|
+
const Or = { fit: "showAll", stretch: "exactFit", fill: "noBorder", none: "noScale" };
|
|
1372
|
+
class $r {
|
|
1373
|
+
constructor(t) {
|
|
1374
|
+
this.bridge = t;
|
|
1375
|
+
}
|
|
1376
|
+
bridge;
|
|
1377
|
+
async zoom(t) {
|
|
1378
|
+
await this.bridge.definition("room.RoomManagerWorld").at("instance", "updateRoomZoom").call(Math.round(t));
|
|
1379
|
+
}
|
|
1380
|
+
async zoomLevel() {
|
|
1381
|
+
return await this.bridge.definition("gMainFrame").at("layerManager", "bkg", "scaleX").get() * 100;
|
|
1382
|
+
}
|
|
1383
|
+
async stretch(t) {
|
|
1384
|
+
await this.bridge.stage().at("scaleMode").set(Or[t]);
|
|
1385
|
+
}
|
|
1386
|
+
hideHud(t) {
|
|
1387
|
+
return this.bridge.highlight({ target: { kind: "definition", name: "gui.GuiManager" }, path: t ? ["mainHud", t] : ["mainHud"] }, ue({ hide: !0 }));
|
|
1388
|
+
}
|
|
1389
|
+
hideLayer(t) {
|
|
1390
|
+
return this.bridge.highlight({ target: { kind: "definition", name: "gMainFrame" }, path: ["layerManager", t] }, ue({ hide: !0 }));
|
|
1391
|
+
}
|
|
1392
|
+
async setQuality(t) {
|
|
1393
|
+
await this.bridge.stage().at("quality").set(t);
|
|
1394
|
+
}
|
|
1395
|
+
async setFrameRate(t) {
|
|
1396
|
+
const n = this.bridge.stage().at("frameRate"), r = await n.get();
|
|
1397
|
+
return await n.set(Math.max(1, Math.min(120, t))), r;
|
|
1398
|
+
}
|
|
1399
|
+
}
|
|
1400
|
+
class x extends Error {
|
|
1401
|
+
constructor(t, n, r) {
|
|
1402
|
+
super(r === void 0 ? t : `${t} (at ${r})`), this.code = n, this.offset = r, this.name = "ProtocolError";
|
|
1403
|
+
}
|
|
1404
|
+
code;
|
|
1405
|
+
offset;
|
|
1406
|
+
}
|
|
1407
|
+
new TextEncoder();
|
|
1408
|
+
const Pr = { lt: "<", gt: ">", amp: "&", apos: "'", quot: '"' };
|
|
1409
|
+
function dt(e) {
|
|
1410
|
+
if (!e.includes("&")) return e;
|
|
1411
|
+
let t = "", n = 0;
|
|
1412
|
+
for (; n < e.length; ) {
|
|
1413
|
+
const r = e.indexOf("&", n);
|
|
1414
|
+
if (r === -1) break;
|
|
1415
|
+
const i = e.indexOf(";", r + 1);
|
|
1416
|
+
t += e.slice(n, r);
|
|
1417
|
+
const a = i === -1 ? null : Lr(e.slice(r + 1, i));
|
|
1418
|
+
a === null ? (t += "&", n = r + 1) : (t += a, n = i + 1);
|
|
1419
|
+
}
|
|
1420
|
+
return t + e.slice(n);
|
|
1421
|
+
}
|
|
1422
|
+
function Lr(e) {
|
|
1423
|
+
if (e.startsWith("#")) {
|
|
1424
|
+
const t = e[1] === "x" || e[1] === "X", n = e.slice(t ? 2 : 1);
|
|
1425
|
+
if (n.length === 0 || !(t ? Fr(n) : Ur(n))) return null;
|
|
1426
|
+
const r = Number.parseInt(n, t ? 16 : 10);
|
|
1427
|
+
return r <= 1114111 ? String.fromCodePoint(r) : null;
|
|
1428
|
+
}
|
|
1429
|
+
return Pr[e] ?? null;
|
|
1430
|
+
}
|
|
1431
|
+
function Ur(e) {
|
|
1432
|
+
for (const t of e) if (t < "0" || t > "9") return !1;
|
|
1433
|
+
return !0;
|
|
1434
|
+
}
|
|
1435
|
+
function Fr(e) {
|
|
1436
|
+
for (const t of e.toLowerCase()) if (!(t >= "0" && t <= "9" || t >= "a" && t <= "f")) return !1;
|
|
1437
|
+
return !0;
|
|
1438
|
+
}
|
|
1439
|
+
function nt(e) {
|
|
1440
|
+
let t = "";
|
|
1441
|
+
for (const n of e) n === "&" ? t += "&" : n === "<" ? t += "<" : n === ">" ? t += ">" : t += n;
|
|
1442
|
+
return t;
|
|
1443
|
+
}
|
|
1444
|
+
function qt(e, t) {
|
|
1445
|
+
let n = "";
|
|
1446
|
+
for (const r of e) r === "&" ? n += "&" : r === "<" ? n += "<" : r === t ? n += t === '"' ? """ : "'" : n += r;
|
|
1447
|
+
return n;
|
|
1448
|
+
}
|
|
1449
|
+
class R {
|
|
1450
|
+
constructor(t, n, r = "'", i = " ", a = ["", ""]) {
|
|
1451
|
+
this.name = t, this.quote = r, this.leading = i, this.around = a, this.written = n, this.decoded = dt(n);
|
|
1452
|
+
}
|
|
1453
|
+
name;
|
|
1454
|
+
quote;
|
|
1455
|
+
leading;
|
|
1456
|
+
around;
|
|
1457
|
+
written;
|
|
1458
|
+
decoded;
|
|
1459
|
+
static create(t, n, r = "'") {
|
|
1460
|
+
return new R(t, qt(n, r), r);
|
|
1461
|
+
}
|
|
1462
|
+
get value() {
|
|
1463
|
+
return this.decoded;
|
|
1464
|
+
}
|
|
1465
|
+
set value(t) {
|
|
1466
|
+
this.decoded = t, this.written = qt(t, this.quote);
|
|
1467
|
+
}
|
|
1468
|
+
get raw() {
|
|
1469
|
+
return this.written;
|
|
1470
|
+
}
|
|
1471
|
+
}
|
|
1472
|
+
class De {
|
|
1473
|
+
type = "text";
|
|
1474
|
+
written;
|
|
1475
|
+
decoded;
|
|
1476
|
+
constructor(t) {
|
|
1477
|
+
this.written = t, this.decoded = dt(t);
|
|
1478
|
+
}
|
|
1479
|
+
static create(t) {
|
|
1480
|
+
return new De(nt(t));
|
|
1481
|
+
}
|
|
1482
|
+
get value() {
|
|
1483
|
+
return this.decoded;
|
|
1484
|
+
}
|
|
1485
|
+
set value(t) {
|
|
1486
|
+
this.decoded = t, this.written = nt(t);
|
|
1487
|
+
}
|
|
1488
|
+
get raw() {
|
|
1489
|
+
return this.written;
|
|
1490
|
+
}
|
|
1491
|
+
}
|
|
1492
|
+
class ee {
|
|
1493
|
+
constructor(t) {
|
|
1494
|
+
this.value = t;
|
|
1495
|
+
}
|
|
1496
|
+
value;
|
|
1497
|
+
type = "cdata";
|
|
1498
|
+
}
|
|
1499
|
+
class Br {
|
|
1500
|
+
constructor(t) {
|
|
1501
|
+
this.value = t;
|
|
1502
|
+
}
|
|
1503
|
+
value;
|
|
1504
|
+
type = "comment";
|
|
1505
|
+
}
|
|
1506
|
+
class Rr {
|
|
1507
|
+
constructor(t, n) {
|
|
1508
|
+
this.target = t, this.content = n;
|
|
1509
|
+
}
|
|
1510
|
+
target;
|
|
1511
|
+
content;
|
|
1512
|
+
type = "instruction";
|
|
1513
|
+
}
|
|
1514
|
+
class B {
|
|
1515
|
+
constructor(t, n = {}) {
|
|
1516
|
+
this.name = t, this.attributes = n.attributes ?? [], this.children = n.children ?? [], this.selfClosing = n.selfClosing ?? !1, this.trailing = n.trailing ?? "", this.closingTrailing = n.closingTrailing ?? "";
|
|
1517
|
+
}
|
|
1518
|
+
name;
|
|
1519
|
+
type = "element";
|
|
1520
|
+
attributes;
|
|
1521
|
+
children;
|
|
1522
|
+
selfClosing;
|
|
1523
|
+
trailing;
|
|
1524
|
+
closingTrailing;
|
|
1525
|
+
attribute(t) {
|
|
1526
|
+
var n;
|
|
1527
|
+
return ((n = this.attributes.find((r) => r.name === t)) == null ? void 0 : n.value) ?? null;
|
|
1528
|
+
}
|
|
1529
|
+
setAttribute(t, n) {
|
|
1530
|
+
const r = this.attributes.find((i) => i.name === t);
|
|
1531
|
+
r ? r.value = n : this.attributes.push(R.create(t, n));
|
|
1532
|
+
}
|
|
1533
|
+
removeAttribute(t) {
|
|
1534
|
+
const n = this.attributes.findIndex((r) => r.name === t);
|
|
1535
|
+
return n === -1 ? !1 : (this.attributes.splice(n, 1), !0);
|
|
1536
|
+
}
|
|
1537
|
+
get elements() {
|
|
1538
|
+
return this.children.filter((t) => t.type === "element");
|
|
1539
|
+
}
|
|
1540
|
+
child(t) {
|
|
1541
|
+
return this.elements.find((n) => n.name === t) ?? null;
|
|
1542
|
+
}
|
|
1543
|
+
childrenNamed(t) {
|
|
1544
|
+
return this.elements.filter((n) => n.name === t);
|
|
1545
|
+
}
|
|
1546
|
+
get textContent() {
|
|
1547
|
+
return this.children.map((t) => {
|
|
1548
|
+
switch (t.type) {
|
|
1549
|
+
case "element":
|
|
1550
|
+
return t.textContent;
|
|
1551
|
+
case "text":
|
|
1552
|
+
case "cdata":
|
|
1553
|
+
return t.value;
|
|
1554
|
+
default:
|
|
1555
|
+
return "";
|
|
1556
|
+
}
|
|
1557
|
+
}).join("");
|
|
1558
|
+
}
|
|
1559
|
+
set textContent(t) {
|
|
1560
|
+
const n = this.children.some((r) => r.type === "cdata");
|
|
1561
|
+
this.children = [n ? new ee(t) : De.create(t)], this.selfClosing = !1;
|
|
1562
|
+
}
|
|
1563
|
+
append(...t) {
|
|
1564
|
+
this.children.push(...t), t.length > 0 && (this.selfClosing = !1);
|
|
1565
|
+
}
|
|
1566
|
+
}
|
|
1567
|
+
class bn {
|
|
1568
|
+
constructor(t) {
|
|
1569
|
+
this.children = t;
|
|
1570
|
+
}
|
|
1571
|
+
children;
|
|
1572
|
+
get root() {
|
|
1573
|
+
return this.children.find((t) => t.type === "element") ?? null;
|
|
1574
|
+
}
|
|
1575
|
+
}
|
|
1576
|
+
class zr {
|
|
1577
|
+
constructor(t) {
|
|
1578
|
+
this.input = t;
|
|
1579
|
+
}
|
|
1580
|
+
input;
|
|
1581
|
+
index = 0;
|
|
1582
|
+
get offset() {
|
|
1583
|
+
return this.index;
|
|
1584
|
+
}
|
|
1585
|
+
get done() {
|
|
1586
|
+
return this.index >= this.input.length;
|
|
1587
|
+
}
|
|
1588
|
+
peek(t = 0) {
|
|
1589
|
+
return this.input.charAt(this.index + t);
|
|
1590
|
+
}
|
|
1591
|
+
startsWith(t) {
|
|
1592
|
+
return this.input.startsWith(t, this.index);
|
|
1593
|
+
}
|
|
1594
|
+
advance(t = 1) {
|
|
1595
|
+
this.index = Math.min(this.index + t, this.input.length);
|
|
1596
|
+
}
|
|
1597
|
+
expect(t) {
|
|
1598
|
+
this.startsWith(t) || this.fail(`Expected "${t}"`), this.index += t.length;
|
|
1599
|
+
}
|
|
1600
|
+
whitespace() {
|
|
1601
|
+
const t = this.index;
|
|
1602
|
+
for (; !this.done && Kr(this.input.charCodeAt(this.index)); ) this.index++;
|
|
1603
|
+
return this.input.slice(t, this.index);
|
|
1604
|
+
}
|
|
1605
|
+
until(t, n) {
|
|
1606
|
+
const r = this.input.indexOf(t, this.index);
|
|
1607
|
+
r === -1 && this.fail(`Unterminated ${n}`);
|
|
1608
|
+
const i = this.input.slice(this.index, r);
|
|
1609
|
+
return this.index = r, i;
|
|
1610
|
+
}
|
|
1611
|
+
name() {
|
|
1612
|
+
const t = this.index;
|
|
1613
|
+
for ((this.done || !In(this.input.charCodeAt(this.index))) && this.fail("Expected a name"), this.index++; !this.done && Gr(this.input.charCodeAt(this.index)); ) this.index++;
|
|
1614
|
+
return this.input.slice(t, this.index);
|
|
1615
|
+
}
|
|
1616
|
+
fail(t) {
|
|
1617
|
+
throw new x(t, "XML_SYNTAX", this.index);
|
|
1618
|
+
}
|
|
1619
|
+
}
|
|
1620
|
+
const Vr = 32, Hr = 9, Wr = 10, _r = 13;
|
|
1621
|
+
function Kr(e) {
|
|
1622
|
+
return e === Vr || e === Hr || e === Wr || e === _r;
|
|
1623
|
+
}
|
|
1624
|
+
function In(e) {
|
|
1625
|
+
return e >= 97 && e <= 122 || e >= 65 && e <= 90 || e === 95 || e === 58 || e > 127;
|
|
1626
|
+
}
|
|
1627
|
+
function Gr(e) {
|
|
1628
|
+
return In(e) || e >= 48 && e <= 57 || e === 45 || e === 46;
|
|
1629
|
+
}
|
|
1630
|
+
const Mt = 64;
|
|
1631
|
+
function kn(e) {
|
|
1632
|
+
const t = new zr(e), n = xn(t, null, 0);
|
|
1633
|
+
return n.some((r) => r.type === "element") || t.fail("Expected an element"), new bn(n);
|
|
1634
|
+
}
|
|
1635
|
+
function xn(e, t, n) {
|
|
1636
|
+
const r = [];
|
|
1637
|
+
for (; !e.done; ) {
|
|
1638
|
+
if (e.startsWith("</")) return t === null && e.fail("Closing tag with nothing open"), r;
|
|
1639
|
+
e.startsWith("<![CDATA[") ? (e.advance(9), r.push(new ee(e.until("]]>", "CDATA section"))), e.advance(3)) : e.startsWith("<!--") ? (e.advance(4), r.push(new Br(e.until("-->", "comment"))), e.advance(3)) : e.startsWith("<?") ? r.push(Yr(e)) : e.startsWith("<!") ? e.fail("Document type declarations are not supported") : e.peek() === "<" ? r.push(Jr(e, n)) : r.push(Xr(e));
|
|
1640
|
+
}
|
|
1641
|
+
return t !== null && e.fail(`Unclosed element <${t}>`), r;
|
|
1642
|
+
}
|
|
1643
|
+
function Xr(e) {
|
|
1644
|
+
const t = e.offset;
|
|
1645
|
+
for (; !e.done && e.peek() !== "<"; ) e.advance();
|
|
1646
|
+
return new De(e.input.slice(t, e.offset));
|
|
1647
|
+
}
|
|
1648
|
+
function Yr(e) {
|
|
1649
|
+
e.expect("<?");
|
|
1650
|
+
const t = e.name(), n = e.until("?>", "processing instruction");
|
|
1651
|
+
return e.advance(2), new Rr(t, n);
|
|
1652
|
+
}
|
|
1653
|
+
function Jr(e, t) {
|
|
1654
|
+
t >= Mt && e.fail(`Elements nested deeper than ${Mt}`), e.expect("<");
|
|
1655
|
+
const n = e.name(), r = [];
|
|
1656
|
+
for (; ; ) {
|
|
1657
|
+
const i = e.whitespace();
|
|
1658
|
+
if (e.startsWith("/>")) return e.advance(2), new B(n, { attributes: r, selfClosing: !0, trailing: i });
|
|
1659
|
+
if (e.peek() === ">") {
|
|
1660
|
+
e.advance();
|
|
1661
|
+
const a = xn(e, n, t + 1);
|
|
1662
|
+
e.expect("</");
|
|
1663
|
+
const s = e.name();
|
|
1664
|
+
s !== n && e.fail(`Expected </${n}> but found </${s}>`);
|
|
1665
|
+
const o = e.whitespace();
|
|
1666
|
+
return e.expect(">"), new B(n, { attributes: r, children: a, trailing: i, closingTrailing: o });
|
|
1667
|
+
}
|
|
1668
|
+
e.done && e.fail(`Unterminated tag <${n}>`), i.length === 0 && e.fail("Expected whitespace before an attribute"), r.push(Qr(e, i, r));
|
|
1669
|
+
}
|
|
1670
|
+
}
|
|
1671
|
+
function Qr(e, t, n) {
|
|
1672
|
+
const r = e.name();
|
|
1673
|
+
n.some((d) => d.name === r) && e.fail(`Attribute "${r}" given twice`);
|
|
1674
|
+
const i = e.whitespace();
|
|
1675
|
+
e.expect("=");
|
|
1676
|
+
const a = e.whitespace(), s = e.peek();
|
|
1677
|
+
s !== '"' && s !== "'" && e.fail("Expected a quoted attribute value"), e.advance();
|
|
1678
|
+
const o = e.until(s, "attribute value");
|
|
1679
|
+
return o.includes("<") && e.fail('"<" is not allowed in an attribute value'), e.advance(), new R(r, o, s, t, [i, a]);
|
|
1680
|
+
}
|
|
1681
|
+
function Et(e) {
|
|
1682
|
+
return e instanceof bn ? e.children.map(rt).join("") : rt(e);
|
|
1683
|
+
}
|
|
1684
|
+
function rt(e) {
|
|
1685
|
+
switch (e.type) {
|
|
1686
|
+
case "element":
|
|
1687
|
+
return Zr(e);
|
|
1688
|
+
case "text":
|
|
1689
|
+
return e.raw;
|
|
1690
|
+
case "cdata":
|
|
1691
|
+
return `<![CDATA[${e.value.split("]]>").join("]]]]><![CDATA[>")}]]>`;
|
|
1692
|
+
case "comment":
|
|
1693
|
+
return `<!--${e.value}-->`;
|
|
1694
|
+
case "instruction":
|
|
1695
|
+
return `<?${e.target}${e.content}?>`;
|
|
1696
|
+
}
|
|
1697
|
+
}
|
|
1698
|
+
function Zr(e) {
|
|
1699
|
+
const t = e.attributes.map(ei).join(""), n = `<${e.name}${t}${e.trailing}`;
|
|
1700
|
+
if (e.selfClosing && e.children.length === 0) return `${n}/>`;
|
|
1701
|
+
const r = e.children.map(rt).join("");
|
|
1702
|
+
return `${n}>${r}</${e.name}${e.closingTrailing}>`;
|
|
1703
|
+
}
|
|
1704
|
+
function ei(e) {
|
|
1705
|
+
const [t, n] = e.around, { leading: r, name: i, quote: a, raw: s } = e;
|
|
1706
|
+
return `${r}${i}${t}=${n}${a}${s}${a}`;
|
|
1707
|
+
}
|
|
1708
|
+
function ti(e) {
|
|
1709
|
+
const t = kn(e).root;
|
|
1710
|
+
if (!t || t.name !== "dataObj") throw new x("Expected a <dataObj> element", "DATA_OBJECT");
|
|
1711
|
+
return Tn(t, {});
|
|
1712
|
+
}
|
|
1713
|
+
function Tn(e, t) {
|
|
1714
|
+
const n = t;
|
|
1715
|
+
for (const r of e.elements) if (r.name === "var") n[Ae(r, "n")] = ni(r);
|
|
1716
|
+
else if (r.name === "obj") {
|
|
1717
|
+
const i = Ae(r, "t");
|
|
1718
|
+
if (i !== "a" && i !== "o") throw new x(`Unknown object kind "${i}"`, "DATA_OBJECT");
|
|
1719
|
+
n[Ae(r, "o")] = Tn(r, i === "a" ? [] : {});
|
|
1720
|
+
}
|
|
1721
|
+
return t;
|
|
1722
|
+
}
|
|
1723
|
+
function ni(e) {
|
|
1724
|
+
const t = e.textContent;
|
|
1725
|
+
switch (Ae(e, "t")) {
|
|
1726
|
+
case "s":
|
|
1727
|
+
return t;
|
|
1728
|
+
case "n":
|
|
1729
|
+
return Number(t);
|
|
1730
|
+
case "b":
|
|
1731
|
+
return t !== "0";
|
|
1732
|
+
case "x":
|
|
1733
|
+
return null;
|
|
1734
|
+
default:
|
|
1735
|
+
throw new x(`Unknown variable type "${e.attribute("t")}"`, "DATA_OBJECT");
|
|
1736
|
+
}
|
|
1737
|
+
}
|
|
1738
|
+
function Ae(e, t) {
|
|
1739
|
+
const n = e.attribute(t);
|
|
1740
|
+
if (n === null) throw new x(`<${e.name}> is missing its "${t}" attribute`, "DATA_OBJECT");
|
|
1741
|
+
return n;
|
|
1742
|
+
}
|
|
1743
|
+
function ri(e) {
|
|
1744
|
+
return `<dataObj>${Nn(e)}</dataObj>`;
|
|
1745
|
+
}
|
|
1746
|
+
function Nn(e) {
|
|
1747
|
+
return Object.entries(e).map(([t, n]) => n === null ? `<var n='${t}' t='x'></var>` : typeof n == "object" ? `<obj t='${Array.isArray(n) ? "a" : "o"}' o='${t}'>${Nn(n)}</obj>` : typeof n == "boolean" ? `<var n='${t}' t='b'>${n ? 1 : 0}</var>` : typeof n == "number" ? `<var n='${t}' t='n'>${n}</var>` : `<var n='${t}' t='s'>${nt(n)}</var>`).join("");
|
|
1748
|
+
}
|
|
1749
|
+
class Oe {
|
|
1750
|
+
constructor(t, n) {
|
|
1751
|
+
this.raw = t, this.direction = n;
|
|
1752
|
+
}
|
|
1753
|
+
raw;
|
|
1754
|
+
direction;
|
|
1755
|
+
wasModified = !1;
|
|
1756
|
+
wasDropped = !1;
|
|
1757
|
+
get modified() {
|
|
1758
|
+
return this.wasModified;
|
|
1759
|
+
}
|
|
1760
|
+
get dropped() {
|
|
1761
|
+
return this.wasDropped;
|
|
1762
|
+
}
|
|
1763
|
+
drop() {
|
|
1764
|
+
this.wasDropped = !0;
|
|
1765
|
+
}
|
|
1766
|
+
encode() {
|
|
1767
|
+
return this.wasModified ? this.serialize() : this.raw;
|
|
1768
|
+
}
|
|
1769
|
+
toString() {
|
|
1770
|
+
return this.encode();
|
|
1771
|
+
}
|
|
1772
|
+
markModified() {
|
|
1773
|
+
this.wasModified = !0;
|
|
1774
|
+
}
|
|
1775
|
+
}
|
|
1776
|
+
class lt extends Oe {
|
|
1777
|
+
format = "json";
|
|
1778
|
+
envelope;
|
|
1779
|
+
constructor(t, n) {
|
|
1780
|
+
super(t, n), this.envelope = ii(t);
|
|
1781
|
+
}
|
|
1782
|
+
static create(t, n, r, i = -1, a = "o") {
|
|
1783
|
+
const s = t === "toServer" ? { t: "xt", b: { x: a, c: n, r: i, p: r } } : { t: "xt", b: { r: i, o: { _cmd: n, ...r } } };
|
|
1784
|
+
return new lt(JSON.stringify(s), t);
|
|
1785
|
+
}
|
|
1786
|
+
get type() {
|
|
1787
|
+
return this.envelope.t;
|
|
1788
|
+
}
|
|
1789
|
+
get command() {
|
|
1790
|
+
var t;
|
|
1791
|
+
const n = this.direction === "toServer" ? this.envelope.b.c : (t = this.envelope.b.o) == null ? void 0 : t._cmd;
|
|
1792
|
+
return typeof n == "string" ? n : null;
|
|
1793
|
+
}
|
|
1794
|
+
get room() {
|
|
1795
|
+
const t = this.envelope.b.r;
|
|
1796
|
+
return typeof t == "number" && Number.isInteger(t) ? t : null;
|
|
1797
|
+
}
|
|
1798
|
+
get params() {
|
|
1799
|
+
if (this.direction === "toServer") return this.envelope.b.p ?? {};
|
|
1800
|
+
const { _cmd: t, ...n } = this.envelope.b.o ?? {};
|
|
1801
|
+
return n;
|
|
1802
|
+
}
|
|
1803
|
+
get value() {
|
|
1804
|
+
return this.envelope;
|
|
1805
|
+
}
|
|
1806
|
+
edit(t) {
|
|
1807
|
+
t(this.envelope), this.markModified();
|
|
1808
|
+
}
|
|
1809
|
+
serialize() {
|
|
1810
|
+
return JSON.stringify(this.envelope);
|
|
1811
|
+
}
|
|
1812
|
+
}
|
|
1813
|
+
function ii(e) {
|
|
1814
|
+
let t;
|
|
1815
|
+
try {
|
|
1816
|
+
t = JSON.parse(e);
|
|
1817
|
+
} catch (n) {
|
|
1818
|
+
throw new x(`Not JSON: ${n.message}`, "JSON_SYNTAX");
|
|
1819
|
+
}
|
|
1820
|
+
if (!jt(t) || typeof t.t != "string" || !jt(t.b)) throw new x('A JSON message is an object with "t" and "b"', "JSON_SYNTAX");
|
|
1821
|
+
return t;
|
|
1822
|
+
}
|
|
1823
|
+
function jt(e) {
|
|
1824
|
+
return typeof e == "object" && e !== null && !Array.isArray(e);
|
|
1825
|
+
}
|
|
1826
|
+
class Dt extends Oe {
|
|
1827
|
+
constructor(t, n, r = null) {
|
|
1828
|
+
super(t, n), this.problem = r;
|
|
1829
|
+
}
|
|
1830
|
+
problem;
|
|
1831
|
+
format = "raw";
|
|
1832
|
+
get command() {
|
|
1833
|
+
return null;
|
|
1834
|
+
}
|
|
1835
|
+
get room() {
|
|
1836
|
+
return null;
|
|
1837
|
+
}
|
|
1838
|
+
serialize() {
|
|
1839
|
+
return this.raw;
|
|
1840
|
+
}
|
|
1841
|
+
}
|
|
1842
|
+
const Ot = "xt";
|
|
1843
|
+
class me extends Oe {
|
|
1844
|
+
format = "xml";
|
|
1845
|
+
document;
|
|
1846
|
+
constructor(t, n) {
|
|
1847
|
+
super(t, n), this.document = kn(t);
|
|
1848
|
+
}
|
|
1849
|
+
static create(t, n, r, i, a = []) {
|
|
1850
|
+
const s = new B("msg", { attributes: [R.create("t", n)], children: [new B("body", { attributes: [R.create("action", r), R.create("r", String(i))], children: [...a] })] });
|
|
1851
|
+
return new me(Et(s), t);
|
|
1852
|
+
}
|
|
1853
|
+
get element() {
|
|
1854
|
+
return this.document.root.name;
|
|
1855
|
+
}
|
|
1856
|
+
get type() {
|
|
1857
|
+
var t;
|
|
1858
|
+
return ((t = this.envelope) == null ? void 0 : t.attribute("t")) ?? null;
|
|
1859
|
+
}
|
|
1860
|
+
get command() {
|
|
1861
|
+
var t;
|
|
1862
|
+
return ((t = this.body) == null ? void 0 : t.attribute("action")) ?? null;
|
|
1863
|
+
}
|
|
1864
|
+
get room() {
|
|
1865
|
+
const t = this.body, n = Number((t == null ? void 0 : t.attribute("r")) ?? (t == null ? void 0 : t.attribute("id")) ?? Number.NaN);
|
|
1866
|
+
return Number.isInteger(n) ? n : null;
|
|
1867
|
+
}
|
|
1868
|
+
get signed() {
|
|
1869
|
+
var t;
|
|
1870
|
+
return (((t = this.envelope) == null ? void 0 : t.attribute("h")) ?? null) !== null;
|
|
1871
|
+
}
|
|
1872
|
+
get body() {
|
|
1873
|
+
var t;
|
|
1874
|
+
return ((t = this.envelope) == null ? void 0 : t.child("body")) ?? null;
|
|
1875
|
+
}
|
|
1876
|
+
get data() {
|
|
1877
|
+
return this.type !== Ot || !this.body ? null : ti(this.body.textContent);
|
|
1878
|
+
}
|
|
1879
|
+
set data(t) {
|
|
1880
|
+
if (this.type !== Ot || !this.body) throw new x("Only an extension message carries an object", "PACKET_FORMAT");
|
|
1881
|
+
this.edit((n) => {
|
|
1882
|
+
const r = n.root.child("body");
|
|
1883
|
+
r.children = [new ee(ri(t))];
|
|
1884
|
+
});
|
|
1885
|
+
}
|
|
1886
|
+
edit(t) {
|
|
1887
|
+
if (this.signed) throw new x("This message is signed by the client; changing it would fail the server’s check", "PACKET_FORMAT");
|
|
1888
|
+
t(this.document), this.markModified();
|
|
1889
|
+
}
|
|
1890
|
+
serialize() {
|
|
1891
|
+
return Et(this.document);
|
|
1892
|
+
}
|
|
1893
|
+
get envelope() {
|
|
1894
|
+
const t = this.document.root;
|
|
1895
|
+
return (t == null ? void 0 : t.name) === "msg" ? t : null;
|
|
1896
|
+
}
|
|
1897
|
+
}
|
|
1898
|
+
const _ = "%", it = "xt";
|
|
1899
|
+
class pe extends Oe {
|
|
1900
|
+
format = "xt";
|
|
1901
|
+
fields;
|
|
1902
|
+
constructor(t, n) {
|
|
1903
|
+
super(t, n), this.fields = ai(t, n);
|
|
1904
|
+
}
|
|
1905
|
+
static create(t, n, r, i = [], a = "o") {
|
|
1906
|
+
return new pe($t(t, { extension: a, command: n, room: String(r), args: i.map(String) }), t);
|
|
1907
|
+
}
|
|
1908
|
+
get command() {
|
|
1909
|
+
return this.fields.command;
|
|
1910
|
+
}
|
|
1911
|
+
set command(t) {
|
|
1912
|
+
Se(t), this.fields.command = t, this.markModified();
|
|
1913
|
+
}
|
|
1914
|
+
get extension() {
|
|
1915
|
+
return this.fields.extension;
|
|
1916
|
+
}
|
|
1917
|
+
get room() {
|
|
1918
|
+
const t = Number(this.fields.room);
|
|
1919
|
+
return Number.isInteger(t) ? t : null;
|
|
1920
|
+
}
|
|
1921
|
+
set room(t) {
|
|
1922
|
+
this.fields.room = String(t), this.markModified();
|
|
1923
|
+
}
|
|
1924
|
+
get args() {
|
|
1925
|
+
return [...this.fields.args];
|
|
1926
|
+
}
|
|
1927
|
+
get length() {
|
|
1928
|
+
return this.fields.args.length;
|
|
1929
|
+
}
|
|
1930
|
+
arg(t) {
|
|
1931
|
+
return this.fields.args[t];
|
|
1932
|
+
}
|
|
1933
|
+
setArg(t, n) {
|
|
1934
|
+
if (!Number.isInteger(t) || t < 0 || t > this.fields.args.length) throw new RangeError(`Argument ${t} is outside a message of ${this.length} arguments`);
|
|
1935
|
+
const r = String(n);
|
|
1936
|
+
Se(r), this.fields.args[t] = r, this.markModified();
|
|
1937
|
+
}
|
|
1938
|
+
setArgs(t) {
|
|
1939
|
+
const n = t.map(String);
|
|
1940
|
+
n.forEach(Se), this.fields.args = n, this.markModified();
|
|
1941
|
+
}
|
|
1942
|
+
serialize() {
|
|
1943
|
+
return $t(this.direction, this.fields);
|
|
1944
|
+
}
|
|
1945
|
+
}
|
|
1946
|
+
function ai(e, t) {
|
|
1947
|
+
if (e.length < 2 || !e.startsWith(_) || !e.endsWith(_)) throw new x('An extension message starts and ends with "%"', "XT_SYNTAX");
|
|
1948
|
+
const n = e.slice(1, -1).split(_);
|
|
1949
|
+
if (n[0] !== it) throw new x(`Expected the "xt" handler, found "${n[0]}"`, "XT_SYNTAX", 1);
|
|
1950
|
+
const r = t === "toServer" ? 4 : 3;
|
|
1951
|
+
if (n.length < r) throw new x(`A message to the ${t === "toServer" ? "server" : "client"} has at least ${r} fields`, "XT_SYNTAX");
|
|
1952
|
+
return t === "toServer" ? { extension: n[1], command: n[2], room: n[3], args: n.slice(4) } : { extension: null, command: n[1], room: n[2], args: n.slice(3) };
|
|
1953
|
+
}
|
|
1954
|
+
function $t(e, t) {
|
|
1955
|
+
const n = [...e === "toServer" ? [it, t.extension ?? "o", t.command, t.room] : [it, t.command, t.room], ...t.args];
|
|
1956
|
+
return n.forEach(Se), _ + n.map((r) => r + _).join("");
|
|
1957
|
+
}
|
|
1958
|
+
function Se(e) {
|
|
1959
|
+
if (e.includes(_)) throw new x(`An extension message value cannot contain "${_}": ${e}`, "XT_VALUE");
|
|
1960
|
+
}
|
|
1961
|
+
function An(e, t) {
|
|
1962
|
+
try {
|
|
1963
|
+
switch (e.charAt(0)) {
|
|
1964
|
+
case "<":
|
|
1965
|
+
return new me(e, t);
|
|
1966
|
+
case _:
|
|
1967
|
+
return new pe(e, t);
|
|
1968
|
+
case "{":
|
|
1969
|
+
return new lt(e, t);
|
|
1970
|
+
default:
|
|
1971
|
+
return new Dt(e, t);
|
|
1972
|
+
}
|
|
1973
|
+
} catch (n) {
|
|
1974
|
+
return new Dt(e, t, n);
|
|
1975
|
+
}
|
|
1976
|
+
}
|
|
1977
|
+
class fe {
|
|
1978
|
+
constructor(t, n) {
|
|
1979
|
+
this.values = t, this.packet = n;
|
|
1980
|
+
}
|
|
1981
|
+
values;
|
|
1982
|
+
packet;
|
|
1983
|
+
index = 0;
|
|
1984
|
+
get position() {
|
|
1985
|
+
return this.index;
|
|
1986
|
+
}
|
|
1987
|
+
get remaining() {
|
|
1988
|
+
return this.values.length - this.index;
|
|
1989
|
+
}
|
|
1990
|
+
string(t) {
|
|
1991
|
+
return this.next(t);
|
|
1992
|
+
}
|
|
1993
|
+
int(t) {
|
|
1994
|
+
const n = this.next(t), r = Number(n);
|
|
1995
|
+
return (n.trim() === "" || !Number.isInteger(r)) && this.fail(t, this.index - 1, "is not an integer", n), r;
|
|
1996
|
+
}
|
|
1997
|
+
number(t) {
|
|
1998
|
+
const n = this.next(t), r = Number(n);
|
|
1999
|
+
return (n.trim() === "" || !Number.isFinite(r)) && this.fail(t, this.index - 1, "is not a number", n), r;
|
|
2000
|
+
}
|
|
2001
|
+
flag(t) {
|
|
2002
|
+
return this.next(t) !== "0";
|
|
2003
|
+
}
|
|
2004
|
+
repeat(t, n) {
|
|
2005
|
+
return Array.from({ length: t }, (r, i) => n(i));
|
|
2006
|
+
}
|
|
2007
|
+
rest() {
|
|
2008
|
+
const t = this.values.slice(this.index);
|
|
2009
|
+
return this.index = this.values.length, t;
|
|
2010
|
+
}
|
|
2011
|
+
next(t) {
|
|
2012
|
+
return this.index >= this.values.length && this.fail(t, this.index, `is missing: the message has ${this.values.length} arguments`), this.values[this.index++];
|
|
2013
|
+
}
|
|
2014
|
+
fail(t, n, r, i) {
|
|
2015
|
+
const a = i === void 0 ? "" : ` ("${i}")`;
|
|
2016
|
+
throw new x(`${this.packet}: field "${t}" (${n}) ${r}${a}`, "PACKET_FIELD");
|
|
2017
|
+
}
|
|
2018
|
+
}
|
|
2019
|
+
class si {
|
|
2020
|
+
written = [];
|
|
2021
|
+
string(t) {
|
|
2022
|
+
return this.written.push(t), this;
|
|
2023
|
+
}
|
|
2024
|
+
int(t) {
|
|
2025
|
+
if (!Number.isInteger(t)) throw new RangeError(`${t} is not an integer`);
|
|
2026
|
+
return this.written.push(t), this;
|
|
2027
|
+
}
|
|
2028
|
+
number(t) {
|
|
2029
|
+
if (!Number.isFinite(t)) throw new RangeError(`${t} is not a finite number`);
|
|
2030
|
+
return this.written.push(t), this;
|
|
2031
|
+
}
|
|
2032
|
+
flag(t) {
|
|
2033
|
+
return this.written.push(t ? "1" : "0"), this;
|
|
2034
|
+
}
|
|
2035
|
+
each(t, n) {
|
|
2036
|
+
return t.forEach(n), this;
|
|
2037
|
+
}
|
|
2038
|
+
raw(t) {
|
|
2039
|
+
return this.written.push(...t), this;
|
|
2040
|
+
}
|
|
2041
|
+
get values() {
|
|
2042
|
+
return this.written;
|
|
2043
|
+
}
|
|
2044
|
+
}
|
|
2045
|
+
function l(e) {
|
|
2046
|
+
const { name: t, description: n, direction: r, command: i, extension: a = "o", read: s, write: o } = e, d = (c) => c instanceof pe && c.direction === r && c.command === i && (r === "toClient" || c.extension === a);
|
|
2047
|
+
return { name: t, description: n, format: "xt", direction: r, command: i, matches: d, decode(c) {
|
|
2048
|
+
return Sn(d(c), t, c), { ...s(new fe(c.args, t)), room: c.room ?? -1 };
|
|
2049
|
+
}, encode(c) {
|
|
2050
|
+
const h = new si();
|
|
2051
|
+
return o(h, c), pe.create(r, i, c.room, h.values, a);
|
|
2052
|
+
} };
|
|
2053
|
+
}
|
|
2054
|
+
function oe(e) {
|
|
2055
|
+
const { name: t, description: n, direction: r, command: i, type: a, read: s, write: o } = e, d = (c) => c instanceof me && c.direction === r && c.type === a && c.command === i;
|
|
2056
|
+
return { name: t, description: n, format: "xml", direction: r, command: i, matches: d, decode(c) {
|
|
2057
|
+
return Sn(d(c), t, c), { ...s(c), room: c.room ?? -1 };
|
|
2058
|
+
}, encode(c) {
|
|
2059
|
+
return me.create(r, a, i, c.room, o(c));
|
|
2060
|
+
} };
|
|
2061
|
+
}
|
|
2062
|
+
function Sn(e, t, n) {
|
|
2063
|
+
if (!e) throw new TypeError(`A ${n.format} "${n.command}" message ${n.direction} is not ${t}`);
|
|
2064
|
+
}
|
|
2065
|
+
function Pt(e) {
|
|
2066
|
+
return { invId: e.int("invId"), defId: e.int("defId") };
|
|
2067
|
+
}
|
|
2068
|
+
function Lt(e, t) {
|
|
2069
|
+
e.int(t.length).each(t, ({ invId: n, defId: r }) => e.int(n).int(r));
|
|
2070
|
+
}
|
|
2071
|
+
l({ name: "achievement.list-request", description: "The client asks for a player’s achievements.", direction: "toServer", command: "za", read: (e) => ({ userName: e.string("userName"), secondsSinceLastAsked: e.int("secondsSinceLastAsked") }), write: (e, { userName: t, secondsSinceLastAsked: n }) => e.string(t).int(n) }), l({ name: "achievement.set-user-var", description: "The client sets one of the player’s user variables.", direction: "toServer", command: "zs", read: (e) => ({ userVarId: e.int("userVarId"), value: e.int("value"), notify: e.flag("notify") }), write: (e, { userVarId: t, value: n, notify: r }) => e.int(t).int(n).int(r ? 1 : 0) }), l({ name: "achievement.user-vars-request", description: "The client asks for all of the player’s user variables.", direction: "toServer", command: "zg", read: () => ({}), write: () => {
|
|
2072
|
+
} }), l({ name: "achievement.list", description: "The server gives a player’s achievements.", direction: "toClient", command: "za", read: (e) => {
|
|
2073
|
+
const t = e.string("userName"), n = e.int("count");
|
|
2074
|
+
return { userName: t, archived: n === -1, achievements: e.repeat(Math.max(n, 0), () => Pt(e)) };
|
|
2075
|
+
}, write: (e, { userName: t, archived: n, achievements: r }) => {
|
|
2076
|
+
e.string(t), n ? e.int(-1) : Lt(e, r);
|
|
2077
|
+
} }), l({ name: "achievement.user-var-changed", description: "One of the player’s user variables changed, and any achievements it earned.", direction: "toClient", command: "zs", read: (e) => ({ userVarId: e.int("userVarId"), value: e.number("value"), achievements: e.repeat(e.int("count"), () => Pt(e)) }), write: (e, { userVarId: t, value: n, achievements: r }) => {
|
|
2078
|
+
e.int(t).number(n), Lt(e, r);
|
|
2079
|
+
} }), l({ name: "achievement.user-vars", description: "The server gives all of the player’s user variables.", direction: "toClient", command: "zg", read: (e) => ({ userVars: e.repeat(e.int("count"), () => ({ userVarId: e.int("userVarId"), type: e.int("type"), value: e.number("value") })) }), write: (e, { userVars: t }) => e.int(t.length).each(t, ({ userVarId: n, type: r, value: i }) => e.int(n).int(r).number(i)) });
|
|
2080
|
+
function Cn(e) {
|
|
2081
|
+
return { lBits: e.int("lBits"), uBits: e.int("uBits"), eBits: e.int("eBits"), name: e.string("petName"), createdTs: e.number("createdTs"), personalityDefId: e.int("personalityDefId"), favoriteFoodDefId: e.int("favoriteFoodDefId"), favoriteToyDefId: e.int("favoriteToyDefId") };
|
|
2082
|
+
}
|
|
2083
|
+
function qn(e, t) {
|
|
2084
|
+
e.int(t.lBits).int(t.uBits).int(t.eBits).string(t.name).number(t.createdTs).int(t.personalityDefId).int(t.favoriteFoodDefId).int(t.favoriteToyDefId);
|
|
2085
|
+
}
|
|
2086
|
+
l({ name: "pet.list-request", description: "The client asks for a player’s pets.", direction: "toServer", command: "pl", read: (e) => ({ userName: e.string("userName") }), write: (e, { userName: t }) => e.string(t) }), l({ name: "pet.list", description: "The server lists a player’s pets.", direction: "toClient", command: "pl", read: (e) => {
|
|
2087
|
+
const t = e.string("found") === "1";
|
|
2088
|
+
if (!t) return { found: t, userName: "", pets: [] };
|
|
2089
|
+
const n = e.string("userName"), r = e.repeat(e.int("count"), () => ({ invId: e.int("invId"), createdTs: e.number("createdTs"), name: e.string("name"), lBits: e.int("lBits"), uBits: e.int("uBits"), eBits: e.int("eBits"), masteryCounter: e.int("masteryCounter"), personalityDefId: e.int("personalityDefId"), favoriteToyDefId: e.int("favoriteToyDefId"), favoriteFoodDefId: e.int("favoriteFoodDefId"), denStoreInvId: e.int("denStoreInvId") }));
|
|
2090
|
+
return { found: t, userName: n, pets: r };
|
|
2091
|
+
}, write: (e, { found: t, userName: n, pets: r }) => {
|
|
2092
|
+
e.string(t ? "1" : "0"), t && e.string(n).int(r.length).each(r, (i) => e.int(i.invId).number(i.createdTs).string(i.name).int(i.lBits).int(i.uBits).int(i.eBits).int(i.masteryCounter).int(i.personalityDefId).int(i.favoriteToyDefId).int(i.favoriteFoodDefId).int(i.denStoreInvId));
|
|
2093
|
+
} }), l({ name: "pet.switch-request", description: "The player brings out a pet, or puts theirs away.", direction: "toServer", command: "ps", read: (e) => ({ invId: e.int("invId") }), write: (e, { invId: t }) => e.int(t) }), l({ name: "pet.switched", description: "Someone brought out a pet or put theirs away.", direction: "toClient", command: "ps", read: (e) => {
|
|
2094
|
+
const t = e.string("success") === "1";
|
|
2095
|
+
if (!t) return { success: t, userId: -1, activePetInvId: null, pet: null };
|
|
2096
|
+
const n = e.int("userId");
|
|
2097
|
+
return e.remaining === 1 ? { success: t, userId: n, activePetInvId: e.int("activePetInvId"), pet: null } : { success: t, userId: n, activePetInvId: null, pet: Cn(e) };
|
|
2098
|
+
}, write: (e, { success: t, userId: n, activePetInvId: r, pet: i }) => {
|
|
2099
|
+
if (e.string(t ? "1" : "0"), !!t) if (e.int(n), i) qn(e, i);
|
|
2100
|
+
else if (r !== null) e.int(r);
|
|
2101
|
+
else throw new x("pet.switched: a success names a pet or an inventory id", "PACKET_FIELD");
|
|
2102
|
+
} }), l({ name: "pet.mastery-display-request", description: "The player shows or hides a pet’s mastery badge.", direction: "toServer", command: "pm", read: (e) => ({ show: e.flag("show"), invId: e.int("invId") }), write: (e, { show: t, invId: n }) => e.flag(t).int(n) }), l({ name: "pet.mastery-displayed", description: "The server says whether a pet’s mastery badge changed.", direction: "toClient", command: "pm", read: (e) => {
|
|
2103
|
+
const t = e.flag("success");
|
|
2104
|
+
return t ? { success: t, invId: e.int("invId"), lBits: e.int("lBits"), uBits: e.int("uBits"), eBits: e.int("eBits") } : { success: t, invId: -1, lBits: 0, uBits: 0, eBits: 0 };
|
|
2105
|
+
}, write: (e, { success: t, invId: n, lBits: r, uBits: i, eBits: a }) => {
|
|
2106
|
+
e.flag(t), t && e.int(n).int(r).int(i).int(a);
|
|
2107
|
+
} }), l({ name: "pet.egg-name-request", description: "The player names a newly hatched egg pet from two lists of predefined name parts.", direction: "toServer", command: "pn", read: (e) => ({ invId: e.int("invId"), firstNameLocId: e.int("firstNameLocId"), secondNameLocId: e.int("secondNameLocId") }), write: (e, { invId: t, firstNameLocId: n, secondNameLocId: r }) => e.int(t).int(n).int(r) }), l({ name: "pet.egg-named", description: "The server says whether an egg pet was named.", direction: "toClient", command: "pn", read: (e) => ({ success: e.flag("success"), invId: e.int("invId"), name: e.string("name") }), write: (e, { success: t, invId: n, name: r }) => e.flag(t).int(n).string(r) }), l({ name: "pet.create-request", description: "The player adopts a new pet.", direction: "toServer", command: "pc", read: (e) => ({ shopId: e.int("shopId"), lBits: e.int("lBits"), uBits: e.int("uBits"), eBits: e.int("eBits"), firstNameLocId: e.int("firstNameLocId"), secondNameLocId: e.int("secondNameLocId"), fromRedemption: e.flag("fromRedemption") }), write: (e, t) => e.int(t.shopId).int(t.lBits).int(t.uBits).int(t.eBits).int(t.firstNameLocId).int(t.secondNameLocId).flag(t.fromRedemption) }), l({ name: "pet.created", description: "The server says whether a new pet was adopted.", direction: "toClient", command: "pc", read: (e) => {
|
|
2108
|
+
const t = e.flag("success");
|
|
2109
|
+
if (!t) return { success: t, balance: 0, currencyType: 0, pet: null };
|
|
2110
|
+
const n = e.int("balance"), r = e.int("currencyType"), i = e.int("invId"), a = e.int("lBits"), s = e.int("uBits"), o = e.int("eBits"), d = e.string("name"), c = e.number("createdTs"), h = e.int("personalityDefId"), m = e.int("favoriteToyDefId"), u = e.int("favoriteFoodDefId"), f = e.flag("broughtOut");
|
|
2111
|
+
return { success: t, balance: n, currencyType: r, pet: { invId: i, lBits: a, uBits: s, eBits: o, name: d, createdTs: c, personalityDefId: h, favoriteToyDefId: m, favoriteFoodDefId: u, broughtOut: f } };
|
|
2112
|
+
}, write: (e, t) => {
|
|
2113
|
+
e.flag(t.success), !(!t.success || !t.pet) && e.int(t.balance).int(t.currencyType).int(t.pet.invId).int(t.pet.lBits).int(t.pet.uBits).int(t.pet.eBits).string(t.pet.name).number(t.pet.createdTs).int(t.pet.personalityDefId).int(t.pet.favoriteToyDefId).int(t.pet.favoriteFoodDefId).flag(t.pet.broughtOut);
|
|
2114
|
+
} }), l({ name: "pet.dismiss-request", description: "The player frees one of their pets.", direction: "toServer", command: "pd", read: (e) => ({ invId: e.int("invId") }), write: (e, { invId: t }) => e.int(t) }), l({ name: "pet.dismissed", description: "The server says whether a pet was freed.", direction: "toClient", command: "pd", read: (e) => ({ success: e.string("success") === "1", invId: e.int("invId") }), write: (e, { success: t, invId: n }) => e.string(t ? "1" : "0").int(n) }), l({ name: "avatar.move", description: "The player walks or is placed somewhere in the room.", direction: "toServer", command: "au", read: (e) => {
|
|
2115
|
+
const t = e.int("count"), n = e.repeat(t, () => ({ x: e.int("x"), y: e.int("y") })), r = e.int("animation") >>> 0;
|
|
2116
|
+
return { points: n, animation: r, immediate: e.flag("immediate") };
|
|
2117
|
+
}, write: (e, { points: t, animation: n, immediate: r }) => e.int(t.length).each(t, ({ x: i, y: a }) => e.int(i).int(a)).int(n >>> 0).flag(r) }), l({ name: "avatar.moved", description: "Avatars in the room walked or were placed.", direction: "toClient", command: "au", read: (e) => ({ avatars: e.repeat(e.int("users"), () => {
|
|
2118
|
+
const t = e.int("userId"), n = e.int("count"), r = e.repeat(n, () => ({ x: e.int("x"), y: e.int("y") }));
|
|
2119
|
+
return { userId: t, path: r, teleport: e.flag("teleport") };
|
|
2120
|
+
}) }), write: (e, { avatars: t }) => e.int(t.length).each(t, ({ userId: n, path: r, teleport: i }) => e.int(n).int(r.length).each(r, ({ x: a, y: s }) => e.int(a).int(s)).flag(i)) }), l({ name: "avatar.paint", description: "The player changes their avatar’s colours.", direction: "toServer", command: "ap", read: (e) => ({ colors: [e.int("color1"), e.int("color2"), e.int("color3")], avatarId: e.int("avatarId") }), write: (e, { colors: t, avatarId: n }) => e.int(t[0]).int(t[1]).int(t[2]).int(n) });
|
|
2121
|
+
function be(e) {
|
|
2122
|
+
return [e.int("color1"), e.int("color2"), e.int("color3")];
|
|
2123
|
+
}
|
|
2124
|
+
function Ie(e, t) {
|
|
2125
|
+
e.int(t[0]).int(t[1]).int(t[2]);
|
|
2126
|
+
}
|
|
2127
|
+
function Ut(e) {
|
|
2128
|
+
return e !== void 0 && e.trim() !== "" && Number.isInteger(Number(e));
|
|
2129
|
+
}
|
|
2130
|
+
l({ name: "avatar.paint-result", description: "The server says whether the player’s colours changed.", direction: "toClient", command: "ap", read: (e) => ({ success: e.string("success") === "1", extra: e.rest() }), write: (e, { success: t, extra: n }) => e.string(t ? "1" : "0").raw(n) }), l({ name: "avatar.switch-request", description: "The player switches to another of their avatars.", direction: "toServer", command: "as", read: (e) => ({ perUserAvId: e.int("perUserAvId") }), write: (e, { perUserAvId: t }) => e.int(t) }), l({ name: "avatar.switched", description: "Someone in the room switched avatars.", direction: "toClient", command: "as", read: (e) => {
|
|
2131
|
+
if (!e.flag("success")) return { success: !1, extra: e.rest() };
|
|
2132
|
+
const t = e.int("userId"), n = { perUserAvId: e.int("perUserAvId"), avInvId: e.int("avInvId"), customAvId: e.int("customAvId"), avTypeId: e.int("avTypeId"), colors: be(e), avName: e.string("avName") };
|
|
2133
|
+
if (e.remaining === 2) {
|
|
2134
|
+
const i = { activePetInvId: e.int("activePetInvId"), questLevel: e.int("questLevel") };
|
|
2135
|
+
return { success: !0, userId: t, avatar: n, player: i, other: null };
|
|
2136
|
+
}
|
|
2137
|
+
const r = { pet: Cn(e), questLevel: e.int("questLevel") };
|
|
2138
|
+
return { success: !0, userId: t, avatar: n, player: null, other: r };
|
|
2139
|
+
}, write: (e, t) => {
|
|
2140
|
+
if (!t.success) {
|
|
2141
|
+
e.flag(!1).raw(t.extra);
|
|
2142
|
+
return;
|
|
2143
|
+
}
|
|
2144
|
+
const { userId: n, avatar: r, player: i, other: a } = t;
|
|
2145
|
+
if (e.flag(!0).int(n).int(r.perUserAvId).int(r.avInvId).int(r.customAvId).int(r.avTypeId), Ie(e, r.colors), e.string(r.avName), i) e.int(i.activePetInvId).int(i.questLevel);
|
|
2146
|
+
else if (a) qn(e, a.pet), e.int(a.questLevel);
|
|
2147
|
+
else throw new x("avatar.switched: a success has a player or an other part", "PACKET_FIELD");
|
|
2148
|
+
} }), l({ name: "avatar.list-request", description: "The client asks for a player’s avatars.", direction: "toServer", command: "al", read: (e) => ({ userName: e.string("userName") }), write: (e, { userName: t }) => e.string(t) }), l({ name: "avatar.list", description: "The server lists a player’s avatars.", direction: "toClient", command: "al", read: (e) => {
|
|
2149
|
+
const t = e.rest(), n = new fe(t, "avatar.list"), r = n.string("userName"), i = Number(t[1]);
|
|
2150
|
+
if (Ut(t[1]) && t.length === 2 + i && t.slice(2).every((d) => Ut(d))) {
|
|
2151
|
+
const d = n.int("count");
|
|
2152
|
+
return { own: !1, userName: r, perUserAvIds: n.repeat(d, () => n.int("perUserAvId")) };
|
|
2153
|
+
}
|
|
2154
|
+
const a = n.int("slotFlags") >>> 0, s = n.string("uuid"), o = n.repeat(n.int("count"), () => ({ perUserAvId: n.int("perUserAvId"), avInvId: n.int("avInvId"), avName: n.string("avName"), avTypeId: n.int("avTypeId"), customAvId: n.int("customAvId") }));
|
|
2155
|
+
return { own: !0, userName: r, slotFlags: a, uuid: s, avatars: o };
|
|
2156
|
+
}, write: (e, t) => {
|
|
2157
|
+
if (e.string(t.userName), !t.own) {
|
|
2158
|
+
e.int(t.perUserAvIds.length).each(t.perUserAvIds, (n) => e.int(n));
|
|
2159
|
+
return;
|
|
2160
|
+
}
|
|
2161
|
+
e.int(t.slotFlags >>> 0).string(t.uuid).int(t.avatars.length).each(t.avatars, (n) => e.int(n.perUserAvId).int(n.avInvId).string(n.avName).int(n.avTypeId).int(n.customAvId));
|
|
2162
|
+
} }), l({ name: "avatar.data-request", description: "The client asks for one of a player’s avatars.", direction: "toServer", command: "ad", read: (e) => ({ userName: e.string("userName"), perUserAvId: e.int("perUserAvId"), items: e.int("items") }), write: (e, { userName: t, perUserAvId: n, items: r }) => e.string(t).int(n).int(r) }), l({ name: "avatar.data", description: "The server describes one of a player’s avatars.", direction: "toClient", command: "ad", read: (e) => {
|
|
2163
|
+
const t = { userName: e.string("userName"), uuid: e.string("uuid"), nameBarData: e.int("nameBarData"), enviroType: e.int("enviroType"), userNameModeratedFlag: e.int("userNameModeratedFlag"), timeLeftHostingCustomParty: e.int("timeLeftHostingCustomParty"), daysSinceLastLogin: e.int("daysSinceLastLogin"), perUserAvId: e.int("perUserAvId"), avTypeId: e.int("avTypeId"), customAvId: e.int("customAvId"), colors: be(e), avName: e.string("avName"), questLevel: e.int("questLevel") };
|
|
2164
|
+
if (e.remaining === 8) {
|
|
2165
|
+
const r = { avInvId: e.int("avInvId"), landPetInvId: e.int("landPetInvId"), oceanPetInvId: e.int("oceanPetInvId"), attackBase: e.int("attackBase"), attackMax: e.int("attackMax"), defenseBase: e.int("defenseBase"), defenseMax: e.int("defenseMax"), healthBase: e.int("healthBase") };
|
|
2166
|
+
return { ...t, player: r, other: null };
|
|
2167
|
+
}
|
|
2168
|
+
const n = { lBits: e.int("lBits"), uBits: e.int("uBits"), eBits: e.int("eBits"), petName: e.string("petName") };
|
|
2169
|
+
return { ...t, player: null, other: n };
|
|
2170
|
+
}, write: (e, t) => {
|
|
2171
|
+
e.string(t.userName).string(t.uuid).int(t.nameBarData).int(t.enviroType).int(t.userNameModeratedFlag).int(t.timeLeftHostingCustomParty).int(t.daysSinceLastLogin).int(t.perUserAvId).int(t.avTypeId).int(t.customAvId), Ie(e, t.colors), e.string(t.avName).int(t.questLevel);
|
|
2172
|
+
const { player: n, other: r } = t;
|
|
2173
|
+
if (n) e.int(n.avInvId).int(n.landPetInvId).int(n.oceanPetInvId).int(n.attackBase).int(n.attackMax).int(n.defenseBase).int(n.defenseMax).int(n.healthBase);
|
|
2174
|
+
else if (r) e.int(r.lBits).int(r.uBits).int(r.eBits).string(r.petName);
|
|
2175
|
+
else throw new x("avatar.data: an avatar has a player or an other part", "PACKET_FIELD");
|
|
2176
|
+
} }), l({ name: "avatar.lookup-request", description: "The client looks a player up by name.", direction: "toServer", command: "ag", read: (e) => ({ userName: e.string("userName"), userLookup: e.flag("userLookup") }), write: (e, { userName: t, userLookup: n }) => e.string(t).flag(n) }), l({ name: "avatar.lookup", description: "The server describes a player looked up by name.", direction: "toClient", command: "ag", read: (e) => {
|
|
2177
|
+
const t = e.string("userName"), n = e.string("uuid"), r = e.int("status");
|
|
2178
|
+
if (r !== 0 && r !== 1) return { userName: t, uuid: n, status: r, avatar: null };
|
|
2179
|
+
const i = { accountType: e.int("accountType"), isGuide: e.string("isGuide") === "1", daysSinceLastLogin: e.int("daysSinceLastLogin"), perUserAvId: e.int("perUserAvId"), avInvId: e.int("avInvId"), nameBarData: e.int("nameBarData"), avTypeId: e.int("avTypeId"), customAvId: e.int("customAvId"), colors: be(e), avName: e.string("avName"), eyesDefId: e.int("eyesDefId"), patternDefId: e.int("patternDefId"), questLevel: e.int("questLevel") }, a = e.int("count"), s = { userId: e.int("userId"), userNameModeratedFlag: e.int("userNameModeratedFlag"), pet: { lBits: e.int("lBits"), uBits: e.int("uBits"), eBits: e.int("eBits"), name: e.string("petName") }, items: e.repeat(a, () => ({ defId: e.int("defId"), color: e.int("color") })) };
|
|
2180
|
+
return { userName: t, uuid: n, status: r, avatar: { ...i, ...s } };
|
|
2181
|
+
}, write: (e, { userName: t, uuid: n, status: r, avatar: i }) => {
|
|
2182
|
+
e.string(t).string(n).int(r), i && (e.int(i.accountType).string(i.isGuide ? "1" : "0").int(i.daysSinceLastLogin).int(i.perUserAvId).int(i.avInvId).int(i.nameBarData).int(i.avTypeId).int(i.customAvId), Ie(e, i.colors), e.string(i.avName).int(i.eyesDefId).int(i.patternDefId).int(i.questLevel).int(i.items.length).int(i.userId).int(i.userNameModeratedFlag).int(i.pet.lBits).int(i.pet.uBits).int(i.pet.eBits).string(i.pet.name).each(i.items, ({ defId: a, color: s }) => e.int(a).int(s)));
|
|
2183
|
+
} }), l({ name: "avatar.joined", description: "An avatar appears in the room.", direction: "toClient", command: "ac", read: (e) => ({ userId: e.int("userId"), x: e.int("x"), y: e.int("y"), animation: e.int("animation") >>> 0, userName: e.string("userName"), uuid: e.string("uuid"), perUserAvId: e.int("perUserAvId"), avName: e.string("avName"), avTypeId: e.int("avTypeId"), customAvId: e.int("customAvId"), colors: be(e), questLevel: e.int("questLevel"), details: e.rest() }), write: (e, t) => {
|
|
2184
|
+
e.int(t.userId).int(t.x).int(t.y).int(t.animation >>> 0).string(t.userName).string(t.uuid).int(t.perUserAvId).string(t.avName).int(t.avTypeId).int(t.customAvId), Ie(e, t.colors), e.int(t.questLevel).raw(t.details);
|
|
2185
|
+
} }), l({ name: "avatar.kill-request", description: "The player deletes one of their avatars for good.", direction: "toServer", command: "ak", read: (e) => ({ perUserAvId: e.int("perUserAvId") }), write: (e, { perUserAvId: t }) => e.int(t) }), l({ name: "avatar.killed", description: "The server says whether an avatar was deleted for good.", direction: "toClient", command: "ak", read: (e) => ({ success: e.flag("success"), extra: e.int("extra") }), write: (e, { success: t, extra: n }) => e.flag(t).int(n) }), l({ name: "avatar.left", description: "An avatar leaves the room.", direction: "toClient", command: "ar", read: (e) => {
|
|
2186
|
+
const t = e.int("userId");
|
|
2187
|
+
if (e.remaining === 0) return { userId: t, walkOut: 0, walkTo: null, extra: [] };
|
|
2188
|
+
const n = e.int("walkOut"), r = n > 0 ? { x: e.int("x"), y: e.int("y") } : null;
|
|
2189
|
+
return { userId: t, walkOut: n, walkTo: r, extra: e.rest() };
|
|
2190
|
+
}, write: (e, { userId: t, walkOut: n, walkTo: r, extra: i }) => {
|
|
2191
|
+
e.int(t), !(n === 0 && !r && i.length === 0) && (e.int(n), n > 0 && r && e.int(r.x).int(r.y), e.raw(i));
|
|
2192
|
+
} }), l({ name: "buddy.list-request", description: "The player asks for their buddy and blocked lists.", direction: "toServer", command: "bl", read: () => ({}), write: () => {
|
|
2193
|
+
} }), l({ name: "buddy.list", description: "The server sends the buddy list or the blocked list.", direction: "toClient", command: "bl", read: (e) => {
|
|
2194
|
+
if (e.string("list") !== "0") {
|
|
2195
|
+
const r = e.int("blocked");
|
|
2196
|
+
return { blocked: !0, buddies: [], blockedUserNames: e.repeat(r, () => e.string("userName")) };
|
|
2197
|
+
}
|
|
2198
|
+
const t = e.repeat(e.int("online"), () => Ft(e, !0)), n = e.repeat(e.int("offline"), () => Ft(e, !1));
|
|
2199
|
+
return { blocked: !1, buddies: [...t, ...n], blockedUserNames: [] };
|
|
2200
|
+
}, write: (e, { blocked: t, buddies: n, blockedUserNames: r }) => {
|
|
2201
|
+
if (t) {
|
|
2202
|
+
e.string("1").int(r.length), r.forEach((s) => e.string(s));
|
|
2203
|
+
return;
|
|
2204
|
+
}
|
|
2205
|
+
const i = n.filter((s) => s.online), a = n.filter((s) => !s.online);
|
|
2206
|
+
e.string("0").int(i.length), i.forEach((s) => Bt(e, s, !0)), e.int(a.length), a.forEach((s) => Bt(e, s, !1));
|
|
2207
|
+
} }), l({ name: "buddy.add-request", description: "The player asks someone to be their buddy.", direction: "toServer", command: "ba", read: (e) => ({ userName: e.string("userName") }), write: (e, { userName: t }) => e.string(t) }), l({ name: "buddy.add-result", description: "Someone asks to be a buddy, or the server answers the player’s request.", direction: "toClient", command: "ba", read: (e) => ({ status: e.int("status"), userName: e.string("userName"), userNameModerationFlag: e.int("userNameModerationFlag") }), write: (e, { status: t, userName: n, userNameModerationFlag: r }) => e.int(t).string(n).int(r) }), l({ name: "buddy.confirm", description: "The player accepts or declines a buddy request.", direction: "toServer", command: "bc", read: (e) => ({ userName: e.string("userName"), accept: e.flag("accept") }), write: (e, { userName: t, accept: n }) => e.string(t).flag(n) }), l({ name: "buddy.status", description: "A buddy comes online or goes offline, is added, or is renamed.", direction: "toClient", command: "bs", read: (e) => {
|
|
2208
|
+
const t = e.string("withAvatar") === "1", n = { userName: e.string("userName"), uuid: e.string("uuid"), userNameModerationFlag: e.int("userNameModerationFlag"), online: e.string("online") === "1", accountType: e.int("accountType"), change: e.int("change") };
|
|
2209
|
+
return t ? { withAvatar: t, ...n, newUserName: null, avatarName: e.string("avatarName"), perUserAvatarId: e.int("perUserAvatarId"), partyTimeLeft: e.int("partyTimeLeft") } : { withAvatar: t, ...n, newUserName: e.string("newUserName"), avatarName: null, perUserAvatarId: null, partyTimeLeft: null };
|
|
2210
|
+
}, write: (e, t) => {
|
|
2211
|
+
e.flag(t.withAvatar).string(t.userName).string(t.uuid).int(t.userNameModerationFlag).flag(t.online).int(t.accountType).int(t.change), t.withAvatar ? e.string(t.avatarName ?? "").int(t.perUserAvatarId ?? -1).int(t.partyTimeLeft ?? -1) : e.string(t.newUserName ?? "");
|
|
2212
|
+
} }), l({ name: "buddy.remove-request", description: "The player removes a buddy.", direction: "toServer", command: "bd", read: (e) => ({ userName: e.string("userName") }), write: (e, { userName: t }) => e.string(t) }), l({ name: "buddy.removed", description: "A buddy is no longer a buddy.", direction: "toClient", command: "bd", read: (e) => ({ userName: e.string("userName") }), write: (e, { userName: t }) => e.string(t) }), l({ name: "buddy.location-request", description: "The player asks where a buddy is.", direction: "toServer", command: "br", read: (e) => ({ userName: e.string("userName") }), write: (e, { userName: t }) => e.string(t) }), l({ name: "buddy.location", description: "The server says where a buddy is.", direction: "toClient", command: "br", read: (e) => ({ roomName: e.string("roomName"), displayName: e.string("displayName"), displayNameId: e.int("displayNameId"), locked: e.string("locked") === "1" }), write: (e, { roomName: t, displayName: n, displayNameId: r, locked: i }) => e.string(t).string(n).int(r).flag(i) }), l({ name: "buddy.block-request", description: "The player blocks someone.", direction: "toServer", command: "bb", read: (e) => ({ userName: e.string("userName") }), write: (e, { userName: t }) => e.string(t) }), l({ name: "buddy.block-result", description: "The server says whether someone was blocked.", direction: "toClient", command: "bb", read: (e) => ({ userName: e.string("userName"), success: e.string("success") === "1" }), write: (e, { userName: t, success: n }) => e.string(t).flag(n) }), l({ name: "buddy.unblock-request", description: "The player unblocks someone.", direction: "toServer", command: "bu", read: (e) => ({ userName: e.string("userName") }), write: (e, { userName: t }) => e.string(t) }), l({ name: "buddy.unblock-result", description: "The server says whether someone was unblocked.", direction: "toClient", command: "bu", read: (e) => ({ userName: e.string("userName"), success: e.string("success") === "1" }), write: (e, { userName: t, success: n }) => e.string(t).flag(n) }), l({ name: "buddy.block-info-request", description: "The player asks whether someone is blocking them.", direction: "toServer", command: "bi", read: (e) => ({ userName: e.string("userName") }), write: (e, { userName: t }) => e.string(t) }), l({ name: "buddy.block-info", description: "The server says whether someone is blocking the player.", direction: "toClient", command: "bi", read: (e) => ({ userName: e.string("userName"), blockingPlayer: e.string("blockingPlayer") === "1" }), write: (e, { userName: t, blockingPlayer: n }) => e.string(t).flag(n) });
|
|
2213
|
+
function Ft(e, t) {
|
|
2214
|
+
return { userName: e.string("userName"), uuid: e.string("uuid"), userNameModerationFlag: e.int("userNameModerationFlag"), online: t, accountType: e.int("accountType"), partyTimeLeft: t ? e.int("partyTimeLeft") : null };
|
|
2215
|
+
}
|
|
2216
|
+
function Bt(e, t, n) {
|
|
2217
|
+
e.string(t.userName).string(t.uuid).int(t.userNameModerationFlag).int(t.accountType), n && e.int(t.partyTimeLeft ?? -1);
|
|
2218
|
+
}
|
|
2219
|
+
const ze = { free: 0, safeChat: 1, emote: 2, action: 3, attachmentEmote: 4, permanentEmote: 5, slide: 6, petAction: 7, blendColor: 8, freeSafeChat: 9, alpha: 10, customAdventure: 11, customPvp: 12 };
|
|
2220
|
+
oe({ name: "chat.public", description: "The player says something in the room.", direction: "toServer", type: "sys", command: "pubMsg", read: (e) => {
|
|
2221
|
+
var t, n;
|
|
2222
|
+
const r = dt(((n = (t = e.body) == null ? void 0 : t.child("txt")) == null ? void 0 : n.textContent) ?? ""), i = r.lastIndexOf("%");
|
|
2223
|
+
if (i === -1) throw new x("chat.public: the text has no kind after it", "PACKET_FIELD");
|
|
2224
|
+
const a = Number(r.slice(i + 1));
|
|
2225
|
+
if (!Number.isInteger(a)) throw new x("chat.public: the kind is not an integer", "PACKET_FIELD");
|
|
2226
|
+
return { text: r.slice(0, i), kind: a };
|
|
2227
|
+
}, write: ({ text: e, kind: t }) => [new B("txt", { children: [new ee(oi(`${e}%${t}`))] })] }), l({ name: "chat.room", description: "Someone in the room said something.", direction: "toClient", command: "uc", read: (e) => ({ userId: e.int("userId"), text: e.string("text"), kind: e.int("kind"), level: e.remaining > 0 ? e.int("level") : null, extra: e.rest() }), write: (e, { userId: t, text: n, kind: r, level: i, extra: a }) => {
|
|
2228
|
+
e.int(t).string(n).int(r), i !== null && e.int(i), e.raw(a);
|
|
2229
|
+
} }), l({ name: "chat.moderation", description: "A moderator bans, silences, kicks, warns or messages the player.", direction: "toClient", command: "fd", read: (e) => ({ action: e.string("action"), extra: e.rest() }), write: (e, { action: t, extra: n }) => e.string(t).raw(n) }), l({ name: "facilitator.invis-mode", description: "The server confirms the player's ghost mode.", direction: "toClient", command: "fi", read: (e) => ({ invisible: e.flag("invisible") }), write: (e, { invisible: t }) => e.flag(t) }), l({ name: "facilitator.report-request", description: "The player reports someone.", direction: "toServer", command: "fr", read: (e) => ({ userName: e.string("userName"), reasonId: e.int("reasonId") }), write: (e, { userName: t, reasonId: n }) => e.string(t).int(n) }), l({ name: "facilitator.report-result", description: "The server confirms a report.", direction: "toClient", command: "fr", read: (e) => ({ success: e.flag("success") }), write: (e, { success: t }) => e.flag(t) }), l({ name: "facilitator.report-with-data-request", description: "The player reports someone over something specific they sent.", direction: "toServer", command: "fra", read: (e) => ({ userName: e.string("userName"), reasonId: e.int("reasonId"), dataType: e.int("dataType"), data: e.string("data") }), write: (e, { userName: t, reasonId: n, dataType: r, data: i }) => e.string(t).int(n).int(r).string(i) }), l({ name: "facilitator.report-with-data-result", description: "The server confirms a report with content attached.", direction: "toClient", command: "fra", read: (e) => ({ success: e.flag("success") }), write: (e, { success: t }) => e.flag(t) });
|
|
2230
|
+
function oi(e) {
|
|
2231
|
+
let t = "";
|
|
2232
|
+
for (const n of e) t += ci[n] ?? n;
|
|
2233
|
+
return t;
|
|
2234
|
+
}
|
|
2235
|
+
const ci = { "&": "&", "<": "<", ">": ">", "'": "'", '"': """ }, Rt = 100;
|
|
2236
|
+
l({ name: "currency.update", description: "One or more of the player’s balances changed.", direction: "toClient", command: "cu", read: (e) => {
|
|
2237
|
+
const t = e.int("currency"), n = t === Rt ? di(e.string("balances")) : [{ currency: t, amount: e.int("amount") }], r = e.remaining > 0 ? e.int("reason") : null;
|
|
2238
|
+
return { currency: t, balances: n, reason: r, extra: e.rest() };
|
|
2239
|
+
}, write: (e, { currency: t, balances: n, reason: r, extra: i }) => {
|
|
2240
|
+
var a;
|
|
2241
|
+
e.int(t), t === Rt ? e.string(n.map(({ currency: s, amount: o }) => `${s}x${o}`).join(",")) : e.int(((a = n[0]) == null ? void 0 : a.amount) ?? 0), r !== null && e.int(r), e.raw(i);
|
|
2242
|
+
} });
|
|
2243
|
+
function di(e) {
|
|
2244
|
+
return e === "" ? [] : e.split(",").map((t) => {
|
|
2245
|
+
const n = t.split("x"), [r = "", i = ""] = n, a = Number(r), s = Number(i), o = r.trim() === "" || i.trim() === "";
|
|
2246
|
+
if (n.length !== 2 || o || !Number.isInteger(a) || !Number.isInteger(s)) throw new x(`currency.update: field "balances" has "${t}", not <currency>x<amount>`, "PACKET_FIELD");
|
|
2247
|
+
return { currency: a, amount: s };
|
|
2248
|
+
});
|
|
2249
|
+
}
|
|
2250
|
+
l({ name: "currency.donate", description: "The player donates gems.", direction: "toServer", command: "cd", read: (e) => ({ amount: e.int("amount") }), write: (e, { amount: t }) => e.int(t) }), l({ name: "currency.donate-result", description: "The server says whether the donation went through.", direction: "toClient", command: "cd", read: (e) => ({ success: e.string("result") === "1", extra: e.rest() }), write: (e, { success: t, extra: n }) => e.string(t ? "1" : "0").raw(n) }), l({ name: "currency.exchange", description: "The player exchanges one currency for another at a shop.", direction: "toServer", command: "ce", read: (e) => ({ shopId: e.int("shopId"), exchangeDefId: e.int("exchangeDefId") }), write: (e, { shopId: t, exchangeDefId: n }) => e.int(t).int(n) }), l({ name: "currency.exchange-result", description: "The server says whether the exchange went through.", direction: "toClient", command: "ce", read: (e) => ({ success: e.string("result") === "1", balance: e.remaining > 0 ? e.string("balance") : "", extra: e.rest() }), write: (e, { success: t, balance: n, extra: r }) => e.string(t ? "1" : "0").string(n).raw(r) }), l({ name: "currency.redeem-code", description: "The player redeems a code.", direction: "toServer", command: "grc", read: (e) => ({ code: e.string("code"), captchaQuestion: e.string("captchaQuestion"), captchaAnswer: e.string("captchaAnswer") }), write: (e, { code: t, captchaQuestion: n, captchaAnswer: r }) => e.string(t).string(n).string(r) }), l({ name: "currency.redeem-code-result", description: "The server says what a redeemed code came to.", direction: "toClient", command: "grc", read: (e) => {
|
|
2251
|
+
const t = e.string("result"), n = e.remaining > 0 ? e.string("details") : "", r = e.remaining > 0 ? e.string("hasGiftsElsewhere") === "1" : !1;
|
|
2252
|
+
return { result: t, details: li(n), hasGiftsElsewhere: r, extra: e.rest() };
|
|
2253
|
+
}, write: (e, { result: t, details: n, hasGiftsElsewhere: r, extra: i }) => e.string(t).string(n === null ? "" : JSON.stringify(n)).string(r ? "1" : "0").raw(i) });
|
|
2254
|
+
function li(e) {
|
|
2255
|
+
if (e === "") return null;
|
|
2256
|
+
try {
|
|
2257
|
+
return JSON.parse(e);
|
|
2258
|
+
} catch {
|
|
2259
|
+
throw new x(`currency.redeem-code-result: field "details" is not JSON ("${e}")`, "PACKET_FIELD");
|
|
2260
|
+
}
|
|
2261
|
+
}
|
|
2262
|
+
l({ name: "currency.membership-redeemed", description: "A membership was redeemed on the account.", direction: "toClient", command: "grm", read: (e) => {
|
|
2263
|
+
const t = e.int("result");
|
|
2264
|
+
return t !== 1 ? { result: t, accountType: null, daysLeft: null, sourceType: null, extra: e.rest() } : { result: t, accountType: e.int("accountType"), daysLeft: e.int("daysLeft"), sourceType: e.string("sourceType"), extra: e.rest() };
|
|
2265
|
+
}, write: (e, { result: t, accountType: n, daysLeft: r, sourceType: i, extra: a }) => {
|
|
2266
|
+
e.int(t), t === 1 && e.int(n ?? 0).int(r ?? 0).string(i ?? ""), e.raw(a);
|
|
2267
|
+
} }), l({ name: "den.join-request", description: "The player asks to join a den.", direction: "toServer", command: "dj", read: (e) => ({ denName: e.string("denName"), confirmLanguageChange: e.flag("confirmLanguageChange"), doorItem: e.int("doorItem") }), write: (e, { denName: t, confirmLanguageChange: n, doorItem: r }) => e.string(t).flag(n).int(r) }), l({ name: "den.privacy-request", description: "The player sets their den’s privacy, or asks for someone else’s.", direction: "toServer", command: "dp", read: (e) => ({ query: e.flag("lookup") ? { request: "lookup", userName: e.string("userName") } : { request: "set", privacy: e.int("privacy") } }), write: (e, { query: t }) => {
|
|
2268
|
+
t.request === "lookup" ? e.flag(!0).string(t.userName) : e.flag(!1).int(t.privacy);
|
|
2269
|
+
} }), l({ name: "den.privacy-result", description: "The server says who may come into someone’s den.", direction: "toClient", command: "dp", read: (e) => ({ userName: e.string("userName"), privacy: e.int("privacy") }), write: (e, { userName: t, privacy: n }) => e.string(t).int(n) }), l({ name: "den.kicked", description: "The player was sent out of a den its owner locked.", direction: "toClient", command: "dpk", read: () => ({}), write: () => {
|
|
2270
|
+
} }), l({ name: "den.visitor-count", description: "The server says how many are in a den.", direction: "toClient", command: "drc", read: (e) => ({ count: e.int("count"), countsOwner: e.flag("countsOwner"), ownerName: e.string("ownerName") }), write: (e, { count: t, countsOwner: n, ownerName: r }) => e.int(t).flag(n).string(r) }), l({ name: "den.room-list-request", description: "The player asks for their den rooms.", direction: "toServer", command: "dl", read: () => ({}), write: () => {
|
|
2271
|
+
} }), l({ name: "den.room-list", description: "The server lists the player’s den rooms.", direction: "toClient", command: "dl", read: (e) => ({ rooms: e.repeat(e.int("count"), () => ({ invIdx: e.int("invIdx"), defId: e.int("defId") })) }), write: (e, { rooms: t }) => e.int(t.length).each(t, ({ invIdx: n, defId: r }) => e.int(n).int(r)) }), l({ name: "den.change-request", description: "The player switches to another of their den rooms.", direction: "toServer", command: "dc", read: (e) => ({ invIdx: e.int("invIdx") }), write: (e, { invIdx: t }) => e.int(t) }), l({ name: "den.change-result", description: "The server says which den room the player switched to.", direction: "toClient", command: "dc", read: (e) => {
|
|
2272
|
+
const t = e.int("denRoomDefId"), n = e.remaining >= 2;
|
|
2273
|
+
return { denRoomDefId: t, perUserAvId: n ? e.int("perUserAvId") : null, activePetInvId: n ? e.int("activePetInvId") : null, extra: e.rest() };
|
|
2274
|
+
}, write: (e, { denRoomDefId: t, perUserAvId: n, activePetInvId: r, extra: i }) => {
|
|
2275
|
+
e.int(t), n !== null && r !== null && e.int(n).int(r), e.raw(i);
|
|
2276
|
+
} }), l({ name: "den.masterpiece-items-request", description: "The player asks for every masterpiece placed in someone’s den.", direction: "toServer", command: "dmi", read: (e) => ({ userName: e.string("userName") }), write: (e, { userName: t }) => e.string(t) }), l({ name: "den.masterpiece-items", description: "The server lists every masterpiece placed in a den.", direction: "toClient", command: "dmi", read: (e) => ({ items: e.repeat(e.int("count"), () => ({ defId: e.int("defId"), invIdx: e.int("invIdx"), version: e.int("version"), approved: e.string("approved") !== "", uniqueImageId: e.string("uniqueImageId"), uniqueImageCreatorDbId: e.int("uniqueImageCreatorDbId"), uniqueImageCreatorUUID: e.string("uniqueImageCreatorUUID") })) }), write: (e, { items: t }) => e.int(t.length).each(t, (n) => e.int(n.defId).int(n.invIdx).int(n.version).string(n.approved ? "1" : "").string(n.uniqueImageId).int(n.uniqueImageCreatorDbId).string(n.uniqueImageCreatorUUID)) }), l({ name: "den.masterpiece-creator-request", description: "The player asks who drew a masterpiece.", direction: "toServer", command: "dmc", read: (e) => ({ denUserName: e.string("denUserName"), uniqueImageId: e.string("uniqueImageId") }), write: (e, { denUserName: t, uniqueImageId: n }) => e.string(t).string(n) }), l({ name: "den.masterpiece-creator", description: "The server names who drew a masterpiece.", direction: "toClient", command: "dmc", read: (e) => ({ creatorName: e.string("creatorName") }), write: (e, { creatorName: t }) => e.string(t) }), l({ name: "ecard.list-request", description: "The player asks for their jam-a-grams.", direction: "toServer", command: "el", read: (e) => ({ interactive: e.flag("interactive") }), write: (e, { interactive: t }) => e.flag(t) }), l({ name: "ecard.list", description: "The server sends the player’s jam-a-grams.", direction: "toClient", command: "el", read: (e) => {
|
|
2277
|
+
const t = e.int("count");
|
|
2278
|
+
return { cards: e.repeat(Math.max(t, 0), () => zt(e)) };
|
|
2279
|
+
}, write: (e, { cards: t }) => {
|
|
2280
|
+
e.int(t.length), t.forEach((n) => Vt(e, n));
|
|
2281
|
+
} }), l({ name: "ecard.received", description: "The player receives a jam-a-gram.", direction: "toClient", command: "ep", read: (e) => ({ card: zt(e) }), write: (e, { card: t }) => Vt(e, t) }), l({ name: "ecard.send", description: "The player sends a jam-a-gram.", direction: "toServer", command: "es", read: (e) => ({ userName: e.string("userName"), cardMediaId: e.int("cardMediaId"), stampMediaId: e.int("stampMediaId"), messageType: e.int("messageType"), message: e.string("message"), type: e.int("type"), giftInvIdx: e.int("giftInvIdx"), specialType: e.int("specialType") }), write: (e, t) => e.string(t.userName).int(t.cardMediaId).int(t.stampMediaId).int(t.messageType).string(t.message).int(t.type).int(t.giftInvIdx).int(t.specialType) }), l({ name: "ecard.send-result", description: "The server says whether a jam-a-gram was sent.", direction: "toClient", command: "es", read: (e) => ({ result: e.int("result") }), write: (e, { result: t }) => e.int(t) }), l({ name: "ecard.read", description: "The player opens a jam-a-gram.", direction: "toServer", command: "er", read: (e) => ({ messageId: e.int("messageId") }), write: (e, { messageId: t }) => e.int(t) }), l({ name: "ecard.read-result", description: "The server says whether a jam-a-gram was marked read.", direction: "toClient", command: "er", read: (e) => ({ messageId: e.int("messageId"), success: e.string("success") === "1" }), write: (e, { messageId: t, success: n }) => e.int(t).flag(n) }), l({ name: "ecard.delete", description: "The player deletes a jam-a-gram.", direction: "toServer", command: "ed", read: (e) => ({ messageId: e.int("messageId") }), write: (e, { messageId: t }) => e.int(t) }), l({ name: "ecard.delete-result", description: "The server says which jam-a-grams were deleted.", direction: "toClient", command: "ed", read: (e) => ({ success: e.string("success") === "1", messageIds: e.repeat(e.int("count"), () => e.int("messageId")) }), write: (e, { success: t, messageIds: n }) => {
|
|
2282
|
+
e.flag(t).int(n.length), n.forEach((r) => e.int(r));
|
|
2283
|
+
} }), l({ name: "ecard.gift", description: "The player accepts or discards a jam-a-gram’s gift.", direction: "toServer", command: "eg", read: (e) => ({ messageId: e.int("messageId"), accept: e.flag("accept"), option: e.remaining > 0 ? e.int("option") : null }), write: (e, { messageId: t, accept: n, option: r }) => {
|
|
2284
|
+
e.int(t).flag(n), r !== null && e.int(r);
|
|
2285
|
+
} }), l({ name: "ecard.gift-result", description: "The server says whether a jam-a-gram’s gift was accepted or discarded.", direction: "toClient", command: "eg", read: (e) => ({ messageId: e.int("messageId"), success: e.string("success") === "1" }), write: (e, { messageId: t, success: n }) => e.int(t).flag(n) }), l({ name: "ecard.update", description: "The server changes a jam-a-gram’s message.", direction: "toClient", command: "eu", read: (e) => ({ messageId: e.int("messageId"), message: e.string("message") }), write: (e, { messageId: t, message: n }) => e.int(t).string(n) }), l({ name: "ecard.privacy", description: "The player changes who may send them jam-a-grams.", direction: "toServer", command: "ei", read: (e) => ({ setting: e.int("setting") }), write: (e, { setting: t }) => e.int(t) }), l({ name: "ecard.privacy-result", description: "The server says whether the jam-a-gram privacy setting changed.", direction: "toClient", command: "ei", read: (e) => ({ success: e.string("success") === "1" }), write: (e, { success: t }) => e.flag(t) });
|
|
2286
|
+
function zt(e) {
|
|
2287
|
+
return { messageId: e.int("messageId"), senderUserName: e.string("senderUserName"), cardMediaId: e.int("cardMediaId"), stampMediaId: e.int("stampMediaId"), read: e.string("read") === "1", message: e.string("message"), type: e.int("type"), giftId: e.int("giftId"), giftColor: e.int("giftColor"), giftName: e.string("giftName"), senderAccountType: e.int("senderAccountType"), senderNameBarData: e.int("senderNameBarData"), secondaryType: e.int("secondaryType"), senderType: e.int("senderType"), userNameModerationFlag: e.int("userNameModerationFlag"), additionalGiftData: e.string("additionalGiftData"), specialType: e.int("specialType") };
|
|
2288
|
+
}
|
|
2289
|
+
function Vt(e, t) {
|
|
2290
|
+
e.int(t.messageId).string(t.senderUserName).int(t.cardMediaId).int(t.stampMediaId).flag(t.read).string(t.message).int(t.type).int(t.giftId).int(t.giftColor).string(t.giftName).int(t.senderAccountType).int(t.senderNameBarData).int(t.secondaryType).int(t.senderType).int(t.userNameModerationFlag).string(t.additionalGiftData).int(t.specialType);
|
|
2291
|
+
}
|
|
2292
|
+
l({ name: "item.list-request", description: "The client asks for an avatar’s items.", direction: "toServer", command: "il", read: (e) => ({ userName: e.string("userName"), perUserAvId: e.int("perUserAvId"), full: e.flag("full") }), write: (e, { userName: t, perUserAvId: n, full: r }) => e.string(t).int(n).flag(r) }), l({ name: "item.list", description: "The server lists or changes an avatar’s items.", direction: "toClient", command: "il", read: (e) => {
|
|
2293
|
+
const t = e.string("type");
|
|
2294
|
+
if (t === "-1") return { kind: "failed", extra: e.rest() };
|
|
2295
|
+
if (t === "0" || t === "1") {
|
|
2296
|
+
const m = { unused: e.string("unused"), perUserAvId: e.int("perUserAvId"), userName: e.string("userName"), eyesDefId: e.int("eyesDefId"), patternDefId: e.int("patternDefId") }, u = e.int("count"), f = u > 0 && e.remaining === u * 5, y = e.repeat(u, () => ui(e, f));
|
|
2297
|
+
return { kind: t === "0" ? "inventory" : "worn", ...m, items: y };
|
|
2298
|
+
}
|
|
2299
|
+
const n = t === "3", r = e.string("wear") === "1", i = e.int("perUserAvId"), a = e.string("userName"), s = e.int("color") >>> 0, o = e.int("added"), d = e.int("removed"), c = e.repeat(o, () => ({ invId: e.int("invId"), defId: e.int("defId") })), h = e.repeat(d, () => e.int("invId"));
|
|
2300
|
+
return { kind: "changed", wornOnly: n, wear: r, perUserAvId: i, userName: a, color: s, added: c, removed: h };
|
|
2301
|
+
}, write: (e, t) => {
|
|
2302
|
+
if (t.kind === "failed") {
|
|
2303
|
+
e.string("-1").raw(t.extra);
|
|
2304
|
+
return;
|
|
2305
|
+
}
|
|
2306
|
+
if (t.kind === "changed") {
|
|
2307
|
+
e.string(t.wornOnly ? "3" : "2").string(t.wear ? "1" : "0").int(t.perUserAvId).string(t.userName).int(t.color >>> 0).int(t.added.length).int(t.removed.length).each(t.added, ({ invId: n, defId: r }) => e.int(n).int(r)).each(t.removed, (n) => e.int(n));
|
|
2308
|
+
return;
|
|
2309
|
+
}
|
|
2310
|
+
e.string(t.kind === "inventory" ? "0" : "1").string(t.unused).int(t.perUserAvId).string(t.userName).int(t.eyesDefId).int(t.patternDefId).int(t.items.length).each(t.items, (n) => {
|
|
2311
|
+
e.int(n.defId).int(n.invId).int(n.color >>> 0), n.equippedAvatars !== null && e.string(n.equippedAvatars).int(n.denStoreInvId ?? 0);
|
|
2312
|
+
});
|
|
2313
|
+
} });
|
|
2314
|
+
function ui(e, t) {
|
|
2315
|
+
const n = e.int("defId"), r = e.int("invId"), i = e.int("color") >>> 0;
|
|
2316
|
+
return t ? { defId: n, invId: r, color: i, equippedAvatars: e.string("equippedAvatars"), denStoreInvId: e.int("denStoreInvId") } : { defId: n, invId: r, color: i, equippedAvatars: null, denStoreInvId: null };
|
|
2317
|
+
}
|
|
2318
|
+
l({ name: "item.use", description: "The player puts items on and takes items off.", direction: "toServer", command: "iu", read: (e) => {
|
|
2319
|
+
const t = e.int("wearCount"), n = e.int("removeCount");
|
|
2320
|
+
return { wear: e.repeat(t, () => e.int("invId")), remove: e.repeat(n, () => e.int("invId")) };
|
|
2321
|
+
}, write: (e, { wear: t, remove: n }) => e.int(t.length).int(n.length).each(t, (r) => e.int(r)).each(n, (r) => e.int(r)) }), l({ name: "item.use-result", description: "The server says whether the player’s items changed.", direction: "toClient", command: "iu", read: (e) => ({ success: e.string("success") === "1", extra: e.rest() }), write: (e, { success: t, extra: n }) => e.string(t ? "1" : "0").raw(n) }), l({ name: "item.buy", description: "The player buys an item.", direction: "toServer", command: "ib", read: (e) => ({ shopId: e.int("shopId"), quantity: e.int("quantity"), defId: e.int("defId"), colorIndex: e.int("colorIndex"), diamond: e.flag("diamond"), targetInvId: e.int("targetInvId"), targetUserName: e.string("targetUserName") }), write: (e, t) => e.int(t.shopId).int(t.quantity).int(t.defId).int(t.colorIndex).flag(t.diamond).int(t.targetInvId).string(t.targetUserName) }), l({ name: "item.buy-result", description: "The server says whether an item was bought.", direction: "toClient", command: "ib", read: (e) => {
|
|
2322
|
+
const t = e.int("status"), n = e.int("shopId"), r = e.string("balance"), i = r === "" ? null : Number(r);
|
|
2323
|
+
return { status: t, shopId: n, balance: i, currencyType: e.int("currencyType"), extra: e.rest() };
|
|
2324
|
+
}, write: (e, { status: t, shopId: n, balance: r, currencyType: i, extra: a }) => e.int(t).int(n).string(r === null ? "" : String(r)).int(i).raw(a) }), l({ name: "item.recycle", description: "The player recycles items.", direction: "toServer", command: "ir", read: (e) => ({ invIds: e.repeat(e.remaining, () => e.int("invId")) }), write: (e, { invIds: t }) => e.each(t, (n) => e.int(n)) }), l({ name: "item.recycle-result", description: "The server says which items were recycled.", direction: "toClient", command: "ir", read: (e) => {
|
|
2325
|
+
const t = e.int("count");
|
|
2326
|
+
return { gems: e.int("gems"), invIds: e.repeat(t, () => e.int("invId")) };
|
|
2327
|
+
}, write: (e, { gems: t, invIds: n }) => e.int(n.length).int(t).each(n, (r) => e.int(r)) }), l({ name: "item.diamond-bundle-buy", description: "The player buys the bundle shop’s whole bundle for diamonds.", direction: "toServer", command: "id", read: (e) => ({ shopId: e.int("shopId") }), write: (e, { shopId: t }) => e.int(t) }), l({ name: "item.diamond-bundle-buy-result", description: "The server says whether the bundle shop’s whole bundle was bought.", direction: "toClient", command: "id", read: (e) => ({ bought: e.string("bought") === "true", balance: e.remaining > 0 ? e.int("balance") : null, extra: e.rest() }), write: (e, { bought: t, balance: n, extra: r }) => {
|
|
2328
|
+
e.string(t ? "true" : "false"), n !== null && e.int(n), e.raw(r);
|
|
2329
|
+
} });
|
|
2330
|
+
const hi = ["hc", "pf", "mo", "as", "ul"];
|
|
2331
|
+
l({ name: "minigame.info-request", description: "The client asks the server to describe minigames.", direction: "toServer", command: "mi", read: (e) => ({ gameDefIds: e.repeat(e.remaining, () => e.int("gameDefId")) }), write: (e, { gameDefIds: t }) => e.each(t, (n) => e.int(n)) }), l({ name: "minigame.join", description: "The player asks to play a minigame.", direction: "toServer", command: "mj", read: (e) => ({ gameDefId: e.int("gameDefId"), multiplayer: e.flag("multiplayer"), proModeId: e.int("proModeId"), hostUserId: e.int("hostUserId") }), write: (e, { gameDefId: t, multiplayer: n, proModeId: r, hostUserId: i }) => e.int(t).flag(n).int(r).int(i) }), l({ name: "minigame.start-request", description: "The player starts a waiting minigame now.", direction: "toServer", command: "ms", read: (e) => ({ gameDefId: e.int("gameDefId") }), write: (e, { gameDefId: t }) => e.int(t) }), l({ name: "minigame.leave", description: "The player leaves an in-room minigame.", direction: "toServer", command: "ml", read: () => ({}), write: () => {
|
|
2332
|
+
} }), l({ name: "minigame.send", description: "A minigame sends its own message to the server.", direction: "toServer", command: "mm", read: (e) => ({ gameDefId: e.int("gameDefId"), data: e.rest() }), write: (e, { gameDefId: t, data: n }) => e.int(t).raw(n) }), l({ name: "minigame.pvp", description: "The player challenges, accepts, or turns down a two player game.", direction: "toServer", command: "mp", read: (e) => ({ gameDefId: e.int("gameDefId"), action: e.int("action"), userName: e.remaining > 0 ? e.string("userName") : "" }), write: (e, { gameDefId: t, action: n, userName: r }) => {
|
|
2333
|
+
e.int(t).int(n), r !== "" && e.string(r);
|
|
2334
|
+
} }), l({ name: "minigame.custom-pvp-join", description: "The player joins a two player game another player set up.", direction: "toServer", command: "mcp", read: (e) => ({ gameDefId: e.int("gameDefId"), action: e.int("action"), userName: e.string("userName") }), write: (e, { gameDefId: t, action: n, userName: r }) => e.int(t).int(n).string(r) }), l({ name: "minigame.leaderboard-request", description: "The client asks for a minigame’s leaderboard.", direction: "toServer", command: "mlb", read: (e) => ({ gameDefId: e.int("gameDefId") }), write: (e, { gameDefId: t }) => e.int(t) }), l({ name: "minigame.info", description: "The server describes minigames.", direction: "toClient", command: "mi", read: (e) => ({ games: e.repeat(e.int("count"), () => ({ gameDefId: e.int("gameDefId"), titleStrId: e.int("titleStrId"), extName: e.string("extName"), swfName: e.string("swfName"), minPlayers: e.int("minPlayers"), maxPlayers: e.int("maxPlayers"), maxSpectators: e.int("maxSpectators"), type: e.int("type"), gameCardMediaId: e.int("gameCardMediaId"), gameCountUserVarRef: e.int("gameCountUserVarRef"), custom1UserVarRef: e.int("custom1UserVarRef"), custom2UserVarRef: e.int("custom2UserVarRef"), readyForPvp: e.flag("readyForPvp"), gemMultiplier: e.number("gemMultiplier"), petDefId: e.int("petDefId"), proModeUserVarRefId: e.int("proModeUserVarRefId"), leaderboardUserVarRef: e.int("leaderboardUserVarRef"), gameLibraryIconMediaId: e.int("gameLibraryIconMediaId"), requiredAvatarType: e.int("requiredAvatarType") })) }), write: (e, { games: t }) => e.int(t.length).each(t, (n) => e.int(n.gameDefId).int(n.titleStrId).string(n.extName).string(n.swfName).int(n.minPlayers).int(n.maxPlayers).int(n.maxSpectators).int(n.type).int(n.gameCardMediaId).int(n.gameCountUserVarRef).int(n.custom1UserVarRef).int(n.custom2UserVarRef).flag(n.readyForPvp).number(n.gemMultiplier).int(n.petDefId).int(n.proModeUserVarRefId).int(n.leaderboardUserVarRef).int(n.gameLibraryIconMediaId).int(n.requiredAvatarType)) }), l({ name: "minigame.join-result", description: "The server seats the player in a minigame, or says why not.", direction: "toClient", command: "mj", read: (e) => {
|
|
2335
|
+
if (e.remaining === 0) return { joined: !0, refusal: null, waitingUserIds: [], detail: [] };
|
|
2336
|
+
const t = e.string("result"), n = hi.find((a) => a === t);
|
|
2337
|
+
if (n) return { joined: !1, refusal: n, waitingUserIds: [], detail: e.rest() };
|
|
2338
|
+
const r = new fe([t], "minigame.join-result").int("userId"), i = e.repeat(e.remaining, () => e.int("userId"));
|
|
2339
|
+
return { joined: !0, refusal: null, waitingUserIds: [r, ...i], detail: [] };
|
|
2340
|
+
}, write: (e, t) => {
|
|
2341
|
+
t.joined ? e.each(t.waitingUserIds, (n) => e.int(n)) : e.string(t.refusal).raw(t.detail);
|
|
2342
|
+
} }), l({ name: "minigame.started", description: "The minigame starts, with its players.", direction: "toClient", command: "ms", read: (e) => ({ playerIds: e.repeat(e.int("playerCount"), () => e.int("userId")), data: e.rest() }), write: (e, { playerIds: t, data: n }) => e.int(t.length).each(t, (r) => e.int(r)).raw(n) });
|
|
2343
|
+
function ke(e, t, n) {
|
|
2344
|
+
return l({ name: e, description: n, direction: "toClient", command: t, read: (r) => ({ data: r.rest() }), write: (r, { data: i }) => r.raw(i) });
|
|
2345
|
+
}
|
|
2346
|
+
ke("minigame.message", "mm", "A minigame’s own message from the server."), ke("minigame.left", "ml", "A player left the minigame."), ke("minigame.ended", "me", "The minigame ended."), ke("minigame.room-removed", "mr", "The minigame’s room was removed."), l({ name: "minigame.pvp-invite", description: "A player challenges the player to a two player game, or turns them down.", direction: "toClient", command: "mp", read: (e) => {
|
|
2347
|
+
const t = e.int("gameDefId"), n = e.int("action");
|
|
2348
|
+
return n !== 0 ? { gameDefId: t, action: n, userName: "", nameVisible: !1, extra: e.rest() } : { gameDefId: t, action: n, userName: e.string("userName"), nameVisible: e.int("nameVisible") > 0, extra: e.rest() };
|
|
2349
|
+
}, write: (e, { gameDefId: t, action: n, userName: r, nameVisible: i, extra: a }) => {
|
|
2350
|
+
e.int(t).int(n), n === 0 && e.string(r).int(i ? 1 : 0), e.raw(a);
|
|
2351
|
+
} }), l({ name: "minigame.leaderboard", description: "The server gives a minigame’s leaderboard.", direction: "toClient", command: "mlb", read: (e) => {
|
|
2352
|
+
const t = e.int("gameDefId");
|
|
2353
|
+
if (t === -1) return { gameDefId: t, allTime: [], thisWeek: [], buddies: [] };
|
|
2354
|
+
const n = () => e.repeat(e.int("count"), () => ({ name: e.string("name"), score: e.number("score") })), r = n(), i = n(), a = n();
|
|
2355
|
+
return { gameDefId: t, allTime: r, thisWeek: i, buddies: a };
|
|
2356
|
+
}, write: (e, { gameDefId: t, allTime: n, thisWeek: r, buddies: i }) => {
|
|
2357
|
+
if (e.int(t), t !== -1) for (const a of [n, r, i]) e.int(a.length).each(a, ({ name: s, score: o }) => e.string(s).number(o));
|
|
2358
|
+
} }), l({ name: "party.list-request", description: "The player asks which parties are on.", direction: "toServer", command: "sl", read: () => ({}), write: () => {
|
|
2359
|
+
} }), l({ name: "party.list", description: "The server lists Animal Jam’s parties.", direction: "toClient", command: "sl", read: (e) => ({ unread: e.string("unread"), parties: e.repeat(e.int("count"), () => ({ defId: e.int("defId"), secondsToStart: e.number("secondsToStart"), secondsToEnd: e.number("secondsToEnd") })) }), write: (e, { unread: t, parties: n }) => e.string(t).int(n.length).each(n, (r) => e.int(r.defId).number(r.secondsToStart).number(r.secondsToEnd)) }), l({ name: "party.join-request", description: "The player asks to join a party.", direction: "toServer", command: "sj", read: (e) => ({ defId: e.int("defId") }), write: (e, { defId: t }) => e.int(t) }), l({ name: "party.join-result", description: "The server says a party could not be joined.", direction: "toClient", command: "sj", read: (e) => {
|
|
2360
|
+
const t = e.flag("joined"), n = !t && e.remaining > 0 ? e.string("reason") : null;
|
|
2361
|
+
return { joined: t, reason: n, extra: e.rest() };
|
|
2362
|
+
}, write: (e, { joined: t, reason: n, extra: r }) => {
|
|
2363
|
+
e.flag(t), n !== null && e.string(n), e.raw(r);
|
|
2364
|
+
} }), l({ name: "party.custom-list-request", description: "The player asks which parties players are hosting.", direction: "toServer", command: "slp", read: (e) => ({ start: e.int("start"), limit: e.int("limit") }), write: (e, { start: t, limit: n }) => e.int(t).int(n) }), l({ name: "party.custom-list", description: "The server lists the parties players are hosting.", direction: "toClient", command: "slp", read: (e) => {
|
|
2365
|
+
const t = e.flag("unread"), n = e.int("total");
|
|
2366
|
+
if (n <= 0) return { unread: t, total: n, skipped: null, parties: [] };
|
|
2367
|
+
const r = [e.int("skipped1"), e.int("skipped2")], i = e.repeat(e.int("count"), () => ({ creatorUuid: e.string("creatorUuid"), name: e.string("name"), node: e.string("node"), defId: e.int("defId"), timeLeft: e.number("timeLeft") }));
|
|
2368
|
+
return { unread: t, total: n, skipped: r, parties: i };
|
|
2369
|
+
}, write: (e, { unread: t, total: n, skipped: r, parties: i }) => {
|
|
2370
|
+
e.flag(t).int(n), !(n <= 0) && e.int((r == null ? void 0 : r[0]) ?? 0).int((r == null ? void 0 : r[1]) ?? 0).int(i.length).each(i, (a) => e.string(a.creatorUuid).string(a.name).string(a.node).int(a.defId).number(a.timeLeft));
|
|
2371
|
+
} }), l({ name: "party.custom-join-request", description: "The player asks to join a party a player hosts.", direction: "toServer", command: "sjp", read: (e) => ({ creatorUuid: e.string("creatorUuid") }), write: (e, { creatorUuid: t }) => e.string(t) }), l({ name: "party.custom-join-result", description: "The server says whether a hosted party could be joined.", direction: "toClient", command: "sjp", read: (e) => {
|
|
2372
|
+
const t = e.string("joined") === "1", n = !t && e.remaining > 0 ? e.string("reason") : null;
|
|
2373
|
+
return { joined: t, reason: n, extra: e.rest() };
|
|
2374
|
+
}, write: (e, { joined: t, reason: n, extra: r }) => {
|
|
2375
|
+
e.string(t ? "1" : "0"), n !== null && e.string(n), e.raw(r);
|
|
2376
|
+
} }), l({ name: "party.custom-node-request", description: "The player asks which server a hosted party is on.", direction: "toServer", command: "spn", read: (e) => ({ creatorUuid: e.string("creatorUuid") }), write: (e, { creatorUuid: t }) => e.string(t) }), l({ name: "party.custom-host-result", description: "The server says whether the player may host a party.", direction: "toClient", command: "scp", read: (e) => {
|
|
2377
|
+
const t = e.flag("hosting"), n = { hosting: t, secondsLeft: null, reason: null };
|
|
2378
|
+
if (!t) return { ...n, reason: e.string("reason") };
|
|
2379
|
+
const r = e.flag("stillHosting");
|
|
2380
|
+
return { ...n, secondsLeft: r ? e.int("secondsLeft") : null };
|
|
2381
|
+
}, write: (e, { hosting: t, secondsLeft: n, reason: r }) => {
|
|
2382
|
+
if (e.flag(t), !t) {
|
|
2383
|
+
e.string(r ?? "");
|
|
2384
|
+
return;
|
|
2385
|
+
}
|
|
2386
|
+
e.flag(n !== null), n !== null && e.int(n);
|
|
2387
|
+
} }), l({ name: "party.custom-killed", description: "The server ends the player’s hosted party from outside the client.", direction: "toClient", command: "spk", read: (e) => ({ diamondsRefunded: e.int("diamondsRefunded") }), write: (e, { diamondsRefunded: t }) => e.int(t) }), l({ name: "party.custom-node", description: "The server says which server a hosted party is on.", direction: "toClient", command: "spn", read: (e) => {
|
|
2388
|
+
const t = e.string("found") === "1", n = t ? { creatorUuid: e.string("creatorUuid"), node: e.string("node") } : null;
|
|
2389
|
+
return { found: t, party: n, extra: e.rest() };
|
|
2390
|
+
}, write: (e, { found: t, party: n, extra: r }) => {
|
|
2391
|
+
e.string(t ? "1" : "0"), t && n && e.string(n.creatorUuid).string(n.node), e.raw(r);
|
|
2392
|
+
} }), l({ name: "newspaper.page-seen-request", description: "The player marks a newspaper page seen.", direction: "toServer", command: "nps", read: (e) => ({ defId: e.int("defId") }), write: (e, { defId: t }) => e.int(t) }), l({ name: "newspaper.page-seen", description: "The server confirms a newspaper page was marked seen.", direction: "toClient", command: "nps", read: (e) => ({ defId: e.int("defId"), timeSeen: e.int("timeSeen") }), write: (e, { defId: t, timeSeen: n }) => e.int(t).int(n) });
|
|
2393
|
+
const ce = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
2394
|
+
function mi(e) {
|
|
2395
|
+
const t = e.replace(/[\s=]/g, ""), n = new Uint8Array(Math.floor(t.length * 3 / 4));
|
|
2396
|
+
let r = 0, i = 0, a = 0;
|
|
2397
|
+
for (const s of t) {
|
|
2398
|
+
const o = ce.indexOf(s);
|
|
2399
|
+
if (o === -1) throw new x(`"${s}" is not a Base64 character`, "PACKET_FIELD");
|
|
2400
|
+
r = r << 6 | o, i += 6, i >= 8 && (i -= 8, n[a++] = r >> i & 255);
|
|
2401
|
+
}
|
|
2402
|
+
return n.subarray(0, a);
|
|
2403
|
+
}
|
|
2404
|
+
function pi(e) {
|
|
2405
|
+
let t = "";
|
|
2406
|
+
for (let n = 0; n < e.length; n += 3) {
|
|
2407
|
+
const r = e[n], i = e[n + 1], a = e[n + 2], s = r << 16 | (i ?? 0) << 8 | (a ?? 0);
|
|
2408
|
+
t += ce[s >> 18 & 63] + ce[s >> 12 & 63], t += i === void 0 ? "=" : ce[s >> 6 & 63], t += a === void 0 ? "=" : ce[s & 63];
|
|
2409
|
+
}
|
|
2410
|
+
return t;
|
|
2411
|
+
}
|
|
2412
|
+
class gi {
|
|
2413
|
+
constructor(t) {
|
|
2414
|
+
this.bytes = t;
|
|
2415
|
+
}
|
|
2416
|
+
bytes;
|
|
2417
|
+
position = 0;
|
|
2418
|
+
readShort() {
|
|
2419
|
+
const t = this.byte() << 8 | this.byte();
|
|
2420
|
+
return t >= 32768 ? t - 65536 : t;
|
|
2421
|
+
}
|
|
2422
|
+
readUTF() {
|
|
2423
|
+
const t = this.byte() << 8 | this.byte(), n = this.position + t;
|
|
2424
|
+
n > this.bytes.length && this.fail("A string runs past the end of the bytes");
|
|
2425
|
+
let r = "";
|
|
2426
|
+
for (; this.position < n; ) {
|
|
2427
|
+
const i = this.byte();
|
|
2428
|
+
if (i < 128) r += String.fromCharCode(i);
|
|
2429
|
+
else if ((i & 224) === 192) r += String.fromCharCode((i & 31) << 6 | this.byte() & 63);
|
|
2430
|
+
else if ((i & 240) === 224) {
|
|
2431
|
+
const a = this.byte();
|
|
2432
|
+
r += String.fromCharCode((i & 15) << 12 | (a & 63) << 6 | this.byte() & 63);
|
|
2433
|
+
} else this.fail("A string holds a byte modified UTF-8 never starts a character with");
|
|
2434
|
+
}
|
|
2435
|
+
return r;
|
|
2436
|
+
}
|
|
2437
|
+
byte() {
|
|
2438
|
+
return this.position >= this.bytes.length && this.fail("The bytes end early"), this.bytes[this.position++];
|
|
2439
|
+
}
|
|
2440
|
+
fail(t) {
|
|
2441
|
+
throw new x(t, "PACKET_FIELD", this.position);
|
|
2442
|
+
}
|
|
2443
|
+
}
|
|
2444
|
+
class fi {
|
|
2445
|
+
bytes = [];
|
|
2446
|
+
writeShort(t) {
|
|
2447
|
+
return this.bytes.push(t >> 8 & 255, t & 255), this;
|
|
2448
|
+
}
|
|
2449
|
+
writeUTF(t) {
|
|
2450
|
+
const n = [];
|
|
2451
|
+
for (let r = 0; r < t.length; r++) {
|
|
2452
|
+
const i = t.charCodeAt(r);
|
|
2453
|
+
i >= 1 && i < 128 ? n.push(i) : i < 2048 ? n.push(192 | i >> 6, 128 | i & 63) : n.push(224 | i >> 12, 128 | i >> 6 & 63, 128 | i & 63);
|
|
2454
|
+
}
|
|
2455
|
+
if (n.length > 65535) throw new x("A string is longer than writeUTF can write", "PACKET_FIELD");
|
|
2456
|
+
return this.writeShort(n.length), this.bytes.push(...n), this;
|
|
2457
|
+
}
|
|
2458
|
+
toBytes() {
|
|
2459
|
+
return Uint8Array.from(this.bytes);
|
|
2460
|
+
}
|
|
2461
|
+
}
|
|
2462
|
+
function yi(e) {
|
|
2463
|
+
const t = Math.max(1, Math.ceil(e.length / 65535)), n = new Uint8Array(2 + t * 5 + e.length + 4);
|
|
2464
|
+
n[0] = 120, n[1] = 1;
|
|
2465
|
+
let r = 2;
|
|
2466
|
+
for (let o = 0; o < t; o++) {
|
|
2467
|
+
const d = o * 65535, c = Math.min(65535, e.length - d);
|
|
2468
|
+
n[r++] = o === t - 1 ? 1 : 0, n[r++] = c & 255, n[r++] = c >> 8, n[r++] = ~c & 255, n[r++] = ~c >> 8 & 255, n.set(e.subarray(d, d + c), r), r += c;
|
|
2469
|
+
}
|
|
2470
|
+
let i = 1, a = 0;
|
|
2471
|
+
for (const o of e) i = (i + o) % 65521, a = (a + i) % 65521;
|
|
2472
|
+
const s = (a << 16 | i) >>> 0;
|
|
2473
|
+
return n[r++] = s >>> 24, n[r++] = s >>> 16 & 255, n[r++] = s >>> 8 & 255, n[r] = s & 255, n;
|
|
2474
|
+
}
|
|
2475
|
+
function wi(e) {
|
|
2476
|
+
return e.length < 2 && P("A zlib stream has a two byte header"), ((e[0] & 15) !== 8 || (e[0] << 8 | e[1]) % 31 !== 0) && P("Not a zlib stream of deflate data"), e[1] & 32 && P("A zlib stream with a preset dictionary cannot be read"), Ni(e.subarray(2));
|
|
2477
|
+
}
|
|
2478
|
+
const vi = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15], Ht = [3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258], bi = [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0], Wt = [1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577], Ii = [0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13];
|
|
2479
|
+
function le(e) {
|
|
2480
|
+
const t = new Uint16Array(16);
|
|
2481
|
+
for (let i = 0; i < e.length; i++) t[e[i]]++;
|
|
2482
|
+
t[0] = 0;
|
|
2483
|
+
const n = new Uint16Array(16);
|
|
2484
|
+
for (let i = 1; i < 16; i++) n[i] = n[i - 1] + t[i - 1];
|
|
2485
|
+
const r = new Uint16Array(e.length);
|
|
2486
|
+
for (let i = 0; i < e.length; i++) {
|
|
2487
|
+
const a = e[i];
|
|
2488
|
+
a !== 0 && (r[n[a]++] = i);
|
|
2489
|
+
}
|
|
2490
|
+
return { counts: t, symbols: r };
|
|
2491
|
+
}
|
|
2492
|
+
let Ve = null;
|
|
2493
|
+
function ki() {
|
|
2494
|
+
if (!Ve) {
|
|
2495
|
+
const e = new Uint8Array(288);
|
|
2496
|
+
e.fill(8, 0, 144), e.fill(9, 144, 256), e.fill(7, 256, 280), e.fill(8, 280, 288), Ve = { literals: le(e), distances: le(new Uint8Array(30).fill(5)) };
|
|
2497
|
+
}
|
|
2498
|
+
return Ve;
|
|
2499
|
+
}
|
|
2500
|
+
class xi {
|
|
2501
|
+
constructor(t) {
|
|
2502
|
+
this.bytes = t;
|
|
2503
|
+
}
|
|
2504
|
+
bytes;
|
|
2505
|
+
position = 0;
|
|
2506
|
+
bitBuffer = 0;
|
|
2507
|
+
bitCount = 0;
|
|
2508
|
+
bits(t) {
|
|
2509
|
+
for (; this.bitCount < t; ) this.position >= this.bytes.length && P("The deflate data ends early"), this.bitBuffer |= this.bytes[this.position++] << this.bitCount, this.bitCount += 8;
|
|
2510
|
+
const n = this.bitBuffer & (1 << t) - 1;
|
|
2511
|
+
return this.bitBuffer >>>= t, this.bitCount -= t, n;
|
|
2512
|
+
}
|
|
2513
|
+
align() {
|
|
2514
|
+
this.bitBuffer = 0, this.bitCount = 0;
|
|
2515
|
+
}
|
|
2516
|
+
byte() {
|
|
2517
|
+
return this.position >= this.bytes.length && P("The deflate data ends early"), this.bytes[this.position++];
|
|
2518
|
+
}
|
|
2519
|
+
decode(t) {
|
|
2520
|
+
let n = 0, r = 0, i = 0;
|
|
2521
|
+
for (let a = 1; a < 16; a++) {
|
|
2522
|
+
i |= this.bits(1);
|
|
2523
|
+
const s = t.counts[a];
|
|
2524
|
+
if (i - n < s) return t.symbols[r + i - n];
|
|
2525
|
+
r += s, n = n + s << 1, i <<= 1;
|
|
2526
|
+
}
|
|
2527
|
+
return P("The deflate data holds a code that is not in its table");
|
|
2528
|
+
}
|
|
2529
|
+
}
|
|
2530
|
+
class Ti {
|
|
2531
|
+
bytes = new Uint8Array(1024);
|
|
2532
|
+
length = 0;
|
|
2533
|
+
push(t) {
|
|
2534
|
+
if (this.length === this.bytes.length) {
|
|
2535
|
+
const n = new Uint8Array(this.bytes.length * 2);
|
|
2536
|
+
n.set(this.bytes), this.bytes = n;
|
|
2537
|
+
}
|
|
2538
|
+
this.bytes[this.length++] = t;
|
|
2539
|
+
}
|
|
2540
|
+
}
|
|
2541
|
+
function Ni(e) {
|
|
2542
|
+
const t = new xi(e), n = new Ti();
|
|
2543
|
+
let r = !1;
|
|
2544
|
+
for (; !r; ) {
|
|
2545
|
+
r = t.bits(1) === 1;
|
|
2546
|
+
const i = t.bits(2);
|
|
2547
|
+
if (i === 0) {
|
|
2548
|
+
t.align();
|
|
2549
|
+
const a = t.byte() | t.byte() << 8, s = t.byte() | t.byte() << 8;
|
|
2550
|
+
(a ^ 65535) !== s && P("A stored deflate block has a bad length");
|
|
2551
|
+
for (let o = 0; o < a; o++) n.push(t.byte());
|
|
2552
|
+
} else if (i === 1) {
|
|
2553
|
+
const { literals: a, distances: s } = ki();
|
|
2554
|
+
_t(t, n, a, s);
|
|
2555
|
+
} else if (i === 2) {
|
|
2556
|
+
const { literals: a, distances: s } = Ai(t);
|
|
2557
|
+
_t(t, n, a, s);
|
|
2558
|
+
} else P("A deflate block has the reserved type 3");
|
|
2559
|
+
}
|
|
2560
|
+
return n.bytes.slice(0, n.length);
|
|
2561
|
+
}
|
|
2562
|
+
function Ai(e) {
|
|
2563
|
+
const t = e.bits(5) + 257, n = e.bits(5) + 1, r = e.bits(4) + 4, i = new Uint8Array(19);
|
|
2564
|
+
for (let d = 0; d < r; d++) i[vi[d]] = e.bits(3);
|
|
2565
|
+
const a = le(i), s = new Uint8Array(t + n);
|
|
2566
|
+
let o = 0;
|
|
2567
|
+
for (; o < s.length; ) {
|
|
2568
|
+
const d = e.decode(a);
|
|
2569
|
+
if (d < 16) {
|
|
2570
|
+
s[o++] = d;
|
|
2571
|
+
continue;
|
|
2572
|
+
}
|
|
2573
|
+
let c, h = 0;
|
|
2574
|
+
d === 16 ? (o === 0 && P("A deflate block repeats a code length before giving one"), h = s[o - 1], c = 3 + e.bits(2)) : d === 17 ? c = 3 + e.bits(3) : c = 11 + e.bits(7), o + c > s.length && P("A deflate block has too many code lengths"), s.fill(h, o, o + c), o += c;
|
|
2575
|
+
}
|
|
2576
|
+
return { literals: le(s.subarray(0, t)), distances: le(s.subarray(t)) };
|
|
2577
|
+
}
|
|
2578
|
+
function _t(e, t, n, r) {
|
|
2579
|
+
for (; ; ) {
|
|
2580
|
+
const i = e.decode(n);
|
|
2581
|
+
if (i < 256) t.push(i);
|
|
2582
|
+
else {
|
|
2583
|
+
if (i === 256) return;
|
|
2584
|
+
{
|
|
2585
|
+
const a = i - 257;
|
|
2586
|
+
a >= Ht.length && P("A deflate block has a bad length code");
|
|
2587
|
+
const s = Ht[a] + e.bits(bi[a]), o = e.decode(r);
|
|
2588
|
+
o >= Wt.length && P("A deflate block has a bad distance code");
|
|
2589
|
+
const d = Wt[o] + e.bits(Ii[o]);
|
|
2590
|
+
d > t.length && P("A deflate block points before its start");
|
|
2591
|
+
for (let c = 0; c < s; c++) t.push(t.bytes[t.length - d]);
|
|
2592
|
+
}
|
|
2593
|
+
}
|
|
2594
|
+
}
|
|
2595
|
+
}
|
|
2596
|
+
function P(e) {
|
|
2597
|
+
throw new x(e, "PACKET_FIELD");
|
|
2598
|
+
}
|
|
2599
|
+
const Si = 200, Mn = 16, Ci = [11, 23], qi = { setState: 1 }, W = { denItem: 1, clothing: 2, gems: 3, crystals: 4 };
|
|
2600
|
+
l({ name: "quest.join", description: "The player joins or creates a public adventure.", direction: "toServer", command: "qj", read: (e) => ({ roomName: e.string("roomName"), scriptDefId: e.int("scriptDefId"), difficulty: e.int("difficulty"), reserved: e.int("reserved") }), write: (e, { roomName: t, scriptDefId: n, difficulty: r, reserved: i }) => e.string(t).int(n).int(r).int(i) }), l({ name: "quest.create-private", description: "The player creates a private adventure to host.", direction: "toServer", command: "qjc", read: (e) => ({ roomName: e.string("roomName"), scriptDefId: e.int("scriptDefId"), difficulty: e.int("difficulty") }), write: (e, { roomName: t, scriptDefId: n, difficulty: r }) => e.string(t).int(n).int(r) }), l({ name: "quest.join-private", description: "The player joins a private adventure another player hosts.", direction: "toServer", command: "qjp", read: (e) => ({ roomName: e.string("roomName"), hostUserName: e.string("hostUserName") }), write: (e, { roomName: t, hostUserName: n }) => e.string(t).string(n) }), l({ name: "quest.join-buddy", description: "The player joins the adventure a buddy is in.", direction: "toServer", command: "qjf", read: (e) => ({ roomName: e.string("roomName"), buddyUserName: e.string("buddyUserName") }), write: (e, { roomName: t, buddyUserName: n }) => e.string(t).string(n) }), l({ name: "quest.join-cancel", description: "The player leaves an adventure lobby before it starts.", direction: "toServer", command: "qjx", read: () => ({}), write: () => {
|
|
2601
|
+
} }), l({ name: "quest.kick", description: "The host removes a player from a private adventure lobby.", direction: "toServer", command: "qjk", read: (e) => ({ userName: e.string("userName") }), write: (e, { userName: t }) => e.string(t) }), l({ name: "quest.start", description: "The player starts the adventure they are waiting in.", direction: "toServer", command: "qs", read: (e) => ({ roomName: e.string("roomName") }), write: (e, { roomName: t }) => e.string(t) }), l({ name: "quest.exit", description: "The player leaves the adventure.", direction: "toServer", command: "qx", read: (e) => ({ exitType: e.string("exitType") }), write: (e, { exitType: t }) => e.string(t) }), l({ name: "quest.actor-trigger", description: "The player sets off an adventure actor, such as a treasure chest.", direction: "toServer", command: "qat", read: (e) => ({ actorId: e.string("actorId"), value: e.int("value") }), write: (e, { actorId: t, value: n }) => e.string(t).int(n) }), l({ name: "quest.treasure-choice", description: "The player keeps or turns down a treasure chest’s prize.", direction: "toServer", command: "qatt", read: (e) => ({ actorId: e.string("actorId"), keep: e.flag("keep") }), write: (e, { actorId: t, keep: n }) => e.string(t).flag(n) }), l({ name: "quest.pick-up", description: "The player picks up an item in an adventure.", direction: "toServer", command: "qpup", read: (e) => ({ actorId: e.string("actorId"), userId: e.int("userId") }), write: (e, { actorId: t, userId: n }) => e.string(t).int(n) });
|
|
2602
|
+
function Kt(e, t, n) {
|
|
2603
|
+
return l({ name: e, description: n, direction: "toServer", command: t, read: (r) => ({ index: r.int("index"), belowGoal: r.flag("belowGoal"), discarded: r.flag("discarded") }), write: (r, { index: i, belowGoal: a, discarded: s }) => r.int(i).flag(a).flag(s) });
|
|
2604
|
+
}
|
|
2605
|
+
Kt("quest.gift-choice", "qpgift", "The player picks a gift on an adventure’s reward screen."), Kt("quest.player-gift-choice", "qpgiftplr", "The player picks a gift on their own reward screen."), l({ name: "quest.gifts-done", description: "The player finished picking an adventure’s gifts.", direction: "toServer", command: "qpgiftdone", read: (e) => ({ done: e.flag("done") }), write: (e, { done: t }) => e.flag(t) });
|
|
2606
|
+
function He(e, t, n, r) {
|
|
2607
|
+
return l({ name: e, description: n, direction: "toClient", command: t, read: (i) => {
|
|
2608
|
+
const a = i.flag("joined");
|
|
2609
|
+
return a ? { joined: a, status: i.string("status"), scriptDefId: i.int("scriptDefId"), difficulty: r && i.remaining > 0 ? i.int("difficulty") : null, extra: i.rest(), refusal: null } : { joined: a, refusal: i.string("refusal"), extra: i.rest() };
|
|
2610
|
+
}, write: (i, a) => {
|
|
2611
|
+
i.flag(a.joined), a.joined ? (i.string(a.status).int(a.scriptDefId), a.difficulty !== null && i.int(a.difficulty)) : i.string(a.refusal), i.raw(a.extra);
|
|
2612
|
+
} });
|
|
2613
|
+
}
|
|
2614
|
+
He("quest.join-result", "qj", "The server says whether the player joined a public adventure.", !0), He("quest.create-private-result", "qjc", "The server says whether the player’s private adventure was created.", !1), He("quest.join-private-result", "qjp", "The server says whether the player joined a private adventure.", !0), l({ name: "quest.waiting", description: "The players waiting in the adventure lobby changed.", direction: "toClient", command: "qw", read: (e) => ({ userIds: e.repeat(e.remaining, () => e.int("userId")) }), write: (e, { userIds: t }) => e.each(t, (n) => e.int(n)) }), l({ name: "quest.join-cancelled", description: "The server confirms the player left the adventure lobby.", direction: "toClient", command: "qjx", read: (e) => ({ extra: e.rest() }), write: (e, { extra: t }) => e.raw(t) }), l({ name: "quest.started", description: "The adventure starts, with every actor in it.", direction: "toClient", command: "qs", read: (e) => {
|
|
2615
|
+
const t = e.int("scriptDefId"), n = e.int("playerCount"), r = e.int("actorCount");
|
|
2616
|
+
if (r < 0) return { scriptDefId: t, playerCount: n, started: !1, timestamp: "", actors: [], extra: e.rest() };
|
|
2617
|
+
const i = e.string("timestamp"), a = e.repeat(r, () => Mi(e));
|
|
2618
|
+
return { scriptDefId: t, playerCount: n, started: !0, timestamp: i, actors: a, extra: e.rest() };
|
|
2619
|
+
}, write: (e, { scriptDefId: t, playerCount: n, started: r, timestamp: i, actors: a, extra: s }) => {
|
|
2620
|
+
e.int(t).int(n), r ? e.int(a.length).string(i).each(a, (o) => Ei(e, o)) : e.int(-1), e.raw(s);
|
|
2621
|
+
} });
|
|
2622
|
+
function Mi(e) {
|
|
2623
|
+
const t = e.string("actorId"), n = e.int("type"), r = n === Mn, i = r ? e.string("defName") : null, a = r ? null : e.int("defId");
|
|
2624
|
+
return { actorId: t, type: n, defId: a, defName: i, state: e.int("state"), visible: e.int("visible") === 1, requireClick: e.int("requireClick") === 1, pathName: e.string("pathName"), swfState: e.string("swfState") };
|
|
2625
|
+
}
|
|
2626
|
+
function Ei(e, t) {
|
|
2627
|
+
e.string(t.actorId).int(t.type), t.type === Mn ? e.string(t.defName ?? "") : e.int(t.defId ?? 0), e.int(t.state).int(t.visible ? 1 : 0).int(t.requireClick ? 1 : 0).string(t.pathName).string(t.swfState);
|
|
2628
|
+
}
|
|
2629
|
+
l({ name: "quest.treasure", description: "A treasure chest offers the player its prize.", direction: "toClient", command: "qatt", read: (e) => ({ actorId: e.string("actorId"), prize: e.int("prize"), value: e.int("value"), color: e.int("color"), popup: e.int("popup") }), write: (e, { actorId: t, prize: n, value: r, color: i, popup: a }) => e.string(t).int(n).int(r).int(i).int(a) }), l({ name: "quest.xp", description: "The player earned adventure experience.", direction: "toClient", command: "quxp", read: (e) => ({ earned: e.int("earned"), totalXp: e.int("totalXp"), previousLevel: e.int("previousLevel"), level: e.int("level"), levelProgress: e.number("levelProgress"), actorId: e.string("actorId") }), write: (e, { earned: t, totalXp: n, previousLevel: r, level: i, levelProgress: a, actorId: s }) => e.int(t).int(n).int(r).int(i).number(a).string(s) }), l({ name: "quest.level-up", description: "A player in the adventure levelled up.", direction: "toClient", command: "qulu", read: (e) => ({ userId: e.int("userId"), level: e.int("level") }), write: (e, { userId: t, level: n }) => e.int(t).int(n) }), l({ name: "quest.player-left", description: "A player left the adventure.", direction: "toClient", command: "qplq", read: (e) => ({ userId: e.int("userId"), avatarName: e.string("avatarName") }), write: (e, { userId: t, avatarName: n }) => e.int(t).string(n) });
|
|
2630
|
+
function Gt(e, t, n) {
|
|
2631
|
+
return l({ name: e, description: n, direction: "toClient", command: t, read: (r) => {
|
|
2632
|
+
const i = r.int("count"), a = r.int("popupType"), s = r.repeat(i, () => ({ prize: r.int("prize"), value: r.int("value"), color: r.int("color") }));
|
|
2633
|
+
return { popupType: a, gifts: s };
|
|
2634
|
+
}, write: (r, { popupType: i, gifts: a }) => r.int(a.length).int(i).each(a, ({ prize: s, value: o, color: d }) => r.int(s).int(o).int(d)) });
|
|
2635
|
+
}
|
|
2636
|
+
Gt("quest.rewards", "qpgift", "The adventure’s reward screen opens with its gifts."), Gt("quest.player-rewards", "qpgiftplr", "The player’s own reward screen opens with its gifts."), l({ name: "quest.award", description: "The adventure awards a stat or achievement.", direction: "toClient", command: "qaward", read: (e) => ({ userVarId: e.int("userVarId"), value: e.int("value") }), write: (e, { userVarId: t, value: n }) => e.int(t).int(n) }), l({ name: "quest.exit-by-type", description: "The server sends the player out of the adventure.", direction: "toClient", command: "qxt", read: (e) => ({ exitType: e.string("exitType") }), write: (e, { exitType: t }) => e.string(t) }), l({ name: "quest.bundle", description: "Several adventure messages packed into one.", direction: "toClient", command: "qqm", read: (e) => {
|
|
2637
|
+
const t = e.string("payload"), n = new gi(wi(mi(t))), r = n.readShort();
|
|
2638
|
+
return { messages: Array.from({ length: Math.max(0, r) }, () => {
|
|
2639
|
+
const i = n.readShort(), a = n.readUTF(), s = Array.from({ length: Math.max(0, i - 1) }, () => n.readUTF());
|
|
2640
|
+
return { command: a, args: s };
|
|
2641
|
+
}), extra: e.rest() };
|
|
2642
|
+
}, write: (e, { messages: t, extra: n }) => {
|
|
2643
|
+
const r = new fi().writeShort(t.length);
|
|
2644
|
+
for (const { command: i, args: a } of t) r.writeShort(a.length + 1).writeUTF(i), a.forEach((s) => r.writeUTF(s));
|
|
2645
|
+
e.string(pi(yi(r.toBytes()))).raw(n);
|
|
2646
|
+
} }), l({ name: "quest.actor-spawned", description: "An actor appears in the adventure, such as dropped treasure.", direction: "toClient", command: "qspn", read: (e) => {
|
|
2647
|
+
const t = e.string("spawnedFrom"), n = e.string("actorId"), r = e.int("type"), i = e.int("defId");
|
|
2648
|
+
let a = null, s = null;
|
|
2649
|
+
if (r === Si) {
|
|
2650
|
+
const o = e.int("subType");
|
|
2651
|
+
a = { subType: o, denDefId: null, itemDefId: null, color: null, amount: null }, o === W.denItem ? a.denDefId = e.int("denDefId") : o === W.clothing ? (a.itemDefId = e.int("itemDefId"), a.color = e.int("color")) : (o === W.gems || o === W.crystals) && (a.amount = e.int("amount"));
|
|
2652
|
+
} else Ci.includes(r) && (s = { x: e.number("spawnOffsetX"), y: e.number("spawnOffsetY") });
|
|
2653
|
+
return { spawnedFrom: t, actorId: n, type: r, defId: i, dropped: a, spawnOffset: s, extra: e.rest() };
|
|
2654
|
+
}, write: (e, { spawnedFrom: t, actorId: n, type: r, defId: i, dropped: a, spawnOffset: s, extra: o }) => {
|
|
2655
|
+
e.string(t).string(n).int(r).int(i), a ? (e.int(a.subType), a.subType === W.denItem ? e.int(a.denDefId ?? 0) : a.subType === W.clothing ? e.int(a.itemDefId ?? 0).int(a.color ?? 0) : (a.subType === W.gems || a.subType === W.crystals) && e.int(a.amount ?? 0)) : s && e.number(s.x).number(s.y), e.raw(o);
|
|
2656
|
+
} }), l({ name: "quest.actor-moved", description: "An adventure actor moved.", direction: "toClient", command: "qau", read: (e) => ({ actorId: e.string("actorId"), x: e.int("x"), y: e.int("y"), velocity: e.int("velocity"), seekType: e.int("seekType"), nearestX: e.int("nearestX"), nearestY: e.int("nearestY") }), write: (e, { actorId: t, x: n, y: r, velocity: i, seekType: a, nearestX: s, nearestY: o }) => e.string(t).int(n).int(r).int(i).int(a).int(s).int(o) }), l({ name: "quest.actor-position-report", description: "The client reports where an adventure actor it moves is.", direction: "toServer", command: "qau", read: (e) => ({ actorId: e.string("actorId"), x: e.int("x"), y: e.int("y"), velocity: e.int("velocity"), seekType: e.int("seekType"), nearestX: e.int("nearestX"), nearestY: e.int("nearestY") }), write: (e, { actorId: t, x: n, y: r, velocity: i, seekType: a, nearestX: s, nearestY: o }) => e.string(t).int(n).int(r).int(i).int(a).int(s).int(o) }), l({ name: "quest.actor-seek", description: "An adventure actor starts seeking a player, path or plant.", direction: "toClient", command: "qas", read: (e) => ({ actorId: e.string("actorId"), seekType: e.int("seekType"), userId: e.int("userId") }), write: (e, { actorId: t, seekType: n, userId: r }) => e.string(t).int(n).int(r) }), l({ name: "quest.actor-seek-request", description: "The client asks for an adventure actor to seek.", direction: "toServer", command: "qas", read: (e) => ({ actorId: e.string("actorId"), seekType: e.int("seekType") }), write: (e, { actorId: t, seekType: n }) => e.string(t).int(n) }), l({ name: "quest.actor-untrigger", description: "The player left an adventure actor’s area.", direction: "toServer", command: "qaut", read: (e) => ({ actorId: e.string("actorId") }), write: (e, { actorId: t }) => e.string(t) }), l({ name: "quest.actor-health", description: "An adventure actor was hit, or missed.", direction: "toClient", command: "qahs", read: (e) => {
|
|
2657
|
+
const t = e.string("actorId"), n = e.int("healthPercent"), r = n === -1, i = !r && e.remaining > 0 ? e.int("damage") : null, a = i !== null && e.remaining > 0 ? e.int("fierce") === 1 : null;
|
|
2658
|
+
return { actorId: t, healthPercent: n, missed: r, damage: i, fierce: a, extra: e.rest() };
|
|
2659
|
+
}, write: (e, { actorId: t, healthPercent: n, damage: r, fierce: i, extra: a }) => {
|
|
2660
|
+
e.string(t).int(n), r !== null && (e.int(r), i !== null && e.int(i ? 1 : 0)), e.raw(a);
|
|
2661
|
+
} }), l({ name: "quest.actor-died", description: "An adventure actor was defeated or used up.", direction: "toClient", command: "qad", read: (e) => ({ actorId: e.string("actorId"), damage: e.int("damage"), moved: e.string("moved") === "1", x: e.int("x"), y: e.int("y"), otherActorId: e.string("otherActorId") }), write: (e, { actorId: t, damage: n, moved: r, x: i, y: a, otherActorId: s }) => e.string(t).int(n).flag(r).int(i).int(a).string(s) }), l({ name: "quest.actor-restored", description: "An adventure actor came back.", direction: "toClient", command: "qrestore", read: (e) => ({ actorId: e.string("actorId"), healthPercent: e.int("healthPercent") }), write: (e, { actorId: t, healthPercent: n }) => e.string(t).int(n) });
|
|
2662
|
+
function Xt(e, t, n, r) {
|
|
2663
|
+
return l({ name: e, description: n, direction: "toClient", command: t, read: (i) => {
|
|
2664
|
+
const a = i.int("command");
|
|
2665
|
+
if (a !== qi.setState || i.remaining < 2) return { command: a, actorId: null, state: null, visible: null, requireClick: null, args: i.rest() };
|
|
2666
|
+
const s = i.string("actorId"), o = i.int("state"), d = !r && i.remaining >= 2, c = d ? i.string("visible") === "1" : null, h = d ? i.string("requireClick") === "1" : null;
|
|
2667
|
+
return { command: a, actorId: s, state: o, visible: c, requireClick: h, args: i.rest() };
|
|
2668
|
+
}, write: (i, a) => {
|
|
2669
|
+
i.int(a.command), a.actorId !== null && a.state !== null && (i.string(a.actorId).int(a.state), a.visible !== null && a.requireClick !== null && i.flag(a.visible).flag(a.requireClick)), i.raw(a.args);
|
|
2670
|
+
} });
|
|
2671
|
+
}
|
|
2672
|
+
Xt("quest.command", "qcmd", "The adventure’s script tells the client to do something, such as change an actor.", !1), Xt("quest.variable", "qcmdVT", "The adventure’s script sets one of its variables.", !0), l({ name: "quest.actor-swf-state", description: "An adventure actor’s animation changes state.", direction: "toClient", command: "qswfs", read: (e) => ({ actorId: e.string("actorId"), swfState: e.string("swfState") }), write: (e, { actorId: t, swfState: n }) => e.string(t).string(n) }), l({ name: "quest.actor-path", description: "An adventure actor walks another path.", direction: "toClient", command: "qsp", read: (e) => ({ actorId: e.string("actorId"), pathName: e.string("pathName") }), write: (e, { actorId: t, pathName: n }) => e.string(t).string(n) }), l({ name: "quest.actor-icon", description: "An adventure actor’s icon shows or hides.", direction: "toClient", command: "qicon", read: (e) => ({ actorId: e.string("actorId"), showing: e.string("showing") === "1" }), write: (e, { actorId: t, showing: n }) => e.string(t).flag(n) }), l({ name: "quest.moved-items", description: "Where players moved the adventure’s items.", direction: "toClient", command: "qmi", read: (e) => ({ items: e.repeat(Math.floor(e.remaining / 5), () => ({ actorId: e.string("actorId"), innerRadius: e.int("innerRadius"), outerRadius: e.int("outerRadius"), x: e.number("x"), y: e.number("y") })), extra: e.rest() }), write: (e, { items: t, extra: n }) => e.each(t, (r) => e.string(r.actorId).int(r.innerRadius).int(r.outerRadius).number(r.x).number(r.y)).raw(n) });
|
|
2673
|
+
const ne = { askToDrop: 0, pickedUp: 1, droppedAt: 3, placedAt: 4 };
|
|
2674
|
+
l({ name: "quest.pick-up-result", description: "The server says what came of picking up an adventure item.", direction: "toClient", command: "qpup", read: (e) => {
|
|
2675
|
+
const t = e.int("result"), n = { result: t, heldItem: null, actorId: null, userId: null, x: null, y: null, innerRadius: null, outerRadius: null, dropperUserId: null };
|
|
2676
|
+
if (t === ne.askToDrop) return { ...n, heldItem: e.string("heldItem"), extra: e.rest() };
|
|
2677
|
+
if (t !== ne.pickedUp && t !== ne.droppedAt && t !== ne.placedAt) return { ...n, extra: e.rest() };
|
|
2678
|
+
const r = { ...n, actorId: e.string("actorId"), userId: e.int("userId") };
|
|
2679
|
+
return t !== ne.pickedUp && (r.x = e.number("x"), r.y = e.number("y")), t === ne.placedAt && (r.innerRadius = e.int("innerRadius"), r.outerRadius = e.int("outerRadius"), r.dropperUserId = e.int("dropperUserId")), { ...r, extra: e.rest() };
|
|
2680
|
+
}, write: (e, t) => {
|
|
2681
|
+
e.int(t.result), t.heldItem !== null && e.string(t.heldItem), t.actorId !== null && e.string(t.actorId).int(t.userId ?? 0), t.x !== null && t.y !== null && e.number(t.x).number(t.y), t.innerRadius !== null && e.int(t.innerRadius).int(t.outerRadius ?? 0).int(t.dropperUserId ?? 0), e.raw(t.extra);
|
|
2682
|
+
} }), l({ name: "quest.give-item", description: "The server hands the player an adventure item to pick up.", direction: "toClient", command: "qgi", read: (e) => ({ actorId: e.string("actorId") }), write: (e, { actorId: t }) => e.string(t) });
|
|
2683
|
+
function Yt(e, t, n, r) {
|
|
2684
|
+
return l({ name: e, description: n, direction: "toClient", command: t, read: (i) => {
|
|
2685
|
+
const a = i.int("userId"), s = i.int("healthPercent"), o = i.int("change"), d = i.int("health"), c = i.int("maxHealth"), h = r && i.remaining >= 2, m = h ? i.int("x") : null, u = h ? i.int("y") : null;
|
|
2686
|
+
return { userId: a, healthPercent: s, change: o, health: d, maxHealth: c, x: m, y: u, extra: i.rest() };
|
|
2687
|
+
}, write: (i, { userId: a, healthPercent: s, change: o, health: d, maxHealth: c, x: h, y: m, extra: u }) => {
|
|
2688
|
+
i.int(a).int(s).int(o).int(d).int(c), h !== null && m !== null && i.int(h).int(m), i.raw(u);
|
|
2689
|
+
} });
|
|
2690
|
+
}
|
|
2691
|
+
Yt("quest.health", "quhp", "A player’s health in the adventure changed.", !1), Yt("quest.respawned", "qrspn", "A player came back to life in the adventure.", !0), l({ name: "quest.player-dead", description: "A player in the adventure was defeated.", direction: "toClient", command: "qpd", read: (e) => ({ userId: e.int("userId") }), write: (e, { userId: t }) => e.int(t) }), l({ name: "quest.crystals", description: "The crystals the player gathered in the adventure changed.", direction: "toClient", command: "qporbs", read: (e) => ({ crystals: e.int("crystals") }), write: (e, { crystals: t }) => e.int(t) }), l({ name: "quest.exited", description: "The server answers the player leaving the adventure.", direction: "toClient", command: "qx", read: (e) => ({ extra: e.rest() }), write: (e, { extra: t }) => e.raw(t) }), l({ name: "quest.seed-given", description: "The player’s seed count changed.", direction: "toClient", command: "qseed", read: (e) => ({ defId: e.int("defId"), count: e.int("count"), max: e.int("max") }), write: (e, { defId: t, count: n, max: r }) => e.int(t).int(n).int(r) }), l({ name: "quest.seed-planted", description: "A seed was planted in the adventure, or refused.", direction: "toClient", command: "qps", read: (e) => {
|
|
2692
|
+
const t = { planted: e.flag("planted"), userName: e.string("userName"), plant: null };
|
|
2693
|
+
return t.planted ? { ...t, plant: { actorName: e.string("actorName"), defId: e.int("defId"), x: e.int("x"), y: e.int("y"), launcherUserId: e.int("launcherUserId") } } : t;
|
|
2694
|
+
}, write: (e, { planted: t, userName: n, plant: r }) => {
|
|
2695
|
+
e.flag(t).string(n), t && r && e.string(r.actorName).int(r.defId).int(r.x).int(r.y).int(r.launcherUserId);
|
|
2696
|
+
} }), l({ name: "quest.plant-ate", description: "A planted seed’s plant ate a phantom.", direction: "toClient", command: "qpa", read: (e) => ({ plantActorId: e.string("plantActorId"), phantomActorId: e.string("phantomActorId") }), write: (e, { plantActorId: t, phantomActorId: n }) => e.string(t).string(n) }), l({ name: "quest.plant-eat-recoil", description: "A planted seed’s plant recoils after eating.", direction: "toClient", command: "qepr", read: (e) => ({ actorId: e.string("actorId") }), write: (e, { actorId: t }) => e.string(t) }), l({ name: "quest.volume-progress", description: "An interactive volume’s progress changed.", direction: "toClient", command: "qviu", read: (e) => ({ actorId: e.string("actorId"), progress: e.int("progress") }), write: (e, { actorId: t, progress: n }) => e.string(t).int(n) }), l({ name: "quest.stats-update", description: "The player’s own attack and defence range in the adventure changed.", direction: "toClient", command: "qusu", read: (e) => ({ attackBase: e.int("attackBase"), attackMax: e.int("attackMax"), defenseBase: e.int("defenseBase"), defenseMax: e.int("defenseMax") }), write: (e, { attackBase: t, attackMax: n, defenseBase: r, defenseMax: i }) => e.int(t).int(n).int(r).int(i) }), l({ name: "quest.avatar-switch", description: "A player is drawn disguised as a phantom or NPC, or their disguise is taken off.", direction: "toClient", command: "qavsw", read: (e) => {
|
|
2697
|
+
const t = e.int("avatarRefId");
|
|
2698
|
+
return { avatarRefId: t === -1 ? null : t, userId: e.int("userId") };
|
|
2699
|
+
}, write: (e, { avatarRefId: t, userId: n }) => e.int(t ?? -1).int(n) }), l({ name: "room.join-request", description: "The player asks to join a room.", direction: "toServer", command: "rj", read: (e) => ({ target: e.string("target"), confirmLanguageChange: e.flag("confirmLanguageChange"), invisible: e.flag("invisible"), joinType: e.string("joinType") }), write: (e, { target: t, confirmLanguageChange: n, invisible: r, joinType: i }) => e.string(t).flag(n).flag(r).string(i) });
|
|
2700
|
+
const ji = 8;
|
|
2701
|
+
l({ name: "room.join-result", description: "The server says whether the player joined, and describes the room.", direction: "toClient", command: "rj", read: (e) => {
|
|
2702
|
+
const t = e.flag("joined");
|
|
2703
|
+
if (!t) {
|
|
2704
|
+
const i = e.remaining > 0 ? e.string("error") : null;
|
|
2705
|
+
return { joined: t, joinedRoom: null, details: null, error: i, extra: e.rest() };
|
|
2706
|
+
}
|
|
2707
|
+
const n = { name: e.string("name"), id: e.int("id"), users: e.int("users"), maxUsers: e.int("maxUsers"), spectators: e.int("spectators"), maxSpectators: e.int("maxSpectators"), isPrivate: e.flag("isPrivate"), isGame: e.flag("isGame"), isLimbo: e.flag("isLimbo") }, r = e.remaining >= ji ? Di(e) : null;
|
|
2708
|
+
return { joined: t, joinedRoom: n, details: r, error: null, extra: e.rest() };
|
|
2709
|
+
}, write: (e, { joined: t, joinedRoom: n, details: r, error: i, extra: a }) => {
|
|
2710
|
+
e.flag(t), t && n ? (e.string(n.name).int(n.id).int(n.users).int(n.maxUsers).int(n.spectators).int(n.maxSpectators).flag(n.isPrivate).flag(n.isGame).flag(n.isLimbo), r && (e.flag(r.isTemp).flag(r.isSubRoom).string(r.displayName).int(r.displayNameId).int(r.perUserAvId).int(r.activePetInvId).int(r.language).int(r.customMusicDef), r.shardId !== null && e.int(r.shardId))) : !t && i !== null && e.string(i), e.raw(a);
|
|
2711
|
+
} });
|
|
2712
|
+
function Di(e) {
|
|
2713
|
+
return { isTemp: e.flag("isTemp"), isSubRoom: e.flag("isSubRoom"), displayName: e.string("displayName"), displayNameId: e.int("displayNameId"), perUserAvId: e.int("perUserAvId"), activePetInvId: e.int("activePetInvId"), language: e.int("language"), customMusicDef: e.int("customMusicDef"), shardId: e.remaining > 0 ? e.int("shardId") : null };
|
|
2714
|
+
}
|
|
2715
|
+
l({ name: "room.properties", description: "The server says which room to load, and how.", direction: "toClient", command: "rp", read: (e) => ({ pathName: e.string("pathName"), environmentType: e.int("environmentType"), roomType: e.int("roomType"), secondaryDefId: e.int("secondaryDefId"), zoom: e.int("zoom"), roomDefId: e.int("roomDefId"), customData: e.remaining > 0 ? e.string("customData") : null }), write: (e, t) => {
|
|
2716
|
+
e.string(t.pathName).int(t.environmentType).int(t.roomType).int(t.secondaryDefId).int(t.zoom).int(t.roomDefId), t.customData !== null && e.string(t.customData);
|
|
2717
|
+
} }), l({ name: "room.leave-request", description: "The player leaves an in room game’s room.", direction: "toServer", command: "rl", read: (e) => ({ roomId: e.int("roomId") }), write: (e, { roomId: t }) => e.int(t) }), l({ name: "room.list", description: "The server lists the rooms the client knows.", direction: "toClient", command: "rl", read: (e) => ({ rooms: e.repeat(e.int("count"), () => ({ id: e.int("id"), name: e.string("name"), maxUsers: e.int("maxUsers"), isTemp: e.flag("isTemp"), isGame: e.flag("isGame"), users: e.int("users") })) }), write: (e, { rooms: t }) => e.int(t.length).each(t, (n) => e.int(n.id).string(n.name).int(n.maxUsers).flag(n.isTemp).flag(n.isGame).int(n.users)) }), oe({ name: "session.version-check", description: "The client says which SmartFox version it speaks.", direction: "toServer", type: "sys", command: "verChk", read: (e) => {
|
|
2718
|
+
var t, n;
|
|
2719
|
+
return { version: ((n = (t = e.body) == null ? void 0 : t.child("ver")) == null ? void 0 : n.attribute("v")) ?? "" };
|
|
2720
|
+
}, write: ({ version: e }) => [new B("ver", { attributes: [R.create("v", e)], selfClosing: !0, trailing: " " })] }), oe({ name: "session.random-key-request", description: "The client asks for the key it signs its login with.", direction: "toServer", type: "sys", command: "rndK", read: () => ({}), write: () => [] }), oe({ name: "session.random-key", description: "The server gives the key the login is signed with.", direction: "toClient", type: "sys", command: "rndK", read: (e) => {
|
|
2721
|
+
var t, n;
|
|
2722
|
+
return { key: ((n = (t = e.body) == null ? void 0 : t.child("k")) == null ? void 0 : n.textContent) ?? "" };
|
|
2723
|
+
}, write: ({ key: e }) => [new B("k", { children: [new ee(e)] })] }), oe({ name: "session.login", description: "The client signs in to a zone with its auth token.", direction: "toServer", type: "sys", command: "login", read: (e) => {
|
|
2724
|
+
var t, n, r;
|
|
2725
|
+
const i = (t = e.body) == null ? void 0 : t.child("login");
|
|
2726
|
+
return { zone: (i == null ? void 0 : i.attribute("z")) ?? "", nick: ((n = i == null ? void 0 : i.child("nick")) == null ? void 0 : n.textContent) ?? "", password: ((r = i == null ? void 0 : i.child("pword")) == null ? void 0 : r.textContent) ?? "" };
|
|
2727
|
+
}, write: ({ zone: e, nick: t, password: n }) => [new B("login", { attributes: [R.create("z", e)], children: [new B("nick", { children: [new ee(t)] }), new B("pword", { children: [new ee(n)] })] })] });
|
|
2728
|
+
const ie = { clothing: 1e3, denItems: 1030, denRooms: 1040, currencyExchange: 1051, diamondShop: 1054, combined: 1060 }, Oi = [ie.clothing, ie.denItems, ie.denRooms, ie.currencyExchange, ie.diamondShop];
|
|
2729
|
+
l({ name: "shop.list-request", description: "The player asks for a shop’s contents.", direction: "toServer", command: "gl", read: (e) => ({ listId: e.int("listId") }), write: (e, { listId: t }) => e.int(t) }), l({ name: "shop.list", description: "The server sends a shop’s contents.", direction: "toClient", command: "gl", read: (e) => {
|
|
2730
|
+
const t = e.int("listId"), n = e.int("listType"), r = Oi.indexOf(n) !== -1;
|
|
2731
|
+
if (!r && n !== ie.combined) return { kind: "other", listId: t, listType: n, body: e.rest() };
|
|
2732
|
+
const i = { listId: t, listType: n, titleStrId: e.string("titleStrId"), unused: e.string("unused"), diamondBundle: e.string("diamondBundle") !== "", diamondCost: at(e.string("diamondCost")) }, a = e.int("count");
|
|
2733
|
+
return r ? { ...i, kind: "items", defIds: e.repeat(a, () => e.int("defId")) } : { ...i, kind: "combined", groups: $i(e, a) };
|
|
2734
|
+
}, write: (e, t) => {
|
|
2735
|
+
if (e.int(t.listId).int(t.listType), t.kind === "other") {
|
|
2736
|
+
e.raw(t.body);
|
|
2737
|
+
return;
|
|
2738
|
+
}
|
|
2739
|
+
if (e.string(t.titleStrId).string(t.unused).string(t.diamondBundle ? "1" : "").int(t.diamondCost), t.kind === "items") {
|
|
2740
|
+
e.int(t.defIds.length).each(t.defIds, (n) => e.int(n));
|
|
2741
|
+
return;
|
|
2742
|
+
}
|
|
2743
|
+
e.int(t.groups.length), t.groups.length !== 0 && (e.string(t.groups.map((n) => n.listType).join(",")).string(t.groups.map((n) => n.defIds.length).join(",")), t.groups.forEach((n) => n.defIds.forEach((r) => e.int(r))));
|
|
2744
|
+
} });
|
|
2745
|
+
function $i(e, t) {
|
|
2746
|
+
if (t === 0) return [];
|
|
2747
|
+
const n = e.string("groupTypes").split(","), r = e.string("groupCounts").split(",");
|
|
2748
|
+
return n.map((i, a) => ({ listType: at(i), defIds: e.repeat(at(r[a] ?? ""), () => e.int("defId")) }));
|
|
2749
|
+
}
|
|
2750
|
+
function at(e) {
|
|
2751
|
+
const t = Number(e);
|
|
2752
|
+
return Number.isInteger(t) ? t : 0;
|
|
2753
|
+
}
|
|
2754
|
+
l({ name: "shop.den-shop-update-request", description: "The player adds, reprices or removes items in their own den shop.", direction: "toServer", command: "dsu", read: (e) => ({ storeInvId: e.int("storeInvId"), state: e.string("state"), upserts: e.repeat(e.int("upsertCount"), () => ({ itemKind: e.int("itemKind"), invIdx: e.int("invIdx"), currencyType: e.int("currencyType"), cost: e.int("cost") })), removals: e.repeat(e.int("removeCount"), () => ({ itemKind: e.int("itemKind"), invIdx: e.int("invIdx") })) }), write: (e, { storeInvId: t, state: n, upserts: r, removals: i }) => {
|
|
2755
|
+
e.int(t).string(n), e.int(r.length).each(r, (a) => e.int(a.itemKind).int(a.invIdx).int(a.currencyType).int(a.cost)), e.int(i.length).each(i, (a) => e.int(a.itemKind).int(a.invIdx));
|
|
2756
|
+
} }), l({ name: "shop.den-shop-update-result", description: "The server answers a change to the player’s own den shop.", direction: "toClient", command: "dsu", read: (e) => {
|
|
2757
|
+
const t = e.string("ok") === "1";
|
|
2758
|
+
return { ok: t, state: t ? e.string("state") : "" };
|
|
2759
|
+
}, write: (e, { ok: t, state: n }) => {
|
|
2760
|
+
e.string(t ? "1" : "0"), t && e.string(n);
|
|
2761
|
+
} }), l({ name: "shop.den-shop-info-request", description: "The player asks to see a den shop’s listings.", direction: "toServer", command: "dsi", read: (e) => ({ userName: e.string("userName"), storeInvId: e.int("storeInvId") }), write: (e, { userName: t, storeInvId: n }) => e.string(t).int(n) }), l({ name: "shop.den-shop-info", description: "The server sends a den shop’s listings.", direction: "toClient", command: "dsi", read: (e) => {
|
|
2762
|
+
const t = e.string("ok") === "1", n = e.int("itemCount");
|
|
2763
|
+
if (!t || n < 0) return { ok: t, itemCount: -1, state: "", items: [] };
|
|
2764
|
+
const r = e.string("state");
|
|
2765
|
+
return { ok: t, itemCount: n, state: r, items: e.rest() };
|
|
2766
|
+
}, write: (e, t) => {
|
|
2767
|
+
e.string(t.ok ? "1" : "0").int(t.itemCount), t.ok && t.itemCount >= 0 && e.string(t.state).raw(t.items);
|
|
2768
|
+
} }), l({ name: "shop.den-shop-buy-request", description: "The player buys an item from a den shop.", direction: "toServer", command: "dsb", read: (e) => ({ userName: e.string("userName"), shopInvIdx: e.int("shopInvIdx"), state: e.string("state"), itemKind: e.int("itemKind"), invIdx: e.int("invIdx"), currencyType: e.int("currencyType"), cost: e.int("cost") }), write: (e, { userName: t, shopInvIdx: n, state: r, itemKind: i, invIdx: a, currencyType: s, cost: o }) => e.string(t).int(n).string(r).int(i).int(a).int(s).int(o) }), l({ name: "shop.den-shop-buy-result", description: "The server answers a den shop purchase.", direction: "toClient", command: "dsb", read: (e) => {
|
|
2769
|
+
const t = e.int("status");
|
|
2770
|
+
if (t !== 1) return { status: t, ownerUserName: "", storeInvId: -1, rest: [] };
|
|
2771
|
+
const n = e.string("ownerUserName"), r = e.int("storeInvId");
|
|
2772
|
+
return { status: t, ownerUserName: n, storeInvId: r, rest: e.rest() };
|
|
2773
|
+
}, write: (e, t) => {
|
|
2774
|
+
e.int(t.status), t.status === 1 && e.string(t.ownerUserName).int(t.storeInvId).raw(t.rest);
|
|
2775
|
+
} }), l({ name: "trade.list-request", description: "The player asks for someone’s trade list.", direction: "toServer", command: "tl", read: (e) => ({ userName: e.string("userName") }), write: (e, { userName: t }) => e.string(t) }), l({ name: "trade.list", description: "The server sends someone’s trade list.", direction: "toClient", command: "tl", read: (e) => ({ userName: e.string("userName"), clothing: e.repeat(e.int("clothing"), () => ({ defId: e.int("defId"), invIdx: e.int("invIdx"), color: e.int("color") })), den: e.repeat(e.int("den"), () => {
|
|
2776
|
+
const t = e.int("defId"), n = e.int("invIdx");
|
|
2777
|
+
return { defId: t, invIdx: n, ...ut(e) };
|
|
2778
|
+
}), pets: e.repeat(e.int("pets"), () => {
|
|
2779
|
+
const t = e.int("defId"), n = e.int("invIdx"), r = e.number("createdAt"), i = mt(e), a = e.string("name");
|
|
2780
|
+
return { defId: t, invIdx: n, createdAt: r, bits: i, name: a, ...gt(e) };
|
|
2781
|
+
}) }), write: (e, { userName: t, clothing: n, den: r, pets: i }) => {
|
|
2782
|
+
e.string(t).int(n.length), n.forEach((a) => e.int(a.defId).int(a.invIdx ?? -1).int(a.color)), e.int(r.length), r.forEach((a) => {
|
|
2783
|
+
e.int(a.defId).int(a.invIdx ?? -1), ht(e, a);
|
|
2784
|
+
}), e.int(i.length), i.forEach((a) => {
|
|
2785
|
+
e.int(a.defId).int(a.invIdx).number(a.createdAt), pt(e, a), e.string(a.name), ft(e, a);
|
|
2786
|
+
});
|
|
2787
|
+
} }), l({ name: "trade.list-change", description: "The player changes their trade list.", direction: "toServer", command: "ts", read: (e) => ({ removed: e.repeat(e.int("removed"), () => We(e)), added: e.repeat(e.int("added"), () => We(e)) }), write: (e, { removed: t, added: n }) => {
|
|
2788
|
+
e.int(t.length), t.forEach((r) => e.int(r.itemType).int(r.invIdx)), e.int(n.length), n.forEach((r) => e.int(r.itemType).int(r.invIdx));
|
|
2789
|
+
} }), l({ name: "trade.busy", description: "The player starts or stops being busy with a trade.", direction: "toServer", command: "tb", read: (e) => ({ busy: e.flag("busy") }), write: (e, { busy: t }) => e.flag(t) }), l({ name: "trade.action", description: "The player asks for a trade, answers one, withdraws or confirms.", direction: "toServer", command: "ti", read: (e) => {
|
|
2790
|
+
const t = e.int("action");
|
|
2791
|
+
switch (t) {
|
|
2792
|
+
case 0: {
|
|
2793
|
+
const n = e.string("userName"), r = e.int("itemType"), i = e.int("invIdx"), a = e.int("clothing"), s = e.int("den"), o = e.int("audio"), d = e.int("pets");
|
|
2794
|
+
return { action: "request", userName: n, itemType: r, invIdx: i, clothing: e.repeat(a, () => e.int("invIdx")), den: e.repeat(s + o, () => e.int("invIdx")), audio: o, pets: e.repeat(d, () => e.int("invIdx")) };
|
|
2795
|
+
}
|
|
2796
|
+
case 1:
|
|
2797
|
+
return { action: "respond", response: e.int("response") };
|
|
2798
|
+
case 2:
|
|
2799
|
+
return { action: "cancel" };
|
|
2800
|
+
case 3:
|
|
2801
|
+
return { action: "confirm", confirm: e.flag("confirm") };
|
|
2802
|
+
default:
|
|
2803
|
+
throw new x(`trade.action: unknown action ${t}`, "PACKET_FIELD");
|
|
2804
|
+
}
|
|
2805
|
+
}, write: (e, t) => {
|
|
2806
|
+
switch (t.action) {
|
|
2807
|
+
case "request":
|
|
2808
|
+
e.int(0).string(t.userName).int(t.itemType).int(t.invIdx).int(t.clothing.length).int(t.den.length - t.audio).int(t.audio).int(t.pets.length), [...t.clothing, ...t.den, ...t.pets].forEach((n) => e.int(n));
|
|
2809
|
+
return;
|
|
2810
|
+
case "respond":
|
|
2811
|
+
e.int(1).int(t.response);
|
|
2812
|
+
return;
|
|
2813
|
+
case "cancel":
|
|
2814
|
+
e.int(2);
|
|
2815
|
+
return;
|
|
2816
|
+
case "confirm":
|
|
2817
|
+
e.int(3).int(t.confirm ? 1 : 0);
|
|
2818
|
+
return;
|
|
2819
|
+
}
|
|
2820
|
+
} }), l({ name: "trade.result", description: "Someone offers a trade, or a trade is accepted, done or ends.", direction: "toClient", command: "ti", read: (e) => {
|
|
2821
|
+
const t = e.int("status");
|
|
2822
|
+
switch (t) {
|
|
2823
|
+
case 0:
|
|
2824
|
+
return { kind: "offer", status: 0, offer: Pi(e) };
|
|
2825
|
+
case 1: {
|
|
2826
|
+
if (e.int("stage") === 0) return { kind: "confirm", status: 1 };
|
|
2827
|
+
const n = e.repeat(e.int("received"), () => Ui(e)), r = e.repeat(e.int("removed"), () => We(e));
|
|
2828
|
+
return { kind: "completed", status: 1, received: n, removed: r, extra: e.rest() };
|
|
2829
|
+
}
|
|
2830
|
+
case 6:
|
|
2831
|
+
return { kind: "closed", status: 6, extra: e.rest() };
|
|
2832
|
+
case 7:
|
|
2833
|
+
return { kind: "different-server", status: 7, roomName: e.string("roomName"), extra: e.rest() };
|
|
2834
|
+
default:
|
|
2835
|
+
return { kind: "failed", status: t, userName: e.string("userName"), userNameModerationFlag: e.int("userNameModerationFlag"), extra: e.rest() };
|
|
2836
|
+
}
|
|
2837
|
+
}, write: (e, t) => {
|
|
2838
|
+
switch (e.int(t.status), t.kind) {
|
|
2839
|
+
case "offer":
|
|
2840
|
+
Li(e, t.offer);
|
|
2841
|
+
return;
|
|
2842
|
+
case "confirm":
|
|
2843
|
+
e.int(0);
|
|
2844
|
+
return;
|
|
2845
|
+
case "completed":
|
|
2846
|
+
e.int(1).int(t.received.length), t.received.forEach((n) => Fi(e, n)), e.int(t.removed.length), t.removed.forEach((n) => e.int(n.itemType).int(n.invIdx)), e.raw(t.extra);
|
|
2847
|
+
return;
|
|
2848
|
+
case "closed":
|
|
2849
|
+
e.raw(t.extra);
|
|
2850
|
+
return;
|
|
2851
|
+
case "different-server":
|
|
2852
|
+
e.string(t.roomName).raw(t.extra);
|
|
2853
|
+
return;
|
|
2854
|
+
case "failed":
|
|
2855
|
+
e.string(t.userName).int(t.userNameModerationFlag).raw(t.extra);
|
|
2856
|
+
return;
|
|
2857
|
+
}
|
|
2858
|
+
} });
|
|
2859
|
+
function Pi(e) {
|
|
2860
|
+
const t = e.string("userName"), n = e.int("userNameModerationFlag"), r = e.int("wantedKind"), i = e.int("wantedInvIdx"), a = e.int("clothing"), s = e.int("den"), o = e.int("pets");
|
|
2861
|
+
return { userName: t, userNameModerationFlag: n, wantedKind: r, wantedInvIdx: i, offered: { clothing: e.repeat(a, () => ({ defId: e.int("defId"), color: e.int("color"), invIdx: null })), den: e.repeat(s, () => ({ defId: e.int("defId"), invIdx: null, ...ut(e) })), pets: e.repeat(o, () => {
|
|
2862
|
+
const d = e.number("createdAt"), c = e.int("defId"), h = e.int("invIdx"), m = mt(e), u = gt(e);
|
|
2863
|
+
return { defId: c, invIdx: h, createdAt: d, bits: m, name: e.string("name"), ...u };
|
|
2864
|
+
}) } };
|
|
2865
|
+
}
|
|
2866
|
+
function Li(e, t) {
|
|
2867
|
+
const { clothing: n, den: r, pets: i } = t.offered;
|
|
2868
|
+
e.string(t.userName).int(t.userNameModerationFlag).int(t.wantedKind).int(t.wantedInvIdx).int(n.length).int(r.length).int(i.length), n.forEach((a) => e.int(a.defId).int(a.color)), r.forEach((a) => {
|
|
2869
|
+
e.int(a.defId), ht(e, a);
|
|
2870
|
+
}), i.forEach((a) => {
|
|
2871
|
+
e.number(a.createdAt).int(a.defId).int(a.invIdx), pt(e, a), ft(e, a), e.string(a.name);
|
|
2872
|
+
});
|
|
2873
|
+
}
|
|
2874
|
+
function Ui(e) {
|
|
2875
|
+
const t = e.int("type");
|
|
2876
|
+
switch (t) {
|
|
2877
|
+
case 0:
|
|
2878
|
+
return { type: "clothing", defId: e.int("defId"), invIdx: e.int("invIdx"), color: e.int("color") };
|
|
2879
|
+
case 1: {
|
|
2880
|
+
const n = e.int("invIdx");
|
|
2881
|
+
return { type: "den", defId: e.int("defId"), invIdx: n, ...ut(e) };
|
|
2882
|
+
}
|
|
2883
|
+
case 2: {
|
|
2884
|
+
const n = e.number("createdAt"), r = e.int("invIdx"), i = e.int("defId"), a = mt(e), s = gt(e);
|
|
2885
|
+
return { type: "pet", defId: i, invIdx: r, createdAt: n, bits: a, name: e.string("name"), ...s };
|
|
2886
|
+
}
|
|
2887
|
+
default:
|
|
2888
|
+
throw new x(`trade.result: unknown received item type ${t}`, "PACKET_FIELD");
|
|
2889
|
+
}
|
|
2890
|
+
}
|
|
2891
|
+
function Fi(e, t) {
|
|
2892
|
+
switch (t.type) {
|
|
2893
|
+
case "clothing":
|
|
2894
|
+
e.int(0).int(t.defId).int(t.invIdx ?? -1).int(t.color);
|
|
2895
|
+
return;
|
|
2896
|
+
case "den":
|
|
2897
|
+
e.int(1).int(t.invIdx ?? -1).int(t.defId), ht(e, t);
|
|
2898
|
+
return;
|
|
2899
|
+
case "pet":
|
|
2900
|
+
e.int(2).number(t.createdAt).int(t.invIdx).int(t.defId), pt(e, t), ft(e, t), e.string(t.name);
|
|
2901
|
+
return;
|
|
2902
|
+
}
|
|
2903
|
+
}
|
|
2904
|
+
function We(e) {
|
|
2905
|
+
return { itemType: e.int("itemType"), invIdx: e.int("invIdx") };
|
|
2906
|
+
}
|
|
2907
|
+
function ut(e) {
|
|
2908
|
+
return { version: e.int("version"), approved: e.string("approved") === "true", uniqueImageId: e.string("uniqueImageId"), creatorDbId: e.int("creatorDbId"), creatorUuid: e.string("creatorUuid") };
|
|
2909
|
+
}
|
|
2910
|
+
function ht(e, t) {
|
|
2911
|
+
e.int(t.version).string(t.approved ? "true" : "false").string(t.uniqueImageId).int(t.creatorDbId).string(t.creatorUuid);
|
|
2912
|
+
}
|
|
2913
|
+
function mt(e) {
|
|
2914
|
+
return [e.int("bits1"), e.int("bits2"), e.int("bits3")];
|
|
2915
|
+
}
|
|
2916
|
+
function pt(e, t) {
|
|
2917
|
+
e.int(t.bits[0]).int(t.bits[1]).int(t.bits[2]);
|
|
2918
|
+
}
|
|
2919
|
+
function gt(e) {
|
|
2920
|
+
return { traitDefId: e.int("traitDefId"), toyDefId: e.int("toyDefId"), foodDefId: e.int("foodDefId") };
|
|
2921
|
+
}
|
|
2922
|
+
function ft(e, t) {
|
|
2923
|
+
e.int(t.traitDefId).int(t.toyDefId).int(t.foodDefId);
|
|
2924
|
+
}
|
|
2925
|
+
l({ name: "world.room-count-request", description: "The player asks how many are in each room.", direction: "toServer", command: "rc", read: () => ({}), write: () => {
|
|
2926
|
+
} }), l({ name: "world.room-counts", description: "The server says how many are in each room.", direction: "toClient", command: "rc", read: (e) => ({ rooms: e.repeat(e.int("count"), () => ({ name: e.string("name"), users: e.int("users") })) }), write: (e, { rooms: t }) => e.int(t.length).each(t, ({ name: n, users: r }) => e.string(n).int(r)) }), l({ name: "world.shard-list-request", description: "The player asks for the list of shards.", direction: "toServer", command: "rm", read: () => ({}), write: () => {
|
|
2927
|
+
} });
|
|
2928
|
+
const _e = 4;
|
|
2929
|
+
l({ name: "world.shard-list", description: "The server lists the shards on each server node.", direction: "toClient", command: "rm", read: (e) => {
|
|
2930
|
+
const t = e.rest(), n = t[0];
|
|
2931
|
+
return n !== void 0 && En(n) ? { status: new fe(t, "world.shard-list").int("status"), nodes: [] } : { status: null, nodes: Bi(t) };
|
|
2932
|
+
}, write: (e, { status: t, nodes: n }) => {
|
|
2933
|
+
if (t !== null) {
|
|
2934
|
+
e.int(t);
|
|
2935
|
+
return;
|
|
2936
|
+
}
|
|
2937
|
+
e.each(n, ({ host: r, shards: i }) => e.string(r).each(i, (a) => e.int(a.id).int(a.language).int(a.population).int(a.buddies)));
|
|
2938
|
+
} });
|
|
2939
|
+
function Bi(e) {
|
|
2940
|
+
const t = [];
|
|
2941
|
+
let n = 0;
|
|
2942
|
+
for (; n < e.length; ) {
|
|
2943
|
+
const r = e[n++];
|
|
2944
|
+
let i = n;
|
|
2945
|
+
for (; i < e.length && En(e[i]); ) i++;
|
|
2946
|
+
const a = i - n;
|
|
2947
|
+
if (a % _e !== 0) throw new x(`world.shard-list: node "${r}" has ${a} numbers, not shards of ${_e}`, "PACKET_FIELD");
|
|
2948
|
+
const s = new fe(e.slice(n, i), "world.shard-list"), o = s.repeat(a / _e, () => ({ id: s.int("id"), language: s.int("language"), population: s.int("population"), buddies: s.int("buddies") }));
|
|
2949
|
+
t.push({ host: r, shards: o }), n = i;
|
|
2950
|
+
}
|
|
2951
|
+
return t;
|
|
2952
|
+
}
|
|
2953
|
+
function En(e) {
|
|
2954
|
+
return e.trim() !== "" && Number.isFinite(Number(e));
|
|
2955
|
+
}
|
|
2956
|
+
l({ name: "world.node-hop-request", description: "The player asks to move off a server that is shutting down.", direction: "toServer", command: "nd", read: () => ({}), write: () => {
|
|
2957
|
+
} }), l({ name: "world.node-hop", description: "The server names the server to move to.", direction: "toClient", command: "nd", read: (e) => ({ host: e.string("host") }), write: (e, { host: t }) => e.string(t) });
|
|
2958
|
+
const st = { send: "avatar.UserCommXtCommManager.onSendMessage", focusChat: "gui.ChatHistory.setFocusOnMsgText" };
|
|
2959
|
+
function Ri(e, t) {
|
|
2960
|
+
const n = /* @__PURE__ */ new Map();
|
|
2961
|
+
for (const [s, o] of Object.entries(t)) n.set(s.toLowerCase(), o);
|
|
2962
|
+
if (n.size === 0) return e;
|
|
2963
|
+
let r = "", i = "";
|
|
2964
|
+
const a = () => {
|
|
2965
|
+
r += n.get(i.toLowerCase()) ?? i, i = "";
|
|
2966
|
+
};
|
|
2967
|
+
for (const s of e) s === " " || s === " " ? (a(), r += s) : i += s;
|
|
2968
|
+
return a(), r;
|
|
2969
|
+
}
|
|
2970
|
+
function zi(e, t) {
|
|
2971
|
+
const n = e.toLowerCase();
|
|
2972
|
+
return t.some((r) => typeof r == "string" ? r !== "" && n.includes(r.toLowerCase()) : (r.lastIndex = 0, r.test(e)));
|
|
2973
|
+
}
|
|
2974
|
+
async function Vi(e, t = {}) {
|
|
2975
|
+
const { arg: n, fromClass: r, equals: i, exists: a, all: s } = e.flash.rules, o = t.shortcuts ?? {}, d = t.blocked ?? [], c = r("avatar.UserCommXtCommManager", "_mainHud", "chatBar", "text01_chat", "text"), h = [], m = yt(async () => {
|
|
2976
|
+
for (const u of h.splice(0).reverse()) await u().catch(() => {
|
|
2977
|
+
});
|
|
2978
|
+
});
|
|
2979
|
+
try {
|
|
2980
|
+
h.push(await e.flash.hook(st.send, { when: s(i(n("myMsg"), ""), a(c)), replaceArgs: { myMsg: c } })), h.push(await e.flash.override(st.send, async (u) => {
|
|
2981
|
+
var f;
|
|
2982
|
+
const [y, p] = u.argList, g = typeof p == "string" ? p : "";
|
|
2983
|
+
if (g.trim() !== "" && zi(g, d)) {
|
|
2984
|
+
(f = t.onBlocked) == null || f.call(t, g);
|
|
2985
|
+
return;
|
|
2986
|
+
}
|
|
2987
|
+
const v = Ri(g, o);
|
|
2988
|
+
v === g ? await u.original() : await u.original(y, v);
|
|
2989
|
+
}, { sequential: !0 }));
|
|
2990
|
+
} catch (u) {
|
|
2991
|
+
throw await m(), u;
|
|
2992
|
+
}
|
|
2993
|
+
return m;
|
|
2994
|
+
}
|
|
2995
|
+
async function Hi(e, t = {}) {
|
|
2996
|
+
const n = t.style ?? {}, r = e.flash.overlay, i = e.flash.use("gui.GuiManager").$at("mainHud"), a = t.maxLength ?? await e.flash.use("gui.GuiManager").$at("chatHist", "chatMsgText", "maxChars").$get().then((c) => typeof c == "number" && c > 0 ? c : 70).catch(() => 70), s = { family: n.font ?? "_sans", size: n.size ?? 13 }, o = [], d = yt(async () => {
|
|
2997
|
+
for (const c of o.splice(0).reverse()) await c().catch(() => {
|
|
2998
|
+
});
|
|
2999
|
+
});
|
|
3000
|
+
try {
|
|
3001
|
+
o.push(async () => {
|
|
3002
|
+
await e.flash.use("gui.GuiManager").setFocusToChatText();
|
|
3003
|
+
});
|
|
3004
|
+
const c = await r.input({ replaces: i.$at("chatBar"), placeholder: n.placeholderText ?? "Say something", maxLength: a, fill: n.background ?? 16777215, stroke: n.border ?? 8141549, cornerRadius: n.cornerRadius ?? 6, padding: 6, font: { ...s, color: n.text ?? 1120295 } });
|
|
3005
|
+
o.push(() => c.remove());
|
|
3006
|
+
const h = await r.button(n.buttonLabel ?? "Send", { replaces: i.$at("sendChatBtn"), fill: n.button ?? 8141549, hoverFill: n.buttonHover ?? 9133302, cornerRadius: n.cornerRadius ?? 6, font: { ...s, color: n.buttonText ?? 16777215, bold: !0 } });
|
|
3007
|
+
o.push(() => h.remove());
|
|
3008
|
+
let m = !1;
|
|
3009
|
+
const u = async () => {
|
|
3010
|
+
const f = c.value();
|
|
3011
|
+
if (!(m || f.trim() === "")) {
|
|
3012
|
+
m = !0;
|
|
3013
|
+
try {
|
|
3014
|
+
await e.chat.say(f), await c.setValue(""), await c.focus();
|
|
3015
|
+
} finally {
|
|
3016
|
+
m = !1;
|
|
3017
|
+
}
|
|
3018
|
+
}
|
|
3019
|
+
};
|
|
3020
|
+
return o.push(c.on("submit", () => {
|
|
3021
|
+
u();
|
|
3022
|
+
})), o.push(h.on("click", () => {
|
|
3023
|
+
u();
|
|
3024
|
+
})), o.push(await e.flash.hook(st.focusChat, { skip: !0, phase: "enter", capture: { args: [] } }, () => {
|
|
3025
|
+
c.focus();
|
|
3026
|
+
})), (t.focus ?? !0) && await c.focus(), Object.assign(d, { input: c, send: u });
|
|
3027
|
+
} catch (c) {
|
|
3028
|
+
throw await d(), c;
|
|
3029
|
+
}
|
|
3030
|
+
}
|
|
3031
|
+
const Wi = [16096779, 1096065, 3900150, 15485081, 9133302, 15680580, 1357990, 15381256], Ke = 22;
|
|
3032
|
+
async function _i(e, t = {}) {
|
|
3033
|
+
const n = t.style ?? {}, r = e.flash.overlay, i = n.nameColors && n.nameColors.length > 0 ? n.nameColors : Wi, a = t.width ?? 280, s = t.height ?? 200, o = { family: n.font ?? "_sans", size: n.size ?? 12 }, d = /* @__PURE__ */ new Map(), c = [], h = yt(async () => {
|
|
3034
|
+
for (const m of c.splice(0).reverse()) await Promise.resolve(m()).catch(() => {
|
|
3035
|
+
});
|
|
3036
|
+
});
|
|
3037
|
+
try {
|
|
3038
|
+
const m = await r.panel({ title: t.title ?? "Chat", x: t.x ?? 12, y: t.y ?? 60, width: a, height: s, resizable: !0, fill: { color: n.background ?? 1120295, alpha: n.backgroundAlpha ?? 0.9 }, stroke: n.border ?? 3621201, titleFill: n.titleBar ?? 2042167, titleHeight: Ke, titleFont: { ...o, color: n.titleText ?? 16777215, bold: !0 }, ...t.onMove ? { onMove: t.onMove } : {} });
|
|
3039
|
+
c.push(() => m.remove());
|
|
3040
|
+
const u = await r.list({ parent: m, width: a, height: s - Ke, fill: null, maxRows: t.maxRows ?? 200, font: { ...o, color: n.text ?? 15987958 } });
|
|
3041
|
+
c.push(m.on("resize", (g) => {
|
|
3042
|
+
var v;
|
|
3043
|
+
(v = t.onResize) == null || v.call(t, g), u.update({ width: g.width, height: g.height - Ke });
|
|
3044
|
+
})), c.push(u.on("link", (g) => {
|
|
3045
|
+
const v = d.get(g);
|
|
3046
|
+
if (v) {
|
|
3047
|
+
if (t.onNameClick) {
|
|
3048
|
+
t.onNameClick(v);
|
|
3049
|
+
return;
|
|
3050
|
+
}
|
|
3051
|
+
Ki(e, v.userId);
|
|
3052
|
+
}
|
|
3053
|
+
}));
|
|
3054
|
+
const f = async (g) => {
|
|
3055
|
+
let v = null;
|
|
3056
|
+
if (g.kind === ze.free || g.kind === ze.freeSafeChat ? v = g.text : g.kind === ze.safeChat && (v = await e.chat.phrase(g.text).catch(() => null) ?? null), v === null) return null;
|
|
3057
|
+
const k = e.room.players.get(g.userId), T = (k == null ? void 0 : k.avatarName) || (k == null ? void 0 : k.userName) || `#${g.userId}`, j = String(g.userId);
|
|
3058
|
+
return d.set(j, { userId: g.userId, name: T }), [{ text: T, bold: !0, color: i[Math.abs(g.userId) % i.length], link: j }, { text: `: ${v}` }];
|
|
3059
|
+
}, y = (await Promise.all(e.chat.recent.map(f))).filter((g) => g !== null);
|
|
3060
|
+
y.length > 0 && await u.append(...y);
|
|
3061
|
+
let p = Promise.resolve();
|
|
3062
|
+
return c.push(e.chat.onMessage((g) => {
|
|
3063
|
+
p = p.then(async () => {
|
|
3064
|
+
const v = await f(g);
|
|
3065
|
+
v && await u.append(v);
|
|
3066
|
+
}).catch(() => {
|
|
3067
|
+
});
|
|
3068
|
+
})), Object.assign(h, { panel: m, note: (g) => u.append({ markup: g }) });
|
|
3069
|
+
} catch (m) {
|
|
3070
|
+
throw await h(), m;
|
|
3071
|
+
}
|
|
3072
|
+
}
|
|
3073
|
+
async function Ki(e, t) {
|
|
3074
|
+
const n = e.flash.use("avatar.AvatarManager").avatarViewList.$at(String(t)), r = await e.flash.highlight(n, { color: 16436245, strength: 3 });
|
|
3075
|
+
setTimeout(() => {
|
|
3076
|
+
r();
|
|
3077
|
+
}, 2e3);
|
|
3078
|
+
}
|
|
3079
|
+
function yt(e) {
|
|
3080
|
+
let t = null;
|
|
3081
|
+
return () => t ??= e();
|
|
3082
|
+
}
|
|
3083
|
+
class Gi {
|
|
3084
|
+
constructor(t) {
|
|
3085
|
+
this.bridge = t, this.overlay = new Sr(t), this.entities = new pr(this), this.view = new $r(t);
|
|
3086
|
+
}
|
|
3087
|
+
bridge;
|
|
3088
|
+
overlay;
|
|
3089
|
+
entities;
|
|
3090
|
+
view;
|
|
3091
|
+
rules = ur;
|
|
3092
|
+
hookIndex = null;
|
|
3093
|
+
use(t) {
|
|
3094
|
+
return q(this.bridge, this.bridge.definition(t), { className: t });
|
|
3095
|
+
}
|
|
3096
|
+
global(t) {
|
|
3097
|
+
return q(this.bridge, this.bridge.definition(t));
|
|
3098
|
+
}
|
|
3099
|
+
stage() {
|
|
3100
|
+
return q(this.bridge, this.bridge.stage());
|
|
3101
|
+
}
|
|
3102
|
+
client() {
|
|
3103
|
+
return q(this.bridge, this.bridge.gameClient());
|
|
3104
|
+
}
|
|
3105
|
+
whenReady() {
|
|
3106
|
+
return this.bridge.whenReady();
|
|
3107
|
+
}
|
|
3108
|
+
hooks(t) {
|
|
3109
|
+
if (t !== void 0 || !this.hookIndex) {
|
|
3110
|
+
const n = this.bridge.hookTable(t).then((r) => new lr(r));
|
|
3111
|
+
n.catch(() => {
|
|
3112
|
+
this.hookIndex === n && (this.hookIndex = null);
|
|
3113
|
+
}), this.hookIndex = n;
|
|
3114
|
+
}
|
|
3115
|
+
return this.hookIndex;
|
|
3116
|
+
}
|
|
3117
|
+
async hook(t, n = {}, r) {
|
|
3118
|
+
return hr(this.bridge, await this.hooks(), t, n, r);
|
|
3119
|
+
}
|
|
3120
|
+
async override(t, n, ...[r]) {
|
|
3121
|
+
return Dr(this.bridge, await this.hooks(), t, n, r ?? {});
|
|
3122
|
+
}
|
|
3123
|
+
style(t, n) {
|
|
3124
|
+
return this.bridge.style(A(t), n);
|
|
3125
|
+
}
|
|
3126
|
+
hold(t, n, r = {}) {
|
|
3127
|
+
return At(this.bridge, [{ place: t, value: n }], r);
|
|
3128
|
+
}
|
|
3129
|
+
holdAll(t, n = {}) {
|
|
3130
|
+
return At(this.bridge, t, n);
|
|
3131
|
+
}
|
|
3132
|
+
repeat(t, n = {}) {
|
|
3133
|
+
return mr(this.bridge, t, n);
|
|
3134
|
+
}
|
|
3135
|
+
collect(t, n, r = {}) {
|
|
3136
|
+
return cr(this.bridge, t, n, r);
|
|
3137
|
+
}
|
|
3138
|
+
async track(t, n, r = {}) {
|
|
3139
|
+
if (await this.bridge.whenReady(), !this.bridge.features.includes("track")) throw new Error("This game is running a loader from before lists; look for them yourself");
|
|
3140
|
+
const i = r.where === void 0 ? { target: { kind: "stage" }, path: [] } : A(r.where), a = (s) => s.filter((o) => o instanceof L).map((o) => q(this.bridge, o.at(), { handle: o }));
|
|
3141
|
+
return this.bridge.track(i, t, { ...r.mode !== void 0 ? { mode: r.mode } : {}, ...r.everyFrames !== void 0 ? { everyFrames: r.everyFrames } : {} }, ({ added: s, removed: o }) => n({ added: a(s), removed: a(o) }));
|
|
3142
|
+
}
|
|
3143
|
+
async snapshot(t, n = {}) {
|
|
3144
|
+
if (await this.bridge.whenReady(), !this.bridge.features.includes("snapshot")) throw new Error("This game is running a loader from before pictures; nothing can be drawn");
|
|
3145
|
+
return this.bridge.snapshot(A(t), n);
|
|
3146
|
+
}
|
|
3147
|
+
notes() {
|
|
3148
|
+
return new vr(this.bridge);
|
|
3149
|
+
}
|
|
3150
|
+
async find(t, n) {
|
|
3151
|
+
return await gr(this.bridge, n, t ?? {});
|
|
3152
|
+
}
|
|
3153
|
+
answering(t, n) {
|
|
3154
|
+
return new or(this.bridge, t, n);
|
|
3155
|
+
}
|
|
3156
|
+
watch(t, n, r) {
|
|
3157
|
+
const i = r;
|
|
3158
|
+
let a, s = [], o;
|
|
3159
|
+
if (Array.isArray(t)) a = "list", o = [...t];
|
|
3160
|
+
else if (Yi(t)) a = "one", o = [t];
|
|
3161
|
+
else {
|
|
3162
|
+
a = "record";
|
|
3163
|
+
const m = t;
|
|
3164
|
+
s = Object.keys(m), o = s.map((u) => m[u]);
|
|
3165
|
+
}
|
|
3166
|
+
const d = o.map(A), c = (m) => a === "one" ? m[0] : a === "list" ? m : Object.fromEntries(s.map((u, f) => [u, m[f]]));
|
|
3167
|
+
let h = null;
|
|
3168
|
+
return this.bridge.watch(d, n, (m, u) => {
|
|
3169
|
+
const f = m.map((g) => S(this.bridge, g)), y = c(f), p = d.map((g, v) => (u == null ? void 0 : u[v]) ?? null);
|
|
3170
|
+
i(y, h, a === "one" ? p[0] : c(p)), h = y;
|
|
3171
|
+
});
|
|
3172
|
+
}
|
|
3173
|
+
onTick(t, n = {}) {
|
|
3174
|
+
return this.bridge.tick(n.everyFrames ?? 1, t);
|
|
3175
|
+
}
|
|
3176
|
+
highlight(t, n = {}) {
|
|
3177
|
+
return this.bridge.highlight(A(t), ue(n));
|
|
3178
|
+
}
|
|
3179
|
+
hide(t) {
|
|
3180
|
+
return this.bridge.highlight(A(t), ue({ hide: !0 }));
|
|
3181
|
+
}
|
|
3182
|
+
recolor(t, n) {
|
|
3183
|
+
const r = n ? A(n) : { target: { kind: "loader" }, path: [] };
|
|
3184
|
+
return this.bridge.highlight(r, { glow: null, ...pn(t), hide: !1, pulse: null });
|
|
3185
|
+
}
|
|
3186
|
+
onKey(t, n, r = {}) {
|
|
3187
|
+
return this.bridge.onKey(yr(t, r), (i) => Xi(n)({ code: i.code, char: i.char, ctrl: i.ctrl, shift: i.shift, alt: i.alt, phase: i.phase }));
|
|
3188
|
+
}
|
|
3189
|
+
}
|
|
3190
|
+
function Xi(e) {
|
|
3191
|
+
return (t) => {
|
|
3192
|
+
try {
|
|
3193
|
+
const n = e(t);
|
|
3194
|
+
n instanceof Promise && n.catch((r) => Jt(r));
|
|
3195
|
+
} catch (n) {
|
|
3196
|
+
Jt(n);
|
|
3197
|
+
}
|
|
3198
|
+
};
|
|
3199
|
+
}
|
|
3200
|
+
function Jt(e) {
|
|
3201
|
+
console.error("phantom.flash.onKey: a listener failed", e);
|
|
3202
|
+
}
|
|
3203
|
+
function Yi(e) {
|
|
3204
|
+
try {
|
|
3205
|
+
return A(e), !0;
|
|
3206
|
+
} catch {
|
|
3207
|
+
return !1;
|
|
3208
|
+
}
|
|
3209
|
+
}
|
|
3210
|
+
const Ji = { avatarManager: "avatar.AvatarManager" }, Qi = { none: 0, game: 1, denVolume: 2, splash: 3, storePet: 4, socialGroup: 5, socialEmoticon: 6, guiAction: 7, recycleAccessory: 8, recycleDenItem: 9, triggerWalkIn: 11, genericList: 12, clickEmoticon: 13, air: 14, dynamicCollision: 15, dynamicAir: 16, dynamicPhantomAir: 17, plant: 18, stealth: 19, adventureInteract: 20, darkSoft: 21, darkHard: 22, fallingPhantom: 23 };
|
|
3211
|
+
Object.fromEntries(Object.entries(Qi).map(([e, t]) => [t, e]));
|
|
3212
|
+
const Zi = "com.sbi.loader.LoaderCache.fetchCDNURL", ea = 2e4;
|
|
3213
|
+
class ta {
|
|
3214
|
+
channel;
|
|
3215
|
+
flash;
|
|
3216
|
+
hooks = /* @__PURE__ */ new Map();
|
|
3217
|
+
constructor(t, n) {
|
|
3218
|
+
this.channel = t.content ?? null, this.flash = n;
|
|
3219
|
+
}
|
|
3220
|
+
get available() {
|
|
3221
|
+
return this.channel !== null;
|
|
3222
|
+
}
|
|
3223
|
+
async replace(t, n) {
|
|
3224
|
+
const r = this.reach(), i = Qt(t);
|
|
3225
|
+
await this.unhook(Ge(i));
|
|
3226
|
+
const a = await r.replace(i, Xe(n)), s = [], o = await this.pointClientAt(i, a.url);
|
|
3227
|
+
return o && (this.hooks.set(Ge(i), o), s.push("client")), s.push("proxy"), { ...a, how: s, stop: () => this.restore(i).then(() => {
|
|
3228
|
+
}) };
|
|
3229
|
+
}
|
|
3230
|
+
async restore(t) {
|
|
3231
|
+
const n = this.reach(), r = Qt(t);
|
|
3232
|
+
return await this.unhook(Ge(r)), n.restore(r);
|
|
3233
|
+
}
|
|
3234
|
+
replacements() {
|
|
3235
|
+
return this.reach().list();
|
|
3236
|
+
}
|
|
3237
|
+
onRequest(t) {
|
|
3238
|
+
return this.reach().observe(t);
|
|
3239
|
+
}
|
|
3240
|
+
async replaceOnScreen(t, n, r = {}) {
|
|
3241
|
+
const { url: i, id: a } = await this.addressOf(n), { refreshFrames: s, ...o } = r, d = await this.flash.overlay.image(i, { ...o, replaces: s === void 0 ? t : { place: t, refreshFrames: s } });
|
|
3242
|
+
return { url: i, stop: async () => {
|
|
3243
|
+
await d.remove(), a && await this.reach().release(a);
|
|
3244
|
+
} };
|
|
3245
|
+
}
|
|
3246
|
+
async load(t, n = {}) {
|
|
3247
|
+
const r = this.flash.bridge, i = Xe(t), a = await r.construct("flash.display.Loader"), s = [];
|
|
3248
|
+
try {
|
|
3249
|
+
const o = await r.definition("flash.system.ApplicationDomain").at("currentDomain").get();
|
|
3250
|
+
s.push(() => o.release());
|
|
3251
|
+
const d = await r.construct("flash.system.LoaderContext", !1, o);
|
|
3252
|
+
s.push(() => d.release()), await d.at("allowCodeImport").set(n.allowCode === !0).catch(() => {
|
|
3253
|
+
});
|
|
3254
|
+
const c = this.whenLoaded(a, n.timeoutMs ?? ea);
|
|
3255
|
+
if (i.kind === "data-url") {
|
|
3256
|
+
const m = await this.decodeInFlash(i.url);
|
|
3257
|
+
s.push(() => m.release()), await a.at("loadBytes").call(m, d);
|
|
3258
|
+
} else {
|
|
3259
|
+
const m = await this.reach().hold(i);
|
|
3260
|
+
s.push(() => this.reach().release(m.id)), await a.at("load").call(new ct("flash.net.URLRequest", [m.url]), d);
|
|
3261
|
+
}
|
|
3262
|
+
await c;
|
|
3263
|
+
const h = await a.at("content").get();
|
|
3264
|
+
if (!h) throw new Error("Nothing was loaded");
|
|
3265
|
+
return { content: h, loader: a, unload: async () => {
|
|
3266
|
+
await a.at("unloadAndStop").call().catch(() => {
|
|
3267
|
+
}), await h.release().catch(() => {
|
|
3268
|
+
}), await a.release().catch(() => {
|
|
3269
|
+
});
|
|
3270
|
+
} };
|
|
3271
|
+
} catch (o) {
|
|
3272
|
+
throw await a.release().catch(() => {
|
|
3273
|
+
}), o;
|
|
3274
|
+
} finally {
|
|
3275
|
+
for (const o of s) await o().catch(() => {
|
|
3276
|
+
});
|
|
3277
|
+
}
|
|
3278
|
+
}
|
|
3279
|
+
async pointClientAt(t, n) {
|
|
3280
|
+
if (t.kind === "pattern") return null;
|
|
3281
|
+
const r = na(t.value);
|
|
3282
|
+
if (!r) return null;
|
|
3283
|
+
const { arg: i, equals: a, startsWith: s, any: o } = this.flash.rules, d = t.kind === "prefix" ? s : a;
|
|
3284
|
+
try {
|
|
3285
|
+
return await this.flash.hook(Zi, { when: o(d(i("assetPath"), r), d(i("assetPath"), `/${r}`)), replaceReturn: n });
|
|
3286
|
+
} catch {
|
|
3287
|
+
return null;
|
|
3288
|
+
}
|
|
3289
|
+
}
|
|
3290
|
+
async unhook(t) {
|
|
3291
|
+
const n = this.hooks.get(t);
|
|
3292
|
+
n && (this.hooks.delete(t), await n().catch(() => {
|
|
3293
|
+
}));
|
|
3294
|
+
}
|
|
3295
|
+
async addressOf(t) {
|
|
3296
|
+
const n = Xe(t);
|
|
3297
|
+
if (n.kind === "data-url") return { url: n.url, id: null };
|
|
3298
|
+
const r = await this.reach().hold(n);
|
|
3299
|
+
return { url: r.url, id: r.id };
|
|
3300
|
+
}
|
|
3301
|
+
async decodeInFlash(t) {
|
|
3302
|
+
const n = t.indexOf(",");
|
|
3303
|
+
if (n === -1 || t.slice(0, n).indexOf(";base64") === -1) throw new Error("Only base64 data: URLs can be loaded into the client");
|
|
3304
|
+
const r = await this.flash.bridge.definition("phantom.overlay.Base64").at("decode").call(t.slice(n + 1));
|
|
3305
|
+
if (!r) throw new Error("The loader could not decode those bytes");
|
|
3306
|
+
return r;
|
|
3307
|
+
}
|
|
3308
|
+
whenLoaded(t, n) {
|
|
3309
|
+
const r = t.at("contentLoaderInfo");
|
|
3310
|
+
return new Promise((i, a) => {
|
|
3311
|
+
const s = [], o = (h) => {
|
|
3312
|
+
clearTimeout(d);
|
|
3313
|
+
for (const m of s.splice(0)) m().catch(() => {
|
|
3314
|
+
});
|
|
3315
|
+
h ? a(h) : i();
|
|
3316
|
+
}, d = setTimeout(() => o(new Error(`Flash did not load those bytes within ${n}ms`)), n), c = (h, m) => r.listen(h, () => o(m === null ? null : new Error(m))).then((u) => s.push(u), (u) => o(u));
|
|
3317
|
+
c("complete", null), c("ioError", "Flash could not read those bytes"), c("securityError", "Flash refused those bytes");
|
|
3318
|
+
});
|
|
3319
|
+
}
|
|
3320
|
+
reach() {
|
|
3321
|
+
if (!this.channel) throw new Error("This game cannot replace content: it was made without a content origin");
|
|
3322
|
+
return this.channel;
|
|
3323
|
+
}
|
|
3324
|
+
}
|
|
3325
|
+
function Ge(e) {
|
|
3326
|
+
return `${e.kind}:${e.value}`;
|
|
3327
|
+
}
|
|
3328
|
+
function na(e) {
|
|
3329
|
+
let t = e.charAt(0) === "/" ? e.slice(1) : e;
|
|
3330
|
+
const n = t.indexOf("?");
|
|
3331
|
+
n !== -1 && (t = t.slice(0, n)), t.slice(0, 8) === "content/" && (t = t.slice(8));
|
|
3332
|
+
const r = t.indexOf("/"), i = r === -1 ? t : t.slice(0, r);
|
|
3333
|
+
return r !== -1 && i.length > 0 && ra(i) && (t = t.slice(r + 1)), t;
|
|
3334
|
+
}
|
|
3335
|
+
function ra(e) {
|
|
3336
|
+
for (const t of e) if (t < "0" || t > "9") return !1;
|
|
3337
|
+
return e.length > 0;
|
|
3338
|
+
}
|
|
3339
|
+
function Qt(e) {
|
|
3340
|
+
const t = typeof e == "string" ? { kind: "path", value: e } : e;
|
|
3341
|
+
if (!t || typeof t.value != "string" || !t.value) throw new TypeError("A replacement matches a path, a prefix or a pattern");
|
|
3342
|
+
const n = t.kind;
|
|
3343
|
+
if (n !== "path" && n !== "prefix" && n !== "pattern") throw new TypeError(`${n} is not path, prefix or pattern`);
|
|
3344
|
+
const r = t.value.charAt(0) === "/" ? t.value : `/${t.value}`;
|
|
3345
|
+
return { kind: n, value: r };
|
|
3346
|
+
}
|
|
3347
|
+
function Xe(e) {
|
|
3348
|
+
if (typeof e == "string") return e.slice(0, 5).toLowerCase() === "data:" ? { kind: "data-url", url: e } : { kind: "file", path: e };
|
|
3349
|
+
if (e instanceof ArrayBuffer) return { kind: "bytes", bytes: new Uint8Array(e) };
|
|
3350
|
+
if (ArrayBuffer.isView(e)) {
|
|
3351
|
+
const t = e;
|
|
3352
|
+
return { kind: "bytes", bytes: new Uint8Array(t.buffer, t.byteOffset, t.byteLength) };
|
|
3353
|
+
}
|
|
3354
|
+
if (e && typeof e == "object") {
|
|
3355
|
+
const t = "contentType" in e && e.contentType ? e.contentType : null, n = t ? { contentType: t } : {};
|
|
3356
|
+
if ("bytes" in e) {
|
|
3357
|
+
const r = e.bytes, i = r instanceof ArrayBuffer ? new Uint8Array(r) : r;
|
|
3358
|
+
if (!(i instanceof Uint8Array)) throw new TypeError("bytes are a Uint8Array");
|
|
3359
|
+
return { kind: "bytes", bytes: i, ...n };
|
|
3360
|
+
}
|
|
3361
|
+
if ("dataUrl" in e && typeof e.dataUrl == "string") return { kind: "data-url", url: e.dataUrl, ...n };
|
|
3362
|
+
if ("file" in e && typeof e.file == "string") return { kind: "file", path: e.file, ...n };
|
|
3363
|
+
}
|
|
3364
|
+
throw new TypeError("A source is bytes, a data: URL, or the path of a file on this computer");
|
|
3365
|
+
}
|
|
3366
|
+
const O = { definitionByName: "GETDEFINITIONBYNAME", resourceStack: "com.sbi.loader.ResourceStack", guiManager: "gui.GuiManager", loadProgress: "loadProgress.LoadProgress", denEditor: "gui.DenEditor", fonts: "gui.Fonts", palette: "com.sbi.graphics.PaletteHelper", colorTable: "gui.ColorTable", avatarManager: "avatar.AvatarManager" }, ia = { message: "com.sbi.popup.SBMessage", ok: "com.sbi.popup.SBOkPopup", okCancel: "com.sbi.popup.SBOkCancelPopup", yesNo: "com.sbi.popup.SBYesNoPopup", titled: "com.sbi.popup.SBStandardTitlePopup", parchment: "com.sbi.popup.SBParchmentPopup" }, jn = { ink: 1118483, line: 3816e3, light: 15790322, muted: 10000543, accent: 8141549, danger: 15680580, size: 12, cornerRadius: 4 }, Ce = { ink: 4403228, line: 9071167, light: 16643032, muted: 9402972, accent: 3123423, danger: 13369344, size: 11, cornerRadius: 8 }, Ye = { game: 28, phantom: 24 }, aa = 18;
|
|
3367
|
+
function xe(e) {
|
|
3368
|
+
return (...t) => {
|
|
3369
|
+
try {
|
|
3370
|
+
const n = e(...t);
|
|
3371
|
+
n instanceof Promise && n.catch(Zt);
|
|
3372
|
+
} catch (n) {
|
|
3373
|
+
Zt(n);
|
|
3374
|
+
}
|
|
3375
|
+
};
|
|
3376
|
+
}
|
|
3377
|
+
function Zt(e) {
|
|
3378
|
+
console.error("phantom.ui: a listener failed", e);
|
|
3379
|
+
}
|
|
3380
|
+
const sa = { game: 110, phantom: 96 }, ot = "_sans";
|
|
3381
|
+
function oa(e, t = ot) {
|
|
3382
|
+
return { skin: e, font: t, ...e === "game" ? Ce : jn };
|
|
3383
|
+
}
|
|
3384
|
+
const ca = { PopupSkin: "The plain popup frame: `ba` (its `t`, `m` and `b` slices) and `c`, its content box.", PopupContent: "What a plain popup shows: a `text` field the popup sizes itself around.", OkPopupSkin: "The frame of a popup with one button.", OkPopupContent: "An OK button (`okBtn`) and the `text` above it.", YesNoPopupSkin: "The frame of a popup with two buttons.", YesNoPopupContent: "Yes (`yesBtn`) and No (`noBtn`), and the `text` above them.", okCancelPopupContent: "OK (`okCancelBtn`) and Cancel (`cancelBtn`).", ConfirmSkin: "The frame the client asks you to confirm something in.", Tooltip: "The client's own tooltip (`gui.ToolTipPopup`): `txt`, and `l`, `m` and `r`.", HelpTxtBubble: "The bubble the client points at something it is explaining.", closeBtn: "The round close button in the corner of the client windows.", scrollbar2: "A scrollbar: `track`, `handle`, `topBtn` and `botBtn`.", BuddyListPopup: "The buddy list window's frame.", BuddyListContent: "What the buddy list shows inside that frame.", BD_AvatarEditorSkin: "The frame of the avatar editor's own dialog.", BD_AvatarEditorContent: "What that dialog shows.", DenEditorAsset: "The whole den editor, as the client builds it.", MySettings: "The settings window.", MainHud: "The whole HUD.", FreeNameBar: "The name bar above a player who is not a member.", memberNameBar: "The name bar above a member.", AnimsTitleBanner: "The banner the client puts a title in.", ChatBalloonAsset: "A chat balloon.", Cursor: "The client's own mouse cursor.", QuestPickupIcon: "The icon an adventure shows over something to pick up.", MinigameLobbySkin: "A minigame lobby's frame.", MinigameLobbyContent: "What a minigame lobby shows.", BroadcastPopupSkin: "The frame an announcement is shown in.", BroadcastPopupContent: "What an announcement shows.", DenLockPopupSkin: "The frame of the den's lock settings.", DenLockPopupContent: "What the den lock settings show.", ReportRulesPopupSkin: "The frame of the report window's rules.", ReportRulesPopupContent: "What the report rules show." }, da = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
3385
|
+
function en(e) {
|
|
3386
|
+
if (!da.test(e)) throw new TypeError(`"${e}" is not a symbol name: a symbol is named in letters, digits and underscores`);
|
|
3387
|
+
return e;
|
|
3388
|
+
}
|
|
3389
|
+
const tn = { gui: { className: O.guiManager, path: ["guiLayer"] }, hud: { className: O.guiManager, path: ["mainHud"] }, room: { className: O.avatarManager, path: ["playerAvatarWorldView", "parent"] }, avatarEditor: { className: O.guiManager, path: ["avatarEditor", "avEditor"] }, denEditor: { className: O.denEditor, path: ["staticEditor"] } }, nn = "stage", rn = { avatarEditor: { open: "gui.AvatarEditor.init", close: "gui.AvatarEditor.destroy", spot: "avatarEditor" }, denEditor: { open: "gui.DenEditor.init", close: "gui.DenEditor.destroy", spot: "denEditor" }, settings: { open: "gui.MySettings.init", close: "gui.MySettings.destroy", spot: null }, buddyList: { open: "buddy.BuddyList.init", close: "buddy.BuddyList.destroy", spot: null }, petCreator: { open: "gui.PetCreator.init", close: "gui.PetCreator.destroy", spot: null }, achievements: { open: "gui.AchievementViewer.init", close: "gui.AchievementViewer.destroy", spot: null }, bulletinBoard: { open: "gui.BulletinBoard.init", close: "gui.BulletinBoard.destroy", spot: null }, playerSearch: { open: "gui.PlayerSearch.init", close: "gui.PlayerSearch.destroy", spot: null }, recycle: { open: "gui.RecycleItems.init", close: "gui.RecycleItems.destroy", spot: null }, trade: { open: "gui.TradeManager.init", close: "gui.TradeManager.destroy", spot: null }, petInventory: { open: "gui.PetInventory.init", close: "gui.PetInventory.destroy", spot: null }, reportPlayer: { open: "gui.ReportAPlayer.init", close: "gui.ReportAPlayer.destroy", spot: null }, serverSelector: { open: "gui.ServerSelector.init", close: "gui.ServerSelector.destroy", spot: null } }, la = { ok: 0, yesNo: 1, continueExit: 2, continue: 3 };
|
|
3390
|
+
function ua(e, t, n = {}) {
|
|
3391
|
+
const r = { slot: "layer" }, i = { slot: "callback" }, a = n.name ?? null, s = ia[e];
|
|
3392
|
+
switch (e) {
|
|
3393
|
+
case "message":
|
|
3394
|
+
return { className: s, args: [r, { slot: "skin" }, t, !0, !0, n.modal ?? !1, n.draggable ?? !0, n.darken ?? !1, a] };
|
|
3395
|
+
case "ok":
|
|
3396
|
+
return { className: s, args: [r, t, n.darken ?? !0, null, !0, !0, n.modal ?? !0, n.draggable ?? !1, a] };
|
|
3397
|
+
case "yesNo":
|
|
3398
|
+
return { className: s, args: [r, t, n.darken ?? !0, i, null, !0, !0, n.modal ?? !0, n.draggable ?? !1, a] };
|
|
3399
|
+
case "okCancel":
|
|
3400
|
+
return { className: s, args: [r, t, n.darken ?? !0, i, null] };
|
|
3401
|
+
case "titled":
|
|
3402
|
+
return { className: s, args: [r, t, n.title ?? null, n.mediaId ?? 370, i, !0, n.darken ?? !0] };
|
|
3403
|
+
case "parchment":
|
|
3404
|
+
return { className: s, args: [r, la[n.buttons ?? "ok"], t, n.darken ?? !0, i, null] };
|
|
3405
|
+
}
|
|
3406
|
+
}
|
|
3407
|
+
function an(e) {
|
|
3408
|
+
const t = Math.max(1, Math.floor(e.columns)), n = [];
|
|
3409
|
+
for (let r = 0; r < Math.max(0, Math.floor(e.count)); r++) {
|
|
3410
|
+
const i = Math.floor(r / t), a = r % t;
|
|
3411
|
+
n.push({ index: r, row: i, column: a, x: a * (e.tileWidth + e.gap), y: i * (e.tileHeight + e.gap), width: e.tileWidth, height: e.tileHeight });
|
|
3412
|
+
}
|
|
3413
|
+
return n;
|
|
3414
|
+
}
|
|
3415
|
+
function ha(e, t) {
|
|
3416
|
+
const n = t.gap, r = e.length;
|
|
3417
|
+
if (r === 0) return [];
|
|
3418
|
+
const i = (t.width + n) / r;
|
|
3419
|
+
return e.map((a, s) => {
|
|
3420
|
+
const o = Math.round(s * i), d = s === r - 1 ? t.width + n : Math.round((s + 1) * i);
|
|
3421
|
+
return { index: s, value: a, x: o, width: Math.max(0, d - o - n) };
|
|
3422
|
+
});
|
|
3423
|
+
}
|
|
3424
|
+
function ma(e) {
|
|
3425
|
+
const t = Math.max(0, e.contentHeight - e.viewHeight), n = Math.min(t, Math.max(0, e.offset)), r = e.minThumb ?? 16, i = e.contentHeight > 0 ? e.viewHeight / e.contentHeight : 1, a = Math.max(Math.min(e.trackHeight, r), Math.min(e.trackHeight, Math.round(e.trackHeight * i))), s = e.trackHeight - a;
|
|
3426
|
+
return { offset: n, max: t, thumbY: t > 0 ? Math.round(n / t * s) : 0, thumbHeight: a };
|
|
3427
|
+
}
|
|
3428
|
+
class pa {
|
|
3429
|
+
bridge;
|
|
3430
|
+
flash;
|
|
3431
|
+
drawn = /* @__PURE__ */ new Set();
|
|
3432
|
+
popups = /* @__PURE__ */ new Set();
|
|
3433
|
+
symbolMaker = null;
|
|
3434
|
+
gameFont = null;
|
|
3435
|
+
defaultSkin = "phantom";
|
|
3436
|
+
popup;
|
|
3437
|
+
constructor(t, n) {
|
|
3438
|
+
this.bridge = t.flash, this.flash = n, this.popup = new ga((r, i, a, s, o) => this.openPopup(r, i, a, s, o), () => this.clear());
|
|
3439
|
+
}
|
|
3440
|
+
get skin() {
|
|
3441
|
+
return this.defaultSkin;
|
|
3442
|
+
}
|
|
3443
|
+
set skin(t) {
|
|
3444
|
+
this.defaultSkin = t;
|
|
3445
|
+
}
|
|
3446
|
+
async theme(t) {
|
|
3447
|
+
const n = t ?? this.defaultSkin;
|
|
3448
|
+
return oa(n, n === "game" ? await this.clientFont() : ot);
|
|
3449
|
+
}
|
|
3450
|
+
symbols() {
|
|
3451
|
+
return Object.entries(ca);
|
|
3452
|
+
}
|
|
3453
|
+
async hasSymbol(t) {
|
|
3454
|
+
const n = en(t);
|
|
3455
|
+
try {
|
|
3456
|
+
return await this.bridge.definition(O.resourceStack).at("hudAssetsLoaderInfo", "applicationDomain", "hasDefinition").call(n) === !0;
|
|
3457
|
+
} catch {
|
|
3458
|
+
return !1;
|
|
3459
|
+
}
|
|
3460
|
+
}
|
|
3461
|
+
async symbol(t, n = {}) {
|
|
3462
|
+
const r = en(t), i = await this.flash.overlay.group({ x: n.x ?? 0, y: n.y ?? 0, ...n.scale === void 0 ? {} : { scale: n.scale }, ...n.visible === void 0 ? {} : { visible: n.visible } });
|
|
3463
|
+
let a;
|
|
3464
|
+
try {
|
|
3465
|
+
a = await (await this.maker()).at("apply").call(null, [r, n.localize === !0]), await (await this.nodeObject(i)).at("addChild").call(a);
|
|
3466
|
+
} catch (o) {
|
|
3467
|
+
throw await i.remove(), o;
|
|
3468
|
+
}
|
|
3469
|
+
await i.update({ ...n.parent === void 0 ? {} : { parent: M(n.parent) }, ...n.host === void 0 ? {} : { host: n.host === null ? null : this.placeOf(n.host) }, ...n.replaces === void 0 ? {} : { replaces: n.replaces === null ? null : this.placeOf(n.replaces) } });
|
|
3470
|
+
const s = a.at();
|
|
3471
|
+
return this.widget(i, n.skin ?? this.defaultSkin, { name: r, object: a, on: async (o, d) => {
|
|
3472
|
+
const c = await s.listen(ya[o], () => d());
|
|
3473
|
+
return async () => {
|
|
3474
|
+
await c();
|
|
3475
|
+
};
|
|
3476
|
+
}, size: async () => ({ width: await a.at("width").get() ?? 0, height: await a.at("height").get() ?? 0 }) });
|
|
3477
|
+
}
|
|
3478
|
+
async window(t = {}) {
|
|
3479
|
+
const n = t.skin ?? this.defaultSkin, r = await this.theme(n), i = { width: t.width ?? 280, height: t.height ?? 200 }, a = n === "game", s = await this.flash.overlay.panel({ x: t.x ?? 40, y: t.y ?? 40, width: i.width, height: i.height, title: t.title ?? "", titleHeight: a ? 30 : 24, draggable: t.draggable !== !1, resizable: t.resizable === !0 && !a, cornerRadius: r.cornerRadius, fill: a ? { color: r.light, alpha: 0 } : { color: r.ink, alpha: 0.94 }, stroke: a ? null : r.line, titleFill: a ? { color: r.line, alpha: 4e-3 } : r.line, titleFont: { family: r.font, size: r.size + 1, bold: !0, color: a ? r.ink : r.light }, ...t.parent ? { parent: M(t.parent) } : {}, ...t.visible === void 0 ? {} : { visible: t.visible } }), o = a ? await this.dressWindow(s, i) : { ...i, top: 0 };
|
|
3480
|
+
a && await s.update({ width: o.width, height: o.height, titleHeight: Math.round(o.top) + aa });
|
|
3481
|
+
const d = /* @__PURE__ */ new Set(), c = this.widget(s, n, { body: s, width: o.width, height: o.height, setTitle: (h) => s.update({ title: h }), onClose: (h) => (d.add(h), async () => {
|
|
3482
|
+
d.delete(h);
|
|
3483
|
+
}), onMove: (h) => {
|
|
3484
|
+
const m = s.on("move", h);
|
|
3485
|
+
return async () => {
|
|
3486
|
+
await m();
|
|
3487
|
+
};
|
|
3488
|
+
} });
|
|
3489
|
+
return t.closable !== !1 && (await this.flash.overlay.button("x", { parent: s, x: o.width - (a ? 26 : 24), y: 2, width: 18, height: 16, cornerRadius: r.cornerRadius, fill: a ? { color: r.line, alpha: 0.2 } : r.line, hoverFill: { color: r.danger, alpha: 0.8 }, font: { family: r.font, size: r.size, bold: !0, color: a ? r.ink : r.light } })).on("click", () => {
|
|
3490
|
+
c().then(() => d.forEach((h) => h()));
|
|
3491
|
+
}), c;
|
|
3492
|
+
}
|
|
3493
|
+
async button(t, n = {}) {
|
|
3494
|
+
const r = n.skin ?? this.defaultSkin, i = await this.theme(r), a = await this.flash.overlay.button(t, { ...this.box(n, { width: sa[r], height: Ye[r] }), ...se(i, n.primary === !0), cornerRadius: i.cornerRadius, ...n.disabled === void 0 ? {} : { disabled: n.disabled }, font: { family: i.font, size: i.size, bold: !0, color: n.primary === !0 || r === "phantom" ? i.light : i.ink } });
|
|
3495
|
+
return this.widget(a, r, { setLabel: (s) => a.setLabel(s), setDisabled: (s) => a.setDisabled(s), onClick: (s) => {
|
|
3496
|
+
const o = a.on("click", xe(s));
|
|
3497
|
+
return async () => {
|
|
3498
|
+
await o();
|
|
3499
|
+
};
|
|
3500
|
+
} });
|
|
3501
|
+
}
|
|
3502
|
+
async label(t, n = {}) {
|
|
3503
|
+
const r = n.skin ?? this.defaultSkin, i = await this.theme(r), a = await this.flash.overlay.text(t, { x: n.x ?? 0, y: n.y ?? 0, ...n.parent ? { parent: M(n.parent) } : {}, ...n.visible === void 0 ? {} : { visible: n.visible }, centered: n.centered === !0, font: { family: i.font, size: n.heading === !0 ? i.size + 3 : i.size, bold: n.heading === !0, color: n.muted === !0 ? i.muted : r === "game" ? i.ink : i.light }, ...n.background === !0 ? { background: r === "game" ? { color: i.light, alpha: 0.9 } : { color: i.ink, alpha: 0.7 }, padding: 4 } : {} });
|
|
3504
|
+
return this.widget(a, r, { setText: (s) => a.update({ text: s }) });
|
|
3505
|
+
}
|
|
3506
|
+
async input(t = {}) {
|
|
3507
|
+
const n = t.skin ?? this.defaultSkin, r = await this.theme(n), i = await this.flash.overlay.input({ ...this.box(t, { width: 200, height: Ye[n] }), ...t.value === void 0 ? {} : { value: t.value }, ...t.placeholder === void 0 ? {} : { placeholder: t.placeholder }, ...t.maxLength === void 0 ? {} : { maxLength: t.maxLength }, ...t.multiline === void 0 ? {} : { multiline: t.multiline }, ...t.disabled === void 0 ? {} : { disabled: t.disabled }, fill: n === "game" ? r.light : 16777215, stroke: r.line, cornerRadius: r.cornerRadius, font: { family: r.font, size: r.size, color: n === "game" ? r.ink : 1120295 } });
|
|
3508
|
+
return this.widget(i, n, { value: () => i.value(), setValue: (a) => i.setValue(a), focus: () => i.focus(), onChange: (a) => {
|
|
3509
|
+
const s = i.on("change", xe(a));
|
|
3510
|
+
return async () => {
|
|
3511
|
+
await s();
|
|
3512
|
+
};
|
|
3513
|
+
}, onSubmit: (a) => {
|
|
3514
|
+
const s = i.on("submit", xe(a));
|
|
3515
|
+
return async () => {
|
|
3516
|
+
await s();
|
|
3517
|
+
};
|
|
3518
|
+
} });
|
|
3519
|
+
}
|
|
3520
|
+
async checkbox(t, n = {}) {
|
|
3521
|
+
const r = n.skin ?? this.defaultSkin, i = await this.theme(r), a = await this.flash.overlay.group({ x: n.x ?? 0, y: n.y ?? 0, ...n.parent ? { parent: M(n.parent) } : {}, ...n.visible === void 0 ? {} : { visible: n.visible } });
|
|
3522
|
+
let s = n.checked === !0;
|
|
3523
|
+
const o = await this.flash.overlay.button(s ? "x" : "", { parent: a, width: 14, height: 14, cornerRadius: Math.min(3, i.cornerRadius), fill: r === "game" ? i.light : { color: i.ink, alpha: 0.9 }, hoverFill: r === "game" ? 16777215 : { color: i.line, alpha: 0.9 }, stroke: i.line, font: { family: i.font, size: i.size, bold: !0, color: i.accent } });
|
|
3524
|
+
await this.flash.overlay.text(t, { parent: a, x: 20, y: 0, font: { family: i.font, size: i.size, color: r === "game" ? i.ink : i.light } });
|
|
3525
|
+
const d = /* @__PURE__ */ new Set(), c = async (h) => {
|
|
3526
|
+
s = h, await o.setLabel(h ? "x" : "");
|
|
3527
|
+
};
|
|
3528
|
+
return o.on("click", () => {
|
|
3529
|
+
c(!s).then(() => d.forEach((h) => h(s)));
|
|
3530
|
+
}), this.widget(a, r, { checked: () => s, setChecked: c, onChange: (h) => (d.add(h), async () => {
|
|
3531
|
+
d.delete(h);
|
|
3532
|
+
}) });
|
|
3533
|
+
}
|
|
3534
|
+
async dropdown(t) {
|
|
3535
|
+
var n;
|
|
3536
|
+
const r = t.skin ?? this.defaultSkin, i = await this.theme(r), a = t.width ?? 140, s = t.height ?? Ye[r], o = await this.flash.overlay.group({ x: t.x ?? 0, y: t.y ?? 0, ...t.parent ? { parent: M(t.parent) } : {}, ...t.visible === void 0 ? {} : { visible: t.visible } });
|
|
3537
|
+
let d = [...t.choices], c = t.value ?? ((n = d[0]) == null ? void 0 : n.value) ?? null;
|
|
3538
|
+
const h = (p) => {
|
|
3539
|
+
var g;
|
|
3540
|
+
return ((g = d.find((v) => v.value === p)) == null ? void 0 : g.label) ?? t.placeholder ?? "Choose...";
|
|
3541
|
+
}, m = await this.flash.overlay.button(h(c), { parent: o, width: a, height: s, cornerRadius: i.cornerRadius, ...se(i, !1), font: { family: i.font, size: i.size, color: r === "game" ? i.ink : i.light } }), u = await this.flash.overlay.list({ parent: o, y: s + 2, width: a, height: Math.min(140, Math.max(20, d.length * 16 + 8)), visible: !1, fill: r === "game" ? i.light : { color: i.ink, alpha: 0.96 }, stroke: i.line, cornerRadius: i.cornerRadius, rows: d.map((p) => p.label), font: { family: i.font, size: i.size, color: r === "game" ? i.ink : i.light } });
|
|
3542
|
+
let f = !1;
|
|
3543
|
+
const y = /* @__PURE__ */ new Set();
|
|
3544
|
+
return m.on("click", () => {
|
|
3545
|
+
f = !f, f ? u.show() : u.hide();
|
|
3546
|
+
}), u.on("row", (p) => {
|
|
3547
|
+
const g = d[p];
|
|
3548
|
+
f = !1, u.hide(), g && (c = g.value, m.setLabel(g.label).then(() => y.forEach((v) => v(g.value))));
|
|
3549
|
+
}), this.widget(o, r, { value: () => c, setValue: async (p) => {
|
|
3550
|
+
c = p, await m.setLabel(h(p));
|
|
3551
|
+
}, setChoices: async (p) => {
|
|
3552
|
+
d = [...p], await u.setRows(d.map((g) => g.label)), await m.setLabel(h(c));
|
|
3553
|
+
}, onChange: (p) => (y.add(p), async () => {
|
|
3554
|
+
y.delete(p);
|
|
3555
|
+
}) });
|
|
3556
|
+
}
|
|
3557
|
+
async tabs(t) {
|
|
3558
|
+
var n;
|
|
3559
|
+
const r = t.skin ?? this.defaultSkin, i = await this.theme(r), a = t.width ?? 260, s = t.tabHeight ?? 22, o = await this.flash.overlay.group({ x: t.x ?? 0, y: t.y ?? 0, ...t.parent ? { parent: M(t.parent) } : {}, ...t.visible === void 0 ? {} : { visible: t.visible } }), d = ha(t.tabs.map((y) => y.value), { width: a, gap: 2 });
|
|
3560
|
+
let c = t.value ?? ((n = t.tabs[0]) == null ? void 0 : n.value) ?? "";
|
|
3561
|
+
const h = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Set();
|
|
3562
|
+
for (const y of d) {
|
|
3563
|
+
const p = t.tabs[y.index];
|
|
3564
|
+
m.set(p.value, await this.flash.overlay.button(p.label, { parent: o, x: y.x, width: y.width, height: s, cornerRadius: i.cornerRadius, ...se(i, p.value === c), font: { family: i.font, size: i.size, bold: p.value === c, color: p.value === c || r === "phantom" ? i.light : i.ink } })), h.set(p.value, await this.flash.overlay.group({ parent: o, y: s + 4, visible: p.value === c }));
|
|
3565
|
+
}
|
|
3566
|
+
const f = async (y) => {
|
|
3567
|
+
if (h.has(y)) {
|
|
3568
|
+
c = y;
|
|
3569
|
+
for (const [p, g] of h) await (p === y ? g.show() : g.hide());
|
|
3570
|
+
for (const [p, g] of m) await g.update({ ...se(i, p === y), font: { family: i.font, size: i.size, bold: p === y, color: p === y || r === "phantom" ? i.light : i.ink } });
|
|
3571
|
+
}
|
|
3572
|
+
};
|
|
3573
|
+
for (const [y, p] of m) p.on("click", () => {
|
|
3574
|
+
f(y).then(() => u.forEach((g) => g(y)));
|
|
3575
|
+
});
|
|
3576
|
+
return this.widget(o, r, { current: () => c, select: f, body: (y) => {
|
|
3577
|
+
const p = h.get(y);
|
|
3578
|
+
if (!p) throw new TypeError(`There is no tab called "${y}"`);
|
|
3579
|
+
return p;
|
|
3580
|
+
}, onSelect: (y) => (u.add(y), async () => {
|
|
3581
|
+
u.delete(y);
|
|
3582
|
+
}) });
|
|
3583
|
+
}
|
|
3584
|
+
async list(t = {}) {
|
|
3585
|
+
const n = t.skin ?? this.defaultSkin, r = await this.theme(n), i = await this.flash.overlay.list({ ...this.box(t, { width: 240, height: 160 }), ...t.rows === void 0 ? {} : { rows: [...t.rows] }, ...t.maxRows === void 0 ? {} : { maxRows: t.maxRows }, fill: n === "game" ? r.light : { color: r.ink, alpha: 0.85 }, stroke: r.line, cornerRadius: r.cornerRadius, font: { family: r.font, size: r.size, color: n === "game" ? r.ink : r.light } });
|
|
3586
|
+
return this.widget(i, n, { setRows: (a) => i.setRows([...a]), append: (...a) => i.append(...a), onRow: (a) => {
|
|
3587
|
+
const s = i.on("row", xe(a));
|
|
3588
|
+
return async () => {
|
|
3589
|
+
await s();
|
|
3590
|
+
};
|
|
3591
|
+
} });
|
|
3592
|
+
}
|
|
3593
|
+
async grid(t) {
|
|
3594
|
+
const n = t.skin ?? this.defaultSkin, r = await this.theme(n), i = { columns: t.columns ?? 4, tileWidth: t.tileWidth ?? 48, tileHeight: t.tileHeight ?? 48, gap: t.gap ?? 4 }, a = await this.flash.overlay.group({ x: t.x ?? 0, y: t.y ?? 0, ...t.parent ? { parent: M(t.parent) } : {}, ...t.visible === void 0 ? {} : { visible: t.visible } }), s = /* @__PURE__ */ new Set(), o = [], d = async (c) => {
|
|
3595
|
+
for (const m of o.splice(0)) await m.remove();
|
|
3596
|
+
const h = an({ count: c.length, ...i });
|
|
3597
|
+
for (const m of h) {
|
|
3598
|
+
const u = c[m.index], f = await this.flash.overlay.button(u.label ?? "", { parent: a, x: m.x, y: m.y, width: m.width, height: m.height, cornerRadius: r.cornerRadius, fill: u.color ?? (n === "game" ? r.light : { color: r.ink, alpha: 0.9 }), hoverFill: u.color ?? (n === "game" ? 16777215 : r.line), pressedFill: u.color ?? r.accent, stroke: r.line, ...u.disabled === void 0 ? {} : { disabled: u.disabled }, font: { family: r.font, size: r.size - 2, color: n === "game" ? r.ink : r.light } });
|
|
3599
|
+
f.on("click", () => s.forEach((y) => y(u.value, m.index))), o.push(f), u.image !== void 0 && o.push(await this.flash.overlay.image(u.image, { parent: a, x: m.x + 2, y: m.y + 2, width: m.width - 4, height: m.height - 4 }));
|
|
3600
|
+
}
|
|
3601
|
+
};
|
|
3602
|
+
return await d(t.items), this.widget(a, n, { setItems: d, onSelect: (c) => (s.add(c), async () => {
|
|
3603
|
+
s.delete(c);
|
|
3604
|
+
}) });
|
|
3605
|
+
}
|
|
3606
|
+
async scroll(t = {}) {
|
|
3607
|
+
const n = t.skin ?? this.defaultSkin, r = await this.theme(n), i = t.width ?? 220, a = t.height ?? 120, s = t.step ?? 32, o = await this.flash.overlay.panel({ x: t.x ?? 0, y: t.y ?? 0, width: i, height: a, titleHeight: 0, draggable: !1, cornerRadius: r.cornerRadius, fill: n === "game" ? { color: r.light, alpha: 0.9 } : { color: r.ink, alpha: 0.85 }, stroke: r.line, ...t.parent ? { parent: M(t.parent) } : {}, ...t.visible === void 0 ? {} : { visible: t.visible } }), d = await this.flash.overlay.group({ parent: o, x: 0, y: 0 });
|
|
3608
|
+
let c = t.contentHeight ?? a, h = 0;
|
|
3609
|
+
const m = async (u) => {
|
|
3610
|
+
h = ma({ contentHeight: c, viewHeight: a, offset: u, trackHeight: a }).offset, await d.update({ y: -h });
|
|
3611
|
+
};
|
|
3612
|
+
for (const [u, f, y] of [["^", -s, 0], ["v", s, a - 16]]) (await this.flash.overlay.button(u, { parent: o, x: i - 16, y, width: 14, height: 14, cornerRadius: Math.min(3, r.cornerRadius), ...se(r, !1), font: { family: r.font, size: r.size - 2, bold: !0, color: n === "game" ? r.ink : r.light } })).on("click", () => {
|
|
3613
|
+
m(h + f);
|
|
3614
|
+
});
|
|
3615
|
+
return this.widget(o, n, { body: d, offset: () => h, scrollTo: m, setContentHeight: async (u) => {
|
|
3616
|
+
c = u, await m(h);
|
|
3617
|
+
} });
|
|
3618
|
+
}
|
|
3619
|
+
async tooltip(t = {}) {
|
|
3620
|
+
const n = t.skin ?? this.defaultSkin, r = t.text ?? "";
|
|
3621
|
+
if (n === "game") {
|
|
3622
|
+
const s = await this.clientTooltip(r, t);
|
|
3623
|
+
if (s) return s;
|
|
3624
|
+
}
|
|
3625
|
+
const i = await this.theme(n), a = await this.flash.overlay.text(r, { x: t.x ?? 0, y: t.y ?? 0, visible: t.visible === !0, ...t.parent ? { parent: M(t.parent) } : {}, background: n === "game" ? { color: i.light, alpha: 0.95 } : { color: i.ink, alpha: 0.92 }, padding: 4, font: { family: i.font, size: i.size, color: n === "game" ? i.ink : i.light } });
|
|
3626
|
+
return this.widget(a, n, { setText: (s) => a.update({ text: s }), showAt: async (s, o) => {
|
|
3627
|
+
await a.update({ x: s, y: o, visible: !0 });
|
|
3628
|
+
} });
|
|
3629
|
+
}
|
|
3630
|
+
async progress(t = {}) {
|
|
3631
|
+
const n = t.skin ?? this.defaultSkin, r = await this.theme(n), i = t.width ?? 200, a = t.height ?? 16, s = await this.flash.overlay.group({ x: t.x ?? 0, y: t.y ?? 0, ...t.parent ? { parent: M(t.parent) } : {}, ...t.visible === void 0 ? {} : { visible: t.visible } });
|
|
3632
|
+
await this.flash.overlay.rect({ parent: s, width: i, height: a, cornerRadius: r.cornerRadius, fill: n === "game" ? r.light : { color: r.ink, alpha: 0.9 }, stroke: r.line });
|
|
3633
|
+
let o = sn(t.value ?? 0);
|
|
3634
|
+
const d = await this.flash.overlay.rect({ parent: s, width: Math.round(i * o), height: a, cornerRadius: r.cornerRadius, fill: r.accent }), c = await this.flash.overlay.text(t.label ?? "", { parent: s, x: Math.round(i / 2), y: Math.round(a / 2), centered: !0, font: { family: r.font, size: r.size - 1, bold: !0, color: n === "game" ? r.ink : r.light } });
|
|
3635
|
+
return this.widget(s, n, { value: () => o, setValue: async (h) => {
|
|
3636
|
+
o = sn(h), await d.update({ width: Math.round(i * o) });
|
|
3637
|
+
}, setLabel: (h) => c.update({ text: h }) });
|
|
3638
|
+
}
|
|
3639
|
+
async colors(t = {}) {
|
|
3640
|
+
const n = t.skin ?? this.defaultSkin, r = t.columns ?? 10, i = t.swatchWidth ?? 24, a = t.swatchHeight ?? 30, { values: s, indexes: o } = await this.palette(t.palette ?? 1), d = /* @__PURE__ */ new Set();
|
|
3641
|
+
let c = t.value ?? o[0] ?? 0;
|
|
3642
|
+
const h = (f) => {
|
|
3643
|
+
c = f, d.forEach((y) => y(f, s[f] ?? 0));
|
|
3644
|
+
}, m = Math.max(1, Math.ceil(o.length / r)), u = n === "game" ? await this.clientColorTable({ columns: r, rows: m, width: r * i, height: m * a, values: s, indexes: o, current: c, options: t, tell: h }) : await this.swatchGrid({ columns: r, swatchWidth: i, swatchHeight: a, values: s, indexes: o, options: t, tell: h });
|
|
3645
|
+
return this.widget(u, n, { value: () => c, onPick: (f) => (d.add(f), async () => {
|
|
3646
|
+
d.delete(f);
|
|
3647
|
+
}) });
|
|
3648
|
+
}
|
|
3649
|
+
async paletteValues(t = "game") {
|
|
3650
|
+
const { values: n, indexes: r } = await this.palette(t);
|
|
3651
|
+
return r.map((i) => n[i] ?? 0);
|
|
3652
|
+
}
|
|
3653
|
+
places() {
|
|
3654
|
+
const t = Object.keys(tn);
|
|
3655
|
+
return [nn, ...t, ...wa];
|
|
3656
|
+
}
|
|
3657
|
+
place(t) {
|
|
3658
|
+
if (t === nn) return this.bridge.stage();
|
|
3659
|
+
const n = tn[t];
|
|
3660
|
+
return n ? this.bridge.definition(n.className).at(...n.path) : this.bridge.definition(O.guiManager).at("mainHud", t);
|
|
3661
|
+
}
|
|
3662
|
+
async attach(t, n) {
|
|
3663
|
+
const r = M(n);
|
|
3664
|
+
return await this.flash.overlay.attach(this.placeOf(t), r), () => r.remove();
|
|
3665
|
+
}
|
|
3666
|
+
async replace(t, n) {
|
|
3667
|
+
const r = M(n);
|
|
3668
|
+
return await this.flash.overlay.replace(this.placeOf(t), r), () => r.remove();
|
|
3669
|
+
}
|
|
3670
|
+
async hide(t) {
|
|
3671
|
+
const n = await this.flash.hide(this.placeOf(t)), r = async () => {
|
|
3672
|
+
this.drawn.delete(r), await n();
|
|
3673
|
+
};
|
|
3674
|
+
return this.drawn.add(r), r;
|
|
3675
|
+
}
|
|
3676
|
+
piece(t, ...n) {
|
|
3677
|
+
return this.pieceOf(this.placeOf(t), n);
|
|
3678
|
+
}
|
|
3679
|
+
async feed(t, n, r = {}) {
|
|
3680
|
+
return typeof n == "function" ? this.deferredFeed(t, n, r) : this.insideFeed(t, n, r);
|
|
3681
|
+
}
|
|
3682
|
+
async insideFeed(t, n, r) {
|
|
3683
|
+
if (!Object.keys(n).length) throw new TypeError(`A feed of ${t} names no argument to change`);
|
|
3684
|
+
let i = null, a = 0;
|
|
3685
|
+
const s = await this.flash.hook(t, { phase: "enter", capture: { args: !0 }, replaceArgs: n, ...r.when === void 0 ? {} : { when: r.when }, ...r.first === void 0 ? {} : { first: r.first }, ...r.every === void 0 ? {} : { every: r.every }, ...r.perFrame === void 0 ? {} : { perFrame: r.perFrame } }, (o) => {
|
|
3686
|
+
a += 1, i = { method: t, call: o.call, args: [...o.argList], named: { ...o.args }, on: this.pieceOf(this.bridge.stage(), []) };
|
|
3687
|
+
});
|
|
3688
|
+
return this.feedOf(t, !0, s, () => a, () => i);
|
|
3689
|
+
}
|
|
3690
|
+
async deferredFeed(t, n, r) {
|
|
3691
|
+
if (r.deferred !== !0) throw new TypeError(`A feed of ${t} was given a function, which cannot run inside the call: the client's method is skipped and run again once the function answers. A builder whose result the client uses in the same breath comes up empty that way. Give the arguments themselves to change them inside the call, or set "deferred" to say the waiting is understood.`);
|
|
3692
|
+
let i = null, a = 0;
|
|
3693
|
+
const s = async (c) => {
|
|
3694
|
+
a += 1;
|
|
3695
|
+
const h = { method: t, call: c.call, args: [...c.argList], named: { ...c.args }, on: this.pieceOf(he(c.self) ?? this.bridge.stage(), []) };
|
|
3696
|
+
i = h;
|
|
3697
|
+
const m = await n(h);
|
|
3698
|
+
if (!m) {
|
|
3699
|
+
await c.original();
|
|
3700
|
+
return;
|
|
3701
|
+
}
|
|
3702
|
+
const u = [...h.args];
|
|
3703
|
+
for (const [f, y] of Object.entries(m)) {
|
|
3704
|
+
const p = /^\d+$/.test(f) ? Number(f) : c.hook.parameters.findIndex((g) => g.name === f);
|
|
3705
|
+
if (p < 0 || p >= u.length) {
|
|
3706
|
+
const g = c.hook.parameters.map((v) => v.name).join(", ");
|
|
3707
|
+
throw new TypeError(`${t} has no argument "${f}" (its arguments: ${g})`);
|
|
3708
|
+
}
|
|
3709
|
+
u[p] = y;
|
|
3710
|
+
}
|
|
3711
|
+
await c.original(...u);
|
|
3712
|
+
}, o = {};
|
|
3713
|
+
r.when !== void 0 && (o.when = r.when), r.first !== void 0 && (o.first = r.first), r.every !== void 0 && (o.every = r.every), r.sequential !== void 0 && (o.sequential = r.sequential), r.perFrame !== void 0 && (o.perFrame = r.perFrame), r.returns !== void 0 && (o.returns = r.returns);
|
|
3714
|
+
const d = await this.flash.override(t, s, o);
|
|
3715
|
+
return this.feedOf(t, !1, d, () => a, () => i);
|
|
3716
|
+
}
|
|
3717
|
+
feedOf(t, n, r, i, a) {
|
|
3718
|
+
const s = async () => {
|
|
3719
|
+
this.drawn.delete(s), await r();
|
|
3720
|
+
};
|
|
3721
|
+
this.drawn.add(s);
|
|
3722
|
+
const o = s;
|
|
3723
|
+
return Object.defineProperty(o, "method", { value: t, enumerable: !0 }), Object.defineProperty(o, "inside", { value: n, enumerable: !0 }), Object.defineProperty(o, "calls", { get: i, enumerable: !0 }), Object.defineProperty(o, "last", { value: a, enumerable: !0 }), o;
|
|
3724
|
+
}
|
|
3725
|
+
screens() {
|
|
3726
|
+
return Object.keys(rn);
|
|
3727
|
+
}
|
|
3728
|
+
onScreen(t, n) {
|
|
3729
|
+
const r = rn[t];
|
|
3730
|
+
let i = !0;
|
|
3731
|
+
const a = [];
|
|
3732
|
+
return (async () => {
|
|
3733
|
+
for (const [s, o] of [[r.open, !0], [r.close, !1]]) {
|
|
3734
|
+
const d = await this.flash.hook(s, { phase: o ? "exit" : "enter", capture: { args: [] } }, () => n({ name: t, open: o, spot: r.spot }));
|
|
3735
|
+
if (!i) {
|
|
3736
|
+
await d();
|
|
3737
|
+
return;
|
|
3738
|
+
}
|
|
3739
|
+
a.push(d);
|
|
3740
|
+
}
|
|
3741
|
+
})().catch((s) => {
|
|
3742
|
+
console.error(`phantom.ui.onScreen could not hook ${t}: ${on(s)}`);
|
|
3743
|
+
}), () => {
|
|
3744
|
+
i = !1;
|
|
3745
|
+
for (const s of a.splice(0)) s().catch(() => {
|
|
3746
|
+
});
|
|
3747
|
+
};
|
|
3748
|
+
}
|
|
3749
|
+
async clear() {
|
|
3750
|
+
for (const t of [...this.popups]) await t().catch(() => {
|
|
3751
|
+
});
|
|
3752
|
+
for (const t of [...this.drawn]) await t().catch(() => {
|
|
3753
|
+
});
|
|
3754
|
+
}
|
|
3755
|
+
pieceOf(t, n) {
|
|
3756
|
+
const r = he(t);
|
|
3757
|
+
if (!r) throw new TypeError("Expected a place in the client, or one of Phantom's spots");
|
|
3758
|
+
const i = r.at(...n);
|
|
3759
|
+
return { place: i, at: (...a) => this.pieceOf(i, a), exists: async () => {
|
|
3760
|
+
try {
|
|
3761
|
+
return await i.get() != null;
|
|
3762
|
+
} catch {
|
|
3763
|
+
return !1;
|
|
3764
|
+
}
|
|
3765
|
+
}, get: async (...a) => {
|
|
3766
|
+
try {
|
|
3767
|
+
const s = await i.at(...a).get();
|
|
3768
|
+
return S(this.bridge, s) ?? null;
|
|
3769
|
+
} catch {
|
|
3770
|
+
return null;
|
|
3771
|
+
}
|
|
3772
|
+
}, set: (a, s) => i.at(...typeof a == "string" ? [a] : a).set(s), read: async (...a) => {
|
|
3773
|
+
const s = await Promise.all(a.map((d) => i.at(d).get().catch(() => null))), o = {};
|
|
3774
|
+
return a.forEach((d, c) => {
|
|
3775
|
+
o[d] = S(this.bridge, s[c] ?? null);
|
|
3776
|
+
}), o;
|
|
3777
|
+
}, call: async (a, ...s) => {
|
|
3778
|
+
const o = await Q(this.bridge, s);
|
|
3779
|
+
return S(this.bridge, await i.at(a).call(...o));
|
|
3780
|
+
}, on: async (a, s) => {
|
|
3781
|
+
const o = await i.listen(a, (c) => s(S(this.bridge, c))), d = async () => {
|
|
3782
|
+
this.drawn.delete(d), await o();
|
|
3783
|
+
};
|
|
3784
|
+
return this.drawn.add(d), d;
|
|
3785
|
+
}, attach: (a) => this.attach(i, a), replace: (a) => this.replace(i, a), hide: () => this.hide(i), use: () => q(this.bridge, i) };
|
|
3786
|
+
}
|
|
3787
|
+
widget(t, n, r) {
|
|
3788
|
+
const i = async () => {
|
|
3789
|
+
this.drawn.delete(i), await t.remove();
|
|
3790
|
+
};
|
|
3791
|
+
this.drawn.add(i);
|
|
3792
|
+
const a = { skin: n, node: t, move: (s, o) => t.update({ x: s, y: o }), show: () => t.show(), hide: () => t.hide(), remove: i, ...r };
|
|
3793
|
+
for (const [s, o] of Object.entries(a)) Object.defineProperty(i, s, { value: o, enumerable: !0, configurable: !0 });
|
|
3794
|
+
return i;
|
|
3795
|
+
}
|
|
3796
|
+
box(t, n) {
|
|
3797
|
+
return { x: t.x ?? 0, y: t.y ?? 0, width: t.width ?? n.width, height: t.height ?? n.height, ...t.parent ? { parent: M(t.parent) } : {}, ...t.visible === void 0 ? {} : { visible: t.visible } };
|
|
3798
|
+
}
|
|
3799
|
+
placeOf(t) {
|
|
3800
|
+
return typeof t == "string" ? this.place(t) : t;
|
|
3801
|
+
}
|
|
3802
|
+
maker() {
|
|
3803
|
+
if (!this.symbolMaker) {
|
|
3804
|
+
const t = this.bridge.definition(O.definitionByName).get().then((n) => {
|
|
3805
|
+
if (!n) throw new TypeError("This client has no GETDEFINITIONBYNAME");
|
|
3806
|
+
return n;
|
|
3807
|
+
});
|
|
3808
|
+
t.catch(() => {
|
|
3809
|
+
this.symbolMaker === t && (this.symbolMaker = null);
|
|
3810
|
+
}), this.symbolMaker = t;
|
|
3811
|
+
}
|
|
3812
|
+
return this.symbolMaker;
|
|
3813
|
+
}
|
|
3814
|
+
nodeObject(t) {
|
|
3815
|
+
return new J(this.bridge, { kind: "overlay" }, []).at("getChildByName").call(`phantomNode${t.node}`);
|
|
3816
|
+
}
|
|
3817
|
+
clientFont() {
|
|
3818
|
+
if (!this.gameFont) {
|
|
3819
|
+
const t = this.bridge.definition(O.fonts), n = (async () => {
|
|
3820
|
+
for (const r of [["defaultFontFormat", "font"], ["defaultFont", "fontName"]]) try {
|
|
3821
|
+
const i = await t.at(...r).get();
|
|
3822
|
+
if (typeof i == "string" && i.length > 0) return i;
|
|
3823
|
+
} catch {
|
|
3824
|
+
}
|
|
3825
|
+
return ot;
|
|
3826
|
+
})();
|
|
3827
|
+
n.catch(() => {
|
|
3828
|
+
this.gameFont === n && (this.gameFont = null);
|
|
3829
|
+
}), this.gameFont = n;
|
|
3830
|
+
}
|
|
3831
|
+
return this.gameFont;
|
|
3832
|
+
}
|
|
3833
|
+
async frameOnly(t) {
|
|
3834
|
+
const n = await t.at("numChildren").get() ?? 0;
|
|
3835
|
+
for (let r = 0; r < Math.min(n, 32); r += 1) {
|
|
3836
|
+
const i = await t.at("getChildAt").call(r);
|
|
3837
|
+
try {
|
|
3838
|
+
await i.at("name").get() !== "ba" && await i.at("visible").set(!1);
|
|
3839
|
+
} finally {
|
|
3840
|
+
await this.bridge.release([i]).catch(() => {
|
|
3841
|
+
});
|
|
3842
|
+
}
|
|
3843
|
+
}
|
|
3844
|
+
}
|
|
3845
|
+
async dressWindow(t, n) {
|
|
3846
|
+
try {
|
|
3847
|
+
const r = await (await this.maker()).at("apply").call(null, ["PopupSkin", !1]), i = r.at("ba"), a = await i.at("t", "height").get() ?? 0, s = await i.at("b", "height").get() ?? 0, o = Math.max(0, n.height - a - s);
|
|
3848
|
+
await i.at("m", "height").set(o), await i.at("m", "y").set(-(o / 2)), await i.at("t", "y").set(-(o / 2) - a), await i.at("b", "y").set(o / 2);
|
|
3849
|
+
const d = await r.at("width").get() ?? n.width, c = await r.at("height").get() ?? n.height;
|
|
3850
|
+
return await r.at("x").set(d / 2), await r.at("y").set(c / 2), await this.frameOnly(r), await (await this.nodeObject(t)).at("addChildAt").call(r, 0), { width: d, height: c, top: a };
|
|
3851
|
+
} catch {
|
|
3852
|
+
return await t.update({ fill: { color: Ce.light, alpha: 0.96 }, stroke: { color: Ce.line, width: 2 }, titleFill: Ce.line }), { ...n, top: 0 };
|
|
3853
|
+
}
|
|
3854
|
+
}
|
|
3855
|
+
async clientTooltip(t, n) {
|
|
3856
|
+
let r;
|
|
3857
|
+
try {
|
|
3858
|
+
r = await this.symbol("Tooltip", { skin: "game", x: n.x ?? 0, y: n.y ?? 0, visible: n.visible === !0, ...n.parent ? { parent: n.parent } : {} });
|
|
3859
|
+
} catch {
|
|
3860
|
+
return null;
|
|
3861
|
+
}
|
|
3862
|
+
const i = async (a) => {
|
|
3863
|
+
await r.object.at("setToolTipText").call(a);
|
|
3864
|
+
};
|
|
3865
|
+
try {
|
|
3866
|
+
t && await i(t);
|
|
3867
|
+
} catch {
|
|
3868
|
+
return await r.remove(), null;
|
|
3869
|
+
}
|
|
3870
|
+
return Object.assign(r, { setText: i, showAt: async (a, s) => {
|
|
3871
|
+
await r.node.update({ x: a, y: s, visible: !0 });
|
|
3872
|
+
} });
|
|
3873
|
+
}
|
|
3874
|
+
async palette(t) {
|
|
3875
|
+
const n = this.bridge.definition(O.palette), r = await n.at("gamePalette").get() ?? [];
|
|
3876
|
+
if (!r.length) throw new TypeError("The client has no palette yet: it is set as the game loads");
|
|
3877
|
+
if (t === "game") return { values: r, indexes: r.map((a, s) => s) };
|
|
3878
|
+
const i = await n.at(t === 1 ? "avatarPalette1" : "avatarPalette2").get() ?? [];
|
|
3879
|
+
return { values: r, indexes: i.length ? i : r.map((a, s) => s) };
|
|
3880
|
+
}
|
|
3881
|
+
async clientColorTable(t) {
|
|
3882
|
+
const n = await this.flash.overlay.group({ x: t.options.x ?? 0, y: t.options.y ?? 0, ...t.options.parent ? { parent: M(t.options.parent) } : {}, ...t.options.visible === void 0 ? {} : { visible: t.options.visible } }), r = await this.bridge.construct(O.colorTable);
|
|
3883
|
+
return await r.at("init").call(0, t.width, t.height, t.columns, t.rows, t.values, t.indexes, t.current, (i, a) => t.tell(Number(a)), -1), await (await this.nodeObject(n)).at("addChild").call(r), n;
|
|
3884
|
+
}
|
|
3885
|
+
async swatchGrid(t) {
|
|
3886
|
+
const n = await this.flash.overlay.group({ x: t.options.x ?? 0, y: t.options.y ?? 0, ...t.options.parent ? { parent: M(t.options.parent) } : {}, ...t.options.visible === void 0 ? {} : { visible: t.options.visible } }), r = an({ count: t.indexes.length, columns: t.columns, tileWidth: t.swatchWidth, tileHeight: t.swatchHeight, gap: 1 });
|
|
3887
|
+
for (const i of r) {
|
|
3888
|
+
const a = t.indexes[i.index];
|
|
3889
|
+
(await this.flash.overlay.button("", { parent: n, x: i.x, y: i.y, width: i.width, height: i.height, cornerRadius: 2, fill: t.values[a] ?? 0, hoverFill: t.values[a] ?? 0, stroke: { color: jn.line, alpha: 0.6 } })).on("click", () => t.tell(a));
|
|
3890
|
+
}
|
|
3891
|
+
return n;
|
|
3892
|
+
}
|
|
3893
|
+
openPopup(t, n, r, i, a) {
|
|
3894
|
+
let s = () => {
|
|
3895
|
+
};
|
|
3896
|
+
const o = new Promise((p) => {
|
|
3897
|
+
s = p;
|
|
3898
|
+
});
|
|
3899
|
+
let d = null, c = !1, h = null;
|
|
3900
|
+
const m = (p) => {
|
|
3901
|
+
c || (c = !0, h && clearTimeout(h), h = null, this.popups.delete(f), s(p));
|
|
3902
|
+
}, u = () => {
|
|
3903
|
+
c || h || (h = setTimeout(() => m(a), fa));
|
|
3904
|
+
}, f = async () => {
|
|
3905
|
+
const p = d;
|
|
3906
|
+
d = null, m(a), p && await p.at("destroy").call().catch(() => {
|
|
3907
|
+
});
|
|
3908
|
+
};
|
|
3909
|
+
this.popups.add(f);
|
|
3910
|
+
const y = ua(t, n, r);
|
|
3911
|
+
return (async () => {
|
|
3912
|
+
const p = this.bridge.definition(r.layer === "load" ? O.loadProgress : O.guiManager).at(r.layer === "load" ? "loadLayer" : "guiLayer"), g = [];
|
|
3913
|
+
for (const k of y.args) {
|
|
3914
|
+
if (k !== null && typeof k == "object") {
|
|
3915
|
+
if (k.slot === "layer") g.push(await p.get());
|
|
3916
|
+
else if (k.slot === "callback") g.push((...T) => m(i(T[0] ?? null)));
|
|
3917
|
+
else {
|
|
3918
|
+
const T = await this.maker();
|
|
3919
|
+
g.push(await T.at("apply").call(null, ["PopupSkin", !1]));
|
|
3920
|
+
}
|
|
3921
|
+
continue;
|
|
3922
|
+
}
|
|
3923
|
+
g.push(k);
|
|
3924
|
+
}
|
|
3925
|
+
const v = await this.bridge.construct(y.className, ...g);
|
|
3926
|
+
d = v, await v.at("closeCallback").set(() => u()).catch(() => {
|
|
3927
|
+
});
|
|
3928
|
+
})().catch((p) => {
|
|
3929
|
+
this.popups.delete(f), c || (c = !0, s(a)), console.error(`phantom.ui.popup.${t} could not open: ${on(p)}`);
|
|
3930
|
+
}), Object.assign(o, { close: f });
|
|
3931
|
+
}
|
|
3932
|
+
}
|
|
3933
|
+
class ga {
|
|
3934
|
+
constructor(t, n) {
|
|
3935
|
+
this.open = t, this.closeEverything = n;
|
|
3936
|
+
}
|
|
3937
|
+
open;
|
|
3938
|
+
closeEverything;
|
|
3939
|
+
message(t, n = {}) {
|
|
3940
|
+
return this.open("message", t, n, () => {
|
|
3941
|
+
}, void 0);
|
|
3942
|
+
}
|
|
3943
|
+
ok(t, n = {}) {
|
|
3944
|
+
return this.open("ok", t, n, () => {
|
|
3945
|
+
}, void 0);
|
|
3946
|
+
}
|
|
3947
|
+
okCancel(t, n = {}) {
|
|
3948
|
+
return this.open("okCancel", t, n, Je, null);
|
|
3949
|
+
}
|
|
3950
|
+
yesNo(t, n = {}) {
|
|
3951
|
+
return this.open("yesNo", t, n, Je, null);
|
|
3952
|
+
}
|
|
3953
|
+
titled(t, n = {}) {
|
|
3954
|
+
return this.open("titled", t, n, () => {
|
|
3955
|
+
}, void 0);
|
|
3956
|
+
}
|
|
3957
|
+
parchment(t, n = {}) {
|
|
3958
|
+
return this.open("parchment", t, n, Je, null);
|
|
3959
|
+
}
|
|
3960
|
+
async closeAll() {
|
|
3961
|
+
await this.closeEverything();
|
|
3962
|
+
}
|
|
3963
|
+
}
|
|
3964
|
+
const fa = 50, ya = { click: "click", down: "mouseDown", up: "mouseUp", over: "rollOver", out: "rollOut" }, wa = ["chatBar", "chatHist", "chatTxt", "sendChatBtn", "safeChatBtn", "actionsBtn", "emotesBtn", "denBtn", "worldMapBtn", "buddyListBtn", "newsBtn", "partyBtn", "mySettingsBtn", "money", "zoneName"];
|
|
3965
|
+
function M(e) {
|
|
3966
|
+
if (!e) throw new TypeError("Expected a widget or an overlay node");
|
|
3967
|
+
return typeof e.node == "number" ? e : e.node;
|
|
3968
|
+
}
|
|
3969
|
+
function se(e, t) {
|
|
3970
|
+
return t ? { fill: e.accent, hoverFill: { color: e.accent, alpha: 0.85 }, pressedFill: { color: e.accent, alpha: 0.7 }, stroke: e.line } : e.skin === "game" ? { fill: e.light, hoverFill: 16777215, pressedFill: e.line, stroke: e.line } : { fill: { color: e.ink, alpha: 0.92 }, hoverFill: e.line, pressedFill: { color: e.line, alpha: 0.7 }, stroke: e.line };
|
|
3971
|
+
}
|
|
3972
|
+
function Je(e) {
|
|
3973
|
+
if (e !== null && typeof e == "object" && !Array.isArray(e)) {
|
|
3974
|
+
const t = e.status;
|
|
3975
|
+
if (typeof t == "boolean") return t;
|
|
3976
|
+
}
|
|
3977
|
+
return null;
|
|
3978
|
+
}
|
|
3979
|
+
function sn(e) {
|
|
3980
|
+
return Number.isFinite(e) ? Math.min(1, Math.max(0, e)) : 0;
|
|
3981
|
+
}
|
|
3982
|
+
function on(e) {
|
|
3983
|
+
return e instanceof Error ? e.message : String(e);
|
|
3984
|
+
}
|
|
3985
|
+
function va(e, t, n) {
|
|
3986
|
+
return new Gi(new er(ba(e, t), { firstId: n }));
|
|
3987
|
+
}
|
|
3988
|
+
function ba(e, t) {
|
|
3989
|
+
const n = /* @__PURE__ */ new Set();
|
|
3990
|
+
let r = null;
|
|
3991
|
+
const i = (a) => {
|
|
3992
|
+
for (const s of n) s(a);
|
|
3993
|
+
};
|
|
3994
|
+
return { send(a) {
|
|
3995
|
+
e.call("flash.request", t, [a]).catch((s) => {
|
|
3996
|
+
const o = Ia(a, s);
|
|
3997
|
+
o ? i(o) : e.log("warn", [`A Flash request was refused: ${$(s)}`]);
|
|
3998
|
+
});
|
|
3999
|
+
}, onMessage(a) {
|
|
4000
|
+
return n.add(a), r ??= e.subscribe("flash.messages", t, { event(s) {
|
|
4001
|
+
const [o] = s;
|
|
4002
|
+
typeof o == "string" && i(o);
|
|
4003
|
+
}, ended(s) {
|
|
4004
|
+
r = null, s && e.log("warn", [`Flash stopped answering: ${s.message}`]);
|
|
4005
|
+
} }), () => {
|
|
4006
|
+
n.delete(a), !n.size && r && (r(), r = null);
|
|
4007
|
+
};
|
|
4008
|
+
} };
|
|
4009
|
+
}
|
|
4010
|
+
function Ia(e, t) {
|
|
4011
|
+
let n;
|
|
4012
|
+
try {
|
|
4013
|
+
n = un(e);
|
|
4014
|
+
} catch {
|
|
4015
|
+
return null;
|
|
4016
|
+
}
|
|
4017
|
+
if (typeof (n == null ? void 0 : n.id) != "number") return null;
|
|
4018
|
+
const r = t instanceof C ? t.code : "FAILED", i = t instanceof Error ? t.message : $(t);
|
|
4019
|
+
return re({ kind: "result", id: n.id, ok: !1, error: { name: r, message: i, errorId: 0 } });
|
|
4020
|
+
}
|
|
4021
|
+
function ka(e) {
|
|
4022
|
+
let t = null, n = null;
|
|
4023
|
+
const r = () => {
|
|
4024
|
+
const i = e.flash();
|
|
4025
|
+
return t ??= new ta({ flash: i.bridge, content: xa(e.port, e.game) }, i), t;
|
|
4026
|
+
};
|
|
4027
|
+
return { avatar: { view: () => e.flash().bridge.definition(Ji.avatarManager).at("playerAvatarWorldView").get() }, adventures: { record: () => Ta(e.remote) }, content: { load: (i, a) => r().load(i, a), replaceOnScreen: (i, a, s) => r().replaceOnScreen(i, a, s) }, ui: () => {
|
|
4028
|
+
const i = e.flash();
|
|
4029
|
+
return n ??= new pa({ flash: i.bridge }, i), n;
|
|
4030
|
+
}, recipes: { chatShortcuts: async (i) => Vi(await Qe(e), i), customChatBox: async (i) => Hi(await Qe(e), i), chatHistoryPanel: async (i) => _i(await Qe(e), i) } };
|
|
4031
|
+
}
|
|
4032
|
+
function xa(e, t) {
|
|
4033
|
+
const n = () => {
|
|
4034
|
+
throw new C("NOT_SUPPORTED", "Only holding and releasing content happen in a frame");
|
|
4035
|
+
};
|
|
4036
|
+
return { hold: (r) => e.call("content.hold", t, [r]), release: (r) => e.call("content.release", t, [r]), replace: n, restore: n, list: n, observe: n };
|
|
4037
|
+
}
|
|
4038
|
+
function Ta(e) {
|
|
4039
|
+
const t = Date.now(), n = [];
|
|
4040
|
+
let r = null, i = null;
|
|
4041
|
+
const a = () => {
|
|
4042
|
+
r === null && e.adventures.current().then((o) => r ??= (o == null ? void 0 : o.scriptDefId) ?? null).catch(() => {
|
|
4043
|
+
}), i === null && e.adventures.actor("diff_level").then((o) => i ??= (o == null ? void 0 : o.state) ?? null).catch(() => {
|
|
4044
|
+
});
|
|
4045
|
+
};
|
|
4046
|
+
a();
|
|
4047
|
+
const s = e.adventures.onStep(({ time: o, ...d }) => {
|
|
4048
|
+
a(), n.push({ ...d, at: o - t });
|
|
4049
|
+
});
|
|
4050
|
+
return { stop: () => (s(), { version: 1, scriptDefId: r, difficulty: i, steps: [...n] }) };
|
|
4051
|
+
}
|
|
4052
|
+
async function Qe(e) {
|
|
4053
|
+
const t = e.flash(), { remote: n } = e, r = [...await n.chat.recent()], i = /* @__PURE__ */ new Map();
|
|
4054
|
+
for (const a of await n.room.players.list()) i.set(a.userId, a);
|
|
4055
|
+
return n.room.players.onEnter((a) => i.set(a.userId, a)), n.room.players.onLeave((a) => i.delete(a.userId)), n.chat.onMessage((a) => r.push(a)), { flash: t, chat: { say: n.chat.say, phrase: n.chat.phrase, onMessage: n.chat.onMessage, recent: r }, room: { players: { get: (a) => i.get(a) ?? null } } };
|
|
4056
|
+
}
|
|
4057
|
+
function Na(e, t) {
|
|
4058
|
+
const n = {};
|
|
4059
|
+
for (const r of Object.keys(On)) {
|
|
4060
|
+
const i = r.split(".");
|
|
4061
|
+
let a = n;
|
|
4062
|
+
for (const o of i.slice(0, -1)) a = a[o] ??= {};
|
|
4063
|
+
const s = i[i.length - 1];
|
|
4064
|
+
a[s] = $n(r) ? Sa(e, t, r) : Aa(e, t, r);
|
|
4065
|
+
}
|
|
4066
|
+
return Dn(n);
|
|
4067
|
+
}
|
|
4068
|
+
function Aa(e, t, n) {
|
|
4069
|
+
return (...r) => e.call(`sdk:${n}`, t, r);
|
|
4070
|
+
}
|
|
4071
|
+
function Sa(e, t, n) {
|
|
4072
|
+
return (r) => {
|
|
4073
|
+
if (typeof r != "function") throw new TypeError(`${n} takes a listener function`);
|
|
4074
|
+
return e.subscribe(`sdk:${n}`, t, { event: (i) => r(...i), ended(i) {
|
|
4075
|
+
i && e.log("warn", [`${n} stopped: ${i.code}: ${$(i.message)}`]);
|
|
4076
|
+
} });
|
|
4077
|
+
};
|
|
4078
|
+
}
|
|
4079
|
+
function Dn(e) {
|
|
4080
|
+
for (const t of Object.values(e)) typeof t == "object" && t !== null && Dn(t);
|
|
4081
|
+
return Object.freeze(e);
|
|
4082
|
+
}
|
|
4083
|
+
function cn(e, t, n, r) {
|
|
4084
|
+
const i = (a) => ({ direction: r, ...a === "*" ? {} : { commands: [...a] } });
|
|
4085
|
+
return { send(a) {
|
|
4086
|
+
return e.call("packets.send", t, [n, String(a)]);
|
|
4087
|
+
}, watch(a, s) {
|
|
4088
|
+
return e.subscribe("packets.watch", t, { event(o) {
|
|
4089
|
+
const d = qa(o, r);
|
|
4090
|
+
d && s(An(d.text, d.direction));
|
|
4091
|
+
}, ended: (o) => {
|
|
4092
|
+
o && e.log("warn", [`Watching the traffic stopped: ${o.message}`]);
|
|
4093
|
+
} }, i(a));
|
|
4094
|
+
}, on(a, s) {
|
|
4095
|
+
return e.subscribe("packets.intercept", t, { event: () => {
|
|
4096
|
+
}, intercepted: (o) => {
|
|
4097
|
+
Ca(e, o, s);
|
|
4098
|
+
}, ended: (o) => {
|
|
4099
|
+
o && e.log("warn", [`Hooking the traffic stopped: ${o.message}`]);
|
|
4100
|
+
} }, i(a));
|
|
4101
|
+
} };
|
|
4102
|
+
}
|
|
4103
|
+
async function Ca(e, t, n) {
|
|
4104
|
+
let r;
|
|
4105
|
+
try {
|
|
4106
|
+
r = An(t.text, t.direction), await n(r);
|
|
4107
|
+
} catch (i) {
|
|
4108
|
+
e.log("error", [`A traffic hook failed: ${$(i)}`]), e.verdict(t.requestId, !1, null);
|
|
4109
|
+
return;
|
|
4110
|
+
}
|
|
4111
|
+
e.verdict(t.requestId, r.dropped, r.modified ? r.encode() : null);
|
|
4112
|
+
}
|
|
4113
|
+
function qa(e, t) {
|
|
4114
|
+
const [n, r] = e;
|
|
4115
|
+
if (typeof n == "string") return { text: n, direction: dn(r) ? r : t };
|
|
4116
|
+
if (typeof n == "object" && n !== null) {
|
|
4117
|
+
const { text: i, direction: a } = n;
|
|
4118
|
+
if (typeof i == "string") return { text: i, direction: dn(a) ? a : t };
|
|
4119
|
+
}
|
|
4120
|
+
return null;
|
|
4121
|
+
}
|
|
4122
|
+
function dn(e) {
|
|
4123
|
+
return e === "toServer" || e === "toClient";
|
|
4124
|
+
}
|
|
4125
|
+
function Ma(e) {
|
|
4126
|
+
const t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set();
|
|
4127
|
+
function r(i) {
|
|
4128
|
+
var a, s;
|
|
4129
|
+
const o = i ?? Rn(I.role);
|
|
4130
|
+
if (!o) throw new C("NO_GAME", ((a = I.role) == null ? void 0 : a.kind) === "page" || ((s = I.role) == null ? void 0 : s.kind) === "logic" ? "This frame works with several games: name one, as ctx.phantom(id), from ctx.games()" : "This frame is not bound to a game yet");
|
|
4131
|
+
let d = t.get(o);
|
|
4132
|
+
return d || (d = Ea(e, o), t.set(o, d)), d;
|
|
4133
|
+
}
|
|
4134
|
+
return { ctx: { get plugin() {
|
|
4135
|
+
return I.plugin;
|
|
4136
|
+
}, get granted() {
|
|
4137
|
+
return I.granted;
|
|
4138
|
+
}, get preferences() {
|
|
4139
|
+
return I.preferences;
|
|
4140
|
+
}, can: (i) => ja(I.granted.scopes, i), games: () => [...I.games], onGames(i) {
|
|
4141
|
+
return n.add(i), () => n.delete(i);
|
|
4142
|
+
}, phantom: r, storage: { get: (i) => e.call("storage.get", null, [String(i)]), set: (i, a) => e.call("storage.set", null, [String(i), a]), remove: (i) => e.call("storage.remove", null, [String(i)]), keys: () => e.call("storage.keys", null, []) }, async fetch(i, a) {
|
|
4143
|
+
const s = await e.call("fetch", null, [String(i), a ?? {}]);
|
|
4144
|
+
return Da(s);
|
|
4145
|
+
}, copy: (i) => e.call("copy", null, [String(i)]), notify: (i, a) => e.call("notify", null, a === void 0 ? [String(i)] : [String(i), String(a)]), toast: (i, a) => e.call("toast", null, [String(i), a ?? {}]), confirm: (i, a) => e.call("confirm", null, [String(i), a ?? {}]), openUrl: (i) => e.call("openUrl", null, [String(i)]), log: (...i) => e.log("log", i.map($)) }, notifyGames(i) {
|
|
4146
|
+
for (const a of [...n]) try {
|
|
4147
|
+
a([...i]);
|
|
4148
|
+
} catch (s) {
|
|
4149
|
+
e.log("error", [`An onGames listener failed: ${$(s)}`]);
|
|
4150
|
+
}
|
|
4151
|
+
}, dispose() {
|
|
4152
|
+
n.clear(), t.clear();
|
|
4153
|
+
} };
|
|
4154
|
+
}
|
|
4155
|
+
function Ea(e, t) {
|
|
4156
|
+
let n = null;
|
|
4157
|
+
const r = () => {
|
|
4158
|
+
if (n) return n;
|
|
4159
|
+
if (I.flashIds === null) throw new C("PERMISSION_DENIED", "game.flash needs the flash scope, which this plugin was not granted");
|
|
4160
|
+
return n = va(e, t, I.flashIds), n;
|
|
4161
|
+
}, i = Na(e, t), a = ka({ port: e, game: t, remote: i, flash: r }), s = { ...i, avatar: Object.freeze({ ...i.avatar, ...a.avatar }), adventures: Object.freeze({ ...i.adventures, ...a.adventures }), content: Object.freeze({ ...i.content, ...a.content }), recipes: Object.freeze(a.recipes), id: t, server: cn(e, t, "toServer", "toClient"), client: cn(e, t, "toClient", "toServer") };
|
|
4162
|
+
return Object.defineProperties(s, { flash: { enumerable: !0, get: r }, ui: { enumerable: !0, get: a.ui } }), s;
|
|
4163
|
+
}
|
|
4164
|
+
function ja(e, t) {
|
|
4165
|
+
if (e.includes(t)) return !0;
|
|
4166
|
+
if (!t.startsWith("network:")) return !1;
|
|
4167
|
+
const n = t.slice(8);
|
|
4168
|
+
return e.some((r) => {
|
|
4169
|
+
if (!r.startsWith("network:*.")) return !1;
|
|
4170
|
+
const i = r.slice(9);
|
|
4171
|
+
return n.endsWith(i) && n.length > i.length;
|
|
4172
|
+
});
|
|
4173
|
+
}
|
|
4174
|
+
function Da(e) {
|
|
4175
|
+
const t = e.body ?? "";
|
|
4176
|
+
return { status: e.status, ok: e.status >= 200 && e.status < 300, headers: e.headers ?? {}, text: async () => t, json: async () => JSON.parse(t) };
|
|
4177
|
+
}
|
|
4178
|
+
const Oa = 6e4;
|
|
4179
|
+
function $a(e, t = {}) {
|
|
4180
|
+
const n = t.prefix ?? `f${Math.random().toString(36).slice(2, 10)}-`, r = t.timeoutMs ?? Oa;
|
|
4181
|
+
let i = 0, a = !1;
|
|
4182
|
+
const s = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), d = () => `${n}${i += 1}`;
|
|
4183
|
+
function c(p, g) {
|
|
4184
|
+
if (!a) try {
|
|
4185
|
+
e({ phantom: F, type: "log", level: p, values: g });
|
|
4186
|
+
} catch {
|
|
4187
|
+
}
|
|
4188
|
+
}
|
|
4189
|
+
function h(p, g, v) {
|
|
4190
|
+
if (a) return Promise.reject(new C("FAILED", "The frame was closed"));
|
|
4191
|
+
const k = d();
|
|
4192
|
+
return new Promise((T, j) => {
|
|
4193
|
+
const z = setTimeout(() => {
|
|
4194
|
+
s.delete(k), j(new C("TIMEOUT", `Phantom did not answer ${p} in ${r / 1e3}s`));
|
|
4195
|
+
}, r);
|
|
4196
|
+
s.set(k, { resolve: T, reject: j, timer: z });
|
|
4197
|
+
try {
|
|
4198
|
+
e({ phantom: F, type: "call", id: k, method: p, game: g, args: qe(v) });
|
|
4199
|
+
} catch (E) {
|
|
4200
|
+
clearTimeout(z), s.delete(k), j(new C("FAILED", `${p} could not be sent: ${$(E)}`));
|
|
4201
|
+
}
|
|
4202
|
+
});
|
|
4203
|
+
}
|
|
4204
|
+
function m(p, g, v, k) {
|
|
4205
|
+
if (a) return () => {
|
|
4206
|
+
};
|
|
4207
|
+
const T = d();
|
|
4208
|
+
o.set(T, v);
|
|
4209
|
+
try {
|
|
4210
|
+
e({ phantom: F, type: "subscribe", id: T, topic: p, game: g, ...k ? { filter: qe(k) } : {} });
|
|
4211
|
+
} catch (j) {
|
|
4212
|
+
throw o.delete(T), new C("FAILED", `${p} could not be heard: ${$(j)}`);
|
|
4213
|
+
}
|
|
4214
|
+
return () => {
|
|
4215
|
+
!o.delete(T) || a || e({ phantom: F, type: "unsubscribe", id: T });
|
|
4216
|
+
};
|
|
4217
|
+
}
|
|
4218
|
+
function u(p, g, v) {
|
|
4219
|
+
a || e({ phantom: F, type: "verdict", requestId: p, drop: g, text: v });
|
|
4220
|
+
}
|
|
4221
|
+
function f(p) {
|
|
4222
|
+
switch (p.type) {
|
|
4223
|
+
case "call-result": {
|
|
4224
|
+
const g = s.get(p.id);
|
|
4225
|
+
return g ? (s.delete(p.id), clearTimeout(g.timer), p.ok ? g.resolve(p.value) : g.reject(Hn(p.error)), !0) : !1;
|
|
4226
|
+
}
|
|
4227
|
+
case "event": {
|
|
4228
|
+
const g = o.get(p.subscription);
|
|
4229
|
+
return g ? (y(() => g.event(Array.isArray(p.args) ? p.args : [])), !0) : !1;
|
|
4230
|
+
}
|
|
4231
|
+
case "intercepted": {
|
|
4232
|
+
const g = o.get(p.subscription);
|
|
4233
|
+
return g != null && g.intercepted ? (g.intercepted(p), !0) : (u(p.requestId, !1, null), !!g);
|
|
4234
|
+
}
|
|
4235
|
+
case "subscription-ended": {
|
|
4236
|
+
const g = o.get(p.subscription);
|
|
4237
|
+
return g ? (o.delete(p.subscription), y(() => {
|
|
4238
|
+
var v;
|
|
4239
|
+
return (v = g.ended) == null ? void 0 : v.call(g, p.error);
|
|
4240
|
+
}), !0) : !1;
|
|
4241
|
+
}
|
|
4242
|
+
}
|
|
4243
|
+
}
|
|
4244
|
+
function y(p) {
|
|
4245
|
+
try {
|
|
4246
|
+
p();
|
|
4247
|
+
} catch (g) {
|
|
4248
|
+
c("error", [`A listener failed: ${$(g)}`]);
|
|
4249
|
+
}
|
|
4250
|
+
}
|
|
4251
|
+
return { call: h, subscribe: m, verdict: u, log: c, receive: f, close(p) {
|
|
4252
|
+
if (!a) {
|
|
4253
|
+
a = !0;
|
|
4254
|
+
for (const g of s.values()) clearTimeout(g.timer), g.reject(new C("FAILED", p));
|
|
4255
|
+
s.clear(), o.clear();
|
|
4256
|
+
}
|
|
4257
|
+
} };
|
|
4258
|
+
}
|
|
4259
|
+
function Pa(e, t, n = /* @__PURE__ */ new Set()) {
|
|
4260
|
+
const r = /* @__PURE__ */ new Set();
|
|
4261
|
+
for (const [a, s] of Object.entries((t == null ? void 0 : t.variables) ?? {})) !a.startsWith("--phantom-") || typeof s != "string" || (e.style.setProperty(a, s), r.add(a));
|
|
4262
|
+
for (const a of n) r.has(a) || e.style.removeProperty(a);
|
|
4263
|
+
const i = (t == null ? void 0 : t.mode) === "light" ? "light" : "dark";
|
|
4264
|
+
return e.dataset.theme = i, e.style.setProperty("color-scheme", i), r;
|
|
4265
|
+
}
|
|
4266
|
+
const La = 2e3;
|
|
4267
|
+
function Ua(e, t) {
|
|
4268
|
+
zn(t.development ?? !1);
|
|
4269
|
+
let n = !1, r = /* @__PURE__ */ new Set(), i = null, a = null;
|
|
4270
|
+
function s(w) {
|
|
4271
|
+
var b;
|
|
4272
|
+
n || (e.post(w), (b = t.tap) == null || b.call(t, w));
|
|
4273
|
+
}
|
|
4274
|
+
const o = $a(s), d = Ma(o), c = d.ctx;
|
|
4275
|
+
It(c);
|
|
4276
|
+
function h(w) {
|
|
4277
|
+
var b;
|
|
4278
|
+
const N = Ne(w);
|
|
4279
|
+
try {
|
|
4280
|
+
s({ phantom: F, type: "crash", error: N });
|
|
4281
|
+
} catch {
|
|
4282
|
+
}
|
|
4283
|
+
(b = e.view) == null || b.showError(N, I.development);
|
|
4284
|
+
}
|
|
4285
|
+
let m;
|
|
4286
|
+
const u = new Promise((w) => m = w).then(async () => {
|
|
4287
|
+
try {
|
|
4288
|
+
const w = t.definition, b = await (typeof w == "function" ? w() : w);
|
|
4289
|
+
return i = Fa(b), !0;
|
|
4290
|
+
} catch (w) {
|
|
4291
|
+
return h(w), !1;
|
|
4292
|
+
}
|
|
4293
|
+
}), f = u.then(async (w) => {
|
|
4294
|
+
var b;
|
|
4295
|
+
if (!w || ((b = I.role) == null ? void 0 : b.kind) !== "logic") return w;
|
|
4296
|
+
if (s({ phantom: F, type: "ready", implements: { pages: Te(i == null ? void 0 : i.pages), panels: Te(i == null ? void 0 : i.panels), commands: Te(i == null ? void 0 : i.commands), commandViews: Te(i == null ? void 0 : i.commandViews) } }), !(i != null && i.setup)) return !0;
|
|
4297
|
+
try {
|
|
4298
|
+
const N = await i.setup(c);
|
|
4299
|
+
typeof N == "function" && (n ? j(N) : a = N);
|
|
4300
|
+
} catch (N) {
|
|
4301
|
+
h(N);
|
|
4302
|
+
}
|
|
4303
|
+
return !0;
|
|
4304
|
+
});
|
|
4305
|
+
function y(w) {
|
|
4306
|
+
if (n || !Pn(w)) return;
|
|
4307
|
+
const b = w;
|
|
4308
|
+
switch (b.type) {
|
|
4309
|
+
case "init":
|
|
4310
|
+
p(b);
|
|
4311
|
+
return;
|
|
4312
|
+
case "games":
|
|
4313
|
+
I.games = Array.isArray(b.games) ? b.games : [], d.notifyGames(I.games);
|
|
4314
|
+
return;
|
|
4315
|
+
case "stop":
|
|
4316
|
+
E();
|
|
4317
|
+
return;
|
|
4318
|
+
case "mount":
|
|
4319
|
+
v(b);
|
|
4320
|
+
return;
|
|
4321
|
+
case "invoke":
|
|
4322
|
+
T(b);
|
|
4323
|
+
return;
|
|
4324
|
+
case "call-result":
|
|
4325
|
+
case "event":
|
|
4326
|
+
case "subscription-ended":
|
|
4327
|
+
case "intercepted":
|
|
4328
|
+
o.receive(b);
|
|
4329
|
+
return;
|
|
4330
|
+
}
|
|
4331
|
+
}
|
|
4332
|
+
function p(w) {
|
|
4333
|
+
var b;
|
|
4334
|
+
e.root && w.theme && (r = Pa(e.root, w.theme, r)), Object.assign(I, { role: I.role ?? w.role ?? null, plugin: w.plugin ?? I.plugin, mode: ((b = w.theme) == null ? void 0 : b.mode) === "light" ? "light" : "dark", granted: w.granted ?? { scopes: [] }, preferences: w.preferences ?? {}, games: Array.isArray(w.games) ? w.games : [], flashIds: typeof w.flashIds == "number" ? w.flashIds : null, development: I.development || !!w.development, initialized: !0 }), d.notifyGames(I.games), m();
|
|
4335
|
+
}
|
|
4336
|
+
const g = e.listen(y);
|
|
4337
|
+
async function v(w) {
|
|
4338
|
+
var b, N;
|
|
4339
|
+
const [K] = await Promise.all([u, ((b = e.loadStyles) == null ? void 0 : b.call(e)) ?? Promise.resolve()]);
|
|
4340
|
+
n || ((N = I.role) == null ? void 0 : N.kind) === "logic" || (Object.assign(I, { kind: w.kind, contribution: w.contribution, props: w.props ?? {} }), K && k());
|
|
4341
|
+
}
|
|
4342
|
+
function k() {
|
|
4343
|
+
var w;
|
|
4344
|
+
if (!I.kind || !I.contribution) return;
|
|
4345
|
+
const [b, N] = I.kind === "page" ? [i == null ? void 0 : i.pages, "pages"] : I.kind === "panel" ? [i == null ? void 0 : i.panels, "panels"] : [i == null ? void 0 : i.commandViews, "commandViews"], K = b == null ? void 0 : b[I.contribution];
|
|
4346
|
+
if (!K) {
|
|
4347
|
+
h(new C("NOT_SUPPORTED", `definePlugin has no ${N}["${I.contribution}"], so there is nothing to show here`));
|
|
4348
|
+
return;
|
|
4349
|
+
}
|
|
4350
|
+
try {
|
|
4351
|
+
(w = e.view) == null || w.mount(K, c);
|
|
4352
|
+
} catch (V) {
|
|
4353
|
+
h(V);
|
|
4354
|
+
}
|
|
4355
|
+
}
|
|
4356
|
+
async function T(w) {
|
|
4357
|
+
var b, N;
|
|
4358
|
+
const K = (V, $e) => {
|
|
4359
|
+
try {
|
|
4360
|
+
s({ phantom: F, type: "result", id: w.id, ok: V, ...$e });
|
|
4361
|
+
} catch (Pe) {
|
|
4362
|
+
s({ phantom: F, type: "result", id: w.id, ok: !1, error: Ne(new C("FAILED", `The answer could not be sent to Phantom: ${$(Pe)}`)) });
|
|
4363
|
+
}
|
|
4364
|
+
};
|
|
4365
|
+
try {
|
|
4366
|
+
if (!await f || !i) throw new C("FAILED", "The plugin did not load");
|
|
4367
|
+
if (w.kind !== "commands") throw new C("NOT_SUPPORTED", `Phantom asked for an unknown kind, "${w.kind}"`);
|
|
4368
|
+
const V = (b = i.commands) == null ? void 0 : b[w.contribution];
|
|
4369
|
+
if (typeof V != "function") throw new C("NOT_SUPPORTED", `definePlugin has no commands["${w.contribution}"] function`);
|
|
4370
|
+
const $e = { arguments: ((N = w.input) == null ? void 0 : N.arguments) ?? {} }, Pe = await V($e, c.phantom(w.game), c);
|
|
4371
|
+
K(!0, { value: qe(Pe ?? null) });
|
|
4372
|
+
} catch (V) {
|
|
4373
|
+
K(!1, { error: Ne(V) });
|
|
4374
|
+
}
|
|
4375
|
+
}
|
|
4376
|
+
function j(w) {
|
|
4377
|
+
try {
|
|
4378
|
+
const b = w();
|
|
4379
|
+
b instanceof Promise && b.catch((N) => z(N));
|
|
4380
|
+
} catch (b) {
|
|
4381
|
+
z(b);
|
|
4382
|
+
}
|
|
4383
|
+
}
|
|
4384
|
+
function z(w) {
|
|
4385
|
+
o.log("error", [`setup's cleanup failed: ${$(w)}`]);
|
|
4386
|
+
}
|
|
4387
|
+
async function E() {
|
|
4388
|
+
const w = a;
|
|
4389
|
+
if (a = null, w) try {
|
|
4390
|
+
await Promise.race([Promise.resolve(w()), new Promise((b) => setTimeout(b, La))]);
|
|
4391
|
+
} catch (b) {
|
|
4392
|
+
z(b);
|
|
4393
|
+
}
|
|
4394
|
+
s({ phantom: F, type: "stopped" });
|
|
4395
|
+
}
|
|
4396
|
+
return { ctx: c, crash: h, log: (w, b) => o.log(w, b), replaceDefinition(w) {
|
|
4397
|
+
var b;
|
|
4398
|
+
i = w, ((b = I.role) == null ? void 0 : b.kind) !== "logic" && k();
|
|
4399
|
+
}, stop() {
|
|
4400
|
+
n || (a && (j(a), a = null), n = !0, g(), o.close("The frame was closed"), d.dispose(), It(null));
|
|
4401
|
+
} };
|
|
4402
|
+
}
|
|
4403
|
+
function Te(e) {
|
|
4404
|
+
return Object.keys(e ?? {});
|
|
4405
|
+
}
|
|
4406
|
+
function Fa(e) {
|
|
4407
|
+
return !e || typeof e != "object" ? {} : "default" in e && e.default && typeof e.default == "object" ? e.default : e;
|
|
4408
|
+
}
|
|
4409
|
+
const Ba = { class: "flex flex-col p-3", role: "alert" }, Ra = { class: "flex flex-col gap-2 overflow-hidden rounded-lg border border-phantom-danger/25 bg-phantom-danger/10 px-3 py-2.5" }, za = { class: "flex items-start gap-2" }, Va = { class: "min-w-0 flex-1" }, Ha = { class: "text-xs font-medium text-phantom-danger" }, Wa = { class: "mt-0.5 break-words text-2xs text-phantom-text-soft" }, _a = ["textContent"], Ka = { key: 1, class: "text-2xs text-phantom-subtle" }, Ga = Fn({ __name: "ErrorCard", props: { error: {}, development: { type: Boolean }, kind: {} }, emits: ["dismiss"], setup(e, { emit: t }) {
|
|
4410
|
+
const n = e, r = t, i = Bn(() => n.kind === "panel" ? "This panel" : n.kind === "page" ? "This page" : "This plugin");
|
|
4411
|
+
return (a, s) => (ye(), we("div", Ba, [te("div", Ra, [te("div", za, [s[1] || (s[1] = te("span", { class: "mt-1.5 h-1.5 w-1.5 shrink-0 rounded-full bg-phantom-danger", "aria-hidden": "true" }, null, -1)), te("div", Va, [te("p", Ha, Le(i.value) + " stopped with an error", 1), te("p", Wa, Le(e.error.message), 1)]), e.development ? (ye(), we("button", { key: 0, type: "button", class: "shrink-0 rounded px-1.5 text-2xs text-phantom-muted transition-colors hover:bg-phantom-danger/10 hover:text-phantom-text", onClick: s[0] || (s[0] = (o) => r("dismiss")) }, " Dismiss ")) : wt("", !0)]), e.development && e.error.stack ? (ye(), we("pre", { key: 0, class: "max-h-64 overflow-auto whitespace-pre-wrap break-words rounded-md bg-phantom-canvas/60 px-2.5 py-2 font-mono text-3xs text-phantom-muted", textContent: Le(e.error.stack) }, null, 8, _a)) : e.development ? wt("", !0) : (ye(), we("p", Ka, " More is in the plugin's log, in Plugins. "))])]));
|
|
4412
|
+
} });
|
|
4413
|
+
function Xa(e) {
|
|
4414
|
+
let t = null, n = null, r = -1;
|
|
4415
|
+
const i = () => {
|
|
4416
|
+
const o = Math.ceil(Math.max(e.content.scrollHeight, e.content.getBoundingClientRect().height));
|
|
4417
|
+
o !== r && (r = o, e.onResize(o));
|
|
4418
|
+
}, a = typeof ResizeObserver > "u" ? null : new ResizeObserver(i);
|
|
4419
|
+
a == null || a.observe(e.content);
|
|
4420
|
+
function s() {
|
|
4421
|
+
n == null || n.unmount(), n = null, e.content.hidden = !1;
|
|
4422
|
+
}
|
|
4423
|
+
return { mount(o, d) {
|
|
4424
|
+
s(), t == null || t.unmount(), document.documentElement.dataset.kind = I.kind ?? "", t = vt({ name: "PhantomPluginView", render: () => bt(o, { ...I.props }) }), t.provide(Vn, d), t.config.errorHandler = (c) => e.onError(c), t.mount(e.content);
|
|
4425
|
+
}, showError(o, d) {
|
|
4426
|
+
n == null || n.unmount(), e.content.hidden = !0, n = vt({ render: () => bt(Ga, { error: o, development: d, kind: I.kind, onDismiss: () => s() }) }), n.mount(e.errors), i();
|
|
4427
|
+
}, unmount() {
|
|
4428
|
+
a == null || a.disconnect(), t == null || t.unmount(), n == null || n.unmount(), t = null, n = null;
|
|
4429
|
+
} };
|
|
4430
|
+
}
|
|
4431
|
+
function rs(e) {
|
|
4432
|
+
window.parent === window && Ya();
|
|
4433
|
+
const t = ln("app"), n = ln("phantom-error");
|
|
4434
|
+
let r = null;
|
|
4435
|
+
function i(o) {
|
|
4436
|
+
window.parent.postMessage(o, "*");
|
|
4437
|
+
}
|
|
4438
|
+
const a = Xa({ content: t, errors: n, onError: (o) => r == null ? void 0 : r.crash(o), onResize: (o) => {
|
|
4439
|
+
document.documentElement.dataset.kind && i({ phantom: F, type: "resize", height: o });
|
|
4440
|
+
} });
|
|
4441
|
+
r = Ua({ post: i, listen(o) {
|
|
4442
|
+
const d = (c) => {
|
|
4443
|
+
c.source === window.parent && o(c.data);
|
|
4444
|
+
};
|
|
4445
|
+
return window.addEventListener("message", d), () => window.removeEventListener("message", d);
|
|
4446
|
+
}, root: document.documentElement, view: a, ...e.loadStyles ? { loadStyles: e.loadStyles } : {} }, e);
|
|
4447
|
+
const s = r;
|
|
4448
|
+
return _n(console, (o, d) => s.log(o, d)), window.addEventListener("error", (o) => {
|
|
4449
|
+
String(o.message).includes("ResizeObserver loop") || s.crash(o.error ?? o.message);
|
|
4450
|
+
}), window.addEventListener("unhandledrejection", (o) => s.crash(o.reason)), window.addEventListener("pagehide", () => {
|
|
4451
|
+
a.unmount(), s.stop();
|
|
4452
|
+
}), document.addEventListener("click", (o) => {
|
|
4453
|
+
const d = o.target, c = d && typeof d.closest == "function" ? d.closest("a[href]") : null;
|
|
4454
|
+
if (!c) return;
|
|
4455
|
+
const h = c.getAttribute("href") ?? "";
|
|
4456
|
+
h.startsWith("#") || (o.preventDefault(), /^https:\/\//i.test(h) ? s.ctx.openUrl(h).catch(() => {
|
|
4457
|
+
}) : s.log("warn", [`Only https links open from a plugin; this one goes to ${h}`]));
|
|
4458
|
+
}), s;
|
|
4459
|
+
}
|
|
4460
|
+
function ln(e) {
|
|
4461
|
+
const t = document.getElementById(e);
|
|
4462
|
+
if (t) return t;
|
|
4463
|
+
const n = document.createElement("div");
|
|
4464
|
+
return n.id = e, document.body.append(n), n;
|
|
4465
|
+
}
|
|
4466
|
+
function Ya() {
|
|
4467
|
+
const e = document.createElement("p");
|
|
4468
|
+
e.className = "m-6 max-w-md text-xs text-phantom-muted", e.textContent = "This is a Phantom plugin frame. It runs inside Phantom: turn on Developer mode in Plugins, and a plugin served by phantom-plugin dev shows up there.", document.body.prepend(e);
|
|
4469
|
+
}
|
|
4470
|
+
export {
|
|
4471
|
+
Oa as CALL_TIMEOUT_MS,
|
|
4472
|
+
Vn as PLUGIN_CONTEXT,
|
|
4473
|
+
Pa as applyTheme,
|
|
4474
|
+
Ma as createContext,
|
|
4475
|
+
ba as createFlashTransport,
|
|
4476
|
+
Ua as createGuest,
|
|
4477
|
+
va as createPluginFlash,
|
|
4478
|
+
cn as createPluginSide,
|
|
4479
|
+
$a as createPort,
|
|
4480
|
+
Na as createRemoteSdk,
|
|
4481
|
+
ns as currentContext,
|
|
4482
|
+
$ as describe,
|
|
4483
|
+
_n as forwardConsole,
|
|
4484
|
+
I as frame,
|
|
4485
|
+
Hn as fromWireError,
|
|
4486
|
+
ja as hasScope,
|
|
4487
|
+
rs as startGuest,
|
|
4488
|
+
qe as toPlain,
|
|
4489
|
+
Ne as toWireError
|
|
4490
|
+
};
|