@oasys/oecs 0.5.2 → 0.5.4

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.
Files changed (189) hide show
  1. package/CHANGELOG.md +208 -14
  2. package/README.md +198 -145
  3. package/dist/core/ecs/access_check.d.cts +3 -3
  4. package/dist/core/ecs/access_check.d.ts +3 -3
  5. package/dist/core/ecs/archetype.d.cts +103 -43
  6. package/dist/core/ecs/archetype.d.ts +103 -43
  7. package/dist/core/ecs/archetype.d.ts.map +1 -1
  8. package/dist/core/ecs/archetype_graph.d.cts +8 -8
  9. package/dist/core/ecs/archetype_graph.d.ts +8 -8
  10. package/dist/core/ecs/archetype_graph.d.ts.map +1 -1
  11. package/dist/core/ecs/builtin_relations.d.cts +1 -1
  12. package/dist/core/ecs/builtin_relations.d.ts +1 -1
  13. package/dist/core/ecs/command_log.d.cts +4 -4
  14. package/dist/core/ecs/command_log.d.ts +4 -4
  15. package/dist/core/ecs/command_log.d.ts.map +1 -1
  16. package/dist/core/ecs/component.d.cts +4 -4
  17. package/dist/core/ecs/component.d.ts +4 -4
  18. package/dist/core/ecs/deferred_commands.d.cts +1 -1
  19. package/dist/core/ecs/deferred_commands.d.ts +1 -1
  20. package/dist/core/ecs/deferred_commands.d.ts.map +1 -1
  21. package/dist/core/ecs/ecs.d.cts +85 -43
  22. package/dist/core/ecs/ecs.d.ts +85 -43
  23. package/dist/core/ecs/ecs.d.ts.map +1 -1
  24. package/dist/core/ecs/ecs_memory.d.cts +15 -15
  25. package/dist/core/ecs/ecs_memory.d.ts +15 -15
  26. package/dist/core/ecs/ecs_memory.d.ts.map +1 -1
  27. package/dist/core/ecs/entity_allocator.d.cts +6 -6
  28. package/dist/core/ecs/entity_allocator.d.ts +6 -6
  29. package/dist/core/ecs/entity_allocator.d.ts.map +1 -1
  30. package/dist/core/ecs/event.d.cts +2 -2
  31. package/dist/core/ecs/event.d.ts +2 -2
  32. package/dist/core/ecs/event_registry.d.cts +1 -1
  33. package/dist/core/ecs/event_registry.d.ts +1 -1
  34. package/dist/core/ecs/event_registry.d.ts.map +1 -1
  35. package/dist/core/ecs/facades.d.cts +15 -15
  36. package/dist/core/ecs/facades.d.ts +15 -15
  37. package/dist/core/ecs/facades.d.ts.map +1 -1
  38. package/dist/core/ecs/frame_trace.d.cts +2 -2
  39. package/dist/core/ecs/frame_trace.d.ts +2 -2
  40. package/dist/core/ecs/host_commands.d.cts +12 -12
  41. package/dist/core/ecs/host_commands.d.ts +12 -12
  42. package/dist/core/ecs/host_commands.d.ts.map +1 -1
  43. package/dist/core/ecs/index.d.cts +1 -1
  44. package/dist/core/ecs/index.d.ts +1 -1
  45. package/dist/core/ecs/index.d.ts.map +1 -1
  46. package/dist/core/ecs/observer.d.cts +9 -9
  47. package/dist/core/ecs/observer.d.ts +9 -9
  48. package/dist/core/ecs/observer.d.ts.map +1 -1
  49. package/dist/core/ecs/query.d.cts +91 -70
  50. package/dist/core/ecs/query.d.ts +91 -70
  51. package/dist/core/ecs/query.d.ts.map +1 -1
  52. package/dist/core/ecs/ref.d.cts +53 -1
  53. package/dist/core/ecs/ref.d.ts +53 -1
  54. package/dist/core/ecs/ref.d.ts.map +1 -1
  55. package/dist/core/ecs/relation.d.cts +15 -15
  56. package/dist/core/ecs/relation.d.ts +15 -15
  57. package/dist/core/ecs/relation.d.ts.map +1 -1
  58. package/dist/core/ecs/relation_service.d.cts +14 -14
  59. package/dist/core/ecs/relation_service.d.ts +14 -14
  60. package/dist/core/ecs/relation_service.d.ts.map +1 -1
  61. package/dist/core/ecs/resource.d.cts +1 -1
  62. package/dist/core/ecs/resource.d.ts +1 -1
  63. package/dist/core/ecs/resource_registry.d.cts +2 -2
  64. package/dist/core/ecs/resource_registry.d.ts +2 -2
  65. package/dist/core/ecs/resume.d.cts +3 -3
  66. package/dist/core/ecs/resume.d.ts +3 -3
  67. package/dist/core/ecs/resume.d.ts.map +1 -1
  68. package/dist/core/ecs/schedule.d.cts +22 -9
  69. package/dist/core/ecs/schedule.d.ts +22 -9
  70. package/dist/core/ecs/schedule.d.ts.map +1 -1
  71. package/dist/core/ecs/snapshot_service.d.cts +3 -3
  72. package/dist/core/ecs/snapshot_service.d.ts +3 -3
  73. package/dist/core/ecs/sparse_store.d.cts +6 -6
  74. package/dist/core/ecs/sparse_store.d.ts +6 -6
  75. package/dist/core/ecs/sparse_store.d.ts.map +1 -1
  76. package/dist/core/ecs/store.d.cts +189 -110
  77. package/dist/core/ecs/store.d.ts +189 -110
  78. package/dist/core/ecs/store.d.ts.map +1 -1
  79. package/dist/core/ecs/store_layout_listener.d.cts +2 -2
  80. package/dist/core/ecs/store_layout_listener.d.ts +2 -2
  81. package/dist/core/ecs/system.d.cts +8 -8
  82. package/dist/core/ecs/system.d.ts +8 -8
  83. package/dist/core/ecs/system.d.ts.map +1 -1
  84. package/dist/core/ecs/utils/error.d.cts +7 -0
  85. package/dist/core/ecs/utils/error.d.ts +7 -0
  86. package/dist/core/ecs/utils/error.d.ts.map +1 -1
  87. package/dist/core/store/action_ring.d.cts +7 -8
  88. package/dist/core/store/action_ring.d.ts +7 -8
  89. package/dist/core/store/action_ring.d.ts.map +1 -1
  90. package/dist/core/store/allocator.d.cts +58 -35
  91. package/dist/core/store/allocator.d.ts +58 -35
  92. package/dist/core/store/allocator.d.ts.map +1 -1
  93. package/dist/core/store/buffer_backed_column.d.cts +5 -6
  94. package/dist/core/store/buffer_backed_column.d.ts +5 -6
  95. package/dist/core/store/buffer_backed_column.d.ts.map +1 -1
  96. package/dist/core/store/column_store.d.cts +23 -23
  97. package/dist/core/store/column_store.d.ts +23 -23
  98. package/dist/core/store/column_store.d.ts.map +1 -1
  99. package/dist/core/store/command_dispatch.d.cts +1 -1
  100. package/dist/core/store/command_dispatch.d.ts +1 -1
  101. package/dist/core/store/command_ring.d.cts +6 -7
  102. package/dist/core/store/command_ring.d.ts +6 -7
  103. package/dist/core/store/command_ring.d.ts.map +1 -1
  104. package/dist/core/store/descriptor.d.cts +2 -2
  105. package/dist/core/store/descriptor.d.ts +2 -2
  106. package/dist/core/store/entity_index.d.cts +3 -3
  107. package/dist/core/store/entity_index.d.ts +3 -3
  108. package/dist/core/store/event_ring.d.cts +7 -7
  109. package/dist/core/store/event_ring.d.ts +7 -7
  110. package/dist/core/store/extend.d.cts +2 -2
  111. package/dist/core/store/extend.d.ts +2 -2
  112. package/dist/core/store/extend.d.ts.map +1 -1
  113. package/dist/core/store/grow.d.cts +1 -1
  114. package/dist/core/store/grow.d.ts +1 -1
  115. package/dist/core/store/grow.d.ts.map +1 -1
  116. package/dist/core/store/header.d.cts +9 -9
  117. package/dist/core/store/header.d.ts +9 -9
  118. package/dist/core/store/header.d.ts.map +1 -1
  119. package/dist/core/store/layout_ops.d.cts +25 -7
  120. package/dist/core/store/layout_ops.d.ts +25 -7
  121. package/dist/core/store/layout_ops.d.ts.map +1 -1
  122. package/dist/core/store/state_hash.d.cts +3 -3
  123. package/dist/core/store/state_hash.d.ts +3 -3
  124. package/dist/extensions/editor/editor.d.cts +4 -4
  125. package/dist/extensions/editor/editor.d.ts +4 -4
  126. package/dist/extensions/editor/editor.d.ts.map +1 -1
  127. package/dist/extensions/editor/field_handle.d.cts +1 -1
  128. package/dist/extensions/editor/field_handle.d.ts +1 -1
  129. package/dist/extensions/editor/index.d.cts +2 -2
  130. package/dist/extensions/editor/index.d.ts +2 -2
  131. package/dist/extensions/editor/index.development.js +4 -4
  132. package/dist/extensions/editor/index.js +4 -4
  133. package/dist/extensions/reactive/ecs_sync.d.cts +4 -4
  134. package/dist/extensions/reactive/ecs_sync.d.ts +4 -4
  135. package/dist/extensions/reactive/index.d.cts +4 -4
  136. package/dist/extensions/reactive/index.d.ts +4 -4
  137. package/dist/extensions/reactive/index.development.js +3 -3
  138. package/dist/extensions/reactive/index.js +3 -3
  139. package/dist/extensions/solid/index.d.cts +1 -1
  140. package/dist/extensions/solid/index.d.ts +1 -1
  141. package/dist/extensions/solid/index.development.js +1 -1
  142. package/dist/extensions/solid/index.js +1 -1
  143. package/dist/extensions/solid/kernel_solid.d.cts +1 -1
  144. package/dist/extensions/solid/kernel_solid.d.ts +1 -1
  145. package/dist/extensions/solid/kernel_solid.d.ts.map +1 -1
  146. package/dist/{host_commands-BI8pEmjH.js → host_commands-BlR3oZ3x.js} +473 -393
  147. package/dist/host_commands-C2cpU3yC.cjs +1 -0
  148. package/dist/index.cjs +1 -1
  149. package/dist/index.d.cts +2 -2
  150. package/dist/index.d.ts +2 -2
  151. package/dist/index.d.ts.map +1 -1
  152. package/dist/index.development.cjs +1 -1
  153. package/dist/index.development.js +3345 -2963
  154. package/dist/index.js +1496 -1131
  155. package/dist/{internal-BMDgWZbt.js → internal-BoxWl4dG.js} +410 -330
  156. package/dist/internal-CGBEwfeB.cjs +2 -0
  157. package/dist/internal.cjs +1 -1
  158. package/dist/internal.development.cjs +1 -1
  159. package/dist/internal.development.js +1 -1
  160. package/dist/internal.js +1 -1
  161. package/dist/primitives.development.js +1 -1
  162. package/dist/primitives.js +1 -1
  163. package/dist/reactive/index.d.cts +2 -2
  164. package/dist/reactive/index.d.ts +2 -2
  165. package/dist/reactive/index.development.js +1 -1
  166. package/dist/reactive/index.js +1 -1
  167. package/dist/reactive/kernel.d.cts +5 -5
  168. package/dist/reactive/kernel.d.ts +5 -5
  169. package/dist/reactive/shallow.d.cts +1 -1
  170. package/dist/reactive/shallow.d.ts +1 -1
  171. package/dist/{shallow-DfnAm9vG.js → shallow-Bs39EPh1.js} +1 -1
  172. package/dist/{shallow-9S1pY_Iw.js → shallow-CiFC70Dz.js} +1 -1
  173. package/dist/{shared-BU1Cd40h.js → shared-B4v0L1cw.js} +41 -35
  174. package/dist/shared-DU78k0pU.cjs +1 -0
  175. package/dist/shared.cjs +1 -1
  176. package/dist/shared.d.cts +1 -1
  177. package/dist/shared.d.ts +1 -1
  178. package/dist/shared.development.cjs +1 -1
  179. package/dist/shared.development.js +1 -1
  180. package/dist/shared.js +1 -1
  181. package/dist/type_primitives/typed_arrays/typed_arrays.d.cts +2 -2
  182. package/dist/type_primitives/typed_arrays/typed_arrays.d.ts +2 -2
  183. package/dist/{typed_arrays-BcXcnzB4.js → typed_arrays-DIVwVy5_.js} +1 -1
  184. package/dist/version.d.cts +2 -2
  185. package/dist/version.d.ts +2 -2
  186. package/package.json +1 -1
  187. package/dist/host_commands-CxhpzMx9.cjs +0 -1
  188. package/dist/internal-LiTSB_tG.cjs +0 -2
  189. package/dist/shared-BymrGTyR.cjs +0 -1
@@ -16,7 +16,7 @@ export interface ArchetypeEdge {
16
16
  * Cached resolution of a *multi*-component add out of this archetype: the
17
17
  * target archetype the union lands in, plus the pre-built src→target batch
18
18
  * transition map. Keyed (on the source archetype) by an exact N-tagged pack of
19
- * the added component ids — see `Store.addComponents` (#659).
19
+ * the added component ids — see `Store.addComponents`.
20
20
  *
21
21
  * Where `ArchetypeEdge` is the per-*component* edge the single-add path indexes
22
22
  * by `edges[component_id]`, this is the per-*set* edge the plural-add path looks
@@ -53,7 +53,7 @@ export type ColumnFactory = (componentId: ComponentID, fieldIdx: number, tag: Ty
53
53
  * across every SAB-backed archetype; after the handler returns,
54
54
  * `arch._flatColumns[i].buf.length` is guaranteed to be `>= arch.length +
55
55
  * additional`. Heap-backed archetypes leave this unset — their
56
- * `GrowableTypedArray` grows in place. (#171 §6.1.9 Phase 3)
56
+ * `GrowableTypedArray` grows in place.
57
57
  */
58
58
  export type ArchetypeGrowHandler = (arch: Archetype, additional: number) => void;
59
59
  /**
@@ -63,8 +63,7 @@ export type ArchetypeGrowHandler = (arch: Archetype, additional: number) => void
63
63
  * `removeEntity`, `moveEntityFrom`, `writeFields`, `setEdge`, and the
64
64
  * mutable `getColumn`) stays internal so query iteration can't bypass the
65
65
  * deferred-flush path that prevents iterator invalidation. This is the same
66
- * back door PR #163 closed for `Store`; issue #378 closed it again for
67
- * `Query`.
66
+ * back door that is closed for `Store` and closed again for `Query`.
68
67
  *
69
68
  * `id` is the archetype's opaque identity (not a mutator) — exposed so the
70
69
  * public `ECS.batchAddComponent`/`batchRemoveComponent` API can target an
@@ -73,16 +72,16 @@ export type ArchetypeGrowHandler = (arch: Archetype, additional: number) => void
73
72
  export interface ArchetypeView<out Defs extends readonly ComponentDef<any>[] = readonly ComponentDef<any>[]> {
74
73
  /** Opaque archetype identity. Pass to `ECS.batch_*_component`. */
75
74
  readonly id: ArchetypeID;
76
- /** Number of **enabled** entities — the default-iteration bound (#577). Rows
75
+ /** Number of **enabled** entities — the default-iteration bound. Rows
77
76
  * `0..entityCount-1` are enabled; disabled rows (if any) sit contiguously at
78
77
  * `entityCount..totalCount-1`. `forEach` SoA loops read this, so they skip
79
78
  * disabled rows for free. Use `totalCount` to span disabled rows too. */
80
79
  readonly entityCount: number;
81
- /** Total live rows, enabled + disabled (#577). Equal to `entityCount` unless
80
+ /** Total live rows, enabled + disabled. Equal to `entityCount` unless
82
81
  * some rows are disabled. Use for full-state work (serialization, snapshot,
83
82
  * determinism) that must see every entity regardless of enabled state. */
84
83
  readonly totalCount: number;
85
- /** Number of disabled rows = `totalCount - entityCount` (#577). */
84
+ /** Number of disabled rows = `totalCount - entityCount`. */
86
85
  readonly disabledCount: number;
87
86
  /** Raw entity ID buffer (packed `EntityID`s). Valid data at indices
88
87
  * 0..totalCount-1 (enabled rows first, then disabled). */
@@ -91,7 +90,7 @@ export interface ArchetypeView<out Defs extends readonly ComponentDef<any>[] = r
91
90
  hasComponent(id: ComponentID): boolean;
92
91
  /** Get a single field's column (read-only). Valid data: indices
93
92
  * 0..entityCount-1. `def` must be a term of the iterating query
94
- * (POLISH_AUDIT #6); the bare-`ArchetypeView` default stays permissive. */
93
+ *; the bare-`ArchetypeView` default stays permissive. */
95
94
  getColumnRead<D extends ComponentDef<any>, K extends string & keyof SchemaOf<D>>(def: D & DeclaredQueryTerm<Defs, D>, field: K): ReadonlyColumn;
96
95
  /** Tuple fetch of several of one component's columns —
97
96
  * `const [q, r] = arch.getColumnsRead(HexPos, "q", "r")`. One small
@@ -100,7 +99,7 @@ export interface ArchetypeView<out Defs extends readonly ComponentDef<any>[] = r
100
99
  [I in keyof K]: ReadonlyColumn;
101
100
  };
102
101
  /** Get a single field's column **if this archetype has the component**,
103
- * else `undefined` — the optional-query fetch-if-present accessor (#575).
102
+ * else `undefined` — the optional-query fetch-if-present accessor.
104
103
  * The absent branch is expected (resolve the column pointer per archetype
105
104
  * span: present ⇒ column, absent ⇒ `undefined`), not an error. Same
106
105
  * advisory-readonly view and `reads`-access-check as `getColumnRead`. */
@@ -125,7 +124,7 @@ export declare class Archetype implements ArchetypeView {
125
124
  private readonly _entityIds;
126
125
  length: number;
127
126
  /**
128
- * Enabled/disabled row partition (#577 — entity enable/disable). Rows
127
+ * Enabled/disabled row partition (entity enable/disable). Rows
129
128
  * `[0, enabled_count)` are enabled, `[enabled_count, length)` are disabled.
130
129
  * `enabled_count === length` (no disabled rows) is the common case — every
131
130
  * fast path below short-circuits on it, so an archetype that never disables
@@ -139,14 +138,14 @@ export declare class Archetype implements ArchetypeView {
139
138
  enabledCount: number;
140
139
  /**
141
140
  * Flush-epoch stamp + captured pre-counts for the Store's per-entity flush
142
- * 0-crossing detector (#328, #812): `_flushAdds`/`_flushRemoves` stamp each
141
+ * 0-crossing detector: `_flushAdds`/`_flushRemoves` stamp each
143
142
  * archetype on first sight per flush (a few field accesses) instead of probing
144
143
  * a `Map<archetype_id, pre_count>` per entity — the same per-entity Map
145
- * cost the destroy drain shed in #457. Both `_flushPreLen` and
144
+ * cost the destroy drain also avoids. Both `_flushPreLen` and
146
145
  * `_flushPreEnabled` are recorded so the settle pass can detect a 0-crossing
147
146
  * on either the total (`length`) or the enabled partition (`enabledCount`) —
148
- * an enabled append into an all-disabled archetype crosses only the latter
149
- * (#812). Owned by Store; pure scheduling bookkeeping, never folded into
147
+ * an enabled append into an all-disabled archetype crosses only the latter.
148
+ * Owned by Store; pure scheduling bookkeeping, never folded into
150
149
  * `stateHash`/snapshot.
151
150
  */
152
151
  _flushSeenEpoch: number;
@@ -171,13 +170,17 @@ export declare class Archetype implements ArchetypeView {
171
170
  */
172
171
  private readonly batchTransitionMaps;
173
172
  /**
174
- * Per-set add-edge cache for `Store.addComponents` (#659), keyed by an
173
+ * Per-set add-edge cache for `Store.addComponents`, keyed by an
175
174
  * exact pack of the added component ids. Lazily allocated: most archetypes
176
175
  * never originate a plural add, so the Map stays `null` until the first one
177
176
  * is resolved — the single-add `edges[]` path never touches it.
178
177
  */
179
178
  private compositeAddEdges;
180
179
  readonly _flatColumns: ColumnBacking<AnyTypedArray>[];
180
+ _bufs: AnyTypedArray[];
181
+ private _eids;
182
+ private _rowCap;
183
+ private _colCap;
181
184
  /** Set by `fromColumnStore` to record which SAB archetype this Archetype
182
185
  * draws its column views from. `null` for the default heap-backed path
183
186
  * (no SAB linkage; `refreshViews` would be a no-op there and so
@@ -196,9 +199,66 @@ export declare class Archetype implements ArchetypeView {
196
199
  * archetype during construction; `null` on heap-backed archetypes (the
197
200
  * default `GrowableTypedArray` grows in place). Insertion methods call
198
201
  * `_invoke_grow(...)` below before any push that would overflow the
199
- * current SAB row capacity. (#171 §6.1.9 Phase 3) */
202
+ * current SAB row capacity. */
200
203
  growHandler: ArchetypeGrowHandler | null;
201
204
  constructor(id: ArchetypeID, mask: BitSet, layouts?: ArchetypeColumnLayout[], initialCapacity?: number, columnFactory?: ColumnFactory);
205
+ /** Re-derive the `_bufs` / `_eids` / `_rowCap` row plane from the backing
206
+ * columns. The sole writer of all three — see the `_bufs` field doc for the
207
+ * invariant it restores. Cold: construction, `refreshViews`, tail of a grow. */
208
+ private _syncRowPlane;
209
+ /** Re-point every cached `eachChunk` column group at the current `_bufs`.
210
+ *
211
+ * Called only from `_syncRowPlane`, which is the only thing that can change a
212
+ * column's buffer identity — so after this runs, a cached group is correct by
213
+ * construction and `columnGroupMut` / `columnGroupRead` need no staleness test
214
+ * at all. That absence is the point: those two run once per archetype per
215
+ * `eachChunk` pass, which for a fragmented query is once per chunk, and this
216
+ * file already carries one hard-won lesson (`_onArchLenChange`): one more
217
+ * statement pushed that per-mutation function past V8's inlining budget, and
218
+ * it became much slower. We measured two earlier forms of this optimisation
219
+ * and rejected both for the same cause. A fill through a shared helper made
220
+ * fragmented iteration slower, and an inline test for a stale buffer also made
221
+ * it slower. Each loss was larger than the gain in system dispatch. Move the
222
+ * work to the cold path, and the gain stays with no loss.
223
+ *
224
+ * Refreshes in place, preserving object identity, for the same reason
225
+ * `_syncRowPlane` refills `_bufs` in place: a caller that captured the group
226
+ * sees fresh buffers rather than silently stale ones. */
227
+ private _refreshGroupCaches;
228
+ /** DEV-only: assert the row plane still addresses the live buffers.
229
+ *
230
+ * `_bufs`/`_eids` and `_flatColumns[i].buf`/`_entityIds.buf` are two paths to
231
+ * one buffer, and only the first is cached — the row ops index the cache while
232
+ * `getColumnRead` / `writeFields` read `.buf` fresh. Anything that changes a
233
+ * buffer's identity owes a `_syncRowPlane`; miss one and the two paths split
234
+ * silently, with row writes landing in an orphan that later reads never see.
235
+ *
236
+ * Checked at the boundaries that read `.buf` directly, and O(1): index 0 alone
237
+ * is enough, because `_syncRowPlane` rewrites every entry together — there is
238
+ * no way to desync one column and not the first. */
239
+ private _assertRowPlaneFresh;
240
+ /** Make room for `additional` more rows, growing if the append would
241
+ * overflow. Replaces the `this.length >= cols[0].buf.length` probe the append
242
+ * paths each open-coded — that read a column object and its buffer's length
243
+ * on every single-row append; this is one compare against a cached number.
244
+ *
245
+ * Both backings are handled by `_growRows` so callers don't branch: a
246
+ * SAB-backed archetype delegates to the store's `growHandler` (realloc +
247
+ * republish, which re-enters `refreshViews`), a heap-backed one
248
+ * (`growHandler === null`, the unit-test factory) grows each column in place.
249
+ * Either way the buffers may have moved, so the row plane is re-synced before
250
+ * returning — including when the grow throws. */
251
+ private _reserveRows;
252
+ /** Cold half of `_reserveRows`: the append genuinely doesn't fit, so grow.
253
+ * Never called on the fast path — see the caller. */
254
+ private _growRows;
255
+ /** Push `Archetype.length` down into each column's own logical length (and
256
+ * the entity-id array's). The row plane keeps `length` authoritative and never
257
+ * touches `_len`, so the columns' view of it goes stale between publishes.
258
+ * Nothing on the ECS hot paths reads it; the boundaries that DO — a
259
+ * reallocating `ensureCapacity`, `refreshView`'s shrink check, `view()` —
260
+ * publish first. */
261
+ private _publishRowCounts;
202
262
  /**
203
263
  * Build an Archetype whose columns are TypedArray views into a single
204
264
  * `ColumnStore`-managed `SharedArrayBuffer`. The store must contain an
@@ -208,7 +268,7 @@ export declare class Archetype implements ArchetypeView {
208
268
  * The resulting archetype is fixed-capacity at the SAB row capacity —
209
269
  * any operation that would push past it throws `StoreColumnOverflowError`.
210
270
  * To grow capacity, call `growColumnStore(...)` between ticks and then
211
- * `refreshViews(newStore)` on this archetype (#171 §6.1.4 / §8.1).
271
+ * `refreshViews(newStore)` on this archetype.
212
272
  */
213
273
  static fromColumnStore(id: ArchetypeID, mask: BitSet, layouts: ArchetypeColumnLayout[], columnStore: ColumnStore, storeArchetypeId: number): Archetype;
214
274
  /** True iff this archetype was constructed via `fromColumnStore` and its
@@ -228,7 +288,7 @@ export declare class Archetype implements ArchetypeView {
228
288
  * expects.
229
289
  */
230
290
  refreshViews(newColumnStore: ColumnStore): void;
231
- /** Enabled-row count — the default iteration bound (#577). See `enabled_count`.
291
+ /** Enabled-row count — the default iteration bound. See `enabled_count`.
232
292
  * Equals `length` whenever no entity is disabled (the common case).
233
293
  *
234
294
  * During an `includeDisabled()` query's `forEach`, the module flag
@@ -237,9 +297,9 @@ export declare class Archetype implements ArchetypeView {
237
297
  * transparently, with no change to the loop. Outside such iteration the flag is
238
298
  * false and this is `enabled_count`. */
239
299
  get entityCount(): number;
240
- /** Total live rows incl. disabled (#577). */
300
+ /** Total live rows incl. disabled. */
241
301
  get totalCount(): number;
242
- /** Disabled-row count (#577). */
302
+ /** Disabled-row count. */
243
303
  get disabledCount(): number;
244
304
  /** Raw entity ID buffer (packed `EntityID`s). Valid data at indices
245
305
  * 0..totalCount-1 (enabled rows first, then disabled). */
@@ -250,7 +310,7 @@ export declare class Archetype implements ArchetypeView {
250
310
  * cares about (it knows the two `entityIds` after the swap). The partition
251
311
  * primitives (`disableRow`/`enableRow`/`removeRow`/`_placeTail`) build on
252
312
  * this. Writes through each column's live backing buffer (`buf`), so it works
253
- * for both heap- and SAB-backed columns. No-op when `a === b`. (#577) */
313
+ * for both heap- and SAB-backed columns. No-op when `a === b`. */
254
314
  swapRows(a: number, b: number): void;
255
315
  /**
256
316
  * Place a freshly-appended ENABLED entity (currently at the tail row `tail`,
@@ -259,11 +319,11 @@ export declare class Archetype implements ArchetypeView {
259
319
  *
260
320
  * Common case — no disabled rows (`enabled_count === tail`): the tail row IS
261
321
  * the next enabled slot, so this is just `enabled_count++` and returns `tail`
262
- * (byte-for-byte the pre-#577 behaviour, `entityRow` untouched). Rare case —
322
+ * (byte-for-byte the earlier behaviour, `entityRow` untouched). Rare case —
263
323
  * disabled rows occupy `[enabled_count, tail)`: swap the appended row into the
264
324
  * first disabled slot and push that disabled occupant to the tail, updating
265
325
  * its `entityRow`. Requires `entityRow` in that case (a `DEV` guard fires
266
- * if a caller appends into a disabled-bearing archetype without passing it). (#577) */
326
+ * if a caller appends into a disabled-bearing archetype without passing it). */
267
327
  private _placeTail;
268
328
  /**
269
329
  * Bulk analog of `_placeTail` for `count` freshly-appended enabled rows at
@@ -271,21 +331,21 @@ export declare class Archetype implements ArchetypeView {
271
331
  * start`): `enabled_count += count`, return `start`. The bulk callers
272
332
  * (`spawnMany`, batch ops) fall back to a per-entity append loop when the
273
333
  * target already has disabled rows, so the rare branch is a `DEV` guard
274
- * rather than a block-rotation. (#577) */
334
+ * rather than a block-rotation. */
275
335
  private _placeTailBulk;
276
336
  /**
277
337
  * Disable the entity at `row` (precondition: enabled, `row < enabled_count`).
278
338
  * Swaps it to the end of the enabled region and shrinks the region, so it
279
339
  * lands in the disabled tail with its data intact — no archetype transition,
280
- * O(1)+one row swap. Updates `entityRow` for both rows touched. (#577) */
340
+ * O(1)+one row swap. Updates `entityRow` for both rows touched. */
281
341
  disableRow(row: number, entityRow: Int32Array): void;
282
342
  /**
283
343
  * Enable the entity at `row` (precondition: disabled, `row >= enabled_count`).
284
344
  * Swaps it to the front of the disabled region and grows the enabled region.
285
- * Updates `entityRow` for both rows touched. (#577) */
345
+ * Updates `entityRow` for both rows touched. */
286
346
  enableRow(row: number, entityRow: Int32Array): void;
287
347
  /**
288
- * Partition-aware swap-remove that owns its `entityRow` updates (#577). The
348
+ * Partition-aware swap-remove that owns its `entityRow` updates. The
289
349
  * Store's destroy/move paths call this instead of `removeEntity`; it keeps the
290
350
  * enabled prefix contiguous in every case:
291
351
  * - disabled row (`row >= enabled_count`): swap-remove within the disabled
@@ -297,9 +357,9 @@ export declare class Archetype implements ArchetypeView {
297
357
  * Updates `entityRow` for every relocated entity (never for the removed one —
298
358
  * the caller frees/repoints it). */
299
359
  removeRow(row: number, entityRow: Int32Array): void;
300
- /** @internal — cold partition-aware tail of `removeRow` (#577): the
360
+ /** @internal — cold partition-aware tail of `removeRow`: the
301
361
  * disabled-bearing archetype case. Split out so the no-disabled fast path
302
- * above stays small enough to inline (#649); see the doc on `removeRow`. */
362
+ * above stays small enough to inline; see the doc on `removeRow`. */
303
363
  private _removeRowPartitioned;
304
364
  get entityList(): Uint32Array;
305
365
  hasComponent(id: ComponentID): boolean;
@@ -309,7 +369,7 @@ export declare class Archetype implements ArchetypeView {
309
369
  * data: indices 0..entityCount-1. The `ReadonlyColumn` return is an
310
370
  * *advisory* compile-time barrier: it is the live mutable backing buffer,
311
371
  * so the `readonly` index signature blocks writes at the type layer only
312
- * (a §10c-policed cast can still write through). For writes use the
372
+ * (a deliberate cast can still write through). For writes use the
313
373
  * mutable `getColumn` (tick-bumping) below.
314
374
  */
315
375
  getColumnRead<S extends ComponentSchema, K extends string & keyof S>(def: ComponentDef<S>, field: K): ReadonlyColumn;
@@ -326,8 +386,8 @@ export declare class Archetype implements ArchetypeView {
326
386
  };
327
387
  /**
328
388
  * Get a single field's column **if this archetype has the component**, else
329
- * `undefined` — the fetch-if-present accessor for optional query terms (#575,
330
- * Bevy `Option<&T>` / flecs `?`). An optional query (`q.optional(T)`) spans
389
+ * `undefined` — the fetch-if-present accessor for optional query terms
390
+ * (Bevy `Option<&T>` / flecs `?`). An optional query (`q.optional(T)`) spans
331
391
  * archetypes both with and without `T`; the caller branches once per
332
392
  * archetype span on the return:
333
393
  *
@@ -344,7 +404,7 @@ export declare class Archetype implements ArchetypeView {
344
404
  * depend on whether the current span happens to hold `T`. Two checks fire:
345
405
  * (1) `accessCheck.checkRead` — an optional read needs `reads:[T]` coverage
346
406
  * exactly as a required read does; (2) `accessCheck.checkOptionalFetch` —
347
- * the iterating query must have declared `.optional(T)` (#592), the read-side
407
+ * the iterating query must have declared `.optional(T)`, the read-side
348
408
  * analog that makes the query term the fetch's authorization rather than inert
349
409
  * decoration. The return is the same advisory-readonly view `getColumnRead`
350
410
  * hands back.
@@ -389,9 +449,9 @@ export declare class Archetype implements ArchetypeView {
389
449
  * starting dstRow for the batch. Caller is responsible for tracking
390
450
  * entityIndex → row for every entity in the batch.
391
451
  *
392
- * Collapses the N×C `push(0)` cost of N sequential `addEntity` calls
393
- * into C `bulkAppendZeroes(count)` calls — the same pattern
394
- * `bulkMoveAllFrom` (`:580`) uses for the move-with-data case (#330).
452
+ * Collapses the N×C per-element cost of N sequential `addEntity` calls into
453
+ * C `fill` calls, one for each column — the same pattern `bulkMoveAllFrom`
454
+ * uses for the move-with-data case.
395
455
  */
396
456
  addEntities(entityIds: Uint32Array, count?: number): number;
397
457
  /** Tag-optimized bulk add: skip the per-column zero-fill entirely. */
@@ -401,8 +461,8 @@ export declare class Archetype implements ArchetypeView {
401
461
  * `addEntitiesWithValues` appends run internally, lifted out so the spawn
402
462
  * path can pre-reserve capacity BEFORE it commits an entity slot. A SAB-cap
403
463
  * grow throws here (with the world untouched) instead of mid-append after the
404
- * slot is already live — see `Store.spawn`/`spawnMany` (#775). No-op for a
405
- * tag-only archetype (no SAB columns) or when no grow handler is installed. */
464
+ * slot is already live — see `Store.spawn`/`spawnMany`. Now just the
465
+ * public name for `_reserveRows`, which every append path shares. */
406
466
  ensureRowCapacity(additional: number): void;
407
467
  /** Append one entity, writing `flatValues[i]` straight into column `i`
408
468
  * (in `_flatColumns` order) — no zero-fill-then-overwrite. Bumps every
@@ -424,7 +484,7 @@ export declare class Archetype implements ArchetypeView {
424
484
  /**
425
485
  * Move an entity from src into this archetype (tag-only: no columns to copy).
426
486
  * Writes dstRow to _moveResult[0]; _moveResult[1] is always NO_SWAP (the
427
- * partition-aware src/dst updates are owned internally, #577).
487
+ * partition-aware src/dst updates are owned internally).
428
488
  */
429
489
  moveEntityFromTag(src: Archetype, srcRow: number, entityId: EntityID, entityRow: Int32Array): void;
430
490
  /**
@@ -444,7 +504,7 @@ export declare class Archetype implements ArchetypeView {
444
504
  clearRows(): void;
445
505
  /**
446
506
  * Re-derive the host-side row bookkeeping after a snapshot is mounted onto a
447
- * live world (#789, `Store.restoreInto`). A snapshot reloads the column bytes
507
+ * live world (`Store.restoreInto`). A snapshot reloads the column bytes
448
508
  * (dense SAB) but NOT the host-side `length` / `enabledCount` / `_entityIds`
449
509
  * back-reference — those are reconstructed here. `refreshViews` must have
450
510
  * already repointed the columns at the restored SAB.
@@ -452,7 +512,7 @@ export declare class Archetype implements ArchetypeView {
452
512
  * The caller scans the restored entity-index region to learn which entity
453
513
  * occupies each row and passes them in row order (`rowEntityIds[r]` is the
454
514
  * packed `EntityID` at row `r`; rows `[0, length)` are dense, enabled rows
455
- * first then disabled per the #577 partition). `enabledCount` is the restored
515
+ * first then disabled per the partition). `enabledCount` is the restored
456
516
  * partition boundary. This is the inverse of the per-row `addEntity` /
457
517
  * `disableRow` bookkeeping the live run accumulated.
458
518
  */
@@ -465,12 +525,12 @@ export declare class Archetype implements ArchetypeView {
465
525
  * cache only covers single-component steps.
466
526
  */
467
527
  getBatchTransitionMap(target: Archetype): Int16Array;
468
- /** Look up a cached plural-add transition by its packed key (#659). Returns
528
+ /** Look up a cached plural-add transition by its packed key. Returns
469
529
  * `undefined` until the first composite add out of this archetype plants the
470
530
  * lazy Map — the common case for archetypes that only ever see single adds. */
471
531
  getCompositeAddEdge(key: number): CompositeAddEdge | undefined;
472
532
  /** Cache a resolved plural-add transition (target + src→target map) under its
473
- * packed key (#659), allocating the backing Map on first use. */
533
+ * packed key, allocating the backing Map on first use. */
474
534
  cacheCompositeAddEdge(key: number, target: ArchetypeID, map: Int16Array): void;
475
535
  }
476
536
  /** Reusable result buffer for move_entity_from/move_entity_from_tag. [dstRow, swapped_index] */