@oasys/oecs 0.5.3 → 0.6.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 +1399 -276
- package/README.md +327 -169
- package/dist/core/ecs/access_check.d.cts +31 -31
- package/dist/core/ecs/access_check.d.ts +31 -31
- package/dist/core/ecs/access_check.d.ts.map +1 -1
- package/dist/core/ecs/archetype.d.cts +273 -205
- package/dist/core/ecs/archetype.d.ts +273 -205
- package/dist/core/ecs/archetype.d.ts.map +1 -1
- package/dist/core/ecs/archetype_closure.d.cts +23 -0
- package/dist/core/ecs/archetype_closure.d.ts +23 -0
- package/dist/core/ecs/archetype_closure.d.ts.map +1 -0
- package/dist/core/ecs/archetype_graph.d.cts +34 -34
- package/dist/core/ecs/archetype_graph.d.ts +34 -34
- package/dist/core/ecs/archetype_graph.d.ts.map +1 -1
- package/dist/core/ecs/archetype_types.d.cts +55 -0
- package/dist/core/ecs/archetype_types.d.ts +55 -0
- package/dist/core/ecs/archetype_types.d.ts.map +1 -0
- package/dist/core/ecs/change_feed.d.cts +53 -0
- package/dist/core/ecs/change_feed.d.ts +53 -0
- package/dist/core/ecs/change_feed.d.ts.map +1 -0
- package/dist/core/ecs/changed_query.d.cts +36 -0
- package/dist/core/ecs/changed_query.d.ts +36 -0
- package/dist/core/ecs/changed_query.d.ts.map +1 -0
- package/dist/core/ecs/chunk_columns.d.cts +49 -0
- package/dist/core/ecs/chunk_columns.d.ts +49 -0
- package/dist/core/ecs/chunk_columns.d.ts.map +1 -0
- package/dist/core/ecs/command_log.d.cts +30 -30
- package/dist/core/ecs/command_log.d.ts +30 -30
- package/dist/core/ecs/command_log.d.ts.map +1 -1
- package/dist/core/ecs/component.d.cts +45 -44
- package/dist/core/ecs/component.d.ts +45 -44
- package/dist/core/ecs/component.d.ts.map +1 -1
- package/dist/core/ecs/component_registry.d.cts +53 -0
- package/dist/core/ecs/component_registry.d.ts +53 -0
- package/dist/core/ecs/component_registry.d.ts.map +1 -0
- package/dist/core/ecs/compute_backend.d.cts +18 -7
- package/dist/core/ecs/compute_backend.d.ts +18 -7
- package/dist/core/ecs/compute_backend.d.ts.map +1 -1
- package/dist/core/ecs/deferred_commands.d.cts +15 -14
- package/dist/core/ecs/deferred_commands.d.ts +15 -14
- package/dist/core/ecs/deferred_commands.d.ts.map +1 -1
- package/dist/core/ecs/dispatch_trace.d.cts +32 -31
- package/dist/core/ecs/dispatch_trace.d.ts +32 -31
- package/dist/core/ecs/dispatch_trace.d.ts.map +1 -1
- package/dist/core/ecs/ecs.d.cts +337 -276
- package/dist/core/ecs/ecs.d.ts +337 -276
- package/dist/core/ecs/ecs.d.ts.map +1 -1
- package/dist/core/ecs/ecs_memory.d.cts +134 -136
- package/dist/core/ecs/ecs_memory.d.ts +134 -136
- package/dist/core/ecs/ecs_memory.d.ts.map +1 -1
- package/dist/core/ecs/ecs_options.d.cts +89 -0
- package/dist/core/ecs/ecs_options.d.ts +89 -0
- package/dist/core/ecs/ecs_options.d.ts.map +1 -0
- package/dist/core/ecs/entity.d.cts +4 -4
- package/dist/core/ecs/entity.d.ts +4 -4
- package/dist/core/ecs/entity_allocator.d.cts +24 -22
- package/dist/core/ecs/entity_allocator.d.ts +24 -22
- package/dist/core/ecs/entity_allocator.d.ts.map +1 -1
- package/dist/core/ecs/event.d.cts +37 -23
- package/dist/core/ecs/event.d.ts +37 -23
- package/dist/core/ecs/event.d.ts.map +1 -1
- package/dist/core/ecs/facades.d.cts +12 -126
- package/dist/core/ecs/facades.d.ts +12 -126
- package/dist/core/ecs/facades.d.ts.map +1 -1
- package/dist/core/ecs/frame_stepper.d.cts +12 -12
- package/dist/core/ecs/frame_stepper.d.ts +12 -12
- package/dist/core/ecs/frame_stepper.d.ts.map +1 -1
- package/dist/core/ecs/frame_trace.d.cts +34 -34
- package/dist/core/ecs/frame_trace.d.ts +34 -34
- package/dist/core/ecs/frame_trace.d.ts.map +1 -1
- package/dist/core/ecs/host_commands.d.cts +107 -89
- package/dist/core/ecs/host_commands.d.ts +107 -89
- package/dist/core/ecs/host_commands.d.ts.map +1 -1
- package/dist/core/ecs/index.d.cts +22 -12
- package/dist/core/ecs/index.d.ts +22 -12
- package/dist/core/ecs/index.d.ts.map +1 -1
- package/dist/core/ecs/observer.d.cts +41 -122
- package/dist/core/ecs/observer.d.ts +41 -122
- package/dist/core/ecs/observer.d.ts.map +1 -1
- package/dist/core/ecs/phase.d.cts +79 -0
- package/dist/core/ecs/phase.d.ts +79 -0
- package/dist/core/ecs/phase.d.ts.map +1 -0
- package/dist/core/ecs/plugin.d.cts +125 -0
- package/dist/core/ecs/plugin.d.ts +125 -0
- package/dist/core/ecs/plugin.d.ts.map +1 -0
- package/dist/core/ecs/plugin_slots.d.cts +26 -0
- package/dist/core/ecs/plugin_slots.d.ts +26 -0
- package/dist/core/ecs/plugin_slots.d.ts.map +1 -0
- package/dist/core/ecs/query.d.cts +219 -568
- package/dist/core/ecs/query.d.ts +219 -568
- package/dist/core/ecs/query.d.ts.map +1 -1
- package/dist/core/ecs/query_cache.d.cts +130 -0
- package/dist/core/ecs/query_cache.d.ts +130 -0
- package/dist/core/ecs/query_cache.d.ts.map +1 -0
- package/dist/core/ecs/query_registry.d.cts +47 -0
- package/dist/core/ecs/query_registry.d.ts +47 -0
- package/dist/core/ecs/query_registry.d.ts.map +1 -0
- package/dist/core/ecs/query_terms.d.cts +126 -0
- package/dist/core/ecs/query_terms.d.ts +126 -0
- package/dist/core/ecs/query_terms.d.ts.map +1 -0
- package/dist/core/ecs/ref.d.cts +129 -16
- package/dist/core/ecs/ref.d.ts +129 -16
- package/dist/core/ecs/ref.d.ts.map +1 -1
- package/dist/core/ecs/relation.d.cts +105 -186
- package/dist/core/ecs/relation.d.ts +105 -186
- package/dist/core/ecs/relation.d.ts.map +1 -1
- package/dist/core/ecs/resource.d.cts +14 -14
- package/dist/core/ecs/resource.d.ts +14 -14
- package/dist/core/ecs/resource_registry.d.cts +6 -6
- package/dist/core/ecs/resource_registry.d.ts +6 -6
- package/dist/core/ecs/resource_registry.d.ts.map +1 -1
- package/dist/core/ecs/row_kinds.d.cts +24 -0
- package/dist/core/ecs/row_kinds.d.ts +24 -0
- package/dist/core/ecs/row_kinds.d.ts.map +1 -0
- package/dist/core/ecs/run_condition.d.cts +23 -23
- package/dist/core/ecs/run_condition.d.ts +23 -23
- package/dist/core/ecs/run_condition.d.ts.map +1 -1
- package/dist/core/ecs/schedule.d.cts +98 -114
- package/dist/core/ecs/schedule.d.ts +98 -114
- package/dist/core/ecs/schedule.d.ts.map +1 -1
- package/dist/core/ecs/schedule_plan.d.cts +33 -0
- package/dist/core/ecs/schedule_plan.d.ts +33 -0
- package/dist/core/ecs/schedule_plan.d.ts.map +1 -0
- package/dist/core/ecs/snapshot.d.cts +77 -0
- package/dist/core/ecs/snapshot.d.ts +77 -0
- package/dist/core/ecs/snapshot.d.ts.map +1 -0
- package/dist/core/ecs/snapshot_mount.d.cts +42 -0
- package/dist/core/ecs/snapshot_mount.d.ts +42 -0
- package/dist/core/ecs/snapshot_mount.d.ts.map +1 -0
- package/dist/core/ecs/sparse_store.d.cts +110 -53
- package/dist/core/ecs/sparse_store.d.ts +110 -53
- package/dist/core/ecs/sparse_store.d.ts.map +1 -1
- package/dist/core/ecs/store.d.cts +644 -511
- package/dist/core/ecs/store.d.ts +644 -511
- package/dist/core/ecs/store.d.ts.map +1 -1
- package/dist/core/ecs/store_layout_listener.d.cts +8 -8
- package/dist/core/ecs/store_layout_listener.d.ts +8 -8
- package/dist/core/ecs/store_types.d.cts +122 -0
- package/dist/core/ecs/store_types.d.ts +122 -0
- package/dist/core/ecs/store_types.d.ts.map +1 -0
- package/dist/core/ecs/system.d.cts +151 -66
- package/dist/core/ecs/system.d.ts +151 -66
- package/dist/core/ecs/system.d.ts.map +1 -1
- package/dist/core/ecs/system_context.d.cts +296 -0
- package/dist/core/ecs/system_context.d.ts +296 -0
- package/dist/core/ecs/system_context.d.ts.map +1 -0
- package/dist/core/ecs/system_set.d.cts +48 -0
- package/dist/core/ecs/system_set.d.ts +48 -0
- package/dist/core/ecs/system_set.d.ts.map +1 -0
- package/dist/core/ecs/utils/arrays.d.cts +15 -1
- package/dist/core/ecs/utils/arrays.d.ts +15 -1
- package/dist/core/ecs/utils/arrays.d.ts.map +1 -1
- package/dist/core/ecs/utils/error.d.cts +87 -4
- package/dist/core/ecs/utils/error.d.ts +87 -4
- package/dist/core/ecs/utils/error.d.ts.map +1 -1
- package/dist/core/ecs/utils/plugin_error.d.cts +10 -0
- package/dist/core/ecs/utils/plugin_error.d.ts +10 -0
- package/dist/core/ecs/utils/plugin_error.d.ts.map +1 -0
- package/dist/core/restore_errors.d.cts +30 -0
- package/dist/core/restore_errors.d.ts +30 -0
- package/dist/core/restore_errors.d.ts.map +1 -0
- package/dist/core/store/action_ring.d.cts +48 -49
- package/dist/core/store/action_ring.d.ts +48 -49
- package/dist/core/store/action_ring.d.ts.map +1 -1
- package/dist/core/store/allocator.d.cts +166 -114
- package/dist/core/store/allocator.d.ts +166 -114
- package/dist/core/store/allocator.d.ts.map +1 -1
- package/dist/core/store/buffer_backed_column.d.cts +21 -22
- package/dist/core/store/buffer_backed_column.d.ts +21 -22
- package/dist/core/store/buffer_backed_column.d.ts.map +1 -1
- package/dist/core/store/column_store.d.cts +138 -100
- package/dist/core/store/column_store.d.ts +138 -100
- package/dist/core/store/column_store.d.ts.map +1 -1
- package/dist/core/store/command_dispatch.d.cts +14 -15
- package/dist/core/store/command_dispatch.d.ts +14 -15
- package/dist/core/store/command_dispatch.d.ts.map +1 -1
- package/dist/core/store/command_ring.d.cts +41 -45
- package/dist/core/store/command_ring.d.ts +41 -45
- package/dist/core/store/command_ring.d.ts.map +1 -1
- package/dist/core/store/descriptor.d.cts +35 -18
- package/dist/core/store/descriptor.d.ts +35 -18
- package/dist/core/store/descriptor.d.ts.map +1 -1
- package/dist/core/store/entity_index.d.cts +34 -35
- package/dist/core/store/entity_index.d.ts +34 -35
- package/dist/core/store/entity_index.d.ts.map +1 -1
- package/dist/core/store/event_ring.d.cts +40 -42
- package/dist/core/store/event_ring.d.ts +40 -42
- package/dist/core/store/event_ring.d.ts.map +1 -1
- package/dist/core/store/extend.d.cts +15 -9
- package/dist/core/store/extend.d.ts +15 -9
- package/dist/core/store/extend.d.ts.map +1 -1
- package/dist/core/store/grow.d.cts +3 -3
- package/dist/core/store/grow.d.ts +3 -3
- package/dist/core/store/grow.d.ts.map +1 -1
- package/dist/core/store/header.d.cts +37 -33
- package/dist/core/store/header.d.ts +37 -33
- package/dist/core/store/header.d.ts.map +1 -1
- package/dist/core/store/index.d.cts +10 -10
- package/dist/core/store/index.d.ts +10 -10
- package/dist/core/store/index.d.ts.map +1 -1
- package/dist/core/store/layout_ops.d.cts +72 -63
- package/dist/core/store/layout_ops.d.ts +72 -63
- package/dist/core/store/layout_ops.d.ts.map +1 -1
- package/dist/core/store/region_table.d.cts +28 -21
- package/dist/core/store/region_table.d.ts +28 -21
- package/dist/core/store/region_table.d.ts.map +1 -1
- package/dist/core/store/snapshot.d.cts +31 -16
- package/dist/core/store/snapshot.d.ts +31 -16
- package/dist/core/store/snapshot.d.ts.map +1 -1
- package/dist/core/store/state_hash.d.cts +14 -14
- package/dist/core/store/state_hash.d.ts +14 -14
- package/dist/core/store/state_hash.d.ts.map +1 -1
- package/dist/core/store/store_regions.d.cts +10 -10
- package/dist/core/store/store_regions.d.ts +10 -10
- package/dist/core/store/store_regions.d.ts.map +1 -1
- package/dist/core/store/vendored_abi/abi.d.cts +27 -2
- package/dist/core/store/vendored_abi/abi.d.ts +27 -2
- package/dist/core/store/vendored_abi/abi.d.ts.map +1 -1
- package/dist/host_commands-B2KMx8O2.cjs +1 -0
- package/dist/host_commands-ClVPvhSa.cjs +2 -0
- package/dist/host_commands-CwxVQS1z.js +1524 -0
- package/dist/host_commands-nJvTy88E.js +1667 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +16 -11
- package/dist/index.d.ts +16 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.development.cjs +1 -1
- package/dist/index.development.js +6709 -5729
- package/dist/index.js +5664 -4743
- package/dist/internal.cjs +2 -2
- package/dist/internal.d.cts +5 -2
- package/dist/internal.d.ts +5 -2
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.development.cjs +1 -1
- package/dist/internal.development.js +70 -20
- package/dist/internal.js +138 -83
- package/dist/plugins/abi-D3V-QUSf.cjs +1 -0
- package/dist/plugins/abi-NP8pNxpd.js +42 -0
- package/dist/plugins/arrays-Dr_1hCjL.js +28 -0
- package/dist/plugins/arrays-Dt-Joc4i.cjs +1 -0
- package/dist/plugins/assertions-gtDVfbnQ.js +6 -0
- package/dist/plugins/assertions-z5GQd_bB.cjs +1 -0
- package/dist/{extensions → plugins}/editor/editor.d.cts +56 -56
- package/dist/{extensions → plugins}/editor/editor.d.ts +56 -56
- package/dist/plugins/editor/editor.d.ts.map +1 -0
- package/dist/{extensions → plugins}/editor/field_handle.d.cts +13 -13
- package/dist/{extensions → plugins}/editor/field_handle.d.ts +13 -13
- package/dist/plugins/editor/field_handle.d.ts.map +1 -0
- package/dist/plugins/editor/index.d.cts +22 -0
- package/dist/plugins/editor/index.d.ts +22 -0
- package/dist/plugins/editor/index.d.ts.map +1 -0
- package/dist/plugins/editor.cjs +1 -0
- package/dist/plugins/editor.d.cts +1 -0
- package/dist/plugins/editor.d.ts +1 -0
- package/dist/plugins/editor.development.cjs +1 -0
- package/dist/{extensions/editor/index.development.js → plugins/editor.development.js} +83 -66
- package/dist/{extensions/editor/index.js → plugins/editor.js} +83 -66
- package/dist/plugins/events/event_channel.d.cts +13 -0
- package/dist/plugins/events/event_channel.d.ts +13 -0
- package/dist/plugins/events/event_channel.d.ts.map +1 -0
- package/dist/plugins/events/event_registry.d.cts +22 -0
- package/dist/plugins/events/event_registry.d.ts +22 -0
- package/dist/plugins/events/event_registry.d.ts.map +1 -0
- package/dist/plugins/events/facade.d.cts +26 -0
- package/dist/plugins/events/facade.d.ts +26 -0
- package/dist/plugins/events/facade.d.ts.map +1 -0
- package/dist/plugins/events/index.d.cts +10 -0
- package/dist/plugins/events/index.d.ts +10 -0
- package/dist/plugins/events/index.d.ts.map +1 -0
- package/dist/plugins/events.cjs +1 -0
- package/dist/plugins/events.d.cts +1 -0
- package/dist/plugins/events.d.ts +1 -0
- package/dist/plugins/events.development.cjs +1 -0
- package/dist/plugins/events.development.js +174 -0
- package/dist/plugins/events.js +159 -0
- package/dist/plugins/observers/index.d.cts +23 -0
- package/dist/plugins/observers/index.d.ts +23 -0
- package/dist/plugins/observers/index.d.ts.map +1 -0
- package/dist/plugins/observers/observer_registry.d.cts +101 -0
- package/dist/plugins/observers/observer_registry.d.ts +101 -0
- package/dist/plugins/observers/observer_registry.d.ts.map +1 -0
- package/dist/plugins/observers.cjs +1 -0
- package/dist/plugins/observers.d.cts +1 -0
- package/dist/plugins/observers.d.ts +1 -0
- package/dist/plugins/observers.development.cjs +1 -0
- package/dist/plugins/observers.development.js +431 -0
- package/dist/plugins/observers.js +403 -0
- package/dist/plugins/relation_store-BsoegrZh.js +313 -0
- package/dist/plugins/relation_store-DQKSnxsm.cjs +1 -0
- package/dist/plugins/relation_store-RBhpcE28.cjs +1 -0
- package/dist/plugins/relation_store-RqW5Snx6.js +328 -0
- package/dist/plugins/relations/builtin_relations.d.cts +48 -0
- package/dist/plugins/relations/builtin_relations.d.ts +48 -0
- package/dist/plugins/relations/builtin_relations.d.ts.map +1 -0
- package/dist/plugins/relations/facade.d.cts +73 -0
- package/dist/plugins/relations/facade.d.ts +73 -0
- package/dist/plugins/relations/facade.d.ts.map +1 -0
- package/dist/plugins/relations/index.d.cts +11 -0
- package/dist/plugins/relations/index.d.ts +11 -0
- package/dist/plugins/relations/index.d.ts.map +1 -0
- package/dist/{core/ecs → plugins/relations}/relation_service.d.cts +93 -105
- package/dist/{core/ecs → plugins/relations}/relation_service.d.ts +93 -105
- package/dist/plugins/relations/relation_service.d.ts.map +1 -0
- package/dist/plugins/relations/relation_store.d.cts +177 -0
- package/dist/plugins/relations/relation_store.d.ts +177 -0
- package/dist/plugins/relations/relation_store.d.ts.map +1 -0
- package/dist/plugins/relations.cjs +1 -0
- package/dist/plugins/relations.d.cts +1 -0
- package/dist/plugins/relations.d.ts +1 -0
- package/dist/plugins/relations.development.cjs +1 -0
- package/dist/plugins/relations.development.js +603 -0
- package/dist/plugins/relations.js +553 -0
- package/dist/plugins/snapshots/index.d.cts +33 -0
- package/dist/plugins/snapshots/index.d.ts +33 -0
- package/dist/plugins/snapshots/index.d.ts.map +1 -0
- package/dist/plugins/snapshots/resume.d.cts +57 -0
- package/dist/plugins/snapshots/resume.d.ts +57 -0
- package/dist/plugins/snapshots/resume.d.ts.map +1 -0
- package/dist/plugins/snapshots/snapshot_service.d.cts +59 -0
- package/dist/plugins/snapshots/snapshot_service.d.ts +59 -0
- package/dist/plugins/snapshots/snapshot_service.d.ts.map +1 -0
- package/dist/plugins/snapshots.cjs +1 -0
- package/dist/plugins/snapshots.d.cts +1 -0
- package/dist/plugins/snapshots.d.ts +1 -0
- package/dist/plugins/snapshots.development.cjs +1 -0
- package/dist/plugins/snapshots.development.js +737 -0
- package/dist/plugins/snapshots.js +737 -0
- package/dist/plugins/solid/index.d.cts +8 -0
- package/dist/plugins/solid/index.d.ts +8 -0
- package/dist/plugins/solid/index.d.ts.map +1 -0
- package/dist/plugins/solid/solid.d.cts +97 -0
- package/dist/plugins/solid/solid.d.ts +97 -0
- package/dist/plugins/solid/solid.d.ts.map +1 -0
- package/dist/plugins/solid.cjs +1 -0
- package/dist/plugins/solid.d.cts +1 -0
- package/dist/plugins/solid.d.ts +1 -0
- package/dist/plugins/solid.development.cjs +1 -0
- package/dist/plugins/solid.development.js +319 -0
- package/dist/plugins/solid.js +319 -0
- package/dist/plugins/workers/index.d.cts +75 -0
- package/dist/plugins/workers/index.d.ts +75 -0
- package/dist/plugins/workers/index.d.ts.map +1 -0
- package/dist/plugins/workers/node_threads.d.cts +25 -0
- package/dist/plugins/workers/node_threads.d.ts +25 -0
- package/dist/plugins/workers/node_threads.d.ts.map +1 -0
- package/dist/plugins/workers/plan.d.cts +61 -0
- package/dist/plugins/workers/plan.d.ts +61 -0
- package/dist/plugins/workers/plan.d.ts.map +1 -0
- package/dist/plugins/workers/pool.d.cts +144 -0
- package/dist/plugins/workers/pool.d.ts +144 -0
- package/dist/plugins/workers/pool.d.ts.map +1 -0
- package/dist/plugins/workers/protocol.d.cts +112 -0
- package/dist/plugins/workers/protocol.d.ts +112 -0
- package/dist/plugins/workers/protocol.d.ts.map +1 -0
- package/dist/plugins/workers/worker_bind.d.cts +64 -0
- package/dist/plugins/workers/worker_bind.d.ts +64 -0
- package/dist/plugins/workers/worker_bind.d.ts.map +1 -0
- package/dist/plugins/workers/worker_loop.d.cts +14 -0
- package/dist/plugins/workers/worker_loop.d.ts +14 -0
- package/dist/plugins/workers/worker_loop.d.ts.map +1 -0
- package/dist/plugins/workers.cjs +1 -0
- package/dist/plugins/workers.d.cts +1 -0
- package/dist/plugins/workers.d.ts +1 -0
- package/dist/plugins/workers.development.cjs +1 -0
- package/dist/plugins/workers.development.js +596 -0
- package/dist/plugins/workers.js +474 -0
- package/dist/primitives.cjs +1 -1
- package/dist/primitives.d.cts +4 -4
- package/dist/primitives.d.ts +4 -4
- package/dist/primitives.development.cjs +1 -1
- package/dist/primitives.development.js +66 -22
- package/dist/primitives.js +66 -22
- package/dist/shared-BKl12xF1.js +132 -0
- package/dist/shared-Dk-pACZT.cjs +1 -0
- package/dist/shared.cjs +1 -1
- package/dist/shared.d.cts +7 -7
- package/dist/shared.d.ts +7 -7
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.development.cjs +1 -1
- package/dist/shared.development.js +4 -3
- package/dist/shared.js +4 -3
- package/dist/topological_sort-Cc_yXqPT.js +346 -0
- package/dist/topological_sort-vp1imU6D.cjs +1 -0
- package/dist/type_primitives/assertions.d.cts +12 -16
- package/dist/type_primitives/assertions.d.ts +12 -16
- package/dist/type_primitives/assertions.d.ts.map +1 -1
- package/dist/type_primitives/binary_heap/binary_heap.d.cts +2 -6
- package/dist/type_primitives/binary_heap/binary_heap.d.ts +2 -6
- package/dist/type_primitives/binary_heap/binary_heap.d.ts.map +1 -1
- package/dist/type_primitives/bitset/bitset.d.cts +7 -11
- package/dist/type_primitives/bitset/bitset.d.ts +7 -11
- package/dist/type_primitives/bitset/bitset.d.ts.map +1 -1
- package/dist/type_primitives/brand.d.cts +2 -7
- package/dist/type_primitives/brand.d.ts +2 -7
- package/dist/type_primitives/brand.d.ts.map +1 -1
- package/dist/type_primitives/error.d.cts +1 -2
- package/dist/type_primitives/error.d.ts +1 -2
- package/dist/type_primitives/error.d.ts.map +1 -1
- package/dist/type_primitives/index.d.cts +1 -1
- package/dist/type_primitives/index.d.ts +1 -1
- package/dist/type_primitives/sparse_map/sparse_map.d.cts +3 -7
- package/dist/type_primitives/sparse_map/sparse_map.d.ts +3 -7
- package/dist/type_primitives/sparse_map/sparse_map.d.ts.map +1 -1
- package/dist/type_primitives/sparse_set/sparse_set.d.cts +2 -6
- package/dist/type_primitives/sparse_set/sparse_set.d.ts +2 -6
- package/dist/type_primitives/sparse_set/sparse_set.d.ts.map +1 -1
- package/dist/type_primitives/topological_sort/topological_sort.d.cts +1 -5
- package/dist/type_primitives/topological_sort/topological_sort.d.ts +1 -5
- package/dist/type_primitives/topological_sort/topological_sort.d.ts.map +1 -1
- package/dist/type_primitives/typed_arrays/typed_arrays.d.cts +18 -17
- package/dist/type_primitives/typed_arrays/typed_arrays.d.ts +18 -17
- package/dist/type_primitives/typed_arrays/typed_arrays.d.ts.map +1 -1
- package/dist/utils/error.d.ts.map +1 -1
- package/dist/version.d.cts +4 -4
- package/dist/version.d.ts +4 -4
- package/dist/worker.cjs +1 -0
- package/dist/worker.d.cts +17 -0
- package/dist/worker.d.ts +17 -0
- package/dist/worker.d.ts.map +1 -0
- package/dist/worker.development.cjs +1 -0
- package/dist/worker.development.js +253 -0
- package/dist/worker.js +253 -0
- package/package.json +363 -191
- package/dist/core/ecs/builtin_relations.d.cts +0 -43
- package/dist/core/ecs/builtin_relations.d.ts +0 -43
- package/dist/core/ecs/builtin_relations.d.ts.map +0 -1
- package/dist/core/ecs/event_registry.d.cts +0 -22
- package/dist/core/ecs/event_registry.d.ts +0 -22
- package/dist/core/ecs/event_registry.d.ts.map +0 -1
- package/dist/core/ecs/relation_service.d.ts.map +0 -1
- package/dist/core/ecs/resume.d.cts +0 -85
- package/dist/core/ecs/resume.d.ts +0 -85
- package/dist/core/ecs/resume.d.ts.map +0 -1
- package/dist/core/ecs/snapshot_service.d.cts +0 -94
- package/dist/core/ecs/snapshot_service.d.ts +0 -94
- package/dist/core/ecs/snapshot_service.d.ts.map +0 -1
- package/dist/extensions/editor/editor.d.ts.map +0 -1
- package/dist/extensions/editor/field_handle.d.ts.map +0 -1
- package/dist/extensions/editor/index.cjs +0 -1
- package/dist/extensions/editor/index.d.cts +0 -21
- package/dist/extensions/editor/index.d.ts +0 -21
- package/dist/extensions/editor/index.d.ts.map +0 -1
- package/dist/extensions/editor/index.development.cjs +0 -1
- package/dist/extensions/reactive/ecs_sync.d.cts +0 -214
- package/dist/extensions/reactive/ecs_sync.d.ts +0 -214
- package/dist/extensions/reactive/ecs_sync.d.ts.map +0 -1
- package/dist/extensions/reactive/index.cjs +0 -1
- package/dist/extensions/reactive/index.d.cts +0 -23
- package/dist/extensions/reactive/index.d.ts +0 -23
- package/dist/extensions/reactive/index.d.ts.map +0 -1
- package/dist/extensions/reactive/index.development.cjs +0 -1
- package/dist/extensions/reactive/index.development.js +0 -215
- package/dist/extensions/reactive/index.js +0 -215
- package/dist/extensions/solid/index.cjs +0 -1
- package/dist/extensions/solid/index.d.cts +0 -6
- package/dist/extensions/solid/index.d.ts +0 -6
- package/dist/extensions/solid/index.d.ts.map +0 -1
- package/dist/extensions/solid/index.development.cjs +0 -1
- package/dist/extensions/solid/index.development.js +0 -40
- package/dist/extensions/solid/index.js +0 -36
- package/dist/extensions/solid/kernel_solid.d.cts +0 -45
- package/dist/extensions/solid/kernel_solid.d.ts +0 -45
- package/dist/extensions/solid/kernel_solid.d.ts.map +0 -1
- package/dist/host_commands-3jyFfWNg.js +0 -2326
- package/dist/host_commands-DNf0f6ko.cjs +0 -1
- package/dist/internal-C9jjL90H.js +0 -2485
- package/dist/internal-RZN14uMw.cjs +0 -2
- package/dist/interop-CT-REx0W.cjs +0 -1
- package/dist/interop-CcY6ASQc.js +0 -18
- package/dist/interop-DqxleBo7.js +0 -18
- package/dist/interop-T1HZ-Dpa.cjs +0 -1
- package/dist/kernel-Cz2Kxlwl.js +0 -240
- package/dist/kernel-DgyrLFjW.js +0 -227
- package/dist/kernel-sw7ScKWu.cjs +0 -1
- package/dist/kernel-yWV3XnAb.cjs +0 -1
- package/dist/reactive/array.d.cts +0 -24
- package/dist/reactive/array.d.ts +0 -24
- package/dist/reactive/array.d.ts.map +0 -1
- package/dist/reactive/index.cjs +0 -1
- package/dist/reactive/index.d.cts +0 -11
- package/dist/reactive/index.d.ts +0 -11
- package/dist/reactive/index.d.ts.map +0 -1
- package/dist/reactive/index.development.cjs +0 -1
- package/dist/reactive/index.development.js +0 -18
- package/dist/reactive/index.js +0 -18
- package/dist/reactive/interop.d.cts +0 -19
- package/dist/reactive/interop.d.ts +0 -19
- package/dist/reactive/interop.d.ts.map +0 -1
- package/dist/reactive/kernel.d.cts +0 -73
- package/dist/reactive/kernel.d.ts +0 -73
- package/dist/reactive/kernel.d.ts.map +0 -1
- package/dist/reactive/map.d.cts +0 -16
- package/dist/reactive/map.d.ts +0 -16
- package/dist/reactive/map.d.ts.map +0 -1
- package/dist/reactive/shallow.d.cts +0 -11
- package/dist/reactive/shallow.d.ts +0 -11
- package/dist/reactive/shallow.d.ts.map +0 -1
- package/dist/reactive/struct.d.cts +0 -10
- package/dist/reactive/struct.d.ts +0 -10
- package/dist/reactive/struct.d.ts.map +0 -1
- package/dist/shallow-9S1pY_Iw.js +0 -159
- package/dist/shallow-C5YmTbtb.cjs +0 -1
- package/dist/shallow-DQ8aG51_.cjs +0 -1
- package/dist/shallow-DfnAm9vG.js +0 -150
- package/dist/shared-BMXh9hxm.cjs +0 -1
- package/dist/shared-DQKK0i-E.js +0 -109
- package/dist/topological_sort-BDvEyb9W.cjs +0 -1
- package/dist/topological_sort-DK6EjpWa.js +0 -135
- package/dist/typed_arrays-BcXcnzB4.js +0 -258
- package/dist/typed_arrays-D3NmwtCG.cjs +0 -1
|
@@ -1,134 +1,122 @@
|
|
|
1
|
-
import { BitSet
|
|
2
|
-
import { Archetype } from '
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
isAlive(id: EntityID): boolean;
|
|
12
|
-
hasSparse(entityId: EntityID, def: SparseComponentDef): boolean;
|
|
13
|
-
pushSparseStore(fieldNames: string[], fieldTypes: TypedArrayTag[]): SparseComponentDef;
|
|
14
|
-
sparseStoreOf(def: SparseComponentDef): SparseComponentStore;
|
|
15
|
-
sparseStores(): readonly SparseComponentStore[];
|
|
16
|
-
entityGenerations(): Int32Array;
|
|
17
|
-
entityArchetype(): Int32Array;
|
|
18
|
-
entityRow(): Int32Array;
|
|
19
|
-
archetypes(): readonly Archetype[];
|
|
20
|
-
forEachSparseMatch(include: BitSet, exclude: BitSet | null, anyOf: BitSet | null, sparseInclude: readonly SparseComponentID[], sparseExclude: readonly SparseComponentID[], denseArchetypes: readonly Archetype[], cb: (entityId: EntityID) => void, includeDisabled: boolean): void;
|
|
21
|
-
}
|
|
22
|
-
export declare class RelationService {
|
|
23
|
-
private readonly host;
|
|
24
|
-
private readonly relations;
|
|
1
|
+
import { BitSet } from '../../type_primitives/index.js';
|
|
2
|
+
import { Archetype } from '../../core/ecs/archetype.js';
|
|
3
|
+
import { QueryTerms } from '../../core/ecs/query_terms.js';
|
|
4
|
+
import { EntityID } from '../../core/ecs/entity.js';
|
|
5
|
+
import { RelationDef, RelationHooks, RelationOptions, RelationServiceHost } from '../../core/ecs/relation.js';
|
|
6
|
+
import { RelationStore } from './relation_store.js';
|
|
7
|
+
import { SparseComponentID } from '../../core/ecs/sparse_store.js';
|
|
8
|
+
export declare class RelationService implements RelationHooks {
|
|
9
|
+
private readonly _host;
|
|
10
|
+
private readonly _relations;
|
|
25
11
|
private _hasTargetCleanup;
|
|
26
|
-
private
|
|
12
|
+
private _hierarchyRadixOut;
|
|
27
13
|
private readonly _hierarchyRadixC0;
|
|
28
14
|
private readonly _hierarchyRadixC1;
|
|
29
|
-
constructor(
|
|
30
|
-
/** The registry, indexed by RelationID
|
|
31
|
-
* `stateHash
|
|
15
|
+
constructor(_host: RelationServiceHost);
|
|
16
|
+
/** The registry, indexed by RelationID, the read-only view the Store's
|
|
17
|
+
* `stateHash`, snapshot and restore paths iterate. */
|
|
32
18
|
get stores(): readonly RelationStore[];
|
|
33
19
|
/** Number of registered relations. */
|
|
34
20
|
get count(): number;
|
|
35
|
-
/** Whether any relation registered a non-`orphan` `onDeleteTarget` policy
|
|
36
|
-
* the destroy paths' gate for `cleanupTarget
|
|
21
|
+
/** Whether any relation registered a non-`orphan` `onDeleteTarget` policy,
|
|
22
|
+
* the destroy paths' gate for `cleanupTarget`. */
|
|
37
23
|
get hasTargetCleanup(): boolean;
|
|
38
24
|
/** Register a relation kind. `exclusive` (the default) → one target per
|
|
39
25
|
* source, stored in a backing `{ target: f64 }` sparse component, so the
|
|
40
|
-
* forward index rides the sparse store and inherits query membership
|
|
41
|
-
* `stateHash` + snapshot
|
|
26
|
+
* forward index rides the sparse store and inherits query membership,
|
|
27
|
+
* `stateHash` + snapshot and restore for free. `multi` → a set of
|
|
42
28
|
* targets per source, backed by a sparse tag for membership plus a side
|
|
43
29
|
* forward index the relation owns. The two cardinalities are mutually
|
|
44
30
|
* exclusive. `onDeleteTarget` selects the cleanup policy run when a target
|
|
45
|
-
* is destroyed
|
|
46
|
-
* sources survive), or `orphan` (default: leave it dangling
|
|
47
|
-
*
|
|
31
|
+
* is destroyed, `delete` (cascade-destroy sources), `clear` (drop the link,
|
|
32
|
+
* sources survive), or `orphan` (default: leave it dangling). See
|
|
33
|
+
* `relation_store.ts`.
|
|
48
34
|
*
|
|
49
35
|
* The backing sparse store is resolved and handed to the relation so it can
|
|
50
|
-
* drive forward
|
|
51
|
-
* interaction
|
|
52
|
-
* branch here
|
|
36
|
+
* drive forward and membership rows directly, the cardinality-specific
|
|
37
|
+
* interaction belongs to `ExclusiveRelationStore` and `MultiRelationStore`, not to a
|
|
38
|
+
* branch here. */
|
|
53
39
|
registerRelation(opts?: RelationOptions): RelationDef;
|
|
54
|
-
private
|
|
40
|
+
private _relationOf;
|
|
55
41
|
/** Add a `(R, tgt)` pair to `src`. No archetype transition. Exclusive:
|
|
56
42
|
* replaces any existing target (engine-enforced one-per-source), a no-op if
|
|
57
43
|
* `tgt` is already the target. Multi: adds `tgt` to the set, a no-op if
|
|
58
44
|
* already present. A dead `src` *or* `tgt` is caller error: it throws in
|
|
59
|
-
* `DEV` and is a no-op in production
|
|
60
|
-
* never links a reverse-index entry keyed by a destroyed handle
|
|
45
|
+
* `DEV` and is a no-op in production, symmetric, so a production build
|
|
46
|
+
* never links a reverse-index entry keyed by a destroyed handle. */
|
|
61
47
|
addRelation(src: EntityID, def: RelationDef, tgt: EntityID): void;
|
|
62
48
|
/** Remove a `(R, tgt)` pair from `src`. No archetype transition. Exclusive:
|
|
63
49
|
* `tgt` is optional and the removal is a no-op when it names a target other
|
|
64
50
|
* than the current one. Multi: omitting `tgt` removes *all* of `src`'s
|
|
65
|
-
* targets
|
|
51
|
+
* targets. Passing one removes only that pair (dropping membership when the
|
|
66
52
|
* set empties). */
|
|
67
53
|
removeRelation(src: EntityID, def: RelationDef, tgt?: EntityID): void;
|
|
68
54
|
/** The single target of `src` under an exclusive relation, or `undefined`.
|
|
69
55
|
* Throws in `DEV` on a multi-target relation (use `targetsOf`). */
|
|
70
56
|
targetOf(src: EntityID, def: RelationDef): EntityID | undefined;
|
|
71
|
-
/** All targets of `src` under `R
|
|
72
|
-
* for multi
|
|
57
|
+
/** All targets of `src` under `R`, one or zero for exclusive, the full set
|
|
58
|
+
* for multi, ascending by id. */
|
|
73
59
|
targetsOf(src: EntityID, def: RelationDef): EntityID[];
|
|
74
60
|
/** Sources that point at `tgt` under `R` (the reverse index), ascending by
|
|
75
|
-
* id
|
|
61
|
+
* id. Empty when none. */
|
|
76
62
|
sourcesOf(tgt: EntityID, def: RelationDef): EntityID[];
|
|
77
63
|
/** Whether `src` holds any pair under `R`. */
|
|
78
64
|
hasRelation(src: EntityID, def: RelationDef): boolean;
|
|
79
|
-
/** All `(source, target)` pairs of relation `R
|
|
80
|
-
*
|
|
65
|
+
/** All `(source, target)` pairs of relation `R`, the `(R, *)` wildcard.
|
|
66
|
+
* Sources are emitted in **canonical entity-index order** (the
|
|
81
67
|
* determinism convention): exclusive relations ride the backing sparse
|
|
82
68
|
* store's `canonicalIndices`, multi relations ride the same
|
|
83
|
-
* `forEachCanonicalTargetSet` traversal `stateHash`
|
|
84
|
-
* use
|
|
85
|
-
* relation holds no pairs. Cold path
|
|
86
|
-
*
|
|
87
|
-
* point-query forms are `targetOf`
|
|
69
|
+
* `forEachCanonicalTargetSet` traversal that `stateHash` and
|
|
70
|
+
* `snapshotRelations` use. A multi source's targets follow ascending by id.
|
|
71
|
+
* Empty when the relation holds no pairs. Cold path, it allocates the result
|
|
72
|
+
* array, and for multi it sorts each source's target set. Not for per-tick
|
|
73
|
+
* use. The point-query forms are `targetOf` and `targetsOf`. */
|
|
88
74
|
pairsOf(def: RelationDef): readonly (readonly [EntityID, EntityID])[];
|
|
89
75
|
/** Every `(relation, source)` pointing at `tgt`, across **all** registered
|
|
90
|
-
* relation kinds
|
|
76
|
+
* relation kinds, the `(*, T)` wildcard. Walks the relation registry
|
|
91
77
|
* in id order (each relation's reverse index already returns sources
|
|
92
78
|
* ascending by id), so the result is ordered by relation id then source id.
|
|
93
79
|
* Empty when nothing targets `tgt`. The single-relation form is
|
|
94
80
|
* `sourcesOf(tgt, def)`. */
|
|
95
81
|
sourcesOfAny(tgt: EntityID): readonly (readonly [RelationDef, EntityID])[];
|
|
96
|
-
/** The backing sparse component id of relation `R
|
|
97
|
-
* `(R, *)` wildcard term (`Query.
|
|
82
|
+
/** The backing sparse component id of relation `R`, the membership store a
|
|
83
|
+
* `(R, *)` wildcard term (`Query.andRelation`) drives through the shared
|
|
98
84
|
* sparse-match path. Exclusive relations back a `{ target: f64 }` sparse
|
|
99
|
-
* component, multi a tag
|
|
85
|
+
* component, multi a tag. Both carry per-source membership, so "has any
|
|
100
86
|
* `(R, *)` pair" is exactly membership in this store (including an
|
|
101
|
-
* orphan-dangling source, whose membership row persists
|
|
102
|
-
* `pairsOf`). The def is engine-owned and never handed to callers
|
|
103
|
-
* the query builder only its erased id for the `
|
|
87
|
+
* orphan-dangling source, whose membership row persists, consistent with
|
|
88
|
+
* `pairsOf`). The def is engine-owned and never handed to callers. This hands
|
|
89
|
+
* the query builder only its erased id for the `sparseIncludes` list. */
|
|
104
90
|
relationBackingSparseId(def: RelationDef): SparseComponentID;
|
|
105
91
|
/** Drive a `(*, T)` wildcard query (`Query.forEachRelatedTo`): every source
|
|
106
92
|
* related to `target` under **any** relation, intersected with the query's
|
|
107
|
-
* dense mask
|
|
93
|
+
* dense mask, its sparse require and exclude terms, and the default
|
|
94
|
+
* enabled-row filter,
|
|
108
95
|
* each source yielded once. Unions `sourcesOf(target, R)` across every
|
|
109
|
-
* relation into a `Set` (dedup by full `EntityID
|
|
96
|
+
* relation into a `Set` (dedup by full `EntityID`, a source related to `T`
|
|
110
97
|
* via two relations is yielded once), then sorts ascending: the cross-relation
|
|
111
98
|
* union has no inherent order, so one cold sort gives a deterministic,
|
|
112
|
-
* canonical `(*, T)` order matching `sourcesOf`
|
|
113
|
-
* the same way). Cold
|
|
114
|
-
* `
|
|
99
|
+
* canonical `(*, T)` order matching `sourcesOf` and `sourcesOfAny` (which sort
|
|
100
|
+
* the same way). Cold and structural, not a per-tick hot loop over many targets.
|
|
101
|
+
* `sparseIncludes` and `sparseExcludes` carry both raw sparse terms and the backing
|
|
115
102
|
* stores of any composed `(R, *)` terms, so it intersects with them uniformly. */
|
|
116
|
-
|
|
103
|
+
forEachTargetMatch(target: EntityID, include: BitSet, exclude: BitSet | null, anyOf: BitSet | null, terms: QueryTerms, cb: (entityId: EntityID) => void): void;
|
|
117
104
|
/** Reclaim reverse-index memory: drop every relation's reverse entries whose
|
|
118
105
|
* **target** has been destroyed, returning the total dropped across all
|
|
119
|
-
* relations
|
|
106
|
+
* relations. Under the default `orphan` policy a destroyed target
|
|
120
107
|
* leaves its reverse entry intact until each source re-targets or dies, so a
|
|
121
108
|
* long-lived source that orphan-points at a churn of short-lived targets and
|
|
122
109
|
* never re-targets accumulates dead-target keys without bound. This cold-path
|
|
123
|
-
* hook drops them on demand
|
|
110
|
+
* hook drops them on demand, call it at scene or snapshot boundaries.
|
|
124
111
|
*
|
|
125
112
|
* Purely a memory reclaim with no observable state change: forward links stay
|
|
126
113
|
* dangling (so `orphan`'s `targetOf`-returns-the-dead-handle contract is
|
|
127
114
|
* unchanged), `stateHash` is unaffected (the reverse index is derived, never
|
|
128
|
-
* folded), and the dropped entries are faithfully rebuilt by snapshot
|
|
129
|
-
* from the surviving forward links (
|
|
115
|
+
* folded), and the dropped entries are faithfully rebuilt by snapshot and restore
|
|
116
|
+
* from the surviving forward links (the snapshot plugin's
|
|
117
|
+
* `_rebuildRelationIndices`). The only
|
|
130
118
|
* difference a caller can see is `sourcesOf(deadHandle, R)` going from the
|
|
131
|
-
* dangling sources to `[]
|
|
119
|
+
* dangling sources to `[]`, both meaningless once the target is gone.
|
|
132
120
|
* No-op (returns 0) when no relations are registered. */
|
|
133
121
|
compactRelations(): number;
|
|
134
122
|
/** Walk exclusive relation `R` from `src` toward the root, returning the
|
|
@@ -136,34 +124,34 @@ export declare class RelationService {
|
|
|
136
124
|
* inclusive of both endpoints). A source with no target returns `[src]`. The
|
|
137
125
|
* root is the first entity in the chain with no `R`-target, **or** a dangling
|
|
138
126
|
* dead target handle (see below). Throws `RELATION_MODE_MISMATCH` on a multi
|
|
139
|
-
* relation and `RELATION_CYCLE` on a cycle (both `DEV`-only
|
|
127
|
+
* relation and `RELATION_CYCLE` on a cycle (both `DEV`-only, in production
|
|
140
128
|
* a cycle stops at the repeated node).
|
|
141
129
|
*
|
|
142
130
|
* **Dangling links terminate the chain.** Under the `orphan` policy a source
|
|
143
131
|
* keeps pointing at a destroyed target (a dead handle). The walk must *not*
|
|
144
132
|
* advance through such a handle: the backing store is keyed by entity
|
|
145
133
|
* **index**, so reading the dead handle's index would return whatever now
|
|
146
|
-
* occupies that recycled slot
|
|
134
|
+
* occupies that recycled slot, splicing the chain onto an unrelated entity
|
|
147
135
|
* (the ABA the `EntityID`-keyed reverse index avoids for `cascadeOf`). So a
|
|
148
136
|
* dead next-hop is appended as the chain's (dangling) terminus and the walk
|
|
149
|
-
* stops
|
|
137
|
+
* stops. The caller can detect it with `isAlive`, exactly as `targetOf`
|
|
150
138
|
* returns a dead handle. */
|
|
151
139
|
ancestorsOf(src: EntityID, def: RelationDef): EntityID[];
|
|
152
|
-
/** The root of `src`'s exclusive-relation chain
|
|
140
|
+
/** The root of `src`'s exclusive-relation chain, the last entity of
|
|
153
141
|
* `ancestorsOf` (the one with no `R`-target). `src` itself when it has no
|
|
154
142
|
* target. If the chain ends in a dangling dead target handle (orphan policy),
|
|
155
|
-
* that handle is the root
|
|
143
|
+
* that handle is the root, `isAlive`-check the result if dangling links are
|
|
156
144
|
* possible. Same `DEV` guards as `ancestorsOf`. */
|
|
157
145
|
rootOf(src: EntityID, def: RelationDef): EntityID;
|
|
158
146
|
/** Walk exclusive relation `R` **down** from `root` over the reverse index,
|
|
159
|
-
* returning the subtree (including `root`) breadth-first
|
|
147
|
+
* returning the subtree (including `root`) breadth-first, **parents before
|
|
160
148
|
* children** (the `cascade` order). Children of each node come from
|
|
161
149
|
* `sourcesOf` (ascending by id), so the traversal is deterministic. Throws
|
|
162
150
|
* `RELATION_MODE_MISMATCH` on a multi relation and `RELATION_CYCLE` on a cycle
|
|
163
|
-
* (both `DEV`-only
|
|
151
|
+
* (both `DEV`-only, in production an already-visited node is skipped, so
|
|
164
152
|
* it never hangs). */
|
|
165
153
|
cascadeOf(root: EntityID, def: RelationDef): EntityID[];
|
|
166
|
-
/** Purge a destroyed entity from the relation indices
|
|
154
|
+
/** Purge a destroyed entity from the relation indices, its **source** role
|
|
167
155
|
* only: drop its forward target(s) and unlink it from every target's reverse
|
|
168
156
|
* set. The backing sparse membership row is dropped separately by the Store's
|
|
169
157
|
* `_purgeSparse`, so this must run *before* it (it reads the sparse target
|
|
@@ -171,64 +159,64 @@ export declare class RelationService {
|
|
|
171
159
|
* intact: the reverse index is keyed by full `EntityID`, so a recycled slot
|
|
172
160
|
* never aliases the dead target's sources. The destroyed entity's **target**
|
|
173
161
|
* role is handled separately by `cleanupTarget` per each relation's
|
|
174
|
-
* `OnDeleteTarget` policy
|
|
162
|
+
* `OnDeleteTarget` policy. Gated by the caller on `count > 0`. */
|
|
175
163
|
purgeSource(entityId: EntityID): void;
|
|
176
164
|
/** Apply each relation's `OnDeleteTarget` policy for a destroyed **target**
|
|
177
|
-
* `targetId
|
|
165
|
+
* `targetId`. Walks the registry. For every relation whose reverse
|
|
178
166
|
* index has sources pointing at the dead target:
|
|
179
167
|
*
|
|
180
|
-
* - **`delete
|
|
181
|
-
* through the same path, so chains
|
|
168
|
+
* - **`delete`**, append each source to `cascade`. The caller destroys them
|
|
169
|
+
* through the same path, so chains and trees cascade recursively. The sources'
|
|
182
170
|
* own source-role purge (`purgeSource`) drops their forward link and
|
|
183
171
|
* unlinks them from `targetId`'s reverse set, so no reverse entry leaks.
|
|
184
|
-
* - **`clear
|
|
185
|
-
* `rs.unlink(src, targetId)` (exclusive drops the row
|
|
172
|
+
* - **`clear`**, drop each source's link to the dead target in place via
|
|
173
|
+
* `rs.unlink(src, targetId)` (exclusive drops the row, multi removes the
|
|
186
174
|
* target from the set, dropping membership when it empties). Sources
|
|
187
|
-
* survive
|
|
188
|
-
* - **`orphan
|
|
175
|
+
* survive, the cardinality bookkeeping is the relation's, not branched here.
|
|
176
|
+
* - **`orphan`**, skipped (the link is left dangling, safe because the
|
|
189
177
|
* reverse key carries the generation).
|
|
190
178
|
*
|
|
191
179
|
* `sourcesOf` returns a fresh snapshot, so mutating the reverse index while
|
|
192
180
|
* iterating is safe. Gated by the caller on `hasTargetCleanup`, so the
|
|
193
181
|
* whole walk is skipped when no relation opts into a non-`orphan` policy. */
|
|
194
182
|
cleanupTarget(targetId: EntityID, cascade: EntityID[]): void;
|
|
195
|
-
/**
|
|
196
|
-
* sparse-match intersection (dense mask
|
|
197
|
-
* default enabled-row filter)
|
|
183
|
+
/** A query-match path: yield the matched entities, the exact
|
|
184
|
+
* sparse-match intersection (dense mask, sparse require and exclude, and the
|
|
185
|
+
* default enabled-row filter), in canonical **hierarchy depth order** over
|
|
198
186
|
* exclusive relation `R`: depth ascending (parents before children), **entity
|
|
199
187
|
* index ascending within each depth band**. Entities deeper than `maxDepth`
|
|
200
188
|
* are skipped (`Infinity` = unbounded). Only reached via `Query.forEachEntity`
|
|
201
189
|
* on a query carrying a `.hierarchy(R)` term.
|
|
202
190
|
*
|
|
203
|
-
* `.hierarchy(R)` does not narrow the matched set
|
|
191
|
+
* `.hierarchy(R)` does not narrow the matched set. It reorders it, so an
|
|
204
192
|
* entity with no `R`-parent is a root (depth 0) and is yielded first. Depth is a
|
|
205
193
|
* structural property of the *full* tree (an ancestor outside the matched set
|
|
206
194
|
* still counts toward depth), computed by a memoised upward walk shared across
|
|
207
|
-
* the whole batch, so a shared
|
|
195
|
+
* the whole batch, so a shared or deep chain costs O(nodes), not O(nodes²).
|
|
208
196
|
*
|
|
209
|
-
* The canonical order is produced without a comparator sort
|
|
210
|
-
*
|
|
211
|
-
* the host's `forEachSparseMatch
|
|
212
|
-
* ascending
|
|
197
|
+
* The canonical order is produced without a comparator sort, which is far
|
|
198
|
+
* slower: (1) collect the matched ids via
|
|
199
|
+
* the host's `forEachSparseMatch`, (2) `radixSortByIndex` → entity-index
|
|
200
|
+
* ascending, and (3) stable-bucket by depth, since the input is index-ascending
|
|
213
201
|
* and the bucket append is stable, each depth band stays index-ascending.
|
|
214
202
|
* Tuned for the motivating per-tick case (transform propagation): the radix
|
|
215
203
|
* scratch is reused instance state (`_hierarchyRadix*`), so a per-tick pass
|
|
216
|
-
* churns no histograms
|
|
217
|
-
* `visiting`) is still allocated per call, as it must stay call-local for
|
|
204
|
+
* churns no histograms. The working set (`matched`, `buckets`, `depthMemo`
|
|
205
|
+
* and `visiting`) is still allocated per call, as it must stay call-local for
|
|
218
206
|
* re-entrancy.
|
|
219
207
|
*
|
|
220
|
-
* Exclusive-only
|
|
221
|
-
* (mirrors `cascadeOf`
|
|
222
|
-
* `DEV` and a safe break in production. */
|
|
223
|
-
forEachHierarchyMatch(include: BitSet, exclude: BitSet | null, anyOf: BitSet | null,
|
|
208
|
+
* Exclusive-only, a multi relation throws `RELATION_MODE_MISMATCH` in `DEV`
|
|
209
|
+
* (mirrors `cascadeOf` and `ancestorsOf`). A cycle is a loud `RELATION_CYCLE`
|
|
210
|
+
* in `DEV` and a safe break in production. */
|
|
211
|
+
forEachHierarchyMatch(include: BitSet, exclude: BitSet | null, anyOf: BitSet | null, terms: QueryTerms, denseArchetypes: readonly Archetype[], relation: RelationDef, maxDepth: number, cb: (entityId: EntityID) => void): void;
|
|
224
212
|
/** Depth of entity index `idx` in the exclusive-relation tree backing `store`
|
|
225
213
|
* (root = 0), for `forEachHierarchyMatch`. Memoised across the batch (`memo`),
|
|
226
214
|
* so a shared ancestor chain is walked once. Walks upward via the backing store's
|
|
227
215
|
* target field 0 (mirroring `ancestorsOf`), stopping at: a root (no target), an
|
|
228
|
-
* already-memoised node, or a dangling
|
|
229
|
-
* a root
|
|
230
|
-
* `visiting` flags the nodes on the current upward path to catch a cycle
|
|
231
|
-
* `RELATION_CYCLE` in `DEV`, treated as a root in production
|
|
216
|
+
* already-memoised node, or a dangling or dead parent (the child is then treated as
|
|
217
|
+
* a root, never advance through a recycled slot, the ABA `ancestorsOf` guards).
|
|
218
|
+
* `visiting` flags the nodes on the current upward path to catch a cycle,
|
|
219
|
+
* `RELATION_CYCLE` in `DEV`, treated as a root in production, and is emptied
|
|
232
220
|
* on the way back down so it can be reused for the next entity. */
|
|
233
221
|
private _hierarchyDepthOf;
|
|
234
222
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relation_service.d.ts","sourceRoot":"","sources":["../../../src/plugins/relations/relation_service.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { EntityID } from '../../core/ecs/entity.cjs';
|
|
2
|
+
import { SparseComponentDef, SparseComponentStore } from '../../core/ecs/sparse_store.cjs';
|
|
3
|
+
import { CanonicalPairFn, CanonicalTargetSetFn, MakeSourceID, OnDeleteTarget, RelationStoreView } from '../../core/ecs/relation.cjs';
|
|
4
|
+
/** One relation's derived side state. **Abstract over cardinality:** the
|
|
5
|
+
* base owns the cardinality-agnostic **reverse index** (target → sources, keyed
|
|
6
|
+
* by full `EntityID` so a recycled slot can't alias a dead target's sources) and
|
|
7
|
+
* a handle on the backing `SparseComponentStore`. The forward representation and
|
|
8
|
+
* its sparse interaction are owned by the concrete `ExclusiveRelationStore` and
|
|
9
|
+
* `MultiRelationStore` (built by `createRelationStore`).
|
|
10
|
+
*
|
|
11
|
+
* The registry level (`Store` and `RelationService`) owns what is genuinely its
|
|
12
|
+
* own, entity liveness, registration, and destroy orchestration, and drives
|
|
13
|
+
* a relation through the virtual `link`,
|
|
14
|
+
* `unlink`, `purgeSource`, `forEachCanonicalPair` and their peers, without ever
|
|
15
|
+
* branching on cardinality. Each cardinality keeps the forward link, the reverse
|
|
16
|
+
* index and the sparse membership in lockstep inside one method on one class, so the
|
|
17
|
+
* lockstep can't be broken by missing a scattered `if (rs.exclusive)` site. */
|
|
18
|
+
export declare abstract class RelationStore implements RelationStoreView {
|
|
19
|
+
/** `true` → one target per source, held in the sparse field. `false` →
|
|
20
|
+
* a set of targets per source. The cardinality discriminant survives as a
|
|
21
|
+
* field because the snapshot header and the traversal and `targetOf`
|
|
22
|
+
* mode guards carry it. The forward mechanics stay virtual, never branched
|
|
23
|
+
* on it. */
|
|
24
|
+
readonly exclusive: boolean;
|
|
25
|
+
/** Backing sparse component def: `{ target: f64 }` when exclusive, a tag when
|
|
26
|
+
* multi. Carries membership (and the target, when exclusive). */
|
|
27
|
+
readonly sparse: SparseComponentDef;
|
|
28
|
+
/** Cleanup policy applied to this relation's sources when a target is
|
|
29
|
+
* destroyed. `orphan` (the default) is a no-op, the link dangles
|
|
30
|
+
* safely. `Store` reads this at destroy-flush off `sourcesOf`. */
|
|
31
|
+
readonly onDeleteTarget: OnDeleteTarget;
|
|
32
|
+
/** The backing sparse store instance. Owned for registration and liveness by
|
|
33
|
+
* `Store`, but the relation drives the forward and membership rows on it directly.
|
|
34
|
+
* That is the cardinality interaction this class now encapsulates. */
|
|
35
|
+
protected readonly _store: SparseComponentStore;
|
|
36
|
+
/** target `EntityID` → set of source `EntityID`s. Keyed by the full id, not
|
|
37
|
+
* the index, so a recycled target slot can't alias a dead target's sources.
|
|
38
|
+
* An entry is dropped the moment its set empties (`_unlinkReverse`). */
|
|
39
|
+
private readonly _reverse;
|
|
40
|
+
constructor(exclusive: boolean, sparse: SparseComponentDef, store: SparseComponentStore, onDeleteTarget: OnDeleteTarget);
|
|
41
|
+
/** Record that `src` points at `tgt` in the reverse index. */
|
|
42
|
+
protected _linkReverse(tgt: EntityID, src: EntityID): void;
|
|
43
|
+
/** Drop the `src → tgt` edge from the reverse index, removing the target's
|
|
44
|
+
* entry entirely once its last source is gone (so a dead-target key doesn't
|
|
45
|
+
* linger with an empty set). */
|
|
46
|
+
protected _unlinkReverse(tgt: EntityID, src: EntityID): void;
|
|
47
|
+
/** Drop every reverse-index entry whose **target** is no longer alive,
|
|
48
|
+
* returning the count dropped. The `orphan` policy intentionally
|
|
49
|
+
* leaves a destroyed target's reverse entry intact (the link dangles
|
|
50
|
+
* safely), so a long-lived source that orphan-points at a stream of
|
|
51
|
+
* short-lived targets and never re-targets or dies accumulates dead-target keys
|
|
52
|
+
* without bound. This is the reclaim primitive behind `ecs.relations.compact`,
|
|
53
|
+
* a cold path the host calls at scene and snapshot boundaries. It is
|
|
54
|
+
* cardinality-free (reverse-index only), so it lives on the base unchanged.
|
|
55
|
+
*
|
|
56
|
+
* Pure index reclaim: the **forward** links (the exclusive sparse target
|
|
57
|
+
* field, the multi forward set) are left untouched, so `targetOf` and
|
|
58
|
+
* `targetsOf` still return the dangling dead handle exactly as `orphan`
|
|
59
|
+
* promises. The reverse index is derived, so dropping a dead-target entry
|
|
60
|
+
* changes nothing observable except `sourcesOf` on that dead handle (which
|
|
61
|
+
* goes from the dangling sources to `[]`, meaningless either way, the target
|
|
62
|
+
* is gone) and is faithfully rebuilt by snapshot and restore from the surviving
|
|
63
|
+
* forward links. Only the **target** role can leak here: a destroyed *source*
|
|
64
|
+
* is already unlinked from every reverse set by `purgeSource`, so a live
|
|
65
|
+
* target's set never holds a dead source. `isAlive` is supplied by `Store`,
|
|
66
|
+
* which owns entity liveness. Deleting during `Map` key iteration is
|
|
67
|
+
* well-defined, already-visited and not-yet-reached keys are unaffected. */
|
|
68
|
+
pruneDeadReverse(isAlive: (id: EntityID) => boolean): number;
|
|
69
|
+
/** Sources that point at `tgt`, ascending by id (deterministic, cold-path
|
|
70
|
+
* sort), empty when none. */
|
|
71
|
+
sourcesOf(tgt: EntityID): EntityID[];
|
|
72
|
+
/** Drop every derived side index, the reverse index and (for multi) the
|
|
73
|
+
* forward target sets. Restore path only (`restoreRelations`): the side
|
|
74
|
+
* indices are rebuilt from scratch, so they're cleared first to stay
|
|
75
|
+
* idempotent when restoring into a dirty world. The backing sparse store is
|
|
76
|
+
* cleared separately by `restoreSparseStores`. */
|
|
77
|
+
resetIndices(): void;
|
|
78
|
+
/** Clear this relation's forward representation. Multi clears the side map.
|
|
79
|
+
* Exclusive clears nothing, because its forward links live in the sparse
|
|
80
|
+
* store, which `restoreSparseStores` clears. */
|
|
81
|
+
protected abstract _resetForward(): void;
|
|
82
|
+
/** Add a `(R, tgt)` link from `src`, keeping the forward link, the membership
|
|
83
|
+
* row and the reverse index in lockstep. Exclusive: replaces any existing target
|
|
84
|
+
* (idempotent if `tgt` is already the target). Multi: adds to the set
|
|
85
|
+
* (idempotent on a duplicate), establishing the membership tag on the first
|
|
86
|
+
* target. `src` must be live, `Store` checks before delegating. */
|
|
87
|
+
abstract link(src: EntityID, tgt: EntityID): void;
|
|
88
|
+
/** Remove `(R, tgt)` from `src`, or, when `tgt` is omitted, every target of
|
|
89
|
+
* `src`, keeping the forward link, the membership row and the reverse index
|
|
90
|
+
* in lockstep. A
|
|
91
|
+
* no-op when the link isn't present. */
|
|
92
|
+
abstract unlink(src: EntityID, tgt?: EntityID): void;
|
|
93
|
+
/** Purge a destroyed **source**: drop its forward link(s) and unlink it from
|
|
94
|
+
* every target's reverse set, but leave the sparse **membership** row alone,
|
|
95
|
+
* `Store._purgeSparse` drops that (for every store) right after, so this
|
|
96
|
+
* runs first and must not double-remove. */
|
|
97
|
+
abstract purgeSource(src: EntityID): void;
|
|
98
|
+
/** The single target of source `index`, or `undefined`. Exclusive reads the
|
|
99
|
+
* sparse field. Multi has no single target and returns `undefined` (matching
|
|
100
|
+
* the production `targetOf`-on-multi read, which the `DEV` guard rejects). */
|
|
101
|
+
abstract singleTargetAt(index: number): EntityID | undefined;
|
|
102
|
+
/** All targets of source `index`, ascending by id, one or zero for
|
|
103
|
+
* exclusive, the full sorted set for multi. The symmetric counterpart to
|
|
104
|
+
* `sourcesOf`. */
|
|
105
|
+
abstract targetsAt(index: number): EntityID[];
|
|
106
|
+
/** Whether source `index` holds any target under this relation (sparse
|
|
107
|
+
* membership). */
|
|
108
|
+
abstract hasIndex(index: number): boolean;
|
|
109
|
+
/** Fold `cb` over this relation's **multi** forward target sets in canonical
|
|
110
|
+
* order (sources ascending by index, each source's targets ascending by id),
|
|
111
|
+
* skipping empty sets. The single source of truth for the canonical multi
|
|
112
|
+
* traversal shared by `stateHash`, `snapshotRelations`, and `pairsOf`.
|
|
113
|
+
* Exclusive relations contribute via the sparse store, so this
|
|
114
|
+
* is a no-op for them. */
|
|
115
|
+
abstract forEachCanonicalTargetSet(cb: CanonicalTargetSetFn): void;
|
|
116
|
+
/** Fold `cb` over every `(source, target)` pair of this relation in canonical
|
|
117
|
+
* order, the `(R, *)` wildcard drive order. `createId` maps a source
|
|
118
|
+
* index to its full `EntityID`. Exclusive rides the backing store's
|
|
119
|
+
* `canonicalIndices`. Multi rides `forEachCanonicalTargetSet`. */
|
|
120
|
+
abstract forEachCanonicalPair(createId: MakeSourceID, cb: CanonicalPairFn): void;
|
|
121
|
+
/** Rebuild the reverse index from the forward links after a restore.
|
|
122
|
+
* Exclusive reads it back from the newly restored sparse target field (the
|
|
123
|
+
* reverse index is never serialized). Multi already rebuilt its reverse edges
|
|
124
|
+
* in `restoreAddTarget`, so this is a no-op for it. `createId` maps a source
|
|
125
|
+
* index to its full `EntityID`. */
|
|
126
|
+
abstract rebuildReverse(createId: MakeSourceID): void;
|
|
127
|
+
/** Restore one decoded multi forward edge `(source index → tgt)` plus its
|
|
128
|
+
* reverse edge (the source's full `EntityID` is `src`). Multi only, the
|
|
129
|
+
* snapshot header guards exclusive relations out before this is reached, so
|
|
130
|
+
* the exclusive override throws defensively. */
|
|
131
|
+
abstract restoreAddTarget(index: number, tgt: EntityID, src: EntityID): void;
|
|
132
|
+
}
|
|
133
|
+
/** Build the right `RelationStore` for a cardinality. The only construction
|
|
134
|
+
* site is `Store.registerRelation`, which resolves the backing sparse store and
|
|
135
|
+
* hands it in so the relation can drive forward and membership rows directly. */
|
|
136
|
+
export declare function createRelationStore(exclusive: boolean, sparse: SparseComponentDef, store: SparseComponentStore, onDeleteTarget: OnDeleteTarget): RelationStore;
|
|
137
|
+
/** Serialize the relation side data that does **not** live in the sparse store,
|
|
138
|
+
* i.e. each **multi** relation's forward target sets (`Map<source index,
|
|
139
|
+
* Set<target>>`). Exclusive relations store their target in the backing sparse
|
|
140
|
+
* field, so they ride `snapshotSparseStores` and contribute only a header
|
|
141
|
+
* here. The reverse index is fully derivable (from the sparse store for
|
|
142
|
+
* exclusive, from these sets for multi), so it is never serialized. It is
|
|
143
|
+
* rebuilt by `restoreRelations` + the caller's exclusive-reverse pass.
|
|
144
|
+
*
|
|
145
|
+
* Members are emitted in canonical order (sources ascending by entity index,
|
|
146
|
+
* each source's targets ascending by id) so the bytes are independent of
|
|
147
|
+
* add and remove history, the same byte-level determinism invariant the sparse
|
|
148
|
+
* snapshot holds. Layout (integers little-endian):
|
|
149
|
+
*
|
|
150
|
+
* u32 relationCount
|
|
151
|
+
* repeat relationCount times (registration and id order):
|
|
152
|
+
* u32 isMulti
|
|
153
|
+
* if multi:
|
|
154
|
+
* u32 sourceCount
|
|
155
|
+
* repeat sourceCount times (ascending source index):
|
|
156
|
+
* u32 sourceIndex
|
|
157
|
+
* u32 targetCount
|
|
158
|
+
* f64 × targetCount (target EntityIDs, ascending) */
|
|
159
|
+
export declare function snapshotRelations(relations: readonly RelationStoreView[]): Uint8Array;
|
|
160
|
+
/** Rebuild every relation's side indices from a `snapshotRelations` buffer and
|
|
161
|
+
* the already-restored sparse stores. Each relation's indices are reset first
|
|
162
|
+
* (idempotent into a dirty world), then:
|
|
163
|
+
*
|
|
164
|
+
* - **multi**, forward target sets and their reverse edges are rebuilt from
|
|
165
|
+
* `bytes` (the sets aren't in the sparse store, so the bytes are the only
|
|
166
|
+
* source). `createId` maps a source entity index to its full `EntityID`
|
|
167
|
+
* (generation from the live slot) so reverse edges key correctly.
|
|
168
|
+
* - **exclusive**, only the reset happens here. The reverse index is rebuilt
|
|
169
|
+
* by the caller from the backing sparse store (which already round-tripped
|
|
170
|
+
* through `restoreSparseStores`), since this function can't read it.
|
|
171
|
+
*
|
|
172
|
+
* Throws `SparseRestoreError` on any shape mismatch (relation count, an
|
|
173
|
+
* exclusive or multi flag that disagrees with the registered relation, a multi
|
|
174
|
+
* source index past `MAX_INDEX`, or a truncated or over-long buffer) rather than
|
|
175
|
+
* silently building a corrupt index. */
|
|
176
|
+
export declare function restoreRelations(relations: readonly RelationStoreView[], bytes: Uint8Array, createId: (index: number) => EntityID): void;
|
|
177
|
+
//# sourceMappingURL=relation_store.d.ts.map
|