@oasys/oecs 0.5.2 → 0.5.4
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 +208 -14
- package/README.md +198 -145
- package/dist/core/ecs/access_check.d.cts +3 -3
- package/dist/core/ecs/access_check.d.ts +3 -3
- package/dist/core/ecs/archetype.d.cts +103 -43
- package/dist/core/ecs/archetype.d.ts +103 -43
- package/dist/core/ecs/archetype.d.ts.map +1 -1
- package/dist/core/ecs/archetype_graph.d.cts +8 -8
- package/dist/core/ecs/archetype_graph.d.ts +8 -8
- package/dist/core/ecs/archetype_graph.d.ts.map +1 -1
- package/dist/core/ecs/builtin_relations.d.cts +1 -1
- package/dist/core/ecs/builtin_relations.d.ts +1 -1
- package/dist/core/ecs/command_log.d.cts +4 -4
- package/dist/core/ecs/command_log.d.ts +4 -4
- package/dist/core/ecs/command_log.d.ts.map +1 -1
- package/dist/core/ecs/component.d.cts +4 -4
- package/dist/core/ecs/component.d.ts +4 -4
- package/dist/core/ecs/deferred_commands.d.cts +1 -1
- package/dist/core/ecs/deferred_commands.d.ts +1 -1
- package/dist/core/ecs/deferred_commands.d.ts.map +1 -1
- package/dist/core/ecs/ecs.d.cts +85 -43
- package/dist/core/ecs/ecs.d.ts +85 -43
- package/dist/core/ecs/ecs.d.ts.map +1 -1
- package/dist/core/ecs/ecs_memory.d.cts +15 -15
- package/dist/core/ecs/ecs_memory.d.ts +15 -15
- package/dist/core/ecs/ecs_memory.d.ts.map +1 -1
- package/dist/core/ecs/entity_allocator.d.cts +6 -6
- package/dist/core/ecs/entity_allocator.d.ts +6 -6
- package/dist/core/ecs/entity_allocator.d.ts.map +1 -1
- package/dist/core/ecs/event.d.cts +2 -2
- package/dist/core/ecs/event.d.ts +2 -2
- package/dist/core/ecs/event_registry.d.cts +1 -1
- package/dist/core/ecs/event_registry.d.ts +1 -1
- package/dist/core/ecs/event_registry.d.ts.map +1 -1
- package/dist/core/ecs/facades.d.cts +15 -15
- package/dist/core/ecs/facades.d.ts +15 -15
- package/dist/core/ecs/facades.d.ts.map +1 -1
- package/dist/core/ecs/frame_trace.d.cts +2 -2
- package/dist/core/ecs/frame_trace.d.ts +2 -2
- package/dist/core/ecs/host_commands.d.cts +12 -12
- package/dist/core/ecs/host_commands.d.ts +12 -12
- package/dist/core/ecs/host_commands.d.ts.map +1 -1
- package/dist/core/ecs/index.d.cts +1 -1
- package/dist/core/ecs/index.d.ts +1 -1
- package/dist/core/ecs/index.d.ts.map +1 -1
- package/dist/core/ecs/observer.d.cts +9 -9
- package/dist/core/ecs/observer.d.ts +9 -9
- package/dist/core/ecs/observer.d.ts.map +1 -1
- package/dist/core/ecs/query.d.cts +91 -70
- package/dist/core/ecs/query.d.ts +91 -70
- package/dist/core/ecs/query.d.ts.map +1 -1
- package/dist/core/ecs/ref.d.cts +53 -1
- package/dist/core/ecs/ref.d.ts +53 -1
- package/dist/core/ecs/ref.d.ts.map +1 -1
- package/dist/core/ecs/relation.d.cts +15 -15
- package/dist/core/ecs/relation.d.ts +15 -15
- package/dist/core/ecs/relation.d.ts.map +1 -1
- package/dist/core/ecs/relation_service.d.cts +14 -14
- package/dist/core/ecs/relation_service.d.ts +14 -14
- package/dist/core/ecs/relation_service.d.ts.map +1 -1
- package/dist/core/ecs/resource.d.cts +1 -1
- package/dist/core/ecs/resource.d.ts +1 -1
- package/dist/core/ecs/resource_registry.d.cts +2 -2
- package/dist/core/ecs/resource_registry.d.ts +2 -2
- package/dist/core/ecs/resume.d.cts +3 -3
- package/dist/core/ecs/resume.d.ts +3 -3
- package/dist/core/ecs/resume.d.ts.map +1 -1
- package/dist/core/ecs/schedule.d.cts +22 -9
- package/dist/core/ecs/schedule.d.ts +22 -9
- package/dist/core/ecs/schedule.d.ts.map +1 -1
- package/dist/core/ecs/snapshot_service.d.cts +3 -3
- package/dist/core/ecs/snapshot_service.d.ts +3 -3
- package/dist/core/ecs/sparse_store.d.cts +6 -6
- package/dist/core/ecs/sparse_store.d.ts +6 -6
- package/dist/core/ecs/sparse_store.d.ts.map +1 -1
- package/dist/core/ecs/store.d.cts +189 -110
- package/dist/core/ecs/store.d.ts +189 -110
- package/dist/core/ecs/store.d.ts.map +1 -1
- package/dist/core/ecs/store_layout_listener.d.cts +2 -2
- package/dist/core/ecs/store_layout_listener.d.ts +2 -2
- package/dist/core/ecs/system.d.cts +8 -8
- package/dist/core/ecs/system.d.ts +8 -8
- package/dist/core/ecs/system.d.ts.map +1 -1
- package/dist/core/ecs/utils/error.d.cts +7 -0
- package/dist/core/ecs/utils/error.d.ts +7 -0
- package/dist/core/ecs/utils/error.d.ts.map +1 -1
- package/dist/core/store/action_ring.d.cts +7 -8
- package/dist/core/store/action_ring.d.ts +7 -8
- package/dist/core/store/action_ring.d.ts.map +1 -1
- package/dist/core/store/allocator.d.cts +58 -35
- package/dist/core/store/allocator.d.ts +58 -35
- package/dist/core/store/allocator.d.ts.map +1 -1
- package/dist/core/store/buffer_backed_column.d.cts +5 -6
- package/dist/core/store/buffer_backed_column.d.ts +5 -6
- package/dist/core/store/buffer_backed_column.d.ts.map +1 -1
- package/dist/core/store/column_store.d.cts +23 -23
- package/dist/core/store/column_store.d.ts +23 -23
- package/dist/core/store/column_store.d.ts.map +1 -1
- package/dist/core/store/command_dispatch.d.cts +1 -1
- package/dist/core/store/command_dispatch.d.ts +1 -1
- package/dist/core/store/command_ring.d.cts +6 -7
- package/dist/core/store/command_ring.d.ts +6 -7
- package/dist/core/store/command_ring.d.ts.map +1 -1
- package/dist/core/store/descriptor.d.cts +2 -2
- package/dist/core/store/descriptor.d.ts +2 -2
- package/dist/core/store/entity_index.d.cts +3 -3
- package/dist/core/store/entity_index.d.ts +3 -3
- package/dist/core/store/event_ring.d.cts +7 -7
- package/dist/core/store/event_ring.d.ts +7 -7
- package/dist/core/store/extend.d.cts +2 -2
- package/dist/core/store/extend.d.ts +2 -2
- package/dist/core/store/extend.d.ts.map +1 -1
- package/dist/core/store/grow.d.cts +1 -1
- package/dist/core/store/grow.d.ts +1 -1
- package/dist/core/store/grow.d.ts.map +1 -1
- package/dist/core/store/header.d.cts +9 -9
- package/dist/core/store/header.d.ts +9 -9
- package/dist/core/store/header.d.ts.map +1 -1
- package/dist/core/store/layout_ops.d.cts +25 -7
- package/dist/core/store/layout_ops.d.ts +25 -7
- package/dist/core/store/layout_ops.d.ts.map +1 -1
- package/dist/core/store/state_hash.d.cts +3 -3
- package/dist/core/store/state_hash.d.ts +3 -3
- package/dist/extensions/editor/editor.d.cts +4 -4
- package/dist/extensions/editor/editor.d.ts +4 -4
- package/dist/extensions/editor/editor.d.ts.map +1 -1
- package/dist/extensions/editor/field_handle.d.cts +1 -1
- package/dist/extensions/editor/field_handle.d.ts +1 -1
- package/dist/extensions/editor/index.d.cts +2 -2
- package/dist/extensions/editor/index.d.ts +2 -2
- package/dist/extensions/editor/index.development.js +4 -4
- package/dist/extensions/editor/index.js +4 -4
- package/dist/extensions/reactive/ecs_sync.d.cts +4 -4
- package/dist/extensions/reactive/ecs_sync.d.ts +4 -4
- package/dist/extensions/reactive/index.d.cts +4 -4
- package/dist/extensions/reactive/index.d.ts +4 -4
- package/dist/extensions/reactive/index.development.js +3 -3
- package/dist/extensions/reactive/index.js +3 -3
- package/dist/extensions/solid/index.d.cts +1 -1
- package/dist/extensions/solid/index.d.ts +1 -1
- package/dist/extensions/solid/index.development.js +1 -1
- package/dist/extensions/solid/index.js +1 -1
- package/dist/extensions/solid/kernel_solid.d.cts +1 -1
- package/dist/extensions/solid/kernel_solid.d.ts +1 -1
- package/dist/extensions/solid/kernel_solid.d.ts.map +1 -1
- package/dist/{host_commands-BI8pEmjH.js → host_commands-BlR3oZ3x.js} +473 -393
- package/dist/host_commands-C2cpU3yC.cjs +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.development.cjs +1 -1
- package/dist/index.development.js +3345 -2963
- package/dist/index.js +1496 -1131
- package/dist/{internal-BMDgWZbt.js → internal-BoxWl4dG.js} +410 -330
- package/dist/internal-CGBEwfeB.cjs +2 -0
- package/dist/internal.cjs +1 -1
- package/dist/internal.development.cjs +1 -1
- package/dist/internal.development.js +1 -1
- package/dist/internal.js +1 -1
- package/dist/primitives.development.js +1 -1
- package/dist/primitives.js +1 -1
- package/dist/reactive/index.d.cts +2 -2
- package/dist/reactive/index.d.ts +2 -2
- package/dist/reactive/index.development.js +1 -1
- package/dist/reactive/index.js +1 -1
- package/dist/reactive/kernel.d.cts +5 -5
- package/dist/reactive/kernel.d.ts +5 -5
- package/dist/reactive/shallow.d.cts +1 -1
- package/dist/reactive/shallow.d.ts +1 -1
- package/dist/{shallow-DfnAm9vG.js → shallow-Bs39EPh1.js} +1 -1
- package/dist/{shallow-9S1pY_Iw.js → shallow-CiFC70Dz.js} +1 -1
- package/dist/{shared-BU1Cd40h.js → shared-B4v0L1cw.js} +41 -35
- package/dist/shared-DU78k0pU.cjs +1 -0
- package/dist/shared.cjs +1 -1
- package/dist/shared.d.cts +1 -1
- package/dist/shared.d.ts +1 -1
- package/dist/shared.development.cjs +1 -1
- package/dist/shared.development.js +1 -1
- package/dist/shared.js +1 -1
- package/dist/type_primitives/typed_arrays/typed_arrays.d.cts +2 -2
- package/dist/type_primitives/typed_arrays/typed_arrays.d.ts +2 -2
- package/dist/{typed_arrays-BcXcnzB4.js → typed_arrays-DIVwVy5_.js} +1 -1
- package/dist/version.d.cts +2 -2
- package/dist/version.d.ts +2 -2
- package/package.json +1 -1
- package/dist/host_commands-CxhpzMx9.cjs +0 -1
- package/dist/internal-LiTSB_tG.cjs +0 -2
- package/dist/shared-BymrGTyR.cjs +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";const P=require("./shared-DU78k0pU.cjs"),We=require("./topological_sort-BDvEyb9W.cjs");class ze extends Error{constructor(e,n,r){super(e),this.isOperational=n,this.context=r,this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor)}}var Se=(t=>(t.ASSERTION_FAIL_CONDITION="ASSERTION_FAIL_CONDITION",t.VALIDATION_FAIL_CONDITION="VALIDATION_FAIL_CONDITION",t.ASSERTION_FAIL_NON_NULLABLE="ASSERTION_FAIL_NON_NULLABLE",t.ASSERTION_FAIL_UNREACHABLE="ASSERTION_FAIL_UNREACHABLE",t))(Se||{});class qe extends ze{constructor(e,n,r){super(n,!1,r),this.category=e}}const Et=t=>Number.isInteger(t)&&t>=0;function mt(t,e,n){if(!e(t))throw new qe(Se.VALIDATION_FAIL_CONDITION,`Expected value to meet validation: ${n}`);return t}function gt(t){return t}function pt(t,e){throw new qe(Se.ASSERTION_FAIL_UNREACHABLE,`Unhandled ${e}: ${String(t)}`)}var T=(t=>(t.EID_MAX_INDEX_OVERFLOW="EID_MAX_INDEX_OVERFLOW",t.EID_MAX_GEN_OVERFLOW="EID_MAX_GEN_OVERFLOW",t.COMPONENT_NOT_REGISTERED="COMPONENT_NOT_REGISTERED",t.COMPONENT_LIMIT_EXCEEDED="COMPONENT_LIMIT_EXCEEDED",t.ENTITY_NOT_ALIVE="ENTITY_NOT_ALIVE",t.CIRCULAR_SYSTEM_DEPENDENCY="CIRCULAR_SYSTEM_DEPENDENCY",t.DUPLICATE_SYSTEM="DUPLICATE_SYSTEM",t.ARCHETYPE_NOT_FOUND="ARCHETYPE_NOT_FOUND",t.RESOURCE_NOT_REGISTERED="RESOURCE_NOT_REGISTERED",t.RESOURCE_ALREADY_REGISTERED="RESOURCE_ALREADY_REGISTERED",t.EVENT_ALREADY_REGISTERED="EVENT_ALREADY_REGISTERED",t.EVENT_NOT_REGISTERED="EVENT_NOT_REGISTERED",t.FIELD_NOT_REGISTERED="FIELD_NOT_REGISTERED",t.RELATION_NOT_REGISTERED="RELATION_NOT_REGISTERED",t.RELATION_MODE_INVALID="RELATION_MODE_INVALID",t.RELATION_MODE_MISMATCH="RELATION_MODE_MISMATCH",t.RELATION_CYCLE="RELATION_CYCLE",t.SPARSE_CACHE_KEY_OVERFLOW="SPARSE_CACHE_KEY_OVERFLOW",t.SPARSE_QUERY_DENSE_PATH="SPARSE_QUERY_DENSE_PATH",t.HIERARCHY_ALREADY_SET="HIERARCHY_ALREADY_SET",t.HIERARCHY_INVALID_MAX_DEPTH="HIERARCHY_INVALID_MAX_DEPTH",t.OBSERVER_NON_CONVERGENT="OBSERVER_NON_CONVERGENT",t.OBSERVER_INVALID_CONFIG="OBSERVER_INVALID_CONFIG",t.OBSERVER_ONSET_EMIT="OBSERVER_ONSET_EMIT",t.INVALID_FIXED_TIMESTEP="INVALID_FIXED_TIMESTEP",t.INVALID_MAX_FIXED_STEPS="INVALID_MAX_FIXED_STEPS",t.INVALID_RECORDER_SCHEDULE="INVALID_RECORDER_SCHEDULE",t.EMPTY_ARCHETYPE_MATERIALIZE="EMPTY_ARCHETYPE_MATERIALIZE",t.COMPONENT_INDEX_INVARIANT="COMPONENT_INDEX_INVARIANT",t.ARCHETYPE_ROW_INVARIANT="ARCHETYPE_ROW_INVARIANT",t.OPTIONAL_TERM_NOT_DECLARED="OPTIONAL_TERM_NOT_DECLARED",t.QUERY_ACCESS_UNDECLARED="QUERY_ACCESS_UNDECLARED",t.ACCESS_UNDECLARED="ACCESS_UNDECLARED",t.QUERY_NOT_SINGLETON="QUERY_NOT_SINGLETON",t.INVALID_RUN_CONDITION="INVALID_RUN_CONDITION",t.SYSTEM_FN_ARITY="SYSTEM_FN_ARITY",t.PARTITION_APPEND_NEEDS_ENTITY_ROW="PARTITION_APPEND_NEEDS_ENTITY_ROW",t.PARTITION_BULK_INTO_DISABLED="PARTITION_BULK_INTO_DISABLED",t.ENTITY_NOT_DISABLED="ENTITY_NOT_DISABLED",t.STRUCTURAL_DURING_ITERATION="STRUCTURAL_DURING_ITERATION",t.BACKEND_ALREADY_ATTACHED="BACKEND_ALREADY_ATTACHED",t.DETERMINISM_DISABLED="DETERMINISM_DISABLED",t.NON_DETERMINISTIC_COLUMN_TYPE="NON_DETERMINISTIC_COLUMN_TYPE",t.INVALID_MEMORY_OPTIONS="INVALID_MEMORY_OPTIONS",t.STORE_CAP_EXCEEDED="STORE_CAP_EXCEEDED",t.REGION_NOT_DECLARED="REGION_NOT_DECLARED",t.COMMAND_LOG_TAG_COLLISION="COMMAND_LOG_TAG_COLLISION",t.INVALID_FRAME_STEP="INVALID_FRAME_STEP",t))(T||{});class A extends ze{constructor(e,n,r){super(n??e,!0,r),this.category=e}}function Tt(t){return t instanceof A}const At=-1,yt=-1,It=Object.freeze(Object.create(null)),St=2654435769,Rt=1367130551,F=1024,Nt=0,wt=31,Dt=1/60,Ot=4,Ct=0,W=20,Re=(1<<W)-1,U=Re,bt=wt-W,J=(1<<bt)-1,vt=J,Lt=J-1,ge=J<<W|U,Ut=(t,e)=>{{if(t<0||t>U)throw new A(T.EID_MAX_INDEX_OVERFLOW);if(e<0||e>J)throw new A(T.EID_MAX_GEN_OVERFLOW)}return e<<W|t},L=t=>t&Re,pe=t=>t>>W,Mt=(t,e,n)=>new A(T.ENTITY_NOT_ALIVE,`${t}: entity ${e} (index ${L(e)}, generation ${pe(e)}) is not alive${n?` — ${n}`:""} (destroyed, never created, or a stale handle; guard with isAlive() first)`,{entity:e,index:L(e),generation:pe(e),op:t}),Ne=new WeakMap;function Pt(t,e){Ne.set(t,e)}function $t(t){return Ne.get(t)}function Ke(t){const e=Ne.get(t);return e!==void 0?`'${e}' (component ${t.id})`:`component ${t.id}`}const je=827148627,Qe=0,Q=4,Ze=52,E={magic:0,sim_abi_version:4,view_stamp:8,capacity:12,archetype_count:16,layout_descriptor_off:20,command_ring_off:24,action_ring_off:28,entity_index_off:32,event_ring_off:36,region_table_off:40,region_table_count:44,bindings_off:48},ee=12,$={region_id:0,byte_offset:4,byte_length:8},ce=16,O={component_id:0,field_id:2,type_tag:4,byte_off:8,stride:12},le=36,N={archetype_id:0,component_mask:4,row_count:20,row_capacity:24,column_count:28,enabled_count:32};function Bt(t,e){t.setUint32(E.magic,e.magic,!0),t.setUint32(E.sim_abi_version,e.simAbiVersion,!0),t.setUint32(E.view_stamp,e.viewStamp,!0),t.setUint32(E.capacity,e.capacity,!0),t.setUint32(E.archetype_count,e.archetypeCount,!0),t.setUint32(E.layout_descriptor_off,e.layoutDescriptorOff,!0),t.setUint32(E.command_ring_off,e.commandRingOff,!0),t.setUint32(E.action_ring_off,e.actionRingOff,!0),t.setUint32(E.entity_index_off,e.entityIndexOff,!0),t.setUint32(E.event_ring_off,e.eventRingOff,!0),t.setUint32(E.region_table_off,e.regionTableOff,!0),t.setUint32(E.region_table_count,e.regionTableCount,!0),t.setUint32(E.bindings_off,e.bindingsOff,!0)}function Ft(t){return{magic:t.getUint32(E.magic,!0),simAbiVersion:t.getUint32(E.sim_abi_version,!0),viewStamp:t.getUint32(E.view_stamp,!0),capacity:t.getUint32(E.capacity,!0),archetypeCount:t.getUint32(E.archetype_count,!0),layoutDescriptorOff:t.getUint32(E.layout_descriptor_off,!0),commandRingOff:t.getUint32(E.command_ring_off,!0),actionRingOff:t.getUint32(E.action_ring_off,!0),entityIndexOff:t.getUint32(E.entity_index_off,!0),eventRingOff:t.getUint32(E.event_ring_off,!0),regionTableOff:t.getUint32(E.region_table_off,!0),regionTableCount:t.getUint32(E.region_table_count,!0),bindingsOff:t.getUint32(E.bindings_off,!0)}}const g={u8:0,i8:1,u16:2,i16:3,u32:4,i32:5,f32:6,f64:7},Te=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}),xt={u8:g.u8,i8:g.i8,u16:g.u16,i16:g.i16,u32:g.u32,i32:g.i32,f32:g.f32,f64:g.f64};function Yt(t,e,n){t.setUint16(e+O.component_id,n.componentId,!0),t.setUint16(e+O.field_id,n.fieldId,!0),t.setUint8(e+O.type_tag,n.typeTag),t.setUint32(e+O.byte_off,n.byteOff,!0),t.setUint16(e+O.stride,n.stride,!0)}function kt(t,e){return{componentId:t.getUint16(e+O.component_id,!0),fieldId:t.getUint16(e+O.field_id,!0),typeTag:t.getUint8(e+O.type_tag),byteOff:t.getUint32(e+O.byte_off,!0),stride:t.getUint16(e+O.stride,!0)}}const Ht=Q*32;function we(t){return le+t*ce}function Je(t,e,n){t.setUint32(e+N.archetype_id,n.archetypeId,!0);for(let s=0;s<Q;s++)t.setUint32(e+N.component_mask+s*4,n.componentMask[s]??0,!0);t.setUint32(e+N.row_count,n.rowCount,!0),t.setUint32(e+N.row_capacity,n.rowCapacity,!0),t.setUint32(e+N.column_count,n.columns.length,!0),t.setUint32(e+N.enabled_count,n.enabledCount,!0);let r=e+le;for(let s=0;s<n.columns.length;s++)Yt(t,r,n.columns[s]),r+=ce;return r}function Gt(t,e){const n=t.getUint32(e+N.column_count,!0),r=new Array(n);let s=e+le;for(let i=0;i<n;i++)r[i]=kt(t,s),s+=ce;const o=new Array(Q);for(let i=0;i<Q;i++)o[i]=t.getUint32(e+N.component_mask+i*4,!0);return{archetypeId:t.getUint32(e+N.archetype_id,!0),componentMask:o,rowCount:t.getUint32(e+N.row_count,!0),rowCapacity:t.getUint32(e+N.row_capacity,!0),enabledCount:t.getUint32(e+N.enabled_count,!0),columns:r}}function Vt(t,e,n){let r=e;for(let s=0;s<n.length;s++)r=Je(t,r,n[s]);return r}function Xt(t,e,n){const r=new Array(n);let s=e;for(let o=0;o<n;o++){const i=Gt(t,s);r[o]=i,s+=we(i.columns.length)}return r}function Wt(t){let e=0;for(let n=0;n<t.length;n++)e+=we(t[n].columns.length);return e}const et=16,x=16,zt=256,C={write_head:0,read_head:4,capacity_slots:8,overflow_flag:12},De=0;function $e(t){return et+t*x}function qt(t){return t>0&&(t&t-1)===0}class M extends Error{constructor(e){super(e),this.name="CommandRingError"}}function Kt(t,e,n){if(!qt(n))throw new M(`command ring capacity_slots must be a positive power of two (got ${n})`);t.setUint32(e+C.write_head,0,!0),t.setUint32(e+C.read_head,0,!0),t.setUint32(e+C.capacity_slots,n,!0),t.setUint32(e+C.overflow_flag,0,!0)}function jt(t,e){return t.getUint32(e+C.write_head,!0)}function Qt(t,e){return t.getUint32(e+C.read_head,!0)}function Zt(t,e){return t.getUint32(e+C.capacity_slots,!0)}function Jt(t,e,n){if(n.byteLength!==x-1)throw new M(`outPayload must be ${x-1} bytes (got ${n.byteLength})`);const r=jt(t,e),s=Qt(t,e);if(r===s)return De;const o=Zt(t,e),i=s&o-1,a=e+et+i*x,c=t.getUint8(a),l=new Uint8Array(t.buffer,a+1,x-1);return n.set(l),t.setUint32(e+C.read_head,s+1>>>0,!0),c}function en(t,e,n){let r=0;const s=new Uint8Array(x-1);for(;;){const o=Jt(t,e,s);if(o===De)return r;n(o,s.slice()),r++}}const te=16,w=12,Z={length:0,capacity:4},v=1<<20;function Be(t){if(t<0||!Number.isInteger(t))throw new tt(`entity index capacity must be a non-negative integer (got ${t})`);return te+t*w}function tn(t){return t+te}function nn(t,e){return t+te+e*4}function sn(t,e){return t+te+e*8}class tt extends Error{constructor(e){super(e),this.name="EntityIndexError"}}function rn(t,e,n){if(n<0||!Number.isInteger(n))throw new tt(`entity index capacity must be a non-negative integer (got ${n})`);t.setUint32(e+Z.length,0,!0),t.setUint32(e+Z.capacity,n,!0)}function on(t,e,n){return{generations:new Int32Array(t,tn(e),n),archetypes:new Int32Array(t,nn(e,n),n),rows:new Int32Array(t,sn(e,n),n)}}const an=16,cn=16,ln=256,G={write_head:0,read_head:4,capacity_slots:8,overflow_flag:12};function Fe(t){return an+t*cn}function dn(t){return t>0&&(t&t-1)===0}class un extends Error{constructor(e){super(e),this.name="EventRingError"}}function fn(t,e,n){if(!dn(n))throw new un(`event ring capacity_slots must be a positive power of two (got ${n})`);t.setUint32(e+G.write_head,0,!0),t.setUint32(e+G.read_head,0,!0),t.setUint32(e+G.capacity_slots,n,!0),t.setUint32(e+G.overflow_flag,0,!0)}const _n=16,hn=16,En=256,V={write_head:0,read_head:4,capacity_slots:8,overflow_flag:12},mn=V.write_head/4,gn=V.read_head/4,pn=V.capacity_slots/4,Tn=V.overflow_flag/4;function An(t,e){return new Int32Array(t.buffer,t.byteOffset+e,4)}function xe(t){return _n+t*hn}function yn(t){return t>0&&(t&t-1)===0}class Ye extends Error{constructor(e){super(e),this.name="ActionRingError"}}function In(t,e,n){if(!yn(n))throw new Ye(`action ring capacity_slots must be a positive power of two (got ${n})`);if((t.byteOffset+e)%4!==0)throw new Ye(`action ring header must be 4-byte aligned for Atomics (view.byteOffset ${t.byteOffset} + ringOff ${e} is not a multiple of 4)`);const r=An(t,e);Atomics.store(r,mn,0),Atomics.store(r,gn,0),Atomics.store(r,pn,n),Atomics.store(r,Tn,0)}const q=[{name:"command_ring",headerOff:"command_ring_off",sizeFromOptions:t=>t.commandRingCapacitySlots!==void 0?$e(t.commandRingCapacitySlots):0,init:(t,e,n)=>Kt(t,e,n.commandRingCapacitySlots),regionBytes:(t,e)=>$e(t.getUint32(e+C.capacity_slots,!0)),readOptions:(t,e,n)=>{n.commandRingCapacitySlots=t.getUint32(e+C.capacity_slots,!0)}},{name:"entity_index",headerOff:"entity_index_off",sizeFromOptions:t=>t.entityIndexCapacity!==void 0?Be(t.entityIndexCapacity):0,init:(t,e,n)=>rn(t,e,n.entityIndexCapacity),regionBytes:(t,e)=>Be(t.getUint32(e+Z.capacity,!0)),readOptions:(t,e,n)=>{n.entityIndexCapacity=t.getUint32(e+Z.capacity,!0)}},{name:"event_ring",headerOff:"event_ring_off",sizeFromOptions:t=>t.eventRingCapacitySlots!==void 0?Fe(t.eventRingCapacitySlots):0,init:(t,e,n)=>fn(t,e,n.eventRingCapacitySlots),regionBytes:(t,e)=>Fe(t.getUint32(e+G.capacity_slots,!0)),readOptions:(t,e,n)=>{n.eventRingCapacitySlots=t.getUint32(e+G.capacity_slots,!0)}},{name:"action_ring",headerOff:"action_ring_off",sizeFromOptions:t=>t.actionRingCapacitySlots!==void 0?xe(t.actionRingCapacitySlots):0,init:(t,e,n)=>In(t,e,n.actionRingCapacitySlots),regionBytes:(t,e)=>xe(t.getUint32(e+V.capacity_slots,!0)),readOptions:(t,e,n)=>{n.actionRingCapacitySlots=t.getUint32(e+V.capacity_slots,!0)}}];class se extends Error{constructor(e){super(e),this.name="RegionRegistryError"}}function nt(t){return t*ee}function Oe(t,e){const n=t.getUint32(E.region_table_count,!0);if(e+nt(n)>t.byteLength)throw new se(`region table of ${n} entries at byte ${e} overruns the buffer (${t.byteLength} bytes)`);return n}function Sn(t){const e=new Set;for(let n=0;n<t.length;n++){const r=t[n];if(!Number.isInteger(r.id)||r.id<=0)throw new se(`region "${r.name}" has invalid id ${r.id} — region ids must be positive integers (0 is the absent sentinel)`);if(e.has(r.id))throw new se(`duplicate region id ${r.id} (region "${r.name}") — ids must be distinct within a consumer's region set`);if(e.add(r.id),!Number.isInteger(r.bytes)||r.bytes<=0)throw new se(`region "${r.name}" (id ${r.id}) has invalid byte size ${r.bytes} — must be a positive integer`)}}function Rn(t,e,n){t.setUint32(e+$.region_id,n.regionId,!0),t.setUint32(e+$.byte_offset,n.byteOffset,!0),t.setUint32(e+$.byte_length,n.byteLength,!0)}function st(t,e){return{regionId:t.getUint32(e+$.region_id,!0),byteOffset:t.getUint32(e+$.byte_offset,!0),byteLength:t.getUint32(e+$.byte_length,!0)}}function Nn(t,e,n){for(let r=0;r<n.length;r++)Rn(t,e+r*ee,n[r])}function wn(t,e,n){const r=new Array(n);for(let s=0;s<n;s++)r[s]=st(t,e+s*ee);return r}function Dn(t){const e=t.getUint32(E.region_table_off,!0);if(e===0)return[];const n=Oe(t,e);return wn(t,e,n)}function On(t,e){const n=t.getUint32(E.region_table_off,!0);if(n===0)return 0;const r=Oe(t,n);for(let s=0;s<r;s++){const o=n+s*ee;if(t.getUint32(o+$.region_id,!0)===e)return t.getUint32(o+$.byte_offset,!0)}return 0}function Cn(t,e){const n=t.getUint32(E.region_table_off,!0);if(n===0)return null;const r=Oe(t,n);for(let s=0;s<r;s++){const o=st(t,n+s*ee);if(o.regionId===e)return o}return null}function rt(t,e){return t<<16|e}const de=2**31;class Ce extends Error{constructor(e){super(`SAB column layout offset ${e} reaches or exceeds the 2³¹ (${de}-byte) ceiling. Past 2 GiB the signed-32-bit bitwise alignment math wraps to negative/misaligned offsets. This is a structural limit independent of the (default 256 MiB) allocator cap — a single SAB cannot back more than ~2 GiB of column data.`),this.name="StoreLayoutOverflowError"}}function be(t,e){if(t+e>de)throw new Ce(t);return t+(e-1)&~(e-1)}function bn(t,e,n,r){switch(e){case g.u8:return new Uint8Array(t,n,r);case g.i8:return new Int8Array(t,n,r);case g.u16:return new Uint16Array(t,n,r);case g.i16:return new Int16Array(t,n,r);case g.u32:return new Uint32Array(t,n,r);case g.i32:return new Int32Array(t,n,r);case g.f32:return new Float32Array(t,n,r);case g.f64:return new Float64Array(t,n,r)}}function vn(t,e,n=0){const s=Wt(t.map(a=>({archetypeId:a.archetypeId,componentMask:a.componentMask,rowCount:0,enabledCount:0,rowCapacity:a.rowCapacity,columns:a.columns.map(c=>({componentId:c.componentId,fieldId:c.fieldId,typeTag:c.typeTag,byteOff:0,stride:Te[c.typeTag]}))})))+n;let o=e+s;const i=new Array(t.length);for(let a=0;a<t.length;a++){const c=t[a],l=new Array(c.columns.length);for(let d=0;d<c.columns.length;d++){const f=c.columns[d],_=Te[f.typeTag];o=be(o,_),l[d]={componentId:f.componentId,fieldId:f.fieldId,typeTag:f.typeTag,byteOff:o,stride:_},o+=_*c.rowCapacity}i[a]={archetypeId:c.archetypeId,componentMask:c.componentMask,rowCount:0,enabledCount:0,rowCapacity:c.rowCapacity,columns:l}}if(o>de)throw new Ce(o);return{descriptors:i,totalBytes:o,regionBytes:s}}function Ln(t){const e=t;return typeof e._regionBytes=="number"&&typeof e._allocator=="function"&&typeof e._reservedDescriptorBytes=="number"}function Un(t,e=P.DEFAULT_SAB_ALLOCATOR,n={}){const r={};let s=Ze;for(let S=0;S<q.length;S++){const b=q[S],z=b.sizeFromOptions(n);r[b.headerOff]=z===0?0:s,s+=z}const o=n.regions??[];Sn(o);const i=o.length,a=i>0?s:0;s+=nt(i);const c=new Array(i);for(let S=0;S<o.length;S++){const b=o[S];c[S]={regionId:b.id,byteOffset:s,byteLength:b.bytes},s+=b.bytes}const l=n.bindingsRegionBytes??0,d=l===0?0:s;s+=l;const f=s,{descriptors:_,totalBytes:m,regionBytes:p}=vn(t,f,n.reservedDescriptorBytes??0),u=e(m),h=new DataView(u),I={magic:je,simAbiVersion:Qe,viewStamp:0,capacity:m,archetypeCount:t.length,layoutDescriptorOff:f,bindingsOff:d,regionTableOff:a,regionTableCount:i,commandRingOff:r.command_ring_off,entityIndexOff:r.entity_index_off,eventRingOff:r.event_ring_off,actionRingOff:r.action_ring_off};Bt(h,I),l>0&&new Uint8Array(u,d,l).fill(0);for(let S=0;S<q.length;S++){const b=q[S],z=r[b.headerOff];z!==0&&b.init(h,z,n)}a!==0&&Nn(h,a,c);for(let S=0;S<o.length;S++)o[S].init(h,c[S].byteOffset);Vt(h,f,_);const Y=ot(u,_);return{buffer:u,view:h,header:I,archetypes:Y,_regionBytes:p,_allocator:e,_reservedDescriptorBytes:n.reservedDescriptorBytes??0}}function ot(t,e){const n=new Map;for(let r=0;r<e.length;r++){const s=e[r],o=new Array(s.columns.length),i=new Map;for(let a=0;a<s.columns.length;a++){const c=s.columns[a],l={componentId:c.componentId,fieldId:c.fieldId,typeTag:c.typeTag,byteOff:c.byteOff,stride:c.stride,view:bn(t,c.typeTag,c.byteOff,s.rowCapacity)};o[a]=l,i.set(rt(c.componentId,c.fieldId),l)}n.set(s.archetypeId,{archetypeId:s.archetypeId,componentMask:s.componentMask,rowCapacity:s.rowCapacity,columns:i,columnsInOrder:o})}return n}const it=2166136261,ve=16777619;function _e(t,e){return t=(t^e&255)>>>0,Math.imul(t,ve)>>>0}function Mn(t,e){return t=(t^e>>>0)>>>0,Math.imul(t,ve)>>>0}class Pn{_data=new We.SparseMap;fieldNames;fieldTypes;fieldIndex;constructor(e,n){this.fieldNames=e,this.fieldTypes=n;const r=Object.create(null);for(let s=0;s<e.length;s++)r[e[s]]=s;this.fieldIndex=r}get size(){return this._data.size}get indices(){return this._data.keys}canonicalIndices(){return this._data.keys.slice().sort((e,n)=>e-n)}getRow(e){return this._data.get(e)}clear(){this._data.clear()}setRawRow(e,n){this._data.set(e,n)}has(e){return this._data.has(e)}setRow(e,n){const r=this.fieldNames,s=new Array(r.length);for(let o=0;o<r.length;o++){const i=n[r[o]];s[o]=i===void 0?0:i}this._data.set(e,s)}remove(e){return this._data.delete(e)}getField(e,n){const r=this._data.get(e);return r===void 0?void 0:r[n]}setField(e,n,r){const s=this._data.get(e);return s===void 0?!1:(s[n]=r,!0)}}class y extends Error{constructor(e){super(e),this.name="SparseRestoreError"}}const Le=12,Ue=4,X=8;function Me(t,e){let n=it;const r=s=>{for(let o=0;o<s.length;o++)n=_e(n,s.charCodeAt(o))};for(let s=0;s<t.length;s++)r(t[s]),n=_e(n,31),r(e[s]),n=_e(n,30);return n>>>0}function $n(t){let e=4;for(let o=0;o<t.length;o++){const i=t[o],a=i.fieldNames.length;e+=Le+i.size*(Ue+a*X)}const n=new Uint8Array(e),r=new DataView(n.buffer);let s=0;r.setUint32(s,t.length,!0),s+=4;for(let o=0;o<t.length;o++){const i=t[o],a=i.fieldNames.length,c=i.canonicalIndices();r.setUint32(s,a,!0),s+=4,r.setUint32(s,Me(i.fieldNames,i.fieldTypes),!0),s+=4,r.setUint32(s,c.length,!0),s+=4;for(let l=0;l<c.length;l++){const d=c[l];r.setUint32(s,d,!0),s+=4;const f=i.getRow(d);for(let _=0;_<a;_++)r.setFloat64(s,f[_],!0),s+=X}}return n}function Bn(t,e){const n=new DataView(e.buffer,e.byteOffset,e.byteLength),r=e.byteLength;let s=0;const o=a=>{if(s+a>r)throw new y(`sparse snapshot truncated: need ${a} more bytes at offset ${s}, have ${r-s}`)};o(4);const i=n.getUint32(s,!0);if(s+=4,i!==t.length)throw new y(`sparse store count mismatch: snapshot=${i}, registered=${t.length}`);for(let a=0;a<t.length;a++){const c=t[a];o(Le);const l=n.getUint32(s,!0);s+=4;const d=n.getUint32(s,!0);s+=4;const f=n.getUint32(s,!0);if(s+=4,l!==c.fieldNames.length)throw new y(`sparse store ${a} field-count mismatch: snapshot=${l}, registered=${c.fieldNames.length}`);const _=Me(c.fieldNames,c.fieldTypes);if(d!==_)throw new y(`sparse store ${a} schema identity mismatch: snapshot hash=${d}, registered=${_} (same field count, different field names/types — likely a registration-order divergence between the snapshot and restore worlds)`);c.clear();for(let m=0;m<f;m++){o(Ue+l*X);const p=n.getUint32(s,!0);if(s+=4,p>U)throw new y(`sparse store ${a} member ${m} entity index ${p} exceeds MAX_INDEX (${U})`);const u=new Array(l);for(let h=0;h<l;h++)u[h]=n.getFloat64(s,!0),s+=X;c.setRawRow(p,u)}}if(s!==r)throw new y(`sparse snapshot has ${r-s} trailing bytes after the last store (not a canonical encoding)`)}function Fn(t,e){const n=new DataView(e.buffer,e.byteOffset,e.byteLength),r=e.byteLength;let s=0;const o=a=>{if(s+a>r)throw new y(`sparse snapshot truncated: need ${a} more bytes at offset ${s}, have ${r-s}`)};o(4);const i=n.getUint32(s,!0);if(s+=4,i!==t.length)throw new y(`sparse store count mismatch: snapshot=${i}, registered=${t.length}`);for(let a=0;a<t.length;a++){const c=t[a];o(Le);const l=n.getUint32(s,!0);s+=4;const d=n.getUint32(s,!0);s+=4;const f=n.getUint32(s,!0);if(s+=4,l!==c.fieldNames.length)throw new y(`sparse store ${a} field-count mismatch: snapshot=${l}, registered=${c.fieldNames.length}`);const _=Me(c.fieldNames,c.fieldTypes);if(d!==_)throw new y(`sparse store ${a} schema identity mismatch: snapshot hash=${d}, registered=${_} (same field count, different field names/types — likely a registration-order divergence between the snapshot and restore worlds)`);for(let m=0;m<f;m++){o(Ue+l*X);const p=n.getUint32(s,!0);if(s+=4,p>U)throw new y(`sparse store ${a} member ${m} entity index ${p} exceeds MAX_INDEX (${U})`);s+=l*X}}if(s!==r)throw new y(`sparse snapshot has ${r-s} trailing bytes after the last store (not a canonical encoding)`)}const Ae=2147483647,xn="orphan",at="target",Yn=Object.freeze({});class ct{exclusive;sparse;onDeleteTarget;_store;_reverse=new Map;constructor(e,n,r,s){this.exclusive=e,this.sparse=n,this._store=r,this.onDeleteTarget=s}linkReverse(e,n){let r=this._reverse.get(e);r===void 0&&(r=new Set,this._reverse.set(e,r)),r.add(n)}unlinkReverse(e,n){const r=this._reverse.get(e);r!==void 0&&(r.delete(n),r.size===0&&this._reverse.delete(e))}pruneDeadReverse(e){let n=0;for(const r of this._reverse.keys())e(r)||(this._reverse.delete(r),n++);return n}sourcesOf(e){const n=this._reverse.get(e);if(n===void 0||n.size===0)return[];const r=new Array(n.size);let s=0;return n.forEach(o=>{r[s++]=o}),r.sort((o,i)=>o-i),r}resetIndices(){this._reverse.clear(),this._resetForward()}}class kn extends ct{constructor(e,n,r){super(!0,e,n,r)}_resetForward(){}link(e,n){const r=L(e),s=this._store.getField(r,0);if(s!==void 0){if(s===n)return;this.unlinkReverse(s,e)}this._store.setRow(r,{[at]:n}),this.linkReverse(n,e)}unlink(e,n){const r=L(e),s=this._store.getField(r,0);s!==void 0&&(n!==void 0&&s!==n||(this.unlinkReverse(s,e),this._store.remove(r)))}purgeSource(e){const n=L(e),r=this._store.getField(n,0);r!==void 0&&this.unlinkReverse(r,e)}singleTarget(e){const n=this._store.getField(e,0);return n===void 0?void 0:n}targetsOf(e){const n=this._store.getField(e,0);return n===void 0?[]:[n]}has(e){return this._store.has(e)}forEachCanonicalTargetSet(e){}forEachCanonicalPair(e,n){const r=this._store.canonicalIndices();for(let s=0;s<r.length;s++){const o=r[s];n(e(o),this._store.getField(o,0))}}rebuildReverseFromForward(e){const n=this._store.indices;for(let r=0;r<n.length;r++){const s=n[r];this.linkReverse(this._store.getField(s,0),e(s))}}restoreAddTarget(){throw new y("exclusive relation has no multi forward sources to restore (snapshot header should have guarded this)")}}class Hn extends ct{_forward=new Map;constructor(e,n,r){super(!1,e,n,r)}_resetForward(){this._forward.clear()}link(e,n){const r=L(e);let s=this._forward.get(r);s===void 0&&(s=new Set,this._forward.set(r,s),this._store.setRow(r,Yn)),s.add(n),this.linkReverse(n,e)}unlink(e,n){const r=L(e),s=this._forward.get(r);if(s!==void 0){if(n===void 0){this._forward.delete(r),s.forEach(o=>this.unlinkReverse(o,e)),this._store.remove(r);return}s.has(n)&&(s.delete(n),this.unlinkReverse(n,e),s.size===0&&(this._forward.delete(r),this._store.remove(r)))}}purgeSource(e){const n=L(e),r=this._forward.get(n);r!==void 0&&(this._forward.delete(n),r.forEach(s=>this.unlinkReverse(s,e)))}singleTarget(){}targetsOf(e){const n=this._forward.get(e);if(n===void 0||n.size===0)return[];const r=new Array(n.size);let s=0;return n.forEach(o=>{r[s++]=o}),r.sort((o,i)=>o-i),r}has(e){return this._store.has(e)}forEachCanonicalTargetSet(e){const n=Array.from(this._forward.keys()).sort((r,s)=>r-s);for(let r=0;r<n.length;r++){const s=this.targetsOf(n[r]);s.length!==0&&e(n[r],s)}}forEachCanonicalPair(e,n){this.forEachCanonicalTargetSet((r,s)=>{const o=e(r);for(let i=0;i<s.length;i++)n(o,s[i])})}rebuildReverseFromForward(){}restoreAddTarget(e,n,r){let s=this._forward.get(e);s===void 0&&(s=new Set,this._forward.set(e,s)),s.add(n),this.linkReverse(n,r)}}function Gn(t,e,n,r){return t?new kn(e,n,r):new Hn(e,n,r)}const lt=4,dt=4,ut=8,re=8;function Vn(t){const e=new Array(t.length);let n=4;for(let i=0;i<t.length;i++){n+=lt;const a=t[i];if(a.exclusive){e[i]=null;continue}const c=[];a.forEachCanonicalTargetSet((l,d)=>c.push([l,d])),e[i]=c,n+=dt;for(let l=0;l<c.length;l++)n+=ut+c[l][1].length*re}const r=new Uint8Array(n),s=new DataView(r.buffer);let o=0;s.setUint32(o,t.length,!0),o+=4;for(let i=0;i<t.length;i++){s.setUint32(o,t[i].exclusive?0:1,!0),o+=4;const a=e[i];if(a!==null){s.setUint32(o,a.length,!0),o+=4;for(let c=0;c<a.length;c++){const l=a[c][0],d=a[c][1];s.setUint32(o,l,!0),o+=4,s.setUint32(o,d.length,!0),o+=4;for(let f=0;f<d.length;f++)s.setFloat64(o,d[f],!0),o+=re}}}return r}function Xn(t,e,n){const r=new DataView(e.buffer,e.byteOffset,e.byteLength),s=e.byteLength;let o=0;const i=c=>{if(o+c>s)throw new y(`relation snapshot truncated: need ${c} more bytes at offset ${o}, have ${s-o}`)};for(let c=0;c<t.length;c++)t[c].resetIndices();i(4);const a=r.getUint32(o,!0);if(o+=4,a!==t.length)throw new y(`relation count mismatch: snapshot=${a}, registered=${t.length}`);for(let c=0;c<t.length;c++){const l=t[c];i(lt);const d=r.getUint32(o,!0);if(o+=4,d===1===l.exclusive)throw new y(`relation ${c} cardinality mismatch: snapshot ${d?"multi":"exclusive"}, registered ${l.exclusive?"exclusive":"multi"}`);if(l.exclusive)continue;i(dt);const f=r.getUint32(o,!0);o+=4;for(let _=0;_<f;_++){i(ut);const m=r.getUint32(o,!0);o+=4;const p=r.getUint32(o,!0);if(o+=4,m>U)throw new y(`relation ${c} source index ${m} exceeds MAX_INDEX (${U})`);i(p*re);const u=n(m);for(let h=0;h<p;h++){const I=r.getFloat64(o,!0);o+=re;const Y=I;if(!Number.isInteger(Y)||Y<0||Y>ge)throw new y(`relation ${c} target ${Y} is not a well-formed packed EntityID (expected an integer in [0, ${ge}])`);l.restoreAddTarget(m,I,u)}}}if(o!==s)throw new y(`relation snapshot has ${s-o} trailing bytes after the last relation (not a canonical encoding)`)}const ke=new WeakMap;function Wn(t){const e=new Set,n=new Set,r=new Set,s=new Set,o=new Set,i=new Set,a=new Set,c=new Set,l=new Set,d=new Set;for(let u=0;u<t.writes.length;u++){const h=t.writes[u].id;n.add(h),e.add(h),r.add(h)}for(let u=0;u<t.reads.length;u++)e.add(t.reads[u].id);for(let u=0;u<t.spawns.length;u++){const h=t.spawns[u];for(let I=0;I<h.length;I++)r.add(h[I].id)}for(let u=0;u<t.transitions.length;u++){const h=t.transitions[u];if(h.add)for(let I=0;I<h.add.length;I++)r.add(h.add[I].id);if(h.remove)for(let I=0;I<h.remove.length;I++)s.add(h.remove[I].id)}for(let u=0;u<t.despawns.length;u++)s.add(t.despawns[u].id);for(let u=0;u<t.resourceReads.length;u++)o.add(t.resourceReads[u]);for(let u=0;u<t.resourceWrites.length;u++){const h=t.resourceWrites[u];i.add(h),o.add(h)}const f=t.sparseWrites;if(f!==void 0)for(let u=0;u<f.length;u++){const h=f[u];c.add(h),a.add(h)}const _=t.sparseReads;if(_!==void 0)for(let u=0;u<_.length;u++)a.add(_[u]);const m=t.relationWrites;if(m!==void 0)for(let u=0;u<m.length;u++){const h=m[u];d.add(h),l.add(h)}const p=t.relationReads;if(p!==void 0)for(let u=0;u<p.length;u++)l.add(p[u]);return{reads:e,writes:n,addAllowed:r,removeAllowed:s,hasDespawns:t.despawns.length>0,resourceReads:o,resourceWrites:i,sparseReads:a,sparseWrites:c,relationReads:l,relationWrites:d}}function zn(t){const e=ke.get(t);if(e!==void 0)return e;const n=Wn(t);return ke.set(t,n),n}const He=new WeakMap;function qn(t){const e=new Set,n=new Set;if(t.reads!==void 0)for(let r=0;r<t.reads.length;r++)e.add(t.reads[r].id);if(t.resourceReads!==void 0)for(let r=0;r<t.resourceReads.length;r++)n.add(t.resourceReads[r]);return{reads:e,writes:new Set,addAllowed:new Set,removeAllowed:new Set,hasDespawns:!1,resourceReads:n,resourceWrites:new Set,sparseReads:new Set,sparseWrites:new Set,relationReads:new Set,relationWrites:new Set}}function Kn(t){const e=He.get(t);if(e!==void 0)return e;const n=qn(t);return He.set(t,n),n}class jn{active=null;sets=null;activeName=null;exclusive=!1;enter(e){this.active=e,this.activeName=e.name??`system_${e.id}`,this.exclusive=e.exclusive===!0,this.sets=this.exclusive?null:zn(e)}enterCondition(e){this.active=null,this.activeName=e.name,this.sets=Kn(e)}leave(){this.active=null,this.activeName=null,this.sets=null,this.exclusive=!1}isActive(){return this.sets!==null||this.exclusive}current(){return this.active}checkRead(e){this.sets!==null&&(this.sets.reads.has(e.id)||this.failComponent("read",e,"reads"))}checkWrite(e){this.sets!==null&&(this.sets.writes.has(e.id)||this.failComponent("write",e,"writes"))}checkAdd(e){this.sets!==null&&(this.sets.addAllowed.has(e.id)||this.failComponent("addComponent",e,"spawns / transitions.add / writes"))}checkRemove(e){this.sets!==null&&(this.sets.removeAllowed.has(e.id)||this.failComponent("removeComponent",e,"despawns / transitions.remove"))}checkDestroy(){if(this.sets===null||this.sets.hasDespawns)return;const e=this.activeName;throw new A(T.ACCESS_UNDECLARED,`system '${e}' called despawn but didn't declare any despawns — declare the components this system removes via despawn in its 'despawns'`,{system:e,op:"despawn"})}checkResourceRead(e){if(this.sets===null)return;const n=e;this.sets.resourceReads.has(n)||this.failResource("read",e,"resourceReads")}checkResourceWrite(e){if(this.sets===null)return;const n=e;this.sets.resourceWrites.has(n)||this.failResource("write",e,"resourceWrites")}checkSparseRead(e){if(this.sets===null)return;const n=e;this.sets.sparseReads.has(n)||this.failSparse("read",n,"sparseReads")}checkSparseWrite(e){if(this.sets===null)return;const n=e;this.sets.sparseWrites.has(n)||this.failSparse("write",n,"sparseWrites")}checkRelationRead(e){if(this.sets===null)return;const n=e;this.sets.relationReads.has(n)||this.failRelation("read",n,"relationReads")}checkRelationWrite(e){if(this.sets===null)return;const n=e;this.sets.relationWrites.has(n)||this.failRelation("write",n,"relationWrites")}checkRelationReadAny(){this.sets!==null&&(this.sets.relationReads.has(Ae)||this.failRelation("(*, T) wildcard read",Ae,"relationReads (as ANY_RELATION)"))}optionalScopes=[];enterOptionalScope(e){this.optionalScopes.push(e)}leaveOptionalScope(){this.optionalScopes.pop()}checkOptionalFetch(e){const n=this.optionalScopes.length;if(n===0)return;const r=this.optionalScopes[n-1],s=e.id;for(let o=0;o<r.length;o++)if(r[o]===s)return;throw new A(T.OPTIONAL_TERM_NOT_DECLARED,`getOptionalColumnRead fetched optional component ${s} but the iterating query didn't declare it — add .optional(component) to the query before fetching it`)}failComponent(e,n,r){const s=this.activeName,o=Ke(n);throw new A(T.ACCESS_UNDECLARED,`system '${s}' performed ${e} on ${o} but didn't declare it — add it to '${r}' (see docs/api/systems.md)`,{system:s,op:e,component:n.id})}failSparse(e,n,r){const s=this.activeName;throw new A(T.ACCESS_UNDECLARED,`system '${s}' performed ${e} on sparse component ${n} but didn't declare it — add it to '${r}' (see docs/api/systems.md)`,{system:s,op:e,sparse:n})}failRelation(e,n,r){const s=this.activeName;throw new A(T.ACCESS_UNDECLARED,`system '${s}' performed ${e} on relation ${n} but didn't declare it — add it to '${r}' (see docs/api/systems.md)`,{system:s,op:e,relation:n})}failResource(e,n,r){const s=this.activeName,o=n.description??"<unnamed>";throw new A(T.ACCESS_UNDECLARED,`system '${s}' performed resource ${e} on '${o}' but didn't declare it — add the resource key to '${r}' (see docs/api/systems.md)`,{system:s,op:e,resource:o})}}const K=new jn,Qn="/packages/engine/src/core/ecs/";class Zn{activeCache=null;repoRootCache=null;buf=new Map;callsiteCache=new Map;isActive(){if(this.activeCache!==null)return this.activeCache;const n=globalThis.process?.env?.VISUAL_INTEL_TRACE;return this.activeCache=n==="1"||n==="true"}repoRoot(){if(this.repoRootCache!==null)return this.repoRootCache;const e=globalThis.process;return this.repoRootCache=e?.cwd?.()??""}resolveCallsite(){return es(new Error().stack??null,this.repoRoot(),this.callsiteCache)}record(e,n,r){const s=this.resolveCallsite();if(!s)return;const o=`${e} ${n} ${r} ${s}`;this.buf.set(o,(this.buf.get(o)??0)+1)}recordEmit(e){this.record("ecs-events","emit",e)}recordRead(e){this.record("ecs-events","read",e)}recordResourceRead(e){this.record("resources","read",e)}recordResourceWrite(e){this.record("resources","write",e)}recordResourceRegister(e){this.record("resources","register",e)}recordResourceRemove(e){this.record("resources","remove",e)}recordSendAction(e){this.record("actions","send_action",e)}recordHandleAction(e){this.record("actions","handle_action",e)}snapshot(){const e={"ecs-events":{emit:[],read:[]},actions:{send_action:[],handle_action:[]},resources:{read:[],write:[],register:[],remove:[]}};for(const[n,r]of this.buf.entries()){const[s,o,i,a]=n.split(" ");if(!s||!o||a===void 0)continue;const l={key:s==="actions"?Number(i):i,file:a,count:r},f=e[s][o];f&&f.push(l)}for(const n of Object.values(e))for(const r of Object.values(n))r.sort((s,o)=>{if(s.file!==o.file)return s.file<o.file?-1:1;const i=String(s.key),a=String(o.key);return i<a?-1:i>a?1:0});return{schemaVersion:1,capturedAt:new Date().toISOString(),channels:e}}reset(){this.buf.clear(),this.callsiteCache.clear(),this.activeCache=null,this.repoRootCache=null}}function Jn(t){const e=/\(([^)]+):\d+:\d+\)\s*$/.exec(t);if(e)return e[1]??null;const n=/at\s+([^\s][^()]*?):\d+:\d+\s*$/.exec(t);return n&&(n[1]??"").trim()||null}function es(t,e,n){if(!t)return null;const r=t.split(`
|
|
2
|
+
`);for(let s=0;s<r.length;s++){const o=r[s],i=n?.get(o);if(i!==void 0){if(i===null)continue;return i}const a=Jn(o);if(!a){n?.set(o,null);continue}if(a.includes(Qn)){n?.set(o,null);continue}const c=ts(a,e);return n?.set(o,c),c}return null}function ts(t,e){let n=t;return n.startsWith("file://")&&(n=n.slice(7)),e&&n.startsWith(e+"/")&&(n=n.slice(e.length+1)),n.replace(/\\/g,"/")}const ns=new Zn;var B=(t=>(t.PRE_STARTUP="PRE_STARTUP",t.STARTUP="STARTUP",t.POST_STARTUP="POST_STARTUP",t.FIXED_UPDATE="FIXED_UPDATE",t.PRE_UPDATE="PRE_UPDATE",t.UPDATE="UPDATE",t.POST_UPDATE="POST_UPDATE",t))(B||{});const he=["PRE_STARTUP","STARTUP","POST_STARTUP"],Ee=["PRE_UPDATE","UPDATE","POST_UPDATE"];function ss(t){return Object.freeze({name:t})}function rs(t){return!("fn"in t)}const j=Object.freeze([]);function me(t){return t===void 0?j:Array.isArray(t)?t:[t]}class os{labelSystems=new Map;sortedCache=new Map;systemIndex=new Map;systemLastRun=[];lastRunSlots=new Map;freeLastRunSlots=[];_driveDepth=0;gatedSystems=new Map;setConditions=new Map;setOrdering=new Map;nextInsertionOrder=0;_backend=null;onWarn;_fixedNodes=[];constructor(e){this.onWarn=e??(n=>console.warn(n));for(let n=0;n<he.length;n++)this.labelSystems.set(he[n],[]);this.labelSystems.set("FIXED_UPDATE",this._fixedNodes);for(let n=0;n<Ee.length;n++)this.labelSystems.set(Ee[n],[])}addSystems(e,...n){for(const r of n){const s="system"in r,o=s?r.system:r,i=s?r.ordering:void 0,a=s?me(r.runIf):j,c=s?me(r.set):j;if(this.systemIndex.has(o))throw new A(T.DUPLICATE_SYSTEM,`System ${o.name??o.id} is already scheduled`);const l={descriptor:o,insertionOrder:this.nextInsertionOrder++,before:new Set(i?.before??[]),after:new Set(i?.after??[]),conditions:a,sets:c};this.labelSystems.get(e).push(l),this.systemIndex.set(o,e),this._assignLastRunSlot(o),(a.length>0||c.length>0)&&this.gatedSystems.set(o,l),this.sortedCache.delete(e)}}configureSet(e,n){const r=me(n.runIf);if(r.length>0){const s=this.setConditions.get(e);s===void 0?this.setConditions.set(e,[...r]):s.push(...r)}if(n.before!==void 0||n.after!==void 0){let s=this.setOrdering.get(e);s===void 0&&(s={before:new Set,after:new Set},this.setOrdering.set(e,s));for(const o of n.before??j)s.before.add(o);for(const o of n.after??j)s.after.add(o);this.sortedCache.clear()}}removeSystem(e){const n=this.systemIndex.get(e);if(n===void 0)return;const r=this.labelSystems.get(n),s=r.findIndex(i=>i.descriptor===e);if(s!==-1){const i=r.length-1;s!==i&&(r[s]=r[i]),r.pop();for(const a of r)a.before.delete(e),a.after.delete(e)}this.systemIndex.delete(e);const o=this.lastRunSlots.get(e);o!==void 0&&(this.systemLastRun[o]=0,this.lastRunSlots.delete(e),this.freeLastRunSlots.push(o)),this.gatedSystems.delete(e),this.sortedCache.clear()}setBackend(e){this._backend=e}runStartup(e,n){this._driveDepth++;try{for(const r of he)this.runLabel(r,e,Ct,n)}finally{this._driveDepth--}}runUpdate(e,n,r){this._driveDepth++;try{for(const s of Ee)this.runLabel(s,e,n,r)}finally{this._driveDepth--}}runFixedUpdate(e,n,r){this._driveDepth++;try{this.runLabel("FIXED_UPDATE",e,n,r)}finally{this._driveDepth--}}hasFixedSystems(){return this._fixedNodes.length>0}getAllSystems(){const e=[];for(const n of this.labelSystems.values())for(const r of n)e.push(r.descriptor);return e}hasSystem(e){return this.systemIndex.has(e)}_assignLastRunSlot(e){let n=this.lastRunSlots.get(e);if(n===void 0){const r=this._driveDepth===0?this.freeLastRunSlots.pop():void 0;r!==void 0?(n=r,this.systemLastRun[n]=0):(n=this.systemLastRun.length,this.systemLastRun.push(0)),this.lastRunSlots.set(e,n)}return n}clear(){for(const e of this.labelSystems.values())e.length=0;this.sortedCache.clear(),this.systemIndex.clear(),this._driveDepth===0?this.systemLastRun.length=0:this.systemLastRun.fill(0),this.lastRunSlots.clear(),this.freeLastRunSlots.length=0,this.gatedSystems.clear(),this.setConditions.clear(),this.setOrdering.clear()}runLabel(e,n,r,s){const o=this.getSorted(e),i=o.sorted,a=o.slots,c=this.gatedSystems.size>0,l=this._backend,d=c?new Map:void 0;for(let f=0;f<i.length;f++){const _=i[f];if(c){const p=this.gatedSystems.get(_);if(p!==void 0&&!this.shouldRun(p,n,d))continue}n.lastRunTick=this.systemLastRun[a[f]];const m=l!==null?_.backendHandle:void 0;K.enter(_),n._trace?.systemStart(_,e);try{m!==void 0?l.run(m):_.fn?.(n,r)}finally{n._trace?.systemEnd(_),K.leave()}this.systemLastRun[a[f]]=s}n._trace?.flushBegin(e),n.flush(),n._trace?.flushEnd(e),n._trace?.phaseBoundary(e)}shouldRun(e,n,r){if(e.conditions.length>0&&!this.evalConditions(e.conditions,n))return!1;for(let s=0;s<e.sets.length;s++){const o=e.sets[s];let i=r.get(o);if(i===void 0){const a=this.setConditions.get(o);i=a===void 0||a.length===0?!0:this.evalConditions(a,n),r.set(o,i)}if(!i)return!1}return!0}evalConditions(e,n){for(let r=0;r<e.length;r++){const s=e[r];K.enterCondition(s);let o;try{o=s.evaluate(n)}finally{K.leave()}if(!o)return!1}return!0}getSorted(e){const n=this.sortedCache.get(e);if(n!==void 0)return n;const r=this.labelSystems.get(e),s=this.sortSystems(r,e),o=new Int32Array(s.length);for(let a=0;a<s.length;a++)o[a]=this._assignLastRunSlot(s[a]);const i={sorted:s,slots:o};return this.sortedCache.set(e,i),i}sortSystems(e,n){if(e.length===0)return[];const r=[],s=new Map,o=new Set,i=new Map;for(const d of e){r.push(d.descriptor),s.set(d.descriptor,d.insertionOrder),o.add(d.descriptor);for(let f=0;f<d.sets.length;f++){const _=d.sets[f];let m=i.get(_);m===void 0&&(m=[],i.set(_,m)),m.push(d.descriptor)}}const a=new Map;for(const d of e)a.set(d.descriptor,[]);for(const d of e){this.resolveEdges(d.descriptor,d.before,"before",o,i,a,n),this.resolveEdges(d.descriptor,d.after,"after",o,i,a,n);for(let f=0;f<d.sets.length;f++){const _=this.setOrdering.get(d.sets[f]);_!==void 0&&(this.resolveEdges(d.descriptor,_.before,"before",o,i,a,n),this.resolveEdges(d.descriptor,_.after,"after",o,i,a,n))}}const c=(d,f)=>s.get(d)-s.get(f),l=d=>d.name??`system_${d.id}`;try{return We.topologicalSort(r,a,c,l)}catch(d){throw d instanceof TypeError?new A(T.CIRCULAR_SYSTEM_DEPENDENCY,`Circular system dependency detected in ${n}: ${d.message}`):d}}resolveEdges(e,n,r,s,o,i,a){for(const c of n){if(rs(c)){const l=o.get(c);if(l===void 0)continue;for(let d=0;d<l.length;d++){const f=l[d];f!==e&&this.addDirectedEdge(e,f,r,i)}continue}if(!s.has(c)){this.warnDroppedEdge(e,c,r,a);continue}this.addDirectedEdge(e,c,r,i)}}addDirectedEdge(e,n,r,s){r==="before"?s.get(e).push(n):s.get(n).push(e)}warnDroppedEdge(e,n,r,s){if(this.systemIndex.has(n))return;const o=i=>i.name??`system_${i.id}`;this.onWarn(`Schedule[${s}]: \`${o(e)}\` declares \`${r}\` ordering against \`${o(n)}\`, which is not registered in any phase — the constraint is ignored. Check for a typo or a missing add_systems() call.`)}}const oe=1024,ie=1024*oe,Ge=64*oe,H=256*ie,ye=3,ft=64,_t=8,Ve=4*ie,Xe=t=>2**Math.ceil(Math.log2(Math.max(1,t))),ne=t=>2**Math.floor(Math.log2(Math.max(1,t))),k=(t,e,n)=>Math.min(n,Math.max(e,t)),R=t=>t>=ie?`${(t/ie).toFixed(1)} MiB`:t>=oe?`${(t/oe).toFixed(0)} KiB`:`${t} B`;function D(t,e){if(!Number.isInteger(e)||e<=0)throw new A(T.INVALID_MEMORY_OPTIONS,`memory.${t} must be a positive integer (got ${e})`)}function is(t){const e=["budget","maxBytes","wasm","allocator","heap","shared"].filter(s=>t!==void 0&&t[s]!==void 0);if(e.length>1)throw new A(T.INVALID_MEMORY_OPTIONS,`memory takes at most one of budget | maxBytes | wasm | allocator | heap | shared (got: ${e.join(", ")})`);const n=t?.columnCapacity;if(n!==void 0&&D("columnCapacity",n),t?.budget!==void 0){const{entities:s}=t.budget,o=t.budget.archetypes??_t,i=t.budget.bytesPerEntity??ft;if(D("budget.entities",s),D("budget.archetypes",o),D("budget.bytesPerEntity",i),s>1<<20)throw new A(T.INVALID_MEMORY_OPTIONS,`memory.budget.entities=${s} exceeds the EntityID index space (1<<20 = ${1<<20})`);const a=n??k(Xe(Math.ceil(s/o)),64,1<<20),c=k(Xe(s*2),4096,1<<20),l=c*w,d=s*i*ye,f=be(Math.max(l+d,Ve),Ge);return{source:"budget",allocator:P.heapArraybufferAllocator(f),columnCapacity:a,entityIndexCapacity:c,capBytes:f,intentLabel:`budget of ${s} entities`,budgetEntities:s,derivation:[`columnCapacity = ${n!==void 0?`${a} (pinned)`:`pow2(${s}/${o} per archetype) = ${a}`}`,`entityIndex = pow2(2 × ${s}) = ${c} slots × ${w} B = ${R(l)}`,`columns = ${s} × ${i} B × ${ye} (double+holes headroom) = ${R(d)}`,`cap = align64K(max(index + columns, ${R(Ve)} floor)) = ${R(f)}`],wasmMemory:null}}if(t?.maxBytes!==void 0){D("maxBytes",t.maxBytes);const s=n??F,o=k(ne(t.maxBytes/4/w),4096,v);return{source:"maxBytes",allocator:P.heapArraybufferAllocator(t.maxBytes),columnCapacity:s,entityIndexCapacity:o,capBytes:t.maxBytes,intentLabel:`explicit cap of ${R(t.maxBytes)}`,budgetEntities:null,derivation:[`cap = ${R(t.maxBytes)} (caller-declared)`,`columnCapacity = ${s} (${n!==void 0?"pinned":"default"})`,`entityIndex = floor_pow2(cap/4 ÷ ${w} B) = ${o} slots`],wasmMemory:null}}if(t?.wasm!==void 0){const s=t.wasm,o=n??F;if(s.memory!==void 0){if(!(s.memory.buffer instanceof SharedArrayBuffer))throw new A(T.INVALID_MEMORY_OPTIONS,"memory.wasm.memory must be constructed with `shared: true` — the SAB substrate requires a SharedArrayBuffer-backed WebAssembly.Memory");return{source:"wasm",allocator:P.wasmMemoryAllocator(s.memory),columnCapacity:o,entityIndexCapacity:v,capBytes:null,intentLabel:"caller-supplied WebAssembly.Memory",budgetEntities:null,derivation:["backing = wasm_memory_allocator(memory) — zero-copy with the sim (is_in_place ✓)","cap = the Memory's own `maximum` (declared by the caller; not readable from JS)",`columnCapacity = ${o} (${n!==void 0?"pinned":"default"})`],wasmMemory:s.memory}}D("wasm.maximumPages",s.maximumPages);const i=s.initialPages??Math.min(32,s.maximumPages);if(D("wasm.initialPages",i),i>s.maximumPages)throw new A(T.INVALID_MEMORY_OPTIONS,`memory.wasm.initialPages (${i}) exceeds maximumPages (${s.maximumPages})`);const a=new WebAssembly.Memory({initial:i,maximum:s.maximumPages,shared:!0}),c=s.maximumPages*Ge,l=k(ne(c/4/w),4096,v);return{source:"wasm",allocator:P.wasmMemoryAllocator(a),columnCapacity:o,entityIndexCapacity:l,capBytes:c,intentLabel:`engine-constructed WebAssembly.Memory (max ${s.maximumPages} pages)`,budgetEntities:null,derivation:[`cap = ${s.maximumPages} pages × 64 KiB = ${R(c)} (Memory maximum)`,`initial = ${i} pages (${s.initialPages!==void 0?"declared":"default"})`,`entityIndex = floor_pow2(cap/4 ÷ ${w} B) = ${l} slots`,`columnCapacity = ${o} (${n!==void 0?"pinned":"default"})`],wasmMemory:a}}if(t?.allocator!==void 0){if(t.allocator.isInPlace!==!0)throw new A(T.INVALID_MEMORY_OPTIONS,"memory.allocator must declare `isInPlace: true`: a live Store's flush loops hoist entity-index views across grows, so a non-in-place allocator (e.g. DEFAULT_SAB_ALLOCATOR) corrupts the entity→row mapping. Use growableSabAllocator / wasmMemoryAllocator; non-in-place allocators are snapshot/test sizing only.");const s=n??F,o=t.capBytesHint;return o!==void 0&&D("capBytesHint",o),{source:"allocator",allocator:t.allocator,columnCapacity:s,entityIndexCapacity:v,capBytes:o??null,intentLabel:o!==void 0?`custom in-place allocator (cap hint ${R(o)})`:"custom in-place allocator",budgetEntities:null,derivation:["backing = caller allocator (is_in_place ✓ checked at construction)",o!==void 0?`cap = ${R(o)} (caller hint — diagnostics only; the allocator owns the real cap)`:"cap = allocator-owned (no hint)",`columnCapacity = ${s} (${n!==void 0?"pinned":"default"})`],wasmMemory:null}}if(t?.heap!==void 0){t.heap.maxBytes!==void 0&&D("heap.maxBytes",t.heap.maxBytes);const s=t.heap.maxBytes??H,o=n??F,i=k(ne(s/4/w),4096,v);return{source:"heap",allocator:P.heapArraybufferAllocator(s),columnCapacity:o,entityIndexCapacity:i,capBytes:s,intentLabel:`pure-TS heap backing (${R(s)} growable cap, no SharedArrayBuffer)`,budgetEntities:null,derivation:[`backing = heap_arraybuffer_allocator(${R(s)}) — fixed ArrayBuffer reserved at the cap, no SAB / no COOP+COEP (is_in_place ✓)`,"trade-off: no worker offload / no WASM backend (both need a transferable SharedArrayBuffer)",`columnCapacity = ${o} (${n!==void 0?"pinned":"default"})`,`entityIndex = floor_pow2(cap/4 ÷ ${w} B) = ${i} slots`],wasmMemory:null}}if(t?.shared!==void 0){t.shared.maxBytes!==void 0&&D("shared.maxBytes",t.shared.maxBytes);const s=t.shared.maxBytes??H,o=n??F,i=k(ne(s/4/w),4096,v);return{source:"shared",allocator:P.growableSabAllocator(s),columnCapacity:o,entityIndexCapacity:i,capBytes:s,intentLabel:`shared SharedArrayBuffer backing (${R(s)} growable cap, needs COOP/COEP)`,budgetEntities:null,derivation:[`backing = growable_sab_allocator(${R(s)}) — growable SharedArrayBuffer (is_in_place ✓); needs cross-origin isolation`,"enables worker offload + a WASM compute backend (transferable SharedArrayBuffer)",`columnCapacity = ${o} (${n!==void 0?"pinned":"default"})`,`entityIndex = floor_pow2(cap/4 ÷ ${w} B) = ${i} slots`],wasmMemory:null}}const r=n??F;return{source:"default",allocator:P.heapArraybufferAllocator(),columnCapacity:r,entityIndexCapacity:v,capBytes:H,intentLabel:`default sizing (${R(H)} growable cap)`,budgetEntities:null,derivation:[`cap = ${R(H)} (heap_arraybuffer_allocator default)`,`columnCapacity = ${r} (${n!==void 0?"pinned":"DEFAULT_COLUMN_CAPACITY"})`,`entityIndex = ${v} slots (full EntityID space, ~12 MiB virtual)`],wasmMemory:null}}function as(t,e){return{def:t,values:e}}function ae(t,e){switch(e.kind){case"spawn":{const n=t.commands.spawn();for(const r of e.components)t.commands.add(n,r.def,r.values);return e.onSpawned?.(n),n}case"despawn":t.commands.despawn(e.eid);return;case"add_component":t.commands.add(e.eid,e.def,e.values);return;case"remove_component":t.commands.remove(e.eid,e.def);return;case"set_field":if(!t.hasComponent(e.eid,e.def))throw new A(T.COMPONENT_NOT_REGISTERED,`host set_field on entity ${e.eid} targets a component it does not have. If you added that component via a host command this same frame, the add is deferred to the phase flush while set_field is immediate — carry the value in add_component/spawnEntry instead of a separate set_field, or set it next frame. (host write seam)`);t.setField(e.eid,e.def,e.field,e.value);return;case"disable":t.commands.disable(e.eid);return;case"enable":t.commands.enable(e.eid);return;default:return pt(e,"HostCommand kind")}}class ht{queued=[];spawn(e,n){return this.queued.push({kind:"spawn",components:e,onSpawned:n}),this}despawn(e){return this.queued.push({kind:"despawn",eid:e}),this}add(e,n,r){return this.queued.push({kind:"add_component",eid:e,def:n,values:r}),this}remove(e,n){return this.queued.push({kind:"remove_component",eid:e,def:n}),this}setField(e,n,r,s){return this.queued.push({kind:"set_field",eid:e,def:n,field:r,value:s}),this}disable(e){return this.queued.push({kind:"disable",eid:e}),this}enable(e){return this.queued.push({kind:"enable",eid:e}),this}push(e){return this.queued.push(e),this}get pending(){return this.queued.length}clear(){const e=this.queued.length;return this.queued.length=0,e}drain(e,n){const r=this.queued.length;if(r===0)return 0;if(n===void 0)for(let s=0;s<r;s++)ae(e,this.queued[s]);else for(let s=0;s<r;s++){const o=this.queued[s];n(o),ae(e,o)}return this.queued.splice(0,r),r}}const Pe=x-1;function cs(t){if(t===De)throw new M("cannot bind opCode 0 (reserved as the command-ring empty-slot marker)");if(t<0||t>255||!Number.isInteger(t))throw new M(`command opCode must be a u8 in [1, 255] (got ${t})`)}function ue(t){const e=new Uint8Array(Pe);return new DataView(e.buffer).setUint32(0,t,!0),e}function fe(t){return new DataView(t.buffer,t.byteOffset,t.byteLength).getUint32(0,!0)}function ls(t,e){return{encode(n){if(n.kind!=="set_field")throw new M(`ringSetFieldCodec encodes a "set_field" command (got "${n.kind}")`);const r=new Uint8Array(Pe),s=new DataView(r.buffer);return s.setUint32(0,n.eid,!0),s.setFloat64(4,n.value,!0),r},decode(n){const r=new DataView(n.buffer,n.byteOffset,n.byteLength);return{kind:"set_field",eid:r.getUint32(0,!0),def:t,field:e,value:r.getFloat64(4,!0)}}}}function ds(){return{encode(t){if(t.kind!=="despawn")throw new M(`ringDespawnCodec encodes a "despawn" command (got "${t.kind}")`);return ue(t.eid)},decode:t=>({kind:"despawn",eid:fe(t)})}}function us(){return{encode(t){if(t.kind!=="disable")throw new M(`ringDisableCodec encodes a "disable" command (got "${t.kind}")`);return ue(t.eid)},decode:t=>({kind:"disable",eid:fe(t)})}}function fs(){return{encode(t){if(t.kind!=="enable")throw new M(`ringEnableCodec encodes an "enable" command (got "${t.kind}")`);return ue(t.eid)},decode:t=>({kind:"enable",eid:fe(t)})}}function _s(t){return{encode(e){if(e.kind!=="remove_component")throw new M(`ringRemoveComponentCodec encodes a "remove_component" command (got "${e.kind}")`);return ue(e.eid)},decode:e=>({kind:"remove_component",eid:fe(e),def:t})}}class hs{appliers=new Map;on(e,n){return cs(e),this.appliers.set(e,n),this}off(e){return this.appliers.delete(e)}onCommand(e,n){return this.on(e,(r,s,o)=>{const i=n.decode(s);o?.(i),ae(r,i)})}drain(e,n,r,s){return en(n,r,(o,i)=>{const a=this.appliers.get(o);a!==void 0&&a(e,i,s)})}}const Es=new Set([B.PRE_STARTUP,B.STARTUP,B.POST_STARTUP]),Ie=new WeakMap;function ms(t,e){const n=Ie.get(e);if(n===void 0)return!1;for(const r of n)t.removeSystem(r);return Ie.delete(e),e.clear(),!0}function gs(t,e){const n=new ht,r=[];Ie.set(n,r);const s=e?.name??"host_command_apply",o=e?.ring,i=e?.recorder,a=i?.record,c=e?.schedules??[B.PRE_STARTUP,B.PRE_UPDATE];if(i!==void 0&&c.includes(B.FIXED_UPDATE))throw new A(T.INVALID_RECORDER_SCHEDULE,"install_host_command_seam: a recorder cannot drain on SCHEDULE.FIXED_UPDATE — it would log the fixed-step dt instead of the host update(dt) and diverge on replay. Use a variable-update phase (PRE_UPDATE/UPDATE/POST_UPDATE).");for(const l of c){const d=!Es.has(l),f=t.registerSystem({name:`${s}:${l}`,reads:[],writes:[],exclusive:!0,fn:(_,m)=>{if(i!==void 0&&d&&i.openTick(_.ecsTick,m),n.drain(_,a),o!==void 0){const p=t.columnStore,u=p.header.commandRingOff;u!==0&&o.drain(_,p.view,u,a)}}});t.addSystems(l,f),r.push(f)}return n}exports.ACTION_RING_DEFAULT_CAPACITY_SLOTS=En;exports.ANY_RELATION=Ae;exports.ARCHETYPE_DESCRIPTOR_HEADER_BYTES=le;exports.ARCHETYPE_DESCRIPTOR_OFFSETS=N;exports.BUDGET_DEFAULT_ARCHETYPES=_t;exports.BUDGET_DEFAULT_BYTES_PER_ENTITY=ft;exports.BUDGET_GROWTH_HEADROOM=ye;exports.COLUMN_DESCRIPTOR_BYTES=ce;exports.COMMAND_RING_DEFAULT_CAPACITY_SLOTS=zt;exports.COMPONENT_MASK_WORDS=Q;exports.DEFAULT_COLUMN_CAPACITY=F;exports.DEFAULT_ECS_CAP_BYTES=H;exports.DEFAULT_FIXED_TIMESTEP=Dt;exports.DEFAULT_MAX_FIXED_STEPS=Ot;exports.DEFAULT_ON_DELETE_TARGET=xn;exports.ECSError=A;exports.ECS_ERROR=T;exports.EMPTY_VALUES=It;exports.ENTITY_INDEX_DEFAULT_CAPACITY=v;exports.ENTITY_INDEX_HEADER_BYTES=te;exports.ENTITY_INDEX_HEADER_OFFSETS=Z;exports.EVENT_RING_DEFAULT_CAPACITY_SLOTS=ln;exports.FNV1A_OFFSET_BASIS=it;exports.FNV1A_PRIME=ve;exports.HASH_GOLDEN_RATIO=St;exports.HASH_SECONDARY_PRIME=Rt;exports.HOST_COMMAND_PAYLOAD_BYTES=Pe;exports.HostCommandDispatcher=hs;exports.HostCommandQueue=ht;exports.INDEX_BITS=W;exports.INDEX_MASK=Re;exports.INITIAL_GENERATION=Nt;exports.MAX_ENTITY_ID=ge;exports.MAX_GENERATION=J;exports.MAX_INDEX=U;exports.MAX_LIVE_GENERATION=Lt;exports.NO_SWAP=yt;exports.RELATION_TARGET_FIELD=at;exports.RETIRED_GENERATION=vt;exports.SCHEDULE=B;exports.SIM_ABI_VERSION=Qe;exports.STORE_DESCRIPTOR_COMPONENT_LIMIT=Ht;exports.STORE_HEADER_BYTES=Ze;exports.STORE_HEADER_OFFSETS=E;exports.STORE_MAGIC=je;exports.STORE_MAX_BYTE_OFFSET=de;exports.STORE_PREFIX_REGIONS=q;exports.Schedule=os;exports.SparseComponentStore=Pn;exports.SparseRestoreError=y;exports.StoreLayoutOverflowError=Ce;exports.TYPED_ARRAY_TAG_TO_TYPE_TAG=xt;exports.TYPE_TAG_STRIDE=Te;exports.UNASSIGNED=At;exports.accessCheck=K;exports.alignUp=be;exports.applyHostCommand=ae;exports.archetypeDescriptorBytes=we;exports.buildArchetypeViews=ot;exports.buildEntityIndexViews=on;exports.columnKey=rt;exports.componentDebugName=$t;exports.componentLabel=Ke;exports.createColumnStore=Un;exports.createEntityId=Ut;exports.dispatchTrace=ns;exports.entityNotAliveError=Mt;exports.findRegionEntry=Cn;exports.findRegionOffset=On;exports.fnv1aStepWord=Mn;exports.getEntityGeneration=pe;exports.getEntityIndex=L;exports.installHostCommandSeam=gs;exports.isColumnStoreInternal=Ln;exports.isEcsError=Tt;exports.isNonNegativeInteger=Et;exports.makeRelationStore=Gn;exports.readHeaderRegionTable=Dn;exports.readLayoutDescriptorRegion=Xt;exports.readStoreHeader=Ft;exports.resolveECSMemory=is;exports.restoreRelations=Xn;exports.restoreSparseStores=Bn;exports.ringDespawnCodec=ds;exports.ringDisableCodec=us;exports.ringEnableCodec=fs;exports.ringRemoveComponentCodec=_s;exports.ringSetFieldCodec=ls;exports.setComponentDebugName=Pt;exports.snapshotRelations=Vn;exports.snapshotSparseStores=$n;exports.spawnEntry=as;exports.systemSet=ss;exports.uninstallHostCommandSeam=ms;exports.unsafeCast=gt;exports.validateAndCast=mt;exports.validateSparseStores=Fn;exports.writeArchetypeDescriptor=Je;
|
package/dist/internal.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./host_commands-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./host_commands-C2cpU3yC.cjs"),d="/packages/engine/src/core/ecs/";class h{activeCache=null;repoRootCache=null;buf=new Map;callsiteCache=new Map;isActive(){if(this.activeCache!==null)return this.activeCache;const t=globalThis.process?.env?.VISUAL_INTEL_TRACE;return this.activeCache=t==="1"||t==="true"}repoRoot(){if(this.repoRootCache!==null)return this.repoRootCache;const e=globalThis.process;return this.repoRootCache=e?.cwd?.()??""}resolveCallsite(){return T(new Error().stack??null,this.repoRoot(),this.callsiteCache)}record(e,t,l){const s=this.resolveCallsite();if(!s)return;const o=`${e} ${t} ${l} ${s}`;this.buf.set(o,(this.buf.get(o)??0)+1)}recordEmit(e){this.record("ecs-events","emit",e)}recordRead(e){this.record("ecs-events","read",e)}recordResourceRead(e){this.record("resources","read",e)}recordResourceWrite(e){this.record("resources","write",e)}recordResourceRegister(e){this.record("resources","register",e)}recordResourceRemove(e){this.record("resources","remove",e)}recordSendAction(e){this.record("actions","send_action",e)}recordHandleAction(e){this.record("actions","handle_action",e)}snapshot(){const e={"ecs-events":{emit:[],read:[]},actions:{send_action:[],handle_action:[]},resources:{read:[],write:[],register:[],remove:[]}};for(const[t,l]of this.buf.entries()){const[s,o,n,c]=t.split(" ");if(!s||!o||c===void 0)continue;const u={key:s==="actions"?Number(n):n,file:c,count:l},E=e[s][o];E&&E.push(u)}for(const t of Object.values(e))for(const l of Object.values(t))l.sort((s,o)=>{if(s.file!==o.file)return s.file<o.file?-1:1;const n=String(s.key),c=String(o.key);return n<c?-1:n>c?1:0});return{schemaVersion:1,capturedAt:new Date().toISOString(),channels:e}}reset(){this.buf.clear(),this.callsiteCache.clear(),this.activeCache=null,this.repoRootCache=null}}function _(i){const e=/\(([^)]+):\d+:\d+\)\s*$/.exec(i);if(e)return e[1]??null;const t=/at\s+([^\s][^()]*?):\d+:\d+\s*$/.exec(i);return t&&(t[1]??"").trim()||null}function T(i,e,t){if(!i)return null;const l=i.split(`
|
|
2
2
|
`);for(let s=0;s<l.length;s++){const o=l[s],n=t?.get(o);if(n!==void 0){if(n===null)continue;return n}const c=_(o);if(!c){t?.set(o,null);continue}if(c.includes(d)){t?.set(o,null);continue}const a=C(c,e);return t?.set(o,a),a}return null}function C(i,e){let t=i;return t.startsWith("file://")&&(t=t.slice(7)),e&&t.startsWith(e+"/")&&(t=t.slice(e.length+1)),t.replace(/\\/g,"/")}const R=new h;exports.BUDGET_DEFAULT_ARCHETYPES=r.BUDGET_DEFAULT_ARCHETYPES;exports.BUDGET_DEFAULT_BYTES_PER_ENTITY=r.BUDGET_DEFAULT_BYTES_PER_ENTITY;exports.BUDGET_GROWTH_HEADROOM=r.BUDGET_GROWTH_HEADROOM;exports.DEFAULT_ECS_CAP_BYTES=r.DEFAULT_ECS_CAP_BYTES;exports.HOST_COMMAND_PAYLOAD_BYTES=r.HOST_COMMAND_PAYLOAD_BYTES;exports.HostCommandDispatcher=r.HostCommandDispatcher;exports.MAX_ENTITY_ID=r.MAX_ENTITY_ID;exports.MAX_GENERATION=r.MAX_GENERATION;exports.MAX_INDEX=r.MAX_INDEX;exports.MAX_LIVE_GENERATION=r.MAX_LIVE_GENERATION;exports.RETIRED_GENERATION=r.RETIRED_GENERATION;exports.accessCheck=r.accessCheck;exports.createEntityId=r.createEntityId;exports.getEntityGeneration=r.getEntityGeneration;exports.resolveECSMemory=r.resolveECSMemory;exports.ringDespawnCodec=r.ringDespawnCodec;exports.ringDisableCodec=r.ringDisableCodec;exports.ringEnableCodec=r.ringEnableCodec;exports.ringRemoveComponentCodec=r.ringRemoveComponentCodec;exports.ringSetFieldCodec=r.ringSetFieldCodec;exports.dispatchTrace=R;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./internal-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./internal-CGBEwfeB.cjs");exports.BUDGET_DEFAULT_ARCHETYPES=e.BUDGET_DEFAULT_ARCHETYPES;exports.BUDGET_DEFAULT_BYTES_PER_ENTITY=e.BUDGET_DEFAULT_BYTES_PER_ENTITY;exports.BUDGET_GROWTH_HEADROOM=e.BUDGET_GROWTH_HEADROOM;exports.DEFAULT_ECS_CAP_BYTES=e.DEFAULT_ECS_CAP_BYTES;exports.HOST_COMMAND_PAYLOAD_BYTES=e.HOST_COMMAND_PAYLOAD_BYTES;exports.HostCommandDispatcher=e.HostCommandDispatcher;exports.MAX_ENTITY_ID=e.MAX_ENTITY_ID;exports.MAX_GENERATION=e.MAX_GENERATION;exports.MAX_INDEX=e.MAX_INDEX;exports.MAX_LIVE_GENERATION=e.MAX_LIVE_GENERATION;exports.RETIRED_GENERATION=e.RETIRED_GENERATION;exports.accessCheck=e.accessCheck;exports.createEntityId=e.createEntityId;exports.dispatchTrace=e.dispatchTrace;exports.getEntityGeneration=e.getEntityGeneration;exports.resolveECSMemory=e.resolveECSMemory;exports.ringDespawnCodec=e.ringDespawnCodec;exports.ringDisableCodec=e.ringDisableCodec;exports.ringEnableCodec=e.ringEnableCodec;exports.ringRemoveComponentCodec=e.ringRemoveComponentCodec;exports.ringSetFieldCodec=e.ringSetFieldCodec;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ax as s, aw as e, av as T, au as _, aE as A, ay as o, a4 as D, aG as n, aF as C, aH as r, p as t, h as c, o as i, ad as d, a3 as I, af as N, aA as R, aB as G, aC as O, aD as M, az as S } from "./internal-
|
|
1
|
+
import { ax as s, aw as e, av as T, au as _, aE as A, ay as o, a4 as D, aG as n, aF as C, aH as r, p as t, h as c, o as i, ad as d, a3 as I, af as N, aA as R, aB as G, aC as O, aD as M, az as S } from "./internal-BoxWl4dG.js";
|
|
2
2
|
export {
|
|
3
3
|
s as BUDGET_DEFAULT_ARCHETYPES,
|
|
4
4
|
e as BUDGET_DEFAULT_BYTES_PER_ENTITY,
|
package/dist/internal.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { b as v, a as A, B as g, D as m, i as D, H as S, n as b, l as I, M, m as N, R as O, c as k, j as w, k as y, r as G, e as F, f as B, g as H, h as L, d as U } from "./host_commands-
|
|
1
|
+
import { b as v, a as A, B as g, D as m, i as D, H as S, n as b, l as I, M, m as N, R as O, c as k, j as w, k as y, r as G, e as F, f as B, g as H, h as L, d as U } from "./host_commands-BlR3oZ3x.js";
|
|
2
2
|
const h = "/packages/engine/src/core/ecs/";
|
|
3
3
|
class d {
|
|
4
4
|
activeCache = null;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as h, a as o, b as l, d as p, e as _, c as d, G as b, g as u, h as w, f as G } from "./typed_arrays-
|
|
1
|
+
import { B as h, a as o, b as l, d as p, e as _, c as d, G as b, g as u, h as w, f as G } from "./typed_arrays-DIVwVy5_.js";
|
|
2
2
|
import { B as y, S as A, t as S } from "./topological_sort-DK6EjpWa.js";
|
|
3
3
|
class a {
|
|
4
4
|
_dense = [];
|
package/dist/primitives.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as h, a as o, b as l, d as p, e as _, c as d, G as b, g as u, h as w, f as G } from "./typed_arrays-
|
|
1
|
+
import { B as h, a as o, b as l, d as p, e as _, c as d, G as b, g as u, h as w, f as G } from "./typed_arrays-DIVwVy5_.js";
|
|
2
2
|
import { B as y, S as A, t as S } from "./topological_sort-DK6EjpWa.js";
|
|
3
3
|
class a {
|
|
4
4
|
_dense = [];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Reactive kernel — the engine UI seam's fine-grained, glitch-free reactive core
|
|
3
|
-
*
|
|
2
|
+
* Reactive kernel — the engine UI seam's fine-grained, glitch-free reactive core.
|
|
3
|
+
* Zero dependencies; consumer owns rendering. See docs/api/reactive.md.
|
|
4
4
|
*/
|
|
5
5
|
export { signal, computed, effect, batch, untrack, root, onCleanup, type Accessor, type Setter, type Eq } from './kernel.cjs';
|
|
6
6
|
export { reactiveMap, type ReactiveMap } from './map.cjs';
|
package/dist/reactive/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Reactive kernel — the engine UI seam's fine-grained, glitch-free reactive core
|
|
3
|
-
*
|
|
2
|
+
* Reactive kernel — the engine UI seam's fine-grained, glitch-free reactive core.
|
|
3
|
+
* Zero dependencies; consumer owns rendering. See docs/api/reactive.md.
|
|
4
4
|
*/
|
|
5
5
|
export { signal, computed, effect, batch, untrack, root, onCleanup, type Accessor, type Setter, type Eq } from './kernel.js';
|
|
6
6
|
export { reactiveMap, type ReactiveMap } from './map.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { b as r, c as e, e as t, o, r as c, s as p, u } from "../kernel-Cz2Kxlwl.js";
|
|
2
|
-
import { b as f, r as i, a as l, s as n } from "../shallow-
|
|
2
|
+
import { b as f, r as i, a as l, s as n } from "../shallow-CiFC70Dz.js";
|
|
3
3
|
import { s as x, t as v } from "../interop-DqxleBo7.js";
|
|
4
4
|
export {
|
|
5
5
|
r as batch,
|
package/dist/reactive/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { b as r, c as e, e as t, o, r as c, s as p, u } from "../kernel-DgyrLFjW.js";
|
|
2
|
-
import { b as f, r as i, a as l, s as n } from "../shallow-
|
|
2
|
+
import { b as f, r as i, a as l, s as n } from "../shallow-Bs39EPh1.js";
|
|
3
3
|
import { s as x, t as v } from "../interop-CcY6ASQc.js";
|
|
4
4
|
export {
|
|
5
5
|
r as batch,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* In-house fine-grained reactive kernel — signal / computed / effect / batch,
|
|
3
|
-
* plus ownership scopes (`root` / `onCleanup`). Zero dependencies
|
|
3
|
+
* plus ownership scopes (`root` / `onCleanup`). Zero dependencies.
|
|
4
4
|
*
|
|
5
5
|
* This is the engine UI seam's propagation core. It is the same class of machine
|
|
6
|
-
* as the ECS observer system
|
|
7
|
-
* a fixed point — at a different granularity, which is exactly why
|
|
8
|
-
*
|
|
6
|
+
* as the ECS observer system — fine-grained, glitch-free, cascades to
|
|
7
|
+
* a fixed point — at a different granularity, which is exactly why we own
|
|
8
|
+
* it rather than adopt solid-js / @preact/signals-core / alien-signals.
|
|
9
9
|
*
|
|
10
10
|
* The dependency graph is an intrusive doubly-linked structure. One pooled `Link`
|
|
11
11
|
* per edge is threaded into BOTH the source's subscriber list and the target's
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
* track their sources (no auto-unsubscribe of unobserved computeds — the TRACKING
|
|
35
35
|
* optimization) and there is no global-version fast path. The two help only a
|
|
36
36
|
* workload heavy in *unobserved* computeds and are low-value without each other;
|
|
37
|
-
*
|
|
37
|
+
* Cycle reads return the stale value rather than throwing.
|
|
38
38
|
*/
|
|
39
39
|
export type Eq<T> = (a: T, b: T) => boolean;
|
|
40
40
|
/** A read accessor; calling it inside an effect/computed subscribes to the source. */
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* In-house fine-grained reactive kernel — signal / computed / effect / batch,
|
|
3
|
-
* plus ownership scopes (`root` / `onCleanup`). Zero dependencies
|
|
3
|
+
* plus ownership scopes (`root` / `onCleanup`). Zero dependencies.
|
|
4
4
|
*
|
|
5
5
|
* This is the engine UI seam's propagation core. It is the same class of machine
|
|
6
|
-
* as the ECS observer system
|
|
7
|
-
* a fixed point — at a different granularity, which is exactly why
|
|
8
|
-
*
|
|
6
|
+
* as the ECS observer system — fine-grained, glitch-free, cascades to
|
|
7
|
+
* a fixed point — at a different granularity, which is exactly why we own
|
|
8
|
+
* it rather than adopt solid-js / @preact/signals-core / alien-signals.
|
|
9
9
|
*
|
|
10
10
|
* The dependency graph is an intrusive doubly-linked structure. One pooled `Link`
|
|
11
11
|
* per edge is threaded into BOTH the source's subscriber list and the target's
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
* track their sources (no auto-unsubscribe of unobserved computeds — the TRACKING
|
|
35
35
|
* optimization) and there is no global-version fast path. The two help only a
|
|
36
36
|
* workload heavy in *unobserved* computeds and are low-value without each other;
|
|
37
|
-
*
|
|
37
|
+
* Cycle reads return the stale value rather than throwing.
|
|
38
38
|
*/
|
|
39
39
|
export type Eq<T> = (a: T, b: T) => boolean;
|
|
40
40
|
/** A read accessor; calling it inside an effect/computed subscribes to the source. */
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* "equal write wakes nobody" for projections that build a fresh object each tick.
|
|
6
6
|
*
|
|
7
7
|
* Lives in the kernel entry (`/reactive`) — it has zero ECS dependency
|
|
8
|
-
|
|
8
|
+
*; `/reactive-sync` re-exports it for compatibility.
|
|
9
9
|
*/
|
|
10
10
|
export declare function shallow(a: object, b: object): boolean;
|
|
11
11
|
//# sourceMappingURL=shallow.d.ts.map
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* "equal write wakes nobody" for projections that build a fresh object each tick.
|
|
6
6
|
*
|
|
7
7
|
* Lives in the kernel entry (`/reactive`) — it has zero ECS dependency
|
|
8
|
-
|
|
8
|
+
*; `/reactive-sync` re-exports it for compatibility.
|
|
9
9
|
*/
|
|
10
10
|
export declare function shallow(a: object, b: object): boolean;
|
|
11
11
|
//# sourceMappingURL=shallow.d.ts.map
|
|
@@ -59,7 +59,7 @@ function M(p, l = {}) {
|
|
|
59
59
|
ownKeys: () => i,
|
|
60
60
|
getOwnPropertyDescriptor: (r, o) => a.has(o) ? { get: () => e[o](), enumerable: !0, configurable: !0 } : void 0,
|
|
61
61
|
// Writes go through `set.field(v)` — the proxy is a READ surface, and its
|
|
62
|
-
// public type says so (`Readonly<T
|
|
62
|
+
// public type says so (`Readonly<T>`). The trap backs the
|
|
63
63
|
// type for JS callers / policed casts: without it, a field assignment threw
|
|
64
64
|
// an opaque "Cannot redefine property" (the accessor descriptor above has no
|
|
65
65
|
// setter) and a TYPO'D field silently stuck on the hidden target as a
|
|
@@ -62,7 +62,7 @@ function x(p, i = {}) {
|
|
|
62
62
|
ownKeys: () => l,
|
|
63
63
|
getOwnPropertyDescriptor: (n, o) => a.has(o) ? { get: () => t[o](), enumerable: !0, configurable: !0 } : void 0,
|
|
64
64
|
// Writes go through `set.field(v)` — the proxy is a READ surface, and its
|
|
65
|
-
// public type says so (`Readonly<T
|
|
65
|
+
// public type says so (`Readonly<T>`). The trap backs the
|
|
66
66
|
// type for JS callers / policed casts: without it, a field assignment threw
|
|
67
67
|
// an opaque "Cannot redefine property" (the accessor descriptor above has no
|
|
68
68
|
// setter) and a TYPO'D field silently stuck on the hidden target as a
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
class u extends Error {
|
|
2
|
-
constructor(t, e,
|
|
3
|
-
super(t, n), this.requestedBytes = e, this.capBytes =
|
|
2
|
+
constructor(t, e, a, n) {
|
|
3
|
+
super(t, n), this.requestedBytes = e, this.capBytes = a, this.name = "StoreCapExceededError";
|
|
4
4
|
}
|
|
5
5
|
}
|
|
6
6
|
class c extends Error {
|
|
@@ -10,80 +10,86 @@ class c extends Error {
|
|
|
10
10
|
), this.name = "SabUnavailableError";
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
|
-
const d = (
|
|
13
|
+
const d = (r) => {
|
|
14
14
|
if (typeof SharedArrayBuffer > "u") throw new c();
|
|
15
|
-
return new SharedArrayBuffer(
|
|
15
|
+
return new SharedArrayBuffer(r);
|
|
16
16
|
}, h = 64 * 1024;
|
|
17
|
-
function f(
|
|
17
|
+
function f(r, t, e) {
|
|
18
18
|
if (e <= 0 || !Number.isInteger(e))
|
|
19
|
-
throw new Error(`${
|
|
20
|
-
let
|
|
19
|
+
throw new Error(`${r}: maxBytes must be a positive integer (got ${e})`);
|
|
20
|
+
let a = null;
|
|
21
21
|
const n = (o) => {
|
|
22
22
|
if (o > e)
|
|
23
23
|
throw new u(
|
|
24
|
-
`${
|
|
24
|
+
`${r}: requested ${o} bytes exceeds the by-design maxBytes cap of ${e}. This is a hard ceiling with no grow-beyond-cap fallback; a real workload stays ~16 MiB. Reaching it signals runaway entity/column growth upstream — diagnose that rather than raising the cap blindly.`,
|
|
25
25
|
o,
|
|
26
26
|
e
|
|
27
27
|
);
|
|
28
|
-
return
|
|
28
|
+
return a === null ? (a = t.create(o, e), a) : (o > a.byteLength && t.growTo(a, o), a);
|
|
29
29
|
};
|
|
30
30
|
return Object.defineProperty(n, "isInPlace", { value: !0, enumerable: !0 }), n;
|
|
31
31
|
}
|
|
32
|
-
function w(
|
|
32
|
+
function w(r = 256 * 1024 * 1024) {
|
|
33
33
|
if (typeof SharedArrayBuffer > "u") throw new c();
|
|
34
34
|
return f(
|
|
35
|
-
"
|
|
35
|
+
"growableSabAllocator",
|
|
36
36
|
{
|
|
37
37
|
create: (t, e) => {
|
|
38
|
-
const
|
|
39
|
-
return new
|
|
38
|
+
const a = SharedArrayBuffer;
|
|
39
|
+
return new a(t, { maxByteLength: e });
|
|
40
40
|
},
|
|
41
41
|
// boundary: SharedArrayBuffer.grow is in the spec but not in all
|
|
42
42
|
// lib types; widen here so the rest of the layer doesn't need to.
|
|
43
43
|
growTo: (t, e) => t.grow(e)
|
|
44
44
|
},
|
|
45
|
-
|
|
45
|
+
r
|
|
46
46
|
);
|
|
47
47
|
}
|
|
48
|
-
function b(
|
|
48
|
+
function b(r = 256 * 1024 * 1024) {
|
|
49
49
|
return f(
|
|
50
|
-
"
|
|
50
|
+
"heapArraybufferAllocator",
|
|
51
51
|
{
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
//
|
|
57
|
-
//
|
|
58
|
-
//
|
|
59
|
-
|
|
52
|
+
// Reserve the whole cap as ONE fixed buffer. `byteLength` (the current
|
|
53
|
+
// need) is ignored: the buffer never resizes, so it must be born at the
|
|
54
|
+
// ceiling. Lazy page-faulting keeps RSS proportional to real use.
|
|
55
|
+
create: (t, e) => new ArrayBuffer(e),
|
|
56
|
+
// Unreachable: the buffer is created at `maxByteLength`, so
|
|
57
|
+
// `makeGrowableAllocator`'s `bytes > buffer.byteLength` guard never fires
|
|
58
|
+
// (a byte count past the cap throws first). A fixed `ArrayBuffer` has no
|
|
59
|
+
// `.resize()`; assert loudly rather than attempt one, in case the guard
|
|
60
|
+
// logic ever changes.
|
|
61
|
+
growTo: () => {
|
|
62
|
+
throw new Error(
|
|
63
|
+
"heap_arraybuffer_allocator: the heap buffer is fixed at maxBytes and must never grow — growth relocates columns within the buffer, not the buffer itself"
|
|
64
|
+
);
|
|
65
|
+
}
|
|
60
66
|
},
|
|
61
|
-
|
|
67
|
+
r
|
|
62
68
|
);
|
|
63
69
|
}
|
|
64
|
-
function g(
|
|
65
|
-
if (!(
|
|
70
|
+
function g(r) {
|
|
71
|
+
if (!(r.buffer instanceof SharedArrayBuffer))
|
|
66
72
|
throw new Error(
|
|
67
|
-
"
|
|
73
|
+
"wasmMemoryAllocator: WebAssembly.Memory must be constructed with `shared: true` so its buffer is a SharedArrayBuffer"
|
|
68
74
|
);
|
|
69
|
-
const t = () =>
|
|
70
|
-
const n =
|
|
71
|
-
if (
|
|
75
|
+
const t = () => r.buffer, e = (a) => {
|
|
76
|
+
const n = r.buffer.byteLength;
|
|
77
|
+
if (a <= n)
|
|
72
78
|
return t();
|
|
73
|
-
const o = Math.ceil((
|
|
79
|
+
const o = Math.ceil((a - n) / h), s = (i) => (
|
|
74
80
|
// The JS API doesn't expose the Memory's `maximum`, so the cap is
|
|
75
81
|
// reported as unknowable (`null`) — the caller declared it at
|
|
76
82
|
// `new WebAssembly.Memory({ maximum })` time.
|
|
77
83
|
new u(
|
|
78
|
-
`wasm_memory_allocator: memory.grow(${o}) failed (current=${n} bytes, requested=${
|
|
79
|
-
|
|
84
|
+
`wasm_memory_allocator: memory.grow(${o}) failed (current=${n} bytes, requested=${a} bytes, maximum may be reached)`,
|
|
85
|
+
a,
|
|
80
86
|
null,
|
|
81
87
|
{ cause: i }
|
|
82
88
|
)
|
|
83
89
|
);
|
|
84
90
|
let l;
|
|
85
91
|
try {
|
|
86
|
-
l =
|
|
92
|
+
l = r.grow(o);
|
|
87
93
|
} catch (i) {
|
|
88
94
|
throw s(i);
|
|
89
95
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";class l extends Error{constructor(t,e,a,n){super(t,n),this.requestedBytes=e,this.capBytes=a,this.name="StoreCapExceededError"}}class s 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: { heap: {} }`), which is backed by a plain ArrayBuffer and needs no SAB / no COOP+COEP. In Bun/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 h=r=>{if(typeof SharedArrayBuffer>"u")throw new s;return new SharedArrayBuffer(r)},d=64*1024;function f(r,t,e){if(e<=0||!Number.isInteger(e))throw new Error(`${r}: maxBytes must be a positive integer (got ${e})`);let a=null;const n=o=>{if(o>e)throw new l(`${r}: requested ${o} bytes exceeds the by-design maxBytes cap of ${e}. This is a hard ceiling with no grow-beyond-cap fallback; a real workload stays ~16 MiB. Reaching it signals runaway entity/column growth upstream — diagnose that rather than raising the cap blindly.`,o,e);return a===null?(a=t.create(o,e),a):(o>a.byteLength&&t.growTo(a,o),a)};return Object.defineProperty(n,"isInPlace",{value:!0,enumerable:!0}),n}function w(r=256*1024*1024){if(typeof SharedArrayBuffer>"u")throw new s;return f("growableSabAllocator",{create:(t,e)=>{const a=SharedArrayBuffer;return new a(t,{maxByteLength:e})},growTo:(t,e)=>t.grow(e)},r)}function b(r=256*1024*1024){return f("heapArraybufferAllocator",{create:(t,e)=>new ArrayBuffer(e),growTo:()=>{throw new Error("heap_arraybuffer_allocator: the heap buffer is fixed at maxBytes and must never grow — growth relocates columns within the buffer, not the buffer itself")}},r)}function A(r){if(!(r.buffer instanceof SharedArrayBuffer))throw new Error("wasmMemoryAllocator: WebAssembly.Memory must be constructed with `shared: true` so its buffer is a SharedArrayBuffer");const t=()=>r.buffer,e=a=>{const n=r.buffer.byteLength;if(a<=n)return t();const o=Math.ceil((a-n)/d),u=i=>new l(`wasm_memory_allocator: memory.grow(${o}) failed (current=${n} bytes, requested=${a} bytes, maximum may be reached)`,a,null,{cause:i});let c;try{c=r.grow(o)}catch(i){throw u(i)}if(c===-1)throw u();return t()};return Object.defineProperty(e,"isInPlace",{value:!0,enumerable:!0}),e}exports.DEFAULT_SAB_ALLOCATOR=h;exports.SabUnavailableError=s;exports.StoreCapExceededError=l;exports.growableSabAllocator=w;exports.heapArraybufferAllocator=b;exports.wasmMemoryAllocator=A;
|
package/dist/shared.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./shared-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./shared-DU78k0pU.cjs");exports.DEFAULT_SAB_ALLOCATOR=a.DEFAULT_SAB_ALLOCATOR;exports.SabUnavailableError=a.SabUnavailableError;exports.growableSabAllocator=a.growableSabAllocator;exports.wasmMemoryAllocator=a.wasmMemoryAllocator;
|
package/dist/shared.d.cts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* `@oasys/oecs/shared` — the opt-in SharedArrayBuffer / WASM profile.
|
|
3
3
|
*
|
|
4
4
|
* The default `@oasys/oecs` profile runs the column store over a plain
|
|
5
|
-
*
|
|
5
|
+
* fixed `ArrayBuffer` (no cross-origin isolation). This entry surfaces the
|
|
6
6
|
* `SharedArrayBuffer`-backed allocators for worlds that opt into worker offload
|
|
7
7
|
* or a WASM compute backend — construct with `new ECS({ memory: { shared: {} } })`,
|
|
8
8
|
* or pass one of these allocators through `memory: { allocator }`.
|
package/dist/shared.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* `@oasys/oecs/shared` — the opt-in SharedArrayBuffer / WASM profile.
|
|
3
3
|
*
|
|
4
4
|
* The default `@oasys/oecs` profile runs the column store over a plain
|
|
5
|
-
*
|
|
5
|
+
* fixed `ArrayBuffer` (no cross-origin isolation). This entry surfaces the
|
|
6
6
|
* `SharedArrayBuffer`-backed allocators for worlds that opt into worker offload
|
|
7
7
|
* or a WASM compute backend — construct with `new ECS({ memory: { shared: {} } })`,
|
|
8
8
|
* or pass one of these allocators through `memory: { allocator }`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./shared-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./shared-DU78k0pU.cjs");exports.DEFAULT_SAB_ALLOCATOR=a.DEFAULT_SAB_ALLOCATOR;exports.SabUnavailableError=a.SabUnavailableError;exports.growableSabAllocator=a.growableSabAllocator;exports.wasmMemoryAllocator=a.wasmMemoryAllocator;
|
package/dist/shared.js
CHANGED
|
@@ -34,7 +34,7 @@ export interface ColumnBacking<T extends AnyTypedArray> {
|
|
|
34
34
|
bulkAppendZeroes(count: number): void;
|
|
35
35
|
bulkAppendValue(value: number, count: number): void;
|
|
36
36
|
/** Set the logical length directly, declaring that `[0, len)` already holds
|
|
37
|
-
* valid data. The snapshot-mount path (`Archetype.restoreHostRows
|
|
37
|
+
* valid data. The snapshot-mount path (`Archetype.restoreHostRows`)
|
|
38
38
|
* uses this: a restored SAB carries the column bytes, but the column's logical
|
|
39
39
|
* length is host state that must be re-synced with `Archetype.length`. Throws
|
|
40
40
|
* if `len` exceeds capacity. NOT a hot-path method — push/pop track length. */
|
|
@@ -60,7 +60,7 @@ export declare class GrowableTypedArray<T extends AnyTypedArray> implements Colu
|
|
|
60
60
|
*/
|
|
61
61
|
swapRemove(i: number): number;
|
|
62
62
|
clear(): void;
|
|
63
|
-
/** Set the logical length directly (snapshot-mount reconstruction
|
|
63
|
+
/** Set the logical length directly (snapshot-mount reconstruction). The
|
|
64
64
|
* caller guarantees `[0, len)` already holds valid data. Grows the backing if
|
|
65
65
|
* needed so the length is always representable. */
|
|
66
66
|
setLength(len: number): void;
|
|
@@ -34,7 +34,7 @@ export interface ColumnBacking<T extends AnyTypedArray> {
|
|
|
34
34
|
bulkAppendZeroes(count: number): void;
|
|
35
35
|
bulkAppendValue(value: number, count: number): void;
|
|
36
36
|
/** Set the logical length directly, declaring that `[0, len)` already holds
|
|
37
|
-
* valid data. The snapshot-mount path (`Archetype.restoreHostRows
|
|
37
|
+
* valid data. The snapshot-mount path (`Archetype.restoreHostRows`)
|
|
38
38
|
* uses this: a restored SAB carries the column bytes, but the column's logical
|
|
39
39
|
* length is host state that must be re-synced with `Archetype.length`. Throws
|
|
40
40
|
* if `len` exceeds capacity. NOT a hot-path method — push/pop track length. */
|
|
@@ -60,7 +60,7 @@ export declare class GrowableTypedArray<T extends AnyTypedArray> implements Colu
|
|
|
60
60
|
*/
|
|
61
61
|
swapRemove(i: number): number;
|
|
62
62
|
clear(): void;
|
|
63
|
-
/** Set the logical length directly (snapshot-mount reconstruction
|
|
63
|
+
/** Set the logical length directly (snapshot-mount reconstruction). The
|
|
64
64
|
* caller guarantees `[0, len)` already holds valid data. Grows the backing if
|
|
65
65
|
* needed so the length is always representable. */
|
|
66
66
|
setLength(len: number): void;
|
|
@@ -143,7 +143,7 @@ class _ {
|
|
|
143
143
|
clear() {
|
|
144
144
|
this._len = 0;
|
|
145
145
|
}
|
|
146
|
-
/** Set the logical length directly (snapshot-mount reconstruction
|
|
146
|
+
/** Set the logical length directly (snapshot-mount reconstruction). The
|
|
147
147
|
* caller guarantees `[0, len)` already holds valid data. Grows the backing if
|
|
148
148
|
* needed so the length is always representable. */
|
|
149
149
|
setLength(t) {
|
package/dist/version.d.cts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The package version, readable at runtime
|
|
2
|
+
* The package version, readable at runtime.
|
|
3
3
|
*
|
|
4
4
|
* A literal, not a build-time injection, so raw-source (JSR) consumers get the
|
|
5
5
|
* same value as the npm bundle. Kept in lock-step with `package.json` /
|
|
6
6
|
* `jsr.json` by `src/__tests__/version_sync.test.ts` — bump all three
|
|
7
7
|
* together.
|
|
8
8
|
*/
|
|
9
|
-
export declare const VERSION = "0.5.
|
|
9
|
+
export declare const VERSION = "0.5.4";
|
|
10
10
|
//# sourceMappingURL=version.d.ts.map
|
package/dist/version.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The package version, readable at runtime
|
|
2
|
+
* The package version, readable at runtime.
|
|
3
3
|
*
|
|
4
4
|
* A literal, not a build-time injection, so raw-source (JSR) consumers get the
|
|
5
5
|
* same value as the npm bundle. Kept in lock-step with `package.json` /
|
|
6
6
|
* `jsr.json` by `src/__tests__/version_sync.test.ts` — bump all three
|
|
7
7
|
* together.
|
|
8
8
|
*/
|
|
9
|
-
export declare const VERSION = "0.5.
|
|
9
|
+
export declare const VERSION = "0.5.4";
|
|
10
10
|
//# sourceMappingURL=version.d.ts.map
|