@vworlds/vecs 1.0.14 → 1.0.16

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 (187) 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 +12 -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 +18 -20
  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 +23 -0
  137. package/dist/util/id_pool.js +194 -0
  138. package/dist/util/id_pool.js.map +1 -0
  139. package/dist/util/ordered_set.js.map +1 -1
  140. package/dist/world/index.d.ts +3 -0
  141. package/dist/world/index.js +3 -0
  142. package/dist/world/index.js.map +1 -0
  143. package/dist/world/world.base.d.ts +6 -0
  144. package/dist/world/world.base.js +21 -0
  145. package/dist/world/world.base.js.map +1 -0
  146. package/dist/world/world.components.d.ts +67 -0
  147. package/dist/world/world.components.js +93 -0
  148. package/dist/world/world.components.js.map +1 -0
  149. package/dist/world/world.d.ts +29 -0
  150. package/dist/world/world.deferred.d.ts +13 -0
  151. package/dist/world/world.deferred.js +93 -0
  152. package/dist/world/world.deferred.js.map +1 -0
  153. package/dist/world/world.entities.d.ts +18 -0
  154. package/dist/world/world.entities.js +97 -0
  155. package/dist/world/world.entities.js.map +1 -0
  156. package/dist/world/world.js +39 -0
  157. package/dist/world/world.js.map +1 -0
  158. package/dist/world/world.modules.d.ts +12 -0
  159. package/dist/world/world.modules.js +21 -0
  160. package/dist/world/world.modules.js.map +1 -0
  161. package/dist/world/world.pipeline.d.ts +21 -0
  162. package/dist/world/world.pipeline.js +105 -0
  163. package/dist/world/world.pipeline.js.map +1 -0
  164. package/dist/world/world.pools.d.ts +9 -0
  165. package/dist/world/world.pools.js +59 -0
  166. package/dist/world/world.pools.js.map +1 -0
  167. package/dist/world/world.queries.d.ts +18 -0
  168. package/dist/world/world.queries.js +101 -0
  169. package/dist/world/world.queries.js.map +1 -0
  170. package/dist/world/world.storage.d.ts +7 -0
  171. package/dist/world/world.storage.js +26 -0
  172. package/dist/world/world.storage.js.map +1 -0
  173. package/package.json +18 -20
  174. package/tsconfig.build.json +13 -0
  175. package/.husky/pre-commit +0 -3
  176. package/.prettierrc +0 -7
  177. package/dist/entity.d.ts +0 -215
  178. package/dist/entity.js +0 -457
  179. package/dist/entity.js.map +0 -1
  180. package/dist/query.d.ts +0 -251
  181. package/dist/query.js +0 -353
  182. package/dist/query.js.map +0 -1
  183. package/dist/world.d.ts +0 -389
  184. package/dist/world.js +0 -631
  185. package/dist/world.js.map +0 -1
  186. package/eslint-rules/internal-underscore.js +0 -60
  187. package/eslint.config.js +0 -22
package/dist/world.d.ts DELETED
@@ -1,389 +0,0 @@
1
- import { type ComponentClass, ComponentClassOrType, ComponentMeta, Hook } from "./component.js";
2
- import { Entity } from "./entity.js";
3
- import { Query } from "./query.js";
4
- import { System } from "./system.js";
5
- import { Filter } from "./filter.js";
6
- import { type QueryDSL, type ExtractRequired } from "./dsl.js";
7
- import { IPhase } from "./phase.js";
8
- /**
9
- * The central ECS container. One world per game session.
10
- *
11
- * A `World` owns every entity, every registered component class, every
12
- * registered query / system, and the update pipeline. The typical lifecycle:
13
- *
14
- * 1. **Register components** — {@link registerComponent} (and optionally
15
- * {@link registerComponentType}) for every component class you plan to use.
16
- * 2. **Build the pipeline** — {@link addPhase} for every named phase, then
17
- * {@link system} / {@link query} for each processor.
18
- * 3. **Start** — call {@link start} to freeze component registration and
19
- * distribute systems into their phases.
20
- * 4. **Run loop** — call {@link runPhase} per phase or {@link progress} for
21
- * every phase, once per frame.
22
- *
23
- * ```ts
24
- * const world = new World();
25
- *
26
- * class Position { x = 0; y = 0; }
27
- * class Velocity { vx = 0; vy = 0; }
28
- *
29
- * world.registerComponent(Position);
30
- * world.registerComponent(Velocity);
31
- *
32
- * world.system("Move")
33
- * .requires(Position, Velocity)
34
- * .each([Position, Velocity], (e, [pos, vel]) => {
35
- * pos.x += vel.vx;
36
- * e.modified(Position);
37
- * });
38
- *
39
- * world.start();
40
- *
41
- * // game loop:
42
- * world.progress(now, delta);
43
- * ```
44
- *
45
- * ## Deferred mode
46
- *
47
- * The world can be in **deferred mode**, in which case entity mutations
48
- * (`add` / `attach` / `set` / `remove` / `destroy` / `setParent` / `modified`) are
49
- * queued instead of applied inline. Systems run inside an automatically
50
- * deferred scope; user code can wrap arbitrary blocks with
51
- * {@link beginDefer} / {@link endDefer} or {@link defer}. {@link flush}
52
- * drains the queue at top level.
53
- */
54
- export declare class World {
55
- /** Hidden property key used to store this world's meta on component classes. */
56
- readonly worldKey: string;
57
- constructor();
58
- /** Read-only view of the live entities, keyed by entity id. */
59
- get entities(): Omit<Map<number, Entity>, "set" | "delete" | "clear">;
60
- /** Read-only view of every registered query (includes systems). */
61
- get queries(): ReadonlyArray<Query>;
62
- /**
63
- * `true` while the world is in deferred mode — entity mutations are queued
64
- * rather than applied inline. Equivalent to "the queue depth is non-zero or
65
- * the world is currently draining".
66
- */
67
- get deferred(): boolean;
68
- /**
69
- * Enter deferred mode. Mutations made until the matching {@link endDefer}
70
- * are queued instead of executing inline.
71
- *
72
- * Nested `beginDefer` / `endDefer` pairs are allowed; only the outermost
73
- * `endDefer` triggers a queue drain.
74
- */
75
- beginDefer(): void;
76
- /**
77
- * Leave deferred mode. When the depth returns to zero the world drains the
78
- * command queue (firing hooks and routing enter / exit / update events).
79
- */
80
- endDefer(): void;
81
- /**
82
- * Run `fn` inside a deferred scope. Equivalent to
83
- * `beginDefer(); try { fn(); } finally { endDefer(); }`.
84
- *
85
- * @param fn - Callback executed in deferred mode.
86
- */
87
- defer(fn: () => void): void;
88
- /**
89
- * Drain any commands queued at the top level (depth 0).
90
- *
91
- * Call between phases or after batch-loading network snapshots to surface
92
- * accumulated mutations (firing hooks and routing enter / exit / update)
93
- * before the next read or system run.
94
- */
95
- flush(): void;
96
- /**
97
- * Pre-register a `componentName → typeId` mapping without binding a class.
98
- *
99
- * Useful when network messages refer to components by type id and the
100
- * corresponding class may be registered later. Call this **before**
101
- * {@link registerComponent} so the class picks up the server-assigned id
102
- * rather than a locally generated one.
103
- *
104
- * @param componentName - String name used in network payloads.
105
- * @param type - Numeric type id assigned by the server.
106
- */
107
- registerComponentType(componentName: string, type: number): void;
108
- /**
109
- * Register a component class with the world.
110
- *
111
- * Must be called before any entity uses the component. Components are plain
112
- * classes constructed with no arguments. Registration is disabled once
113
- * {@link start} (or {@link disableComponentRegistration}) is called.
114
- *
115
- * **Overloads:**
116
- * - `registerComponent(Class)` — type id auto-assigned from the
117
- * {@link registerComponentType} map, falling back to a local counter
118
- * (≥ 256) if the name is not yet mapped.
119
- * - `registerComponent(Class, type)` — explicit numeric type id.
120
- * - `registerComponent(Class, componentName)` — auto-assigned id, custom
121
- * display name (useful when the class name differs from the network name).
122
- * - `registerComponent(Class, type, componentName)` — explicit id + name.
123
- *
124
- * @param ComponentClass - Component class to register.
125
- * @returns The world-specific metadata record for the component class.
126
- * @throws When the class has already been registered in this world or
127
- * registration is disabled.
128
- */
129
- registerComponent(ComponentClass: ComponentClass): ComponentMeta;
130
- registerComponent(ComponentClass: ComponentClass, type: number): ComponentMeta;
131
- registerComponent(ComponentClass: ComponentClass, componentName?: string): ComponentMeta;
132
- registerComponent(ComponentClass: ComponentClass, type: number, componentName: string): ComponentMeta;
133
- /**
134
- * Look up the {@link ComponentMeta} for a registered component.
135
- *
136
- * @param typeOrClass - Component class or numeric type id.
137
- * @returns The corresponding meta record.
138
- * @throws When no component with that class or type id has been registered.
139
- */
140
- getComponentMeta(typeOrClass: ComponentClassOrType): ComponentMeta;
141
- /**
142
- * Resolve a component class or type id to its numeric type id.
143
- *
144
- * @param typeOrClass - Component class or numeric type id.
145
- * @returns The numeric type id.
146
- */
147
- getComponentType(typeOrClass: ComponentClassOrType): number;
148
- /**
149
- * Return the {@link Hook} for a component class.
150
- *
151
- * Hooks let you react to component lifecycle events (add / remove / set)
152
- * without building a full {@link System}. The same hook is returned on every
153
- * call — handlers stack on the underlying meta record.
154
- *
155
- * ```ts
156
- * world.hook(Sprite)
157
- * .onAdd((entity, c) => c.initialize(scene, entity))
158
- * .onRemove((entity, c) => c.destroy(scene, entity));
159
- * ```
160
- *
161
- * @param C - Component class.
162
- * @returns The hook bound to that component type.
163
- */
164
- hook<T extends ComponentClass>(C: T): Hook<InstanceType<T>>;
165
- /**
166
- * Declare a group of mutually exclusive components.
167
- *
168
- * Adding any component in the group to an entity that already has another
169
- * member of the group automatically removes the previous member. Members
170
- * not in the group are unaffected.
171
- *
172
- * ```ts
173
- * world.setExclusiveComponents(Walking, Running, Idle);
174
- * entity.add(Walking);
175
- * entity.add(Running); // Walking is removed automatically
176
- * ```
177
- *
178
- * Each call defines one independent group. A component may belong to at
179
- * most one group at a time; calling {@link setExclusiveComponents} with the
180
- * same class again overwrites its group. Safe to call before or after
181
- * {@link start}.
182
- *
183
- * @param components - Two or more component classes that cannot coexist.
184
- * @throws When any class has not been registered.
185
- */
186
- setExclusiveComponents(...components: ComponentClass[]): void;
187
- /**
188
- * Set the starting value of the auto-incrementing entity id counter.
189
- *
190
- * Must be called **before** {@link start} (or
191
- * {@link disableComponentRegistration}). Useful when the world runs
192
- * alongside a server that owns a different id range — locally created
193
- * client entities can start at a high offset to avoid collisions with
194
- * server-assigned ids.
195
- *
196
- * @param min - First id assigned by {@link entity}.
197
- * @throws When called after registration has been disabled.
198
- */
199
- setEntityIdRange(min: number): void;
200
- /**
201
- * Return the entity with id `eid`, creating it if it does not yet exist.
202
- *
203
- * Used by networking code to materialise server-assigned entities:
204
- *
205
- * ```ts
206
- * const e = world.getOrCreateEntity(snapshot.eid, (e) => {
207
- * networkEntities.add(e);
208
- * });
209
- * e.add(snapshot.type);
210
- * ```
211
- *
212
- * @param eid - Entity id to look up or create.
213
- * @param onCreateCallback - Optional callback invoked only when a new
214
- * entity is created, before it is returned. Use it to initialise
215
- * bookkeeping (e.g. tracking it in a local set).
216
- * @returns The existing or newly created entity.
217
- */
218
- getOrCreateEntity(eid: number, onCreateCallback?: (e: Entity) => void): Entity;
219
- /**
220
- * Create a new entity with an auto-assigned id.
221
- *
222
- * The id counter starts at `0` (or at the value set by
223
- * {@link setEntityIdRange}) and increments by one for each call. In
224
- * deferred mode the new entity is queued onto the command queue and is not
225
- * visible in {@link entities} until the queue drains.
226
- */
227
- entity(): Entity;
228
- /**
229
- * Look up an existing entity by id.
230
- *
231
- * @param id - Numeric entity id.
232
- * @returns The entity, or `undefined` when no entity with that id exists.
233
- */
234
- entity(id: number): Entity | undefined;
235
- /**
236
- * Destroy every entity currently tracked by the world.
237
- *
238
- * Triggers all `onRemove` hooks and `exit` callbacks. Useful when
239
- * transitioning between game sessions or resetting to a clean state.
240
- */
241
- clearAllEntities(): void;
242
- /**
243
- * Create, register, and return a new {@link System}, ready for fluent
244
- * configuration.
245
- *
246
- * ```ts
247
- * world.system("Render")
248
- * .phase("update")
249
- * .requires(Position, Sprite)
250
- * .enter([Sprite], (e, [sprite]) => sprite.initialize(scene))
251
- * .each([Position, Sprite], (e, [pos, sprite]) => sprite.draw(pos.x, pos.y));
252
- * ```
253
- *
254
- * @param name - Unique display name for the system.
255
- * @returns The new system.
256
- */
257
- system(name: string): System;
258
- /**
259
- * Create, register, and return a standalone {@link Query}, ready for fluent
260
- * configuration.
261
- *
262
- * Unlike a {@link System}, a standalone query has no phase and no per-tick
263
- * callbacks — it is a reactive entity set that can be read at any time. It
264
- * can also be created **after** {@link start}; existing matched entities
265
- * are backfilled immediately.
266
- *
267
- * ```ts
268
- * const enemies = world.query("Enemies")
269
- * .requires(Enemy, Health)
270
- * .enter((e) => console.log("enemy spawned", e.eid));
271
- *
272
- * world.start();
273
- * // enemies.entities is kept up-to-date automatically
274
- * ```
275
- *
276
- * @param name - Unique display name for the query.
277
- * @returns The new query.
278
- */
279
- query(name: string): Query;
280
- /**
281
- * Create a non-reactive {@link Filter} that matches entities satisfying `q`.
282
- *
283
- * Unlike {@link query}, the returned filter holds no tracked entity set and
284
- * registers nothing on the world. Each call to {@link Filter.forEach} walks
285
- * all current world entities and invokes the callback on the matches.
286
- *
287
- * The component classes guaranteed present on every matched entity are
288
- * inferred from the DSL where possible (plain arrays, `HAS`, `HAS_ONLY`,
289
- * and `AND` of those forms). For shapes the inferer cannot see through
290
- * (`OR`, `NOT`, `PARENT`, custom `EntityTestFunc`) supply a `_guaranteed`
291
- * tuple as a type-level override:
292
- *
293
- * ```ts
294
- * // Auto-deduced: pos and vel are non-nullable.
295
- * world.filter([Position, Velocity])
296
- * .forEach([Position, Velocity], (e, [pos, vel]) => { ... });
297
- *
298
- * // Manual override for an opaque query.
299
- * world.filter(myTestFunc, [Position])
300
- * .forEach([Position], (e, [pos]) => pos.x);
301
- * ```
302
- *
303
- * @param q - Query expression.
304
- * @param _guaranteed - Optional type hint declaring which components are
305
- * guaranteed present (not validated at runtime).
306
- */
307
- filter<Q extends QueryDSL>(q: Q): Filter<ExtractRequired<Q>>;
308
- filter<T extends ComponentClass[]>(q: QueryDSL, _guaranteed: readonly [...T]): Filter<T>;
309
- /**
310
- * Add a named phase to the update pipeline.
311
- *
312
- * Phases are executed in insertion order when {@link runPhase} or
313
- * {@link progress} is called. Systems join a phase via {@link System.phase}.
314
- *
315
- * ```ts
316
- * const preUpdate = world.addPhase("preupdate");
317
- * const update = world.addPhase("update");
318
- * const send = world.addPhase("send");
319
- * ```
320
- *
321
- * @param name - Unique phase name. Systems can reference it by this string.
322
- * @returns The new phase.
323
- */
324
- addPhase(name: string): IPhase;
325
- /**
326
- * Prevent any further calls to {@link registerComponent}.
327
- *
328
- * Called automatically by {@link start}. Call directly if you want to lock
329
- * registration before the rest of the systems are wired up.
330
- */
331
- disableComponentRegistration(): void;
332
- /**
333
- * Freeze component registration and prepare the world for running.
334
- *
335
- * Distributes every system registered so far into its phase (defaulting to
336
- * `"update"`) and logs the phase → system order to the console. Systems
337
- * and queries can still be created after this call — standalone queries
338
- * backfill existing matched entities immediately.
339
- *
340
- * Call once before the first {@link runPhase} / {@link progress}.
341
- */
342
- start(): void;
343
- /**
344
- * Open a new frame and evaluate every registered tick source once.
345
- *
346
- * Call this before one or more {@link runPhase} calls when manually driving
347
- * phases. {@link progress} wraps this automatically for the full pipeline.
348
- *
349
- * @param delta - Milliseconds elapsed since the previous frame.
350
- * @throws When a frame is already open.
351
- */
352
- beginFrame(delta: number): void;
353
- /**
354
- * Close the current frame.
355
- *
356
- * @throws When no frame is currently open.
357
- */
358
- endFrame(): void;
359
- /**
360
- * Execute every system in `phase` within the current frame.
361
- *
362
- * Pending top-level mutations are drained before the first system runs so
363
- * each system observes a consistent world. Each system body executes in a
364
- * deferred scope; mutations made by callbacks land in the world queue and
365
- * are processed before the next system runs.
366
- *
367
- * `runPhase` is safe to call re-entrantly from a system body: it reuses the
368
- * frame opened by {@link beginFrame} and does not advance `_frameCounter` or
369
- * re-evaluate tick sources.
370
- *
371
- * @param phase - Phase reference returned from {@link addPhase}.
372
- * @param now - Absolute timestamp in milliseconds (e.g. `Date.now()`).
373
- * @param delta - Milliseconds elapsed since the previous tick.
374
- * @throws When called outside an open frame.
375
- */
376
- runPhase(phase: IPhase, now: number, delta: number): void;
377
- /**
378
- * Run every phase in the pipeline in registration order.
379
- *
380
- * Equivalent to `beginFrame(delta)`, calling {@link runPhase} for each
381
- * phase, then {@link endFrame}. All registered tick sources are evaluated
382
- * once up front for the whole frame, and the frame is closed in a `finally`
383
- * block if a system throws.
384
- *
385
- * @param now - Absolute timestamp in milliseconds (e.g. `Date.now()`).
386
- * @param delta - Milliseconds elapsed since the previous tick.
387
- */
388
- progress(now: number, delta: number): void;
389
- }