@holtjs/stage 0.0.0-stage → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,567 @@
1
+ // src/surfaces.ts
2
+ const SURFACE_BAND = {
3
+ /** Base world / canvas input (movement, interaction, camera zoom). */
4
+ world: 100,
5
+ /** Passive non-blocking HUD cards & contextual hints. */
6
+ hud: 200,
7
+ /** Active workspaces, docked editors & fullscreen modes. */
8
+ workspace: 400,
9
+ /** Guided coach-mark tours (map-scoped or global). */
10
+ tour: 500,
11
+ /** Blocking dialogs, modals, drawers & floating windows. */
12
+ modal: 600,
13
+ /** Non-modal floating popovers, panels & sheets. */
14
+ popover: 700,
15
+ /** Transient menus, dropdowns, select lists & inline pickers. */
16
+ menu: 800,
17
+ /** Blocking confirmation dialogs & critical alerts. */
18
+ confirm: 900,
19
+ /** Full-screen opaque loading, transition & connection-failure covers. */
20
+ cover: 950,
21
+ /** Raw key capture (e.g. keybinding recorder). */
22
+ capture: 1e3
23
+ };
24
+ function resolveSurfacePriority(band) {
25
+ if (typeof band === "number") return Number.isFinite(band) ? band : SURFACE_BAND.modal;
26
+ return SURFACE_BAND[band] ?? SURFACE_BAND.modal;
27
+ }
28
+ /**
29
+ * Canonical pure mapping from `SURFACE_BAND` priority to base root-DOM `z-index`.
30
+ * Allocates strictly disjoint z-index ranges across bands so DOM companions and overlays
31
+ * never interleave across semantic priority boundaries.
32
+ */
33
+ function surfacePriorityToDomZ(priority) {
34
+ if (priority < SURFACE_BAND.hud) return 10;
35
+ if (priority < SURFACE_BAND.workspace) return 20;
36
+ if (priority < SURFACE_BAND.tour) {
37
+ if (priority < SURFACE_BAND.workspace + 10) return 40 + (priority - SURFACE_BAND.workspace);
38
+ if (priority < SURFACE_BAND.workspace + 50) return 50;
39
+ if (priority < SURFACE_BAND.workspace + 60) return 59;
40
+ if (priority < SURFACE_BAND.workspace + 70) return 60;
41
+ return 62;
42
+ }
43
+ if (priority < SURFACE_BAND.modal) return 72;
44
+ if (priority < SURFACE_BAND.popover) {
45
+ const off = priority - SURFACE_BAND.modal;
46
+ if (off <= 0) return 78;
47
+ if (off === 1) return 80;
48
+ if (off === 2) return 82;
49
+ if (off === 3) return 85;
50
+ if (off < 10) return 90;
51
+ return 100;
52
+ }
53
+ if (priority < SURFACE_BAND.confirm) return 200;
54
+ if (priority < SURFACE_BAND.cover) return 250;
55
+ return 2e3;
56
+ }
57
+ function domZBucketCap(priority) {
58
+ if (priority < SURFACE_BAND.hud) return 14;
59
+ if (priority < SURFACE_BAND.workspace) return 24;
60
+ if (priority < SURFACE_BAND.workspace + 10) return 49;
61
+ if (priority < SURFACE_BAND.workspace + 50) return 50;
62
+ if (priority < SURFACE_BAND.tour) return 69;
63
+ if (priority < SURFACE_BAND.modal) return 77;
64
+ if (priority < SURFACE_BAND.popover) {
65
+ const off = priority - SURFACE_BAND.modal;
66
+ if (off <= 3) return 87;
67
+ if (off < 10) return 94;
68
+ return 199;
69
+ }
70
+ if (priority < SURFACE_BAND.confirm) return 249;
71
+ if (priority < SURFACE_BAND.cover) return 295;
72
+ return 2099;
73
+ }
74
+ /**
75
+ * Compute strictly monotonic root-DOM `z-index` assignments for active surfaces from their
76
+ * `(priority, seq)` order (ascending = back to front). Ties within the same band advance
77
+ * by the previous surface's `span` (clamped within `[base, cap]` so cross-band monotonicity holds).
78
+ */
79
+ function computeSurfaceDomZ(entries) {
80
+ const out = /* @__PURE__ */ new Map();
81
+ if (!entries.length) return out;
82
+ const sorted = [...entries].sort((a, b) => {
83
+ if (a.priority !== b.priority) return a.priority - b.priority;
84
+ if (a.seq !== b.seq) return a.seq - b.seq;
85
+ return a.id < b.id ? -1 : a.id > b.id ? 1 : 0;
86
+ });
87
+ let prevEnd = -1e400;
88
+ let prevCap = -1e400;
89
+ for (let i = 0; i < sorted.length; i++) {
90
+ const item = sorted[i];
91
+ const span = Math.max(1, Math.floor(item.span ?? 1));
92
+ const base = surfacePriorityToDomZ(item.priority);
93
+ const cap = domZBucketCap(item.priority);
94
+ const candidate = cap === prevCap ? Math.max(base, prevEnd) : base;
95
+ const maxStart = Math.max(base, cap - (span - 1));
96
+ const z = Math.min(maxStart, candidate);
97
+ out.set(item.id, z);
98
+ prevEnd = z + span;
99
+ prevCap = cap;
100
+ }
101
+ return out;
102
+ }
103
+ function compareDesc(a, b) {
104
+ if (a.priority !== b.priority) return b.priority - a.priority;
105
+ return b.seq - a.seq;
106
+ }
107
+ function createSurfaceTree(opts) {
108
+ const nodes = /* @__PURE__ */ new Map();
109
+ const listeners = /* @__PURE__ */ new Set();
110
+ const evaluating = /* @__PURE__ */ new Set();
111
+ const evaluatingBarrier = /* @__PURE__ */ new Set();
112
+ let nextSeq = 1;
113
+ let nextAutoId = 1;
114
+ let nextToken = 1;
115
+ function notify() {
116
+ if (!listeners.size) return;
117
+ for (const fn of [...listeners]) try {
118
+ fn();
119
+ } catch (err) {
120
+ opts?.onError?.("subscribe", err);
121
+ }
122
+ }
123
+ function resolveBarrier(entry) {
124
+ if (typeof entry.barrier !== "function") return entry.barrier;
125
+ if (evaluatingBarrier.has(entry.id)) return "none";
126
+ evaluatingBarrier.add(entry.id);
127
+ try {
128
+ const b = entry.barrier();
129
+ return b === "modal" || b === "fullscreen" ? b : "none";
130
+ } catch (err) {
131
+ opts?.onError?.(entry.id, err);
132
+ return "none";
133
+ } finally {
134
+ evaluatingBarrier.delete(entry.id);
135
+ }
136
+ }
137
+ function isOwnAndParentEnabled(entry) {
138
+ if (evaluating.has(entry.id)) return false;
139
+ evaluating.add(entry.id);
140
+ try {
141
+ if (entry.parent) {
142
+ const p = nodes.get(entry.parent);
143
+ if (!p || !isOwnAndParentEnabled(p)) return false;
144
+ }
145
+ if (entry.enabled) try {
146
+ if (!entry.enabled()) return false;
147
+ } catch (err) {
148
+ opts?.onError?.(entry.id, err);
149
+ return false;
150
+ }
151
+ return true;
152
+ } finally {
153
+ evaluating.delete(entry.id);
154
+ }
155
+ }
156
+ function hasMapScopeInChain(entry) {
157
+ const seen = /* @__PURE__ */ new Set();
158
+ let cur = entry;
159
+ while (cur && !seen.has(cur.id)) {
160
+ if (cur.scope === "map") return true;
161
+ seen.add(cur.id);
162
+ cur = cur.parent ? nodes.get(cur.parent) : void 0;
163
+ }
164
+ return false;
165
+ }
166
+ function hasActiveGlobalFullscreen() {
167
+ for (const entry of nodes.values()) {
168
+ if (entry.scope !== "global") continue;
169
+ if (resolveBarrier(entry) !== "fullscreen") continue;
170
+ if (hasMapScopeInChain(entry)) continue;
171
+ if (isOwnAndParentEnabled(entry)) return true;
172
+ }
173
+ return false;
174
+ }
175
+ function getGlobalFullscreen(cache) {
176
+ if (cache.value === null) cache.value = hasActiveGlobalFullscreen();
177
+ return cache.value;
178
+ }
179
+ function isEntryActive(entry, globalFsCache) {
180
+ if (evaluating.has(entry.id)) return false;
181
+ evaluating.add(entry.id);
182
+ try {
183
+ if (entry.parent) {
184
+ const p = nodes.get(entry.parent);
185
+ if (!p || !isEntryActive(p, globalFsCache)) return false;
186
+ }
187
+ if (entry.enabled) try {
188
+ if (!entry.enabled()) return false;
189
+ } catch (err) {
190
+ opts?.onError?.(entry.id, err);
191
+ return false;
192
+ }
193
+ if (entry.scope === "map") {
194
+ if (globalFsCache) {
195
+ if (globalFsCache.value === null) globalFsCache.value = hasActiveGlobalFullscreen();
196
+ if (globalFsCache.value) return false;
197
+ } else if (hasActiveGlobalFullscreen()) return false;
198
+ }
199
+ return true;
200
+ } finally {
201
+ evaluating.delete(entry.id);
202
+ }
203
+ }
204
+ function isAbove(candidate, ref) {
205
+ if (candidate.priority !== ref.priority) return candidate.priority > ref.priority;
206
+ return candidate.seq > ref.seq;
207
+ }
208
+ function sortedSnapshot() {
209
+ return [...nodes.values()].sort(compareDesc);
210
+ }
211
+ function toInfo(entry, barrier) {
212
+ return {
213
+ id: entry.id,
214
+ priority: entry.priority,
215
+ seq: entry.seq,
216
+ scope: entry.scope,
217
+ barrier: barrier ?? resolveBarrier(entry),
218
+ parent: entry.parent
219
+ };
220
+ }
221
+ return {
222
+ register(input) {
223
+ const id = input.id && input.id.length > 0 ? input.id : `surf#${nextAutoId++}`;
224
+ const priority = resolveSurfacePriority(input.band);
225
+ const token = nextToken++;
226
+ const entry = {
227
+ id,
228
+ token,
229
+ priority,
230
+ seq: nextSeq++,
231
+ scope: input.scope ?? "global",
232
+ parent: input.parent ?? null,
233
+ barrier: input.barrier ?? "none",
234
+ enabled: input.enabled,
235
+ onCancel: input.onCancel,
236
+ onKey: input.onKey,
237
+ onFocusCycle: input.onFocusCycle,
238
+ allowCancelInEditable: input.allowCancelInEditable ?? priority >= SURFACE_BAND.menu,
239
+ allowCancelModifiers: input.allowCancelModifiers ?? false,
240
+ allowKeyInEditable: input.allowKeyInEditable ?? false,
241
+ passthroughKey: input.passthroughKey
242
+ };
243
+ nodes.set(id, entry);
244
+ notify();
245
+ return () => {
246
+ const cur = nodes.get(id);
247
+ if (cur && cur.token === token) {
248
+ nodes.delete(id);
249
+ notify();
250
+ }
251
+ };
252
+ },
253
+ unregister(id) {
254
+ const existed = nodes.delete(id);
255
+ if (existed) notify();
256
+ return existed;
257
+ },
258
+ raise(id) {
259
+ const cur = nodes.get(id);
260
+ if (!cur) return false;
261
+ cur.seq = nextSeq++;
262
+ notify();
263
+ return true;
264
+ },
265
+ has(id) {
266
+ return nodes.has(id);
267
+ },
268
+ isActive(id) {
269
+ const cur = nodes.get(id);
270
+ return cur ? isEntryActive(cur) : false;
271
+ },
272
+ entries() {
273
+ return sortedSnapshot().map((entry) => toInfo(entry));
274
+ },
275
+ active() {
276
+ const list = sortedSnapshot();
277
+ const gfs = { value: null };
278
+ const out = [];
279
+ for (let i = 0; i < list.length; i++) {
280
+ const entry = list[i];
281
+ if (isEntryActive(entry, gfs)) out.push(toInfo(entry));
282
+ }
283
+ return out;
284
+ },
285
+ topBarrier(filter) {
286
+ const list = sortedSnapshot();
287
+ const gfs = { value: null };
288
+ for (let i = 0; i < list.length; i++) {
289
+ const entry = list[i];
290
+ if (filter?.scope && entry.scope !== filter.scope) continue;
291
+ const b = resolveBarrier(entry);
292
+ if (filter?.fullscreenOnly ? b !== "fullscreen" : b === "none") continue;
293
+ if (!isEntryActive(entry, gfs)) continue;
294
+ return toInfo(entry, b);
295
+ }
296
+ return null;
297
+ },
298
+ isBlocked(id) {
299
+ const ref = nodes.get(id);
300
+ const gfs = { value: null };
301
+ if (!ref) {
302
+ for (const entry of nodes.values()) {
303
+ if (resolveBarrier(entry) === "none") continue;
304
+ if (isEntryActive(entry, gfs)) return true;
305
+ }
306
+ return false;
307
+ }
308
+ if (ref.scope === "map" && getGlobalFullscreen(gfs)) return true;
309
+ for (const entry of nodes.values()) {
310
+ if (entry.id === ref.id) continue;
311
+ if (!isAbove(entry, ref)) continue;
312
+ if (resolveBarrier(entry) === "none") continue;
313
+ if (isEntryActive(entry, gfs)) return true;
314
+ }
315
+ return false;
316
+ },
317
+ isOccluded(id) {
318
+ const gfs = { value: null };
319
+ const ref = id ? nodes.get(id) : void 0;
320
+ if (!ref) {
321
+ for (const entry of nodes.values()) {
322
+ if (resolveBarrier(entry) !== "fullscreen") continue;
323
+ if (isEntryActive(entry, gfs)) return true;
324
+ }
325
+ return false;
326
+ }
327
+ if (ref.scope === "map" && getGlobalFullscreen(gfs)) return true;
328
+ for (const entry of nodes.values()) {
329
+ if (entry.id === ref.id) continue;
330
+ if (!isAbove(entry, ref)) continue;
331
+ if (resolveBarrier(entry) !== "fullscreen") continue;
332
+ if (isEntryActive(entry, gfs)) return true;
333
+ }
334
+ return false;
335
+ },
336
+ isWorldBlocked() {
337
+ const gfs = { value: null };
338
+ for (const entry of nodes.values()) {
339
+ if (entry.priority <= SURFACE_BAND.world) continue;
340
+ if (resolveBarrier(entry) === "none") continue;
341
+ if (isEntryActive(entry, gfs)) return true;
342
+ }
343
+ return false;
344
+ },
345
+ hasHigherSurface(id, query) {
346
+ const ref = nodes.get(id);
347
+ if (!ref) return false;
348
+ const minPrio = query?.minBand !== void 0 ? resolveSurfacePriority(query.minBand) : -1e400;
349
+ const gfs = { value: null };
350
+ for (const entry of nodes.values()) {
351
+ if (entry.id === ref.id) continue;
352
+ if (entry.priority < minPrio) continue;
353
+ const barrier = resolveBarrier(entry);
354
+ if (query?.barriersOnly && barrier === "none") continue;
355
+ if (!(ref.scope === "map" && entry.scope === "global" && barrier === "fullscreen") && !isAbove(entry, ref)) continue;
356
+ if (isEntryActive(entry, gfs)) return true;
357
+ }
358
+ return false;
359
+ },
360
+ hasEligibleCancel(ctx) {
361
+ const list = sortedSnapshot();
362
+ const gfs = { value: null };
363
+ for (let i = 0; i < list.length; i++) {
364
+ const candidate = list[i];
365
+ const live = nodes.get(candidate.id);
366
+ if (!live || live.token !== candidate.token) continue;
367
+ if (!isEntryActive(live, gfs)) continue;
368
+ const barrier = resolveBarrier(live);
369
+ if (!live.onCancel && barrier === "none") continue;
370
+ if (ctx.hasModifier && !live.allowCancelModifiers) {
371
+ if (barrier !== "none") return false;
372
+ continue;
373
+ }
374
+ if (ctx.inEditable && !live.allowCancelInEditable) return false;
375
+ if (live.onCancel) return true;
376
+ if (barrier !== "none") return false;
377
+ }
378
+ return false;
379
+ },
380
+ dispatchCancel(ctx) {
381
+ if (ctx.repeat) return {
382
+ handled: false,
383
+ id: null,
384
+ blockedBy: null
385
+ };
386
+ const list = sortedSnapshot();
387
+ for (let i = 0; i < list.length; i++) {
388
+ const candidate = list[i];
389
+ const live = nodes.get(candidate.id);
390
+ if (!live || live.token !== candidate.token) continue;
391
+ if (!isEntryActive(live)) continue;
392
+ const barrier = resolveBarrier(live);
393
+ if (!live.onCancel && barrier === "none") continue;
394
+ if (ctx.hasModifier && !live.allowCancelModifiers) {
395
+ if (barrier !== "none") return {
396
+ handled: false,
397
+ id: null,
398
+ blockedBy: live.id
399
+ };
400
+ continue;
401
+ }
402
+ if (ctx.inEditable && !live.allowCancelInEditable) return {
403
+ handled: false,
404
+ id: null,
405
+ blockedBy: live.id
406
+ };
407
+ if (live.onCancel) try {
408
+ const result = live.onCancel(ctx);
409
+ if (result === "yield") return {
410
+ handled: false,
411
+ id: null,
412
+ blockedBy: live.id
413
+ };
414
+ if (result !== false) return {
415
+ handled: true,
416
+ id: live.id,
417
+ blockedBy: null
418
+ };
419
+ } catch (err) {
420
+ opts?.onError?.(live.id, err);
421
+ return {
422
+ handled: true,
423
+ id: live.id,
424
+ blockedBy: null
425
+ };
426
+ }
427
+ if (barrier !== "none") return {
428
+ handled: false,
429
+ id: null,
430
+ blockedBy: live.id
431
+ };
432
+ }
433
+ return {
434
+ handled: false,
435
+ id: null,
436
+ blockedBy: null
437
+ };
438
+ },
439
+ dispatchKey(ctx) {
440
+ const list = sortedSnapshot();
441
+ for (let i = 0; i < list.length; i++) {
442
+ const candidate = list[i];
443
+ const live = nodes.get(candidate.id);
444
+ if (!live || live.token !== candidate.token) continue;
445
+ if (!isEntryActive(live)) continue;
446
+ const barrier = resolveBarrier(live);
447
+ let allowPass = false;
448
+ if (barrier !== "none" && !ctx.inEditable && ctx.event && live.passthroughKey) try {
449
+ allowPass = Boolean(live.passthroughKey(ctx.event));
450
+ } catch (err) {
451
+ opts?.onError?.(live.id, err);
452
+ allowPass = false;
453
+ }
454
+ if (live.onKey && !allowPass) {
455
+ if (ctx.inEditable && !live.allowKeyInEditable) {
456
+ if (barrier !== "none") return {
457
+ handled: false,
458
+ preventDefault: false,
459
+ id: null,
460
+ blockedBy: live.id
461
+ };
462
+ continue;
463
+ }
464
+ try {
465
+ const result = live.onKey(ctx);
466
+ if (result === "yield") return {
467
+ handled: false,
468
+ preventDefault: false,
469
+ id: null,
470
+ blockedBy: live.id
471
+ };
472
+ if (result === "stop") return {
473
+ handled: true,
474
+ preventDefault: false,
475
+ id: live.id,
476
+ blockedBy: null
477
+ };
478
+ if (result !== false) return {
479
+ handled: true,
480
+ preventDefault: true,
481
+ id: live.id,
482
+ blockedBy: null
483
+ };
484
+ } catch (err) {
485
+ opts?.onError?.(live.id, err);
486
+ return {
487
+ handled: true,
488
+ preventDefault: true,
489
+ id: live.id,
490
+ blockedBy: null
491
+ };
492
+ }
493
+ }
494
+ if (barrier !== "none" && !allowPass) return {
495
+ handled: false,
496
+ preventDefault: false,
497
+ id: null,
498
+ blockedBy: live.id
499
+ };
500
+ }
501
+ return {
502
+ handled: false,
503
+ preventDefault: false,
504
+ id: null,
505
+ blockedBy: null
506
+ };
507
+ },
508
+ dispatchFocus(ctx) {
509
+ if (ctx.hasModifier) return {
510
+ handled: false,
511
+ id: null,
512
+ blockedBy: null
513
+ };
514
+ const list = sortedSnapshot();
515
+ for (let i = 0; i < list.length; i++) {
516
+ const candidate = list[i];
517
+ const live = nodes.get(candidate.id);
518
+ if (!live || live.token !== candidate.token) continue;
519
+ if (!isEntryActive(live)) continue;
520
+ const barrier = resolveBarrier(live);
521
+ if (!live.onFocusCycle && barrier === "none") continue;
522
+ if (live.onFocusCycle) try {
523
+ const result = live.onFocusCycle(ctx);
524
+ if (result === "yield") return {
525
+ handled: false,
526
+ id: null,
527
+ blockedBy: live.id
528
+ };
529
+ if (result !== false) return {
530
+ handled: true,
531
+ id: live.id,
532
+ blockedBy: null
533
+ };
534
+ } catch (err) {
535
+ opts?.onError?.(live.id, err);
536
+ return {
537
+ handled: true,
538
+ id: live.id,
539
+ blockedBy: null
540
+ };
541
+ }
542
+ if (barrier !== "none") return {
543
+ handled: false,
544
+ id: null,
545
+ blockedBy: live.id
546
+ };
547
+ }
548
+ return {
549
+ handled: false,
550
+ id: null,
551
+ blockedBy: null
552
+ };
553
+ },
554
+ subscribe(fn) {
555
+ listeners.add(fn);
556
+ return () => {
557
+ listeners.delete(fn);
558
+ };
559
+ },
560
+ clear() {
561
+ if (!nodes.size) return;
562
+ nodes.clear();
563
+ notify();
564
+ }
565
+ };
566
+ }
567
+ export { SURFACE_BAND, computeSurfaceDomZ, createSurfaceTree, resolveSurfacePriority, surfacePriorityToDomZ };
@@ -0,0 +1,143 @@
1
+ import { n as EngineClockSnapshot, p as SceneLifecycleStats, u as Scene } from "./game-NqFMKsuL.js";
2
+ import { u as TweenStats } from "./tween-D3Ztppuz.js";
3
+ export interface SceneDigestNode {
4
+ trackId: string | null;
5
+ role: string | null;
6
+ alt: string | null;
7
+ surface: string | null;
8
+ type: string;
9
+ visible: boolean;
10
+ enabled: boolean;
11
+ zIndex: number;
12
+ depth: number;
13
+ alpha: number;
14
+ bounds: [number, number, number, number];
15
+ }
16
+ export interface SceneDigestOverlayStats {
17
+ popovers: number;
18
+ dropdowns: number;
19
+ tooltipVisible: boolean;
20
+ toasts: number;
21
+ queuedToasts: number;
22
+ }
23
+ export interface SceneDigestSurfaceEntry {
24
+ id: string;
25
+ priority: number;
26
+ seq: number;
27
+ scope: string;
28
+ barrier: string;
29
+ parent: string | null;
30
+ }
31
+ export interface SceneDigestActiveFocus {
32
+ tag: string;
33
+ ui: string | null;
34
+ role: string | null;
35
+ }
36
+ export interface SceneDigestSurfaces {
37
+ active: SceneDigestSurfaceEntry[];
38
+ topBarrier: SceneDigestSurfaceEntry | null;
39
+ worldBlocked: boolean;
40
+ domZ: Record<string, number> | null;
41
+ activeFocus: SceneDigestActiveFocus | null;
42
+ }
43
+ export interface SceneDigestEngineSandbox {
44
+ modId: string;
45
+ ready: boolean;
46
+ uptimeMs: number;
47
+ renderer: string | null;
48
+ apps: number;
49
+ frames: number;
50
+ longFrames: number;
51
+ drawCalls: number;
52
+ texBinds: number;
53
+ errors: number;
54
+ violations: number;
55
+ lastHeartbeatMs: number | null;
56
+ }
57
+ export interface SceneDigestSandbox {
58
+ engine: SceneDigestEngineSandbox | null;
59
+ mountedWorkers: number;
60
+ }
61
+ export interface SceneDigest {
62
+ clock: EngineClockSnapshot | null;
63
+ traceId: string | null;
64
+ viewport: {
65
+ w: number;
66
+ h: number;
67
+ dpr: number;
68
+ };
69
+ renderer: {
70
+ type: string;
71
+ drawCalls?: number;
72
+ flushes?: number;
73
+ tris?: number;
74
+ culled?: number;
75
+ texBinds?: number;
76
+ sdfPanels?: number;
77
+ sdfDraws?: number;
78
+ msdfIcons?: number;
79
+ msdfDraws?: number;
80
+ pixelAaIcons?: number;
81
+ pixelAaDraws?: number;
82
+ };
83
+ lifecycle: SceneLifecycleStats | null;
84
+ tweens: TweenStats | null;
85
+ overlays: SceneDigestOverlayStats | null;
86
+ surfaces: SceneDigestSurfaces | null;
87
+ sandbox: SceneDigestSandbox | null;
88
+ displayListCount: number;
89
+ uiCount: number;
90
+ truncated: boolean;
91
+ nodes: SceneDigestNode[];
92
+ }
93
+ export interface SceneDigestSurfaceSource {
94
+ active?: () => ReadonlyArray<{
95
+ id: string;
96
+ priority: number;
97
+ seq: number;
98
+ scope: string;
99
+ barrier: string;
100
+ parent: string | null;
101
+ }>;
102
+ topBarrier?: () => {
103
+ id: string;
104
+ priority: number;
105
+ seq: number;
106
+ scope: string;
107
+ barrier: string;
108
+ parent: string | null;
109
+ } | null;
110
+ isWorldBlocked?: () => boolean;
111
+ domZ?: () => Record<string, number>;
112
+ activeFocus?: () => SceneDigestActiveFocus | null;
113
+ }
114
+ export interface SceneDigestOptions {
115
+ ui?: {
116
+ view?: {
117
+ w: number;
118
+ h: number;
119
+ };
120
+ dpr?: number;
121
+ registry?: {
122
+ api?: {
123
+ list?: () => Array<Record<string, any>>;
124
+ };
125
+ };
126
+ __overlays?: {
127
+ stats?: () => SceneDigestOverlayStats;
128
+ } | null;
129
+ } | null;
130
+ surfaces?: SceneDigestSurfaceSource | null;
131
+ sandbox?: SceneDigestSandbox | (() => SceneDigestSandbox | null) | null;
132
+ traceId?: string | null;
133
+ dpr?: number;
134
+ maxNodes?: number;
135
+ }
136
+ /** Sanitize a privacy-safe semantic identifier (`trackId`, `role`, `surface`). Returns null if invalid or empty. */
137
+ export declare function sanitizeTrackToken(raw: unknown, maxLen?: number): string | null;
138
+ /**
139
+ * Build a privacy-safe structural snapshot of a Stage2D scene and optional UiRoot.
140
+ * Never reads arbitrary `TextObject.text` or user-typed strings; only emits sanitized `trackId`/`role`/`surface`
141
+ * tokens and explicitly declared semantic `alt` labels.
142
+ */
143
+ export declare function buildSceneDigest(scene: Scene, opts?: SceneDigestOptions): SceneDigest;