@vworlds/vecs 1.0.20 → 1.0.22

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 (155) hide show
  1. package/README.md +84 -99
  2. package/dist/component.d.ts +5 -2
  3. package/dist/component.js +4 -57
  4. package/dist/component.js.map +1 -1
  5. package/dist/component_meta.d.ts +15 -8
  6. package/dist/component_meta.js +6 -4
  7. package/dist/component_meta.js.map +1 -1
  8. package/dist/dsl.d.ts +56 -11
  9. package/dist/dsl.js +55 -38
  10. package/dist/dsl.js.map +1 -1
  11. package/dist/entity/entity.base.d.ts +4 -3
  12. package/dist/entity/entity.base.js +4 -4
  13. package/dist/entity/entity.base.js.map +1 -1
  14. package/dist/entity/entity.components.d.ts +16 -7
  15. package/dist/entity/entity.components.js +48 -23
  16. package/dist/entity/entity.components.js.map +1 -1
  17. package/dist/entity/entity.d.ts +5 -1
  18. package/dist/entity/entity.js +5 -0
  19. package/dist/entity/entity.js.map +1 -1
  20. package/dist/entity/entity.lifecycle.js +25 -25
  21. package/dist/entity/entity.lifecycle.js.map +1 -1
  22. package/dist/entity/entity.queries.js +0 -6
  23. package/dist/entity/entity.queries.js.map +1 -1
  24. package/dist/entity/entity.relationships.d.ts +1 -1
  25. package/dist/entity/entity.relationships.js +7 -5
  26. package/dist/entity/entity.relationships.js.map +1 -1
  27. package/dist/entity/index.d.ts +1 -1
  28. package/dist/entity/index.js.map +1 -1
  29. package/dist/filter.d.ts +6 -6
  30. package/dist/filter.js +2 -1
  31. package/dist/filter.js.map +1 -1
  32. package/dist/index.d.ts +10 -6
  33. package/dist/index.js +6 -3
  34. package/dist/index.js.map +1 -1
  35. package/dist/inject.d.ts +18 -17
  36. package/dist/inject.js +34 -34
  37. package/dist/inject.js.map +1 -1
  38. package/dist/module.d.ts +4 -4
  39. package/dist/module.js +0 -3
  40. package/dist/module.js.map +1 -1
  41. package/dist/modules/pipeline.d.ts +20 -0
  42. package/dist/modules/pipeline.js +57 -0
  43. package/dist/modules/pipeline.js.map +1 -0
  44. package/dist/modules/relationship_types.d.ts +37 -0
  45. package/dist/modules/relationship_types.js +39 -0
  46. package/dist/modules/relationship_types.js.map +1 -0
  47. package/dist/modules/relationships.d.ts +24 -0
  48. package/dist/modules/relationships.js +82 -0
  49. package/dist/modules/relationships.js.map +1 -0
  50. package/dist/modules/singleton.js +1 -2
  51. package/dist/modules/singleton.js.map +1 -1
  52. package/dist/package.json +2 -2
  53. package/dist/query/callbacks.d.ts +17 -0
  54. package/dist/query/callbacks.js +113 -0
  55. package/dist/query/callbacks.js.map +1 -0
  56. package/dist/query/constants.d.ts +1 -0
  57. package/dist/query/constants.js +2 -0
  58. package/dist/query/constants.js.map +1 -0
  59. package/dist/query/{query.03.tracking.d.ts → group.d.ts} +11 -9
  60. package/dist/query/group.js +31 -0
  61. package/dist/query/group.js.map +1 -0
  62. package/dist/query/grouped_query.d.ts +26 -0
  63. package/dist/query/grouped_query.js +121 -0
  64. package/dist/query/grouped_query.js.map +1 -0
  65. package/dist/query/grouped_query_registry.d.ts +4 -0
  66. package/dist/query/grouped_query_registry.js +11 -0
  67. package/dist/query/grouped_query_registry.js.map +1 -0
  68. package/dist/query/grouping.d.ts +24 -0
  69. package/dist/query/{query.07.groups.js → grouping.js} +29 -60
  70. package/dist/query/grouping.js.map +1 -0
  71. package/dist/query/index.d.ts +6 -6
  72. package/dist/query/index.js +6 -4
  73. package/dist/query/index.js.map +1 -1
  74. package/dist/query/query.d.ts +58 -28
  75. package/dist/query/query.js +334 -88
  76. package/dist/query/query.js.map +1 -1
  77. package/dist/system.d.ts +24 -54
  78. package/dist/system.js +47 -81
  79. package/dist/system.js.map +1 -1
  80. package/dist/terms/all_term.d.ts +2 -6
  81. package/dist/terms/all_term.js +2 -7
  82. package/dist/terms/all_term.js.map +1 -1
  83. package/dist/terms/any_term.d.ts +2 -6
  84. package/dist/terms/any_term.js +2 -7
  85. package/dist/terms/any_term.js.map +1 -1
  86. package/dist/terms/build.d.ts +9 -6
  87. package/dist/terms/build.js +17 -14
  88. package/dist/terms/build.js.map +1 -1
  89. package/dist/terms/component_term.d.ts +3 -3
  90. package/dist/terms/component_term.js.map +1 -1
  91. package/dist/terms/composite_build.d.ts +32 -0
  92. package/dist/terms/composite_build.js +28 -0
  93. package/dist/terms/composite_build.js.map +1 -0
  94. package/dist/terms/only_term.d.ts +3 -3
  95. package/dist/terms/only_term.js.map +1 -1
  96. package/dist/terms/predicate_term.d.ts +3 -3
  97. package/dist/terms/predicate_term.js +3 -3
  98. package/dist/terms/predicate_term.js.map +1 -1
  99. package/dist/terms/target_term.d.ts +3 -2
  100. package/dist/terms/target_term.js +11 -17
  101. package/dist/terms/target_term.js.map +1 -1
  102. package/dist/util/dense_set.js +1 -1
  103. package/dist/util/id_pool.d.ts +2 -0
  104. package/dist/util/id_pool.js +10 -0
  105. package/dist/util/id_pool.js.map +1 -1
  106. package/dist/util/ordered_set.js +15 -10
  107. package/dist/util/ordered_set.js.map +1 -1
  108. package/dist/world/world.components.d.ts +5 -9
  109. package/dist/world/world.components.js +16 -28
  110. package/dist/world/world.components.js.map +1 -1
  111. package/dist/world/world.d.ts +3 -6
  112. package/dist/world/world.entities.d.ts +2 -2
  113. package/dist/world/world.entities.js.map +1 -1
  114. package/dist/world/world.js +10 -10
  115. package/dist/world/world.js.map +1 -1
  116. package/dist/world/world.modules.d.ts +4 -7
  117. package/dist/world/world.modules.js +13 -10
  118. package/dist/world/world.modules.js.map +1 -1
  119. package/dist/world/world.pipeline.d.ts +5 -8
  120. package/dist/world/world.pipeline.js +24 -53
  121. package/dist/world/world.pipeline.js.map +1 -1
  122. package/dist/world/world.pools.d.ts +2 -1
  123. package/dist/world/world.pools.js.map +1 -1
  124. package/dist/world/world.queries.d.ts +3 -5
  125. package/dist/world/world.queries.js +11 -8
  126. package/dist/world/world.queries.js.map +1 -1
  127. package/package.json +2 -2
  128. package/dist/phase.d.ts +0 -29
  129. package/dist/phase.js +0 -24
  130. package/dist/phase.js.map +0 -1
  131. package/dist/query/query.00.base.d.ts +0 -23
  132. package/dist/query/query.00.base.js +0 -77
  133. package/dist/query/query.00.base.js.map +0 -1
  134. package/dist/query/query.01.reactive.d.ts +0 -7
  135. package/dist/query/query.01.reactive.js +0 -58
  136. package/dist/query/query.01.reactive.js.map +0 -1
  137. package/dist/query/query.02.lifecycle.d.ts +0 -6
  138. package/dist/query/query.02.lifecycle.js +0 -63
  139. package/dist/query/query.02.lifecycle.js.map +0 -1
  140. package/dist/query/query.03.tracking.js +0 -31
  141. package/dist/query/query.03.tracking.js.map +0 -1
  142. package/dist/query/query.04.callbacks.d.ts +0 -14
  143. package/dist/query/query.04.callbacks.js +0 -65
  144. package/dist/query/query.04.callbacks.js.map +0 -1
  145. package/dist/query/query.05.updates.d.ts +0 -14
  146. package/dist/query/query.05.updates.js +0 -81
  147. package/dist/query/query.05.updates.js.map +0 -1
  148. package/dist/query/query.06.predicate.d.ts +0 -13
  149. package/dist/query/query.06.predicate.js +0 -40
  150. package/dist/query/query.06.predicate.js.map +0 -1
  151. package/dist/query/query.07.groups.d.ts +0 -41
  152. package/dist/query/query.07.groups.js.map +0 -1
  153. package/dist/relationship.d.ts +0 -19
  154. package/dist/relationship.js +0 -18
  155. package/dist/relationship.js.map +0 -1
package/dist/system.d.ts CHANGED
@@ -1,9 +1,8 @@
1
1
  import { type ComponentType } from "./component.js";
2
2
  import { Iter, type FanInjectTuple, type MaybeResolvedInjectTuple } from "./inject.js";
3
3
  import { Query } from "./query/index.js";
4
- import { type QueryDSL } from "./dsl.js";
4
+ import { type ExtractSpecsRequired, type QuerySpec } from "./dsl.js";
5
5
  import { Entity } from "./entity/index.js";
6
- import { type IPhase } from "./phase.js";
7
6
  import { type World } from "./world/index.js";
8
7
  import { type ITickSource } from "./timer.js";
9
8
  export type { QueryDSL as SystemQuery, EntityTestFunc } from "./dsl.js";
@@ -15,16 +14,14 @@ type RunCallback = (now: number, delta: number) => void;
15
14
  *
16
15
  * ```ts
17
16
  * world.system("Move")
18
- * .requires(Position, Velocity) // track entities with both components
19
- * .phase("update")
17
+ * .with(Position, Velocity) // track entities with both components
20
18
  * .enter([Position], (e, [pos]) => { pos.x = 0; })
21
19
  * .update(Position, (e, pos) => { pos.x += pos.vx; })
22
20
  * .exit((e) => { console.log("entity left", e.eid); });
23
21
  * ```
24
22
  *
25
- * Every builder method returns `this` for chaining. After registering systems
26
- * call {@link World.start} once, then drive the loop with
27
- * {@link World.runPhase} or {@link World.progress}.
23
+ * Every builder method returns `this` for chaining. Systems are inserted into
24
+ * the world's pipeline the next time {@link World.progress} runs.
28
25
  *
29
26
  * Internally each system holds a single ordered **inbox** of routed events
30
27
  * (`enter`, `exit`, `update`). The world appends to it during command-queue
@@ -33,12 +30,12 @@ type RunCallback = (now: number, delta: number) => void;
33
30
  *
34
31
  * ### Component injection and type inference
35
32
  *
36
- * `enter`, `exit`, `update`, `each`, and `sort` accept an array of component
33
+ * `enter`, `exit`, `update`, `each`, and `orderBy` accept an array of component
37
34
  * classes resolved from the entity and passed as a typed tuple to the
38
35
  * callback.
39
36
  *
40
- * Components declared via {@link requires} (or the `_guaranteed` argument of
41
- * {@link query}) are tracked as the type parameter `R`. Inside `sort`,
37
+ * Components declared via {@link with} (or the `hint` field of a
38
+ * {@link QueryConfig}) are tracked as the type parameter `R`. Inside `orderBy`,
42
39
  * `each`, and `update` injection callbacks they are non-nullable; any other
43
40
  * component remains `Type | undefined`.
44
41
  *
@@ -50,11 +47,13 @@ export declare class System<R extends ComponentType[] = []> extends Query<R> imp
50
47
  get didTick(): boolean;
51
48
  /** Milliseconds accumulated into this system's most recent fire. */
52
49
  get lastFireDelta(): number;
50
+ /** Place this system after a phase entity in the world pipeline. */
51
+ phase(phase: Entity | string): this;
53
52
  /**
54
53
  * Run this system at a fixed interval, expressed in seconds.
55
54
  *
56
- * This is seconds, unlike `World.beginFrame`, `World.progress`, and
57
- * `runPhase`, which receive millisecond deltas. Calling `interval` replaces
55
+ * This is seconds, unlike `World.beginFrame` and `World.progress`, which
56
+ * receive millisecond deltas. Calling `interval` replaces
58
57
  * the current cadence source with an {@link IntervalTickSource}. When this
59
58
  * system has a cadence source, the `delta` passed to {@link run} is the
60
59
  * accumulated milliseconds since the previous fire, not the per-frame delta.
@@ -113,19 +112,6 @@ export declare class System<R extends ComponentType[] = []> extends Query<R> imp
113
112
  */
114
113
  tickSource(source: ITickSource): this;
115
114
  private _setTickSource;
116
- /**
117
- * Assign this system to a pipeline phase.
118
- *
119
- * Pass either a phase name (resolved at {@link World.start}) or an
120
- * {@link IPhase} reference returned from {@link World.addPhase}. Systems
121
- * with no explicit phase fall into the built-in `"update"` phase.
122
- *
123
- * @param p - Phase name or `IPhase` reference.
124
- * @returns This system, for chaining.
125
- * @throws When the phase reference is not a `Phase`, or belongs to a
126
- * different world.
127
- */
128
- phase(p: string | IPhase): this;
129
115
  /**
130
116
  * Register a per-tick callback fired every time this system's phase runs,
131
117
  * regardless of entity membership.
@@ -146,11 +132,11 @@ export declare class System<R extends ComponentType[] = []> extends Query<R> imp
146
132
  *
147
133
  * Unlike {@link update} (which only fires when `entity.modified(C)` is
148
134
  * called), `each` fires every tick the system runs, once per tracked entity.
149
- * Components declared via {@link requires} are non-nullable in the resolved
135
+ * Components declared via {@link with} are non-nullable in the resolved
150
136
  * tuple; any other component class may be `undefined` if the entity lacks it.
151
137
  *
152
138
  * `each` does **not** modify the system's query — define membership with
153
- * {@link requires} or {@link query} as usual. It does, however, implicitly
139
+ * {@link with} as usual. It does, however, implicitly
154
140
  * enable {@link track}, so matched entities are exposed via {@link count},
155
141
  * {@link has}, iteration, and {@link forEach}.
156
142
  *
@@ -163,14 +149,14 @@ export declare class System<R extends ComponentType[] = []> extends Query<R> imp
163
149
  *
164
150
  * @param components - Component classes to resolve from each entity.
165
151
  * @param callback - Receives the entity and a tuple of resolved component
166
- * instances (`undefined` for any not covered by {@link requires}).
152
+ * instances (`undefined` for any not covered by {@link with}).
167
153
  * @returns This system, for chaining.
168
154
  * @throws When `each` has already been registered on this system.
169
155
  *
170
156
  * @example
171
157
  * ```ts
172
158
  * world.system("Move")
173
- * .requires(Position, Velocity)
159
+ * .with(Position, Velocity)
174
160
  * .each([Position, Velocity], (e, [pos, vel]) => {
175
161
  * pos.x += vel.vx;
176
162
  * pos.y += vel.vy;
@@ -188,37 +174,21 @@ export declare class System<R extends ComponentType[] = []> extends Query<R> imp
188
174
  * cursor instead of the bare entity. The cursor exposes the visited entity
189
175
  * (`it.entity`) and, in `it.src`, the source entity each resolved component
190
176
  * was read from (the visited entity for direct components, the relationship
191
- * target for `up`-injected ones).
177
+ * target for `target`-injected ones).
192
178
  */
193
179
  each<J extends FanInjectTuple>(cursor: typeof Iter, components: readonly [...J], callback: (it: Iter, resolved: MaybeResolvedInjectTuple<J, R>) => void): this;
194
180
  /**
195
- * Set the entity-membership predicate using a {@link QueryDSL} expression.
181
+ * Add entity-membership predicates using {@link QuerySpec} expressions.
196
182
  *
197
- * Replaces any implicit query derived from `update` watchlists and any
198
- * previous `requires` call. After calling `query`, watchlist auto-expansion
199
- * via `update` is disabled.
200
- *
201
- * The optional `_guaranteed` tuple is a pure type-level hint — see
202
- * {@link Query.query} for details.
203
- *
204
- * @param q - Query expression.
205
- * @param _guaranteed - Component classes guaranteed present on every matched
206
- * entity (type hint only — not validated at runtime).
207
- * @returns This system, retyped with the guaranteed tuple as its `R`.
208
- */
209
- query<T extends ComponentType[] = []>(q: QueryDSL, _guaranteed?: readonly [...T]): System<T>;
210
- /**
211
- * Shorthand for `query([...components])` — tracks entities that have **all**
212
- * of the listed component types.
183
+ * Merges with any existing predicate using `all`. After calling `with`,
184
+ * watchlist auto-expansion via `update` is disabled.
213
185
  *
214
- * Equivalent to `query(components)`. The listed components are also
215
- * recorded in the type parameter `R`, so {@link sort}, {@link each}, and
216
- * {@link update} callbacks treat them as non-nullable.
186
+ * `hint` fields are pure type-level hints see {@link Query.with} for details.
217
187
  *
218
- * @param components - Component classes to require.
219
- * @returns This system, retyped with the required tuple as its `R`.
188
+ * @param specs - Query specifications to add.
189
+ * @returns This system, retyped with the guaranteed components added to `R`.
220
190
  */
221
- requires<T extends ComponentType[]>(...components: [...T]): System<T>;
191
+ with<const S extends readonly QuerySpec[]>(...specs: [...S]): System<[...R, ...ExtractSpecsRequired<S>]>;
222
192
  /**
223
193
  * Systems cannot use groupBy. Use `world.query(...).groupBy(...)` instead.
224
194
  */
@@ -244,7 +214,7 @@ export declare class System<R extends ComponentType[] = []> extends Query<R> imp
244
214
  *
245
215
  * @example
246
216
  * ```ts
247
- * const sys = world.system("AI").requires(Enemy).run(runAI);
217
+ * const sys = world.system("AI").with(Enemy).run(runAI);
248
218
  * // Pause AI processing during a cutscene:
249
219
  * sys.disable();
250
220
  * // Resume:
package/dist/system.js CHANGED
@@ -1,7 +1,8 @@
1
1
  import { isCursorMarker, makeInjectedInvoker, wantsIter, } from "./inject.js";
2
2
  import { SOURCE_TRACKED_QUERY_ERROR, Query } from "./query/index.js";
3
- import { containsDownTerm } from "./dsl.js";
4
- import { Phase } from "./phase.js";
3
+ import { containsDownTerm, } from "./dsl.js";
4
+ import { ON_UPDATE, Phase } from "./modules/pipeline.js";
5
+ import { DependsOn } from "./modules/relationships.js";
5
6
  import { ALWAYS_TICK_SOURCE, IntervalTickSource, RateTickSource, } from "./timer.js";
6
7
  /**
7
8
  * A reactive processor running over a filtered subset of world entities.
@@ -10,16 +11,14 @@ import { ALWAYS_TICK_SOURCE, IntervalTickSource, RateTickSource, } from "./timer
10
11
  *
11
12
  * ```ts
12
13
  * world.system("Move")
13
- * .requires(Position, Velocity) // track entities with both components
14
- * .phase("update")
14
+ * .with(Position, Velocity) // track entities with both components
15
15
  * .enter([Position], (e, [pos]) => { pos.x = 0; })
16
16
  * .update(Position, (e, pos) => { pos.x += pos.vx; })
17
17
  * .exit((e) => { console.log("entity left", e.eid); });
18
18
  * ```
19
19
  *
20
- * Every builder method returns `this` for chaining. After registering systems
21
- * call {@link World.start} once, then drive the loop with
22
- * {@link World.runPhase} or {@link World.progress}.
20
+ * Every builder method returns `this` for chaining. Systems are inserted into
21
+ * the world's pipeline the next time {@link World.progress} runs.
23
22
  *
24
23
  * Internally each system holds a single ordered **inbox** of routed events
25
24
  * (`enter`, `exit`, `update`). The world appends to it during command-queue
@@ -28,12 +27,12 @@ import { ALWAYS_TICK_SOURCE, IntervalTickSource, RateTickSource, } from "./timer
28
27
  *
29
28
  * ### Component injection and type inference
30
29
  *
31
- * `enter`, `exit`, `update`, `each`, and `sort` accept an array of component
30
+ * `enter`, `exit`, `update`, `each`, and `orderBy` accept an array of component
32
31
  * classes resolved from the entity and passed as a typed tuple to the
33
32
  * callback.
34
33
  *
35
- * Components declared via {@link requires} (or the `_guaranteed` argument of
36
- * {@link query}) are tracked as the type parameter `R`. Inside `sort`,
34
+ * Components declared via {@link with} (or the `hint` field of a
35
+ * {@link QueryConfig}) are tracked as the type parameter `R`. Inside `orderBy`,
37
36
  * `each`, and `update` injection callbacks they are non-nullable; any other
38
37
  * component remains `Type | undefined`.
39
38
  *
@@ -49,6 +48,7 @@ export class System extends Query {
49
48
  /** @internal Cadence source for this system. Defaults to every frame. */
50
49
  this._tickSource = ALWAYS_TICK_SOURCE;
51
50
  this.entity.attach(System, this);
51
+ this.phase(ON_UPDATE);
52
52
  }
53
53
  /** @internal Reject non-reactive source/children terms before registering this system. */
54
54
  _build() {
@@ -72,6 +72,7 @@ export class System extends Query {
72
72
  * translate root-term membership events into inbox commands here.
73
73
  */
74
74
  _enter(e) {
75
+ this.changed = true;
75
76
  this._entities?.add(e);
76
77
  e._addQueryMembership(this);
77
78
  if (!this._enabled) {
@@ -80,13 +81,13 @@ export class System extends Query {
80
81
  if (this._enterCallback !== undefined) {
81
82
  this._inbox.push({ kind: 0 /* InboxCommand.Enter */, entity: e });
82
83
  }
83
- e.components.forEach((c, eid) => {
84
- const meta = this.world.entity(eid).ownMeta;
85
- if (this._watchlistBitmask.hasBit(meta.bitPtr)) {
86
- // Entry-time initialization bypasses the silence filter: an entity
87
- // introduced by an ignored source must still initialize in this system.
88
- this._pushUpdate(e, meta, c);
84
+ e.components.forEach((c, ceid) => {
85
+ if (!this._watchlistBitmask.has(ceid)) {
86
+ return;
89
87
  }
88
+ // Entry-time initialization bypasses the silence filter: an entity
89
+ // introduced by an ignored source must still initialize in this system.
90
+ this._pushUpdate(e, ceid, c);
90
91
  });
91
92
  }
92
93
  /**
@@ -96,6 +97,7 @@ export class System extends Query {
96
97
  * resolvable after the underlying components are removed.
97
98
  */
98
99
  _exit(e) {
100
+ this.changed = true;
99
101
  this._entities?.delete(e);
100
102
  e._removeQueryMembership(this);
101
103
  if (!this._enabled) {
@@ -105,10 +107,10 @@ export class System extends Query {
105
107
  let snapshot;
106
108
  if (this._exitSnapshotTypes && this._exitSnapshotTypes.length > 0) {
107
109
  snapshot = new Map();
108
- for (const eid of this._exitSnapshotTypes) {
109
- const c = e._get(eid);
110
+ for (const ceid of this._exitSnapshotTypes) {
111
+ const c = e._get(ceid);
110
112
  if (c) {
111
- snapshot.set(eid, c);
113
+ snapshot.set(ceid, c);
112
114
  }
113
115
  }
114
116
  }
@@ -119,8 +121,8 @@ export class System extends Query {
119
121
  * @internal Routing entry: push an inbox `update` event when the modified
120
122
  * component matches the watchlist and its source is not silenced.
121
123
  */
122
- _notifyModified(e, meta, c) {
123
- if (!this._watchlistBitmask.hasBit(meta.bitPtr)) {
124
+ _notifyModified(e, ceid, c) {
125
+ if (!this._watchlistBitmask.has(ceid)) {
124
126
  return;
125
127
  }
126
128
  if (!this._enabled) {
@@ -129,11 +131,12 @@ export class System extends Query {
129
131
  if (this._isSourceSilenced()) {
130
132
  return;
131
133
  }
132
- this._pushUpdate(e, meta, c);
134
+ this.changed = true;
135
+ this._pushUpdate(e, ceid, c);
133
136
  }
134
137
  /** @internal Append an `update` event to the inbox, bypassing the silence filter. */
135
- _pushUpdate(e, meta, c) {
136
- this._inbox.push({ kind: 2 /* InboxCommand.Update */, entity: e, meta, component: c });
138
+ _pushUpdate(e, ceid, c) {
139
+ this._inbox.push({ kind: 2 /* InboxCommand.Update */, entity: e, eid: ceid, component: c });
137
140
  }
138
141
  /**
139
142
  * @internal Execute one tick: drain the inbox in arrival order, then run
@@ -175,7 +178,7 @@ export class System extends Query {
175
178
  this._exitCallback(event.entity, event.snapshot);
176
179
  break;
177
180
  case 2 /* InboxCommand.Update */:
178
- const callback = this._componentUpdateCallbacks.get(event.meta.eid);
181
+ const callback = this._componentUpdateCallbacks.get(event.eid);
179
182
  if (callback) {
180
183
  callback(event.entity, event.component);
181
184
  }
@@ -187,7 +190,7 @@ export class System extends Query {
187
190
  this._runCallback(now, tickDelta);
188
191
  }
189
192
  if (this._eachCallback) {
190
- this.forEach(this._eachCallback);
193
+ this._forEach(this._eachCallback);
191
194
  }
192
195
  });
193
196
  }
@@ -208,11 +211,18 @@ export class System extends Query {
208
211
  world._registerTickSource(this);
209
212
  this._tickSource._register(world);
210
213
  }
214
+ /** Place this system after a phase entity in the world pipeline. */
215
+ phase(phase) {
216
+ this._assertConfigurable();
217
+ const target = (typeof phase === "string" ? this.world.entity(phase) : phase).add(Phase);
218
+ this.entity.set(DependsOn, { target });
219
+ return this;
220
+ }
211
221
  /**
212
222
  * Run this system at a fixed interval, expressed in seconds.
213
223
  *
214
- * This is seconds, unlike `World.beginFrame`, `World.progress`, and
215
- * `runPhase`, which receive millisecond deltas. Calling `interval` replaces
224
+ * This is seconds, unlike `World.beginFrame` and `World.progress`, which
225
+ * receive millisecond deltas. Calling `interval` replaces
216
226
  * the current cadence source with an {@link IntervalTickSource}. When this
217
227
  * system has a cadence source, the `delta` passed to {@link run} is the
218
228
  * accumulated milliseconds since the previous fire, not the per-frame delta.
@@ -264,31 +274,6 @@ export class System extends Query {
264
274
  this._tickSource = source;
265
275
  source._register(this.world);
266
276
  }
267
- /**
268
- * Assign this system to a pipeline phase.
269
- *
270
- * Pass either a phase name (resolved at {@link World.start}) or an
271
- * {@link IPhase} reference returned from {@link World.addPhase}. Systems
272
- * with no explicit phase fall into the built-in `"update"` phase.
273
- *
274
- * @param p - Phase name or `IPhase` reference.
275
- * @returns This system, for chaining.
276
- * @throws When the phase reference is not a `Phase`, or belongs to a
277
- * different world.
278
- */
279
- phase(p) {
280
- this._assertConfigurable();
281
- if (typeof p !== "string") {
282
- if (!(p instanceof Phase)) {
283
- throw new Error("Invalid Phase object");
284
- }
285
- if (p.world !== this.world) {
286
- throw new Error("Phase does not belong to this system's world");
287
- }
288
- }
289
- this._phase = p;
290
- return this;
291
- }
292
277
  /**
293
278
  * Register a per-tick callback fired every time this system's phase runs,
294
279
  * regardless of entity membership.
@@ -320,37 +305,18 @@ export class System extends Query {
320
305
  return this;
321
306
  }
322
307
  /**
323
- * Set the entity-membership predicate using a {@link QueryDSL} expression.
324
- *
325
- * Replaces any implicit query derived from `update` watchlists and any
326
- * previous `requires` call. After calling `query`, watchlist auto-expansion
327
- * via `update` is disabled.
308
+ * Add entity-membership predicates using {@link QuerySpec} expressions.
328
309
  *
329
- * The optional `_guaranteed` tuple is a pure type-level hint — see
330
- * {@link Query.query} for details.
331
- *
332
- * @param q - Query expression.
333
- * @param _guaranteed - Component classes guaranteed present on every matched
334
- * entity (type hint only — not validated at runtime).
335
- * @returns This system, retyped with the guaranteed tuple as its `R`.
336
- */
337
- query(q, _guaranteed) {
338
- super.query(q, _guaranteed);
339
- return this;
340
- }
341
- /**
342
- * Shorthand for `query([...components])` — tracks entities that have **all**
343
- * of the listed component types.
310
+ * Merges with any existing predicate using `all`. After calling `with`,
311
+ * watchlist auto-expansion via `update` is disabled.
344
312
  *
345
- * Equivalent to `query(components)`. The listed components are also
346
- * recorded in the type parameter `R`, so {@link sort}, {@link each}, and
347
- * {@link update} callbacks treat them as non-nullable.
313
+ * `hint` fields are pure type-level hints see {@link Query.with} for details.
348
314
  *
349
- * @param components - Component classes to require.
350
- * @returns This system, retyped with the required tuple as its `R`.
315
+ * @param specs - Query specifications to add.
316
+ * @returns This system, retyped with the guaranteed components added to `R`.
351
317
  */
352
- requires(...components) {
353
- super.requires(...components);
318
+ with(...specs) {
319
+ super.with(...specs);
354
320
  return this;
355
321
  }
356
322
  /**
@@ -380,7 +346,7 @@ export class System extends Query {
380
346
  *
381
347
  * @example
382
348
  * ```ts
383
- * const sys = world.system("AI").requires(Enemy).run(runAI);
349
+ * const sys = world.system("AI").with(Enemy).run(runAI);
384
350
  * // Pause AI processing during a cutscene:
385
351
  * sys.disable();
386
352
  * // Resume:
@@ -1 +1 @@
1
- {"version":3,"file":"system.js","sourceRoot":"","sources":["../src/system.ts"],"names":[],"mappings":"AACA,OAAO,EACL,cAAc,EAEd,mBAAmB,EACnB,SAAS,GAIV,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,0BAA0B,EAAE,KAAK,EAAsB,MAAM,kBAAkB,CAAC;AACzF,OAAO,EAAE,gBAAgB,EAAiB,MAAM,UAAU,CAAC;AAE3D,OAAO,EAAE,KAAK,EAAe,MAAM,YAAY,CAAC;AAEhD,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAElB,cAAc,GACf,MAAM,YAAY,CAAC;AAiCpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,MAAM,OAAO,MAAuC,SAAQ,KAAQ;IAgBlE,YAAY,IAAY,EAAE,KAAY;QACpC,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;QAhB5B,wEAAwE;QACvD,WAAM,GAAwB,EAAE,CAAC;QASlD,yEAAyE;QACjE,aAAQ,GAAG,IAAI,CAAC;QACxB,yEAAyE;QACjE,gBAAW,GAAgB,kBAAkB,CAAC;QAIpD,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACnC,CAAC;IAED,0FAA0F;IAC1E,MAAM;QACpB,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,IAAI,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YAC3D,IAAI,CAAC,OAAO,EAA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CAAC;QACb,MAAM,OAAO,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;QAChC,MAAM,UAAU,GAAG,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAgC,CAAC;QACvF,MAAM,QAAQ,GAAG,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAG3C,CAAC;QACV,IAAI,CAAC,aAAa,GAAG,mBAAmB,CAAC,IAAI,CAAC,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;QACpF,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;;;;;OAUG;IACa,IAAI,CAClB,GAAG,KAAa;QAEhB,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC;QACrB,OAAO,IAA8B,CAAC;IACxC,CAAC;IAED;;OAEG;IACa,OAAO,CAAC,GAAG,KAAY;QACrC,MAAM,IAAI,KAAK,CAAC,oEAAoE,CAAC,CAAC;IACxF,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACI,OAAO;QACZ,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;QACtB,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;QACvB,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;;;;;;OAWG;IACI,MAAM;QACX,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,qDAAqD;IACrC,OAAO;QACrB,IAAI,CAAC,OAAO,EAAE,CAAC;QACf,KAAK,CAAC,OAAO,EAAE,CAAC;IAClB,CAAC;CACF"}
@@ -1,7 +1,7 @@
1
1
  import type { QueryDSL } from "../dsl.js";
2
2
  import type { World } from "../world/index.js";
3
3
  import { Term } from "./term.js";
4
- import { type MergedInfo } from "./predicate_term.js";
4
+ import { type CompositePrecheck } from "./composite_build.js";
5
5
  import type { getTerm as GetTermFn } from "./build.js";
6
6
  /**
7
7
  * Composite term that matches entities present in **all** of its children.
@@ -24,9 +24,5 @@ export declare class AllTerm extends Term {
24
24
  * @param onDestroy - Called when the last consumer unsubscribes.
25
25
  * @returns An `AllTerm` or, on diamond, a `PredicateTerm` with `kind === "merged"`.
26
26
  */
27
- static build(world: World, terms: readonly QueryDSL[], key: string, originalDSL: QueryDSL, getTerm: typeof GetTermFn, precheck: (terms: readonly QueryDSL[]) => {
28
- hasDiamond: boolean;
29
- containsTarget: boolean;
30
- info: MergedInfo;
31
- }, onDestroy: (term: Term) => void): Term;
27
+ static build(world: World, terms: readonly QueryDSL[], key: string, originalDSL: QueryDSL, getTerm: typeof GetTermFn, precheck: CompositePrecheck, onDestroy: (term: Term) => void): Term;
32
28
  }
@@ -1,5 +1,5 @@
1
1
  import { Term } from "./term.js";
2
- import { PredicateTerm } from "./predicate_term.js";
2
+ import { buildCompositeTerm } from "./composite_build.js";
3
3
  /**
4
4
  * Composite term that matches entities present in **all** of its children.
5
5
  *
@@ -26,12 +26,7 @@ export class AllTerm extends Term {
26
26
  * @returns An `AllTerm` or, on diamond, a `PredicateTerm` with `kind === "merged"`.
27
27
  */
28
28
  static build(world, terms, key, originalDSL, getTerm, precheck, onDestroy) {
29
- const checked = precheck(terms);
30
- if (checked.hasDiamond && !checked.containsTarget) {
31
- return PredicateTerm.buildMerged(world, originalDSL, key, checked.info, getTerm, onDestroy);
32
- }
33
- const children = terms.map((dsl) => getTerm(world, dsl));
34
- return new AllTerm(world, key, children, onDestroy);
29
+ return buildCompositeTerm(AllTerm, world, terms, key, originalDSL, getTerm, precheck, onDestroy);
35
30
  }
36
31
  /** @internal */
37
32
  _matches(entity) {
@@ -1 +1 @@
1
- {"version":3,"file":"all_term.js","sourceRoot":"","sources":["../../src/terms/all_term.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OA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OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,kBAAkB,EAA0B,MAAM,sBAAsB,CAAC;AAGlF;;;;;GAKG;AACH,MAAM,OAAO,OAAQ,SAAQ,IAAI;IAC/B,YACE,KAAY,EACZ,GAAW,EACX,QAAyB,EACzB,SAA+B;QAE/B,KAAK,CAAC,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;QAC3C,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;QAC5B,IAAI,CAAC,oBAAoB,EAAE,CAAC;IAC9B,CAAC;IAED;;;;;;;;;;;;OAYG;IACI,MAAM,CAAC,KAAK,CACjB,KAAY,EACZ,KAA0B,EAC1B,GAAW,EACX,WAAqB,EACrB,OAAyB,EACzB,QAA2B,EAC3B,SAA+B;QAE/B,OAAO,kBAAkB,CACvB,OAAO,EACP,KAAK,EACL,KAAK,EACL,GAAG,EACH,WAAW,EACX,OAAO,EACP,QAAQ,EACR,SAAS,CACV,CAAC;IACJ,CAAC;IAED,gBAAgB;IACN,QAAQ,CAAC,MAAc;QAC/B,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;IAC5D,CAAC;CACF"}
@@ -1,7 +1,7 @@
1
1
  import type { QueryDSL } from "../dsl.js";
2
2
  import type { World } from "../world/index.js";
3
3
  import { Term } from "./term.js";
4
- import { type MergedInfo } from "./predicate_term.js";
4
+ import { type CompositePrecheck } from "./composite_build.js";
5
5
  import type { getTerm as GetTermFn } from "./build.js";
6
6
  /**
7
7
  * Composite term that matches entities present in **at least one** of its
@@ -25,9 +25,5 @@ export declare class AnyTerm extends Term {
25
25
  * @param onDestroy - Called when the last consumer unsubscribes.
26
26
  * @returns An `AnyTerm` or, on diamond, a `PredicateTerm` with `kind === "merged"`.
27
27
  */
28
- static build(world: World, terms: readonly QueryDSL[], key: string, originalDSL: QueryDSL, getTerm: typeof GetTermFn, precheck: (terms: readonly QueryDSL[]) => {
29
- hasDiamond: boolean;
30
- containsTarget: boolean;
31
- info: MergedInfo;
32
- }, onDestroy: (term: Term) => void): Term;
28
+ static build(world: World, terms: readonly QueryDSL[], key: string, originalDSL: QueryDSL, getTerm: typeof GetTermFn, precheck: CompositePrecheck, onDestroy: (term: Term) => void): Term;
33
29
  }
@@ -1,5 +1,5 @@
1
1
  import { Term } from "./term.js";
2
- import { PredicateTerm } from "./predicate_term.js";
2
+ import { buildCompositeTerm } from "./composite_build.js";
3
3
  /**
4
4
  * Composite term that matches entities present in **at least one** of its
5
5
  * children.
@@ -27,12 +27,7 @@ export class AnyTerm extends Term {
27
27
  * @returns An `AnyTerm` or, on diamond, a `PredicateTerm` with `kind === "merged"`.
28
28
  */
29
29
  static build(world, terms, key, originalDSL, getTerm, precheck, onDestroy) {
30
- const checked = precheck(terms);
31
- if (checked.hasDiamond && !checked.containsTarget) {
32
- return PredicateTerm.buildMerged(world, originalDSL, key, checked.info, getTerm, onDestroy);
33
- }
34
- const children = terms.map((dsl) => getTerm(world, dsl));
35
- return new AnyTerm(world, key, children, onDestroy);
30
+ return buildCompositeTerm(AnyTerm, world, terms, key, originalDSL, getTerm, precheck, onDestroy);
36
31
  }
37
32
  /** @internal */
38
33
  _matches(entity) {
@@ -1 +1 @@
1
- {"version":3,"file":"any_term.js","sourceRoot":"","sources":["../../src/terms/any_term.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,aAAa,EAAmB,MAAM,qBAAqB,CAAC;AAGrE;;;;;;GAMG;AACH,MAAM,OAAO,OAAQ,SAAQ,IAAI;IAC/B,YACE,KAAY,EACZ,GAAW,EACX,QAAyB,EACzB,SAA+B;QAE/B,KAAK,CAAC,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,CAAC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,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;QAC3C,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;QAC5B,IAAI,CAAC,oBAAoB,EAAE,CAAC;IAC9B,CAAC;IAED;;;;;;;;;;;;OAYG;IACI,MAAM,CAAC,KAAK,CACjB,KAAY,EACZ,KAA0B,EAC1B,GAAW,EACX,WAAqB,EACrB,OAAyB,EACzB,QAA2B,EAC3B,SAA+B;QAE/B,OAAO,kBAAkB,CACvB,OAAO,EACP,KAAK,EACL,KAAK,EACL,GAAG,EACH,WAAW,EACX,OAAO,EACP,QAAQ,EACR,SAAS,CACV,CAAC;IACJ,CAAC;IAED,gBAAgB;IACN,QAAQ,CAAC,MAAc;QAC/B,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;IAC3D,CAAC;CACF"}
@@ -1,6 +1,6 @@
1
1
  import { type QueryDSL } from "../dsl.js";
2
2
  import type { World } from "../world/index.js";
3
- import type { Entity } from "../entity/index.js";
3
+ import type { EID, Entity } from "../entity/index.js";
4
4
  import { Term } from "./term.js";
5
5
  /**
6
6
  * Canonicalize `dsl`, look up or create its term in the world cache, and
@@ -18,7 +18,9 @@ export declare function getTerm(world: World, dsl: QueryDSL): Term;
18
18
  /**
19
19
  * Return the cached term for `dsl` without creating one if absent.
20
20
  *
21
- * Useful for introspection and testing; does not simplify the DSL.
21
+ * Useful for introspection and testing. It canonicalizes `dsl` (via the same
22
+ * simplify + cache-key path as {@link getTerm}) to look the term up, but never
23
+ * creates one.
22
24
  *
23
25
  * @param world - Owning world.
24
26
  * @param dsl - Query DSL expression to look up.
@@ -31,7 +33,7 @@ export declare function getCachedTerm(world: World, dsl: QueryDSL): Term | undef
31
33
  * Routes to the corresponding `ComponentTerm` (membership enter) and to the
32
34
  * world term (shape change, needed by `only` and merged predicate terms).
33
35
  */
34
- export declare function notifyComponentAdded(world: World, componentEid: number, entity: Entity): void;
36
+ export declare function notifyComponentAdded(world: World, componentEid: EID, entity: Entity): void;
35
37
  /**
36
38
  * Notify the term graph that a component of `componentEid` changed value on
37
39
  * `entity` without a membership change.
@@ -39,18 +41,19 @@ export declare function notifyComponentAdded(world: World, componentEid: number,
39
41
  * Routes only to the `ComponentTerm`'s refresh channel (not shape), which
40
42
  * wakes predicate terms watching this component.
41
43
  */
42
- export declare function notifyComponentChanged(world: World, componentEid: number, entity: Entity): void;
44
+ export declare function notifyComponentChanged(world: World, componentEid: EID, entity: Entity): void;
43
45
  /**
44
46
  * Notify the term graph that `componentEid` was removed from `entity`.
45
47
  *
46
48
  * Routes to the `ComponentTerm` (membership exit) and world term (shape).
47
49
  */
48
- export declare function notifyComponentRemoved(world: World, componentEid: number, entity: Entity): void;
50
+ export declare function notifyComponentRemoved(world: World, componentEid: EID, entity: Entity): void;
49
51
  /**
50
52
  * Notify the term graph that a new entity was created.
51
53
  *
52
54
  * The world term evaluates the entity immediately and emits an enter event if
53
- * it qualifies (i.e. it is not a `Component` instance).
55
+ * it qualifies (any live, non-destroyed entity component-definition entities
56
+ * included, so they are picked up reactively like ordinary entities).
54
57
  */
55
58
  export declare function notifyEntityCreated(world: World, entity: Entity): void;
56
59
  /**