@vworlds/vecs 1.0.15 → 1.0.17

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 (181) hide show
  1. package/README.md +249 -119
  2. package/dist/component.d.ts +52 -76
  3. package/dist/component.js +60 -45
  4. package/dist/component.js.map +1 -1
  5. package/dist/component_meta.d.ts +98 -0
  6. package/dist/component_meta.js +65 -0
  7. package/dist/component_meta.js.map +1 -0
  8. package/dist/dsl.d.ts +46 -34
  9. package/dist/dsl.js +459 -61
  10. package/dist/dsl.js.map +1 -1
  11. package/dist/entity/entity.base.d.ts +57 -0
  12. package/dist/entity/entity.base.js +81 -0
  13. package/dist/entity/entity.base.js.map +1 -0
  14. package/dist/entity/entity.components.d.ts +117 -0
  15. package/dist/entity/entity.components.js +244 -0
  16. package/dist/entity/entity.components.js.map +1 -0
  17. package/dist/entity/entity.d.ts +35 -0
  18. package/dist/entity/entity.identity.d.ts +8 -0
  19. package/dist/entity/entity.identity.js +15 -0
  20. package/dist/entity/entity.identity.js.map +1 -0
  21. package/dist/entity/entity.js +33 -0
  22. package/dist/entity/entity.js.map +1 -0
  23. package/dist/entity/entity.lifecycle.d.ts +12 -0
  24. package/dist/entity/entity.lifecycle.js +111 -0
  25. package/dist/entity/entity.lifecycle.js.map +1 -0
  26. package/dist/entity/entity.queries.d.ts +3 -0
  27. package/dist/entity/entity.queries.js +33 -0
  28. package/dist/entity/entity.queries.js.map +1 -0
  29. package/dist/entity/entity.relationships.d.ts +9 -0
  30. package/dist/entity/entity.relationships.js +74 -0
  31. package/dist/entity/entity.relationships.js.map +1 -0
  32. package/dist/entity/index.d.ts +2 -0
  33. package/dist/entity/index.js +3 -0
  34. package/dist/entity/index.js.map +1 -0
  35. package/dist/filter.d.ts +27 -8
  36. package/dist/filter.js +33 -18
  37. package/dist/filter.js.map +1 -1
  38. package/dist/index.d.ts +13 -5
  39. package/dist/index.js +13 -2
  40. package/dist/index.js.map +1 -1
  41. package/dist/inject.d.ts +80 -0
  42. package/dist/inject.js +270 -0
  43. package/dist/inject.js.map +1 -0
  44. package/dist/module.d.ts +23 -0
  45. package/dist/module.js +17 -0
  46. package/dist/module.js.map +1 -0
  47. package/dist/modules/identity.d.ts +15 -0
  48. package/dist/modules/identity.js +41 -0
  49. package/dist/modules/identity.js.map +1 -0
  50. package/dist/modules/singleton.d.ts +26 -0
  51. package/dist/modules/singleton.js +41 -0
  52. package/dist/modules/singleton.js.map +1 -0
  53. package/dist/package.json +12 -1
  54. package/dist/phase.d.ts +2 -2
  55. package/dist/query/index.d.ts +6 -0
  56. package/dist/query/index.js +5 -0
  57. package/dist/query/index.js.map +1 -0
  58. package/dist/query/query.00.base.d.ts +23 -0
  59. package/dist/query/query.00.base.js +77 -0
  60. package/dist/query/query.00.base.js.map +1 -0
  61. package/dist/query/query.01.reactive.d.ts +7 -0
  62. package/dist/query/query.01.reactive.js +58 -0
  63. package/dist/query/query.01.reactive.js.map +1 -0
  64. package/dist/query/query.02.lifecycle.d.ts +6 -0
  65. package/dist/query/query.02.lifecycle.js +63 -0
  66. package/dist/query/query.02.lifecycle.js.map +1 -0
  67. package/dist/query/query.03.tracking.d.ts +15 -0
  68. package/dist/query/query.03.tracking.js +31 -0
  69. package/dist/query/query.03.tracking.js.map +1 -0
  70. package/dist/query/query.04.callbacks.d.ts +14 -0
  71. package/dist/query/query.04.callbacks.js +65 -0
  72. package/dist/query/query.04.callbacks.js.map +1 -0
  73. package/dist/query/query.05.updates.d.ts +14 -0
  74. package/dist/query/query.05.updates.js +81 -0
  75. package/dist/query/query.05.updates.js.map +1 -0
  76. package/dist/query/query.06.predicate.d.ts +13 -0
  77. package/dist/query/query.06.predicate.js +40 -0
  78. package/dist/query/query.06.predicate.js.map +1 -0
  79. package/dist/query/query.07.groups.d.ts +41 -0
  80. package/dist/query/query.07.groups.js +110 -0
  81. package/dist/query/query.07.groups.js.map +1 -0
  82. package/dist/query/query.d.ts +53 -0
  83. package/dist/query/query.js +138 -0
  84. package/dist/query/query.js.map +1 -0
  85. package/dist/relationship.d.ts +19 -0
  86. package/dist/relationship.js +18 -0
  87. package/dist/relationship.js.map +1 -0
  88. package/dist/system.d.ts +37 -23
  89. package/dist/system.js +80 -64
  90. package/dist/system.js.map +1 -1
  91. package/dist/terms/all_term.d.ts +32 -0
  92. package/dist/terms/all_term.js +41 -0
  93. package/dist/terms/all_term.js.map +1 -0
  94. package/dist/terms/any_term.d.ts +33 -0
  95. package/dist/terms/any_term.js +42 -0
  96. package/dist/terms/any_term.js.map +1 -0
  97. package/dist/terms/build.d.ts +62 -0
  98. package/dist/terms/build.js +382 -0
  99. package/dist/terms/build.js.map +1 -0
  100. package/dist/terms/component_term.d.ts +37 -0
  101. package/dist/terms/component_term.js +49 -0
  102. package/dist/terms/component_term.js.map +1 -0
  103. package/dist/terms/empty_term.d.ts +6 -0
  104. package/dist/terms/empty_term.js +12 -0
  105. package/dist/terms/empty_term.js.map +1 -0
  106. package/dist/terms/index.d.ts +11 -0
  107. package/dist/terms/index.js +12 -0
  108. package/dist/terms/index.js.map +1 -0
  109. package/dist/terms/not_term.d.ts +35 -0
  110. package/dist/terms/not_term.js +47 -0
  111. package/dist/terms/not_term.js.map +1 -0
  112. package/dist/terms/only_term.d.ts +47 -0
  113. package/dist/terms/only_term.js +79 -0
  114. package/dist/terms/only_term.js.map +1 -0
  115. package/dist/terms/predicate_term.d.ts +80 -0
  116. package/dist/terms/predicate_term.js +109 -0
  117. package/dist/terms/predicate_term.js.map +1 -0
  118. package/dist/terms/target_term.d.ts +43 -0
  119. package/dist/terms/target_term.js +87 -0
  120. package/dist/terms/target_term.js.map +1 -0
  121. package/dist/terms/term.d.ts +94 -0
  122. package/dist/terms/term.js +202 -0
  123. package/dist/terms/term.js.map +1 -0
  124. package/dist/terms/world_term.d.ts +68 -0
  125. package/dist/terms/world_term.js +99 -0
  126. package/dist/terms/world_term.js.map +1 -0
  127. package/dist/timer.js +2 -2
  128. package/dist/timer.js.map +1 -1
  129. package/dist/util/array_map.js +12 -0
  130. package/dist/util/array_map.js.map +1 -1
  131. package/dist/util/bitset.js +107 -22
  132. package/dist/util/bitset.js.map +1 -1
  133. package/dist/util/dense_set.d.ts +1 -0
  134. package/dist/util/dense_set.js +90 -0
  135. package/dist/util/dense_set.js.map +1 -0
  136. package/dist/util/id_pool.d.ts +30 -0
  137. package/dist/util/id_pool.js +222 -0
  138. package/dist/util/id_pool.js.map +1 -0
  139. package/dist/world/index.d.ts +3 -0
  140. package/dist/world/index.js +3 -0
  141. package/dist/world/index.js.map +1 -0
  142. package/dist/world/world.base.d.ts +6 -0
  143. package/dist/world/world.base.js +21 -0
  144. package/dist/world/world.base.js.map +1 -0
  145. package/dist/world/world.components.d.ts +67 -0
  146. package/dist/world/world.components.js +93 -0
  147. package/dist/world/world.components.js.map +1 -0
  148. package/dist/world/world.d.ts +29 -0
  149. package/dist/world/world.deferred.d.ts +13 -0
  150. package/dist/world/world.deferred.js +93 -0
  151. package/dist/world/world.deferred.js.map +1 -0
  152. package/dist/world/world.entities.d.ts +18 -0
  153. package/dist/world/world.entities.js +97 -0
  154. package/dist/world/world.entities.js.map +1 -0
  155. package/dist/world/world.js +39 -0
  156. package/dist/world/world.js.map +1 -0
  157. package/dist/world/world.modules.d.ts +12 -0
  158. package/dist/world/world.modules.js +21 -0
  159. package/dist/world/world.modules.js.map +1 -0
  160. package/dist/world/world.pipeline.d.ts +21 -0
  161. package/dist/world/world.pipeline.js +106 -0
  162. package/dist/world/world.pipeline.js.map +1 -0
  163. package/dist/world/world.pools.d.ts +9 -0
  164. package/dist/world/world.pools.js +63 -0
  165. package/dist/world/world.pools.js.map +1 -0
  166. package/dist/world/world.queries.d.ts +18 -0
  167. package/dist/world/world.queries.js +101 -0
  168. package/dist/world/world.queries.js.map +1 -0
  169. package/dist/world/world.storage.d.ts +7 -0
  170. package/dist/world/world.storage.js +26 -0
  171. package/dist/world/world.storage.js.map +1 -0
  172. package/package.json +12 -1
  173. package/dist/entity.d.ts +0 -215
  174. package/dist/entity.js +0 -457
  175. package/dist/entity.js.map +0 -1
  176. package/dist/query.d.ts +0 -251
  177. package/dist/query.js +0 -353
  178. package/dist/query.js.map +0 -1
  179. package/dist/world.d.ts +0 -389
  180. package/dist/world.js +0 -631
  181. package/dist/world.js.map +0 -1
package/dist/query.d.ts DELETED
@@ -1,251 +0,0 @@
1
- import { type ComponentClass } from "./component.js";
2
- import type { Entity } from "./entity.js";
3
- import { type World } from "./world.js";
4
- import { type EntityTestFunc, type QueryDSL, type MaybeRequired } from "./dsl.js";
5
- export type { EntityTestFunc, QueryDSL, MaybeRequired };
6
- /** Component class, or `{ parent: ComponentClass }` to resolve from the entity's parent. */
7
- type ComponentOrParent = ComponentClass | {
8
- parent: ComponentClass;
9
- };
10
- /** Resolves the component instance type for one element of a `ComponentOrParent` tuple. */
11
- type ComponentInstance<T> = T extends {
12
- parent: ComponentClass;
13
- } ? InstanceType<T["parent"]> : T extends ComponentClass ? InstanceType<T> : never;
14
- /**
15
- * A reactive, always-up-to-date set of entities matching a {@link QueryDSL}
16
- * predicate.
17
- *
18
- * `Query` listens to entity / component mutations through the world's command
19
- * queue and tracks which entities currently satisfy its predicate. It fires
20
- * `enter`, `exit`, and `update` callbacks as the matched set changes. The
21
- * tracked set is exposed via {@link entities} and {@link forEach}.
22
- *
23
- * Callbacks fire **synchronously** when the world routes a command — so
24
- * mutations made inside one of these callbacks are themselves observed
25
- * immediately by other queries / systems.
26
- *
27
- * {@link System} extends `Query` and queues callbacks into an inbox replayed
28
- * during `_run` instead of firing them immediately. Use `Query` directly when
29
- * you want a reactive entity set without pipeline integration.
30
- *
31
- * @typeParam R - Component classes guaranteed present on every matched entity
32
- * (declared via {@link requires} or the `_guaranteed` hint of {@link query}).
33
- * Components in `R` appear as non-nullable in {@link sort}, {@link forEach},
34
- * and {@link update} callback tuples.
35
- */
36
- export declare class Query<R extends ComponentClass[] = []> {
37
- /** Unique display name; appears in logs and debug output. */
38
- readonly name: string;
39
- /** World that owns this query. */
40
- readonly world: World;
41
- constructor(
42
- /** Unique display name; appears in logs and debug output. */
43
- name: string,
44
- /** World that owns this query. */
45
- world: World, track?: boolean);
46
- /**
47
- * Read-only view of the entities currently tracked by this query.
48
- *
49
- * Populated as entities enter and removed as they exit. Empty unless
50
- * tracking is enabled — that is the default for standalone queries created
51
- * via {@link World.query}, but {@link System} requires an explicit
52
- * {@link track}, {@link sort}, or `each` call.
53
- */
54
- get entities(): ReadonlySet<Entity>;
55
- /** Returns the query name. */
56
- toString(): string;
57
- /**
58
- * Enable entity tracking: matched entities are inserted into {@link entities}
59
- * as they enter and removed as they exit.
60
- *
61
- * Idempotent. When called after {@link World.start}, immediately backfills
62
- * every existing entity that satisfies the current predicate.
63
- *
64
- * @returns This query, for chaining.
65
- */
66
- track(): this;
67
- /** Returns `true` when `e` satisfies this query's predicate. */
68
- belongs(e: Entity): boolean;
69
- /**
70
- * Iterate every entity currently tracked by this query.
71
- *
72
- * Mutations made by `callback` are buffered into the world command queue
73
- * and only become visible after iteration finishes. Nested iteration inside
74
- * an already-deferred context (a system, an outer `forEach`) inherits the
75
- * outer scope and does not drain on exit.
76
- *
77
- * @param callback - Invoked once per tracked entity, in insertion order
78
- * (or sort order when {@link sort} is configured).
79
- */
80
- forEach(callback: (e: Entity) => void): void;
81
- /**
82
- * Iterate every tracked entity with component injection.
83
- *
84
- * Components covered by {@link requires} (or the `_guaranteed` hint of
85
- * {@link query}) are non-nullable in the resolved tuple; any other
86
- * requested component may be `undefined` if the entity lacks it.
87
- *
88
- * @param components - Component classes to resolve from each entity.
89
- * @param callback - Receives the entity and a tuple of resolved component
90
- * instances.
91
- */
92
- forEach<J extends ComponentClass[]>(components: readonly [...J], callback: (e: Entity, resolved: {
93
- [K in keyof J]: MaybeRequired<J[K], R>;
94
- }) => void): void;
95
- /**
96
- * Register a callback invoked when an entity **enters** this query (i.e.
97
- * first satisfies the predicate), with injected components.
98
- *
99
- * @param inject - Ordered list of component classes (or `{ parent: C }`) to
100
- * resolve from the entering entity and pass to `callback`.
101
- * @param callback - Receives the entity and the resolved component tuple.
102
- * @returns This query, for chaining.
103
- *
104
- * @example
105
- * ```ts
106
- * query.enter([Position, Sprite], (e, [pos, sprite]) => {
107
- * sprite.initialize(scene);
108
- * sprite.sprite.setPosition(pos.x, pos.y);
109
- * });
110
- * ```
111
- */
112
- enter<J extends ComponentOrParent[]>(inject: readonly [...J], callback: (e: Entity, injected: {
113
- [K in keyof J]: ComponentInstance<J[K]>;
114
- }) => void): this;
115
- /**
116
- * Register an `enter` callback without component injection.
117
- *
118
- * @param callback - Receives only the entering entity.
119
- * @returns This query, for chaining.
120
- */
121
- enter(callback: (e: Entity) => void): this;
122
- /**
123
- * Register a callback invoked when an entity **exits** this query (its
124
- * archetype no longer satisfies the predicate, or it was destroyed), with
125
- * injected components.
126
- *
127
- * Components removed in the same frame as the exit are still resolvable
128
- * because the runtime snapshots them at routing time.
129
- *
130
- * @param inject - Component classes to resolve and inject.
131
- * @param callback - Receives the entity and the resolved component tuple.
132
- * @returns This query, for chaining.
133
- */
134
- exit<J extends ComponentOrParent[]>(inject: readonly [...J], callback: (e: Entity, injected: {
135
- [K in keyof J]: ComponentInstance<J[K]>;
136
- }) => void): this;
137
- /**
138
- * Register an `exit` callback without component injection.
139
- *
140
- * @param callback - Receives only the exiting entity.
141
- * @returns This query, for chaining.
142
- */
143
- exit(callback: (e: Entity) => void): this;
144
- /**
145
- * Register a callback invoked when a component of `ComponentClass` is
146
- * modified on a tracked entity.
147
- *
148
- * On a {@link Query} the callback fires **immediately** when the world
149
- * routes the corresponding `Set` / `Modified` command. On a {@link System}
150
- * the event is buffered in the inbox and the callback fires during the
151
- * system's next `_run`.
152
- *
153
- * If no other predicate has been set on this query, the watchlist
154
- * automatically expands so `ComponentClass` is implicitly required (the
155
- * predicate becomes a `HAS` of every watched type).
156
- *
157
- * @param ComponentClass - Component class to watch.
158
- * @param callback - Receives the entity and modified component instance.
159
- * @returns This query, for chaining.
160
- *
161
- * @example
162
- * ```ts
163
- * world.system("RenderPosition")
164
- * .update(Position, (e, pos) => sprite.setPosition(pos.x, pos.y));
165
- * ```
166
- */
167
- update<C extends ComponentClass>(ComponentClass: C, callback: (e: Entity, c: InstanceType<C>) => void): this;
168
- /**
169
- * Like {@link update}, but with extra components injected from the same
170
- * entity.
171
- *
172
- * @param ComponentClass - Component class to watch.
173
- * @param inject - Additional component classes to resolve from the entity.
174
- * @param callback - Receives the entity, modified component, and injected tuple.
175
- * @returns This query, for chaining.
176
- */
177
- update<C extends ComponentClass, J extends ComponentClass[]>(ComponentClass: C, inject: readonly [...J], callback: (e: Entity, c: InstanceType<C>, injected: {
178
- [K in keyof J]: MaybeRequired<J[K], R>;
179
- }) => void): this;
180
- /**
181
- * Switch the tracked set to a sorted ordering: matched entities are stored
182
- * in the position determined by `compare`, which receives each entity and a
183
- * tuple of resolved component instances for each pair being ordered.
184
- *
185
- * Implies {@link track}.
186
- *
187
- * @param components - Component classes to resolve and pass to `compare`.
188
- * @param compare - Negative when `entityA` should sort before `entityB`, zero
189
- * for equality, positive when `entityA` should sort after `entityB`.
190
- * @returns This query, for chaining.
191
- *
192
- * @example
193
- * ```ts
194
- * world.system("Render")
195
- * .requires(Position, Sprite)
196
- * .sort([Position], (_entityA, [posA], _entityB, [posB]) => posA.z - posB.z);
197
- * ```
198
- */
199
- sort<J extends ComponentClass[]>(components: readonly [...J], compare: (entityA: Entity, a: {
200
- [K in keyof J]: MaybeRequired<J[K], R>;
201
- }, entityB: Entity, b: {
202
- [K in keyof J]: MaybeRequired<J[K], R>;
203
- }) => number): this;
204
- /**
205
- * Set the entity-membership predicate using a {@link QueryDSL} expression.
206
- *
207
- * Replaces any previous predicate. The optional `_guaranteed` tuple is a
208
- * pure type-level hint: it tells {@link sort} / {@link forEach} /
209
- * {@link update} callbacks which components are guaranteed present on every
210
- * matched entity, eliminating `| undefined` from those positions. It has no
211
- * effect at runtime.
212
- *
213
- * @param q - Query expression.
214
- * @param _guaranteed - Component classes guaranteed present on every matched
215
- * entity (type hint only — not validated at runtime).
216
- * @returns This query, retyped with the guaranteed tuple as its `R`.
217
- *
218
- * @example
219
- * ```ts
220
- * world.system("Move")
221
- * .query({ AND: [{ HAS: Position }, { HAS: Velocity }] }, [Position, Velocity])
222
- * .each([Position, Velocity], (e, [pos, vel]) => {
223
- * pos.x += vel.vx; // no ! needed
224
- * });
225
- * ```
226
- */
227
- query<T extends ComponentClass[] = []>(q: QueryDSL, _guaranteed?: readonly [...T]): Query<T>;
228
- /**
229
- * Shorthand for `query([...components])`: track entities that have **all**
230
- * of the listed component types.
231
- *
232
- * Equivalent to `query({ HAS: components })`. Unlike `query`, the listed
233
- * components are also recorded in the type parameter `R`, so {@link sort}
234
- * and {@link forEach} callbacks see them as non-nullable.
235
- *
236
- * @param components - Component classes to require.
237
- * @returns This query, retyped with the required tuple as its `R`.
238
- */
239
- requires<T extends ComponentClass[]>(...components: [...T]): Query<T>;
240
- /**
241
- * Permanently remove this query from the world.
242
- *
243
- * Every entity that currently belongs to this query has the membership
244
- * silently purged (no `exit` callbacks fire), the tracked set is cleared,
245
- * and the `world` reference is forced to `undefined`. Calling any method on
246
- * the query afterwards is **undefined behavior**.
247
- *
248
- * Not supported on {@link System} — calling it on a system throws.
249
- */
250
- destroy(): void;
251
- }
package/dist/query.js DELETED
@@ -1,353 +0,0 @@
1
- import { OrderedSet } from "./util/ordered_set.js";
2
- import { ArrayMap } from "./util/array_map.js";
3
- import { Bitset } from "./util/bitset.js";
4
- import { _HAS, _buildEntityTest, } from "./dsl.js";
5
- const EMPTY_ENTITIES = new Set();
6
- /**
7
- * A reactive, always-up-to-date set of entities matching a {@link QueryDSL}
8
- * predicate.
9
- *
10
- * `Query` listens to entity / component mutations through the world's command
11
- * queue and tracks which entities currently satisfy its predicate. It fires
12
- * `enter`, `exit`, and `update` callbacks as the matched set changes. The
13
- * tracked set is exposed via {@link entities} and {@link forEach}.
14
- *
15
- * Callbacks fire **synchronously** when the world routes a command — so
16
- * mutations made inside one of these callbacks are themselves observed
17
- * immediately by other queries / systems.
18
- *
19
- * {@link System} extends `Query` and queues callbacks into an inbox replayed
20
- * during `_run` instead of firing them immediately. Use `Query` directly when
21
- * you want a reactive entity set without pipeline integration.
22
- *
23
- * @typeParam R - Component classes guaranteed present on every matched entity
24
- * (declared via {@link requires} or the `_guaranteed` hint of {@link query}).
25
- * Components in `R` appear as non-nullable in {@link sort}, {@link forEach},
26
- * and {@link update} callback tuples.
27
- */
28
- export class Query {
29
- constructor(
30
- /** Unique display name; appears in logs and debug output. */
31
- name,
32
- /** World that owns this query. */
33
- world, track = true) {
34
- this.name = name;
35
- this.world = world;
36
- /** @internal Predicate compiled from the query DSL; defaults to "match nothing". */
37
- this._belongs = (_e) => false;
38
- /** @internal `true` once {@link query} or {@link requires} has set an explicit predicate. */
39
- this._hasQuery = false;
40
- /** @internal `enter` callback (already wraps any injection logic). */
41
- this._enterCallback = undefined;
42
- /** @internal `exit` callback (already wraps any injection logic). */
43
- this._exitCallback = undefined;
44
- /** @internal Type ids the exit callback needs snapshotted before component removal. */
45
- this._exitSnapshotTypes = undefined;
46
- /** @internal Per-component-type `update` callbacks. */
47
- this._componentUpdateCallbacks = new ArrayMap();
48
- /** @internal Bitmask of component types this query reacts to via `update`. */
49
- this._watchlistBitmask = new Bitset();
50
- world._addQuery(this);
51
- if (track) {
52
- this.track();
53
- }
54
- }
55
- /**
56
- * @internal Backfill the tracked set with every existing entity that
57
- * satisfies the current predicate. Runs inside a deferred scope so the
58
- * caller's reentrant routing remains consistent.
59
- */
60
- _backfill() {
61
- if (this._entities === undefined) {
62
- return;
63
- }
64
- this.world.defer(() => {
65
- this.world.entities.forEach((e) => {
66
- if (this.belongs(e) && !e._isInQuery(this)) {
67
- this._enter(e);
68
- }
69
- });
70
- });
71
- }
72
- /**
73
- * @internal Resolve one element of an `inject` tuple to a component
74
- * instance, falling back to `exitSnapshot` when the entity is mid-exit.
75
- */
76
- _getComponent(e, C, exitSnapshot) {
77
- if (typeof C === "number") {
78
- return exitSnapshot?.get(C) ?? e.get(C);
79
- }
80
- else {
81
- return e.parent?.get(C.parent);
82
- }
83
- }
84
- /**
85
- * @internal Resolve every element of an `inject` tuple, throwing if any
86
- * required component is missing on the entity (or its parent).
87
- */
88
- _getInjected(e, inject, exitSnapshot) {
89
- const injected = [];
90
- inject.forEach((C) => {
91
- const c = this._getComponent(e, C, exitSnapshot);
92
- if (!c) {
93
- throw "query does not contain component";
94
- }
95
- injected.push(c);
96
- });
97
- return injected;
98
- }
99
- /**
100
- * @internal Translate a tuple of component classes (or `{ parent: C }`
101
- * markers) into the corresponding type ids understood by {@link _getInjected}.
102
- */
103
- _mapInjectedClassToTypes(inject) {
104
- return inject.map((C) => {
105
- if (typeof C === "function") {
106
- return this.world.getComponentType(C);
107
- }
108
- return { parent: this.world.getComponentType(C.parent) };
109
- });
110
- }
111
- /**
112
- * @internal Add `e` to the tracked set, register query membership on the
113
- * entity, fire any registered `enter` callback, then bridge the entity's
114
- * already-attached watched components through {@link _notifyModified} so
115
- * `update` callbacks see them once on entry.
116
- *
117
- * `System` overrides this to push events into its inbox.
118
- */
119
- _enter(e) {
120
- this._entities?.add(e);
121
- e._addQueryMembership(this);
122
- this._enterCallback?.(e);
123
- e.components.forEach((c, type) => {
124
- const meta = this.world.getComponentMeta(type);
125
- if (this._watchlistBitmask.hasBit(meta.bitPtr)) {
126
- this._notifyModified(e, meta, c);
127
- }
128
- });
129
- }
130
- /**
131
- * @internal Remove `e` from the tracked set, deregister query membership,
132
- * and fire any registered `exit` callback. `System` overrides this to push
133
- * an inbox event.
134
- */
135
- _exit(e) {
136
- this._exitCallback?.(e);
137
- this._entities?.delete(e);
138
- e._removeQueryMembership(this);
139
- }
140
- /**
141
- * @internal Routing entry: when the watchlist matches, invoke the registered
142
- * `update` callback for the component type. `System` overrides this to push
143
- * an inbox event instead of firing immediately.
144
- */
145
- _notifyModified(e, meta, c) {
146
- if (!this._watchlistBitmask.hasBit(meta.bitPtr)) {
147
- return;
148
- }
149
- const callback = this._componentUpdateCallbacks.get(meta.type);
150
- if (callback) {
151
- callback(e, c);
152
- }
153
- }
154
- /**
155
- * Read-only view of the entities currently tracked by this query.
156
- *
157
- * Populated as entities enter and removed as they exit. Empty unless
158
- * tracking is enabled — that is the default for standalone queries created
159
- * via {@link World.query}, but {@link System} requires an explicit
160
- * {@link track}, {@link sort}, or `each` call.
161
- */
162
- get entities() {
163
- return this._entities ?? EMPTY_ENTITIES;
164
- }
165
- /** Returns the query name. */
166
- toString() {
167
- return this.name;
168
- }
169
- /**
170
- * Enable entity tracking: matched entities are inserted into {@link entities}
171
- * as they enter and removed as they exit.
172
- *
173
- * Idempotent. When called after {@link World.start}, immediately backfills
174
- * every existing entity that satisfies the current predicate.
175
- *
176
- * @returns This query, for chaining.
177
- */
178
- track() {
179
- this._entities ?? (this._entities = new Set());
180
- this._backfill();
181
- return this;
182
- }
183
- /** Returns `true` when `e` satisfies this query's predicate. */
184
- belongs(e) {
185
- return this._belongs(e);
186
- }
187
- forEach(componentsOrCallback, callback) {
188
- this.world.beginDefer();
189
- try {
190
- if (typeof componentsOrCallback === "function") {
191
- this._entities?.forEach(componentsOrCallback);
192
- }
193
- else {
194
- if (!this._entities || !this.world) {
195
- return;
196
- }
197
- const types = componentsOrCallback.map((C) => this.world.getComponentType(C));
198
- this._entities.forEach((e) => {
199
- const resolved = types.map((t) => e.get(t));
200
- callback(e, resolved);
201
- });
202
- }
203
- }
204
- finally {
205
- this.world.endDefer();
206
- }
207
- }
208
- enter(injectOrCallback, callback) {
209
- if (typeof injectOrCallback === "function") {
210
- this._enterCallback = injectOrCallback;
211
- }
212
- else {
213
- const inject = this._mapInjectedClassToTypes(injectOrCallback);
214
- this._enterCallback = (e) => {
215
- callback(e, this._getInjected(e, inject));
216
- };
217
- }
218
- return this;
219
- }
220
- exit(injectOrCallback, callback) {
221
- if (typeof injectOrCallback === "function") {
222
- this._exitCallback = injectOrCallback;
223
- this._exitSnapshotTypes = undefined;
224
- }
225
- else {
226
- const inject = this._mapInjectedClassToTypes(injectOrCallback);
227
- this._exitSnapshotTypes = inject.filter((t) => typeof t === "number");
228
- this._exitCallback = (e, exitSnapshot) => {
229
- callback(e, this._getInjected(e, inject, exitSnapshot));
230
- };
231
- }
232
- return this;
233
- }
234
- update(ComponentClass, injectOrCallback, callback) {
235
- const type = this.world.getComponentType(ComponentClass);
236
- if (typeof injectOrCallback === "function") {
237
- callback = injectOrCallback;
238
- this._componentUpdateCallbacks.set(type, callback);
239
- }
240
- else {
241
- const inject = injectOrCallback;
242
- const injectedComponentTypes = inject.map((C) => this.world.getComponentType(C));
243
- const cb = (e, c) => {
244
- const injected = [];
245
- injectedComponentTypes.forEach((InjectedComponentType) => {
246
- injected.push(e.get(InjectedComponentType));
247
- });
248
- if (callback) {
249
- callback(e, c, injected);
250
- }
251
- };
252
- this._componentUpdateCallbacks.set(type, cb);
253
- }
254
- this._watchlistBitmask.add(type);
255
- if (!this._hasQuery) {
256
- // Update-only queries derive membership from the watched component set.
257
- // Install that predicate before backfill so the default match-nothing
258
- // predicate is never used for update-watchlist expansion.
259
- const watchlist = this._watchlistBitmask.indices();
260
- this._belongs = _HAS(this.world, ...watchlist);
261
- this._backfill();
262
- }
263
- return this;
264
- }
265
- /**
266
- * Switch the tracked set to a sorted ordering: matched entities are stored
267
- * in the position determined by `compare`, which receives each entity and a
268
- * tuple of resolved component instances for each pair being ordered.
269
- *
270
- * Implies {@link track}.
271
- *
272
- * @param components - Component classes to resolve and pass to `compare`.
273
- * @param compare - Negative when `entityA` should sort before `entityB`, zero
274
- * for equality, positive when `entityA` should sort after `entityB`.
275
- * @returns This query, for chaining.
276
- *
277
- * @example
278
- * ```ts
279
- * world.system("Render")
280
- * .requires(Position, Sprite)
281
- * .sort([Position], (_entityA, [posA], _entityB, [posB]) => posA.z - posB.z);
282
- * ```
283
- */
284
- sort(components, compare) {
285
- const types = components.map((C) => this.world.getComponentType(C));
286
- this._entities = new OrderedSet((a, b) => compare(a, types.map((t) => a.get(t)), b, types.map((t) => b.get(t))));
287
- this._backfill();
288
- return this;
289
- }
290
- /**
291
- * Set the entity-membership predicate using a {@link QueryDSL} expression.
292
- *
293
- * Replaces any previous predicate. The optional `_guaranteed` tuple is a
294
- * pure type-level hint: it tells {@link sort} / {@link forEach} /
295
- * {@link update} callbacks which components are guaranteed present on every
296
- * matched entity, eliminating `| undefined` from those positions. It has no
297
- * effect at runtime.
298
- *
299
- * @param q - Query expression.
300
- * @param _guaranteed - Component classes guaranteed present on every matched
301
- * entity (type hint only — not validated at runtime).
302
- * @returns This query, retyped with the guaranteed tuple as its `R`.
303
- *
304
- * @example
305
- * ```ts
306
- * world.system("Move")
307
- * .query({ AND: [{ HAS: Position }, { HAS: Velocity }] }, [Position, Velocity])
308
- * .each([Position, Velocity], (e, [pos, vel]) => {
309
- * pos.x += vel.vx; // no ! needed
310
- * });
311
- * ```
312
- */
313
- query(q, _guaranteed) {
314
- this._belongs = _buildEntityTest(this.world, q);
315
- this._hasQuery = true;
316
- this._backfill();
317
- return this;
318
- }
319
- /**
320
- * Shorthand for `query([...components])`: track entities that have **all**
321
- * of the listed component types.
322
- *
323
- * Equivalent to `query({ HAS: components })`. Unlike `query`, the listed
324
- * components are also recorded in the type parameter `R`, so {@link sort}
325
- * and {@link forEach} callbacks see them as non-nullable.
326
- *
327
- * @param components - Component classes to require.
328
- * @returns This query, retyped with the required tuple as its `R`.
329
- */
330
- requires(...components) {
331
- this.query(components);
332
- return this;
333
- }
334
- /**
335
- * Permanently remove this query from the world.
336
- *
337
- * Every entity that currently belongs to this query has the membership
338
- * silently purged (no `exit` callbacks fire), the tracked set is cleared,
339
- * and the `world` reference is forced to `undefined`. Calling any method on
340
- * the query afterwards is **undefined behavior**.
341
- *
342
- * Not supported on {@link System} — calling it on a system throws.
343
- */
344
- destroy() {
345
- this.world._removeQuery(this);
346
- this._entities?.forEach((e) => e._purgeQuery(this));
347
- this._entities?.clear();
348
- this._entities = undefined;
349
- this._belongs = (_e) => false;
350
- this.world = undefined;
351
- }
352
- }
353
- //# sourceMappingURL=query.js.map
package/dist/query.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"query.js","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAI1C,OAAO,EACL,IAAI,EACJ,gBAAgB,GAIjB,MAAM,UAAU,CAAC;AAoBlB,MAAM,cAAc,GAAwB,IAAI,GAAG,EAAE,CAAC;AAEtD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,OAAO,KAAK;IAoBhB;IACE,6DAA6D;IAC7C,IAAY;IAC5B,kCAAkC;IAClB,KAAY,EAC5B,QAAiB,IAAI;QAHL,SAAI,GAAJ,IAAI,CAAQ;QAEZ,UAAK,GAAL,KAAK,CAAO;QArB9B,oFAAoF;QAC1E,aAAQ,GAAmB,CAAC,EAAU,EAAE,EAAE,CAAC,KAAK,CAAC;QAC3D,6FAA6F;QACnF,cAAS,GAAY,KAAK,CAAC;QAErC,sEAAsE;QAC5D,mBAAc,GAA+B,SAAS,CAAC;QACjE,qEAAqE;QAC3D,kBAAa,GAA+B,SAAS,CAAC;QAChE,uFAAuF;QAC7E,uBAAkB,GAAyB,SAAS,CAAC;QAE/D,uDAAuD;QAC7C,8BAAyB,GAAG,IAAI,QAAQ,EAAqB,CAAC;QACxE,8EAA8E;QACpE,sBAAiB,GAAW,IAAI,MAAM,EAAE,CAAC;QASjD,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QACtB,IAAI,KAAK,EAAE,CAAC;YACV,IAAI,CAAC,KAAK,EAAE,CAAC;QACf,CAAC;IACH,CAAC;IAED;;;;OAIG;IACK,SAAS;QACf,IAAI,IAAI,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC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