@oasys/oecs 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +553 -0
- package/README.md +42 -31
- package/dist/core/ecs/access_check.d.cts +77 -0
- package/dist/core/ecs/access_check.d.ts +8 -8
- package/dist/core/ecs/access_check.d.ts.map +1 -1
- package/dist/core/ecs/archetype.d.cts +486 -0
- package/dist/core/ecs/archetype.d.ts +23 -11
- package/dist/core/ecs/archetype.d.ts.map +1 -1
- package/dist/core/ecs/archetype_graph.d.cts +96 -0
- package/dist/core/ecs/archetype_graph.d.ts +96 -0
- package/dist/core/ecs/archetype_graph.d.ts.map +1 -0
- package/dist/core/ecs/builtin_relations.d.cts +43 -0
- package/dist/core/ecs/builtin_relations.d.ts +8 -8
- package/dist/core/ecs/builtin_relations.d.ts.map +1 -1
- package/dist/core/ecs/command_log.d.cts +116 -0
- package/dist/core/ecs/command_log.d.ts +13 -10
- package/dist/core/ecs/command_log.d.ts.map +1 -1
- package/dist/core/ecs/component.d.cts +176 -0
- package/dist/core/ecs/component.d.ts +75 -5
- package/dist/core/ecs/component.d.ts.map +1 -1
- package/dist/core/ecs/compute_backend.d.cts +37 -0
- package/dist/core/ecs/compute_backend.d.ts +2 -2
- package/dist/core/ecs/debug_names.d.cts +7 -0
- package/dist/core/ecs/debug_names.d.ts +7 -0
- package/dist/core/ecs/debug_names.d.ts.map +1 -0
- package/dist/core/ecs/deferred_commands.d.cts +55 -0
- package/dist/core/ecs/deferred_commands.d.ts +55 -0
- package/dist/core/ecs/deferred_commands.d.ts.map +1 -0
- package/dist/core/ecs/dispatch_trace.d.cts +93 -0
- package/dist/core/ecs/dispatch_trace.d.ts +3 -3
- package/dist/core/ecs/ecs.d.cts +562 -0
- package/dist/core/ecs/ecs.d.ts +314 -285
- package/dist/core/ecs/ecs.d.ts.map +1 -1
- package/dist/core/ecs/ecs_memory.d.cts +179 -0
- package/dist/core/ecs/ecs_memory.d.ts +1 -1
- package/dist/core/ecs/entity.d.cts +34 -0
- package/dist/core/ecs/entity.d.ts +7 -1
- package/dist/core/ecs/entity.d.ts.map +1 -1
- package/dist/core/ecs/entity_allocator.d.cts +59 -0
- package/dist/core/ecs/entity_allocator.d.ts +59 -0
- package/dist/core/ecs/entity_allocator.d.ts.map +1 -0
- package/dist/core/ecs/event.d.cts +79 -0
- package/dist/core/ecs/event.d.ts +36 -11
- package/dist/core/ecs/event.d.ts.map +1 -1
- package/dist/core/ecs/event_registry.d.cts +22 -0
- package/dist/core/ecs/event_registry.d.ts +22 -0
- package/dist/core/ecs/event_registry.d.ts.map +1 -0
- package/dist/core/ecs/facades.d.cts +158 -0
- package/dist/core/ecs/facades.d.ts +158 -0
- package/dist/core/ecs/facades.d.ts.map +1 -0
- package/dist/core/ecs/frame_stepper.d.cts +58 -0
- package/dist/core/ecs/frame_stepper.d.ts +58 -0
- package/dist/core/ecs/frame_stepper.d.ts.map +1 -0
- package/dist/core/ecs/frame_trace.d.cts +133 -0
- package/dist/core/ecs/frame_trace.d.ts +5 -5
- package/dist/core/ecs/frame_trace.d.ts.map +1 -1
- package/dist/core/ecs/host_commands.d.cts +274 -0
- package/dist/core/ecs/host_commands.d.ts +53 -31
- package/dist/core/ecs/host_commands.d.ts.map +1 -1
- package/dist/core/ecs/index.d.cts +46 -0
- package/dist/core/ecs/index.d.ts +45 -40
- package/dist/core/ecs/index.d.ts.map +1 -1
- package/dist/core/ecs/observer.d.cts +173 -0
- package/dist/core/ecs/observer.d.ts +43 -12
- package/dist/core/ecs/observer.d.ts.map +1 -1
- package/dist/core/ecs/query.d.cts +718 -0
- package/dist/core/ecs/query.d.ts +251 -90
- package/dist/core/ecs/query.d.ts.map +1 -1
- package/dist/core/ecs/ref.d.cts +31 -0
- package/dist/core/ecs/ref.d.ts +3 -3
- package/dist/core/ecs/relation.d.cts +243 -0
- package/dist/core/ecs/relation.d.ts +26 -14
- package/dist/core/ecs/relation.d.ts.map +1 -1
- package/dist/core/ecs/relation_service.d.cts +235 -0
- package/dist/core/ecs/relation_service.d.ts +235 -0
- package/dist/core/ecs/relation_service.d.ts.map +1 -0
- package/dist/core/ecs/resource.d.cts +53 -0
- package/dist/core/ecs/resource.d.ts +25 -5
- package/dist/core/ecs/resource.d.ts.map +1 -1
- package/dist/core/ecs/resource_registry.d.cts +20 -0
- package/dist/core/ecs/resource_registry.d.ts +20 -0
- package/dist/core/ecs/resource_registry.d.ts.map +1 -0
- package/dist/core/ecs/resume.d.cts +85 -0
- package/dist/core/ecs/resume.d.ts +6 -6
- package/dist/core/ecs/resume.d.ts.map +1 -1
- package/dist/core/ecs/run_condition.d.cts +81 -0
- package/dist/core/ecs/run_condition.d.ts +15 -9
- package/dist/core/ecs/run_condition.d.ts.map +1 -1
- package/dist/core/ecs/schedule.d.cts +142 -0
- package/dist/core/ecs/schedule.d.ts +15 -6
- package/dist/core/ecs/schedule.d.ts.map +1 -1
- package/dist/core/ecs/snapshot_service.d.cts +94 -0
- package/dist/core/ecs/snapshot_service.d.ts +94 -0
- package/dist/core/ecs/snapshot_service.d.ts.map +1 -0
- package/dist/core/ecs/sparse_store.d.cts +110 -0
- package/dist/core/ecs/sparse_store.d.ts +5 -2
- package/dist/core/ecs/sparse_store.d.ts.map +1 -1
- package/dist/core/ecs/store.d.cts +950 -0
- package/dist/core/ecs/store.d.ts +143 -342
- package/dist/core/ecs/store.d.ts.map +1 -1
- package/dist/core/ecs/store_layout_listener.d.cts +23 -0
- package/dist/core/ecs/system.d.cts +250 -0
- package/dist/core/ecs/system.d.ts +138 -22
- package/dist/core/ecs/system.d.ts.map +1 -1
- package/dist/{utils/arrays.d.ts → core/ecs/utils/arrays.d.cts} +1 -0
- package/dist/core/ecs/utils/error.d.cts +61 -0
- package/dist/core/ecs/utils/error.d.ts +12 -2
- package/dist/core/ecs/utils/error.d.ts.map +1 -1
- package/dist/core/store/action_ring.d.cts +136 -0
- package/dist/core/store/allocator.d.cts +238 -0
- package/dist/core/store/allocator.d.ts.map +1 -1
- package/dist/core/store/buffer_backed_column.d.cts +69 -0
- package/dist/core/store/buffer_backed_column.d.ts +2 -2
- package/dist/core/store/column_store.d.cts +273 -0
- package/dist/core/store/column_store.d.ts +18 -10
- package/dist/core/store/column_store.d.ts.map +1 -1
- package/dist/core/store/command_dispatch.d.cts +52 -0
- package/dist/core/store/command_ring.d.cts +107 -0
- package/dist/core/store/descriptor.d.cts +80 -0
- package/dist/core/store/descriptor.d.ts +1 -1
- package/dist/core/store/descriptor.d.ts.map +1 -1
- package/dist/core/store/entity_index.d.cts +108 -0
- package/dist/core/store/event_ring.d.cts +95 -0
- package/dist/core/store/extend.d.cts +39 -0
- package/dist/core/store/extend.d.ts +3 -73
- package/dist/core/store/extend.d.ts.map +1 -1
- package/dist/core/store/grow.d.cts +34 -0
- package/dist/core/store/grow.d.ts +4 -9
- package/dist/core/store/grow.d.ts.map +1 -1
- package/dist/core/store/header.d.cts +64 -0
- package/dist/core/store/header.d.ts +1 -1
- package/dist/core/store/header.d.ts.map +1 -1
- package/dist/core/store/index.d.cts +17 -0
- package/dist/core/store/index.d.ts +16 -15
- package/dist/core/store/index.d.ts.map +1 -1
- package/dist/core/store/layout_ops.d.cts +152 -0
- package/dist/core/store/layout_ops.d.ts +152 -0
- package/dist/core/store/layout_ops.d.ts.map +1 -0
- package/dist/core/store/region_table.d.cts +74 -0
- package/dist/core/store/region_table.d.ts +1 -1
- package/dist/core/store/region_table.d.ts.map +1 -1
- package/dist/core/store/snapshot.d.cts +43 -0
- package/dist/core/store/snapshot.d.ts +2 -2
- package/dist/core/store/state_hash.d.cts +38 -0
- package/dist/core/store/state_hash.d.ts +1 -1
- package/dist/core/store/store_regions.d.cts +38 -0
- package/dist/core/store/store_regions.d.ts +1 -1
- package/dist/core/store/vendored_abi/abi.d.ts +43 -0
- package/dist/core/store/{__generated__ → vendored_abi}/abi.d.ts.map +1 -1
- package/dist/dev_flag.d.cts +17 -0
- package/dist/dev_flag.d.ts +17 -0
- package/dist/dev_flag.d.ts.map +1 -0
- package/dist/extensions/editor/editor.d.cts +170 -0
- package/dist/extensions/editor/editor.d.ts +43 -22
- package/dist/extensions/editor/editor.d.ts.map +1 -1
- package/dist/extensions/editor/field_handle.d.cts +40 -0
- package/dist/extensions/editor/field_handle.d.ts +8 -3
- package/dist/extensions/editor/field_handle.d.ts.map +1 -1
- package/dist/extensions/editor/index.cjs +1 -1
- package/dist/extensions/editor/index.d.cts +21 -0
- package/dist/extensions/editor/index.d.ts +2 -2
- package/dist/extensions/editor/index.js +116 -88
- package/dist/extensions/reactive/ecs_sync.d.cts +214 -0
- package/dist/extensions/reactive/ecs_sync.d.ts +26 -22
- package/dist/extensions/reactive/ecs_sync.d.ts.map +1 -1
- package/dist/extensions/reactive/index.cjs +1 -1
- package/dist/extensions/reactive/index.d.cts +23 -0
- package/dist/extensions/reactive/index.d.ts +1 -1
- package/dist/extensions/reactive/index.js +106 -116
- package/dist/extensions/solid/index.cjs +1 -1
- package/dist/extensions/solid/index.d.cts +6 -0
- package/dist/extensions/solid/index.d.ts +2 -2
- package/dist/extensions/solid/index.js +8 -4
- package/dist/extensions/solid/kernel_solid.d.cts +45 -0
- package/dist/extensions/solid/kernel_solid.d.ts +6 -3
- package/dist/extensions/solid/kernel_solid.d.ts.map +1 -1
- package/dist/host_commands-BF8QMi3c.cjs +1 -0
- package/dist/host_commands-i4cAeyL5.js +2318 -0
- package/dist/index.cjs +1 -2
- package/dist/index.d.cts +66 -0
- package/dist/index.d.ts +50 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4469 -5933
- package/dist/internal.cjs +2 -0
- package/dist/internal.d.cts +20 -0
- package/dist/internal.d.ts +20 -0
- package/dist/internal.d.ts.map +1 -0
- package/dist/internal.js +141 -0
- package/dist/primitives.cjs +1 -1
- package/dist/primitives.d.cts +18 -0
- package/dist/primitives.d.ts +6 -6
- package/dist/primitives.js +24 -23
- package/dist/reactive/array.d.ts +24 -0
- package/dist/reactive/array.d.ts.map +1 -0
- package/dist/reactive/index.cjs +1 -0
- package/dist/reactive/index.d.cts +11 -0
- package/dist/reactive/index.d.ts +11 -0
- package/dist/reactive/index.d.ts.map +1 -0
- package/dist/reactive/index.js +18 -0
- package/dist/reactive/interop.d.cts +19 -0
- package/dist/{core/reactive → reactive}/interop.d.ts +1 -1
- package/dist/reactive/interop.d.ts.map +1 -0
- package/dist/reactive/kernel.d.cts +73 -0
- package/dist/{core/reactive → reactive}/kernel.d.ts +5 -3
- package/dist/reactive/kernel.d.ts.map +1 -0
- package/dist/reactive/map.d.ts +16 -0
- package/dist/reactive/map.d.ts.map +1 -0
- package/dist/reactive/shallow.d.cts +11 -0
- package/dist/reactive/shallow.d.ts +11 -0
- package/dist/reactive/shallow.d.ts.map +1 -0
- package/dist/reactive/struct.d.cts +10 -0
- package/dist/{core/reactive → reactive}/struct.d.ts +1 -1
- package/dist/reactive/struct.d.ts.map +1 -0
- package/dist/shallow-DQ8aG51_.cjs +1 -0
- package/dist/shallow-DfnAm9vG.js +150 -0
- package/dist/shared-BU1Cd40h.js +103 -0
- package/dist/shared-BymrGTyR.cjs +1 -0
- package/dist/shared.cjs +1 -1
- package/dist/shared.d.cts +22 -0
- package/dist/shared.d.ts +2 -2
- package/dist/shared.js +1 -1
- package/dist/topological_sort-BDvEyb9W.cjs +1 -0
- package/dist/topological_sort-DK6EjpWa.js +135 -0
- package/dist/type_primitives/assertions.d.cts +32 -0
- package/dist/type_primitives/assertions.d.ts +13 -1
- package/dist/type_primitives/assertions.d.ts.map +1 -1
- package/dist/type_primitives/binary_heap/binary_heap.d.cts +37 -0
- package/dist/type_primitives/bitset/bitset.d.cts +54 -0
- package/dist/type_primitives/brand.d.cts +23 -0
- package/dist/type_primitives/error.d.cts +16 -0
- package/dist/type_primitives/error.d.ts +4 -3
- package/dist/type_primitives/error.d.ts.map +1 -1
- package/dist/type_primitives/index.d.cts +13 -0
- package/dist/type_primitives/index.d.ts +9 -9
- package/dist/type_primitives/sparse_map/sparse_map.d.cts +30 -0
- package/dist/type_primitives/sparse_set/sparse_set.d.cts +28 -0
- package/dist/type_primitives/topological_sort/topological_sort.d.cts +29 -0
- package/dist/type_primitives/typed_arrays/typed_arrays.d.cts +127 -0
- package/dist/typed_arrays-BcXcnzB4.js +258 -0
- package/dist/typed_arrays-D3NmwtCG.cjs +1 -0
- package/dist/utils/error.d.cts +6 -0
- package/dist/version.d.cts +10 -0
- package/dist/version.d.ts +10 -0
- package/dist/version.d.ts.map +1 -0
- package/package.json +102 -19
- package/dist/array-CxbPyiHO.cjs +0 -1
- package/dist/array-uFR7Q8fU.js +0 -132
- package/dist/core/reactive/array.d.ts.map +0 -1
- package/dist/core/reactive/index.cjs +0 -1
- package/dist/core/reactive/index.d.ts +0 -10
- package/dist/core/reactive/index.d.ts.map +0 -1
- package/dist/core/reactive/index.js +0 -17
- package/dist/core/reactive/interop.d.ts.map +0 -1
- package/dist/core/reactive/kernel.d.ts.map +0 -1
- package/dist/core/reactive/map.d.ts.map +0 -1
- package/dist/core/reactive/struct.d.ts.map +0 -1
- package/dist/log/console_sink.d.ts +0 -4
- package/dist/log/console_sink.d.ts.map +0 -1
- package/dist/log/index.d.ts +0 -3
- package/dist/log/index.d.ts.map +0 -1
- package/dist/log/logger.d.ts +0 -27
- package/dist/log/logger.d.ts.map +0 -1
- package/dist/shared-BXSZnxx4.cjs +0 -1
- package/dist/shared-C678TAPY.js +0 -99
- package/dist/topological_sort-DlRpSrxu.js +0 -391
- package/dist/topological_sort-WAT-VHb-.cjs +0 -1
- package/dist/utils/arrays.d.ts.map +0 -1
- package/dist/utils/constants.d.ts.map +0 -1
- /package/dist/{utils/constants.d.ts → core/ecs/utils/constants.d.cts} +0 -0
- /package/dist/core/store/{__generated__/abi.d.ts → vendored_abi/abi.d.cts} +0 -0
- /package/dist/{core/reactive/array.d.ts → reactive/array.d.cts} +0 -0
- /package/dist/{core/reactive/map.d.ts → reactive/map.d.cts} +0 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { EmptyEventSchema, EventDef, EventReader, EventShape } from './event.js';
|
|
2
|
+
export declare class EventRegistry {
|
|
3
|
+
private readonly channels;
|
|
4
|
+
private readonly dirtyChannels;
|
|
5
|
+
private count;
|
|
6
|
+
private readonly keyMap;
|
|
7
|
+
registerEvent<S extends EventShape<S>>(fields: readonly (keyof S & string)[]): EventDef<S>;
|
|
8
|
+
emitEvent(def: EventDef<any>, values: Record<string, number>): void;
|
|
9
|
+
emitSignal(def: EventDef<EmptyEventSchema>): void;
|
|
10
|
+
getEventReader<S extends EventShape<S>>(def: EventDef<S>): EventReader<S>;
|
|
11
|
+
clearEvents(): void;
|
|
12
|
+
/** `DEV`-only: total events currently buffered across the dirty channels.
|
|
13
|
+
* `ECS.update` samples this either side of `dispatchSet` to assert an onSet
|
|
14
|
+
* observer emitted nothing — its emissions would be wiped by the tick-tail
|
|
15
|
+
* `clearEvents` and break the empty-channel-at-boundary invariant snapshot /
|
|
16
|
+
* restore relies on (#586). Walks only the dirty list, never the hot emit path. */
|
|
17
|
+
devBufferedEventCount(): number;
|
|
18
|
+
registerEventByKey<S extends EventShape<S>>(key: symbol, fields: readonly (keyof S & string)[]): EventDef<S>;
|
|
19
|
+
getEventDefByKey(key: symbol): EventDef<any>;
|
|
20
|
+
hasEventKey(key: symbol): boolean;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=event_registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event_registry.d.ts","sourceRoot":"","sources":["../../../src/core/ecs/event_registry.ts"],"names":[],"mappings":"AAAA;;;;;;;KAOK;AAGL,OAAO,EAGN,KAAK,gBAAgB,EACrB,KAAK,QAAQ,EACb,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,MAAM,SAAS,CAAC;AAGjB,qBAAa,aAAa;IAEzB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAsB;IAK/C,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAgB;IAC9C,OAAO,CAAC,KAAK,CAAK;IAIlB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAyC;IAEzD,aAAa,CAAC,CAAC,SAAS,UAAU,CAAC,CAAC,CAAC,EAC3C,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,EAAE,GACnC,QAAQ,CAAC,CAAC,CAAC;IAOP,SAAS,CAAC,GAAG,EAAE,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI;IAYnE,UAAU,CAAC,GAAG,EAAE,QAAQ,CAAC,gBAAgB,CAAC,GAAG,IAAI;IAQjD,cAAc,CAAC,CAAC,SAAS,UAAU,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC;IAIzE,WAAW,IAAI,IAAI;IAS1B;;;;uFAImF;IAC5E,qBAAqB,IAAI,MAAM;IAQ/B,kBAAkB,CAAC,CAAC,SAAS,UAAU,CAAC,CAAC,CAAC,EAChD,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,EAAE,GACnC,QAAQ,CAAC,CAAC,CAAC;IAcP,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,CAAC,GAAG,CAAC;IAY5C,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;CAGxC"}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { Store } from './store.cjs';
|
|
2
|
+
import { EntityID } from './entity.cjs';
|
|
3
|
+
import { OnDeleteTarget, RelationDef, RelationOptions } from './relation.cjs';
|
|
4
|
+
import { ResourceKey } from './resource.cjs';
|
|
5
|
+
import { EventFieldsCover, EventKey, EventReader, EventShape, SignalKey } from './event.cjs';
|
|
6
|
+
/** Relations — sparse `(relation, target)` pairs and hierarchy traversal
|
|
7
|
+
* (#471 / #474, ADR-0011). Add/remove/re-target cause no archetype
|
|
8
|
+
* transition; ops are immediate and safe mid-tick. Traversal and wildcard
|
|
9
|
+
* reads are cold-path. */
|
|
10
|
+
export declare class ECSRelations {
|
|
11
|
+
private readonly store;
|
|
12
|
+
/** @internal constructed by `ECS`. */
|
|
13
|
+
constructor(store: Store);
|
|
14
|
+
/** Register a relation kind. Exclusive (default) stores one target per
|
|
15
|
+
* source; `{ multi: true }` stores a target set per source.
|
|
16
|
+
* `{ onDeleteTarget: "delete" | "clear" | "orphan" }` selects target-death
|
|
17
|
+
* cleanup (default `orphan`, #473).
|
|
18
|
+
*
|
|
19
|
+
* The overloads stamp the CARDINALITY into the handle type (typestate
|
|
20
|
+
* a173382 / POLISH_AUDIT #7), exactly like the flat `registerRelation`:
|
|
21
|
+
* the exclusive-only surfaces (`targetOf`, `ancestorsOf`/`rootOf`/
|
|
22
|
+
* `cascadeOf`, `Query.hierarchy`) accept only `RelationDef<"exclusive">`,
|
|
23
|
+
* so passing a `{ multi: true }` relation is a compile error. A
|
|
24
|
+
* dynamically-built options value falls to the erased overload and keeps
|
|
25
|
+
* the runtime check as its only guard. */
|
|
26
|
+
register(opts?: {
|
|
27
|
+
readonly exclusive?: true;
|
|
28
|
+
readonly multi?: false;
|
|
29
|
+
readonly onDeleteTarget?: OnDeleteTarget;
|
|
30
|
+
}): RelationDef<"exclusive">;
|
|
31
|
+
register(opts: {
|
|
32
|
+
readonly multi: true;
|
|
33
|
+
readonly exclusive?: false;
|
|
34
|
+
readonly onDeleteTarget?: OnDeleteTarget;
|
|
35
|
+
}): RelationDef<"multi">;
|
|
36
|
+
register(opts?: RelationOptions): RelationDef;
|
|
37
|
+
/** Count of registered relations. */
|
|
38
|
+
get count(): number;
|
|
39
|
+
/** Add a `(R, tgt)` pair to `src`. Exclusive replaces the existing target;
|
|
40
|
+
* multi adds to the set. No archetype transition. */
|
|
41
|
+
add(src: EntityID, def: RelationDef, tgt: EntityID): this;
|
|
42
|
+
/** Remove a `(R, tgt)` pair from `src`. For multi, omitting `tgt` removes
|
|
43
|
+
* all of `src`'s targets. No archetype transition. */
|
|
44
|
+
remove(src: EntityID, def: RelationDef, tgt?: EntityID): this;
|
|
45
|
+
/** Whether `src` holds any pair under `R`. */
|
|
46
|
+
has(src: EntityID, def: RelationDef): boolean;
|
|
47
|
+
/** The single target of `src` under an exclusive relation, or `undefined`. */
|
|
48
|
+
targetOf(src: EntityID, def: RelationDef<"exclusive">): EntityID | undefined;
|
|
49
|
+
/** All targets of `src` under `R`, ascending by id. */
|
|
50
|
+
targetsOf(src: EntityID, def: RelationDef): EntityID[];
|
|
51
|
+
/** Sources pointing at `tgt` under `R` (the reverse index), ascending by id.
|
|
52
|
+
* `(entity, def)` order, matching `targetOf` / `targetsOf`. */
|
|
53
|
+
sourcesOf(tgt: EntityID, def: RelationDef): EntityID[];
|
|
54
|
+
/** All `(source, target)` pairs of relation `R` — the `(R, *)` wildcard
|
|
55
|
+
* (#472). Sources in canonical entity-index order. Cold path. */
|
|
56
|
+
pairsOf(def: RelationDef): readonly (readonly [EntityID, EntityID])[];
|
|
57
|
+
/** Every `(relation, source)` pointing at `tgt`, across all relation kinds —
|
|
58
|
+
* the `(*, T)` wildcard (#472). Ordered by relation id then source id. */
|
|
59
|
+
sourcesOfAny(tgt: EntityID): readonly (readonly [RelationDef, EntityID])[];
|
|
60
|
+
/** Walk relation `R` up from `src` to its chain root, returning
|
|
61
|
+
* `[src, parent, …, root]` (nearest-ancestor-first). Exclusive only. */
|
|
62
|
+
ancestorsOf(src: EntityID, def: RelationDef<"exclusive">): EntityID[];
|
|
63
|
+
/** The root of `src`'s `R`-chain (`src` itself when it has no target).
|
|
64
|
+
* Exclusive only. */
|
|
65
|
+
rootOf(src: EntityID, def: RelationDef<"exclusive">): EntityID;
|
|
66
|
+
/** Walk relation `R` down from `root` over the reverse index, returning the
|
|
67
|
+
* subtree (including `root`) breadth-first — parents before children (the
|
|
68
|
+
* `cascade` order). Exclusive only. */
|
|
69
|
+
cascadeOf(root: EntityID, def: RelationDef<"exclusive">): EntityID[];
|
|
70
|
+
/** Reclaim relation reverse-index memory: drop every reverse entry whose
|
|
71
|
+
* target has been destroyed, returning the total dropped (#491). Purely
|
|
72
|
+
* cold-path, no observable state change — call at scene/snapshot
|
|
73
|
+
* boundaries. */
|
|
74
|
+
compact(): number;
|
|
75
|
+
}
|
|
76
|
+
/** Event channels and signals. Emit during one `update()`, visible to every
|
|
77
|
+
* later system in that call, cleared before the next. System-side reads and
|
|
78
|
+
* emits go through `ctx` — this facade is the HOST-side surface. */
|
|
79
|
+
export declare class ECSEvents {
|
|
80
|
+
private readonly store;
|
|
81
|
+
/** @internal constructed by `ECS`. */
|
|
82
|
+
constructor(store: Store);
|
|
83
|
+
/** Register an event channel at world setup, before anything emits on it.
|
|
84
|
+
* `fields` must name EVERY schema key — an under-registered channel would
|
|
85
|
+
* silently drop the missing fields at emit (see `EventFieldsCover`).
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* const Damaged = eventKey<{ target: EntityID; amount: number }>("Damaged");
|
|
89
|
+
* ecs.events.register(Damaged, ["target", "amount"]);
|
|
90
|
+
* ecs.events.emit(Damaged, { target: e, amount: 10 }); // or ctx.emit inside a system
|
|
91
|
+
*/
|
|
92
|
+
register<S extends EventShape<S>, const F extends readonly (keyof S & string)[]>(key: EventKey<S>, fields: F & EventFieldsCover<S, F>): void;
|
|
93
|
+
/** Register a signal (empty-payload event channel). */
|
|
94
|
+
registerSignal(key: SignalKey): void;
|
|
95
|
+
emit(key: SignalKey): void;
|
|
96
|
+
emit<S extends EventShape<S>>(key: EventKey<S>, values: NoInfer<S>): void;
|
|
97
|
+
read<S extends EventShape<S>>(key: EventKey<S>): EventReader<S>;
|
|
98
|
+
}
|
|
99
|
+
/** World resources — singleton values keyed by `ResourceKey<T>`. Runtime
|
|
100
|
+
* mutations (`set` / `remove`) are access-checked as resource writes inside
|
|
101
|
+
* a system span; `register` is a one-time world-setup op. */
|
|
102
|
+
export declare class ECSResources {
|
|
103
|
+
private readonly store;
|
|
104
|
+
/** @internal constructed by `ECS`. */
|
|
105
|
+
constructor(store: Store);
|
|
106
|
+
/** Register a resource at world setup. Reading/writing an unregistered
|
|
107
|
+
* key throws (fail-closed) — registration is the explicit "this world has
|
|
108
|
+
* this singleton" declaration, not a lazy default.
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* const GameTime = resourceKey<{ elapsed: number }>("GameTime");
|
|
112
|
+
* ecs.resources.register(GameTime, { elapsed: 0 });
|
|
113
|
+
* ecs.resources.get(GameTime).elapsed; // or ctx.resource(GameTime) inside a system
|
|
114
|
+
*/
|
|
115
|
+
register<T>(key: ResourceKey<T>, value: NoInfer<T>): void;
|
|
116
|
+
get<T>(key: ResourceKey<T>): T;
|
|
117
|
+
set<T>(key: ResourceKey<T>, value: NoInfer<T>): void;
|
|
118
|
+
/** Drop a resource from the world (#798). Access-checked as a *write*;
|
|
119
|
+
* fails closed on a missing key. Afterwards the key is free to `register`
|
|
120
|
+
* again — the present → absent → present lifecycle. */
|
|
121
|
+
remove<T>(key: ResourceKey<T>): void;
|
|
122
|
+
has<T>(key: ResourceKey<T>): boolean;
|
|
123
|
+
}
|
|
124
|
+
/** The determinism surface (#626 / ADR-0020): world snapshot/resume and the
|
|
125
|
+
* canonical state digest. Every member except `deterministic` throws
|
|
126
|
+
* `DETERMINISM_DISABLED` unless the world was constructed with
|
|
127
|
+
* `{ deterministic: true }`. All cold-path — take captures at tick
|
|
128
|
+
* boundaries (between `update()`s). */
|
|
129
|
+
export declare class ECSSnapshots {
|
|
130
|
+
private readonly store;
|
|
131
|
+
/** @internal constructed by `ECS`. */
|
|
132
|
+
constructor(store: Store);
|
|
133
|
+
/** Whether the determinism surface is enabled. */
|
|
134
|
+
get deterministic(): boolean;
|
|
135
|
+
/** FNV-1a 32 digest over every archetype's live rows in id order — the
|
|
136
|
+
* canonical "live ECS state digest". Per-call cost scales with live
|
|
137
|
+
* entity count, not SAB capacity. */
|
|
138
|
+
stateHash(): number;
|
|
139
|
+
/** Capture the full live world (dense + sparse/relations + host-side
|
|
140
|
+
* bookkeeping) to one self-contained byte buffer that `restore` can mount
|
|
141
|
+
* back onto a live, ticking world (#789). v1 does NOT capture resources,
|
|
142
|
+
* events, or change-detection baselines (ADR-0031). */
|
|
143
|
+
capture(): Uint8Array;
|
|
144
|
+
/** Mount a `capture()` buffer onto this live world and keep ticking.
|
|
145
|
+
* Fails closed on a malformed frame or registration mismatch BEFORE
|
|
146
|
+
* mutating any live state. Requires a matching archetype set + column
|
|
147
|
+
* layout (prewarm so the set is stable). */
|
|
148
|
+
restore(bytes: Uint8Array): void;
|
|
149
|
+
/** Serialize the sparse stores + relations to a self-contained buffer —
|
|
150
|
+
* the sparse half of a world snapshot, canonical entity-index order
|
|
151
|
+
* (#470). Pairs with `restoreSparse`. */
|
|
152
|
+
captureSparse(): Uint8Array;
|
|
153
|
+
/** Repopulate the sparse stores + relation indices from `captureSparse`
|
|
154
|
+
* bytes. Sparse components must already be registered in the same order;
|
|
155
|
+
* throws `SparseRestoreError` on a shape or identity mismatch. */
|
|
156
|
+
restoreSparse(bytes: Uint8Array): void;
|
|
157
|
+
}
|
|
158
|
+
//# sourceMappingURL=facades.d.ts.map
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { Store } from './store.js';
|
|
2
|
+
import { EntityID } from './entity.js';
|
|
3
|
+
import { OnDeleteTarget, RelationDef, RelationOptions } from './relation.js';
|
|
4
|
+
import { ResourceKey } from './resource.js';
|
|
5
|
+
import { EventFieldsCover, EventKey, EventReader, EventShape, SignalKey } from './event.js';
|
|
6
|
+
/** Relations — sparse `(relation, target)` pairs and hierarchy traversal
|
|
7
|
+
* (#471 / #474, ADR-0011). Add/remove/re-target cause no archetype
|
|
8
|
+
* transition; ops are immediate and safe mid-tick. Traversal and wildcard
|
|
9
|
+
* reads are cold-path. */
|
|
10
|
+
export declare class ECSRelations {
|
|
11
|
+
private readonly store;
|
|
12
|
+
/** @internal constructed by `ECS`. */
|
|
13
|
+
constructor(store: Store);
|
|
14
|
+
/** Register a relation kind. Exclusive (default) stores one target per
|
|
15
|
+
* source; `{ multi: true }` stores a target set per source.
|
|
16
|
+
* `{ onDeleteTarget: "delete" | "clear" | "orphan" }` selects target-death
|
|
17
|
+
* cleanup (default `orphan`, #473).
|
|
18
|
+
*
|
|
19
|
+
* The overloads stamp the CARDINALITY into the handle type (typestate
|
|
20
|
+
* a173382 / POLISH_AUDIT #7), exactly like the flat `registerRelation`:
|
|
21
|
+
* the exclusive-only surfaces (`targetOf`, `ancestorsOf`/`rootOf`/
|
|
22
|
+
* `cascadeOf`, `Query.hierarchy`) accept only `RelationDef<"exclusive">`,
|
|
23
|
+
* so passing a `{ multi: true }` relation is a compile error. A
|
|
24
|
+
* dynamically-built options value falls to the erased overload and keeps
|
|
25
|
+
* the runtime check as its only guard. */
|
|
26
|
+
register(opts?: {
|
|
27
|
+
readonly exclusive?: true;
|
|
28
|
+
readonly multi?: false;
|
|
29
|
+
readonly onDeleteTarget?: OnDeleteTarget;
|
|
30
|
+
}): RelationDef<"exclusive">;
|
|
31
|
+
register(opts: {
|
|
32
|
+
readonly multi: true;
|
|
33
|
+
readonly exclusive?: false;
|
|
34
|
+
readonly onDeleteTarget?: OnDeleteTarget;
|
|
35
|
+
}): RelationDef<"multi">;
|
|
36
|
+
register(opts?: RelationOptions): RelationDef;
|
|
37
|
+
/** Count of registered relations. */
|
|
38
|
+
get count(): number;
|
|
39
|
+
/** Add a `(R, tgt)` pair to `src`. Exclusive replaces the existing target;
|
|
40
|
+
* multi adds to the set. No archetype transition. */
|
|
41
|
+
add(src: EntityID, def: RelationDef, tgt: EntityID): this;
|
|
42
|
+
/** Remove a `(R, tgt)` pair from `src`. For multi, omitting `tgt` removes
|
|
43
|
+
* all of `src`'s targets. No archetype transition. */
|
|
44
|
+
remove(src: EntityID, def: RelationDef, tgt?: EntityID): this;
|
|
45
|
+
/** Whether `src` holds any pair under `R`. */
|
|
46
|
+
has(src: EntityID, def: RelationDef): boolean;
|
|
47
|
+
/** The single target of `src` under an exclusive relation, or `undefined`. */
|
|
48
|
+
targetOf(src: EntityID, def: RelationDef<"exclusive">): EntityID | undefined;
|
|
49
|
+
/** All targets of `src` under `R`, ascending by id. */
|
|
50
|
+
targetsOf(src: EntityID, def: RelationDef): EntityID[];
|
|
51
|
+
/** Sources pointing at `tgt` under `R` (the reverse index), ascending by id.
|
|
52
|
+
* `(entity, def)` order, matching `targetOf` / `targetsOf`. */
|
|
53
|
+
sourcesOf(tgt: EntityID, def: RelationDef): EntityID[];
|
|
54
|
+
/** All `(source, target)` pairs of relation `R` — the `(R, *)` wildcard
|
|
55
|
+
* (#472). Sources in canonical entity-index order. Cold path. */
|
|
56
|
+
pairsOf(def: RelationDef): readonly (readonly [EntityID, EntityID])[];
|
|
57
|
+
/** Every `(relation, source)` pointing at `tgt`, across all relation kinds —
|
|
58
|
+
* the `(*, T)` wildcard (#472). Ordered by relation id then source id. */
|
|
59
|
+
sourcesOfAny(tgt: EntityID): readonly (readonly [RelationDef, EntityID])[];
|
|
60
|
+
/** Walk relation `R` up from `src` to its chain root, returning
|
|
61
|
+
* `[src, parent, …, root]` (nearest-ancestor-first). Exclusive only. */
|
|
62
|
+
ancestorsOf(src: EntityID, def: RelationDef<"exclusive">): EntityID[];
|
|
63
|
+
/** The root of `src`'s `R`-chain (`src` itself when it has no target).
|
|
64
|
+
* Exclusive only. */
|
|
65
|
+
rootOf(src: EntityID, def: RelationDef<"exclusive">): EntityID;
|
|
66
|
+
/** Walk relation `R` down from `root` over the reverse index, returning the
|
|
67
|
+
* subtree (including `root`) breadth-first — parents before children (the
|
|
68
|
+
* `cascade` order). Exclusive only. */
|
|
69
|
+
cascadeOf(root: EntityID, def: RelationDef<"exclusive">): EntityID[];
|
|
70
|
+
/** Reclaim relation reverse-index memory: drop every reverse entry whose
|
|
71
|
+
* target has been destroyed, returning the total dropped (#491). Purely
|
|
72
|
+
* cold-path, no observable state change — call at scene/snapshot
|
|
73
|
+
* boundaries. */
|
|
74
|
+
compact(): number;
|
|
75
|
+
}
|
|
76
|
+
/** Event channels and signals. Emit during one `update()`, visible to every
|
|
77
|
+
* later system in that call, cleared before the next. System-side reads and
|
|
78
|
+
* emits go through `ctx` — this facade is the HOST-side surface. */
|
|
79
|
+
export declare class ECSEvents {
|
|
80
|
+
private readonly store;
|
|
81
|
+
/** @internal constructed by `ECS`. */
|
|
82
|
+
constructor(store: Store);
|
|
83
|
+
/** Register an event channel at world setup, before anything emits on it.
|
|
84
|
+
* `fields` must name EVERY schema key — an under-registered channel would
|
|
85
|
+
* silently drop the missing fields at emit (see `EventFieldsCover`).
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* const Damaged = eventKey<{ target: EntityID; amount: number }>("Damaged");
|
|
89
|
+
* ecs.events.register(Damaged, ["target", "amount"]);
|
|
90
|
+
* ecs.events.emit(Damaged, { target: e, amount: 10 }); // or ctx.emit inside a system
|
|
91
|
+
*/
|
|
92
|
+
register<S extends EventShape<S>, const F extends readonly (keyof S & string)[]>(key: EventKey<S>, fields: F & EventFieldsCover<S, F>): void;
|
|
93
|
+
/** Register a signal (empty-payload event channel). */
|
|
94
|
+
registerSignal(key: SignalKey): void;
|
|
95
|
+
emit(key: SignalKey): void;
|
|
96
|
+
emit<S extends EventShape<S>>(key: EventKey<S>, values: NoInfer<S>): void;
|
|
97
|
+
read<S extends EventShape<S>>(key: EventKey<S>): EventReader<S>;
|
|
98
|
+
}
|
|
99
|
+
/** World resources — singleton values keyed by `ResourceKey<T>`. Runtime
|
|
100
|
+
* mutations (`set` / `remove`) are access-checked as resource writes inside
|
|
101
|
+
* a system span; `register` is a one-time world-setup op. */
|
|
102
|
+
export declare class ECSResources {
|
|
103
|
+
private readonly store;
|
|
104
|
+
/** @internal constructed by `ECS`. */
|
|
105
|
+
constructor(store: Store);
|
|
106
|
+
/** Register a resource at world setup. Reading/writing an unregistered
|
|
107
|
+
* key throws (fail-closed) — registration is the explicit "this world has
|
|
108
|
+
* this singleton" declaration, not a lazy default.
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* const GameTime = resourceKey<{ elapsed: number }>("GameTime");
|
|
112
|
+
* ecs.resources.register(GameTime, { elapsed: 0 });
|
|
113
|
+
* ecs.resources.get(GameTime).elapsed; // or ctx.resource(GameTime) inside a system
|
|
114
|
+
*/
|
|
115
|
+
register<T>(key: ResourceKey<T>, value: NoInfer<T>): void;
|
|
116
|
+
get<T>(key: ResourceKey<T>): T;
|
|
117
|
+
set<T>(key: ResourceKey<T>, value: NoInfer<T>): void;
|
|
118
|
+
/** Drop a resource from the world (#798). Access-checked as a *write*;
|
|
119
|
+
* fails closed on a missing key. Afterwards the key is free to `register`
|
|
120
|
+
* again — the present → absent → present lifecycle. */
|
|
121
|
+
remove<T>(key: ResourceKey<T>): void;
|
|
122
|
+
has<T>(key: ResourceKey<T>): boolean;
|
|
123
|
+
}
|
|
124
|
+
/** The determinism surface (#626 / ADR-0020): world snapshot/resume and the
|
|
125
|
+
* canonical state digest. Every member except `deterministic` throws
|
|
126
|
+
* `DETERMINISM_DISABLED` unless the world was constructed with
|
|
127
|
+
* `{ deterministic: true }`. All cold-path — take captures at tick
|
|
128
|
+
* boundaries (between `update()`s). */
|
|
129
|
+
export declare class ECSSnapshots {
|
|
130
|
+
private readonly store;
|
|
131
|
+
/** @internal constructed by `ECS`. */
|
|
132
|
+
constructor(store: Store);
|
|
133
|
+
/** Whether the determinism surface is enabled. */
|
|
134
|
+
get deterministic(): boolean;
|
|
135
|
+
/** FNV-1a 32 digest over every archetype's live rows in id order — the
|
|
136
|
+
* canonical "live ECS state digest". Per-call cost scales with live
|
|
137
|
+
* entity count, not SAB capacity. */
|
|
138
|
+
stateHash(): number;
|
|
139
|
+
/** Capture the full live world (dense + sparse/relations + host-side
|
|
140
|
+
* bookkeeping) to one self-contained byte buffer that `restore` can mount
|
|
141
|
+
* back onto a live, ticking world (#789). v1 does NOT capture resources,
|
|
142
|
+
* events, or change-detection baselines (ADR-0031). */
|
|
143
|
+
capture(): Uint8Array;
|
|
144
|
+
/** Mount a `capture()` buffer onto this live world and keep ticking.
|
|
145
|
+
* Fails closed on a malformed frame or registration mismatch BEFORE
|
|
146
|
+
* mutating any live state. Requires a matching archetype set + column
|
|
147
|
+
* layout (prewarm so the set is stable). */
|
|
148
|
+
restore(bytes: Uint8Array): void;
|
|
149
|
+
/** Serialize the sparse stores + relations to a self-contained buffer —
|
|
150
|
+
* the sparse half of a world snapshot, canonical entity-index order
|
|
151
|
+
* (#470). Pairs with `restoreSparse`. */
|
|
152
|
+
captureSparse(): Uint8Array;
|
|
153
|
+
/** Repopulate the sparse stores + relation indices from `captureSparse`
|
|
154
|
+
* bytes. Sparse components must already be registered in the same order;
|
|
155
|
+
* throws `SparseRestoreError` on a shape or identity mismatch. */
|
|
156
|
+
restoreSparse(bytes: Uint8Array): void;
|
|
157
|
+
}
|
|
158
|
+
//# sourceMappingURL=facades.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"facades.d.ts","sourceRoot":"","sources":["../../../src/core/ecs/facades.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { ECS } from './ecs.cjs';
|
|
2
|
+
type FrameCallback = (timestampMs: number) => void;
|
|
3
|
+
type RequestFrame = (callback: FrameCallback) => number;
|
|
4
|
+
type CancelFrame = (handle: number) => void;
|
|
5
|
+
export interface FrameStepperOptions {
|
|
6
|
+
/** Delta used by `step()` when no dt is supplied, in seconds. Default 1/60. */
|
|
7
|
+
readonly fixedDt?: number;
|
|
8
|
+
/** Clamp browser-frame deltas before forwarding them to `ECS.update()`, in
|
|
9
|
+
* seconds. Default 0.25. A backgrounded tab suspends rAF; the first frame
|
|
10
|
+
* after it resumes carries the whole suspended interval as one delta, and
|
|
11
|
+
* without the clamp that lands in `update()`'s accumulator as a giant
|
|
12
|
+
* catch-up burst (bounded by `maxFixedSteps`, but still a burst). Manual
|
|
13
|
+
* `step()` deltas are deliberately not clamped — an explicit dt is trusted. */
|
|
14
|
+
readonly maxDt?: number;
|
|
15
|
+
/** Dependency injection for tests or non-browser hosts. Defaults to `requestAnimationFrame`. */
|
|
16
|
+
readonly requestFrame?: RequestFrame;
|
|
17
|
+
/** Dependency injection for tests or non-browser hosts. Defaults to `cancelAnimationFrame`. */
|
|
18
|
+
readonly cancelFrame?: CancelFrame;
|
|
19
|
+
/** Start the automatic frame loop immediately. */
|
|
20
|
+
readonly autoStart?: boolean;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Small host-side controller for manual ECS frame stepping.
|
|
24
|
+
*
|
|
25
|
+
* `ECS.update(dt)` is already the authoritative "run one frame" primitive.
|
|
26
|
+
* This class wraps it with pause/play controls for browser loops and an explicit
|
|
27
|
+
* `step()` method for debuggers, tests, editor tools, and rollback playback.
|
|
28
|
+
*/
|
|
29
|
+
export declare class FrameStepper {
|
|
30
|
+
private readonly ecs;
|
|
31
|
+
private readonly requestFrame?;
|
|
32
|
+
private readonly cancelFrame?;
|
|
33
|
+
private frameHandle;
|
|
34
|
+
private lastTimestampMs;
|
|
35
|
+
private running;
|
|
36
|
+
private _fixedDt;
|
|
37
|
+
private _maxDt;
|
|
38
|
+
constructor(ecs: ECS, options?: FrameStepperOptions);
|
|
39
|
+
get fixedDt(): number;
|
|
40
|
+
set fixedDt(value: number);
|
|
41
|
+
get maxDt(): number;
|
|
42
|
+
set maxDt(value: number);
|
|
43
|
+
get isRunning(): boolean;
|
|
44
|
+
/** Advance exactly one ECS frame. */
|
|
45
|
+
step(dt?: number): void;
|
|
46
|
+
/** Advance several fixed-size frames, useful for replaying a paused sim. */
|
|
47
|
+
stepFrames(count: number, dt?: number): void;
|
|
48
|
+
/** Start ticking with `requestAnimationFrame`; no-op when already running. */
|
|
49
|
+
play(): void;
|
|
50
|
+
/** Stop the automatic frame loop. Manual `step()` still works while paused. */
|
|
51
|
+
pause(): void;
|
|
52
|
+
toggle(): void;
|
|
53
|
+
dispose(): void;
|
|
54
|
+
private scheduleNextFrame;
|
|
55
|
+
private readonly onFrame;
|
|
56
|
+
}
|
|
57
|
+
export {};
|
|
58
|
+
//# sourceMappingURL=frame_stepper.d.ts.map
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { ECS } from './ecs.js';
|
|
2
|
+
type FrameCallback = (timestampMs: number) => void;
|
|
3
|
+
type RequestFrame = (callback: FrameCallback) => number;
|
|
4
|
+
type CancelFrame = (handle: number) => void;
|
|
5
|
+
export interface FrameStepperOptions {
|
|
6
|
+
/** Delta used by `step()` when no dt is supplied, in seconds. Default 1/60. */
|
|
7
|
+
readonly fixedDt?: number;
|
|
8
|
+
/** Clamp browser-frame deltas before forwarding them to `ECS.update()`, in
|
|
9
|
+
* seconds. Default 0.25. A backgrounded tab suspends rAF; the first frame
|
|
10
|
+
* after it resumes carries the whole suspended interval as one delta, and
|
|
11
|
+
* without the clamp that lands in `update()`'s accumulator as a giant
|
|
12
|
+
* catch-up burst (bounded by `maxFixedSteps`, but still a burst). Manual
|
|
13
|
+
* `step()` deltas are deliberately not clamped — an explicit dt is trusted. */
|
|
14
|
+
readonly maxDt?: number;
|
|
15
|
+
/** Dependency injection for tests or non-browser hosts. Defaults to `requestAnimationFrame`. */
|
|
16
|
+
readonly requestFrame?: RequestFrame;
|
|
17
|
+
/** Dependency injection for tests or non-browser hosts. Defaults to `cancelAnimationFrame`. */
|
|
18
|
+
readonly cancelFrame?: CancelFrame;
|
|
19
|
+
/** Start the automatic frame loop immediately. */
|
|
20
|
+
readonly autoStart?: boolean;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Small host-side controller for manual ECS frame stepping.
|
|
24
|
+
*
|
|
25
|
+
* `ECS.update(dt)` is already the authoritative "run one frame" primitive.
|
|
26
|
+
* This class wraps it with pause/play controls for browser loops and an explicit
|
|
27
|
+
* `step()` method for debuggers, tests, editor tools, and rollback playback.
|
|
28
|
+
*/
|
|
29
|
+
export declare class FrameStepper {
|
|
30
|
+
private readonly ecs;
|
|
31
|
+
private readonly requestFrame?;
|
|
32
|
+
private readonly cancelFrame?;
|
|
33
|
+
private frameHandle;
|
|
34
|
+
private lastTimestampMs;
|
|
35
|
+
private running;
|
|
36
|
+
private _fixedDt;
|
|
37
|
+
private _maxDt;
|
|
38
|
+
constructor(ecs: ECS, options?: FrameStepperOptions);
|
|
39
|
+
get fixedDt(): number;
|
|
40
|
+
set fixedDt(value: number);
|
|
41
|
+
get maxDt(): number;
|
|
42
|
+
set maxDt(value: number);
|
|
43
|
+
get isRunning(): boolean;
|
|
44
|
+
/** Advance exactly one ECS frame. */
|
|
45
|
+
step(dt?: number): void;
|
|
46
|
+
/** Advance several fixed-size frames, useful for replaying a paused sim. */
|
|
47
|
+
stepFrames(count: number, dt?: number): void;
|
|
48
|
+
/** Start ticking with `requestAnimationFrame`; no-op when already running. */
|
|
49
|
+
play(): void;
|
|
50
|
+
/** Stop the automatic frame loop. Manual `step()` still works while paused. */
|
|
51
|
+
pause(): void;
|
|
52
|
+
toggle(): void;
|
|
53
|
+
dispose(): void;
|
|
54
|
+
private scheduleNextFrame;
|
|
55
|
+
private readonly onFrame;
|
|
56
|
+
}
|
|
57
|
+
export {};
|
|
58
|
+
//# sourceMappingURL=frame_stepper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frame_stepper.d.ts","sourceRoot":"","sources":["../../../src/core/ecs/frame_stepper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAGjC,KAAK,aAAa,GAAG,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;AACnD,KAAK,YAAY,GAAG,CAAC,QAAQ,EAAE,aAAa,KAAK,MAAM,CAAC;AACxD,KAAK,WAAW,GAAG,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;AAM5C,MAAM,WAAW,mBAAmB;IACnC,+EAA+E;IAC/E,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B;;;;;mFAK+E;IAC/E,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,gGAAgG;IAChG,QAAQ,CAAC,YAAY,CAAC,EAAE,YAAY,CAAC;IACrC,+FAA+F;IAC/F,QAAQ,CAAC,WAAW,CAAC,EAAE,WAAW,CAAC;IACnC,kDAAkD;IAClD,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;CAC7B;AAsBD;;;;;;GAMG;AACH,qBAAa,YAAY;IACxB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAM;IAC1B,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAe;IAC7C,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAc;IAC3C,OAAO,CAAC,WAAW,CAAuB;IAC1C,OAAO,CAAC,eAAe,CAAuB;IAC9C,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,MAAM,CAAS;gBAEJ,GAAG,EAAE,GAAG,EAAE,OAAO,GAAE,mBAAwB;IAW9D,IAAW,OAAO,IAAI,MAAM,CAE3B;IAED,IAAW,OAAO,CAAC,KAAK,EAAE,MAAM,EAE/B;IAED,IAAW,KAAK,IAAI,MAAM,CAEzB;IAED,IAAW,KAAK,CAAC,KAAK,EAAE,MAAM,EAE7B;IAED,IAAW,SAAS,IAAI,OAAO,CAE9B;IAED,qCAAqC;IAC9B,IAAI,CAAC,EAAE,GAAE,MAAsB,GAAG,IAAI;IAI7C,4EAA4E;IACrE,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,GAAE,MAAsB,GAAG,IAAI;IAMlE,8EAA8E;IACvE,IAAI,IAAI,IAAI;IAanB,+EAA+E;IACxE,KAAK,IAAI,IAAI;IASb,MAAM,IAAI,IAAI;IAKd,OAAO,IAAI,IAAI;IAItB,OAAO,CAAC,iBAAiB;IAIzB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAQtB;CACF"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { EntityID } from './entity.cjs';
|
|
2
|
+
import { SystemDescriptor } from './system.cjs';
|
|
3
|
+
import { SCHEDULE } from './schedule.cjs';
|
|
4
|
+
/** A deferred structural command issued through `ctx.commands.*` (`query.ts`).
|
|
5
|
+
* `spawn`/`despawn`/`enable`/`disable` carry a `null` component; `add`/`remove`
|
|
6
|
+
* carry the affected component's id. */
|
|
7
|
+
export type StructuralOp = "spawn" | "despawn" | "add" | "remove" | "enable" | "disable";
|
|
8
|
+
/** An observer edge that fired at a flush (`add`/`remove`/`enable`/`disable`) or
|
|
9
|
+
* at the post-update onSet detection point (`set`). */
|
|
10
|
+
export type ObserverOp = "add" | "remove" | "set" | "enable" | "disable";
|
|
11
|
+
/**
|
|
12
|
+
* The push sink. All callers are `DEV`-gated, so the methods receive raw ids
|
|
13
|
+
* and descriptor references (no string-building on the hot path); the recorder
|
|
14
|
+
* decides what to retain. Implementations must be side-effect-free with respect
|
|
15
|
+
* to the ECS — they observe, never mutate.
|
|
16
|
+
*/
|
|
17
|
+
export interface FrameTraceSink {
|
|
18
|
+
/** Opens a frame. Fired first in `ecs.update`, before any phase runs. */
|
|
19
|
+
tickBegin(tick: number, dt: number): void;
|
|
20
|
+
/** Closes the frame opened by `tickBegin` (after onSet + `clearEvents`). */
|
|
21
|
+
tickEnd(tick: number): void;
|
|
22
|
+
/** A scheduled system is about to run, in the given phase. */
|
|
23
|
+
systemStart(system: SystemDescriptor, phase: SCHEDULE): void;
|
|
24
|
+
/** The system that last `systemStart`'d has returned. */
|
|
25
|
+
systemEnd(system: SystemDescriptor): void;
|
|
26
|
+
/** A deferred structural command was enqueued (applied at the next flush). */
|
|
27
|
+
commandQueued(op: StructuralOp, entity: EntityID, component: number | null): void;
|
|
28
|
+
/** The deferred command buffer is about to drain for this phase. */
|
|
29
|
+
flushBegin(phase: SCHEDULE): void;
|
|
30
|
+
/** The deferred command buffer (and any observer cascade) has settled. */
|
|
31
|
+
flushEnd(phase: SCHEDULE): void;
|
|
32
|
+
/**
|
|
33
|
+
* A schedule phase has fully settled — every system in `phase` ran and the
|
|
34
|
+
* deferred command buffer (plus any observer cascade) flushed — so the live
|
|
35
|
+
* world sits at a consistent, fingerprint-able point WITHIN the frame. Fired
|
|
36
|
+
* once per phase that runs (each startup phase, each fixed step, and each
|
|
37
|
+
* update phase), immediately after `flushEnd(phase)`.
|
|
38
|
+
*
|
|
39
|
+
* This is the blessed seam for a consumer to read `stateHash()` between the
|
|
40
|
+
* phases of one `update()` and bisect a divergence to the exact phase that
|
|
41
|
+
* introduced it (#797 / ADR-0032). `flushEnd` marks the same instant, but it
|
|
42
|
+
* is an observation of the flush *mechanism*, not a "safe to read consistent
|
|
43
|
+
* state" contract — so per-phase fingerprinting binds to this method, not to a
|
|
44
|
+
* flush-internal name. Like every sink method the call is read-only w.r.t. the
|
|
45
|
+
* ECS: reading `stateHash()` here cannot perturb the per-tick hash or ordering.
|
|
46
|
+
*
|
|
47
|
+
* Caveat: the POST_UPDATE boundary fires BEFORE the tick-tail onSet-observer
|
|
48
|
+
* dispatch + `clearEvents`, so for a world with onSet observers the final
|
|
49
|
+
* per-tick `stateHash` (after `update()` returns) may differ from the
|
|
50
|
+
* POST_UPDATE phase hash. A world with no onSet observers reconciles exactly.
|
|
51
|
+
*/
|
|
52
|
+
phaseBoundary(phase: SCHEDULE): void;
|
|
53
|
+
/** An observer callback fired for one entity (`entity === -1` for an
|
|
54
|
+
* archetype-granular onSet, which has no per-entity id). */
|
|
55
|
+
observerFired(op: ObserverOp, component: number, entity: number, observer: SystemDescriptor): void;
|
|
56
|
+
/** A system emitted an event on `key` (the channel's symbol description). */
|
|
57
|
+
eventEmitted(key: string): void;
|
|
58
|
+
/** A system read an event channel; `count` is how many events it saw. */
|
|
59
|
+
eventRead(key: string, count: number): void;
|
|
60
|
+
}
|
|
61
|
+
/** One captured event, as plain JSON-serialisable data (string names + numeric
|
|
62
|
+
* ids), so a `FrameTrace[]` streams straight to a browser renderer. */
|
|
63
|
+
export type FrameTraceEvent = {
|
|
64
|
+
readonly kind: "system_start";
|
|
65
|
+
readonly system: string;
|
|
66
|
+
readonly phase: SCHEDULE;
|
|
67
|
+
} | {
|
|
68
|
+
readonly kind: "system_end";
|
|
69
|
+
readonly system: string;
|
|
70
|
+
} | {
|
|
71
|
+
readonly kind: "command_queued";
|
|
72
|
+
readonly op: StructuralOp;
|
|
73
|
+
readonly entity: number;
|
|
74
|
+
readonly component: number | null;
|
|
75
|
+
} | {
|
|
76
|
+
readonly kind: "flush_begin";
|
|
77
|
+
readonly phase: SCHEDULE;
|
|
78
|
+
} | {
|
|
79
|
+
readonly kind: "flush_end";
|
|
80
|
+
readonly phase: SCHEDULE;
|
|
81
|
+
} | {
|
|
82
|
+
readonly kind: "observer_fired";
|
|
83
|
+
readonly op: ObserverOp;
|
|
84
|
+
readonly component: number;
|
|
85
|
+
readonly entity: number;
|
|
86
|
+
readonly observer: string;
|
|
87
|
+
} | {
|
|
88
|
+
readonly kind: "event_emitted";
|
|
89
|
+
readonly key: string;
|
|
90
|
+
} | {
|
|
91
|
+
readonly kind: "event_read";
|
|
92
|
+
readonly key: string;
|
|
93
|
+
readonly count: number;
|
|
94
|
+
};
|
|
95
|
+
/** One frame's captured internals, in causal order. */
|
|
96
|
+
export interface FrameTrace {
|
|
97
|
+
readonly tick: number;
|
|
98
|
+
readonly dt: number;
|
|
99
|
+
readonly events: FrameTraceEvent[];
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* The in-tree `FrameTraceSink`. Mirrors `command_log.ts`'s `openTick` /
|
|
103
|
+
* `RecordedTick` shape: `tickBegin` opens a fresh `FrameTrace`, every other
|
|
104
|
+
* method appends to it, `tickEnd` closes it. Events arriving with no open
|
|
105
|
+
* frame (e.g. a stray pre-`update` flush) are ignored rather than throwing —
|
|
106
|
+
* the recorder is a passive observer.
|
|
107
|
+
*/
|
|
108
|
+
export declare class FrameTraceRecorder implements FrameTraceSink {
|
|
109
|
+
private readonly _frames;
|
|
110
|
+
private _current;
|
|
111
|
+
tickBegin(tick: number, dt: number): void;
|
|
112
|
+
tickEnd(_tick: number): void;
|
|
113
|
+
systemStart(system: SystemDescriptor, phase: SCHEDULE): void;
|
|
114
|
+
systemEnd(system: SystemDescriptor): void;
|
|
115
|
+
commandQueued(op: StructuralOp, entity: EntityID, component: number | null): void;
|
|
116
|
+
flushBegin(phase: SCHEDULE): void;
|
|
117
|
+
flushEnd(phase: SCHEDULE): void;
|
|
118
|
+
/** No-op (#797 / ADR-0032). The recorder already marks this instant with
|
|
119
|
+
* `flushEnd`, and a per-phase fingerprint is a consumer concern — the recorder
|
|
120
|
+
* holds no world reference to hash. The seam exists so a consumer's OWN sink can
|
|
121
|
+
* run code (e.g. `stateHash()`) at the safe post-flush point; the in-tree
|
|
122
|
+
* event-stream recorder has nothing to add, so it stays a stream of causal
|
|
123
|
+
* events, not fingerprints. */
|
|
124
|
+
phaseBoundary(_phase: SCHEDULE): void;
|
|
125
|
+
observerFired(op: ObserverOp, component: number, entity: number, observer: SystemDescriptor): void;
|
|
126
|
+
eventEmitted(key: string): void;
|
|
127
|
+
eventRead(key: string, count: number): void;
|
|
128
|
+
/** The captured frames, in `update()` order. */
|
|
129
|
+
frames(): readonly FrameTrace[];
|
|
130
|
+
/** Drop all captured frames (reuse the recorder for a fresh run). */
|
|
131
|
+
reset(): void;
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=frame_trace.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { EntityID } from './entity';
|
|
2
|
-
import { SystemDescriptor } from './system';
|
|
3
|
-
import { SCHEDULE } from './schedule';
|
|
1
|
+
import { EntityID } from './entity.js';
|
|
2
|
+
import { SystemDescriptor } from './system.js';
|
|
3
|
+
import { SCHEDULE } from './schedule.js';
|
|
4
4
|
/** A deferred structural command issued through `ctx.commands.*` (`query.ts`).
|
|
5
5
|
* `spawn`/`despawn`/`enable`/`disable` carry a `null` component; `add`/`remove`
|
|
6
6
|
* carry the affected component's id. */
|
|
@@ -9,13 +9,13 @@ export type StructuralOp = "spawn" | "despawn" | "add" | "remove" | "enable" | "
|
|
|
9
9
|
* at the post-update onSet detection point (`set`). */
|
|
10
10
|
export type ObserverOp = "add" | "remove" | "set" | "enable" | "disable";
|
|
11
11
|
/**
|
|
12
|
-
* The push sink. All callers are `
|
|
12
|
+
* The push sink. All callers are `DEV`-gated, so the methods receive raw ids
|
|
13
13
|
* and descriptor references (no string-building on the hot path); the recorder
|
|
14
14
|
* decides what to retain. Implementations must be side-effect-free with respect
|
|
15
15
|
* to the ECS — they observe, never mutate.
|
|
16
16
|
*/
|
|
17
17
|
export interface FrameTraceSink {
|
|
18
|
-
/** Opens a frame. Fired first in `
|
|
18
|
+
/** Opens a frame. Fired first in `ecs.update`, before any phase runs. */
|
|
19
19
|
tickBegin(tick: number, dt: number): void;
|
|
20
20
|
/** Closes the frame opened by `tickBegin` (after onSet + `clearEvents`). */
|
|
21
21
|
tickEnd(tick: number): void;
|