@oasys/oecs 0.5.4 → 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 +1223 -266
- package/README.md +217 -112
- package/dist/core/ecs/access_check.d.cts +29 -29
- package/dist/core/ecs/access_check.d.ts +29 -29
- package/dist/core/ecs/access_check.d.ts.map +1 -1
- package/dist/core/ecs/archetype.d.cts +217 -209
- package/dist/core/ecs/archetype.d.ts +217 -209
- 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 +33 -33
- package/dist/core/ecs/archetype_graph.d.ts +33 -33
- 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 +26 -26
- package/dist/core/ecs/command_log.d.ts +26 -26
- package/dist/core/ecs/command_log.d.ts.map +1 -1
- package/dist/core/ecs/component.d.cts +43 -42
- package/dist/core/ecs/component.d.ts +43 -42
- 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 +289 -270
- package/dist/core/ecs/ecs.d.ts +289 -270
- 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 +20 -18
- package/dist/core/ecs/entity_allocator.d.ts +20 -18
- package/dist/core/ecs/entity_allocator.d.ts.map +1 -1
- package/dist/core/ecs/event.d.cts +36 -22
- package/dist/core/ecs/event.d.ts +36 -22
- 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 +32 -32
- package/dist/core/ecs/frame_trace.d.ts +32 -32
- package/dist/core/ecs/frame_trace.d.ts.map +1 -1
- package/dist/core/ecs/host_commands.d.cts +103 -85
- package/dist/core/ecs/host_commands.d.ts +103 -85
- package/dist/core/ecs/host_commands.d.ts.map +1 -1
- package/dist/core/ecs/index.d.cts +21 -11
- package/dist/core/ecs/index.d.ts +21 -11
- package/dist/core/ecs/index.d.ts.map +1 -1
- package/dist/core/ecs/observer.d.cts +39 -120
- package/dist/core/ecs/observer.d.ts +39 -120
- 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 +208 -578
- package/dist/core/ecs/query.d.ts +208 -578
- 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 +100 -39
- package/dist/core/ecs/ref.d.ts +100 -39
- package/dist/core/ecs/ref.d.ts.map +1 -1
- package/dist/core/ecs/relation.d.cts +101 -182
- package/dist/core/ecs/relation.d.ts +101 -182
- package/dist/core/ecs/relation.d.ts.map +1 -1
- package/dist/core/ecs/resource.d.cts +13 -13
- package/dist/core/ecs/resource.d.ts +13 -13
- package/dist/core/ecs/resource_registry.d.cts +5 -5
- package/dist/core/ecs/resource_registry.d.ts +5 -5
- 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 +91 -120
- package/dist/core/ecs/schedule.d.ts +91 -120
- 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 +108 -51
- package/dist/core/ecs/sparse_store.d.ts +108 -51
- package/dist/core/ecs/sparse_store.d.ts.map +1 -1
- package/dist/core/ecs/store.d.cts +527 -473
- package/dist/core/ecs/store.d.ts +527 -473
- package/dist/core/ecs/store.d.ts.map +1 -1
- package/dist/core/ecs/store_layout_listener.d.cts +6 -6
- package/dist/core/ecs/store_layout_listener.d.ts +6 -6
- 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 +146 -61
- package/dist/core/ecs/system.d.ts +146 -61
- 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 +82 -6
- package/dist/core/ecs/utils/error.d.ts +82 -6
- 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 +44 -44
- package/dist/core/store/action_ring.d.ts +44 -44
- package/dist/core/store/action_ring.d.ts.map +1 -1
- package/dist/core/store/allocator.d.cts +149 -95
- package/dist/core/store/allocator.d.ts +149 -95
- package/dist/core/store/allocator.d.ts.map +1 -1
- package/dist/core/store/buffer_backed_column.d.cts +17 -17
- package/dist/core/store/buffer_backed_column.d.ts +17 -17
- package/dist/core/store/buffer_backed_column.d.ts.map +1 -1
- package/dist/core/store/column_store.d.cts +124 -86
- package/dist/core/store/column_store.d.ts +124 -86
- 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 +36 -39
- package/dist/core/store/command_ring.d.ts +36 -39
- package/dist/core/store/command_ring.d.ts.map +1 -1
- package/dist/core/store/descriptor.d.cts +34 -17
- package/dist/core/store/descriptor.d.ts +34 -17
- 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 +36 -38
- package/dist/core/store/event_ring.d.ts +36 -38
- package/dist/core/store/event_ring.d.ts.map +1 -1
- package/dist/core/store/extend.d.cts +13 -7
- package/dist/core/store/extend.d.ts +13 -7
- package/dist/core/store/extend.d.ts.map +1 -1
- package/dist/core/store/grow.d.cts +2 -2
- package/dist/core/store/grow.d.ts +2 -2
- package/dist/core/store/grow.d.ts.map +1 -1
- package/dist/core/store/header.d.cts +31 -27
- package/dist/core/store/header.d.ts +31 -27
- 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 +71 -62
- package/dist/core/store/layout_ops.d.ts +71 -62
- 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 +12 -12
- package/dist/core/store/state_hash.d.ts +12 -12
- 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 +15 -10
- package/dist/index.d.ts +15 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.development.cjs +1 -1
- package/dist/index.development.js +5804 -5203
- package/dist/index.js +5323 -4764
- 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 +54 -54
- package/dist/{extensions → plugins}/editor/editor.d.ts +54 -54
- package/dist/plugins/editor/editor.d.ts.map +1 -0
- package/dist/{extensions → plugins}/editor/field_handle.d.cts +12 -12
- package/dist/{extensions → plugins}/editor/field_handle.d.ts +12 -12
- 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} +81 -64
- package/dist/{extensions/editor/index.js → plugins/editor.js} +81 -64
- 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 +85 -97
- package/dist/{core/ecs → plugins/relations}/relation_service.d.ts +85 -97
- 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 +16 -15
- package/dist/type_primitives/typed_arrays/typed_arrays.d.ts +16 -15
- 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 +3 -3
- package/dist/version.d.ts +3 -3
- 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-BlR3oZ3x.js +0 -2406
- package/dist/host_commands-C2cpU3yC.cjs +0 -1
- package/dist/internal-BoxWl4dG.js +0 -2565
- package/dist/internal-CGBEwfeB.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-Bs39EPh1.js +0 -150
- package/dist/shallow-C5YmTbtb.cjs +0 -1
- package/dist/shallow-CiFC70Dz.js +0 -159
- package/dist/shallow-DQ8aG51_.cjs +0 -1
- package/dist/shared-B4v0L1cw.js +0 -109
- package/dist/shared-DU78k0pU.cjs +0 -1
- package/dist/topological_sort-BDvEyb9W.cjs +0 -1
- package/dist/topological_sort-DK6EjpWa.js +0 -135
- package/dist/typed_arrays-D3NmwtCG.cjs +0 -1
- package/dist/typed_arrays-DIVwVy5_.js +0 -258
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { ECS_SNAPSHOT_VERSION, ArchetypeRowState, HostState } from '../../core/ecs/snapshot.js';
|
|
2
|
+
import { ArchetypeViews } from '../../core/store/index.js';
|
|
3
|
+
import { ECSRestoreError } from '../../core/ecs/utils/error.js';
|
|
4
|
+
/** Magic for the combined world-snapshot frame (`"WRS0"` little-endian). Distinct
|
|
5
|
+
* from the SAB `STORE_MAGIC` so a bare dense snapshot fed to `restore` is
|
|
6
|
+
* rejected with a clear error instead of being mis-parsed as a combined frame. */
|
|
7
|
+
export declare const WORLD_SNAPSHOT_MAGIC = 810766935;
|
|
8
|
+
export { ECSRestoreError };
|
|
9
|
+
export { ECS_SNAPSHOT_VERSION };
|
|
10
|
+
export type { ArchetypeRowState, HostState };
|
|
11
|
+
/** Serialize host-state to a self-contained little-endian byte buffer. Layout:
|
|
12
|
+
*
|
|
13
|
+
* [u32 tick][u32 highWater][u32 alive_count]
|
|
14
|
+
* [u32 freeCount][u32 free_index × freeCount]
|
|
15
|
+
* [u32 archCount][(u32 id, u32 length, u32 enabled_count) × archCount]
|
|
16
|
+
*/
|
|
17
|
+
export declare function serializeHostState(hs: HostState): Uint8Array;
|
|
18
|
+
/** Parse host-state bytes produced by `serializeHostState`. Throws
|
|
19
|
+
* `ECSRestoreError` on truncation or a trailing-byte (non-canonical) buffer. */
|
|
20
|
+
export declare function parseHostState(bytes: Uint8Array): HostState;
|
|
21
|
+
/** Assemble the combined world-snapshot frame from its three sections. Layout:
|
|
22
|
+
*
|
|
23
|
+
* [u32 magic][u32 version][u32 denseLen][u32 sparseLen][u32 hostLen]
|
|
24
|
+
* [dense][sparse][host]
|
|
25
|
+
*/
|
|
26
|
+
export declare function frameWorldSnapshot(dense: Uint8Array, sparse: Uint8Array, host: Uint8Array): Uint8Array;
|
|
27
|
+
/** The three sections of a combined frame, as zero-copy subviews over `bytes`. */
|
|
28
|
+
export interface WorldSnapshotSections {
|
|
29
|
+
readonly dense: Uint8Array;
|
|
30
|
+
readonly sparse: Uint8Array;
|
|
31
|
+
readonly host: Uint8Array;
|
|
32
|
+
}
|
|
33
|
+
/** Split a combined frame back into its sections. Validates magic, version, and
|
|
34
|
+
* an exact (no trailing bytes) frame. Throws `ECSRestoreError` otherwise. */
|
|
35
|
+
export declare function unframeWorldSnapshot(bytes: Uint8Array): WorldSnapshotSections;
|
|
36
|
+
/**
|
|
37
|
+
* Fail-closed registration guard, read **directly from the snapshot's dense
|
|
38
|
+
* bytes** so it can run before the dense backing is touched. `restore`
|
|
39
|
+
* builds the restored store through the live world's in-place allocator,
|
|
40
|
+
* which reuses the live backing buffer, so validating a
|
|
41
|
+
* *materialised* `ColumnStore` would already have overwritten live column data
|
|
42
|
+
* (the buffer is overwritten inside `restoreColumnStore`, before any post-build
|
|
43
|
+
* check could run). Parsing the descriptors off the raw `dense` `Uint8Array`
|
|
44
|
+
* keeps the check non-mutating, so a mismatch leaves the live world untouched.
|
|
45
|
+
*
|
|
46
|
+
* Asserts: the dense section's SAB magic and ABI, and that its archetype set,
|
|
47
|
+
* its per-archetype `componentMask` and its per-column
|
|
48
|
+
* `(componentId, fieldId, typeTag)`
|
|
49
|
+
* match the live store's exactly (so every live `Archetype.refreshViews` finds
|
|
50
|
+
* its region and no snapshot archetype is orphaned), and that the entity-index
|
|
51
|
+
* capacity matches (the region is sized once at construction). The archetype
|
|
52
|
+
* graph is rebuilt from registration code, not the snapshot (mirroring
|
|
53
|
+
* `restoreSparse`'s "registered in the same order" contract). Throws
|
|
54
|
+
* `ECSRestoreError` on any mismatch and malformed section.
|
|
55
|
+
*/
|
|
56
|
+
export declare function assertDenseMatchesLive(dense: Uint8Array, live: ReadonlyMap<number, ArchetypeViews>, liveEntityIndexCapacity: number): void;
|
|
57
|
+
//# sourceMappingURL=resume.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resume.d.ts","sourceRoot":"","sources":["../../../src/plugins/snapshots/resume.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,OAAO,EACN,oBAAoB,EACpB,KAAK,iBAAiB,EACtB,KAAK,SAAS,EACd,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAaN,KAAK,cAAc,EACnB,MAAM,kBAAkB,CAAC;AAE1B;;kFAEkF;AAClF,eAAO,MAAM,oBAAoB,YAAa,CAAC;AAM/C,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,CAAC;AAI3B,OAAO,EAAE,oBAAoB,EAAE,CAAC;AAChC,YAAY,EAAE,iBAAiB,EAAE,SAAS,EAAE,CAAC;AAI7C;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,SAAS,GAAG,UAAU,CAwB5D;AAED;gFACgF;AAChF,wBAAgB,cAAc,CAAC,KAAK,EAAE,UAAU,GAAG,SAAS,CAqC3D;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CACjC,KAAK,EAAE,UAAU,EACjB,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,UAAU,GACd,UAAU,CAaZ;AAED,kFAAkF;AAClF,MAAM,WAAW,qBAAqB;IACrC,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5B,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;CAC1B;AAED;6EAC6E;AAC7E,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,UAAU,GAAG,qBAAqB,CAuC7E;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,sBAAsB,CACrC,KAAK,EAAE,UAAU,EACjB,IAAI,EAAE,WAAW,CAAC,MAAM,EAAE,cAAc,CAAC,EACzC,uBAAuB,EAAE,MAAM,GAC7B,IAAI,CA4GN"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { EntityAllocator } from '../../core/ecs/entity_allocator.cjs';
|
|
2
|
+
import { SnapshotHooks, SnapshotHost } from '../../core/ecs/snapshot.cjs';
|
|
3
|
+
export declare class SnapshotService implements SnapshotHooks {
|
|
4
|
+
private readonly _host;
|
|
5
|
+
/** The allocator is its own snapshot seam: a free-list copy on
|
|
6
|
+
* capture, `setHighWater` and `restoreHostState` on mount. */
|
|
7
|
+
private readonly _allocator;
|
|
8
|
+
constructor(host: SnapshotHost, allocator: EntityAllocator);
|
|
9
|
+
/** Serialize the sparse stores **and** relation side data to a self-contained
|
|
10
|
+
* byte buffer, the sparse half of a world snapshot (the dense half is the
|
|
11
|
+
* SAB snapshot). Two framed sections: the sparse stores (`snapshotSparseStores`,
|
|
12
|
+
* where the exclusive relation targets and the multi membership ride) followed
|
|
13
|
+
* by the relation side data (`snapshotRelations`, multi forward target
|
|
14
|
+
* sets, which live outside the sparse store). Both are written in canonical
|
|
15
|
+
* entity-index order, so two worlds with identical contents inserted in
|
|
16
|
+
* different orders snapshot byte-for-byte the same. The reverse index
|
|
17
|
+
* is derived and never serialized, `restoreSparse` rebuilds it. */
|
|
18
|
+
snapshotSparse(): Uint8Array;
|
|
19
|
+
/** Repopulate the sparse stores from `snapshotSparse` bytes, replacing all
|
|
20
|
+
* current sparse data (full-equality round-trip of membership and data), then
|
|
21
|
+
* rebuild every relation's derived side indices: multi forward sets from the
|
|
22
|
+
* relation section, and the reverse index for both cardinalities (exclusive
|
|
23
|
+
* from the newly restored sparse target field, multi from the rebuilt forward
|
|
24
|
+
* sets). The sparse components and relations must already be registered in
|
|
25
|
+
* the same order, restore carries data, not the registration (which is
|
|
26
|
+
* code). Throws `SparseRestoreError` if the snapshot's shape, field identity,
|
|
27
|
+
* entity-index bounds, or frame length don't validate. */
|
|
28
|
+
restoreSparse(bytes: Uint8Array): void;
|
|
29
|
+
/** Rebuild every relation's derived side indices after the sparse stores have
|
|
30
|
+
* been restored. `restoreRelations` resets all relations, rebuilds the multi
|
|
31
|
+
* forward sets and their reverse edges from `relBytes`, and validates shape.
|
|
32
|
+
* The exclusive reverse index can't be carried in the bytes (it's derivable),
|
|
33
|
+
* so it's rebuilt here from the backing sparse store: every member row holds
|
|
34
|
+
* `(source index → target EntityID)`, which is exactly one reverse edge. */
|
|
35
|
+
private _rebuildRelationIndices;
|
|
36
|
+
/** Capture the full live world to one self-contained byte buffer that
|
|
37
|
+
* `restore` can mount back onto a live, ticking world. Three
|
|
38
|
+
* sections (see `resume.ts`): the dense SAB column bytes, the sparse and
|
|
39
|
+
* relation bytes, and the host-side bookkeeping the SAB omits. */
|
|
40
|
+
snapshot(): Uint8Array;
|
|
41
|
+
/** Gather the host-side state a snapshot carries alongside the dense and
|
|
42
|
+
* sparse bytes, see `snapshot()`. The free-list is copied, because it is a
|
|
43
|
+
* live mutable. */
|
|
44
|
+
private _collectHostState;
|
|
45
|
+
/** Mount a `snapshot()` buffer onto the live world and leave it ready to keep
|
|
46
|
+
* ticking. Fails closed on a malformed frame or a registration mismatch
|
|
47
|
+
* before any live state is touched. */
|
|
48
|
+
restore(bytes: Uint8Array): void;
|
|
49
|
+
/** Read-only validation of a `snapshotSparse` Section (the framed
|
|
50
|
+
* `[sparseLen][relLen][sparse][rel]` buffer) against the live registry, used
|
|
51
|
+
* by `restore` to fail closed on a sparse-registration mismatch before the
|
|
52
|
+
* dense mount commits. Mirrors `restoreSparse`'s frame check, then validates the
|
|
53
|
+
* sparse-stores sub-section without mutating. A relation-registration difference
|
|
54
|
+
* surfaces here too: every `registerRelation` adds a backing sparse store, so a
|
|
55
|
+
* differing relation set changes the sparse store count or its schema. Throws
|
|
56
|
+
* `SparseRestoreError` on a mismatch. */
|
|
57
|
+
private _assertSparseMatchesLive;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=snapshot_service.d.ts.map
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { EntityAllocator } from '../../core/ecs/entity_allocator.js';
|
|
2
|
+
import { SnapshotHooks, SnapshotHost } from '../../core/ecs/snapshot.js';
|
|
3
|
+
export declare class SnapshotService implements SnapshotHooks {
|
|
4
|
+
private readonly _host;
|
|
5
|
+
/** The allocator is its own snapshot seam: a free-list copy on
|
|
6
|
+
* capture, `setHighWater` and `restoreHostState` on mount. */
|
|
7
|
+
private readonly _allocator;
|
|
8
|
+
constructor(host: SnapshotHost, allocator: EntityAllocator);
|
|
9
|
+
/** Serialize the sparse stores **and** relation side data to a self-contained
|
|
10
|
+
* byte buffer, the sparse half of a world snapshot (the dense half is the
|
|
11
|
+
* SAB snapshot). Two framed sections: the sparse stores (`snapshotSparseStores`,
|
|
12
|
+
* where the exclusive relation targets and the multi membership ride) followed
|
|
13
|
+
* by the relation side data (`snapshotRelations`, multi forward target
|
|
14
|
+
* sets, which live outside the sparse store). Both are written in canonical
|
|
15
|
+
* entity-index order, so two worlds with identical contents inserted in
|
|
16
|
+
* different orders snapshot byte-for-byte the same. The reverse index
|
|
17
|
+
* is derived and never serialized, `restoreSparse` rebuilds it. */
|
|
18
|
+
snapshotSparse(): Uint8Array;
|
|
19
|
+
/** Repopulate the sparse stores from `snapshotSparse` bytes, replacing all
|
|
20
|
+
* current sparse data (full-equality round-trip of membership and data), then
|
|
21
|
+
* rebuild every relation's derived side indices: multi forward sets from the
|
|
22
|
+
* relation section, and the reverse index for both cardinalities (exclusive
|
|
23
|
+
* from the newly restored sparse target field, multi from the rebuilt forward
|
|
24
|
+
* sets). The sparse components and relations must already be registered in
|
|
25
|
+
* the same order, restore carries data, not the registration (which is
|
|
26
|
+
* code). Throws `SparseRestoreError` if the snapshot's shape, field identity,
|
|
27
|
+
* entity-index bounds, or frame length don't validate. */
|
|
28
|
+
restoreSparse(bytes: Uint8Array): void;
|
|
29
|
+
/** Rebuild every relation's derived side indices after the sparse stores have
|
|
30
|
+
* been restored. `restoreRelations` resets all relations, rebuilds the multi
|
|
31
|
+
* forward sets and their reverse edges from `relBytes`, and validates shape.
|
|
32
|
+
* The exclusive reverse index can't be carried in the bytes (it's derivable),
|
|
33
|
+
* so it's rebuilt here from the backing sparse store: every member row holds
|
|
34
|
+
* `(source index → target EntityID)`, which is exactly one reverse edge. */
|
|
35
|
+
private _rebuildRelationIndices;
|
|
36
|
+
/** Capture the full live world to one self-contained byte buffer that
|
|
37
|
+
* `restore` can mount back onto a live, ticking world. Three
|
|
38
|
+
* sections (see `resume.ts`): the dense SAB column bytes, the sparse and
|
|
39
|
+
* relation bytes, and the host-side bookkeeping the SAB omits. */
|
|
40
|
+
snapshot(): Uint8Array;
|
|
41
|
+
/** Gather the host-side state a snapshot carries alongside the dense and
|
|
42
|
+
* sparse bytes, see `snapshot()`. The free-list is copied, because it is a
|
|
43
|
+
* live mutable. */
|
|
44
|
+
private _collectHostState;
|
|
45
|
+
/** Mount a `snapshot()` buffer onto the live world and leave it ready to keep
|
|
46
|
+
* ticking. Fails closed on a malformed frame or a registration mismatch
|
|
47
|
+
* before any live state is touched. */
|
|
48
|
+
restore(bytes: Uint8Array): void;
|
|
49
|
+
/** Read-only validation of a `snapshotSparse` Section (the framed
|
|
50
|
+
* `[sparseLen][relLen][sparse][rel]` buffer) against the live registry, used
|
|
51
|
+
* by `restore` to fail closed on a sparse-registration mismatch before the
|
|
52
|
+
* dense mount commits. Mirrors `restoreSparse`'s frame check, then validates the
|
|
53
|
+
* sparse-stores sub-section without mutating. A relation-registration difference
|
|
54
|
+
* surfaces here too: every `registerRelation` adds a backing sparse store, so a
|
|
55
|
+
* differing relation set changes the sparse store count or its schema. Throws
|
|
56
|
+
* `SparseRestoreError` on a mismatch. */
|
|
57
|
+
private _assertSparseMatchesLive;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=snapshot_service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snapshot_service.d.ts","sourceRoot":"","sources":["../../../src/plugins/snapshots/snapshot_service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAIH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAOvE,OAAO,KAAK,EAGX,aAAa,EACb,YAAY,EACZ,MAAM,yBAAyB,CAAC;AAWjC,qBAAa,eAAgB,YAAW,aAAa;IACpD,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAe;IACrC;kEAC8D;IAC9D,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAkB;gBAEjC,IAAI,EAAE,YAAY,EAAE,SAAS,EAAE,eAAe;IAK1D;;;;;;;;uEAQmE;IAC5D,cAAc,IAAI,UAAU;IAanC;;;;;;;;8DAQ0D;IACnD,aAAa,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI;IAuB7C;;;;;gFAK4E;IAC5E,OAAO,CAAC,uBAAuB;IAW/B;;;sEAGkE;IAC3D,QAAQ,IAAI,UAAU;IAa7B;;uBAEmB;IACnB,OAAO,CAAC,iBAAiB;IAqBzB;;2CAEuC;IAChC,OAAO,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI;IA+CvC;;;;;;;6CAOyC;IACzC,OAAO,CAAC,wBAAwB;CAgBhC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const R=require("./relation_store-DQKSnxsm.cjs"),u=require("../index.cjs"),a=require("./abi-D3V-QUSf.cjs"),P=require("../internal.cjs");function F(t){return{magic:t.getUint32(a.STORE_HEADER_OFFSETS.magic,!0),simAbiVersion:t.getUint32(a.STORE_HEADER_OFFSETS.sim_abi_version,!0),viewStamp:t.getUint32(a.STORE_HEADER_OFFSETS.view_stamp,!0),capacity:t.getUint32(a.STORE_HEADER_OFFSETS.capacity,!0),archetypeCount:t.getUint32(a.STORE_HEADER_OFFSETS.archetype_count,!0),layoutDescriptorOff:t.getUint32(a.STORE_HEADER_OFFSETS.layout_descriptor_off,!0),commandRingOff:t.getUint32(a.STORE_HEADER_OFFSETS.command_ring_off,!0),actionRingOff:t.getUint32(a.STORE_HEADER_OFFSETS.action_ring_off,!0),entityIndexOff:t.getUint32(a.STORE_HEADER_OFFSETS.entity_index_off,!0),eventRingOff:t.getUint32(a.STORE_HEADER_OFFSETS.event_ring_off,!0),regionTableOff:t.getUint32(a.STORE_HEADER_OFFSETS.region_table_off,!0),regionTableCount:t.getUint32(a.STORE_HEADER_OFFSETS.region_table_count,!0),bindingsOff:t.getUint32(a.STORE_HEADER_OFFSETS.bindings_off,!0)}}const g={u8:0,i8:1,u16:2,i16:3,u32:4,i32:5,f32:6,f64:7},B=Object.freeze({[g.u8]:1,[g.i8]:1,[g.u16]:2,[g.i16]:2,[g.u32]:4,[g.i32]:4,[g.f32]:4,[g.f64]:8});function N(t,e,n){t.setUint16(e+a.COLUMN_DESCRIPTOR_OFFSETS.component_id,n.componentId,!0),t.setUint16(e+a.COLUMN_DESCRIPTOR_OFFSETS.field_id,n.fieldId,!0),t.setUint8(e+a.COLUMN_DESCRIPTOR_OFFSETS.type_tag,n.typeTag),t.setUint32(e+a.COLUMN_DESCRIPTOR_OFFSETS.byte_off,n.byteOff,!0),t.setUint16(e+a.COLUMN_DESCRIPTOR_OFFSETS.stride,n.stride,!0)}function M(t,e){return{componentId:t.getUint16(e+a.COLUMN_DESCRIPTOR_OFFSETS.component_id,!0),fieldId:t.getUint16(e+a.COLUMN_DESCRIPTOR_OFFSETS.field_id,!0),typeTag:t.getUint8(e+a.COLUMN_DESCRIPTOR_OFFSETS.type_tag),byteOff:t.getUint32(e+a.COLUMN_DESCRIPTOR_OFFSETS.byte_off,!0),stride:t.getUint16(e+a.COLUMN_DESCRIPTOR_OFFSETS.stride,!0)}}function Y(t,e=a.ARCHETYPE_DESCRIPTOR_HEADER_BYTES){return e+t*a.COLUMN_DESCRIPTOR_BYTES}function V(t,e,n){t.setUint32(e+a.ARCHETYPE_DESCRIPTOR_OFFSETS.archetype_id,n.archetypeId,!0);for(let r=0;r<a.COMPONENT_MASK_WORDS;r++)t.setUint32(e+a.ARCHETYPE_DESCRIPTOR_OFFSETS.component_mask+r*4,n.componentMask[r]??0,!0);t.setUint32(e+a.ARCHETYPE_DESCRIPTOR_OFFSETS.row_count,n.rowCount,!0),t.setUint32(e+a.ARCHETYPE_DESCRIPTOR_OFFSETS.row_capacity,n.rowCapacity,!0),t.setUint32(e+a.ARCHETYPE_DESCRIPTOR_OFFSETS.column_count,n.columns.length,!0),t.setUint32(e+a.ARCHETYPE_DESCRIPTOR_OFFSETS.enabled_count,n.enabledCount,!0),t.setUint32(e+a.ARCHETYPE_DESCRIPTOR_OFFSETS.entity_ids_off,0,!0);let o=e+a.ARCHETYPE_DESCRIPTOR_HEADER_BYTES;for(let r=0;r<n.columns.length;r++)N(t,o,n.columns[r]),o+=a.COLUMN_DESCRIPTOR_BYTES;return o}function v(t,e,n=a.ARCHETYPE_DESCRIPTOR_HEADER_BYTES){const o=t.getUint32(e+a.ARCHETYPE_DESCRIPTOR_OFFSETS.column_count,!0),r=new Array(o);let s=e+n;for(let i=0;i<o;i++)r[i]=M(t,s),s+=a.COLUMN_DESCRIPTOR_BYTES;const c=new Array(a.COMPONENT_MASK_WORDS);for(let i=0;i<a.COMPONENT_MASK_WORDS;i++)c[i]=t.getUint32(e+a.ARCHETYPE_DESCRIPTOR_OFFSETS.component_mask+i*4,!0);return{archetypeId:t.getUint32(e+a.ARCHETYPE_DESCRIPTOR_OFFSETS.archetype_id,!0),componentMask:c,rowCount:t.getUint32(e+a.ARCHETYPE_DESCRIPTOR_OFFSETS.row_count,!0),rowCapacity:t.getUint32(e+a.ARCHETYPE_DESCRIPTOR_OFFSETS.row_capacity,!0),enabledCount:t.getUint32(e+a.ARCHETYPE_DESCRIPTOR_OFFSETS.enabled_count,!0),columns:r}}function x(t,e,n){let o=e;for(let r=0;r<n.length;r++)o=V(t,o,n[r]);return o}function C(t,e,n,o=a.ARCHETYPE_DESCRIPTOR_HEADER_BYTES){const r=new Array(n);let s=e;for(let c=0;c<n;c++){const i=v(t,s,o);r[c]=i,s+=Y(i.columns.length,o)}return r}class k extends Error{constructor(){super('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.'),this.name="SabUnavailableError"}}const G=t=>{if(typeof SharedArrayBuffer>"u")throw new k;return new SharedArrayBuffer(t)},X=16,W={capacity:4};function q(t,e){return t<<16|e}const $=2**31;class z extends Error{constructor(e){super(`SAB column layout offset ${e} reaches or exceeds the 2³¹ (${$}-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.`),this.name="StoreLayoutOverflowError"}}function j(t,e){if(t+e>$)throw new z(t);return t+(e-1)&~(e-1)}function K(t,e,n,o,r){const s=e+o;switch(n){case g.u8:return new Uint8Array(t,s,r);case g.i8:return new Int8Array(t,s,r);case g.u16:return new Uint16Array(t,s,r);case g.i16:return new Int16Array(t,s,r);case g.u32:return new Uint32Array(t,s,r);case g.i32:return new Int32Array(t,s,r);case g.f32:return new Float32Array(t,s,r);case g.f64:return new Float64Array(t,s,r)}}const U=16;function J(t){if(!Number.isInteger(t)||t<0)throw new RangeError(`createColumnStore: storeBase must be an integer >= 0, got ${t}`);if(t%U!==0)throw new RangeError(`createColumnStore: storeBase must be a multiple of ${U}, got ${t}`)}function Q(t,e,n){const o=new Map;for(let r=0;r<n.length;r++){const s=n[r],c=new Array(s.columns.length),i=new Map;for(let h=0;h<s.columns.length;h++){const E=s.columns[h],S={componentId:E.componentId,fieldId:E.fieldId,typeTag:E.typeTag,byteOff:E.byteOff,stride:E.stride,view:K(t,e,E.typeTag,E.byteOff,s.rowCapacity)};c[h]=S,i.set(q(E.componentId,E.fieldId),S)}o.set(s.archetypeId,{archetypeId:s.archetypeId,componentMask:s.componentMask,rowCapacity:s.rowCapacity,columns:i,columnsInOrder:c})}return o}function Z(t){const e=t.view.getUint32(a.STORE_HEADER_OFFSETS.capacity,!0);return new Uint8Array(t.buffer,t.storeBase,e)}const tt=Math.max(...Object.values(B));function et(t){const e=a.ARCHETYPE_DESCRIPTOR_HEADER_BYTES-a.LEGACY_ARCHETYPE_DESCRIPTOR_HEADER_BYTES;return j(t*e,tt)}function rt(t){const e=new DataView(t.buffer,t.byteOffset,t.byteLength),n=e.getUint32(a.STORE_HEADER_OFFSETS.layout_descriptor_off,!0),o=e.getUint32(a.STORE_HEADER_OFFSETS.archetype_count,!0),r=et(o);if(r===0)return t;const s=C(e,n,o,a.LEGACY_ARCHETYPE_DESCRIPTOR_HEADER_BYTES),c=new Uint8Array(t.byteLength+r);c.set(t.subarray(0,n),0),c.set(t.subarray(n),n+r);const i=new DataView(c.buffer),h=s.map(S=>({...S,columns:S.columns.map(f=>({...f,byteOff:f.byteOff+r}))}));x(i,n,h);const E=e.getUint32(a.STORE_HEADER_OFFSETS.capacity,!0);return i.setUint32(a.STORE_HEADER_OFFSETS.capacity,E+r,!0),c}function nt(t,e=G,n={}){const o=n.storeBase??0;J(o);const r=new DataView(t.buffer,t.byteOffset,t.byteLength);if(t.byteLength<a.STORE_HEADER_BYTES)throw new u.StoreRestoreError(`snapshot too small: ${t.byteLength} bytes (header alone needs ${a.STORE_HEADER_BYTES})`);const s=r.getUint32(a.STORE_HEADER_OFFSETS.magic,!0);if(s!==a.STORE_MAGIC)throw new u.StoreRestoreError(`bad magic: 0x${s.toString(16).padStart(8,"0")} (expected 0x${a.STORE_MAGIC.toString(16).padStart(8,"0")})`);const c=r.getUint32(a.STORE_HEADER_OFFSETS.sim_abi_version,!0);if(c!==a.SIM_ABI_VERSION&&c!==a.LEGACY_ABSOLUTE_ABI_VERSION)throw new u.StoreRestoreError(`incompatible sim_abi_version: snapshot=${c}, build=${a.SIM_ABI_VERSION}`);const i=r.getUint32(a.STORE_HEADER_OFFSETS.layout_descriptor_off,!0);if(i>t.byteLength)throw new u.StoreRestoreError(`layout_descriptor_off ${i} is outside the snapshot (${t.byteLength} bytes)`);let h=t;if(c===a.LEGACY_ABSOLUTE_ABI_VERSION)try{h=rt(t)}catch(_){throw _ instanceof RangeError?new u.StoreRestoreError(`snapshot layout is corrupt or truncated: a version 0 descriptor reads past the ${t.byteLength}-byte span (${_.message})`):_}const E=e(o+h.byteLength);new Uint8Array(E,o,h.byteLength).set(h);const S=new DataView(E,o);S.setUint32(a.STORE_HEADER_OFFSETS.sim_abi_version,a.SIM_ABI_VERSION,!0);const f=F(S);if(f.layoutDescriptorOff<0||f.layoutDescriptorOff>h.byteLength)throw new u.StoreRestoreError(`layout_descriptor_off ${f.layoutDescriptorOff} is outside the snapshot (${h.byteLength} bytes)`);try{const _=C(S,f.layoutDescriptorOff,f.archetypeCount),l=Q(E,o,_);return{buffer:E,view:S,header:f,storeBase:o,archetypes:l}}catch(_){throw _ instanceof RangeError?new u.StoreRestoreError(`snapshot layout is corrupt or truncated: a descriptor offset or column extent reads past the ${h.byteLength}-byte span (${_.message})`):_}}const ot=2166136261,st=16777619;function w(t,e){return t=(t^e&255)>>>0,Math.imul(t,st)>>>0}const I=12,b=4,O=8;function D(t,e){let n=ot;const o=r=>{for(let s=0;s<r.length;s++)n=w(n,r.charCodeAt(s))};for(let r=0;r<t.length;r++)o(t[r]),n=w(n,31),o(e[r]),n=w(n,30);return n>>>0}function at(t){let e=4;for(let s=0;s<t.length;s++){const c=t[s],i=c.fieldNames.length;e+=I+c.size*(b+i*O)}const n=new Uint8Array(e),o=new DataView(n.buffer);let r=0;o.setUint32(r,t.length,!0),r+=4;for(let s=0;s<t.length;s++){const c=t[s],i=c.fieldNames.length,h=c.canonicalIndices();o.setUint32(r,i,!0),r+=4,o.setUint32(r,D(c.fieldNames,c.fieldTypes),!0),r+=4,o.setUint32(r,h.length,!0),r+=4;for(let E=0;E<h.length;E++){const S=h[E];o.setUint32(r,S,!0),r+=4;const f=c.getRow(S);for(let _=0;_<i;_++)o.setFloat64(r,f[_],!0),r+=O}}return n}function it(t,e){const n=new DataView(e.buffer,e.byteOffset,e.byteLength),o=e.byteLength;let r=0;const s=i=>{if(r+i>o)throw new u.SparseRestoreError(`sparse snapshot truncated: need ${i} more bytes at offset ${r}, have ${o-r}`)};s(4);const c=n.getUint32(r,!0);if(r+=4,c!==t.length)throw new u.SparseRestoreError(`sparse store count mismatch: snapshot=${c}, registered=${t.length}`);for(let i=0;i<t.length;i++){const h=t[i];s(I);const E=n.getUint32(r,!0);r+=4;const S=n.getUint32(r,!0);r+=4;const f=n.getUint32(r,!0);if(r+=4,E!==h.fieldNames.length)throw new u.SparseRestoreError(`sparse store ${i} field-count mismatch: snapshot=${E}, registered=${h.fieldNames.length}`);const _=D(h.fieldNames,h.fieldTypes);if(S!==_)throw new u.SparseRestoreError(`sparse store ${i} schema identity mismatch: snapshot hash=${S}, registered=${_} (same field count, different field names or types, likely a registration-order divergence between the snapshot and restore worlds)`);h.clear();for(let l=0;l<f;l++){s(b+E*O);const d=n.getUint32(r,!0);if(r+=4,d>R.MAX_INDEX)throw new u.SparseRestoreError(`sparse store ${i} member ${l} entity index ${d} exceeds MAX_INDEX (${R.MAX_INDEX})`);const p=new Array(E);for(let T=0;T<E;T++)p[T]=n.getFloat64(r,!0),r+=O;h.setRawRow(d,p)}}if(r!==o)throw new u.SparseRestoreError(`sparse snapshot has ${o-r} trailing bytes after the last store (not a canonical encoding)`)}function ct(t,e){const n=new DataView(e.buffer,e.byteOffset,e.byteLength),o=e.byteLength;let r=0;const s=i=>{if(r+i>o)throw new u.SparseRestoreError(`sparse snapshot truncated: need ${i} more bytes at offset ${r}, have ${o-r}`)};s(4);const c=n.getUint32(r,!0);if(r+=4,c!==t.length)throw new u.SparseRestoreError(`sparse store count mismatch: snapshot=${c}, registered=${t.length}`);for(let i=0;i<t.length;i++){const h=t[i];s(I);const E=n.getUint32(r,!0);r+=4;const S=n.getUint32(r,!0);r+=4;const f=n.getUint32(r,!0);if(r+=4,E!==h.fieldNames.length)throw new u.SparseRestoreError(`sparse store ${i} field-count mismatch: snapshot=${E}, registered=${h.fieldNames.length}`);const _=D(h.fieldNames,h.fieldTypes);if(S!==_)throw new u.SparseRestoreError(`sparse store ${i} schema identity mismatch: snapshot hash=${S}, registered=${_} (same field count, different field names or types, likely a registration-order divergence between the snapshot and restore worlds)`);for(let l=0;l<f;l++){s(b+E*O);const d=n.getUint32(r,!0);if(r+=4,d>R.MAX_INDEX)throw new u.SparseRestoreError(`sparse store ${i} member ${l} entity index ${d} exceeds MAX_INDEX (${R.MAX_INDEX})`);r+=E*O}}if(r!==o)throw new u.SparseRestoreError(`sparse snapshot has ${o-r} trailing bytes after the last store (not a canonical encoding)`)}const m=1,A=810766935,y=4;function ht(t){const e=t.freeIndices.length,n=t.archetypeRows.length,o=y*(4+e+1+n*3),r=new Uint8Array(o),s=new DataView(r.buffer);let c=0;const i=h=>{s.setUint32(c,h,!0),c+=y};i(t.tick),i(t.entityHighWater),i(t.entityAliveCount),i(e);for(let h=0;h<e;h++)i(t.freeIndices[h]);i(n);for(let h=0;h<n;h++){const E=t.archetypeRows[h];i(E.archetypeId),i(E.length),i(E.enabledCount)}return r}function Et(t){const e=new DataView(t.buffer,t.byteOffset,t.byteLength),n=t.byteLength;let o=0;const r=l=>{if(o+l>n)throw new u.ECSRestoreError(`host-state truncated: need ${l} more bytes at offset ${o}, have ${n-o}`)},s=()=>{r(y);const l=e.getUint32(o,!0);return o+=y,l},c=s(),i=s(),h=s(),E=s(),S=new Array(E);for(let l=0;l<E;l++)S[l]=s();const f=s(),_=new Array(f);for(let l=0;l<f;l++){const d=s(),p=s(),T=s();_[l]={archetypeId:d,length:p,enabledCount:T}}if(o!==n)throw new u.ECSRestoreError(`host-state has ${n-o} trailing bytes after the last archetype (not a canonical encoding)`);return{tick:c,entityHighWater:i,entityAliveCount:h,freeIndices:S,archetypeRows:_}}function ut(t,e,n){const o=y*5,r=new Uint8Array(o+t.length+e.length+n.length),s=new DataView(r.buffer);return s.setUint32(0,A,!0),s.setUint32(4,m,!0),s.setUint32(8,t.length,!0),s.setUint32(12,e.length,!0),s.setUint32(16,n.length,!0),r.set(t,o),r.set(e,o+t.length),r.set(n,o+t.length+e.length),r}function lt(t){const e=y*5;if(t.byteLength<e)throw new u.ECSRestoreError(`world snapshot too small: ${t.byteLength} bytes (frame header needs ${e})`);const n=new DataView(t.buffer,t.byteOffset,t.byteLength),o=n.getUint32(0,!0);if(o!==A)throw new u.ECSRestoreError(`bad world-snapshot magic: 0x${o.toString(16).padStart(8,"0")} (expected 0x${A.toString(16).padStart(8,"0")}). A bare dense (SAB) snapshot is not a combined world snapshot, pass the bytes from ECS.snapshot(), not columnStoreBytesView().`);const r=n.getUint32(4,!0);if(r!==m)throw new u.ECSRestoreError(`incompatible world-snapshot version: snapshot=${r}, build=${m}`);const s=n.getUint32(8,!0),c=n.getUint32(12,!0),i=n.getUint32(16,!0);if(e+s+c+i!==t.byteLength)throw new u.ECSRestoreError(`world-snapshot frame mismatch: header declares ${e}+${s}+${c}+${i}=${e+s+c+i} bytes, buffer is ${t.byteLength}`);const h=t.byteOffset,E=t.buffer;return{dense:new Uint8Array(E,h+e,s),sparse:new Uint8Array(E,h+e+s,c),host:new Uint8Array(E,h+e+s+c,i)}}function St(t,e,n){if(t.byteLength<a.STORE_HEADER_BYTES)throw new u.ECSRestoreError(`dense section too small: ${t.byteLength} bytes (SAB header needs ${a.STORE_HEADER_BYTES})`);const o=new DataView(t.buffer,t.byteOffset,t.byteLength),r=o.getUint32(a.STORE_HEADER_OFFSETS.magic,!0);if(r!==a.STORE_MAGIC)throw new u.ECSRestoreError(`dense section bad magic: 0x${r.toString(16).padStart(8,"0")} (expected SAB magic 0x${a.STORE_MAGIC.toString(16).padStart(8,"0")})`);const s=o.getUint32(a.STORE_HEADER_OFFSETS.sim_abi_version,!0);if(s!==a.SIM_ABI_VERSION&&s!==a.LEGACY_ABSOLUTE_ABI_VERSION)throw new u.ECSRestoreError(`dense section incompatible sim_abi_version: snapshot=${s}, build=${a.SIM_ABI_VERSION}`);const c=F(o);if(c.layoutDescriptorOff<0||c.layoutDescriptorOff>t.byteLength)throw new u.ECSRestoreError(`dense layoutDescriptorOff ${c.layoutDescriptorOff} is outside the section (${t.byteLength} bytes)`);const i=c.entityIndexOff;if(i<0||i+X>t.byteLength)throw new u.ECSRestoreError(`dense entityIndexOff ${i} is outside the section (${t.byteLength} bytes)`);const h=o.getUint32(i+W.capacity,!0);if(h!==n)throw new u.ECSRestoreError(`entity-index capacity mismatch: live=${n}, snapshot=${h}`);let E;try{E=C(o,c.layoutDescriptorOff,c.archetypeCount,s===a.LEGACY_ABSOLUTE_ABI_VERSION?a.LEGACY_ARCHETYPE_DESCRIPTOR_HEADER_BYTES:a.ARCHETYPE_DESCRIPTOR_HEADER_BYTES)}catch(S){throw S instanceof RangeError?new u.ECSRestoreError(`dense section layout is corrupt or truncated: a descriptor reads past the ${t.byteLength}-byte section (${S.message})`):S}if(e.size!==E.length)throw new u.ECSRestoreError(`archetype-set mismatch: the live world has ${e.size} SAB archetypes, the snapshot has ${E.length}. restore requires an identical archetype set. Prewarm the world so its archetype set is stable.`);for(let S=0;S<E.length;S++){const f=E[S],_=e.get(f.archetypeId);if(_===void 0)throw new u.ECSRestoreError(`archetype-set mismatch: snapshot archetype ${f.archetypeId} is absent from the live world`);if(!ft(_.componentMask,f.componentMask))throw new u.ECSRestoreError(`archetype ${f.archetypeId} component-mask mismatch between the live world and the snapshot (different component registration)`);const l=_.columnsInOrder,d=f.columns;if(l.length!==d.length)throw new u.ECSRestoreError(`archetype ${f.archetypeId} column-count mismatch: live=${l.length}, snapshot=${d.length}`);for(let p=0;p<l.length;p++)if(l[p].componentId!==d[p].componentId||l[p].fieldId!==d[p].fieldId||l[p].typeTag!==d[p].typeTag)throw new u.ECSRestoreError(`archetype ${f.archetypeId} column ${p} layout mismatch: live=(c${l[p].componentId},f${l[p].fieldId},t${l[p].typeTag}), snapshot=(c${d[p].componentId},f${d[p].fieldId},t${d[p].typeTag})`)}}function ft(t,e){if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;return!0}class _t{_host;_allocator;constructor(e,n){this._host=e,this._allocator=n}snapshotSparse(){const e=at(this._host.sparseStores()),n=R.snapshotRelations(this._host.relationStores()),o=new Uint8Array(8+e.length+n.length),r=new DataView(o.buffer);return r.setUint32(0,e.length,!0),r.setUint32(4,n.length,!0),o.set(e,8),o.set(n,8+e.length),o}restoreSparse(e){const n=new DataView(e.buffer,e.byteOffset,e.byteLength);if(e.byteLength<8)throw new u.SparseRestoreError(`sparse snapshot truncated: need 8 header bytes, have ${e.byteLength}`);const o=n.getUint32(0,!0),r=n.getUint32(4,!0);if(8+o+r!==e.byteLength)throw new u.SparseRestoreError(`sparse snapshot frame mismatch: header declares 8+${o}+${r}=${8+o+r} bytes, buffer is ${e.byteLength}`);it(this._host.sparseStores(),e.subarray(8,8+o)),this._rebuildRelationIndices(e.subarray(8+o,8+o+r))}_rebuildRelationIndices(e){const n=this._host.generations(),o=s=>R.createEntityId(s,n[s]),r=this._host.relationStores();R.restoreRelations(r,e,o);for(let s=0;s<r.length;s++)r[s].rebuildReverse(o)}snapshot(){this._host.publishRowCounts();const e=new Uint8Array(Z(this._host.columnStore())),n=this.snapshotSparse(),o=ht(this._collectHostState());return ut(e,n,o)}_collectHostState(){const e=[],n=this._host.archetypes();for(let o=0;o<n.length;o++){const r=n[o];r.isBufferBacked&&e.push({archetypeId:r.id,length:r.length,enabledCount:r.enabledCount})}return{tick:this._host.tick(),entityHighWater:this._allocator.highWater,entityAliveCount:this._allocator.aliveCount,freeIndices:this._allocator.snapshotFreeIndices(),archetypeRows:e}}restore(e){const n=lt(e),o=Et(n.host);St(n.dense,this._host.columnStore().archetypes,this._host.entityIndexCapacity()),this._assertSparseMatchesLive(n.sparse);const r=nt(n.dense,this._host.bufferAllocator(),{storeBase:this._host.columnStore().storeBase});this._host.mountRestoredDense(r),this._host.reconstructHostRows(o),this._allocator.restoreHostState(o.freeIndices,o.entityAliveCount),this._host.setTick(o.tick),this._host.invalidateCaches(),this.restoreSparse(n.sparse)}_assertSparseMatchesLive(e){const n=new DataView(e.buffer,e.byteOffset,e.byteLength);if(e.byteLength<8)throw new u.SparseRestoreError(`sparse snapshot truncated: need 8 header bytes, have ${e.byteLength}`);const o=n.getUint32(0,!0),r=n.getUint32(4,!0);if(8+o+r!==e.byteLength)throw new u.SparseRestoreError(`sparse snapshot frame mismatch: header declares 8+${o}+${r}=${8+o+r} bytes, buffer is ${e.byteLength}`);ct(this._host.sparseStores(),e.subarray(8,8+o))}}class L{_store;constructor(e){this._store=e}get deterministic(){return this._store.deterministic}stateHash(){return this._store.stateHash()}}for(const t of["capture","restore","captureSparse","restoreSparse"])L.prototype[t]=function(){throw P.pluginMissingError("snapshots",`ecs.snapshots.${t}`)};class H extends L{capture(){return this._store.snapshot()}restore(e){this._store.restore(e)}captureSparse(){return this._store.snapshotSparse()}restoreSparse(e){this._store.restoreSparse(e)}}function pt(){return{name:"snapshots",install(t){const e=t.store;return e.installSnapshots(new _t(e.snapshotHost(),e.entityAllocator)),{snapshots:new H(e)}}}}exports.ECSSnapshotsFull=H;exports.snapshots=pt;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./snapshots/index.cjs";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./snapshots/index.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const R=require("./relation_store-RBhpcE28.cjs"),u=require("../index.development.cjs"),a=require("./abi-D3V-QUSf.cjs"),P=require("../internal.development.cjs");function F(t){return{magic:t.getUint32(a.STORE_HEADER_OFFSETS.magic,!0),simAbiVersion:t.getUint32(a.STORE_HEADER_OFFSETS.sim_abi_version,!0),viewStamp:t.getUint32(a.STORE_HEADER_OFFSETS.view_stamp,!0),capacity:t.getUint32(a.STORE_HEADER_OFFSETS.capacity,!0),archetypeCount:t.getUint32(a.STORE_HEADER_OFFSETS.archetype_count,!0),layoutDescriptorOff:t.getUint32(a.STORE_HEADER_OFFSETS.layout_descriptor_off,!0),commandRingOff:t.getUint32(a.STORE_HEADER_OFFSETS.command_ring_off,!0),actionRingOff:t.getUint32(a.STORE_HEADER_OFFSETS.action_ring_off,!0),entityIndexOff:t.getUint32(a.STORE_HEADER_OFFSETS.entity_index_off,!0),eventRingOff:t.getUint32(a.STORE_HEADER_OFFSETS.event_ring_off,!0),regionTableOff:t.getUint32(a.STORE_HEADER_OFFSETS.region_table_off,!0),regionTableCount:t.getUint32(a.STORE_HEADER_OFFSETS.region_table_count,!0),bindingsOff:t.getUint32(a.STORE_HEADER_OFFSETS.bindings_off,!0)}}const g={u8:0,i8:1,u16:2,i16:3,u32:4,i32:5,f32:6,f64:7},B=Object.freeze({[g.u8]:1,[g.i8]:1,[g.u16]:2,[g.i16]:2,[g.u32]:4,[g.i32]:4,[g.f32]:4,[g.f64]:8});function N(t,e,n){t.setUint16(e+a.COLUMN_DESCRIPTOR_OFFSETS.component_id,n.componentId,!0),t.setUint16(e+a.COLUMN_DESCRIPTOR_OFFSETS.field_id,n.fieldId,!0),t.setUint8(e+a.COLUMN_DESCRIPTOR_OFFSETS.type_tag,n.typeTag),t.setUint32(e+a.COLUMN_DESCRIPTOR_OFFSETS.byte_off,n.byteOff,!0),t.setUint16(e+a.COLUMN_DESCRIPTOR_OFFSETS.stride,n.stride,!0)}function M(t,e){return{componentId:t.getUint16(e+a.COLUMN_DESCRIPTOR_OFFSETS.component_id,!0),fieldId:t.getUint16(e+a.COLUMN_DESCRIPTOR_OFFSETS.field_id,!0),typeTag:t.getUint8(e+a.COLUMN_DESCRIPTOR_OFFSETS.type_tag),byteOff:t.getUint32(e+a.COLUMN_DESCRIPTOR_OFFSETS.byte_off,!0),stride:t.getUint16(e+a.COLUMN_DESCRIPTOR_OFFSETS.stride,!0)}}function Y(t,e=a.ARCHETYPE_DESCRIPTOR_HEADER_BYTES){return e+t*a.COLUMN_DESCRIPTOR_BYTES}function V(t,e,n){t.setUint32(e+a.ARCHETYPE_DESCRIPTOR_OFFSETS.archetype_id,n.archetypeId,!0);for(let r=0;r<a.COMPONENT_MASK_WORDS;r++)t.setUint32(e+a.ARCHETYPE_DESCRIPTOR_OFFSETS.component_mask+r*4,n.componentMask[r]??0,!0);t.setUint32(e+a.ARCHETYPE_DESCRIPTOR_OFFSETS.row_count,n.rowCount,!0),t.setUint32(e+a.ARCHETYPE_DESCRIPTOR_OFFSETS.row_capacity,n.rowCapacity,!0),t.setUint32(e+a.ARCHETYPE_DESCRIPTOR_OFFSETS.column_count,n.columns.length,!0),t.setUint32(e+a.ARCHETYPE_DESCRIPTOR_OFFSETS.enabled_count,n.enabledCount,!0),t.setUint32(e+a.ARCHETYPE_DESCRIPTOR_OFFSETS.entity_ids_off,0,!0);let o=e+a.ARCHETYPE_DESCRIPTOR_HEADER_BYTES;for(let r=0;r<n.columns.length;r++)N(t,o,n.columns[r]),o+=a.COLUMN_DESCRIPTOR_BYTES;return o}function v(t,e,n=a.ARCHETYPE_DESCRIPTOR_HEADER_BYTES){const o=t.getUint32(e+a.ARCHETYPE_DESCRIPTOR_OFFSETS.column_count,!0),r=new Array(o);let s=e+n;for(let i=0;i<o;i++)r[i]=M(t,s),s+=a.COLUMN_DESCRIPTOR_BYTES;const c=new Array(a.COMPONENT_MASK_WORDS);for(let i=0;i<a.COMPONENT_MASK_WORDS;i++)c[i]=t.getUint32(e+a.ARCHETYPE_DESCRIPTOR_OFFSETS.component_mask+i*4,!0);return{archetypeId:t.getUint32(e+a.ARCHETYPE_DESCRIPTOR_OFFSETS.archetype_id,!0),componentMask:c,rowCount:t.getUint32(e+a.ARCHETYPE_DESCRIPTOR_OFFSETS.row_count,!0),rowCapacity:t.getUint32(e+a.ARCHETYPE_DESCRIPTOR_OFFSETS.row_capacity,!0),enabledCount:t.getUint32(e+a.ARCHETYPE_DESCRIPTOR_OFFSETS.enabled_count,!0),columns:r}}function x(t,e,n){let o=e;for(let r=0;r<n.length;r++)o=V(t,o,n[r]);return o}function C(t,e,n,o=a.ARCHETYPE_DESCRIPTOR_HEADER_BYTES){const r=new Array(n);let s=e;for(let c=0;c<n;c++){const i=v(t,s,o);r[c]=i,s+=Y(i.columns.length,o)}return r}class k extends Error{constructor(){super('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.'),this.name="SabUnavailableError"}}const G=t=>{if(typeof SharedArrayBuffer>"u")throw new k;return new SharedArrayBuffer(t)},X=16,W={capacity:4};function q(t,e){return t<<16|e}const $=2**31;class z extends Error{constructor(e){super(`SAB column layout offset ${e} reaches or exceeds the 2³¹ (${$}-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.`),this.name="StoreLayoutOverflowError"}}function j(t,e){if(t+e>$)throw new z(t);return t+(e-1)&~(e-1)}function K(t,e,n,o,r){const s=e+o;switch(n){case g.u8:return new Uint8Array(t,s,r);case g.i8:return new Int8Array(t,s,r);case g.u16:return new Uint16Array(t,s,r);case g.i16:return new Int16Array(t,s,r);case g.u32:return new Uint32Array(t,s,r);case g.i32:return new Int32Array(t,s,r);case g.f32:return new Float32Array(t,s,r);case g.f64:return new Float64Array(t,s,r)}}const U=16;function J(t){if(!Number.isInteger(t)||t<0)throw new RangeError(`createColumnStore: storeBase must be an integer >= 0, got ${t}`);if(t%U!==0)throw new RangeError(`createColumnStore: storeBase must be a multiple of ${U}, got ${t}`)}function Q(t,e,n){const o=new Map;for(let r=0;r<n.length;r++){const s=n[r],c=new Array(s.columns.length),i=new Map;for(let h=0;h<s.columns.length;h++){const E=s.columns[h],S={componentId:E.componentId,fieldId:E.fieldId,typeTag:E.typeTag,byteOff:E.byteOff,stride:E.stride,view:K(t,e,E.typeTag,E.byteOff,s.rowCapacity)};c[h]=S,i.set(q(E.componentId,E.fieldId),S)}o.set(s.archetypeId,{archetypeId:s.archetypeId,componentMask:s.componentMask,rowCapacity:s.rowCapacity,columns:i,columnsInOrder:c})}return o}function Z(t){const e=t.view.getUint32(a.STORE_HEADER_OFFSETS.capacity,!0);return new Uint8Array(t.buffer,t.storeBase,e)}const tt=Math.max(...Object.values(B));function et(t){const e=a.ARCHETYPE_DESCRIPTOR_HEADER_BYTES-a.LEGACY_ARCHETYPE_DESCRIPTOR_HEADER_BYTES;return j(t*e,tt)}function rt(t){const e=new DataView(t.buffer,t.byteOffset,t.byteLength),n=e.getUint32(a.STORE_HEADER_OFFSETS.layout_descriptor_off,!0),o=e.getUint32(a.STORE_HEADER_OFFSETS.archetype_count,!0),r=et(o);if(r===0)return t;const s=C(e,n,o,a.LEGACY_ARCHETYPE_DESCRIPTOR_HEADER_BYTES),c=new Uint8Array(t.byteLength+r);c.set(t.subarray(0,n),0),c.set(t.subarray(n),n+r);const i=new DataView(c.buffer),h=s.map(S=>({...S,columns:S.columns.map(f=>({...f,byteOff:f.byteOff+r}))}));x(i,n,h);const E=e.getUint32(a.STORE_HEADER_OFFSETS.capacity,!0);return i.setUint32(a.STORE_HEADER_OFFSETS.capacity,E+r,!0),c}function nt(t,e=G,n={}){const o=n.storeBase??0;J(o);const r=new DataView(t.buffer,t.byteOffset,t.byteLength);if(t.byteLength<a.STORE_HEADER_BYTES)throw new u.StoreRestoreError(`snapshot too small: ${t.byteLength} bytes (header alone needs ${a.STORE_HEADER_BYTES})`);const s=r.getUint32(a.STORE_HEADER_OFFSETS.magic,!0);if(s!==a.STORE_MAGIC)throw new u.StoreRestoreError(`bad magic: 0x${s.toString(16).padStart(8,"0")} (expected 0x${a.STORE_MAGIC.toString(16).padStart(8,"0")})`);const c=r.getUint32(a.STORE_HEADER_OFFSETS.sim_abi_version,!0);if(c!==a.SIM_ABI_VERSION&&c!==a.LEGACY_ABSOLUTE_ABI_VERSION)throw new u.StoreRestoreError(`incompatible sim_abi_version: snapshot=${c}, build=${a.SIM_ABI_VERSION}`);const i=r.getUint32(a.STORE_HEADER_OFFSETS.layout_descriptor_off,!0);if(i>t.byteLength)throw new u.StoreRestoreError(`layout_descriptor_off ${i} is outside the snapshot (${t.byteLength} bytes)`);let h=t;if(c===a.LEGACY_ABSOLUTE_ABI_VERSION)try{h=rt(t)}catch(_){throw _ instanceof RangeError?new u.StoreRestoreError(`snapshot layout is corrupt or truncated: a version 0 descriptor reads past the ${t.byteLength}-byte span (${_.message})`):_}const E=e(o+h.byteLength);new Uint8Array(E,o,h.byteLength).set(h);const S=new DataView(E,o);S.setUint32(a.STORE_HEADER_OFFSETS.sim_abi_version,a.SIM_ABI_VERSION,!0);const f=F(S);if(f.layoutDescriptorOff<0||f.layoutDescriptorOff>h.byteLength)throw new u.StoreRestoreError(`layout_descriptor_off ${f.layoutDescriptorOff} is outside the snapshot (${h.byteLength} bytes)`);try{const _=C(S,f.layoutDescriptorOff,f.archetypeCount),l=Q(E,o,_);return{buffer:E,view:S,header:f,storeBase:o,archetypes:l}}catch(_){throw _ instanceof RangeError?new u.StoreRestoreError(`snapshot layout is corrupt or truncated: a descriptor offset or column extent reads past the ${h.byteLength}-byte span (${_.message})`):_}}const ot=2166136261,st=16777619;function w(t,e){return t=(t^e&255)>>>0,Math.imul(t,st)>>>0}const I=12,b=4,O=8;function D(t,e){let n=ot;const o=r=>{for(let s=0;s<r.length;s++)n=w(n,r.charCodeAt(s))};for(let r=0;r<t.length;r++)o(t[r]),n=w(n,31),o(e[r]),n=w(n,30);return n>>>0}function at(t){let e=4;for(let s=0;s<t.length;s++){const c=t[s],i=c.fieldNames.length;e+=I+c.size*(b+i*O)}const n=new Uint8Array(e),o=new DataView(n.buffer);let r=0;o.setUint32(r,t.length,!0),r+=4;for(let s=0;s<t.length;s++){const c=t[s],i=c.fieldNames.length,h=c.canonicalIndices();o.setUint32(r,i,!0),r+=4,o.setUint32(r,D(c.fieldNames,c.fieldTypes),!0),r+=4,o.setUint32(r,h.length,!0),r+=4;for(let E=0;E<h.length;E++){const S=h[E];o.setUint32(r,S,!0),r+=4;const f=c.getRow(S);for(let _=0;_<i;_++)o.setFloat64(r,f[_],!0),r+=O}}return n}function it(t,e){const n=new DataView(e.buffer,e.byteOffset,e.byteLength),o=e.byteLength;let r=0;const s=i=>{if(r+i>o)throw new u.SparseRestoreError(`sparse snapshot truncated: need ${i} more bytes at offset ${r}, have ${o-r}`)};s(4);const c=n.getUint32(r,!0);if(r+=4,c!==t.length)throw new u.SparseRestoreError(`sparse store count mismatch: snapshot=${c}, registered=${t.length}`);for(let i=0;i<t.length;i++){const h=t[i];s(I);const E=n.getUint32(r,!0);r+=4;const S=n.getUint32(r,!0);r+=4;const f=n.getUint32(r,!0);if(r+=4,E!==h.fieldNames.length)throw new u.SparseRestoreError(`sparse store ${i} field-count mismatch: snapshot=${E}, registered=${h.fieldNames.length}`);const _=D(h.fieldNames,h.fieldTypes);if(S!==_)throw new u.SparseRestoreError(`sparse store ${i} schema identity mismatch: snapshot hash=${S}, registered=${_} (same field count, different field names or types, likely a registration-order divergence between the snapshot and restore worlds)`);h.clear();for(let l=0;l<f;l++){s(b+E*O);const d=n.getUint32(r,!0);if(r+=4,d>R.MAX_INDEX)throw new u.SparseRestoreError(`sparse store ${i} member ${l} entity index ${d} exceeds MAX_INDEX (${R.MAX_INDEX})`);const p=new Array(E);for(let T=0;T<E;T++)p[T]=n.getFloat64(r,!0),r+=O;h.setRawRow(d,p)}}if(r!==o)throw new u.SparseRestoreError(`sparse snapshot has ${o-r} trailing bytes after the last store (not a canonical encoding)`)}function ct(t,e){const n=new DataView(e.buffer,e.byteOffset,e.byteLength),o=e.byteLength;let r=0;const s=i=>{if(r+i>o)throw new u.SparseRestoreError(`sparse snapshot truncated: need ${i} more bytes at offset ${r}, have ${o-r}`)};s(4);const c=n.getUint32(r,!0);if(r+=4,c!==t.length)throw new u.SparseRestoreError(`sparse store count mismatch: snapshot=${c}, registered=${t.length}`);for(let i=0;i<t.length;i++){const h=t[i];s(I);const E=n.getUint32(r,!0);r+=4;const S=n.getUint32(r,!0);r+=4;const f=n.getUint32(r,!0);if(r+=4,E!==h.fieldNames.length)throw new u.SparseRestoreError(`sparse store ${i} field-count mismatch: snapshot=${E}, registered=${h.fieldNames.length}`);const _=D(h.fieldNames,h.fieldTypes);if(S!==_)throw new u.SparseRestoreError(`sparse store ${i} schema identity mismatch: snapshot hash=${S}, registered=${_} (same field count, different field names or types, likely a registration-order divergence between the snapshot and restore worlds)`);for(let l=0;l<f;l++){s(b+E*O);const d=n.getUint32(r,!0);if(r+=4,d>R.MAX_INDEX)throw new u.SparseRestoreError(`sparse store ${i} member ${l} entity index ${d} exceeds MAX_INDEX (${R.MAX_INDEX})`);r+=E*O}}if(r!==o)throw new u.SparseRestoreError(`sparse snapshot has ${o-r} trailing bytes after the last store (not a canonical encoding)`)}const m=1,A=810766935,y=4;function ht(t){const e=t.freeIndices.length,n=t.archetypeRows.length,o=y*(4+e+1+n*3),r=new Uint8Array(o),s=new DataView(r.buffer);let c=0;const i=h=>{s.setUint32(c,h,!0),c+=y};i(t.tick),i(t.entityHighWater),i(t.entityAliveCount),i(e);for(let h=0;h<e;h++)i(t.freeIndices[h]);i(n);for(let h=0;h<n;h++){const E=t.archetypeRows[h];i(E.archetypeId),i(E.length),i(E.enabledCount)}return r}function Et(t){const e=new DataView(t.buffer,t.byteOffset,t.byteLength),n=t.byteLength;let o=0;const r=l=>{if(o+l>n)throw new u.ECSRestoreError(`host-state truncated: need ${l} more bytes at offset ${o}, have ${n-o}`)},s=()=>{r(y);const l=e.getUint32(o,!0);return o+=y,l},c=s(),i=s(),h=s(),E=s(),S=new Array(E);for(let l=0;l<E;l++)S[l]=s();const f=s(),_=new Array(f);for(let l=0;l<f;l++){const d=s(),p=s(),T=s();_[l]={archetypeId:d,length:p,enabledCount:T}}if(o!==n)throw new u.ECSRestoreError(`host-state has ${n-o} trailing bytes after the last archetype (not a canonical encoding)`);return{tick:c,entityHighWater:i,entityAliveCount:h,freeIndices:S,archetypeRows:_}}function ut(t,e,n){const o=y*5,r=new Uint8Array(o+t.length+e.length+n.length),s=new DataView(r.buffer);return s.setUint32(0,A,!0),s.setUint32(4,m,!0),s.setUint32(8,t.length,!0),s.setUint32(12,e.length,!0),s.setUint32(16,n.length,!0),r.set(t,o),r.set(e,o+t.length),r.set(n,o+t.length+e.length),r}function lt(t){const e=y*5;if(t.byteLength<e)throw new u.ECSRestoreError(`world snapshot too small: ${t.byteLength} bytes (frame header needs ${e})`);const n=new DataView(t.buffer,t.byteOffset,t.byteLength),o=n.getUint32(0,!0);if(o!==A)throw new u.ECSRestoreError(`bad world-snapshot magic: 0x${o.toString(16).padStart(8,"0")} (expected 0x${A.toString(16).padStart(8,"0")}). A bare dense (SAB) snapshot is not a combined world snapshot, pass the bytes from ECS.snapshot(), not columnStoreBytesView().`);const r=n.getUint32(4,!0);if(r!==m)throw new u.ECSRestoreError(`incompatible world-snapshot version: snapshot=${r}, build=${m}`);const s=n.getUint32(8,!0),c=n.getUint32(12,!0),i=n.getUint32(16,!0);if(e+s+c+i!==t.byteLength)throw new u.ECSRestoreError(`world-snapshot frame mismatch: header declares ${e}+${s}+${c}+${i}=${e+s+c+i} bytes, buffer is ${t.byteLength}`);const h=t.byteOffset,E=t.buffer;return{dense:new Uint8Array(E,h+e,s),sparse:new Uint8Array(E,h+e+s,c),host:new Uint8Array(E,h+e+s+c,i)}}function St(t,e,n){if(t.byteLength<a.STORE_HEADER_BYTES)throw new u.ECSRestoreError(`dense section too small: ${t.byteLength} bytes (SAB header needs ${a.STORE_HEADER_BYTES})`);const o=new DataView(t.buffer,t.byteOffset,t.byteLength),r=o.getUint32(a.STORE_HEADER_OFFSETS.magic,!0);if(r!==a.STORE_MAGIC)throw new u.ECSRestoreError(`dense section bad magic: 0x${r.toString(16).padStart(8,"0")} (expected SAB magic 0x${a.STORE_MAGIC.toString(16).padStart(8,"0")})`);const s=o.getUint32(a.STORE_HEADER_OFFSETS.sim_abi_version,!0);if(s!==a.SIM_ABI_VERSION&&s!==a.LEGACY_ABSOLUTE_ABI_VERSION)throw new u.ECSRestoreError(`dense section incompatible sim_abi_version: snapshot=${s}, build=${a.SIM_ABI_VERSION}`);const c=F(o);if(c.layoutDescriptorOff<0||c.layoutDescriptorOff>t.byteLength)throw new u.ECSRestoreError(`dense layoutDescriptorOff ${c.layoutDescriptorOff} is outside the section (${t.byteLength} bytes)`);const i=c.entityIndexOff;if(i<0||i+X>t.byteLength)throw new u.ECSRestoreError(`dense entityIndexOff ${i} is outside the section (${t.byteLength} bytes)`);const h=o.getUint32(i+W.capacity,!0);if(h!==n)throw new u.ECSRestoreError(`entity-index capacity mismatch: live=${n}, snapshot=${h}`);let E;try{E=C(o,c.layoutDescriptorOff,c.archetypeCount,s===a.LEGACY_ABSOLUTE_ABI_VERSION?a.LEGACY_ARCHETYPE_DESCRIPTOR_HEADER_BYTES:a.ARCHETYPE_DESCRIPTOR_HEADER_BYTES)}catch(S){throw S instanceof RangeError?new u.ECSRestoreError(`dense section layout is corrupt or truncated: a descriptor reads past the ${t.byteLength}-byte section (${S.message})`):S}if(e.size!==E.length)throw new u.ECSRestoreError(`archetype-set mismatch: the live world has ${e.size} SAB archetypes, the snapshot has ${E.length}. restore requires an identical archetype set. Prewarm the world so its archetype set is stable.`);for(let S=0;S<E.length;S++){const f=E[S],_=e.get(f.archetypeId);if(_===void 0)throw new u.ECSRestoreError(`archetype-set mismatch: snapshot archetype ${f.archetypeId} is absent from the live world`);if(!ft(_.componentMask,f.componentMask))throw new u.ECSRestoreError(`archetype ${f.archetypeId} component-mask mismatch between the live world and the snapshot (different component registration)`);const l=_.columnsInOrder,d=f.columns;if(l.length!==d.length)throw new u.ECSRestoreError(`archetype ${f.archetypeId} column-count mismatch: live=${l.length}, snapshot=${d.length}`);for(let p=0;p<l.length;p++)if(l[p].componentId!==d[p].componentId||l[p].fieldId!==d[p].fieldId||l[p].typeTag!==d[p].typeTag)throw new u.ECSRestoreError(`archetype ${f.archetypeId} column ${p} layout mismatch: live=(c${l[p].componentId},f${l[p].fieldId},t${l[p].typeTag}), snapshot=(c${d[p].componentId},f${d[p].fieldId},t${d[p].typeTag})`)}}function ft(t,e){if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;return!0}class _t{_host;_allocator;constructor(e,n){this._host=e,this._allocator=n}snapshotSparse(){const e=at(this._host.sparseStores()),n=R.snapshotRelations(this._host.relationStores()),o=new Uint8Array(8+e.length+n.length),r=new DataView(o.buffer);return r.setUint32(0,e.length,!0),r.setUint32(4,n.length,!0),o.set(e,8),o.set(n,8+e.length),o}restoreSparse(e){const n=new DataView(e.buffer,e.byteOffset,e.byteLength);if(e.byteLength<8)throw new u.SparseRestoreError(`sparse snapshot truncated: need 8 header bytes, have ${e.byteLength}`);const o=n.getUint32(0,!0),r=n.getUint32(4,!0);if(8+o+r!==e.byteLength)throw new u.SparseRestoreError(`sparse snapshot frame mismatch: header declares 8+${o}+${r}=${8+o+r} bytes, buffer is ${e.byteLength}`);it(this._host.sparseStores(),e.subarray(8,8+o)),this._rebuildRelationIndices(e.subarray(8+o,8+o+r))}_rebuildRelationIndices(e){const n=this._host.generations(),o=s=>R.createEntityId(s,n[s]),r=this._host.relationStores();R.restoreRelations(r,e,o);for(let s=0;s<r.length;s++)r[s].rebuildReverse(o)}snapshot(){this._host.publishRowCounts();const e=new Uint8Array(Z(this._host.columnStore())),n=this.snapshotSparse(),o=ht(this._collectHostState());return ut(e,n,o)}_collectHostState(){const e=[],n=this._host.archetypes();for(let o=0;o<n.length;o++){const r=n[o];r.isBufferBacked&&e.push({archetypeId:r.id,length:r.length,enabledCount:r.enabledCount})}return{tick:this._host.tick(),entityHighWater:this._allocator.highWater,entityAliveCount:this._allocator.aliveCount,freeIndices:this._allocator.snapshotFreeIndices(),archetypeRows:e}}restore(e){const n=lt(e),o=Et(n.host);St(n.dense,this._host.columnStore().archetypes,this._host.entityIndexCapacity()),this._assertSparseMatchesLive(n.sparse);const r=nt(n.dense,this._host.bufferAllocator(),{storeBase:this._host.columnStore().storeBase});this._host.mountRestoredDense(r),this._host.reconstructHostRows(o),this._allocator.restoreHostState(o.freeIndices,o.entityAliveCount),this._host.setTick(o.tick),this._host.invalidateCaches(),this.restoreSparse(n.sparse)}_assertSparseMatchesLive(e){const n=new DataView(e.buffer,e.byteOffset,e.byteLength);if(e.byteLength<8)throw new u.SparseRestoreError(`sparse snapshot truncated: need 8 header bytes, have ${e.byteLength}`);const o=n.getUint32(0,!0),r=n.getUint32(4,!0);if(8+o+r!==e.byteLength)throw new u.SparseRestoreError(`sparse snapshot frame mismatch: header declares 8+${o}+${r}=${8+o+r} bytes, buffer is ${e.byteLength}`);ct(this._host.sparseStores(),e.subarray(8,8+o))}}class L{_store;constructor(e){this._store=e}get deterministic(){return this._store.deterministic}stateHash(){return this._store.stateHash()}}for(const t of["capture","restore","captureSparse","restoreSparse"])L.prototype[t]=function(){throw P.pluginMissingError("snapshots",`ecs.snapshots.${t}`)};class H extends L{capture(){return this._store.snapshot()}restore(e){this._store.restore(e)}captureSparse(){return this._store.snapshotSparse()}restoreSparse(e){this._store.restoreSparse(e)}}function pt(){return{name:"snapshots",install(t){const e=t.store;return e.installSnapshots(new _t(e.snapshotHost(),e.entityAllocator)),{snapshots:new H(e)}}}}exports.ECSSnapshotsFull=H;exports.snapshots=pt;
|