@oasys/oecs 0.5.4 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (510) hide show
  1. package/CHANGELOG.md +1223 -266
  2. package/README.md +217 -112
  3. package/dist/core/ecs/access_check.d.cts +29 -29
  4. package/dist/core/ecs/access_check.d.ts +29 -29
  5. package/dist/core/ecs/access_check.d.ts.map +1 -1
  6. package/dist/core/ecs/archetype.d.cts +217 -209
  7. package/dist/core/ecs/archetype.d.ts +217 -209
  8. package/dist/core/ecs/archetype.d.ts.map +1 -1
  9. package/dist/core/ecs/archetype_closure.d.cts +23 -0
  10. package/dist/core/ecs/archetype_closure.d.ts +23 -0
  11. package/dist/core/ecs/archetype_closure.d.ts.map +1 -0
  12. package/dist/core/ecs/archetype_graph.d.cts +33 -33
  13. package/dist/core/ecs/archetype_graph.d.ts +33 -33
  14. package/dist/core/ecs/archetype_graph.d.ts.map +1 -1
  15. package/dist/core/ecs/archetype_types.d.cts +55 -0
  16. package/dist/core/ecs/archetype_types.d.ts +55 -0
  17. package/dist/core/ecs/archetype_types.d.ts.map +1 -0
  18. package/dist/core/ecs/change_feed.d.cts +53 -0
  19. package/dist/core/ecs/change_feed.d.ts +53 -0
  20. package/dist/core/ecs/change_feed.d.ts.map +1 -0
  21. package/dist/core/ecs/changed_query.d.cts +36 -0
  22. package/dist/core/ecs/changed_query.d.ts +36 -0
  23. package/dist/core/ecs/changed_query.d.ts.map +1 -0
  24. package/dist/core/ecs/chunk_columns.d.cts +49 -0
  25. package/dist/core/ecs/chunk_columns.d.ts +49 -0
  26. package/dist/core/ecs/chunk_columns.d.ts.map +1 -0
  27. package/dist/core/ecs/command_log.d.cts +26 -26
  28. package/dist/core/ecs/command_log.d.ts +26 -26
  29. package/dist/core/ecs/command_log.d.ts.map +1 -1
  30. package/dist/core/ecs/component.d.cts +43 -42
  31. package/dist/core/ecs/component.d.ts +43 -42
  32. package/dist/core/ecs/component.d.ts.map +1 -1
  33. package/dist/core/ecs/component_registry.d.cts +53 -0
  34. package/dist/core/ecs/component_registry.d.ts +53 -0
  35. package/dist/core/ecs/component_registry.d.ts.map +1 -0
  36. package/dist/core/ecs/compute_backend.d.cts +18 -7
  37. package/dist/core/ecs/compute_backend.d.ts +18 -7
  38. package/dist/core/ecs/compute_backend.d.ts.map +1 -1
  39. package/dist/core/ecs/deferred_commands.d.cts +15 -14
  40. package/dist/core/ecs/deferred_commands.d.ts +15 -14
  41. package/dist/core/ecs/deferred_commands.d.ts.map +1 -1
  42. package/dist/core/ecs/dispatch_trace.d.cts +32 -31
  43. package/dist/core/ecs/dispatch_trace.d.ts +32 -31
  44. package/dist/core/ecs/dispatch_trace.d.ts.map +1 -1
  45. package/dist/core/ecs/ecs.d.cts +289 -270
  46. package/dist/core/ecs/ecs.d.ts +289 -270
  47. package/dist/core/ecs/ecs.d.ts.map +1 -1
  48. package/dist/core/ecs/ecs_memory.d.cts +134 -136
  49. package/dist/core/ecs/ecs_memory.d.ts +134 -136
  50. package/dist/core/ecs/ecs_memory.d.ts.map +1 -1
  51. package/dist/core/ecs/ecs_options.d.cts +89 -0
  52. package/dist/core/ecs/ecs_options.d.ts +89 -0
  53. package/dist/core/ecs/ecs_options.d.ts.map +1 -0
  54. package/dist/core/ecs/entity.d.cts +4 -4
  55. package/dist/core/ecs/entity.d.ts +4 -4
  56. package/dist/core/ecs/entity_allocator.d.cts +20 -18
  57. package/dist/core/ecs/entity_allocator.d.ts +20 -18
  58. package/dist/core/ecs/entity_allocator.d.ts.map +1 -1
  59. package/dist/core/ecs/event.d.cts +36 -22
  60. package/dist/core/ecs/event.d.ts +36 -22
  61. package/dist/core/ecs/event.d.ts.map +1 -1
  62. package/dist/core/ecs/facades.d.cts +12 -126
  63. package/dist/core/ecs/facades.d.ts +12 -126
  64. package/dist/core/ecs/facades.d.ts.map +1 -1
  65. package/dist/core/ecs/frame_stepper.d.cts +12 -12
  66. package/dist/core/ecs/frame_stepper.d.ts +12 -12
  67. package/dist/core/ecs/frame_stepper.d.ts.map +1 -1
  68. package/dist/core/ecs/frame_trace.d.cts +32 -32
  69. package/dist/core/ecs/frame_trace.d.ts +32 -32
  70. package/dist/core/ecs/frame_trace.d.ts.map +1 -1
  71. package/dist/core/ecs/host_commands.d.cts +103 -85
  72. package/dist/core/ecs/host_commands.d.ts +103 -85
  73. package/dist/core/ecs/host_commands.d.ts.map +1 -1
  74. package/dist/core/ecs/index.d.cts +21 -11
  75. package/dist/core/ecs/index.d.ts +21 -11
  76. package/dist/core/ecs/index.d.ts.map +1 -1
  77. package/dist/core/ecs/observer.d.cts +39 -120
  78. package/dist/core/ecs/observer.d.ts +39 -120
  79. package/dist/core/ecs/observer.d.ts.map +1 -1
  80. package/dist/core/ecs/phase.d.cts +79 -0
  81. package/dist/core/ecs/phase.d.ts +79 -0
  82. package/dist/core/ecs/phase.d.ts.map +1 -0
  83. package/dist/core/ecs/plugin.d.cts +125 -0
  84. package/dist/core/ecs/plugin.d.ts +125 -0
  85. package/dist/core/ecs/plugin.d.ts.map +1 -0
  86. package/dist/core/ecs/plugin_slots.d.cts +26 -0
  87. package/dist/core/ecs/plugin_slots.d.ts +26 -0
  88. package/dist/core/ecs/plugin_slots.d.ts.map +1 -0
  89. package/dist/core/ecs/query.d.cts +208 -578
  90. package/dist/core/ecs/query.d.ts +208 -578
  91. package/dist/core/ecs/query.d.ts.map +1 -1
  92. package/dist/core/ecs/query_cache.d.cts +130 -0
  93. package/dist/core/ecs/query_cache.d.ts +130 -0
  94. package/dist/core/ecs/query_cache.d.ts.map +1 -0
  95. package/dist/core/ecs/query_registry.d.cts +47 -0
  96. package/dist/core/ecs/query_registry.d.ts +47 -0
  97. package/dist/core/ecs/query_registry.d.ts.map +1 -0
  98. package/dist/core/ecs/query_terms.d.cts +126 -0
  99. package/dist/core/ecs/query_terms.d.ts +126 -0
  100. package/dist/core/ecs/query_terms.d.ts.map +1 -0
  101. package/dist/core/ecs/ref.d.cts +100 -39
  102. package/dist/core/ecs/ref.d.ts +100 -39
  103. package/dist/core/ecs/ref.d.ts.map +1 -1
  104. package/dist/core/ecs/relation.d.cts +101 -182
  105. package/dist/core/ecs/relation.d.ts +101 -182
  106. package/dist/core/ecs/relation.d.ts.map +1 -1
  107. package/dist/core/ecs/resource.d.cts +13 -13
  108. package/dist/core/ecs/resource.d.ts +13 -13
  109. package/dist/core/ecs/resource_registry.d.cts +5 -5
  110. package/dist/core/ecs/resource_registry.d.ts +5 -5
  111. package/dist/core/ecs/resource_registry.d.ts.map +1 -1
  112. package/dist/core/ecs/row_kinds.d.cts +24 -0
  113. package/dist/core/ecs/row_kinds.d.ts +24 -0
  114. package/dist/core/ecs/row_kinds.d.ts.map +1 -0
  115. package/dist/core/ecs/run_condition.d.cts +23 -23
  116. package/dist/core/ecs/run_condition.d.ts +23 -23
  117. package/dist/core/ecs/run_condition.d.ts.map +1 -1
  118. package/dist/core/ecs/schedule.d.cts +91 -120
  119. package/dist/core/ecs/schedule.d.ts +91 -120
  120. package/dist/core/ecs/schedule.d.ts.map +1 -1
  121. package/dist/core/ecs/schedule_plan.d.cts +33 -0
  122. package/dist/core/ecs/schedule_plan.d.ts +33 -0
  123. package/dist/core/ecs/schedule_plan.d.ts.map +1 -0
  124. package/dist/core/ecs/snapshot.d.cts +77 -0
  125. package/dist/core/ecs/snapshot.d.ts +77 -0
  126. package/dist/core/ecs/snapshot.d.ts.map +1 -0
  127. package/dist/core/ecs/snapshot_mount.d.cts +42 -0
  128. package/dist/core/ecs/snapshot_mount.d.ts +42 -0
  129. package/dist/core/ecs/snapshot_mount.d.ts.map +1 -0
  130. package/dist/core/ecs/sparse_store.d.cts +108 -51
  131. package/dist/core/ecs/sparse_store.d.ts +108 -51
  132. package/dist/core/ecs/sparse_store.d.ts.map +1 -1
  133. package/dist/core/ecs/store.d.cts +527 -473
  134. package/dist/core/ecs/store.d.ts +527 -473
  135. package/dist/core/ecs/store.d.ts.map +1 -1
  136. package/dist/core/ecs/store_layout_listener.d.cts +6 -6
  137. package/dist/core/ecs/store_layout_listener.d.ts +6 -6
  138. package/dist/core/ecs/store_types.d.cts +122 -0
  139. package/dist/core/ecs/store_types.d.ts +122 -0
  140. package/dist/core/ecs/store_types.d.ts.map +1 -0
  141. package/dist/core/ecs/system.d.cts +146 -61
  142. package/dist/core/ecs/system.d.ts +146 -61
  143. package/dist/core/ecs/system.d.ts.map +1 -1
  144. package/dist/core/ecs/system_context.d.cts +296 -0
  145. package/dist/core/ecs/system_context.d.ts +296 -0
  146. package/dist/core/ecs/system_context.d.ts.map +1 -0
  147. package/dist/core/ecs/system_set.d.cts +48 -0
  148. package/dist/core/ecs/system_set.d.ts +48 -0
  149. package/dist/core/ecs/system_set.d.ts.map +1 -0
  150. package/dist/core/ecs/utils/arrays.d.cts +15 -1
  151. package/dist/core/ecs/utils/arrays.d.ts +15 -1
  152. package/dist/core/ecs/utils/arrays.d.ts.map +1 -1
  153. package/dist/core/ecs/utils/error.d.cts +82 -6
  154. package/dist/core/ecs/utils/error.d.ts +82 -6
  155. package/dist/core/ecs/utils/error.d.ts.map +1 -1
  156. package/dist/core/ecs/utils/plugin_error.d.cts +10 -0
  157. package/dist/core/ecs/utils/plugin_error.d.ts +10 -0
  158. package/dist/core/ecs/utils/plugin_error.d.ts.map +1 -0
  159. package/dist/core/restore_errors.d.cts +30 -0
  160. package/dist/core/restore_errors.d.ts +30 -0
  161. package/dist/core/restore_errors.d.ts.map +1 -0
  162. package/dist/core/store/action_ring.d.cts +44 -44
  163. package/dist/core/store/action_ring.d.ts +44 -44
  164. package/dist/core/store/action_ring.d.ts.map +1 -1
  165. package/dist/core/store/allocator.d.cts +149 -95
  166. package/dist/core/store/allocator.d.ts +149 -95
  167. package/dist/core/store/allocator.d.ts.map +1 -1
  168. package/dist/core/store/buffer_backed_column.d.cts +17 -17
  169. package/dist/core/store/buffer_backed_column.d.ts +17 -17
  170. package/dist/core/store/buffer_backed_column.d.ts.map +1 -1
  171. package/dist/core/store/column_store.d.cts +124 -86
  172. package/dist/core/store/column_store.d.ts +124 -86
  173. package/dist/core/store/column_store.d.ts.map +1 -1
  174. package/dist/core/store/command_dispatch.d.cts +14 -15
  175. package/dist/core/store/command_dispatch.d.ts +14 -15
  176. package/dist/core/store/command_dispatch.d.ts.map +1 -1
  177. package/dist/core/store/command_ring.d.cts +36 -39
  178. package/dist/core/store/command_ring.d.ts +36 -39
  179. package/dist/core/store/command_ring.d.ts.map +1 -1
  180. package/dist/core/store/descriptor.d.cts +34 -17
  181. package/dist/core/store/descriptor.d.ts +34 -17
  182. package/dist/core/store/descriptor.d.ts.map +1 -1
  183. package/dist/core/store/entity_index.d.cts +34 -35
  184. package/dist/core/store/entity_index.d.ts +34 -35
  185. package/dist/core/store/entity_index.d.ts.map +1 -1
  186. package/dist/core/store/event_ring.d.cts +36 -38
  187. package/dist/core/store/event_ring.d.ts +36 -38
  188. package/dist/core/store/event_ring.d.ts.map +1 -1
  189. package/dist/core/store/extend.d.cts +13 -7
  190. package/dist/core/store/extend.d.ts +13 -7
  191. package/dist/core/store/extend.d.ts.map +1 -1
  192. package/dist/core/store/grow.d.cts +2 -2
  193. package/dist/core/store/grow.d.ts +2 -2
  194. package/dist/core/store/grow.d.ts.map +1 -1
  195. package/dist/core/store/header.d.cts +31 -27
  196. package/dist/core/store/header.d.ts +31 -27
  197. package/dist/core/store/header.d.ts.map +1 -1
  198. package/dist/core/store/index.d.cts +10 -10
  199. package/dist/core/store/index.d.ts +10 -10
  200. package/dist/core/store/index.d.ts.map +1 -1
  201. package/dist/core/store/layout_ops.d.cts +71 -62
  202. package/dist/core/store/layout_ops.d.ts +71 -62
  203. package/dist/core/store/layout_ops.d.ts.map +1 -1
  204. package/dist/core/store/region_table.d.cts +28 -21
  205. package/dist/core/store/region_table.d.ts +28 -21
  206. package/dist/core/store/region_table.d.ts.map +1 -1
  207. package/dist/core/store/snapshot.d.cts +31 -16
  208. package/dist/core/store/snapshot.d.ts +31 -16
  209. package/dist/core/store/snapshot.d.ts.map +1 -1
  210. package/dist/core/store/state_hash.d.cts +12 -12
  211. package/dist/core/store/state_hash.d.ts +12 -12
  212. package/dist/core/store/state_hash.d.ts.map +1 -1
  213. package/dist/core/store/store_regions.d.cts +10 -10
  214. package/dist/core/store/store_regions.d.ts +10 -10
  215. package/dist/core/store/store_regions.d.ts.map +1 -1
  216. package/dist/core/store/vendored_abi/abi.d.cts +27 -2
  217. package/dist/core/store/vendored_abi/abi.d.ts +27 -2
  218. package/dist/core/store/vendored_abi/abi.d.ts.map +1 -1
  219. package/dist/host_commands-B2KMx8O2.cjs +1 -0
  220. package/dist/host_commands-ClVPvhSa.cjs +2 -0
  221. package/dist/host_commands-CwxVQS1z.js +1524 -0
  222. package/dist/host_commands-nJvTy88E.js +1667 -0
  223. package/dist/index.cjs +1 -1
  224. package/dist/index.d.cts +15 -10
  225. package/dist/index.d.ts +15 -10
  226. package/dist/index.d.ts.map +1 -1
  227. package/dist/index.development.cjs +1 -1
  228. package/dist/index.development.js +5804 -5203
  229. package/dist/index.js +5323 -4764
  230. package/dist/internal.cjs +2 -2
  231. package/dist/internal.d.cts +5 -2
  232. package/dist/internal.d.ts +5 -2
  233. package/dist/internal.d.ts.map +1 -1
  234. package/dist/internal.development.cjs +1 -1
  235. package/dist/internal.development.js +70 -20
  236. package/dist/internal.js +138 -83
  237. package/dist/plugins/abi-D3V-QUSf.cjs +1 -0
  238. package/dist/plugins/abi-NP8pNxpd.js +42 -0
  239. package/dist/plugins/arrays-Dr_1hCjL.js +28 -0
  240. package/dist/plugins/arrays-Dt-Joc4i.cjs +1 -0
  241. package/dist/plugins/assertions-gtDVfbnQ.js +6 -0
  242. package/dist/plugins/assertions-z5GQd_bB.cjs +1 -0
  243. package/dist/{extensions → plugins}/editor/editor.d.cts +54 -54
  244. package/dist/{extensions → plugins}/editor/editor.d.ts +54 -54
  245. package/dist/plugins/editor/editor.d.ts.map +1 -0
  246. package/dist/{extensions → plugins}/editor/field_handle.d.cts +12 -12
  247. package/dist/{extensions → plugins}/editor/field_handle.d.ts +12 -12
  248. package/dist/plugins/editor/field_handle.d.ts.map +1 -0
  249. package/dist/plugins/editor/index.d.cts +22 -0
  250. package/dist/plugins/editor/index.d.ts +22 -0
  251. package/dist/plugins/editor/index.d.ts.map +1 -0
  252. package/dist/plugins/editor.cjs +1 -0
  253. package/dist/plugins/editor.d.cts +1 -0
  254. package/dist/plugins/editor.d.ts +1 -0
  255. package/dist/plugins/editor.development.cjs +1 -0
  256. package/dist/{extensions/editor/index.development.js → plugins/editor.development.js} +81 -64
  257. package/dist/{extensions/editor/index.js → plugins/editor.js} +81 -64
  258. package/dist/plugins/events/event_channel.d.cts +13 -0
  259. package/dist/plugins/events/event_channel.d.ts +13 -0
  260. package/dist/plugins/events/event_channel.d.ts.map +1 -0
  261. package/dist/plugins/events/event_registry.d.cts +22 -0
  262. package/dist/plugins/events/event_registry.d.ts +22 -0
  263. package/dist/plugins/events/event_registry.d.ts.map +1 -0
  264. package/dist/plugins/events/facade.d.cts +26 -0
  265. package/dist/plugins/events/facade.d.ts +26 -0
  266. package/dist/plugins/events/facade.d.ts.map +1 -0
  267. package/dist/plugins/events/index.d.cts +10 -0
  268. package/dist/plugins/events/index.d.ts +10 -0
  269. package/dist/plugins/events/index.d.ts.map +1 -0
  270. package/dist/plugins/events.cjs +1 -0
  271. package/dist/plugins/events.d.cts +1 -0
  272. package/dist/plugins/events.d.ts +1 -0
  273. package/dist/plugins/events.development.cjs +1 -0
  274. package/dist/plugins/events.development.js +174 -0
  275. package/dist/plugins/events.js +159 -0
  276. package/dist/plugins/observers/index.d.cts +23 -0
  277. package/dist/plugins/observers/index.d.ts +23 -0
  278. package/dist/plugins/observers/index.d.ts.map +1 -0
  279. package/dist/plugins/observers/observer_registry.d.cts +101 -0
  280. package/dist/plugins/observers/observer_registry.d.ts +101 -0
  281. package/dist/plugins/observers/observer_registry.d.ts.map +1 -0
  282. package/dist/plugins/observers.cjs +1 -0
  283. package/dist/plugins/observers.d.cts +1 -0
  284. package/dist/plugins/observers.d.ts +1 -0
  285. package/dist/plugins/observers.development.cjs +1 -0
  286. package/dist/plugins/observers.development.js +431 -0
  287. package/dist/plugins/observers.js +403 -0
  288. package/dist/plugins/relation_store-BsoegrZh.js +313 -0
  289. package/dist/plugins/relation_store-DQKSnxsm.cjs +1 -0
  290. package/dist/plugins/relation_store-RBhpcE28.cjs +1 -0
  291. package/dist/plugins/relation_store-RqW5Snx6.js +328 -0
  292. package/dist/plugins/relations/builtin_relations.d.cts +48 -0
  293. package/dist/plugins/relations/builtin_relations.d.ts +48 -0
  294. package/dist/plugins/relations/builtin_relations.d.ts.map +1 -0
  295. package/dist/plugins/relations/facade.d.cts +73 -0
  296. package/dist/plugins/relations/facade.d.ts +73 -0
  297. package/dist/plugins/relations/facade.d.ts.map +1 -0
  298. package/dist/plugins/relations/index.d.cts +11 -0
  299. package/dist/plugins/relations/index.d.ts +11 -0
  300. package/dist/plugins/relations/index.d.ts.map +1 -0
  301. package/dist/{core/ecs → plugins/relations}/relation_service.d.cts +85 -97
  302. package/dist/{core/ecs → plugins/relations}/relation_service.d.ts +85 -97
  303. package/dist/plugins/relations/relation_service.d.ts.map +1 -0
  304. package/dist/plugins/relations/relation_store.d.cts +177 -0
  305. package/dist/plugins/relations/relation_store.d.ts +177 -0
  306. package/dist/plugins/relations/relation_store.d.ts.map +1 -0
  307. package/dist/plugins/relations.cjs +1 -0
  308. package/dist/plugins/relations.d.cts +1 -0
  309. package/dist/plugins/relations.d.ts +1 -0
  310. package/dist/plugins/relations.development.cjs +1 -0
  311. package/dist/plugins/relations.development.js +603 -0
  312. package/dist/plugins/relations.js +553 -0
  313. package/dist/plugins/snapshots/index.d.cts +33 -0
  314. package/dist/plugins/snapshots/index.d.ts +33 -0
  315. package/dist/plugins/snapshots/index.d.ts.map +1 -0
  316. package/dist/plugins/snapshots/resume.d.cts +57 -0
  317. package/dist/plugins/snapshots/resume.d.ts +57 -0
  318. package/dist/plugins/snapshots/resume.d.ts.map +1 -0
  319. package/dist/plugins/snapshots/snapshot_service.d.cts +59 -0
  320. package/dist/plugins/snapshots/snapshot_service.d.ts +59 -0
  321. package/dist/plugins/snapshots/snapshot_service.d.ts.map +1 -0
  322. package/dist/plugins/snapshots.cjs +1 -0
  323. package/dist/plugins/snapshots.d.cts +1 -0
  324. package/dist/plugins/snapshots.d.ts +1 -0
  325. package/dist/plugins/snapshots.development.cjs +1 -0
  326. package/dist/plugins/snapshots.development.js +737 -0
  327. package/dist/plugins/snapshots.js +737 -0
  328. package/dist/plugins/solid/index.d.cts +8 -0
  329. package/dist/plugins/solid/index.d.ts +8 -0
  330. package/dist/plugins/solid/index.d.ts.map +1 -0
  331. package/dist/plugins/solid/solid.d.cts +97 -0
  332. package/dist/plugins/solid/solid.d.ts +97 -0
  333. package/dist/plugins/solid/solid.d.ts.map +1 -0
  334. package/dist/plugins/solid.cjs +1 -0
  335. package/dist/plugins/solid.d.cts +1 -0
  336. package/dist/plugins/solid.d.ts +1 -0
  337. package/dist/plugins/solid.development.cjs +1 -0
  338. package/dist/plugins/solid.development.js +319 -0
  339. package/dist/plugins/solid.js +319 -0
  340. package/dist/plugins/workers/index.d.cts +75 -0
  341. package/dist/plugins/workers/index.d.ts +75 -0
  342. package/dist/plugins/workers/index.d.ts.map +1 -0
  343. package/dist/plugins/workers/node_threads.d.cts +25 -0
  344. package/dist/plugins/workers/node_threads.d.ts +25 -0
  345. package/dist/plugins/workers/node_threads.d.ts.map +1 -0
  346. package/dist/plugins/workers/plan.d.cts +61 -0
  347. package/dist/plugins/workers/plan.d.ts +61 -0
  348. package/dist/plugins/workers/plan.d.ts.map +1 -0
  349. package/dist/plugins/workers/pool.d.cts +144 -0
  350. package/dist/plugins/workers/pool.d.ts +144 -0
  351. package/dist/plugins/workers/pool.d.ts.map +1 -0
  352. package/dist/plugins/workers/protocol.d.cts +112 -0
  353. package/dist/plugins/workers/protocol.d.ts +112 -0
  354. package/dist/plugins/workers/protocol.d.ts.map +1 -0
  355. package/dist/plugins/workers/worker_bind.d.cts +64 -0
  356. package/dist/plugins/workers/worker_bind.d.ts +64 -0
  357. package/dist/plugins/workers/worker_bind.d.ts.map +1 -0
  358. package/dist/plugins/workers/worker_loop.d.cts +14 -0
  359. package/dist/plugins/workers/worker_loop.d.ts +14 -0
  360. package/dist/plugins/workers/worker_loop.d.ts.map +1 -0
  361. package/dist/plugins/workers.cjs +1 -0
  362. package/dist/plugins/workers.d.cts +1 -0
  363. package/dist/plugins/workers.d.ts +1 -0
  364. package/dist/plugins/workers.development.cjs +1 -0
  365. package/dist/plugins/workers.development.js +596 -0
  366. package/dist/plugins/workers.js +474 -0
  367. package/dist/primitives.cjs +1 -1
  368. package/dist/primitives.d.cts +4 -4
  369. package/dist/primitives.d.ts +4 -4
  370. package/dist/primitives.development.cjs +1 -1
  371. package/dist/primitives.development.js +66 -22
  372. package/dist/primitives.js +66 -22
  373. package/dist/shared-BKl12xF1.js +132 -0
  374. package/dist/shared-Dk-pACZT.cjs +1 -0
  375. package/dist/shared.cjs +1 -1
  376. package/dist/shared.d.cts +7 -7
  377. package/dist/shared.d.ts +7 -7
  378. package/dist/shared.d.ts.map +1 -1
  379. package/dist/shared.development.cjs +1 -1
  380. package/dist/shared.development.js +4 -3
  381. package/dist/shared.js +4 -3
  382. package/dist/topological_sort-Cc_yXqPT.js +346 -0
  383. package/dist/topological_sort-vp1imU6D.cjs +1 -0
  384. package/dist/type_primitives/assertions.d.cts +12 -16
  385. package/dist/type_primitives/assertions.d.ts +12 -16
  386. package/dist/type_primitives/assertions.d.ts.map +1 -1
  387. package/dist/type_primitives/binary_heap/binary_heap.d.cts +2 -6
  388. package/dist/type_primitives/binary_heap/binary_heap.d.ts +2 -6
  389. package/dist/type_primitives/binary_heap/binary_heap.d.ts.map +1 -1
  390. package/dist/type_primitives/bitset/bitset.d.cts +7 -11
  391. package/dist/type_primitives/bitset/bitset.d.ts +7 -11
  392. package/dist/type_primitives/bitset/bitset.d.ts.map +1 -1
  393. package/dist/type_primitives/brand.d.cts +2 -7
  394. package/dist/type_primitives/brand.d.ts +2 -7
  395. package/dist/type_primitives/brand.d.ts.map +1 -1
  396. package/dist/type_primitives/error.d.cts +1 -2
  397. package/dist/type_primitives/error.d.ts +1 -2
  398. package/dist/type_primitives/error.d.ts.map +1 -1
  399. package/dist/type_primitives/index.d.cts +1 -1
  400. package/dist/type_primitives/index.d.ts +1 -1
  401. package/dist/type_primitives/sparse_map/sparse_map.d.cts +3 -7
  402. package/dist/type_primitives/sparse_map/sparse_map.d.ts +3 -7
  403. package/dist/type_primitives/sparse_map/sparse_map.d.ts.map +1 -1
  404. package/dist/type_primitives/sparse_set/sparse_set.d.cts +2 -6
  405. package/dist/type_primitives/sparse_set/sparse_set.d.ts +2 -6
  406. package/dist/type_primitives/sparse_set/sparse_set.d.ts.map +1 -1
  407. package/dist/type_primitives/topological_sort/topological_sort.d.cts +1 -5
  408. package/dist/type_primitives/topological_sort/topological_sort.d.ts +1 -5
  409. package/dist/type_primitives/topological_sort/topological_sort.d.ts.map +1 -1
  410. package/dist/type_primitives/typed_arrays/typed_arrays.d.cts +16 -15
  411. package/dist/type_primitives/typed_arrays/typed_arrays.d.ts +16 -15
  412. package/dist/type_primitives/typed_arrays/typed_arrays.d.ts.map +1 -1
  413. package/dist/utils/error.d.ts.map +1 -1
  414. package/dist/version.d.cts +3 -3
  415. package/dist/version.d.ts +3 -3
  416. package/dist/worker.cjs +1 -0
  417. package/dist/worker.d.cts +17 -0
  418. package/dist/worker.d.ts +17 -0
  419. package/dist/worker.d.ts.map +1 -0
  420. package/dist/worker.development.cjs +1 -0
  421. package/dist/worker.development.js +253 -0
  422. package/dist/worker.js +253 -0
  423. package/package.json +363 -191
  424. package/dist/core/ecs/builtin_relations.d.cts +0 -43
  425. package/dist/core/ecs/builtin_relations.d.ts +0 -43
  426. package/dist/core/ecs/builtin_relations.d.ts.map +0 -1
  427. package/dist/core/ecs/event_registry.d.cts +0 -22
  428. package/dist/core/ecs/event_registry.d.ts +0 -22
  429. package/dist/core/ecs/event_registry.d.ts.map +0 -1
  430. package/dist/core/ecs/relation_service.d.ts.map +0 -1
  431. package/dist/core/ecs/resume.d.cts +0 -85
  432. package/dist/core/ecs/resume.d.ts +0 -85
  433. package/dist/core/ecs/resume.d.ts.map +0 -1
  434. package/dist/core/ecs/snapshot_service.d.cts +0 -94
  435. package/dist/core/ecs/snapshot_service.d.ts +0 -94
  436. package/dist/core/ecs/snapshot_service.d.ts.map +0 -1
  437. package/dist/extensions/editor/editor.d.ts.map +0 -1
  438. package/dist/extensions/editor/field_handle.d.ts.map +0 -1
  439. package/dist/extensions/editor/index.cjs +0 -1
  440. package/dist/extensions/editor/index.d.cts +0 -21
  441. package/dist/extensions/editor/index.d.ts +0 -21
  442. package/dist/extensions/editor/index.d.ts.map +0 -1
  443. package/dist/extensions/editor/index.development.cjs +0 -1
  444. package/dist/extensions/reactive/ecs_sync.d.cts +0 -214
  445. package/dist/extensions/reactive/ecs_sync.d.ts +0 -214
  446. package/dist/extensions/reactive/ecs_sync.d.ts.map +0 -1
  447. package/dist/extensions/reactive/index.cjs +0 -1
  448. package/dist/extensions/reactive/index.d.cts +0 -23
  449. package/dist/extensions/reactive/index.d.ts +0 -23
  450. package/dist/extensions/reactive/index.d.ts.map +0 -1
  451. package/dist/extensions/reactive/index.development.cjs +0 -1
  452. package/dist/extensions/reactive/index.development.js +0 -215
  453. package/dist/extensions/reactive/index.js +0 -215
  454. package/dist/extensions/solid/index.cjs +0 -1
  455. package/dist/extensions/solid/index.d.cts +0 -6
  456. package/dist/extensions/solid/index.d.ts +0 -6
  457. package/dist/extensions/solid/index.d.ts.map +0 -1
  458. package/dist/extensions/solid/index.development.cjs +0 -1
  459. package/dist/extensions/solid/index.development.js +0 -40
  460. package/dist/extensions/solid/index.js +0 -36
  461. package/dist/extensions/solid/kernel_solid.d.cts +0 -45
  462. package/dist/extensions/solid/kernel_solid.d.ts +0 -45
  463. package/dist/extensions/solid/kernel_solid.d.ts.map +0 -1
  464. package/dist/host_commands-BlR3oZ3x.js +0 -2406
  465. package/dist/host_commands-C2cpU3yC.cjs +0 -1
  466. package/dist/internal-BoxWl4dG.js +0 -2565
  467. package/dist/internal-CGBEwfeB.cjs +0 -2
  468. package/dist/interop-CT-REx0W.cjs +0 -1
  469. package/dist/interop-CcY6ASQc.js +0 -18
  470. package/dist/interop-DqxleBo7.js +0 -18
  471. package/dist/interop-T1HZ-Dpa.cjs +0 -1
  472. package/dist/kernel-Cz2Kxlwl.js +0 -240
  473. package/dist/kernel-DgyrLFjW.js +0 -227
  474. package/dist/kernel-sw7ScKWu.cjs +0 -1
  475. package/dist/kernel-yWV3XnAb.cjs +0 -1
  476. package/dist/reactive/array.d.cts +0 -24
  477. package/dist/reactive/array.d.ts +0 -24
  478. package/dist/reactive/array.d.ts.map +0 -1
  479. package/dist/reactive/index.cjs +0 -1
  480. package/dist/reactive/index.d.cts +0 -11
  481. package/dist/reactive/index.d.ts +0 -11
  482. package/dist/reactive/index.d.ts.map +0 -1
  483. package/dist/reactive/index.development.cjs +0 -1
  484. package/dist/reactive/index.development.js +0 -18
  485. package/dist/reactive/index.js +0 -18
  486. package/dist/reactive/interop.d.cts +0 -19
  487. package/dist/reactive/interop.d.ts +0 -19
  488. package/dist/reactive/interop.d.ts.map +0 -1
  489. package/dist/reactive/kernel.d.cts +0 -73
  490. package/dist/reactive/kernel.d.ts +0 -73
  491. package/dist/reactive/kernel.d.ts.map +0 -1
  492. package/dist/reactive/map.d.cts +0 -16
  493. package/dist/reactive/map.d.ts +0 -16
  494. package/dist/reactive/map.d.ts.map +0 -1
  495. package/dist/reactive/shallow.d.cts +0 -11
  496. package/dist/reactive/shallow.d.ts +0 -11
  497. package/dist/reactive/shallow.d.ts.map +0 -1
  498. package/dist/reactive/struct.d.cts +0 -10
  499. package/dist/reactive/struct.d.ts +0 -10
  500. package/dist/reactive/struct.d.ts.map +0 -1
  501. package/dist/shallow-Bs39EPh1.js +0 -150
  502. package/dist/shallow-C5YmTbtb.cjs +0 -1
  503. package/dist/shallow-CiFC70Dz.js +0 -159
  504. package/dist/shallow-DQ8aG51_.cjs +0 -1
  505. package/dist/shared-B4v0L1cw.js +0 -109
  506. package/dist/shared-DU78k0pU.cjs +0 -1
  507. package/dist/topological_sort-BDvEyb9W.cjs +0 -1
  508. package/dist/topological_sort-DK6EjpWa.js +0 -135
  509. package/dist/typed_arrays-D3NmwtCG.cjs +0 -1
  510. package/dist/typed_arrays-DIVwVy5_.js +0 -258
@@ -0,0 +1,1667 @@
1
+ import { D as Ge, w as de, g as We, h as Xe } from "./shared-BKl12xF1.js";
2
+ class be extends Error {
3
+ constructor(t, n, s) {
4
+ super(t), this.isOperational = n, this.context = s, this.name = this.constructor.name, typeof Error.captureStackTrace == "function" && Error.captureStackTrace(this, this.constructor);
5
+ }
6
+ }
7
+ var oe = /* @__PURE__ */ ((e) => (e.ASSERTION_FAIL_CONDITION = "ASSERTION_FAIL_CONDITION", e.VALIDATION_FAIL_CONDITION = "VALIDATION_FAIL_CONDITION", e.ASSERTION_FAIL_NON_NULLABLE = "ASSERTION_FAIL_NON_NULLABLE", e.ASSERTION_FAIL_UNREACHABLE = "ASSERTION_FAIL_UNREACHABLE", e))(oe || {});
8
+ class Le extends be {
9
+ constructor(t, n, s) {
10
+ super(n, !1, s), this.category = t, this.name = "AssertionError";
11
+ }
12
+ }
13
+ const rn = (e) => Number.isInteger(e) && e >= 0;
14
+ function an(e, t, n) {
15
+ if (!t(e))
16
+ throw new Le(
17
+ oe.VALIDATION_FAIL_CONDITION,
18
+ `Expected value to meet validation: ${n}`
19
+ );
20
+ return e;
21
+ }
22
+ function cn(e) {
23
+ return e;
24
+ }
25
+ function Ke(e, t) {
26
+ throw new Le(
27
+ oe.ASSERTION_FAIL_UNREACHABLE,
28
+ `Unhandled ${t}: ${String(e)}`
29
+ );
30
+ }
31
+ var E = /* @__PURE__ */ ((e) => (e.EID_MAX_INDEX_OVERFLOW = "EID_MAX_INDEX_OVERFLOW", e.EID_MAX_GEN_OVERFLOW = "EID_MAX_GEN_OVERFLOW", e.COMPONENT_NOT_REGISTERED = "COMPONENT_NOT_REGISTERED", e.COMPONENT_LIMIT_EXCEEDED = "COMPONENT_LIMIT_EXCEEDED", e.ENTITY_NOT_ALIVE = "ENTITY_NOT_ALIVE", e.CIRCULAR_SYSTEM_DEPENDENCY = "CIRCULAR_SYSTEM_DEPENDENCY", e.DUPLICATE_SYSTEM = "DUPLICATE_SYSTEM", e.UNKNOWN_PHASE = "UNKNOWN_PHASE", e.CIRCULAR_PHASE_DEPENDENCY = "CIRCULAR_PHASE_DEPENDENCY", e.ARCHETYPE_NOT_FOUND = "ARCHETYPE_NOT_FOUND", e.RESOURCE_NOT_REGISTERED = "RESOURCE_NOT_REGISTERED", e.RESOURCE_ALREADY_REGISTERED = "RESOURCE_ALREADY_REGISTERED", e.EVENT_ALREADY_REGISTERED = "EVENT_ALREADY_REGISTERED", e.EVENT_NOT_REGISTERED = "EVENT_NOT_REGISTERED", e.INVALID_EVENT_ID = "INVALID_EVENT_ID", e.FIELD_NOT_REGISTERED = "FIELD_NOT_REGISTERED", e.RELATION_NOT_REGISTERED = "RELATION_NOT_REGISTERED", e.RELATION_MODE_INVALID = "RELATION_MODE_INVALID", e.RELATION_MODE_MISMATCH = "RELATION_MODE_MISMATCH", e.RELATION_CYCLE = "RELATION_CYCLE", e.SPARSE_CACHE_KEY_OVERFLOW = "SPARSE_CACHE_KEY_OVERFLOW", e.SPARSE_QUERY_DENSE_PATH = "SPARSE_QUERY_DENSE_PATH", e.QUERY_TERM_DENSE_PATH = "QUERY_TERM_DENSE_PATH", e.HIERARCHY_ALREADY_SET = "HIERARCHY_ALREADY_SET", e.HIERARCHY_INVALID_MAX_DEPTH = "HIERARCHY_INVALID_MAX_DEPTH", e.OBSERVER_NON_CONVERGENT = "OBSERVER_NON_CONVERGENT", e.OBSERVER_INVALID_CONFIG = "OBSERVER_INVALID_CONFIG", e.OBSERVER_ONSET_EMIT = "OBSERVER_ONSET_EMIT", e.ROW_TICKS_NOT_TRACKED = "ROW_TICKS_NOT_TRACKED", e.INVALID_FIXED_TIMESTEP = "INVALID_FIXED_TIMESTEP", e.INVALID_MAX_FIXED_STEPS = "INVALID_MAX_FIXED_STEPS", e.INVALID_RECORDER_SCHEDULE = "INVALID_RECORDER_SCHEDULE", e.EMPTY_ARCHETYPE_MATERIALIZE = "EMPTY_ARCHETYPE_MATERIALIZE", e.COMPONENT_INDEX_INVARIANT = "COMPONENT_INDEX_INVARIANT", e.ARCHETYPE_ROW_INVARIANT = "ARCHETYPE_ROW_INVARIANT", e.OPTIONAL_TERM_NOT_DECLARED = "OPTIONAL_TERM_NOT_DECLARED", e.QUERY_ACCESS_UNDECLARED = "QUERY_ACCESS_UNDECLARED", e.ACCESS_UNDECLARED = "ACCESS_UNDECLARED", e.QUERY_NOT_SINGLETON = "QUERY_NOT_SINGLETON", e.INVALID_RUN_CONDITION = "INVALID_RUN_CONDITION", e.SYSTEM_FN_ARITY = "SYSTEM_FN_ARITY", e.INVALID_SYSTEM_ID = "INVALID_SYSTEM_ID", e.PARTITION_APPEND_NEEDS_ENTITY_ROW = "PARTITION_APPEND_NEEDS_ENTITY_ROW", e.PARTITION_BULK_INTO_DISABLED = "PARTITION_BULK_INTO_DISABLED", e.STRUCTURAL_DURING_ITERATION = "STRUCTURAL_DURING_ITERATION", e.BACKEND_ALREADY_ATTACHED = "BACKEND_ALREADY_ATTACHED", e.DETERMINISM_DISABLED = "DETERMINISM_DISABLED", e.SNAPSHOT_RESTORE_FAILED = "SNAPSHOT_RESTORE_FAILED", e.NON_DETERMINISTIC_COLUMN_TYPE = "NON_DETERMINISTIC_COLUMN_TYPE", e.INVALID_MEMORY_OPTIONS = "INVALID_MEMORY_OPTIONS", e.STORE_CAP_EXCEEDED = "STORE_CAP_EXCEEDED", e.REGION_NOT_DECLARED = "REGION_NOT_DECLARED", e.COMMAND_LOG_TAG_COLLISION = "COMMAND_LOG_TAG_COLLISION", e.INVALID_FRAME_STEP = "INVALID_FRAME_STEP", e.INVALID_TEMPLATE = "INVALID_TEMPLATE", e.PLUGIN_NOT_INSTALLED = "PLUGIN_NOT_INSTALLED", e.PLUGIN_ALREADY_INSTALLED = "PLUGIN_ALREADY_INSTALLED", e.PLUGIN_SURFACE_COLLISION = "PLUGIN_SURFACE_COLLISION", e.WORKERS_ATTACHED = "WORKERS_ATTACHED", e.WORKERS_NEED_SHARED_BACKING = "WORKERS_NEED_SHARED_BACKING", e.WORKERS_HOST_CANNOT_PARK = "WORKERS_HOST_CANNOT_PARK", e.WORKERS_COUNT_INVALID = "WORKERS_COUNT_INVALID", e.WORKERS_ENTRY_UNREACHABLE = "WORKERS_ENTRY_UNREACHABLE", e.PARALLEL_ACCESS = "PARALLEL_ACCESS", e.PARALLEL_KERNEL_MODULE = "PARALLEL_KERNEL_MODULE", e.PARALLEL_KERNEL_FAILED = "PARALLEL_KERNEL_FAILED", e))(E || {});
32
+ class f extends be {
33
+ constructor(t, n, s) {
34
+ super(n ?? t, !0, s), this.category = t, this.name = "ECSError";
35
+ }
36
+ }
37
+ function dn(e) {
38
+ return e instanceof f;
39
+ }
40
+ class ln extends f {
41
+ constructor(t) {
42
+ super("SNAPSHOT_RESTORE_FAILED", t), this.name = "ECSRestoreError";
43
+ }
44
+ }
45
+ const _n = -1, un = -1, fn = Object.freeze(/* @__PURE__ */ Object.create(null)), En = 2654435769, mn = 1367130551, ze = 1024, An = 0, je = 31, hn = 1 / 60, In = 4, pn = 0, F = 20, Ce = (1 << F) - 1, Pe = Ce, Qe = je - F, z = (1 << Qe) - 1, Tn = z, gn = z - 1, Nn = z << F | Pe, yn = (e, t) => {
46
+ {
47
+ if (e < 0 || e > Pe)
48
+ throw new f(E.EID_MAX_INDEX_OVERFLOW);
49
+ if (t < 0 || t > z)
50
+ throw new f(E.EID_MAX_GEN_OVERFLOW);
51
+ }
52
+ return t << F | e;
53
+ }, le = (e) => e & Ce, _e = (e) => e >> F, Sn = (e, t, n) => new f(
54
+ E.ENTITY_NOT_ALIVE,
55
+ `${e}: entity ${t} (index ${le(t)}, generation ${_e(
56
+ t
57
+ )}) is not alive${n ? `, ${n}` : ""}. It was destroyed, never created, or the handle is stale. Guard with isAlive() first`,
58
+ { entity: t, index: le(t), generation: _e(t), op: e }
59
+ ), re = /* @__PURE__ */ new WeakMap();
60
+ function On(e, t) {
61
+ re.set(e, t);
62
+ }
63
+ function Dn(e) {
64
+ return re.get(e);
65
+ }
66
+ function qe(e) {
67
+ const t = re.get(e);
68
+ return t !== void 0 ? `'${t}' (component ${e.id})` : `component ${e.id}`;
69
+ }
70
+ const Je = 827148627, Ze = 1, ve = 4, et = 52, g = {
71
+ magic: 0,
72
+ sim_abi_version: 4,
73
+ view_stamp: 8,
74
+ capacity: 12,
75
+ archetype_count: 16,
76
+ layout_descriptor_off: 20,
77
+ command_ring_off: 24,
78
+ action_ring_off: 28,
79
+ entity_index_off: 32,
80
+ event_ring_off: 36,
81
+ region_table_off: 40,
82
+ region_table_count: 44,
83
+ bindings_off: 48
84
+ }, V = 12, C = {
85
+ region_id: 0,
86
+ byte_offset: 4,
87
+ byte_length: 8
88
+ }, Me = 16, x = {
89
+ component_id: 0,
90
+ field_id: 2,
91
+ type_tag: 4,
92
+ byte_off: 8,
93
+ stride: 12
94
+ }, Ue = 40, P = {
95
+ archetype_id: 0,
96
+ component_mask: 4,
97
+ row_count: 20,
98
+ row_capacity: 24,
99
+ column_count: 28,
100
+ enabled_count: 32,
101
+ entity_ids_off: 36
102
+ }, A = {
103
+ u8: 0,
104
+ i8: 1,
105
+ u16: 2,
106
+ i16: 3,
107
+ u32: 4,
108
+ i32: 5,
109
+ f32: 6,
110
+ f64: 7
111
+ }, ue = Object.freeze({
112
+ [A.u8]: 1,
113
+ [A.i8]: 1,
114
+ [A.u16]: 2,
115
+ [A.i16]: 2,
116
+ [A.u32]: 4,
117
+ [A.i32]: 4,
118
+ [A.f32]: 4,
119
+ [A.f64]: 8
120
+ }), wn = {
121
+ u8: A.u8,
122
+ i8: A.i8,
123
+ u16: A.u16,
124
+ i16: A.i16,
125
+ u32: A.u32,
126
+ i32: A.i32,
127
+ f32: A.f32,
128
+ f64: A.f64
129
+ };
130
+ function tt(e, t, n) {
131
+ e.setUint16(t + x.component_id, n.componentId, !0), e.setUint16(t + x.field_id, n.fieldId, !0), e.setUint8(t + x.type_tag, n.typeTag), e.setUint32(t + x.byte_off, n.byteOff, !0), e.setUint16(t + x.stride, n.stride, !0);
132
+ }
133
+ const Rn = ve * 32;
134
+ function $e(e, t = Ue) {
135
+ return t + e * Me;
136
+ }
137
+ function nt(e, t, n) {
138
+ e.setUint32(t + P.archetype_id, n.archetypeId, !0);
139
+ for (let o = 0; o < ve; o++)
140
+ e.setUint32(
141
+ t + P.component_mask + o * 4,
142
+ n.componentMask[o] ?? 0,
143
+ !0
144
+ );
145
+ e.setUint32(t + P.row_count, n.rowCount, !0), e.setUint32(t + P.row_capacity, n.rowCapacity, !0), e.setUint32(t + P.column_count, n.columns.length, !0), e.setUint32(t + P.enabled_count, n.enabledCount, !0), e.setUint32(t + P.entity_ids_off, 0, !0);
146
+ let s = t + Ue;
147
+ for (let o = 0; o < n.columns.length; o++)
148
+ tt(e, s, n.columns[o]), s += Me;
149
+ return s;
150
+ }
151
+ function st(e, t, n) {
152
+ let s = t;
153
+ for (let o = 0; o < n.length; o++)
154
+ s = nt(e, s, n[o]);
155
+ return s;
156
+ }
157
+ function ot(e) {
158
+ let t = 0;
159
+ for (let n = 0; n < e.length; n++)
160
+ t += $e(e[n].columns.length);
161
+ return t;
162
+ }
163
+ function rt(e, t) {
164
+ e.setUint32(g.magic, t.magic, !0), e.setUint32(g.sim_abi_version, t.simAbiVersion, !0), e.setUint32(g.view_stamp, t.viewStamp, !0), e.setUint32(g.capacity, t.capacity, !0), e.setUint32(g.archetype_count, t.archetypeCount, !0), e.setUint32(g.layout_descriptor_off, t.layoutDescriptorOff, !0), e.setUint32(g.command_ring_off, t.commandRingOff, !0), e.setUint32(g.action_ring_off, t.actionRingOff, !0), e.setUint32(g.entity_index_off, t.entityIndexOff, !0), e.setUint32(g.event_ring_off, t.eventRingOff, !0), e.setUint32(g.region_table_off, t.regionTableOff, !0), e.setUint32(g.region_table_count, t.regionTableCount, !0), e.setUint32(g.bindings_off, t.bindingsOff, !0);
165
+ }
166
+ const Be = 16, M = 16, bn = 256, D = {
167
+ write_head: 0,
168
+ read_head: 4,
169
+ capacity_slots: 8,
170
+ overflow_flag: 12
171
+ }, ie = 0;
172
+ function fe(e) {
173
+ return Be + e * M;
174
+ }
175
+ function it(e) {
176
+ return e > 0 && (e & e - 1) === 0;
177
+ }
178
+ class R extends Error {
179
+ constructor(t) {
180
+ super(t), this.name = "CommandRingError";
181
+ }
182
+ }
183
+ function at(e, t, n) {
184
+ if (!it(n))
185
+ throw new R(
186
+ `command ring capacity_slots must be a positive power of two (got ${n})`
187
+ );
188
+ e.setUint32(t + D.write_head, 0, !0), e.setUint32(t + D.read_head, 0, !0), e.setUint32(t + D.capacity_slots, n, !0), e.setUint32(t + D.overflow_flag, 0, !0);
189
+ }
190
+ function ct(e, t) {
191
+ return e.getUint32(t + D.write_head, !0);
192
+ }
193
+ function dt(e, t) {
194
+ return e.getUint32(t + D.read_head, !0);
195
+ }
196
+ function lt(e, t) {
197
+ return e.getUint32(t + D.capacity_slots, !0);
198
+ }
199
+ function _t(e, t, n) {
200
+ if (n.byteLength !== M - 1)
201
+ throw new R(
202
+ `outPayload must be ${M - 1} bytes (got ${n.byteLength})`
203
+ );
204
+ const s = ct(e, t), o = dt(e, t);
205
+ if (s === o) return ie;
206
+ const r = lt(e, t), l = o & r - 1, d = t + Be + l * M, c = e.getUint8(d), _ = new Uint8Array(
207
+ e.buffer,
208
+ e.byteOffset + d + 1,
209
+ M - 1
210
+ );
211
+ return n.set(_), e.setUint32(t + D.read_head, o + 1 >>> 0, !0), c;
212
+ }
213
+ function ut(e, t, n) {
214
+ let s = 0;
215
+ const o = new Uint8Array(M - 1);
216
+ for (; ; ) {
217
+ const r = _t(e, t, o);
218
+ if (r === ie) return s;
219
+ n(r, o.slice()), s++;
220
+ }
221
+ }
222
+ const j = 16, L = 12, G = {
223
+ length: 0,
224
+ capacity: 4
225
+ // 8..16: pad to 16-byte alignment so the i32 arrays start aligned.
226
+ }, Ee = 1 << 20;
227
+ function me(e) {
228
+ if (e < 0 || !Number.isInteger(e))
229
+ throw new Ye(
230
+ `entity index capacity must be a non-negative integer (got ${e})`
231
+ );
232
+ return j + e * L;
233
+ }
234
+ function ft(e) {
235
+ return e + j;
236
+ }
237
+ function Et(e, t) {
238
+ return e + j + t * 4;
239
+ }
240
+ function mt(e, t) {
241
+ return e + j + t * 8;
242
+ }
243
+ class Ye extends Error {
244
+ constructor(t) {
245
+ super(t), this.name = "EntityIndexError";
246
+ }
247
+ }
248
+ function At(e, t, n) {
249
+ if (n < 0 || !Number.isInteger(n))
250
+ throw new Ye(
251
+ `entity index capacity must be a non-negative integer (got ${n})`
252
+ );
253
+ e.setUint32(t + G.length, 0, !0), e.setUint32(t + G.capacity, n, !0);
254
+ }
255
+ function Ln(e, t, n) {
256
+ return {
257
+ generations: new Int32Array(e, ft(t), n),
258
+ archetypes: new Int32Array(e, Et(t, n), n),
259
+ rows: new Int32Array(e, mt(t, n), n)
260
+ };
261
+ }
262
+ const ht = 16, It = 16, Cn = 256, U = {
263
+ write_head: 0,
264
+ read_head: 4,
265
+ capacity_slots: 8,
266
+ overflow_flag: 12
267
+ };
268
+ function Ae(e) {
269
+ return ht + e * It;
270
+ }
271
+ function pt(e) {
272
+ return e > 0 && (e & e - 1) === 0;
273
+ }
274
+ class Tt extends Error {
275
+ constructor(t) {
276
+ super(t), this.name = "EventRingError";
277
+ }
278
+ }
279
+ function gt(e, t, n) {
280
+ if (!pt(n))
281
+ throw new Tt(
282
+ `event ring capacity_slots must be a positive power of two (got ${n})`
283
+ );
284
+ e.setUint32(t + U.write_head, 0, !0), e.setUint32(t + U.read_head, 0, !0), e.setUint32(t + U.capacity_slots, n, !0), e.setUint32(t + U.overflow_flag, 0, !0);
285
+ }
286
+ const Nt = 16, yt = 16, Pn = 256, B = {
287
+ write_head: 0,
288
+ read_head: 4,
289
+ capacity_slots: 8,
290
+ overflow_flag: 12
291
+ }, St = B.write_head / 4, Ot = B.read_head / 4, Dt = B.capacity_slots / 4, wt = B.overflow_flag / 4;
292
+ function Rt(e, t) {
293
+ return new Int32Array(e.buffer, e.byteOffset + t, 4);
294
+ }
295
+ function he(e) {
296
+ return Nt + e * yt;
297
+ }
298
+ function bt(e) {
299
+ return e > 0 && (e & e - 1) === 0;
300
+ }
301
+ class Ie extends Error {
302
+ constructor(t) {
303
+ super(t), this.name = "ActionRingError";
304
+ }
305
+ }
306
+ function Lt(e, t, n) {
307
+ if (!bt(n))
308
+ throw new Ie(
309
+ `action ring capacity_slots must be a positive power of two (got ${n})`
310
+ );
311
+ if ((e.byteOffset + t) % 4 !== 0)
312
+ throw new Ie(
313
+ `action ring header must be 4-byte aligned for Atomics (view.byteOffset ${e.byteOffset} + ringOff ${t} is not a multiple of 4)`
314
+ );
315
+ const s = Rt(e, t);
316
+ Atomics.store(s, St, 0), Atomics.store(s, Ot, 0), Atomics.store(s, Dt, n), Atomics.store(s, wt, 0);
317
+ }
318
+ const k = [
319
+ {
320
+ name: "command_ring",
321
+ headerOff: "command_ring_off",
322
+ sizeFromOptions: (e) => e.commandRingCapacitySlots !== void 0 ? fe(e.commandRingCapacitySlots) : 0,
323
+ init: (e, t, n) => at(e, t, n.commandRingCapacitySlots),
324
+ regionBytes: (e, t) => fe(e.getUint32(t + D.capacity_slots, !0)),
325
+ readOptions: (e, t, n) => {
326
+ n.commandRingCapacitySlots = e.getUint32(
327
+ t + D.capacity_slots,
328
+ !0
329
+ );
330
+ }
331
+ },
332
+ {
333
+ name: "entity_index",
334
+ headerOff: "entity_index_off",
335
+ sizeFromOptions: (e) => e.entityIndexCapacity !== void 0 ? me(e.entityIndexCapacity) : 0,
336
+ init: (e, t, n) => At(e, t, n.entityIndexCapacity),
337
+ regionBytes: (e, t) => me(e.getUint32(t + G.capacity, !0)),
338
+ readOptions: (e, t, n) => {
339
+ n.entityIndexCapacity = e.getUint32(t + G.capacity, !0);
340
+ }
341
+ },
342
+ {
343
+ name: "event_ring",
344
+ headerOff: "event_ring_off",
345
+ sizeFromOptions: (e) => e.eventRingCapacitySlots !== void 0 ? Ae(e.eventRingCapacitySlots) : 0,
346
+ init: (e, t, n) => gt(e, t, n.eventRingCapacitySlots),
347
+ regionBytes: (e, t) => Ae(e.getUint32(t + U.capacity_slots, !0)),
348
+ readOptions: (e, t, n) => {
349
+ n.eventRingCapacitySlots = e.getUint32(
350
+ t + U.capacity_slots,
351
+ !0
352
+ );
353
+ }
354
+ },
355
+ {
356
+ name: "action_ring",
357
+ headerOff: "action_ring_off",
358
+ sizeFromOptions: (e) => e.actionRingCapacitySlots !== void 0 ? he(e.actionRingCapacitySlots) : 0,
359
+ init: (e, t, n) => Lt(e, t, n.actionRingCapacitySlots),
360
+ regionBytes: (e, t) => he(e.getUint32(t + B.capacity_slots, !0)),
361
+ readOptions: (e, t, n) => {
362
+ n.actionRingCapacitySlots = e.getUint32(
363
+ t + B.capacity_slots,
364
+ !0
365
+ );
366
+ }
367
+ }
368
+ ];
369
+ class H extends Error {
370
+ constructor(t) {
371
+ super(t), this.name = "RegionRegistryError";
372
+ }
373
+ }
374
+ function xe(e) {
375
+ return e * V;
376
+ }
377
+ function ae(e, t) {
378
+ const n = e.getUint32(g.region_table_count, !0);
379
+ if (t + xe(n) > e.byteLength)
380
+ throw new H(
381
+ `region table of ${n} entries at byte ${t} overruns the buffer (${e.byteLength} bytes)`
382
+ );
383
+ return n;
384
+ }
385
+ function Ct(e) {
386
+ const t = /* @__PURE__ */ new Set();
387
+ for (let n = 0; n < e.length; n++) {
388
+ const s = e[n];
389
+ if (!Number.isInteger(s.id) || s.id <= 0)
390
+ throw new H(
391
+ `region "${s.name}" has invalid id ${s.id}, region ids must be positive integers (0 is the absent sentinel)`
392
+ );
393
+ if (t.has(s.id))
394
+ throw new H(
395
+ `duplicate region id ${s.id} (region "${s.name}"), ids must be distinct within a consumer's region set`
396
+ );
397
+ if (t.add(s.id), !Number.isInteger(s.bytes) || s.bytes <= 0)
398
+ throw new H(
399
+ `region "${s.name}" (id ${s.id}) has invalid byte size ${s.bytes}, must be a positive integer`
400
+ );
401
+ }
402
+ }
403
+ function Pt(e, t, n) {
404
+ e.setUint32(t + C.region_id, n.regionId, !0), e.setUint32(t + C.byte_offset, n.byteOffset, !0), e.setUint32(t + C.byte_length, n.byteLength, !0);
405
+ }
406
+ function Fe(e, t) {
407
+ return {
408
+ regionId: e.getUint32(t + C.region_id, !0),
409
+ byteOffset: e.getUint32(t + C.byte_offset, !0),
410
+ byteLength: e.getUint32(t + C.byte_length, !0)
411
+ };
412
+ }
413
+ function vt(e, t, n) {
414
+ for (let s = 0; s < n.length; s++)
415
+ Pt(e, t + s * V, n[s]);
416
+ }
417
+ function Mt(e, t, n) {
418
+ const s = new Array(n);
419
+ for (let o = 0; o < n; o++)
420
+ s[o] = Fe(e, t + o * V);
421
+ return s;
422
+ }
423
+ function vn(e) {
424
+ const t = e.getUint32(g.region_table_off, !0);
425
+ if (t === 0) return [];
426
+ const n = ae(e, t);
427
+ return Mt(e, t, n);
428
+ }
429
+ function Mn(e, t) {
430
+ const n = e.getUint32(g.region_table_off, !0);
431
+ if (n === 0) return 0;
432
+ const s = ae(e, n);
433
+ for (let o = 0; o < s; o++) {
434
+ const r = n + o * V;
435
+ if (e.getUint32(r + C.region_id, !0) === t)
436
+ return e.getUint32(r + C.byte_offset, !0);
437
+ }
438
+ return 0;
439
+ }
440
+ function Un(e, t) {
441
+ const n = e.getUint32(g.region_table_off, !0);
442
+ if (n === 0) return null;
443
+ const s = ae(e, n);
444
+ for (let o = 0; o < s; o++) {
445
+ const r = Fe(e, n + o * V);
446
+ if (r.regionId === t) return r;
447
+ }
448
+ return null;
449
+ }
450
+ function Ut(e, t) {
451
+ return e << 16 | t;
452
+ }
453
+ const ce = 2 ** 31;
454
+ class Ve extends Error {
455
+ constructor(t) {
456
+ super(
457
+ `SAB column layout offset ${t} reaches or exceeds the 2³¹ (${ce}-byte) ceiling. Past 2 GiB the signed-32-bit bitwise alignment math wraps to a negative or misaligned offset. This is a structural limit independent of the allocator cap, so a single store cannot back more than 2 GiB of column data.`
458
+ ), this.name = "StoreLayoutOverflowError";
459
+ }
460
+ }
461
+ function ke(e, t) {
462
+ if (e + t > ce)
463
+ throw new Ve(e);
464
+ return e + (t - 1) & ~(t - 1);
465
+ }
466
+ function $t(e, t, n, s, o) {
467
+ const r = t + s;
468
+ switch (n) {
469
+ case A.u8:
470
+ return new Uint8Array(e, r, o);
471
+ case A.i8:
472
+ return new Int8Array(e, r, o);
473
+ case A.u16:
474
+ return new Uint16Array(e, r, o);
475
+ case A.i16:
476
+ return new Int16Array(e, r, o);
477
+ case A.u32:
478
+ return new Uint32Array(e, r, o);
479
+ case A.i32:
480
+ return new Int32Array(e, r, o);
481
+ case A.f32:
482
+ return new Float32Array(e, r, o);
483
+ case A.f64:
484
+ return new Float64Array(e, r, o);
485
+ }
486
+ }
487
+ function Bt(e, t, n = 0) {
488
+ const o = ot(
489
+ e.map((d) => ({
490
+ archetypeId: d.archetypeId,
491
+ componentMask: d.componentMask,
492
+ rowCount: 0,
493
+ enabledCount: 0,
494
+ rowCapacity: d.rowCapacity,
495
+ columns: d.columns.map((c) => ({
496
+ componentId: c.componentId,
497
+ fieldId: c.fieldId,
498
+ typeTag: c.typeTag,
499
+ byteOff: 0,
500
+ stride: ue[c.typeTag]
501
+ }))
502
+ }))
503
+ ) + n;
504
+ let r = t + o;
505
+ const l = new Array(e.length);
506
+ for (let d = 0; d < e.length; d++) {
507
+ const c = e[d], _ = new Array(c.columns.length);
508
+ for (let m = 0; m < c.columns.length; m++) {
509
+ const h = c.columns[m], p = ue[h.typeTag];
510
+ r = ke(r, p), _[m] = {
511
+ componentId: h.componentId,
512
+ fieldId: h.fieldId,
513
+ typeTag: h.typeTag,
514
+ byteOff: r,
515
+ stride: p
516
+ }, r += p * c.rowCapacity;
517
+ }
518
+ l[d] = {
519
+ archetypeId: c.archetypeId,
520
+ componentMask: c.componentMask,
521
+ rowCount: 0,
522
+ enabledCount: 0,
523
+ rowCapacity: c.rowCapacity,
524
+ columns: _
525
+ };
526
+ }
527
+ if (r > ce)
528
+ throw new Ve(r);
529
+ return { descriptors: l, totalBytes: r, regionBytes: o };
530
+ }
531
+ const W = 16;
532
+ function Yt(e) {
533
+ if (!Number.isInteger(e) || e < 0)
534
+ throw new RangeError(`createColumnStore: storeBase must be an integer >= 0, got ${e}`);
535
+ if (e % W !== 0)
536
+ throw new RangeError(
537
+ `createColumnStore: storeBase must be a multiple of ${W}, got ${e}`
538
+ );
539
+ }
540
+ function xt(e) {
541
+ let t = 0;
542
+ for (const [, n] of e) t += $e(n.columnsInOrder.length);
543
+ return t;
544
+ }
545
+ function $n(e) {
546
+ const t = e;
547
+ return typeof t._regionBytes == "number" && typeof t._allocator == "function" && typeof t._reservedDescriptorBytes == "number";
548
+ }
549
+ function Bn(e, t = Ge, n = {}) {
550
+ const s = n.storeBase ?? 0;
551
+ Yt(s);
552
+ const o = {};
553
+ let r = et;
554
+ for (let T = 0; T < k.length; T++) {
555
+ const w = k[T], Y = w.sizeFromOptions(n);
556
+ o[w.headerOff] = Y === 0 ? 0 : r, r += Y;
557
+ }
558
+ const l = n.regions ?? [];
559
+ Ct(l);
560
+ const d = l.length, c = d > 0 ? r : 0;
561
+ r += xe(d);
562
+ const _ = new Array(d);
563
+ for (let T = 0; T < l.length; T++) {
564
+ const w = l[T];
565
+ _[T] = { regionId: w.id, byteOffset: r, byteLength: w.bytes }, r += w.bytes;
566
+ }
567
+ const m = n.bindingsRegionBytes ?? 0, h = m === 0 ? 0 : r;
568
+ r += m;
569
+ const p = r, { descriptors: S, totalBytes: N, regionBytes: a } = Bt(
570
+ e,
571
+ p,
572
+ n.reservedDescriptorBytes ?? 0
573
+ ), i = t(s + N), u = new DataView(i, s), O = {
574
+ magic: Je,
575
+ simAbiVersion: Ze,
576
+ viewStamp: 0,
577
+ capacity: N,
578
+ archetypeCount: e.length,
579
+ layoutDescriptorOff: p,
580
+ bindingsOff: h,
581
+ regionTableOff: c,
582
+ regionTableCount: d,
583
+ // `regionOffsets` stays keyed by the snake ABI field names (it also indexes
584
+ // `STORE_HEADER_OFFSETS`). Map its 4 entries onto the camelCase header fields.
585
+ commandRingOff: o.command_ring_off,
586
+ entityIndexOff: o.entity_index_off,
587
+ eventRingOff: o.event_ring_off,
588
+ actionRingOff: o.action_ring_off
589
+ };
590
+ rt(u, O), m > 0 && new Uint8Array(i, s + h, m).fill(0);
591
+ for (let T = 0; T < k.length; T++) {
592
+ const w = k[T], Y = o[w.headerOff];
593
+ Y !== 0 && w.init(u, Y, n);
594
+ }
595
+ c !== 0 && vt(u, c, _);
596
+ for (let T = 0; T < l.length; T++)
597
+ l[T].init(u, _[T].byteOffset);
598
+ st(u, p, S);
599
+ const y = Ft(i, s, S);
600
+ return {
601
+ buffer: i,
602
+ view: u,
603
+ header: O,
604
+ storeBase: s,
605
+ archetypes: y,
606
+ _regionBytes: a,
607
+ _allocator: t,
608
+ // Carry the headroom policy with the store so the realloc slow path
609
+ // (`optionsFromOld`) can re-reserve the same margin.
610
+ _reservedDescriptorBytes: n.reservedDescriptorBytes ?? 0,
611
+ _usedDescriptorBytes: xt(y)
612
+ };
613
+ }
614
+ function Ft(e, t, n) {
615
+ const s = /* @__PURE__ */ new Map();
616
+ for (let o = 0; o < n.length; o++) {
617
+ const r = n[o], l = new Array(r.columns.length), d = /* @__PURE__ */ new Map();
618
+ for (let c = 0; c < r.columns.length; c++) {
619
+ const _ = r.columns[c], m = {
620
+ componentId: _.componentId,
621
+ fieldId: _.fieldId,
622
+ typeTag: _.typeTag,
623
+ byteOff: _.byteOff,
624
+ stride: _.stride,
625
+ view: $t(e, t, _.typeTag, _.byteOff, r.rowCapacity)
626
+ };
627
+ l[c] = m, d.set(Ut(_.componentId, _.fieldId), m);
628
+ }
629
+ s.set(r.archetypeId, {
630
+ archetypeId: r.archetypeId,
631
+ componentMask: r.componentMask,
632
+ rowCapacity: r.rowCapacity,
633
+ columns: d,
634
+ columnsInOrder: l
635
+ });
636
+ }
637
+ return s;
638
+ }
639
+ const pe = 2147483647, Te = /* @__PURE__ */ new WeakMap();
640
+ function Vt(e) {
641
+ const t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Set(), _ = /* @__PURE__ */ new Set(), m = /* @__PURE__ */ new Set();
642
+ for (let a = 0; a < e.writes.length; a++) {
643
+ const i = e.writes[a].id;
644
+ n.add(i), t.add(i), s.add(i);
645
+ }
646
+ for (let a = 0; a < e.reads.length; a++)
647
+ t.add(e.reads[a].id);
648
+ for (let a = 0; a < e.spawns.length; a++) {
649
+ const i = e.spawns[a];
650
+ for (let u = 0; u < i.length; u++)
651
+ s.add(i[u].id);
652
+ }
653
+ for (let a = 0; a < e.transitions.length; a++) {
654
+ const i = e.transitions[a];
655
+ if (i.add)
656
+ for (let u = 0; u < i.add.length; u++)
657
+ s.add(i.add[u].id);
658
+ if (i.remove)
659
+ for (let u = 0; u < i.remove.length; u++)
660
+ o.add(i.remove[u].id);
661
+ }
662
+ for (let a = 0; a < e.despawns.length; a++)
663
+ o.add(e.despawns[a].id);
664
+ for (let a = 0; a < e.resourceReads.length; a++)
665
+ r.add(e.resourceReads[a]);
666
+ for (let a = 0; a < e.resourceWrites.length; a++) {
667
+ const i = e.resourceWrites[a];
668
+ l.add(i), r.add(i);
669
+ }
670
+ const h = e.sparseWrites;
671
+ if (h !== void 0)
672
+ for (let a = 0; a < h.length; a++) {
673
+ const i = h[a];
674
+ c.add(i), d.add(i);
675
+ }
676
+ const p = e.sparseReads;
677
+ if (p !== void 0)
678
+ for (let a = 0; a < p.length; a++) d.add(p[a]);
679
+ const S = e.relationWrites;
680
+ if (S !== void 0)
681
+ for (let a = 0; a < S.length; a++) {
682
+ const i = S[a];
683
+ m.add(i), _.add(i);
684
+ }
685
+ const N = e.relationReads;
686
+ if (N !== void 0)
687
+ for (let a = 0; a < N.length; a++) _.add(N[a]);
688
+ return {
689
+ reads: t,
690
+ writes: n,
691
+ addAllowed: s,
692
+ removeAllowed: o,
693
+ hasDespawns: e.despawns.length > 0,
694
+ resourceReads: r,
695
+ resourceWrites: l,
696
+ sparseReads: d,
697
+ sparseWrites: c,
698
+ relationReads: _,
699
+ relationWrites: m
700
+ };
701
+ }
702
+ function kt(e) {
703
+ const t = Te.get(e);
704
+ if (t !== void 0) return t;
705
+ const n = Vt(e);
706
+ return Te.set(e, n), n;
707
+ }
708
+ const ge = /* @__PURE__ */ new WeakMap();
709
+ function Ht(e) {
710
+ const t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set();
711
+ if (e.reads !== void 0)
712
+ for (let s = 0; s < e.reads.length; s++) t.add(e.reads[s].id);
713
+ if (e.resourceReads !== void 0)
714
+ for (let s = 0; s < e.resourceReads.length; s++)
715
+ n.add(e.resourceReads[s]);
716
+ return {
717
+ reads: t,
718
+ writes: /* @__PURE__ */ new Set(),
719
+ addAllowed: /* @__PURE__ */ new Set(),
720
+ removeAllowed: /* @__PURE__ */ new Set(),
721
+ hasDespawns: !1,
722
+ resourceReads: n,
723
+ resourceWrites: /* @__PURE__ */ new Set(),
724
+ sparseReads: /* @__PURE__ */ new Set(),
725
+ sparseWrites: /* @__PURE__ */ new Set(),
726
+ relationReads: /* @__PURE__ */ new Set(),
727
+ relationWrites: /* @__PURE__ */ new Set()
728
+ };
729
+ }
730
+ function Gt(e) {
731
+ const t = ge.get(e);
732
+ if (t !== void 0) return t;
733
+ const n = Ht(e);
734
+ return ge.set(e, n), n;
735
+ }
736
+ class Wt {
737
+ _activeSystem = null;
738
+ _activeSets = null;
739
+ // The label used in violation messages. Tracks `_activeSystem` for a system span,
740
+ // but a run-condition span has no descriptor, only this name, so the
741
+ // failure helpers read the label here rather than off `_activeSystem`.
742
+ _activeName = null;
743
+ // An `_exclusive` system has full world access: every check_* below
744
+ // passes for the whole span. Kept as an explicit flag (rather than leaving
745
+ // `_activeSets` null) so `isActive()` stays truthful inside the span.
746
+ _exclusive = !1;
747
+ enter(t) {
748
+ this._activeSystem = t, this._activeName = t.name ?? `system_${t.id}`, this._exclusive = t.exclusive === !0, this._activeSets = this._exclusive ? null : kt(t);
749
+ }
750
+ /** Open a reads-only span for a run condition. No descriptor, a
751
+ * condition can gate a whole SystemSet, so it isn't attributable to one
752
+ * system, only its declared `reads` and `resourceReads` and a name for diagnostics.
753
+ * Paired with `leave()`. */
754
+ enterCondition(t) {
755
+ this._activeSystem = null, this._activeName = t.name, this._activeSets = Gt(t);
756
+ }
757
+ leave() {
758
+ this._activeSystem = null, this._activeName = null, this._activeSets = null, this._exclusive = !1;
759
+ }
760
+ isActive() {
761
+ return this._activeSets !== null || this._exclusive;
762
+ }
763
+ /** Current system descriptor, if any. Null during a run-condition span. */
764
+ current() {
765
+ return this._activeSystem;
766
+ }
767
+ assertRead(t) {
768
+ this._activeSets !== null && (this._activeSets.reads.has(t.id) || this._failComponent("read", t, "reads"));
769
+ }
770
+ assertWrite(t) {
771
+ this._activeSets !== null && (this._activeSets.writes.has(t.id) || this._failComponent("write", t, "writes"));
772
+ }
773
+ assertAdd(t) {
774
+ this._activeSets !== null && (this._activeSets.addAllowed.has(t.id) || this._failComponent("addComponent", t, "spawns, transitions.add or writes"));
775
+ }
776
+ assertRemove(t) {
777
+ this._activeSets !== null && (this._activeSets.removeAllowed.has(t.id) || this._failComponent("removeComponent", t, "despawns or transitions.remove"));
778
+ }
779
+ assertDespawn() {
780
+ if (this._activeSets === null || this._activeSets.hasDespawns) return;
781
+ const t = this._activeName;
782
+ throw new f(
783
+ E.ACCESS_UNDECLARED,
784
+ `system '${t}' called despawn but did not declare any despawns. Name the components it removes in 'despawns'`,
785
+ { system: t, op: "despawn" }
786
+ );
787
+ }
788
+ assertResourceRead(t) {
789
+ if (this._activeSets === null) return;
790
+ const n = t;
791
+ this._activeSets.resourceReads.has(n) || this._failResource("read", t, "resourceReads");
792
+ }
793
+ assertResourceWrite(t) {
794
+ if (this._activeSets === null) return;
795
+ const n = t;
796
+ this._activeSets.resourceWrites.has(n) || this._failResource("write", t, "resourceWrites");
797
+ }
798
+ // --- Sparse component and relation checks ---
799
+ // Keyed against the dedicated sparse and relation sets, not the dense
800
+ // `reads` and `writes` sets, the id spaces are disjoint by construction (see
801
+ // file header). `def as unknown as number` recovers the SparseComponentID or
802
+ // the RelationID the branded handle erases to at runtime.
803
+ assertSparseRead(t) {
804
+ if (this._activeSets === null) return;
805
+ const n = t;
806
+ this._activeSets.sparseReads.has(n) || this._failSparse("read", n, "sparseReads");
807
+ }
808
+ assertSparseWrite(t) {
809
+ if (this._activeSets === null) return;
810
+ const n = t;
811
+ this._activeSets.sparseWrites.has(n) || this._failSparse("write", n, "sparseWrites");
812
+ }
813
+ assertRelationRead(t) {
814
+ if (this._activeSets === null) return;
815
+ const n = t;
816
+ this._activeSets.relationReads.has(n) || this._failRelation("read", n, "relationReads");
817
+ }
818
+ assertRelationWrite(t) {
819
+ if (this._activeSets === null) return;
820
+ const n = t;
821
+ this._activeSets.relationWrites.has(n) || this._failRelation("write", n, "relationWrites");
822
+ }
823
+ /** A `(*, T)` wildcard (`Query.forEachRelatedTo`) reads every
824
+ * relation's reverse index, so it can't name a specific relation. It is
825
+ * authorised by the `ANY_RELATION` sentinel in `relationReads`. Honoured here
826
+ * exactly like a per-relation read, only keyed on the reserved sentinel id
827
+ * (which computeSets folds into `relationReads` like any other entry). */
828
+ assertRelationReadAny() {
829
+ this._activeSets !== null && (this._activeSets.relationReads.has(pe) || this._failRelation(
830
+ "(*, T) wildcard read",
831
+ pe,
832
+ "relationReads (as ANY_RELATION)"
833
+ ));
834
+ }
835
+ // --- Optional query-term scope ---
836
+ // The dense iterators of `Query` and `ChangedQuery` push the iterating
837
+ // query's `terms.optionalTerms` list for the span of the callback.
838
+ // `Archetype.getOptionalColumnRead` then verifies the fetched component was
839
+ // declared via `.optional(T)`, the term that authorizes the optional fetch.
840
+ // This is what makes the optional term *consumed* rather than decorative: like
841
+ // `reads:[T]` for required access, `.optional(T)` is the fetch's declaration,
842
+ // checked here in `DEV`. A stack (not a single slot) handles a re-entrant or
843
+ // nested `forEach`. The optional scope is independent of the per-system
844
+ // `enter` and `leave` above, a host-side `ecs.query(...).forEach` outside any
845
+ // system still establishes one. No active scope ⇒ lenient: a manual
846
+ // `query.archetypes` walk can't be attributed to an optional declaration, so it
847
+ // isn't checked, mirroring the unchecked outside-of-system calls in the header.
848
+ //
849
+ // Caveat: the gate always attributes to the innermost active
850
+ // `forEach`. If you nest `forEach` and call `getOptionalColumnRead` on an
851
+ // outer query's archetype inside the inner loop, it is checked against the inner
852
+ // query's terms (a false throw or false pass). Per-query attribution isn't worth
853
+ // the complexity for a dev-only assertion. Iterate one query at a time, or read
854
+ // the outer span before entering the inner loop.
855
+ _optionalScopes = [];
856
+ enterOptionalScope(t) {
857
+ this._optionalScopes.push(t);
858
+ }
859
+ leaveOptionalScope() {
860
+ this._optionalScopes.pop();
861
+ }
862
+ assertOptionalFetch(t) {
863
+ const n = this._optionalScopes.length;
864
+ if (n === 0) return;
865
+ const s = this._optionalScopes[n - 1], o = t.id;
866
+ for (let r = 0; r < s.length; r++)
867
+ if (s[r] === o) return;
868
+ throw new f(
869
+ E.OPTIONAL_TERM_NOT_DECLARED,
870
+ `getOptionalColumnRead fetched optional component ${o} but the iterating query did not declare it. Add .optional(component) to the query before the fetch`
871
+ );
872
+ }
873
+ _failComponent(t, n, s) {
874
+ const o = this._activeName, r = qe(n);
875
+ throw new f(
876
+ E.ACCESS_UNDECLARED,
877
+ `system '${o}' performed ${t} on ${r} but did not declare it. Add it to '${s}'`,
878
+ { system: o, op: t, component: n.id }
879
+ );
880
+ }
881
+ _failSparse(t, n, s) {
882
+ const o = this._activeName;
883
+ throw new f(
884
+ E.ACCESS_UNDECLARED,
885
+ `system '${o}' performed ${t} on sparse component ${n} but did not declare it. Add it to '${s}'`,
886
+ { system: o, op: t, sparse: n }
887
+ );
888
+ }
889
+ _failRelation(t, n, s) {
890
+ const o = this._activeName;
891
+ throw new f(
892
+ E.ACCESS_UNDECLARED,
893
+ `system '${o}' performed ${t} on relation ${n} but did not declare it. Add it to '${s}'`,
894
+ { system: o, op: t, relation: n }
895
+ );
896
+ }
897
+ _failResource(t, n, s) {
898
+ const o = this._activeName, r = n.description ?? "<unnamed>";
899
+ throw new f(
900
+ E.ACCESS_UNDECLARED,
901
+ `system '${o}' performed resource ${t} on '${r}' but did not declare it. Add the resource key to '${s}'`,
902
+ { system: o, op: t, resource: r }
903
+ );
904
+ }
905
+ }
906
+ const Yn = new Wt();
907
+ function xn(e, t) {
908
+ return new f(
909
+ E.PLUGIN_NOT_INSTALLED,
910
+ `${t} needs the ${e} plugin, which this world did not install. Pass it at construction: ECS.create({ plugins: [${e}()] }), imported from @oasys/oecs/${e}`,
911
+ { plugin: e }
912
+ );
913
+ }
914
+ function Fn(e) {
915
+ return new f(
916
+ E.PLUGIN_ALREADY_INSTALLED,
917
+ `${e} is already installed on this world. Pass each plugin once to ECS.create`,
918
+ { plugin: e }
919
+ );
920
+ }
921
+ const Ne = ["/oecs/src/", "/@oasys/oecs/"];
922
+ function Xt(e) {
923
+ for (let t = 0; t < Ne.length; t++)
924
+ if (e.includes(Ne[t])) return !0;
925
+ return !1;
926
+ }
927
+ class Kt {
928
+ _activeCache = null;
929
+ _repoRootCache = null;
930
+ _counts = /* @__PURE__ */ new Map();
931
+ _callsiteCache = /* @__PURE__ */ new Map();
932
+ isActive() {
933
+ if (this._activeCache !== null) return this._activeCache;
934
+ const n = globalThis.process?.env?.VISUAL_INTEL_TRACE;
935
+ return this._activeCache = n === "1" || n === "true";
936
+ }
937
+ _repoRoot() {
938
+ if (this._repoRootCache !== null) return this._repoRootCache;
939
+ const t = globalThis.process;
940
+ return this._repoRootCache = t?.cwd?.() ?? "";
941
+ }
942
+ _resolveCallsite() {
943
+ return jt(
944
+ new Error().stack ?? null,
945
+ this._repoRoot(),
946
+ this._callsiteCache
947
+ );
948
+ }
949
+ _record(t, n, s) {
950
+ const o = this._resolveCallsite();
951
+ if (!o) return;
952
+ const r = `${t} ${n} ${s} ${o}`;
953
+ this._counts.set(r, (this._counts.get(r) ?? 0) + 1);
954
+ }
955
+ recordEventEmit(t) {
956
+ this._record("ecs-events", "emit", t);
957
+ }
958
+ recordEventRead(t) {
959
+ this._record("ecs-events", "read", t);
960
+ }
961
+ recordResourceRead(t) {
962
+ this._record("resources", "read", t);
963
+ }
964
+ recordResourceWrite(t) {
965
+ this._record("resources", "write", t);
966
+ }
967
+ recordResourceRegister(t) {
968
+ this._record("resources", "register", t);
969
+ }
970
+ recordResourceRemove(t) {
971
+ this._record("resources", "remove", t);
972
+ }
973
+ recordSendAction(t) {
974
+ this._record("actions", "send_action", t);
975
+ }
976
+ recordHandleAction(t) {
977
+ this._record("actions", "handle_action", t);
978
+ }
979
+ snapshot() {
980
+ const t = {
981
+ "ecs-events": { emit: [], read: [] },
982
+ actions: { send_action: [], handle_action: [] },
983
+ resources: { read: [], write: [], register: [], remove: [] }
984
+ };
985
+ for (const [n, s] of this._counts.entries()) {
986
+ const [o, r, l, d] = n.split(" ");
987
+ if (!o || !r || d === void 0) continue;
988
+ const _ = { key: o === "actions" ? Number(l) : l, file: d, count: s }, h = t[o][r];
989
+ h && h.push(_);
990
+ }
991
+ for (const n of Object.values(t))
992
+ for (const s of Object.values(n))
993
+ s.sort((o, r) => {
994
+ if (o.file !== r.file) return o.file < r.file ? -1 : 1;
995
+ const l = String(o.key), d = String(r.key);
996
+ return l < d ? -1 : l > d ? 1 : 0;
997
+ });
998
+ return {
999
+ schemaVersion: 1,
1000
+ capturedAt: (/* @__PURE__ */ new Date()).toISOString(),
1001
+ channels: t
1002
+ };
1003
+ }
1004
+ reset() {
1005
+ this._counts.clear(), this._callsiteCache.clear(), this._activeCache = null, this._repoRootCache = null;
1006
+ }
1007
+ }
1008
+ function zt(e) {
1009
+ const t = /\(([^)]+):\d+:\d+\)\s*$/.exec(e);
1010
+ if (t) return t[1] ?? null;
1011
+ const n = /at\s+([^\s][^()]*?):\d+:\d+\s*$/.exec(e);
1012
+ return n && (n[1] ?? "").trim() || null;
1013
+ }
1014
+ function jt(e, t, n) {
1015
+ if (!e) return null;
1016
+ const s = e.split(`
1017
+ `);
1018
+ for (let o = 0; o < s.length; o++) {
1019
+ const r = s[o], l = n?.get(r);
1020
+ if (l !== void 0) {
1021
+ if (l === null) continue;
1022
+ return l;
1023
+ }
1024
+ const d = zt(r);
1025
+ if (!d) {
1026
+ n?.set(r, null);
1027
+ continue;
1028
+ }
1029
+ if (Xt(d)) {
1030
+ n?.set(r, null);
1031
+ continue;
1032
+ }
1033
+ const c = Qt(d, t);
1034
+ return n?.set(r, c), c;
1035
+ }
1036
+ return null;
1037
+ }
1038
+ function Qt(e, t) {
1039
+ let n = e;
1040
+ return n.startsWith("file://") && (n = n.slice(7)), t && n.startsWith(t + "/") && (n = n.slice(t.length + 1)), n.replace(/\\/g, "/");
1041
+ }
1042
+ const Vn = new Kt();
1043
+ var ee = /* @__PURE__ */ ((e) => (e.PRE_STARTUP = "PRE_STARTUP", e.STARTUP = "STARTUP", e.POST_STARTUP = "POST_STARTUP", e.FIXED_UPDATE = "FIXED_UPDATE", e.PRE_UPDATE = "PRE_UPDATE", e.UPDATE = "UPDATE", e.POST_UPDATE = "POST_UPDATE", e))(ee || {});
1044
+ function ye(e) {
1045
+ if (typeof e != "string") return e.loop;
1046
+ switch (e) {
1047
+ case "PRE_STARTUP":
1048
+ case "STARTUP":
1049
+ case "POST_STARTUP":
1050
+ return "startup";
1051
+ case "FIXED_UPDATE":
1052
+ return "fixed";
1053
+ case "PRE_UPDATE":
1054
+ case "UPDATE":
1055
+ case "POST_UPDATE":
1056
+ return "update";
1057
+ }
1058
+ }
1059
+ function Se(e) {
1060
+ return typeof e == "string" ? e : e.name;
1061
+ }
1062
+ const X = 1024, K = 1024 * X, $ = 64 * X, te = $;
1063
+ function kn(e, t = 0) {
1064
+ if (!Number.isFinite(t) || t < 0)
1065
+ throw new f(
1066
+ E.INVALID_MEMORY_OPTIONS,
1067
+ `storeBaseAbove: extraBytes must be a finite number >= 0, got ${String(t)}`
1068
+ );
1069
+ const n = e?.__heap_base, s = typeof n == "object" && n !== null && "value" in n ? n.value : n;
1070
+ if (typeof s != "number" || !Number.isFinite(s))
1071
+ throw new f(
1072
+ E.INVALID_MEMORY_OPTIONS,
1073
+ `storeBaseAbove: the module exports no numeric '__heap_base', got ${String(s)}. Link with --export=__heap_base, or pass memory.storeBase by hand.`
1074
+ );
1075
+ const o = Math.ceil((s + t) / $) * $;
1076
+ return Math.max(te, o);
1077
+ }
1078
+ const J = 256 * K, Oe = 3, qt = 64, Jt = 8, De = 4 * K, we = (e) => 2 ** Math.ceil(Math.log2(Math.max(1, e))), Zt = (e) => 2 ** Math.floor(Math.log2(Math.max(1, e))), Z = (e, t, n) => Math.min(n, Math.max(t, e)), I = (e) => e >= K ? `${(e / K).toFixed(1)} MiB` : e >= X ? `${(e / X).toFixed(0)} KiB` : `${e} B`;
1079
+ function en(e, t) {
1080
+ if (e === void 0) return t ? te : 0;
1081
+ if (!Number.isInteger(e) || e < 0)
1082
+ throw new f(
1083
+ E.INVALID_MEMORY_OPTIONS,
1084
+ `memory.storeBase must be an integer >= 0, got ${e}`
1085
+ );
1086
+ if (e % W !== 0)
1087
+ throw new f(
1088
+ E.INVALID_MEMORY_OPTIONS,
1089
+ `memory.storeBase must be a multiple of ${W}, got ${e}. The alignment keeps every column on its element boundary.`
1090
+ );
1091
+ if (t && e === 0)
1092
+ throw new f(
1093
+ E.INVALID_MEMORY_OPTIONS,
1094
+ `memory.storeBase is 0, and a header at address 0 is unreadable from a safe build of a WASM module. Pass a storeBase of at least one page (${te}), above the module's own data.`
1095
+ );
1096
+ return e;
1097
+ }
1098
+ function v(e, t) {
1099
+ if (!Number.isInteger(t) || t <= 0)
1100
+ throw new f(
1101
+ E.INVALID_MEMORY_OPTIONS,
1102
+ `memory.${e} must be a positive integer (got ${t})`
1103
+ );
1104
+ }
1105
+ const Re = {
1106
+ budget: "{ budget: { entities: N } } → { entities: N }",
1107
+ heap: '{ heap: { maxBytes: X } } → { maxBytes: X, backing: "heap" }',
1108
+ shared: '{ shared: { maxBytes: X } } → { maxBytes: X, backing: "shared" }',
1109
+ wasm: "{ wasm: W } → { backing: { wasm: W } }",
1110
+ allocator: "{ allocator: A } → { backing: { allocator: A } }",
1111
+ capBytesHint: "{ capBytesHint: X } → { maxBytes: X }"
1112
+ };
1113
+ function tn(e) {
1114
+ const t = Object.prototype.hasOwnProperty, n = Object.keys(Re).filter((s) => t.call(e, s));
1115
+ if (n.length !== 0)
1116
+ throw new f(
1117
+ E.INVALID_MEMORY_OPTIONS,
1118
+ `${n.map((s) => `memory.${s}`).join(" and ")} ${n.length > 1 ? "were" : "was"} removed in 0.6. Sizing and backing are now two independent fields, so every combination of them is expressible. Rewrite as: ` + n.map((s) => Re[s]).join(". ")
1119
+ );
1120
+ }
1121
+ function Hn(e) {
1122
+ e !== void 0 && tn(e);
1123
+ const t = e?.entities, n = e?.maxBytes, s = e?.columnCapacity, o = e?.backing ?? "heap", r = typeof o == "object" && o.wasm !== void 0, l = en(e?.storeBase, r);
1124
+ if (s !== void 0 && v("columnCapacity", s), n !== void 0 && v("maxBytes", n), t === void 0) {
1125
+ for (const i of ["archetypes", "bytesPerEntity"])
1126
+ if (e?.[i] !== void 0)
1127
+ throw new f(
1128
+ E.INVALID_MEMORY_OPTIONS,
1129
+ `memory.${i} shapes the sizing derived from memory.entities, which was not given. Add memory.entities, or drop memory.${i}.`
1130
+ );
1131
+ }
1132
+ let d, c, _ = null;
1133
+ const m = [];
1134
+ if (t !== void 0) {
1135
+ const i = e?.archetypes ?? Jt, u = e?.bytesPerEntity ?? qt;
1136
+ if (v("entities", t), v("archetypes", i), v("bytesPerEntity", u), t > 1 << 20)
1137
+ throw new f(
1138
+ E.INVALID_MEMORY_OPTIONS,
1139
+ `memory.entities=${t} exceeds the EntityID index space (1<<20 = ${1 << 20})`
1140
+ );
1141
+ d = s ?? Z(we(Math.ceil(t / i)), 64, 1 << 20), c = Z(we(t * 2), 4096, 1 << 20);
1142
+ const O = c * L, y = t * u * Oe;
1143
+ _ = ke(
1144
+ Math.max(O + y, De),
1145
+ $
1146
+ ), m.push(
1147
+ `columnCapacity = ${s !== void 0 ? `${d} (pinned)` : `pow2(${t}/${i} per archetype) = ${d}`}`,
1148
+ `entityIndex = pow2(2 × ${t}) = ${c} slots × ${L} B = ${I(O)}`,
1149
+ `columns = ${t} × ${u} B × ${Oe} (double+holes headroom) = ${I(y)}`
1150
+ );
1151
+ } else
1152
+ d = s ?? ze, c = Ee, m.push(
1153
+ `columnCapacity = ${d} (${s !== void 0 ? "pinned" : "default"})`
1154
+ );
1155
+ const h = (i) => Z(Zt(i / 4 / L), 4096, Ee), p = t !== void 0 ? n !== void 0 ? "entities+maxBytes" : "entities" : n !== void 0 ? "maxBytes" : "default", S = (i) => n !== void 0 ? `${I(i)} (caller-declared maxBytes; the ${I(_ ?? i)} the entity count implies is overridden)` : `align64K(max(index + columns, ${I(De)} floor)) = ${I(i)}`, N = (i, u, O, y, b) => (t === void 0 && (c = h(i)), {
1156
+ source: u,
1157
+ sizing: p,
1158
+ allocator: O,
1159
+ columnCapacity: d,
1160
+ entityIndexCapacity: c,
1161
+ capBytes: i,
1162
+ storeBase: l,
1163
+ intentLabel: y,
1164
+ budgetEntities: t ?? null,
1165
+ derivation: [
1166
+ ...b,
1167
+ ...l > 0 ? [`storeBase = ${I(l)}, the store writes nothing below it`] : [],
1168
+ ...m,
1169
+ t === void 0 ? `entityIndex = floor_pow2(cap/4 ÷ ${L} B) = ${c} slots` : `cap = ${S(i)}`
1170
+ ],
1171
+ wasmMemory: null
1172
+ });
1173
+ if (typeof o == "object" && o.wasm !== void 0) {
1174
+ const i = o.wasm;
1175
+ if (i.memory !== void 0) {
1176
+ if (!(i.memory.buffer instanceof SharedArrayBuffer))
1177
+ throw new f(
1178
+ E.INVALID_MEMORY_OPTIONS,
1179
+ "memory.backing.wasm.memory must be constructed with `shared: true`, the SAB substrate requires a SharedArrayBuffer-backed WebAssembly.Memory"
1180
+ );
1181
+ const b = n ?? J;
1182
+ return t === void 0 && (c = h(Math.max(b - l, 0))), {
1183
+ source: "wasm",
1184
+ sizing: p,
1185
+ allocator: de(i.memory),
1186
+ columnCapacity: d,
1187
+ entityIndexCapacity: c,
1188
+ capBytes: b,
1189
+ storeBase: l,
1190
+ intentLabel: `caller-supplied WebAssembly.Memory (declared cap ${I(b)})`,
1191
+ budgetEntities: t ?? null,
1192
+ derivation: [
1193
+ "backing = wasm_memory_allocator(memory), zero-copy with a WASM compute backend (is_in_place ✓)",
1194
+ n !== void 0 ? `cap = ${I(b)} (caller-declared maxBytes; the Memory's own maximum is not readable from JS)` : `cap = ${I(b)} (default; the Memory's own maximum is not readable from JS)`,
1195
+ `storeBase = ${I(l)}, the module owns every byte below it`,
1196
+ ...m,
1197
+ t === void 0 ? `entityIndex = floor_pow2((cap - storeBase)/4 ÷ ${L} B) = ${c} slots` : "entityIndex sized from the entity count above"
1198
+ ],
1199
+ wasmMemory: i.memory
1200
+ };
1201
+ }
1202
+ v("backing.wasm.maximumPages", i.maximumPages);
1203
+ const u = i.initialPages ?? Math.min(32, i.maximumPages);
1204
+ if (v("backing.wasm.initialPages", u), u > i.maximumPages)
1205
+ throw new f(
1206
+ E.INVALID_MEMORY_OPTIONS,
1207
+ `memory.backing.wasm.initialPages (${u}) exceeds maximumPages (${i.maximumPages})`
1208
+ );
1209
+ if (n !== void 0)
1210
+ throw new f(
1211
+ E.INVALID_MEMORY_OPTIONS,
1212
+ `memory.maxBytes (${I(n)}) cannot be given beside memory.backing.wasm.maximumPages (${i.maximumPages} pages = ${I(i.maximumPages * $)}), the Memory's page maximum IS the ceiling. Declare it once, in pages.`
1213
+ );
1214
+ const O = new WebAssembly.Memory({
1215
+ initial: u,
1216
+ maximum: i.maximumPages,
1217
+ shared: !0
1218
+ }), y = i.maximumPages * $;
1219
+ return t === void 0 && (c = h(Math.max(y - l, 0))), {
1220
+ source: "wasm",
1221
+ sizing: p,
1222
+ allocator: de(O),
1223
+ columnCapacity: d,
1224
+ entityIndexCapacity: c,
1225
+ capBytes: y,
1226
+ storeBase: l,
1227
+ intentLabel: `engine-constructed WebAssembly.Memory (max ${i.maximumPages} pages)`,
1228
+ budgetEntities: t ?? null,
1229
+ derivation: [
1230
+ `cap = ${i.maximumPages} pages × 64 KiB = ${I(y)} (Memory maximum)`,
1231
+ `initial = ${u} pages (${i.initialPages !== void 0 ? "declared" : "default"})`,
1232
+ `storeBase = ${I(l)}, the module owns every byte below it`,
1233
+ ...m,
1234
+ t === void 0 ? `entityIndex = floor_pow2((cap - storeBase)/4 ÷ ${L} B) = ${c} slots` : "entityIndex sized from the entity count above"
1235
+ ],
1236
+ wasmMemory: O
1237
+ };
1238
+ }
1239
+ if (typeof o == "object" && o.allocator !== void 0) {
1240
+ if (o.allocator.isInPlace !== !0)
1241
+ throw new f(
1242
+ E.INVALID_MEMORY_OPTIONS,
1243
+ "memory.backing.allocator must declare `isInPlace: true`. A live Store's flush loops hoist entity-index views across grows, so an allocator that is not in-place (DEFAULT_SAB_ALLOCATOR, for example) corrupts the entity→row mapping. Use growableSabAllocator, fixedSabAllocator or wasmMemoryAllocator. An allocator that is not in-place is for snapshot and test sizing only."
1244
+ );
1245
+ const i = n ?? null;
1246
+ return t === void 0 && i !== null && (c = h(i)), {
1247
+ source: "allocator",
1248
+ sizing: p,
1249
+ allocator: o.allocator,
1250
+ columnCapacity: d,
1251
+ entityIndexCapacity: c,
1252
+ capBytes: i,
1253
+ storeBase: l,
1254
+ intentLabel: i !== null ? `custom in-place allocator (declared cap ${I(i)})` : "custom in-place allocator",
1255
+ budgetEntities: t ?? null,
1256
+ derivation: [
1257
+ "backing = caller allocator (is_in_place ✓ checked at construction)",
1258
+ i !== null ? `cap = ${I(i)} (caller-declared; the allocator owns the real ceiling)` : "cap = allocator-owned (no maxBytes declared)",
1259
+ ...m,
1260
+ t !== void 0 ? "entityIndex sized from the entity count above" : i !== null ? `entityIndex = floor_pow2(cap/4 ÷ ${L} B) = ${c} slots` : `entityIndex = ${c} slots (default, no entity count and no declared cap)`
1261
+ ],
1262
+ wasmMemory: null
1263
+ };
1264
+ }
1265
+ if (o === "shared") {
1266
+ const i = n ?? _ ?? J;
1267
+ return N(
1268
+ i,
1269
+ "shared",
1270
+ We(i),
1271
+ `shared SharedArrayBuffer backing (${I(i)} growable cap, needs COOP and COEP)`,
1272
+ [
1273
+ `backing = growable_sab_allocator(${I(i)}), growable SharedArrayBuffer (is_in_place ✓), needs cross-origin isolation`,
1274
+ "enables worker offload + a WASM compute backend (transferable SharedArrayBuffer)"
1275
+ ]
1276
+ );
1277
+ }
1278
+ if (o !== "heap")
1279
+ throw new f(
1280
+ E.INVALID_MEMORY_OPTIONS,
1281
+ `memory.backing must be "heap", "shared", { wasm }, or { allocator } (got ${JSON.stringify(o)})`
1282
+ );
1283
+ const a = n ?? _ ?? J;
1284
+ return N(
1285
+ a,
1286
+ "heap",
1287
+ Xe(a),
1288
+ p === "default" ? `default sizing (${I(a)} reserved cap)` : t !== void 0 ? `budget of ${t} entities` : `explicit cap of ${I(a)}`,
1289
+ [
1290
+ `backing = heap_arraybuffer_allocator(${I(a)}), fixed ArrayBuffer reserved at the cap, no SAB and no COOP+COEP (is_in_place ✓)`,
1291
+ "trade-off: no worker offload and no WASM backend (both need a transferable SharedArrayBuffer)"
1292
+ ]
1293
+ );
1294
+ }
1295
+ function Gn(e, t) {
1296
+ return { def: e, values: t };
1297
+ }
1298
+ function ne(e, t) {
1299
+ switch (t.kind) {
1300
+ case "spawn": {
1301
+ const n = e.commands.spawn();
1302
+ for (const s of t.components)
1303
+ e.commands.add(n, s.def, s.values);
1304
+ return t.onSpawned?.(n), n;
1305
+ }
1306
+ case "despawn":
1307
+ e.commands.despawn(t.eid);
1308
+ return;
1309
+ case "add_component":
1310
+ e.commands.add(t.eid, t.def, t.values);
1311
+ return;
1312
+ case "remove_component":
1313
+ e.commands.remove(t.eid, t.def);
1314
+ return;
1315
+ case "set_field":
1316
+ if (!e.hasComponent(t.eid, t.def))
1317
+ throw new f(
1318
+ E.COMPONENT_NOT_REGISTERED,
1319
+ `host set_field on entity ${t.eid} targets a component it does not have. If you added that component via a host command this same frame, the add is deferred to the phase flush while set_field is immediate. Carry the value in add_component or in spawnEntry instead of a separate set_field, or set it next frame. (host write seam)`
1320
+ );
1321
+ e.setField(t.eid, t.def, t.field, t.value);
1322
+ return;
1323
+ case "disable":
1324
+ e.commands.disable(t.eid);
1325
+ return;
1326
+ case "enable":
1327
+ e.commands.enable(t.eid);
1328
+ return;
1329
+ default:
1330
+ return Ke(t, "HostCommand kind");
1331
+ }
1332
+ }
1333
+ class nn {
1334
+ _pending = [];
1335
+ spawn(t, n) {
1336
+ return this._pending.push({ kind: "spawn", components: t, onSpawned: n }), this;
1337
+ }
1338
+ despawn(t) {
1339
+ return this._pending.push({ kind: "despawn", eid: t }), this;
1340
+ }
1341
+ /** Attach `def` (with complete `values`) to `entityId` (deferred to the
1342
+ * drain). The namespaced-handle grammar, the queue is a commands buffer, so
1343
+ * it drops the noun (`add`, not `addComponent`), matching `ctx.commands.add`
1344
+ * and the queue's own bare `spawn`, `despawn`, `disable` and `enable`. Values are
1345
+ * complete (transport carries explicit intent per field, see `spawnEntry`),
1346
+ * unlike the authoring-side bundle sugar. */
1347
+ add(t, n, s) {
1348
+ return this._pending.push({ kind: "add_component", eid: t, def: n, values: s }), this;
1349
+ }
1350
+ /** Detach `def` from `entityId` (deferred to the drain). Bare `remove`
1351
+ * matching `ctx.commands.remove`, see `add`. */
1352
+ remove(t, n) {
1353
+ return this._pending.push({ kind: "remove_component", eid: t, def: n }), this;
1354
+ }
1355
+ /** Set `field` of `def` on `entityId`. Applied immediately at the drain, unlike
1356
+ * the deferred structural ops, so `def` must already be on `entityId`. Do not
1357
+ * `add` and `spawn` `def` and `setField` it in the same frame: the add is
1358
+ * still pending its flush when the immediate set runs (carry the value in
1359
+ * `add` or `spawnEntry` instead). `applyHostCommand` throws an
1360
+ * actionable error in `DEV` if you do. */
1361
+ setField(t, n, s, o) {
1362
+ return this._pending.push({
1363
+ kind: "set_field",
1364
+ eid: t,
1365
+ def: n,
1366
+ field: s,
1367
+ value: o
1368
+ }), this;
1369
+ }
1370
+ disable(t) {
1371
+ return this._pending.push({ kind: "disable", eid: t }), this;
1372
+ }
1373
+ enable(t) {
1374
+ return this._pending.push({ kind: "enable", eid: t }), this;
1375
+ }
1376
+ /** Enqueue a pre-built command. The path for a SAB-ring codec, an editor's
1377
+ * reified inverse, or a replay log, all of which produce `HostCommand` data
1378
+ * directly rather than calling the typed sugar above. */
1379
+ push(t) {
1380
+ return this._pending.push(t), this;
1381
+ }
1382
+ /** Commands buffered but not yet applied. */
1383
+ get pendingCount() {
1384
+ return this._pending.length;
1385
+ }
1386
+ /** Drop every buffered command without applying it, e.g. abandoning
1387
+ * queued edits on a scene unload. Returns how many were dropped. Does not
1388
+ * touch commands already drained into the world. */
1389
+ clear() {
1390
+ const t = this._pending.length;
1391
+ return this._pending.length = 0, t;
1392
+ }
1393
+ /**
1394
+ * Apply and clear every buffered command. Called by the blessed apply system
1395
+ * inside its schedule span. Not part of the host-facing surface. Returns the
1396
+ * count applied.
1397
+ *
1398
+ * `tap`, when present, is invoked with each command in apply order immediately before
1399
+ * it is applied, the record and replay hook ({@link HostCommandRecorder}). It is
1400
+ * an opt-in observer: the tap-free path keeps the original tight loop, so an
1401
+ * un-recorded drain pays nothing.
1402
+ */
1403
+ drain(t, n) {
1404
+ const s = this._pending.length;
1405
+ if (s === 0) return 0;
1406
+ if (n === void 0)
1407
+ for (let o = 0; o < s; o++) ne(t, this._pending[o]);
1408
+ else
1409
+ for (let o = 0; o < s; o++) {
1410
+ const r = this._pending[o];
1411
+ n(r), ne(t, r);
1412
+ }
1413
+ return this._pending.splice(0, s), s;
1414
+ }
1415
+ }
1416
+ const He = M - 1;
1417
+ function sn(e) {
1418
+ if (e === ie)
1419
+ throw new R(
1420
+ "cannot bind opCode 0 (reserved as the command-ring empty-slot marker)"
1421
+ );
1422
+ if (e < 0 || e > 255 || !Number.isInteger(e))
1423
+ throw new R(`command opCode must be a u8 in [1, 255] (got ${e})`);
1424
+ }
1425
+ function Q(e) {
1426
+ const t = new Uint8Array(He);
1427
+ return new DataView(t.buffer).setUint32(0, e, !0), t;
1428
+ }
1429
+ function q(e) {
1430
+ return new DataView(e.buffer, e.byteOffset, e.byteLength).getUint32(0, !0);
1431
+ }
1432
+ function Wn(e, t) {
1433
+ return {
1434
+ encode(n) {
1435
+ if (n.kind !== "set_field")
1436
+ throw new R(
1437
+ `ringSetFieldCodec encodes a "set_field" command (got "${n.kind}")`
1438
+ );
1439
+ const s = new Uint8Array(He), o = new DataView(s.buffer);
1440
+ return o.setUint32(0, n.eid, !0), o.setFloat64(4, n.value, !0), s;
1441
+ },
1442
+ decode(n) {
1443
+ const s = new DataView(n.buffer, n.byteOffset, n.byteLength);
1444
+ return {
1445
+ kind: "set_field",
1446
+ // boundary: branded-ID bridging, a decoded `u32` is an `EntityID` handle.
1447
+ eid: s.getUint32(0, !0),
1448
+ // schema-erased into the flat HostCommand union (the callable def is invariant in S).
1449
+ def: e,
1450
+ field: t,
1451
+ value: s.getFloat64(4, !0)
1452
+ };
1453
+ }
1454
+ };
1455
+ }
1456
+ function Xn() {
1457
+ return {
1458
+ encode(e) {
1459
+ if (e.kind !== "despawn")
1460
+ throw new R(
1461
+ `ringDespawnCodec encodes a "despawn" command (got "${e.kind}")`
1462
+ );
1463
+ return Q(e.eid);
1464
+ },
1465
+ decode: (e) => ({ kind: "despawn", eid: q(e) })
1466
+ };
1467
+ }
1468
+ function Kn() {
1469
+ return {
1470
+ encode(e) {
1471
+ if (e.kind !== "disable")
1472
+ throw new R(
1473
+ `ringDisableCodec encodes a "disable" command (got "${e.kind}")`
1474
+ );
1475
+ return Q(e.eid);
1476
+ },
1477
+ decode: (e) => ({ kind: "disable", eid: q(e) })
1478
+ };
1479
+ }
1480
+ function zn() {
1481
+ return {
1482
+ encode(e) {
1483
+ if (e.kind !== "enable")
1484
+ throw new R(
1485
+ `ringEnableCodec encodes an "enable" command (got "${e.kind}")`
1486
+ );
1487
+ return Q(e.eid);
1488
+ },
1489
+ decode: (e) => ({ kind: "enable", eid: q(e) })
1490
+ };
1491
+ }
1492
+ function jn(e) {
1493
+ return {
1494
+ encode(t) {
1495
+ if (t.kind !== "remove_component")
1496
+ throw new R(
1497
+ `ringRemoveComponentCodec encodes a "remove_component" command (got "${t.kind}")`
1498
+ );
1499
+ return Q(t.eid);
1500
+ },
1501
+ decode: (t) => ({ kind: "remove_component", eid: q(t), def: e })
1502
+ };
1503
+ }
1504
+ class Qn {
1505
+ _appliers = /* @__PURE__ */ new Map();
1506
+ /** Bind a raw ctx-aware applier to `opCode`. Re-binding replaces. */
1507
+ on(t, n) {
1508
+ return sn(t), this._appliers.set(t, n), this;
1509
+ }
1510
+ /** Unbind `opCode`. Returns whether a binding was removed. Subsequent
1511
+ * slots carrying it hit the unknown-opcode path. */
1512
+ off(t) {
1513
+ return this._appliers.delete(t);
1514
+ }
1515
+ /** Bind a `HostCommand` codec to `opCode`: each matching slot is decoded and
1516
+ * run through `applyHostCommand`, the same dispatch the typed queue uses.
1517
+ * A drain-time `tap` (record and replay) sees the decoded command before it
1518
+ * applies, so ring-sourced commands share one log with the typed transport. */
1519
+ onCommand(t, n) {
1520
+ return this.on(t, (s, o, r) => {
1521
+ const l = n.decode(o);
1522
+ r?.(l), ne(s, l);
1523
+ });
1524
+ }
1525
+ /** Drain every pending slot, dispatching each to its bound applier. Unbound
1526
+ * opcodes are skipped (the read head still advances, matching
1527
+ * `drainCommandRing` and `CommandDispatcher`). Returns slots drained. `tap`,
1528
+ * when present, is forwarded to each applier as the record and replay hook.
1529
+ * Only an `onCommand`-bound (generic `HostCommand`) opcode surfaces to it. */
1530
+ drain(t, n, s, o) {
1531
+ return ut(n, s, (r, l) => {
1532
+ const d = this._appliers.get(r);
1533
+ d !== void 0 && d(t, l, o);
1534
+ });
1535
+ }
1536
+ }
1537
+ const se = /* @__PURE__ */ new WeakMap();
1538
+ function qn(e, t) {
1539
+ const n = se.get(t);
1540
+ if (n === void 0) return !1;
1541
+ for (const s of n) e.removeSystem(s);
1542
+ return se.delete(t), t.clear(), !0;
1543
+ }
1544
+ function Jn(e, t) {
1545
+ const n = new nn(), s = [];
1546
+ se.set(n, s);
1547
+ const o = t?.name ?? "host_command_apply", r = t?.ring, l = t?.recorder, d = l?.record, c = t?.schedules ?? [
1548
+ ee.PRE_STARTUP,
1549
+ ee.PRE_UPDATE
1550
+ ];
1551
+ if (l !== void 0) {
1552
+ for (const _ of c)
1553
+ if (ye(_) === "fixed")
1554
+ throw new f(
1555
+ E.INVALID_RECORDER_SCHEDULE,
1556
+ `installHostCommandSeam: a recorder cannot drain at ${Se(_)}, a phase of the fixed loop. It would log the fixed timestep and not the host update dt, so a replay would diverge. Drain at a phase of the update loop instead.`
1557
+ );
1558
+ }
1559
+ for (const _ of c) {
1560
+ const m = ye(_) !== "startup", h = e.registerSystem({
1561
+ name: `${o}:${Se(_)}`,
1562
+ // `reads` and `writes` are required by `SystemConfig` but empty here: the
1563
+ // apply system declares nothing because it mutates components not known
1564
+ // at registration. Full world access: the host may queue mutations to
1565
+ // anything. The deferred-flush apply point is unchanged, so structural
1566
+ // safety holds. `exclusive` only waives the DEV access check.
1567
+ reads: [],
1568
+ writes: [],
1569
+ exclusive: !0,
1570
+ fn: (p, S) => {
1571
+ if (l !== void 0 && m && l.openTick(p.ecsTick, S), n.drain(p, d), r !== void 0) {
1572
+ const N = e.columnStore, a = N.header.commandRingOff;
1573
+ a !== 0 && r.drain(p, N.view, a, d);
1574
+ }
1575
+ }
1576
+ });
1577
+ e.addSystems(_, h), s.push(h);
1578
+ }
1579
+ return n;
1580
+ }
1581
+ export {
1582
+ Ft as $,
1583
+ le as A,
1584
+ Oe as B,
1585
+ Ut as C,
1586
+ J as D,
1587
+ f as E,
1588
+ An as F,
1589
+ g as G,
1590
+ Qn as H,
1591
+ Ce as I,
1592
+ Bn as J,
1593
+ ke as K,
1594
+ ce as L,
1595
+ Pe as M,
1596
+ un as N,
1597
+ Ve as O,
1598
+ k as P,
1599
+ vn as Q,
1600
+ Tn as R,
1601
+ Rn as S,
1602
+ A as T,
1603
+ _n as U,
1604
+ $n as V,
1605
+ te as W,
1606
+ Mn as X,
1607
+ P as Y,
1608
+ nt as Z,
1609
+ $e as _,
1610
+ E as a,
1611
+ xt as a0,
1612
+ ue as a1,
1613
+ ve as a2,
1614
+ G as a3,
1615
+ ln as a4,
1616
+ Ee as a5,
1617
+ Ln as a6,
1618
+ Un as a7,
1619
+ Ue as a8,
1620
+ Me as a9,
1621
+ fn as aa,
1622
+ Sn as ab,
1623
+ cn as ac,
1624
+ F as ad,
1625
+ Pn as ae,
1626
+ bn as af,
1627
+ Cn as ag,
1628
+ ee as ah,
1629
+ pn as ai,
1630
+ hn as aj,
1631
+ In as ak,
1632
+ En as al,
1633
+ mn as am,
1634
+ kn as an,
1635
+ Jn as ao,
1636
+ qn as ap,
1637
+ ne as aq,
1638
+ nn as ar,
1639
+ Gn as as,
1640
+ pe as at,
1641
+ dn as au,
1642
+ qt as b,
1643
+ Jt as c,
1644
+ Yn as d,
1645
+ Vn as e,
1646
+ Wn as f,
1647
+ Xn as g,
1648
+ Kn as h,
1649
+ zn as i,
1650
+ jn as j,
1651
+ He as k,
1652
+ yn as l,
1653
+ _e as m,
1654
+ z as n,
1655
+ gn as o,
1656
+ Nn as p,
1657
+ xn as q,
1658
+ Hn as r,
1659
+ Fn as s,
1660
+ On as t,
1661
+ Dn as u,
1662
+ qe as v,
1663
+ an as w,
1664
+ rn as x,
1665
+ wn as y,
1666
+ ze as z
1667
+ };