@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
@@ -0,0 +1,260 @@
1
+ import { execFileSync } from 'node:child_process';
2
+ import os from 'node:os';
3
+ import {
4
+ type Component,
5
+ defineComponent,
6
+ defineRelationship,
7
+ type EntityHandle,
8
+ Time,
9
+ Update,
10
+ World,
11
+ } from '@forgeax/engine-ecs';
12
+ import { describe, expect, it } from 'vitest';
13
+
14
+ const { source: ChildOf, target: Children } = defineRelationship({
15
+ sourceName: 'M0PerfChildOf',
16
+ sourceField: 'parent',
17
+ targetName: 'M0PerfChildren',
18
+ targetField: 'entities',
19
+ exclusive: true,
20
+ linkedSpawn: true,
21
+ });
22
+
23
+ const ENTITY_COUNT = 100_000;
24
+ const ROOT_COUNT = 1_000;
25
+ const COMMAND_COUNT = 10_000;
26
+ const CLOCK_READ_COUNT = 10_000_000;
27
+ const SAMPLE_ROUNDS = 3;
28
+
29
+ type Sample = {
30
+ readonly name: string;
31
+ readonly samplesMs: number[];
32
+ readonly medianMs: number;
33
+ readonly p95Ms: number;
34
+ readonly ci95Ms: readonly [number, number];
35
+ readonly workload: Record<string, number>;
36
+ };
37
+
38
+ function percentile(samples: readonly number[], quantile: number): number {
39
+ const ordered = [...samples].sort((a, b) => a - b);
40
+ const index = Math.min(ordered.length - 1, Math.ceil(ordered.length * quantile) - 1);
41
+ return ordered[index] ?? 0;
42
+ }
43
+
44
+ function summarize(name: string, samplesMs: number[], workload: Record<string, number>): Sample {
45
+ const mean = samplesMs.reduce((sum, sample) => sum + sample, 0) / samplesMs.length;
46
+ const variance =
47
+ samplesMs.reduce((sum, sample) => sum + (sample - mean) ** 2, 0) /
48
+ Math.max(1, samplesMs.length - 1);
49
+ const margin = 1.96 * Math.sqrt(variance / samplesMs.length);
50
+ return {
51
+ name,
52
+ samplesMs,
53
+ medianMs: percentile(samplesMs, 0.5),
54
+ p95Ms: percentile(samplesMs, 0.95),
55
+ ci95Ms: [mean - margin, mean + margin],
56
+ workload,
57
+ };
58
+ }
59
+
60
+ function measure(name: string, run: () => number, workload: Record<string, number>): Sample {
61
+ const samples: number[] = [];
62
+ for (let round = 0; round < SAMPLE_ROUNDS; round += 1) {
63
+ const start = performance.now();
64
+ const result = run();
65
+ samples.push(performance.now() - start);
66
+ if (result < 0) throw new Error('M0 benchmark sink underflow');
67
+ }
68
+ return summarize(name, samples, workload);
69
+ }
70
+
71
+ function createHierarchy(): {
72
+ world: World;
73
+ roots: EntityHandle[];
74
+ entities: EntityHandle[];
75
+ value: Component;
76
+ } {
77
+ const Value = defineComponent('M0PerfValue', { value: 'u32' });
78
+ const children = Children as unknown as Component;
79
+ const childOf = ChildOf as unknown as Component;
80
+ const world = new World();
81
+ const roots: EntityHandle[] = [];
82
+ for (let index = 0; index < ROOT_COUNT; index += 1) {
83
+ roots.push(
84
+ world
85
+ .spawn(
86
+ { component: children, data: { entities: [] } },
87
+ { component: Value, data: { value: index } },
88
+ )
89
+ .unwrap(),
90
+ );
91
+ }
92
+ const entities: EntityHandle[] = [...roots];
93
+ for (let index = ROOT_COUNT; index < ENTITY_COUNT; index += 1) {
94
+ const parent = roots[index % ROOT_COUNT];
95
+ if (parent === undefined) throw new Error('M0 benchmark root missing');
96
+ entities.push(
97
+ world
98
+ .spawn(
99
+ { component: childOf, data: { parent } },
100
+ { component: Value, data: { value: index } },
101
+ )
102
+ .unwrap(),
103
+ );
104
+ }
105
+ return { world, roots, entities, value: Value };
106
+ }
107
+
108
+ function createSubtree(): { world: World; root: EntityHandle } {
109
+ const world = new World();
110
+ const root = world
111
+ .spawn({ component: Children as unknown as Component, data: { entities: [] } })
112
+ .unwrap();
113
+ for (let index = 0; index < 10_000; index += 1) {
114
+ world.spawn({ component: ChildOf as unknown as Component, data: { parent: root } }).unwrap();
115
+ }
116
+ return { world, root };
117
+ }
118
+
119
+ describe('M0 ECS reduction workload characterization', () => {
120
+ it('records fixed workload statistics and no comparison verdict', { timeout: 300_000 }, () => {
121
+ const hierarchy = createHierarchy();
122
+ const valueQuery = hierarchy.world.query({ read: [hierarchy.value] });
123
+ expect(valueQuery.ok).toBe(true);
124
+ if (!valueQuery.ok) throw new Error('M0 benchmark query failed');
125
+ const samples: Sample[] = [];
126
+ samples.push(
127
+ measure(
128
+ 'row-span-iteration',
129
+ () => {
130
+ let rowSum = 0;
131
+ for (const row of valueQuery.value)
132
+ rowSum += Number((row.get(hierarchy.value) as { value: number }).value);
133
+ let spanSum = 0;
134
+ for (const span of valueQuery.value.spans().unwrap()) {
135
+ const values = (span.get(hierarchy.value) as unknown as { value: ArrayLike<number> })
136
+ .value;
137
+ for (let index = 0; index < span.length; index += 1) spanSum += values[index] ?? 0;
138
+ }
139
+ return rowSum + spanSum;
140
+ },
141
+ { entities: ENTITY_COUNT, roots: ROOT_COUNT },
142
+ ),
143
+ );
144
+ samples.push(
145
+ measure(
146
+ 'children-iteration',
147
+ () =>
148
+ hierarchy.roots.reduce(
149
+ (sum, root) =>
150
+ sum +
151
+ ((
152
+ hierarchy.world.get(root, Children as unknown as Component).unwrap() as unknown as {
153
+ entities: ArrayLike<number>;
154
+ }
155
+ ).entities.length ?? 0),
156
+ 0,
157
+ ),
158
+ { entities: ENTITY_COUNT, roots: ROOT_COUNT },
159
+ ),
160
+ );
161
+ samples.push(
162
+ measure(
163
+ 'continuous-reparent',
164
+ () => {
165
+ let sum = 0;
166
+ for (let index = ROOT_COUNT; index < ROOT_COUNT * 2; index += 1) {
167
+ const entity = hierarchy.entities[index];
168
+ const parent = hierarchy.roots[(index + 1) % ROOT_COUNT];
169
+ if (entity === undefined || parent === undefined) continue;
170
+ sum += Number(
171
+ hierarchy.world.addComponent(entity, {
172
+ component: ChildOf as unknown as Component,
173
+ data: { parent },
174
+ }).ok,
175
+ );
176
+ }
177
+ return sum;
178
+ },
179
+ { entities: ENTITY_COUNT, roots: ROOT_COUNT, operations: ROOT_COUNT },
180
+ ),
181
+ );
182
+ samples.push(
183
+ measure(
184
+ 'subtree-despawn',
185
+ () => {
186
+ const subtree = createSubtree();
187
+ return Number(subtree.world.despawn(subtree.root).ok);
188
+ },
189
+ { subtreeEntities: 10_001 },
190
+ ),
191
+ );
192
+ samples.push(
193
+ measure(
194
+ 'mixed-command-batch',
195
+ () => {
196
+ const world = new World();
197
+ const Marker = defineComponent('M0PerfCommandMarker', {});
198
+ world.addSystem(Update, {
199
+ name: 'm0-command-batch',
200
+ queries: [],
201
+ fn: (_world, _queries, commands) => {
202
+ for (let index = 0; index < COMMAND_COUNT; index += 1)
203
+ commands.spawn({ component: Marker, data: {} });
204
+ },
205
+ });
206
+ return Number(world.update(0).ok);
207
+ },
208
+ { commands: COMMAND_COUNT },
209
+ ),
210
+ );
211
+ samples.push(
212
+ measure(
213
+ 'clock-getter',
214
+ () => {
215
+ let sink = 0;
216
+ const time = hierarchy.world.getResource(Time);
217
+ for (let index = 0; index < CLOCK_READ_COUNT; index += 1) sink += time.elapsed;
218
+ return sink;
219
+ },
220
+ { reads: CLOCK_READ_COUNT },
221
+ ),
222
+ );
223
+ samples.push(
224
+ measure(
225
+ 'shared-ref-churn',
226
+ () => {
227
+ let sink = 0;
228
+ for (let index = 0; index < COMMAND_COUNT; index += 1) {
229
+ const handle = hierarchy.world.allocSharedRef('M0PerfAsset', { index });
230
+ sink += Number(hierarchy.world.sharedRefs.release(handle).ok);
231
+ }
232
+ return sink;
233
+ },
234
+ { handles: COMMAND_COUNT },
235
+ ),
236
+ );
237
+ const revision = execFileSync('git', ['rev-parse', 'HEAD'], {
238
+ cwd: process.cwd(),
239
+ encoding: 'utf8',
240
+ }).trim();
241
+ process.stdout.write(
242
+ `${JSON.stringify({
243
+ schemaVersion: 1,
244
+ baseline: 'M0',
245
+ comparison: null,
246
+ environment: {
247
+ node: process.version,
248
+ platform: process.platform,
249
+ arch: process.arch,
250
+ cpu: os.cpus()[0]?.model,
251
+ revision,
252
+ },
253
+ samples,
254
+ stopRule: 'same-semantics p95 regression greater than 5 percent requires human decision',
255
+ })}\n`,
256
+ );
257
+ expect(samples).toHaveLength(7);
258
+ expect(samples.every((sample) => sample.p95Ms >= sample.medianMs)).toBe(true);
259
+ });
260
+ });
@@ -0,0 +1,42 @@
1
+ // ecs-error-code-31.test-d - owner error union boundary type-test.
2
+ //
3
+ // Coverage (plan-strategy D-9):
4
+ // - EcsErrorCode union has gained the 31st member 'scene-override-type-
5
+ // mismatch' (literal D-9 string locked).
6
+ // - The new literal is assignable to EcsErrorCode at the type layer
7
+ // (positive assertion). Cross-feat hardening: the literal must NOT
8
+ // be quietly aliased to a different existing member.
9
+ //
10
+ // EcsErrorDetail evolution for this code (detail shape `{ code, comp,
11
+ // field, expectedType, actualType }`) is exercised by M2 unit tests
12
+ // (requirements §Edge cases table last row, reviewer Issue 1) — out
13
+ // of scope here; this file only locks the EcsErrorCode union literal.
14
+ //
15
+ // TDD red signal: until w9 widens EcsErrorCode to 31 members, the
16
+ // `toExtend<EcsErrorCode>` assertion produces TS2344. w9 turns this
17
+ // red into green.
18
+ //
19
+ // Note: plan-tasks.json originally listed the targetFile under
20
+ // packages/types; @forgeax/engine-types has zero engine-ecs dep
21
+ // (math-free + ecs-free per AGENTS.md). The test must live under the
22
+ // ecs package to import EcsErrorCode locally — recorded in the M1
23
+ // report as filesOutsideTargets with reason.
24
+ //
25
+ // Charter mapping: proposition 4 (explicit failure: type-level union
26
+ // widening surfaced at compile-time, not via ad-hoc string literal
27
+ // matching).
28
+
29
+ import { describe, expectTypeOf, it } from 'vitest';
30
+ import type { EcsErrorCode } from '../errors';
31
+
32
+ describe('owner error union boundary', () => {
33
+ it("keeps 'scene-override-type-mismatch' out of EcsErrorCode", () => {
34
+ expectTypeOf<'scene-override-type-mismatch'>().not.toExtend<EcsErrorCode>();
35
+ });
36
+ });
37
+
38
+ describe('EcsErrorCode enum write validation', () => {
39
+ it("includes the 'component-field-invalid-value' literal", () => {
40
+ expectTypeOf<'component-field-invalid-value'>().toExtend<EcsErrorCode>();
41
+ });
42
+ });
@@ -0,0 +1,37 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { Disabled, defineComponent, World } from '../index';
3
+ import type { Query } from '../query/query';
4
+
5
+ const Target = defineComponent('EntityDisablingTarget', { value: 'u32' });
6
+
7
+ function count(query: Query): number {
8
+ return [...query].length;
9
+ }
10
+
11
+ describe('Disabled default query filter', () => {
12
+ it('excludes disabled entities while explicit Disabled queries include them', () => {
13
+ const world = new World();
14
+ world.spawn({ component: Target, data: { value: 1 } }).unwrap();
15
+ world
16
+ .spawn({ component: Target, data: { value: 2 } }, { component: Disabled, data: {} })
17
+ .unwrap();
18
+
19
+ const active = world.query({ read: [Target] }).unwrap();
20
+ const disabled = world.query({ read: [Target], with: [Disabled] }).unwrap();
21
+
22
+ expect(count(active)).toBe(1);
23
+ expect(count(disabled)).toBe(1);
24
+ });
25
+
26
+ it('recomputes the default filter when an entity is disabled and re-enabled', () => {
27
+ const world = new World();
28
+ const entity = world.spawn({ component: Target, data: { value: 1 } }).unwrap();
29
+ const active = world.query({ read: [Target] }).unwrap();
30
+
31
+ expect(count(active)).toBe(1);
32
+ world.addComponent(entity, { component: Disabled, data: {} }).unwrap();
33
+ expect(count(active)).toBe(0);
34
+ world.removeComponent(entity, Disabled).unwrap();
35
+ expect(count(active)).toBe(1);
36
+ });
37
+ });
@@ -0,0 +1,126 @@
1
+ // Entity handle codec parity unit tests (w3).
2
+ //
3
+ // Runtime value assertions verifying bit-pattern equivalence between
4
+ // entity-handle functions and the shared codec in @forgeax/engine-types.
5
+ // These are the AC-14 regression baseline -- encodeEntity must produce
6
+ // identical u32 values to codec.pack, and decode/entityIndex/entityGeneration
7
+ // must match codec unpack results for all gen values including gen>=128
8
+ // (>>>0 anti-ToInt32 guard, R5 from plan-strategy).
9
+ //
10
+ // This file holds runtime assertions; the plan targetFiles listed
11
+ // .test-d.ts which are typecheck-only and cannot execute these checks.
12
+
13
+ import { MAX_GEN, MAX_SLOT, pack, unpackGen, unpackSlot } from '@forgeax/engine-types';
14
+ import { describe, expect, it } from 'vitest';
15
+ import {
16
+ decodeEntity,
17
+ ENTITY_MAX_GENERATION,
18
+ ENTITY_MAX_INDEX,
19
+ type EntityHandle,
20
+ encodeEntity,
21
+ entityGeneration,
22
+ entityIndex,
23
+ } from '../entity-handle';
24
+
25
+ describe('[w3] Entity codec parity -- constants', () => {
26
+ it('ENTITY_MAX_INDEX === MAX_SLOT', () => {
27
+ expect(ENTITY_MAX_INDEX).toBe(MAX_SLOT);
28
+ });
29
+
30
+ it('ENTITY_MAX_GENERATION === MAX_GEN', () => {
31
+ expect(ENTITY_MAX_GENERATION).toBe(MAX_GEN);
32
+ });
33
+ });
34
+
35
+ describe('[w3] Entity codec parity -- encodeEntity equals codec.pack', () => {
36
+ const SLOTS = [0, 1, 5, 42, 1023, 1024, 16777215] as const;
37
+
38
+ // gen=0: pack(slot,0)===slot invariant (D-8)
39
+ it('encodeEntity(i, 0) === pack(i, 0) for sampled slot values', () => {
40
+ for (const slot of SLOTS) {
41
+ expect(encodeEntity(slot, 0)).toBe(pack(slot, 0));
42
+ }
43
+ });
44
+
45
+ // gen=128: the >>>0 guard is load-bearing (R5)
46
+ it('encodeEntity(i, 128) === pack(i, 128) -- gen>=128 ToInt32 guard', () => {
47
+ for (const slot of SLOTS) {
48
+ expect(encodeEntity(slot, 128)).toBe(pack(slot, 128));
49
+ }
50
+ });
51
+
52
+ // gen=255: edge case, max generation
53
+ it('encodeEntity(i, 255) === pack(i, 255) -- max gen edge', () => {
54
+ for (const slot of SLOTS) {
55
+ expect(encodeEntity(slot, 255)).toBe(pack(slot, 255));
56
+ }
57
+ });
58
+
59
+ // gen=64: mid-range smoke test
60
+ it('encodeEntity(i, 64) === pack(i, 64) -- mid-range gen', () => {
61
+ for (const slot of SLOTS) {
62
+ expect(encodeEntity(slot, 64)).toBe(pack(slot, 64));
63
+ }
64
+ });
65
+
66
+ // Mixed gen values across different slots
67
+ it('encodeEntity(s, g) === pack(s, g) for cross-product of {0,1,42,1024,16777215} x {0,5,17,128,255}', () => {
68
+ const slots = [0, 1, 42, 1024, 16777215];
69
+ const gens = [0, 5, 17, 128, 255];
70
+ for (const slot of slots) {
71
+ for (const gen of gens) {
72
+ expect(encodeEntity(slot, gen)).toBe(pack(slot, gen));
73
+ }
74
+ }
75
+ });
76
+ });
77
+
78
+ describe('[w3] Entity codec parity -- decode functions', () => {
79
+ const CASES: [number, number][] = [
80
+ [0, 0],
81
+ [1, 0],
82
+ [42, 5],
83
+ [1024, 128],
84
+ [16777215, 255],
85
+ [0, 64],
86
+ [1, 255],
87
+ [16777215, 0],
88
+ [1023, 17],
89
+ ];
90
+
91
+ it('decodeEntity(pack(s, g)) returns { index: s, generation: g }', () => {
92
+ for (const [slot, gen] of CASES) {
93
+ const raw = pack(slot, gen) as EntityHandle;
94
+ const { index, generation } = decodeEntity(raw);
95
+ expect(index).toBe(slot);
96
+ expect(generation).toBe(gen);
97
+ }
98
+ });
99
+
100
+ it('entityIndex(pack(s, g)) === unpackSlot(pack(s, g))', () => {
101
+ for (const [slot, gen] of CASES) {
102
+ const raw = pack(slot, gen) as EntityHandle;
103
+ expect(entityIndex(raw)).toBe(unpackSlot(raw));
104
+ }
105
+ });
106
+
107
+ it('entityGeneration(pack(s, g)) === unpackGen(pack(s, g))', () => {
108
+ for (const [slot, gen] of CASES) {
109
+ const raw = pack(slot, gen) as EntityHandle;
110
+ expect(entityGeneration(raw)).toBe(unpackGen(raw));
111
+ }
112
+ });
113
+
114
+ // Full round-trip: encodeEntity -> entityIndex/entityGeneration
115
+ it('entityIndex(encodeEntity(s, g)) === s', () => {
116
+ for (const [slot, gen] of CASES) {
117
+ expect(entityIndex(encodeEntity(slot, gen))).toBe(slot);
118
+ }
119
+ });
120
+
121
+ it('entityGeneration(encodeEntity(s, g)) === g', () => {
122
+ for (const [slot, gen] of CASES) {
123
+ expect(entityGeneration(encodeEntity(slot, gen))).toBe(gen);
124
+ }
125
+ });
126
+ });