@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,38 @@
1
+ import { ColumnStore } from './column_store.js';
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state_hash.d.ts","sourceRoot":"","sources":["../../../src/core/store/state_hash.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,mDAAmD;AACnD,eAAO,MAAM,kBAAkB,aAAa,CAAC;AAC7C,2BAA2B;AAC3B,eAAO,MAAM,WAAW,WAAa,CAAC;AAEtC;;;;;;;;+DAQ+D;AAC/D,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAGzD;AAED;;;;;;kBAMkB;AAClB,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAGhE;AAED;;;;;4BAK4B;AAC5B,wBAAgB,OAAO,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAIjD;AAED;;;;;sEAKsE;AACtE,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CAE/D"}
@@ -0,0 +1,38 @@
1
+ import { CreateColumnStoreOptions } from './column_store.cjs';
2
+ /** The `StoreHeader` fields that hold a MECHANISM region's byte offset (0 ⇒
3
+ * region absent). Exactly the four fields a `MechanismRegionSpec` can own; the
4
+ * always-present `bindings_off` / `layout_descriptor_off` and the generic
5
+ * `region_table_off` / `region_table_count` pair are not mechanism regions in
6
+ * this sense and are computed directly outside the loop. */
7
+ export type StoreRegionOffsetField = "command_ring_off" | "entity_index_off" | "event_ring_off" | "action_ring_off";
8
+ /** Mutable accumulator for building `CreateColumnStoreOptions` field by field as
9
+ * each region reads itself back out of an existing SAB (`readOptions`). */
10
+ export type MutableColumnStoreOptions = {
11
+ -readonly [K in keyof CreateColumnStoreOptions]: CreateColumnStoreOptions[K];
12
+ };
13
+ /** One engine MECHANISM region. The four closures are the per-region half of
14
+ * each generic pass; see the module doc for which consumer drives which.
15
+ *
16
+ * (Consumer/game regions use the separate self-contained `StoreRegionSpec` in
17
+ * `region_table.ts` — they carry a precomputed `bytes` + `init` and are
18
+ * addressed by an opaque `region_id`, not a named header field.) */
19
+ export interface MechanismRegionSpec {
20
+ /** Stable name — reads in diagnostics and keeps the array self-documenting. */
21
+ readonly name: string;
22
+ /** `StoreHeader` field this region's byte offset is written to. */
23
+ readonly headerOff: StoreRegionOffsetField;
24
+ /** Byte size implied by `options` (0 ⇒ region absent, so no offset/init). */
25
+ readonly sizeFromOptions: (options: CreateColumnStoreOptions) => number;
26
+ /** Initialise the region's header at `off`. Called by `createColumnStore`
27
+ * only when the region is present (`off !== 0`). */
28
+ readonly init: (view: DataView, off: number, options: CreateColumnStoreOptions) => void;
29
+ /** Byte length of an already-allocated region, read from its own header.
30
+ * Used to snapshot exactly the live bytes before a realloc. */
31
+ readonly regionBytes: (view: DataView, off: number) => number;
32
+ /** Re-derive the `CreateColumnStoreOptions` knobs that recreate this region
33
+ * from an existing SAB, so a realloc lays it out identically. */
34
+ readonly readOptions: (view: DataView, off: number, out: MutableColumnStoreOptions) => void;
35
+ }
36
+ /** The engine mechanism prefix regions, in SAB byte order (see module doc). */
37
+ export declare const STORE_PREFIX_REGIONS: readonly MechanismRegionSpec[];
38
+ //# sourceMappingURL=store_regions.d.ts.map
@@ -0,0 +1,38 @@
1
+ import { CreateColumnStoreOptions } from './column_store.js';
2
+ /** The `StoreHeader` fields that hold a MECHANISM region's byte offset (0 ⇒
3
+ * region absent). Exactly the four fields a `MechanismRegionSpec` can own; the
4
+ * always-present `bindings_off` / `layout_descriptor_off` and the generic
5
+ * `region_table_off` / `region_table_count` pair are not mechanism regions in
6
+ * this sense and are computed directly outside the loop. */
7
+ export type StoreRegionOffsetField = "command_ring_off" | "entity_index_off" | "event_ring_off" | "action_ring_off";
8
+ /** Mutable accumulator for building `CreateColumnStoreOptions` field by field as
9
+ * each region reads itself back out of an existing SAB (`readOptions`). */
10
+ export type MutableColumnStoreOptions = {
11
+ -readonly [K in keyof CreateColumnStoreOptions]: CreateColumnStoreOptions[K];
12
+ };
13
+ /** One engine MECHANISM region. The four closures are the per-region half of
14
+ * each generic pass; see the module doc for which consumer drives which.
15
+ *
16
+ * (Consumer/game regions use the separate self-contained `StoreRegionSpec` in
17
+ * `region_table.ts` — they carry a precomputed `bytes` + `init` and are
18
+ * addressed by an opaque `region_id`, not a named header field.) */
19
+ export interface MechanismRegionSpec {
20
+ /** Stable name — reads in diagnostics and keeps the array self-documenting. */
21
+ readonly name: string;
22
+ /** `StoreHeader` field this region's byte offset is written to. */
23
+ readonly headerOff: StoreRegionOffsetField;
24
+ /** Byte size implied by `options` (0 ⇒ region absent, so no offset/init). */
25
+ readonly sizeFromOptions: (options: CreateColumnStoreOptions) => number;
26
+ /** Initialise the region's header at `off`. Called by `createColumnStore`
27
+ * only when the region is present (`off !== 0`). */
28
+ readonly init: (view: DataView, off: number, options: CreateColumnStoreOptions) => void;
29
+ /** Byte length of an already-allocated region, read from its own header.
30
+ * Used to snapshot exactly the live bytes before a realloc. */
31
+ readonly regionBytes: (view: DataView, off: number) => number;
32
+ /** Re-derive the `CreateColumnStoreOptions` knobs that recreate this region
33
+ * from an existing SAB, so a realloc lays it out identically. */
34
+ readonly readOptions: (view: DataView, off: number, out: MutableColumnStoreOptions) => void;
35
+ }
36
+ /** The engine mechanism prefix regions, in SAB byte order (see module doc). */
37
+ export declare const STORE_PREFIX_REGIONS: readonly MechanismRegionSpec[];
38
+ //# sourceMappingURL=store_regions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store_regions.d.ts","sourceRoot":"","sources":["../../../src/core/store/store_regions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAUH,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAE/D;;;;4DAI4D;AAC5D,MAAM,MAAM,sBAAsB,GAC/B,kBAAkB,GAClB,kBAAkB,GAClB,gBAAgB,GAChB,iBAAiB,CAAC;AAErB;2EAC2E;AAC3E,MAAM,MAAM,yBAAyB,GAAG;IACvC,CAAC,UAAU,CAAC,IAAI,MAAM,wBAAwB,GAAG,wBAAwB,CAAC,CAAC,CAAC;CAC5E,CAAC;AAEF;;;;;oEAKoE;AACpE,MAAM,WAAW,mBAAmB;IACnC,+EAA+E;IAC/E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,mEAAmE;IACnE,QAAQ,CAAC,SAAS,EAAE,sBAAsB,CAAC;IAC3C,6EAA6E;IAC7E,QAAQ,CAAC,eAAe,EAAE,CAAC,OAAO,EAAE,wBAAwB,KAAK,MAAM,CAAC;IACxE;wDACoD;IACpD,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,wBAAwB,KAAK,IAAI,CAAC;IACxF;mEAC+D;IAC/D,QAAQ,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;IAC9D;qEACiE;IACjE,QAAQ,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,yBAAyB,KAAK,IAAI,CAAC;CAC5F;AAED,+EAA+E;AAC/E,eAAO,MAAM,oBAAoB,EAAE,SAAS,mBAAmB,EAgE9D,CAAC"}
@@ -0,0 +1,43 @@
1
+ export declare const STORE_MAGIC = 827148627;
2
+ export declare const SIM_ABI_VERSION = 0;
3
+ export declare const COMPONENT_MASK_WORDS = 4;
4
+ export declare const STORE_HEADER_BYTES = 52;
5
+ export declare const STORE_HEADER_OFFSETS: {
6
+ readonly magic: 0;
7
+ readonly sim_abi_version: 4;
8
+ readonly view_stamp: 8;
9
+ readonly capacity: 12;
10
+ readonly archetype_count: 16;
11
+ readonly layout_descriptor_off: 20;
12
+ readonly command_ring_off: 24;
13
+ readonly action_ring_off: 28;
14
+ readonly entity_index_off: 32;
15
+ readonly event_ring_off: 36;
16
+ readonly region_table_off: 40;
17
+ readonly region_table_count: 44;
18
+ readonly bindings_off: 48;
19
+ };
20
+ export declare const REGION_TABLE_ENTRY_BYTES = 12;
21
+ export declare const REGION_TABLE_ENTRY_OFFSETS: {
22
+ readonly region_id: 0;
23
+ readonly byte_offset: 4;
24
+ readonly byte_length: 8;
25
+ };
26
+ export declare const COLUMN_DESCRIPTOR_BYTES = 16;
27
+ export declare const COLUMN_DESCRIPTOR_OFFSETS: {
28
+ readonly component_id: 0;
29
+ readonly field_id: 2;
30
+ readonly type_tag: 4;
31
+ readonly byte_off: 8;
32
+ readonly stride: 12;
33
+ };
34
+ export declare const ARCHETYPE_DESCRIPTOR_HEADER_BYTES = 36;
35
+ export declare const ARCHETYPE_DESCRIPTOR_OFFSETS: {
36
+ readonly archetype_id: 0;
37
+ readonly component_mask: 4;
38
+ readonly row_count: 20;
39
+ readonly row_capacity: 24;
40
+ readonly column_count: 28;
41
+ readonly enabled_count: 32;
42
+ };
43
+ //# sourceMappingURL=abi.d.ts.map
@@ -0,0 +1,43 @@
1
+ export declare const STORE_MAGIC = 827148627;
2
+ export declare const SIM_ABI_VERSION = 0;
3
+ export declare const COMPONENT_MASK_WORDS = 4;
4
+ export declare const STORE_HEADER_BYTES = 52;
5
+ export declare const STORE_HEADER_OFFSETS: {
6
+ readonly magic: 0;
7
+ readonly sim_abi_version: 4;
8
+ readonly view_stamp: 8;
9
+ readonly capacity: 12;
10
+ readonly archetype_count: 16;
11
+ readonly layout_descriptor_off: 20;
12
+ readonly command_ring_off: 24;
13
+ readonly action_ring_off: 28;
14
+ readonly entity_index_off: 32;
15
+ readonly event_ring_off: 36;
16
+ readonly region_table_off: 40;
17
+ readonly region_table_count: 44;
18
+ readonly bindings_off: 48;
19
+ };
20
+ export declare const REGION_TABLE_ENTRY_BYTES = 12;
21
+ export declare const REGION_TABLE_ENTRY_OFFSETS: {
22
+ readonly region_id: 0;
23
+ readonly byte_offset: 4;
24
+ readonly byte_length: 8;
25
+ };
26
+ export declare const COLUMN_DESCRIPTOR_BYTES = 16;
27
+ export declare const COLUMN_DESCRIPTOR_OFFSETS: {
28
+ readonly component_id: 0;
29
+ readonly field_id: 2;
30
+ readonly type_tag: 4;
31
+ readonly byte_off: 8;
32
+ readonly stride: 12;
33
+ };
34
+ export declare const ARCHETYPE_DESCRIPTOR_HEADER_BYTES = 36;
35
+ export declare const ARCHETYPE_DESCRIPTOR_OFFSETS: {
36
+ readonly archetype_id: 0;
37
+ readonly component_mask: 4;
38
+ readonly row_count: 20;
39
+ readonly row_capacity: 24;
40
+ readonly column_count: 28;
41
+ readonly enabled_count: 32;
42
+ };
43
+ //# sourceMappingURL=abi.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"abi.d.ts","sourceRoot":"","sources":["../../../../src/core/store/vendored_abi/abi.ts"],"names":[],"mappings":"AAqBA,eAAO,MAAM,WAAW,YAAa,CAAC;AACtC,eAAO,MAAM,eAAe,IAAI,CAAC;AACjC,eAAO,MAAM,oBAAoB,IAAI,CAAC;AAEtC,eAAO,MAAM,kBAAkB,KAAK,CAAC;AACrC,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;CAcvB,CAAC;AAEX,eAAO,MAAM,wBAAwB,KAAK,CAAC;AAC3C,eAAO,MAAM,0BAA0B;;;;CAI7B,CAAC;AAEX,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAC1C,eAAO,MAAM,yBAAyB;;;;;;CAM5B,CAAC;AAEX,eAAO,MAAM,iCAAiC,KAAK,CAAC;AACpD,eAAO,MAAM,4BAA4B;;;;;;;CAO/B,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * The dev-mode flag, resolved once at module load.
3
+ *
4
+ * Bundled (npm) builds: Vite's `define` replaces the bare `__DEV__` global
5
+ * below with a literal (`false` for `vite build`, `true` for dev/test), so
6
+ * `DEV` constant-folds and dev-only branches are eliminated.
7
+ *
8
+ * Raw-source (JSR/Deno) consumers: no bundler defines `__DEV__`, the `typeof`
9
+ * probe falls through, and `DEV` defaults to `true` (all dev checks on). To
10
+ * opt out, set `globalThis.__DEV__ = false` before the first import of this
11
+ * package.
12
+ */
13
+ declare global {
14
+ var __DEV__: boolean;
15
+ }
16
+ export declare const DEV: boolean;
17
+ //# sourceMappingURL=dev_flag.d.ts.map
@@ -0,0 +1,17 @@
1
+ /**
2
+ * The dev-mode flag, resolved once at module load.
3
+ *
4
+ * Bundled (npm) builds: Vite's `define` replaces the bare `__DEV__` global
5
+ * below with a literal (`false` for `vite build`, `true` for dev/test), so
6
+ * `DEV` constant-folds and dev-only branches are eliminated.
7
+ *
8
+ * Raw-source (JSR/Deno) consumers: no bundler defines `__DEV__`, the `typeof`
9
+ * probe falls through, and `DEV` defaults to `true` (all dev checks on). To
10
+ * opt out, set `globalThis.__DEV__ = false` before the first import of this
11
+ * package.
12
+ */
13
+ declare global {
14
+ var __DEV__: boolean;
15
+ }
16
+ export declare const DEV: boolean;
17
+ //# sourceMappingURL=dev_flag.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dev_flag.d.ts","sourceRoot":"","sources":["../src/dev_flag.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,CAAC,MAAM,CAAC;IAEd,IAAI,OAAO,EAAE,OAAO,CAAC;CACrB;AAED,eAAO,MAAM,GAAG,EAAE,OAAyD,CAAC"}
@@ -0,0 +1,170 @@
1
+ import { ComponentDef, ComponentHandle, ComponentSchema, EntityID, CompleteFieldValues, HostCommand, HostCommandQueue, SpawnEntries } from '../../core/ecs/index.cjs';
2
+ /**
3
+ * Reads the committed value of one `(entity, component, field)` slot — the editor
4
+ * uses it to seed a `setField` inverse with the value the edit replaced. Wire it
5
+ * to the reactive read channel (e.g. a `reactiveMap`/`reactiveStruct` projection)
6
+ * or to `ecs.getField`; `undefined` for an unknown slot falls back to `0`.
7
+ */
8
+ export type FieldReader = (eid: EntityID, def: ComponentDef, field: string) => number | undefined;
9
+ /**
10
+ * A reified, undoable unit of editor work: the `forward` commands and their
11
+ * `inverse`, both plain `HostCommand` data on the one bus. The arrays are mutable
12
+ * internally (the spawn/despawn id finalizers patch a slot at apply time) but the
13
+ * type handed back from {@link Editor.transaction} is read-only.
14
+ */
15
+ export interface EditorTransaction {
16
+ readonly forward: readonly HostCommand[];
17
+ readonly inverse: readonly HostCommand[];
18
+ }
19
+ /**
20
+ * Accumulates the `forward`/`inverse` commands for ONE transaction. Each method
21
+ * appends a forward command and its inverse, computing the inverse from the
22
+ * shadow / read channel where needed. Spawn and despawn install id-finalizers
23
+ * (via `HostCommand.onSpawned`) that patch the apply-time id into the right slot.
24
+ *
25
+ * Obtained from {@link Editor.transaction}; not constructed directly.
26
+ */
27
+ export declare class TransactionBuilder {
28
+ private readonly readField;
29
+ private readonly shadow;
30
+ /** Values staged by THIS build, layered over the editor's shared shadow. Kept
31
+ * transaction-local so an aborted build (the callback throws before commit)
32
+ * leaves the shared shadow untouched — a phantom staged value would poison
33
+ * `pendingField` and seed the NEXT edit's inverse with a value the world never
34
+ * held. The one merge point into the shared shadow is commit's `applyShadow`. */
35
+ private readonly staged;
36
+ /** @internal */
37
+ constructor(readField: FieldReader, shadow: Map<string, number>);
38
+ private get _txn();
39
+ /**
40
+ * Spawn an entity carrying `components`. Inverse: despawn the created entity,
41
+ * finalized once the spawn applies (the id only exists post-flush). `onSpawned`
42
+ * also forwards the new id to the caller. The finalizer re-fires on redo, so the
43
+ * inverse tracks the current id.
44
+ */
45
+ spawn<Defs extends readonly ComponentDef[]>(components: SpawnEntries<Defs>, onSpawned?: (eid: EntityID) => void): this;
46
+ /**
47
+ * Despawn `eid`. Inverse: respawn from `restore` (the components+values to
48
+ * recreate — read them from the channel before despawning). Undo respawns the
49
+ * DATA, not the identity: the new entity gets a fresh id, and the respawn's
50
+ * `onSpawned` rewrites this despawn's target so redo removes the respawned
51
+ * entity rather than the dead original.
52
+ */
53
+ despawn<Defs extends readonly ComponentDef[]>(eid: EntityID, restore: SpawnEntries<Defs>): this;
54
+ /**
55
+ * Set `field` of `def` on `eid` to `value`. Inverse: set it back to the value
56
+ * this edit replaced — read from the staged overlay / shadow (so stacked edits,
57
+ * within one build or before a commit, invert correctly) or, failing that, the
58
+ * read channel (`0` if unknown).
59
+ */
60
+ setField<S extends ComponentSchema>(eid: EntityID, def: ComponentDef<S>, field: string & keyof S, value: number): this;
61
+ /** Add `def` (with complete `values`) to `eid`. Inverse: remove it. */
62
+ addComponent<S extends ComponentSchema>(eid: EntityID, def: ComponentDef<S>, values: CompleteFieldValues<S>): this;
63
+ /**
64
+ * Remove `def` from `eid`. Inverse: re-add it from `restore` (the field values
65
+ * to recreate — read them from the channel before removing).
66
+ */
67
+ removeComponent<S extends ComponentSchema>(eid: EntityID, def: ComponentDef<S>, restore: CompleteFieldValues<S>): this;
68
+ /** Disable `eid`. Inverse: enable it. */
69
+ disable(eid: EntityID): this;
70
+ /** Enable `eid`. Inverse: disable it. */
71
+ enable(eid: EntityID): this;
72
+ }
73
+ /**
74
+ * The editor's undo/redo manager over a {@link HostCommandQueue}. Each action is a
75
+ * reified {@link EditorTransaction} pushed onto the undo stack; `undo()`/`redo()`
76
+ * enqueue its inverse/forward on the SAME bus. The single-action methods
77
+ * (`spawn`, `setField`, …) are sugar for one-command transactions; `transaction`
78
+ * groups several into one undo entry.
79
+ *
80
+ * Construct with the queue and a {@link FieldReader} for the committed read
81
+ * channel (used to seed `setField` inverses).
82
+ */
83
+ export declare class Editor {
84
+ private readonly queue;
85
+ private readonly readField;
86
+ private readonly undoStack;
87
+ private readonly redoStack;
88
+ /** onChange subscribers — see {@link onChange}. */
89
+ private readonly listeners;
90
+ /** Per-`(entity, component, field)` shadow of edited values, for inverse correctness. */
91
+ private readonly shadow;
92
+ constructor(queue: HostCommandQueue, readField: FieldReader);
93
+ /**
94
+ * Group several actions into ONE undo entry. Build them on the passed
95
+ * {@link TransactionBuilder}; the whole group commits (enqueues its forward
96
+ * commands) and lands on the undo stack atomically, clearing the redo stack.
97
+ */
98
+ transaction(build: (tx: TransactionBuilder) => void): EditorTransaction;
99
+ /** Spawn `components` as its own undo entry. `onSpawned` reports the new id. */
100
+ spawn<Defs extends readonly ComponentDef[]>(components: SpawnEntries<Defs>, onSpawned?: (eid: EntityID) => void): EditorTransaction;
101
+ /** Despawn `eid` as its own undo entry; `restore` recreates it on undo. */
102
+ despawn<Defs extends readonly ComponentDef[]>(eid: EntityID, restore: SpawnEntries<Defs>): EditorTransaction;
103
+ /** Set one field as its own undo entry. */
104
+ setField<S extends ComponentSchema>(eid: EntityID, def: ComponentDef<S>, field: string & keyof S, value: number): EditorTransaction;
105
+ /** Add a component as its own undo entry. */
106
+ addComponent<S extends ComponentSchema>(eid: EntityID, def: ComponentDef<S>, values: CompleteFieldValues<S>): EditorTransaction;
107
+ /** Remove a component as its own undo entry; `restore` re-adds it on undo. */
108
+ removeComponent<S extends ComponentSchema>(eid: EntityID, def: ComponentDef<S>, restore: CompleteFieldValues<S>): EditorTransaction;
109
+ /** Disable `eid` as its own undo entry. */
110
+ disable(eid: EntityID): EditorTransaction;
111
+ /** Enable `eid` as its own undo entry. */
112
+ enable(eid: EntityID): EditorTransaction;
113
+ /**
114
+ * Undo the most recent transaction: enqueue its inverse commands (in reverse
115
+ * order — a group unwinds last-action-first) on the bus and move it to the redo
116
+ * stack. Returns `false` if the undo stack is empty.
117
+ */
118
+ undo(): boolean;
119
+ /**
120
+ * Redo the most recently undone transaction: re-enqueue its forward commands on
121
+ * the bus and move it back to the undo stack. Returns `false` if the redo stack
122
+ * is empty.
123
+ */
124
+ redo(): boolean;
125
+ /** Drop both stacks (e.g. on load). Does not touch the world. */
126
+ clear(): void;
127
+ /** Current stack depths — for an "Undo (3)" / "Redo" affordance. */
128
+ depths(): {
129
+ undo: number;
130
+ redo: number;
131
+ };
132
+ /** `true` when `undo()` would do something — allocation-free (M10). */
133
+ get canUndo(): boolean;
134
+ /** `true` when `redo()` would do something — allocation-free (M10). */
135
+ get canRedo(): boolean;
136
+ /**
137
+ * Subscribe to undo/redo-stack changes: fires after every commit, undo,
138
+ * redo, and clear — the push signal an "Undo (3)" affordance needs instead
139
+ * of polling `depths()` per frame (M10). Returns an unsubscribe function.
140
+ * Callbacks run synchronously in subscription order; read `canUndo` /
141
+ * `canRedo` / `depths()` inside.
142
+ */
143
+ onChange(cb: () => void): () => void;
144
+ private notify;
145
+ /** Read one committed `(entity, component, field)` slot through the reader
146
+ * this editor was constructed with — the default read for `fieldHandle`
147
+ * when no channel thunk is supplied (M11). */
148
+ committedField(eid: EntityID, def: ComponentDef, field: string): number | undefined;
149
+ /**
150
+ * The pending value the editor believes for a field that the committed read
151
+ * channel has NOT caught up to yet (the shadow), or `undefined` if none. Lets an
152
+ * inspector echo an edit between the `set` and the tick that commits it.
153
+ *
154
+ * Self-resolving: once the read channel reports the shadowed value (the edit
155
+ * landed) — or reports `undefined` (the slot is gone: entity despawned or
156
+ * component removed) — the entry is dropped and this returns `undefined`, so
157
+ * `pending` does not outlive its set→commit window and shadow a later external
158
+ * write, nor a dead slot's lifetime. The one
159
+ * residual: if an external write changes the field to a *different* value within
160
+ * the same window before this is next consulted, `pending` can read stale until
161
+ * the next edit to the slot. `value` (the read channel) is always the source of
162
+ * truth; `pending` is only the optimistic bridge.
163
+ */
164
+ pendingField(eid: EntityID, def: ComponentHandle, field: string): number | undefined;
165
+ /** Enqueue forward commands, record the transaction, clear redo, sync shadow. */
166
+ private commit;
167
+ /** Keep the setField shadow in step with the commands just enqueued. */
168
+ private applyShadow;
169
+ }
170
+ //# sourceMappingURL=editor.d.ts.map
@@ -0,0 +1,170 @@
1
+ import { ComponentDef, ComponentHandle, ComponentSchema, EntityID, CompleteFieldValues, HostCommand, HostCommandQueue, SpawnEntries } from '../../core/ecs/index.js';
2
+ /**
3
+ * Reads the committed value of one `(entity, component, field)` slot — the editor
4
+ * uses it to seed a `setField` inverse with the value the edit replaced. Wire it
5
+ * to the reactive read channel (e.g. a `reactiveMap`/`reactiveStruct` projection)
6
+ * or to `ecs.getField`; `undefined` for an unknown slot falls back to `0`.
7
+ */
8
+ export type FieldReader = (eid: EntityID, def: ComponentDef, field: string) => number | undefined;
9
+ /**
10
+ * A reified, undoable unit of editor work: the `forward` commands and their
11
+ * `inverse`, both plain `HostCommand` data on the one bus. The arrays are mutable
12
+ * internally (the spawn/despawn id finalizers patch a slot at apply time) but the
13
+ * type handed back from {@link Editor.transaction} is read-only.
14
+ */
15
+ export interface EditorTransaction {
16
+ readonly forward: readonly HostCommand[];
17
+ readonly inverse: readonly HostCommand[];
18
+ }
19
+ /**
20
+ * Accumulates the `forward`/`inverse` commands for ONE transaction. Each method
21
+ * appends a forward command and its inverse, computing the inverse from the
22
+ * shadow / read channel where needed. Spawn and despawn install id-finalizers
23
+ * (via `HostCommand.onSpawned`) that patch the apply-time id into the right slot.
24
+ *
25
+ * Obtained from {@link Editor.transaction}; not constructed directly.
26
+ */
27
+ export declare class TransactionBuilder {
28
+ private readonly readField;
29
+ private readonly shadow;
30
+ /** Values staged by THIS build, layered over the editor's shared shadow. Kept
31
+ * transaction-local so an aborted build (the callback throws before commit)
32
+ * leaves the shared shadow untouched — a phantom staged value would poison
33
+ * `pendingField` and seed the NEXT edit's inverse with a value the world never
34
+ * held. The one merge point into the shared shadow is commit's `applyShadow`. */
35
+ private readonly staged;
36
+ /** @internal */
37
+ constructor(readField: FieldReader, shadow: Map<string, number>);
38
+ private get _txn();
39
+ /**
40
+ * Spawn an entity carrying `components`. Inverse: despawn the created entity,
41
+ * finalized once the spawn applies (the id only exists post-flush). `onSpawned`
42
+ * also forwards the new id to the caller. The finalizer re-fires on redo, so the
43
+ * inverse tracks the current id.
44
+ */
45
+ spawn<Defs extends readonly ComponentDef[]>(components: SpawnEntries<Defs>, onSpawned?: (eid: EntityID) => void): this;
46
+ /**
47
+ * Despawn `eid`. Inverse: respawn from `restore` (the components+values to
48
+ * recreate — read them from the channel before despawning). Undo respawns the
49
+ * DATA, not the identity: the new entity gets a fresh id, and the respawn's
50
+ * `onSpawned` rewrites this despawn's target so redo removes the respawned
51
+ * entity rather than the dead original.
52
+ */
53
+ despawn<Defs extends readonly ComponentDef[]>(eid: EntityID, restore: SpawnEntries<Defs>): this;
54
+ /**
55
+ * Set `field` of `def` on `eid` to `value`. Inverse: set it back to the value
56
+ * this edit replaced — read from the staged overlay / shadow (so stacked edits,
57
+ * within one build or before a commit, invert correctly) or, failing that, the
58
+ * read channel (`0` if unknown).
59
+ */
60
+ setField<S extends ComponentSchema>(eid: EntityID, def: ComponentDef<S>, field: string & keyof S, value: number): this;
61
+ /** Add `def` (with complete `values`) to `eid`. Inverse: remove it. */
62
+ addComponent<S extends ComponentSchema>(eid: EntityID, def: ComponentDef<S>, values: CompleteFieldValues<S>): this;
63
+ /**
64
+ * Remove `def` from `eid`. Inverse: re-add it from `restore` (the field values
65
+ * to recreate — read them from the channel before removing).
66
+ */
67
+ removeComponent<S extends ComponentSchema>(eid: EntityID, def: ComponentDef<S>, restore: CompleteFieldValues<S>): this;
68
+ /** Disable `eid`. Inverse: enable it. */
69
+ disable(eid: EntityID): this;
70
+ /** Enable `eid`. Inverse: disable it. */
71
+ enable(eid: EntityID): this;
72
+ }
73
+ /**
74
+ * The editor's undo/redo manager over a {@link HostCommandQueue}. Each action is a
75
+ * reified {@link EditorTransaction} pushed onto the undo stack; `undo()`/`redo()`
76
+ * enqueue its inverse/forward on the SAME bus. The single-action methods
77
+ * (`spawn`, `setField`, …) are sugar for one-command transactions; `transaction`
78
+ * groups several into one undo entry.
79
+ *
80
+ * Construct with the queue and a {@link FieldReader} for the committed read
81
+ * channel (used to seed `setField` inverses).
82
+ */
83
+ export declare class Editor {
84
+ private readonly queue;
85
+ private readonly readField;
86
+ private readonly undoStack;
87
+ private readonly redoStack;
88
+ /** onChange subscribers — see {@link onChange}. */
89
+ private readonly listeners;
90
+ /** Per-`(entity, component, field)` shadow of edited values, for inverse correctness. */
91
+ private readonly shadow;
92
+ constructor(queue: HostCommandQueue, readField: FieldReader);
93
+ /**
94
+ * Group several actions into ONE undo entry. Build them on the passed
95
+ * {@link TransactionBuilder}; the whole group commits (enqueues its forward
96
+ * commands) and lands on the undo stack atomically, clearing the redo stack.
97
+ */
98
+ transaction(build: (tx: TransactionBuilder) => void): EditorTransaction;
99
+ /** Spawn `components` as its own undo entry. `onSpawned` reports the new id. */
100
+ spawn<Defs extends readonly ComponentDef[]>(components: SpawnEntries<Defs>, onSpawned?: (eid: EntityID) => void): EditorTransaction;
101
+ /** Despawn `eid` as its own undo entry; `restore` recreates it on undo. */
102
+ despawn<Defs extends readonly ComponentDef[]>(eid: EntityID, restore: SpawnEntries<Defs>): EditorTransaction;
103
+ /** Set one field as its own undo entry. */
104
+ setField<S extends ComponentSchema>(eid: EntityID, def: ComponentDef<S>, field: string & keyof S, value: number): EditorTransaction;
105
+ /** Add a component as its own undo entry. */
106
+ addComponent<S extends ComponentSchema>(eid: EntityID, def: ComponentDef<S>, values: CompleteFieldValues<S>): EditorTransaction;
107
+ /** Remove a component as its own undo entry; `restore` re-adds it on undo. */
108
+ removeComponent<S extends ComponentSchema>(eid: EntityID, def: ComponentDef<S>, restore: CompleteFieldValues<S>): EditorTransaction;
109
+ /** Disable `eid` as its own undo entry. */
110
+ disable(eid: EntityID): EditorTransaction;
111
+ /** Enable `eid` as its own undo entry. */
112
+ enable(eid: EntityID): EditorTransaction;
113
+ /**
114
+ * Undo the most recent transaction: enqueue its inverse commands (in reverse
115
+ * order — a group unwinds last-action-first) on the bus and move it to the redo
116
+ * stack. Returns `false` if the undo stack is empty.
117
+ */
118
+ undo(): boolean;
119
+ /**
120
+ * Redo the most recently undone transaction: re-enqueue its forward commands on
121
+ * the bus and move it back to the undo stack. Returns `false` if the redo stack
122
+ * is empty.
123
+ */
124
+ redo(): boolean;
125
+ /** Drop both stacks (e.g. on load). Does not touch the world. */
126
+ clear(): void;
127
+ /** Current stack depths — for an "Undo (3)" / "Redo" affordance. */
128
+ depths(): {
129
+ undo: number;
130
+ redo: number;
131
+ };
132
+ /** `true` when `undo()` would do something — allocation-free (M10). */
133
+ get canUndo(): boolean;
134
+ /** `true` when `redo()` would do something — allocation-free (M10). */
135
+ get canRedo(): boolean;
136
+ /**
137
+ * Subscribe to undo/redo-stack changes: fires after every commit, undo,
138
+ * redo, and clear — the push signal an "Undo (3)" affordance needs instead
139
+ * of polling `depths()` per frame (M10). Returns an unsubscribe function.
140
+ * Callbacks run synchronously in subscription order; read `canUndo` /
141
+ * `canRedo` / `depths()` inside.
142
+ */
143
+ onChange(cb: () => void): () => void;
144
+ private notify;
145
+ /** Read one committed `(entity, component, field)` slot through the reader
146
+ * this editor was constructed with — the default read for `fieldHandle`
147
+ * when no channel thunk is supplied (M11). */
148
+ committedField(eid: EntityID, def: ComponentDef, field: string): number | undefined;
149
+ /**
150
+ * The pending value the editor believes for a field that the committed read
151
+ * channel has NOT caught up to yet (the shadow), or `undefined` if none. Lets an
152
+ * inspector echo an edit between the `set` and the tick that commits it.
153
+ *
154
+ * Self-resolving: once the read channel reports the shadowed value (the edit
155
+ * landed) — or reports `undefined` (the slot is gone: entity despawned or
156
+ * component removed) — the entry is dropped and this returns `undefined`, so
157
+ * `pending` does not outlive its set→commit window and shadow a later external
158
+ * write, nor a dead slot's lifetime. The one
159
+ * residual: if an external write changes the field to a *different* value within
160
+ * the same window before this is next consulted, `pending` can read stale until
161
+ * the next edit to the slot. `value` (the read channel) is always the source of
162
+ * truth; `pending` is only the optimistic bridge.
163
+ */
164
+ pendingField(eid: EntityID, def: ComponentHandle, field: string): number | undefined;
165
+ /** Enqueue forward commands, record the transaction, clear redo, sync shadow. */
166
+ private commit;
167
+ /** Keep the setField shadow in step with the commands just enqueued. */
168
+ private applyShadow;
169
+ }
170
+ //# sourceMappingURL=editor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../../../src/extensions/editor/editor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;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AAO,CAAC,MAAM;IAId;;kDAE8C;IAC9C,cAAc,CAAC,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAInF;;;;;;;;;;;;;;OAcG;IACH,YAAY,CAAC,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAkBpF,iFAAiF;IACjF,OAAO,CAAC,MAAM;IAad,wEAAwE;IACxE,OAAO,CAAC,WAAW;CAOnB"}
@@ -0,0 +1,40 @@
1
+ import { ComponentDef, ComponentSchema, EntityID } from '../../core/ecs/index.cjs';
2
+ import { Editor } from './editor.cjs';
3
+ /**
4
+ * A two-way handle on one `(entity, component, field)` slot. `value` reads the
5
+ * reactive channel (tracked, if read in a tracking scope); `set` enqueues an
6
+ * undoable `setField` command via the editor.
7
+ */
8
+ export interface FieldHandle {
9
+ /**
10
+ * The field's current value through the reactive read channel — `undefined`
11
+ * until the channel has it (e.g. before the spawn's first commit). Read inside
12
+ * a tracking scope to subscribe to the channel; the value reflects the last
13
+ * COMMITTED tick, so a fresh `set` shows up on the next tick.
14
+ */
15
+ readonly value: number | undefined;
16
+ /** Enqueue an undoable `setField` for this slot; applied at the next tick. */
17
+ set(value: number): void;
18
+ /**
19
+ * The editor's pending (not-yet-committed) value for this slot, or `undefined`
20
+ * if none — a NON-reactive read of the editor shadow, for an optimistic echo
21
+ * between the `set` and its commit. Self-resolves to `undefined` once the read
22
+ * channel catches up, so it does not outlive the edit. Not a substitute for
23
+ * `value` in a tracking scope (it does not subscribe); `value` is the source of
24
+ * truth.
25
+ */
26
+ readonly pending: number | undefined;
27
+ }
28
+ /**
29
+ * Build a {@link FieldHandle} for one `(eid, def, field)` slot. `read` is the
30
+ * tracked read of the reactive channel for this field (e.g.
31
+ * `() => sync.map.get(eid)?.x`); `set` routes through `editor.setField`, so the
32
+ * edit is queued, batched, and undoable.
33
+ *
34
+ * `read` is optional (M11): omitted, the handle reads through the editor's own
35
+ * committed-channel reader (`editor.committedField`). That default is correct
36
+ * but NOT reactive — supply the channel thunk when the handle's `value` must
37
+ * subscribe inside a tracking scope.
38
+ */
39
+ export declare function fieldHandle<S extends ComponentSchema>(editor: Editor, eid: EntityID, def: ComponentDef<S>, field: string & keyof S, read?: () => number | undefined): FieldHandle;
40
+ //# sourceMappingURL=field_handle.d.ts.map