@forgeax/engine-ecs 0.1.2

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 (374) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +272 -0
  3. package/dist/.tsbuildinfo +1 -0
  4. package/dist/__fixtures__/field-shape-fixture.d.ts +16 -0
  5. package/dist/__fixtures__/field-shape-fixture.d.ts.map +1 -0
  6. package/dist/__tests__/__fixtures__/inspect-scripts.snapshot.d.ts +3 -0
  7. package/dist/__tests__/__fixtures__/inspect-scripts.snapshot.d.ts.map +1 -0
  8. package/dist/__tests__/archetype.unit.test.d.ts +2 -0
  9. package/dist/__tests__/archetype.unit.test.d.ts.map +1 -0
  10. package/dist/__tests__/array-handle-element.test-d.d.ts +2 -0
  11. package/dist/__tests__/array-handle-element.test-d.d.ts.map +1 -0
  12. package/dist/__tests__/buffer-array-vocab.test-d.d.ts +2 -0
  13. package/dist/__tests__/buffer-array-vocab.test-d.d.ts.map +1 -0
  14. package/dist/__tests__/buffer-field-input-widen.unit.test.d.ts +2 -0
  15. package/dist/__tests__/buffer-field-input-widen.unit.test.d.ts.map +1 -0
  16. package/dist/__tests__/buffer-pool.test-d.d.ts +2 -0
  17. package/dist/__tests__/buffer-pool.test-d.d.ts.map +1 -0
  18. package/dist/__tests__/change-detection.unit.test.d.ts +2 -0
  19. package/dist/__tests__/change-detection.unit.test.d.ts.map +1 -0
  20. package/dist/__tests__/command-buffer.test.d.ts +2 -0
  21. package/dist/__tests__/command-buffer.test.d.ts.map +1 -0
  22. package/dist/__tests__/commands-deferred.unit.test.d.ts +2 -0
  23. package/dist/__tests__/commands-deferred.unit.test.d.ts.map +1 -0
  24. package/dist/__tests__/component-catalog.test.d.ts +2 -0
  25. package/dist/__tests__/component-catalog.test.d.ts.map +1 -0
  26. package/dist/__tests__/component-definition-identity.unit.test.d.ts +2 -0
  27. package/dist/__tests__/component-definition-identity.unit.test.d.ts.map +1 -0
  28. package/dist/__tests__/component-schema.test-d.d.ts +2 -0
  29. package/dist/__tests__/component-schema.test-d.d.ts.map +1 -0
  30. package/dist/__tests__/component-schema.test.d.ts +2 -0
  31. package/dist/__tests__/component-schema.test.d.ts.map +1 -0
  32. package/dist/__tests__/define-component-options.test-d.d.ts +2 -0
  33. package/dist/__tests__/define-component-options.test-d.d.ts.map +1 -0
  34. package/dist/__tests__/deprecated-vocab-rejection.unit.test.d.ts +2 -0
  35. package/dist/__tests__/deprecated-vocab-rejection.unit.test.d.ts.map +1 -0
  36. package/dist/__tests__/despawn-all.unit.test.d.ts +2 -0
  37. package/dist/__tests__/despawn-all.unit.test.d.ts.map +1 -0
  38. package/dist/__tests__/ecs-core-reduction.characterization.test.d.ts +2 -0
  39. package/dist/__tests__/ecs-core-reduction.characterization.test.d.ts.map +1 -0
  40. package/dist/__tests__/ecs-core-reduction.perf.test.d.ts +2 -0
  41. package/dist/__tests__/ecs-core-reduction.perf.test.d.ts.map +1 -0
  42. package/dist/__tests__/ecs-error-code-31.test-d.d.ts +2 -0
  43. package/dist/__tests__/ecs-error-code-31.test-d.d.ts.map +1 -0
  44. package/dist/__tests__/entity-disabling.unit.test.d.ts +2 -0
  45. package/dist/__tests__/entity-disabling.unit.test.d.ts.map +1 -0
  46. package/dist/__tests__/entity-handle-codec-parity.unit.test.d.ts +2 -0
  47. package/dist/__tests__/entity-handle-codec-parity.unit.test.d.ts.map +1 -0
  48. package/dist/__tests__/errors.unit.test.d.ts +2 -0
  49. package/dist/__tests__/errors.unit.test.d.ts.map +1 -0
  50. package/dist/__tests__/execution-conflict-boundary.unit.test.d.ts +2 -0
  51. package/dist/__tests__/execution-conflict-boundary.unit.test.d.ts.map +1 -0
  52. package/dist/__tests__/execution-shared-storage.unit.test.d.ts +2 -0
  53. package/dist/__tests__/execution-shared-storage.unit.test.d.ts.map +1 -0
  54. package/dist/__tests__/externalization-portable-value.unit.test.d.ts +2 -0
  55. package/dist/__tests__/externalization-portable-value.unit.test.d.ts.map +1 -0
  56. package/dist/__tests__/externalization-projection.unit.test.d.ts +2 -0
  57. package/dist/__tests__/externalization-projection.unit.test.d.ts.map +1 -0
  58. package/dist/__tests__/externalization-root-surface.unit.test.d.ts +2 -0
  59. package/dist/__tests__/externalization-root-surface.unit.test.d.ts.map +1 -0
  60. package/dist/__tests__/field-enum-labels-reflection.test.d.ts +2 -0
  61. package/dist/__tests__/field-enum-labels-reflection.test.d.ts.map +1 -0
  62. package/dist/__tests__/field-shape-fixture.test.d.ts +2 -0
  63. package/dist/__tests__/field-shape-fixture.test.d.ts.map +1 -0
  64. package/dist/__tests__/field-transient-reflection.test.d.ts +2 -0
  65. package/dist/__tests__/field-transient-reflection.test.d.ts.map +1 -0
  66. package/dist/__tests__/field-value-type.test-d.d.ts +2 -0
  67. package/dist/__tests__/field-value-type.test-d.d.ts.map +1 -0
  68. package/dist/__tests__/fixed-update.unit.test.d.ts +2 -0
  69. package/dist/__tests__/fixed-update.unit.test.d.ts.map +1 -0
  70. package/dist/__tests__/handle.test-d.d.ts +2 -0
  71. package/dist/__tests__/handle.test-d.d.ts.map +1 -0
  72. package/dist/__tests__/hierarchy.unit.test.d.ts +2 -0
  73. package/dist/__tests__/hierarchy.unit.test.d.ts.map +1 -0
  74. package/dist/__tests__/managed-array-vocab.test-d.d.ts +2 -0
  75. package/dist/__tests__/managed-array-vocab.test-d.d.ts.map +1 -0
  76. package/dist/__tests__/minimal-example.test-d.d.ts +2 -0
  77. package/dist/__tests__/minimal-example.test-d.d.ts.map +1 -0
  78. package/dist/__tests__/name-read-types.test-d.d.ts +2 -0
  79. package/dist/__tests__/name-read-types.test-d.d.ts.map +1 -0
  80. package/dist/__tests__/plugin-service.test.d.ts +2 -0
  81. package/dist/__tests__/plugin-service.test.d.ts.map +1 -0
  82. package/dist/__tests__/query-combinations.unit.test.d.ts +2 -0
  83. package/dist/__tests__/query-combinations.unit.test.d.ts.map +1 -0
  84. package/dist/__tests__/query-light-extract-flat-column-ratio.perf.test.d.ts +2 -0
  85. package/dist/__tests__/query-light-extract-flat-column-ratio.perf.test.d.ts.map +1 -0
  86. package/dist/__tests__/query-storage-trends.perf.test.d.ts +2 -0
  87. package/dist/__tests__/query-storage-trends.perf.test.d.ts.map +1 -0
  88. package/dist/__tests__/query-trs-flat-column-ratio.perf.test.d.ts +2 -0
  89. package/dist/__tests__/query-trs-flat-column-ratio.perf.test.d.ts.map +1 -0
  90. package/dist/__tests__/query.unit.test.d.ts +2 -0
  91. package/dist/__tests__/query.unit.test.d.ts.map +1 -0
  92. package/dist/__tests__/relationship-index.perf.test.d.ts +2 -0
  93. package/dist/__tests__/relationship-index.perf.test.d.ts.map +1 -0
  94. package/dist/__tests__/relationship-index.test.d.ts +2 -0
  95. package/dist/__tests__/relationship-index.test.d.ts.map +1 -0
  96. package/dist/__tests__/scalar-field-type-owner.test-d.d.ts +2 -0
  97. package/dist/__tests__/scalar-field-type-owner.test-d.d.ts.map +1 -0
  98. package/dist/__tests__/schedule-determinism.unit.test.d.ts +2 -0
  99. package/dist/__tests__/schedule-determinism.unit.test.d.ts.map +1 -0
  100. package/dist/__tests__/schedule-inspection.unit.test.d.ts +2 -0
  101. package/dist/__tests__/schedule-inspection.unit.test.d.ts.map +1 -0
  102. package/dist/__tests__/schedule-scope-error.unit.test.d.ts +2 -0
  103. package/dist/__tests__/schedule-scope-error.unit.test.d.ts.map +1 -0
  104. package/dist/__tests__/schedule-token.unit.test.d.ts +2 -0
  105. package/dist/__tests__/schedule-token.unit.test.d.ts.map +1 -0
  106. package/dist/__tests__/schema-vocab.test-d.d.ts +2 -0
  107. package/dist/__tests__/schema-vocab.test-d.d.ts.map +1 -0
  108. package/dist/__tests__/serialization.unit.test.d.ts +2 -0
  109. package/dist/__tests__/serialization.unit.test.d.ts.map +1 -0
  110. package/dist/__tests__/shared-kernel-eligibility.test-d.d.ts +2 -0
  111. package/dist/__tests__/shared-kernel-eligibility.test-d.d.ts.map +1 -0
  112. package/dist/__tests__/shared-kernel-eligibility.unit.test.d.ts +2 -0
  113. package/dist/__tests__/shared-kernel-eligibility.unit.test.d.ts.map +1 -0
  114. package/dist/__tests__/shared-ref-store.unit.test.d.ts +2 -0
  115. package/dist/__tests__/shared-ref-store.unit.test.d.ts.map +1 -0
  116. package/dist/__tests__/sparse-tag.unit.test.d.ts +2 -0
  117. package/dist/__tests__/sparse-tag.unit.test.d.ts.map +1 -0
  118. package/dist/__tests__/spawn-field-error.test-d.d.ts +2 -0
  119. package/dist/__tests__/spawn-field-error.test-d.d.ts.map +1 -0
  120. package/dist/__tests__/stale-error.test-d.d.ts +2 -0
  121. package/dist/__tests__/stale-error.test-d.d.ts.map +1 -0
  122. package/dist/__tests__/string-view-symmetry.test-d.d.ts +2 -0
  123. package/dist/__tests__/string-view-symmetry.test-d.d.ts.map +1 -0
  124. package/dist/__tests__/string-vocab.test-d.d.ts +2 -0
  125. package/dist/__tests__/string-vocab.test-d.d.ts.map +1 -0
  126. package/dist/__tests__/structure-epoch-boundaries.unit.test.d.ts +2 -0
  127. package/dist/__tests__/structure-epoch-boundaries.unit.test.d.ts.map +1 -0
  128. package/dist/__tests__/structure-epoch.unit.test.d.ts +2 -0
  129. package/dist/__tests__/structure-epoch.unit.test.d.ts.map +1 -0
  130. package/dist/__tests__/table-archetype-mapping.unit.test.d.ts +2 -0
  131. package/dist/__tests__/table-archetype-mapping.unit.test.d.ts.map +1 -0
  132. package/dist/__tests__/time.unit.test.d.ts +2 -0
  133. package/dist/__tests__/time.unit.test.d.ts.map +1 -0
  134. package/dist/__tests__/types.test-d.d.ts +2 -0
  135. package/dist/__tests__/types.test-d.d.ts.map +1 -0
  136. package/dist/__tests__/unique-ref-store.unit.test.d.ts +2 -0
  137. package/dist/__tests__/unique-ref-store.unit.test.d.ts.map +1 -0
  138. package/dist/__tests__/utils/handle-numeric.d.ts +14 -0
  139. package/dist/__tests__/utils/handle-numeric.d.ts.map +1 -0
  140. package/dist/__tests__/validation-root-surface.unit.test.d.ts +2 -0
  141. package/dist/__tests__/validation-root-surface.unit.test.d.ts.map +1 -0
  142. package/dist/__tests__/visibility-atomic-write.unit.test.d.ts +2 -0
  143. package/dist/__tests__/visibility-atomic-write.unit.test.d.ts.map +1 -0
  144. package/dist/__tests__/world-change-journal.unit.test.d.ts +2 -0
  145. package/dist/__tests__/world-change-journal.unit.test.d.ts.map +1 -0
  146. package/dist/__tests__/world-characterization.unit.test.d.ts +2 -0
  147. package/dist/__tests__/world-characterization.unit.test.d.ts.map +1 -0
  148. package/dist/__tests__/world-consumer-inference.test-d.d.ts +2 -0
  149. package/dist/__tests__/world-consumer-inference.test-d.d.ts.map +1 -0
  150. package/dist/__tests__/world-health.contract.test.d.ts +2 -0
  151. package/dist/__tests__/world-health.contract.test.d.ts.map +1 -0
  152. package/dist/__tests__/world-inspection.test.d.ts +2 -0
  153. package/dist/__tests__/world-inspection.test.d.ts.map +1 -0
  154. package/dist/__tests__/world-internal-identity.unit.test.d.ts +2 -0
  155. package/dist/__tests__/world-internal-identity.unit.test.d.ts.map +1 -0
  156. package/dist/__tests__/world-managed-roundtrip.unit.test.d.ts +2 -0
  157. package/dist/__tests__/world-managed-roundtrip.unit.test.d.ts.map +1 -0
  158. package/dist/__tests__/world-scheduling.m4.test.d.ts +2 -0
  159. package/dist/__tests__/world-scheduling.m4.test.d.ts.map +1 -0
  160. package/dist/__tests__/world-unique-roundtrip.unit.test.d.ts +2 -0
  161. package/dist/__tests__/world-unique-roundtrip.unit.test.d.ts.map +1 -0
  162. package/dist/__tests__/world.test-d.d.ts +2 -0
  163. package/dist/__tests__/world.test-d.d.ts.map +1 -0
  164. package/dist/buffer-pool.d.ts +109 -0
  165. package/dist/buffer-pool.d.ts.map +1 -0
  166. package/dist/commands.d.ts +93 -0
  167. package/dist/commands.d.ts.map +1 -0
  168. package/dist/component-default-fallback.d.ts +88 -0
  169. package/dist/component-default-fallback.d.ts.map +1 -0
  170. package/dist/component-schema.d.ts +34 -0
  171. package/dist/component-schema.d.ts.map +1 -0
  172. package/dist/component-value-validate.d.ts +29 -0
  173. package/dist/component-value-validate.d.ts.map +1 -0
  174. package/dist/component.d.ts +581 -0
  175. package/dist/component.d.ts.map +1 -0
  176. package/dist/entity-handle.d.ts +68 -0
  177. package/dist/entity-handle.d.ts.map +1 -0
  178. package/dist/entity.d.ts +86 -0
  179. package/dist/entity.d.ts.map +1 -0
  180. package/dist/errors/query-and-component-errors.d.ts +132 -0
  181. package/dist/errors/query-and-component-errors.d.ts.map +1 -0
  182. package/dist/errors/relationship-errors.d.ts +112 -0
  183. package/dist/errors/relationship-errors.d.ts.map +1 -0
  184. package/dist/errors/sprite-and-shared-errors.d.ts +107 -0
  185. package/dist/errors/sprite-and-shared-errors.d.ts.map +1 -0
  186. package/dist/errors/validation-errors.d.ts +214 -0
  187. package/dist/errors/validation-errors.d.ts.map +1 -0
  188. package/dist/errors.d.ts +756 -0
  189. package/dist/errors.d.ts.map +1 -0
  190. package/dist/execution/shared-kernel.d.ts +106 -0
  191. package/dist/execution/shared-kernel.d.ts.map +1 -0
  192. package/dist/externalization/index.d.ts +31 -0
  193. package/dist/externalization/index.d.ts.map +1 -0
  194. package/dist/externalization/index.mjs +298 -0
  195. package/dist/externalization/index.mjs.map +1 -0
  196. package/dist/index.d.ts +261 -0
  197. package/dist/index.d.ts.map +1 -0
  198. package/dist/index.mjs +7354 -0
  199. package/dist/index.mjs.map +1 -0
  200. package/dist/internal.mjs +479 -0
  201. package/dist/internal.mjs.map +1 -0
  202. package/dist/plugin-service.d.ts +11 -0
  203. package/dist/plugin-service.d.ts.map +1 -0
  204. package/dist/projection/index.d.ts +50 -0
  205. package/dist/projection/index.d.ts.map +1 -0
  206. package/dist/projection/index.mjs +517 -0
  207. package/dist/projection/index.mjs.map +1 -0
  208. package/dist/query/query.d.ts +58 -0
  209. package/dist/query/query.d.ts.map +1 -0
  210. package/dist/relationship-index.d.ts +81 -0
  211. package/dist/relationship-index.d.ts.map +1 -0
  212. package/dist/resource.d.ts +70 -0
  213. package/dist/resource.d.ts.map +1 -0
  214. package/dist/schedule-token.d.ts +16 -0
  215. package/dist/schedule-token.d.ts.map +1 -0
  216. package/dist/schedule.d.ts +271 -0
  217. package/dist/schedule.d.ts.map +1 -0
  218. package/dist/shared-ref-store.d.ts +144 -0
  219. package/dist/shared-ref-store.d.ts.map +1 -0
  220. package/dist/shared.d.ts +3 -0
  221. package/dist/shared.d.ts.map +1 -0
  222. package/dist/shared.mjs +364 -0
  223. package/dist/shared.mjs.map +1 -0
  224. package/dist/storage/archetype-graph.d.ts +54 -0
  225. package/dist/storage/archetype-graph.d.ts.map +1 -0
  226. package/dist/storage/archetype.d.ts +23 -0
  227. package/dist/storage/archetype.d.ts.map +1 -0
  228. package/dist/storage/change-detection.d.ts +40 -0
  229. package/dist/storage/change-detection.d.ts.map +1 -0
  230. package/dist/storage/column.d.ts +111 -0
  231. package/dist/storage/column.d.ts.map +1 -0
  232. package/dist/storage/table.d.ts +29 -0
  233. package/dist/storage/table.d.ts.map +1 -0
  234. package/dist/time.d.ts +57 -0
  235. package/dist/time.d.ts.map +1 -0
  236. package/dist/unique-ref-store.d.ts +105 -0
  237. package/dist/unique-ref-store.d.ts.map +1 -0
  238. package/dist/world-change-journal.d.ts +34 -0
  239. package/dist/world-change-journal.d.ts.map +1 -0
  240. package/dist/world-component-access.d.ts +264 -0
  241. package/dist/world-component-access.d.ts.map +1 -0
  242. package/dist/world-component-storage.d.ts +282 -0
  243. package/dist/world-component-storage.d.ts.map +1 -0
  244. package/dist/world-core.d.ts +39 -0
  245. package/dist/world-core.d.ts.map +1 -0
  246. package/dist/world-entity-lifecycle.d.ts +30 -0
  247. package/dist/world-entity-lifecycle.d.ts.map +1 -0
  248. package/dist/world-internal.d.ts +14 -0
  249. package/dist/world-internal.d.ts.map +1 -0
  250. package/dist/world-scheduling.d.ts +30 -0
  251. package/dist/world-scheduling.d.ts.map +1 -0
  252. package/dist/world.d.ts +620 -0
  253. package/dist/world.d.ts.map +1 -0
  254. package/package.json +77 -0
  255. package/src/__fixtures__/field-shape-fixture.ts +30 -0
  256. package/src/__tests__/__fixtures__/inspect-scripts.snapshot.ts +2 -0
  257. package/src/__tests__/archetype.unit.test.ts +1837 -0
  258. package/src/__tests__/array-handle-element.test-d.ts +34 -0
  259. package/src/__tests__/buffer-array-vocab.test-d.ts +53 -0
  260. package/src/__tests__/buffer-field-input-widen.unit.test.ts +99 -0
  261. package/src/__tests__/buffer-pool.test-d.ts +32 -0
  262. package/src/__tests__/change-detection.unit.test.ts +86 -0
  263. package/src/__tests__/command-buffer.test.ts +179 -0
  264. package/src/__tests__/commands-deferred.unit.test.ts +68 -0
  265. package/src/__tests__/component-catalog.test.ts +59 -0
  266. package/src/__tests__/component-definition-identity.unit.test.ts +24 -0
  267. package/src/__tests__/component-schema.test-d.ts +119 -0
  268. package/src/__tests__/component-schema.test.ts +55 -0
  269. package/src/__tests__/define-component-options.test-d.ts +35 -0
  270. package/src/__tests__/deprecated-vocab-rejection.unit.test.ts +59 -0
  271. package/src/__tests__/despawn-all.unit.test.ts +17 -0
  272. package/src/__tests__/ecs-core-reduction.characterization.test.ts +130 -0
  273. package/src/__tests__/ecs-core-reduction.perf.test.ts +260 -0
  274. package/src/__tests__/ecs-error-code-31.test-d.ts +42 -0
  275. package/src/__tests__/entity-disabling.unit.test.ts +37 -0
  276. package/src/__tests__/entity-handle-codec-parity.unit.test.ts +126 -0
  277. package/src/__tests__/errors.unit.test.ts +1452 -0
  278. package/src/__tests__/execution-conflict-boundary.unit.test.ts +123 -0
  279. package/src/__tests__/execution-shared-storage.unit.test.ts +40 -0
  280. package/src/__tests__/externalization-portable-value.unit.test.ts +275 -0
  281. package/src/__tests__/externalization-projection.unit.test.ts +325 -0
  282. package/src/__tests__/externalization-root-surface.unit.test.ts +33 -0
  283. package/src/__tests__/field-enum-labels-reflection.test.ts +66 -0
  284. package/src/__tests__/field-shape-fixture.test.ts +61 -0
  285. package/src/__tests__/field-transient-reflection.test.ts +59 -0
  286. package/src/__tests__/field-value-type.test-d.ts +57 -0
  287. package/src/__tests__/fixed-update.unit.test.ts +78 -0
  288. package/src/__tests__/handle.test-d.ts +86 -0
  289. package/src/__tests__/hierarchy.unit.test.ts +2534 -0
  290. package/src/__tests__/managed-array-vocab.test-d.ts +137 -0
  291. package/src/__tests__/minimal-example.test-d.ts +42 -0
  292. package/src/__tests__/name-read-types.test-d.ts +72 -0
  293. package/src/__tests__/plugin-service.test.ts +13 -0
  294. package/src/__tests__/query-combinations.unit.test.ts +42 -0
  295. package/src/__tests__/query-light-extract-flat-column-ratio.perf.test.ts +252 -0
  296. package/src/__tests__/query-storage-trends.perf.test.ts +104 -0
  297. package/src/__tests__/query-trs-flat-column-ratio.perf.test.ts +194 -0
  298. package/src/__tests__/query.unit.test.ts +196 -0
  299. package/src/__tests__/relationship-index.perf.test.ts +126 -0
  300. package/src/__tests__/relationship-index.test.ts +70 -0
  301. package/src/__tests__/scalar-field-type-owner.test-d.ts +71 -0
  302. package/src/__tests__/schedule-determinism.unit.test.ts +36 -0
  303. package/src/__tests__/schedule-inspection.unit.test.ts +81 -0
  304. package/src/__tests__/schedule-scope-error.unit.test.ts +63 -0
  305. package/src/__tests__/schedule-token.unit.test.ts +54 -0
  306. package/src/__tests__/schema-vocab.test-d.ts +103 -0
  307. package/src/__tests__/serialization.unit.test.ts +2740 -0
  308. package/src/__tests__/shared-kernel-eligibility.test-d.ts +18 -0
  309. package/src/__tests__/shared-kernel-eligibility.unit.test.ts +78 -0
  310. package/src/__tests__/shared-ref-store.unit.test.ts +646 -0
  311. package/src/__tests__/sparse-tag.unit.test.ts +201 -0
  312. package/src/__tests__/spawn-field-error.test-d.ts +41 -0
  313. package/src/__tests__/stale-error.test-d.ts +207 -0
  314. package/src/__tests__/string-view-symmetry.test-d.ts +26 -0
  315. package/src/__tests__/string-vocab.test-d.ts +49 -0
  316. package/src/__tests__/structure-epoch-boundaries.unit.test.ts +39 -0
  317. package/src/__tests__/structure-epoch.unit.test.ts +48 -0
  318. package/src/__tests__/table-archetype-mapping.unit.test.ts +78 -0
  319. package/src/__tests__/time.unit.test.ts +79 -0
  320. package/src/__tests__/types.test-d.ts +38 -0
  321. package/src/__tests__/unique-ref-store.unit.test.ts +348 -0
  322. package/src/__tests__/utils/handle-numeric.ts +30 -0
  323. package/src/__tests__/validation-root-surface.unit.test.ts +15 -0
  324. package/src/__tests__/visibility-atomic-write.unit.test.ts +82 -0
  325. package/src/__tests__/world-change-journal.unit.test.ts +97 -0
  326. package/src/__tests__/world-characterization.unit.test.ts +408 -0
  327. package/src/__tests__/world-consumer-inference.test-d.ts +16 -0
  328. package/src/__tests__/world-health.contract.test.ts +87 -0
  329. package/src/__tests__/world-inspection.test.ts +37 -0
  330. package/src/__tests__/world-internal-identity.unit.test.ts +17 -0
  331. package/src/__tests__/world-managed-roundtrip.unit.test.ts +98 -0
  332. package/src/__tests__/world-scheduling.m4.test.ts +52 -0
  333. package/src/__tests__/world-unique-roundtrip.unit.test.ts +357 -0
  334. package/src/__tests__/world.test-d.ts +156 -0
  335. package/src/buffer-pool.ts +357 -0
  336. package/src/commands.ts +644 -0
  337. package/src/component-default-fallback.ts +236 -0
  338. package/src/component-schema.ts +92 -0
  339. package/src/component-value-validate.ts +135 -0
  340. package/src/component.ts +1268 -0
  341. package/src/entity-handle.ts +104 -0
  342. package/src/entity.ts +140 -0
  343. package/src/errors/query-and-component-errors.ts +200 -0
  344. package/src/errors/relationship-errors.ts +198 -0
  345. package/src/errors/sprite-and-shared-errors.ts +231 -0
  346. package/src/errors/validation-errors.ts +418 -0
  347. package/src/errors.ts +1453 -0
  348. package/src/execution/shared-kernel.ts +392 -0
  349. package/src/externalization/index.ts +170 -0
  350. package/src/index.ts +414 -0
  351. package/src/plugin-service.ts +35 -0
  352. package/src/projection/index.ts +142 -0
  353. package/src/query/query.ts +606 -0
  354. package/src/relationship-index.ts +175 -0
  355. package/src/resource.ts +106 -0
  356. package/src/schedule-token.ts +40 -0
  357. package/src/schedule.ts +846 -0
  358. package/src/shared-ref-store.ts +418 -0
  359. package/src/shared.ts +23 -0
  360. package/src/storage/archetype-graph.ts +166 -0
  361. package/src/storage/archetype.ts +78 -0
  362. package/src/storage/change-detection.ts +231 -0
  363. package/src/storage/column.ts +247 -0
  364. package/src/storage/table.ts +153 -0
  365. package/src/time.ts +122 -0
  366. package/src/unique-ref-store.ts +278 -0
  367. package/src/world-change-journal.ts +84 -0
  368. package/src/world-component-access.ts +1412 -0
  369. package/src/world-component-storage.ts +1178 -0
  370. package/src/world-core.ts +74 -0
  371. package/src/world-entity-lifecycle.ts +539 -0
  372. package/src/world-internal.ts +75 -0
  373. package/src/world-scheduling.ts +499 -0
  374. package/src/world.ts +1397 -0
@@ -0,0 +1,23 @@
1
+ import type { Component, ComponentId } from '../component';
2
+ import type { TableId } from './table';
3
+ export type ArchetypeId = number;
4
+ export interface Archetype {
5
+ readonly id: ArchetypeId;
6
+ readonly key: string;
7
+ readonly components: ReadonlyArray<Component>;
8
+ readonly tableId: TableId;
9
+ rows: Uint32Array;
10
+ size: number;
11
+ capacity: number;
12
+ addEdges: Map<ComponentId, ArchetypeId>;
13
+ removeEdges: Map<ComponentId, ArchetypeId>;
14
+ }
15
+ export declare function archetypeKey(componentIds: ReadonlyArray<ComponentId>): string;
16
+ export declare function createArchetype(components: ReadonlyArray<Component>, id: ArchetypeId, tableId: TableId): Archetype;
17
+ export declare function appendArchetypeRow(archetype: Archetype, tableRow: number): number;
18
+ export declare function removeArchetypeRow(archetype: Archetype, row: number): {
19
+ movedTableRow: number;
20
+ newRow: number;
21
+ } | null;
22
+ export declare function growArchetype(archetype: Archetype, targetCapacity: number): void;
23
+ //# sourceMappingURL=archetype.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"archetype.d.ts","sourceRoot":"","sources":["../../src/storage/archetype.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAG3D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAIvC,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC;AAEjC,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,EAAE,EAAE,WAAW,CAAC;IACzB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;IAC9C,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,IAAI,EAAE,WAAW,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,GAAG,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;IACxC,WAAW,EAAE,GAAG,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;CAC5C;AAED,wBAAgB,YAAY,CAAC,YAAY,EAAE,aAAa,CAAC,WAAW,CAAC,GAAG,MAAM,CAE7E;AAED,wBAAgB,eAAe,CAC7B,UAAU,EAAE,aAAa,CAAC,SAAS,CAAC,EACpC,EAAE,EAAE,WAAW,EACf,OAAO,EAAE,OAAO,GACf,SAAS,CAeX;AAED,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAMjF;AAED,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,SAAS,EACpB,GAAG,EAAE,MAAM,GACV;IAAE,aAAa,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAUlD;AAED,wBAAgB,aAAa,CAAC,SAAS,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,GAAG,IAAI,CAQhF"}
@@ -0,0 +1,40 @@
1
+ import type { Component } from '../component';
2
+ import { type EntityHandle } from '../entity-handle';
3
+ export { WorldChangeJournal, type WorldChangeRead } from '../world-change-journal';
4
+ import type { ArchetypeGraph } from './archetype-graph';
5
+ import type { Table } from './table';
6
+ export interface ComponentEpochColumns {
7
+ added: Float64Array;
8
+ changed: Float64Array;
9
+ }
10
+ export declare function createComponentEpochColumns(capacity: number): ComponentEpochColumns;
11
+ export declare function growComponentEpochColumns(columns: ComponentEpochColumns, capacity: number): ComponentEpochColumns;
12
+ export declare function copyComponentEpoch(source: ComponentEpochColumns, sourceRow: number, target: ComponentEpochColumns, targetRow: number): void;
13
+ export interface SparseTagSet {
14
+ readonly component: Component;
15
+ sparse: Int32Array;
16
+ dense: Uint32Array;
17
+ added: Float64Array;
18
+ changed: Float64Array;
19
+ size: number;
20
+ }
21
+ export declare function createSparseTagSet(component: Component): SparseTagSet;
22
+ export declare function sparseTagIndex(set: SparseTagSet, entity: EntityHandle): number;
23
+ export declare function sparseTagHas(set: SparseTagSet, entity: EntityHandle): boolean;
24
+ export declare function insertSparseTag(set: SparseTagSet, entity: EntityHandle, epoch: number): number;
25
+ export declare function removeSparseTag(set: SparseTagSet, entity: EntityHandle): boolean;
26
+ export interface ChangeTicks {
27
+ added: number;
28
+ changed: number;
29
+ }
30
+ export declare const NEVER_CHANGED_TICK = -1;
31
+ export declare function createChangeTicks(tick: number): ChangeTicks;
32
+ interface EntityLocation {
33
+ readonly archetypeId: number;
34
+ readonly archetypeRow: number;
35
+ }
36
+ export declare function readComponentChange(graph: ArchetypeGraph, location: EntityLocation, entity: EntityHandle, componentId: number): ChangeTicks | undefined;
37
+ export declare function markComponentsAdded(graph: ArchetypeGraph, location: EntityLocation, entity: EntityHandle, componentIds: readonly number[], epoch: number): void;
38
+ export declare function markComponentChanged(graph: ArchetypeGraph, location: EntityLocation, entity: EntityHandle, componentId: number, epoch: () => number): void;
39
+ export declare function readTableEntityRange(table: Table, rowStart: number, rowCount: number): readonly EntityHandle[];
40
+ //# sourceMappingURL=change-detection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"change-detection.d.ts","sourceRoot":"","sources":["../../src/storage/change-detection.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAG9C,OAAO,EA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AE,YAAY,EAAE,MAAM,EAAE,YAAY,GAAG,OAAO,CAchF;AA0BD,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,kBAAkB,KAAK,CAAC;AAErC,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAE3D;AAED,UAAU,cAAc;IACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;CAC/B;AAED,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,cAAc,EACrB,QAAQ,EAAE,cAAc,EACxB,MAAM,EAAE,YAAY,EACpB,WAAW,EAAE,MAAM,GAClB,WAAW,GAAG,SAAS,CAmBzB;AAED,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,cAAc,EACrB,QAAQ,EAAE,cAAc,EACxB,MAAM,EAAE,YAAY,EACpB,YAAY,EAAE,SAAS,MAAM,EAAE,EAC/B,KAAK,EAAE,MAAM,GACZ,IAAI,CAiBN;AAED,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,cAAc,EACrB,QAAQ,EAAE,cAAc,EACxB,MAAM,EAAE,YAAY,EACpB,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,MAAM,MAAM,GAClB,IAAI,CAaN;AAED,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,GACf,SAAS,YAAY,EAAE,CAKzB"}
@@ -0,0 +1,111 @@
1
+ import { type ComponentSchema, type ScalarFieldType } from '../component';
2
+ /**
3
+ * Read-only access shape for the 4 managed-vocab column keywords --
4
+ * `'string'` / `` `ref<T>` `` / variable `'buffer'` / variable `` `array<T>` ``.
5
+ *
6
+ * The column carries u32 slot ids (`UniqueRefStore` / `BufferPool`); direct
7
+ * index assignment would corrupt the slot table. The reader exposes
8
+ * `.length` + `.get(i): number` so consumers can walk row indices and
9
+ * retrieve slot ids, then route through the public dispatch (`world.set`,
10
+ * `world.push`, `world.allocUniqueRef`, etc.) for any mutation.
11
+ *
12
+ * Phantom brand `__managed` (D-7 / requirements-decisions q2): the
13
+ * double-underscore + semantic-word pattern matches `Handle.__handle`. The
14
+ * brand is a structural-typing safety net; the class name already
15
+ * disambiguates against `Uint32Array` / `Uint8Array` / fixed inline views.
16
+ *
17
+ * Intentionally minimal -- no iterator, no `toArray`, no `slice`. Adding
18
+ * those invites a "cache the slot ids, mutate later" anti-pattern that
19
+ * silently desyncs from the live column on the next archetype migration
20
+ * (charter P4 / plan-strategy §8.4).
21
+ */
22
+ export interface ManagedColumnReader<T extends string> {
23
+ readonly length: number;
24
+ get(i: number): number;
25
+ readonly __managed: T;
26
+ }
27
+ /**
28
+ * Sidecar column name for the live `count` of an `array<T>` (variable-
29
+ * capacity) field. Format `<fieldName>:count` keeps the suffix outside the
30
+ * legal user-facing schema name space (the colon is forbidden in user
31
+ * field names by convention) so the archetype Map can carry both columns
32
+ * under one `Map<fieldName, Column>` keyed namespace without collision
33
+ * (D-3 double-column allocation in M1 / w7).
34
+ */
35
+ export declare function arrayCountColumnName(fieldName: string): string;
36
+ /** TypedArray view types used by columns. */
37
+ export type FieldView = Float32Array | Float64Array | Int32Array | Uint32Array | Int16Array | Uint16Array | Int8Array | Uint8Array;
38
+ /** A single column: one field's ArrayBuffer + TypedArray view. */
39
+ export interface Column {
40
+ buffer: ArrayBuffer | SharedArrayBuffer;
41
+ view: FieldView;
42
+ capacity: number;
43
+ fieldType: ScalarFieldType;
44
+ /**
45
+ * Number of elements per row (stride). Scalar and variable-capacity columns
46
+ * default to 1 (one u32 slot id or one scalar value per row). Fixed-capacity
47
+ * `array<T,N>` / `buffer<N>` inline columns (feat-20260602) have arity = N.
48
+ *
49
+ * For inline columns, the TypedArray view returned by `col.view.subarray()`
50
+ * aliases the column buffer directly. The view is transient: `growColumn`
51
+ * detaches the old `ArrayBuffer` via `transfer()`, so callers must re-fetch
52
+ * the view after any structural change. See `packages/ecs/README.md`
53
+ * Transient view contract section.
54
+ */
55
+ arity: number;
56
+ }
57
+ /**
58
+ * Create a column for a single field with given capacity.
59
+ *
60
+ * @param fieldType - scalar storage type for the column view ctor
61
+ * @param capacity - number of rows
62
+ * @param arity - elements per row (stride); default 1 for scalar/variable columns
63
+ */
64
+ export declare function createColumn(fieldType: ScalarFieldType, capacity: number, arity?: number, shared?: boolean): Column;
65
+ /**
66
+ * Module-level cache for `ArrayBuffer.prototype.transfer` support (O-1).
67
+ * Checked once at import time; avoids per-call feature detection overhead.
68
+ *
69
+ * Note: `transfer()` is ES2024. We use runtime feature detection + type cast
70
+ * so that tsconfig does not need `lib: ["es2024"]`.
71
+ */
72
+ export declare const HAS_TRANSFER: boolean;
73
+ /**
74
+ * Grow a column to a new capacity, preserving existing data.
75
+ * Returns a new Column; the old column is not modified.
76
+ *
77
+ * When the runtime supports `ArrayBuffer.transfer()` (ES2024, Node 22+,
78
+ * modern browsers), uses zero-copy buffer transfer. Otherwise falls back
79
+ * to `new ArrayBuffer` + `Uint8Array.set` copy.
80
+ *
81
+ * Both paths produce data-equivalent results (O-1 acceptance criterion).
82
+ */
83
+ export declare function growColumn(col: Column, newCapacity: number): Column;
84
+ /**
85
+ * Normalize a `'buffer'` / `'buffer<N>'` write payload to a `Uint8Array` view
86
+ * over its raw bytes. The write surface (`FieldInputType<'buffer'>`) accepts
87
+ * any `AllowSharedBufferSource` (Float32Array / ArrayBuffer / Uint8Array / any
88
+ * TypedArray); the column store and read side speak `Uint8Array` only. This is
89
+ * the single ingestion point that bridges the two — a strict superset of the
90
+ * prior Uint8Array-only behavior (an existing `Uint8Array` caller round-trips
91
+ * through `new Uint8Array(buffer, byteOffset, byteLength)`, same bytes, same
92
+ * length), so existing callers see zero behavior change.
93
+ *
94
+ * Returns `null` for non-buffer-source inputs (e.g. a forced cast feeding a
95
+ * number) so callers keep their existing "no-op / alloc(0)" branch for raw
96
+ * that is not a real buffer view.
97
+ */
98
+ export declare function normalizeBufferWrite(raw: unknown): Uint8Array | null;
99
+ /**
100
+ * Determine if a schema is "hot" (all fields are scalar → TypedArray SoA).
101
+ * Returns true if all fields are in the scalar field type set.
102
+ * Empty schema (tag component) returns true by convention (vacuously true).
103
+ *
104
+ * Schema-vocab keywords (`buffer:<N>` / `ref<T>` / `handle<T>` / `entity` /
105
+ * `array<T,N>` / `array<T>`) are explicitly cold — their storage is owned by
106
+ * separate subsystems (UniqueRefStore / BufferPool), not the column SoA path. The keyword check uses an unsafe narrowing because
107
+ * `SchemaFieldType` is wider than the set's `ScalarFieldType` element type;
108
+ * the `has` test is the runtime gate.
109
+ */
110
+ export declare function isHotSchema(schema: ComponentSchema): boolean;
111
+ //# sourceMappingURL=column.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"column.d.ts","sourceRoot":"","sources":["../../src/storage/column.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,eAAe,EAAiB,MAAM,cAAc,CAAC;AAOzF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,WAAW,mBAAmB,CAAC,CAAC,SAAS,MAAM;IACnD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,GAAG,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,QAAQ,CAAC,SAAS,EAAE,CAAC,CAAC;CACvB;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAE9D;AAMD,6CAA6C;AAC7C,MAAM,MAAM,SAAS,GACjB,YAAY,GACZ,YAAY,GACZ,UAAU,GACV,WAAW,GACX,UAAU,GACV,WAAW,GACX,SAAS,GACT,UAAU,CAAC;AAef,kEAAkE;AAClE,MAAM,WAAW,MAAM;IACrB,MAAM,EAAE,WAAW,GAAG,iBAAiB,CAAC;IACxC,IAAI,EAAE,SAAS,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,eAAe,CAAC;IAC3B;;;;;;;;;;OAUG;IACH,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC1B,SAAS,EAAE,eAAe,EAC1B,QAAQ,EAAE,MAAM,EAChB,KAAK,SAAI,EACT,MAAM,UAAQ,GACb,MAAM,CAaR;AAED;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,EAAE,OACuD,CAAC;AAEnF;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CA6BnE;AAMD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,OAAO,GAAG,UAAU,GAAG,IAAI,CAcpE;AAMD;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAO5D"}
@@ -0,0 +1,29 @@
1
+ import { type Component, type ComponentId } from '../component';
2
+ import type { EntityHandle } from '../entity-handle';
3
+ import { type ComponentEpochColumns } from './change-detection';
4
+ import { type Column } from './column';
5
+ export type TableId = number;
6
+ export interface TableComponentStorage {
7
+ readonly component: Component;
8
+ fields: Map<string, Column>;
9
+ epochs: ComponentEpochColumns;
10
+ }
11
+ export interface Table {
12
+ readonly id: TableId;
13
+ readonly key: string;
14
+ readonly components: ReadonlyArray<Component>;
15
+ storage: Map<ComponentId, TableComponentStorage>;
16
+ size: number;
17
+ capacity: number;
18
+ version: number;
19
+ }
20
+ export declare function tableKey(componentIds: ReadonlyArray<ComponentId>): string;
21
+ export declare function canonicalComponents(components: ReadonlyArray<Component>): Component[];
22
+ export declare function createTable(components: ReadonlyArray<Component>, id: TableId, shared?: boolean): Table;
23
+ export declare function appendTableRow(table: Table, entity: EntityHandle): number;
24
+ export declare function removeTableRow(table: Table, row: number): {
25
+ movedEntity: EntityHandle;
26
+ newRow: number;
27
+ } | null;
28
+ export declare function growTable(table: Table, targetCapacity: number): void;
29
+ //# sourceMappingURL=table.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../src/storage/table.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,SAAS,EACd,KAAK,WAAW,EAQjB,MAAM,cAAc,CAAC;AAEtB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EACL,KAAK,qBAAqB,EAI3B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAwB,KAAK,MAAM,EAA4B,MAAM,UAAU,CAAC;AAIvF,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC;AAE7B,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5B,MAAM,EAAE,qBAAqB,CAAC;CAC/B;AAED,MAAM,WAAW,KAAK;IACpB,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;IAC9C,OAAO,EAAE,GAAG,CAAC,WAAW,EAAE,qBAAqB,CAAC,CAAC;IACjD,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,QAAQ,CAAC,YAAY,EAAE,aAAa,CAAC,WAAW,CAAC,GAAG,MAAM,CAEzE;AAED,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,aAAa,CAAC,SAAS,CAAC,GAAG,SAAS,EAAE,CAKrF;AAED,wBAAgB,WAAW,CACzB,UAAU,EAAE,aAAa,CAAC,SAAS,CAAC,EACpC,EAAE,EAAE,OAAO,EACX,MAAM,UAAQ,GACb,KAAK,CAgDP;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,GAAG,MAAM,CAOzE;AAED,wBAAgB,cAAc,CAC5B,KAAK,EAAE,KAAK,EACZ,GAAG,EAAE,MAAM,GACV;IAAE,WAAW,EAAE,YAAY,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAiBtD;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,GAAG,IAAI,CAcpE"}
package/dist/time.d.ts ADDED
@@ -0,0 +1,57 @@
1
+ export interface TimeResource {
2
+ readonly delta: number;
3
+ readonly elapsed: number;
4
+ readonly maxDeltaSeconds: number;
5
+ }
6
+ export interface FixedTimeResource {
7
+ readonly delta: number;
8
+ readonly maxStepsPerUpdate: number;
9
+ readonly tick: number;
10
+ /** Seconds accumulated toward the next fixed update. */
11
+ readonly overstep: number;
12
+ readonly droppedSeconds: number;
13
+ readonly droppedUpdates: number;
14
+ }
15
+ export type MutableTimeResource = {
16
+ -readonly [K in keyof TimeResource]: TimeResource[K];
17
+ };
18
+ export type MutableFixedTimeResource = {
19
+ -readonly [K in keyof FixedTimeResource]: FixedTimeResource[K];
20
+ };
21
+ /** Scheduler-only mutable clock capability; World never exposes this publicly. */
22
+ export interface ClockWriter {
23
+ readonly time: MutableTimeResource;
24
+ readonly fixed: MutableFixedTimeResource;
25
+ }
26
+ export interface WorldClock {
27
+ readonly time: TimeResource;
28
+ readonly fixed: FixedTimeResource;
29
+ readonly writer: ClockWriter;
30
+ }
31
+ interface ResourceToken<T> {
32
+ readonly name: string;
33
+ readonly __resourceType?: T;
34
+ }
35
+ export type ResourceValue<Key> = Key extends ResourceToken<infer Value> ? Value : never;
36
+ export interface TimePolicy {
37
+ readonly fixedDeltaSeconds?: number;
38
+ readonly maxStepsPerUpdate?: number;
39
+ readonly maxDeltaSeconds?: number;
40
+ }
41
+ export interface WorldOptions {
42
+ readonly time?: TimePolicy;
43
+ /** SAB-backed dense numeric columns for a SharedKernel-capable Engine Realm. */
44
+ readonly storage?: 'local' | 'shared';
45
+ }
46
+ /** World-owned variable-rate clock resource key. */
47
+ export declare const Time: ResourceToken<TimeResource> & TimeResource;
48
+ /** World-owned fixed-rate clock, policy, and catch-up metric resource key. */
49
+ export declare const FixedTime: ResourceToken<FixedTimeResource> & FixedTimeResource;
50
+ export declare const TIME_RESOURCE_KEY: string;
51
+ export declare const FIXED_TIME_RESOURCE_KEY: string;
52
+ export declare const DEFAULT_TIME_POLICY: Required<TimePolicy>;
53
+ export declare function createTimeResource(policy: Required<TimePolicy>): TimeResource;
54
+ export declare function createFixedTimeResource(policy: Required<TimePolicy>): FixedTimeResource;
55
+ export declare function createWorldClock(policy: Required<TimePolicy>): WorldClock;
56
+ export {};
57
+ //# sourceMappingURL=time.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"time.d.ts","sourceRoot":"","sources":["../src/time.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;CAClC;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,wDAAwD;IACxD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;CACjC;AAED,MAAM,MAAM,mBAAmB,GAAG;IAAE,CAAC,UAAU,CAAC,IAAI,MAAM,YAAY,GAAG,YAAY,CAAC,CAAC,CAAC;CAAE,CAAC;AAC3F,MAAM,MA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,uBAAuB,QAAiB,CAAC;AAEtD,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,UAAU,CAIpD,CAAC;AAEF,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,QAAQ,CAAC,UAAU,CAAC,GAAG,YAAY,CAE7E;AAED,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,QAAQ,CAAC,UAAU,CAAC,GAAG,iBAAiB,CASvF;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,QAAQ,CAAC,UAAU,CAAC,GAAG,UAAU,CAuCzE"}
@@ -0,0 +1,105 @@
1
+ import type { Handle } from '@forgeax/engine-types';
2
+ import { type Result } from '@forgeax/engine-types';
3
+ import { UniqueRefDoubleReleaseError, UniqueRefReleasedError, UniqueRefStaleError } from './errors';
4
+ /**
5
+ * Per-slot singleton store for ECS-managed `Handle<T, 'unique'>` lifecycles.
6
+ * World hooks the three release paths (despawn, removeComponent, set) into
7
+ * `release(handle)`; `resolve(handle)` is the read path AI users reach
8
+ * indirectly through `world.get(e, C)` for `ref<T>` schema fields.
9
+ *
10
+ * §contract — handles carry a generation; stale-by-reuse is detected: the
11
+ * handle u32 packs `(gen << 24) | slot` via the shared codec; `resolve` /
12
+ * `release` compare the handle generation against `_generations[slot]` and
13
+ * return `UniqueRefStaleError` ('unique-ref-stale') when a released slot has
14
+ * been re-allocated, instead of silently resolving to the next payload.
15
+ * README §"Managed handles carry a generation" is the canonical AI-user-
16
+ * facing statement.
17
+ *
18
+ * Identity invariant (AC-04 prelude): the payload returned by `resolve` is
19
+ * the same object reference on every call until `release`. Carry-over (M4)
20
+ * relies on this - archetype migrate moves the row index, not the payload.
21
+ *
22
+ * Storage is type-erased (`unknown`): the store routes lifecycle without ever
23
+ * inspecting payload fields. Per-call payload typing flows through method
24
+ * generics: `alloc<T>` accepts a `T` payload + matching `onRelease(T)`, and
25
+ * `resolve<T>` returns `Result<T, ...>`. Both narrow at the call boundary
26
+ * (the single read site is World.get's ref path); making the class generic
27
+ * on `T` was decoration with no internal use, so the parameter was dropped
28
+ * (architecture-principles.md §1 SSOT).
29
+ */
30
+ export declare class UniqueRefStore {
31
+ private readonly payloads;
32
+ private readonly freeSlots;
33
+ private readonly releaseCallbacks;
34
+ private nextSlot;
35
+ /**
36
+ * Generation table indexed by slot (D-6). Each entry tracks the current
37
+ * generation for the slot — written to during alloc (welded into the
38
+ * returned handle via pack) and incremented on release (M4).
39
+ *
40
+ * Slot 0 is the sentinel and always has gen=0 — it is never allocated
41
+ * and never incremented (R6).
42
+ *
43
+ * @internal
44
+ */
45
+ private readonly _generations;
46
+ /**
47
+ * Allocate a fresh managed handle for `payload`, branded against `target`.
48
+ *
49
+ * Slot 0 is reserved as the "null/unset" sentinel - schema-vocab `ref<T>`
50
+ * fields default to this sentinel before the first write, and World's
51
+ * release loop uses it to short-circuit (`shouldRelease(0) === false`).
52
+ *
53
+ * The returned handle carries a generation tag welded via codec.pack
54
+ * (D-8, OOS-2): first allocation gen=0 (AC-06), reused slot gen = the
55
+ * current generation from _generations[slot]. The toUnique brand cast
56
+ * happens internally — external callers no longer construct Handle<...>
57
+ * directly.
58
+ *
59
+ * @returns a `Handle<T, 'unique'>` u32. The branded number is safe to
60
+ * widen to `number` for GPU upload (charter consistent abstraction).
61
+ */
62
+ alloc<Target extends string, T = unknown>(target: Target, payload: T, onRelease?: (payload: T) => void): Handle<Target, 'unique'>;
63
+ /**
64
+ * Look up `payload` by handle. Returns `err(unique-ref-released)` when
65
+ * the handle's slot has no live payload (release happened in between, and
66
+ * no re-alloc has filled the slot). Resolves the same payload object on
67
+ * every call - identity-stable until release.
68
+ *
69
+ * §contract: a stale handle whose slot has been released and re-allocated
70
+ * returns `err(unique-ref-stale)` — the generation welded into the handle
71
+ * no longer matches `_generations[slot]`. The gen check runs before the
72
+ * payload lookup, so stale-by-reuse is caught deterministically — see
73
+ * README §"Managed handles carry a generation".
74
+ *
75
+ * `T` flows from the caller's `Handle<T, 'unique'>` type; the store erases
76
+ * payload types at the storage layer and the call boundary re-narrows.
77
+ */
78
+ resolve<Target extends string, T = unknown>(handle: Handle<Target, 'unique'>): Result<T, UniqueRefReleasedError | UniqueRefStaleError>;
79
+ /**
80
+ * Release `handle` - drop the payload and push the slot onto the free list.
81
+ * Releasing the same handle twice surfaces `unique-ref-double-release`
82
+ * (D-1) so World's release loop can route the second release to Layer 3
83
+ * ErrorHandler without aborting the despawn chain. Detection is by
84
+ * payload-presence, not generation (§contract — managed handles are
85
+ * operational, not persistent).
86
+ *
87
+ * Releasing the slot-0 sentinel is a no-op - World's release loop calls
88
+ * `shouldRelease` first to filter sentinels.
89
+ */
90
+ release<Target extends string>(handle: Handle<Target, 'unique'>): Result<void, UniqueRefDoubleReleaseError | UniqueRefStaleError>;
91
+ /** @internal Replace the payload of a live slot without changing its handle. */
92
+ _setPayload<Target extends string, T>(handle: Handle<Target, 'unique'>, payload: T): void;
93
+ /**
94
+ * `true` if `handle` references a live slot - used by World's release loop
95
+ * to decide whether to call `release` (skips sentinel + already-released).
96
+ *
97
+ * The release loop differentiates "expected sentinel" (no error) from
98
+ * "leaked already-released handle" (`unique-ref-double-release`) at the
99
+ * caller layer; this helper handles only the no-op short-circuit.
100
+ */
101
+ isLive<Target extends string>(handle: Handle<Target, 'unique'>): boolean;
102
+ /** @internal Diagnostic count of live slots. Exposed for tests + inspector. */
103
+ _liveCount(): number;
104
+ }
105
+ //# sourceMappingURL=unique-ref-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unique-ref-store.d.ts","sourceRoot":"","sources":["../src/unique-ref-store.ts"],"names":[],"mappings":"AAyDA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAQL,KAAK,MAAM,EAGZ,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,2BAA2B,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAKpG;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,qBA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entity-handle';
2
+ export type WorldChangeKind = 'component-added' | 'component-changed' | 'component-removed' | 'derived-component-changed' | 'entity-removed';
3
+ export interface WorldChangeRecord {
4
+ readonly sequence: number;
5
+ readonly kind: WorldChangeKind;
6
+ readonly entity: EntityHandle;
7
+ readonly componentId?: number;
8
+ }
9
+ export type WorldChange = Omit<WorldChangeRecord, 'sequence'>;
10
+ export type WorldChangeRead = {
11
+ readonly status: 'ok';
12
+ readonly cursor: number;
13
+ readonly records: readonly WorldChangeRecord[];
14
+ } | {
15
+ readonly status: 'overflow';
16
+ readonly cursor: number;
17
+ readonly oldestAvailable: number;
18
+ };
19
+ /**
20
+ * Bounded mutation evidence for engine-owned projections.
21
+ *
22
+ * Readers retain a cursor and rebuild their projection when the ring has
23
+ * overwritten unread records. An overflow never returns a partial delta.
24
+ */
25
+ export declare class WorldChangeJournal {
26
+ readonly capacity: number;
27
+ private readonly records;
28
+ private nextSequence;
29
+ constructor(capacity?: number);
30
+ cursor(): number;
31
+ append(change: WorldChange): number;
32
+ readAfter(cursor: number): WorldChangeRead;
33
+ }
34
+ //# sourceMappingURL=world-change-journal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"world-change-journal.d.ts","sourceRoot":"","sources":["../src/world-change-journal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD,MAAM,MAAM,eAAe,GACvB,iBAAiB,GACjB,mBAAmB,GACnB,mBAAmB,GACnB,2BAA2B,GAC3B,gBAAgB,CAAC;AAErB,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAC/B,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED,MAAM,MAAM,WAAW,GAAG,IAAI,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC;AAE9D,MAAM,MAAM,eAAe,GACvB;IACE,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,SAAS,iBAAiB,EAAE,CAAC;CAChD,GACD;IACE,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;CAClC,CAAC;AAIN;;;;;GAKG;AACH,qBAAa,kBAAkB;IAIjB,QAAQ,CAAC,QAAQ;IAH7B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAuC;IAC/D,OAAO,CAAC,YAAY,CAAK;gBAEJ,QAAQ,SAAS;IAOtC,MAAM,IAAI,MAAM;IAIhB,MAAM,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM;IAOnC,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,eAAe;CAuB3C"}