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