@holtjs/stage 0.10.3 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/ecs.d.ts CHANGED
@@ -18,11 +18,62 @@ export type ComponentSchema = Record<string, ComponentFieldType>;
18
18
  export type ComponentColumns<S extends ComponentSchema> = { [K in keyof S]: ComponentArrayMap[S[K]]; };
19
19
  /** Optional initial values object passed to `world.add(entity, def, init)`. */
20
20
  export type ComponentInit<S extends ComponentSchema> = { [K in keyof S]?: number; };
21
- /** Immutable component definition created by `defineComponent()`. */
22
- export interface ComponentDef<S extends ComponentSchema = ComponentSchema> {
23
- readonly name: string;
21
+ /** Immutable component definition created by `defineComponent()` or `defineTag()`. */
22
+ export interface ComponentDef<S extends ComponentSchema = ComponentSchema, N extends string = string> {
23
+ readonly name: N;
24
24
  readonly schema: Readonly<S>;
25
25
  readonly fields: readonly (keyof S & string)[];
26
+ readonly isTag?: boolean;
27
+ }
28
+ /** Zero-byte boolean tag component definition created by `defineTag()` (occupies 1 bit in `masks`, 0 column bytes). */
29
+ export type TagDef<N extends string = string> = ComponentDef<Record<never, never>, N> & {
30
+ readonly isTag: true;
31
+ };
32
+ /** Immutable per-frame SoA event schema definition created by `defineEvent()`. */
33
+ export interface EventDef<S extends ComponentSchema = ComponentSchema, N extends string = string> {
34
+ readonly name: N;
35
+ readonly schema: Readonly<S>;
36
+ readonly fields: readonly (keyof S & string)[];
37
+ }
38
+ /** Stateless SoA per-frame event table (`world.events(def)`), cleared via `table.clear()` or `world.clearEvents()`. */
39
+ export interface EventTable<S extends ComponentSchema = ComponentSchema> {
40
+ readonly def: EventDef<S>;
41
+ readonly columns: ComponentColumns<S>;
42
+ readonly count: number;
43
+ readonly capacity: number;
44
+ /** Append an event row and return its dense index (`0 .. count - 1`). */
45
+ emit(init?: ComponentInit<S>): number;
46
+ /** Claim a zeroed row index (`0 .. count - 1`) for zero-object-allocation direct column writes. */
47
+ pushSlot(): number;
48
+ /** Iterate over `0 .. count - 1` emitted events in FIFO order. */
49
+ each(fn: (index: number, columns: ComponentColumns<S>) => void): void;
50
+ /** Reset `count = 0` in O(1) without freeing underlying TypedArray buffers. */
51
+ clear(): void;
52
+ }
53
+ /** Declarative `luaecs`-style relational query descriptor (`world.select(...)` / `world.query({...})`). */
54
+ export interface RelationalQuerySpec<R extends readonly ComponentDef<any, any>[] = readonly [], W extends readonly ComponentDef<any, any>[] = readonly []> {
55
+ readonly read?: R;
56
+ readonly write?: W;
57
+ readonly with?: readonly ComponentDef<any, any>[];
58
+ readonly without?: readonly ComponentDef<any, any>[];
59
+ }
60
+ /** Named column map inferred from `read` + `write` component lists (`{ Pos: ..., Vel: ... }`). */
61
+ export type RelationalQueryColumns<R extends readonly ComponentDef<any, any>[], W extends readonly ComponentDef<any, any>[]> = { readonly [D in R[number] | W[number] as D['name']]: D extends ComponentDef<infer S, any> ? ComponentColumns<S> : never; };
62
+ /** Compiled zero-GC relational query handle over `SoaWorld`. */
63
+ export interface RelationalQuery<R extends readonly ComponentDef<any, any>[] = readonly [], W extends readonly ComponentDef<any, any>[] = readonly []> {
64
+ readonly includeMask: number;
65
+ readonly excludeMask: number;
66
+ readonly columns: RelationalQueryColumns<R, W>;
67
+ /** Count currently matching live entities in O(world.count) bitwise scan. */
68
+ count(): number;
69
+ /** Iterate matching `(slot, entity, columns)` tuples with zero heap allocations. */
70
+ each(fn: (slot: number, entity: EntityId, columns: RelationalQueryColumns<R, W>) => void): void;
71
+ /** Write matching dense slot indices into an internal (or caller-provided) `Int32Array` cursor for tight SIMD loops. */
72
+ collectSlots(outSlots?: Int32Array): {
73
+ readonly slots: Int32Array;
74
+ readonly count: number;
75
+ readonly columns: RelationalQueryColumns<R, W>;
76
+ };
26
77
  }
27
78
  /** Opaque generational entity handle (20-bit handle index + 11-bit generation in a positive 31-bit SMI). */
28
79
  export type EntityId = number;
@@ -62,7 +113,25 @@ export declare function entityGeneration(entity: EntityId): number;
62
113
  * const Velocity = defineComponent('Velocity', { vx: 'f32', vy: 'f32' });
63
114
  * ```
64
115
  */
65
- export declare function defineComponent<const S extends ComponentSchema>(name: string, schema: S): ComponentDef<S>;
116
+ export declare function defineComponent<const N extends string, const S extends ComponentSchema>(name: N, schema: S): ComponentDef<S, N>;
117
+ /**
118
+ * Define a zero-byte boolean tag component (`0` column arrays allocated; `1` bit in `world.masks`).
119
+ *
120
+ * ```ts
121
+ * const Burning = defineTag('Burning');
122
+ * const Frozen = defineTag('Frozen');
123
+ * world.add(mob, Burning);
124
+ * ```
125
+ */
126
+ export declare function defineTag<const N extends string>(name: N): TagDef<N>;
127
+ /**
128
+ * Define a typed Structure-of-Arrays per-frame event table schema for stateless inter-system communication.
129
+ *
130
+ * ```ts
131
+ * const DamageEvent = defineEvent('Damage', { target: 'u32', amount: 'f32', knockX: 'f32', knockY: 'f32' });
132
+ * ```
133
+ */
134
+ export declare function defineEvent<const N extends string, const S extends ComponentSchema>(name: N, schema: S): EventDef<S, N>;
66
135
  /**
67
136
  * Dense-packed, zero-GC Structure-of-Arrays (SoA) ECS world.
68
137
  *
@@ -87,6 +156,8 @@ export declare class SoaWorld {
87
156
  private handleGen;
88
157
  private stores;
89
158
  private defToStore;
159
+ private eventTables;
160
+ private eventTableList;
90
161
  /** Optional uniform CSR spatial hash grid synced over dense slots `0 .. count - 1`. */
91
162
  grid: SpatialHashGrid | null;
92
163
  private gridOriginX;
@@ -127,11 +198,21 @@ export declare class SoaWorld {
127
198
  remove(entity: EntityId, def: ComponentDef<any>): boolean;
128
199
  /** Returns true iff `entity` is alive and currently holds component `def`. */
129
200
  has(entity: EntityId, def: ComponentDef<any>): boolean;
201
+ /** Access (or lazily create) the per-frame `EventTable` for `def`. */
202
+ events<S extends ComponentSchema>(def: EventDef<S, any>): EventTable<S>;
203
+ /** Clear all per-frame `EventTable`s in O(numEventTables) at the end of a simulation tick (zero GC). */
204
+ clearEvents(): void;
205
+ /**
206
+ * Compile a declarative `luaecs`-style relational query (`read`, `write`, `with`, `without`).
207
+ *Note: column references stay live even when `SoaWorld` grows capacity!
208
+ */
209
+ select<const R extends readonly ComponentDef<any, any>[] = readonly [], const W extends readonly ComponentDef<any, any>[] = readonly []>(spec: RelationalQuerySpec<R, W>): RelationalQuery<R, W>;
130
210
  /**
131
- * Populate `outSlots` with dense slot indices matching `includeMask` (and excluding `excludeMask`).
132
- * Returns the number of matching slots written (zero allocations).
211
+ * Populate `outSlots` with dense slot indices matching `includeMask` (and excluding `excludeMask`),
212
+ * OR compile a declarative relational `RelationalQuery` when passed a `{ read, write, with, without }` spec.
133
213
  */
134
214
  query(includeMask: number, outSlots: Int32Array, excludeMask?: number): number;
215
+ query<const R extends readonly ComponentDef<any, any>[] = readonly [], const W extends readonly ComponentDef<any, any>[] = readonly []>(spec: RelationalQuerySpec<R, W>): RelationalQuery<R, W>;
135
216
  /** Zero-GC callback iteration over dense slots matching `includeMask` (and excluding `excludeMask`). */
136
217
  forEach(includeMask: number, fn: (slot: number, entity: EntityId) => void, excludeMask?: number): void;
137
218
  /**
package/dist/ecs.js CHANGED
@@ -67,6 +67,93 @@ function defineComponent(name, schema) {
67
67
  });
68
68
  }
69
69
  /**
70
+ * Define a zero-byte boolean tag component (`0` column arrays allocated; `1` bit in `world.masks`).
71
+ *
72
+ * ```ts
73
+ * const Burning = defineTag('Burning');
74
+ * const Frozen = defineTag('Frozen');
75
+ * world.add(mob, Burning);
76
+ * ```
77
+ */
78
+ function defineTag(name) {
79
+ return Object.freeze({
80
+ name,
81
+ schema: Object.freeze({}),
82
+ fields: Object.freeze([]),
83
+ isTag: true
84
+ });
85
+ }
86
+ /**
87
+ * Define a typed Structure-of-Arrays per-frame event table schema for stateless inter-system communication.
88
+ *
89
+ * ```ts
90
+ * const DamageEvent = defineEvent('Damage', { target: 'u32', amount: 'f32', knockX: 'f32', knockY: 'f32' });
91
+ * ```
92
+ */
93
+ function defineEvent(name, schema) {
94
+ const fields = Object.freeze(Object.keys(schema));
95
+ return Object.freeze({
96
+ name,
97
+ schema: Object.freeze({ ...schema }),
98
+ fields
99
+ });
100
+ }
101
+ var DenseEventTable = class {
102
+ def;
103
+ columns;
104
+ count = 0;
105
+ capacity;
106
+ rawCols = {};
107
+ constructor(def, initialCapacity = 64) {
108
+ this.def = def;
109
+ const cap = nextPow2(Math.max(16, initialCapacity | 0));
110
+ this.capacity = cap;
111
+ for (let i = 0; i < def.fields.length; i++) {
112
+ const f = def.fields[i];
113
+ this.rawCols[f] = allocColumn(def.schema[f], cap);
114
+ }
115
+ this.columns = this.rawCols;
116
+ }
117
+ ensureEventCapacity(needed) {
118
+ if (needed <= this.capacity) return;
119
+ const cap = nextPow2(needed);
120
+ this.capacity = cap;
121
+ for (let i = 0; i < this.def.fields.length; i++) {
122
+ const f = this.def.fields[i];
123
+ this.rawCols[f] = growTypedArray(this.rawCols[f], cap);
124
+ }
125
+ }
126
+ pushSlot() {
127
+ const idx = this.count;
128
+ this.ensureEventCapacity(idx + 1);
129
+ this.count = idx + 1;
130
+ const fields = this.def.fields;
131
+ for (let f = 0; f < fields.length; f++) this.rawCols[fields[f]][idx] = 0;
132
+ return idx;
133
+ }
134
+ emit(init) {
135
+ const idx = this.count;
136
+ this.ensureEventCapacity(idx + 1);
137
+ this.count = idx + 1;
138
+ const fields = this.def.fields;
139
+ if (init) for (let f = 0; f < fields.length; f++) {
140
+ const key = fields[f];
141
+ const v = init[key];
142
+ this.rawCols[key][idx] = v !== void 0 ? v : 0;
143
+ }
144
+ else for (let f = 0; f < fields.length; f++) this.rawCols[fields[f]][idx] = 0;
145
+ return idx;
146
+ }
147
+ each(fn) {
148
+ const n = this.count;
149
+ const cols = this.columns;
150
+ for (let i = 0; i < n; i++) fn(i, cols);
151
+ }
152
+ clear() {
153
+ this.count = 0;
154
+ }
155
+ };
156
+ /**
70
157
  * Dense-packed, zero-GC Structure-of-Arrays (SoA) ECS world.
71
158
  *
72
159
  * Live entities occupy contiguous dense slots `0 .. world.count - 1` so simulation loops,
@@ -90,6 +177,8 @@ var SoaWorld = class {
90
177
  handleGen;
91
178
  stores = [];
92
179
  defToStore = /* @__PURE__ */ new Map();
180
+ eventTables = /* @__PURE__ */ new Map();
181
+ eventTableList = [];
93
182
  /** Optional uniform CSR spatial hash grid synced over dense slots `0 .. count - 1`. */
94
183
  grid = null;
95
184
  gridOriginX = 0;
@@ -282,14 +371,91 @@ var SoaWorld = class {
282
371
  const st = this.defToStore.get(def);
283
372
  return Boolean(st && (this.masks[slot] & st.bit) !== 0);
284
373
  }
374
+ /** Access (or lazily create) the per-frame `EventTable` for `def`. */
375
+ events(def) {
376
+ let table = this.eventTables.get(def);
377
+ if (!table) {
378
+ table = new DenseEventTable(def, 64);
379
+ this.eventTables.set(def, table);
380
+ this.eventTableList.push(table);
381
+ }
382
+ return table;
383
+ }
384
+ /** Clear all per-frame `EventTable`s in O(numEventTables) at the end of a simulation tick (zero GC). */
385
+ clearEvents() {
386
+ for (let i = 0; i < this.eventTableList.length; i++) this.eventTableList[i].clear();
387
+ }
285
388
  /**
286
- * Populate `outSlots` with dense slot indices matching `includeMask` (and excluding `excludeMask`).
287
- * Returns the number of matching slots written (zero allocations).
389
+ * Compile a declarative `luaecs`-style relational query (`read`, `write`, `with`, `without`).
390
+ *Note: column references stay live even when `SoaWorld` grows capacity!
288
391
  */
289
- query(includeMask, outSlots, excludeMask = 0) {
392
+ select(spec) {
393
+ const readDefs = spec.read ?? [];
394
+ const writeDefs = spec.write ?? [];
395
+ const withDefs = spec.with ?? [];
396
+ const withoutDefs = spec.without ?? [];
397
+ let inc = 0;
398
+ for (let i = 0; i < readDefs.length; i++) inc = (inc | this.bitOf(readDefs[i])) >>> 0;
399
+ for (let i = 0; i < writeDefs.length; i++) inc = (inc | this.bitOf(writeDefs[i])) >>> 0;
400
+ for (let i = 0; i < withDefs.length; i++) inc = (inc | this.bitOf(withDefs[i])) >>> 0;
401
+ let exc = 0;
402
+ for (let i = 0; i < withoutDefs.length; i++) exc = (exc | this.bitOf(withoutDefs[i])) >>> 0;
403
+ const colMap = {};
404
+ for (let i = 0; i < readDefs.length; i++) {
405
+ const d = readDefs[i];
406
+ colMap[d.name] = this.defToStore.get(d).columns;
407
+ }
408
+ for (let i = 0; i < writeDefs.length; i++) {
409
+ const d = writeDefs[i];
410
+ colMap[d.name] = this.defToStore.get(d).columns;
411
+ }
412
+ const typedCols = colMap;
413
+ let scratchSlots = new Int32Array(Math.max(64, this.capacity));
414
+ return {
415
+ includeMask: inc,
416
+ excludeMask: exc,
417
+ columns: typedCols,
418
+ count: () => {
419
+ const n = this.count;
420
+ const masks = this.masks;
421
+ let c = 0;
422
+ for (let s = 0; s < n; s++) {
423
+ const m = masks[s];
424
+ if ((m & inc) === inc && (exc === 0 || (m & exc) === 0)) c++;
425
+ }
426
+ return c;
427
+ },
428
+ each: (fn) => {
429
+ const n = this.count;
430
+ const masks = this.masks;
431
+ const entities = this.entities;
432
+ for (let s = 0; s < n; s++) {
433
+ const m = masks[s];
434
+ if ((m & inc) === inc && (exc === 0 || (m & exc) === 0)) fn(s, entities[s], typedCols);
435
+ }
436
+ },
437
+ collectSlots: (outSlots) => {
438
+ let target = outSlots;
439
+ if (!target) {
440
+ if (scratchSlots.length < this.count) scratchSlots = new Int32Array(this.capacity);
441
+ target = scratchSlots;
442
+ }
443
+ const matched = this.query(inc, target, exc);
444
+ return {
445
+ slots: target,
446
+ count: matched,
447
+ columns: typedCols
448
+ };
449
+ }
450
+ };
451
+ }
452
+ query(maskOrSpec, outSlots, excludeMask = 0) {
453
+ if (typeof maskOrSpec !== "number") return this.select(maskOrSpec);
454
+ const includeMask = maskOrSpec;
455
+ const dst = outSlots;
290
456
  const n = this.count;
291
457
  const masks = this.masks;
292
- const maxOut = outSlots.length;
458
+ const maxOut = dst.length;
293
459
  let written = 0;
294
460
  const inc = includeMask >>> 0;
295
461
  const exc = excludeMask >>> 0;
@@ -297,7 +463,7 @@ var SoaWorld = class {
297
463
  const m = masks[s];
298
464
  if ((m & inc) === inc && (exc === 0 || (m & exc) === 0)) {
299
465
  if (written >= maxOut) break;
300
- outSlots[written++] = s;
466
+ dst[written++] = s;
301
467
  }
302
468
  }
303
469
  return written;
@@ -534,4 +700,4 @@ function partitionDepthBands(sortedSlots, sortedCount, depthCol, blockerDepths,
534
700
  }
535
701
  return bands;
536
702
  }
537
- export { SoaWorld, cullAndSortSlots, defineComponent, entityGeneration, entityIndex, partitionDepthBands, sortSlotsByDepth };
703
+ export { SoaWorld, cullAndSortSlots, defineComponent, defineEvent, defineTag, entityGeneration, entityIndex, partitionDepthBands, sortSlotsByDepth };
package/dist/flex.d.ts CHANGED
@@ -110,4 +110,188 @@ export interface WrapResult {
110
110
  * Solve a multi-line wrapping flow (`columns` omitted) or fixed-column grid (`columns >= 1`)
111
111
  * with crisp integer pixel snapping and `(row, col)` coordinates for 2D keyboard navigation.
112
112
  */
113
- export declare function computeWrapLayout(container: WrapContainerSpec, items: readonly WrapItemSpec[]): WrapResult;
113
+ export declare function computeWrapLayout(container: WrapContainerSpec, items: readonly WrapItemSpec[]): WrapResult;
114
+ export interface FlexPanelStyle {
115
+ fillColor?: number;
116
+ fillAlpha?: number;
117
+ borderColor?: number;
118
+ borderAlpha?: number;
119
+ borderWidth?: number;
120
+ radius?: number;
121
+ }
122
+ export interface FlexTextSpec {
123
+ content: string;
124
+ style?: Record<string, unknown>;
125
+ align?: 'left' | 'center' | 'right';
126
+ vAlign?: 'top' | 'center' | 'bottom';
127
+ offsetX?: number;
128
+ offsetY?: number;
129
+ }
130
+ export interface FlexIconSpec {
131
+ texture: string;
132
+ frame?: string | number;
133
+ w?: number;
134
+ h?: number;
135
+ tint?: number;
136
+ alpha?: number;
137
+ }
138
+ export interface FlexNodeSpec extends FlexContainerSpec {
139
+ id?: string;
140
+ trackId?: string;
141
+ basis?: number | null;
142
+ grow?: number;
143
+ shrink?: number;
144
+ minW?: number;
145
+ maxW?: number;
146
+ minH?: number;
147
+ maxH?: number;
148
+ alignSelf?: FlexAlign;
149
+ visible?: boolean;
150
+ panel?: FlexPanelStyle;
151
+ text?: string | FlexTextSpec;
152
+ icon?: FlexIconSpec;
153
+ onClick?: (node: FlattenedFlexNode, pointer: {
154
+ x: number;
155
+ y: number;
156
+ button?: number;
157
+ }) => void;
158
+ children?: readonly FlexNodeSpec[];
159
+ }
160
+ export interface FlattenedFlexNode {
161
+ readonly id: string | null;
162
+ readonly trackId: string | null;
163
+ readonly x: number;
164
+ readonly y: number;
165
+ readonly w: number;
166
+ readonly h: number;
167
+ readonly depth: number;
168
+ readonly visible: boolean;
169
+ readonly spec: FlexNodeSpec;
170
+ }
171
+ export interface FlattenedFlexTree {
172
+ readonly width: number;
173
+ readonly height: number;
174
+ readonly nodes: readonly FlattenedFlexNode[];
175
+ readonly byId: ReadonlyMap<string, FlattenedFlexNode>;
176
+ }
177
+ /**
178
+ * Solve an arbitrarily nested declarative `FlexNodeSpec` tree (2-pass bottom-up intrinsic sizing +
179
+ * top-down stretch/grow propagation) and flatten it into absolute `(x, y, w, h)` screen rectangles.
180
+ */
181
+ export declare function flattenFlexTree(root: FlexNodeSpec, originX?: number, originY?: number): FlattenedFlexTree;
182
+ /** Minimal duck-typed Scene contract for `mountFlexUi` (keeps `./flex` 100% zero-cycle). */
183
+ export interface FlexUiSceneHost {
184
+ readonly add: {
185
+ container(x?: number, y?: number): FlexUiContainerLike;
186
+ };
187
+ readonly make: {
188
+ shapeBatch(maxCount: number): FlexUiShapeBatchLike;
189
+ text(x: number, y: number, text: string, style?: Record<string, unknown>): FlexUiTextLike;
190
+ image(x: number, y: number, key: string, frame?: string | number): FlexUiImageLike;
191
+ rectangle?(x: number, y: number, w: number, h: number, color?: number, alpha?: number): FlexUiHitNodeLike;
192
+ };
193
+ readonly input?: {
194
+ on(event: string, fn: (pointer: {
195
+ x: number;
196
+ y: number;
197
+ button?: number;
198
+ }) => void): void;
199
+ off(event: string, fn: (pointer: {
200
+ x: number;
201
+ y: number;
202
+ button?: number;
203
+ }) => void): void;
204
+ };
205
+ }
206
+ export interface FlexUiContainerLike {
207
+ x: number;
208
+ y: number;
209
+ visible: boolean;
210
+ trackId: string | null;
211
+ setScrollFactor(x: number, y?: number): unknown;
212
+ setDepth(depth: number): unknown;
213
+ add(child: unknown): unknown;
214
+ destroy(fromScene?: boolean): void;
215
+ }
216
+ export interface FlexUiShapeBatchLike {
217
+ maxCount: number;
218
+ zIndex: number;
219
+ setOrigin(ox: number, oy?: number): unknown;
220
+ setColumns(cols: {
221
+ count: number;
222
+ x: Float32Array;
223
+ y: Float32Array;
224
+ width: Float32Array;
225
+ height: Float32Array;
226
+ radius: Float32Array;
227
+ fillColor: Uint32Array;
228
+ fillAlpha: Float32Array;
229
+ borderColor: Uint32Array;
230
+ borderAlpha: Float32Array;
231
+ borderWidth: Float32Array;
232
+ }): unknown;
233
+ destroy(): void;
234
+ }
235
+ export interface FlexUiTextLike {
236
+ x: number;
237
+ y: number;
238
+ zIndex: number;
239
+ visible: boolean;
240
+ trackId: string | null;
241
+ setText(t: string): unknown;
242
+ setStyle?(s: Record<string, unknown>): unknown;
243
+ setOrigin(ox: number, oy?: number): unknown;
244
+ destroy(): void;
245
+ }
246
+ export interface FlexUiImageLike {
247
+ x: number;
248
+ y: number;
249
+ zIndex: number;
250
+ visible: boolean;
251
+ alpha: number;
252
+ trackId: string | null;
253
+ setTexture(key: string, frame?: string | number): unknown;
254
+ setDisplaySize(w: number, h: number): unknown;
255
+ setOrigin(ox: number, oy?: number): unknown;
256
+ setTint(rgb: number): unknown;
257
+ destroy(): void;
258
+ }
259
+ export interface FlexUiHitNodeLike {
260
+ x: number;
261
+ y: number;
262
+ width: number;
263
+ height: number;
264
+ visible: boolean;
265
+ trackId: string | null;
266
+ setOrigin(ox: number, oy?: number): unknown;
267
+ destroy(): void;
268
+ }
269
+ export interface MountFlexUiOptions {
270
+ x?: number;
271
+ y?: number;
272
+ depth?: number;
273
+ scrollFactor?: number;
274
+ /** Listen to `scene.input` `'pointerdown'` for `onClick` handlers (`default = true`). */
275
+ interactive?: boolean;
276
+ /** Optional predicate checked before dispatching clicks (e.g. `() => !surfaces.isBlocked('hud')`). */
277
+ canInteract?: () => boolean;
278
+ trackId?: string;
279
+ }
280
+ export interface MountedFlexUi {
281
+ readonly container: FlexUiContainerLike;
282
+ readonly tree: FlattenedFlexTree;
283
+ /** Look up the flattened screen rectangle of a node by `id`. */
284
+ rectOf(id: string): FlattenedFlexNode | undefined;
285
+ /** Deepest visible interactive (or any) flattened node containing `(x, y)`. */
286
+ hitTest(x: number, y: number, interactiveOnly?: boolean): FlattenedFlexNode | null;
287
+ /** Programmatically trigger `onClick` at `(x, y)` (returns `true` if an `onClick` handler matched). */
288
+ dispatchClick(x: number, y: number, button?: number): boolean;
289
+ /** Re-flatten and update batched GPU SDF panels, icons, labels, and hit rects in one pass. */
290
+ relayout(nextRoot?: FlexNodeSpec, originX?: number, originY?: number): FlattenedFlexTree;
291
+ destroy(): void;
292
+ }
293
+ /**
294
+ * Flatten a nested `FlexNodeSpec` tree into a single GPU-instanced `ShapeBatch` for all panel
295
+ * backgrounds/borders + pooled `TextObject`s / `ImageObject`s + `trackId` hit regions!
296
+ */
297
+ export declare function mountFlexUi(scene: FlexUiSceneHost, initialRoot: FlexNodeSpec, options?: MountFlexUiOptions): MountedFlexUi;