@phantomclient/plugin 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/chunks/{api-Cu4nKe7h.js → api-DhaU9Jsd.js} +327 -307
- package/dist/lib/chunks/sdk-permissions-CyDMa4we.js +429 -0
- package/dist/lib/chunks/{state-kAlKf5xt.js → state-BGYMFLti.js} +9 -8
- package/dist/lib/guest.js +1126 -851
- package/dist/lib/index.js +33 -27
- package/dist/lib/styles.css +1 -1
- package/dist/lib/vue.js +3 -3
- package/dist/runtime/chunks/api-DCkkcNDr.js +1 -0
- package/dist/runtime/chunks/sdk-permissions-AYsXGgro.js +1 -0
- package/dist/runtime/chunks/{state-BjAtxWlm.js → state-CyERnsrb.js} +1 -1
- package/dist/runtime/frame.html +3 -3
- package/dist/runtime/runtime.css +1 -1
- package/dist/runtime/runtime.js +4 -1
- package/dist/runtime/sdk-vue.js +1 -1
- package/dist/runtime/sdk.js +1 -1
- package/dist/types/index.d.ts +1519 -288
- package/dist/types/vue.d.ts +1260 -217
- package/package.json +1 -1
- package/dist/lib/chunks/sdk-permissions-DPyveeLR.js +0 -250
- package/dist/runtime/chunks/api-ByZmAFMe.js +0 -1
- package/dist/runtime/chunks/sdk-permissions-BKJgZYgg.js +0 -1
package/dist/lib/guest.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { j as
|
|
2
|
-
import { isRef as
|
|
3
|
-
import { M as
|
|
4
|
-
import { f as
|
|
5
|
-
import { c as
|
|
6
|
-
class
|
|
1
|
+
import { c as Ve, a as Ue, b as _e, s as Ye, j as Ge, S as Ke, i as Je, d as Xe, e as Qe, P as B, f as Ze } from "./chunks/sdk-permissions-CyDMa4we.js";
|
|
2
|
+
import { isRef as ta, toRaw as ea, defineComponent as aa, computed as ra, openBlock as ht, createElementBlock as ut, createElementVNode as Z, toDisplayString as St, createCommentVNode as Qt, createApp as Zt, h as te } from "vue";
|
|
3
|
+
import { M as Re, P as ee, X as na, a as ia, b as sa, C as Ot, c as A, r as oa } from "./chunks/api-DhaU9Jsd.js";
|
|
4
|
+
import { f as x, b as la, r as ca, s as ae, P as ha } from "./chunks/state-BGYMFLti.js";
|
|
5
|
+
import { c as $n } from "./chunks/state-BGYMFLti.js";
|
|
6
|
+
class L extends Error {
|
|
7
7
|
constructor(t, e, r = null) {
|
|
8
|
-
super(
|
|
8
|
+
super(ua(e, r, t)), this.code = t, this.flash = r, this.name = "BridgeError";
|
|
9
9
|
}
|
|
10
10
|
code;
|
|
11
11
|
flash;
|
|
12
12
|
}
|
|
13
|
-
function
|
|
14
|
-
if (typeof a == "string" && a.trim() !== "") return
|
|
15
|
-
const r =
|
|
13
|
+
function ua(a, t, e) {
|
|
14
|
+
if (typeof a == "string" && a.trim() !== "") return pa(a, t);
|
|
15
|
+
const r = fa(a);
|
|
16
16
|
return r || (typeof (t == null ? void 0 : t.name) == "string" ? t.name.trim() : "") || `The game answered with no reason (${e})`;
|
|
17
17
|
}
|
|
18
|
-
const
|
|
19
|
-
function
|
|
20
|
-
const e = typeof (t == null ? void 0 : t.errorId) == "number" ? t.errorId : 0, r =
|
|
18
|
+
const da = { 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" };
|
|
19
|
+
function pa(a, t) {
|
|
20
|
+
const e = typeof (t == null ? void 0 : t.errorId) == "number" ? t.errorId : 0, r = da[e];
|
|
21
21
|
return !r || !/^\s*Error #\d+\s*$/.test(a) ? a : `${a.trim()}: ${r}`;
|
|
22
22
|
}
|
|
23
|
-
function
|
|
23
|
+
function fa(a) {
|
|
24
24
|
if (a == null) return "";
|
|
25
25
|
if (typeof a == "string") return a.trim();
|
|
26
26
|
if (typeof a != "object") return String(a);
|
|
@@ -33,17 +33,17 @@ function Ve(a) {
|
|
|
33
33
|
return "";
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
const
|
|
37
|
-
function
|
|
36
|
+
const re = 2;
|
|
37
|
+
function tt(a) {
|
|
38
38
|
return encodeURIComponent(JSON.stringify(a));
|
|
39
39
|
}
|
|
40
|
-
function
|
|
40
|
+
function Fe(a) {
|
|
41
41
|
return JSON.parse(decodeURIComponent(a));
|
|
42
42
|
}
|
|
43
|
-
function
|
|
43
|
+
function ga(a) {
|
|
44
44
|
return typeof a == "object" && a !== null && "$handle" in a;
|
|
45
45
|
}
|
|
46
|
-
function
|
|
46
|
+
function ma(a) {
|
|
47
47
|
switch (a.kind) {
|
|
48
48
|
case "result":
|
|
49
49
|
return a.id;
|
|
@@ -72,14 +72,14 @@ function _e(a) {
|
|
|
72
72
|
return null;
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
|
-
class
|
|
75
|
+
class vt {
|
|
76
76
|
constructor(t, e = []) {
|
|
77
77
|
this.className = t, this.args = e;
|
|
78
78
|
}
|
|
79
79
|
className;
|
|
80
80
|
args;
|
|
81
81
|
}
|
|
82
|
-
class
|
|
82
|
+
class z {
|
|
83
83
|
constructor(t, e, r) {
|
|
84
84
|
this.bridge = t, this.handle = e, this.className = r;
|
|
85
85
|
}
|
|
@@ -87,13 +87,13 @@ class R {
|
|
|
87
87
|
handle;
|
|
88
88
|
className;
|
|
89
89
|
at(...t) {
|
|
90
|
-
return new
|
|
90
|
+
return new J(this.bridge, { kind: "handle", handle: this.handle }, t);
|
|
91
91
|
}
|
|
92
92
|
release() {
|
|
93
93
|
return this.bridge.release([this]);
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
|
-
class
|
|
96
|
+
class J {
|
|
97
97
|
constructor(t, e, r = []) {
|
|
98
98
|
this.bridge = t, this.target = e, this.path = r;
|
|
99
99
|
}
|
|
@@ -101,7 +101,7 @@ class U {
|
|
|
101
101
|
target;
|
|
102
102
|
path;
|
|
103
103
|
at(...t) {
|
|
104
|
-
return new
|
|
104
|
+
return new J(this.bridge, this.target, [...this.path, ...t]);
|
|
105
105
|
}
|
|
106
106
|
get() {
|
|
107
107
|
return this.bridge.request({ op: "get", target: this.target, path: [...this.path] });
|
|
@@ -123,8 +123,8 @@ class U {
|
|
|
123
123
|
return { target: this.target, path: [...this.path] };
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
|
-
const
|
|
127
|
-
class
|
|
126
|
+
const wa = /* @__PURE__ */ new Set(["drive-failed", "track", "hook", "override", "hook-dropped", "hook-failed", "watch", "tick", "overlay", "key"]);
|
|
127
|
+
class ya {
|
|
128
128
|
constructor(t, e = {}) {
|
|
129
129
|
this.transport = t, this.timeoutMs = e.timeoutMs ?? 5e3, this.firstId = e.firstId ?? 1, this.nextId = this.firstId, this.batchOption = e.batch, this.stopReceiving = t.onMessage((r) => this.receive(r));
|
|
130
130
|
}
|
|
@@ -160,16 +160,16 @@ class Ye {
|
|
|
160
160
|
return this.nextId++;
|
|
161
161
|
}
|
|
162
162
|
whenReady() {
|
|
163
|
-
return this.stateValue === "ready" ? Promise.resolve() : this.stateValue === "closed" ? Promise.reject(new
|
|
163
|
+
return this.stateValue === "ready" ? Promise.resolve() : this.stateValue === "closed" ? Promise.reject(new L("CLOSED", "The game is closed")) : new Promise((t, e) => this.readyWaiters.push({ resolve: t, reject: e }));
|
|
164
164
|
}
|
|
165
165
|
definition(t) {
|
|
166
|
-
return new
|
|
166
|
+
return new J(this, { kind: "definition", name: t });
|
|
167
167
|
}
|
|
168
168
|
gameClient() {
|
|
169
|
-
return new
|
|
169
|
+
return new J(this, { kind: "client" });
|
|
170
170
|
}
|
|
171
171
|
stage() {
|
|
172
|
-
return new
|
|
172
|
+
return new J(this, { kind: "stage" });
|
|
173
173
|
}
|
|
174
174
|
construct(t, ...e) {
|
|
175
175
|
return this.request({ op: "construct", className: t, args: e.map((r) => this.encode(r)) });
|
|
@@ -227,7 +227,7 @@ class Ye {
|
|
|
227
227
|
let n = this.ticks.get(r);
|
|
228
228
|
if (!n) {
|
|
229
229
|
const o = /* @__PURE__ */ new Set(), l = this.subscribe((c) => ({ op: "tick", tick: c, everyFrames: r }), (c) => ({ op: "untick", tick: c }), (c) => {
|
|
230
|
-
if (c.kind === "tick") for (const
|
|
230
|
+
if (c.kind === "tick") for (const d of [...o]) d(c.frame, c.time);
|
|
231
231
|
});
|
|
232
232
|
n = { listeners: o, started: l }, this.ticks.set(r, n), l.catch(() => {
|
|
233
233
|
this.ticks.get(r) === n && this.ticks.delete(r);
|
|
@@ -289,7 +289,7 @@ class Ye {
|
|
|
289
289
|
}
|
|
290
290
|
async snapshot(t, { scale: e = 1, background: r = null, maxSize: n = 0 } = {}) {
|
|
291
291
|
const i = await this.request({ op: "snapshot", target: t.target, path: [...t.path], scale: e, background: r, maxSize: n });
|
|
292
|
-
if (typeof i != "string") throw new
|
|
292
|
+
if (typeof i != "string") throw new L("FLASH", "The picture came back empty");
|
|
293
293
|
return i;
|
|
294
294
|
}
|
|
295
295
|
note(t, e, r, n) {
|
|
@@ -300,7 +300,7 @@ class Ye {
|
|
|
300
300
|
}
|
|
301
301
|
async find(t, e) {
|
|
302
302
|
const r = await this.request({ op: "find", target: t.target, path: [...t.path], spec: e });
|
|
303
|
-
return (Array.isArray(r) ? r : []).filter((n) => n instanceof
|
|
303
|
+
return (Array.isArray(r) ? r : []).filter((n) => n instanceof z);
|
|
304
304
|
}
|
|
305
305
|
async answer(t, e) {
|
|
306
306
|
this.stateValue !== "closed" && await this.request({ op: "answer", callback: t, ...e === void 0 ? {} : { value: this.encode(e) } });
|
|
@@ -313,12 +313,12 @@ class Ye {
|
|
|
313
313
|
if (this.stateValue === "ready" && this.featureList.includes("dispose")) {
|
|
314
314
|
const e = this.nextId++;
|
|
315
315
|
try {
|
|
316
|
-
this.transport.send(
|
|
316
|
+
this.transport.send(tt({ id: e, op: "dispose", from: this.firstId, to: this.nextId }));
|
|
317
317
|
} catch {
|
|
318
318
|
}
|
|
319
319
|
}
|
|
320
320
|
this.stateValue = "closed", this.stopReceiving();
|
|
321
|
-
const t = new
|
|
321
|
+
const t = new L("CLOSED", "The game was closed");
|
|
322
322
|
for (const e of this.pending.values()) clearTimeout(e.timer), e.reject(t);
|
|
323
323
|
this.pending.clear();
|
|
324
324
|
for (const e of this.batches.values()) clearTimeout(e.timer);
|
|
@@ -326,7 +326,7 @@ class Ye {
|
|
|
326
326
|
}
|
|
327
327
|
readyWithin(t) {
|
|
328
328
|
return new Promise((e, r) => {
|
|
329
|
-
const n = setTimeout(() => r(new
|
|
329
|
+
const n = setTimeout(() => r(new L("NOT_READY", "The game has not started yet")), t);
|
|
330
330
|
this.whenReady().then(() => {
|
|
331
331
|
clearTimeout(n), e();
|
|
332
332
|
}, (i) => {
|
|
@@ -335,20 +335,20 @@ class Ye {
|
|
|
335
335
|
});
|
|
336
336
|
}
|
|
337
337
|
encodeRequest(t) {
|
|
338
|
-
return
|
|
338
|
+
return tt({ ...t, id: this.nextId++ });
|
|
339
339
|
}
|
|
340
340
|
request(t) {
|
|
341
|
-
if (this.stateValue === "closed") return Promise.reject(new
|
|
341
|
+
if (this.stateValue === "closed") return Promise.reject(new L("CLOSED", "The game is closed"));
|
|
342
342
|
if (this.stateValue !== "ready") return this.readyWithin(this.timeoutMs).then(() => this.request(t));
|
|
343
343
|
const e = this.nextId++;
|
|
344
344
|
return new Promise((r, n) => {
|
|
345
345
|
const i = setTimeout(() => {
|
|
346
|
-
this.pending.delete(e), n(new
|
|
346
|
+
this.pending.delete(e), n(new L("TIMEOUT", `The game did not answer "${t.op}" in ${this.timeoutMs}ms`));
|
|
347
347
|
}, this.timeoutMs);
|
|
348
348
|
this.pending.set(e, { resolve: r, reject: n, timer: i });
|
|
349
349
|
const s = { ...t, id: e };
|
|
350
350
|
if (!this.batching || s.op === "hookTable" || s.op === "batch") {
|
|
351
|
-
this.transport.send(
|
|
351
|
+
this.transport.send(tt(s));
|
|
352
352
|
return;
|
|
353
353
|
}
|
|
354
354
|
this.queue.push(s), this.queue.length === 1 && queueMicrotask(() => this.flush());
|
|
@@ -361,15 +361,15 @@ class Ye {
|
|
|
361
361
|
const t = this.queue;
|
|
362
362
|
if (this.queue = [], t.length === 0 || this.stateValue !== "ready") return;
|
|
363
363
|
if (t.length === 1) {
|
|
364
|
-
this.transport.send(
|
|
364
|
+
this.transport.send(tt(t[0]));
|
|
365
365
|
return;
|
|
366
366
|
}
|
|
367
367
|
const e = this.nextId++, r = t.map((i) => i.id), n = setTimeout(() => this.batches.delete(e), this.timeoutMs + 1e3);
|
|
368
|
-
this.batches.set(e, { ids: r, timer: n }), this.transport.send(
|
|
368
|
+
this.batches.set(e, { ids: r, timer: n }), this.transport.send(tt({ id: e, op: "batch", requests: t }));
|
|
369
369
|
}
|
|
370
370
|
settle(t, e) {
|
|
371
371
|
const r = this.pending.get(t);
|
|
372
|
-
r && (this.pending.delete(t), clearTimeout(r.timer), e.ok ? r.resolve(this.decode(e.value)) : r.reject(new
|
|
372
|
+
r && (this.pending.delete(t), clearTimeout(r.timer), e.ok ? r.resolve(this.decode(e.value)) : r.reject(new L("FLASH", e.error.message, e.error)));
|
|
373
373
|
}
|
|
374
374
|
encode(t) {
|
|
375
375
|
if (t === void 0) return { $undefined: !0 };
|
|
@@ -380,12 +380,12 @@ class Ye {
|
|
|
380
380
|
}
|
|
381
381
|
return t;
|
|
382
382
|
}
|
|
383
|
-
return t instanceof
|
|
383
|
+
return t instanceof z ? { $handle: t.handle } : t instanceof vt ? { $new: t.className, args: t.args.map((e) => this.encode(e)) } : Array.isArray(t) ? t.map((e) => this.encode(e)) : Object.fromEntries(Object.entries(t).map(([e, r]) => [e, this.encode(r)]));
|
|
384
384
|
}
|
|
385
385
|
decode(t) {
|
|
386
386
|
if (t === null || typeof t != "object") return t;
|
|
387
387
|
if (Array.isArray(t)) return t.map((e) => this.decode(e));
|
|
388
|
-
if (
|
|
388
|
+
if (ga(t)) return new z(this, t.$handle, t.className);
|
|
389
389
|
if (!("$undefined" in t)) return Object.fromEntries(Object.entries(t).map(([e, r]) => [e, this.decode(r)]));
|
|
390
390
|
}
|
|
391
391
|
receive(t) {
|
|
@@ -393,14 +393,14 @@ class Ye {
|
|
|
393
393
|
if (this.stateValue === "closed") return;
|
|
394
394
|
let i;
|
|
395
395
|
try {
|
|
396
|
-
i =
|
|
396
|
+
i = Fe(t);
|
|
397
397
|
} catch {
|
|
398
398
|
return;
|
|
399
399
|
}
|
|
400
400
|
switch (i.kind) {
|
|
401
401
|
case "ready":
|
|
402
|
-
if (i.version !==
|
|
403
|
-
const s = new
|
|
402
|
+
if (i.version !== re) {
|
|
403
|
+
const s = new L("VERSION", `The loader speaks bridge ${i.version}; this Phantom speaks ${re}`);
|
|
404
404
|
this.readyWaiters.splice(0).forEach((o) => o.reject(s)), this.close();
|
|
405
405
|
return;
|
|
406
406
|
}
|
|
@@ -432,20 +432,20 @@ class Ye {
|
|
|
432
432
|
(r = this.callbacks.get(i.callback)) == null || r(...i.args.map((s) => this.decode(s)));
|
|
433
433
|
return;
|
|
434
434
|
case "uncaught": {
|
|
435
|
-
const s = new
|
|
435
|
+
const s = new L("FLASH", i.error.message, i.error);
|
|
436
436
|
this.uncaughtListeners.forEach((o) => o(s));
|
|
437
437
|
return;
|
|
438
438
|
}
|
|
439
439
|
default:
|
|
440
|
-
if (
|
|
441
|
-
const s =
|
|
440
|
+
if (wa.has(i.kind)) {
|
|
441
|
+
const s = ma(i);
|
|
442
442
|
s !== null && ((n = this.subscriptions.get(s)) == null || n(i));
|
|
443
443
|
}
|
|
444
444
|
}
|
|
445
445
|
}
|
|
446
446
|
}
|
|
447
|
-
const
|
|
448
|
-
function
|
|
447
|
+
const ba = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0], Ce = { r: 0.3086, g: 0.6094, b: 0.082 };
|
|
448
|
+
function dt(a, t) {
|
|
449
449
|
const e = new Array(20).fill(0);
|
|
450
450
|
for (let r = 0; r < 4; r++) for (let n = 0; n < 5; n++) {
|
|
451
451
|
let i = n === 4 ? t[r * 5 + 4] : 0;
|
|
@@ -454,26 +454,26 @@ function nt(a, t) {
|
|
|
454
454
|
}
|
|
455
455
|
return e;
|
|
456
456
|
}
|
|
457
|
-
function
|
|
458
|
-
const t = a, { r: e, g: r, b: n } =
|
|
457
|
+
function Le(a) {
|
|
458
|
+
const t = a, { r: e, g: r, b: n } = Ce;
|
|
459
459
|
return [e * (1 - t) + t, r * (1 - t), n * (1 - t), 0, 0, e * (1 - t), r * (1 - t) + t, n * (1 - t), 0, 0, e * (1 - t), r * (1 - t), n * (1 - t) + t, 0, 0, 0, 0, 0, 1, 0];
|
|
460
460
|
}
|
|
461
|
-
function
|
|
461
|
+
function va(a) {
|
|
462
462
|
const t = a * 255;
|
|
463
463
|
return [1, 0, 0, 0, t, 0, 1, 0, 0, t, 0, 0, 1, 0, t, 0, 0, 0, 1, 0];
|
|
464
464
|
}
|
|
465
|
-
function
|
|
465
|
+
function ka(a) {
|
|
466
466
|
const t = a + 1, e = 128 * (1 - t);
|
|
467
467
|
return [t, 0, 0, 0, e, 0, t, 0, 0, e, 0, 0, t, 0, e, 0, 0, 0, 1, 0];
|
|
468
468
|
}
|
|
469
|
-
function
|
|
470
|
-
const t = a * Math.PI / 180, e = Math.cos(t), r = Math.sin(t), { r: n, g: i, b: s } =
|
|
469
|
+
function xa(a) {
|
|
470
|
+
const t = a * Math.PI / 180, e = Math.cos(t), r = Math.sin(t), { r: n, g: i, b: s } = Ce;
|
|
471
471
|
return [n + e * (1 - n) + r * -n, i + e * -i + r * -i, s + e * -s + r * (1 - s), 0, 0, n + e * -n + r * 0.143, i + e * (1 - i) + r * 0.14, s + e * -s + r * -0.283, 0, 0, n + e * -n + r * -0.6914, i + e * -i + r * i, s + e * (1 - s) + r * s, 0, 0, 0, 0, 0, 1, 0];
|
|
472
472
|
}
|
|
473
|
-
const
|
|
474
|
-
function
|
|
473
|
+
const Ma = { grayscale: Le(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] };
|
|
474
|
+
function Ne(a) {
|
|
475
475
|
if (typeof a == "string") {
|
|
476
|
-
const e =
|
|
476
|
+
const e = Ma[a];
|
|
477
477
|
if (!e) throw new TypeError(`Unknown colour look "${String(a)}"`);
|
|
478
478
|
return { matrix: [...e], colorTransform: null };
|
|
479
479
|
}
|
|
@@ -483,74 +483,74 @@ function ve(a) {
|
|
|
483
483
|
}
|
|
484
484
|
if ("tint" in a) {
|
|
485
485
|
const e = Math.max(0, Math.min(1, a.amount ?? 0.5)), r = (n) => (a.tint >> n & 255) * e;
|
|
486
|
-
return { matrix: null, colorTransform:
|
|
486
|
+
return { matrix: null, colorTransform: ne({ redMultiplier: 1 - e, greenMultiplier: 1 - e, blueMultiplier: 1 - e, redOffset: r(16), greenOffset: r(8), blueOffset: r(0) }) };
|
|
487
487
|
}
|
|
488
|
-
if ("transform" in a) return { matrix: null, colorTransform:
|
|
489
|
-
let t = [...
|
|
490
|
-
return a.saturation !== void 0 && (t =
|
|
488
|
+
if ("transform" in a) return { matrix: null, colorTransform: ne(a.transform) };
|
|
489
|
+
let t = [...ba];
|
|
490
|
+
return a.saturation !== void 0 && (t = dt(t, Le(a.saturation))), a.hue !== void 0 && (t = dt(t, xa(a.hue))), a.contrast !== void 0 && (t = dt(t, ka(a.contrast))), a.brightness !== void 0 && (t = dt(t, va(a.brightness))), { matrix: t, colorTransform: null };
|
|
491
491
|
}
|
|
492
|
-
function
|
|
492
|
+
function ne(a) {
|
|
493
493
|
return { redMultiplier: a.redMultiplier ?? 1, greenMultiplier: a.greenMultiplier ?? 1, blueMultiplier: a.blueMultiplier ?? 1, alphaMultiplier: a.alphaMultiplier ?? 1, redOffset: a.redOffset ?? 0, greenOffset: a.greenOffset ?? 0, blueOffset: a.blueOffset ?? 0, alphaOffset: a.alphaOffset ?? 0 };
|
|
494
494
|
}
|
|
495
|
-
function
|
|
496
|
-
const t = a.recolor ?
|
|
495
|
+
function lt(a = {}) {
|
|
496
|
+
const t = a.recolor ? Ne(a.recolor) : { matrix: null, colorTransform: null }, e = a.glow ?? !(a.recolor || a.hide) ? { color: a.color ?? 9133302, alpha: a.alpha ?? 1, blur: a.blur ?? 8, strength: a.strength ?? 2, inner: a.inner ?? !1, knockout: a.knockout ?? !1 } : null;
|
|
497
497
|
if (e && t.matrix) throw new TypeError("A highlight is a glow or a colour matrix, not both: use two highlights");
|
|
498
498
|
const r = a.pulse === void 0 || a.pulse === !1 ? null : a.pulse === !0 ? { frames: 60, from: 0.6, to: 1 } : { frames: a.pulse.frames ?? 60, from: a.pulse.from ?? 0.6, to: a.pulse.to ?? 1 };
|
|
499
499
|
return { glow: e, matrix: t.matrix, colorTransform: t.colorTransform, hide: a.hide ?? !1, pulse: r };
|
|
500
500
|
}
|
|
501
|
-
const
|
|
502
|
-
function
|
|
503
|
-
return typeof a == "function" && a[
|
|
501
|
+
const kt = /* @__PURE__ */ Symbol.for("phantom.typedFlash");
|
|
502
|
+
function ze(a) {
|
|
503
|
+
return typeof a == "function" && a[kt] !== void 0;
|
|
504
504
|
}
|
|
505
|
-
function
|
|
506
|
-
const r = { reference: t, handle: e.handle ?? null, className: e.className ?? null }, n = (o) =>
|
|
505
|
+
function P(a, t, e = {}) {
|
|
506
|
+
const r = { reference: t, handle: e.handle ?? null, className: e.className ?? null }, n = (o) => $(a, o), i = { $get: () => t.get().then(n), $set: async (o) => t.set((await X(a, [o]))[0]), $listen: (o, l) => t.listen(o, (c) => l(n(c))), $describe: () => t.describe(), $at: (...o) => P(a, t.at(...o)), $as: () => P(a, t, { ...r.handle ? { handle: r.handle } : {} }), $release: () => r.handle ? r.handle.release() : Promise.resolve(), $reference: t, $new: async (...o) => {
|
|
507
507
|
if (!r.className) throw new TypeError("Only a class can make objects with $new");
|
|
508
|
-
return n(await a.construct(r.className, ...await
|
|
509
|
-
}, toJSON: () => `[Flash ${
|
|
508
|
+
return n(await a.construct(r.className, ...await X(a, o)));
|
|
509
|
+
}, toJSON: () => `[Flash ${Ta(r)}]` }, s = (() => {
|
|
510
510
|
});
|
|
511
511
|
return new Proxy(s, { get: (o, l) => {
|
|
512
|
-
if (l ===
|
|
513
|
-
if (typeof l != "symbol" && l !== "then") return Object.prototype.hasOwnProperty.call(i, l) ? i[l] :
|
|
514
|
-
}, apply: async (o, l, c) => n(await t.call(...await
|
|
512
|
+
if (l === kt) return r;
|
|
513
|
+
if (typeof l != "symbol" && l !== "then") return Object.prototype.hasOwnProperty.call(i, l) ? i[l] : P(a, t.at(l));
|
|
514
|
+
}, apply: async (o, l, c) => n(await t.call(...await X(a, c))) });
|
|
515
515
|
}
|
|
516
|
-
function
|
|
517
|
-
return
|
|
516
|
+
function et(a) {
|
|
517
|
+
return ze(a) ? a[kt].reference : a instanceof z ? a.at() : a && typeof a == "object" && "target" in a && "path" in a && typeof a.at == "function" ? a : null;
|
|
518
518
|
}
|
|
519
|
-
function
|
|
520
|
-
if (t instanceof
|
|
521
|
-
if (Array.isArray(t)) return t.map((e) =>
|
|
519
|
+
function $(a, t) {
|
|
520
|
+
if (t instanceof z) return P(a, t.at(), { handle: t });
|
|
521
|
+
if (Array.isArray(t)) return t.map((e) => $(a, e));
|
|
522
522
|
if (t && typeof t == "object") {
|
|
523
523
|
const e = {};
|
|
524
|
-
for (const [r, n] of Object.entries(t)) e[r] =
|
|
524
|
+
for (const [r, n] of Object.entries(t)) e[r] = $(a, n);
|
|
525
525
|
return e;
|
|
526
526
|
}
|
|
527
527
|
return t;
|
|
528
528
|
}
|
|
529
|
-
async function
|
|
530
|
-
return Promise.all(t.map((e) =>
|
|
529
|
+
async function X(a, t) {
|
|
530
|
+
return Promise.all(t.map((e) => Wt(a, e)));
|
|
531
531
|
}
|
|
532
|
-
async function
|
|
533
|
-
if (
|
|
534
|
-
const e = t[
|
|
532
|
+
async function Wt(a, t) {
|
|
533
|
+
if (ze(t)) {
|
|
534
|
+
const e = t[kt];
|
|
535
535
|
return e.handle && e.reference.path.length === 0 ? e.handle : e.reference.get();
|
|
536
536
|
}
|
|
537
537
|
if (typeof t == "function") {
|
|
538
538
|
const e = t;
|
|
539
|
-
return (...r) => e(...r.map((n) =>
|
|
539
|
+
return (...r) => e(...r.map((n) => $(a, n)));
|
|
540
540
|
}
|
|
541
|
-
if (Array.isArray(t)) return Promise.all(t.map((e) =>
|
|
541
|
+
if (Array.isArray(t)) return Promise.all(t.map((e) => Wt(a, e)));
|
|
542
542
|
if (t && typeof t == "object" && Object.getPrototypeOf(t) === Object.prototype) {
|
|
543
543
|
const e = {};
|
|
544
|
-
for (const [r, n] of Object.entries(t)) e[r] = await
|
|
544
|
+
for (const [r, n] of Object.entries(t)) e[r] = await Wt(a, n);
|
|
545
545
|
return e;
|
|
546
546
|
}
|
|
547
547
|
return t;
|
|
548
548
|
}
|
|
549
|
-
function
|
|
549
|
+
function Ta({ reference: a, className: t }) {
|
|
550
550
|
const e = a.target, r = e.kind === "definition" ? e.name : e.kind === "handle" ? `object ${e.handle}` : e.kind, n = a.path.join(".");
|
|
551
551
|
return t ?? (n ? `${r}.${n}` : r);
|
|
552
552
|
}
|
|
553
|
-
class
|
|
553
|
+
class Sa {
|
|
554
554
|
constructor(t, e, r) {
|
|
555
555
|
this.bridge = t;
|
|
556
556
|
const n = t.encode(e);
|
|
@@ -565,7 +565,7 @@ class ea {
|
|
|
565
565
|
async answers(t) {
|
|
566
566
|
if (this.stopped) return;
|
|
567
567
|
await this.ready();
|
|
568
|
-
const [e] = await
|
|
568
|
+
const [e] = await X(this.bridge, [t]);
|
|
569
569
|
await this.bridge.answer(this.callback, e);
|
|
570
570
|
}
|
|
571
571
|
async answersNothing() {
|
|
@@ -578,34 +578,37 @@ class ea {
|
|
|
578
578
|
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");
|
|
579
579
|
}
|
|
580
580
|
}
|
|
581
|
-
function
|
|
582
|
-
const t =
|
|
581
|
+
function S(a) {
|
|
582
|
+
const t = et(a);
|
|
583
583
|
if (!t) throw new TypeError("Expected a place in Flash: a typed place, an object read from Flash, or a reference");
|
|
584
584
|
return { target: t.target, path: [...t.path] };
|
|
585
585
|
}
|
|
586
|
-
|
|
586
|
+
function ie(a) {
|
|
587
|
+
return et(a) !== null;
|
|
588
|
+
}
|
|
589
|
+
async function Oa(a, t, e, r) {
|
|
587
590
|
if (await a.whenReady(), !a.features.includes("collect")) throw new Error("This game is running a loader from before collects; read the items one by one");
|
|
588
|
-
const n = { fields:
|
|
591
|
+
const n = { fields: Ea(e) };
|
|
589
592
|
r.skip !== void 0 && (n.skip = Math.max(0, Math.trunc(r.skip))), r.limit !== void 0 && (n.limit = Math.max(1, Math.trunc(r.limit))), r.handles !== void 0 && (n.handles = r.handles);
|
|
590
|
-
const i = await a.collect(
|
|
591
|
-
return { rows: i.items.map((s) =>
|
|
593
|
+
const i = await a.collect(S(t), n);
|
|
594
|
+
return { rows: i.items.map((s) => $(a, s)), total: i.total };
|
|
592
595
|
}
|
|
593
|
-
function
|
|
596
|
+
function Ea(a) {
|
|
594
597
|
const t = Array.isArray(a) ? a.map((e) => [e, e]) : Object.entries(a);
|
|
595
598
|
if (t.length === 0) throw new TypeError("A collect needs the members to read");
|
|
596
599
|
return t.map(([e, r]) => ({ name: e, path: (Array.isArray(r) ? r : String(r).split(".")).filter((n) => n.length > 0) }));
|
|
597
600
|
}
|
|
598
|
-
function
|
|
601
|
+
function ct(a) {
|
|
599
602
|
const t = `${a.className}.${a.member}`;
|
|
600
603
|
return a.kind === "getter" ? `${t}@get` : a.kind === "setter" ? `${t}@set` : t;
|
|
601
604
|
}
|
|
602
|
-
const
|
|
603
|
-
class
|
|
605
|
+
const xt = /* @__PURE__ */ Symbol.for("phantom.hookRead"), Q = /* @__PURE__ */ Symbol.for("phantom.hookTest");
|
|
606
|
+
class Aa {
|
|
604
607
|
constructor(t) {
|
|
605
608
|
this.table = t;
|
|
606
609
|
for (const e of t.hooks) {
|
|
607
610
|
this.byId.set(e.id, e);
|
|
608
|
-
const r =
|
|
611
|
+
const r = ct(e);
|
|
609
612
|
this.byKey.has(r) || this.byKey.set(r, e);
|
|
610
613
|
}
|
|
611
614
|
}
|
|
@@ -622,92 +625,92 @@ class na {
|
|
|
622
625
|
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;
|
|
623
626
|
}
|
|
624
627
|
}
|
|
625
|
-
function
|
|
628
|
+
function K(a) {
|
|
626
629
|
return a.flatMap((t) => Array.isArray(t) ? t : t.includes("::") ? [t] : t.split(".").filter(Boolean));
|
|
627
630
|
}
|
|
628
|
-
function
|
|
629
|
-
return Object.freeze({ [
|
|
631
|
+
function _(a) {
|
|
632
|
+
return Object.freeze({ [xt]: a });
|
|
630
633
|
}
|
|
631
|
-
function
|
|
632
|
-
return Object.freeze({ [
|
|
634
|
+
function I(a, t, e) {
|
|
635
|
+
return Object.freeze({ [Q]: e === void 0 && a === "exists" ? { test: a, left: t } : { test: a, left: t, right: e } });
|
|
633
636
|
}
|
|
634
|
-
const
|
|
635
|
-
function
|
|
636
|
-
return typeof a == "object" && a !== null &&
|
|
637
|
+
const $a = { self: (...a) => _({ from: "self", path: K(a) }), arg: (a, ...t) => _({ from: "arg", arg: a, path: K(t) }), returned: (...a) => _({ from: "return", path: K(a) }), fromClass: (a, ...t) => _({ from: "class", name: a, path: K(t) }), place: (a, ...t) => _({ from: "place", place: a, path: K(t) }), calls: () => _({ from: "calls" }), constant: (a) => _({ from: "constant", value: a }), equals: (a, t) => I("equals", a, t), notEquals: (a, t) => I("notEquals", a, t), less: (a, t) => I("less", a, t), lessOrEqual: (a, t) => I("lessOrEqual", a, t), greater: (a, t) => I("greater", a, t), greaterOrEqual: (a, t) => I("greaterOrEqual", a, t), contains: (a, t) => I("contains", a, t), startsWith: (a, t) => I("startsWith", a, t), endsWith: (a, t) => I("endsWith", a, t), oneOf: (a, t) => I("in", a, t), exists: (a) => I("exists", a), all: (...a) => Object.freeze({ [Q]: { all: a } }), any: (...a) => Object.freeze({ [Q]: { any: a } }), not: (a) => Object.freeze({ [Q]: { not: a } }) };
|
|
638
|
+
function Ie(a) {
|
|
639
|
+
return typeof a == "object" && a !== null && xt in a;
|
|
637
640
|
}
|
|
638
|
-
function
|
|
639
|
-
return typeof a == "object" && a !== null &&
|
|
640
|
-
}
|
|
641
|
-
function
|
|
642
|
-
const n = (
|
|
643
|
-
if (typeof
|
|
644
|
-
const
|
|
645
|
-
if (
|
|
646
|
-
if (/^\d+$/.test(
|
|
641
|
+
function Be(a) {
|
|
642
|
+
return typeof a == "object" && a !== null && Q in a;
|
|
643
|
+
}
|
|
644
|
+
function Vt(a, t, e, r) {
|
|
645
|
+
const n = (u) => {
|
|
646
|
+
if (typeof u == "number") return se(t, u);
|
|
647
|
+
const h = t.parameters.findIndex((m) => m.name === u);
|
|
648
|
+
if (h >= 0) return h;
|
|
649
|
+
if (/^\d+$/.test(u)) return se(t, Number(u));
|
|
647
650
|
const g = t.parameters.map((m) => m.name).join(", ") || "none";
|
|
648
|
-
throw new TypeError(`${
|
|
649
|
-
}, i = (
|
|
650
|
-
if (!
|
|
651
|
-
const
|
|
652
|
-
switch (
|
|
651
|
+
throw new TypeError(`${ct(t)} has no argument "${u}" (its arguments: ${g})`);
|
|
652
|
+
}, i = (u) => {
|
|
653
|
+
if (!Ie(u)) return bt(u) ?? { from: "constant", value: at(a, u) };
|
|
654
|
+
const h = u[xt];
|
|
655
|
+
switch (h.from) {
|
|
653
656
|
case "constant":
|
|
654
|
-
return { from: "constant", value:
|
|
657
|
+
return { from: "constant", value: at(a, h.value) };
|
|
655
658
|
case "arg":
|
|
656
|
-
return { from: "arg", index: n(
|
|
659
|
+
return { from: "arg", index: n(h.arg), path: h.path };
|
|
657
660
|
case "self":
|
|
658
|
-
return { from: "self", path:
|
|
661
|
+
return { from: "self", path: h.path };
|
|
659
662
|
case "return":
|
|
660
|
-
return { from: "return", path:
|
|
663
|
+
return { from: "return", path: h.path };
|
|
661
664
|
case "class":
|
|
662
|
-
return { from: "class", name:
|
|
665
|
+
return { from: "class", name: h.name, path: h.path };
|
|
663
666
|
case "calls":
|
|
664
667
|
return { from: "calls" };
|
|
665
668
|
case "place": {
|
|
666
|
-
const g =
|
|
669
|
+
const g = bt(h.place, h.path);
|
|
667
670
|
if (!g) throw new TypeError("rules.place takes a place in the game");
|
|
668
671
|
return g;
|
|
669
672
|
}
|
|
670
673
|
}
|
|
671
|
-
}, s = (
|
|
672
|
-
if (!
|
|
673
|
-
const g = Object.entries(
|
|
674
|
+
}, s = (u) => {
|
|
675
|
+
if (!Be(u)) {
|
|
676
|
+
const g = Object.entries(u).map(([m, p]) => ({ test: "equals", left: { from: "arg", index: n(m), path: [] }, right: i(p) }));
|
|
674
677
|
if (g.length === 0) throw new TypeError("A hook condition names nothing to compare");
|
|
675
678
|
return g.length === 1 ? g[0] : { all: g };
|
|
676
679
|
}
|
|
677
|
-
const
|
|
678
|
-
return "all" in
|
|
679
|
-
}, o = e.phase ?? (r ? "enter" : "none"), l = e.capture ?? {}, c = t.parameters.map((
|
|
680
|
-
return { observe: o === "both" ? ["enter", "exit"] : o === "none" ? [] : [o], capture: { args:
|
|
680
|
+
const h = u[Q];
|
|
681
|
+
return "all" in h ? { all: h.all.map(s) } : "any" in h ? { any: h.any.map(s) } : "not" in h ? { not: s(h.not) } : h.test === "exists" ? { test: h.test, left: i(h.left) } : { test: h.test, left: i(h.left), right: i(h.right) };
|
|
682
|
+
}, o = e.phase ?? (r ? "enter" : "none"), l = e.capture ?? {}, c = t.parameters.map((u, h) => h), d = l.args === !0 || l.args === void 0 && r ? c : (l.args ?? []).map(n);
|
|
683
|
+
return { observe: o === "both" ? ["enter", "exit"] : o === "none" ? [] : [o], capture: { args: d, self: Ut(l.self).map(([, u]) => u), value: l.value ?? !1, handles: l.handles ?? !1 }, when: e.when === void 0 ? null : s(e.when), first: e.first ?? null, every: e.every ?? null, skip: e.skip === void 0 || e.skip === !1 ? null : e.skip === !0 ? { from: "constant", value: { $undefined: !0 } } : i(e.skip.returns), replaceArgs: Object.entries(e.replaceArgs ?? {}).map(([u, h]) => ({ index: n(u), value: i(h) })), replaceReturn: "replaceReturn" in e ? i(e.replaceReturn) : null, perFrame: e.perFrame ?? 20 };
|
|
681
684
|
}
|
|
682
|
-
function
|
|
683
|
-
if (!Number.isInteger(t) || t < 0 || a.parameters.length > 0 && t >= a.parameters.length) throw new RangeError(`${
|
|
685
|
+
function se(a, t) {
|
|
686
|
+
if (!Number.isInteger(t) || t < 0 || a.parameters.length > 0 && t >= a.parameters.length) throw new RangeError(`${ct(a)} has no argument ${t}`);
|
|
684
687
|
return t;
|
|
685
688
|
}
|
|
686
|
-
function
|
|
687
|
-
return a ? Array.isArray(a) ? a.map((t) => [t,
|
|
689
|
+
function Ut(a) {
|
|
690
|
+
return a ? Array.isArray(a) ? a.map((t) => [t, K([t])]) : Object.entries(a).map(([t, e]) => [t, K([e])]) : [];
|
|
688
691
|
}
|
|
689
|
-
function
|
|
692
|
+
function He(a, t) {
|
|
690
693
|
const e = (r) => {
|
|
691
|
-
if (!
|
|
692
|
-
const n = r[
|
|
693
|
-
return "all" in n ? { all: n.all.map(e) } : "any" in n ? { any: n.any.map(e) } : "not" in n ? { not: e(n.not) } : n.test === "exists" ? { test: n.test, left:
|
|
694
|
+
if (!Be(r)) throw new TypeError("A condition between calls has no call to read: compare with rules.equals and its like");
|
|
695
|
+
const n = r[Q];
|
|
696
|
+
return "all" in n ? { all: n.all.map(e) } : "any" in n ? { any: n.any.map(e) } : "not" in n ? { not: e(n.not) } : n.test === "exists" ? { test: n.test, left: st(a, n.left) } : { test: n.test, left: st(a, n.left), right: st(a, n.right) };
|
|
694
697
|
};
|
|
695
698
|
return e(t);
|
|
696
699
|
}
|
|
697
|
-
function
|
|
698
|
-
const e =
|
|
700
|
+
function bt(a, t = []) {
|
|
701
|
+
const e = et(a);
|
|
699
702
|
return e ? { from: "place", target: e.target, path: [...e.path, ...t] } : null;
|
|
700
703
|
}
|
|
701
|
-
function
|
|
702
|
-
if (!
|
|
703
|
-
const e = t[
|
|
704
|
+
function st(a, t) {
|
|
705
|
+
if (!Ie(t)) return bt(t) ?? { from: "constant", value: at(a, t) };
|
|
706
|
+
const e = t[xt];
|
|
704
707
|
switch (e.from) {
|
|
705
708
|
case "constant":
|
|
706
|
-
return { from: "constant", value:
|
|
709
|
+
return { from: "constant", value: at(a, e.value) };
|
|
707
710
|
case "class":
|
|
708
711
|
return { from: "class", name: e.name, path: e.path };
|
|
709
712
|
case "place": {
|
|
710
|
-
const r =
|
|
713
|
+
const r = bt(e.place, e.path);
|
|
711
714
|
if (!r) throw new TypeError("rules.place takes a place in the game");
|
|
712
715
|
return r;
|
|
713
716
|
}
|
|
@@ -715,72 +718,72 @@ function Q(a, t) {
|
|
|
715
718
|
throw new TypeError(`rules.${e.from} reads the call it is in; a value held between calls is a constant, rules.fromClass or a place`);
|
|
716
719
|
}
|
|
717
720
|
}
|
|
718
|
-
function
|
|
721
|
+
function at(a, t) {
|
|
719
722
|
if (t === void 0) return { $undefined: !0 };
|
|
720
|
-
if (t instanceof
|
|
721
|
-
const e =
|
|
723
|
+
if (t instanceof z || t instanceof vt) return a.encode(t);
|
|
724
|
+
const e = et(t);
|
|
722
725
|
if (e) {
|
|
723
726
|
if (e.target.kind === "handle" && e.path.length === 0) return { $handle: e.target.handle };
|
|
724
727
|
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");
|
|
725
728
|
}
|
|
726
729
|
if (typeof t == "function") throw new TypeError("A hook rule cannot call a function");
|
|
727
|
-
return Array.isArray(t) ? t.map((r) =>
|
|
730
|
+
return Array.isArray(t) ? t.map((r) => at(a, r)) : t !== null && typeof t == "object" ? Object.fromEntries(Object.entries(t).map(([r, n]) => [r, at(a, n)])) : t;
|
|
728
731
|
}
|
|
729
|
-
async function
|
|
732
|
+
async function Pa(a, t, e, r, n) {
|
|
730
733
|
var i;
|
|
731
734
|
const s = t.find(e);
|
|
732
735
|
if (!s) throw new TypeError(`There is no hook "${e}" in the hook table`);
|
|
733
|
-
let o = r, l =
|
|
734
|
-
const { registration:
|
|
736
|
+
let o = r, l = Ut((i = r.capture) == null ? void 0 : i.self).map(([h]) => h), c = Vt(a, s, r, n !== void 0);
|
|
737
|
+
const { registration: d, stop: u } = await a.hook(s.id, c, (h) => {
|
|
735
738
|
var g;
|
|
736
|
-
switch (
|
|
739
|
+
switch (h.kind) {
|
|
737
740
|
case "hook": {
|
|
738
741
|
if (!n) return;
|
|
739
|
-
const m = (
|
|
740
|
-
c.capture.args.forEach((w,
|
|
741
|
-
var
|
|
742
|
-
p[((
|
|
742
|
+
const m = (h.args ?? []).map((w) => $(a, a.decode(w))), p = {};
|
|
743
|
+
c.capture.args.forEach((w, b) => {
|
|
744
|
+
var k;
|
|
745
|
+
p[((k = s.parameters[w]) == null ? void 0 : k.name) ?? String(w)] = m[b];
|
|
743
746
|
});
|
|
744
747
|
const f = {};
|
|
745
|
-
(
|
|
746
|
-
f[l[
|
|
747
|
-
}), n({ phase:
|
|
748
|
+
(h.self ?? []).forEach((w, b) => {
|
|
749
|
+
f[l[b] ?? String(b)] = $(a, a.decode(w));
|
|
750
|
+
}), n({ phase: h.phase, call: h.call, args: p, argList: m, self: f, ..."value" in h ? { value: $(a, a.decode(h.value)) } : {}, skipped: h.skipped === !0, hook: s });
|
|
748
751
|
return;
|
|
749
752
|
}
|
|
750
753
|
case "hook-dropped":
|
|
751
|
-
(g = o.onDropped) == null || g.call(o,
|
|
754
|
+
(g = o.onDropped) == null || g.call(o, h.dropped);
|
|
752
755
|
return;
|
|
753
756
|
case "hook-failed": {
|
|
754
|
-
const m = new
|
|
757
|
+
const m = new L("FLASH", `The hook on ${ct(s)} failed and is off: ${h.error.message}`, h.error);
|
|
755
758
|
o.onError ? o.onError(m) : console.error(m.message);
|
|
756
759
|
return;
|
|
757
760
|
}
|
|
758
761
|
}
|
|
759
762
|
});
|
|
760
|
-
return Object.assign(() =>
|
|
763
|
+
return Object.assign(() => u(), { registration: d, hook: s, update: async (h, g = {}) => {
|
|
761
764
|
var m;
|
|
762
|
-
const p =
|
|
763
|
-
await a.request({ op: "rehook", registration:
|
|
764
|
-
}, stats: async () => (await a.request({ op: "hookStats" })).find((
|
|
765
|
+
const p = Vt(a, s, h, n !== void 0);
|
|
766
|
+
await a.request({ op: "rehook", registration: d, rules: p, resetCounts: g.resetCounts ?? !1 }), o = h, c = p, l = Ut((m = h.capture) == null ? void 0 : m.self).map(([f]) => f);
|
|
767
|
+
}, stats: async () => (await a.request({ op: "hookStats" })).find((h) => h.registration === d) ?? null });
|
|
765
768
|
}
|
|
766
|
-
async function
|
|
769
|
+
async function ja(a, t, e) {
|
|
767
770
|
if (await a.whenReady(), !a.features.includes("drive")) throw new Error("This game is running a loader from before repeated calls; call it yourself each frame");
|
|
768
|
-
const r =
|
|
771
|
+
const r = S(t);
|
|
769
772
|
if (r.path.length === 0) throw new TypeError("A repeat calls a method, so name one: `place.method`, not the object");
|
|
770
|
-
const n = e.while ?
|
|
771
|
-
return a.drive({ writes: [], calls: [{ target: r.target, path: r.path, args: (e.args ?? []).map((i) =>
|
|
773
|
+
const n = e.while ? He(a, e.while) : null;
|
|
774
|
+
return a.drive({ writes: [], calls: [{ target: r.target, path: r.path, args: (e.args ?? []).map((i) => st(a, i)), times: Math.max(1, Math.trunc(e.times ?? 1)) }], everyFrames: Math.max(1, Math.trunc(e.everyFrames ?? 1)), while: n, restore: !1, once: e.once === !0 }, e.onFailed);
|
|
772
775
|
}
|
|
773
|
-
async function
|
|
776
|
+
async function oe(a, t, e) {
|
|
774
777
|
if (await a.whenReady(), !a.features.includes("drive")) throw new Error("This game is running a loader from before held values; write it yourself each frame");
|
|
775
778
|
if (t.length === 0) throw new TypeError("A hold needs a value to keep");
|
|
776
779
|
const r = t.map(({ place: i, value: s }) => {
|
|
777
|
-
const o =
|
|
780
|
+
const o = S(i);
|
|
778
781
|
if (o.path.length === 0) throw new TypeError("A hold writes to a member, so name one: `place.member`, not the object");
|
|
779
|
-
return { target: o.target, path: o.path, value:
|
|
780
|
-
}), n = e.while ?
|
|
782
|
+
return { target: o.target, path: o.path, value: st(a, s) };
|
|
783
|
+
}), n = e.while ? He(a, e.while) : null;
|
|
781
784
|
return a.drive({ writes: r, everyFrames: Math.max(1, Math.trunc(e.everyFrames ?? 1)), while: n, restore: e.restore !== !1, once: e.once === !0 }, e.onFailed);
|
|
782
785
|
}
|
|
783
|
-
class
|
|
786
|
+
class Et {
|
|
784
787
|
constructor(t, e, r, n, i, s, o) {
|
|
785
788
|
this.host = t, this.kind = e, this.id = r, this.name = n, this.tagY = s, this.handle = o, this.place = i;
|
|
786
789
|
}
|
|
@@ -792,7 +795,7 @@ class bt {
|
|
|
792
795
|
handle;
|
|
793
796
|
place;
|
|
794
797
|
highlight(t = {}) {
|
|
795
|
-
return this.host.bridge.highlight(this.entry(),
|
|
798
|
+
return this.host.bridge.highlight(this.entry(), lt(t));
|
|
796
799
|
}
|
|
797
800
|
tag(t, e = {}) {
|
|
798
801
|
const { anchorX: r, anchorY: n, ...i } = e;
|
|
@@ -816,29 +819,29 @@ class bt {
|
|
|
816
819
|
return { target: t.target, path: [...t.path] };
|
|
817
820
|
}
|
|
818
821
|
}
|
|
819
|
-
class
|
|
822
|
+
class Ra {
|
|
820
823
|
constructor(t) {
|
|
821
824
|
this.host = t;
|
|
822
825
|
}
|
|
823
826
|
host;
|
|
824
827
|
async players() {
|
|
825
|
-
const t = this.host.bridge, e = t.definition("avatar.AvatarManager").at("avatarViewList"), r = await e.get(), n = r && typeof r == "object" && !(r instanceof
|
|
828
|
+
const t = this.host.bridge, e = t.definition("avatar.AvatarManager").at("avatarViewList"), r = await e.get(), n = r && typeof r == "object" && !(r instanceof z) ? Object.keys(r) : [], i = n.map((s) => r[s]).filter((s) => s instanceof z);
|
|
826
829
|
try {
|
|
827
|
-
const s = await Promise.all(n.map((o) =>
|
|
828
|
-
return n.map((o, l) => new
|
|
830
|
+
const s = await Promise.all(n.map((o) => W(e.at(o, "userName").get())));
|
|
831
|
+
return n.map((o, l) => new Et(this.host, "player", o, typeof s[l] == "string" ? s[l] : null, P(t, e.at(o)), -80, null));
|
|
829
832
|
} finally {
|
|
830
833
|
await t.release(i);
|
|
831
834
|
}
|
|
832
835
|
}
|
|
833
836
|
async npcs() {
|
|
834
|
-
const t = this.host.bridge, e = t.definition("quest.QuestManager").at("_questActors"), r = await
|
|
837
|
+
const t = this.host.bridge, e = t.definition("quest.QuestManager").at("_questActors"), r = await W(e.at("length").get());
|
|
835
838
|
if (typeof r != "number" || r <= 0) return [];
|
|
836
|
-
const n = Array.from({ length: Math.min(r, 500) }, (c,
|
|
837
|
-
return n.forEach((c,
|
|
838
|
-
const
|
|
839
|
-
if (!(
|
|
840
|
-
const
|
|
841
|
-
l.push(new
|
|
839
|
+
const n = Array.from({ length: Math.min(r, 500) }, (c, d) => String(d)), [i, s, o] = await Promise.all([Promise.all(n.map((c) => W(e.at(c).get()))), Promise.all(n.map((c) => W(e.at(c, "_actorId").get()))), Promise.all(n.map((c) => W(e.at(c, "currAvatar", "avName").get())))]), l = [];
|
|
840
|
+
return n.forEach((c, d) => {
|
|
841
|
+
const u = i[d];
|
|
842
|
+
if (!(u instanceof z)) return;
|
|
843
|
+
const h = o[d];
|
|
844
|
+
l.push(new Et(this.host, "npc", typeof s[d] == "string" ? s[d] : c, typeof h == "string" && h ? h : null, P(t, u.at(), { handle: u }), -90, u));
|
|
842
845
|
}), l;
|
|
843
846
|
}
|
|
844
847
|
async objects() {
|
|
@@ -846,40 +849,40 @@ class la {
|
|
|
846
849
|
let r;
|
|
847
850
|
try {
|
|
848
851
|
r = await e.at("length").get();
|
|
849
|
-
} catch (
|
|
850
|
-
throw
|
|
852
|
+
} catch (d) {
|
|
853
|
+
throw d instanceof L && d.code === "FLASH" ? new L("FLASH", `The room's objects are private to the client, and this client does not reach them: ${d.message}`, d.flash) : d;
|
|
851
854
|
}
|
|
852
855
|
if (typeof r != "number" || r <= 0) return [];
|
|
853
|
-
const n = Array.from({ length: Math.min(r, 500) }, (
|
|
854
|
-
n.forEach((
|
|
855
|
-
const
|
|
856
|
-
for (let m = 0; typeof
|
|
856
|
+
const n = Array.from({ length: Math.min(r, 500) }, (d, u) => String(u)), [i, s] = await Promise.all([Promise.all(n.map((d) => W(e.at(d, "name").get()))), Promise.all(n.map((d) => W(e.at(d, "interactiveObjs", "length").get())))]), o = [];
|
|
857
|
+
n.forEach((d, u) => {
|
|
858
|
+
const h = s[u], g = i[u];
|
|
859
|
+
for (let m = 0; typeof h == "number" && m < Math.min(h, 50); m++) o.push([d, String(m), typeof g == "string" ? g : null]);
|
|
857
860
|
});
|
|
858
|
-
const l = await Promise.all(o.map(([
|
|
859
|
-
return o.forEach(([
|
|
861
|
+
const l = await Promise.all(o.map(([d, u]) => W(e.at(d, "interactiveObjs", u, "mc").get()))), c = [];
|
|
862
|
+
return o.forEach(([d, u, h], g) => {
|
|
860
863
|
const m = l[g];
|
|
861
|
-
m instanceof
|
|
864
|
+
m instanceof z && c.push(new Et(this.host, "object", `${h ?? d}#${u}`, h, P(t, m.at(), { handle: m }), 0, m));
|
|
862
865
|
}), c;
|
|
863
866
|
}
|
|
864
867
|
}
|
|
865
|
-
function
|
|
868
|
+
function W(a) {
|
|
866
869
|
return a.catch(() => null);
|
|
867
870
|
}
|
|
868
|
-
async function
|
|
871
|
+
async function Fa(a, t, e) {
|
|
869
872
|
if (await a.whenReady(), !a.features.includes("find")) throw new Error("This game is running a loader from before searches; only a path reaches an object");
|
|
870
|
-
const r = t === void 0 ? { target: { kind: "stage" }, path: [] } :
|
|
871
|
-
return (await a.find(r,
|
|
873
|
+
const r = t === void 0 ? { target: { kind: "stage" }, path: [] } : S(t);
|
|
874
|
+
return (await a.find(r, Ca(e))).map((n) => P(a, n.at(), { handle: n }));
|
|
872
875
|
}
|
|
873
|
-
function
|
|
876
|
+
function Ca(a) {
|
|
874
877
|
const t = {};
|
|
875
878
|
return a.ofClass !== void 0 && (t.ofClass = a.ofClass), a.named !== void 0 && (t.named = a.named), a.containing !== void 0 && (t.containing = a.containing), a.visibleOnly !== void 0 && (t.visibleOnly = a.visibleOnly), a.through !== void 0 && (t.through = a.through), a.depth !== void 0 && (t.depth = a.depth), a.limit !== void 0 && (t.limit = a.limit), t;
|
|
876
879
|
}
|
|
877
|
-
const
|
|
878
|
-
function
|
|
880
|
+
const le = { 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 };
|
|
881
|
+
function La(a) {
|
|
879
882
|
return a === !0 ? "always" : a === !1 ? "never" : a ?? "empty";
|
|
880
883
|
}
|
|
881
|
-
function
|
|
882
|
-
const e = { phase: t.phase ?? "down", consume: t.consume ?? !1, whileTyping:
|
|
884
|
+
function Na(a, t = {}) {
|
|
885
|
+
const e = { phase: t.phase ?? "down", consume: t.consume ?? !1, whileTyping: La(t.whileTyping), repeat: t.repeat ?? !1 };
|
|
883
886
|
if (typeof a == "number") return { code: a, ctrl: null, shift: null, alt: null, ...e };
|
|
884
887
|
const r = a === "+" || a.endsWith("++"), n = (r ? a.slice(0, -1) : a).split("+").map((o) => o.trim()).filter(Boolean);
|
|
885
888
|
r && n.push("+");
|
|
@@ -887,14 +890,14 @@ function da(a, t = {}) {
|
|
|
887
890
|
let s = null;
|
|
888
891
|
for (const o of n) {
|
|
889
892
|
const l = o.toLowerCase();
|
|
890
|
-
l === "ctrl" || l === "control" || l === "cmd" || l === "meta" ? i.ctrl = !0 : l === "shift" ? i.shift = !0 : l === "alt" || l === "option" ? i.alt = !0 : l === "any" ? s = null : s =
|
|
893
|
+
l === "ctrl" || l === "control" || l === "cmd" || l === "meta" ? i.ctrl = !0 : l === "shift" ? i.shift = !0 : l === "alt" || l === "option" ? i.alt = !0 : l === "any" ? s = null : s = za(o);
|
|
891
894
|
}
|
|
892
895
|
if (s === null && !n.some((o) => o.toLowerCase() === "any")) throw new TypeError(`"${a}" names no key`);
|
|
893
896
|
return { code: s, ...i, ...e };
|
|
894
897
|
}
|
|
895
|
-
function
|
|
898
|
+
function za(a) {
|
|
896
899
|
const t = a.toLowerCase();
|
|
897
|
-
if (t in
|
|
900
|
+
if (t in le) return le[t];
|
|
898
901
|
if (/^[a-z0-9]$/i.test(a)) return a.toUpperCase().charCodeAt(0);
|
|
899
902
|
const e = /^f([1-9]|1[0-5])$/i.exec(a);
|
|
900
903
|
if (e) return 111 + Number(e[1]);
|
|
@@ -903,29 +906,29 @@ function pa(a) {
|
|
|
903
906
|
if (a === "+") return 187;
|
|
904
907
|
throw new TypeError(`Unknown key "${a}"`);
|
|
905
908
|
}
|
|
906
|
-
class
|
|
909
|
+
class Ia {
|
|
907
910
|
constructor(t) {
|
|
908
911
|
this.bridge = t;
|
|
909
912
|
}
|
|
910
913
|
bridge;
|
|
911
914
|
table = null;
|
|
912
915
|
async set(t, e) {
|
|
913
|
-
const [r] = await
|
|
914
|
-
await this.bridge.note(await this.number(), "write",
|
|
916
|
+
const [r] = await X(this.bridge, [e]);
|
|
917
|
+
await this.bridge.note(await this.number(), "write", S(t), r);
|
|
915
918
|
}
|
|
916
919
|
async get(t) {
|
|
917
|
-
const e = await this.bridge.note(await this.number(), "read",
|
|
918
|
-
return e == null ? void 0 :
|
|
920
|
+
const e = await this.bridge.note(await this.number(), "read", S(t));
|
|
921
|
+
return e == null ? void 0 : $(this.bridge, e);
|
|
919
922
|
}
|
|
920
923
|
async has(t) {
|
|
921
|
-
return await this.bridge.note(await this.number(), "has",
|
|
924
|
+
return await this.bridge.note(await this.number(), "has", S(t)) === !0;
|
|
922
925
|
}
|
|
923
926
|
async forget(t) {
|
|
924
|
-
return await this.bridge.note(await this.number(), "forget",
|
|
927
|
+
return await this.bridge.note(await this.number(), "forget", S(t)) === !0;
|
|
925
928
|
}
|
|
926
929
|
async objects() {
|
|
927
930
|
const t = await this.bridge.note(await this.number(), "keys");
|
|
928
|
-
return Array.isArray(t) ? t.filter((e) => e instanceof
|
|
931
|
+
return Array.isArray(t) ? t.filter((e) => e instanceof z).map((e) => P(this.bridge, e.at(), { handle: e })) : [];
|
|
929
932
|
}
|
|
930
933
|
async clear() {
|
|
931
934
|
this.table !== null && await this.bridge.note(this.table, "clear");
|
|
@@ -935,8 +938,8 @@ class fa {
|
|
|
935
938
|
return this.table ??= this.bridge.allocate(), this.table;
|
|
936
939
|
}
|
|
937
940
|
}
|
|
938
|
-
const
|
|
939
|
-
function
|
|
941
|
+
const Ba = 127;
|
|
942
|
+
function De(a) {
|
|
940
943
|
const t = [], e = [];
|
|
941
944
|
let r = "", n = 0;
|
|
942
945
|
const i = () => {
|
|
@@ -946,7 +949,7 @@ function Se(a) {
|
|
|
946
949
|
}, s = () => {
|
|
947
950
|
if (r === "") return;
|
|
948
951
|
const o = { text: r, ...i() }, l = t[t.length - 1];
|
|
949
|
-
l &&
|
|
952
|
+
l && Ua(l, o) ? l.text += r : t.push(o), r = "";
|
|
950
953
|
};
|
|
951
954
|
for (; n < a.length; ) {
|
|
952
955
|
const o = a[n];
|
|
@@ -958,23 +961,23 @@ function Se(a) {
|
|
|
958
961
|
r += "[", n += 2;
|
|
959
962
|
continue;
|
|
960
963
|
}
|
|
961
|
-
const l = a.indexOf("]", n + 1), c = l < 0 ? null :
|
|
964
|
+
const l = a.indexOf("]", n + 1), c = l < 0 ? null : Ha(a.slice(n + 1, l));
|
|
962
965
|
if (c === null) {
|
|
963
966
|
r += o, n++;
|
|
964
967
|
continue;
|
|
965
968
|
}
|
|
966
969
|
if (c.closing) {
|
|
967
|
-
const
|
|
968
|
-
|
|
970
|
+
const d = Va(e, c.name);
|
|
971
|
+
d < 0 ? r += a.slice(n, l + 1) : (s(), e.splice(d));
|
|
969
972
|
} else s(), e.push({ tag: c.name, look: c.look });
|
|
970
973
|
n = l + 1;
|
|
971
974
|
}
|
|
972
975
|
return s(), t;
|
|
973
976
|
}
|
|
974
|
-
function
|
|
977
|
+
function Ha(a) {
|
|
975
978
|
if (a.startsWith("/")) {
|
|
976
979
|
const n = a.slice(1);
|
|
977
|
-
return
|
|
980
|
+
return Da.has(n) ? { name: n, closing: !0 } : null;
|
|
978
981
|
}
|
|
979
982
|
const t = a.indexOf("="), e = t < 0 ? a : a.slice(0, t), r = t < 0 ? null : a.slice(t + 1);
|
|
980
983
|
switch (e) {
|
|
@@ -985,12 +988,12 @@ function ma(a) {
|
|
|
985
988
|
case "u":
|
|
986
989
|
return r === null ? { name: e, closing: !1, look: { underline: !0 } } : null;
|
|
987
990
|
case "color": {
|
|
988
|
-
const n = r === null ? null :
|
|
991
|
+
const n = r === null ? null : Wa(r);
|
|
989
992
|
return n === null ? null : { name: e, closing: !1, look: { color: n } };
|
|
990
993
|
}
|
|
991
994
|
case "size": {
|
|
992
995
|
const n = r === null ? NaN : Number(r);
|
|
993
|
-
return Number.isInteger(n) && n >= 1 && n <=
|
|
996
|
+
return Number.isInteger(n) && n >= 1 && n <= Ba ? { name: e, closing: !1, look: { size: n } } : null;
|
|
994
997
|
}
|
|
995
998
|
case "link":
|
|
996
999
|
return r === null || r === "" ? null : { name: e, closing: !1, look: { link: r } };
|
|
@@ -998,27 +1001,27 @@ function ma(a) {
|
|
|
998
1001
|
return null;
|
|
999
1002
|
}
|
|
1000
1003
|
}
|
|
1001
|
-
const
|
|
1002
|
-
function
|
|
1004
|
+
const Da = /* @__PURE__ */ new Set(["b", "i", "u", "color", "size", "link"]), qa = "0123456789abcdef";
|
|
1005
|
+
function Wa(a) {
|
|
1003
1006
|
const t = a.toLowerCase(), e = t.startsWith("#") ? t.slice(1) : t.startsWith("0x") ? t.slice(2) : null;
|
|
1004
1007
|
if (e === null || e.length !== 6) return null;
|
|
1005
1008
|
let r = 0;
|
|
1006
1009
|
for (const n of e) {
|
|
1007
|
-
const i =
|
|
1010
|
+
const i = qa.indexOf(n);
|
|
1008
1011
|
if (i < 0) return null;
|
|
1009
1012
|
r = r * 16 + i;
|
|
1010
1013
|
}
|
|
1011
1014
|
return r;
|
|
1012
1015
|
}
|
|
1013
|
-
function
|
|
1016
|
+
function Va(a, t) {
|
|
1014
1017
|
for (let e = a.length - 1; e >= 0; e--) if (a[e].tag === t) return e;
|
|
1015
1018
|
return -1;
|
|
1016
1019
|
}
|
|
1017
|
-
function
|
|
1020
|
+
function Ua(a, t) {
|
|
1018
1021
|
return ["color", "bold", "italic", "underline", "size", "font", "link"].every((e) => a[e] === t[e]);
|
|
1019
1022
|
}
|
|
1020
|
-
const
|
|
1021
|
-
class
|
|
1023
|
+
const At = { className: "avatar.AvatarManager", path: ["playerAvatarWorldView", "parent"] }, ce = /* @__PURE__ */ new Set(["click", "down", "up", "over", "out"]);
|
|
1024
|
+
class _a {
|
|
1022
1025
|
constructor(t) {
|
|
1023
1026
|
this.bridge = t;
|
|
1024
1027
|
}
|
|
@@ -1029,7 +1032,7 @@ class xa {
|
|
|
1029
1032
|
return r;
|
|
1030
1033
|
}
|
|
1031
1034
|
world(t = { x: 0, y: 0 }, e = {}) {
|
|
1032
|
-
return { place: this.bridge.definition(
|
|
1035
|
+
return { place: this.bridge.definition(At.className).at(At.path[0], At.path[1]), x: t.x, y: t.y, ...e };
|
|
1033
1036
|
}
|
|
1034
1037
|
marker(t, e = {}) {
|
|
1035
1038
|
const { kind: r = "circle", ...n } = e;
|
|
@@ -1074,7 +1077,7 @@ class xa {
|
|
|
1074
1077
|
}
|
|
1075
1078
|
async list(t = {}) {
|
|
1076
1079
|
const { handle: e, state: r } = await this.make("list", { width: 240, height: 160, fill: { color: 0, alpha: 0.55 }, padding: 4, ...t, font: { color: 16777215, ...t.font } });
|
|
1077
|
-
return Object.assign(e, { append: (...n) => r.removed || n.length === 0 ? Promise.resolve() : this.bridge.draw(e.node, { append: n.map(
|
|
1080
|
+
return Object.assign(e, { append: (...n) => r.removed || n.length === 0 ? Promise.resolve() : this.bridge.draw(e.node, { append: n.map($t) }), setRows: (n) => r.removed ? Promise.resolve() : this.bridge.draw(e.node, { rows: n.map($t) }) });
|
|
1078
1081
|
}
|
|
1079
1082
|
async replace(t, e) {
|
|
1080
1083
|
return await e.update({ parent: null, host: null, replaces: t }), () => e.remove();
|
|
@@ -1143,13 +1146,13 @@ class xa {
|
|
|
1143
1146
|
}
|
|
1144
1147
|
};
|
|
1145
1148
|
let c = r.listeners.get(i);
|
|
1146
|
-
const
|
|
1149
|
+
const d = !c || c.size === 0;
|
|
1147
1150
|
c || (c = /* @__PURE__ */ new Set(), r.listeners.set(i, c)), c.add(l);
|
|
1148
|
-
const
|
|
1149
|
-
|
|
1150
|
-
let
|
|
1151
|
+
const u = ce.has(i);
|
|
1152
|
+
d && u && this.sendMouse(t, r);
|
|
1153
|
+
let h = !1;
|
|
1151
1154
|
return async () => {
|
|
1152
|
-
|
|
1155
|
+
h || (h = !0, c.delete(l), u && c.size === 0 && !r.removed && await this.sendMouse(t, r));
|
|
1153
1156
|
};
|
|
1154
1157
|
}, onFailed: (i) => (r.failed.add(i), () => {
|
|
1155
1158
|
r.failed.delete(i);
|
|
@@ -1159,7 +1162,7 @@ class xa {
|
|
|
1159
1162
|
}) });
|
|
1160
1163
|
}
|
|
1161
1164
|
async sendMouse(t, e) {
|
|
1162
|
-
const r = [...e.listeners.entries()].filter(([n, i]) =>
|
|
1165
|
+
const r = [...e.listeners.entries()].filter(([n, i]) => ce.has(n) && i.size > 0).map(([n]) => n);
|
|
1163
1166
|
await this.bridge.draw(t, { mouse: r });
|
|
1164
1167
|
}
|
|
1165
1168
|
async remove(t) {
|
|
@@ -1187,32 +1190,32 @@ class xa {
|
|
|
1187
1190
|
e.parent = n === null ? null : n.node;
|
|
1188
1191
|
break;
|
|
1189
1192
|
case "anchor":
|
|
1190
|
-
e.anchor = n === null ? null :
|
|
1193
|
+
e.anchor = n === null ? null : Ga(n);
|
|
1191
1194
|
break;
|
|
1192
1195
|
case "host":
|
|
1193
1196
|
case "replaces":
|
|
1194
|
-
e[r] = n === null ? null :
|
|
1197
|
+
e[r] = n === null ? null : Ka(n);
|
|
1195
1198
|
break;
|
|
1196
1199
|
case "fill":
|
|
1197
1200
|
case "background":
|
|
1198
1201
|
case "hoverFill":
|
|
1199
1202
|
case "pressedFill":
|
|
1200
1203
|
case "titleFill":
|
|
1201
|
-
e[r] = n === null ? null :
|
|
1204
|
+
e[r] = n === null ? null : Ja(n);
|
|
1202
1205
|
break;
|
|
1203
1206
|
case "stroke":
|
|
1204
|
-
e.stroke = n === null ? null :
|
|
1207
|
+
e.stroke = n === null ? null : Xa(n);
|
|
1205
1208
|
break;
|
|
1206
1209
|
case "font":
|
|
1207
1210
|
case "titleFont":
|
|
1208
|
-
e[r] =
|
|
1211
|
+
e[r] = Ya(n);
|
|
1209
1212
|
break;
|
|
1210
1213
|
case "rich":
|
|
1211
|
-
e.spans = n === null ? null : typeof n == "string" ?
|
|
1214
|
+
e.spans = n === null ? null : typeof n == "string" ? De(n) : n;
|
|
1212
1215
|
break;
|
|
1213
1216
|
case "rows":
|
|
1214
1217
|
case "append":
|
|
1215
|
-
e[r] = n.map(
|
|
1218
|
+
e[r] = n.map($t);
|
|
1216
1219
|
break;
|
|
1217
1220
|
default:
|
|
1218
1221
|
e[r] = n;
|
|
@@ -1220,82 +1223,82 @@ class xa {
|
|
|
1220
1223
|
return e;
|
|
1221
1224
|
}
|
|
1222
1225
|
}
|
|
1223
|
-
function
|
|
1226
|
+
function Ya(a) {
|
|
1224
1227
|
return { family: "_sans", size: 12, color: 16777215, bold: !1, italic: !1, ...a };
|
|
1225
1228
|
}
|
|
1226
|
-
function
|
|
1229
|
+
function $t(a) {
|
|
1227
1230
|
if (typeof a == "string") return a || " ";
|
|
1228
|
-
const t = (Array.isArray(a) ? a :
|
|
1231
|
+
const t = (Array.isArray(a) ? a : De(a.markup)).filter((e) => e.text.length > 0);
|
|
1229
1232
|
return t.length ? t : " ";
|
|
1230
1233
|
}
|
|
1231
|
-
function
|
|
1232
|
-
const t = typeof a == "object" && a !== null && "place" in a ? a : { place: a }, e =
|
|
1234
|
+
function Ga(a) {
|
|
1235
|
+
const t = typeof a == "object" && a !== null && "place" in a ? a : { place: a }, e = S(t.place);
|
|
1233
1236
|
return { target: e.target, path: e.path, x: t.x ?? 0, y: t.y ?? 0, refreshFrames: t.refreshFrames ?? 12, hideWhenGone: t.hideWhenGone ?? !0 };
|
|
1234
1237
|
}
|
|
1235
|
-
function
|
|
1236
|
-
const t = typeof a == "object" && a !== null && "place" in a ? a : { place: a }, e =
|
|
1238
|
+
function Ka(a) {
|
|
1239
|
+
const t = typeof a == "object" && a !== null && "place" in a ? a : { place: a }, e = S(t.place);
|
|
1237
1240
|
return { target: e.target, path: e.path, refreshFrames: t.refreshFrames ?? 12 };
|
|
1238
1241
|
}
|
|
1239
|
-
function
|
|
1242
|
+
function Ja(a) {
|
|
1240
1243
|
return typeof a == "number" ? { color: a, alpha: 1 } : { color: a.color, alpha: a.alpha ?? 1 };
|
|
1241
1244
|
}
|
|
1242
|
-
function
|
|
1245
|
+
function Xa(a) {
|
|
1243
1246
|
return typeof a == "number" ? { color: a, alpha: 1, width: 1 } : { color: a.color, alpha: a.alpha ?? 1, width: a.width ?? 1 };
|
|
1244
1247
|
}
|
|
1245
|
-
async function
|
|
1248
|
+
async function Qa(a, t, e, r, n = {}) {
|
|
1246
1249
|
const i = t.find(e);
|
|
1247
1250
|
if (!i) throw new TypeError(`There is no hook "${e}" in the hook table`);
|
|
1248
1251
|
const s = { perFrame: n.perFrame ?? 50 };
|
|
1249
1252
|
n.when !== void 0 && (s.when = n.when), n.first !== void 0 && (s.first = n.first), n.every !== void 0 && (s.every = n.every), n.replaceArgs !== void 0 && (s.replaceArgs = n.replaceArgs), "returns" in n && (s.skip = { returns: n.returns });
|
|
1250
|
-
const o = { ...
|
|
1253
|
+
const o = { ...Vt(a, i, s, !1), override: !0 };
|
|
1251
1254
|
let l = 0, c = Promise.resolve();
|
|
1252
|
-
const
|
|
1255
|
+
const d = ct(i), u = async (p) => {
|
|
1253
1256
|
l++;
|
|
1254
1257
|
let f = !1, w = !1;
|
|
1255
|
-
const
|
|
1256
|
-
|
|
1257
|
-
var
|
|
1258
|
-
|
|
1258
|
+
const b = p.args.map((O) => $(a, a.decode(O))), k = {};
|
|
1259
|
+
b.forEach((O, y) => {
|
|
1260
|
+
var v;
|
|
1261
|
+
k[((v = i.parameters[y]) == null ? void 0 : v.name) ?? String(y)] = O;
|
|
1259
1262
|
});
|
|
1260
|
-
const
|
|
1261
|
-
if (w) throw new
|
|
1263
|
+
const M = i.isStatic ? P(a, a.definition(i.className), { className: i.className }) : $(a, a.decode(p.self)), R = { hook: i, call: p.call, self: M, args: k, argList: b, original: async (...O) => {
|
|
1264
|
+
if (w) throw new L("FLASH", `The call of ${d} has ended: its handler finished`);
|
|
1262
1265
|
f = !0;
|
|
1263
|
-
const y = await a.invokeOriginal(
|
|
1264
|
-
return
|
|
1266
|
+
const y = await a.invokeOriginal(h, p.token, O.length === 0 ? null : await X(a, O));
|
|
1267
|
+
return $(a, y);
|
|
1265
1268
|
} };
|
|
1266
1269
|
try {
|
|
1267
|
-
await r(
|
|
1268
|
-
} catch (
|
|
1269
|
-
if (console.error(`The override of ${
|
|
1270
|
-
await a.invokeOriginal(
|
|
1270
|
+
await r(R);
|
|
1271
|
+
} catch (O) {
|
|
1272
|
+
if (console.error(`The override of ${d} failed: ${O instanceof Error ? O.message : String(O)}`), !f && (n.onError ?? "original") === "original") try {
|
|
1273
|
+
await a.invokeOriginal(h, p.token, null);
|
|
1271
1274
|
} catch (y) {
|
|
1272
|
-
console.error(`The original ${
|
|
1275
|
+
console.error(`The original ${d} failed after its override did: ${y instanceof Error ? y.message : String(y)}`);
|
|
1273
1276
|
}
|
|
1274
1277
|
} finally {
|
|
1275
1278
|
w = !0, l--;
|
|
1276
1279
|
try {
|
|
1277
|
-
await a.overrideDone(
|
|
1280
|
+
await a.overrideDone(h, p.token);
|
|
1278
1281
|
} catch {
|
|
1279
1282
|
}
|
|
1280
1283
|
}
|
|
1281
|
-
}, { registration:
|
|
1284
|
+
}, { registration: h, stop: g } = await a.hook(i.id, o, (p) => {
|
|
1282
1285
|
var f;
|
|
1283
1286
|
switch (p.kind) {
|
|
1284
1287
|
case "override":
|
|
1285
|
-
n.sequential ? c = c.then(() =>
|
|
1288
|
+
n.sequential ? c = c.then(() => u(p)) : u(p);
|
|
1286
1289
|
return;
|
|
1287
1290
|
case "hook-dropped":
|
|
1288
1291
|
(f = n.onDropped) == null || f.call(n, p.dropped);
|
|
1289
1292
|
return;
|
|
1290
1293
|
case "hook-failed":
|
|
1291
|
-
console.error(`The override of ${
|
|
1294
|
+
console.error(`The override of ${d} failed and is off: ${p.error.message}`);
|
|
1292
1295
|
return;
|
|
1293
1296
|
}
|
|
1294
|
-
}), m = Object.assign(() => g(), { registration:
|
|
1297
|
+
}), m = Object.assign(() => g(), { registration: h, hook: i, stats: async () => (await a.request({ op: "hookStats" })).find((p) => p.registration === h) ?? null });
|
|
1295
1298
|
return Object.defineProperty(m, "running", { get: () => l, enumerable: !0 }), m;
|
|
1296
1299
|
}
|
|
1297
|
-
const
|
|
1298
|
-
class
|
|
1300
|
+
const Za = { fit: "showAll", stretch: "exactFit", fill: "noBorder", none: "noScale" };
|
|
1301
|
+
class tr {
|
|
1299
1302
|
constructor(t) {
|
|
1300
1303
|
this.bridge = t;
|
|
1301
1304
|
}
|
|
@@ -1307,13 +1310,13 @@ class $a {
|
|
|
1307
1310
|
return await this.bridge.definition("gMainFrame").at("layerManager", "bkg", "scaleX").get() * 100;
|
|
1308
1311
|
}
|
|
1309
1312
|
async stretch(t) {
|
|
1310
|
-
await this.bridge.stage().at("scaleMode").set(
|
|
1313
|
+
await this.bridge.stage().at("scaleMode").set(Za[t]);
|
|
1311
1314
|
}
|
|
1312
1315
|
hideHud(t) {
|
|
1313
|
-
return this.bridge.highlight({ target: { kind: "definition", name: "gui.GuiManager" }, path: t ? ["mainHud", t] : ["mainHud"] },
|
|
1316
|
+
return this.bridge.highlight({ target: { kind: "definition", name: "gui.GuiManager" }, path: t ? ["mainHud", t] : ["mainHud"] }, lt({ hide: !0 }));
|
|
1314
1317
|
}
|
|
1315
1318
|
hideLayer(t) {
|
|
1316
|
-
return this.bridge.highlight({ target: { kind: "definition", name: "gMainFrame" }, path: ["layerManager", t] },
|
|
1319
|
+
return this.bridge.highlight({ target: { kind: "definition", name: "gMainFrame" }, path: ["layerManager", t] }, lt({ hide: !0 }));
|
|
1317
1320
|
}
|
|
1318
1321
|
async setQuality(t) {
|
|
1319
1322
|
await this.bridge.stage().at("quality").set(t);
|
|
@@ -1323,15 +1326,15 @@ class $a {
|
|
|
1323
1326
|
return await e.set(Math.max(1, Math.min(120, t))), r;
|
|
1324
1327
|
}
|
|
1325
1328
|
}
|
|
1326
|
-
class
|
|
1329
|
+
class Kt extends Re {
|
|
1327
1330
|
format = "json";
|
|
1328
1331
|
envelope;
|
|
1329
1332
|
constructor(t, e) {
|
|
1330
|
-
super(t, e), this.envelope =
|
|
1333
|
+
super(t, e), this.envelope = er(t);
|
|
1331
1334
|
}
|
|
1332
1335
|
static create(t, e, r, n = -1, i = "o") {
|
|
1333
1336
|
const s = t === "toServer" ? { t: "xt", b: { x: i, c: e, r: n, p: r } } : { t: "xt", b: { r: n, o: { _cmd: e, ...r } } };
|
|
1334
|
-
return new
|
|
1337
|
+
return new Kt(JSON.stringify(s), t);
|
|
1335
1338
|
}
|
|
1336
1339
|
get type() {
|
|
1337
1340
|
return this.envelope.t;
|
|
@@ -1360,20 +1363,20 @@ class zt extends me {
|
|
|
1360
1363
|
return JSON.stringify(this.envelope);
|
|
1361
1364
|
}
|
|
1362
1365
|
}
|
|
1363
|
-
function
|
|
1366
|
+
function er(a) {
|
|
1364
1367
|
let t;
|
|
1365
1368
|
try {
|
|
1366
1369
|
t = JSON.parse(a);
|
|
1367
1370
|
} catch (e) {
|
|
1368
|
-
throw new
|
|
1371
|
+
throw new ee(`Not JSON: ${e.message}`, "JSON_SYNTAX");
|
|
1369
1372
|
}
|
|
1370
|
-
if (!
|
|
1373
|
+
if (!he(t) || typeof t.t != "string" || !he(t.b)) throw new ee('A JSON message is an object with "t" and "b"', "JSON_SYNTAX");
|
|
1371
1374
|
return t;
|
|
1372
1375
|
}
|
|
1373
|
-
function
|
|
1376
|
+
function he(a) {
|
|
1374
1377
|
return typeof a == "object" && a !== null && !Array.isArray(a);
|
|
1375
1378
|
}
|
|
1376
|
-
class
|
|
1379
|
+
class ue extends Re {
|
|
1377
1380
|
constructor(t, e, r = null) {
|
|
1378
1381
|
super(t, e), this.problem = r;
|
|
1379
1382
|
}
|
|
@@ -1389,24 +1392,24 @@ class Zt extends me {
|
|
|
1389
1392
|
return this.raw;
|
|
1390
1393
|
}
|
|
1391
1394
|
}
|
|
1392
|
-
function
|
|
1395
|
+
function qe(a, t) {
|
|
1393
1396
|
try {
|
|
1394
1397
|
switch (a.charAt(0)) {
|
|
1395
1398
|
case "<":
|
|
1396
|
-
return new
|
|
1397
|
-
case
|
|
1398
|
-
return new
|
|
1399
|
+
return new sa(a, t);
|
|
1400
|
+
case na:
|
|
1401
|
+
return new ia(a, t);
|
|
1399
1402
|
case "{":
|
|
1400
|
-
return new
|
|
1403
|
+
return new Kt(a, t);
|
|
1401
1404
|
default:
|
|
1402
|
-
return new
|
|
1405
|
+
return new ue(a, t);
|
|
1403
1406
|
}
|
|
1404
1407
|
} catch (e) {
|
|
1405
|
-
return new
|
|
1408
|
+
return new ue(a, t, e);
|
|
1406
1409
|
}
|
|
1407
1410
|
}
|
|
1408
|
-
const
|
|
1409
|
-
function
|
|
1411
|
+
const _t = { send: "avatar.UserCommXtCommManager.onSendMessage", focusChat: "gui.ChatHistory.setFocusOnMsgText" };
|
|
1412
|
+
function ar(a, t) {
|
|
1410
1413
|
const e = /* @__PURE__ */ new Map();
|
|
1411
1414
|
for (const [s, o] of Object.entries(t)) e.set(s.toLowerCase(), o);
|
|
1412
1415
|
if (e.size === 0) return a;
|
|
@@ -1417,33 +1420,33 @@ function Fa(a, t) {
|
|
|
1417
1420
|
for (const s of a) s === " " || s === " " ? (i(), r += s) : n += s;
|
|
1418
1421
|
return i(), r;
|
|
1419
1422
|
}
|
|
1420
|
-
function
|
|
1423
|
+
function rr(a, t) {
|
|
1421
1424
|
const e = a.toLowerCase();
|
|
1422
1425
|
return t.some((r) => typeof r == "string" ? r !== "" && e.includes(r.toLowerCase()) : (r.lastIndex = 0, r.test(a)));
|
|
1423
1426
|
}
|
|
1424
|
-
async function
|
|
1425
|
-
const { arg: e, fromClass: r, equals: n, exists: i, all: s } = a.flash.rules, o = t.shortcuts ?? {}, l = t.blocked ?? [], c = r("avatar.UserCommXtCommManager", "_mainHud", "chatBar", "text01_chat", "text"),
|
|
1426
|
-
for (const
|
|
1427
|
+
async function nr(a, t = {}) {
|
|
1428
|
+
const { arg: e, fromClass: r, equals: n, exists: i, all: s } = a.flash.rules, o = t.shortcuts ?? {}, l = t.blocked ?? [], c = r("avatar.UserCommXtCommManager", "_mainHud", "chatBar", "text01_chat", "text"), d = [], u = Jt(async () => {
|
|
1429
|
+
for (const h of d.splice(0).reverse()) await h().catch(() => {
|
|
1427
1430
|
});
|
|
1428
1431
|
});
|
|
1429
1432
|
try {
|
|
1430
|
-
|
|
1433
|
+
d.push(await a.flash.hook(_t.send, { when: s(n(e("myMsg"), ""), i(c)), replaceArgs: { myMsg: c } })), d.push(await a.flash.override(_t.send, async (h) => {
|
|
1431
1434
|
var g;
|
|
1432
|
-
const [m, p] =
|
|
1433
|
-
if (f.trim() !== "" &&
|
|
1435
|
+
const [m, p] = h.argList, f = typeof p == "string" ? p : "";
|
|
1436
|
+
if (f.trim() !== "" && rr(f, l)) {
|
|
1434
1437
|
(g = t.onBlocked) == null || g.call(t, f);
|
|
1435
1438
|
return;
|
|
1436
1439
|
}
|
|
1437
|
-
const w =
|
|
1438
|
-
w === f ? await
|
|
1440
|
+
const w = ar(f, o);
|
|
1441
|
+
w === f ? await h.original() : await h.original(m, w);
|
|
1439
1442
|
}, { sequential: !0 }));
|
|
1440
|
-
} catch (
|
|
1441
|
-
throw await
|
|
1443
|
+
} catch (h) {
|
|
1444
|
+
throw await u(), h;
|
|
1442
1445
|
}
|
|
1443
|
-
return
|
|
1446
|
+
return u;
|
|
1444
1447
|
}
|
|
1445
|
-
async function
|
|
1446
|
-
const e = t.style ?? {}, r = a.flash.overlay, n = a.flash.use("gui.GuiManager").$at("mainHud"), i = t.maxLength ?? await a.flash.use("gui.GuiManager").$at("chatHist", "chatMsgText", "maxChars").$get().then((c) => typeof c == "number" && c > 0 ? c : 70).catch(() => 70), s = { family: e.font ?? "_sans", size: e.size ?? 13 }, o = [], l =
|
|
1448
|
+
async function ir(a, t = {}) {
|
|
1449
|
+
const e = t.style ?? {}, r = a.flash.overlay, n = a.flash.use("gui.GuiManager").$at("mainHud"), i = t.maxLength ?? await a.flash.use("gui.GuiManager").$at("chatHist", "chatMsgText", "maxChars").$get().then((c) => typeof c == "number" && c > 0 ? c : 70).catch(() => 70), s = { family: e.font ?? "_sans", size: e.size ?? 13 }, o = [], l = Jt(async () => {
|
|
1447
1450
|
for (const c of o.splice(0).reverse()) await c().catch(() => {
|
|
1448
1451
|
});
|
|
1449
1452
|
});
|
|
@@ -1453,111 +1456,111 @@ async function Na(a, t = {}) {
|
|
|
1453
1456
|
});
|
|
1454
1457
|
const c = await r.input({ replaces: n.$at("chatBar"), placeholder: e.placeholderText ?? "Say something", maxLength: i, fill: e.background ?? 16777215, stroke: e.border ?? 8141549, cornerRadius: e.cornerRadius ?? 6, padding: 6, font: { ...s, color: e.text ?? 1120295 } });
|
|
1455
1458
|
o.push(() => c.remove());
|
|
1456
|
-
const
|
|
1457
|
-
o.push(() =>
|
|
1458
|
-
let
|
|
1459
|
-
const
|
|
1459
|
+
const d = await r.button(e.buttonLabel ?? "Send", { replaces: n.$at("sendChatBtn"), fill: e.button ?? 8141549, hoverFill: e.buttonHover ?? 9133302, cornerRadius: e.cornerRadius ?? 6, font: { ...s, color: e.buttonText ?? 16777215, bold: !0 } });
|
|
1460
|
+
o.push(() => d.remove());
|
|
1461
|
+
let u = !1;
|
|
1462
|
+
const h = async () => {
|
|
1460
1463
|
const g = c.value();
|
|
1461
|
-
if (!(
|
|
1462
|
-
|
|
1464
|
+
if (!(u || g.trim() === "")) {
|
|
1465
|
+
u = !0;
|
|
1463
1466
|
try {
|
|
1464
1467
|
await a.chat.say(g), await c.setValue(""), await c.focus();
|
|
1465
1468
|
} finally {
|
|
1466
|
-
|
|
1469
|
+
u = !1;
|
|
1467
1470
|
}
|
|
1468
1471
|
}
|
|
1469
1472
|
};
|
|
1470
1473
|
return o.push(c.on("submit", () => {
|
|
1471
|
-
|
|
1472
|
-
})), o.push(
|
|
1473
|
-
|
|
1474
|
-
})), o.push(await a.flash.hook(
|
|
1474
|
+
h();
|
|
1475
|
+
})), o.push(d.on("click", () => {
|
|
1476
|
+
h();
|
|
1477
|
+
})), o.push(await a.flash.hook(_t.focusChat, { skip: !0, phase: "enter", capture: { args: [] } }, () => {
|
|
1475
1478
|
c.focus();
|
|
1476
|
-
})), (t.focus ?? !0) && await c.focus(), Object.assign(l, { input: c, send:
|
|
1479
|
+
})), (t.focus ?? !0) && await c.focus(), Object.assign(l, { input: c, send: h });
|
|
1477
1480
|
} catch (c) {
|
|
1478
1481
|
throw await l(), c;
|
|
1479
1482
|
}
|
|
1480
1483
|
}
|
|
1481
|
-
const
|
|
1482
|
-
async function
|
|
1483
|
-
const e = t.style ?? {}, r = a.flash.overlay, n = e.nameColors && e.nameColors.length > 0 ? e.nameColors :
|
|
1484
|
-
for (const
|
|
1484
|
+
const sr = [16096779, 1096065, 3900150, 15485081, 9133302, 15680580, 1357990, 15381256], Pt = 22;
|
|
1485
|
+
async function or(a, t = {}) {
|
|
1486
|
+
const e = t.style ?? {}, r = a.flash.overlay, n = e.nameColors && e.nameColors.length > 0 ? e.nameColors : sr, i = t.width ?? 280, s = t.height ?? 200, o = { family: e.font ?? "_sans", size: e.size ?? 12 }, l = /* @__PURE__ */ new Map(), c = [], d = Jt(async () => {
|
|
1487
|
+
for (const u of c.splice(0).reverse()) await Promise.resolve(u()).catch(() => {
|
|
1485
1488
|
});
|
|
1486
1489
|
});
|
|
1487
1490
|
try {
|
|
1488
|
-
const
|
|
1489
|
-
c.push(() =>
|
|
1490
|
-
const
|
|
1491
|
-
c.push(
|
|
1491
|
+
const u = await r.panel({ title: t.title ?? "Chat", x: t.x ?? 12, y: t.y ?? 60, width: i, height: s, resizable: !0, fill: { color: e.background ?? 1120295, alpha: e.backgroundAlpha ?? 0.9 }, stroke: e.border ?? 3621201, titleFill: e.titleBar ?? 2042167, titleHeight: Pt, titleFont: { ...o, color: e.titleText ?? 16777215, bold: !0 }, ...t.onMove ? { onMove: t.onMove } : {} });
|
|
1492
|
+
c.push(() => u.remove());
|
|
1493
|
+
const h = await r.list({ parent: u, width: i, height: s - Pt, fill: null, maxRows: t.maxRows ?? 200, font: { ...o, color: e.text ?? 15987958 } });
|
|
1494
|
+
c.push(u.on("resize", (f) => {
|
|
1492
1495
|
var w;
|
|
1493
|
-
(w = t.onResize) == null || w.call(t, f),
|
|
1494
|
-
})), c.push(
|
|
1496
|
+
(w = t.onResize) == null || w.call(t, f), h.update({ width: f.width, height: f.height - Pt });
|
|
1497
|
+
})), c.push(h.on("link", (f) => {
|
|
1495
1498
|
const w = l.get(f);
|
|
1496
1499
|
if (w) {
|
|
1497
1500
|
if (t.onNameClick) {
|
|
1498
1501
|
t.onNameClick(w);
|
|
1499
1502
|
return;
|
|
1500
1503
|
}
|
|
1501
|
-
|
|
1504
|
+
lr(a, w.userId);
|
|
1502
1505
|
}
|
|
1503
1506
|
}));
|
|
1504
1507
|
const g = async (f) => {
|
|
1505
1508
|
let w = null;
|
|
1506
|
-
if (f.kind ===
|
|
1507
|
-
const
|
|
1508
|
-
return l.set(
|
|
1509
|
+
if (f.kind === Ot.free || f.kind === Ot.freeSafeChat ? w = f.text : f.kind === Ot.safeChat && (w = await a.chat.phrase(f.text).catch(() => null) ?? null), w === null) return null;
|
|
1510
|
+
const b = a.room.players.get(f.userId), k = (b == null ? void 0 : b.avatarName) || (b == null ? void 0 : b.userName) || `#${f.userId}`, M = String(f.userId);
|
|
1511
|
+
return l.set(M, { userId: f.userId, name: k }), [{ text: k, bold: !0, color: n[Math.abs(f.userId) % n.length], link: M }, { text: `: ${w}` }];
|
|
1509
1512
|
}, m = (await Promise.all(a.chat.recent.map(g))).filter((f) => f !== null);
|
|
1510
|
-
m.length > 0 && await
|
|
1513
|
+
m.length > 0 && await h.append(...m);
|
|
1511
1514
|
let p = Promise.resolve();
|
|
1512
1515
|
return c.push(a.chat.onMessage((f) => {
|
|
1513
1516
|
p = p.then(async () => {
|
|
1514
1517
|
const w = await g(f);
|
|
1515
|
-
w && await
|
|
1518
|
+
w && await h.append(w);
|
|
1516
1519
|
}).catch(() => {
|
|
1517
1520
|
});
|
|
1518
|
-
})), Object.assign(
|
|
1519
|
-
} catch (
|
|
1520
|
-
throw await
|
|
1521
|
+
})), Object.assign(d, { panel: u, note: (f) => h.append({ markup: f }) });
|
|
1522
|
+
} catch (u) {
|
|
1523
|
+
throw await d(), u;
|
|
1521
1524
|
}
|
|
1522
1525
|
}
|
|
1523
|
-
async function
|
|
1526
|
+
async function lr(a, t) {
|
|
1524
1527
|
const e = a.flash.use("avatar.AvatarManager").avatarViewList.$at(String(t)), r = await a.flash.highlight(e, { color: 16436245, strength: 3 });
|
|
1525
1528
|
setTimeout(() => {
|
|
1526
1529
|
r();
|
|
1527
1530
|
}, 2e3);
|
|
1528
1531
|
}
|
|
1529
|
-
function
|
|
1532
|
+
function Jt(a) {
|
|
1530
1533
|
let t = null;
|
|
1531
1534
|
return () => t ??= a();
|
|
1532
1535
|
}
|
|
1533
|
-
class
|
|
1536
|
+
class cr {
|
|
1534
1537
|
constructor(t) {
|
|
1535
|
-
this.bridge = t, this.overlay = new
|
|
1538
|
+
this.bridge = t, this.overlay = new _a(t), this.entities = new Ra(this), this.view = new tr(t);
|
|
1536
1539
|
}
|
|
1537
1540
|
bridge;
|
|
1538
1541
|
overlay;
|
|
1539
1542
|
entities;
|
|
1540
1543
|
view;
|
|
1541
|
-
rules =
|
|
1544
|
+
rules = $a;
|
|
1542
1545
|
hookIndex = null;
|
|
1543
1546
|
use(t) {
|
|
1544
|
-
return
|
|
1547
|
+
return P(this.bridge, this.bridge.definition(t), { className: t });
|
|
1545
1548
|
}
|
|
1546
1549
|
global(t) {
|
|
1547
|
-
return
|
|
1550
|
+
return P(this.bridge, this.bridge.definition(t));
|
|
1548
1551
|
}
|
|
1549
1552
|
stage() {
|
|
1550
|
-
return
|
|
1553
|
+
return P(this.bridge, this.bridge.stage());
|
|
1551
1554
|
}
|
|
1552
1555
|
client() {
|
|
1553
|
-
return
|
|
1556
|
+
return P(this.bridge, this.bridge.gameClient());
|
|
1554
1557
|
}
|
|
1555
1558
|
whenReady() {
|
|
1556
1559
|
return this.bridge.whenReady();
|
|
1557
1560
|
}
|
|
1558
1561
|
hooks(t) {
|
|
1559
1562
|
if (t !== void 0 || !this.hookIndex) {
|
|
1560
|
-
const e = this.bridge.hookTable(t).then((r) => new
|
|
1563
|
+
const e = this.bridge.hookTable(t).then((r) => new Aa(r));
|
|
1561
1564
|
e.catch(() => {
|
|
1562
1565
|
this.hookIndex === e && (this.hookIndex = null);
|
|
1563
1566
|
}), this.hookIndex = e;
|
|
@@ -1565,100 +1568,100 @@ class Ba {
|
|
|
1565
1568
|
return this.hookIndex;
|
|
1566
1569
|
}
|
|
1567
1570
|
async hook(t, e = {}, r) {
|
|
1568
|
-
return
|
|
1571
|
+
return Pa(this.bridge, await this.hooks(), t, e, r);
|
|
1569
1572
|
}
|
|
1570
1573
|
async override(t, e, ...[r]) {
|
|
1571
|
-
return
|
|
1574
|
+
return Qa(this.bridge, await this.hooks(), t, e, r ?? {});
|
|
1572
1575
|
}
|
|
1573
1576
|
style(t, e) {
|
|
1574
|
-
return this.bridge.style(
|
|
1577
|
+
return this.bridge.style(S(t), e);
|
|
1575
1578
|
}
|
|
1576
1579
|
hold(t, e, r = {}) {
|
|
1577
|
-
return
|
|
1580
|
+
return oe(this.bridge, [{ place: t, value: e }], r);
|
|
1578
1581
|
}
|
|
1579
1582
|
holdAll(t, e = {}) {
|
|
1580
|
-
return
|
|
1583
|
+
return oe(this.bridge, t, e);
|
|
1581
1584
|
}
|
|
1582
1585
|
repeat(t, e = {}) {
|
|
1583
|
-
return
|
|
1586
|
+
return ja(this.bridge, t, e);
|
|
1584
1587
|
}
|
|
1585
1588
|
collect(t, e, r = {}) {
|
|
1586
|
-
return
|
|
1589
|
+
return Oa(this.bridge, t, e, r);
|
|
1587
1590
|
}
|
|
1588
1591
|
async track(t, e, r = {}) {
|
|
1589
1592
|
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");
|
|
1590
|
-
const n = r.where === void 0 ? { target: { kind: "stage" }, path: [] } :
|
|
1593
|
+
const n = r.where === void 0 ? { target: { kind: "stage" }, path: [] } : S(r.where), i = (s) => s.filter((o) => o instanceof z).map((o) => P(this.bridge, o.at(), { handle: o }));
|
|
1591
1594
|
return this.bridge.track(n, t, { ...r.mode !== void 0 ? { mode: r.mode } : {}, ...r.everyFrames !== void 0 ? { everyFrames: r.everyFrames } : {} }, ({ added: s, removed: o }) => e({ added: i(s), removed: i(o) }));
|
|
1592
1595
|
}
|
|
1593
1596
|
async snapshot(t, e = {}) {
|
|
1594
1597
|
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");
|
|
1595
|
-
return this.bridge.snapshot(
|
|
1598
|
+
return this.bridge.snapshot(S(t), e);
|
|
1596
1599
|
}
|
|
1597
1600
|
notes() {
|
|
1598
|
-
return new
|
|
1601
|
+
return new Ia(this.bridge);
|
|
1599
1602
|
}
|
|
1600
1603
|
async find(t, e) {
|
|
1601
|
-
return await
|
|
1604
|
+
return await Fa(this.bridge, e, t ?? {});
|
|
1602
1605
|
}
|
|
1603
1606
|
answering(t, e) {
|
|
1604
|
-
return new
|
|
1607
|
+
return new Sa(this.bridge, t, e);
|
|
1605
1608
|
}
|
|
1606
1609
|
watch(t, e, r) {
|
|
1607
1610
|
const n = r;
|
|
1608
1611
|
let i, s = [], o;
|
|
1609
1612
|
if (Array.isArray(t)) i = "list", o = [...t];
|
|
1610
|
-
else if (
|
|
1613
|
+
else if (ur(t)) i = "one", o = [t];
|
|
1611
1614
|
else {
|
|
1612
1615
|
i = "record";
|
|
1613
|
-
const
|
|
1614
|
-
s = Object.keys(
|
|
1615
|
-
}
|
|
1616
|
-
const l = o.map(
|
|
1617
|
-
let
|
|
1618
|
-
return this.bridge.watch(l, e, (
|
|
1619
|
-
const g =
|
|
1620
|
-
n(m,
|
|
1616
|
+
const u = t;
|
|
1617
|
+
s = Object.keys(u), o = s.map((h) => u[h]);
|
|
1618
|
+
}
|
|
1619
|
+
const l = o.map(S), c = (u) => i === "one" ? u[0] : i === "list" ? u : Object.fromEntries(s.map((h, g) => [h, u[g]]));
|
|
1620
|
+
let d = null;
|
|
1621
|
+
return this.bridge.watch(l, e, (u, h) => {
|
|
1622
|
+
const g = u.map((f) => $(this.bridge, f)), m = c(g), p = l.map((f, w) => (h == null ? void 0 : h[w]) ?? null);
|
|
1623
|
+
n(m, d, i === "one" ? p[0] : c(p)), d = m;
|
|
1621
1624
|
});
|
|
1622
1625
|
}
|
|
1623
1626
|
onTick(t, e = {}) {
|
|
1624
1627
|
return this.bridge.tick(e.everyFrames ?? 1, t);
|
|
1625
1628
|
}
|
|
1626
1629
|
highlight(t, e = {}) {
|
|
1627
|
-
return this.bridge.highlight(
|
|
1630
|
+
return this.bridge.highlight(S(t), lt(e));
|
|
1628
1631
|
}
|
|
1629
1632
|
hide(t) {
|
|
1630
|
-
return this.bridge.highlight(
|
|
1633
|
+
return this.bridge.highlight(S(t), lt({ hide: !0 }));
|
|
1631
1634
|
}
|
|
1632
1635
|
recolor(t, e) {
|
|
1633
|
-
const r = e ?
|
|
1634
|
-
return this.bridge.highlight(r, { glow: null, ...
|
|
1636
|
+
const r = e ? S(e) : { target: { kind: "loader" }, path: [] };
|
|
1637
|
+
return this.bridge.highlight(r, { glow: null, ...Ne(t), hide: !1, pulse: null });
|
|
1635
1638
|
}
|
|
1636
1639
|
onKey(t, e, r = {}) {
|
|
1637
|
-
return this.bridge.onKey(
|
|
1640
|
+
return this.bridge.onKey(Na(t, r), (n) => hr(e)({ code: n.code, char: n.char, ctrl: n.ctrl, shift: n.shift, alt: n.alt, phase: n.phase, consumed: n.consumed === !0 }));
|
|
1638
1641
|
}
|
|
1639
1642
|
}
|
|
1640
|
-
function
|
|
1643
|
+
function hr(a) {
|
|
1641
1644
|
return (t) => {
|
|
1642
1645
|
try {
|
|
1643
1646
|
const e = a(t);
|
|
1644
|
-
e instanceof Promise && e.catch((r) =>
|
|
1647
|
+
e instanceof Promise && e.catch((r) => de(r));
|
|
1645
1648
|
} catch (e) {
|
|
1646
|
-
|
|
1649
|
+
de(e);
|
|
1647
1650
|
}
|
|
1648
1651
|
};
|
|
1649
1652
|
}
|
|
1650
|
-
function
|
|
1653
|
+
function de(a) {
|
|
1651
1654
|
console.error("phantom.flash.onKey: a listener failed", a);
|
|
1652
1655
|
}
|
|
1653
|
-
function
|
|
1656
|
+
function ur(a) {
|
|
1654
1657
|
try {
|
|
1655
|
-
return
|
|
1658
|
+
return S(a), !0;
|
|
1656
1659
|
} catch {
|
|
1657
1660
|
return !1;
|
|
1658
1661
|
}
|
|
1659
1662
|
}
|
|
1660
|
-
const
|
|
1661
|
-
class
|
|
1663
|
+
const dr = { avatarManager: "avatar.AvatarManager" }, pr = "com.sbi.loader.LoaderCache.fetchCDNURL", fr = 2e4;
|
|
1664
|
+
class gr {
|
|
1662
1665
|
channel;
|
|
1663
1666
|
flash;
|
|
1664
1667
|
hooks = /* @__PURE__ */ new Map();
|
|
@@ -1669,15 +1672,15 @@ class Ua {
|
|
|
1669
1672
|
return this.channel !== null;
|
|
1670
1673
|
}
|
|
1671
1674
|
async replace(t, e) {
|
|
1672
|
-
const r = this.reach(), n =
|
|
1673
|
-
await this.unhook(
|
|
1674
|
-
const i = await r.replace(n,
|
|
1675
|
-
return o && (this.hooks.set(
|
|
1675
|
+
const r = this.reach(), n = pe(t);
|
|
1676
|
+
await this.unhook(jt(n));
|
|
1677
|
+
const i = await r.replace(n, Rt(e)), s = [], o = await this.pointClientAt(n, i.url);
|
|
1678
|
+
return o && (this.hooks.set(jt(n), o), s.push("client")), s.push("proxy"), { ...i, how: s, stop: () => this.restore(n).then(() => {
|
|
1676
1679
|
}) };
|
|
1677
1680
|
}
|
|
1678
1681
|
async restore(t) {
|
|
1679
|
-
const e = this.reach(), r =
|
|
1680
|
-
return await this.unhook(
|
|
1682
|
+
const e = this.reach(), r = pe(t);
|
|
1683
|
+
return await this.unhook(jt(r)), e.restore(r);
|
|
1681
1684
|
}
|
|
1682
1685
|
replacements() {
|
|
1683
1686
|
return this.reach().list();
|
|
@@ -1692,27 +1695,27 @@ class Ua {
|
|
|
1692
1695
|
} };
|
|
1693
1696
|
}
|
|
1694
1697
|
async load(t, e = {}) {
|
|
1695
|
-
const r = this.flash.bridge, n =
|
|
1698
|
+
const r = this.flash.bridge, n = Rt(t), i = await r.construct("flash.display.Loader"), s = [];
|
|
1696
1699
|
try {
|
|
1697
1700
|
const o = await r.definition("flash.system.ApplicationDomain").at("currentDomain").get();
|
|
1698
1701
|
s.push(() => o.release());
|
|
1699
1702
|
const l = await r.construct("flash.system.LoaderContext", !1, o);
|
|
1700
1703
|
s.push(() => l.release()), await l.at("allowCodeImport").set(e.allowCode === !0).catch(() => {
|
|
1701
1704
|
});
|
|
1702
|
-
const c = this.whenLoaded(i, e.timeoutMs ??
|
|
1705
|
+
const c = this.whenLoaded(i, e.timeoutMs ?? fr);
|
|
1703
1706
|
if (n.kind === "data-url") {
|
|
1704
|
-
const
|
|
1705
|
-
s.push(() =>
|
|
1707
|
+
const u = await this.decodeInFlash(n.url);
|
|
1708
|
+
s.push(() => u.release()), await i.at("loadBytes").call(u, l);
|
|
1706
1709
|
} else {
|
|
1707
|
-
const
|
|
1708
|
-
s.push(() => this.reach().release(
|
|
1710
|
+
const u = await this.reach().hold(n);
|
|
1711
|
+
s.push(() => this.reach().release(u.id)), await i.at("load").call(new vt("flash.net.URLRequest", [u.url]), l);
|
|
1709
1712
|
}
|
|
1710
1713
|
await c;
|
|
1711
|
-
const
|
|
1712
|
-
if (!
|
|
1713
|
-
return { content:
|
|
1714
|
+
const d = await i.at("content").get();
|
|
1715
|
+
if (!d) throw new Error("Nothing was loaded");
|
|
1716
|
+
return { content: d, loader: i, unload: async () => {
|
|
1714
1717
|
await i.at("unloadAndStop").call().catch(() => {
|
|
1715
|
-
}), await
|
|
1718
|
+
}), await d.release().catch(() => {
|
|
1716
1719
|
}), await i.release().catch(() => {
|
|
1717
1720
|
});
|
|
1718
1721
|
} };
|
|
@@ -1726,11 +1729,11 @@ class Ua {
|
|
|
1726
1729
|
}
|
|
1727
1730
|
async pointClientAt(t, e) {
|
|
1728
1731
|
if (t.kind === "pattern") return null;
|
|
1729
|
-
const r =
|
|
1732
|
+
const r = mr(t.value);
|
|
1730
1733
|
if (!r) return null;
|
|
1731
1734
|
const { arg: n, equals: i, startsWith: s, any: o } = this.flash.rules, l = t.kind === "prefix" ? s : i;
|
|
1732
1735
|
try {
|
|
1733
|
-
return await this.flash.hook(
|
|
1736
|
+
return await this.flash.hook(pr, { when: o(l(n("assetPath"), r), l(n("assetPath"), `/${r}`)), replaceReturn: e });
|
|
1734
1737
|
} catch {
|
|
1735
1738
|
return null;
|
|
1736
1739
|
}
|
|
@@ -1741,7 +1744,7 @@ class Ua {
|
|
|
1741
1744
|
}));
|
|
1742
1745
|
}
|
|
1743
1746
|
async addressOf(t) {
|
|
1744
|
-
const e =
|
|
1747
|
+
const e = Rt(t);
|
|
1745
1748
|
if (e.kind === "data-url") return { url: e.url, id: null };
|
|
1746
1749
|
const r = await this.reach().hold(e);
|
|
1747
1750
|
return { url: r.url, id: r.id };
|
|
@@ -1756,12 +1759,12 @@ class Ua {
|
|
|
1756
1759
|
whenLoaded(t, e) {
|
|
1757
1760
|
const r = t.at("contentLoaderInfo");
|
|
1758
1761
|
return new Promise((n, i) => {
|
|
1759
|
-
const s = [], o = (
|
|
1762
|
+
const s = [], o = (d) => {
|
|
1760
1763
|
clearTimeout(l);
|
|
1761
|
-
for (const
|
|
1764
|
+
for (const u of s.splice(0)) u().catch(() => {
|
|
1762
1765
|
});
|
|
1763
|
-
|
|
1764
|
-
}, l = setTimeout(() => o(new Error(`Flash did not load those bytes within ${e}ms`)), e), c = (
|
|
1766
|
+
d ? i(d) : n();
|
|
1767
|
+
}, l = setTimeout(() => o(new Error(`Flash did not load those bytes within ${e}ms`)), e), c = (d, u) => r.listen(d, () => o(u === null ? null : new Error(u))).then((h) => s.push(h), (h) => o(h));
|
|
1765
1768
|
c("complete", null), c("ioError", "Flash could not read those bytes"), c("securityError", "Flash refused those bytes");
|
|
1766
1769
|
});
|
|
1767
1770
|
}
|
|
@@ -1770,21 +1773,21 @@ class Ua {
|
|
|
1770
1773
|
return this.channel;
|
|
1771
1774
|
}
|
|
1772
1775
|
}
|
|
1773
|
-
function
|
|
1776
|
+
function jt(a) {
|
|
1774
1777
|
return `${a.kind}:${a.value}`;
|
|
1775
1778
|
}
|
|
1776
|
-
function
|
|
1779
|
+
function mr(a) {
|
|
1777
1780
|
let t = a.charAt(0) === "/" ? a.slice(1) : a;
|
|
1778
1781
|
const e = t.indexOf("?");
|
|
1779
1782
|
e !== -1 && (t = t.slice(0, e)), t.slice(0, 8) === "content/" && (t = t.slice(8));
|
|
1780
1783
|
const r = t.indexOf("/"), n = r === -1 ? t : t.slice(0, r);
|
|
1781
|
-
return r !== -1 && n.length > 0 &&
|
|
1784
|
+
return r !== -1 && n.length > 0 && wr(n) && (t = t.slice(r + 1)), t;
|
|
1782
1785
|
}
|
|
1783
|
-
function
|
|
1786
|
+
function wr(a) {
|
|
1784
1787
|
for (const t of a) if (t < "0" || t > "9") return !1;
|
|
1785
1788
|
return a.length > 0;
|
|
1786
1789
|
}
|
|
1787
|
-
function
|
|
1790
|
+
function pe(a) {
|
|
1788
1791
|
const t = typeof a == "string" ? { kind: "path", value: a } : a;
|
|
1789
1792
|
if (!t || typeof t.value != "string" || !t.value) throw new TypeError("A replacement matches a path, a prefix or a pattern");
|
|
1790
1793
|
const e = t.kind;
|
|
@@ -1792,7 +1795,7 @@ function ee(a) {
|
|
|
1792
1795
|
const r = t.value.charAt(0) === "/" ? t.value : `/${t.value}`;
|
|
1793
1796
|
return { kind: e, value: r };
|
|
1794
1797
|
}
|
|
1795
|
-
function
|
|
1798
|
+
function Rt(a) {
|
|
1796
1799
|
if (typeof a == "string") return a.slice(0, 5).toLowerCase() === "data:" ? { kind: "data-url", url: a } : { kind: "file", path: a };
|
|
1797
1800
|
if (a instanceof ArrayBuffer) return { kind: "bytes", bytes: new Uint8Array(a) };
|
|
1798
1801
|
if (ArrayBuffer.isView(a)) {
|
|
@@ -1811,32 +1814,35 @@ function Tt(a) {
|
|
|
1811
1814
|
}
|
|
1812
1815
|
throw new TypeError("A source is bytes, a data: URL, or the path of a file on this computer");
|
|
1813
1816
|
}
|
|
1814
|
-
const
|
|
1815
|
-
function
|
|
1817
|
+
const F = { 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" }, yr = { 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" }, Yt = { ink: 1118483, line: 3816e3, light: 15790322, muted: 10000543, accent: 8141549, danger: 15680580, size: 12, cornerRadius: 4 }, Gt = { ink: 4403228, line: 9071167, light: 16643032, muted: 9402972, accent: 3123423, danger: 13369344, size: 11, cornerRadius: 8 }, H = { game: 28, phantom: 24 }, Ft = 22, Ct = 4, fe = { top: 12, left: 10, right: 10, bottom: 12 }, ge = 4293980400, br = 12e4, vr = 500;
|
|
1818
|
+
function V(a) {
|
|
1816
1819
|
return (...t) => {
|
|
1817
1820
|
try {
|
|
1818
1821
|
const e = a(...t);
|
|
1819
|
-
e instanceof Promise && e.catch(
|
|
1822
|
+
e instanceof Promise && e.catch(D);
|
|
1820
1823
|
} catch (e) {
|
|
1821
|
-
|
|
1824
|
+
D(e);
|
|
1822
1825
|
}
|
|
1823
1826
|
};
|
|
1824
1827
|
}
|
|
1825
|
-
function
|
|
1828
|
+
function D(a) {
|
|
1826
1829
|
console.error("phantom.ui: a listener failed", a);
|
|
1827
1830
|
}
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
return { skin: a, font: t, ...a === "game" ? It : Lt };
|
|
1831
|
+
function Lt(a, t) {
|
|
1832
|
+
console.warn(`phantom.ui: the picture ${a} did not load: ${t}`);
|
|
1831
1833
|
}
|
|
1832
|
-
const
|
|
1833
|
-
function
|
|
1834
|
-
|
|
1834
|
+
const pt = { game: 110, phantom: 96 }, U = 2, me = 0.5, wt = "_sans";
|
|
1835
|
+
function kr(a, t = wt) {
|
|
1836
|
+
return { skin: a, font: t, ...a === "game" ? Gt : Yt };
|
|
1837
|
+
}
|
|
1838
|
+
const xr = { 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." }, Mr = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
1839
|
+
function we(a) {
|
|
1840
|
+
if (!Mr.test(a)) throw new TypeError(`"${a}" is not a symbol name: a symbol is named in letters, digits and underscores`);
|
|
1835
1841
|
return a;
|
|
1836
1842
|
}
|
|
1837
|
-
const
|
|
1838
|
-
function
|
|
1839
|
-
const r = { slot: "layer" }, n = { slot: "callback" }, i = e.name ?? null, s =
|
|
1843
|
+
const ye = { gui: { className: F.guiManager, path: ["guiLayer"] }, hud: { className: F.guiManager, path: ["mainHud"] }, room: { className: F.avatarManager, path: ["playerAvatarWorldView", "parent"] }, avatarEditor: { className: F.guiManager, path: ["avatarEditor", "avEditor"] }, denEditor: { className: F.denEditor, path: ["staticEditor"] } }, be = "stage", ve = { 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 } }, Tr = 5, Sr = 18, rt = 8, Nt = 16, Or = 240, zt = 20, Er = 48, Ar = -80, ke = { x: 12, y: -10 }, T = 8, It = 22, xe = { game: 320, phantom: 300 }, $r = { game: 190, phantom: 150 }, ft = { x: 60, y: 90 }, Pr = { ok: 0, yesNo: 1, continueExit: 2, continue: 3 };
|
|
1844
|
+
function jr(a, t, e = {}) {
|
|
1845
|
+
const r = { slot: "layer" }, n = { slot: "callback" }, i = e.name ?? null, s = yr[a];
|
|
1840
1846
|
switch (a) {
|
|
1841
1847
|
case "message":
|
|
1842
1848
|
return { className: s, args: [r, { slot: "skin" }, t, !0, !0, e.modal ?? !1, e.draggable ?? !0, e.darken ?? !1, i] };
|
|
@@ -1849,10 +1855,10 @@ function ar(a, t, e = {}) {
|
|
|
1849
1855
|
case "titled":
|
|
1850
1856
|
return { className: s, args: [r, t, e.title ?? null, e.mediaId ?? 370, n, !0, e.darken ?? !0] };
|
|
1851
1857
|
case "parchment":
|
|
1852
|
-
return { className: s, args: [r,
|
|
1858
|
+
return { className: s, args: [r, Pr[e.buttons ?? "ok"], t, e.darken ?? !0, n, null] };
|
|
1853
1859
|
}
|
|
1854
1860
|
}
|
|
1855
|
-
function
|
|
1861
|
+
function Me(a) {
|
|
1856
1862
|
const t = Math.max(1, Math.floor(a.columns)), e = [];
|
|
1857
1863
|
for (let r = 0; r < Math.max(0, Math.floor(a.count)); r++) {
|
|
1858
1864
|
const n = Math.floor(r / t), i = r % t;
|
|
@@ -1860,7 +1866,7 @@ function le(a) {
|
|
|
1860
1866
|
}
|
|
1861
1867
|
return e;
|
|
1862
1868
|
}
|
|
1863
|
-
function
|
|
1869
|
+
function Rr(a, t) {
|
|
1864
1870
|
const e = t.gap, r = a.length;
|
|
1865
1871
|
if (r === 0) return [];
|
|
1866
1872
|
const n = (t.width + e) / r;
|
|
@@ -1869,34 +1875,35 @@ function rr(a, t) {
|
|
|
1869
1875
|
return { index: s, value: i, x: o, width: Math.max(0, l - o - e) };
|
|
1870
1876
|
});
|
|
1871
1877
|
}
|
|
1872
|
-
function
|
|
1878
|
+
function Fr(a) {
|
|
1873
1879
|
const t = Math.max(0, a.contentHeight - a.viewHeight), e = Math.min(t, Math.max(0, a.offset)), r = a.minThumb ?? 16, n = a.contentHeight > 0 ? a.viewHeight / a.contentHeight : 1, i = Math.max(Math.min(a.trackHeight, r), Math.min(a.trackHeight, Math.round(a.trackHeight * n))), s = a.trackHeight - i;
|
|
1874
1880
|
return { offset: e, max: t, thumbY: t > 0 ? Math.round(e / t * s) : 0, thumbHeight: i };
|
|
1875
1881
|
}
|
|
1876
|
-
function
|
|
1882
|
+
function Cr(a, t, e) {
|
|
1877
1883
|
const r = Math.max(1, Math.round(a - t - e + 1)), n = -Math.floor(r / 2);
|
|
1878
1884
|
return { middle: r, middleY: n, topY: n - t, bottomY: n + r - 1 };
|
|
1879
1885
|
}
|
|
1880
|
-
function
|
|
1886
|
+
function Lr(a, t) {
|
|
1881
1887
|
const e = t ? { top: t.y, left: t.x, right: a.width - t.x - t.width, bottom: a.height - t.y - t.height } : null, r = (s, o) => {
|
|
1882
1888
|
const l = e == null ? void 0 : e[s];
|
|
1883
|
-
return l !== void 0 && Number.isFinite(l) && l >= 2 && l <= o / 4 ? Math.ceil(l) :
|
|
1884
|
-
}, n = { top: r("top", a.height), left: r("left", a.width), right: r("right", a.width), bottom: r("bottom", a.height) }, i = { x: n.left +
|
|
1885
|
-
return { edge: n, measured: e !== null && Object.keys(
|
|
1889
|
+
return l !== void 0 && Number.isFinite(l) && l >= 2 && l <= o / 4 ? Math.ceil(l) : fe[s];
|
|
1890
|
+
}, n = { top: r("top", a.height), left: r("left", a.width), right: r("right", a.width), bottom: r("bottom", a.height) }, i = { x: n.left + Ct, y: n.top, width: Math.max(0, Math.floor(a.width - n.left - n.right - 2 * Ct)), height: Math.max(Ft, Math.floor(a.height - n.top - n.bottom - Ct)) };
|
|
1891
|
+
return { edge: n, measured: e !== null && Object.keys(fe).every((s) => n[s] === Math.ceil(e[s])), panel: i, titleHeight: Ft, body: { width: i.width, height: i.height - Ft } };
|
|
1886
1892
|
}
|
|
1887
|
-
class
|
|
1893
|
+
class Nr {
|
|
1888
1894
|
bridge;
|
|
1889
1895
|
flash;
|
|
1890
1896
|
drawn = /* @__PURE__ */ new Set();
|
|
1891
1897
|
popups = /* @__PURE__ */ new Set();
|
|
1898
|
+
tags = /* @__PURE__ */ new Map();
|
|
1892
1899
|
symbolMaker = null;
|
|
1893
1900
|
gameFont = null;
|
|
1894
1901
|
defaultSkin = "phantom";
|
|
1895
1902
|
known = { art: !1, palettes: !1 };
|
|
1896
|
-
readyTimeoutMs =
|
|
1903
|
+
readyTimeoutMs = br;
|
|
1897
1904
|
popup;
|
|
1898
1905
|
constructor(t, e) {
|
|
1899
|
-
this.bridge = t.flash, this.flash = e, this.popup = new
|
|
1906
|
+
this.bridge = t.flash, this.flash = e, this.popup = new zr((r, n, i, s, o) => this.openPopup(r, n, i, s, o), () => this.clear());
|
|
1900
1907
|
}
|
|
1901
1908
|
get skin() {
|
|
1902
1909
|
return this.defaultSkin;
|
|
@@ -1916,21 +1923,21 @@ class or {
|
|
|
1916
1923
|
}
|
|
1917
1924
|
async theme(t) {
|
|
1918
1925
|
const e = t ?? this.defaultSkin;
|
|
1919
|
-
return
|
|
1926
|
+
return kr(e, e === "game" ? await this.clientFont() : wt);
|
|
1920
1927
|
}
|
|
1921
1928
|
symbols() {
|
|
1922
|
-
return Object.entries(
|
|
1929
|
+
return Object.entries(xr);
|
|
1923
1930
|
}
|
|
1924
1931
|
async hasSymbol(t) {
|
|
1925
|
-
const e =
|
|
1932
|
+
const e = we(t);
|
|
1926
1933
|
try {
|
|
1927
|
-
return await this.bridge.definition(
|
|
1934
|
+
return await this.bridge.definition(F.resourceStack).at("hudAssetsLoaderInfo", "applicationDomain", "hasDefinition").call(e) === !0;
|
|
1928
1935
|
} catch {
|
|
1929
1936
|
return !1;
|
|
1930
1937
|
}
|
|
1931
1938
|
}
|
|
1932
1939
|
async symbol(t, e = {}) {
|
|
1933
|
-
const r =
|
|
1940
|
+
const r = we(t);
|
|
1934
1941
|
await this.waitFor({ art: !0 });
|
|
1935
1942
|
const n = await this.flash.overlay.group({ x: e.x ?? 0, y: e.y ?? 0, ...e.scale === void 0 ? {} : { scale: e.scale }, ...e.visible === void 0 ? {} : { visible: e.visible } });
|
|
1936
1943
|
let i = null;
|
|
@@ -1941,11 +1948,11 @@ class or {
|
|
|
1941
1948
|
}), c;
|
|
1942
1949
|
}
|
|
1943
1950
|
const s = i, o = s.at(), l = /* @__PURE__ */ new Set();
|
|
1944
|
-
return this.widget(n, e.skin ?? this.defaultSkin, { name: r, object: s, on: async (c,
|
|
1945
|
-
const
|
|
1946
|
-
l.delete(
|
|
1951
|
+
return this.widget(n, e.skin ?? this.defaultSkin, { name: r, object: s, on: async (c, d) => {
|
|
1952
|
+
const u = await o.listen(Te[c], () => d()), h = async () => {
|
|
1953
|
+
l.delete(h), await u();
|
|
1947
1954
|
};
|
|
1948
|
-
return l.add(
|
|
1955
|
+
return l.add(h), h;
|
|
1949
1956
|
}, size: async () => ({ width: await s.at("width").get() ?? 0, height: await s.at("height").get() ?? 0 }) }, async () => {
|
|
1950
1957
|
for (const c of [...l]) await c().catch(() => {
|
|
1951
1958
|
});
|
|
@@ -1955,49 +1962,75 @@ class or {
|
|
|
1955
1962
|
}
|
|
1956
1963
|
async window(t = {}) {
|
|
1957
1964
|
const e = t.skin ?? this.defaultSkin, r = e === "game", n = r && (await this.waitFor({ art: !0 })).art, i = await this.theme(e), s = { width: t.width ?? 280, height: t.height ?? 200 }, o = { x: t.x ?? 40, y: t.y ?? 40 }, l = r ? 30 : 24, c = await this.flash.overlay.panel({ x: o.x, y: o.y, width: s.width, height: s.height, title: t.title ?? "", titleHeight: l, draggable: t.draggable !== !1, resizable: t.resizable === !0 && !r, cornerRadius: i.cornerRadius, fill: r ? { color: i.light, alpha: 0 } : { color: i.ink, alpha: 0.94 }, stroke: r ? null : i.line, titleFill: i.line, titleFont: { family: i.font, size: i.size + 1, bold: !0, color: i.light }, visible: !1 });
|
|
1958
|
-
let
|
|
1965
|
+
let d = null;
|
|
1959
1966
|
if (n) try {
|
|
1960
|
-
|
|
1967
|
+
d = await this.dressWindow(c, s.height);
|
|
1961
1968
|
} catch (w) {
|
|
1962
|
-
console.warn(`phantom.ui.window: the popup frame could not be drawn: ${
|
|
1969
|
+
console.warn(`phantom.ui.window: the popup frame could not be drawn: ${Y(w)}`);
|
|
1963
1970
|
}
|
|
1964
1971
|
else r && console.warn(`phantom.ui.window: the game has not loaded its popup art after ${Math.round(this.readyTimeoutMs / 1e3)} seconds, so "${t.title ?? ""}" is drawn in the game skin's colours instead`);
|
|
1965
|
-
const
|
|
1966
|
-
if (
|
|
1972
|
+
const u = d ? { x: d.layout.panel.x, y: d.layout.panel.y } : { x: 0, y: 0 };
|
|
1973
|
+
if (d ? await c.update({ x: o.x + u.x, y: o.y + u.y, width: d.layout.panel.width, height: d.layout.panel.height, titleHeight: d.layout.titleHeight, titleFill: { color: i.line, alpha: 4e-3 }, titleFont: { family: i.font, size: i.size + 1, bold: !0, color: i.ink } }) : r && await c.update({ fill: { color: Gt.light, alpha: 0.96 }, stroke: { color: Gt.line, width: 2 } }), t.parent) try {
|
|
1967
1974
|
await this.adopt(c, { parent: E(t.parent) });
|
|
1968
1975
|
} catch (w) {
|
|
1969
|
-
throw await c.remove(),
|
|
1976
|
+
throw await c.remove(), d && await this.bridge.release(d.held).catch(() => {
|
|
1970
1977
|
}), w;
|
|
1971
1978
|
}
|
|
1972
|
-
const
|
|
1979
|
+
const h = d ? { width: d.width, height: d.height, bodyWidth: d.layout.body.width, bodyHeight: d.layout.body.height } : { ...s, bodyWidth: s.width, bodyHeight: Math.max(0, s.height - l) }, g = /* @__PURE__ */ new Set(), m = [], p = this.widget(c, e, { body: c, ...h, framed: d !== null, move: (w, b) => c.update({ x: w + u.x, y: b + u.y }), setTitle: (w) => c.update({ title: w }), onClose: (w) => (g.add(w), async () => {
|
|
1973
1980
|
g.delete(w);
|
|
1974
1981
|
}), onMove: (w) => {
|
|
1975
|
-
const
|
|
1982
|
+
const b = c.on("move", ({ x: k, y: M }) => w({ x: k - u.x, y: M - u.y }));
|
|
1976
1983
|
return async () => {
|
|
1977
|
-
await
|
|
1984
|
+
await b();
|
|
1978
1985
|
};
|
|
1979
1986
|
} }, async () => {
|
|
1980
1987
|
for (const w of m.splice(0)) await w().catch(() => {
|
|
1981
1988
|
});
|
|
1982
|
-
|
|
1989
|
+
d && await this.bridge.release(d.held).catch(() => {
|
|
1983
1990
|
});
|
|
1984
1991
|
}), f = () => {
|
|
1985
1992
|
p().then(() => g.forEach((w) => w()));
|
|
1986
1993
|
};
|
|
1987
|
-
if (t.closable !== !1 &&
|
|
1988
|
-
const w = await
|
|
1994
|
+
if (t.closable !== !1 && d != null && d.close) {
|
|
1995
|
+
const w = await d.close.at().listen(Te.down, f);
|
|
1989
1996
|
m.push(async () => {
|
|
1990
1997
|
await w();
|
|
1991
1998
|
});
|
|
1992
|
-
} else t.closable !== !1 && (await this.flash.overlay.button("x", { parent: c, x:
|
|
1999
|
+
} else t.closable !== !1 && (await this.flash.overlay.button("x", { parent: c, x: h.bodyWidth - (r ? 26 : 24), y: 2, width: 18, height: 16, cornerRadius: i.cornerRadius, fill: i.line, hoverFill: { color: i.danger, alpha: 0.8 }, font: { family: i.font, size: i.size, bold: !0, color: i.light } })).on("click", f);
|
|
1993
2000
|
return t.visible !== !1 && await c.show(), p;
|
|
1994
2001
|
}
|
|
1995
2002
|
async button(t, e = {}) {
|
|
1996
|
-
const r = e.skin ?? this.defaultSkin, n = await this.theme(r), i =
|
|
1997
|
-
|
|
1998
|
-
|
|
2003
|
+
const r = e.skin ?? this.defaultSkin, n = await this.theme(r), i = this.box(e, { width: pt[r], height: H[r] }), s = i.width ?? pt[r], o = i.height ?? H[r], l = e.image === void 0 ? null : await this.flash.overlay.group({ x: i.x ?? 0, y: i.y ?? 0, ...i.parent ? { parent: i.parent } : {}, ...i.visible === void 0 ? {} : { visible: i.visible } });
|
|
2004
|
+
let c = t, d = l === null || e.imageOnly !== !0, u = e.disabled === !0;
|
|
2005
|
+
const h = await this.flash.overlay.button(d ? c : "", { ...l === null ? i : { x: 0, y: 0, width: s, height: o, parent: l }, ...nt(n, e.primary === !0), cornerRadius: n.cornerRadius, ...e.disabled === void 0 ? {} : { disabled: e.disabled }, font: { family: n.font, size: n.size, bold: !0, color: e.primary === !0 || r === "phantom" ? n.light : n.ink } }), g = o - U * 2, m = e.imageOnly === !0 ? { width: s - U * 2, height: g } : { width: g, height: g };
|
|
2006
|
+
let p = null;
|
|
2007
|
+
const f = async () => {
|
|
2008
|
+
d || (d = !0, await h.setLabel(c));
|
|
2009
|
+
}, w = async (b) => {
|
|
2010
|
+
if (p) {
|
|
2011
|
+
await p.update({ url: b });
|
|
2012
|
+
return;
|
|
2013
|
+
}
|
|
2014
|
+
p = await this.picture(b, { parent: l, x: U, y: U, ...m, ...u ? { alpha: me } : {} }, (k) => {
|
|
2015
|
+
Lt("on a button", k), f().catch(D);
|
|
2016
|
+
});
|
|
2017
|
+
};
|
|
2018
|
+
return e.image !== void 0 && await w(e.image), this.widget(l ?? h, r, { label: () => c, setLabel: async (b) => {
|
|
2019
|
+
c = b, await h.setLabel(d ? b : "");
|
|
2020
|
+
}, setDisabled: async (b) => {
|
|
2021
|
+
u = b, await h.setDisabled(b), p && await p.update({ alpha: b ? me : 1 });
|
|
2022
|
+
}, setImage: async (b) => {
|
|
2023
|
+
if (l === null) throw new TypeError("This button was drawn without a picture, so there is nowhere to put one: give it `image` when it is drawn");
|
|
2024
|
+
if (b === null) {
|
|
2025
|
+
const k = p;
|
|
2026
|
+
p = null, await (k == null ? void 0 : k.remove()), await f();
|
|
2027
|
+
return;
|
|
2028
|
+
}
|
|
2029
|
+
d = e.imageOnly !== !0, await h.setLabel(d ? c : ""), await w(b);
|
|
2030
|
+
}, onClick: (b) => {
|
|
2031
|
+
const k = h.on("click", V(b));
|
|
1999
2032
|
return async () => {
|
|
2000
|
-
await
|
|
2033
|
+
await k();
|
|
2001
2034
|
};
|
|
2002
2035
|
} });
|
|
2003
2036
|
}
|
|
@@ -2006,14 +2039,14 @@ class or {
|
|
|
2006
2039
|
return this.widget(i, r, { setText: (s) => i.update({ text: s }) });
|
|
2007
2040
|
}
|
|
2008
2041
|
async input(t = {}) {
|
|
2009
|
-
const e = t.skin ?? this.defaultSkin, r = await this.theme(e), n = await this.flash.overlay.input({ ...this.box(t, { width: 200, height:
|
|
2042
|
+
const e = t.skin ?? this.defaultSkin, r = await this.theme(e), n = await this.flash.overlay.input({ ...this.box(t, { width: 200, height: H[e] }), ...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: e === "game" ? r.light : 16777215, stroke: r.line, cornerRadius: r.cornerRadius, font: { family: r.font, size: r.size, color: e === "game" ? r.ink : 1120295 } });
|
|
2010
2043
|
return this.widget(n, e, { value: () => n.value(), setValue: (i) => n.setValue(i), focus: () => n.focus(), onChange: (i) => {
|
|
2011
|
-
const s = n.on("change",
|
|
2044
|
+
const s = n.on("change", V(i));
|
|
2012
2045
|
return async () => {
|
|
2013
2046
|
await s();
|
|
2014
2047
|
};
|
|
2015
2048
|
}, onSubmit: (i) => {
|
|
2016
|
-
const s = n.on("submit",
|
|
2049
|
+
const s = n.on("submit", V(i));
|
|
2017
2050
|
return async () => {
|
|
2018
2051
|
await s();
|
|
2019
2052
|
};
|
|
@@ -2024,69 +2057,69 @@ class or {
|
|
|
2024
2057
|
let s = e.checked === !0;
|
|
2025
2058
|
const o = await this.flash.overlay.button(s ? "x" : "", { parent: i, width: 14, height: 14, cornerRadius: Math.min(3, n.cornerRadius), fill: r === "game" ? n.light : { color: n.ink, alpha: 0.9 }, hoverFill: r === "game" ? 16777215 : { color: n.line, alpha: 0.9 }, stroke: n.line, font: { family: n.font, size: n.size, bold: !0, color: n.accent } });
|
|
2026
2059
|
await this.flash.overlay.text(t, { parent: i, x: 20, y: 0, font: { family: n.font, size: n.size, color: r === "game" ? n.ink : n.light } });
|
|
2027
|
-
const l = /* @__PURE__ */ new Set(), c = async (
|
|
2028
|
-
s =
|
|
2060
|
+
const l = /* @__PURE__ */ new Set(), c = async (d) => {
|
|
2061
|
+
s = d, await o.setLabel(d ? "x" : "");
|
|
2029
2062
|
};
|
|
2030
2063
|
return o.on("click", () => {
|
|
2031
|
-
c(!s).then(() => l.forEach((
|
|
2032
|
-
}), this.widget(i, r, { checked: () => s, setChecked: c, onChange: (
|
|
2033
|
-
l.delete(
|
|
2064
|
+
c(!s).then(() => l.forEach((d) => d(s)));
|
|
2065
|
+
}), this.widget(i, r, { checked: () => s, setChecked: c, onChange: (d) => (l.add(d), async () => {
|
|
2066
|
+
l.delete(d);
|
|
2034
2067
|
}) });
|
|
2035
2068
|
}
|
|
2036
2069
|
async dropdown(t) {
|
|
2037
2070
|
var e;
|
|
2038
|
-
const r = t.skin ?? this.defaultSkin, n = await this.theme(r), i = t.width ?? 140, s = t.height ??
|
|
2071
|
+
const r = t.skin ?? this.defaultSkin, n = await this.theme(r), i = t.width ?? 140, s = t.height ?? H[r], o = await this.flash.overlay.group({ x: t.x ?? 0, y: t.y ?? 0, ...t.parent ? { parent: E(t.parent) } : {}, ...t.visible === void 0 ? {} : { visible: t.visible } });
|
|
2039
2072
|
let l = [...t.choices], c = t.value ?? ((e = l[0]) == null ? void 0 : e.value) ?? null;
|
|
2040
|
-
const
|
|
2073
|
+
const d = (p) => {
|
|
2041
2074
|
var f;
|
|
2042
2075
|
return ((f = l.find((w) => w.value === p)) == null ? void 0 : f.label) ?? t.placeholder ?? "Choose...";
|
|
2043
|
-
},
|
|
2076
|
+
}, u = await this.flash.overlay.button(d(c), { parent: o, width: i, height: s, cornerRadius: n.cornerRadius, ...nt(n, !1), font: { family: n.font, size: n.size, color: r === "game" ? n.ink : n.light } }), h = await this.flash.overlay.list({ parent: o, y: s + 2, width: i, height: Math.min(140, Math.max(20, l.length * 16 + 8)), visible: !1, fill: r === "game" ? n.light : { color: n.ink, alpha: 0.96 }, stroke: n.line, cornerRadius: n.cornerRadius, rows: l.map((p) => p.label), font: { family: n.font, size: n.size, color: r === "game" ? n.ink : n.light } });
|
|
2044
2077
|
let g = !1;
|
|
2045
2078
|
const m = /* @__PURE__ */ new Set();
|
|
2046
|
-
return
|
|
2047
|
-
g = !g, g ?
|
|
2048
|
-
}),
|
|
2079
|
+
return u.on("click", () => {
|
|
2080
|
+
g = !g, g ? h.show() : h.hide();
|
|
2081
|
+
}), h.on("row", (p) => {
|
|
2049
2082
|
const f = l[p];
|
|
2050
|
-
g = !1,
|
|
2083
|
+
g = !1, h.hide(), f && (c = f.value, u.setLabel(f.label).then(() => m.forEach((w) => w(f.value))));
|
|
2051
2084
|
}), this.widget(o, r, { value: () => c, setValue: async (p) => {
|
|
2052
|
-
c = p, await
|
|
2085
|
+
c = p, await u.setLabel(d(p));
|
|
2053
2086
|
}, setChoices: async (p) => {
|
|
2054
|
-
l = [...p], await
|
|
2087
|
+
l = [...p], await h.setRows(l.map((f) => f.label)), await u.setLabel(d(c));
|
|
2055
2088
|
}, onChange: (p) => (m.add(p), async () => {
|
|
2056
2089
|
m.delete(p);
|
|
2057
2090
|
}) });
|
|
2058
2091
|
}
|
|
2059
2092
|
async tabs(t) {
|
|
2060
2093
|
var e;
|
|
2061
|
-
const r = t.skin ?? this.defaultSkin, n = await this.theme(r), i = t.width ?? 260, s = t.tabHeight ?? 22, o = await this.flash.overlay.group({ x: t.x ?? 0, y: t.y ?? 0, ...t.parent ? { parent: E(t.parent) } : {}, ...t.visible === void 0 ? {} : { visible: t.visible } }), l =
|
|
2094
|
+
const r = t.skin ?? this.defaultSkin, n = await this.theme(r), i = t.width ?? 260, s = t.tabHeight ?? 22, o = await this.flash.overlay.group({ x: t.x ?? 0, y: t.y ?? 0, ...t.parent ? { parent: E(t.parent) } : {}, ...t.visible === void 0 ? {} : { visible: t.visible } }), l = Rr(t.tabs.map((m) => m.value), { width: i, gap: 2 });
|
|
2062
2095
|
let c = t.value ?? ((e = t.tabs[0]) == null ? void 0 : e.value) ?? "";
|
|
2063
|
-
const
|
|
2096
|
+
const d = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Set();
|
|
2064
2097
|
for (const m of l) {
|
|
2065
2098
|
const p = t.tabs[m.index];
|
|
2066
|
-
|
|
2099
|
+
u.set(p.value, await this.flash.overlay.button(p.label, { parent: o, x: m.x, width: m.width, height: s, cornerRadius: n.cornerRadius, ...nt(n, p.value === c), font: { family: n.font, size: n.size, bold: p.value === c, color: p.value === c || r === "phantom" ? n.light : n.ink } })), d.set(p.value, await this.flash.overlay.group({ parent: o, y: s + 4, visible: p.value === c }));
|
|
2067
2100
|
}
|
|
2068
2101
|
const g = async (m) => {
|
|
2069
|
-
if (
|
|
2102
|
+
if (d.has(m)) {
|
|
2070
2103
|
c = m;
|
|
2071
|
-
for (const [p, f] of
|
|
2072
|
-
for (const [p, f] of
|
|
2104
|
+
for (const [p, f] of d) await (p === m ? f.show() : f.hide());
|
|
2105
|
+
for (const [p, f] of u) await f.update({ ...nt(n, p === m), font: { family: n.font, size: n.size, bold: p === m, color: p === m || r === "phantom" ? n.light : n.ink } });
|
|
2073
2106
|
}
|
|
2074
2107
|
};
|
|
2075
|
-
for (const [m, p] of
|
|
2076
|
-
g(m).then(() =>
|
|
2108
|
+
for (const [m, p] of u) p.on("click", () => {
|
|
2109
|
+
g(m).then(() => h.forEach((f) => f(m)));
|
|
2077
2110
|
});
|
|
2078
2111
|
return this.widget(o, r, { current: () => c, select: g, body: (m) => {
|
|
2079
|
-
const p =
|
|
2112
|
+
const p = d.get(m);
|
|
2080
2113
|
if (!p) throw new TypeError(`There is no tab called "${m}"`);
|
|
2081
2114
|
return p;
|
|
2082
|
-
}, onSelect: (m) => (
|
|
2083
|
-
|
|
2115
|
+
}, onSelect: (m) => (h.add(m), async () => {
|
|
2116
|
+
h.delete(m);
|
|
2084
2117
|
}) });
|
|
2085
2118
|
}
|
|
2086
2119
|
async list(t = {}) {
|
|
2087
2120
|
const e = t.skin ?? this.defaultSkin, r = await this.theme(e), n = 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: e === "game" ? r.light : { color: r.ink, alpha: 0.85 }, stroke: r.line, cornerRadius: r.cornerRadius, font: { family: r.font, size: r.size, color: e === "game" ? r.ink : r.light } });
|
|
2088
2121
|
return this.widget(n, e, { setRows: (i) => n.setRows([...i]), append: (...i) => n.append(...i), onRow: (i) => {
|
|
2089
|
-
const s = n.on("row",
|
|
2122
|
+
const s = n.on("row", V(i));
|
|
2090
2123
|
return async () => {
|
|
2091
2124
|
await s();
|
|
2092
2125
|
};
|
|
@@ -2094,28 +2127,50 @@ class or {
|
|
|
2094
2127
|
}
|
|
2095
2128
|
async grid(t) {
|
|
2096
2129
|
const e = t.skin ?? this.defaultSkin, r = await this.theme(e), n = { columns: t.columns ?? 4, tileWidth: t.tileWidth ?? 48, tileHeight: t.tileHeight ?? 48, gap: t.gap ?? 4 }, i = await this.flash.overlay.group({ x: t.x ?? 0, y: t.y ?? 0, ...t.parent ? { parent: E(t.parent) } : {}, ...t.visible === void 0 ? {} : { visible: t.visible } }), s = /* @__PURE__ */ new Set(), o = [], l = async (c) => {
|
|
2097
|
-
for (const
|
|
2098
|
-
const
|
|
2099
|
-
for (const
|
|
2100
|
-
const
|
|
2101
|
-
g.on("click", () => s.forEach((m) => m(
|
|
2130
|
+
for (const u of o.splice(0)) await u.remove();
|
|
2131
|
+
const d = Me({ count: c.length, ...n });
|
|
2132
|
+
for (const u of d) {
|
|
2133
|
+
const h = c[u.index], g = await this.flash.overlay.button(h.label ?? "", { parent: i, x: u.x, y: u.y, width: u.width, height: u.height, cornerRadius: r.cornerRadius, fill: h.color ?? (e === "game" ? r.light : { color: r.ink, alpha: 0.9 }), hoverFill: h.color ?? (e === "game" ? 16777215 : r.line), pressedFill: h.color ?? r.accent, stroke: r.line, ...h.disabled === void 0 ? {} : { disabled: h.disabled }, font: { family: r.font, size: r.size - 2, color: e === "game" ? r.ink : r.light } });
|
|
2134
|
+
g.on("click", () => s.forEach((m) => m(h.value, u.index))), o.push(g), h.image !== void 0 && o.push(await this.picture(h.image, { parent: i, x: u.x + U, y: u.y + U, width: u.width - U * 2, height: u.height - U * 2 }, (m) => Lt(`on the grid tile ${h.value}`, m)));
|
|
2102
2135
|
}
|
|
2103
2136
|
};
|
|
2104
2137
|
return await l(t.items), this.widget(i, e, { setItems: l, onSelect: (c) => (s.add(c), async () => {
|
|
2105
2138
|
s.delete(c);
|
|
2106
2139
|
}) });
|
|
2107
2140
|
}
|
|
2141
|
+
async image(t, e = {}) {
|
|
2142
|
+
const r = e.skin ?? this.defaultSkin, n = await this.theme(r), i = await this.flash.overlay.group({ x: e.x ?? 0, y: e.y ?? 0, ...e.parent ? { parent: E(e.parent) } : {}, ...e.visible === void 0 ? {} : { visible: e.visible } }), s = /* @__PURE__ */ new Set();
|
|
2143
|
+
let o = t, l = null, c = !1;
|
|
2144
|
+
const d = async () => {
|
|
2145
|
+
if (c) return;
|
|
2146
|
+
c = !0;
|
|
2147
|
+
const h = e.width ?? H[r], g = e.height ?? H[r], m = await this.flash.overlay.group({ parent: i, ...e.centered === !0 ? { x: -Math.round(h / 2), y: -Math.round(g / 2) } : {} });
|
|
2148
|
+
l = m, await this.flash.overlay.rect({ parent: m, width: h, height: g, cornerRadius: n.cornerRadius, fill: r === "game" ? { color: n.light, alpha: 0.6 } : { color: n.ink, alpha: 0.6 }, stroke: n.line }), !(e.alt === void 0 || e.alt === "") && await this.flash.overlay.text(e.alt, { parent: m, x: Math.round(h / 2), y: Math.round(g / 2), centered: !0, font: { family: n.font, size: n.size - 1, color: n.muted } });
|
|
2149
|
+
}, u = await this.picture(o, { parent: i, ...e.width === void 0 ? {} : { width: e.width }, ...e.height === void 0 ? {} : { height: e.height }, ...e.centered === void 0 ? {} : { centered: e.centered }, ...e.alpha === void 0 ? {} : { alpha: e.alpha } }, (h) => {
|
|
2150
|
+
Lt(e.alt === void 0 ? "drawn on its own" : `of ${e.alt}`, h), d().catch(D), s.forEach((g) => g(h));
|
|
2151
|
+
});
|
|
2152
|
+
return this.widget(i, r, { source: () => o, setSource: async (h) => {
|
|
2153
|
+
o = h;
|
|
2154
|
+
const g = l;
|
|
2155
|
+
l = null, c = !1, await (g == null ? void 0 : g.remove()), await u.update({ url: h });
|
|
2156
|
+
}, onFailed: (h) => {
|
|
2157
|
+
const g = V(h);
|
|
2158
|
+
return s.add(g), async () => {
|
|
2159
|
+
s.delete(g);
|
|
2160
|
+
};
|
|
2161
|
+
} });
|
|
2162
|
+
}
|
|
2108
2163
|
async scroll(t = {}) {
|
|
2109
2164
|
const e = t.skin ?? this.defaultSkin, r = await this.theme(e), n = t.width ?? 220, i = t.height ?? 120, s = t.step ?? 32, o = await this.flash.overlay.panel({ x: t.x ?? 0, y: t.y ?? 0, width: n, height: i, titleHeight: 0, draggable: !1, cornerRadius: r.cornerRadius, fill: e === "game" ? { color: r.light, alpha: 0.9 } : { color: r.ink, alpha: 0.85 }, stroke: r.line, ...t.parent ? { parent: E(t.parent) } : {}, ...t.visible === void 0 ? {} : { visible: t.visible } }), l = await this.flash.overlay.group({ parent: o, x: 0, y: 0 });
|
|
2110
|
-
let c = t.contentHeight ?? i,
|
|
2111
|
-
const
|
|
2112
|
-
|
|
2165
|
+
let c = t.contentHeight ?? i, d = 0;
|
|
2166
|
+
const u = async (h) => {
|
|
2167
|
+
d = Fr({ contentHeight: c, viewHeight: i, offset: h, trackHeight: i }).offset, await l.update({ y: -d });
|
|
2113
2168
|
};
|
|
2114
|
-
for (const [
|
|
2115
|
-
d
|
|
2169
|
+
for (const [h, g, m] of [["^", -s, 0], ["v", s, i - 16]]) (await this.flash.overlay.button(h, { parent: o, x: n - 16, y: m, width: 14, height: 14, cornerRadius: Math.min(3, r.cornerRadius), ...nt(r, !1), font: { family: r.font, size: r.size - 2, bold: !0, color: e === "game" ? r.ink : r.light } })).on("click", () => {
|
|
2170
|
+
u(d + g);
|
|
2116
2171
|
});
|
|
2117
|
-
return this.widget(o, e, { body: l, offset: () =>
|
|
2118
|
-
c =
|
|
2172
|
+
return this.widget(o, e, { body: l, offset: () => d, scrollTo: u, setContentHeight: async (h) => {
|
|
2173
|
+
c = h, await u(d);
|
|
2119
2174
|
} });
|
|
2120
2175
|
}
|
|
2121
2176
|
async tooltip(t = {}) {
|
|
@@ -2135,11 +2190,11 @@ class or {
|
|
|
2135
2190
|
}
|
|
2136
2191
|
explain(t, e) {
|
|
2137
2192
|
const r = e.on("over", ({ x: s, y: o }) => {
|
|
2138
|
-
t.showAt(s + 12, o - 10).catch(
|
|
2193
|
+
t.showAt(s + 12, o - 10).catch(D);
|
|
2139
2194
|
}), n = e.on("out", () => {
|
|
2140
|
-
t.hide().catch(
|
|
2195
|
+
t.hide().catch(D);
|
|
2141
2196
|
}), i = e.onRemoved(() => {
|
|
2142
|
-
t.remove().catch(
|
|
2197
|
+
t.remove().catch(D);
|
|
2143
2198
|
});
|
|
2144
2199
|
t.node.onRemoved(() => {
|
|
2145
2200
|
i(), r().catch(() => {
|
|
@@ -2150,19 +2205,19 @@ class or {
|
|
|
2150
2205
|
async progress(t = {}) {
|
|
2151
2206
|
const e = t.skin ?? this.defaultSkin, r = await this.theme(e), n = t.width ?? 200, i = t.height ?? 16, s = await this.flash.overlay.group({ x: t.x ?? 0, y: t.y ?? 0, ...t.parent ? { parent: E(t.parent) } : {}, ...t.visible === void 0 ? {} : { visible: t.visible } });
|
|
2152
2207
|
await this.flash.overlay.rect({ parent: s, width: n, height: i, cornerRadius: r.cornerRadius, fill: e === "game" ? r.light : { color: r.ink, alpha: 0.9 }, stroke: r.line });
|
|
2153
|
-
let o =
|
|
2208
|
+
let o = Se(t.value ?? 0);
|
|
2154
2209
|
const l = await this.flash.overlay.rect({ parent: s, width: Math.round(n * o), height: i, cornerRadius: r.cornerRadius, fill: r.accent }), c = await this.flash.overlay.text(t.label ?? "", { parent: s, x: Math.round(n / 2), y: Math.round(i / 2), centered: !0, font: { family: r.font, size: r.size - 1, bold: !0, color: e === "game" ? r.ink : r.light } });
|
|
2155
|
-
return this.widget(s, e, { value: () => o, setValue: async (
|
|
2156
|
-
o =
|
|
2157
|
-
}, setLabel: (
|
|
2210
|
+
return this.widget(s, e, { value: () => o, setValue: async (d) => {
|
|
2211
|
+
o = Se(d), await l.update({ width: Math.round(n * o) });
|
|
2212
|
+
}, setLabel: (d) => c.update({ text: d }) });
|
|
2158
2213
|
}
|
|
2159
2214
|
async colors(t = {}) {
|
|
2160
2215
|
const e = t.skin ?? this.defaultSkin, r = t.columns ?? 10, n = t.swatchWidth ?? 24, i = t.swatchHeight ?? 30, { values: s, indexes: o } = await this.palette(t.palette ?? 1), l = /* @__PURE__ */ new Set();
|
|
2161
2216
|
let c = t.value ?? o[0] ?? 0;
|
|
2162
|
-
const
|
|
2217
|
+
const d = (g) => {
|
|
2163
2218
|
c = g, l.forEach((m) => m(g, s[g] ?? 0));
|
|
2164
|
-
},
|
|
2165
|
-
return this.widget(
|
|
2219
|
+
}, u = Math.max(1, Math.ceil(o.length / r)), h = e === "game" ? await this.clientColorTable({ columns: r, rows: u, width: r * n, height: u * i, values: s, indexes: o, current: c, options: t, tell: d }) : await this.swatchGrid({ columns: r, swatchWidth: n, swatchHeight: i, values: s, indexes: o, current: c, options: t, tell: d });
|
|
2220
|
+
return this.widget(h, e, { value: () => c, onPick: (g) => (l.add(g), async () => {
|
|
2166
2221
|
l.delete(g);
|
|
2167
2222
|
}) });
|
|
2168
2223
|
}
|
|
@@ -2170,14 +2225,171 @@ class or {
|
|
|
2170
2225
|
const { values: e, indexes: r } = await this.palette(t);
|
|
2171
2226
|
return r.map((n) => e[n] ?? 0);
|
|
2172
2227
|
}
|
|
2228
|
+
prompt(t, e = {}) {
|
|
2229
|
+
let r = () => {
|
|
2230
|
+
};
|
|
2231
|
+
const n = new Promise((c) => {
|
|
2232
|
+
r = c;
|
|
2233
|
+
});
|
|
2234
|
+
let i = !1, s = null;
|
|
2235
|
+
const o = async (c) => {
|
|
2236
|
+
if (i) return;
|
|
2237
|
+
i = !0, this.popups.delete(l);
|
|
2238
|
+
const d = s;
|
|
2239
|
+
s = null, d && await d().catch(() => {
|
|
2240
|
+
}), r(c);
|
|
2241
|
+
}, l = () => o(null);
|
|
2242
|
+
return this.popups.add(l), (async () => {
|
|
2243
|
+
const c = e.skin ?? this.defaultSkin, d = e.width ?? xe[c], u = await this.window({ skin: c, title: e.title ?? "", x: e.x ?? ft.x, y: e.y ?? ft.y, width: d, height: $r[c], closable: !0 }), h = u.body, g = u.bodyWidth - 2 * T;
|
|
2244
|
+
await this.label(t, { skin: c, parent: h, x: T, y: T });
|
|
2245
|
+
const m = await this.input({ skin: c, parent: h, x: T, y: T + It, width: g, ...e.value === void 0 ? {} : { value: e.value }, ...e.placeholder === void 0 ? {} : { placeholder: e.placeholder }, ...e.maxLength === void 0 ? {} : { maxLength: e.maxLength } }), p = { width: Math.min(pt[c], Math.floor((g - T) / 2)) }, f = u.bodyHeight - T - H[c], w = await this.button(e.cancelLabel ?? "Cancel", { skin: c, parent: h, x: T, y: f, width: p.width }), b = await this.button(e.okLabel ?? "OK", { skin: c, parent: h, x: u.bodyWidth - T - p.width, y: f, width: p.width, primary: !0 });
|
|
2246
|
+
if (s = async () => {
|
|
2247
|
+
await u(), await this.flash.overlay.focusGame().catch(() => {
|
|
2248
|
+
});
|
|
2249
|
+
}, i) {
|
|
2250
|
+
const k = s;
|
|
2251
|
+
s = null, await k();
|
|
2252
|
+
return;
|
|
2253
|
+
}
|
|
2254
|
+
m.onSubmit((k) => {
|
|
2255
|
+
o(k);
|
|
2256
|
+
}), b.onClick(() => {
|
|
2257
|
+
o(m.value());
|
|
2258
|
+
}), w.onClick(() => {
|
|
2259
|
+
o(null);
|
|
2260
|
+
}), u.onClose(() => {
|
|
2261
|
+
o(null);
|
|
2262
|
+
}), await m.focus();
|
|
2263
|
+
})().catch((c) => {
|
|
2264
|
+
console.error(`phantom.ui.prompt could not be drawn: ${Y(c)}`), o(null);
|
|
2265
|
+
}), Object.assign(n, { close: l });
|
|
2266
|
+
}
|
|
2267
|
+
choose(t, e, r = {}) {
|
|
2268
|
+
const n = e.map((u) => typeof u == "string" ? { value: u, label: u } : u);
|
|
2269
|
+
let i = () => {
|
|
2270
|
+
};
|
|
2271
|
+
const s = new Promise((u) => {
|
|
2272
|
+
i = u;
|
|
2273
|
+
});
|
|
2274
|
+
let o = !1, l = null;
|
|
2275
|
+
const c = async (u) => {
|
|
2276
|
+
if (o) return;
|
|
2277
|
+
o = !0, this.popups.delete(d);
|
|
2278
|
+
const h = l;
|
|
2279
|
+
l = null, h && await h().catch(() => {
|
|
2280
|
+
}), i(u);
|
|
2281
|
+
}, d = () => c(null);
|
|
2282
|
+
return this.popups.add(d), (async () => {
|
|
2283
|
+
const u = r.skin ?? this.defaultSkin, h = r.width ?? xe[u], g = Math.max(1, r.rows ?? Tr), m = Math.min(n.length || 1, g) * Sr + 2 * T, p = await this.window({ skin: u, title: r.title ?? "", x: r.x ?? ft.x, y: r.y ?? ft.y, width: h, height: T * 4 + It + m + H[u], closable: !0 }), f = p.body, w = p.bodyWidth - 2 * T;
|
|
2284
|
+
await this.label(t, { skin: u, parent: f, x: T, y: T });
|
|
2285
|
+
const b = await this.list({ skin: u, parent: f, x: T, y: T + It, width: w, height: m, rows: n.map((R) => R.label) }), k = { width: Math.min(pt[u], Math.floor((w - T) / 2)) }, M = await this.button(r.cancelLabel ?? "Cancel", { skin: u, parent: f, x: p.bodyWidth - T - k.width, y: p.bodyHeight - T - H[u], width: k.width });
|
|
2286
|
+
if (l = async () => {
|
|
2287
|
+
await p();
|
|
2288
|
+
}, o) {
|
|
2289
|
+
const R = l;
|
|
2290
|
+
l = null, await R();
|
|
2291
|
+
return;
|
|
2292
|
+
}
|
|
2293
|
+
b.onRow((R) => {
|
|
2294
|
+
var O;
|
|
2295
|
+
c(((O = n[R]) == null ? void 0 : O.value) ?? null);
|
|
2296
|
+
}), M.onClick(() => {
|
|
2297
|
+
c(null);
|
|
2298
|
+
}), p.onClose(() => {
|
|
2299
|
+
c(null);
|
|
2300
|
+
});
|
|
2301
|
+
})().catch((u) => {
|
|
2302
|
+
console.error(`phantom.ui.choose could not be drawn: ${Y(u)}`), c(null);
|
|
2303
|
+
}), Object.assign(s, { close: d });
|
|
2304
|
+
}
|
|
2305
|
+
async notice(t, e = {}) {
|
|
2306
|
+
const r = e.skin ?? this.defaultSkin, n = await this.theme(r), i = e.seconds ?? 6, s = e.width ?? Or, o = Math.max(Nt, (r === "game" ? s - Er : s) - 2 * rt), l = Ht(t, Ee(o, n.size)), c = await this.stageSize(), d = { x: e.x ?? (c.width ? c.width - s - zt : zt), y: e.y ?? zt }, u = await this.window({ skin: r, title: e.title ?? "", x: d.x, y: d.y, width: s, height: 2 * rt + (l.length + 1) * Nt + (r === "game" ? 30 : 24), closable: e.closable !== !1, ...e.draggable === void 0 ? {} : { draggable: e.draggable } }), h = Math.max(Nt, Math.min(o, u.bodyWidth - 2 * rt)), g = Ee(h, n.size), m = await this.label(Ht(t, g).join(`
|
|
2307
|
+
`), { skin: r, parent: u.body, x: rt, y: rt }), p = /* @__PURE__ */ new Set();
|
|
2308
|
+
let f = !1;
|
|
2309
|
+
const w = i > 0 ? setTimeout(() => {
|
|
2310
|
+
u().catch(() => {
|
|
2311
|
+
});
|
|
2312
|
+
}, i * 1e3) : null, b = () => {
|
|
2313
|
+
if (!f) {
|
|
2314
|
+
f = !0, w && clearTimeout(w);
|
|
2315
|
+
for (const k of [...p]) V(k)();
|
|
2316
|
+
}
|
|
2317
|
+
};
|
|
2318
|
+
return u.onClose(b), u.node.onRemoved(b), this.widget(u.node, r, { setText: async (k) => {
|
|
2319
|
+
await m.setText(Ht(k, g).join(`
|
|
2320
|
+
`));
|
|
2321
|
+
}, onClose: (k) => (p.add(k), async () => {
|
|
2322
|
+
p.delete(k);
|
|
2323
|
+
}) }, async () => b());
|
|
2324
|
+
}
|
|
2325
|
+
async tag(t, e, r = {}) {
|
|
2326
|
+
const n = r.skin ?? this.defaultSkin, i = await this.theme(n), s = await this.anchorOf(t);
|
|
2327
|
+
if (!s) throw new TypeError(typeof t == "number" ? `No player with user id ${t} is in the room, so there is nothing to tag` : "Expected a player id, something from phantom.flash.entities, or a place in the client");
|
|
2328
|
+
const o = r.key ?? (typeof t == "number" ? `player:${t}` : null), l = o ? this.tags.get(o) : void 0;
|
|
2329
|
+
l && await l().catch(() => {
|
|
2330
|
+
});
|
|
2331
|
+
const c = await this.flash.overlay.text(e, { anchor: { place: s, x: r.offsetX ?? 0, y: r.offsetY ?? (typeof t == "number" ? Ar : 0) }, centered: !0, font: { family: i.font, size: r.heading === !0 ? i.size + 3 : i.size, bold: r.heading === !0, color: r.colour ?? (n === "game" ? i.ink : i.light) }, ...r.background === !1 ? { outline: 0 } : { background: n === "game" ? { color: i.light, alpha: 0.9 } : { color: i.ink, alpha: 0.8 }, padding: 4 } }), d = r.seconds && r.seconds > 0 ? setTimeout(() => {
|
|
2332
|
+
c.remove().catch(() => {
|
|
2333
|
+
});
|
|
2334
|
+
}, r.seconds * 1e3) : null, u = this.widget(c, n, { setText: (h) => c.update({ text: h }) }, async () => {
|
|
2335
|
+
d && clearTimeout(d), o && this.tags.get(o) === u && this.tags.delete(o);
|
|
2336
|
+
});
|
|
2337
|
+
return o && this.tags.set(o, u), u;
|
|
2338
|
+
}
|
|
2339
|
+
async tipOn(t, e, r = {}) {
|
|
2340
|
+
const n = r.skin ?? this.defaultSkin, i = await this.tooltip({ skin: n, text: typeof e == "string" ? e : "" }), s = this.piece(t), o = { x: r.offsetX ?? ke.x, y: r.offsetY ?? ke.y }, l = async (h) => {
|
|
2341
|
+
typeof e != "string" && await i.setText(await e());
|
|
2342
|
+
const g = Dr(h) ?? await this.mouse();
|
|
2343
|
+
await i.showAt(g.x + o.x, g.y + o.y);
|
|
2344
|
+
}, c = await s.on("rollOver", (h) => {
|
|
2345
|
+
l(h).catch((g) => {
|
|
2346
|
+
console.error(`phantom.ui.tipOn could not show the tooltip: ${Y(g)}`);
|
|
2347
|
+
});
|
|
2348
|
+
}), d = await s.on("rollOut", () => {
|
|
2349
|
+
i.hide().catch(() => {
|
|
2350
|
+
});
|
|
2351
|
+
});
|
|
2352
|
+
let u = !1;
|
|
2353
|
+
return async () => {
|
|
2354
|
+
u || (u = !0, await c().catch(() => {
|
|
2355
|
+
}), await d().catch(() => {
|
|
2356
|
+
}), await i.remove().catch(() => {
|
|
2357
|
+
}));
|
|
2358
|
+
};
|
|
2359
|
+
}
|
|
2360
|
+
async stageSize() {
|
|
2361
|
+
const t = this.bridge.stage(), [e, r] = await Promise.all([t.at("stageWidth").get().catch(() => null), t.at("stageHeight").get().catch(() => null)]);
|
|
2362
|
+
return { width: mt(e), height: mt(r) };
|
|
2363
|
+
}
|
|
2364
|
+
onStageResize(t) {
|
|
2365
|
+
let e = !0, r = null;
|
|
2366
|
+
return (async () => {
|
|
2367
|
+
const n = await this.bridge.stage().listen("resize", () => {
|
|
2368
|
+
this.stageSize().then((i) => V(t)(i)).catch(() => {
|
|
2369
|
+
});
|
|
2370
|
+
});
|
|
2371
|
+
if (!e) {
|
|
2372
|
+
await n();
|
|
2373
|
+
return;
|
|
2374
|
+
}
|
|
2375
|
+
r = n;
|
|
2376
|
+
})().catch((n) => {
|
|
2377
|
+
console.error(`phantom.ui.onStageResize could not hear the stage: ${Y(n)}`);
|
|
2378
|
+
}), () => {
|
|
2379
|
+
e = !1;
|
|
2380
|
+
const n = r;
|
|
2381
|
+
r = null, n && n().catch(() => {
|
|
2382
|
+
});
|
|
2383
|
+
};
|
|
2384
|
+
}
|
|
2173
2385
|
places() {
|
|
2174
|
-
const t = Object.keys(
|
|
2175
|
-
return [
|
|
2386
|
+
const t = Object.keys(ye);
|
|
2387
|
+
return [be, ...t, ...Br];
|
|
2176
2388
|
}
|
|
2177
2389
|
place(t) {
|
|
2178
|
-
if (t ===
|
|
2179
|
-
const e =
|
|
2180
|
-
return e ? this.bridge.definition(e.className).at(...e.path) : this.bridge.definition(
|
|
2390
|
+
if (t === be) return this.bridge.stage();
|
|
2391
|
+
const e = ye[t];
|
|
2392
|
+
return e ? this.bridge.definition(e.className).at(...e.path) : this.bridge.definition(F.guiManager).at("mainHud", t);
|
|
2181
2393
|
}
|
|
2182
2394
|
async attach(t, e) {
|
|
2183
2395
|
const r = E(e);
|
|
@@ -2212,23 +2424,23 @@ class or {
|
|
|
2212
2424
|
let n = null, i = 0;
|
|
2213
2425
|
const s = async (c) => {
|
|
2214
2426
|
i += 1;
|
|
2215
|
-
const
|
|
2216
|
-
n =
|
|
2217
|
-
const
|
|
2218
|
-
if (!
|
|
2427
|
+
const d = { method: t, call: c.call, args: [...c.argList], named: { ...c.args }, on: this.pieceOf(et(c.self) ?? this.bridge.stage(), []) };
|
|
2428
|
+
n = d;
|
|
2429
|
+
const u = await e(d);
|
|
2430
|
+
if (!u) {
|
|
2219
2431
|
await c.original();
|
|
2220
2432
|
return;
|
|
2221
2433
|
}
|
|
2222
|
-
const
|
|
2223
|
-
for (const [g, m] of Object.entries(
|
|
2434
|
+
const h = [...d.args];
|
|
2435
|
+
for (const [g, m] of Object.entries(u)) {
|
|
2224
2436
|
const p = /^\d+$/.test(g) ? Number(g) : c.hook.parameters.findIndex((f) => f.name === g);
|
|
2225
|
-
if (p < 0 || p >=
|
|
2437
|
+
if (p < 0 || p >= h.length) {
|
|
2226
2438
|
const f = c.hook.parameters.map((w) => w.name).join(", ");
|
|
2227
2439
|
throw new TypeError(`${t} has no argument "${g}" (its arguments: ${f})`);
|
|
2228
2440
|
}
|
|
2229
|
-
|
|
2441
|
+
h[p] = m;
|
|
2230
2442
|
}
|
|
2231
|
-
await c.original(...
|
|
2443
|
+
await c.original(...h);
|
|
2232
2444
|
}, o = {};
|
|
2233
2445
|
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);
|
|
2234
2446
|
const l = await this.flash.override(t, s, o);
|
|
@@ -2243,10 +2455,10 @@ class or {
|
|
|
2243
2455
|
return Object.defineProperty(o, "method", { value: t, enumerable: !0 }), Object.defineProperty(o, "inside", { value: e, enumerable: !0 }), Object.defineProperty(o, "calls", { get: n, enumerable: !0 }), Object.defineProperty(o, "last", { value: i, enumerable: !0 }), o;
|
|
2244
2456
|
}
|
|
2245
2457
|
screens() {
|
|
2246
|
-
return Object.keys(
|
|
2458
|
+
return Object.keys(ve);
|
|
2247
2459
|
}
|
|
2248
2460
|
onScreen(t, e) {
|
|
2249
|
-
const r =
|
|
2461
|
+
const r = ve[t];
|
|
2250
2462
|
let n = !0;
|
|
2251
2463
|
const i = [];
|
|
2252
2464
|
return (async () => {
|
|
@@ -2259,7 +2471,7 @@ class or {
|
|
|
2259
2471
|
i.push(l);
|
|
2260
2472
|
}
|
|
2261
2473
|
})().catch((s) => {
|
|
2262
|
-
console.error(`phantom.ui.onScreen could not hook ${t}: ${
|
|
2474
|
+
console.error(`phantom.ui.onScreen could not hook ${t}: ${Y(s)}`);
|
|
2263
2475
|
}), () => {
|
|
2264
2476
|
n = !1;
|
|
2265
2477
|
for (const s of i.splice(0)) s().catch(() => {
|
|
@@ -2273,7 +2485,7 @@ class or {
|
|
|
2273
2485
|
});
|
|
2274
2486
|
}
|
|
2275
2487
|
pieceOf(t, e) {
|
|
2276
|
-
const r =
|
|
2488
|
+
const r = et(t);
|
|
2277
2489
|
if (!r) throw new TypeError("Expected a place in the client, or one of Phantom's spots");
|
|
2278
2490
|
const n = r.at(...e);
|
|
2279
2491
|
return { place: n, at: (...i) => this.pieceOf(n, i), exists: async () => {
|
|
@@ -2285,24 +2497,24 @@ class or {
|
|
|
2285
2497
|
}, get: async (...i) => {
|
|
2286
2498
|
try {
|
|
2287
2499
|
const s = await n.at(...i).get();
|
|
2288
|
-
return
|
|
2500
|
+
return $(this.bridge, s) ?? null;
|
|
2289
2501
|
} catch {
|
|
2290
2502
|
return null;
|
|
2291
2503
|
}
|
|
2292
2504
|
}, set: (i, s) => n.at(...typeof i == "string" ? [i] : i).set(s), read: async (...i) => {
|
|
2293
2505
|
const s = await Promise.all(i.map((l) => n.at(l).get().catch(() => null))), o = {};
|
|
2294
2506
|
return i.forEach((l, c) => {
|
|
2295
|
-
o[l] =
|
|
2507
|
+
o[l] = $(this.bridge, s[c] ?? null);
|
|
2296
2508
|
}), o;
|
|
2297
2509
|
}, call: async (i, ...s) => {
|
|
2298
|
-
const o = await
|
|
2299
|
-
return
|
|
2510
|
+
const o = await X(this.bridge, s);
|
|
2511
|
+
return $(this.bridge, await n.at(i).call(...o));
|
|
2300
2512
|
}, on: async (i, s) => {
|
|
2301
|
-
const o = await n.listen(i, (c) => s(
|
|
2513
|
+
const o = await n.listen(i, (c) => s($(this.bridge, c))), l = async () => {
|
|
2302
2514
|
this.drawn.delete(l), await o();
|
|
2303
2515
|
};
|
|
2304
2516
|
return this.drawn.add(l), l;
|
|
2305
|
-
}, attach: (i) => this.attach(n, i), replace: (i) => this.replace(n, i), hide: () => this.hide(n), use: () =>
|
|
2517
|
+
}, attach: (i) => this.attach(n, i), replace: (i) => this.replace(n, i), hide: () => this.hide(n), use: () => P(this.bridge, n) };
|
|
2306
2518
|
}
|
|
2307
2519
|
widget(t, e, r, n) {
|
|
2308
2520
|
let i = null;
|
|
@@ -2315,19 +2527,37 @@ class or {
|
|
|
2315
2527
|
this.drawn.add(o), t.onRemoved(() => {
|
|
2316
2528
|
s();
|
|
2317
2529
|
});
|
|
2318
|
-
const l = { skin: e, node: t, move: (c,
|
|
2319
|
-
for (const [c,
|
|
2530
|
+
const l = { skin: e, node: t, move: (c, d) => t.update({ x: c, y: d }), show: () => t.show(), hide: () => t.hide(), remove: o, ...r };
|
|
2531
|
+
for (const [c, d] of Object.entries(l)) Object.defineProperty(o, c, { value: d, enumerable: !0, configurable: !0 });
|
|
2320
2532
|
return o;
|
|
2321
2533
|
}
|
|
2534
|
+
async picture(t, e, r) {
|
|
2535
|
+
const n = await this.flash.overlay.image(t, e);
|
|
2536
|
+
return n.onFailed(V(r)), n;
|
|
2537
|
+
}
|
|
2322
2538
|
box(t, e) {
|
|
2323
2539
|
return { x: t.x ?? 0, y: t.y ?? 0, width: t.width ?? e.width, height: t.height ?? e.height, ...t.parent ? { parent: E(t.parent) } : {}, ...t.visible === void 0 ? {} : { visible: t.visible } };
|
|
2324
2540
|
}
|
|
2541
|
+
async anchorOf(t) {
|
|
2542
|
+
if (typeof t == "number") {
|
|
2543
|
+
const r = (await this.flash.entities.players()).find((n) => n.id === String(t));
|
|
2544
|
+
return r ? r.place : null;
|
|
2545
|
+
}
|
|
2546
|
+
if (typeof t == "string") return this.place(t);
|
|
2547
|
+
if (ie(t)) return t;
|
|
2548
|
+
const e = t.place;
|
|
2549
|
+
return ie(e) ? e : null;
|
|
2550
|
+
}
|
|
2551
|
+
async mouse() {
|
|
2552
|
+
const t = this.bridge.stage(), [e, r] = await Promise.all([t.at("mouseX").get().catch(() => null), t.at("mouseY").get().catch(() => null)]);
|
|
2553
|
+
return { x: mt(e), y: mt(r) };
|
|
2554
|
+
}
|
|
2325
2555
|
placeOf(t) {
|
|
2326
2556
|
return typeof t == "string" ? this.place(t) : t;
|
|
2327
2557
|
}
|
|
2328
2558
|
maker() {
|
|
2329
2559
|
if (!this.symbolMaker) {
|
|
2330
|
-
const t = this.bridge.definition(
|
|
2560
|
+
const t = this.bridge.definition(F.definitionByName).get().then((e) => {
|
|
2331
2561
|
if (!e) throw new TypeError("This client has no GETDEFINITIONBYNAME");
|
|
2332
2562
|
return e;
|
|
2333
2563
|
});
|
|
@@ -2338,13 +2568,13 @@ class or {
|
|
|
2338
2568
|
return this.symbolMaker;
|
|
2339
2569
|
}
|
|
2340
2570
|
async nodeObject(t) {
|
|
2341
|
-
const e = await new
|
|
2571
|
+
const e = await new J(this.bridge, { kind: "overlay" }, []).at("getChildByName").call(`phantomNode${t.node}`);
|
|
2342
2572
|
if (!e) throw new TypeError(`Overlay node ${t.node} is not drawn straight into the overlay, so it cannot be dressed`);
|
|
2343
2573
|
return e;
|
|
2344
2574
|
}
|
|
2345
2575
|
async adopt(t, e) {
|
|
2346
2576
|
const r = e.parent;
|
|
2347
|
-
if (r &&
|
|
2577
|
+
if (r && Hr(r)) throw new Error("What it was to be drawn in was taken off the screen before it could be put there");
|
|
2348
2578
|
await t.update(e);
|
|
2349
2579
|
}
|
|
2350
2580
|
async waitFor(t, e = this.readyTimeoutMs) {
|
|
@@ -2352,7 +2582,7 @@ class or {
|
|
|
2352
2582
|
for (; ; ) {
|
|
2353
2583
|
const n = await this.status(), i = (!t.art || n.art) && (!t.palettes || n.palettes), s = r - Date.now();
|
|
2354
2584
|
if (i || s <= 0 || this.bridge.state === "closed") return n;
|
|
2355
|
-
await new Promise((o) => setTimeout(o, Math.min(
|
|
2585
|
+
await new Promise((o) => setTimeout(o, Math.min(vr, s)));
|
|
2356
2586
|
}
|
|
2357
2587
|
}
|
|
2358
2588
|
async artLoaded() {
|
|
@@ -2360,7 +2590,7 @@ class or {
|
|
|
2360
2590
|
}
|
|
2361
2591
|
async palettesLoaded() {
|
|
2362
2592
|
if (!this.known.palettes) try {
|
|
2363
|
-
const t = await this.bridge.definition(
|
|
2593
|
+
const t = await this.bridge.definition(F.palette).at("gamePalette").get();
|
|
2364
2594
|
this.known.palettes = Array.isArray(t) && t.length > 0;
|
|
2365
2595
|
} catch {
|
|
2366
2596
|
}
|
|
@@ -2368,16 +2598,16 @@ class or {
|
|
|
2368
2598
|
}
|
|
2369
2599
|
clientFont() {
|
|
2370
2600
|
if (!this.gameFont) {
|
|
2371
|
-
const t = this.bridge.definition(
|
|
2601
|
+
const t = this.bridge.definition(F.fonts), e = this.known.palettes, r = (async () => {
|
|
2372
2602
|
for (const n of [["defaultFontFormat", "font"], ["defaultFont", "fontName"]]) try {
|
|
2373
2603
|
const i = await t.at(...n).get();
|
|
2374
2604
|
if (typeof i == "string" && i.length > 0) return i;
|
|
2375
2605
|
} catch {
|
|
2376
2606
|
}
|
|
2377
|
-
return
|
|
2607
|
+
return wt;
|
|
2378
2608
|
})();
|
|
2379
2609
|
r.then((n) => {
|
|
2380
|
-
n ===
|
|
2610
|
+
n === wt && !e && this.gameFont === r && (this.gameFont = null);
|
|
2381
2611
|
}, () => {
|
|
2382
2612
|
this.gameFont === r && (this.gameFont = null);
|
|
2383
2613
|
}), this.gameFont = r;
|
|
@@ -2399,14 +2629,14 @@ class or {
|
|
|
2399
2629
|
async dressWindow(t, e) {
|
|
2400
2630
|
const r = await (await this.maker()).at("apply").call(null, ["PopupSkin", !1]), n = [r];
|
|
2401
2631
|
try {
|
|
2402
|
-
const i = r.at("ba"), [s, o] = await Promise.all([
|
|
2632
|
+
const i = r.at("ba"), [s, o] = await Promise.all([gt(i.at("t", "height")), gt(i.at("b", "height"))]), l = Cr(e, s, o);
|
|
2403
2633
|
await Promise.all([i.at("m", "height").set(l.middle), i.at("m", "y").set(l.middleY), i.at("t", "y").set(l.topY), i.at("b", "y").set(l.bottomY)]), await this.frameOnly(r);
|
|
2404
|
-
const c = await this.boundsOf(i, r),
|
|
2405
|
-
await Promise.all([r.at("x").set(Math.round(-c.x -
|
|
2634
|
+
const c = await this.boundsOf(i, r), d = { width: Math.round(c.width), height: Math.round(c.height) }, u = await this.parchmentOf(r, c).catch(() => null), h = Lr(d, u);
|
|
2635
|
+
await Promise.all([r.at("x").set(Math.round(-c.x - h.panel.x)), r.at("y").set(Math.round(-c.y - h.panel.y))]);
|
|
2406
2636
|
const g = await this.nodeObject(t);
|
|
2407
2637
|
n.push(g), await g.at("addChildAt").call(r, 0);
|
|
2408
|
-
const m = await this.frameClose(g,
|
|
2409
|
-
return m && n.push(m), { ...
|
|
2638
|
+
const m = await this.frameClose(g, h).catch(() => null);
|
|
2639
|
+
return m && n.push(m), { ...d, layout: h, close: m, held: n };
|
|
2410
2640
|
} catch (i) {
|
|
2411
2641
|
throw await this.bridge.release(n).catch(() => {
|
|
2412
2642
|
}), i;
|
|
@@ -2427,7 +2657,7 @@ class or {
|
|
|
2427
2657
|
async boundsOf(t, e) {
|
|
2428
2658
|
const r = await t.at("getBounds").call(e);
|
|
2429
2659
|
try {
|
|
2430
|
-
const [n, i, s, o] = await Promise.all(["x", "y", "width", "height"].map((l) =>
|
|
2660
|
+
const [n, i, s, o] = await Promise.all(["x", "y", "width", "height"].map((l) => gt(r.at(l))));
|
|
2431
2661
|
return { x: n, y: i, width: s, height: o };
|
|
2432
2662
|
} finally {
|
|
2433
2663
|
await this.bridge.release([r]).catch(() => {
|
|
@@ -2439,13 +2669,13 @@ class or {
|
|
|
2439
2669
|
if (r <= 0 || n <= 0 || r > 2048 || n > 2048) return null;
|
|
2440
2670
|
const i = await this.bridge.construct("flash.display.BitmapData", r, n, !0, 0);
|
|
2441
2671
|
try {
|
|
2442
|
-
await i.at("draw").call(t, new
|
|
2672
|
+
await i.at("draw").call(t, new vt("flash.geom.Matrix", [1, 0, 0, 1, -e.x, -e.y]));
|
|
2443
2673
|
const s = await i.at("getPixel32").call(Math.floor(r / 2), Math.floor(n / 2));
|
|
2444
2674
|
if (typeof s != "number" || s >>> 24 !== 255) return null;
|
|
2445
|
-
const o = await i.at("getColorBoundsRect").call(
|
|
2675
|
+
const o = await i.at("getColorBoundsRect").call(ge, (s & ge) >>> 0, !0);
|
|
2446
2676
|
try {
|
|
2447
|
-
const [l, c,
|
|
2448
|
-
return { x: l, y: c, width:
|
|
2677
|
+
const [l, c, d, u] = await Promise.all(["x", "y", "width", "height"].map((h) => gt(o.at(h))));
|
|
2678
|
+
return { x: l, y: c, width: d, height: u };
|
|
2449
2679
|
} finally {
|
|
2450
2680
|
await this.bridge.release([o]).catch(() => {
|
|
2451
2681
|
});
|
|
@@ -2476,16 +2706,16 @@ class or {
|
|
|
2476
2706
|
} });
|
|
2477
2707
|
}
|
|
2478
2708
|
async palette(t) {
|
|
2479
|
-
const e = await this.waitFor({ palettes: !0 }), r = this.bridge.definition(
|
|
2709
|
+
const e = await this.waitFor({ palettes: !0 }), r = this.bridge.definition(F.palette), n = e.palettes ? await r.at("gamePalette").get() : null, i = Oe(n);
|
|
2480
2710
|
if (!i.length) throw new Error(`The game has not loaded its colour palettes yet: waited ${Math.round(this.readyTimeoutMs / 1e3)} seconds`);
|
|
2481
2711
|
if (t === "game") return { values: i, indexes: i.map((o, l) => l) };
|
|
2482
|
-
const s =
|
|
2712
|
+
const s = Oe(await r.at(t === 1 ? "avatarPalette1" : "avatarPalette2").get());
|
|
2483
2713
|
return { values: i, indexes: s.length ? s : i.map((o, l) => l) };
|
|
2484
2714
|
}
|
|
2485
2715
|
async clientColorTable(t) {
|
|
2486
2716
|
const e = await this.flash.overlay.group({ x: t.options.x ?? 0, y: t.options.y ?? 0, visible: !1 });
|
|
2487
2717
|
try {
|
|
2488
|
-
const r = await this.bridge.construct(
|
|
2718
|
+
const r = await this.bridge.construct(F.colorTable);
|
|
2489
2719
|
await r.at("init").call(0, t.width, t.height, t.columns, t.rows, t.values, t.indexes, t.current, (i, s) => t.tell(Number(s)), -1);
|
|
2490
2720
|
const n = await this.nodeObject(e);
|
|
2491
2721
|
await n.at("addChild").call(r), await this.bridge.release([n, r]).catch(() => {
|
|
@@ -2496,14 +2726,14 @@ class or {
|
|
|
2496
2726
|
return e;
|
|
2497
2727
|
}
|
|
2498
2728
|
async swatchGrid(t) {
|
|
2499
|
-
const e = await this.flash.overlay.group({ x: t.options.x ?? 0, y: t.options.y ?? 0, ...t.options.parent ? { parent: E(t.options.parent) } : {}, ...t.options.visible === void 0 ? {} : { visible: t.options.visible } }), r =
|
|
2729
|
+
const e = await this.flash.overlay.group({ x: t.options.x ?? 0, y: t.options.y ?? 0, ...t.options.parent ? { parent: E(t.options.parent) } : {}, ...t.options.visible === void 0 ? {} : { visible: t.options.visible } }), r = Me({ count: t.indexes.length, columns: t.columns, tileWidth: t.swatchWidth, tileHeight: t.swatchHeight, gap: 1 }), n = { color: Yt.line, alpha: 0.6 }, i = { color: Yt.light, width: 2 }, s = /* @__PURE__ */ new Map();
|
|
2500
2730
|
let o = t.current;
|
|
2501
2731
|
for (const l of r) {
|
|
2502
|
-
const c = t.indexes[l.index],
|
|
2503
|
-
s.set(c,
|
|
2504
|
-
var
|
|
2505
|
-
const
|
|
2506
|
-
o = c,
|
|
2732
|
+
const c = t.indexes[l.index], d = await this.flash.overlay.button("", { parent: e, x: l.x, y: l.y, width: l.width, height: l.height, cornerRadius: 2, fill: t.values[c] ?? 0, hoverFill: t.values[c] ?? 0, stroke: c === o ? i : n });
|
|
2733
|
+
s.set(c, d), d.on("click", () => {
|
|
2734
|
+
var u;
|
|
2735
|
+
const h = o;
|
|
2736
|
+
o = c, h !== c && ((u = s.get(h)) == null || u.update({ stroke: n }).catch(D), d.update({ stroke: i }).catch(D)), t.tell(c);
|
|
2507
2737
|
});
|
|
2508
2738
|
}
|
|
2509
2739
|
return e;
|
|
@@ -2514,42 +2744,42 @@ class or {
|
|
|
2514
2744
|
const o = new Promise((p) => {
|
|
2515
2745
|
s = p;
|
|
2516
2746
|
});
|
|
2517
|
-
let l = null, c = !1,
|
|
2518
|
-
const
|
|
2519
|
-
c || (c = !0,
|
|
2520
|
-
},
|
|
2521
|
-
c ||
|
|
2747
|
+
let l = null, c = !1, d = null;
|
|
2748
|
+
const u = (p) => {
|
|
2749
|
+
c || (c = !0, d && clearTimeout(d), d = null, this.popups.delete(g), s(p));
|
|
2750
|
+
}, h = () => {
|
|
2751
|
+
c || d || (d = setTimeout(() => u(i), Ir));
|
|
2522
2752
|
}, g = async () => {
|
|
2523
2753
|
const p = l;
|
|
2524
|
-
l = null,
|
|
2754
|
+
l = null, u(i), p && await p.at("destroy").call().catch(() => {
|
|
2525
2755
|
});
|
|
2526
2756
|
};
|
|
2527
2757
|
this.popups.add(g);
|
|
2528
|
-
const m =
|
|
2758
|
+
const m = jr(t, e, r);
|
|
2529
2759
|
return (async () => {
|
|
2530
2760
|
await this.waitFor({ art: !0 });
|
|
2531
|
-
const p = this.bridge.definition(r.layer === "load" ?
|
|
2532
|
-
for (const
|
|
2533
|
-
if (
|
|
2534
|
-
if (
|
|
2535
|
-
else if (
|
|
2761
|
+
const p = this.bridge.definition(r.layer === "load" ? F.loadProgress : F.guiManager).at(r.layer === "load" ? "loadLayer" : "guiLayer"), f = [];
|
|
2762
|
+
for (const b of m.args) {
|
|
2763
|
+
if (b !== null && typeof b == "object") {
|
|
2764
|
+
if (b.slot === "layer") f.push(await p.get());
|
|
2765
|
+
else if (b.slot === "callback") f.push((...k) => u(n(k[0] ?? null)));
|
|
2536
2766
|
else {
|
|
2537
|
-
const
|
|
2538
|
-
f.push(await
|
|
2767
|
+
const k = await this.maker();
|
|
2768
|
+
f.push(await k.at("apply").call(null, ["PopupSkin", !1]));
|
|
2539
2769
|
}
|
|
2540
2770
|
continue;
|
|
2541
2771
|
}
|
|
2542
|
-
f.push(
|
|
2772
|
+
f.push(b);
|
|
2543
2773
|
}
|
|
2544
2774
|
const w = await this.bridge.construct(m.className, ...f);
|
|
2545
|
-
l = w, await w.at("closeCallback").set(() =>
|
|
2775
|
+
l = w, await w.at("closeCallback").set(() => h()).catch(() => {
|
|
2546
2776
|
});
|
|
2547
2777
|
})().catch((p) => {
|
|
2548
|
-
this.popups.delete(g), c || (c = !0, s(i)), console.error(`phantom.ui.popup.${t} could not open: ${
|
|
2778
|
+
this.popups.delete(g), c || (c = !0, s(i)), console.error(`phantom.ui.popup.${t} could not open: ${Y(p)}`);
|
|
2549
2779
|
}), Object.assign(o, { close: g });
|
|
2550
2780
|
}
|
|
2551
2781
|
}
|
|
2552
|
-
class
|
|
2782
|
+
class zr {
|
|
2553
2783
|
constructor(t, e) {
|
|
2554
2784
|
this.open = t, this.closeEverything = e;
|
|
2555
2785
|
}
|
|
@@ -2564,135 +2794,156 @@ class lr {
|
|
|
2564
2794
|
}, void 0);
|
|
2565
2795
|
}
|
|
2566
2796
|
okCancel(t, e = {}) {
|
|
2567
|
-
return this.open("okCancel", t, e,
|
|
2797
|
+
return this.open("okCancel", t, e, Bt, null);
|
|
2568
2798
|
}
|
|
2569
2799
|
yesNo(t, e = {}) {
|
|
2570
|
-
return this.open("yesNo", t, e,
|
|
2800
|
+
return this.open("yesNo", t, e, Bt, null);
|
|
2571
2801
|
}
|
|
2572
2802
|
titled(t, e = {}) {
|
|
2573
2803
|
return this.open("titled", t, e, () => {
|
|
2574
2804
|
}, void 0);
|
|
2575
2805
|
}
|
|
2576
2806
|
parchment(t, e = {}) {
|
|
2577
|
-
return this.open("parchment", t, e,
|
|
2807
|
+
return this.open("parchment", t, e, Bt, null);
|
|
2578
2808
|
}
|
|
2579
2809
|
async closeAll() {
|
|
2580
2810
|
await this.closeEverything();
|
|
2581
2811
|
}
|
|
2582
2812
|
}
|
|
2583
|
-
const
|
|
2813
|
+
const Ir = 50, Te = { click: "click", down: "mouseDown", up: "mouseUp", over: "rollOver", out: "rollOut" }, Br = ["chatBar", "chatHist", "chatTxt", "sendChatBtn", "safeChatBtn", "actionsBtn", "emotesBtn", "denBtn", "worldMapBtn", "buddyListBtn", "newsBtn", "partyBtn", "mySettingsBtn", "money", "zoneName"];
|
|
2584
2814
|
function E(a) {
|
|
2585
2815
|
if (!a) throw new TypeError("Expected a widget or an overlay node");
|
|
2586
2816
|
return typeof a.node == "number" ? a : a.node;
|
|
2587
2817
|
}
|
|
2588
|
-
function
|
|
2818
|
+
function Hr(a) {
|
|
2589
2819
|
let t = !1;
|
|
2590
2820
|
return a.onRemoved(() => {
|
|
2591
2821
|
t = !0;
|
|
2592
2822
|
})(), t;
|
|
2593
2823
|
}
|
|
2594
|
-
function
|
|
2824
|
+
function nt(a, t) {
|
|
2595
2825
|
return t ? { fill: a.accent, hoverFill: { color: a.accent, alpha: 0.85 }, pressedFill: { color: a.accent, alpha: 0.7 }, stroke: a.line } : a.skin === "game" ? { fill: a.light, hoverFill: 16777215, pressedFill: a.line, stroke: a.line } : { fill: { color: a.ink, alpha: 0.92 }, hoverFill: a.line, pressedFill: { color: a.line, alpha: 0.7 }, stroke: a.line };
|
|
2596
2826
|
}
|
|
2597
|
-
function
|
|
2827
|
+
function Bt(a) {
|
|
2598
2828
|
if (a !== null && typeof a == "object" && !Array.isArray(a)) {
|
|
2599
2829
|
const t = a.status;
|
|
2600
2830
|
if (typeof t == "boolean") return t;
|
|
2601
2831
|
}
|
|
2602
2832
|
return null;
|
|
2603
2833
|
}
|
|
2604
|
-
function
|
|
2834
|
+
function Se(a) {
|
|
2605
2835
|
return Number.isFinite(a) ? Math.min(1, Math.max(0, a)) : 0;
|
|
2606
2836
|
}
|
|
2607
|
-
function
|
|
2837
|
+
function Y(a) {
|
|
2608
2838
|
return a instanceof Error ? a.message : String(a);
|
|
2609
2839
|
}
|
|
2610
|
-
async function
|
|
2840
|
+
async function gt(a) {
|
|
2611
2841
|
const t = await a.get();
|
|
2612
2842
|
if (typeof t != "number" || !Number.isFinite(t)) throw new TypeError(`Expected a number at ${a.path.join(".")}, and read ${String(t)}`);
|
|
2613
2843
|
return t;
|
|
2614
2844
|
}
|
|
2615
|
-
function
|
|
2845
|
+
function Oe(a) {
|
|
2616
2846
|
return Array.isArray(a) ? a.map((t) => typeof t == "number" ? t : 0) : [];
|
|
2617
2847
|
}
|
|
2618
|
-
function
|
|
2619
|
-
|
|
2848
|
+
function Ht(a, t) {
|
|
2849
|
+
const e = [];
|
|
2850
|
+
for (const r of a.split(`
|
|
2851
|
+
`)) {
|
|
2852
|
+
let n = "";
|
|
2853
|
+
for (const i of r.split(/\s+/).filter(Boolean)) n ? n.length + 1 + i.length <= t ? n = `${n} ${i}` : (e.push(n), n = i) : n = i;
|
|
2854
|
+
e.push(n);
|
|
2855
|
+
}
|
|
2856
|
+
return e.length ? e : [""];
|
|
2620
2857
|
}
|
|
2621
|
-
function
|
|
2858
|
+
function Ee(a, t) {
|
|
2859
|
+
return Math.max(8, Math.floor(a / Math.max(1, t * 0.55)));
|
|
2860
|
+
}
|
|
2861
|
+
function Dr(a) {
|
|
2862
|
+
if (!a || typeof a != "object" || Array.isArray(a)) return null;
|
|
2863
|
+
const { stageX: t, stageY: e } = a;
|
|
2864
|
+
return typeof t != "number" || typeof e != "number" ? null : { x: t, y: e };
|
|
2865
|
+
}
|
|
2866
|
+
function mt(a) {
|
|
2867
|
+
return typeof a == "number" && Number.isFinite(a) && a > 0 ? a : 0;
|
|
2868
|
+
}
|
|
2869
|
+
function yt(a) {
|
|
2870
|
+
return a instanceof A ? { code: a.code, message: a.message, ...a.stack ? { stack: a.stack } : {} } : a instanceof Error ? { code: "FAILED", message: a.message || a.name, ...a.stack ? { stack: a.stack } : {} } : { code: "FAILED", message: N(a) };
|
|
2871
|
+
}
|
|
2872
|
+
function We(a) {
|
|
2622
2873
|
const t = a && typeof a.code == "string" && a.code ? a.code : "FAILED";
|
|
2623
|
-
return new
|
|
2874
|
+
return new A(t, (a == null ? void 0 : a.message) || "Phantom could not do this");
|
|
2624
2875
|
}
|
|
2625
|
-
function
|
|
2626
|
-
return
|
|
2876
|
+
function ot(a) {
|
|
2877
|
+
return G(a, /* @__PURE__ */ new WeakMap());
|
|
2627
2878
|
}
|
|
2628
|
-
function
|
|
2629
|
-
if (
|
|
2879
|
+
function G(a, t) {
|
|
2880
|
+
if (ta(a)) return G(a.value, t);
|
|
2630
2881
|
if (typeof a == "function" || typeof a == "symbol") return;
|
|
2631
2882
|
if (typeof a != "object" || a === null) return a;
|
|
2632
|
-
const e =
|
|
2883
|
+
const e = ea(a);
|
|
2633
2884
|
if (t.has(e)) return t.get(e);
|
|
2634
2885
|
if (e instanceof Date || e instanceof RegExp || e instanceof ArrayBuffer || ArrayBuffer.isView(e)) return e;
|
|
2635
2886
|
if (Array.isArray(e)) {
|
|
2636
2887
|
const n = [];
|
|
2637
2888
|
t.set(e, n);
|
|
2638
|
-
for (const i of e) n.push(
|
|
2889
|
+
for (const i of e) n.push(G(i, t));
|
|
2639
2890
|
return n;
|
|
2640
2891
|
}
|
|
2641
2892
|
if (e instanceof Map) {
|
|
2642
2893
|
const n = /* @__PURE__ */ new Map();
|
|
2643
2894
|
t.set(e, n);
|
|
2644
|
-
for (const [i, s] of e) n.set(
|
|
2895
|
+
for (const [i, s] of e) n.set(G(i, t), G(s, t));
|
|
2645
2896
|
return n;
|
|
2646
2897
|
}
|
|
2647
2898
|
if (e instanceof Set) {
|
|
2648
2899
|
const n = /* @__PURE__ */ new Set();
|
|
2649
2900
|
t.set(e, n);
|
|
2650
|
-
for (const i of e) n.add(
|
|
2901
|
+
for (const i of e) n.add(G(i, t));
|
|
2651
2902
|
return n;
|
|
2652
2903
|
}
|
|
2653
|
-
if (e instanceof Error) return
|
|
2904
|
+
if (e instanceof Error) return yt(e);
|
|
2654
2905
|
const r = {};
|
|
2655
2906
|
t.set(e, r);
|
|
2656
2907
|
for (const [n, i] of Object.entries(e)) {
|
|
2657
|
-
const s =
|
|
2908
|
+
const s = G(i, t);
|
|
2658
2909
|
s !== void 0 && (r[n] = s);
|
|
2659
2910
|
}
|
|
2660
2911
|
return r;
|
|
2661
2912
|
}
|
|
2662
|
-
function
|
|
2913
|
+
function N(a) {
|
|
2663
2914
|
if (typeof a == "string") return a;
|
|
2664
2915
|
if (a instanceof Error) return a.stack || `${a.name}: ${a.message}`;
|
|
2665
2916
|
if (a === void 0) return "undefined";
|
|
2666
2917
|
if (typeof a == "function") return `[Function ${a.name || "anonymous"}]`;
|
|
2667
2918
|
if (typeof a == "symbol" || typeof a == "bigint") return a.toString();
|
|
2668
2919
|
try {
|
|
2669
|
-
const t = /* @__PURE__ */ new WeakSet(), e = JSON.stringify(
|
|
2920
|
+
const t = /* @__PURE__ */ new WeakSet(), e = JSON.stringify(ot(a), (r, n) => {
|
|
2670
2921
|
if (typeof n == "object" && n !== null) {
|
|
2671
2922
|
if (t.has(n)) return "[Circular]";
|
|
2672
2923
|
t.add(n);
|
|
2673
2924
|
}
|
|
2674
2925
|
return typeof n == "bigint" ? `${n}n` : n;
|
|
2675
2926
|
});
|
|
2676
|
-
return
|
|
2927
|
+
return Ae(e ?? String(a));
|
|
2677
2928
|
} catch {
|
|
2678
|
-
return
|
|
2929
|
+
return Ae(String(a));
|
|
2679
2930
|
}
|
|
2680
2931
|
}
|
|
2681
|
-
const
|
|
2682
|
-
function
|
|
2683
|
-
return a.length >
|
|
2932
|
+
const Dt = 1e4;
|
|
2933
|
+
function Ae(a) {
|
|
2934
|
+
return a.length > Dt ? `${a.slice(0, Dt)}… (${a.length - Dt} more)` : a;
|
|
2684
2935
|
}
|
|
2685
|
-
const
|
|
2686
|
-
function
|
|
2936
|
+
const qr = ["log", "info", "warn", "error"];
|
|
2937
|
+
function Wr(a, t) {
|
|
2687
2938
|
const e = /* @__PURE__ */ new Map();
|
|
2688
2939
|
let r = !1;
|
|
2689
|
-
for (const n of
|
|
2940
|
+
for (const n of qr) {
|
|
2690
2941
|
const i = a[n].bind(a);
|
|
2691
2942
|
e.set(n, i), a[n] = (...s) => {
|
|
2692
2943
|
if (i(...s), !r) {
|
|
2693
2944
|
r = !0;
|
|
2694
2945
|
try {
|
|
2695
|
-
t(n, s.map(
|
|
2946
|
+
t(n, s.map(N));
|
|
2696
2947
|
} finally {
|
|
2697
2948
|
r = !1;
|
|
2698
2949
|
}
|
|
@@ -2703,10 +2954,10 @@ function fr(a, t) {
|
|
|
2703
2954
|
for (const [n, i] of e) a[n] = i;
|
|
2704
2955
|
};
|
|
2705
2956
|
}
|
|
2706
|
-
function
|
|
2707
|
-
return new
|
|
2957
|
+
function Vr(a, t, e) {
|
|
2958
|
+
return new cr(new ya(Ur(a, t), { firstId: e }));
|
|
2708
2959
|
}
|
|
2709
|
-
function
|
|
2960
|
+
function Ur(a, t) {
|
|
2710
2961
|
const e = /* @__PURE__ */ new Set();
|
|
2711
2962
|
let r = null;
|
|
2712
2963
|
const n = (i) => {
|
|
@@ -2714,8 +2965,8 @@ function mr(a, t) {
|
|
|
2714
2965
|
};
|
|
2715
2966
|
return { send(i) {
|
|
2716
2967
|
a.call("flash.request", t, [i]).catch((s) => {
|
|
2717
|
-
const o =
|
|
2718
|
-
o ? n(o) : a.log("warn", [`A Flash request was refused: ${
|
|
2968
|
+
const o = _r(i, s);
|
|
2969
|
+
o ? n(o) : a.log("warn", [`A Flash request was refused: ${N(s)}`]);
|
|
2719
2970
|
});
|
|
2720
2971
|
}, onMessage(i) {
|
|
2721
2972
|
return e.add(i), r ??= a.subscribe("flash.messages", t, { event(s) {
|
|
@@ -2728,35 +2979,35 @@ function mr(a, t) {
|
|
|
2728
2979
|
};
|
|
2729
2980
|
} };
|
|
2730
2981
|
}
|
|
2731
|
-
function
|
|
2982
|
+
function _r(a, t) {
|
|
2732
2983
|
let e;
|
|
2733
2984
|
try {
|
|
2734
|
-
e =
|
|
2985
|
+
e = Fe(a);
|
|
2735
2986
|
} catch {
|
|
2736
2987
|
return null;
|
|
2737
2988
|
}
|
|
2738
2989
|
if (typeof (e == null ? void 0 : e.id) != "number") return null;
|
|
2739
|
-
const r = t instanceof
|
|
2740
|
-
return
|
|
2990
|
+
const r = t instanceof A ? t.code : "FAILED", n = t instanceof Error ? t.message : N(t);
|
|
2991
|
+
return tt({ kind: "result", id: e.id, ok: !1, error: { name: r, message: n, errorId: 0 } });
|
|
2741
2992
|
}
|
|
2742
|
-
function
|
|
2993
|
+
function Yr(a) {
|
|
2743
2994
|
let t = null, e = null;
|
|
2744
2995
|
const r = () => {
|
|
2745
2996
|
const n = a.flash();
|
|
2746
|
-
return t ??= new
|
|
2997
|
+
return t ??= new gr({ flash: n.bridge, content: Gr(a.port, a.game) }, n), t;
|
|
2747
2998
|
};
|
|
2748
|
-
return { avatar: { view: () => a.flash().bridge.definition(
|
|
2999
|
+
return { avatar: { view: () => a.flash().bridge.definition(dr.avatarManager).at("playerAvatarWorldView").get() }, adventures: { record: () => Kr(a.remote) }, realtime: { join: (n, i) => Ge(a.remote.realtime, n, i), stayIn: (n, i, s) => Ye(a.remote.realtime, n, i, s) }, customRooms: { prop: (n, i) => _e(a.remote.customRooms, n, i), object: (n, i) => Ue(a.remote.customRooms, n, i), character: (n, i) => Ve(a.remote.customRooms, n, i) }, room: { surfaces: () => oa(a.flash().bridge) }, content: { load: (n, i) => r().load(n, i), replaceOnScreen: (n, i, s) => r().replaceOnScreen(n, i, s) }, ui: () => {
|
|
2749
3000
|
const n = a.flash();
|
|
2750
|
-
return e ??= new
|
|
2751
|
-
}, recipes: { chatShortcuts: async (n) =>
|
|
3001
|
+
return e ??= new Nr({ flash: n.bridge }, n), e;
|
|
3002
|
+
}, recipes: { chatShortcuts: async (n) => nr(await qt(a), n), customChatBox: async (n) => ir(await qt(a), n), chatHistoryPanel: async (n) => or(await qt(a), n) } };
|
|
2752
3003
|
}
|
|
2753
|
-
function
|
|
3004
|
+
function Gr(a, t) {
|
|
2754
3005
|
const e = () => {
|
|
2755
|
-
throw new
|
|
3006
|
+
throw new A("NOT_SUPPORTED", "Only holding and releasing content happen in a frame");
|
|
2756
3007
|
};
|
|
2757
3008
|
return { hold: (r) => a.call("content.hold", t, [r]), release: (r) => a.call("content.release", t, [r]), replace: e, restore: e, list: e, observe: e };
|
|
2758
3009
|
}
|
|
2759
|
-
function
|
|
3010
|
+
function Kr(a) {
|
|
2760
3011
|
const t = Date.now(), e = [];
|
|
2761
3012
|
let r = null, n = null;
|
|
2762
3013
|
const i = () => {
|
|
@@ -2770,126 +3021,138 @@ function vr(a) {
|
|
|
2770
3021
|
});
|
|
2771
3022
|
return { stop: () => (s(), { version: 1, scriptDefId: r, difficulty: n, steps: [...e] }) };
|
|
2772
3023
|
}
|
|
2773
|
-
async function
|
|
3024
|
+
async function qt(a) {
|
|
2774
3025
|
const t = a.flash(), { remote: e } = a, r = [...await e.chat.recent()], n = /* @__PURE__ */ new Map();
|
|
2775
3026
|
for (const i of await e.room.players.list()) n.set(i.userId, i);
|
|
2776
3027
|
return e.room.players.onEnter((i) => n.set(i.userId, i)), e.room.players.onLeave((i) => n.delete(i.userId)), e.chat.onMessage((i) => r.push(i)), { flash: t, chat: { say: e.chat.say, phrase: e.chat.phrase, onMessage: e.chat.onMessage, recent: r }, room: { players: { get: (i) => n.get(i) ?? null } } };
|
|
2777
3028
|
}
|
|
2778
|
-
function
|
|
3029
|
+
function Jr(a, t) {
|
|
2779
3030
|
const e = {};
|
|
2780
|
-
for (const r of Object.keys(
|
|
3031
|
+
for (const r of Object.keys(Ke)) {
|
|
2781
3032
|
const n = r.split(".");
|
|
2782
3033
|
let i = e;
|
|
2783
3034
|
for (const o of n.slice(0, -1)) i = i[o] ??= {};
|
|
2784
3035
|
const s = n[n.length - 1];
|
|
2785
|
-
i[s] =
|
|
3036
|
+
i[s] = Je(r) ? Zr(a, t, r, Xe(r)) : Qr(a, t, r);
|
|
2786
3037
|
}
|
|
2787
|
-
return
|
|
3038
|
+
return Xt(e, "");
|
|
2788
3039
|
}
|
|
2789
|
-
const
|
|
2790
|
-
function
|
|
3040
|
+
const Xr = /* @__PURE__ */ new Set(["then", "toJSON", "constructor", "nodeType", "tagName"]);
|
|
3041
|
+
function Xt(a, t) {
|
|
2791
3042
|
for (const [e, r] of Object.entries(Object.getOwnPropertyDescriptors(a))) {
|
|
2792
3043
|
const n = r.get || r.set ? null : r.value;
|
|
2793
|
-
!n || typeof n != "object" || !r.writable || (a[e] =
|
|
3044
|
+
!n || typeof n != "object" || !r.writable || (a[e] = Xt(n, `${t}${e}.`));
|
|
2794
3045
|
}
|
|
2795
3046
|
return new Proxy(Object.freeze(a), { get(e, r, n) {
|
|
2796
3047
|
if (typeof r != "string" || r in e) return Reflect.get(e, r, n);
|
|
2797
|
-
if (!(
|
|
3048
|
+
if (!(Xr.has(r) || r.startsWith("__v_"))) throw new A("NOT_SUPPORTED", `phantom.${t}${r} is not in this Phantom's copy of the plugin SDK. Either the name is wrong, or Phantom is serving an older build of @phantomclient/plugin than this plugin was written against; building that package again gives every plugin the newer SDK.`);
|
|
2798
3049
|
} });
|
|
2799
3050
|
}
|
|
2800
|
-
function
|
|
3051
|
+
function Qr(a, t, e) {
|
|
2801
3052
|
return (...r) => a.call(`sdk:${e}`, t, r);
|
|
2802
3053
|
}
|
|
2803
|
-
function
|
|
2804
|
-
return (
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
3054
|
+
function Zr(a, t, e, r) {
|
|
3055
|
+
return (...n) => {
|
|
3056
|
+
const i = n.findIndex((u) => typeof u == "function");
|
|
3057
|
+
if (i === -1 && Qe(e)) throw new TypeError(`${e} takes a listener function`);
|
|
3058
|
+
const s = i === -1 ? null : n[i], o = i === -1 ? n : [...n.slice(0, i), ...n.slice(i + 1)];
|
|
3059
|
+
let l = null;
|
|
3060
|
+
const c = r === "awaited" ? new Promise((u, h) => {
|
|
3061
|
+
l = (g, m) => {
|
|
3062
|
+
l = null, g ? u(g) : h(m);
|
|
3063
|
+
};
|
|
3064
|
+
}) : null, d = a.subscribe(`sdk:${e}`, t, { event: (u) => s == null ? void 0 : s(...u), started: () => l == null ? void 0 : l(() => d()), ended(u) {
|
|
3065
|
+
if (l) {
|
|
3066
|
+
l(null, We(u ?? { code: "FAILED", message: `${e} could not be started` }));
|
|
3067
|
+
return;
|
|
3068
|
+
}
|
|
3069
|
+
u && a.log("warn", [`${e} stopped: ${u.code}: ${N(u.message)}`]);
|
|
3070
|
+
} }, { args: o, ...i === -1 ? {} : { listenerAt: i } });
|
|
3071
|
+
return c ?? d;
|
|
2809
3072
|
};
|
|
2810
3073
|
}
|
|
2811
|
-
function
|
|
3074
|
+
function $e(a, t, e, r) {
|
|
2812
3075
|
const n = (i) => ({ direction: r, ...i === "*" ? {} : { commands: [...i] } });
|
|
2813
3076
|
return { send(i) {
|
|
2814
3077
|
return a.call("packets.send", t, [e, String(i)]);
|
|
2815
3078
|
}, watch(i, s) {
|
|
2816
3079
|
return a.subscribe("packets.watch", t, { event(o) {
|
|
2817
|
-
const l =
|
|
2818
|
-
l && s(
|
|
3080
|
+
const l = en(o, r);
|
|
3081
|
+
l && s(qe(l.text, l.direction));
|
|
2819
3082
|
}, ended: (o) => {
|
|
2820
3083
|
o && a.log("warn", [`Watching the traffic stopped: ${o.message}`]);
|
|
2821
|
-
} }, n(i));
|
|
3084
|
+
} }, { filter: n(i) });
|
|
2822
3085
|
}, on(i, s) {
|
|
2823
3086
|
return a.subscribe("packets.intercept", t, { event: () => {
|
|
2824
3087
|
}, intercepted: (o) => {
|
|
2825
|
-
|
|
3088
|
+
tn(a, o, s);
|
|
2826
3089
|
}, ended: (o) => {
|
|
2827
3090
|
o && a.log("warn", [`Hooking the traffic stopped: ${o.message}`]);
|
|
2828
|
-
} }, n(i));
|
|
3091
|
+
} }, { filter: n(i) });
|
|
2829
3092
|
} };
|
|
2830
3093
|
}
|
|
2831
|
-
async function
|
|
3094
|
+
async function tn(a, t, e) {
|
|
2832
3095
|
let r;
|
|
2833
3096
|
try {
|
|
2834
|
-
r =
|
|
3097
|
+
r = qe(t.text, t.direction), await e(r);
|
|
2835
3098
|
} catch (n) {
|
|
2836
|
-
a.log("error", [`A traffic hook failed: ${
|
|
3099
|
+
a.log("error", [`A traffic hook failed: ${N(n)}`]), a.verdict(t.requestId, !1, null);
|
|
2837
3100
|
return;
|
|
2838
3101
|
}
|
|
2839
3102
|
a.verdict(t.requestId, r.dropped, r.modified ? r.encode() : null);
|
|
2840
3103
|
}
|
|
2841
|
-
function
|
|
3104
|
+
function en(a, t) {
|
|
2842
3105
|
const [e, r] = a;
|
|
2843
|
-
if (typeof e == "string") return { text: e, direction:
|
|
3106
|
+
if (typeof e == "string") return { text: e, direction: Pe(r) ? r : t };
|
|
2844
3107
|
if (typeof e == "object" && e !== null) {
|
|
2845
3108
|
const { text: n, direction: i } = e;
|
|
2846
|
-
if (typeof n == "string") return { text: n, direction:
|
|
3109
|
+
if (typeof n == "string") return { text: n, direction: Pe(i) ? i : t };
|
|
2847
3110
|
}
|
|
2848
3111
|
return null;
|
|
2849
3112
|
}
|
|
2850
|
-
function
|
|
3113
|
+
function Pe(a) {
|
|
2851
3114
|
return a === "toServer" || a === "toClient";
|
|
2852
3115
|
}
|
|
2853
|
-
function
|
|
3116
|
+
function an(a) {
|
|
2854
3117
|
const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Set();
|
|
2855
3118
|
function r(n) {
|
|
2856
3119
|
var i, s;
|
|
2857
|
-
const o = n ??
|
|
2858
|
-
if (!o) throw new
|
|
3120
|
+
const o = n ?? la(x.role);
|
|
3121
|
+
if (!o) throw new A("NO_GAME", ((i = x.role) == null ? void 0 : i.kind) === "page" || ((s = x.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");
|
|
2859
3122
|
let l = t.get(o);
|
|
2860
|
-
return l || (l =
|
|
3123
|
+
return l || (l = rn(a, o), t.set(o, l)), l;
|
|
2861
3124
|
}
|
|
2862
3125
|
return { ctx: { get plugin() {
|
|
2863
|
-
return
|
|
3126
|
+
return x.plugin;
|
|
2864
3127
|
}, get granted() {
|
|
2865
|
-
return
|
|
3128
|
+
return x.granted;
|
|
2866
3129
|
}, get preferences() {
|
|
2867
|
-
return
|
|
2868
|
-
}, can: (n) =>
|
|
3130
|
+
return x.preferences;
|
|
3131
|
+
}, can: (n) => nn(x.granted.scopes, n), games: () => [...x.games], onGames(n) {
|
|
2869
3132
|
return e.add(n), () => e.delete(n);
|
|
2870
3133
|
}, phantom: r, storage: { get: (n) => a.call("storage.get", null, [String(n)]), set: (n, i) => a.call("storage.set", null, [String(n), i]), remove: (n) => a.call("storage.remove", null, [String(n)]), keys: () => a.call("storage.keys", null, []) }, async fetch(n, i) {
|
|
2871
3134
|
const s = await a.call("fetch", null, [String(n), i ?? {}]);
|
|
2872
|
-
return
|
|
2873
|
-
}, copy: (n) => a.call("copy", null, [String(n)]), notify: (n, i) => a.call("notify", null, i === void 0 ? [String(n)] : [String(n), String(i)]), toast: (n, i) => a.call("toast", null, [String(n), i ?? {}]), confirm: (n, i) => a.call("confirm", null, [String(n), i ?? {}]), openUrl: (n) => a.call("openUrl", null, [String(n)]), log: (...n) => a.log("log", n.map(
|
|
3135
|
+
return sn(s);
|
|
3136
|
+
}, copy: (n) => a.call("copy", null, [String(n)]), notify: (n, i) => a.call("notify", null, i === void 0 ? [String(n)] : [String(n), String(i)]), toast: (n, i) => a.call("toast", null, [String(n), i ?? {}]), confirm: (n, i) => a.call("confirm", null, [String(n), i ?? {}]), openUrl: (n) => a.call("openUrl", null, [String(n)]), openPanel: (n, i) => a.call("panel.open", (i == null ? void 0 : i.game) ?? null, [String(n)]), closePanel: (n, i) => a.call("panel.close", (i == null ? void 0 : i.game) ?? null, [String(n)]), log: (...n) => a.log("log", n.map(N)) }, notifyGames(n) {
|
|
2874
3137
|
for (const i of [...e]) try {
|
|
2875
3138
|
i([...n]);
|
|
2876
3139
|
} catch (s) {
|
|
2877
|
-
a.log("error", [`An onGames listener failed: ${
|
|
3140
|
+
a.log("error", [`An onGames listener failed: ${N(s)}`]);
|
|
2878
3141
|
}
|
|
2879
3142
|
}, dispose() {
|
|
2880
3143
|
e.clear(), t.clear();
|
|
2881
3144
|
} };
|
|
2882
3145
|
}
|
|
2883
|
-
function
|
|
3146
|
+
function rn(a, t) {
|
|
2884
3147
|
let e = null;
|
|
2885
3148
|
const r = () => {
|
|
2886
3149
|
if (e) return e;
|
|
2887
|
-
if (
|
|
2888
|
-
return e =
|
|
2889
|
-
}, n =
|
|
2890
|
-
return Object.defineProperties(s, { flash: { enumerable: !0, get: r }, ui: { enumerable: !0, get: i.ui } }),
|
|
3150
|
+
if (x.flashIds === null) throw new A("PERMISSION_DENIED", "game.flash needs the flash scope, which this plugin was not granted");
|
|
3151
|
+
return e = Vr(a, t, x.flashIds), e;
|
|
3152
|
+
}, n = Jr(a, t), i = Yr({ port: a, game: t, remote: n, flash: r }), s = { ...n, avatar: Object.freeze({ ...n.avatar, ...i.avatar }), adventures: Object.freeze({ ...n.adventures, ...i.adventures }), content: Object.freeze({ ...n.content, ...i.content }), realtime: Object.freeze({ ...n.realtime, ...i.realtime }), customRooms: Object.freeze({ ...n.customRooms, ...i.customRooms }), room: Object.freeze({ ...n.room, ...i.room }), recipes: Object.freeze(i.recipes), id: t, server: $e(a, t, "toServer", "toClient"), client: $e(a, t, "toClient", "toServer") };
|
|
3153
|
+
return Object.defineProperties(s, { flash: { enumerable: !0, get: r }, ui: { enumerable: !0, get: i.ui } }), Xt(s, "");
|
|
2891
3154
|
}
|
|
2892
|
-
function
|
|
3155
|
+
function nn(a, t) {
|
|
2893
3156
|
if (a.includes(t)) return !0;
|
|
2894
3157
|
if (!t.startsWith("network:")) return !1;
|
|
2895
3158
|
const e = t.slice(8);
|
|
@@ -2899,66 +3162,76 @@ function Pr(a, t) {
|
|
|
2899
3162
|
return e.endsWith(n) && e.length > n.length;
|
|
2900
3163
|
});
|
|
2901
3164
|
}
|
|
2902
|
-
function
|
|
3165
|
+
function sn(a) {
|
|
2903
3166
|
const t = a.body ?? "";
|
|
2904
3167
|
return { status: a.status, ok: a.status >= 200 && a.status < 300, headers: a.headers ?? {}, text: async () => t, json: async () => JSON.parse(t) };
|
|
2905
3168
|
}
|
|
2906
|
-
const
|
|
2907
|
-
function
|
|
2908
|
-
const e = t.prefix ?? `f${Math.random().toString(36).slice(2, 10)}-`, r = t.timeoutMs ??
|
|
3169
|
+
const on = 6e4;
|
|
3170
|
+
function ln(a, t = {}) {
|
|
3171
|
+
const e = t.prefix ?? `f${Math.random().toString(36).slice(2, 10)}-`, r = t.timeoutMs ?? on;
|
|
2909
3172
|
let n = 0, i = !1;
|
|
2910
3173
|
const s = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), l = () => `${e}${n += 1}`;
|
|
2911
3174
|
function c(p, f) {
|
|
2912
3175
|
if (!i) try {
|
|
2913
|
-
a({ phantom:
|
|
3176
|
+
a({ phantom: B, type: "log", level: p, values: f });
|
|
2914
3177
|
} catch {
|
|
2915
3178
|
}
|
|
2916
3179
|
}
|
|
2917
|
-
function
|
|
2918
|
-
if (i) return Promise.reject(new
|
|
2919
|
-
const
|
|
2920
|
-
return new Promise((
|
|
2921
|
-
const
|
|
2922
|
-
s.delete(
|
|
3180
|
+
function d(p, f, w) {
|
|
3181
|
+
if (i) return Promise.reject(new A("FAILED", "The frame was closed"));
|
|
3182
|
+
const b = l();
|
|
3183
|
+
return new Promise((k, M) => {
|
|
3184
|
+
const R = setTimeout(() => {
|
|
3185
|
+
s.delete(b), M(new A("TIMEOUT", `Phantom did not answer ${p} in ${r / 1e3}s`));
|
|
2923
3186
|
}, r);
|
|
2924
|
-
s.set(
|
|
3187
|
+
s.set(b, { resolve: k, reject: M, timer: R });
|
|
2925
3188
|
try {
|
|
2926
|
-
a({ phantom:
|
|
2927
|
-
} catch (
|
|
2928
|
-
clearTimeout(
|
|
3189
|
+
a({ phantom: B, type: "call", id: b, method: p, game: f, args: ot(w) });
|
|
3190
|
+
} catch (O) {
|
|
3191
|
+
clearTimeout(R), s.delete(b), M(new A("FAILED", `${p} could not be sent: ${N(O)}`));
|
|
2929
3192
|
}
|
|
2930
3193
|
});
|
|
2931
3194
|
}
|
|
2932
|
-
function
|
|
2933
|
-
if (i) return () => {
|
|
3195
|
+
function u(p, f, w, b = {}) {
|
|
3196
|
+
if (i) return m(() => {
|
|
3197
|
+
var M;
|
|
3198
|
+
return (M = w.ended) == null ? void 0 : M.call(w, { code: "FAILED", message: "The frame was closed" });
|
|
3199
|
+
}), () => {
|
|
2934
3200
|
};
|
|
2935
|
-
const
|
|
2936
|
-
o.set(
|
|
3201
|
+
const k = l();
|
|
3202
|
+
o.set(k, w);
|
|
2937
3203
|
try {
|
|
2938
|
-
a({ phantom:
|
|
2939
|
-
} catch (
|
|
2940
|
-
throw o.delete(
|
|
3204
|
+
a({ phantom: B, type: "subscribe", id: k, topic: p, game: f, ...b.filter ? { filter: ot(b.filter) } : {}, ...b.args ? { args: ot(b.args) } : {}, ...typeof b.listenerAt == "number" ? { listenerAt: b.listenerAt } : {} });
|
|
3205
|
+
} catch (M) {
|
|
3206
|
+
throw o.delete(k), new A("FAILED", `${p} could not be heard: ${N(M)}`);
|
|
2941
3207
|
}
|
|
2942
3208
|
return () => {
|
|
2943
|
-
!o.delete(
|
|
3209
|
+
!o.delete(k) || i || a({ phantom: B, type: "unsubscribe", id: k });
|
|
2944
3210
|
};
|
|
2945
3211
|
}
|
|
2946
|
-
function
|
|
2947
|
-
i || a({ phantom:
|
|
3212
|
+
function h(p, f, w) {
|
|
3213
|
+
i || a({ phantom: B, type: "verdict", requestId: p, drop: f, text: w });
|
|
2948
3214
|
}
|
|
2949
3215
|
function g(p) {
|
|
2950
3216
|
switch (p.type) {
|
|
2951
3217
|
case "call-result": {
|
|
2952
3218
|
const f = s.get(p.id);
|
|
2953
|
-
return f ? (s.delete(p.id), clearTimeout(f.timer), p.ok ? f.resolve(p.value) : f.reject(
|
|
3219
|
+
return f ? (s.delete(p.id), clearTimeout(f.timer), p.ok ? f.resolve(p.value) : f.reject(We(p.error)), !0) : !1;
|
|
2954
3220
|
}
|
|
2955
3221
|
case "event": {
|
|
2956
3222
|
const f = o.get(p.subscription);
|
|
2957
3223
|
return f ? (m(() => f.event(Array.isArray(p.args) ? p.args : [])), !0) : !1;
|
|
2958
3224
|
}
|
|
3225
|
+
case "subscribed": {
|
|
3226
|
+
const f = o.get(p.subscription);
|
|
3227
|
+
return f ? (m(() => {
|
|
3228
|
+
var w;
|
|
3229
|
+
return (w = f.started) == null ? void 0 : w.call(f);
|
|
3230
|
+
}), !0) : !1;
|
|
3231
|
+
}
|
|
2959
3232
|
case "intercepted": {
|
|
2960
3233
|
const f = o.get(p.subscription);
|
|
2961
|
-
return f != null && f.intercepted ? (f.intercepted(p), !0) : (
|
|
3234
|
+
return f != null && f.intercepted ? (f.intercepted(p), !0) : (h(p.requestId, !1, null), !!f);
|
|
2962
3235
|
}
|
|
2963
3236
|
case "subscription-ended": {
|
|
2964
3237
|
const f = o.get(p.subscription);
|
|
@@ -2973,172 +3246,174 @@ function Fr(a, t = {}) {
|
|
|
2973
3246
|
try {
|
|
2974
3247
|
p();
|
|
2975
3248
|
} catch (f) {
|
|
2976
|
-
c("error", [`A listener failed: ${
|
|
3249
|
+
c("error", [`A listener failed: ${N(f)}`]);
|
|
2977
3250
|
}
|
|
2978
3251
|
}
|
|
2979
|
-
return { call:
|
|
3252
|
+
return { call: d, subscribe: u, verdict: h, log: c, receive: g, close(p) {
|
|
2980
3253
|
if (!i) {
|
|
2981
3254
|
i = !0;
|
|
2982
|
-
for (const f of s.values()) clearTimeout(f.timer), f.reject(new
|
|
3255
|
+
for (const f of s.values()) clearTimeout(f.timer), f.reject(new A("FAILED", p));
|
|
2983
3256
|
s.clear(), o.clear();
|
|
2984
3257
|
}
|
|
2985
3258
|
} };
|
|
2986
3259
|
}
|
|
2987
|
-
function
|
|
3260
|
+
function cn(a, t, e = /* @__PURE__ */ new Set()) {
|
|
2988
3261
|
const r = /* @__PURE__ */ new Set();
|
|
2989
3262
|
for (const [i, s] of Object.entries((t == null ? void 0 : t.variables) ?? {})) !i.startsWith("--phantom-") || typeof s != "string" || (a.style.setProperty(i, s), r.add(i));
|
|
2990
3263
|
for (const i of e) r.has(i) || a.style.removeProperty(i);
|
|
2991
3264
|
const n = (t == null ? void 0 : t.mode) === "light" ? "light" : "dark";
|
|
2992
3265
|
return a.dataset.theme = n, a.style.setProperty("color-scheme", n), r;
|
|
2993
3266
|
}
|
|
2994
|
-
const
|
|
2995
|
-
function
|
|
2996
|
-
|
|
3267
|
+
const hn = 2e3;
|
|
3268
|
+
function un(a, t) {
|
|
3269
|
+
ca(t.development ?? !1);
|
|
2997
3270
|
let e = !1, r = /* @__PURE__ */ new Set(), n = null, i = null;
|
|
2998
3271
|
function s(y) {
|
|
2999
|
-
var
|
|
3000
|
-
e || (a.post(y), (
|
|
3001
|
-
}
|
|
3002
|
-
const o =
|
|
3003
|
-
|
|
3004
|
-
function
|
|
3005
|
-
var
|
|
3006
|
-
const
|
|
3272
|
+
var v;
|
|
3273
|
+
e || (a.post(y), (v = t.tap) == null || v.call(t, y));
|
|
3274
|
+
}
|
|
3275
|
+
const o = ln(s), l = an(o), c = l.ctx;
|
|
3276
|
+
ae(c);
|
|
3277
|
+
function d(y) {
|
|
3278
|
+
var v;
|
|
3279
|
+
const j = yt(y);
|
|
3007
3280
|
try {
|
|
3008
|
-
s({ phantom:
|
|
3281
|
+
s({ phantom: B, type: "crash", error: j });
|
|
3009
3282
|
} catch {
|
|
3010
3283
|
}
|
|
3011
|
-
(
|
|
3284
|
+
(v = a.view) == null || v.showError(j, x.development);
|
|
3012
3285
|
}
|
|
3013
|
-
let
|
|
3014
|
-
const
|
|
3286
|
+
let u;
|
|
3287
|
+
const h = new Promise((y) => u = y).then(async () => {
|
|
3015
3288
|
try {
|
|
3016
|
-
const y = t.definition,
|
|
3017
|
-
return n =
|
|
3289
|
+
const y = t.definition, v = await (typeof y == "function" ? y() : y);
|
|
3290
|
+
return n = dn(v), !0;
|
|
3018
3291
|
} catch (y) {
|
|
3019
|
-
return
|
|
3292
|
+
return d(y), !1;
|
|
3020
3293
|
}
|
|
3021
|
-
}), g =
|
|
3022
|
-
var
|
|
3023
|
-
if (!y || ((
|
|
3024
|
-
|
|
3294
|
+
}), g = h.then(async (y) => {
|
|
3295
|
+
var v;
|
|
3296
|
+
if (!y || ((v = x.role) == null ? void 0 : v.kind) !== "logic") return y;
|
|
3297
|
+
const j = it(n == null ? void 0 : n.widgets);
|
|
3298
|
+
if (s({ phantom: B, type: "ready", implements: { pages: it(n == null ? void 0 : n.pages), panels: it(n == null ? void 0 : n.panels), commands: it(n == null ? void 0 : n.commands), commandViews: it(n == null ? void 0 : n.commandViews), ...j.length ? { widgets: j } : {} } }), !(n != null && n.setup)) return !0;
|
|
3025
3299
|
try {
|
|
3026
|
-
const
|
|
3027
|
-
typeof
|
|
3028
|
-
} catch (
|
|
3029
|
-
|
|
3300
|
+
const C = await n.setup(c);
|
|
3301
|
+
typeof C == "function" && (e ? M(C) : i = C);
|
|
3302
|
+
} catch (C) {
|
|
3303
|
+
d(C);
|
|
3030
3304
|
}
|
|
3031
3305
|
return !0;
|
|
3032
3306
|
});
|
|
3033
3307
|
function m(y) {
|
|
3034
|
-
if (e ||
|
|
3035
|
-
const
|
|
3036
|
-
switch (
|
|
3308
|
+
if (e || !Ze(y)) return;
|
|
3309
|
+
const v = y;
|
|
3310
|
+
switch (v.type) {
|
|
3037
3311
|
case "init":
|
|
3038
|
-
p(
|
|
3312
|
+
p(v);
|
|
3039
3313
|
return;
|
|
3040
3314
|
case "games":
|
|
3041
|
-
|
|
3315
|
+
x.games = Array.isArray(v.games) ? v.games : [], l.notifyGames(x.games);
|
|
3042
3316
|
return;
|
|
3043
3317
|
case "stop":
|
|
3044
|
-
|
|
3318
|
+
O();
|
|
3045
3319
|
return;
|
|
3046
3320
|
case "mount":
|
|
3047
|
-
w(
|
|
3321
|
+
w(v);
|
|
3048
3322
|
return;
|
|
3049
3323
|
case "invoke":
|
|
3050
|
-
|
|
3324
|
+
k(v);
|
|
3051
3325
|
return;
|
|
3052
3326
|
case "call-result":
|
|
3053
3327
|
case "event":
|
|
3328
|
+
case "subscribed":
|
|
3054
3329
|
case "subscription-ended":
|
|
3055
3330
|
case "intercepted":
|
|
3056
|
-
o.receive(
|
|
3331
|
+
o.receive(v);
|
|
3057
3332
|
return;
|
|
3058
3333
|
}
|
|
3059
3334
|
}
|
|
3060
3335
|
function p(y) {
|
|
3061
|
-
var
|
|
3062
|
-
a.root && y.theme && (r =
|
|
3336
|
+
var v;
|
|
3337
|
+
a.root && y.theme && (r = cn(a.root, y.theme, r)), Object.assign(x, { role: x.role ?? y.role ?? null, plugin: y.plugin ?? x.plugin, mode: ((v = y.theme) == null ? void 0 : v.mode) === "light" ? "light" : "dark", granted: y.granted ?? { scopes: [] }, preferences: y.preferences ?? {}, games: Array.isArray(y.games) ? y.games : [], flashIds: typeof y.flashIds == "number" ? y.flashIds : null, development: x.development || !!y.development, initialized: !0 }), l.notifyGames(x.games), u();
|
|
3063
3338
|
}
|
|
3064
3339
|
const f = a.listen(m);
|
|
3065
3340
|
async function w(y) {
|
|
3066
|
-
var
|
|
3067
|
-
const [
|
|
3068
|
-
e || ((
|
|
3341
|
+
var v, j;
|
|
3342
|
+
const [C] = await Promise.all([h, ((v = a.loadStyles) == null ? void 0 : v.call(a)) ?? Promise.resolve()]);
|
|
3343
|
+
e || ((j = x.role) == null ? void 0 : j.kind) === "logic" || (Object.assign(x, { kind: y.kind, contribution: y.contribution, props: y.props ?? {} }), C && b());
|
|
3069
3344
|
}
|
|
3070
|
-
function
|
|
3345
|
+
function b() {
|
|
3071
3346
|
var y;
|
|
3072
|
-
if (!
|
|
3073
|
-
const [
|
|
3074
|
-
if (!
|
|
3075
|
-
|
|
3347
|
+
if (!x.kind || !x.contribution) return;
|
|
3348
|
+
const [v, j] = x.kind === "page" ? [n == null ? void 0 : n.pages, "pages"] : x.kind === "panel" ? [n == null ? void 0 : n.panels, "panels"] : x.kind === "widget" ? [n == null ? void 0 : n.widgets, "widgets"] : [n == null ? void 0 : n.commandViews, "commandViews"], C = v == null ? void 0 : v[x.contribution];
|
|
3349
|
+
if (!C) {
|
|
3350
|
+
d(new A("NOT_SUPPORTED", `definePlugin has no ${j}["${x.contribution}"], so there is nothing to show here`));
|
|
3076
3351
|
return;
|
|
3077
3352
|
}
|
|
3078
3353
|
try {
|
|
3079
|
-
(y = a.view) == null || y.mount(
|
|
3080
|
-
} catch (
|
|
3081
|
-
|
|
3354
|
+
(y = a.view) == null || y.mount(C, c);
|
|
3355
|
+
} catch (q) {
|
|
3356
|
+
d(q);
|
|
3082
3357
|
}
|
|
3083
3358
|
}
|
|
3084
|
-
async function
|
|
3085
|
-
var
|
|
3086
|
-
const
|
|
3359
|
+
async function k(y) {
|
|
3360
|
+
var v, j;
|
|
3361
|
+
const C = (q, Mt) => {
|
|
3087
3362
|
try {
|
|
3088
|
-
s({ phantom:
|
|
3089
|
-
} catch (
|
|
3090
|
-
s({ phantom:
|
|
3363
|
+
s({ phantom: B, type: "result", id: y.id, ok: q, ...Mt });
|
|
3364
|
+
} catch (Tt) {
|
|
3365
|
+
s({ phantom: B, type: "result", id: y.id, ok: !1, error: yt(new A("FAILED", `The answer could not be sent to Phantom: ${N(Tt)}`)) });
|
|
3091
3366
|
}
|
|
3092
3367
|
};
|
|
3093
3368
|
try {
|
|
3094
|
-
if (!await g || !n) throw new
|
|
3095
|
-
if (y.kind !== "commands") throw new
|
|
3096
|
-
const
|
|
3097
|
-
if (typeof
|
|
3098
|
-
const
|
|
3099
|
-
|
|
3100
|
-
} catch (
|
|
3101
|
-
|
|
3369
|
+
if (!await g || !n) throw new A("FAILED", "The plugin did not load");
|
|
3370
|
+
if (y.kind !== "commands") throw new A("NOT_SUPPORTED", `Phantom asked for an unknown kind, "${y.kind}"`);
|
|
3371
|
+
const q = (v = n.commands) == null ? void 0 : v[y.contribution];
|
|
3372
|
+
if (typeof q != "function") throw new A("NOT_SUPPORTED", `definePlugin has no commands["${y.contribution}"] function`);
|
|
3373
|
+
const Mt = { arguments: ((j = y.input) == null ? void 0 : j.arguments) ?? {} }, Tt = await q(Mt, c.phantom(y.game), c);
|
|
3374
|
+
C(!0, { value: ot(Tt ?? null) });
|
|
3375
|
+
} catch (q) {
|
|
3376
|
+
C(!1, { error: yt(q) });
|
|
3102
3377
|
}
|
|
3103
3378
|
}
|
|
3104
|
-
function
|
|
3379
|
+
function M(y) {
|
|
3105
3380
|
try {
|
|
3106
|
-
const
|
|
3107
|
-
|
|
3108
|
-
} catch (
|
|
3109
|
-
|
|
3381
|
+
const v = y();
|
|
3382
|
+
v instanceof Promise && v.catch((j) => R(j));
|
|
3383
|
+
} catch (v) {
|
|
3384
|
+
R(v);
|
|
3110
3385
|
}
|
|
3111
3386
|
}
|
|
3112
|
-
function
|
|
3113
|
-
o.log("error", [`setup's cleanup failed: ${
|
|
3387
|
+
function R(y) {
|
|
3388
|
+
o.log("error", [`setup's cleanup failed: ${N(y)}`]);
|
|
3114
3389
|
}
|
|
3115
|
-
async function
|
|
3390
|
+
async function O() {
|
|
3116
3391
|
const y = i;
|
|
3117
3392
|
if (i = null, y) try {
|
|
3118
|
-
await Promise.race([Promise.resolve(y()), new Promise((
|
|
3119
|
-
} catch (
|
|
3120
|
-
|
|
3393
|
+
await Promise.race([Promise.resolve(y()), new Promise((v) => setTimeout(v, hn))]);
|
|
3394
|
+
} catch (v) {
|
|
3395
|
+
R(v);
|
|
3121
3396
|
}
|
|
3122
|
-
s({ phantom:
|
|
3397
|
+
s({ phantom: B, type: "stopped" });
|
|
3123
3398
|
}
|
|
3124
|
-
return { ctx: c, crash:
|
|
3125
|
-
var
|
|
3126
|
-
n = y, ((
|
|
3399
|
+
return { ctx: c, crash: d, log: (y, v) => o.log(y, v), replaceDefinition(y) {
|
|
3400
|
+
var v;
|
|
3401
|
+
n = y, ((v = x.role) == null ? void 0 : v.kind) !== "logic" && b();
|
|
3127
3402
|
}, stop() {
|
|
3128
|
-
e || (i && (
|
|
3403
|
+
e || (i && (M(i), i = null), e = !0, f(), o.close("The frame was closed"), l.dispose(), ae(null));
|
|
3129
3404
|
} };
|
|
3130
3405
|
}
|
|
3131
|
-
function
|
|
3406
|
+
function it(a) {
|
|
3132
3407
|
return Object.keys(a ?? {});
|
|
3133
3408
|
}
|
|
3134
|
-
function
|
|
3409
|
+
function dn(a) {
|
|
3135
3410
|
return !a || typeof a != "object" ? {} : "default" in a && a.default && typeof a.default == "object" ? a.default : a;
|
|
3136
3411
|
}
|
|
3137
|
-
const
|
|
3138
|
-
const e = a, r = t, n =
|
|
3139
|
-
return (i, s) => (
|
|
3412
|
+
const pn = { class: "flex flex-col p-3", role: "alert" }, fn = { class: "flex flex-col gap-2 overflow-hidden rounded-lg border border-phantom-danger/25 bg-phantom-danger/10 px-3 py-2.5" }, gn = { class: "flex items-start gap-2" }, mn = { class: "min-w-0 flex-1" }, wn = { class: "text-xs font-medium text-phantom-danger" }, yn = { class: "mt-0.5 break-words text-2xs text-phantom-text-soft" }, bn = ["textContent"], vn = { key: 1, class: "text-2xs text-phantom-subtle" }, kn = aa({ __name: "ErrorCard", props: { error: {}, development: { type: Boolean }, kind: {} }, emits: ["dismiss"], setup(a, { emit: t }) {
|
|
3413
|
+
const e = a, r = t, n = ra(() => e.kind === "panel" ? "This panel" : e.kind === "page" ? "This page" : "This plugin");
|
|
3414
|
+
return (i, s) => (ht(), ut("div", pn, [Z("div", fn, [Z("div", gn, [s[1] || (s[1] = Z("span", { class: "mt-1.5 h-1.5 w-1.5 shrink-0 rounded-full bg-phantom-danger", "aria-hidden": "true" }, null, -1)), Z("div", mn, [Z("p", wn, St(n.value) + " stopped with an error", 1), Z("p", yn, St(a.error.message), 1)]), a.development ? (ht(), ut("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 ")) : Qt("", !0)]), a.development && a.error.stack ? (ht(), ut("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: St(a.error.stack) }, null, 8, bn)) : a.development ? Qt("", !0) : (ht(), ut("p", vn, " More is in the plugin's log, in Plugins. "))])]));
|
|
3140
3415
|
} });
|
|
3141
|
-
function
|
|
3416
|
+
function xn(a) {
|
|
3142
3417
|
let t = null, e = null, r = -1;
|
|
3143
3418
|
const n = () => {
|
|
3144
3419
|
const o = Math.ceil(Math.max(a.content.scrollHeight, a.content.getBoundingClientRect().height));
|
|
@@ -3149,70 +3424,70 @@ function _r(a) {
|
|
|
3149
3424
|
e == null || e.unmount(), e = null, a.content.hidden = !1;
|
|
3150
3425
|
}
|
|
3151
3426
|
return { mount(o, l) {
|
|
3152
|
-
s(), t == null || t.unmount(), document.documentElement.dataset.kind =
|
|
3427
|
+
s(), t == null || t.unmount(), document.documentElement.dataset.kind = x.kind ?? "", t = Zt({ name: "PhantomPluginView", render: () => te(o, { ...x.props }) }), t.provide(ha, l), t.config.errorHandler = (c) => a.onError(c), t.mount(a.content);
|
|
3153
3428
|
}, showError(o, l) {
|
|
3154
|
-
e == null || e.unmount(), a.content.hidden = !0, e =
|
|
3429
|
+
e == null || e.unmount(), a.content.hidden = !0, e = Zt({ render: () => te(kn, { error: o, development: l, kind: x.kind, onDismiss: () => s() }) }), e.mount(a.errors), n();
|
|
3155
3430
|
}, unmount() {
|
|
3156
3431
|
i == null || i.disconnect(), t == null || t.unmount(), e == null || e.unmount(), t = null, e = null;
|
|
3157
3432
|
} };
|
|
3158
3433
|
}
|
|
3159
|
-
function
|
|
3160
|
-
window.parent === window &&
|
|
3161
|
-
const t =
|
|
3434
|
+
function Pn(a) {
|
|
3435
|
+
window.parent === window && Mn();
|
|
3436
|
+
const t = je("app"), e = je("phantom-error");
|
|
3162
3437
|
let r = null;
|
|
3163
3438
|
function n(o) {
|
|
3164
3439
|
window.parent.postMessage(o, "*");
|
|
3165
3440
|
}
|
|
3166
|
-
const i =
|
|
3167
|
-
document.documentElement.dataset.kind && n({ phantom:
|
|
3441
|
+
const i = xn({ content: t, errors: e, onError: (o) => r == null ? void 0 : r.crash(o), onResize: (o) => {
|
|
3442
|
+
document.documentElement.dataset.kind && n({ phantom: B, type: "resize", height: o });
|
|
3168
3443
|
} });
|
|
3169
|
-
r =
|
|
3444
|
+
r = un({ post: n, listen(o) {
|
|
3170
3445
|
const l = (c) => {
|
|
3171
3446
|
c.source === window.parent && o(c.data);
|
|
3172
3447
|
};
|
|
3173
3448
|
return window.addEventListener("message", l), () => window.removeEventListener("message", l);
|
|
3174
3449
|
}, root: document.documentElement, view: i, ...a.loadStyles ? { loadStyles: a.loadStyles } : {} }, a);
|
|
3175
3450
|
const s = r;
|
|
3176
|
-
return
|
|
3451
|
+
return Wr(console, (o, l) => s.log(o, l)), window.addEventListener("error", (o) => {
|
|
3177
3452
|
String(o.message).includes("ResizeObserver loop") || s.crash(o.error ?? o.message);
|
|
3178
3453
|
}), window.addEventListener("unhandledrejection", (o) => s.crash(o.reason)), window.addEventListener("pagehide", () => {
|
|
3179
3454
|
i.unmount(), s.stop();
|
|
3180
3455
|
}), document.addEventListener("click", (o) => {
|
|
3181
3456
|
const l = o.target, c = l && typeof l.closest == "function" ? l.closest("a[href]") : null;
|
|
3182
3457
|
if (!c) return;
|
|
3183
|
-
const
|
|
3184
|
-
|
|
3185
|
-
}) : s.log("warn", [`Only https links open from a plugin; this one goes to ${
|
|
3458
|
+
const d = c.getAttribute("href") ?? "";
|
|
3459
|
+
d.startsWith("#") || (o.preventDefault(), /^https:\/\//i.test(d) ? s.ctx.openUrl(d).catch(() => {
|
|
3460
|
+
}) : s.log("warn", [`Only https links open from a plugin; this one goes to ${d}`]));
|
|
3186
3461
|
}), s;
|
|
3187
3462
|
}
|
|
3188
|
-
function
|
|
3463
|
+
function je(a) {
|
|
3189
3464
|
const t = document.getElementById(a);
|
|
3190
3465
|
if (t) return t;
|
|
3191
3466
|
const e = document.createElement("div");
|
|
3192
3467
|
return e.id = a, document.body.append(e), e;
|
|
3193
3468
|
}
|
|
3194
|
-
function
|
|
3469
|
+
function Mn() {
|
|
3195
3470
|
const a = document.createElement("p");
|
|
3196
3471
|
a.className = "m-6 max-w-md text-xs text-phantom-muted", a.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(a);
|
|
3197
3472
|
}
|
|
3198
3473
|
export {
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3474
|
+
on as CALL_TIMEOUT_MS,
|
|
3475
|
+
ha as PLUGIN_CONTEXT,
|
|
3476
|
+
cn as applyTheme,
|
|
3477
|
+
an as createContext,
|
|
3478
|
+
Ur as createFlashTransport,
|
|
3479
|
+
un as createGuest,
|
|
3480
|
+
Vr as createPluginFlash,
|
|
3481
|
+
$e as createPluginSide,
|
|
3482
|
+
ln as createPort,
|
|
3483
|
+
Jr as createRemoteSdk,
|
|
3484
|
+
$n as currentContext,
|
|
3485
|
+
N as describe,
|
|
3486
|
+
Wr as forwardConsole,
|
|
3487
|
+
x as frame,
|
|
3488
|
+
We as fromWireError,
|
|
3489
|
+
nn as hasScope,
|
|
3490
|
+
Pn as startGuest,
|
|
3491
|
+
ot as toPlain,
|
|
3492
|
+
yt as toWireError
|
|
3218
3493
|
};
|