@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
|
@@ -0,0 +1,737 @@
|
|
|
1
|
+
import { M as L, s as W, r as z, c as q } from "./relation_store-BsoegrZh.js";
|
|
2
|
+
import { StoreRestoreError as $, SparseRestoreError as _, ECSRestoreError as y } from "../index.js";
|
|
3
|
+
import { S as d, A, a as S, C as B, b as M, c as b, d as R, e as T, f as I, L as C, g as v } from "./abi-NP8pNxpd.js";
|
|
4
|
+
import { pluginMissingError as j } from "../internal.js";
|
|
5
|
+
function Y(t) {
|
|
6
|
+
return {
|
|
7
|
+
magic: t.getUint32(d.magic, !0),
|
|
8
|
+
simAbiVersion: t.getUint32(d.sim_abi_version, !0),
|
|
9
|
+
viewStamp: t.getUint32(d.view_stamp, !0),
|
|
10
|
+
capacity: t.getUint32(d.capacity, !0),
|
|
11
|
+
archetypeCount: t.getUint32(d.archetype_count, !0),
|
|
12
|
+
layoutDescriptorOff: t.getUint32(d.layout_descriptor_off, !0),
|
|
13
|
+
commandRingOff: t.getUint32(d.command_ring_off, !0),
|
|
14
|
+
actionRingOff: t.getUint32(d.action_ring_off, !0),
|
|
15
|
+
entityIndexOff: t.getUint32(d.entity_index_off, !0),
|
|
16
|
+
eventRingOff: t.getUint32(d.event_ring_off, !0),
|
|
17
|
+
regionTableOff: t.getUint32(d.region_table_off, !0),
|
|
18
|
+
regionTableCount: t.getUint32(d.region_table_count, !0),
|
|
19
|
+
bindingsOff: t.getUint32(d.bindings_off, !0)
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
const w = {
|
|
23
|
+
u8: 0,
|
|
24
|
+
i8: 1,
|
|
25
|
+
u16: 2,
|
|
26
|
+
i16: 3,
|
|
27
|
+
u32: 4,
|
|
28
|
+
i32: 5,
|
|
29
|
+
f32: 6,
|
|
30
|
+
f64: 7
|
|
31
|
+
}, K = Object.freeze({
|
|
32
|
+
[w.u8]: 1,
|
|
33
|
+
[w.i8]: 1,
|
|
34
|
+
[w.u16]: 2,
|
|
35
|
+
[w.i16]: 2,
|
|
36
|
+
[w.u32]: 4,
|
|
37
|
+
[w.i32]: 4,
|
|
38
|
+
[w.f32]: 4,
|
|
39
|
+
[w.f64]: 8
|
|
40
|
+
});
|
|
41
|
+
function J(t, e, r) {
|
|
42
|
+
t.setUint16(e + b.component_id, r.componentId, !0), t.setUint16(e + b.field_id, r.fieldId, !0), t.setUint8(e + b.type_tag, r.typeTag), t.setUint32(e + b.byte_off, r.byteOff, !0), t.setUint16(e + b.stride, r.stride, !0);
|
|
43
|
+
}
|
|
44
|
+
function Q(t, e) {
|
|
45
|
+
return {
|
|
46
|
+
componentId: t.getUint16(e + b.component_id, !0),
|
|
47
|
+
fieldId: t.getUint16(e + b.field_id, !0),
|
|
48
|
+
typeTag: t.getUint8(e + b.type_tag),
|
|
49
|
+
byteOff: t.getUint32(e + b.byte_off, !0),
|
|
50
|
+
stride: t.getUint16(e + b.stride, !0)
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function Z(t, e = A) {
|
|
54
|
+
return e + t * M;
|
|
55
|
+
}
|
|
56
|
+
function tt(t, e, r) {
|
|
57
|
+
t.setUint32(e + S.archetype_id, r.archetypeId, !0);
|
|
58
|
+
for (let n = 0; n < B; n++)
|
|
59
|
+
t.setUint32(
|
|
60
|
+
e + S.component_mask + n * 4,
|
|
61
|
+
r.componentMask[n] ?? 0,
|
|
62
|
+
!0
|
|
63
|
+
);
|
|
64
|
+
t.setUint32(e + S.row_count, r.rowCount, !0), t.setUint32(e + S.row_capacity, r.rowCapacity, !0), t.setUint32(e + S.column_count, r.columns.length, !0), t.setUint32(e + S.enabled_count, r.enabledCount, !0), t.setUint32(e + S.entity_ids_off, 0, !0);
|
|
65
|
+
let s = e + A;
|
|
66
|
+
for (let n = 0; n < r.columns.length; n++)
|
|
67
|
+
J(t, s, r.columns[n]), s += M;
|
|
68
|
+
return s;
|
|
69
|
+
}
|
|
70
|
+
function et(t, e, r = A) {
|
|
71
|
+
const s = t.getUint32(e + S.column_count, !0), n = new Array(s);
|
|
72
|
+
let o = e + r;
|
|
73
|
+
for (let a = 0; a < s; a++)
|
|
74
|
+
n[a] = Q(t, o), o += M;
|
|
75
|
+
const i = new Array(B);
|
|
76
|
+
for (let a = 0; a < B; a++)
|
|
77
|
+
i[a] = t.getUint32(
|
|
78
|
+
e + S.component_mask + a * 4,
|
|
79
|
+
!0
|
|
80
|
+
);
|
|
81
|
+
return {
|
|
82
|
+
archetypeId: t.getUint32(e + S.archetype_id, !0),
|
|
83
|
+
componentMask: i,
|
|
84
|
+
rowCount: t.getUint32(e + S.row_count, !0),
|
|
85
|
+
rowCapacity: t.getUint32(e + S.row_capacity, !0),
|
|
86
|
+
enabledCount: t.getUint32(e + S.enabled_count, !0),
|
|
87
|
+
columns: n
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
function nt(t, e, r) {
|
|
91
|
+
let s = e;
|
|
92
|
+
for (let n = 0; n < r.length; n++)
|
|
93
|
+
s = tt(t, s, r[n]);
|
|
94
|
+
return s;
|
|
95
|
+
}
|
|
96
|
+
function H(t, e, r, s = A) {
|
|
97
|
+
const n = new Array(r);
|
|
98
|
+
let o = e;
|
|
99
|
+
for (let i = 0; i < r; i++) {
|
|
100
|
+
const a = et(t, o, s);
|
|
101
|
+
n[i] = a, o += Z(a.columns.length, s);
|
|
102
|
+
}
|
|
103
|
+
return n;
|
|
104
|
+
}
|
|
105
|
+
class rt extends Error {
|
|
106
|
+
constructor() {
|
|
107
|
+
super(
|
|
108
|
+
'SharedArrayBuffer is not available in this runtime. The chosen world backing is SAB-based and cannot start without it. In browsers this requires cross-origin isolation: serve the page with `Cross-Origin-Opener-Policy: same-origin` and `Cross-Origin-Embedder-Policy: require-corp` (or `credentialless`). Alternatively choose the pure-TS heap profile (`memory: { backing: "heap" }`), which is backed by a plain ArrayBuffer and needs no SAB and no COOP+COEP. In Bun or Node SAB is available unconditionally. If you see this there, the runtime is older than expected, or the global was shadowed.'
|
|
109
|
+
), this.name = "SabUnavailableError";
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
const st = (t) => {
|
|
113
|
+
if (typeof SharedArrayBuffer > "u") throw new rt();
|
|
114
|
+
return new SharedArrayBuffer(t);
|
|
115
|
+
}, ot = 16, at = {
|
|
116
|
+
capacity: 4
|
|
117
|
+
// 8..16: pad to 16-byte alignment so the i32 arrays start aligned.
|
|
118
|
+
};
|
|
119
|
+
function it(t, e) {
|
|
120
|
+
return t << 16 | e;
|
|
121
|
+
}
|
|
122
|
+
const X = 2 ** 31;
|
|
123
|
+
class ct extends Error {
|
|
124
|
+
constructor(e) {
|
|
125
|
+
super(
|
|
126
|
+
`SAB column layout offset ${e} reaches or exceeds the 2³¹ (${X}-byte) ceiling. Past 2 GiB the signed-32-bit bitwise alignment math wraps to a negative or misaligned offset. This is a structural limit independent of the allocator cap, so a single store cannot back more than 2 GiB of column data.`
|
|
127
|
+
), this.name = "StoreLayoutOverflowError";
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
function ht(t, e) {
|
|
131
|
+
if (t + e > X)
|
|
132
|
+
throw new ct(t);
|
|
133
|
+
return t + (e - 1) & ~(e - 1);
|
|
134
|
+
}
|
|
135
|
+
function ut(t, e, r, s, n) {
|
|
136
|
+
const o = e + s;
|
|
137
|
+
switch (r) {
|
|
138
|
+
case w.u8:
|
|
139
|
+
return new Uint8Array(t, o, n);
|
|
140
|
+
case w.i8:
|
|
141
|
+
return new Int8Array(t, o, n);
|
|
142
|
+
case w.u16:
|
|
143
|
+
return new Uint16Array(t, o, n);
|
|
144
|
+
case w.i16:
|
|
145
|
+
return new Int16Array(t, o, n);
|
|
146
|
+
case w.u32:
|
|
147
|
+
return new Uint32Array(t, o, n);
|
|
148
|
+
case w.i32:
|
|
149
|
+
return new Int32Array(t, o, n);
|
|
150
|
+
case w.f32:
|
|
151
|
+
return new Float32Array(t, o, n);
|
|
152
|
+
case w.f64:
|
|
153
|
+
return new Float64Array(t, o, n);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
const P = 16;
|
|
157
|
+
function lt(t) {
|
|
158
|
+
if (!Number.isInteger(t) || t < 0)
|
|
159
|
+
throw new RangeError(`createColumnStore: storeBase must be an integer >= 0, got ${t}`);
|
|
160
|
+
if (t % P !== 0)
|
|
161
|
+
throw new RangeError(
|
|
162
|
+
`createColumnStore: storeBase must be a multiple of ${P}, got ${t}`
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
function ft(t, e, r) {
|
|
166
|
+
const s = /* @__PURE__ */ new Map();
|
|
167
|
+
for (let n = 0; n < r.length; n++) {
|
|
168
|
+
const o = r[n], i = new Array(o.columns.length), a = /* @__PURE__ */ new Map();
|
|
169
|
+
for (let c = 0; c < o.columns.length; c++) {
|
|
170
|
+
const h = o.columns[c], l = {
|
|
171
|
+
componentId: h.componentId,
|
|
172
|
+
fieldId: h.fieldId,
|
|
173
|
+
typeTag: h.typeTag,
|
|
174
|
+
byteOff: h.byteOff,
|
|
175
|
+
stride: h.stride,
|
|
176
|
+
view: ut(t, e, h.typeTag, h.byteOff, o.rowCapacity)
|
|
177
|
+
};
|
|
178
|
+
i[c] = l, a.set(it(h.componentId, h.fieldId), l);
|
|
179
|
+
}
|
|
180
|
+
s.set(o.archetypeId, {
|
|
181
|
+
archetypeId: o.archetypeId,
|
|
182
|
+
componentMask: o.componentMask,
|
|
183
|
+
rowCapacity: o.rowCapacity,
|
|
184
|
+
columns: a,
|
|
185
|
+
columnsInOrder: i
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
return s;
|
|
189
|
+
}
|
|
190
|
+
function pt(t) {
|
|
191
|
+
const e = t.view.getUint32(d.capacity, !0);
|
|
192
|
+
return new Uint8Array(t.buffer, t.storeBase, e);
|
|
193
|
+
}
|
|
194
|
+
const dt = Math.max(...Object.values(K));
|
|
195
|
+
function gt(t) {
|
|
196
|
+
const e = A - v;
|
|
197
|
+
return ht(t * e, dt);
|
|
198
|
+
}
|
|
199
|
+
function yt(t) {
|
|
200
|
+
const e = new DataView(t.buffer, t.byteOffset, t.byteLength), r = e.getUint32(d.layout_descriptor_off, !0), s = e.getUint32(d.archetype_count, !0), n = gt(s);
|
|
201
|
+
if (n === 0) return t;
|
|
202
|
+
const o = H(
|
|
203
|
+
e,
|
|
204
|
+
r,
|
|
205
|
+
s,
|
|
206
|
+
v
|
|
207
|
+
), i = new Uint8Array(t.byteLength + n);
|
|
208
|
+
i.set(t.subarray(0, r), 0), i.set(t.subarray(r), r + n);
|
|
209
|
+
const a = new DataView(i.buffer), c = o.map((l) => ({
|
|
210
|
+
...l,
|
|
211
|
+
columns: l.columns.map((f) => ({ ...f, byteOff: f.byteOff + n }))
|
|
212
|
+
}));
|
|
213
|
+
nt(a, r, c);
|
|
214
|
+
const h = e.getUint32(d.capacity, !0);
|
|
215
|
+
return a.setUint32(d.capacity, h + n, !0), i;
|
|
216
|
+
}
|
|
217
|
+
function mt(t, e = st, r = {}) {
|
|
218
|
+
const s = r.storeBase ?? 0;
|
|
219
|
+
lt(s);
|
|
220
|
+
const n = new DataView(t.buffer, t.byteOffset, t.byteLength);
|
|
221
|
+
if (t.byteLength < R)
|
|
222
|
+
throw new $(
|
|
223
|
+
`snapshot too small: ${t.byteLength} bytes (header alone needs ${R})`
|
|
224
|
+
);
|
|
225
|
+
const o = n.getUint32(d.magic, !0);
|
|
226
|
+
if (o !== T)
|
|
227
|
+
throw new $(
|
|
228
|
+
`bad magic: 0x${o.toString(16).padStart(8, "0")} (expected 0x${T.toString(16).padStart(8, "0")})`
|
|
229
|
+
);
|
|
230
|
+
const i = n.getUint32(d.sim_abi_version, !0);
|
|
231
|
+
if (i !== I && i !== C)
|
|
232
|
+
throw new $(
|
|
233
|
+
`incompatible sim_abi_version: snapshot=${i}, build=${I}`
|
|
234
|
+
);
|
|
235
|
+
const a = n.getUint32(d.layout_descriptor_off, !0);
|
|
236
|
+
if (a > t.byteLength)
|
|
237
|
+
throw new $(
|
|
238
|
+
`layout_descriptor_off ${a} is outside the snapshot (${t.byteLength} bytes)`
|
|
239
|
+
);
|
|
240
|
+
let c = t;
|
|
241
|
+
if (i === C)
|
|
242
|
+
try {
|
|
243
|
+
c = yt(t);
|
|
244
|
+
} catch (p) {
|
|
245
|
+
throw p instanceof RangeError ? new $(
|
|
246
|
+
`snapshot layout is corrupt or truncated: a version 0 descriptor reads past the ${t.byteLength}-byte span (${p.message})`
|
|
247
|
+
) : p;
|
|
248
|
+
}
|
|
249
|
+
const h = e(s + c.byteLength);
|
|
250
|
+
new Uint8Array(h, s, c.byteLength).set(c);
|
|
251
|
+
const l = new DataView(h, s);
|
|
252
|
+
l.setUint32(d.sim_abi_version, I, !0);
|
|
253
|
+
const f = Y(l);
|
|
254
|
+
if (f.layoutDescriptorOff < 0 || f.layoutDescriptorOff > c.byteLength)
|
|
255
|
+
throw new $(
|
|
256
|
+
`layout_descriptor_off ${f.layoutDescriptorOff} is outside the snapshot (${c.byteLength} bytes)`
|
|
257
|
+
);
|
|
258
|
+
try {
|
|
259
|
+
const p = H(
|
|
260
|
+
l,
|
|
261
|
+
f.layoutDescriptorOff,
|
|
262
|
+
f.archetypeCount
|
|
263
|
+
), u = ft(h, s, p);
|
|
264
|
+
return { buffer: h, view: l, header: f, storeBase: s, archetypes: u };
|
|
265
|
+
} catch (p) {
|
|
266
|
+
throw p instanceof RangeError ? new $(
|
|
267
|
+
`snapshot layout is corrupt or truncated: a descriptor offset or column extent reads past the ${c.byteLength}-byte span (${p.message})`
|
|
268
|
+
) : p;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
const wt = 2166136261, _t = 16777619;
|
|
272
|
+
function D(t, e) {
|
|
273
|
+
return t = (t ^ e & 255) >>> 0, Math.imul(t, _t) >>> 0;
|
|
274
|
+
}
|
|
275
|
+
const V = 12, k = 4, U = 8;
|
|
276
|
+
function F(t, e) {
|
|
277
|
+
let r = wt;
|
|
278
|
+
const s = (n) => {
|
|
279
|
+
for (let o = 0; o < n.length; o++) r = D(r, n.charCodeAt(o));
|
|
280
|
+
};
|
|
281
|
+
for (let n = 0; n < t.length; n++)
|
|
282
|
+
s(t[n]), r = D(r, 31), s(e[n]), r = D(r, 30);
|
|
283
|
+
return r >>> 0;
|
|
284
|
+
}
|
|
285
|
+
function St(t) {
|
|
286
|
+
let e = 4;
|
|
287
|
+
for (let o = 0; o < t.length; o++) {
|
|
288
|
+
const i = t[o], a = i.fieldNames.length;
|
|
289
|
+
e += V + i.size * (k + a * U);
|
|
290
|
+
}
|
|
291
|
+
const r = new Uint8Array(e), s = new DataView(r.buffer);
|
|
292
|
+
let n = 0;
|
|
293
|
+
s.setUint32(n, t.length, !0), n += 4;
|
|
294
|
+
for (let o = 0; o < t.length; o++) {
|
|
295
|
+
const i = t[o], a = i.fieldNames.length, c = i.canonicalIndices();
|
|
296
|
+
s.setUint32(n, a, !0), n += 4, s.setUint32(n, F(i.fieldNames, i.fieldTypes), !0), n += 4, s.setUint32(n, c.length, !0), n += 4;
|
|
297
|
+
for (let h = 0; h < c.length; h++) {
|
|
298
|
+
const l = c[h];
|
|
299
|
+
s.setUint32(n, l, !0), n += 4;
|
|
300
|
+
const f = i.getRow(l);
|
|
301
|
+
for (let p = 0; p < a; p++)
|
|
302
|
+
s.setFloat64(n, f[p], !0), n += U;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
return r;
|
|
306
|
+
}
|
|
307
|
+
function bt(t, e) {
|
|
308
|
+
const r = new DataView(e.buffer, e.byteOffset, e.byteLength), s = e.byteLength;
|
|
309
|
+
let n = 0;
|
|
310
|
+
const o = (a) => {
|
|
311
|
+
if (n + a > s)
|
|
312
|
+
throw new _(
|
|
313
|
+
`sparse snapshot truncated: need ${a} more bytes at offset ${n}, have ${s - n}`
|
|
314
|
+
);
|
|
315
|
+
};
|
|
316
|
+
o(4);
|
|
317
|
+
const i = r.getUint32(n, !0);
|
|
318
|
+
if (n += 4, i !== t.length)
|
|
319
|
+
throw new _(
|
|
320
|
+
`sparse store count mismatch: snapshot=${i}, registered=${t.length}`
|
|
321
|
+
);
|
|
322
|
+
for (let a = 0; a < t.length; a++) {
|
|
323
|
+
const c = t[a];
|
|
324
|
+
o(V);
|
|
325
|
+
const h = r.getUint32(n, !0);
|
|
326
|
+
n += 4;
|
|
327
|
+
const l = r.getUint32(n, !0);
|
|
328
|
+
n += 4;
|
|
329
|
+
const f = r.getUint32(n, !0);
|
|
330
|
+
if (n += 4, h !== c.fieldNames.length)
|
|
331
|
+
throw new _(
|
|
332
|
+
`sparse store ${a} field-count mismatch: snapshot=${h}, registered=${c.fieldNames.length}`
|
|
333
|
+
);
|
|
334
|
+
const p = F(c.fieldNames, c.fieldTypes);
|
|
335
|
+
if (l !== p)
|
|
336
|
+
throw new _(
|
|
337
|
+
`sparse store ${a} schema identity mismatch: snapshot hash=${l}, registered=${p} (same field count, different field names or types, likely a registration-order divergence between the snapshot and restore worlds)`
|
|
338
|
+
);
|
|
339
|
+
c.clear();
|
|
340
|
+
for (let u = 0; u < f; u++) {
|
|
341
|
+
o(k + h * U);
|
|
342
|
+
const m = r.getUint32(n, !0);
|
|
343
|
+
if (n += 4, m > L)
|
|
344
|
+
throw new _(
|
|
345
|
+
`sparse store ${a} member ${u} entity index ${m} exceeds MAX_INDEX (${L})`
|
|
346
|
+
);
|
|
347
|
+
const g = new Array(h);
|
|
348
|
+
for (let O = 0; O < h; O++)
|
|
349
|
+
g[O] = r.getFloat64(n, !0), n += U;
|
|
350
|
+
c.setRawRow(m, g);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
if (n !== s)
|
|
354
|
+
throw new _(
|
|
355
|
+
`sparse snapshot has ${s - n} trailing bytes after the last store (not a canonical encoding)`
|
|
356
|
+
);
|
|
357
|
+
}
|
|
358
|
+
function $t(t, e) {
|
|
359
|
+
const r = new DataView(e.buffer, e.byteOffset, e.byteLength), s = e.byteLength;
|
|
360
|
+
let n = 0;
|
|
361
|
+
const o = (a) => {
|
|
362
|
+
if (n + a > s)
|
|
363
|
+
throw new _(
|
|
364
|
+
`sparse snapshot truncated: need ${a} more bytes at offset ${n}, have ${s - n}`
|
|
365
|
+
);
|
|
366
|
+
};
|
|
367
|
+
o(4);
|
|
368
|
+
const i = r.getUint32(n, !0);
|
|
369
|
+
if (n += 4, i !== t.length)
|
|
370
|
+
throw new _(
|
|
371
|
+
`sparse store count mismatch: snapshot=${i}, registered=${t.length}`
|
|
372
|
+
);
|
|
373
|
+
for (let a = 0; a < t.length; a++) {
|
|
374
|
+
const c = t[a];
|
|
375
|
+
o(V);
|
|
376
|
+
const h = r.getUint32(n, !0);
|
|
377
|
+
n += 4;
|
|
378
|
+
const l = r.getUint32(n, !0);
|
|
379
|
+
n += 4;
|
|
380
|
+
const f = r.getUint32(n, !0);
|
|
381
|
+
if (n += 4, h !== c.fieldNames.length)
|
|
382
|
+
throw new _(
|
|
383
|
+
`sparse store ${a} field-count mismatch: snapshot=${h}, registered=${c.fieldNames.length}`
|
|
384
|
+
);
|
|
385
|
+
const p = F(c.fieldNames, c.fieldTypes);
|
|
386
|
+
if (l !== p)
|
|
387
|
+
throw new _(
|
|
388
|
+
`sparse store ${a} schema identity mismatch: snapshot hash=${l}, registered=${p} (same field count, different field names or types, likely a registration-order divergence between the snapshot and restore worlds)`
|
|
389
|
+
);
|
|
390
|
+
for (let u = 0; u < f; u++) {
|
|
391
|
+
o(k + h * U);
|
|
392
|
+
const m = r.getUint32(n, !0);
|
|
393
|
+
if (n += 4, m > L)
|
|
394
|
+
throw new _(
|
|
395
|
+
`sparse store ${a} member ${u} entity index ${m} exceeds MAX_INDEX (${L})`
|
|
396
|
+
);
|
|
397
|
+
n += h * U;
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
if (n !== s)
|
|
401
|
+
throw new _(
|
|
402
|
+
`sparse snapshot has ${s - n} trailing bytes after the last store (not a canonical encoding)`
|
|
403
|
+
);
|
|
404
|
+
}
|
|
405
|
+
const N = 1, x = 810766935, E = 4;
|
|
406
|
+
function Ut(t) {
|
|
407
|
+
const e = t.freeIndices.length, r = t.archetypeRows.length, s = E * (4 + e + 1 + r * 3), n = new Uint8Array(s), o = new DataView(n.buffer);
|
|
408
|
+
let i = 0;
|
|
409
|
+
const a = (c) => {
|
|
410
|
+
o.setUint32(i, c, !0), i += E;
|
|
411
|
+
};
|
|
412
|
+
a(t.tick), a(t.entityHighWater), a(t.entityAliveCount), a(e);
|
|
413
|
+
for (let c = 0; c < e; c++) a(t.freeIndices[c]);
|
|
414
|
+
a(r);
|
|
415
|
+
for (let c = 0; c < r; c++) {
|
|
416
|
+
const h = t.archetypeRows[c];
|
|
417
|
+
a(h.archetypeId), a(h.length), a(h.enabledCount);
|
|
418
|
+
}
|
|
419
|
+
return n;
|
|
420
|
+
}
|
|
421
|
+
function Et(t) {
|
|
422
|
+
const e = new DataView(t.buffer, t.byteOffset, t.byteLength), r = t.byteLength;
|
|
423
|
+
let s = 0;
|
|
424
|
+
const n = (u) => {
|
|
425
|
+
if (s + u > r)
|
|
426
|
+
throw new y(
|
|
427
|
+
`host-state truncated: need ${u} more bytes at offset ${s}, have ${r - s}`
|
|
428
|
+
);
|
|
429
|
+
}, o = () => {
|
|
430
|
+
n(E);
|
|
431
|
+
const u = e.getUint32(s, !0);
|
|
432
|
+
return s += E, u;
|
|
433
|
+
}, i = o(), a = o(), c = o(), h = o(), l = new Array(h);
|
|
434
|
+
for (let u = 0; u < h; u++) l[u] = o();
|
|
435
|
+
const f = o(), p = new Array(f);
|
|
436
|
+
for (let u = 0; u < f; u++) {
|
|
437
|
+
const m = o(), g = o(), O = o();
|
|
438
|
+
p[u] = { archetypeId: m, length: g, enabledCount: O };
|
|
439
|
+
}
|
|
440
|
+
if (s !== r)
|
|
441
|
+
throw new y(
|
|
442
|
+
`host-state has ${r - s} trailing bytes after the last archetype (not a canonical encoding)`
|
|
443
|
+
);
|
|
444
|
+
return { tick: i, entityHighWater: a, entityAliveCount: c, freeIndices: l, archetypeRows: p };
|
|
445
|
+
}
|
|
446
|
+
function At(t, e, r) {
|
|
447
|
+
const s = E * 5, n = new Uint8Array(s + t.length + e.length + r.length), o = new DataView(n.buffer);
|
|
448
|
+
return o.setUint32(0, x, !0), o.setUint32(4, N, !0), o.setUint32(8, t.length, !0), o.setUint32(12, e.length, !0), o.setUint32(16, r.length, !0), n.set(t, s), n.set(e, s + t.length), n.set(r, s + t.length + e.length), n;
|
|
449
|
+
}
|
|
450
|
+
function Ot(t) {
|
|
451
|
+
const e = E * 5;
|
|
452
|
+
if (t.byteLength < e)
|
|
453
|
+
throw new y(
|
|
454
|
+
`world snapshot too small: ${t.byteLength} bytes (frame header needs ${e})`
|
|
455
|
+
);
|
|
456
|
+
const r = new DataView(t.buffer, t.byteOffset, t.byteLength), s = r.getUint32(0, !0);
|
|
457
|
+
if (s !== x)
|
|
458
|
+
throw new y(
|
|
459
|
+
`bad world-snapshot magic: 0x${s.toString(16).padStart(8, "0")} (expected 0x${x.toString(16).padStart(8, "0")}). A bare dense (SAB) snapshot is not a combined world snapshot, pass the bytes from ECS.snapshot(), not columnStoreBytesView().`
|
|
460
|
+
);
|
|
461
|
+
const n = r.getUint32(4, !0);
|
|
462
|
+
if (n !== N)
|
|
463
|
+
throw new y(
|
|
464
|
+
`incompatible world-snapshot version: snapshot=${n}, build=${N}`
|
|
465
|
+
);
|
|
466
|
+
const o = r.getUint32(8, !0), i = r.getUint32(12, !0), a = r.getUint32(16, !0);
|
|
467
|
+
if (e + o + i + a !== t.byteLength)
|
|
468
|
+
throw new y(
|
|
469
|
+
`world-snapshot frame mismatch: header declares ${e}+${o}+${i}+${a}=${e + o + i + a} bytes, buffer is ${t.byteLength}`
|
|
470
|
+
);
|
|
471
|
+
const c = t.byteOffset, h = t.buffer;
|
|
472
|
+
return {
|
|
473
|
+
dense: new Uint8Array(h, c + e, o),
|
|
474
|
+
sparse: new Uint8Array(h, c + e + o, i),
|
|
475
|
+
host: new Uint8Array(h, c + e + o + i, a)
|
|
476
|
+
};
|
|
477
|
+
}
|
|
478
|
+
function It(t, e, r) {
|
|
479
|
+
if (t.byteLength < R)
|
|
480
|
+
throw new y(
|
|
481
|
+
`dense section too small: ${t.byteLength} bytes (SAB header needs ${R})`
|
|
482
|
+
);
|
|
483
|
+
const s = new DataView(t.buffer, t.byteOffset, t.byteLength), n = s.getUint32(d.magic, !0);
|
|
484
|
+
if (n !== T)
|
|
485
|
+
throw new y(
|
|
486
|
+
`dense section bad magic: 0x${n.toString(16).padStart(8, "0")} (expected SAB magic 0x${T.toString(16).padStart(8, "0")})`
|
|
487
|
+
);
|
|
488
|
+
const o = s.getUint32(d.sim_abi_version, !0);
|
|
489
|
+
if (o !== I && o !== C)
|
|
490
|
+
throw new y(
|
|
491
|
+
`dense section incompatible sim_abi_version: snapshot=${o}, build=${I}`
|
|
492
|
+
);
|
|
493
|
+
const i = Y(s);
|
|
494
|
+
if (i.layoutDescriptorOff < 0 || i.layoutDescriptorOff > t.byteLength)
|
|
495
|
+
throw new y(
|
|
496
|
+
`dense layoutDescriptorOff ${i.layoutDescriptorOff} is outside the section (${t.byteLength} bytes)`
|
|
497
|
+
);
|
|
498
|
+
const a = i.entityIndexOff;
|
|
499
|
+
if (a < 0 || a + ot > t.byteLength)
|
|
500
|
+
throw new y(
|
|
501
|
+
`dense entityIndexOff ${a} is outside the section (${t.byteLength} bytes)`
|
|
502
|
+
);
|
|
503
|
+
const c = s.getUint32(a + at.capacity, !0);
|
|
504
|
+
if (c !== r)
|
|
505
|
+
throw new y(
|
|
506
|
+
`entity-index capacity mismatch: live=${r}, snapshot=${c}`
|
|
507
|
+
);
|
|
508
|
+
let h;
|
|
509
|
+
try {
|
|
510
|
+
h = H(
|
|
511
|
+
s,
|
|
512
|
+
i.layoutDescriptorOff,
|
|
513
|
+
i.archetypeCount,
|
|
514
|
+
o === C ? v : A
|
|
515
|
+
);
|
|
516
|
+
} catch (l) {
|
|
517
|
+
throw l instanceof RangeError ? new y(
|
|
518
|
+
`dense section layout is corrupt or truncated: a descriptor reads past the ${t.byteLength}-byte section (${l.message})`
|
|
519
|
+
) : l;
|
|
520
|
+
}
|
|
521
|
+
if (e.size !== h.length)
|
|
522
|
+
throw new y(
|
|
523
|
+
`archetype-set mismatch: the live world has ${e.size} SAB archetypes, the snapshot has ${h.length}. restore requires an identical archetype set. Prewarm the world so its archetype set is stable.`
|
|
524
|
+
);
|
|
525
|
+
for (let l = 0; l < h.length; l++) {
|
|
526
|
+
const f = h[l], p = e.get(f.archetypeId);
|
|
527
|
+
if (p === void 0)
|
|
528
|
+
throw new y(
|
|
529
|
+
`archetype-set mismatch: snapshot archetype ${f.archetypeId} is absent from the live world`
|
|
530
|
+
);
|
|
531
|
+
if (!Lt(p.componentMask, f.componentMask))
|
|
532
|
+
throw new y(
|
|
533
|
+
`archetype ${f.archetypeId} component-mask mismatch between the live world and the snapshot (different component registration)`
|
|
534
|
+
);
|
|
535
|
+
const u = p.columnsInOrder, m = f.columns;
|
|
536
|
+
if (u.length !== m.length)
|
|
537
|
+
throw new y(
|
|
538
|
+
`archetype ${f.archetypeId} column-count mismatch: live=${u.length}, snapshot=${m.length}`
|
|
539
|
+
);
|
|
540
|
+
for (let g = 0; g < u.length; g++)
|
|
541
|
+
if (u[g].componentId !== m[g].componentId || u[g].fieldId !== m[g].fieldId || u[g].typeTag !== m[g].typeTag)
|
|
542
|
+
throw new y(
|
|
543
|
+
`archetype ${f.archetypeId} column ${g} layout mismatch: live=(c${u[g].componentId},f${u[g].fieldId},t${u[g].typeTag}), snapshot=(c${m[g].componentId},f${m[g].fieldId},t${m[g].typeTag})`
|
|
544
|
+
);
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
function Lt(t, e) {
|
|
548
|
+
if (t.length !== e.length) return !1;
|
|
549
|
+
for (let r = 0; r < t.length; r++) if (t[r] !== e[r]) return !1;
|
|
550
|
+
return !0;
|
|
551
|
+
}
|
|
552
|
+
class Rt {
|
|
553
|
+
_host;
|
|
554
|
+
/** The allocator is its own snapshot seam: a free-list copy on
|
|
555
|
+
* capture, `setHighWater` and `restoreHostState` on mount. */
|
|
556
|
+
_allocator;
|
|
557
|
+
constructor(e, r) {
|
|
558
|
+
this._host = e, this._allocator = r;
|
|
559
|
+
}
|
|
560
|
+
/** Serialize the sparse stores **and** relation side data to a self-contained
|
|
561
|
+
* byte buffer, the sparse half of a world snapshot (the dense half is the
|
|
562
|
+
* SAB snapshot). Two framed sections: the sparse stores (`snapshotSparseStores`,
|
|
563
|
+
* where the exclusive relation targets and the multi membership ride) followed
|
|
564
|
+
* by the relation side data (`snapshotRelations`, multi forward target
|
|
565
|
+
* sets, which live outside the sparse store). Both are written in canonical
|
|
566
|
+
* entity-index order, so two worlds with identical contents inserted in
|
|
567
|
+
* different orders snapshot byte-for-byte the same. The reverse index
|
|
568
|
+
* is derived and never serialized, `restoreSparse` rebuilds it. */
|
|
569
|
+
snapshotSparse() {
|
|
570
|
+
const e = St(this._host.sparseStores()), r = W(this._host.relationStores()), s = new Uint8Array(8 + e.length + r.length), n = new DataView(s.buffer);
|
|
571
|
+
return n.setUint32(0, e.length, !0), n.setUint32(4, r.length, !0), s.set(e, 8), s.set(r, 8 + e.length), s;
|
|
572
|
+
}
|
|
573
|
+
/** Repopulate the sparse stores from `snapshotSparse` bytes, replacing all
|
|
574
|
+
* current sparse data (full-equality round-trip of membership and data), then
|
|
575
|
+
* rebuild every relation's derived side indices: multi forward sets from the
|
|
576
|
+
* relation section, and the reverse index for both cardinalities (exclusive
|
|
577
|
+
* from the newly restored sparse target field, multi from the rebuilt forward
|
|
578
|
+
* sets). The sparse components and relations must already be registered in
|
|
579
|
+
* the same order, restore carries data, not the registration (which is
|
|
580
|
+
* code). Throws `SparseRestoreError` if the snapshot's shape, field identity,
|
|
581
|
+
* entity-index bounds, or frame length don't validate. */
|
|
582
|
+
restoreSparse(e) {
|
|
583
|
+
const r = new DataView(e.buffer, e.byteOffset, e.byteLength);
|
|
584
|
+
if (e.byteLength < 8)
|
|
585
|
+
throw new _(
|
|
586
|
+
`sparse snapshot truncated: need 8 header bytes, have ${e.byteLength}`
|
|
587
|
+
);
|
|
588
|
+
const s = r.getUint32(0, !0), n = r.getUint32(4, !0);
|
|
589
|
+
if (8 + s + n !== e.byteLength)
|
|
590
|
+
throw new _(
|
|
591
|
+
`sparse snapshot frame mismatch: header declares 8+${s}+${n}=${8 + s + n} bytes, buffer is ${e.byteLength}`
|
|
592
|
+
);
|
|
593
|
+
bt(this._host.sparseStores(), e.subarray(8, 8 + s)), this._rebuildRelationIndices(e.subarray(8 + s, 8 + s + n));
|
|
594
|
+
}
|
|
595
|
+
/** Rebuild every relation's derived side indices after the sparse stores have
|
|
596
|
+
* been restored. `restoreRelations` resets all relations, rebuilds the multi
|
|
597
|
+
* forward sets and their reverse edges from `relBytes`, and validates shape.
|
|
598
|
+
* The exclusive reverse index can't be carried in the bytes (it's derivable),
|
|
599
|
+
* so it's rebuilt here from the backing sparse store: every member row holds
|
|
600
|
+
* `(source index → target EntityID)`, which is exactly one reverse edge. */
|
|
601
|
+
_rebuildRelationIndices(e) {
|
|
602
|
+
const r = this._host.generations(), s = (o) => q(o, r[o]), n = this._host.relationStores();
|
|
603
|
+
z(n, e, s);
|
|
604
|
+
for (let o = 0; o < n.length; o++) n[o].rebuildReverse(s);
|
|
605
|
+
}
|
|
606
|
+
/** Capture the full live world to one self-contained byte buffer that
|
|
607
|
+
* `restore` can mount back onto a live, ticking world. Three
|
|
608
|
+
* sections (see `resume.ts`): the dense SAB column bytes, the sparse and
|
|
609
|
+
* relation bytes, and the host-side bookkeeping the SAB omits. */
|
|
610
|
+
snapshot() {
|
|
611
|
+
this._host.publishRowCounts();
|
|
612
|
+
const e = new Uint8Array(pt(this._host.columnStore())), r = this.snapshotSparse(), s = Ut(this._collectHostState());
|
|
613
|
+
return At(e, r, s);
|
|
614
|
+
}
|
|
615
|
+
/** Gather the host-side state a snapshot carries alongside the dense and
|
|
616
|
+
* sparse bytes, see `snapshot()`. The free-list is copied, because it is a
|
|
617
|
+
* live mutable. */
|
|
618
|
+
_collectHostState() {
|
|
619
|
+
const e = [], r = this._host.archetypes();
|
|
620
|
+
for (let s = 0; s < r.length; s++) {
|
|
621
|
+
const n = r[s];
|
|
622
|
+
n.isBufferBacked && e.push({
|
|
623
|
+
archetypeId: n.id,
|
|
624
|
+
length: n.length,
|
|
625
|
+
enabledCount: n.enabledCount
|
|
626
|
+
});
|
|
627
|
+
}
|
|
628
|
+
return {
|
|
629
|
+
tick: this._host.tick(),
|
|
630
|
+
entityHighWater: this._allocator.highWater,
|
|
631
|
+
entityAliveCount: this._allocator.aliveCount,
|
|
632
|
+
freeIndices: this._allocator.snapshotFreeIndices(),
|
|
633
|
+
archetypeRows: e
|
|
634
|
+
};
|
|
635
|
+
}
|
|
636
|
+
/** Mount a `snapshot()` buffer onto the live world and leave it ready to keep
|
|
637
|
+
* ticking. Fails closed on a malformed frame or a registration mismatch
|
|
638
|
+
* before any live state is touched. */
|
|
639
|
+
restore(e) {
|
|
640
|
+
const r = Ot(e), s = Et(r.host);
|
|
641
|
+
It(
|
|
642
|
+
r.dense,
|
|
643
|
+
this._host.columnStore().archetypes,
|
|
644
|
+
this._host.entityIndexCapacity()
|
|
645
|
+
), this._assertSparseMatchesLive(r.sparse);
|
|
646
|
+
const n = mt(r.dense, this._host.bufferAllocator(), {
|
|
647
|
+
storeBase: this._host.columnStore().storeBase
|
|
648
|
+
});
|
|
649
|
+
this._host.mountRestoredDense(n), this._host.reconstructHostRows(s), this._allocator.restoreHostState(s.freeIndices, s.entityAliveCount), this._host.setTick(s.tick), this._host.invalidateCaches(), this.restoreSparse(r.sparse);
|
|
650
|
+
}
|
|
651
|
+
/** Read-only validation of a `snapshotSparse` Section (the framed
|
|
652
|
+
* `[sparseLen][relLen][sparse][rel]` buffer) against the live registry, used
|
|
653
|
+
* by `restore` to fail closed on a sparse-registration mismatch before the
|
|
654
|
+
* dense mount commits. Mirrors `restoreSparse`'s frame check, then validates the
|
|
655
|
+
* sparse-stores sub-section without mutating. A relation-registration difference
|
|
656
|
+
* surfaces here too: every `registerRelation` adds a backing sparse store, so a
|
|
657
|
+
* differing relation set changes the sparse store count or its schema. Throws
|
|
658
|
+
* `SparseRestoreError` on a mismatch. */
|
|
659
|
+
_assertSparseMatchesLive(e) {
|
|
660
|
+
const r = new DataView(e.buffer, e.byteOffset, e.byteLength);
|
|
661
|
+
if (e.byteLength < 8)
|
|
662
|
+
throw new _(
|
|
663
|
+
`sparse snapshot truncated: need 8 header bytes, have ${e.byteLength}`
|
|
664
|
+
);
|
|
665
|
+
const s = r.getUint32(0, !0), n = r.getUint32(4, !0);
|
|
666
|
+
if (8 + s + n !== e.byteLength)
|
|
667
|
+
throw new _(
|
|
668
|
+
`sparse snapshot frame mismatch: header declares 8+${s}+${n}=${8 + s + n} bytes, buffer is ${e.byteLength}`
|
|
669
|
+
);
|
|
670
|
+
$t(this._host.sparseStores(), e.subarray(8, 8 + s));
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
class G {
|
|
674
|
+
// Protected, not private: the snapshot plugin subclasses this to add
|
|
675
|
+
// `capture` and `restore`, and reaches the store the same way.
|
|
676
|
+
_store;
|
|
677
|
+
/** @internal constructed by `ECS`. */
|
|
678
|
+
constructor(e) {
|
|
679
|
+
this._store = e;
|
|
680
|
+
}
|
|
681
|
+
/** Whether the determinism surface is enabled. */
|
|
682
|
+
get deterministic() {
|
|
683
|
+
return this._store.deterministic;
|
|
684
|
+
}
|
|
685
|
+
/** FNV-1a 32 digest over every archetype's live rows in id order, the
|
|
686
|
+
* canonical "live ECS state digest". Per-call cost scales with live
|
|
687
|
+
* entity count, not SAB capacity. */
|
|
688
|
+
stateHash() {
|
|
689
|
+
return this._store.stateHash();
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
for (const t of ["capture", "restore", "captureSparse", "restoreSparse"])
|
|
693
|
+
G.prototype[t] = function() {
|
|
694
|
+
throw j("snapshots", `ecs.snapshots.${t}`);
|
|
695
|
+
};
|
|
696
|
+
class Tt extends G {
|
|
697
|
+
/** Capture the full live world (the dense bytes, the sparse stores and
|
|
698
|
+
* relations, and the host-side bookkeeping) to one self-contained byte
|
|
699
|
+
* buffer that `restore` can mount back onto a live, ticking world. Version 1
|
|
700
|
+
* captures no resource, no event and no change-detection baseline. */
|
|
701
|
+
capture() {
|
|
702
|
+
return this._store.snapshot();
|
|
703
|
+
}
|
|
704
|
+
/** Mount a `capture()` buffer onto this live world and keep ticking.
|
|
705
|
+
* Fails closed on a malformed frame or registration mismatch before
|
|
706
|
+
* mutating any live state. Requires a matching archetype set and column
|
|
707
|
+
* layout (prewarm so the set is stable). */
|
|
708
|
+
restore(e) {
|
|
709
|
+
this._store.restore(e);
|
|
710
|
+
}
|
|
711
|
+
/** Serialize the sparse stores and the relations to a self-contained buffer,
|
|
712
|
+
* the sparse half of a world snapshot, canonical entity-index order.
|
|
713
|
+
* Pairs with `restoreSparse`. */
|
|
714
|
+
captureSparse() {
|
|
715
|
+
return this._store.snapshotSparse();
|
|
716
|
+
}
|
|
717
|
+
/** Repopulate the sparse stores and the relation indices from
|
|
718
|
+
* `captureSparse` bytes. Sparse components must already be registered in the
|
|
719
|
+
* same order. Throws `SparseRestoreError` on a shape or identity
|
|
720
|
+
* mismatch. */
|
|
721
|
+
restoreSparse(e) {
|
|
722
|
+
this._store.restoreSparse(e);
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
function xt() {
|
|
726
|
+
return {
|
|
727
|
+
name: "snapshots",
|
|
728
|
+
install(t) {
|
|
729
|
+
const e = t.store;
|
|
730
|
+
return e.installSnapshots(new Rt(e.snapshotHost(), e.entityAllocator)), { snapshots: new Tt(e) };
|
|
731
|
+
}
|
|
732
|
+
};
|
|
733
|
+
}
|
|
734
|
+
export {
|
|
735
|
+
Tt as ECSSnapshotsFull,
|
|
736
|
+
xt as snapshots
|
|
737
|
+
};
|