@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.
- package/LICENSE +202 -0
- package/README.md +278 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/__fixtures__/field-shape-fixture.d.ts +16 -0
- package/dist/__fixtures__/field-shape-fixture.d.ts.map +1 -0
- package/dist/__tests__/__fixtures__/inspect-scripts.snapshot.d.ts +3 -0
- package/dist/__tests__/__fixtures__/inspect-scripts.snapshot.d.ts.map +1 -0
- package/dist/__tests__/archetype.unit.test.d.ts +2 -0
- package/dist/__tests__/archetype.unit.test.d.ts.map +1 -0
- package/dist/__tests__/array-handle-element.test-d.d.ts +2 -0
- package/dist/__tests__/array-handle-element.test-d.d.ts.map +1 -0
- package/dist/__tests__/buffer-array-vocab.test-d.d.ts +2 -0
- package/dist/__tests__/buffer-array-vocab.test-d.d.ts.map +1 -0
- package/dist/__tests__/buffer-field-input-widen.unit.test.d.ts +2 -0
- package/dist/__tests__/buffer-field-input-widen.unit.test.d.ts.map +1 -0
- package/dist/__tests__/buffer-pool.test-d.d.ts +2 -0
- package/dist/__tests__/buffer-pool.test-d.d.ts.map +1 -0
- package/dist/__tests__/change-detection.unit.test.d.ts +2 -0
- package/dist/__tests__/change-detection.unit.test.d.ts.map +1 -0
- package/dist/__tests__/command-buffer.test.d.ts +2 -0
- package/dist/__tests__/command-buffer.test.d.ts.map +1 -0
- package/dist/__tests__/commands-deferred.unit.test.d.ts +2 -0
- package/dist/__tests__/commands-deferred.unit.test.d.ts.map +1 -0
- package/dist/__tests__/component-catalog.test.d.ts +2 -0
- package/dist/__tests__/component-catalog.test.d.ts.map +1 -0
- package/dist/__tests__/component-definition-identity.unit.test.d.ts +2 -0
- package/dist/__tests__/component-definition-identity.unit.test.d.ts.map +1 -0
- package/dist/__tests__/component-nan-preflight.unit.test.d.ts +2 -0
- package/dist/__tests__/component-nan-preflight.unit.test.d.ts.map +1 -0
- package/dist/__tests__/component-schema.test-d.d.ts +2 -0
- package/dist/__tests__/component-schema.test-d.d.ts.map +1 -0
- package/dist/__tests__/component-schema.test.d.ts +2 -0
- package/dist/__tests__/component-schema.test.d.ts.map +1 -0
- package/dist/__tests__/define-component-options.test-d.d.ts +2 -0
- package/dist/__tests__/define-component-options.test-d.d.ts.map +1 -0
- package/dist/__tests__/deprecated-vocab-rejection.unit.test.d.ts +2 -0
- package/dist/__tests__/deprecated-vocab-rejection.unit.test.d.ts.map +1 -0
- package/dist/__tests__/despawn-all.unit.test.d.ts +2 -0
- package/dist/__tests__/despawn-all.unit.test.d.ts.map +1 -0
- package/dist/__tests__/ecs-core-reduction.characterization.test.d.ts +2 -0
- package/dist/__tests__/ecs-core-reduction.characterization.test.d.ts.map +1 -0
- package/dist/__tests__/ecs-core-reduction.perf.test.d.ts +2 -0
- package/dist/__tests__/ecs-core-reduction.perf.test.d.ts.map +1 -0
- package/dist/__tests__/ecs-error-code-31.test-d.d.ts +2 -0
- package/dist/__tests__/ecs-error-code-31.test-d.d.ts.map +1 -0
- package/dist/__tests__/entity-disabling.unit.test.d.ts +2 -0
- package/dist/__tests__/entity-disabling.unit.test.d.ts.map +1 -0
- package/dist/__tests__/entity-handle-codec-parity.unit.test.d.ts +2 -0
- package/dist/__tests__/entity-handle-codec-parity.unit.test.d.ts.map +1 -0
- package/dist/__tests__/errors.unit.test.d.ts +2 -0
- package/dist/__tests__/errors.unit.test.d.ts.map +1 -0
- package/dist/__tests__/execution-conflict-boundary.unit.test.d.ts +2 -0
- package/dist/__tests__/execution-conflict-boundary.unit.test.d.ts.map +1 -0
- package/dist/__tests__/execution-shared-storage.unit.test.d.ts +2 -0
- package/dist/__tests__/execution-shared-storage.unit.test.d.ts.map +1 -0
- package/dist/__tests__/externalization-portable-value.unit.test.d.ts +2 -0
- package/dist/__tests__/externalization-portable-value.unit.test.d.ts.map +1 -0
- package/dist/__tests__/externalization-projection.unit.test.d.ts +2 -0
- package/dist/__tests__/externalization-projection.unit.test.d.ts.map +1 -0
- package/dist/__tests__/externalization-render-read-lease.test-d.d.ts +2 -0
- package/dist/__tests__/externalization-render-read-lease.test-d.d.ts.map +1 -0
- package/dist/__tests__/externalization-render-read-lease.unit.test.d.ts +2 -0
- package/dist/__tests__/externalization-render-read-lease.unit.test.d.ts.map +1 -0
- package/dist/__tests__/externalization-root-surface.unit.test.d.ts +2 -0
- package/dist/__tests__/externalization-root-surface.unit.test.d.ts.map +1 -0
- package/dist/__tests__/field-enum-labels-reflection.test.d.ts +2 -0
- package/dist/__tests__/field-enum-labels-reflection.test.d.ts.map +1 -0
- package/dist/__tests__/field-shape-fixture.test.d.ts +2 -0
- package/dist/__tests__/field-shape-fixture.test.d.ts.map +1 -0
- package/dist/__tests__/field-transient-reflection.test.d.ts +2 -0
- package/dist/__tests__/field-transient-reflection.test.d.ts.map +1 -0
- package/dist/__tests__/field-value-type.test-d.d.ts +2 -0
- package/dist/__tests__/field-value-type.test-d.d.ts.map +1 -0
- package/dist/__tests__/fixed-update.unit.test.d.ts +2 -0
- package/dist/__tests__/fixed-update.unit.test.d.ts.map +1 -0
- package/dist/__tests__/handle.test-d.d.ts +2 -0
- package/dist/__tests__/handle.test-d.d.ts.map +1 -0
- package/dist/__tests__/hierarchy.unit.test.d.ts +2 -0
- package/dist/__tests__/hierarchy.unit.test.d.ts.map +1 -0
- package/dist/__tests__/managed-array-vocab.test-d.d.ts +2 -0
- package/dist/__tests__/managed-array-vocab.test-d.d.ts.map +1 -0
- package/dist/__tests__/minimal-example.test-d.d.ts +2 -0
- package/dist/__tests__/minimal-example.test-d.d.ts.map +1 -0
- package/dist/__tests__/name-read-types.test-d.d.ts +2 -0
- package/dist/__tests__/name-read-types.test-d.d.ts.map +1 -0
- package/dist/__tests__/plugin-service.test.d.ts +2 -0
- package/dist/__tests__/plugin-service.test.d.ts.map +1 -0
- package/dist/__tests__/query-combinations.unit.test.d.ts +2 -0
- package/dist/__tests__/query-combinations.unit.test.d.ts.map +1 -0
- package/dist/__tests__/query-light-extract-flat-column-ratio.perf.test.d.ts +2 -0
- package/dist/__tests__/query-light-extract-flat-column-ratio.perf.test.d.ts.map +1 -0
- package/dist/__tests__/query-storage-trends.perf.test.d.ts +2 -0
- package/dist/__tests__/query-storage-trends.perf.test.d.ts.map +1 -0
- package/dist/__tests__/query-trs-flat-column-ratio.perf.test.d.ts +2 -0
- package/dist/__tests__/query-trs-flat-column-ratio.perf.test.d.ts.map +1 -0
- package/dist/__tests__/query.unit.test.d.ts +2 -0
- package/dist/__tests__/query.unit.test.d.ts.map +1 -0
- package/dist/__tests__/relationship-index.perf.test.d.ts +2 -0
- package/dist/__tests__/relationship-index.perf.test.d.ts.map +1 -0
- package/dist/__tests__/relationship-index.test.d.ts +2 -0
- package/dist/__tests__/relationship-index.test.d.ts.map +1 -0
- package/dist/__tests__/scalar-field-type-owner.test-d.d.ts +2 -0
- package/dist/__tests__/scalar-field-type-owner.test-d.d.ts.map +1 -0
- package/dist/__tests__/schedule-determinism.unit.test.d.ts +2 -0
- package/dist/__tests__/schedule-determinism.unit.test.d.ts.map +1 -0
- package/dist/__tests__/schedule-inspection.unit.test.d.ts +2 -0
- package/dist/__tests__/schedule-inspection.unit.test.d.ts.map +1 -0
- package/dist/__tests__/schedule-scope-error.unit.test.d.ts +2 -0
- package/dist/__tests__/schedule-scope-error.unit.test.d.ts.map +1 -0
- package/dist/__tests__/schedule-token.unit.test.d.ts +2 -0
- package/dist/__tests__/schedule-token.unit.test.d.ts.map +1 -0
- package/dist/__tests__/schema-vocab.test-d.d.ts +2 -0
- package/dist/__tests__/schema-vocab.test-d.d.ts.map +1 -0
- package/dist/__tests__/serialization.unit.test.d.ts +2 -0
- package/dist/__tests__/serialization.unit.test.d.ts.map +1 -0
- package/dist/__tests__/shared-kernel-eligibility.test-d.d.ts +2 -0
- package/dist/__tests__/shared-kernel-eligibility.test-d.d.ts.map +1 -0
- package/dist/__tests__/shared-kernel-eligibility.unit.test.d.ts +2 -0
- package/dist/__tests__/shared-kernel-eligibility.unit.test.d.ts.map +1 -0
- package/dist/__tests__/shared-ref-store.unit.test.d.ts +2 -0
- package/dist/__tests__/shared-ref-store.unit.test.d.ts.map +1 -0
- package/dist/__tests__/sparse-tag.unit.test.d.ts +2 -0
- package/dist/__tests__/sparse-tag.unit.test.d.ts.map +1 -0
- package/dist/__tests__/spawn-field-error.test-d.d.ts +2 -0
- package/dist/__tests__/spawn-field-error.test-d.d.ts.map +1 -0
- package/dist/__tests__/stale-error.test-d.d.ts +2 -0
- package/dist/__tests__/stale-error.test-d.d.ts.map +1 -0
- package/dist/__tests__/string-view-symmetry.test-d.d.ts +2 -0
- package/dist/__tests__/string-view-symmetry.test-d.d.ts.map +1 -0
- package/dist/__tests__/string-vocab.test-d.d.ts +2 -0
- package/dist/__tests__/string-vocab.test-d.d.ts.map +1 -0
- package/dist/__tests__/structure-epoch-boundaries.unit.test.d.ts +2 -0
- package/dist/__tests__/structure-epoch-boundaries.unit.test.d.ts.map +1 -0
- package/dist/__tests__/structure-epoch.unit.test.d.ts +2 -0
- package/dist/__tests__/structure-epoch.unit.test.d.ts.map +1 -0
- package/dist/__tests__/table-archetype-mapping.unit.test.d.ts +2 -0
- package/dist/__tests__/table-archetype-mapping.unit.test.d.ts.map +1 -0
- package/dist/__tests__/time.unit.test.d.ts +2 -0
- package/dist/__tests__/time.unit.test.d.ts.map +1 -0
- package/dist/__tests__/types.test-d.d.ts +2 -0
- package/dist/__tests__/types.test-d.d.ts.map +1 -0
- package/dist/__tests__/unique-ref-store.unit.test.d.ts +2 -0
- package/dist/__tests__/unique-ref-store.unit.test.d.ts.map +1 -0
- package/dist/__tests__/utils/handle-numeric.d.ts +14 -0
- package/dist/__tests__/utils/handle-numeric.d.ts.map +1 -0
- package/dist/__tests__/validation-root-surface.unit.test.d.ts +2 -0
- package/dist/__tests__/validation-root-surface.unit.test.d.ts.map +1 -0
- package/dist/__tests__/visibility-atomic-write.unit.test.d.ts +2 -0
- package/dist/__tests__/visibility-atomic-write.unit.test.d.ts.map +1 -0
- package/dist/__tests__/world-change-journal.unit.test.d.ts +2 -0
- package/dist/__tests__/world-change-journal.unit.test.d.ts.map +1 -0
- package/dist/__tests__/world-characterization.unit.test.d.ts +2 -0
- package/dist/__tests__/world-characterization.unit.test.d.ts.map +1 -0
- package/dist/__tests__/world-consumer-inference.test-d.d.ts +2 -0
- package/dist/__tests__/world-consumer-inference.test-d.d.ts.map +1 -0
- package/dist/__tests__/world-health.contract.test.d.ts +2 -0
- package/dist/__tests__/world-health.contract.test.d.ts.map +1 -0
- package/dist/__tests__/world-inspection.test.d.ts +2 -0
- package/dist/__tests__/world-inspection.test.d.ts.map +1 -0
- package/dist/__tests__/world-internal-identity.unit.test.d.ts +2 -0
- package/dist/__tests__/world-internal-identity.unit.test.d.ts.map +1 -0
- package/dist/__tests__/world-managed-roundtrip.unit.test.d.ts +2 -0
- package/dist/__tests__/world-managed-roundtrip.unit.test.d.ts.map +1 -0
- package/dist/__tests__/world-scheduling.m4.test.d.ts +2 -0
- package/dist/__tests__/world-scheduling.m4.test.d.ts.map +1 -0
- package/dist/__tests__/world-unique-roundtrip.unit.test.d.ts +2 -0
- package/dist/__tests__/world-unique-roundtrip.unit.test.d.ts.map +1 -0
- package/dist/__tests__/world.test-d.d.ts +2 -0
- package/dist/__tests__/world.test-d.d.ts.map +1 -0
- package/dist/buffer-pool.d.ts +109 -0
- package/dist/buffer-pool.d.ts.map +1 -0
- package/dist/commands.d.ts +93 -0
- package/dist/commands.d.ts.map +1 -0
- package/dist/component-default-fallback.d.ts +88 -0
- package/dist/component-default-fallback.d.ts.map +1 -0
- package/dist/component-schema.d.ts +34 -0
- package/dist/component-schema.d.ts.map +1 -0
- package/dist/component-value-validate.d.ts +29 -0
- package/dist/component-value-validate.d.ts.map +1 -0
- package/dist/component.d.ts +581 -0
- package/dist/component.d.ts.map +1 -0
- package/dist/entity-handle.d.ts +68 -0
- package/dist/entity-handle.d.ts.map +1 -0
- package/dist/entity.d.ts +86 -0
- package/dist/entity.d.ts.map +1 -0
- package/dist/errors/query-and-component-errors.d.ts +132 -0
- package/dist/errors/query-and-component-errors.d.ts.map +1 -0
- package/dist/errors/relationship-errors.d.ts +112 -0
- package/dist/errors/relationship-errors.d.ts.map +1 -0
- package/dist/errors/sprite-and-shared-errors.d.ts +107 -0
- package/dist/errors/sprite-and-shared-errors.d.ts.map +1 -0
- package/dist/errors/validation-errors.d.ts +229 -0
- package/dist/errors/validation-errors.d.ts.map +1 -0
- package/dist/errors.d.ts +763 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/execution/shared-kernel.d.ts +106 -0
- package/dist/execution/shared-kernel.d.ts.map +1 -0
- package/dist/externalization/index.d.ts +31 -0
- package/dist/externalization/index.d.ts.map +1 -0
- package/dist/externalization/index.mjs +298 -0
- package/dist/externalization/index.mjs.map +1 -0
- package/dist/index.d.ts +261 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.mjs +7422 -0
- package/dist/index.mjs.map +1 -0
- package/dist/internal.mjs +479 -0
- package/dist/internal.mjs.map +1 -0
- package/dist/plugin-service.d.ts +11 -0
- package/dist/plugin-service.d.ts.map +1 -0
- package/dist/projection/index.d.ts +103 -0
- package/dist/projection/index.d.ts.map +1 -0
- package/dist/projection/index.mjs +615 -0
- package/dist/projection/index.mjs.map +1 -0
- package/dist/query/query.d.ts +58 -0
- package/dist/query/query.d.ts.map +1 -0
- package/dist/relationship-index.d.ts +81 -0
- package/dist/relationship-index.d.ts.map +1 -0
- package/dist/resource.d.ts +70 -0
- package/dist/resource.d.ts.map +1 -0
- package/dist/schedule-token.d.ts +16 -0
- package/dist/schedule-token.d.ts.map +1 -0
- package/dist/schedule.d.ts +271 -0
- package/dist/schedule.d.ts.map +1 -0
- package/dist/shared-ref-store.d.ts +144 -0
- package/dist/shared-ref-store.d.ts.map +1 -0
- package/dist/shared.d.ts +3 -0
- package/dist/shared.d.ts.map +1 -0
- package/dist/shared.mjs +364 -0
- package/dist/shared.mjs.map +1 -0
- package/dist/storage/archetype-graph.d.ts +54 -0
- package/dist/storage/archetype-graph.d.ts.map +1 -0
- package/dist/storage/archetype.d.ts +23 -0
- package/dist/storage/archetype.d.ts.map +1 -0
- package/dist/storage/change-detection.d.ts +40 -0
- package/dist/storage/change-detection.d.ts.map +1 -0
- package/dist/storage/column.d.ts +111 -0
- package/dist/storage/column.d.ts.map +1 -0
- package/dist/storage/table.d.ts +29 -0
- package/dist/storage/table.d.ts.map +1 -0
- package/dist/time.d.ts +57 -0
- package/dist/time.d.ts.map +1 -0
- package/dist/unique-ref-store.d.ts +105 -0
- package/dist/unique-ref-store.d.ts.map +1 -0
- package/dist/world-change-journal.d.ts +34 -0
- package/dist/world-change-journal.d.ts.map +1 -0
- package/dist/world-component-access.d.ts +265 -0
- package/dist/world-component-access.d.ts.map +1 -0
- package/dist/world-component-storage.d.ts +282 -0
- package/dist/world-component-storage.d.ts.map +1 -0
- package/dist/world-core.d.ts +39 -0
- package/dist/world-core.d.ts.map +1 -0
- package/dist/world-entity-lifecycle.d.ts +30 -0
- package/dist/world-entity-lifecycle.d.ts.map +1 -0
- package/dist/world-internal.d.ts +14 -0
- package/dist/world-internal.d.ts.map +1 -0
- package/dist/world-scheduling.d.ts +30 -0
- package/dist/world-scheduling.d.ts.map +1 -0
- package/dist/world.d.ts +620 -0
- package/dist/world.d.ts.map +1 -0
- package/package.json +77 -0
- package/src/__fixtures__/field-shape-fixture.ts +30 -0
- package/src/__tests__/__fixtures__/inspect-scripts.snapshot.ts +2 -0
- package/src/__tests__/archetype.unit.test.ts +1837 -0
- package/src/__tests__/array-handle-element.test-d.ts +34 -0
- package/src/__tests__/buffer-array-vocab.test-d.ts +53 -0
- package/src/__tests__/buffer-field-input-widen.unit.test.ts +99 -0
- package/src/__tests__/buffer-pool.test-d.ts +32 -0
- package/src/__tests__/change-detection.unit.test.ts +86 -0
- package/src/__tests__/command-buffer.test.ts +179 -0
- package/src/__tests__/commands-deferred.unit.test.ts +68 -0
- package/src/__tests__/component-catalog.test.ts +59 -0
- package/src/__tests__/component-definition-identity.unit.test.ts +24 -0
- package/src/__tests__/component-nan-preflight.unit.test.ts +186 -0
- package/src/__tests__/component-schema.test-d.ts +119 -0
- package/src/__tests__/component-schema.test.ts +55 -0
- package/src/__tests__/define-component-options.test-d.ts +35 -0
- package/src/__tests__/deprecated-vocab-rejection.unit.test.ts +59 -0
- package/src/__tests__/despawn-all.unit.test.ts +17 -0
- package/src/__tests__/ecs-core-reduction.characterization.test.ts +130 -0
- package/src/__tests__/ecs-core-reduction.perf.test.ts +260 -0
- package/src/__tests__/ecs-error-code-31.test-d.ts +42 -0
- package/src/__tests__/entity-disabling.unit.test.ts +37 -0
- package/src/__tests__/entity-handle-codec-parity.unit.test.ts +126 -0
- package/src/__tests__/errors.unit.test.ts +1456 -0
- package/src/__tests__/execution-conflict-boundary.unit.test.ts +123 -0
- package/src/__tests__/execution-shared-storage.unit.test.ts +40 -0
- package/src/__tests__/externalization-portable-value.unit.test.ts +275 -0
- package/src/__tests__/externalization-projection.unit.test.ts +325 -0
- package/src/__tests__/externalization-render-read-lease.test-d.ts +30 -0
- package/src/__tests__/externalization-render-read-lease.unit.test.ts +79 -0
- package/src/__tests__/externalization-root-surface.unit.test.ts +33 -0
- package/src/__tests__/field-enum-labels-reflection.test.ts +66 -0
- package/src/__tests__/field-shape-fixture.test.ts +61 -0
- package/src/__tests__/field-transient-reflection.test.ts +59 -0
- package/src/__tests__/field-value-type.test-d.ts +57 -0
- package/src/__tests__/fixed-update.unit.test.ts +78 -0
- package/src/__tests__/handle.test-d.ts +86 -0
- package/src/__tests__/hierarchy.unit.test.ts +2534 -0
- package/src/__tests__/managed-array-vocab.test-d.ts +137 -0
- package/src/__tests__/minimal-example.test-d.ts +42 -0
- package/src/__tests__/name-read-types.test-d.ts +72 -0
- package/src/__tests__/plugin-service.test.ts +13 -0
- package/src/__tests__/query-combinations.unit.test.ts +42 -0
- package/src/__tests__/query-light-extract-flat-column-ratio.perf.test.ts +252 -0
- package/src/__tests__/query-storage-trends.perf.test.ts +104 -0
- package/src/__tests__/query-trs-flat-column-ratio.perf.test.ts +194 -0
- package/src/__tests__/query.unit.test.ts +196 -0
- package/src/__tests__/relationship-index.perf.test.ts +126 -0
- package/src/__tests__/relationship-index.test.ts +70 -0
- package/src/__tests__/scalar-field-type-owner.test-d.ts +71 -0
- package/src/__tests__/schedule-determinism.unit.test.ts +36 -0
- package/src/__tests__/schedule-inspection.unit.test.ts +81 -0
- package/src/__tests__/schedule-scope-error.unit.test.ts +63 -0
- package/src/__tests__/schedule-token.unit.test.ts +54 -0
- package/src/__tests__/schema-vocab.test-d.ts +103 -0
- package/src/__tests__/serialization.unit.test.ts +2740 -0
- package/src/__tests__/shared-kernel-eligibility.test-d.ts +18 -0
- package/src/__tests__/shared-kernel-eligibility.unit.test.ts +78 -0
- package/src/__tests__/shared-ref-store.unit.test.ts +646 -0
- package/src/__tests__/sparse-tag.unit.test.ts +201 -0
- package/src/__tests__/spawn-field-error.test-d.ts +41 -0
- package/src/__tests__/stale-error.test-d.ts +208 -0
- package/src/__tests__/string-view-symmetry.test-d.ts +26 -0
- package/src/__tests__/string-vocab.test-d.ts +49 -0
- package/src/__tests__/structure-epoch-boundaries.unit.test.ts +39 -0
- package/src/__tests__/structure-epoch.unit.test.ts +48 -0
- package/src/__tests__/table-archetype-mapping.unit.test.ts +78 -0
- package/src/__tests__/time.unit.test.ts +79 -0
- package/src/__tests__/types.test-d.ts +38 -0
- package/src/__tests__/unique-ref-store.unit.test.ts +348 -0
- package/src/__tests__/utils/handle-numeric.ts +30 -0
- package/src/__tests__/validation-root-surface.unit.test.ts +15 -0
- package/src/__tests__/visibility-atomic-write.unit.test.ts +82 -0
- package/src/__tests__/world-change-journal.unit.test.ts +97 -0
- package/src/__tests__/world-characterization.unit.test.ts +408 -0
- package/src/__tests__/world-consumer-inference.test-d.ts +16 -0
- package/src/__tests__/world-health.contract.test.ts +87 -0
- package/src/__tests__/world-inspection.test.ts +37 -0
- package/src/__tests__/world-internal-identity.unit.test.ts +17 -0
- package/src/__tests__/world-managed-roundtrip.unit.test.ts +98 -0
- package/src/__tests__/world-scheduling.m4.test.ts +52 -0
- package/src/__tests__/world-unique-roundtrip.unit.test.ts +357 -0
- package/src/__tests__/world.test-d.ts +156 -0
- package/src/buffer-pool.ts +357 -0
- package/src/commands.ts +644 -0
- package/src/component-default-fallback.ts +236 -0
- package/src/component-schema.ts +92 -0
- package/src/component-value-validate.ts +135 -0
- package/src/component.ts +1268 -0
- package/src/entity-handle.ts +104 -0
- package/src/entity.ts +140 -0
- package/src/errors/query-and-component-errors.ts +200 -0
- package/src/errors/relationship-errors.ts +198 -0
- package/src/errors/sprite-and-shared-errors.ts +231 -0
- package/src/errors/validation-errors.ts +506 -0
- package/src/errors.ts +1464 -0
- package/src/execution/shared-kernel.ts +392 -0
- package/src/externalization/index.ts +170 -0
- package/src/index.ts +414 -0
- package/src/plugin-service.ts +35 -0
- package/src/projection/index.ts +318 -0
- package/src/query/query.ts +606 -0
- package/src/relationship-index.ts +175 -0
- package/src/resource.ts +106 -0
- package/src/schedule-token.ts +40 -0
- package/src/schedule.ts +846 -0
- package/src/shared-ref-store.ts +418 -0
- package/src/shared.ts +23 -0
- package/src/storage/archetype-graph.ts +166 -0
- package/src/storage/archetype.ts +78 -0
- package/src/storage/change-detection.ts +231 -0
- package/src/storage/column.ts +247 -0
- package/src/storage/table.ts +153 -0
- package/src/time.ts +122 -0
- package/src/unique-ref-store.ts +278 -0
- package/src/world-change-journal.ts +84 -0
- package/src/world-component-access.ts +1421 -0
- package/src/world-component-storage.ts +1178 -0
- package/src/world-core.ts +74 -0
- package/src/world-entity-lifecycle.ts +539 -0
- package/src/world-internal.ts +75 -0
- package/src/world-scheduling.ts +499 -0
- package/src/world.ts +1399 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import type { Handle } from '@forgeax/engine-types';
|
|
2
|
+
import { type Result } from '@forgeax/engine-types';
|
|
3
|
+
import { UniqueRefDoubleReleaseError, UniqueRefReleasedError, UniqueRefStaleError } from './errors';
|
|
4
|
+
/**
|
|
5
|
+
* Per-slot singleton store for ECS-managed `Handle<T, 'unique'>` lifecycles.
|
|
6
|
+
* World hooks the three release paths (despawn, removeComponent, set) into
|
|
7
|
+
* `release(handle)`; `resolve(handle)` is the read path AI users reach
|
|
8
|
+
* indirectly through `world.get(e, C)` for `ref<T>` schema fields.
|
|
9
|
+
*
|
|
10
|
+
* §contract — handles carry a generation; stale-by-reuse is detected: the
|
|
11
|
+
* handle u32 packs `(gen << 24) | slot` via the shared codec; `resolve` /
|
|
12
|
+
* `release` compare the handle generation against `_generations[slot]` and
|
|
13
|
+
* return `UniqueRefStaleError` ('unique-ref-stale') when a released slot has
|
|
14
|
+
* been re-allocated, instead of silently resolving to the next payload.
|
|
15
|
+
* README §"Managed handles carry a generation" is the canonical AI-user-
|
|
16
|
+
* facing statement.
|
|
17
|
+
*
|
|
18
|
+
* Identity invariant (AC-04 prelude): the payload returned by `resolve` is
|
|
19
|
+
* the same object reference on every call until `release`. Carry-over (M4)
|
|
20
|
+
* relies on this - archetype migrate moves the row index, not the payload.
|
|
21
|
+
*
|
|
22
|
+
* Storage is type-erased (`unknown`): the store routes lifecycle without ever
|
|
23
|
+
* inspecting payload fields. Per-call payload typing flows through method
|
|
24
|
+
* generics: `alloc<T>` accepts a `T` payload + matching `onRelease(T)`, and
|
|
25
|
+
* `resolve<T>` returns `Result<T, ...>`. Both narrow at the call boundary
|
|
26
|
+
* (the single read site is World.get's ref path); making the class generic
|
|
27
|
+
* on `T` was decoration with no internal use, so the parameter was dropped
|
|
28
|
+
* (architecture-principles.md §1 SSOT).
|
|
29
|
+
*/
|
|
30
|
+
export declare class UniqueRefStore {
|
|
31
|
+
private readonly payloads;
|
|
32
|
+
private readonly freeSlots;
|
|
33
|
+
private readonly releaseCallbacks;
|
|
34
|
+
private nextSlot;
|
|
35
|
+
/**
|
|
36
|
+
* Generation table indexed by slot (D-6). Each entry tracks the current
|
|
37
|
+
* generation for the slot — written to during alloc (welded into the
|
|
38
|
+
* returned handle via pack) and incremented on release (M4).
|
|
39
|
+
*
|
|
40
|
+
* Slot 0 is the sentinel and always has gen=0 — it is never allocated
|
|
41
|
+
* and never incremented (R6).
|
|
42
|
+
*
|
|
43
|
+
* @internal
|
|
44
|
+
*/
|
|
45
|
+
private readonly _generations;
|
|
46
|
+
/**
|
|
47
|
+
* Allocate a fresh managed handle for `payload`, branded against `target`.
|
|
48
|
+
*
|
|
49
|
+
* Slot 0 is reserved as the "null/unset" sentinel - schema-vocab `ref<T>`
|
|
50
|
+
* fields default to this sentinel before the first write, and World's
|
|
51
|
+
* release loop uses it to short-circuit (`shouldRelease(0) === false`).
|
|
52
|
+
*
|
|
53
|
+
* The returned handle carries a generation tag welded via codec.pack
|
|
54
|
+
* (D-8, OOS-2): first allocation gen=0 (AC-06), reused slot gen = the
|
|
55
|
+
* current generation from _generations[slot]. The toUnique brand cast
|
|
56
|
+
* happens internally — external callers no longer construct Handle<...>
|
|
57
|
+
* directly.
|
|
58
|
+
*
|
|
59
|
+
* @returns a `Handle<T, 'unique'>` u32. The branded number is safe to
|
|
60
|
+
* widen to `number` for GPU upload (charter consistent abstraction).
|
|
61
|
+
*/
|
|
62
|
+
alloc<Target extends string, T = unknown>(target: Target, payload: T, onRelease?: (payload: T) => void): Handle<Target, 'unique'>;
|
|
63
|
+
/**
|
|
64
|
+
* Look up `payload` by handle. Returns `err(unique-ref-released)` when
|
|
65
|
+
* the handle's slot has no live payload (release happened in between, and
|
|
66
|
+
* no re-alloc has filled the slot). Resolves the same payload object on
|
|
67
|
+
* every call - identity-stable until release.
|
|
68
|
+
*
|
|
69
|
+
* §contract: a stale handle whose slot has been released and re-allocated
|
|
70
|
+
* returns `err(unique-ref-stale)` — the generation welded into the handle
|
|
71
|
+
* no longer matches `_generations[slot]`. The gen check runs before the
|
|
72
|
+
* payload lookup, so stale-by-reuse is caught deterministically — see
|
|
73
|
+
* README §"Managed handles carry a generation".
|
|
74
|
+
*
|
|
75
|
+
* `T` flows from the caller's `Handle<T, 'unique'>` type; the store erases
|
|
76
|
+
* payload types at the storage layer and the call boundary re-narrows.
|
|
77
|
+
*/
|
|
78
|
+
resolve<Target extends string, T = unknown>(handle: Handle<Target, 'unique'>): Result<T, UniqueRefReleasedError | UniqueRefStaleError>;
|
|
79
|
+
/**
|
|
80
|
+
* Release `handle` - drop the payload and push the slot onto the free list.
|
|
81
|
+
* Releasing the same handle twice surfaces `unique-ref-double-release`
|
|
82
|
+
* (D-1) so World's release loop can route the second release to Layer 3
|
|
83
|
+
* ErrorHandler without aborting the despawn chain. Detection is by
|
|
84
|
+
* payload-presence, not generation (§contract — managed handles are
|
|
85
|
+
* operational, not persistent).
|
|
86
|
+
*
|
|
87
|
+
* Releasing the slot-0 sentinel is a no-op - World's release loop calls
|
|
88
|
+
* `shouldRelease` first to filter sentinels.
|
|
89
|
+
*/
|
|
90
|
+
release<Target extends string>(handle: Handle<Target, 'unique'>): Result<void, UniqueRefDoubleReleaseError | UniqueRefStaleError>;
|
|
91
|
+
/** @internal Replace the payload of a live slot without changing its handle. */
|
|
92
|
+
_setPayload<Target extends string, T>(handle: Handle<Target, 'unique'>, payload: T): void;
|
|
93
|
+
/**
|
|
94
|
+
* `true` if `handle` references a live slot - used by World's release loop
|
|
95
|
+
* to decide whether to call `release` (skips sentinel + already-released).
|
|
96
|
+
*
|
|
97
|
+
* The release loop differentiates "expected sentinel" (no error) from
|
|
98
|
+
* "leaked already-released handle" (`unique-ref-double-release`) at the
|
|
99
|
+
* caller layer; this helper handles only the no-op short-circuit.
|
|
100
|
+
*/
|
|
101
|
+
isLive<Target extends string>(handle: Handle<Target, 'unique'>): boolean;
|
|
102
|
+
/** @internal Diagnostic count of live slots. Exposed for tests + inspector. */
|
|
103
|
+
_liveCount(): number;
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=unique-ref-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
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SAAS,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC,GAAG,IAAI;IAQzF;;;;;;;OAOG;IACH,MAAM,CAAC,MAAM,SAAS,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,OAAO;IAMxE,+EAA+E;IAC/E,UAAU,IAAI,MAAM;CAGrB"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { EntityHandle } from './entity-handle';
|
|
2
|
+
export type WorldChangeKind = 'component-added' | 'component-changed' | 'component-removed' | 'derived-component-changed' | 'entity-removed';
|
|
3
|
+
export interface WorldChangeRecord {
|
|
4
|
+
readonly sequence: number;
|
|
5
|
+
readonly kind: WorldChangeKind;
|
|
6
|
+
readonly entity: EntityHandle;
|
|
7
|
+
readonly componentId?: number;
|
|
8
|
+
}
|
|
9
|
+
export type WorldChange = Omit<WorldChangeRecord, 'sequence'>;
|
|
10
|
+
export type WorldChangeRead = {
|
|
11
|
+
readonly status: 'ok';
|
|
12
|
+
readonly cursor: number;
|
|
13
|
+
readonly records: readonly WorldChangeRecord[];
|
|
14
|
+
} | {
|
|
15
|
+
readonly status: 'overflow';
|
|
16
|
+
readonly cursor: number;
|
|
17
|
+
readonly oldestAvailable: number;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Bounded mutation evidence for engine-owned projections.
|
|
21
|
+
*
|
|
22
|
+
* Readers retain a cursor and rebuild their projection when the ring has
|
|
23
|
+
* overwritten unread records. An overflow never returns a partial delta.
|
|
24
|
+
*/
|
|
25
|
+
export declare class WorldChangeJournal {
|
|
26
|
+
readonly capacity: number;
|
|
27
|
+
private readonly records;
|
|
28
|
+
private nextSequence;
|
|
29
|
+
constructor(capacity?: number);
|
|
30
|
+
cursor(): number;
|
|
31
|
+
append(change: WorldChange): number;
|
|
32
|
+
readAfter(cursor: number): WorldChangeRead;
|
|
33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C"}
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import { type Result } from '@forgeax/engine-types';
|
|
2
|
+
import type { BufferPool } from './buffer-pool';
|
|
3
|
+
import { type Component, type ComponentSchema, type InputShapeOf, type ShapeOf } from './component';
|
|
4
|
+
import { type EntityHandle } from './entity-handle';
|
|
5
|
+
import { RelationshipIndex } from './relationship-index';
|
|
6
|
+
import type { SharedRefStore } from './shared-ref-store';
|
|
7
|
+
import { type Archetype } from './storage/archetype';
|
|
8
|
+
import { type ArchetypeGraph } from './storage/archetype-graph';
|
|
9
|
+
import { type FieldView } from './storage/column';
|
|
10
|
+
import type { UniqueRefStore } from './unique-ref-store';
|
|
11
|
+
import type { ComponentData, EcsError, EntityRecord } from './world';
|
|
12
|
+
type ErrorContext = {
|
|
13
|
+
readonly systemName: string;
|
|
14
|
+
};
|
|
15
|
+
export interface ComponentAccessState {
|
|
16
|
+
readonly graph: ArchetypeGraph;
|
|
17
|
+
readonly records: EntityRecord[];
|
|
18
|
+
readonly freeIndices: number[];
|
|
19
|
+
readonly bufferPool: BufferPool;
|
|
20
|
+
readonly uniqueRefs: UniqueRefStore;
|
|
21
|
+
readonly sharedRefs: SharedRefStore;
|
|
22
|
+
readonly relationshipIndexes: Map<number, RelationshipIndex>;
|
|
23
|
+
readonly markComponentAdded: (entity: EntityHandle, componentId: number) => void;
|
|
24
|
+
readonly markComponentsAdded: (entity: EntityHandle, componentIds: readonly number[]) => void;
|
|
25
|
+
readonly markComponentChanged: (entity: EntityHandle, componentId: number) => void;
|
|
26
|
+
readonly removeComponentChange: (entity: EntityHandle, componentId: number) => void;
|
|
27
|
+
readonly markStructureChanged: () => void;
|
|
28
|
+
routeError(err: unknown, ctx: ErrorContext): void;
|
|
29
|
+
}
|
|
30
|
+
export declare class WorldComponentAccess {
|
|
31
|
+
private readonly state;
|
|
32
|
+
private readonly storage;
|
|
33
|
+
constructor(state: ComponentAccessState);
|
|
34
|
+
private get graph();
|
|
35
|
+
private get records();
|
|
36
|
+
private table;
|
|
37
|
+
private tableRow;
|
|
38
|
+
private get freeIndices();
|
|
39
|
+
private get bufferPool();
|
|
40
|
+
private get uniqueRefs();
|
|
41
|
+
private routeError;
|
|
42
|
+
private relationshipIndex;
|
|
43
|
+
/** Read the World-owned materialized target array; never consults a shadow list. */
|
|
44
|
+
relationshipTargetEntries(source: Component, target: EntityHandle): readonly EntityHandle[];
|
|
45
|
+
private markComponentAdded;
|
|
46
|
+
private markComponentChanged;
|
|
47
|
+
private markStructureChanged;
|
|
48
|
+
relationshipTargetEntity(component: Component, value: Record<string, unknown>): EntityHandle | null;
|
|
49
|
+
private preflightComponentFieldValues;
|
|
50
|
+
/**
|
|
51
|
+
* Validate one structural component payload without touching archetypes,
|
|
52
|
+
* columns, relationship mirrors, epochs, or managed-reference stores.
|
|
53
|
+
* CommandBuffer uses this same owner-level gate as the direct World facade;
|
|
54
|
+
* the optional pending set lets a batch refer to an entity reserved earlier
|
|
55
|
+
* in that batch without mistaking it for a stale live handle.
|
|
56
|
+
*/
|
|
57
|
+
preflightComponentData(holder: EntityHandle | null, componentData: ComponentData, pendingEntities?: ReadonlySet<number>, unavailableEntities?: ReadonlySet<number>): Result<void, EcsError>;
|
|
58
|
+
private relationshipCycleHit;
|
|
59
|
+
/** Prepare the target side before a source archetype mutation commits. */
|
|
60
|
+
private prepareRelationshipInsert;
|
|
61
|
+
/** Append `holder` to the materialized target list. */
|
|
62
|
+
relationshipOnInsert(holder: EntityHandle, component: Component, value: Record<string, unknown>): Result<void, EcsError>;
|
|
63
|
+
/** Remove `holder` from the materialized target list. */
|
|
64
|
+
relationshipOnRemove(holder: EntityHandle, component: Component, oldValue: Record<string, unknown>): Result<void, EcsError>;
|
|
65
|
+
/**
|
|
66
|
+
* Read component data from an entity.
|
|
67
|
+
*
|
|
68
|
+
* **Transient view contract (feat-20260602):** for fixed-capacity
|
|
69
|
+
* `array<T,N>` and `buffer<N>` fields, the returned `TypedArray` (and any
|
|
70
|
+
* subarray of it) aliases the archetype column buffer directly. The view is
|
|
71
|
+
* valid only until the next structural change (`spawn` / `despawn` /
|
|
72
|
+
* `addComponent` / `removeComponent`). Holding a view across a structural
|
|
73
|
+
* change is undefined behaviour -- the backing `ArrayBuffer` is detached on
|
|
74
|
+
* column growth, and swap-remove at the same row index points to the wrong
|
|
75
|
+
* entity. **Re-fetch `world.get(e, C)` on every access.** See
|
|
76
|
+
* `packages/ecs/README.md` Transient view contract section.
|
|
77
|
+
*
|
|
78
|
+
* @returns `Result<ShapeOf<S>, EcsError>` —
|
|
79
|
+
* `ok(ShapeOf<S>)` on success;
|
|
80
|
+
* `err(StaleEntityError)` (`.code = 'stale-entity'`) if entity is dead;
|
|
81
|
+
* `err(ComponentNotPresentError)` (`.code = 'component-not-present'`) if
|
|
82
|
+
* the entity does not have the component (a never-present component on
|
|
83
|
+
* this entity degrades to the same `component-not-present` path — there is
|
|
84
|
+
* no separate "not registered" failure; components are global at
|
|
85
|
+
* `defineComponent` time).
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```ts
|
|
89
|
+
* const Position = defineComponent('Position', { x: 'f32', y: 'f32' });
|
|
90
|
+
* const world = new World();
|
|
91
|
+
* const e = world.spawn({ component: Position, data: { x: 1, y: 2 } }).unwrap();
|
|
92
|
+
* const r = world.get(e, Position);
|
|
93
|
+
* if (!r.ok) { return; } // r.error.code === 'stale-entity' on dead handle
|
|
94
|
+
* const pos = r.value;
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
get<S extends ComponentSchema>(entity: EntityHandle, component: Component<string, S>): Result<ShapeOf<S>, EcsError>;
|
|
98
|
+
/**
|
|
99
|
+
* Column-level zero-copy view of an `array<T, N>` / `array<T>` field.
|
|
100
|
+
*
|
|
101
|
+
* Resolves the live byte region for `(entity, component, fieldName)`
|
|
102
|
+
* directly at the column level and returns the element-typed TypedArray
|
|
103
|
+
* aliasing it (`view.buffer` is the SSOT byte region; mutations route
|
|
104
|
+
* through `world.set`). Unlike `get`, this does NOT build the
|
|
105
|
+
* `{}` whole-component object nor walk every schema field. Per-frame
|
|
106
|
+
* consumers that need one column (the resolved world mat4) take this path to
|
|
107
|
+
* avoid the `get` overhead (1 `{}` alloc + N-field readRow walk).
|
|
108
|
+
*
|
|
109
|
+
* Fixed `array<T,N>` columns (feat-20260602) store their elements inline, so
|
|
110
|
+
* the view aliases the archetype column buffer directly (no BufferPool
|
|
111
|
+
* indirection); variable `array<T>` columns still alias the BufferPool slot.
|
|
112
|
+
* The returned view's element type follows the schema element type
|
|
113
|
+
* (`array<entity,N>` -> `Uint32Array`, `array<f32,N>` -> `Float32Array`,
|
|
114
|
+
* etc.) -- the prior f32-only early-return gate is removed.
|
|
115
|
+
*
|
|
116
|
+
* **Transient view contract:** the returned `TypedArray` aliases the column
|
|
117
|
+
* buffer and is valid only until the next structural change (`spawn` /
|
|
118
|
+
* `despawn` / `addComponent` / `removeComponent`). Column growth
|
|
119
|
+
* (`growColumn`) detaches the old `ArrayBuffer` via `transfer()`; a
|
|
120
|
+
* swap-remove at the same row index leaves the view pointing to the wrong
|
|
121
|
+
* entity. **Callers must re-fetch `_getArrayView` on every access** and must
|
|
122
|
+
* not hold the view across any operation that may cause archetype migration.
|
|
123
|
+
* All existing per-frame consumers (`propagateTransforms` / `render-extract`
|
|
124
|
+
* / `pick`) already conform -- they fetch the view inside a single pass with
|
|
125
|
+
* no intervening structural changes.
|
|
126
|
+
*
|
|
127
|
+
* Returns `undefined` when the entity is dead, the component is absent, the
|
|
128
|
+
* field does not exist, or the field is not an `array<...>` column.
|
|
129
|
+
*
|
|
130
|
+
* @internal Engine-internal fast path; AI users read the typed view through
|
|
131
|
+
* `world.get(e, Transform).world`. The accessor is the zero-materialization
|
|
132
|
+
* route the propagate kernel and render walk use.
|
|
133
|
+
*/
|
|
134
|
+
_getArrayView(entity: EntityHandle, component: Component, fieldName: string): FieldView | undefined;
|
|
135
|
+
/**
|
|
136
|
+
* Write (partial) component data to an entity.
|
|
137
|
+
*
|
|
138
|
+
* @returns `Result<void, EcsError>` —
|
|
139
|
+
* `ok(void)` on success;
|
|
140
|
+
* `err(StaleEntityError)` (`.code = 'stale-entity'`) if entity is dead;
|
|
141
|
+
* `err(ComponentNotPresentError)` (`.code = 'component-not-present'`) if
|
|
142
|
+
* entity does not have the component (F-02: no longer silently ignores).
|
|
143
|
+
*
|
|
144
|
+
* @example
|
|
145
|
+
* ```ts
|
|
146
|
+
* const Position = defineComponent('Position', { x: 'f32', y: 'f32' });
|
|
147
|
+
* const world = new World();
|
|
148
|
+
* const e = world.spawn({ component: Position, data: { x: 0, y: 0 } }).unwrap();
|
|
149
|
+
* const r = world.set(e, Position, { x: 10 });
|
|
150
|
+
* if (!r.ok) { return; } // r.error.code === 'stale-entity' on dead handle
|
|
151
|
+
* r.unwrap();
|
|
152
|
+
* ```
|
|
153
|
+
*/
|
|
154
|
+
set<S extends ComponentSchema>(entity: EntityHandle, component: Component<string, S>, value: Partial<InputShapeOf<S>>, markChanged?: boolean): Result<void, EcsError>;
|
|
155
|
+
/**
|
|
156
|
+
* Append `value` to the variable `array<T>` field `fieldName` on `entity`.
|
|
157
|
+
*
|
|
158
|
+
* BufferPool grow is amortized O(1) via the size-class freelist (research
|
|
159
|
+
* Finding 5). Relationship target arrays grow byte-wise.
|
|
160
|
+
*
|
|
161
|
+
* @returns `Result<void, EcsError>` with the normal stale/component errors.
|
|
162
|
+
*
|
|
163
|
+
* The helper is called only by relationship synchronization.
|
|
164
|
+
*/
|
|
165
|
+
private appendArrayElement;
|
|
166
|
+
private ensureArrayCapacity;
|
|
167
|
+
/**
|
|
168
|
+
* Remove one variable-array element at a known slot. Relationship holders
|
|
169
|
+
* supply the slot from their backpointer, so this is O(1) and never scans
|
|
170
|
+
* the materialized target array.
|
|
171
|
+
*/
|
|
172
|
+
private removeArrayElementAt;
|
|
173
|
+
/**
|
|
174
|
+
* Add a component to an existing entity, triggering archetype migration.
|
|
175
|
+
*
|
|
176
|
+
* @returns `Result<void, EcsError>` —
|
|
177
|
+
* `ok(void)` on success;
|
|
178
|
+
* `err(StaleEntityError)` (`.code = 'stale-entity'`) if entity is dead;
|
|
179
|
+
* `err(ComponentAlreadyPresentError)` (`.code = 'component-already-present'`)
|
|
180
|
+
* if entity already has the component (E-03).
|
|
181
|
+
*
|
|
182
|
+
* @example
|
|
183
|
+
* ```ts
|
|
184
|
+
* const Position = defineComponent('Position', { x: 'f32', y: 'f32' });
|
|
185
|
+
* const Velocity = defineComponent('Velocity', { dx: 'f32', dy: 'f32' });
|
|
186
|
+
* const world = new World();
|
|
187
|
+
* const e = world.spawn({ component: Position, data: { x: 0, y: 0 } }).unwrap();
|
|
188
|
+
* const r = world.addComponent(e, { component: Velocity, data: { dx: 1, dy: 0 } });
|
|
189
|
+
* if (!r.ok) { return; } // r.error.code === 'stale-entity' on dead handle
|
|
190
|
+
* r.unwrap();
|
|
191
|
+
* ```
|
|
192
|
+
*/
|
|
193
|
+
addComponent<S extends ComponentSchema>(entity: EntityHandle, componentData: ComponentData<S>): Result<void, EcsError>;
|
|
194
|
+
/**
|
|
195
|
+
* Core implementation of `addComponent` with reentry guard.
|
|
196
|
+
*
|
|
197
|
+
* @param internal — `true` when called from relationship maintenance
|
|
198
|
+
* (lazy mirror create or exclusive reparent).
|
|
199
|
+
* @internal
|
|
200
|
+
*/
|
|
201
|
+
_addComponentCore<S extends ComponentSchema>(entity: EntityHandle, componentData: ComponentData<S>, internal: boolean): Result<void, EcsError>;
|
|
202
|
+
/**
|
|
203
|
+
* Remove a component from an existing entity, triggering archetype migration.
|
|
204
|
+
*
|
|
205
|
+
* @returns `Result<void, EcsError>` —
|
|
206
|
+
* `ok(void)` on success;
|
|
207
|
+
* `err(StaleEntityError)` (`.code = 'stale-entity'`) if entity is dead;
|
|
208
|
+
* `err(ComponentNotPresentError)` (`.code = 'component-not-present'`)
|
|
209
|
+
* if entity doesn't have the component (E-04).
|
|
210
|
+
*
|
|
211
|
+
* @example
|
|
212
|
+
* ```ts
|
|
213
|
+
* const Position = defineComponent('Position', { x: 'f32', y: 'f32' });
|
|
214
|
+
* const world = new World();
|
|
215
|
+
* const e = world.spawn({ component: Position, data: { x: 0, y: 0 } }).unwrap();
|
|
216
|
+
* const r = world.removeComponent(e, Position);
|
|
217
|
+
* if (!r.ok) { return; } // r.error.code === 'stale-entity' on dead handle
|
|
218
|
+
* r.unwrap();
|
|
219
|
+
* ```
|
|
220
|
+
*/
|
|
221
|
+
removeComponent<S extends ComponentSchema>(entity: EntityHandle, component: Component<string, S>): Result<void, EcsError>;
|
|
222
|
+
/**
|
|
223
|
+
* Core implementation of `removeComponent` with reentry guard.
|
|
224
|
+
*
|
|
225
|
+
* @param internal — `true` when called from relationship maintenance
|
|
226
|
+
* (exclusive reparent).
|
|
227
|
+
* @internal
|
|
228
|
+
*/
|
|
229
|
+
_removeComponentCore<S extends ComponentSchema>(entity: EntityHandle, component: Component<string, S>, internal: boolean): Result<void, EcsError>;
|
|
230
|
+
/**
|
|
231
|
+
* @internal Allocate a pending entity for deferred spawn.
|
|
232
|
+
* Returns an Entity handle. The entity is "pending" because
|
|
233
|
+
* archetypeId === -1 (set by allocateIndex); no separate flag needed.
|
|
234
|
+
*/
|
|
235
|
+
_allocatePendingEntity(): EntityHandle;
|
|
236
|
+
/**
|
|
237
|
+
* Return a deferred-spawn reservation to the free-list without publishing a
|
|
238
|
+
* row or advancing an epoch. CommandBuffer.abort is the sole caller; a
|
|
239
|
+
* materialized entity is intentionally left untouched so an unexpected
|
|
240
|
+
* post-write failure poisons the World instead of attempting an unsafe undo.
|
|
241
|
+
*/
|
|
242
|
+
_cancelPendingEntity(entity: EntityHandle): void;
|
|
243
|
+
/**
|
|
244
|
+
* @internal Materialize a pending entity: actually place it into an archetype.
|
|
245
|
+
* Idempotent: a record with archetypeId !== -1 is already materialized.
|
|
246
|
+
*/
|
|
247
|
+
_materializePendingEntity(entity: EntityHandle, componentDatas: ComponentData[]): Result<void, EcsError>;
|
|
248
|
+
allocateIndex(): number;
|
|
249
|
+
/**
|
|
250
|
+
* Single liveness predicate (feat-20260602 / plan-strategy D-4): a slot is
|
|
251
|
+
* live for a given handle generation iff the record exists, its generation
|
|
252
|
+
* still matches the handle (despawn bumps generation, so a stale or recycled
|
|
253
|
+
* handle fails here), and the slot is materialized into an archetype
|
|
254
|
+
* (archetypeId !== -1). Replaces the former `record.alive && record.generation
|
|
255
|
+
* === gen` conjunction and the intermediate `!record.pending` clause.
|
|
256
|
+
*/
|
|
257
|
+
recordIsLive(record: EntityRecord | undefined, gen: number): record is EntityRecord;
|
|
258
|
+
lookupAlive(entity: EntityHandle, operation: string, component?: string): Result<EntityRecord, EcsError>;
|
|
259
|
+
readRow<S extends ComponentSchema>(arch: Archetype, component: Component<string, S>, row: number): ShapeOf<S>;
|
|
260
|
+
writeEntitySelf(arch: Archetype, row: number, handle: EntityHandle): void;
|
|
261
|
+
writeRow<S extends ComponentSchema>(arch: Archetype, component: Component<string, S>, row: number, value: ShapeOf<S>): void;
|
|
262
|
+
releaseManagedRefsOnRow(arch: Archetype, component: Component, row: number): void;
|
|
263
|
+
}
|
|
264
|
+
export {};
|
|
265
|
+
//# sourceMappingURL=world-component-access.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"world-component-access.d.ts","sourceRoot":"","sources":["../src/world-component-access.ts"],"names":[],"mappings":"AAMA,OAAO,EAA0B,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAC1F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAEL,KAAK,SAAS,EACd,KAAK,eAAe,EAGpB,KAAK,YAAY,EAMjB,KAAK,OAAO,EAEb,MAAM,aAAa,CAAC;AAKrB,OAAO,EAGL,KAAK,YAAY,EAIlB,MAAM,iBAAiB,CAAC;AAczB,OAAO,EAEL,iBAAiB,EAGlB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAC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