@forgeax/engine-ecs 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +272 -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-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-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 +214 -0
- package/dist/errors/validation-errors.d.ts.map +1 -0
- package/dist/errors.d.ts +756 -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 +7354 -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 +50 -0
- package/dist/projection/index.d.ts.map +1 -0
- package/dist/projection/index.mjs +517 -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 +264 -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-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 +1452 -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-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 +207 -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 +418 -0
- package/src/errors.ts +1453 -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 +142 -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 +1412 -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 +1397 -0
|
@@ -0,0 +1,264 @@
|
|
|
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
|
+
/**
|
|
50
|
+
* Validate one structural component payload without touching archetypes,
|
|
51
|
+
* columns, relationship mirrors, epochs, or managed-reference stores.
|
|
52
|
+
* CommandBuffer uses this same owner-level gate as the direct World facade;
|
|
53
|
+
* the optional pending set lets a batch refer to an entity reserved earlier
|
|
54
|
+
* in that batch without mistaking it for a stale live handle.
|
|
55
|
+
*/
|
|
56
|
+
preflightComponentData(holder: EntityHandle | null, componentData: ComponentData, pendingEntities?: ReadonlySet<number>, unavailableEntities?: ReadonlySet<number>): Result<void, EcsError>;
|
|
57
|
+
private relationshipCycleHit;
|
|
58
|
+
/** Prepare the target side before a source archetype mutation commits. */
|
|
59
|
+
private prepareRelationshipInsert;
|
|
60
|
+
/** Append `holder` to the materialized target list. */
|
|
61
|
+
relationshipOnInsert(holder: EntityHandle, component: Component, value: Record<string, unknown>): Result<void, EcsError>;
|
|
62
|
+
/** Remove `holder` from the materialized target list. */
|
|
63
|
+
relationshipOnRemove(holder: EntityHandle, component: Component, oldValue: Record<string, unknown>): Result<void, EcsError>;
|
|
64
|
+
/**
|
|
65
|
+
* Read component data from an entity.
|
|
66
|
+
*
|
|
67
|
+
* **Transient view contract (feat-20260602):** for fixed-capacity
|
|
68
|
+
* `array<T,N>` and `buffer<N>` fields, the returned `TypedArray` (and any
|
|
69
|
+
* subarray of it) aliases the archetype column buffer directly. The view is
|
|
70
|
+
* valid only until the next structural change (`spawn` / `despawn` /
|
|
71
|
+
* `addComponent` / `removeComponent`). Holding a view across a structural
|
|
72
|
+
* change is undefined behaviour -- the backing `ArrayBuffer` is detached on
|
|
73
|
+
* column growth, and swap-remove at the same row index points to the wrong
|
|
74
|
+
* entity. **Re-fetch `world.get(e, C)` on every access.** See
|
|
75
|
+
* `packages/ecs/README.md` Transient view contract section.
|
|
76
|
+
*
|
|
77
|
+
* @returns `Result<ShapeOf<S>, EcsError>` —
|
|
78
|
+
* `ok(ShapeOf<S>)` on success;
|
|
79
|
+
* `err(StaleEntityError)` (`.code = 'stale-entity'`) if entity is dead;
|
|
80
|
+
* `err(ComponentNotPresentError)` (`.code = 'component-not-present'`) if
|
|
81
|
+
* the entity does not have the component (a never-present component on
|
|
82
|
+
* this entity degrades to the same `component-not-present` path — there is
|
|
83
|
+
* no separate "not registered" failure; components are global at
|
|
84
|
+
* `defineComponent` time).
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```ts
|
|
88
|
+
* const Position = defineComponent('Position', { x: 'f32', y: 'f32' });
|
|
89
|
+
* const world = new World();
|
|
90
|
+
* const e = world.spawn({ component: Position, data: { x: 1, y: 2 } }).unwrap();
|
|
91
|
+
* const r = world.get(e, Position);
|
|
92
|
+
* if (!r.ok) { return; } // r.error.code === 'stale-entity' on dead handle
|
|
93
|
+
* const pos = r.value;
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
get<S extends ComponentSchema>(entity: EntityHandle, component: Component<string, S>): Result<ShapeOf<S>, EcsError>;
|
|
97
|
+
/**
|
|
98
|
+
* Column-level zero-copy view of an `array<T, N>` / `array<T>` field.
|
|
99
|
+
*
|
|
100
|
+
* Resolves the live byte region for `(entity, component, fieldName)`
|
|
101
|
+
* directly at the column level and returns the element-typed TypedArray
|
|
102
|
+
* aliasing it (`view.buffer` is the SSOT byte region; mutations route
|
|
103
|
+
* through `world.set`). Unlike `get`, this does NOT build the
|
|
104
|
+
* `{}` whole-component object nor walk every schema field. Per-frame
|
|
105
|
+
* consumers that need one column (the resolved world mat4) take this path to
|
|
106
|
+
* avoid the `get` overhead (1 `{}` alloc + N-field readRow walk).
|
|
107
|
+
*
|
|
108
|
+
* Fixed `array<T,N>` columns (feat-20260602) store their elements inline, so
|
|
109
|
+
* the view aliases the archetype column buffer directly (no BufferPool
|
|
110
|
+
* indirection); variable `array<T>` columns still alias the BufferPool slot.
|
|
111
|
+
* The returned view's element type follows the schema element type
|
|
112
|
+
* (`array<entity,N>` -> `Uint32Array`, `array<f32,N>` -> `Float32Array`,
|
|
113
|
+
* etc.) -- the prior f32-only early-return gate is removed.
|
|
114
|
+
*
|
|
115
|
+
* **Transient view contract:** the returned `TypedArray` aliases the column
|
|
116
|
+
* buffer and is valid only until the next structural change (`spawn` /
|
|
117
|
+
* `despawn` / `addComponent` / `removeComponent`). Column growth
|
|
118
|
+
* (`growColumn`) detaches the old `ArrayBuffer` via `transfer()`; a
|
|
119
|
+
* swap-remove at the same row index leaves the view pointing to the wrong
|
|
120
|
+
* entity. **Callers must re-fetch `_getArrayView` on every access** and must
|
|
121
|
+
* not hold the view across any operation that may cause archetype migration.
|
|
122
|
+
* All existing per-frame consumers (`propagateTransforms` / `render-extract`
|
|
123
|
+
* / `pick`) already conform -- they fetch the view inside a single pass with
|
|
124
|
+
* no intervening structural changes.
|
|
125
|
+
*
|
|
126
|
+
* Returns `undefined` when the entity is dead, the component is absent, the
|
|
127
|
+
* field does not exist, or the field is not an `array<...>` column.
|
|
128
|
+
*
|
|
129
|
+
* @internal Engine-internal fast path; AI users read the typed view through
|
|
130
|
+
* `world.get(e, Transform).world`. The accessor is the zero-materialization
|
|
131
|
+
* route the propagate kernel and render walk use.
|
|
132
|
+
*/
|
|
133
|
+
_getArrayView(entity: EntityHandle, component: Component, fieldName: string): FieldView | undefined;
|
|
134
|
+
/**
|
|
135
|
+
* Write (partial) component data to an entity.
|
|
136
|
+
*
|
|
137
|
+
* @returns `Result<void, EcsError>` —
|
|
138
|
+
* `ok(void)` on success;
|
|
139
|
+
* `err(StaleEntityError)` (`.code = 'stale-entity'`) if entity is dead;
|
|
140
|
+
* `err(ComponentNotPresentError)` (`.code = 'component-not-present'`) if
|
|
141
|
+
* entity does not have the component (F-02: no longer silently ignores).
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* ```ts
|
|
145
|
+
* const Position = defineComponent('Position', { x: 'f32', y: 'f32' });
|
|
146
|
+
* const world = new World();
|
|
147
|
+
* const e = world.spawn({ component: Position, data: { x: 0, y: 0 } }).unwrap();
|
|
148
|
+
* const r = world.set(e, Position, { x: 10 });
|
|
149
|
+
* if (!r.ok) { return; } // r.error.code === 'stale-entity' on dead handle
|
|
150
|
+
* r.unwrap();
|
|
151
|
+
* ```
|
|
152
|
+
*/
|
|
153
|
+
set<S extends ComponentSchema>(entity: EntityHandle, component: Component<string, S>, value: Partial<InputShapeOf<S>>, markChanged?: boolean): Result<void, EcsError>;
|
|
154
|
+
/**
|
|
155
|
+
* Append `value` to the variable `array<T>` field `fieldName` on `entity`.
|
|
156
|
+
*
|
|
157
|
+
* BufferPool grow is amortized O(1) via the size-class freelist (research
|
|
158
|
+
* Finding 5). Relationship target arrays grow byte-wise.
|
|
159
|
+
*
|
|
160
|
+
* @returns `Result<void, EcsError>` with the normal stale/component errors.
|
|
161
|
+
*
|
|
162
|
+
* The helper is called only by relationship synchronization.
|
|
163
|
+
*/
|
|
164
|
+
private appendArrayElement;
|
|
165
|
+
private ensureArrayCapacity;
|
|
166
|
+
/**
|
|
167
|
+
* Remove one variable-array element at a known slot. Relationship holders
|
|
168
|
+
* supply the slot from their backpointer, so this is O(1) and never scans
|
|
169
|
+
* the materialized target array.
|
|
170
|
+
*/
|
|
171
|
+
private removeArrayElementAt;
|
|
172
|
+
/**
|
|
173
|
+
* Add a component to an existing entity, triggering archetype migration.
|
|
174
|
+
*
|
|
175
|
+
* @returns `Result<void, EcsError>` —
|
|
176
|
+
* `ok(void)` on success;
|
|
177
|
+
* `err(StaleEntityError)` (`.code = 'stale-entity'`) if entity is dead;
|
|
178
|
+
* `err(ComponentAlreadyPresentError)` (`.code = 'component-already-present'`)
|
|
179
|
+
* if entity already has the component (E-03).
|
|
180
|
+
*
|
|
181
|
+
* @example
|
|
182
|
+
* ```ts
|
|
183
|
+
* const Position = defineComponent('Position', { x: 'f32', y: 'f32' });
|
|
184
|
+
* const Velocity = defineComponent('Velocity', { dx: 'f32', dy: 'f32' });
|
|
185
|
+
* const world = new World();
|
|
186
|
+
* const e = world.spawn({ component: Position, data: { x: 0, y: 0 } }).unwrap();
|
|
187
|
+
* const r = world.addComponent(e, { component: Velocity, data: { dx: 1, dy: 0 } });
|
|
188
|
+
* if (!r.ok) { return; } // r.error.code === 'stale-entity' on dead handle
|
|
189
|
+
* r.unwrap();
|
|
190
|
+
* ```
|
|
191
|
+
*/
|
|
192
|
+
addComponent<S extends ComponentSchema>(entity: EntityHandle, componentData: ComponentData<S>): Result<void, EcsError>;
|
|
193
|
+
/**
|
|
194
|
+
* Core implementation of `addComponent` with reentry guard.
|
|
195
|
+
*
|
|
196
|
+
* @param internal — `true` when called from relationship maintenance
|
|
197
|
+
* (lazy mirror create or exclusive reparent).
|
|
198
|
+
* @internal
|
|
199
|
+
*/
|
|
200
|
+
_addComponentCore<S extends ComponentSchema>(entity: EntityHandle, componentData: ComponentData<S>, internal: boolean): Result<void, EcsError>;
|
|
201
|
+
/**
|
|
202
|
+
* Remove a component from an existing entity, triggering archetype migration.
|
|
203
|
+
*
|
|
204
|
+
* @returns `Result<void, EcsError>` —
|
|
205
|
+
* `ok(void)` on success;
|
|
206
|
+
* `err(StaleEntityError)` (`.code = 'stale-entity'`) if entity is dead;
|
|
207
|
+
* `err(ComponentNotPresentError)` (`.code = 'component-not-present'`)
|
|
208
|
+
* if entity doesn't have the component (E-04).
|
|
209
|
+
*
|
|
210
|
+
* @example
|
|
211
|
+
* ```ts
|
|
212
|
+
* const Position = defineComponent('Position', { x: 'f32', y: 'f32' });
|
|
213
|
+
* const world = new World();
|
|
214
|
+
* const e = world.spawn({ component: Position, data: { x: 0, y: 0 } }).unwrap();
|
|
215
|
+
* const r = world.removeComponent(e, Position);
|
|
216
|
+
* if (!r.ok) { return; } // r.error.code === 'stale-entity' on dead handle
|
|
217
|
+
* r.unwrap();
|
|
218
|
+
* ```
|
|
219
|
+
*/
|
|
220
|
+
removeComponent<S extends ComponentSchema>(entity: EntityHandle, component: Component<string, S>): Result<void, EcsError>;
|
|
221
|
+
/**
|
|
222
|
+
* Core implementation of `removeComponent` with reentry guard.
|
|
223
|
+
*
|
|
224
|
+
* @param internal — `true` when called from relationship maintenance
|
|
225
|
+
* (exclusive reparent).
|
|
226
|
+
* @internal
|
|
227
|
+
*/
|
|
228
|
+
_removeComponentCore<S extends ComponentSchema>(entity: EntityHandle, component: Component<string, S>, internal: boolean): Result<void, EcsError>;
|
|
229
|
+
/**
|
|
230
|
+
* @internal Allocate a pending entity for deferred spawn.
|
|
231
|
+
* Returns an Entity handle. The entity is "pending" because
|
|
232
|
+
* archetypeId === -1 (set by allocateIndex); no separate flag needed.
|
|
233
|
+
*/
|
|
234
|
+
_allocatePendingEntity(): EntityHandle;
|
|
235
|
+
/**
|
|
236
|
+
* Return a deferred-spawn reservation to the free-list without publishing a
|
|
237
|
+
* row or advancing an epoch. CommandBuffer.abort is the sole caller; a
|
|
238
|
+
* materialized entity is intentionally left untouched so an unexpected
|
|
239
|
+
* post-write failure poisons the World instead of attempting an unsafe undo.
|
|
240
|
+
*/
|
|
241
|
+
_cancelPendingEntity(entity: EntityHandle): void;
|
|
242
|
+
/**
|
|
243
|
+
* @internal Materialize a pending entity: actually place it into an archetype.
|
|
244
|
+
* Idempotent: a record with archetypeId !== -1 is already materialized.
|
|
245
|
+
*/
|
|
246
|
+
_materializePendingEntity(entity: EntityHandle, componentDatas: ComponentData[]): Result<void, EcsError>;
|
|
247
|
+
allocateIndex(): number;
|
|
248
|
+
/**
|
|
249
|
+
* Single liveness predicate (feat-20260602 / plan-strategy D-4): a slot is
|
|
250
|
+
* live for a given handle generation iff the record exists, its generation
|
|
251
|
+
* still matches the handle (despawn bumps generation, so a stale or recycled
|
|
252
|
+
* handle fails here), and the slot is materialized into an archetype
|
|
253
|
+
* (archetypeId !== -1). Replaces the former `record.alive && record.generation
|
|
254
|
+
* === gen` conjunction and the intermediate `!record.pending` clause.
|
|
255
|
+
*/
|
|
256
|
+
recordIsLive(record: EntityRecord | undefined, gen: number): record is EntityRecord;
|
|
257
|
+
lookupAlive(entity: EntityHandle, operation: string, component?: string): Result<EntityRecord, EcsError>;
|
|
258
|
+
readRow<S extends ComponentSchema>(arch: Archetype, component: Component<string, S>, row: number): ShapeOf<S>;
|
|
259
|
+
writeEntitySelf(arch: Archetype, row: number, handle: EntityHandle): void;
|
|
260
|
+
writeRow<S extends ComponentSchema>(arch: Archetype, component: Component<string, S>, row: number, value: ShapeOf<S>): void;
|
|
261
|
+
releaseManagedRefsOnRow(arch: Archetype, component: Component, row: number): void;
|
|
262
|
+
}
|
|
263
|
+
export {};
|
|
264
|
+
//# 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;AAazB,OAAO,EAEL,iBAAiB,EAGlB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,KAAK,SAAS,EAAsB,MAAM,qBAAqB,CAAC;AACzE,OAAO,EACL,KAAK,cAAc,EAKpB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAwB,KAAK,SAAS,EAAwB,MAAM,kBAAkB,CAAC;AAE9F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAGrE,KAAK,YAAY,GAAG;IAAE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC;AA2BpD,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC;IAC/B,QAAQ,CAAC,OAAO,EAAE,YAAY,EAAE,CAAC;IACjC,QAAQ,CAAC,WAAW,EAAE,MA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;;;OAIG;IACH,sBAAsB,IAAI,YAAY;IAMtC;;;;;OAKG;IACH,oBAAoB,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI;IAShD;;;OAGG;IACH,yBAAyB,CACvB,MAAM,EAAE,YAAY,EACpB,cAAc,EAAE,aAAa,EAAE,GAC9B,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC;IAyDzB,aAAa,IAAI,MAAM;IAavB;;;;;;;OAOG;IACH,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,SAAS,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,IAAI,YAAY;IAInF,WAAW,CACT,MAAM,EAAE,YAAY,EACpB,SAAS,EAAE,MAAM,EACjB,SAAS,CAAC,EAAE,MAAM,GACjB,MAAM,CAAC,YAAY,EAAE,QAAQ,CAAC;IAiBjC,OAAO,CAAC,CAAC,SAAS,eAAe,EAC/B,IAAI,EAAE,SAAS,EACf,SAAS,EAAE,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC,EAC/B,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,CAAC,CAAC;IAIb,eAAe,CAAC,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI;IAIzE,QAAQ,CAAC,CAAC,SAAS,eAAe,EAChC,IAAI,EAAE,SAAS,EACf,SAAS,EAAE,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC,EAC/B,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,GAChB,IAAI;IAIP,uBAAuB,CAAC,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI;CAGlF"}
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import type { BufferPool } from './buffer-pool';
|
|
2
|
+
import { type ArrayMeta, type Component, type ComponentSchema, type ManagedArrayElementType, type ShapeOf } from './component';
|
|
3
|
+
import { type EntityHandle } from './entity-handle';
|
|
4
|
+
import type { ManagedArrayErrorEnvelope } from './errors';
|
|
5
|
+
type ErrorContext = {
|
|
6
|
+
readonly systemName: string;
|
|
7
|
+
};
|
|
8
|
+
import type { SharedRefStore } from './shared-ref-store';
|
|
9
|
+
import { type Archetype } from './storage/archetype';
|
|
10
|
+
import { type ArchetypeGraph } from './storage/archetype-graph';
|
|
11
|
+
import { type FieldView } from './storage/column';
|
|
12
|
+
import type { UniqueRefStore } from './unique-ref-store';
|
|
13
|
+
import type { EntityRecord } from './world';
|
|
14
|
+
export interface ComponentStorageState {
|
|
15
|
+
readonly graph: ArchetypeGraph;
|
|
16
|
+
readonly records: EntityRecord[];
|
|
17
|
+
readonly bufferPool: BufferPool;
|
|
18
|
+
readonly uniqueRefs: UniqueRefStore;
|
|
19
|
+
readonly sharedRefs: SharedRefStore;
|
|
20
|
+
routeError(err: unknown, ctx: ErrorContext): void;
|
|
21
|
+
}
|
|
22
|
+
export declare class ComponentStorage {
|
|
23
|
+
private readonly state;
|
|
24
|
+
constructor(state: ComponentStorageState);
|
|
25
|
+
private get records();
|
|
26
|
+
private table;
|
|
27
|
+
private get bufferPool();
|
|
28
|
+
private get uniqueRefs();
|
|
29
|
+
private get sharedRefs();
|
|
30
|
+
private routeError;
|
|
31
|
+
readArrayView(arch: Archetype, component: Component, row: number, fieldName: string): FieldView | undefined;
|
|
32
|
+
readRow<S extends ComponentSchema>(arch: Archetype, component: Component<string, S>, row: number): ShapeOf<S>;
|
|
33
|
+
/**
|
|
34
|
+
* Write the full packed entity handle into the row's essential id=0 `Entity`
|
|
35
|
+
* column (`self` field). Called by `spawn` / `_materializePendingEntity`
|
|
36
|
+
* after the row is appended (feat-20260602 / plan-strategy D-3). The column
|
|
37
|
+
* always exists -- `createArchetype` folds the Entity column into every
|
|
38
|
+
* archetype -- so this is a direct u32 store, no readRow/writeRow walk.
|
|
39
|
+
*/
|
|
40
|
+
writeEntitySelf(arch: Archetype, row: number, handle: EntityHandle): void;
|
|
41
|
+
writeRow<S extends ComponentSchema>(arch: Archetype, component: Component<string, S>, row: number, value: ShapeOf<S>): void;
|
|
42
|
+
/**
|
|
43
|
+
* Release every managed-resource field on `component` for the row at
|
|
44
|
+
* `row` in `arch`. Walks the schema once and delegates each field to
|
|
45
|
+
* `releaseManagedFieldOnRow` (feat-20260614 M2 SSOT). Family coverage
|
|
46
|
+
* (per-field) lives in that helper's JSDoc.
|
|
47
|
+
*
|
|
48
|
+
* Naming note (D-6 whitelist): the prefix `managed` here means
|
|
49
|
+
* `managed = ECS-tracked` — i.e. fields whose lifecycle the ECS
|
|
50
|
+
* actively releases on despawn / overwrite / removeComponent. It does
|
|
51
|
+
* NOT refer to the retired `'managed' | 'unmanaged'` Handle brand
|
|
52
|
+
* (renamed to `'unique' | 'shared'` in feat-20260614 M1). The helper
|
|
53
|
+
* walks BOTH `'unique<T>'` and `'shared<T>'` fields because both are
|
|
54
|
+
* ECS-tracked from the column's perspective; the per-field dispatch
|
|
55
|
+
* inside `releaseManagedFieldOnRow` distinguishes drop-on-despawn
|
|
56
|
+
* (unique) vs ref-counted release (shared).
|
|
57
|
+
*
|
|
58
|
+
* Skips sentinel slots (handle / id 0) and missing stores. Failures
|
|
59
|
+
* (double release / lookup mismatch) route to the Layer 3 ErrorHandler so
|
|
60
|
+
* the despawn / removeComponent chain never aborts (charter: explicit-
|
|
61
|
+
* failure boundary; the chain is total).
|
|
62
|
+
*
|
|
63
|
+
* Four release paths route through this helper (AC-11, plan §6 M2):
|
|
64
|
+
* 1. `world.despawn(e)` - every component on `e`.
|
|
65
|
+
* 2. `world.removeComponent(e, C)` - the removed component only.
|
|
66
|
+
* 3. `world.set` ref/string/buffer overwrite - per-field, before the new
|
|
67
|
+
* value lands in the column.
|
|
68
|
+
* 4. `writeArrayField` set arm prior-slot release (variable array<T>).
|
|
69
|
+
*
|
|
70
|
+
* After feat-20260614 M2 SSOT collapse the schema-field 3-arm dispatch
|
|
71
|
+
* lives in `releaseManagedFieldOnRow` (one site); this method walks the
|
|
72
|
+
* component schema and delegates per field.
|
|
73
|
+
*
|
|
74
|
+
* BufferPool slot id is reusable post-release: same-bucket free-list LIFO
|
|
75
|
+
* (D-7) returns the freed id on the next `alloc(byteLength)`. Tests:
|
|
76
|
+
* `__tests__/managed-array-release.test.ts` (w10) +
|
|
77
|
+
* `__tests__/world-managed-roundtrip.unit.test.ts` (w3 net-zero matrix).
|
|
78
|
+
*/
|
|
79
|
+
releaseManagedRefsOnRow(arch: Archetype, component: Component, row: number): void;
|
|
80
|
+
/**
|
|
81
|
+
* SSOT release dispatch for a single managed field on a row (feat-20260614
|
|
82
|
+
* M2 / D-2). Inspects the component schema's field type and routes to the
|
|
83
|
+
* matching release path:
|
|
84
|
+
*
|
|
85
|
+
* - `'unique<T>'` / `'string'` (`isManagedField`) — release the
|
|
86
|
+
* UniqueRefStore handle u32 stored in the column.
|
|
87
|
+
* - `'buffer'` variable (`isManagedBufferField`) — release the
|
|
88
|
+
* BufferPool slot id stored in the column. Fixed `'buffer<N>'` is
|
|
89
|
+
* inline stride-N (feat-20260602) and has no slot to release.
|
|
90
|
+
* - `array<T>` variable (`isManagedArrayField`) — release the
|
|
91
|
+
* BufferPool slot id in the primary column + zero the column and the
|
|
92
|
+
* `<fieldName>:count` sidecar so post-recycle reads observe count=0
|
|
93
|
+
* (defense-in-depth; the swap-pop row migration overwrites both
|
|
94
|
+
* columns anyway). Fixed `array<T,N>` is inline stride-N — nothing to
|
|
95
|
+
* release.
|
|
96
|
+
*
|
|
97
|
+
* Sentinel handle / slot id 0 short-circuits silently. Double-release /
|
|
98
|
+
* lookup mismatch routes via Layer 3 ErrorHandler so the despawn /
|
|
99
|
+
* removeComponent / set chain never aborts (charter explicit-failure
|
|
100
|
+
* boundary; the chain is total).
|
|
101
|
+
*
|
|
102
|
+
* SceneInstance state alloc/release rollback at world.ts:3494/3522 stays
|
|
103
|
+
* a direct `uniqueRefs.release(stateRef)` (research Finding 1.8 / D-5):
|
|
104
|
+
* those two sites are alloc-pair rollback, not schema-field dispatch.
|
|
105
|
+
*
|
|
106
|
+
* Naming note (D-6 whitelist): `releaseManagedFieldOnRow` uses
|
|
107
|
+
* `managed = ECS-tracked` — every field family this dispatcher knows
|
|
108
|
+
* (`'unique<T>'`, `'shared<T>'`, `'string'`, variable `'buffer'`,
|
|
109
|
+
* variable `'array<T>'`) is one whose lifecycle the ECS owns. The
|
|
110
|
+
* `'managed' | 'unmanaged'` Handle brand is gone (M1 renamed to
|
|
111
|
+
* `'unique' | 'shared'`); the helper name was deliberately kept
|
|
112
|
+
* because `managed` here is a column-side semantic, not a brand label.
|
|
113
|
+
*/
|
|
114
|
+
releaseManagedFieldOnRow(arch: Archetype, component: Component, row: number, fieldName: string): void;
|
|
115
|
+
/**
|
|
116
|
+
* Release a single managed handle u32. Routes failures through Layer 3.
|
|
117
|
+
* Slot-0 sentinel short-circuits silently (no error); already-released
|
|
118
|
+
* slots surface `unique-ref-double-release` through the ErrorHandler so
|
|
119
|
+
* AI users see the structured payload (`.code` / `.hint` / `.expected` /
|
|
120
|
+
* `.detail`) - charter explicit-failure boundary.
|
|
121
|
+
*
|
|
122
|
+
* Helper-internal only after feat-20260614 M2 (AC-03 grep gate). External
|
|
123
|
+
* callers route via `releaseManagedFieldOnRow`.
|
|
124
|
+
*/
|
|
125
|
+
releaseManagedRefHandle(handleU32: number, componentName: string, fieldName: string): void;
|
|
126
|
+
/**
|
|
127
|
+
* Release a single shared-ref handle u32 (feat-20260614 M4 / AC-08).
|
|
128
|
+
* Decrements the SharedRefStore refcount; the slot drops on rc 1 -> 0.
|
|
129
|
+
* Slot-0 sentinel short-circuits silently. Already-released slots route
|
|
130
|
+
* `shared-ref-double-release` through Layer 3 ErrorHandler so AI users
|
|
131
|
+
* see structured payloads (charter explicit-failure boundary).
|
|
132
|
+
*
|
|
133
|
+
* Mirrors `releaseManagedRefHandle` in shape; the store + error code are
|
|
134
|
+
* the only differences. Helper-internal — external callers route via
|
|
135
|
+
* `releaseManagedFieldOnRow` (D-2 SSOT).
|
|
136
|
+
*/
|
|
137
|
+
releaseSharedRefHandle(handleU32: number, componentName: string, fieldName: string): void;
|
|
138
|
+
/**
|
|
139
|
+
* Retain a single `shared<T>` scalar slot id (feat-20260614 M5 / D-5).
|
|
140
|
+
* Mirrors `releaseSharedRefHandle`; called from spawn / set scalar write
|
|
141
|
+
* paths so each ECS holder participates in the SharedRefStore rc.
|
|
142
|
+
* Sentinel slot 0 is a no-op. Failures (handle already released) route
|
|
143
|
+
* via Layer 3 ErrorHandler so the spawn / set chain stays total.
|
|
144
|
+
*/
|
|
145
|
+
retainSharedScalarHandle(handleU32: number, componentName: string, fieldName: string): void;
|
|
146
|
+
/**
|
|
147
|
+
* Release a single managed buffer slot id. Routes failures through Layer 3.
|
|
148
|
+
* Slot id 0 (sentinel for unallocated buffer fields) short-circuits
|
|
149
|
+
* silently. M2 v1 release surface is total - `BufferPool.release` returns
|
|
150
|
+
* `Result<void, never>` for unknown ids, so the chain stays noise-free.
|
|
151
|
+
*
|
|
152
|
+
* Helper-internal only after feat-20260614 M2 (AC-03 grep gate). External
|
|
153
|
+
* callers route via `releaseManagedFieldOnRow`.
|
|
154
|
+
*/
|
|
155
|
+
releaseManagedBufferSlot(slotId: number, componentName: string, fieldName: string): void;
|
|
156
|
+
/**
|
|
157
|
+
* Bridge a Layer-3 ErrorHandler call from a `ManagedArrayErrorEnvelope`.
|
|
158
|
+
* The envelope shape (`code / hint / expected / detail`) already mirrors
|
|
159
|
+
* the EcsError contract; this helper only attaches the systemName context
|
|
160
|
+
* so AI users can correlate the error with the holder component / field.
|
|
161
|
+
*/
|
|
162
|
+
routeArrayError(err: ManagedArrayErrorEnvelope, componentName: string, fieldName: string): void;
|
|
163
|
+
/**
|
|
164
|
+
* Write the value of an `array<T>` / `array<T,N>` field at `row` (D-3 +
|
|
165
|
+
/**
|
|
166
|
+
* Write an `array<T>` / `array<T,N>` field's payload at `row` (M1 / w7,
|
|
167
|
+
* D-1; feat-20260614 M2 / D-3). Spawn and set both delegate here without
|
|
168
|
+
* an `operation` parameter — the caller's calling convention encodes the
|
|
169
|
+
* difference:
|
|
170
|
+
* - Set path: caller invokes `releaseManagedFieldOnRow(arch, comp, row,
|
|
171
|
+
* fieldName)` BEFORE this method to release the prior slot (variable
|
|
172
|
+
* `array<T>`). Fixed `array<T,N>` is inline stride-N (feat-20260602)
|
|
173
|
+
* and has no slot to release on either path.
|
|
174
|
+
* - Spawn path: caller does NOT call the helper — fresh rows treat any
|
|
175
|
+
* non-zero u32 in the column as stale swap-pop debris owned by the
|
|
176
|
+
* migrated entity in the new archetype.
|
|
177
|
+
*
|
|
178
|
+
* Body:
|
|
179
|
+
* - Alloc a fresh BufferPool slot of `payload.length * elementBytes`.
|
|
180
|
+
* - Copy bytes from the payload's typed-array buffer into the slot view.
|
|
181
|
+
* - Persist slot id in the primary u32 column. For `array<T>` (variable),
|
|
182
|
+
* persist the live count in the sidecar `<fieldName>:count` column.
|
|
183
|
+
*
|
|
184
|
+
* Errors flow through `routeArrayError` with a uniform `World.write` label.
|
|
185
|
+
*/
|
|
186
|
+
writeArrayField(arch: Archetype, component: Component, row: number, fieldName: string, _fieldType: string, arrayMeta: ArrayMeta, raw: unknown): void;
|
|
187
|
+
/**
|
|
188
|
+
* Walk the first `count` u32 handles in `bytes` and call
|
|
189
|
+
* `SharedRefStore.retain` on each non-sentinel slot id (feat-20260614 M4 /
|
|
190
|
+
* D-3). Failures route via Layer 3 ErrorHandler so the write chain stays
|
|
191
|
+
* total; charter explicit-failure boundary lets AI users see structured
|
|
192
|
+
* `shared-ref-released` payloads when retaining a stale handle.
|
|
193
|
+
*
|
|
194
|
+
* Helper-internal -- only called from `writeArrayField`'s `'shared'` arm.
|
|
195
|
+
*/
|
|
196
|
+
retainSharedArrayElements(bytes: Uint8Array, count: number): void;
|
|
197
|
+
/**
|
|
198
|
+
* Walk the first `count` u32 handles in `bytes` and call
|
|
199
|
+
* `SharedRefStore.release` on each non-sentinel slot id (feat-20260614 M4 /
|
|
200
|
+
* D-3). Mirrors `retainSharedArrayElements`; called from
|
|
201
|
+
* `releaseManagedFieldOnRow`'s array arm BEFORE the BufferPool slot is
|
|
202
|
+
* released so the underlying bytes are still valid.
|
|
203
|
+
*/
|
|
204
|
+
releaseSharedArrayElements(bytes: Uint8Array, count: number): void;
|
|
205
|
+
writeArrayElementAt(bytes: Uint8Array, idx: number, elementType: ManagedArrayElementType, value: number): void;
|
|
206
|
+
readArrayElementAt(bytes: Uint8Array, idx: number, elementType: ManagedArrayElementType): number;
|
|
207
|
+
/**
|
|
208
|
+
* Materialise a fresh `TypedArray` snapshot for an `array<T,N>` /
|
|
209
|
+
* `array<T>` field at `row` (plan-strategy §2.2 -- read-only snapshot
|
|
210
|
+
* contract; mutations route through `world.set` / `world.push` /
|
|
211
|
+
* `world.pop`).
|
|
212
|
+
*
|
|
213
|
+
* **Transient view contract (feat-20260602):** for fixed `array<T,N>`
|
|
214
|
+
* columns the returned `TypedArray` aliases the inline column buffer
|
|
215
|
+
* directly (`col.view.subarray(row * arity, ...)`); for variable
|
|
216
|
+
* `array<T>` columns it aliases the live `BufferPool` slot bytes
|
|
217
|
+
* (zero-copy; `pool.view(slotId)` is the SSOT byte region). In both
|
|
218
|
+
* cases the view is valid only until the next structural change. Writing
|
|
219
|
+
* into the snapshot is undefined behaviour -- the contract is read-only
|
|
220
|
+
* and the implementation may switch to a copy in the future without
|
|
221
|
+
* breaking AI users who consume only `length` / index reads.
|
|
222
|
+
*
|
|
223
|
+
* For variable arrays the typed-array length matches the live count from
|
|
224
|
+
* the sidecar `<fieldName>:count` column; for fixed arrays it matches the
|
|
225
|
+
* schema-declared `N`. `entity` element fields surface as a `Uint32Array`
|
|
226
|
+
* view (Entity packs slot+gen into u32).
|
|
227
|
+
*/
|
|
228
|
+
materializeArrayView(arch: Archetype, component: Component, row: number, fieldName: string, elementType: ManagedArrayElementType, fixedLength: number | undefined, slotId: number): Float32Array | Float64Array | Int32Array | Uint32Array | Int16Array | Uint16Array | Int8Array | Uint8Array;
|
|
229
|
+
/**
|
|
230
|
+
* Migrate an entity from srcArch to targetArch.
|
|
231
|
+
* Copies all shared component data, then removes from src via swap-pop.
|
|
232
|
+
*
|
|
233
|
+
* AC-04 carry-over contract (M4): for every component that survives the
|
|
234
|
+
* migration (i.e. the target archetype carries the same `compId`), every
|
|
235
|
+
* field column's u32 value is copied verbatim from src to target. This
|
|
236
|
+
* preserves every managed resource handle in place:
|
|
237
|
+
*
|
|
238
|
+
* - `ref<T>` field - the u32 (managed handle = (slot << 8) | gen) is
|
|
239
|
+
* bit-equal across migrate, so `Object.is` on the
|
|
240
|
+
* handle holds and `UniqueRefStore.resolve` returns
|
|
241
|
+
* the same payload object reference (per-(slot, gen)
|
|
242
|
+
* wrapper singleton, D-3).
|
|
243
|
+
* - `buffer<N>` field - fixed-capacity inline stride-N `u8` column
|
|
244
|
+
* (feat-20260602): the N bytes are copied verbatim
|
|
245
|
+
* by the generic per-column row copy, so the live
|
|
246
|
+
* bytes survive byte-for-byte. No BufferPool slot
|
|
247
|
+
* (only variable `buffer` carries a pool slot id).
|
|
248
|
+
* - `entity` field - the u32 (encoded slot+gen) is bit-equal across
|
|
249
|
+
* migrate.
|
|
250
|
+
* - `array<T,N>` field - fixed-capacity inline stride-N column
|
|
251
|
+
* (feat-20260602): the N elements live contiguously
|
|
252
|
+
* in the column row and are copied verbatim by the
|
|
253
|
+
* generic per-column row copy, so they survive
|
|
254
|
+
* byte-for-byte (no BufferPool slot). The TypedArray
|
|
255
|
+
* snapshot is rematerialised on every `world.get`
|
|
256
|
+
* (D-4 no cache); we do NOT guarantee `Object.is` on
|
|
257
|
+
* the wrapper — only the underlying bytes (D-R7 weak
|
|
258
|
+
* carry-over).
|
|
259
|
+
* - `array<T>` field - dual u32 columns: primary slot id + sidecar
|
|
260
|
+
* `<fieldName>:count`. Both columns are copied via
|
|
261
|
+
* the generic per-column loop below, so count and
|
|
262
|
+
* slot id stay in lock-step. Capacity is derived
|
|
263
|
+
* from `BufferPool.view(slotId).byteLength /
|
|
264
|
+
* elementBytes` and is therefore preserved by the
|
|
265
|
+
* slot-id carry-over alone (no separate column).
|
|
266
|
+
*
|
|
267
|
+
* Negative invariant: this routine MUST NOT call UniqueRefStore.release /
|
|
268
|
+
* BufferPool.release for surviving components. The pre-migrate release
|
|
269
|
+
* loop lives at `removeComponent` (only for the component being removed)
|
|
270
|
+
* and `despawn` (every component); migrate is only a column copy. The
|
|
271
|
+
* array-field release-loop split (D-3 / D-5) further guarantees that
|
|
272
|
+
* spawn into a vacated row treats stale slot-id debris as no-op (the slot
|
|
273
|
+
* is owned by the migrated entity in the new archetype) — see
|
|
274
|
+
* `writeArrayField`'s `operation: 'spawn' | 'set'` discriminant.
|
|
275
|
+
* Tests: `__tests__/managed-carry-over.test.ts` (w16),
|
|
276
|
+
* `__tests__/managed-array-carry-over.test.ts` (w8).
|
|
277
|
+
*/
|
|
278
|
+
migrateEntity(record: EntityRecord, srcArch: Archetype, targetArch: Archetype): void;
|
|
279
|
+
moveEntityArchetype(record: EntityRecord, srcArch: Archetype, targetArch: Archetype): void;
|
|
280
|
+
}
|
|
281
|
+
export {};
|
|
282
|
+
//# sourceMappingURL=world-component-storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"world-component-storage.d.ts","sourceRoot":"","sources":["../src/world-component-storage.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EACL,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,eAAe,EAQpB,KAAK,uBAAuB,EAC5B,KAAK,OAAO,EAEb,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAmB,KAAK,YAAY,EAAiC,MAAM,iBAAiB,CAAC;AACpG,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAE1D,KAAK,YAAY,GAAG;IAAE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;CA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I;CAmB3F"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { BufferPool } from './buffer-pool';
|
|
2
|
+
import type { RelationshipIndex } from './relationship-index';
|
|
3
|
+
import type { SharedRefStore } from './shared-ref-store';
|
|
4
|
+
import { type ArchetypeGraph } from './storage/archetype-graph';
|
|
5
|
+
import { WorldChangeJournal } from './storage/change-detection';
|
|
6
|
+
import type { UniqueRefStore } from './unique-ref-store';
|
|
7
|
+
import type { EntityRecord } from './world';
|
|
8
|
+
interface WorldStorageCore {
|
|
9
|
+
readonly graph: ArchetypeGraph;
|
|
10
|
+
readonly records: EntityRecord[];
|
|
11
|
+
readonly freeIndices: number[];
|
|
12
|
+
readonly bufferPool: BufferPool;
|
|
13
|
+
readonly uniqueRefs: UniqueRefStore;
|
|
14
|
+
readonly sharedRefs: SharedRefStore;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Package-private state authority for World. A World is the public facade;
|
|
18
|
+
* this object is the only owner of archetype storage, entity records, managed
|
|
19
|
+
* stores, epochs, and bounded change evidence.
|
|
20
|
+
*/
|
|
21
|
+
export declare class WorldCore {
|
|
22
|
+
readonly identity: string;
|
|
23
|
+
readonly uniqueRefs: UniqueRefStore;
|
|
24
|
+
readonly sharedRefs: SharedRefStore;
|
|
25
|
+
readonly storage: WorldStorageCore;
|
|
26
|
+
readonly componentMutationEpochs: number[];
|
|
27
|
+
readonly changeJournal: WorldChangeJournal;
|
|
28
|
+
/** One packed reverse index per relationship source component. */
|
|
29
|
+
readonly relationshipIndexes: Map<number, RelationshipIndex>;
|
|
30
|
+
mutationEpoch: number;
|
|
31
|
+
structureEpoch: number;
|
|
32
|
+
constructor(sharedStorage: boolean);
|
|
33
|
+
get graph(): ArchetypeGraph;
|
|
34
|
+
get records(): EntityRecord[];
|
|
35
|
+
get freeIndices(): number[];
|
|
36
|
+
get bufferPool(): BufferPool;
|
|
37
|
+
}
|
|
38
|
+
export {};
|
|
39
|
+
//# sourceMappingURL=world-core.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AK,mBAER;IAED,IAAI,OAAO,mBAEV;IAED,IAAI,WAAW,aAEd;IAED,IAAI,UAAU,eAEb;CACF"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type Result } from '@forgeax/engine-types';
|
|
2
|
+
import type { Component, ComponentSchema, InputShapeOf } from './component';
|
|
3
|
+
import { type EntityHandle } from './entity-handle';
|
|
4
|
+
import type { EcsError, World } from './world';
|
|
5
|
+
/**
|
|
6
|
+
* Core implementation of `spawn` with a relationship reentry guard.
|
|
7
|
+
*
|
|
8
|
+
* @param internal - `true` when relationship maintenance creates a mirror.
|
|
9
|
+
*/
|
|
10
|
+
export declare function spawnCore(world: World, componentDatas: {
|
|
11
|
+
component: Component;
|
|
12
|
+
data: Partial<Record<string, unknown>>;
|
|
13
|
+
}[], internal: boolean): Result<EntityHandle, EcsError>;
|
|
14
|
+
/**
|
|
15
|
+
* Core implementation of `despawn` with a linked-spawn cascade guard.
|
|
16
|
+
*
|
|
17
|
+
* @param internal - `true` while recursively retiring linked children.
|
|
18
|
+
*/
|
|
19
|
+
export declare function despawnCore(world: World, entity: EntityHandle, internal: boolean): Result<void, EcsError>;
|
|
20
|
+
/** Attach a child and maintain the relationship mirror through component storage. */
|
|
21
|
+
export declare function worldAddChild<S extends ComponentSchema>(world: World, parent: EntityHandle, child: EntityHandle, component: Component<string, S>, data: Partial<InputShapeOf<S>>): Result<void, EcsError>;
|
|
22
|
+
/** Detach a child only when its current relationship target matches `parent`. */
|
|
23
|
+
export declare function worldRemoveChild<S extends ComponentSchema>(world: World, parent: EntityHandle, child: EntityHandle, component: Component<string, S>): Result<void, EcsError>;
|
|
24
|
+
/** Move a child to a new parent after cycle validation and old-mirror detachment. */
|
|
25
|
+
export declare function worldReparent<S extends ComponentSchema>(world: World, child: EntityHandle, newParent: EntityHandle, component: Component<string, S>, data: Partial<InputShapeOf<S>>): Result<void, EcsError>;
|
|
26
|
+
/** Iterate ancestors in child-to-root order while safely terminating corrupt cycles. */
|
|
27
|
+
export declare function worldIterAncestors(world: World, entity: EntityHandle): Iterable<EntityHandle>;
|
|
28
|
+
/** Iterate descendants depth-first through relationship mirror lists. */
|
|
29
|
+
export declare function worldIterDescendants(world: World, entity: EntityHandle): Iterable<EntityHandle>;
|
|
30
|
+
//# sourceMappingURL=world-entity-lifecycle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"world-entity-lifecycle.d.ts","sourceRoot":"","sources":["../src/world-entity-lifecycle.ts"],"names":[],"mappings":"AAMA,OAAO,EAAgC,KAAK,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAClF,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,YAAY,EAAW,MAAM,aAAa,CAAC;AAKrF,OAAO,EAEL,KAAK,YAAY,EAIlB,MAAM,iBAAiB,CAAC;AAczB,OAAO,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAQ/C;;;;GAIG;AACH,wBAAgB,SAAS,CACvB,KAAK,EAAE,KAAK,EACZ,cAAc,EAAE;IAAE,SAAS,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;CAAE,EAAE,EAClF,QAAQ,EAAE,OAAO,GAChB,MAAM,CAAC,YAAY,EAAE,QAAQ,CAAC,CA0DhC;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,YAAY,EACpB,QAAQ,EAAE,OAAO,GAChB,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,CA+DxB;AAED,qFAAqF;AACrF,wBAAgB,aAAa,CAAC,CAAC,SAAS,eAAe,EACrD,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,YAAY,EACpB,KAAK,EAAE,YAAY,EACnB,SAAS,EAAE,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC,EAC/B,IAAI,EAAE,OAAO,CAA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