@forgeax/engine-ecs 0.0.0-dev.8d955ade1c79

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 (383) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +278 -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-nan-preflight.unit.test.d.ts +2 -0
  29. package/dist/__tests__/component-nan-preflight.unit.test.d.ts.map +1 -0
  30. package/dist/__tests__/component-schema.test-d.d.ts +2 -0
  31. package/dist/__tests__/component-schema.test-d.d.ts.map +1 -0
  32. package/dist/__tests__/component-schema.test.d.ts +2 -0
  33. package/dist/__tests__/component-schema.test.d.ts.map +1 -0
  34. package/dist/__tests__/define-component-options.test-d.d.ts +2 -0
  35. package/dist/__tests__/define-component-options.test-d.d.ts.map +1 -0
  36. package/dist/__tests__/deprecated-vocab-rejection.unit.test.d.ts +2 -0
  37. package/dist/__tests__/deprecated-vocab-rejection.unit.test.d.ts.map +1 -0
  38. package/dist/__tests__/despawn-all.unit.test.d.ts +2 -0
  39. package/dist/__tests__/despawn-all.unit.test.d.ts.map +1 -0
  40. package/dist/__tests__/ecs-core-reduction.characterization.test.d.ts +2 -0
  41. package/dist/__tests__/ecs-core-reduction.characterization.test.d.ts.map +1 -0
  42. package/dist/__tests__/ecs-core-reduction.perf.test.d.ts +2 -0
  43. package/dist/__tests__/ecs-core-reduction.perf.test.d.ts.map +1 -0
  44. package/dist/__tests__/ecs-error-code-31.test-d.d.ts +2 -0
  45. package/dist/__tests__/ecs-error-code-31.test-d.d.ts.map +1 -0
  46. package/dist/__tests__/entity-disabling.unit.test.d.ts +2 -0
  47. package/dist/__tests__/entity-disabling.unit.test.d.ts.map +1 -0
  48. package/dist/__tests__/entity-handle-codec-parity.unit.test.d.ts +2 -0
  49. package/dist/__tests__/entity-handle-codec-parity.unit.test.d.ts.map +1 -0
  50. package/dist/__tests__/errors.unit.test.d.ts +2 -0
  51. package/dist/__tests__/errors.unit.test.d.ts.map +1 -0
  52. package/dist/__tests__/execution-conflict-boundary.unit.test.d.ts +2 -0
  53. package/dist/__tests__/execution-conflict-boundary.unit.test.d.ts.map +1 -0
  54. package/dist/__tests__/execution-shared-storage.unit.test.d.ts +2 -0
  55. package/dist/__tests__/execution-shared-storage.unit.test.d.ts.map +1 -0
  56. package/dist/__tests__/externalization-portable-value.unit.test.d.ts +2 -0
  57. package/dist/__tests__/externalization-portable-value.unit.test.d.ts.map +1 -0
  58. package/dist/__tests__/externalization-projection.unit.test.d.ts +2 -0
  59. package/dist/__tests__/externalization-projection.unit.test.d.ts.map +1 -0
  60. package/dist/__tests__/externalization-render-read-lease.test-d.d.ts +2 -0
  61. package/dist/__tests__/externalization-render-read-lease.test-d.d.ts.map +1 -0
  62. package/dist/__tests__/externalization-render-read-lease.unit.test.d.ts +2 -0
  63. package/dist/__tests__/externalization-render-read-lease.unit.test.d.ts.map +1 -0
  64. package/dist/__tests__/externalization-root-surface.unit.test.d.ts +2 -0
  65. package/dist/__tests__/externalization-root-surface.unit.test.d.ts.map +1 -0
  66. package/dist/__tests__/field-enum-labels-reflection.test.d.ts +2 -0
  67. package/dist/__tests__/field-enum-labels-reflection.test.d.ts.map +1 -0
  68. package/dist/__tests__/field-shape-fixture.test.d.ts +2 -0
  69. package/dist/__tests__/field-shape-fixture.test.d.ts.map +1 -0
  70. package/dist/__tests__/field-transient-reflection.test.d.ts +2 -0
  71. package/dist/__tests__/field-transient-reflection.test.d.ts.map +1 -0
  72. package/dist/__tests__/field-value-type.test-d.d.ts +2 -0
  73. package/dist/__tests__/field-value-type.test-d.d.ts.map +1 -0
  74. package/dist/__tests__/fixed-update.unit.test.d.ts +2 -0
  75. package/dist/__tests__/fixed-update.unit.test.d.ts.map +1 -0
  76. package/dist/__tests__/handle.test-d.d.ts +2 -0
  77. package/dist/__tests__/handle.test-d.d.ts.map +1 -0
  78. package/dist/__tests__/hierarchy.unit.test.d.ts +2 -0
  79. package/dist/__tests__/hierarchy.unit.test.d.ts.map +1 -0
  80. package/dist/__tests__/managed-array-vocab.test-d.d.ts +2 -0
  81. package/dist/__tests__/managed-array-vocab.test-d.d.ts.map +1 -0
  82. package/dist/__tests__/minimal-example.test-d.d.ts +2 -0
  83. package/dist/__tests__/minimal-example.test-d.d.ts.map +1 -0
  84. package/dist/__tests__/name-read-types.test-d.d.ts +2 -0
  85. package/dist/__tests__/name-read-types.test-d.d.ts.map +1 -0
  86. package/dist/__tests__/plugin-service.test.d.ts +2 -0
  87. package/dist/__tests__/plugin-service.test.d.ts.map +1 -0
  88. package/dist/__tests__/query-combinations.unit.test.d.ts +2 -0
  89. package/dist/__tests__/query-combinations.unit.test.d.ts.map +1 -0
  90. package/dist/__tests__/query-light-extract-flat-column-ratio.perf.test.d.ts +2 -0
  91. package/dist/__tests__/query-light-extract-flat-column-ratio.perf.test.d.ts.map +1 -0
  92. package/dist/__tests__/query-storage-trends.perf.test.d.ts +2 -0
  93. package/dist/__tests__/query-storage-trends.perf.test.d.ts.map +1 -0
  94. package/dist/__tests__/query-trs-flat-column-ratio.perf.test.d.ts +2 -0
  95. package/dist/__tests__/query-trs-flat-column-ratio.perf.test.d.ts.map +1 -0
  96. package/dist/__tests__/query.unit.test.d.ts +2 -0
  97. package/dist/__tests__/query.unit.test.d.ts.map +1 -0
  98. package/dist/__tests__/relationship-index.perf.test.d.ts +2 -0
  99. package/dist/__tests__/relationship-index.perf.test.d.ts.map +1 -0
  100. package/dist/__tests__/relationship-index.test.d.ts +2 -0
  101. package/dist/__tests__/relationship-index.test.d.ts.map +1 -0
  102. package/dist/__tests__/scalar-field-type-owner.test-d.d.ts +2 -0
  103. package/dist/__tests__/scalar-field-type-owner.test-d.d.ts.map +1 -0
  104. package/dist/__tests__/schedule-determinism.unit.test.d.ts +2 -0
  105. package/dist/__tests__/schedule-determinism.unit.test.d.ts.map +1 -0
  106. package/dist/__tests__/schedule-inspection.unit.test.d.ts +2 -0
  107. package/dist/__tests__/schedule-inspection.unit.test.d.ts.map +1 -0
  108. package/dist/__tests__/schedule-scope-error.unit.test.d.ts +2 -0
  109. package/dist/__tests__/schedule-scope-error.unit.test.d.ts.map +1 -0
  110. package/dist/__tests__/schedule-token.unit.test.d.ts +2 -0
  111. package/dist/__tests__/schedule-token.unit.test.d.ts.map +1 -0
  112. package/dist/__tests__/schema-vocab.test-d.d.ts +2 -0
  113. package/dist/__tests__/schema-vocab.test-d.d.ts.map +1 -0
  114. package/dist/__tests__/serialization.unit.test.d.ts +2 -0
  115. package/dist/__tests__/serialization.unit.test.d.ts.map +1 -0
  116. package/dist/__tests__/shared-kernel-eligibility.test-d.d.ts +2 -0
  117. package/dist/__tests__/shared-kernel-eligibility.test-d.d.ts.map +1 -0
  118. package/dist/__tests__/shared-kernel-eligibility.unit.test.d.ts +2 -0
  119. package/dist/__tests__/shared-kernel-eligibility.unit.test.d.ts.map +1 -0
  120. package/dist/__tests__/shared-ref-store.unit.test.d.ts +2 -0
  121. package/dist/__tests__/shared-ref-store.unit.test.d.ts.map +1 -0
  122. package/dist/__tests__/sparse-tag.unit.test.d.ts +2 -0
  123. package/dist/__tests__/sparse-tag.unit.test.d.ts.map +1 -0
  124. package/dist/__tests__/spawn-field-error.test-d.d.ts +2 -0
  125. package/dist/__tests__/spawn-field-error.test-d.d.ts.map +1 -0
  126. package/dist/__tests__/stale-error.test-d.d.ts +2 -0
  127. package/dist/__tests__/stale-error.test-d.d.ts.map +1 -0
  128. package/dist/__tests__/string-view-symmetry.test-d.d.ts +2 -0
  129. package/dist/__tests__/string-view-symmetry.test-d.d.ts.map +1 -0
  130. package/dist/__tests__/string-vocab.test-d.d.ts +2 -0
  131. package/dist/__tests__/string-vocab.test-d.d.ts.map +1 -0
  132. package/dist/__tests__/structure-epoch-boundaries.unit.test.d.ts +2 -0
  133. package/dist/__tests__/structure-epoch-boundaries.unit.test.d.ts.map +1 -0
  134. package/dist/__tests__/structure-epoch.unit.test.d.ts +2 -0
  135. package/dist/__tests__/structure-epoch.unit.test.d.ts.map +1 -0
  136. package/dist/__tests__/table-archetype-mapping.unit.test.d.ts +2 -0
  137. package/dist/__tests__/table-archetype-mapping.unit.test.d.ts.map +1 -0
  138. package/dist/__tests__/time.unit.test.d.ts +2 -0
  139. package/dist/__tests__/time.unit.test.d.ts.map +1 -0
  140. package/dist/__tests__/types.test-d.d.ts +2 -0
  141. package/dist/__tests__/types.test-d.d.ts.map +1 -0
  142. package/dist/__tests__/unique-ref-store.unit.test.d.ts +2 -0
  143. package/dist/__tests__/unique-ref-store.unit.test.d.ts.map +1 -0
  144. package/dist/__tests__/utils/handle-numeric.d.ts +14 -0
  145. package/dist/__tests__/utils/handle-numeric.d.ts.map +1 -0
  146. package/dist/__tests__/validation-root-surface.unit.test.d.ts +2 -0
  147. package/dist/__tests__/validation-root-surface.unit.test.d.ts.map +1 -0
  148. package/dist/__tests__/visibility-atomic-write.unit.test.d.ts +2 -0
  149. package/dist/__tests__/visibility-atomic-write.unit.test.d.ts.map +1 -0
  150. package/dist/__tests__/world-change-journal.unit.test.d.ts +2 -0
  151. package/dist/__tests__/world-change-journal.unit.test.d.ts.map +1 -0
  152. package/dist/__tests__/world-characterization.unit.test.d.ts +2 -0
  153. package/dist/__tests__/world-characterization.unit.test.d.ts.map +1 -0
  154. package/dist/__tests__/world-consumer-inference.test-d.d.ts +2 -0
  155. package/dist/__tests__/world-consumer-inference.test-d.d.ts.map +1 -0
  156. package/dist/__tests__/world-health.contract.test.d.ts +2 -0
  157. package/dist/__tests__/world-health.contract.test.d.ts.map +1 -0
  158. package/dist/__tests__/world-inspection.test.d.ts +2 -0
  159. package/dist/__tests__/world-inspection.test.d.ts.map +1 -0
  160. package/dist/__tests__/world-internal-identity.unit.test.d.ts +2 -0
  161. package/dist/__tests__/world-internal-identity.unit.test.d.ts.map +1 -0
  162. package/dist/__tests__/world-managed-roundtrip.unit.test.d.ts +2 -0
  163. package/dist/__tests__/world-managed-roundtrip.unit.test.d.ts.map +1 -0
  164. package/dist/__tests__/world-scheduling.m4.test.d.ts +2 -0
  165. package/dist/__tests__/world-scheduling.m4.test.d.ts.map +1 -0
  166. package/dist/__tests__/world-unique-roundtrip.unit.test.d.ts +2 -0
  167. package/dist/__tests__/world-unique-roundtrip.unit.test.d.ts.map +1 -0
  168. package/dist/__tests__/world.test-d.d.ts +2 -0
  169. package/dist/__tests__/world.test-d.d.ts.map +1 -0
  170. package/dist/buffer-pool.d.ts +109 -0
  171. package/dist/buffer-pool.d.ts.map +1 -0
  172. package/dist/commands.d.ts +93 -0
  173. package/dist/commands.d.ts.map +1 -0
  174. package/dist/component-default-fallback.d.ts +88 -0
  175. package/dist/component-default-fallback.d.ts.map +1 -0
  176. package/dist/component-schema.d.ts +34 -0
  177. package/dist/component-schema.d.ts.map +1 -0
  178. package/dist/component-value-validate.d.ts +29 -0
  179. package/dist/component-value-validate.d.ts.map +1 -0
  180. package/dist/component.d.ts +581 -0
  181. package/dist/component.d.ts.map +1 -0
  182. package/dist/entity-handle.d.ts +68 -0
  183. package/dist/entity-handle.d.ts.map +1 -0
  184. package/dist/entity.d.ts +86 -0
  185. package/dist/entity.d.ts.map +1 -0
  186. package/dist/errors/query-and-component-errors.d.ts +132 -0
  187. package/dist/errors/query-and-component-errors.d.ts.map +1 -0
  188. package/dist/errors/relationship-errors.d.ts +112 -0
  189. package/dist/errors/relationship-errors.d.ts.map +1 -0
  190. package/dist/errors/sprite-and-shared-errors.d.ts +107 -0
  191. package/dist/errors/sprite-and-shared-errors.d.ts.map +1 -0
  192. package/dist/errors/validation-errors.d.ts +229 -0
  193. package/dist/errors/validation-errors.d.ts.map +1 -0
  194. package/dist/errors.d.ts +763 -0
  195. package/dist/errors.d.ts.map +1 -0
  196. package/dist/execution/shared-kernel.d.ts +106 -0
  197. package/dist/execution/shared-kernel.d.ts.map +1 -0
  198. package/dist/externalization/index.d.ts +31 -0
  199. package/dist/externalization/index.d.ts.map +1 -0
  200. package/dist/externalization/index.mjs +298 -0
  201. package/dist/externalization/index.mjs.map +1 -0
  202. package/dist/index.d.ts +261 -0
  203. package/dist/index.d.ts.map +1 -0
  204. package/dist/index.mjs +7422 -0
  205. package/dist/index.mjs.map +1 -0
  206. package/dist/internal.mjs +479 -0
  207. package/dist/internal.mjs.map +1 -0
  208. package/dist/plugin-service.d.ts +11 -0
  209. package/dist/plugin-service.d.ts.map +1 -0
  210. package/dist/projection/index.d.ts +103 -0
  211. package/dist/projection/index.d.ts.map +1 -0
  212. package/dist/projection/index.mjs +615 -0
  213. package/dist/projection/index.mjs.map +1 -0
  214. package/dist/query/query.d.ts +58 -0
  215. package/dist/query/query.d.ts.map +1 -0
  216. package/dist/relationship-index.d.ts +81 -0
  217. package/dist/relationship-index.d.ts.map +1 -0
  218. package/dist/resource.d.ts +70 -0
  219. package/dist/resource.d.ts.map +1 -0
  220. package/dist/schedule-token.d.ts +16 -0
  221. package/dist/schedule-token.d.ts.map +1 -0
  222. package/dist/schedule.d.ts +271 -0
  223. package/dist/schedule.d.ts.map +1 -0
  224. package/dist/shared-ref-store.d.ts +144 -0
  225. package/dist/shared-ref-store.d.ts.map +1 -0
  226. package/dist/shared.d.ts +3 -0
  227. package/dist/shared.d.ts.map +1 -0
  228. package/dist/shared.mjs +364 -0
  229. package/dist/shared.mjs.map +1 -0
  230. package/dist/storage/archetype-graph.d.ts +54 -0
  231. package/dist/storage/archetype-graph.d.ts.map +1 -0
  232. package/dist/storage/archetype.d.ts +23 -0
  233. package/dist/storage/archetype.d.ts.map +1 -0
  234. package/dist/storage/change-detection.d.ts +40 -0
  235. package/dist/storage/change-detection.d.ts.map +1 -0
  236. package/dist/storage/column.d.ts +111 -0
  237. package/dist/storage/column.d.ts.map +1 -0
  238. package/dist/storage/table.d.ts +29 -0
  239. package/dist/storage/table.d.ts.map +1 -0
  240. package/dist/time.d.ts +57 -0
  241. package/dist/time.d.ts.map +1 -0
  242. package/dist/unique-ref-store.d.ts +105 -0
  243. package/dist/unique-ref-store.d.ts.map +1 -0
  244. package/dist/world-change-journal.d.ts +34 -0
  245. package/dist/world-change-journal.d.ts.map +1 -0
  246. package/dist/world-component-access.d.ts +265 -0
  247. package/dist/world-component-access.d.ts.map +1 -0
  248. package/dist/world-component-storage.d.ts +282 -0
  249. package/dist/world-component-storage.d.ts.map +1 -0
  250. package/dist/world-core.d.ts +39 -0
  251. package/dist/world-core.d.ts.map +1 -0
  252. package/dist/world-entity-lifecycle.d.ts +30 -0
  253. package/dist/world-entity-lifecycle.d.ts.map +1 -0
  254. package/dist/world-internal.d.ts +14 -0
  255. package/dist/world-internal.d.ts.map +1 -0
  256. package/dist/world-scheduling.d.ts +30 -0
  257. package/dist/world-scheduling.d.ts.map +1 -0
  258. package/dist/world.d.ts +620 -0
  259. package/dist/world.d.ts.map +1 -0
  260. package/package.json +77 -0
  261. package/src/__fixtures__/field-shape-fixture.ts +30 -0
  262. package/src/__tests__/__fixtures__/inspect-scripts.snapshot.ts +2 -0
  263. package/src/__tests__/archetype.unit.test.ts +1837 -0
  264. package/src/__tests__/array-handle-element.test-d.ts +34 -0
  265. package/src/__tests__/buffer-array-vocab.test-d.ts +53 -0
  266. package/src/__tests__/buffer-field-input-widen.unit.test.ts +99 -0
  267. package/src/__tests__/buffer-pool.test-d.ts +32 -0
  268. package/src/__tests__/change-detection.unit.test.ts +86 -0
  269. package/src/__tests__/command-buffer.test.ts +179 -0
  270. package/src/__tests__/commands-deferred.unit.test.ts +68 -0
  271. package/src/__tests__/component-catalog.test.ts +59 -0
  272. package/src/__tests__/component-definition-identity.unit.test.ts +24 -0
  273. package/src/__tests__/component-nan-preflight.unit.test.ts +186 -0
  274. package/src/__tests__/component-schema.test-d.ts +119 -0
  275. package/src/__tests__/component-schema.test.ts +55 -0
  276. package/src/__tests__/define-component-options.test-d.ts +35 -0
  277. package/src/__tests__/deprecated-vocab-rejection.unit.test.ts +59 -0
  278. package/src/__tests__/despawn-all.unit.test.ts +17 -0
  279. package/src/__tests__/ecs-core-reduction.characterization.test.ts +130 -0
  280. package/src/__tests__/ecs-core-reduction.perf.test.ts +260 -0
  281. package/src/__tests__/ecs-error-code-31.test-d.ts +42 -0
  282. package/src/__tests__/entity-disabling.unit.test.ts +37 -0
  283. package/src/__tests__/entity-handle-codec-parity.unit.test.ts +126 -0
  284. package/src/__tests__/errors.unit.test.ts +1456 -0
  285. package/src/__tests__/execution-conflict-boundary.unit.test.ts +123 -0
  286. package/src/__tests__/execution-shared-storage.unit.test.ts +40 -0
  287. package/src/__tests__/externalization-portable-value.unit.test.ts +275 -0
  288. package/src/__tests__/externalization-projection.unit.test.ts +325 -0
  289. package/src/__tests__/externalization-render-read-lease.test-d.ts +30 -0
  290. package/src/__tests__/externalization-render-read-lease.unit.test.ts +79 -0
  291. package/src/__tests__/externalization-root-surface.unit.test.ts +33 -0
  292. package/src/__tests__/field-enum-labels-reflection.test.ts +66 -0
  293. package/src/__tests__/field-shape-fixture.test.ts +61 -0
  294. package/src/__tests__/field-transient-reflection.test.ts +59 -0
  295. package/src/__tests__/field-value-type.test-d.ts +57 -0
  296. package/src/__tests__/fixed-update.unit.test.ts +78 -0
  297. package/src/__tests__/handle.test-d.ts +86 -0
  298. package/src/__tests__/hierarchy.unit.test.ts +2534 -0
  299. package/src/__tests__/managed-array-vocab.test-d.ts +137 -0
  300. package/src/__tests__/minimal-example.test-d.ts +42 -0
  301. package/src/__tests__/name-read-types.test-d.ts +72 -0
  302. package/src/__tests__/plugin-service.test.ts +13 -0
  303. package/src/__tests__/query-combinations.unit.test.ts +42 -0
  304. package/src/__tests__/query-light-extract-flat-column-ratio.perf.test.ts +252 -0
  305. package/src/__tests__/query-storage-trends.perf.test.ts +104 -0
  306. package/src/__tests__/query-trs-flat-column-ratio.perf.test.ts +194 -0
  307. package/src/__tests__/query.unit.test.ts +196 -0
  308. package/src/__tests__/relationship-index.perf.test.ts +126 -0
  309. package/src/__tests__/relationship-index.test.ts +70 -0
  310. package/src/__tests__/scalar-field-type-owner.test-d.ts +71 -0
  311. package/src/__tests__/schedule-determinism.unit.test.ts +36 -0
  312. package/src/__tests__/schedule-inspection.unit.test.ts +81 -0
  313. package/src/__tests__/schedule-scope-error.unit.test.ts +63 -0
  314. package/src/__tests__/schedule-token.unit.test.ts +54 -0
  315. package/src/__tests__/schema-vocab.test-d.ts +103 -0
  316. package/src/__tests__/serialization.unit.test.ts +2740 -0
  317. package/src/__tests__/shared-kernel-eligibility.test-d.ts +18 -0
  318. package/src/__tests__/shared-kernel-eligibility.unit.test.ts +78 -0
  319. package/src/__tests__/shared-ref-store.unit.test.ts +646 -0
  320. package/src/__tests__/sparse-tag.unit.test.ts +201 -0
  321. package/src/__tests__/spawn-field-error.test-d.ts +41 -0
  322. package/src/__tests__/stale-error.test-d.ts +208 -0
  323. package/src/__tests__/string-view-symmetry.test-d.ts +26 -0
  324. package/src/__tests__/string-vocab.test-d.ts +49 -0
  325. package/src/__tests__/structure-epoch-boundaries.unit.test.ts +39 -0
  326. package/src/__tests__/structure-epoch.unit.test.ts +48 -0
  327. package/src/__tests__/table-archetype-mapping.unit.test.ts +78 -0
  328. package/src/__tests__/time.unit.test.ts +79 -0
  329. package/src/__tests__/types.test-d.ts +38 -0
  330. package/src/__tests__/unique-ref-store.unit.test.ts +348 -0
  331. package/src/__tests__/utils/handle-numeric.ts +30 -0
  332. package/src/__tests__/validation-root-surface.unit.test.ts +15 -0
  333. package/src/__tests__/visibility-atomic-write.unit.test.ts +82 -0
  334. package/src/__tests__/world-change-journal.unit.test.ts +97 -0
  335. package/src/__tests__/world-characterization.unit.test.ts +408 -0
  336. package/src/__tests__/world-consumer-inference.test-d.ts +16 -0
  337. package/src/__tests__/world-health.contract.test.ts +87 -0
  338. package/src/__tests__/world-inspection.test.ts +37 -0
  339. package/src/__tests__/world-internal-identity.unit.test.ts +17 -0
  340. package/src/__tests__/world-managed-roundtrip.unit.test.ts +98 -0
  341. package/src/__tests__/world-scheduling.m4.test.ts +52 -0
  342. package/src/__tests__/world-unique-roundtrip.unit.test.ts +357 -0
  343. package/src/__tests__/world.test-d.ts +156 -0
  344. package/src/buffer-pool.ts +357 -0
  345. package/src/commands.ts +644 -0
  346. package/src/component-default-fallback.ts +236 -0
  347. package/src/component-schema.ts +92 -0
  348. package/src/component-value-validate.ts +135 -0
  349. package/src/component.ts +1268 -0
  350. package/src/entity-handle.ts +104 -0
  351. package/src/entity.ts +140 -0
  352. package/src/errors/query-and-component-errors.ts +200 -0
  353. package/src/errors/relationship-errors.ts +198 -0
  354. package/src/errors/sprite-and-shared-errors.ts +231 -0
  355. package/src/errors/validation-errors.ts +506 -0
  356. package/src/errors.ts +1464 -0
  357. package/src/execution/shared-kernel.ts +392 -0
  358. package/src/externalization/index.ts +170 -0
  359. package/src/index.ts +414 -0
  360. package/src/plugin-service.ts +35 -0
  361. package/src/projection/index.ts +318 -0
  362. package/src/query/query.ts +606 -0
  363. package/src/relationship-index.ts +175 -0
  364. package/src/resource.ts +106 -0
  365. package/src/schedule-token.ts +40 -0
  366. package/src/schedule.ts +846 -0
  367. package/src/shared-ref-store.ts +418 -0
  368. package/src/shared.ts +23 -0
  369. package/src/storage/archetype-graph.ts +166 -0
  370. package/src/storage/archetype.ts +78 -0
  371. package/src/storage/change-detection.ts +231 -0
  372. package/src/storage/column.ts +247 -0
  373. package/src/storage/table.ts +153 -0
  374. package/src/time.ts +122 -0
  375. package/src/unique-ref-store.ts +278 -0
  376. package/src/world-change-journal.ts +84 -0
  377. package/src/world-component-access.ts +1421 -0
  378. package/src/world-component-storage.ts +1178 -0
  379. package/src/world-core.ts +74 -0
  380. package/src/world-entity-lifecycle.ts +539 -0
  381. package/src/world-internal.ts +75 -0
  382. package/src/world-scheduling.ts +499 -0
  383. package/src/world.ts +1399 -0
package/src/index.ts ADDED
@@ -0,0 +1,414 @@
1
+ /**
2
+ * @module @forgeax/engine-ecs
3
+ *
4
+ * Archetype ECS with Result-based mutation errors and poisoned-frame recovery:
5
+ *
6
+ * 1. **Layer 1 (World methods)** — every mutation (`get`/`set`/`spawn`/`despawn`/
7
+ * `addComponent`/`removeComponent`) returns `Result<T, EcsError>`.
8
+ * Use `.unwrap()` for quick-and-dirty or `if (!r.ok) ... r.error ...` for programmatic branching.
9
+ *
10
+ *
11
+ * AI users: import types from this module — `.d.ts` signatures expose
12
+ * `Result<T, EcsError>` on all World methods, making error paths discoverable
13
+ * without reading source. Switch on `.code` for programmatic error branching.
14
+ *
15
+ * **Warning — Result propagation in system bodies**: TypeScript lacks Rust's `?`
16
+ * operator. Handle every Result branch explicitly or return the failure from
17
+ * the system so the frame poison boundary can stop the host.
18
+ */
19
+
20
+ // Layered exports: core API first (World / defineComponent / Entity / Query),
21
+ // then Result + error types, then advanced API (Schedule / CommandBuffer),
22
+ // then errors, then constants. AI users reading .d.ts see high-frequency
23
+ // APIs at the top of the file (charter V1 proposition 1).
24
+
25
+ // ────────────────────────────────────────────────────────────────────────────
26
+ // Result type — the return type of all World mutation methods
27
+ // ────────────────────────────────────────────────────────────────────────────
28
+
29
+ /**
30
+ * Discriminated union result type: `ResultOk<T>` or `ResultErr<E>`.
31
+ * All World mutation methods return `Result<T, EcsError>`. The discriminant
32
+ * is `.ok: boolean`; the success branch carries `.value: T`, the failure
33
+ * branch carries `.error: E`. Method chain: `.unwrap()` / `.unwrapOr(d)`.
34
+ *
35
+ * @example
36
+ * ```ts
37
+ * // Plain field-access idiom (charter proposition 5 consistent abstraction):
38
+ * const r = world.get(entity, Position);
39
+ * if (!r.ok) { console.error(r.error.code, r.error.hint); return; }
40
+ * const data = r.value; // ShapeOf<S>
41
+ *
42
+ * // Method-chain idiom (`.unwrap()` throws the original EcsError on err):
43
+ * const data2 = world.get(entity, Position).unwrap();
44
+ *
45
+ * // Defaulted-fallback idiom (charter proposition 4 explicit-failure
46
+ * // boundary — `unwrapOr` silently drops the error):
47
+ * const data3 = world.get(entity, Position).unwrapOr({ x: 0, y: 0 });
48
+ * ```
49
+ */
50
+
51
+ import { isComponentDefinitionOrderValid } from './component';
52
+ // ────────────────────────────────────────────────────────────────────────────
53
+ // Essential-id forced registration (feat-20260602 M1 / w1; plan-strategy
54
+ // D-1 / D-6b; feat-20260611 D-9 SSOT switch to ESSENTIAL_COMPONENT_IDS).
55
+ //
56
+ // The `Entity` component MUST be the first `defineComponent` evaluated in the
57
+ // process so the owner identity assigns it id=0. ESM
58
+ // evaluates import bindings in source order before any other statement, so this
59
+ // import -- placed textually first among the barrel's module imports -- forces
60
+ // `entity.ts` (and thus `defineComponent('Entity', ...)`) to run ahead of
61
+ // every downstream component module. The fail-fast assertion below converts
62
+ // an import-order regression from a silent runtime mis-id into a structured
63
+ // startup throw (charter P3).
64
+ //
65
+ // The assertion reads `ESSENTIAL_COMPONENT_IDS` (the SSOT for which ids must
66
+ // be present and where) rather than hard-coding a token property so adding a
67
+ // future essential component requires updating exactly one place.
68
+ //
69
+ // `Entity` is re-exported from the barrel as a value (the id=0 component
70
+ // token). The matching type-space handle type is `EntityHandle`, re-exported
71
+ // from `./entity-handle` -- the two no longer share a name (feat-20260611 I-1;
72
+ // renamed from `./entity` to `./entity-handle` in tweak-20260611-M3 to make
73
+ // the file's role explicit; tweak-20260612 then lifted the Entity component
74
+ // from the historical `components/entity.ts` back into `./entity` since that
75
+ // slot was free).
76
+ import { Disabled, Entity, ESSENTIAL_COMPONENT_IDS, foldEssentials } from './entity';
77
+
78
+ if (
79
+ !isComponentDefinitionOrderValid() ||
80
+ ESSENTIAL_COMPONENT_IDS.length !== 1 ||
81
+ ESSENTIAL_COMPONENT_IDS[0] !== 0
82
+ ) {
83
+ throw new Error(
84
+ 'forgeax-engine-ecs: ESSENTIAL_COMPONENT_IDS invariant violated ' +
85
+ `(expected [0], got [${ESSENTIAL_COMPONENT_IDS.join(', ')}]). ` +
86
+ 'A defineComponent() call evaluated before the @forgeax/engine-ecs barrel forced the id counter ' +
87
+ 'past 0. Ensure no module defines a component at import time before importing from the barrel.',
88
+ );
89
+ }
90
+
91
+ /**
92
+ * Branded-number handle type identifying a row (24-bit index + 8-bit
93
+ * generation). The `Entity` component token (value-space, id=0) and the
94
+ * `EntityHandle` type (type-space) are deliberately separate names since
95
+ * feat-20260611 -- a single shared name caused repeated AI-user confusion in
96
+ * `: Entity` annotations.
97
+ */
98
+ export type { EntityHandle } from './entity-handle';
99
+ export type { EcsErrorCode } from './errors';
100
+ export { SharedRefStaleError, UniqueRefStaleError } from './errors';
101
+ export {
102
+ createWorldContext,
103
+ worldPlugin,
104
+ } from './plugin-service';
105
+ export {
106
+ defineRelationship,
107
+ type RelationshipTargetComponent,
108
+ } from './relationship-index';
109
+ export {
110
+ FixedUpdate,
111
+ type ScheduleName,
112
+ type ScheduleToken,
113
+ Update,
114
+ } from './schedule-token';
115
+ export {
116
+ FixedTime,
117
+ type FixedTimeResource,
118
+ Time,
119
+ type TimePolicy,
120
+ type TimeResource,
121
+ type WorldOptions,
122
+ } from './time';
123
+ /**
124
+ * Union of all EcsError types returned by World methods via Result.
125
+ * Switch on `.code` for programmatic branching (e.g. `error.code === 'stale-entity'`).
126
+ */
127
+ export type { EcsError } from './world';
128
+ /**
129
+ * The id=0 essential `Entity` component token. The matching type-space handle
130
+ * type (the branded number returned by `world.spawn` and accepted by every
131
+ * World method that takes an entity argument) is `EntityHandle`, exported
132
+ * separately from this barrel.
133
+ *
134
+ * @example Handle type + spawn:
135
+ * ```ts
136
+ * const e: EntityHandle = world.spawn({ component: Position, data: { x: 0, y: 0 } }).unwrap();
137
+ * ```
138
+ * @example Read the handle off its own column / probe liveness:
139
+ * ```ts
140
+ * world.get(e, Entity).unwrap().self === e;
141
+ * ```
142
+ */
143
+ export { Disabled, Entity, ESSENTIAL_COMPONENT_IDS, foldEssentials };
144
+
145
+ // ────────────────────────────────────────────────────────────────────────────
146
+ // Core API — the 80% surface most users need
147
+ // ────────────────────────────────────────────────────────────────────────────
148
+
149
+ /**
150
+ * Two-axis phantom-branded handle: `Handle<TargetTag, Mode>`.
151
+ *
152
+ * - `Mode = 'unique'` — released by ECS on despawn / removeComponent / set
153
+ * (e.g. derived from schema vocab `ref<T>`).
154
+ * - `Mode = 'shared'` — external owner manages release; ECS treats as
155
+ * plain id (e.g. derived from schema vocab `handle<T>`,
156
+ * `MeshFilter.assetHandle: Handle<'MeshAsset','shared'>`).
157
+ *
158
+ * Cross-mode and cross-target assignment is a TS error (AC-02).
159
+ *
160
+ * The handle type is owned by `@forgeax/engine-types`; ECS schema fields
161
+ * consume it but the ECS barrel does not forward the type.
162
+ *
163
+ * @example
164
+ * ```ts
165
+ * import type { Handle } from '@forgeax/engine-types';
166
+ *
167
+ * declare const mesh: Handle<'MeshAsset', 'shared'>;
168
+ * // const mat: Handle<'MaterialAsset', 'shared'> = mesh; // TS error
169
+ * ```
170
+ */
171
+ /**
172
+ * Opaque component token carrying name + schema type information.
173
+ *
174
+ * Prefer letting `defineComponent` infer the type — both the literal name `N`
175
+ * and schema `S` flow through, enabling typed `QueryRow.get` / `QueryRow.mut`
176
+ * access without `as` assertions.
177
+ *
178
+ * @example
179
+ * ```ts
180
+ * // Recommended — infer both N and S:
181
+ * const Pos = defineComponent('Pos', { x: 'f32', y: 'f32' });
182
+ * // ^? Component<'Pos', { x: 'f32'; y: 'f32' }>
183
+ *
184
+ * // Only annotate when you must — and use both type parameters:
185
+ * const Vel: Component<'Vel', { dx: 'f32'; dy: 'f32' }> =
186
+ * defineComponent('Vel', { dx: 'f32', dy: 'f32' });
187
+ * ```
188
+ */
189
+ export type {
190
+ Component,
191
+ ComponentSchema,
192
+ FieldReflection,
193
+ InputShapeOf,
194
+ SchemaOf,
195
+ ShapeOf,
196
+ } from './component';
197
+ /**
198
+ * Declare a component schema. Returns a frozen opaque token with `.name`, `.fields`, `.storage`.
199
+ *
200
+ * @example
201
+ * ```ts
202
+ * const Position = defineComponent('Position', { x: 'f32', y: 'f32' });
203
+ * ```
204
+ */
205
+ export { defineComponent } from './component';
206
+ /**
207
+ * Query descriptor for With/Without archetype filtering.
208
+ *
209
+ * @example
210
+ * ```ts
211
+ * const desc: QueryDescriptor = { with: [Position, Velocity], without: [Static] };
212
+ * ```
213
+ */
214
+ export type {
215
+ Query,
216
+ QueryCreationError,
217
+ QueryDescriptor,
218
+ QueryRow,
219
+ QuerySpan,
220
+ } from './query/query';
221
+ /**
222
+ * ECS-aware refcount-tracked handle store (M3). Owns the lifecycle of every
223
+ * `Handle<T, 'shared'>` derived from `shared<T>` schema fields. The producer
224
+ * (typically AssetRegistry) calls `alloc` once (alloc-grant rc=1); each
225
+ * additional holder retains; release decrements; rc 1 -> 0 drops the slot
226
+ * and publishes structured release evidence. Payload disposal belongs to the
227
+ * renderer/assets/plugin owner; ECS invokes no user callback.
228
+ *
229
+ * D-15: the store manages ONLY user-tier slots (`>= BUILTIN_BASE`); builtin
230
+ * asset payloads are process-static in their authoring package
231
+ * (@forgeax/engine-runtime) and never reference-counted. Passing a builtin
232
+ * slot fails fast with `BuiltinSlotNotOwnedError`.
233
+ *
234
+ * `World` owns one `SharedRefStore` per instance, exposed as
235
+ * `world.sharedRefs`. The schema-field write barrier (retain on spawn / set,
236
+ * release on despawn / removeComponent) short-circuits on builtin slots.
237
+ *
238
+ * @example
239
+ * ```ts
240
+ * const world = new World();
241
+ * const handle = world.allocSharedRef('MaterialAsset', payload);
242
+ * const M = defineComponent('M', { asset: 'shared<MaterialAsset>' });
243
+ * world.spawn({ component: M, data: { asset: handle } });
244
+ * // the SharedRefStore publishes release evidence at rc=0.
245
+ * ```
246
+ */
247
+ export type { SharedRefReleaseEvidence } from './shared-ref-store';
248
+
249
+ /**
250
+ * ECS-managed handle store (M1). Owns the lifecycle of every
251
+ * `Handle<T, 'unique'>` derived from `ref<T>` schema fields - World hooks
252
+ * `despawn` / `removeComponent` / `set` into `release(handle)`.
253
+ *
254
+ * `World` owns one `UniqueRefStore` per instance, constructed eagerly in the
255
+ * `World` constructor (always-on since feat-20260515-string-managed-collapse).
256
+ * Production code rarely touches the store directly - schema-vocab `ref<T>`
257
+ * fields make `world.get(e, C).<refField>` the canonical access path.
258
+ *
259
+ * @example
260
+ * ```ts
261
+ * const Material = defineComponent('Material', { handle: 'unique<MaterialPayload>' });
262
+ * const world = new World();
263
+ * // World owns the UniqueRefStore internally; AI users do not wire it.
264
+ * ```
265
+ */
266
+
267
+ /**
268
+ * Component data bundle for spawn/addComponent: pairs a component token with initial values.
269
+ *
270
+ * @example
271
+ * ```ts
272
+ * const data: ComponentData = { component: Position, data: { x: 1, y: 2 } };
273
+ * ```
274
+ */
275
+ export type { ComponentData } from './world';
276
+ /**
277
+ * Top-level ECS container. Owns entities, archetypes, systems, and resources.
278
+ *
279
+ * @example
280
+ * ```ts
281
+ * const world = new World();
282
+ * const e = world.spawn({ component: Position, data: { x: 0, y: 0 } });
283
+ * world.update();
284
+ * ```
285
+ */
286
+ export { World } from './world';
287
+
288
+ // ────────────────────────────────────────────────────────────────────────────
289
+ // Advanced API — system scheduling, commands, resources, inspection
290
+ // ────────────────────────────────────────────────────────────────────────────
291
+
292
+ /**
293
+ * Deferred command buffer passed to system functions. Queues structural changes
294
+ * (spawn/despawn/addComponent/removeComponent) for end-of-frame flush.
295
+ *
296
+ * @example
297
+ * ```ts
298
+ * fn: (world, results, commands) => {
299
+ * const e = commands.spawn({ component: Bullet, data: { dmg: 10 } });
300
+ * commands.despawn(oldEntity);
301
+ * }
302
+ * ```
303
+ */
304
+ export type { CommandBuffer } from './commands';
305
+ /**
306
+ * System descriptor for `world.addSystem()`. Declares queries, execution function,
307
+ * and optional before/after ordering constraints.
308
+ *
309
+ * @example
310
+ * ```ts
311
+ * world.addSystem(Update, {
312
+ * name: 'movement',
313
+ * queries: [{ with: [Position, Velocity] }],
314
+ * fn: (world, results, commands) => { ... },
315
+ * });
316
+ * ```
317
+ */
318
+ /**
319
+ * SystemSet nominal branded token type. Use {@link defineSystemSet} to create
320
+ * a token; never construct manually. The {@link SystemSet.__forgeaxSystemSet}
321
+ * brand prevents plain-object assignment.
322
+ *
323
+ * @example
324
+ * ```ts
325
+ * import type { SystemSet } from '@forgeax/engine-ecs';
326
+ * const set: SystemSet = defineSystemSet({ name: 'gameplay' });
327
+ * ```
328
+ */
329
+ export type {
330
+ SystemDescriptor,
331
+ SystemHandle,
332
+ SystemSet,
333
+ } from './schedule';
334
+ /**
335
+ * Define a frozen system token. Executable registration is World-local through
336
+ * `world.addSystem`.
337
+ *
338
+ * @example
339
+ * ```ts
340
+ * const Move = defineSystem({
341
+ * name: 'movement',
342
+ * queries: [{ with: [Position, Velocity] }],
343
+ * fn: (world, results) => { ... },
344
+ * });
345
+ * world.addSystem(Move);
346
+ * ```
347
+ */
348
+ /**
349
+ * Define a frozen system-set token. Membership is World-local.
350
+ *
351
+ * @example
352
+ * ```ts
353
+ * const GameplaySet = defineSystemSet({ name: 'gameplay', runIf: (w) => !w.getResource<boolean>('paused') });
354
+ * const OrderedSet = defineSystemSet({ name: 'ordered', chained: true });
355
+ * ```
356
+ */
357
+ export {
358
+ defineSystem,
359
+ defineSystemSet,
360
+ } from './schedule';
361
+
362
+ /**
363
+ * Inspection snapshot returned by `world.inspect()`. Contains entity count,
364
+ * archetype info, active components, system count, and resource keys.
365
+ *
366
+ * @example
367
+ * ```ts
368
+ * const info = world.inspect();
369
+ * console.log(info.entityCount, info.archetypeCount);
370
+ * ```
371
+ */
372
+
373
+ // ────────────────────────────────────────────────────────────────────────────
374
+ // Entity encoding utilities
375
+ // ────────────────────────────────────────────────────────────────────────────
376
+
377
+ /**
378
+ * Encode/decode entity handles for serialization or debugging.
379
+ *
380
+ * @example
381
+ * ```ts
382
+ * const { index, generation } = decodeEntity(entity);
383
+ * const rebuilt = encodeEntity(index, generation);
384
+ * ```
385
+ */
386
+
387
+ // ────────────────────────────────────────────────────────────────────────────
388
+ // Query engine utilities
389
+ // ────────────────────────────────────────────────────────────────────────────
390
+
391
+ // ────────────────────────────────────────────────────────────────────────────
392
+ // Component internals (for advanced use: custom storage, tooling)
393
+ // ────────────────────────────────────────────────────────────────────────────
394
+
395
+ // ────────────────────────────────────────────────────────────────────────────
396
+ // Layer-3 default-value SSOT helper (feat-20260517-spawn-default-fallback / M1)
397
+ // ────────────────────────────────────────────────────────────────────────────
398
+
399
+ // ────────────────────────────────────────────────────────────────────────────
400
+
401
+ // ────────────────────────────────────────────────────────────────────────────
402
+ // Constants
403
+ // ────────────────────────────────────────────────────────────────────────────
404
+
405
+ // Component policy and metadata are an explicit schema projection, not fields
406
+ // on the token or a process-global registry. Owners that need these facts must
407
+ // receive the token's projection through this seam.
408
+ export { componentDefinition } from './component-schema';
409
+ export { ENTITY_MAX_GENERATION, ENTITY_MAX_INDEX, ENTITY_NULL_RAW } from './entity-handle';
410
+
411
+ // w8: Inspector contributor (registerEcsInspector + RegisterEcsInspectorResult)
412
+ // deleted — routing layer (Registry / sandbox) is removed; eval is the sole
413
+ // command channel.
414
+ // w9: ECS_MUTATING_METHODS export deleted — sandbox dismantled; mutating-methods.ts removed.
@@ -0,0 +1,35 @@
1
+ import { Context, type Plugin } from '@forgeax/engine-plugin';
2
+
3
+ import type { World } from './world';
4
+
5
+ declare module '@forgeax/engine-plugin' {
6
+ interface EngineContextServices {
7
+ world: World;
8
+ }
9
+ }
10
+
11
+ export function worldPlugin(world: World): Plugin {
12
+ return {
13
+ name: 'world',
14
+ provide: 'world',
15
+ apply(ctx) {
16
+ ctx.provide('world', world);
17
+ },
18
+ };
19
+ }
20
+
21
+ /** Create one Cordis realm whose root service is the ECS World. */
22
+ export async function createWorldContext(
23
+ world: World,
24
+ plugins: readonly Plugin[] = [],
25
+ ): Promise<Context> {
26
+ const ctx = new Context();
27
+ try {
28
+ await ctx.plugin(worldPlugin(world));
29
+ for (const plugin of plugins) await ctx.plugin(plugin);
30
+ return ctx;
31
+ } catch (error) {
32
+ await ctx.fiber.dispose();
33
+ throw error;
34
+ }
35
+ }