@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,123 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { defineComponent } from '../component';
3
+ import {
4
+ defineSharedKernel,
5
+ SHARED_KERNEL_EXECUTOR_RESOURCE_KEY,
6
+ type SharedKernelExecutor,
7
+ } from '../execution/shared-kernel';
8
+ import type { QuerySpan } from '../query/query';
9
+ import { Update } from '../schedule-token';
10
+ import { World } from '../world';
11
+
12
+ const Position = defineComponent('ExecutionConflictBoundaryPosition', { x: 'f32' });
13
+ const StructuralMarker = defineComponent('ExecutionConflictBoundaryMarker', {});
14
+
15
+ function readPosition(spans: readonly QuerySpan[]): void {
16
+ for (const span of spans) void span.get(Position).x[0];
17
+ }
18
+
19
+ function incrementPosition(spans: readonly QuerySpan[]): void {
20
+ for (const span of spans) {
21
+ const values = span.mut(Position).x;
22
+ for (let index = 0; index < span.length; index += 1) values[index] = (values[index] ?? 0) + 1;
23
+ }
24
+ }
25
+
26
+ function doublePosition(spans: readonly QuerySpan[]): void {
27
+ for (const span of spans) {
28
+ const values = span.mut(Position).x;
29
+ for (let index = 0; index < span.length; index += 1) values[index] = (values[index] ?? 0) * 2;
30
+ }
31
+ }
32
+
33
+ type ConflictCase = 'read-read' | 'read-write' | 'write-write' | 'structure';
34
+
35
+ function runCase(
36
+ kind: ConflictCase,
37
+ shared: boolean,
38
+ ): { readonly x: number; readonly trace: string[] } {
39
+ const world = new World();
40
+ const trace: string[] = [];
41
+ let dispatchActive = false;
42
+ if (shared) {
43
+ const executor: SharedKernelExecutor = {
44
+ execute(kernel, spans) {
45
+ expect(dispatchActive).toBe(false);
46
+ dispatchActive = true;
47
+ trace.push(kernel.name);
48
+ kernel.run(spans.map(({ span }) => span));
49
+ dispatchActive = false;
50
+ return {
51
+ mode: 'shared',
52
+ dispatched: spans.length,
53
+ completed: spans.length,
54
+ waitMs: 0,
55
+ };
56
+ },
57
+ };
58
+ world.insertResource(SHARED_KERNEL_EXECUTOR_RESOURCE_KEY, executor);
59
+ }
60
+ world.spawn({ component: Position, data: { x: 1 } }).unwrap();
61
+
62
+ const first = defineSharedKernel(import.meta.url, {
63
+ name: `${kind}-first`,
64
+ minimumRows: 1,
65
+ queries: [
66
+ kind === 'read-read' || kind === 'read-write' ? { read: [Position] } : { write: [Position] },
67
+ ],
68
+ run: kind === 'read-read' || kind === 'read-write' ? readPosition : incrementPosition,
69
+ before: kind === 'structure' ? ['structure'] : [`${kind}-second`],
70
+ });
71
+ const second = defineSharedKernel(import.meta.url, {
72
+ name: `${kind}-second`,
73
+ minimumRows: 1,
74
+ queries: [kind === 'read-read' ? { read: [Position] } : { write: [Position] }],
75
+ run:
76
+ kind === 'read-read'
77
+ ? readPosition
78
+ : kind === 'read-write'
79
+ ? incrementPosition
80
+ : doublePosition,
81
+ ...(kind === 'structure' ? { after: ['structure'] } : {}),
82
+ });
83
+ world.addSystem(Update, first).unwrap();
84
+ if (kind === 'structure') {
85
+ world
86
+ .addSystem(Update, {
87
+ name: 'structure',
88
+ queries: [],
89
+ before: [second.name],
90
+ fn: (_world, _queries, commands) => {
91
+ trace.push('structure');
92
+ commands.spawn({ component: StructuralMarker, data: {} });
93
+ },
94
+ })
95
+ .unwrap();
96
+ }
97
+ world.addSystem(Update, second).unwrap();
98
+
99
+ world.update(0).unwrap();
100
+ const [row] = world.query({ read: [Position] }).unwrap();
101
+ return { x: row?.get(Position).x ?? Number.NaN, trace };
102
+ }
103
+
104
+ describe('SharedKernel conflict boundaries', () => {
105
+ it.each<ConflictCase>([
106
+ 'read-read',
107
+ 'read-write',
108
+ 'write-write',
109
+ 'structure',
110
+ ])('keeps %s deterministic and serial-equivalent', (kind) => {
111
+ const serial = runCase(kind, false);
112
+ const shared = runCase(kind, true);
113
+
114
+ expect(shared.x).toBe(serial.x);
115
+ expect(shared.trace.filter((entry) => entry !== 'structure')).toEqual([
116
+ `${kind}-first`,
117
+ `${kind}-second`,
118
+ ]);
119
+ if (kind === 'structure') {
120
+ expect(shared.trace).toEqual(['structure-first', 'structure', 'structure-second']);
121
+ }
122
+ });
123
+ });
@@ -0,0 +1,40 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { defineComponent } from '../component';
3
+ import { World } from '../world';
4
+
5
+ const Position = defineComponent('ExecutionSharedStoragePosition', { x: 'f32', y: 'f32' });
6
+
7
+ describe('shared World storage', () => {
8
+ it('allocates dense numeric QuerySpan fields on SAB and preserves them through growth', () => {
9
+ const world = new World({ storage: 'shared' });
10
+ for (let index = 0; index < 80; index += 1) {
11
+ world.spawn({ component: Position, data: { x: index, y: -index } }).unwrap();
12
+ }
13
+ const spans = [
14
+ ...world
15
+ .query({ write: [Position] })
16
+ .unwrap()
17
+ .spans()
18
+ .unwrap(),
19
+ ];
20
+ expect(spans.length).toBeGreaterThan(0);
21
+ for (const span of spans) {
22
+ expect(span.mut(Position).x.buffer).toBeInstanceOf(SharedArrayBuffer);
23
+ expect(span.mut(Position).y.buffer).toBeInstanceOf(SharedArrayBuffer);
24
+ }
25
+ expect(spans.reduce((sum, span) => sum + span.length, 0)).toBe(80);
26
+ });
27
+
28
+ it('keeps default World columns local', () => {
29
+ const world = new World();
30
+ world.spawn({ component: Position, data: { x: 1, y: 2 } }).unwrap();
31
+ const span = [
32
+ ...world
33
+ .query({ read: [Position] })
34
+ .unwrap()
35
+ .spans()
36
+ .unwrap(),
37
+ ][0];
38
+ expect(span?.get(Position).x.buffer).toBeInstanceOf(ArrayBuffer);
39
+ });
40
+ });
@@ -0,0 +1,275 @@
1
+ // m3-profile-rejection-test — portable value validation / profile boundary tests.
2
+ //
3
+ // Validates that the shared kernel rejects fully-transient component selections
4
+ // and non-portable field types (unique/shared/legacy refs) with structured errors
5
+ // while portable entity fields are accepted. No network metadata in schemas.
6
+
7
+ import { describe, expect, it } from 'vitest';
8
+ import { type Component, componentSchema, defineComponent } from '../component';
9
+ import {
10
+ isComponentFullyTransient,
11
+ isComponentPortable,
12
+ isFieldPortable,
13
+ validateProfileComponents,
14
+ } from '../externalization/index';
15
+
16
+ // ── Test components ──────────────────────────────────────────────────────────
17
+
18
+ const Portable = defineComponent('TestPortable', {
19
+ health: { type: 'u32', default: 100 },
20
+ name: { type: 'string', default: '' },
21
+ pos: { type: 'array<f32, 3>', default: [0, 0, 0] },
22
+ // biome-ignore lint/suspicious/noExplicitAny: test component with array<f32,3> default shape; layer-3 defaults fill the correct shape but the TS type for the literal is a branded handle
23
+ } as any) as Component;
24
+
25
+ const WithEntity = defineComponent('TestWithEntity', {
26
+ target: { type: 'entity' },
27
+ friends: { type: 'array<entity>', default: [] },
28
+ });
29
+
30
+ const FullyTransient = defineComponent(
31
+ 'TestFullyTransient',
32
+ {
33
+ x: { type: 'f32', default: 0 },
34
+ },
35
+ { transient: true },
36
+ );
37
+
38
+ const AllFieldsTransient = defineComponent('TestAllFieldsTransient', {
39
+ derived1: { type: 'f32', default: 0, transient: true },
40
+ derived2: { type: 'f32', default: 0, transient: true },
41
+ });
42
+
43
+ const UniqueRef = defineComponent('TestUniqueRef', {
44
+ resource: { type: 'unique<SomeResource>' },
45
+ });
46
+
47
+ const SharedRef = defineComponent('TestSharedRef', {
48
+ asset: { type: 'shared<SomeAsset>' },
49
+ });
50
+
51
+ const SharedArrayRef = defineComponent('TestSharedArrayRef', {
52
+ assets: { type: 'array<shared<SomeAsset>>' },
53
+ });
54
+
55
+ const LegacyRef = defineComponent('TestLegacyRef', {
56
+ node: { type: 'ref' },
57
+ });
58
+
59
+ const MixedPortable = defineComponent('TestMixedPortable', {
60
+ health: { type: 'u32', default: 100 },
61
+ asset: { type: 'shared<SomeAsset>' },
62
+ });
63
+
64
+ // ── Tests ───────────────────────────────────────────────────────────────────
65
+
66
+ describe('m3 — portable value validation: fully transient component rejection', () => {
67
+ it('(a) component-level transient is detected as fully transient', () => {
68
+ const result = validateProfileComponents([FullyTransient as Component]);
69
+ expect(result.valid).toBe(false);
70
+ expect(result.errors.length).toBe(1);
71
+ expect(result.errors[0]?.code).toBe('component-fully-transient');
72
+ expect(result.errors[0]?.component).toBe('TestFullyTransient');
73
+ expect(result.errors[0]?.expected).toBeTruthy();
74
+ expect(result.errors[0]?.hint).toBeTruthy();
75
+ });
76
+
77
+ it('(b) all-fields-transient component is detected as fully transient', () => {
78
+ const result = validateProfileComponents([AllFieldsTransient as Component]);
79
+ expect(result.valid).toBe(false);
80
+ expect(result.errors.length).toBe(1);
81
+ expect(result.errors[0]?.code).toBe('component-fully-transient');
82
+ expect(result.errors[0]?.component).toBe('TestAllFieldsTransient');
83
+ });
84
+
85
+ it('(c) isComponentFullyTransient returns true for component-level transient', () => {
86
+ expect(isComponentFullyTransient(FullyTransient as Component)).toBe(true);
87
+ });
88
+
89
+ it('(d) isComponentFullyTransient returns true for all-fields-transient', () => {
90
+ expect(isComponentFullyTransient(AllFieldsTransient as Component)).toBe(true);
91
+ });
92
+
93
+ it('(e) isComponentFullyTransient returns false for component with at least one portable field', () => {
94
+ expect(isComponentFullyTransient(Portable as Component)).toBe(false);
95
+ });
96
+ });
97
+
98
+ describe('m3 — portable value validation: non-portable field type rejection', () => {
99
+ it('(a) unique<T> field type is not portable', () => {
100
+ expect(isFieldPortable('unique<SomeResource>')).toBe(false);
101
+ });
102
+
103
+ it('(b) shared<T> field type is not portable', () => {
104
+ expect(isFieldPortable('shared<SomeAsset>')).toBe(false);
105
+ });
106
+
107
+ it('(c) legacy `ref` field type is not portable', () => {
108
+ expect(isFieldPortable('ref')).toBe(false);
109
+ });
110
+
111
+ it('(d) numeric scalar (f32) is portable', () => {
112
+ expect(isFieldPortable('f32')).toBe(true);
113
+ });
114
+
115
+ it('(e) string is portable', () => {
116
+ expect(isFieldPortable('string')).toBe(true);
117
+ });
118
+
119
+ it('(f) entity is portable', () => {
120
+ expect(isFieldPortable('entity')).toBe(true);
121
+ });
122
+
123
+ it('(g) array<entity> is portable', () => {
124
+ expect(isFieldPortable('array<entity>')).toBe(true);
125
+ });
126
+
127
+ it('(h) array<f32> is portable', () => {
128
+ expect(isFieldPortable('array<f32>')).toBe(true);
129
+ });
130
+
131
+ it('(i) array<f32,3> is portable', () => {
132
+ expect(isFieldPortable('array<f32, 3>')).toBe(true);
133
+ });
134
+
135
+ it('(j) array<shared<T>> is not portable when its elements are shared refs', () => {
136
+ expect(isFieldPortable('array<shared<SomeAsset>>')).toBe(false);
137
+ expect(isFieldPortable('array<shared<SomeAsset>, 2>')).toBe(false);
138
+ });
139
+
140
+ it('(k) bool is portable', () => {
141
+ expect(isFieldPortable('bool')).toBe(true);
142
+ });
143
+
144
+ it('(l) enum is portable', () => {
145
+ expect(isFieldPortable('enum')).toBe(true);
146
+ });
147
+
148
+ it('(m) buffer is portable', () => {
149
+ expect(isFieldPortable('buffer')).toBe(true);
150
+ });
151
+
152
+ it('(n) buffer<N> is portable', () => {
153
+ expect(isFieldPortable('buffer<256>')).toBe(true);
154
+ });
155
+ });
156
+
157
+ describe('m3 — portable value validation: validateProfileComponents rejects non-portable', () => {
158
+ it('(a) component with unique<T> field is rejected', () => {
159
+ const result = validateProfileComponents([UniqueRef as Component]);
160
+ expect(result.valid).toBe(false);
161
+ expect(result.errors.length).toBe(1);
162
+ expect(result.errors[0]?.code).toBe('field-not-portable');
163
+ expect(result.errors[0]?.component).toBe('TestUniqueRef');
164
+ expect(result.errors[0]?.field).toBe('resource');
165
+ expect(result.errors[0]?.fieldType).toBe('unique<SomeResource>');
166
+ });
167
+
168
+ it('(b) component with shared<T> field is rejected', () => {
169
+ const result = validateProfileComponents([SharedRef as Component]);
170
+ expect(result.valid).toBe(false);
171
+ expect(result.errors.length).toBe(1);
172
+ expect(result.errors[0]?.code).toBe('field-not-portable');
173
+ expect(result.errors[0]?.component).toBe('TestSharedRef');
174
+ expect(result.errors[0]?.field).toBe('asset');
175
+ });
176
+
177
+ it('(c) component with array<shared<T>> field is rejected', () => {
178
+ const result = validateProfileComponents([SharedArrayRef as Component]);
179
+ expect(result.valid).toBe(false);
180
+ expect(result.errors.length).toBe(1);
181
+ expect(result.errors[0]?.code).toBe('field-not-portable');
182
+ expect(result.errors[0]?.component).toBe('TestSharedArrayRef');
183
+ expect(result.errors[0]?.field).toBe('assets');
184
+ });
185
+
186
+ it('(d) component with legacy `ref` field is rejected', () => {
187
+ const result = validateProfileComponents([LegacyRef as Component]);
188
+ expect(result.valid).toBe(false);
189
+ expect(result.errors.length).toBe(1);
190
+ expect(result.errors[0]?.code).toBe('field-not-portable');
191
+ expect(result.errors[0]?.component).toBe('TestLegacyRef');
192
+ expect(result.errors[0]?.field).toBe('node');
193
+ });
194
+
195
+ it('(e) component with mixed portable and non-portable fields is rejected', () => {
196
+ // MixedPortable has health (u32, portable) and asset (shared<>, non-portable)
197
+ const result = validateProfileComponents([MixedPortable as Component]);
198
+ expect(result.valid).toBe(false);
199
+ expect(result.errors.length).toBe(1);
200
+ expect(result.errors[0]?.code).toBe('field-not-portable');
201
+ expect(result.errors[0]?.field).toBe('asset');
202
+ });
203
+
204
+ it('(f) fully portable component is accepted', () => {
205
+ const result = validateProfileComponents([Portable as Component, WithEntity as Component]);
206
+ expect(result.valid).toBe(true);
207
+ expect(result.errors.length).toBe(0);
208
+ });
209
+
210
+ it('(g) each error has structured .expected and .hint', () => {
211
+ const result = validateProfileComponents([UniqueRef as Component]);
212
+ expect(result.errors[0]?.expected).toBeTruthy();
213
+ expect(result.errors[0]?.hint).toBeTruthy();
214
+ expect(typeof result.errors[0]?.expected).toBe('string');
215
+ expect(typeof result.errors[0]?.hint).toBe('string');
216
+ });
217
+ });
218
+
219
+ describe('m3 — isComponentPortable', () => {
220
+ it('(a) component with at least one portable, non-transient field is portable', () => {
221
+ expect(isComponentPortable(Portable as Component)).toBe(true);
222
+ });
223
+
224
+ it('(b) component with entity field is portable', () => {
225
+ expect(isComponentPortable(WithEntity as Component)).toBe(true);
226
+ });
227
+
228
+ it('(c) fully transient component is not portable', () => {
229
+ expect(isComponentPortable(FullyTransient as Component)).toBe(false);
230
+ });
231
+ });
232
+
233
+ // ── m3-profile-rejection-test supplemental: exhaustive rejection edge cases ──
234
+
235
+ describe('m3 — profile rejection supplemental: multi-component and multi-error', () => {
236
+ it('(h) validateProfileComponents rejects multiple components with multiple errors', () => {
237
+ const result = validateProfileComponents([
238
+ FullyTransient as Component,
239
+ AllFieldsTransient as Component,
240
+ UniqueRef as Component,
241
+ SharedRef as Component,
242
+ ]);
243
+ expect(result.valid).toBe(false);
244
+ // First two are fully transient, next two have non-portable fields
245
+ expect(result.errors.length).toBe(4);
246
+ const codes = result.errors.map((e) => e.code);
247
+ expect(codes).toEqual([
248
+ 'component-fully-transient',
249
+ 'component-fully-transient',
250
+ 'field-not-portable',
251
+ 'field-not-portable',
252
+ ]);
253
+ });
254
+
255
+ it('(i) shared<T> and unique<T> are not portable (direct string test)', () => {
256
+ // shared<SomeAsset> and unique<SomeResource> are not valid
257
+ // defineComponent field types, so test isFieldPortable directly.
258
+ expect(isFieldPortable('shared<SomeAsset>')).toBe(false);
259
+ expect(isFieldPortable('unique<SomeResource>')).toBe(false);
260
+ });
261
+
262
+ it('(j) validateProfileComponents with no network metadata in schema', () => {
263
+ // Components defined with defineComponent have no network-specific fields
264
+ const result = validateProfileComponents([Portable as Component, WithEntity as Component]);
265
+ expect(result.valid).toBe(true);
266
+ expect(result.errors.length).toBe(0);
267
+ // Verify schema has no network metadata
268
+ const schema = componentSchema(Portable) as Record<string, string>;
269
+ for (const key of Object.keys(schema)) {
270
+ expect(key).not.toContain('network');
271
+ expect(key).not.toContain('replicate');
272
+ expect(key).not.toContain('profile');
273
+ }
274
+ });
275
+ });