@oasys/oecs 0.3.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (324) hide show
  1. package/CHANGELOG.md +553 -0
  2. package/README.md +207 -267
  3. package/dist/core/ecs/access_check.d.cts +77 -0
  4. package/dist/core/ecs/access_check.d.ts +77 -0
  5. package/dist/core/ecs/access_check.d.ts.map +1 -0
  6. package/dist/core/ecs/archetype.d.cts +486 -0
  7. package/dist/core/ecs/archetype.d.ts +486 -0
  8. package/dist/core/ecs/archetype.d.ts.map +1 -0
  9. package/dist/core/ecs/archetype_graph.d.cts +96 -0
  10. package/dist/core/ecs/archetype_graph.d.ts +96 -0
  11. package/dist/core/ecs/archetype_graph.d.ts.map +1 -0
  12. package/dist/core/ecs/builtin_relations.d.cts +43 -0
  13. package/dist/core/ecs/builtin_relations.d.ts +43 -0
  14. package/dist/core/ecs/builtin_relations.d.ts.map +1 -0
  15. package/dist/core/ecs/command_log.d.cts +116 -0
  16. package/dist/core/ecs/command_log.d.ts +116 -0
  17. package/dist/core/ecs/command_log.d.ts.map +1 -0
  18. package/dist/core/ecs/component.d.cts +176 -0
  19. package/dist/core/ecs/component.d.ts +176 -0
  20. package/dist/core/ecs/component.d.ts.map +1 -0
  21. package/dist/core/ecs/compute_backend.d.cts +37 -0
  22. package/dist/core/ecs/compute_backend.d.ts +37 -0
  23. package/dist/core/ecs/compute_backend.d.ts.map +1 -0
  24. package/dist/core/ecs/debug_names.d.cts +7 -0
  25. package/dist/core/ecs/debug_names.d.ts +7 -0
  26. package/dist/core/ecs/debug_names.d.ts.map +1 -0
  27. package/dist/core/ecs/deferred_commands.d.cts +55 -0
  28. package/dist/core/ecs/deferred_commands.d.ts +55 -0
  29. package/dist/core/ecs/deferred_commands.d.ts.map +1 -0
  30. package/dist/core/ecs/dispatch_trace.d.cts +93 -0
  31. package/dist/core/ecs/dispatch_trace.d.ts +93 -0
  32. package/dist/core/ecs/dispatch_trace.d.ts.map +1 -0
  33. package/dist/core/ecs/ecs.d.cts +562 -0
  34. package/dist/core/ecs/ecs.d.ts +562 -0
  35. package/dist/core/ecs/ecs.d.ts.map +1 -0
  36. package/dist/core/ecs/ecs_memory.d.cts +179 -0
  37. package/dist/core/ecs/ecs_memory.d.ts +179 -0
  38. package/dist/core/ecs/ecs_memory.d.ts.map +1 -0
  39. package/dist/core/ecs/entity.d.cts +34 -0
  40. package/dist/core/ecs/entity.d.ts +34 -0
  41. package/dist/core/ecs/entity.d.ts.map +1 -0
  42. package/dist/core/ecs/entity_allocator.d.cts +59 -0
  43. package/dist/core/ecs/entity_allocator.d.ts +59 -0
  44. package/dist/core/ecs/entity_allocator.d.ts.map +1 -0
  45. package/dist/core/ecs/event.d.cts +79 -0
  46. package/dist/core/ecs/event.d.ts +79 -0
  47. package/dist/core/ecs/event.d.ts.map +1 -0
  48. package/dist/core/ecs/event_registry.d.cts +22 -0
  49. package/dist/core/ecs/event_registry.d.ts +22 -0
  50. package/dist/core/ecs/event_registry.d.ts.map +1 -0
  51. package/dist/core/ecs/facades.d.cts +158 -0
  52. package/dist/core/ecs/facades.d.ts +158 -0
  53. package/dist/core/ecs/facades.d.ts.map +1 -0
  54. package/dist/core/ecs/frame_stepper.d.cts +58 -0
  55. package/dist/core/ecs/frame_stepper.d.ts +58 -0
  56. package/dist/core/ecs/frame_stepper.d.ts.map +1 -0
  57. package/dist/core/ecs/frame_trace.d.cts +133 -0
  58. package/dist/core/ecs/frame_trace.d.ts +133 -0
  59. package/dist/core/ecs/frame_trace.d.ts.map +1 -0
  60. package/dist/core/ecs/host_commands.d.cts +274 -0
  61. package/dist/core/ecs/host_commands.d.ts +274 -0
  62. package/dist/core/ecs/host_commands.d.ts.map +1 -0
  63. package/dist/core/ecs/index.d.cts +46 -0
  64. package/dist/core/ecs/index.d.ts +46 -0
  65. package/dist/core/ecs/index.d.ts.map +1 -0
  66. package/dist/core/ecs/observer.d.cts +173 -0
  67. package/dist/core/ecs/observer.d.ts +173 -0
  68. package/dist/core/ecs/observer.d.ts.map +1 -0
  69. package/dist/core/ecs/query.d.cts +718 -0
  70. package/dist/core/ecs/query.d.ts +718 -0
  71. package/dist/core/ecs/query.d.ts.map +1 -0
  72. package/dist/core/ecs/ref.d.cts +31 -0
  73. package/dist/core/ecs/ref.d.ts +31 -0
  74. package/dist/core/ecs/ref.d.ts.map +1 -0
  75. package/dist/core/ecs/relation.d.cts +243 -0
  76. package/dist/core/ecs/relation.d.ts +243 -0
  77. package/dist/core/ecs/relation.d.ts.map +1 -0
  78. package/dist/core/ecs/relation_service.d.cts +235 -0
  79. package/dist/core/ecs/relation_service.d.ts +235 -0
  80. package/dist/core/ecs/relation_service.d.ts.map +1 -0
  81. package/dist/core/ecs/resource.d.cts +53 -0
  82. package/dist/core/ecs/resource.d.ts +53 -0
  83. package/dist/core/ecs/resource.d.ts.map +1 -0
  84. package/dist/core/ecs/resource_registry.d.cts +20 -0
  85. package/dist/core/ecs/resource_registry.d.ts +20 -0
  86. package/dist/core/ecs/resource_registry.d.ts.map +1 -0
  87. package/dist/core/ecs/resume.d.cts +85 -0
  88. package/dist/core/ecs/resume.d.ts +85 -0
  89. package/dist/core/ecs/resume.d.ts.map +1 -0
  90. package/dist/core/ecs/run_condition.d.cts +81 -0
  91. package/dist/core/ecs/run_condition.d.ts +81 -0
  92. package/dist/core/ecs/run_condition.d.ts.map +1 -0
  93. package/dist/core/ecs/schedule.d.cts +142 -0
  94. package/dist/core/ecs/schedule.d.ts +142 -0
  95. package/dist/core/ecs/schedule.d.ts.map +1 -0
  96. package/dist/core/ecs/snapshot_service.d.cts +94 -0
  97. package/dist/core/ecs/snapshot_service.d.ts +94 -0
  98. package/dist/core/ecs/snapshot_service.d.ts.map +1 -0
  99. package/dist/core/ecs/sparse_store.d.cts +110 -0
  100. package/dist/core/ecs/sparse_store.d.ts +110 -0
  101. package/dist/core/ecs/sparse_store.d.ts.map +1 -0
  102. package/dist/core/ecs/store.d.cts +950 -0
  103. package/dist/core/ecs/store.d.ts +950 -0
  104. package/dist/core/ecs/store.d.ts.map +1 -0
  105. package/dist/core/ecs/store_layout_listener.d.cts +23 -0
  106. package/dist/core/ecs/store_layout_listener.d.ts +23 -0
  107. package/dist/core/ecs/store_layout_listener.d.ts.map +1 -0
  108. package/dist/core/ecs/system.d.cts +250 -0
  109. package/dist/core/ecs/system.d.ts +250 -0
  110. package/dist/core/ecs/system.d.ts.map +1 -0
  111. package/dist/core/ecs/utils/arrays.d.cts +7 -0
  112. package/dist/{utils → core/ecs/utils}/arrays.d.ts +2 -1
  113. package/dist/core/ecs/utils/arrays.d.ts.map +1 -0
  114. package/dist/core/ecs/utils/constants.d.ts +12 -0
  115. package/dist/core/ecs/utils/constants.d.ts.map +1 -0
  116. package/dist/core/ecs/utils/error.d.cts +61 -0
  117. package/dist/core/ecs/utils/error.d.ts +61 -0
  118. package/dist/core/ecs/utils/error.d.ts.map +1 -0
  119. package/dist/core/store/action_ring.d.cts +136 -0
  120. package/dist/core/store/action_ring.d.ts +136 -0
  121. package/dist/core/store/action_ring.d.ts.map +1 -0
  122. package/dist/core/store/allocator.d.cts +238 -0
  123. package/dist/core/store/allocator.d.ts +238 -0
  124. package/dist/core/store/allocator.d.ts.map +1 -0
  125. package/dist/core/store/buffer_backed_column.d.cts +69 -0
  126. package/dist/core/store/buffer_backed_column.d.ts +69 -0
  127. package/dist/core/store/buffer_backed_column.d.ts.map +1 -0
  128. package/dist/core/store/column_store.d.cts +273 -0
  129. package/dist/core/store/column_store.d.ts +273 -0
  130. package/dist/core/store/column_store.d.ts.map +1 -0
  131. package/dist/core/store/command_dispatch.d.cts +52 -0
  132. package/dist/core/store/command_dispatch.d.ts +52 -0
  133. package/dist/core/store/command_dispatch.d.ts.map +1 -0
  134. package/dist/core/store/command_ring.d.cts +107 -0
  135. package/dist/core/store/command_ring.d.ts +107 -0
  136. package/dist/core/store/command_ring.d.ts.map +1 -0
  137. package/dist/core/store/descriptor.d.cts +80 -0
  138. package/dist/core/store/descriptor.d.ts +80 -0
  139. package/dist/core/store/descriptor.d.ts.map +1 -0
  140. package/dist/core/store/entity_index.d.cts +108 -0
  141. package/dist/core/store/entity_index.d.ts +108 -0
  142. package/dist/core/store/entity_index.d.ts.map +1 -0
  143. package/dist/core/store/event_ring.d.cts +95 -0
  144. package/dist/core/store/event_ring.d.ts +95 -0
  145. package/dist/core/store/event_ring.d.ts.map +1 -0
  146. package/dist/core/store/extend.d.cts +39 -0
  147. package/dist/core/store/extend.d.ts +39 -0
  148. package/dist/core/store/extend.d.ts.map +1 -0
  149. package/dist/core/store/grow.d.cts +34 -0
  150. package/dist/core/store/grow.d.ts +34 -0
  151. package/dist/core/store/grow.d.ts.map +1 -0
  152. package/dist/core/store/header.d.cts +64 -0
  153. package/dist/core/store/header.d.ts +64 -0
  154. package/dist/core/store/header.d.ts.map +1 -0
  155. package/dist/core/store/index.d.cts +17 -0
  156. package/dist/core/store/index.d.ts +17 -0
  157. package/dist/core/store/index.d.ts.map +1 -0
  158. package/dist/core/store/layout_ops.d.cts +152 -0
  159. package/dist/core/store/layout_ops.d.ts +152 -0
  160. package/dist/core/store/layout_ops.d.ts.map +1 -0
  161. package/dist/core/store/region_table.d.cts +74 -0
  162. package/dist/core/store/region_table.d.ts +74 -0
  163. package/dist/core/store/region_table.d.ts.map +1 -0
  164. package/dist/core/store/snapshot.d.cts +43 -0
  165. package/dist/core/store/snapshot.d.ts +43 -0
  166. package/dist/core/store/snapshot.d.ts.map +1 -0
  167. package/dist/core/store/state_hash.d.cts +38 -0
  168. package/dist/core/store/state_hash.d.ts +38 -0
  169. package/dist/core/store/state_hash.d.ts.map +1 -0
  170. package/dist/core/store/store_regions.d.cts +38 -0
  171. package/dist/core/store/store_regions.d.ts +38 -0
  172. package/dist/core/store/store_regions.d.ts.map +1 -0
  173. package/dist/core/store/vendored_abi/abi.d.cts +43 -0
  174. package/dist/core/store/vendored_abi/abi.d.ts +43 -0
  175. package/dist/core/store/vendored_abi/abi.d.ts.map +1 -0
  176. package/dist/dev_flag.d.cts +17 -0
  177. package/dist/dev_flag.d.ts +17 -0
  178. package/dist/dev_flag.d.ts.map +1 -0
  179. package/dist/extensions/editor/editor.d.cts +170 -0
  180. package/dist/extensions/editor/editor.d.ts +170 -0
  181. package/dist/extensions/editor/editor.d.ts.map +1 -0
  182. package/dist/extensions/editor/field_handle.d.cts +40 -0
  183. package/dist/extensions/editor/field_handle.d.ts +40 -0
  184. package/dist/extensions/editor/field_handle.d.ts.map +1 -0
  185. package/dist/extensions/editor/index.cjs +1 -0
  186. package/dist/extensions/editor/index.d.cts +21 -0
  187. package/dist/extensions/editor/index.d.ts +21 -0
  188. package/dist/extensions/editor/index.d.ts.map +1 -0
  189. package/dist/extensions/editor/index.js +237 -0
  190. package/dist/extensions/reactive/ecs_sync.d.cts +214 -0
  191. package/dist/extensions/reactive/ecs_sync.d.ts +214 -0
  192. package/dist/extensions/reactive/ecs_sync.d.ts.map +1 -0
  193. package/dist/extensions/reactive/index.cjs +1 -0
  194. package/dist/extensions/reactive/index.d.cts +23 -0
  195. package/dist/extensions/reactive/index.d.ts +23 -0
  196. package/dist/extensions/reactive/index.d.ts.map +1 -0
  197. package/dist/extensions/reactive/index.js +215 -0
  198. package/dist/extensions/solid/index.cjs +1 -0
  199. package/dist/extensions/solid/index.d.cts +6 -0
  200. package/dist/extensions/solid/index.d.ts +6 -0
  201. package/dist/extensions/solid/index.d.ts.map +1 -0
  202. package/dist/extensions/solid/index.js +36 -0
  203. package/dist/extensions/solid/kernel_solid.d.cts +45 -0
  204. package/dist/extensions/solid/kernel_solid.d.ts +45 -0
  205. package/dist/extensions/solid/kernel_solid.d.ts.map +1 -0
  206. package/dist/host_commands-BF8QMi3c.cjs +1 -0
  207. package/dist/host_commands-i4cAeyL5.js +2318 -0
  208. package/dist/index.cjs +1 -1
  209. package/dist/index.d.cts +66 -0
  210. package/dist/index.d.ts +65 -12
  211. package/dist/index.d.ts.map +1 -1
  212. package/dist/index.js +7080 -1289
  213. package/dist/internal.cjs +2 -0
  214. package/dist/internal.d.cts +20 -0
  215. package/dist/internal.d.ts +20 -0
  216. package/dist/internal.d.ts.map +1 -0
  217. package/dist/internal.js +141 -0
  218. package/dist/interop-CT-REx0W.cjs +1 -0
  219. package/dist/interop-CcY6ASQc.js +18 -0
  220. package/dist/kernel-DgyrLFjW.js +227 -0
  221. package/dist/kernel-yWV3XnAb.cjs +1 -0
  222. package/dist/primitives.cjs +1 -0
  223. package/dist/primitives.d.cts +18 -0
  224. package/dist/primitives.d.ts +18 -0
  225. package/dist/primitives.d.ts.map +1 -0
  226. package/dist/primitives.js +45 -0
  227. package/dist/reactive/array.d.cts +24 -0
  228. package/dist/reactive/array.d.ts +24 -0
  229. package/dist/reactive/array.d.ts.map +1 -0
  230. package/dist/reactive/index.cjs +1 -0
  231. package/dist/reactive/index.d.cts +11 -0
  232. package/dist/reactive/index.d.ts +11 -0
  233. package/dist/reactive/index.d.ts.map +1 -0
  234. package/dist/reactive/index.js +18 -0
  235. package/dist/reactive/interop.d.cts +19 -0
  236. package/dist/reactive/interop.d.ts +19 -0
  237. package/dist/reactive/interop.d.ts.map +1 -0
  238. package/dist/reactive/kernel.d.cts +73 -0
  239. package/dist/reactive/kernel.d.ts +73 -0
  240. package/dist/reactive/kernel.d.ts.map +1 -0
  241. package/dist/reactive/map.d.cts +16 -0
  242. package/dist/reactive/map.d.ts +16 -0
  243. package/dist/reactive/map.d.ts.map +1 -0
  244. package/dist/reactive/shallow.d.cts +11 -0
  245. package/dist/reactive/shallow.d.ts +11 -0
  246. package/dist/reactive/shallow.d.ts.map +1 -0
  247. package/dist/reactive/struct.d.cts +10 -0
  248. package/dist/reactive/struct.d.ts +10 -0
  249. package/dist/reactive/struct.d.ts.map +1 -0
  250. package/dist/shallow-DQ8aG51_.cjs +1 -0
  251. package/dist/shallow-DfnAm9vG.js +150 -0
  252. package/dist/shared-BU1Cd40h.js +103 -0
  253. package/dist/shared-BymrGTyR.cjs +1 -0
  254. package/dist/shared.cjs +1 -0
  255. package/dist/shared.d.cts +22 -0
  256. package/dist/shared.d.ts +22 -0
  257. package/dist/shared.d.ts.map +1 -0
  258. package/dist/shared.js +7 -0
  259. package/dist/topological_sort-BDvEyb9W.cjs +1 -0
  260. package/dist/topological_sort-DK6EjpWa.js +135 -0
  261. package/dist/type_primitives/assertions.d.cts +32 -0
  262. package/dist/type_primitives/assertions.d.ts +25 -9
  263. package/dist/type_primitives/assertions.d.ts.map +1 -1
  264. package/dist/type_primitives/binary_heap/binary_heap.d.cts +37 -0
  265. package/dist/type_primitives/binary_heap/binary_heap.d.ts +6 -2
  266. package/dist/type_primitives/binary_heap/binary_heap.d.ts.map +1 -1
  267. package/dist/type_primitives/bitset/bitset.d.cts +54 -0
  268. package/dist/type_primitives/bitset/bitset.d.ts +16 -4
  269. package/dist/type_primitives/bitset/bitset.d.ts.map +1 -1
  270. package/dist/type_primitives/brand.d.cts +23 -0
  271. package/dist/type_primitives/brand.d.ts +6 -1
  272. package/dist/type_primitives/brand.d.ts.map +1 -1
  273. package/dist/type_primitives/error.d.cts +16 -0
  274. package/dist/type_primitives/error.d.ts +8 -3
  275. package/dist/type_primitives/error.d.ts.map +1 -1
  276. package/dist/type_primitives/index.d.cts +13 -0
  277. package/dist/type_primitives/index.d.ts +12 -9
  278. package/dist/type_primitives/index.d.ts.map +1 -1
  279. package/dist/type_primitives/sparse_map/sparse_map.d.cts +30 -0
  280. package/dist/type_primitives/sparse_map/sparse_map.d.ts +7 -3
  281. package/dist/type_primitives/sparse_map/sparse_map.d.ts.map +1 -1
  282. package/dist/type_primitives/sparse_set/sparse_set.d.cts +28 -0
  283. package/dist/type_primitives/sparse_set/sparse_set.d.ts +4 -0
  284. package/dist/type_primitives/sparse_set/sparse_set.d.ts.map +1 -1
  285. package/dist/type_primitives/topological_sort/topological_sort.d.cts +29 -0
  286. package/dist/type_primitives/topological_sort/topological_sort.d.ts +7 -3
  287. package/dist/type_primitives/topological_sort/topological_sort.d.ts.map +1 -1
  288. package/dist/type_primitives/typed_arrays/typed_arrays.d.cts +127 -0
  289. package/dist/type_primitives/typed_arrays/typed_arrays.d.ts +53 -16
  290. package/dist/type_primitives/typed_arrays/typed_arrays.d.ts.map +1 -1
  291. package/dist/typed_arrays-BcXcnzB4.js +258 -0
  292. package/dist/typed_arrays-D3NmwtCG.cjs +1 -0
  293. package/dist/utils/error.d.cts +6 -0
  294. package/dist/utils/error.d.ts +2 -20
  295. package/dist/utils/error.d.ts.map +1 -1
  296. package/dist/version.d.cts +10 -0
  297. package/dist/version.d.ts +10 -0
  298. package/dist/version.d.ts.map +1 -0
  299. package/package.json +115 -5
  300. package/dist/archetype.d.ts +0 -108
  301. package/dist/archetype.d.ts.map +0 -1
  302. package/dist/component.d.ts +0 -45
  303. package/dist/component.d.ts.map +0 -1
  304. package/dist/ecs.d.ts +0 -104
  305. package/dist/ecs.d.ts.map +0 -1
  306. package/dist/entity.d.ts +0 -11
  307. package/dist/entity.d.ts.map +0 -1
  308. package/dist/event.d.ts +0 -30
  309. package/dist/event.d.ts.map +0 -1
  310. package/dist/query.d.ts +0 -94
  311. package/dist/query.d.ts.map +0 -1
  312. package/dist/ref.d.ts +0 -23
  313. package/dist/ref.d.ts.map +0 -1
  314. package/dist/resource.d.ts +0 -23
  315. package/dist/resource.d.ts.map +0 -1
  316. package/dist/schedule.d.ts +0 -45
  317. package/dist/schedule.d.ts.map +0 -1
  318. package/dist/store.d.ts +0 -118
  319. package/dist/store.d.ts.map +0 -1
  320. package/dist/system.d.ts +0 -16
  321. package/dist/system.d.ts.map +0 -1
  322. package/dist/utils/arrays.d.ts.map +0 -1
  323. package/dist/utils/constants.d.ts.map +0 -1
  324. /package/dist/{utils/constants.d.ts → core/ecs/utils/constants.d.cts} +0 -0
@@ -0,0 +1,17 @@
1
+ export { STORE_MAGIC, SIM_ABI_VERSION, STORE_HEADER_BYTES, STORE_HEADER_OFFSETS, REGION_TABLE_ENTRY_BYTES, REGION_TABLE_ENTRY_OFFSETS, type StoreHeader, writeStoreHeader, readStoreHeader, bumpViewStamp, isValidSab } from './header.js';
2
+ export { type StoreRegionSpec, type RegionTableEntry, type ColumnStoreRegionHandle, RegionRegistryError, regionTableBytes, validateRegionSpecs, writeRegionTableEntry, readRegionTableEntry, writeRegionTable, readRegionTable, readHeaderRegionTable, findRegionOffset, findRegionEntry } from './region_table.js';
3
+ export { TYPE_TAG, type TypeTagValue, TYPE_TAG_STRIDE, TYPED_ARRAY_TAG_TO_TYPE_TAG, COLUMN_DESCRIPTOR_BYTES, COLUMN_DESCRIPTOR_OFFSETS, type ColumnDescriptor, writeColumnDescriptor, readColumnDescriptor, ARCHETYPE_DESCRIPTOR_HEADER_BYTES, ARCHETYPE_DESCRIPTOR_OFFSETS, COMPONENT_MASK_WORDS, STORE_DESCRIPTOR_COMPONENT_LIMIT, type ArchetypeDescriptor, archetypeDescriptorBytes, writeArchetypeDescriptor, readArchetypeDescriptor, writeLayoutDescriptorRegion, readLayoutDescriptorRegion, layoutDescriptorRegionBytes } from './descriptor.js';
4
+ export { type ColumnSpec, type ArchetypeSpec, type ColumnView, type ArchetypeViews, type ColumnStore, type AnyTypedArray, type CreateColumnStoreOptions, alignUp, buildArchetypeViews, columnKey, createColumnStore, StoreLayoutOverflowError, STORE_MAX_BYTE_OFFSET, COMMAND_RING_DEFAULT_CAPACITY_SLOTS, ENTITY_INDEX_DEFAULT_CAPACITY, EVENT_RING_DEFAULT_CAPACITY_SLOTS } from './column_store.js';
5
+ export { EVENT_OP_EMPTY, EVENT_RING_HEADER_BYTES, EVENT_RING_SLOT_BYTES, EVENT_RING_HEADER_OFFSETS, EventRingError, drainEventRing, eventRingBytes, initEventRing, pendingEventCount, popEvent, pushEvent, ringCapacitySlots as eventRingCapacitySlots, ringOverflow as eventRingOverflow, ringReadHead as eventRingReadHead, ringWriteHead as eventRingWriteHead } from './event_ring.js';
6
+ export { ENTITY_INDEX_HEADER_BYTES, ENTITY_INDEX_BYTES_PER_SLOT, ENTITY_INDEX_HEADER_OFFSETS, EntityIndexError, buildEntityIndexViews, entityIndexCapacity, entityIndexLength, entityIndexRegionBytes, initEntityIndexRegion, setEntityIndexLength } from './entity_index.js';
7
+ export { COMMAND_OP_EMPTY, COMMAND_RING_HEADER_BYTES, COMMAND_RING_SLOT_BYTES, COMMAND_RING_HEADER_OFFSETS, CommandRingError, commandRingBytes, drainCommandRing, initCommandRing, pendingCommandCount, popCommand, pushCommand, ringCapacitySlots, ringOverflow, ringReadHead, ringWriteHead } from './command_ring.js';
8
+ export { type PayloadCodec, CommandDispatcher } from './command_dispatch.js';
9
+ export { BufferBackedColumn, StoreColumnOverflowError } from './buffer_backed_column.js';
10
+ export { type ArchetypeGrowSpec, type GrowPlan, type GrowResult, StoreGrowError, growColumnStore } from './grow.js';
11
+ export { type ExtendPlan, type ExtendResult, StoreExtendError, extendColumnStore } from './extend.js';
12
+ export { snapshotLiveColumns, restoreColumnSnapshots } from './layout_ops.js';
13
+ export { type BufferAllocator, type InPlaceBufferAllocator, StoreCapExceededError, SabUnavailableError, DEFAULT_SAB_ALLOCATOR, wasmMemoryAllocator, growableSabAllocator, heapArraybufferAllocator } from './allocator.js';
14
+ export { StoreRestoreError, snapshotColumnStore, restoreColumnStore } from './snapshot.js';
15
+ export { FNV1A_OFFSET_BASIS, FNV1A_PRIME, fnv1a32, fnv1aStep, fnv1aStepWord, columnStoreStateHash } from './state_hash.js';
16
+ export { ACTION_RING_DEFAULT_CAPACITY_SLOTS, ACTION_RING_HEADER_BYTES, ACTION_RING_HEADER_OFFSETS, ACTION_RING_MAX_PAYLOAD_BYTES, ACTION_RING_SLOT_BYTES, ActionRingError, actionRingBytes, actionRingCapacitySlots, actionRingOverflow, actionRingReadHead, actionRingWriteHead, clearActionRingOverflow, drainActionRing, initActionRing, pendingActionCount, popAction, pushAction } from './action_ring.js';
17
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/store/index.ts"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,OAAO,EACP,SAAS,EACT,aAAa,EACb,oBAAoB,EACpB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACN,kCAAkC,EAClC,wBAAwB,EACxB,0BAA0B,EAC1B,6BAA6B,EAC7B,sBAAsB,EACtB,eAAe,EACf,eAAe,EACf,uBAAuB,EACvB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,uBAAuB,EACvB,eAAe,EACf,cAAc,EACd,kBAAkB,EAClB,SAAS,EACT,UAAU,EACV,MAAM,eAAe,CAAC"}
@@ -0,0 +1,152 @@
1
+ import { BufferAllocator } from './allocator.cjs';
2
+ import { ArchetypeSpec, ColumnStore, ColumnStoreInternal, CreateColumnStoreOptions } from './column_store.cjs';
3
+ import { ArchetypeDescriptor, TypeTagValue } from './descriptor.cjs';
4
+ import { StoreRegionOffsetField } from './store_regions.cjs';
5
+ /** Per-archetype resize/copy input, shared by `GrowPlan.archetypes` and
6
+ * `ExtendPlan.existing` (so callers can reuse plan-building helpers). The
7
+ * caller picks the new `row_capacity` and declares the current live
8
+ * `row_count` so the copy knows how many rows matter. */
9
+ export interface ArchetypeGrowSpec {
10
+ readonly archetypeId: number;
11
+ readonly newRowCapacity: number;
12
+ readonly rowCount: number;
13
+ }
14
+ /** One archetype's column-layout request for `layoutColumnsAtTail`. `stride`
15
+ * is resolved by the caller — grow reuses the old column's stride verbatim;
16
+ * extend derives it from `TYPE_TAG_STRIDE[typeTag]` for brand-new columns. */
17
+ export interface TailArchetypeLayout {
18
+ readonly archetypeId: number;
19
+ readonly componentMask: ArchetypeDescriptor["componentMask"];
20
+ readonly rowCapacity: number;
21
+ readonly columns: readonly {
22
+ readonly componentId: number;
23
+ readonly fieldId: number;
24
+ readonly typeTag: TypeTagValue;
25
+ readonly stride: number;
26
+ }[];
27
+ }
28
+ /** Tail-cursor column placement — the single home for the in-place paths'
29
+ * layout rule and the 2³¹ offset cap (#382). Starting at `startCursor`
30
+ * (the current buffer byteLength), each archetype's columns are placed
31
+ * `alignUp(cursor, stride)` then advanced by `stride * rowCapacity`; the
32
+ * final tail (last column's advance, not re-aligned) becomes the grown
33
+ * buffer's byteLength and is guarded past `STORE_MAX_BYTE_OFFSET` exactly
34
+ * like `planLayout` guards the create-time layout. Descriptors come back
35
+ * with `rowCount` / `enabledCount` zeroed (the store side of those counters
36
+ * lives with the caller). */
37
+ export declare function layoutColumnsAtTail(startCursor: number, archetypes: readonly TailArchetypeLayout[]): {
38
+ descriptors: ArchetypeDescriptor[];
39
+ newTotal: number;
40
+ };
41
+ /** Grow an in-place-backed store's buffer to `newTotal` and mint the DataView
42
+ * the caller must write headers/descriptors through. `growableSabAllocator` /
43
+ * `heapArraybufferAllocator` return the SAME buffer instance grown in place;
44
+ * `wasmMemoryAllocator` returns a NEW ref over the same linear memory — old
45
+ * typed-array views stay valid either way (the `isInPlace` contract), but
46
+ * when the ref changed the old DataView's byteLength is frozen at the
47
+ * pre-grow size, so a fresh DataView over the new ref is required for any
48
+ * write past that boundary. */
49
+ export declare function growBufferInPlace(old: ColumnStoreInternal, newTotal: number): {
50
+ grownBuffer: ArrayBufferLike;
51
+ newView: DataView;
52
+ };
53
+ /**
54
+ * Derive `CreateColumnStoreOptions` from an old ColumnStore so a slow-path realloc
55
+ * preserves the same set of optional regions at the same byte offsets in the
56
+ * new SAB. Without this, an extend / grow would silently drop a region — the
57
+ * command ring's pending commands, every entity placement in the index, etc.
58
+ * would be lost.
59
+ *
60
+ * Walks `STORE_PREFIX_REGIONS`: each present region's `readOptions` replays the
61
+ * exact capacity the engine configured (regions may carry non-default sizes),
62
+ * not just the default. Live state (write_head, length, …) is preserved
63
+ * separately via `snapshotPrefixRegions`.
64
+ *
65
+ * Also re-applies the descriptor-region headroom policy
66
+ * (`reservedDescriptorBytes`, #541). Unlike the prefix regions this is NOT
67
+ * read from the SAB bytes — it's a JS-side policy carried on
68
+ * `ColumnStoreInternal._reservedDescriptorBytes` — but it belongs here for the
69
+ * same reason: without it the realloc'd store drops to zero descriptor
70
+ * headroom and every later `extendColumnStore` takes the slow path forever.
71
+ * Re-reserving the same margin (additive, see `planLayout`) keeps the #237
72
+ * in-place fast path alive across reallocs.
73
+ */
74
+ export declare function optionsFromOld(old: ColumnStore): CreateColumnStoreOptions;
75
+ /** A prefix-region snapshot: the live bytes of every present region from the
76
+ * old SAB. `mechanism` is keyed by the `StoreHeader` field holding a mechanism
77
+ * region's offset; `consumer` is keyed by `region_id` (consumer regions have no
78
+ * named header field). Pairs `snapshotPrefixRegions` with
79
+ * `restorePrefixRegions`. */
80
+ export interface PrefixRegionSnapshot {
81
+ readonly mechanism: Map<StoreRegionOffsetField, Uint8Array>;
82
+ readonly consumer: Map<number, Uint8Array>;
83
+ }
84
+ /**
85
+ * Snapshot the live bytes of every present region — both engine MECHANISM
86
+ * regions (STORE_PREFIX_REGIONS) and CONSUMER regions (the region-table
87
+ * directory) — from the old SAB BEFORE any allocator call that may detach
88
+ * views. Each entry is a heap `Uint8Array` copy (via `slice()`) so it survives
89
+ * an allocator-induced detach; `restorePrefixRegions` places it back at the
90
+ * matching offset in the new SAB.
91
+ *
92
+ * Header bytes themselves are NOT snapshotted — `createColumnStore` writes the
93
+ * header (and the region-table directory) from scratch with the correct
94
+ * view_stamp (bumped after this call) and offsets.
95
+ */
96
+ export declare function snapshotPrefixRegions(old: ColumnStore): PrefixRegionSnapshot;
97
+ /** Restore prefix-region byte snapshots into `newStore` at the matching
98
+ * region offsets. Pairs with `snapshotPrefixRegions`. The new SAB's regions
99
+ * were sized identically by `optionsFromOld`, so each snapshot lands at the
100
+ * same length its source had — mechanism regions at their named header offset,
101
+ * consumer regions at the offset the rebuilt region-table resolves their id to. */
102
+ export declare function restorePrefixRegions(newStore: ColumnStore, snap: PrefixRegionSnapshot): void;
103
+ /**
104
+ * Snapshot per-archetype live column bytes from `old` BEFORE any
105
+ * subsequent allocator call may detach the underlying typed-array views.
106
+ * Returned shape: `{ archetype_id → Uint8Array[] }`, one entry per
107
+ * column in `columnsInOrder`. Each `Uint8Array` is a fresh copy
108
+ * (not a view) so it survives a `WebAssembly.Memory.grow`. Archetypes
109
+ * with `row_count === 0` are omitted — nothing to copy.
110
+ */
111
+ export declare function snapshotLiveColumns(old: ColumnStore, rowCountsById: Map<number, number>): Map<number, Uint8Array[]>;
112
+ /**
113
+ * Write per-archetype column snapshots produced by `snapshotLiveColumns`
114
+ * into `newStore`'s column views. The snapshot's column ORDER must match
115
+ * the new archetype's `columnsInOrder` (extend / grow guarantee this
116
+ * because they carry the column spec forward unchanged).
117
+ */
118
+ export declare function restoreColumnSnapshots(newStore: ColumnStore, snapshots: Map<number, Uint8Array[]>): void;
119
+ /**
120
+ * The realloc-and-republish slow path shared by `growColumnStore` and
121
+ * `extendColumnStore` — everything between "the specs are decided" and "the
122
+ * caller shapes its result":
123
+ *
124
+ * 1. Capture `view_stamp` and snapshot live rows AND prefix regions
125
+ * (command ring, entity-index) BEFORE the allocator call — the
126
+ * wasmMemoryAllocator may detach `old`'s views on grow, so everything
127
+ * needed is captured first. The prefix-region preservation is the
128
+ * contract `Store` relies on to keep its entity table across resizes
129
+ * (#245); `optionsFromOld` re-reserves regions and descriptor headroom
130
+ * (#541) so the republished store keeps its layout and fast paths.
131
+ * 2. `createColumnStore` with the derived options (fresh buffer; the same
132
+ * growable allocator carries forward so the new buffer also grows in
133
+ * place).
134
+ * 3. Restore live rows + prefix regions. Archetypes without a row count
135
+ * contributed no snapshot and stay zero-initialised; prefix regions
136
+ * overwrite the empty state `createColumnStore` initialised.
137
+ * 4. Bump `view_stamp` from the pre-capture value and patch the returned
138
+ * header so its cached `viewStamp` matches the buffer bytes just
139
+ * written — `createColumnStore` stamped it 0 (#386). `capacity` /
140
+ * `archetype_count` are already correct (createColumnStore sized them),
141
+ * so the spread carries them — and the internal `_allocator` /
142
+ * `_regionBytes` fields — through unchanged.
143
+ *
144
+ * Every view in the returned store is fresh; callers MUST refresh
145
+ * (`viewsPreserved: false` is the callers' contract with THEIR callers).
146
+ */
147
+ export declare function reallocAndRepublish(old: ColumnStore, specs: readonly ArchetypeSpec[], rowCountsById: Map<number, number>, allocator: BufferAllocator | undefined): {
148
+ store: ColumnStore;
149
+ oldViewStamp: number;
150
+ newViewStamp: number;
151
+ };
152
+ //# sourceMappingURL=layout_ops.d.ts.map
@@ -0,0 +1,152 @@
1
+ import { BufferAllocator } from './allocator.js';
2
+ import { ArchetypeSpec, ColumnStore, ColumnStoreInternal, CreateColumnStoreOptions } from './column_store.js';
3
+ import { ArchetypeDescriptor, TypeTagValue } from './descriptor.js';
4
+ import { StoreRegionOffsetField } from './store_regions.js';
5
+ /** Per-archetype resize/copy input, shared by `GrowPlan.archetypes` and
6
+ * `ExtendPlan.existing` (so callers can reuse plan-building helpers). The
7
+ * caller picks the new `row_capacity` and declares the current live
8
+ * `row_count` so the copy knows how many rows matter. */
9
+ export interface ArchetypeGrowSpec {
10
+ readonly archetypeId: number;
11
+ readonly newRowCapacity: number;
12
+ readonly rowCount: number;
13
+ }
14
+ /** One archetype's column-layout request for `layoutColumnsAtTail`. `stride`
15
+ * is resolved by the caller — grow reuses the old column's stride verbatim;
16
+ * extend derives it from `TYPE_TAG_STRIDE[typeTag]` for brand-new columns. */
17
+ export interface TailArchetypeLayout {
18
+ readonly archetypeId: number;
19
+ readonly componentMask: ArchetypeDescriptor["componentMask"];
20
+ readonly rowCapacity: number;
21
+ readonly columns: readonly {
22
+ readonly componentId: number;
23
+ readonly fieldId: number;
24
+ readonly typeTag: TypeTagValue;
25
+ readonly stride: number;
26
+ }[];
27
+ }
28
+ /** Tail-cursor column placement — the single home for the in-place paths'
29
+ * layout rule and the 2³¹ offset cap (#382). Starting at `startCursor`
30
+ * (the current buffer byteLength), each archetype's columns are placed
31
+ * `alignUp(cursor, stride)` then advanced by `stride * rowCapacity`; the
32
+ * final tail (last column's advance, not re-aligned) becomes the grown
33
+ * buffer's byteLength and is guarded past `STORE_MAX_BYTE_OFFSET` exactly
34
+ * like `planLayout` guards the create-time layout. Descriptors come back
35
+ * with `rowCount` / `enabledCount` zeroed (the store side of those counters
36
+ * lives with the caller). */
37
+ export declare function layoutColumnsAtTail(startCursor: number, archetypes: readonly TailArchetypeLayout[]): {
38
+ descriptors: ArchetypeDescriptor[];
39
+ newTotal: number;
40
+ };
41
+ /** Grow an in-place-backed store's buffer to `newTotal` and mint the DataView
42
+ * the caller must write headers/descriptors through. `growableSabAllocator` /
43
+ * `heapArraybufferAllocator` return the SAME buffer instance grown in place;
44
+ * `wasmMemoryAllocator` returns a NEW ref over the same linear memory — old
45
+ * typed-array views stay valid either way (the `isInPlace` contract), but
46
+ * when the ref changed the old DataView's byteLength is frozen at the
47
+ * pre-grow size, so a fresh DataView over the new ref is required for any
48
+ * write past that boundary. */
49
+ export declare function growBufferInPlace(old: ColumnStoreInternal, newTotal: number): {
50
+ grownBuffer: ArrayBufferLike;
51
+ newView: DataView;
52
+ };
53
+ /**
54
+ * Derive `CreateColumnStoreOptions` from an old ColumnStore so a slow-path realloc
55
+ * preserves the same set of optional regions at the same byte offsets in the
56
+ * new SAB. Without this, an extend / grow would silently drop a region — the
57
+ * command ring's pending commands, every entity placement in the index, etc.
58
+ * would be lost.
59
+ *
60
+ * Walks `STORE_PREFIX_REGIONS`: each present region's `readOptions` replays the
61
+ * exact capacity the engine configured (regions may carry non-default sizes),
62
+ * not just the default. Live state (write_head, length, …) is preserved
63
+ * separately via `snapshotPrefixRegions`.
64
+ *
65
+ * Also re-applies the descriptor-region headroom policy
66
+ * (`reservedDescriptorBytes`, #541). Unlike the prefix regions this is NOT
67
+ * read from the SAB bytes — it's a JS-side policy carried on
68
+ * `ColumnStoreInternal._reservedDescriptorBytes` — but it belongs here for the
69
+ * same reason: without it the realloc'd store drops to zero descriptor
70
+ * headroom and every later `extendColumnStore` takes the slow path forever.
71
+ * Re-reserving the same margin (additive, see `planLayout`) keeps the #237
72
+ * in-place fast path alive across reallocs.
73
+ */
74
+ export declare function optionsFromOld(old: ColumnStore): CreateColumnStoreOptions;
75
+ /** A prefix-region snapshot: the live bytes of every present region from the
76
+ * old SAB. `mechanism` is keyed by the `StoreHeader` field holding a mechanism
77
+ * region's offset; `consumer` is keyed by `region_id` (consumer regions have no
78
+ * named header field). Pairs `snapshotPrefixRegions` with
79
+ * `restorePrefixRegions`. */
80
+ export interface PrefixRegionSnapshot {
81
+ readonly mechanism: Map<StoreRegionOffsetField, Uint8Array>;
82
+ readonly consumer: Map<number, Uint8Array>;
83
+ }
84
+ /**
85
+ * Snapshot the live bytes of every present region — both engine MECHANISM
86
+ * regions (STORE_PREFIX_REGIONS) and CONSUMER regions (the region-table
87
+ * directory) — from the old SAB BEFORE any allocator call that may detach
88
+ * views. Each entry is a heap `Uint8Array` copy (via `slice()`) so it survives
89
+ * an allocator-induced detach; `restorePrefixRegions` places it back at the
90
+ * matching offset in the new SAB.
91
+ *
92
+ * Header bytes themselves are NOT snapshotted — `createColumnStore` writes the
93
+ * header (and the region-table directory) from scratch with the correct
94
+ * view_stamp (bumped after this call) and offsets.
95
+ */
96
+ export declare function snapshotPrefixRegions(old: ColumnStore): PrefixRegionSnapshot;
97
+ /** Restore prefix-region byte snapshots into `newStore` at the matching
98
+ * region offsets. Pairs with `snapshotPrefixRegions`. The new SAB's regions
99
+ * were sized identically by `optionsFromOld`, so each snapshot lands at the
100
+ * same length its source had — mechanism regions at their named header offset,
101
+ * consumer regions at the offset the rebuilt region-table resolves their id to. */
102
+ export declare function restorePrefixRegions(newStore: ColumnStore, snap: PrefixRegionSnapshot): void;
103
+ /**
104
+ * Snapshot per-archetype live column bytes from `old` BEFORE any
105
+ * subsequent allocator call may detach the underlying typed-array views.
106
+ * Returned shape: `{ archetype_id → Uint8Array[] }`, one entry per
107
+ * column in `columnsInOrder`. Each `Uint8Array` is a fresh copy
108
+ * (not a view) so it survives a `WebAssembly.Memory.grow`. Archetypes
109
+ * with `row_count === 0` are omitted — nothing to copy.
110
+ */
111
+ export declare function snapshotLiveColumns(old: ColumnStore, rowCountsById: Map<number, number>): Map<number, Uint8Array[]>;
112
+ /**
113
+ * Write per-archetype column snapshots produced by `snapshotLiveColumns`
114
+ * into `newStore`'s column views. The snapshot's column ORDER must match
115
+ * the new archetype's `columnsInOrder` (extend / grow guarantee this
116
+ * because they carry the column spec forward unchanged).
117
+ */
118
+ export declare function restoreColumnSnapshots(newStore: ColumnStore, snapshots: Map<number, Uint8Array[]>): void;
119
+ /**
120
+ * The realloc-and-republish slow path shared by `growColumnStore` and
121
+ * `extendColumnStore` — everything between "the specs are decided" and "the
122
+ * caller shapes its result":
123
+ *
124
+ * 1. Capture `view_stamp` and snapshot live rows AND prefix regions
125
+ * (command ring, entity-index) BEFORE the allocator call — the
126
+ * wasmMemoryAllocator may detach `old`'s views on grow, so everything
127
+ * needed is captured first. The prefix-region preservation is the
128
+ * contract `Store` relies on to keep its entity table across resizes
129
+ * (#245); `optionsFromOld` re-reserves regions and descriptor headroom
130
+ * (#541) so the republished store keeps its layout and fast paths.
131
+ * 2. `createColumnStore` with the derived options (fresh buffer; the same
132
+ * growable allocator carries forward so the new buffer also grows in
133
+ * place).
134
+ * 3. Restore live rows + prefix regions. Archetypes without a row count
135
+ * contributed no snapshot and stay zero-initialised; prefix regions
136
+ * overwrite the empty state `createColumnStore` initialised.
137
+ * 4. Bump `view_stamp` from the pre-capture value and patch the returned
138
+ * header so its cached `viewStamp` matches the buffer bytes just
139
+ * written — `createColumnStore` stamped it 0 (#386). `capacity` /
140
+ * `archetype_count` are already correct (createColumnStore sized them),
141
+ * so the spread carries them — and the internal `_allocator` /
142
+ * `_regionBytes` fields — through unchanged.
143
+ *
144
+ * Every view in the returned store is fresh; callers MUST refresh
145
+ * (`viewsPreserved: false` is the callers' contract with THEIR callers).
146
+ */
147
+ export declare function reallocAndRepublish(old: ColumnStore, specs: readonly ArchetypeSpec[], rowCountsById: Map<number, number>, allocator: BufferAllocator | undefined): {
148
+ store: ColumnStore;
149
+ oldViewStamp: number;
150
+ newViewStamp: number;
151
+ };
152
+ //# sourceMappingURL=layout_ops.d.ts.map
@@ -0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,KAAK,EAAE,WAAW,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,CAmBpE"}
@@ -0,0 +1,74 @@
1
+ import { REGION_TABLE_ENTRY_BYTES, REGION_TABLE_ENTRY_OFFSETS } from './vendored_abi/abi.cjs';
2
+ export { REGION_TABLE_ENTRY_BYTES, REGION_TABLE_ENTRY_OFFSETS };
3
+ /** A consumer-declared SAB region. The consumer owns `id` (a nonzero integer,
4
+ * distinct within its region set, that it also resolves on the read side),
5
+ * computes `bytes`, and seeds the region header + contents in `init`.
6
+ *
7
+ * `init` runs ONCE at first allocation. Across a SAB grow/extend the region's
8
+ * live bytes are snapshotted and restored verbatim (the table is
9
+ * self-describing), so `init` is not re-run — a consumer must not rely on it
10
+ * firing per realloc. */
11
+ export interface StoreRegionSpec {
12
+ /** Consumer-owned region id (nonzero, distinct). Written to the directory;
13
+ * resolved by the consumer via `findRegionOffset` / `abi.find_region`. */
14
+ readonly id: number;
15
+ /** Human label for diagnostics / the self-documenting directory dump. */
16
+ readonly name: string;
17
+ /** Byte size to allocate for this region (consumer computes from its knobs).
18
+ * Must be > 0. */
19
+ readonly bytes: number;
20
+ /** Initialise the region header + seed bytes at absolute byte offset `off`. */
21
+ readonly init: (view: DataView, off: number) => void;
22
+ }
23
+ /** One decoded directory record. */
24
+ export interface RegionTableEntry {
25
+ readonly regionId: number;
26
+ readonly byteOffset: number;
27
+ readonly byteLength: number;
28
+ }
29
+ /** A resolved handle to a consumer region, returned by `ECS.regionHandle` /
30
+ * `Store.regionHandle`. Carries the live `buffer`/`view` plus the region's byte
31
+ * `offset` and full `bytes`, so a consumer's region module can build a
32
+ * TypedArray view over exactly the region's span without re-reading the
33
+ * directory. Re-fetch after a SAB grow (the offset/view may have moved). */
34
+ export interface ColumnStoreRegionHandle {
35
+ /** `ArrayBufferLike` — see `ColumnStore.buffer`. Consumer regions are a SAB-profile
36
+ * feature (WASM/worker), so in practice this is a `SharedArrayBuffer` wherever
37
+ * regions are declared; the type is widened only because it flows from the
38
+ * backing-agnostic store. */
39
+ readonly buffer: ArrayBufferLike;
40
+ readonly view: DataView;
41
+ readonly offset: number;
42
+ readonly bytes: number;
43
+ }
44
+ export declare class RegionRegistryError extends Error {
45
+ constructor(message: string);
46
+ }
47
+ /** Bytes a region-table directory of `count` entries occupies. */
48
+ export declare function regionTableBytes(count: number): number;
49
+ /** Validate a consumer region set before layout: ids must be nonzero (0 is the
50
+ * "absent" sentinel `findRegionOffset` returns) and distinct, and each region
51
+ * must request a positive byte size. Throws `RegionRegistryError` otherwise —
52
+ * the same loud-failure stance the mechanism registry's paired-knob guards take. */
53
+ export declare function validateRegionSpecs(regions: readonly StoreRegionSpec[]): void;
54
+ /** Write one directory record at absolute byte offset `off`. */
55
+ export declare function writeRegionTableEntry(view: DataView, off: number, e: RegionTableEntry): void;
56
+ /** Read one directory record at absolute byte offset `off`. */
57
+ export declare function readRegionTableEntry(view: DataView, off: number): RegionTableEntry;
58
+ /** Write the whole directory of `entries` at `tableOff`. */
59
+ export declare function writeRegionTable(view: DataView, tableOff: number, entries: readonly RegionTableEntry[]): void;
60
+ /** Read all `count` directory records starting at `tableOff`, in order. */
61
+ export declare function readRegionTable(view: DataView, tableOff: number, count: number): RegionTableEntry[];
62
+ /** Read the directory described by the SAB header (`region_table_off` /
63
+ * `region_table_count`). Empty when no consumer regions were declared. */
64
+ export declare function readHeaderRegionTable(view: DataView): RegionTableEntry[];
65
+ /** Resolve a consumer region's byte offset by `region_id`, or 0 when absent
66
+ * (no directory, or no matching entry). The TS twin of Zig
67
+ * `abi.find_region(header_addr, region_id)`; 0 is an unambiguous "absent"
68
+ * sentinel because a real region never starts at SAB byte 0 (the header does). */
69
+ export declare function findRegionOffset(view: DataView, regionId: number): number;
70
+ /** Resolve a consumer region's `(byte_offset, byte_length)` by `region_id`, or
71
+ * `null` when absent. Use when a reader needs the region's size (e.g. to
72
+ * materialise a TypedArray view) and not just its start. */
73
+ export declare function findRegionEntry(view: DataView, regionId: number): RegionTableEntry | null;
74
+ //# sourceMappingURL=region_table.d.ts.map
@@ -0,0 +1,74 @@
1
+ import { REGION_TABLE_ENTRY_BYTES, REGION_TABLE_ENTRY_OFFSETS } from './vendored_abi/abi.js';
2
+ export { REGION_TABLE_ENTRY_BYTES, REGION_TABLE_ENTRY_OFFSETS };
3
+ /** A consumer-declared SAB region. The consumer owns `id` (a nonzero integer,
4
+ * distinct within its region set, that it also resolves on the read side),
5
+ * computes `bytes`, and seeds the region header + contents in `init`.
6
+ *
7
+ * `init` runs ONCE at first allocation. Across a SAB grow/extend the region's
8
+ * live bytes are snapshotted and restored verbatim (the table is
9
+ * self-describing), so `init` is not re-run — a consumer must not rely on it
10
+ * firing per realloc. */
11
+ export interface StoreRegionSpec {
12
+ /** Consumer-owned region id (nonzero, distinct). Written to the directory;
13
+ * resolved by the consumer via `findRegionOffset` / `abi.find_region`. */
14
+ readonly id: number;
15
+ /** Human label for diagnostics / the self-documenting directory dump. */
16
+ readonly name: string;
17
+ /** Byte size to allocate for this region (consumer computes from its knobs).
18
+ * Must be > 0. */
19
+ readonly bytes: number;
20
+ /** Initialise the region header + seed bytes at absolute byte offset `off`. */
21
+ readonly init: (view: DataView, off: number) => void;
22
+ }
23
+ /** One decoded directory record. */
24
+ export interface RegionTableEntry {
25
+ readonly regionId: number;
26
+ readonly byteOffset: number;
27
+ readonly byteLength: number;
28
+ }
29
+ /** A resolved handle to a consumer region, returned by `ECS.regionHandle` /
30
+ * `Store.regionHandle`. Carries the live `buffer`/`view` plus the region's byte
31
+ * `offset` and full `bytes`, so a consumer's region module can build a
32
+ * TypedArray view over exactly the region's span without re-reading the
33
+ * directory. Re-fetch after a SAB grow (the offset/view may have moved). */
34
+ export interface ColumnStoreRegionHandle {
35
+ /** `ArrayBufferLike` — see `ColumnStore.buffer`. Consumer regions are a SAB-profile
36
+ * feature (WASM/worker), so in practice this is a `SharedArrayBuffer` wherever
37
+ * regions are declared; the type is widened only because it flows from the
38
+ * backing-agnostic store. */
39
+ readonly buffer: ArrayBufferLike;
40
+ readonly view: DataView;
41
+ readonly offset: number;
42
+ readonly bytes: number;
43
+ }
44
+ export declare class RegionRegistryError extends Error {
45
+ constructor(message: string);
46
+ }
47
+ /** Bytes a region-table directory of `count` entries occupies. */
48
+ export declare function regionTableBytes(count: number): number;
49
+ /** Validate a consumer region set before layout: ids must be nonzero (0 is the
50
+ * "absent" sentinel `findRegionOffset` returns) and distinct, and each region
51
+ * must request a positive byte size. Throws `RegionRegistryError` otherwise —
52
+ * the same loud-failure stance the mechanism registry's paired-knob guards take. */
53
+ export declare function validateRegionSpecs(regions: readonly StoreRegionSpec[]): void;
54
+ /** Write one directory record at absolute byte offset `off`. */
55
+ export declare function writeRegionTableEntry(view: DataView, off: number, e: RegionTableEntry): void;
56
+ /** Read one directory record at absolute byte offset `off`. */
57
+ export declare function readRegionTableEntry(view: DataView, off: number): RegionTableEntry;
58
+ /** Write the whole directory of `entries` at `tableOff`. */
59
+ export declare function writeRegionTable(view: DataView, tableOff: number, entries: readonly RegionTableEntry[]): void;
60
+ /** Read all `count` directory records starting at `tableOff`, in order. */
61
+ export declare function readRegionTable(view: DataView, tableOff: number, count: number): RegionTableEntry[];
62
+ /** Read the directory described by the SAB header (`region_table_off` /
63
+ * `region_table_count`). Empty when no consumer regions were declared. */
64
+ export declare function readHeaderRegionTable(view: DataView): RegionTableEntry[];
65
+ /** Resolve a consumer region's byte offset by `region_id`, or 0 when absent
66
+ * (no directory, or no matching entry). The TS twin of Zig
67
+ * `abi.find_region(header_addr, region_id)`; 0 is an unambiguous "absent"
68
+ * sentinel because a real region never starts at SAB byte 0 (the header does). */
69
+ export declare function findRegionOffset(view: DataView, regionId: number): number;
70
+ /** Resolve a consumer region's `(byte_offset, byte_length)` by `region_id`, or
71
+ * `null` when absent. Use when a reader needs the region's size (e.g. to
72
+ * materialise a TypedArray view) and not just its start. */
73
+ export declare function findRegionEntry(view: DataView, regionId: number): RegionTableEntry | null;
74
+ //# sourceMappingURL=region_table.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"region_table.d.ts","sourceRoot":"","sources":["../../../src/core/store/region_table.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EACN,wBAAwB,EACxB,0BAA0B,EAE1B,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,wBAAwB,EAAE,0BAA0B,EAAE,CAAC;AAEhE;;;;;;;yBAOyB;AACzB,MAAM,WAAW,eAAe;IAC/B;8EAC0E;IAC1E,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,yEAAyE;IACzE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB;sBACkB;IAClB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,+EAA+E;IAC/E,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CACrD;AAED,oCAAoC;AACpC,MAAM,WAAW,gBAAgB;IAChC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC5B;AAED;;;;4EAI4E;AAC5E,MAAM,WAAW,uBAAuB;IACvC;;;iCAG6B;IAC7B,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAC;IACjC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACvB;AAED,qBAAa,mBAAoB,SAAQ,KAAK;gBACjC,OAAO,EAAE,MAAM;CAI3B;AAED,kEAAkE;AAClE,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEtD;AAiBD;;;oFAGoF;AACpF,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,SAAS,eAAe,EAAE,GAAG,IAAI,CAqB7E;AAED,gEAAgE;AAChE,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,gBAAgB,GAAG,IAAI,CAI5F;AAED,+DAA+D;AAC/D,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,gBAAgB,CAMlF;AAED,4DAA4D;AAC5D,wBAAgB,gBAAgB,CAC/B,IAAI,EAAE,QAAQ,EACd,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,SAAS,gBAAgB,EAAE,GAClC,IAAI,CAIN;AAED,2EAA2E;AAC3E,wBAAgB,eAAe,CAC9B,IAAI,EAAE,QAAQ,EACd,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,GACX,gBAAgB,EAAE,CAMpB;AAED;0EAC0E;AAC1E,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,QAAQ,GAAG,gBAAgB,EAAE,CAKxE;AAED;;;kFAGkF;AAClF,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAWzE;AAED;;4DAE4D;AAC5D,wBAAgB,eAAe,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,GAAG,gBAAgB,GAAG,IAAI,CASzF"}
@@ -0,0 +1,43 @@
1
+ import { ColumnStore } from './column_store.cjs';
2
+ import { BufferAllocator } from './allocator.cjs';
3
+ export declare class StoreRestoreError extends Error {
4
+ constructor(message: string);
5
+ }
6
+ /** Zero-copy `Uint8Array` view over the SAB's used byte range. Length is
7
+ * `header.capacity` — the canonical size, NOT `buffer.byteLength`. The two
8
+ * coincide for `DEFAULT_SAB_ALLOCATOR` (it allocates exactly `totalBytes`),
9
+ * but `wasmMemoryAllocator` / `growableSabAllocator` round the buffer up
10
+ * to 64 KiB page boundaries, so `buffer.byteLength` can exceed `capacity` by up
11
+ * to a page of trailing slack (see the allocator contract in `allocator.ts`).
12
+ * Hashing or round-tripping that slack would make two logically-identical
13
+ * stores with different grow trajectories (or different allocators) diverge,
14
+ * so we size to `capacity` here.
15
+ *
16
+ * Capacity is read live from `store.view` rather than the cached
17
+ * `store.header` — the in-place grow path bumps the header fields in the
18
+ * view but leaves `store.header` a stale snapshot (see `grow.ts`).
19
+ *
20
+ * The view shares storage with the SAB; subsequent writes to columns are
21
+ * visible through it. Callers that need a stable snapshot should slice
22
+ * (`new Uint8Array(view)`) before mutating the store further. */
23
+ export declare function snapshotColumnStore(store: ColumnStore): Uint8Array;
24
+ /** Allocate a fresh backing buffer of `bytes.byteLength`, copy the snapshot
25
+ * bytes in, validate the header, and reconstruct the `ColumnStore` (header cache +
26
+ * DataView + per-archetype `ArchetypeViews`).
27
+ *
28
+ * `allocator` selects the backing: the default `DEFAULT_SAB_ALLOCATOR`
29
+ * (`SharedArrayBuffer`) keeps existing callers' behaviour; pass
30
+ * `heapArraybufferAllocator()` to round-trip a snapshot into a pure-TS heap
31
+ * world (no SAB required). Either way only one allocation happens — restore
32
+ * never grows — so a non-in-place allocator is fine here.
33
+ *
34
+ * The input can be any `Uint8Array` — a view from `snapshotColumnStore`,
35
+ * a sliced copy, or bytes read off disk / postMessage. The function
36
+ * honours `bytes.byteOffset` and `bytes.byteLength`, so passing a
37
+ * subarray that doesn't start at offset 0 of its backing buffer is
38
+ * supported.
39
+ *
40
+ * Throws `StoreRestoreError` if the bytes are too short for the header,
41
+ * have the wrong magic, or carry an incompatible `sim_abi_version`. */
42
+ export declare function restoreColumnStore(bytes: Uint8Array, allocator?: BufferAllocator): ColumnStore;
43
+ //# sourceMappingURL=snapshot.d.ts.map
@@ -0,0 +1,43 @@
1
+ import { ColumnStore } from './column_store.js';
2
+ import { BufferAllocator } from './allocator.js';
3
+ export declare class StoreRestoreError extends Error {
4
+ constructor(message: string);
5
+ }
6
+ /** Zero-copy `Uint8Array` view over the SAB's used byte range. Length is
7
+ * `header.capacity` — the canonical size, NOT `buffer.byteLength`. The two
8
+ * coincide for `DEFAULT_SAB_ALLOCATOR` (it allocates exactly `totalBytes`),
9
+ * but `wasmMemoryAllocator` / `growableSabAllocator` round the buffer up
10
+ * to 64 KiB page boundaries, so `buffer.byteLength` can exceed `capacity` by up
11
+ * to a page of trailing slack (see the allocator contract in `allocator.ts`).
12
+ * Hashing or round-tripping that slack would make two logically-identical
13
+ * stores with different grow trajectories (or different allocators) diverge,
14
+ * so we size to `capacity` here.
15
+ *
16
+ * Capacity is read live from `store.view` rather than the cached
17
+ * `store.header` — the in-place grow path bumps the header fields in the
18
+ * view but leaves `store.header` a stale snapshot (see `grow.ts`).
19
+ *
20
+ * The view shares storage with the SAB; subsequent writes to columns are
21
+ * visible through it. Callers that need a stable snapshot should slice
22
+ * (`new Uint8Array(view)`) before mutating the store further. */
23
+ export declare function snapshotColumnStore(store: ColumnStore): Uint8Array;
24
+ /** Allocate a fresh backing buffer of `bytes.byteLength`, copy the snapshot
25
+ * bytes in, validate the header, and reconstruct the `ColumnStore` (header cache +
26
+ * DataView + per-archetype `ArchetypeViews`).
27
+ *
28
+ * `allocator` selects the backing: the default `DEFAULT_SAB_ALLOCATOR`
29
+ * (`SharedArrayBuffer`) keeps existing callers' behaviour; pass
30
+ * `heapArraybufferAllocator()` to round-trip a snapshot into a pure-TS heap
31
+ * world (no SAB required). Either way only one allocation happens — restore
32
+ * never grows — so a non-in-place allocator is fine here.
33
+ *
34
+ * The input can be any `Uint8Array` — a view from `snapshotColumnStore`,
35
+ * a sliced copy, or bytes read off disk / postMessage. The function
36
+ * honours `bytes.byteOffset` and `bytes.byteLength`, so passing a
37
+ * subarray that doesn't start at offset 0 of its backing buffer is
38
+ * supported.
39
+ *
40
+ * Throws `StoreRestoreError` if the bytes are too short for the header,
41
+ * have the wrong magic, or carry an incompatible `sim_abi_version`. */
42
+ export declare function restoreColumnStore(bytes: Uint8Array, allocator?: BufferAllocator): ColumnStore;
43
+ //# sourceMappingURL=snapshot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"snapshot.d.ts","sourceRoot":"","sources":["../../../src/core/store/snapshot.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAUH,OAAO,EAAuB,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACvE,OAAO,EAAyB,KAAK,eAAe,EAAE,MAAM,aAAa,CAAC;AAE1E,qBAAa,iBAAkB,SAAQ,KAAK;gBAC/B,OAAO,EAAE,MAAM;CAI3B;AAED;;;;;;;;;;;;;;;;iEAgBiE;AACjE,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,WAAW,GAAG,UAAU,CAGlE;AAED;;;;;;;;;;;;;;;;;uEAiBuE;AACvE,wBAAgB,kBAAkB,CACjC,KAAK,EAAE,UAAU,EACjB,SAAS,GAAE,eAAuC,GAChD,WAAW,CAiEb"}
@@ -0,0 +1,38 @@
1
+ import { ColumnStore } from './column_store.cjs';
2
+ /** FNV-1a 32-bit offset basis (Fowler/Noll/Vo). */
3
+ export declare const FNV1A_OFFSET_BASIS = 2166136261;
4
+ /** FNV-1a 32-bit prime. */
5
+ export declare const FNV1A_PRIME = 16777619;
6
+ /** One FNV-1a round folding a single **byte** (the low 8 bits of `b`) into the
7
+ * running `hash`: `hash = imul((hash ^ (b & 0xff)) >>> 0, PRIME) >>> 0`. The
8
+ * single canonical definition of the byte step (#498) — reused by `fnv1a32`
9
+ * here, by the sparse-store `schemaFingerprint`, and by the server determinism
10
+ * byte/u32 folds, so the constants and the round live in exactly one place.
11
+ *
12
+ * Trivially inlinable (monomorphic, no allocation); the intermediate `>>> 0`s
13
+ * never change a later round (xor/imul see the same 32-bit pattern signed or
14
+ * unsigned), they just keep the value unsigned for readers. */
15
+ export declare function fnv1aStep(hash: number, b: number): number;
16
+ /** One FNV-1a round folding a full 32-bit **word** into `hash` — the whole word
17
+ * xored at once, not four byte rounds. A coarser fold than per-byte FNV-1a, but
18
+ * equally deterministic and ~4× cheaper, which is why `Store.stateHash` folds
19
+ * its columns this way (#326). This is the canonical word-step definition its
20
+ * cold sparse/relation folds call; its hot dense-column inner loop inlines this
21
+ * exact step for speed and must stay in sync. Same `>>> 0` reasoning as
22
+ * `fnv1aStep`. */
23
+ export declare function fnv1aStepWord(hash: number, word: number): number;
24
+ /** FNV-1a 32-bit hash of a byte buffer. Returned as an unsigned 32-bit
25
+ * `number` (i.e. always in `[0, 2^32)`).
26
+ *
27
+ * Standalone export so callers that already have a `Uint8Array` (a sliced
28
+ * snapshot, bytes off disk, a hot subrange) can hash without round-tripping
29
+ * through `ColumnStore`. */
30
+ export declare function fnv1a32(bytes: Uint8Array): number;
31
+ /** FNV-1a 32-bit hash of the entire SAB region — header + descriptors +
32
+ * column bytes. The canonical state identifier for cross-replay determinism
33
+ * checks (#171 plan exit criterion §6.1.7).
34
+ *
35
+ * The snapshot view is zero-copy (`snapshotColumnStore` is a view, not a
36
+ * copy), so this is one scan over the live SAB with no allocation. */
37
+ export declare function columnStoreStateHash(store: ColumnStore): number;
38
+ //# sourceMappingURL=state_hash.d.ts.map