@forgeax/engine-ecs 0.0.0-dev.8d955ade1c79
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +278 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/__fixtures__/field-shape-fixture.d.ts +16 -0
- package/dist/__fixtures__/field-shape-fixture.d.ts.map +1 -0
- package/dist/__tests__/__fixtures__/inspect-scripts.snapshot.d.ts +3 -0
- package/dist/__tests__/__fixtures__/inspect-scripts.snapshot.d.ts.map +1 -0
- package/dist/__tests__/archetype.unit.test.d.ts +2 -0
- package/dist/__tests__/archetype.unit.test.d.ts.map +1 -0
- package/dist/__tests__/array-handle-element.test-d.d.ts +2 -0
- package/dist/__tests__/array-handle-element.test-d.d.ts.map +1 -0
- package/dist/__tests__/buffer-array-vocab.test-d.d.ts +2 -0
- package/dist/__tests__/buffer-array-vocab.test-d.d.ts.map +1 -0
- package/dist/__tests__/buffer-field-input-widen.unit.test.d.ts +2 -0
- package/dist/__tests__/buffer-field-input-widen.unit.test.d.ts.map +1 -0
- package/dist/__tests__/buffer-pool.test-d.d.ts +2 -0
- package/dist/__tests__/buffer-pool.test-d.d.ts.map +1 -0
- package/dist/__tests__/change-detection.unit.test.d.ts +2 -0
- package/dist/__tests__/change-detection.unit.test.d.ts.map +1 -0
- package/dist/__tests__/command-buffer.test.d.ts +2 -0
- package/dist/__tests__/command-buffer.test.d.ts.map +1 -0
- package/dist/__tests__/commands-deferred.unit.test.d.ts +2 -0
- package/dist/__tests__/commands-deferred.unit.test.d.ts.map +1 -0
- package/dist/__tests__/component-catalog.test.d.ts +2 -0
- package/dist/__tests__/component-catalog.test.d.ts.map +1 -0
- package/dist/__tests__/component-definition-identity.unit.test.d.ts +2 -0
- package/dist/__tests__/component-definition-identity.unit.test.d.ts.map +1 -0
- package/dist/__tests__/component-nan-preflight.unit.test.d.ts +2 -0
- package/dist/__tests__/component-nan-preflight.unit.test.d.ts.map +1 -0
- package/dist/__tests__/component-schema.test-d.d.ts +2 -0
- package/dist/__tests__/component-schema.test-d.d.ts.map +1 -0
- package/dist/__tests__/component-schema.test.d.ts +2 -0
- package/dist/__tests__/component-schema.test.d.ts.map +1 -0
- package/dist/__tests__/define-component-options.test-d.d.ts +2 -0
- package/dist/__tests__/define-component-options.test-d.d.ts.map +1 -0
- package/dist/__tests__/deprecated-vocab-rejection.unit.test.d.ts +2 -0
- package/dist/__tests__/deprecated-vocab-rejection.unit.test.d.ts.map +1 -0
- package/dist/__tests__/despawn-all.unit.test.d.ts +2 -0
- package/dist/__tests__/despawn-all.unit.test.d.ts.map +1 -0
- package/dist/__tests__/ecs-core-reduction.characterization.test.d.ts +2 -0
- package/dist/__tests__/ecs-core-reduction.characterization.test.d.ts.map +1 -0
- package/dist/__tests__/ecs-core-reduction.perf.test.d.ts +2 -0
- package/dist/__tests__/ecs-core-reduction.perf.test.d.ts.map +1 -0
- package/dist/__tests__/ecs-error-code-31.test-d.d.ts +2 -0
- package/dist/__tests__/ecs-error-code-31.test-d.d.ts.map +1 -0
- package/dist/__tests__/entity-disabling.unit.test.d.ts +2 -0
- package/dist/__tests__/entity-disabling.unit.test.d.ts.map +1 -0
- package/dist/__tests__/entity-handle-codec-parity.unit.test.d.ts +2 -0
- package/dist/__tests__/entity-handle-codec-parity.unit.test.d.ts.map +1 -0
- package/dist/__tests__/errors.unit.test.d.ts +2 -0
- package/dist/__tests__/errors.unit.test.d.ts.map +1 -0
- package/dist/__tests__/execution-conflict-boundary.unit.test.d.ts +2 -0
- package/dist/__tests__/execution-conflict-boundary.unit.test.d.ts.map +1 -0
- package/dist/__tests__/execution-shared-storage.unit.test.d.ts +2 -0
- package/dist/__tests__/execution-shared-storage.unit.test.d.ts.map +1 -0
- package/dist/__tests__/externalization-portable-value.unit.test.d.ts +2 -0
- package/dist/__tests__/externalization-portable-value.unit.test.d.ts.map +1 -0
- package/dist/__tests__/externalization-projection.unit.test.d.ts +2 -0
- package/dist/__tests__/externalization-projection.unit.test.d.ts.map +1 -0
- package/dist/__tests__/externalization-render-read-lease.test-d.d.ts +2 -0
- package/dist/__tests__/externalization-render-read-lease.test-d.d.ts.map +1 -0
- package/dist/__tests__/externalization-render-read-lease.unit.test.d.ts +2 -0
- package/dist/__tests__/externalization-render-read-lease.unit.test.d.ts.map +1 -0
- package/dist/__tests__/externalization-root-surface.unit.test.d.ts +2 -0
- package/dist/__tests__/externalization-root-surface.unit.test.d.ts.map +1 -0
- package/dist/__tests__/field-enum-labels-reflection.test.d.ts +2 -0
- package/dist/__tests__/field-enum-labels-reflection.test.d.ts.map +1 -0
- package/dist/__tests__/field-shape-fixture.test.d.ts +2 -0
- package/dist/__tests__/field-shape-fixture.test.d.ts.map +1 -0
- package/dist/__tests__/field-transient-reflection.test.d.ts +2 -0
- package/dist/__tests__/field-transient-reflection.test.d.ts.map +1 -0
- package/dist/__tests__/field-value-type.test-d.d.ts +2 -0
- package/dist/__tests__/field-value-type.test-d.d.ts.map +1 -0
- package/dist/__tests__/fixed-update.unit.test.d.ts +2 -0
- package/dist/__tests__/fixed-update.unit.test.d.ts.map +1 -0
- package/dist/__tests__/handle.test-d.d.ts +2 -0
- package/dist/__tests__/handle.test-d.d.ts.map +1 -0
- package/dist/__tests__/hierarchy.unit.test.d.ts +2 -0
- package/dist/__tests__/hierarchy.unit.test.d.ts.map +1 -0
- package/dist/__tests__/managed-array-vocab.test-d.d.ts +2 -0
- package/dist/__tests__/managed-array-vocab.test-d.d.ts.map +1 -0
- package/dist/__tests__/minimal-example.test-d.d.ts +2 -0
- package/dist/__tests__/minimal-example.test-d.d.ts.map +1 -0
- package/dist/__tests__/name-read-types.test-d.d.ts +2 -0
- package/dist/__tests__/name-read-types.test-d.d.ts.map +1 -0
- package/dist/__tests__/plugin-service.test.d.ts +2 -0
- package/dist/__tests__/plugin-service.test.d.ts.map +1 -0
- package/dist/__tests__/query-combinations.unit.test.d.ts +2 -0
- package/dist/__tests__/query-combinations.unit.test.d.ts.map +1 -0
- package/dist/__tests__/query-light-extract-flat-column-ratio.perf.test.d.ts +2 -0
- package/dist/__tests__/query-light-extract-flat-column-ratio.perf.test.d.ts.map +1 -0
- package/dist/__tests__/query-storage-trends.perf.test.d.ts +2 -0
- package/dist/__tests__/query-storage-trends.perf.test.d.ts.map +1 -0
- package/dist/__tests__/query-trs-flat-column-ratio.perf.test.d.ts +2 -0
- package/dist/__tests__/query-trs-flat-column-ratio.perf.test.d.ts.map +1 -0
- package/dist/__tests__/query.unit.test.d.ts +2 -0
- package/dist/__tests__/query.unit.test.d.ts.map +1 -0
- package/dist/__tests__/relationship-index.perf.test.d.ts +2 -0
- package/dist/__tests__/relationship-index.perf.test.d.ts.map +1 -0
- package/dist/__tests__/relationship-index.test.d.ts +2 -0
- package/dist/__tests__/relationship-index.test.d.ts.map +1 -0
- package/dist/__tests__/scalar-field-type-owner.test-d.d.ts +2 -0
- package/dist/__tests__/scalar-field-type-owner.test-d.d.ts.map +1 -0
- package/dist/__tests__/schedule-determinism.unit.test.d.ts +2 -0
- package/dist/__tests__/schedule-determinism.unit.test.d.ts.map +1 -0
- package/dist/__tests__/schedule-inspection.unit.test.d.ts +2 -0
- package/dist/__tests__/schedule-inspection.unit.test.d.ts.map +1 -0
- package/dist/__tests__/schedule-scope-error.unit.test.d.ts +2 -0
- package/dist/__tests__/schedule-scope-error.unit.test.d.ts.map +1 -0
- package/dist/__tests__/schedule-token.unit.test.d.ts +2 -0
- package/dist/__tests__/schedule-token.unit.test.d.ts.map +1 -0
- package/dist/__tests__/schema-vocab.test-d.d.ts +2 -0
- package/dist/__tests__/schema-vocab.test-d.d.ts.map +1 -0
- package/dist/__tests__/serialization.unit.test.d.ts +2 -0
- package/dist/__tests__/serialization.unit.test.d.ts.map +1 -0
- package/dist/__tests__/shared-kernel-eligibility.test-d.d.ts +2 -0
- package/dist/__tests__/shared-kernel-eligibility.test-d.d.ts.map +1 -0
- package/dist/__tests__/shared-kernel-eligibility.unit.test.d.ts +2 -0
- package/dist/__tests__/shared-kernel-eligibility.unit.test.d.ts.map +1 -0
- package/dist/__tests__/shared-ref-store.unit.test.d.ts +2 -0
- package/dist/__tests__/shared-ref-store.unit.test.d.ts.map +1 -0
- package/dist/__tests__/sparse-tag.unit.test.d.ts +2 -0
- package/dist/__tests__/sparse-tag.unit.test.d.ts.map +1 -0
- package/dist/__tests__/spawn-field-error.test-d.d.ts +2 -0
- package/dist/__tests__/spawn-field-error.test-d.d.ts.map +1 -0
- package/dist/__tests__/stale-error.test-d.d.ts +2 -0
- package/dist/__tests__/stale-error.test-d.d.ts.map +1 -0
- package/dist/__tests__/string-view-symmetry.test-d.d.ts +2 -0
- package/dist/__tests__/string-view-symmetry.test-d.d.ts.map +1 -0
- package/dist/__tests__/string-vocab.test-d.d.ts +2 -0
- package/dist/__tests__/string-vocab.test-d.d.ts.map +1 -0
- package/dist/__tests__/structure-epoch-boundaries.unit.test.d.ts +2 -0
- package/dist/__tests__/structure-epoch-boundaries.unit.test.d.ts.map +1 -0
- package/dist/__tests__/structure-epoch.unit.test.d.ts +2 -0
- package/dist/__tests__/structure-epoch.unit.test.d.ts.map +1 -0
- package/dist/__tests__/table-archetype-mapping.unit.test.d.ts +2 -0
- package/dist/__tests__/table-archetype-mapping.unit.test.d.ts.map +1 -0
- package/dist/__tests__/time.unit.test.d.ts +2 -0
- package/dist/__tests__/time.unit.test.d.ts.map +1 -0
- package/dist/__tests__/types.test-d.d.ts +2 -0
- package/dist/__tests__/types.test-d.d.ts.map +1 -0
- package/dist/__tests__/unique-ref-store.unit.test.d.ts +2 -0
- package/dist/__tests__/unique-ref-store.unit.test.d.ts.map +1 -0
- package/dist/__tests__/utils/handle-numeric.d.ts +14 -0
- package/dist/__tests__/utils/handle-numeric.d.ts.map +1 -0
- package/dist/__tests__/validation-root-surface.unit.test.d.ts +2 -0
- package/dist/__tests__/validation-root-surface.unit.test.d.ts.map +1 -0
- package/dist/__tests__/visibility-atomic-write.unit.test.d.ts +2 -0
- package/dist/__tests__/visibility-atomic-write.unit.test.d.ts.map +1 -0
- package/dist/__tests__/world-change-journal.unit.test.d.ts +2 -0
- package/dist/__tests__/world-change-journal.unit.test.d.ts.map +1 -0
- package/dist/__tests__/world-characterization.unit.test.d.ts +2 -0
- package/dist/__tests__/world-characterization.unit.test.d.ts.map +1 -0
- package/dist/__tests__/world-consumer-inference.test-d.d.ts +2 -0
- package/dist/__tests__/world-consumer-inference.test-d.d.ts.map +1 -0
- package/dist/__tests__/world-health.contract.test.d.ts +2 -0
- package/dist/__tests__/world-health.contract.test.d.ts.map +1 -0
- package/dist/__tests__/world-inspection.test.d.ts +2 -0
- package/dist/__tests__/world-inspection.test.d.ts.map +1 -0
- package/dist/__tests__/world-internal-identity.unit.test.d.ts +2 -0
- package/dist/__tests__/world-internal-identity.unit.test.d.ts.map +1 -0
- package/dist/__tests__/world-managed-roundtrip.unit.test.d.ts +2 -0
- package/dist/__tests__/world-managed-roundtrip.unit.test.d.ts.map +1 -0
- package/dist/__tests__/world-scheduling.m4.test.d.ts +2 -0
- package/dist/__tests__/world-scheduling.m4.test.d.ts.map +1 -0
- package/dist/__tests__/world-unique-roundtrip.unit.test.d.ts +2 -0
- package/dist/__tests__/world-unique-roundtrip.unit.test.d.ts.map +1 -0
- package/dist/__tests__/world.test-d.d.ts +2 -0
- package/dist/__tests__/world.test-d.d.ts.map +1 -0
- package/dist/buffer-pool.d.ts +109 -0
- package/dist/buffer-pool.d.ts.map +1 -0
- package/dist/commands.d.ts +93 -0
- package/dist/commands.d.ts.map +1 -0
- package/dist/component-default-fallback.d.ts +88 -0
- package/dist/component-default-fallback.d.ts.map +1 -0
- package/dist/component-schema.d.ts +34 -0
- package/dist/component-schema.d.ts.map +1 -0
- package/dist/component-value-validate.d.ts +29 -0
- package/dist/component-value-validate.d.ts.map +1 -0
- package/dist/component.d.ts +581 -0
- package/dist/component.d.ts.map +1 -0
- package/dist/entity-handle.d.ts +68 -0
- package/dist/entity-handle.d.ts.map +1 -0
- package/dist/entity.d.ts +86 -0
- package/dist/entity.d.ts.map +1 -0
- package/dist/errors/query-and-component-errors.d.ts +132 -0
- package/dist/errors/query-and-component-errors.d.ts.map +1 -0
- package/dist/errors/relationship-errors.d.ts +112 -0
- package/dist/errors/relationship-errors.d.ts.map +1 -0
- package/dist/errors/sprite-and-shared-errors.d.ts +107 -0
- package/dist/errors/sprite-and-shared-errors.d.ts.map +1 -0
- package/dist/errors/validation-errors.d.ts +229 -0
- package/dist/errors/validation-errors.d.ts.map +1 -0
- package/dist/errors.d.ts +763 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/execution/shared-kernel.d.ts +106 -0
- package/dist/execution/shared-kernel.d.ts.map +1 -0
- package/dist/externalization/index.d.ts +31 -0
- package/dist/externalization/index.d.ts.map +1 -0
- package/dist/externalization/index.mjs +298 -0
- package/dist/externalization/index.mjs.map +1 -0
- package/dist/index.d.ts +261 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.mjs +7422 -0
- package/dist/index.mjs.map +1 -0
- package/dist/internal.mjs +479 -0
- package/dist/internal.mjs.map +1 -0
- package/dist/plugin-service.d.ts +11 -0
- package/dist/plugin-service.d.ts.map +1 -0
- package/dist/projection/index.d.ts +103 -0
- package/dist/projection/index.d.ts.map +1 -0
- package/dist/projection/index.mjs +615 -0
- package/dist/projection/index.mjs.map +1 -0
- package/dist/query/query.d.ts +58 -0
- package/dist/query/query.d.ts.map +1 -0
- package/dist/relationship-index.d.ts +81 -0
- package/dist/relationship-index.d.ts.map +1 -0
- package/dist/resource.d.ts +70 -0
- package/dist/resource.d.ts.map +1 -0
- package/dist/schedule-token.d.ts +16 -0
- package/dist/schedule-token.d.ts.map +1 -0
- package/dist/schedule.d.ts +271 -0
- package/dist/schedule.d.ts.map +1 -0
- package/dist/shared-ref-store.d.ts +144 -0
- package/dist/shared-ref-store.d.ts.map +1 -0
- package/dist/shared.d.ts +3 -0
- package/dist/shared.d.ts.map +1 -0
- package/dist/shared.mjs +364 -0
- package/dist/shared.mjs.map +1 -0
- package/dist/storage/archetype-graph.d.ts +54 -0
- package/dist/storage/archetype-graph.d.ts.map +1 -0
- package/dist/storage/archetype.d.ts +23 -0
- package/dist/storage/archetype.d.ts.map +1 -0
- package/dist/storage/change-detection.d.ts +40 -0
- package/dist/storage/change-detection.d.ts.map +1 -0
- package/dist/storage/column.d.ts +111 -0
- package/dist/storage/column.d.ts.map +1 -0
- package/dist/storage/table.d.ts +29 -0
- package/dist/storage/table.d.ts.map +1 -0
- package/dist/time.d.ts +57 -0
- package/dist/time.d.ts.map +1 -0
- package/dist/unique-ref-store.d.ts +105 -0
- package/dist/unique-ref-store.d.ts.map +1 -0
- package/dist/world-change-journal.d.ts +34 -0
- package/dist/world-change-journal.d.ts.map +1 -0
- package/dist/world-component-access.d.ts +265 -0
- package/dist/world-component-access.d.ts.map +1 -0
- package/dist/world-component-storage.d.ts +282 -0
- package/dist/world-component-storage.d.ts.map +1 -0
- package/dist/world-core.d.ts +39 -0
- package/dist/world-core.d.ts.map +1 -0
- package/dist/world-entity-lifecycle.d.ts +30 -0
- package/dist/world-entity-lifecycle.d.ts.map +1 -0
- package/dist/world-internal.d.ts +14 -0
- package/dist/world-internal.d.ts.map +1 -0
- package/dist/world-scheduling.d.ts +30 -0
- package/dist/world-scheduling.d.ts.map +1 -0
- package/dist/world.d.ts +620 -0
- package/dist/world.d.ts.map +1 -0
- package/package.json +77 -0
- package/src/__fixtures__/field-shape-fixture.ts +30 -0
- package/src/__tests__/__fixtures__/inspect-scripts.snapshot.ts +2 -0
- package/src/__tests__/archetype.unit.test.ts +1837 -0
- package/src/__tests__/array-handle-element.test-d.ts +34 -0
- package/src/__tests__/buffer-array-vocab.test-d.ts +53 -0
- package/src/__tests__/buffer-field-input-widen.unit.test.ts +99 -0
- package/src/__tests__/buffer-pool.test-d.ts +32 -0
- package/src/__tests__/change-detection.unit.test.ts +86 -0
- package/src/__tests__/command-buffer.test.ts +179 -0
- package/src/__tests__/commands-deferred.unit.test.ts +68 -0
- package/src/__tests__/component-catalog.test.ts +59 -0
- package/src/__tests__/component-definition-identity.unit.test.ts +24 -0
- package/src/__tests__/component-nan-preflight.unit.test.ts +186 -0
- package/src/__tests__/component-schema.test-d.ts +119 -0
- package/src/__tests__/component-schema.test.ts +55 -0
- package/src/__tests__/define-component-options.test-d.ts +35 -0
- package/src/__tests__/deprecated-vocab-rejection.unit.test.ts +59 -0
- package/src/__tests__/despawn-all.unit.test.ts +17 -0
- package/src/__tests__/ecs-core-reduction.characterization.test.ts +130 -0
- package/src/__tests__/ecs-core-reduction.perf.test.ts +260 -0
- package/src/__tests__/ecs-error-code-31.test-d.ts +42 -0
- package/src/__tests__/entity-disabling.unit.test.ts +37 -0
- package/src/__tests__/entity-handle-codec-parity.unit.test.ts +126 -0
- package/src/__tests__/errors.unit.test.ts +1456 -0
- package/src/__tests__/execution-conflict-boundary.unit.test.ts +123 -0
- package/src/__tests__/execution-shared-storage.unit.test.ts +40 -0
- package/src/__tests__/externalization-portable-value.unit.test.ts +275 -0
- package/src/__tests__/externalization-projection.unit.test.ts +325 -0
- package/src/__tests__/externalization-render-read-lease.test-d.ts +30 -0
- package/src/__tests__/externalization-render-read-lease.unit.test.ts +79 -0
- package/src/__tests__/externalization-root-surface.unit.test.ts +33 -0
- package/src/__tests__/field-enum-labels-reflection.test.ts +66 -0
- package/src/__tests__/field-shape-fixture.test.ts +61 -0
- package/src/__tests__/field-transient-reflection.test.ts +59 -0
- package/src/__tests__/field-value-type.test-d.ts +57 -0
- package/src/__tests__/fixed-update.unit.test.ts +78 -0
- package/src/__tests__/handle.test-d.ts +86 -0
- package/src/__tests__/hierarchy.unit.test.ts +2534 -0
- package/src/__tests__/managed-array-vocab.test-d.ts +137 -0
- package/src/__tests__/minimal-example.test-d.ts +42 -0
- package/src/__tests__/name-read-types.test-d.ts +72 -0
- package/src/__tests__/plugin-service.test.ts +13 -0
- package/src/__tests__/query-combinations.unit.test.ts +42 -0
- package/src/__tests__/query-light-extract-flat-column-ratio.perf.test.ts +252 -0
- package/src/__tests__/query-storage-trends.perf.test.ts +104 -0
- package/src/__tests__/query-trs-flat-column-ratio.perf.test.ts +194 -0
- package/src/__tests__/query.unit.test.ts +196 -0
- package/src/__tests__/relationship-index.perf.test.ts +126 -0
- package/src/__tests__/relationship-index.test.ts +70 -0
- package/src/__tests__/scalar-field-type-owner.test-d.ts +71 -0
- package/src/__tests__/schedule-determinism.unit.test.ts +36 -0
- package/src/__tests__/schedule-inspection.unit.test.ts +81 -0
- package/src/__tests__/schedule-scope-error.unit.test.ts +63 -0
- package/src/__tests__/schedule-token.unit.test.ts +54 -0
- package/src/__tests__/schema-vocab.test-d.ts +103 -0
- package/src/__tests__/serialization.unit.test.ts +2740 -0
- package/src/__tests__/shared-kernel-eligibility.test-d.ts +18 -0
- package/src/__tests__/shared-kernel-eligibility.unit.test.ts +78 -0
- package/src/__tests__/shared-ref-store.unit.test.ts +646 -0
- package/src/__tests__/sparse-tag.unit.test.ts +201 -0
- package/src/__tests__/spawn-field-error.test-d.ts +41 -0
- package/src/__tests__/stale-error.test-d.ts +208 -0
- package/src/__tests__/string-view-symmetry.test-d.ts +26 -0
- package/src/__tests__/string-vocab.test-d.ts +49 -0
- package/src/__tests__/structure-epoch-boundaries.unit.test.ts +39 -0
- package/src/__tests__/structure-epoch.unit.test.ts +48 -0
- package/src/__tests__/table-archetype-mapping.unit.test.ts +78 -0
- package/src/__tests__/time.unit.test.ts +79 -0
- package/src/__tests__/types.test-d.ts +38 -0
- package/src/__tests__/unique-ref-store.unit.test.ts +348 -0
- package/src/__tests__/utils/handle-numeric.ts +30 -0
- package/src/__tests__/validation-root-surface.unit.test.ts +15 -0
- package/src/__tests__/visibility-atomic-write.unit.test.ts +82 -0
- package/src/__tests__/world-change-journal.unit.test.ts +97 -0
- package/src/__tests__/world-characterization.unit.test.ts +408 -0
- package/src/__tests__/world-consumer-inference.test-d.ts +16 -0
- package/src/__tests__/world-health.contract.test.ts +87 -0
- package/src/__tests__/world-inspection.test.ts +37 -0
- package/src/__tests__/world-internal-identity.unit.test.ts +17 -0
- package/src/__tests__/world-managed-roundtrip.unit.test.ts +98 -0
- package/src/__tests__/world-scheduling.m4.test.ts +52 -0
- package/src/__tests__/world-unique-roundtrip.unit.test.ts +357 -0
- package/src/__tests__/world.test-d.ts +156 -0
- package/src/buffer-pool.ts +357 -0
- package/src/commands.ts +644 -0
- package/src/component-default-fallback.ts +236 -0
- package/src/component-schema.ts +92 -0
- package/src/component-value-validate.ts +135 -0
- package/src/component.ts +1268 -0
- package/src/entity-handle.ts +104 -0
- package/src/entity.ts +140 -0
- package/src/errors/query-and-component-errors.ts +200 -0
- package/src/errors/relationship-errors.ts +198 -0
- package/src/errors/sprite-and-shared-errors.ts +231 -0
- package/src/errors/validation-errors.ts +506 -0
- package/src/errors.ts +1464 -0
- package/src/execution/shared-kernel.ts +392 -0
- package/src/externalization/index.ts +170 -0
- package/src/index.ts +414 -0
- package/src/plugin-service.ts +35 -0
- package/src/projection/index.ts +318 -0
- package/src/query/query.ts +606 -0
- package/src/relationship-index.ts +175 -0
- package/src/resource.ts +106 -0
- package/src/schedule-token.ts +40 -0
- package/src/schedule.ts +846 -0
- package/src/shared-ref-store.ts +418 -0
- package/src/shared.ts +23 -0
- package/src/storage/archetype-graph.ts +166 -0
- package/src/storage/archetype.ts +78 -0
- package/src/storage/change-detection.ts +231 -0
- package/src/storage/column.ts +247 -0
- package/src/storage/table.ts +153 -0
- package/src/time.ts +122 -0
- package/src/unique-ref-store.ts +278 -0
- package/src/world-change-journal.ts +84 -0
- package/src/world-component-access.ts +1421 -0
- package/src/world-component-storage.ts +1178 -0
- package/src/world-core.ts +74 -0
- package/src/world-entity-lifecycle.ts +539 -0
- package/src/world-internal.ts +75 -0
- package/src/world-scheduling.ts +499 -0
- package/src/world.ts +1399 -0
|
@@ -0,0 +1,479 @@
|
|
|
1
|
+
import { err, ok } from '@forgeax/engine-types';
|
|
2
|
+
|
|
3
|
+
// src/component.ts
|
|
4
|
+
|
|
5
|
+
// src/component-schema.ts
|
|
6
|
+
var COMPONENT_REGISTRY = /* @__PURE__ */ Symbol.for("forgeax.ecs.componentRegistry");
|
|
7
|
+
var globalSymbols = globalThis;
|
|
8
|
+
var definitions = globalSymbols[COMPONENT_REGISTRY] ?? (() => {
|
|
9
|
+
const registry = { definitions: /* @__PURE__ */ new WeakMap() };
|
|
10
|
+
globalSymbols[COMPONENT_REGISTRY] = registry;
|
|
11
|
+
return registry;
|
|
12
|
+
})();
|
|
13
|
+
function registerComponentDefinition(component, definition) {
|
|
14
|
+
definitions.definitions.set(component, definition);
|
|
15
|
+
}
|
|
16
|
+
function componentDefinition(component) {
|
|
17
|
+
const definition = definitions.definitions.get(component);
|
|
18
|
+
if (definition === void 0) {
|
|
19
|
+
throw new Error(`Component definition missing for '${component.name}'.`);
|
|
20
|
+
}
|
|
21
|
+
return definition;
|
|
22
|
+
}
|
|
23
|
+
function deepFreeze(value) {
|
|
24
|
+
if (value === null || typeof value !== "object" && typeof value !== "function") {
|
|
25
|
+
return value;
|
|
26
|
+
}
|
|
27
|
+
if (ArrayBuffer.isView(value) || value instanceof ArrayBuffer) {
|
|
28
|
+
return value;
|
|
29
|
+
}
|
|
30
|
+
const object = value;
|
|
31
|
+
for (const key of Reflect.ownKeys(object)) {
|
|
32
|
+
const child = object[key];
|
|
33
|
+
if (child !== null && (typeof child === "object" || typeof child === "function")) {
|
|
34
|
+
deepFreeze(child);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return Object.freeze(value);
|
|
38
|
+
}
|
|
39
|
+
function assertComponentStorage(value) {
|
|
40
|
+
if (value !== "table" && value !== "sparse") {
|
|
41
|
+
throw new Error(`Unsupported component storage '${value}'. Expected 'table' or 'sparse'.`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// src/errors.ts
|
|
46
|
+
var SchemaUnsupportedFieldError = class extends Error {
|
|
47
|
+
name = "SchemaUnsupportedFieldError";
|
|
48
|
+
code = "schema-unsupported-field";
|
|
49
|
+
hint;
|
|
50
|
+
constructor(fieldName, fieldType) {
|
|
51
|
+
let hint = "Supported types: f32 / f64 / i32 / u32 / i16 / u16 / i8 / u8 / bool / enum / ref.";
|
|
52
|
+
if (fieldType.startsWith("handle<") && fieldType.endsWith(">")) {
|
|
53
|
+
const tag = fieldType.slice(7, -1);
|
|
54
|
+
hint = `'handle<${tag}>' was removed in feat-20260614 M5; use 'shared<${tag}>' instead. The brand and storage layout are unchanged; only the keyword + write-barrier dispatch (SharedRefStore retain/release) is new.`;
|
|
55
|
+
} else if (fieldType.startsWith("ref<") && fieldType.endsWith(">")) {
|
|
56
|
+
const tag = fieldType.slice(4, -1);
|
|
57
|
+
hint = `'ref<${tag}>' was renamed in feat-20260614 M1; use 'unique<${tag}>' instead. The brand and storage layout are unchanged; the dispatch still routes through UniqueRefStore (single-holder direct release).`;
|
|
58
|
+
}
|
|
59
|
+
super(
|
|
60
|
+
`Schema field "${fieldName}" has unsupported type "${fieldType}".
|
|
61
|
+
field: ${fieldName}
|
|
62
|
+
type: ${fieldType}
|
|
63
|
+
hint: ${hint}`
|
|
64
|
+
);
|
|
65
|
+
this.hint = hint;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
var SparseStorageRequiresTagError = class extends Error {
|
|
69
|
+
name = "SparseStorageRequiresTagError";
|
|
70
|
+
code = "sparse-storage-requires-tag";
|
|
71
|
+
expected = "sparse components have an empty schema and no relationship metadata";
|
|
72
|
+
hint = "remove all fields and relationship metadata, or use storage: table";
|
|
73
|
+
detail;
|
|
74
|
+
constructor(componentName) {
|
|
75
|
+
super(
|
|
76
|
+
`Sparse component "${componentName}" must be a zero-field, non-relationship tag.
|
|
77
|
+
component: ${componentName}
|
|
78
|
+
hint: remove all fields and relationship metadata, or use storage: table`
|
|
79
|
+
);
|
|
80
|
+
this.detail = { componentName };
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
var ManagedArrayElementTypeNotAllowedError = class extends Error {
|
|
84
|
+
name = "ManagedArrayElementTypeNotAllowedError";
|
|
85
|
+
code = "managed-array-element-type-not-allowed";
|
|
86
|
+
hint;
|
|
87
|
+
expected;
|
|
88
|
+
detail;
|
|
89
|
+
constructor(fieldName, elementType) {
|
|
90
|
+
const hint = `array<T> element type must be a scalar (f32/f64/i32/u32/i16/u16/i8/u8/bool/enum/ref) or entity. ref<X> / handle<X> / buffer:N / nested array<...> are forbidden on field "${fieldName}".`;
|
|
91
|
+
const expected = "element type in {scalar | entity}";
|
|
92
|
+
super(
|
|
93
|
+
`managed-array: element type not allowed.
|
|
94
|
+
code: managed-array-element-type-not-allowed
|
|
95
|
+
field: ${fieldName}
|
|
96
|
+
elementType: ${elementType}
|
|
97
|
+
expected: ${expected}
|
|
98
|
+
hint: ${hint}`
|
|
99
|
+
);
|
|
100
|
+
this.hint = hint;
|
|
101
|
+
this.expected = expected;
|
|
102
|
+
this.detail = { fieldName, elementType, hint };
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
// src/component.ts
|
|
107
|
+
var FIELD_SIZE_BYTES = {
|
|
108
|
+
f32: 4,
|
|
109
|
+
f64: 8,
|
|
110
|
+
i32: 4,
|
|
111
|
+
u32: 4,
|
|
112
|
+
i16: 2,
|
|
113
|
+
u16: 2,
|
|
114
|
+
i8: 1,
|
|
115
|
+
u8: 1,
|
|
116
|
+
bool: 1,
|
|
117
|
+
enum: 4,
|
|
118
|
+
ref: 4
|
|
119
|
+
};
|
|
120
|
+
function fieldTypeToMetaKey(fieldType) {
|
|
121
|
+
if (fieldType === "entity" || fieldType === "string" || fieldType === "buffer") {
|
|
122
|
+
return fieldType;
|
|
123
|
+
}
|
|
124
|
+
if (fieldType.startsWith("unique<") && fieldType.endsWith(">")) return "ref";
|
|
125
|
+
if (fieldType.startsWith("shared<") && fieldType.endsWith(">")) return "shared";
|
|
126
|
+
if (fieldType.startsWith("buffer<") && fieldType.endsWith(">")) return "buffer";
|
|
127
|
+
if (fieldType.startsWith("array<") && fieldType.endsWith(">")) return "array";
|
|
128
|
+
if (TYPE_METADATA[fieldType] !== void 0) return fieldType;
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
function isManagedField(fieldType) {
|
|
132
|
+
return TYPE_METADATA[fieldTypeToMetaKey(fieldType) ?? ""]?.isManaged ?? false;
|
|
133
|
+
}
|
|
134
|
+
function isManagedBufferField(fieldType) {
|
|
135
|
+
return TYPE_METADATA[fieldTypeToMetaKey(fieldType) ?? ""]?.isBuffer ?? false;
|
|
136
|
+
}
|
|
137
|
+
function isEntityField(fieldType) {
|
|
138
|
+
return TYPE_METADATA[fieldTypeToMetaKey(fieldType) ?? ""]?.isEntityRef ?? false;
|
|
139
|
+
}
|
|
140
|
+
function isManagedArrayField(fieldType) {
|
|
141
|
+
return TYPE_METADATA[fieldTypeToMetaKey(fieldType) ?? ""]?.isArray ?? false;
|
|
142
|
+
}
|
|
143
|
+
var MANAGED_ARRAY_ELEMENT_TYPES = /* @__PURE__ */ new Set([
|
|
144
|
+
"f32",
|
|
145
|
+
"f64",
|
|
146
|
+
"i32",
|
|
147
|
+
"u32",
|
|
148
|
+
"i16",
|
|
149
|
+
"u16",
|
|
150
|
+
"i8",
|
|
151
|
+
"u8",
|
|
152
|
+
"bool",
|
|
153
|
+
"enum",
|
|
154
|
+
"ref",
|
|
155
|
+
"entity"
|
|
156
|
+
]);
|
|
157
|
+
function isValidArrayElementType(elementType) {
|
|
158
|
+
if (MANAGED_ARRAY_ELEMENT_TYPES.has(elementType)) return true;
|
|
159
|
+
if (elementType.startsWith("shared<") && elementType.endsWith(">") && elementType.length > 9)
|
|
160
|
+
return true;
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
function parseManagedArraySchema(fieldType) {
|
|
164
|
+
if (!fieldType.startsWith("array<") || !fieldType.endsWith(">")) return null;
|
|
165
|
+
const inner = fieldType.slice(6, -1);
|
|
166
|
+
const commaIdx = inner.indexOf(",");
|
|
167
|
+
if (commaIdx === -1) {
|
|
168
|
+
if (!isValidArrayElementType(inner)) return null;
|
|
169
|
+
return { elementType: inner, length: void 0 };
|
|
170
|
+
}
|
|
171
|
+
const head = inner.slice(0, commaIdx).trim();
|
|
172
|
+
const tail = inner.slice(commaIdx + 1).trim();
|
|
173
|
+
if (!isValidArrayElementType(head)) return null;
|
|
174
|
+
if (!/^[1-9]\d*$/.test(tail)) return null;
|
|
175
|
+
return { elementType: head, length: Number.parseInt(tail, 10) };
|
|
176
|
+
}
|
|
177
|
+
function bufferFieldByteLength(fieldType) {
|
|
178
|
+
if (!fieldType.startsWith("buffer<") || !fieldType.endsWith(">")) return Number.NaN;
|
|
179
|
+
const tail = fieldType.slice(7, -1);
|
|
180
|
+
if (!/^[1-9]\d*$/.test(tail)) return Number.NaN;
|
|
181
|
+
return Number.parseInt(tail, 10);
|
|
182
|
+
}
|
|
183
|
+
function isSchemaVocabKeyword(s) {
|
|
184
|
+
if (s === "string") return true;
|
|
185
|
+
if (s === "entity") return true;
|
|
186
|
+
if (s === "buffer") return true;
|
|
187
|
+
if (s.startsWith("buffer<") && s.endsWith(">")) {
|
|
188
|
+
const tail = s.slice(7, -1);
|
|
189
|
+
return /^[1-9]\d*$/.test(tail);
|
|
190
|
+
}
|
|
191
|
+
if (s.startsWith("unique<") && s.endsWith(">")) {
|
|
192
|
+
return /^\w+$/.test(s.slice(7, -1));
|
|
193
|
+
}
|
|
194
|
+
if (s.startsWith("shared<") && s.endsWith(">")) {
|
|
195
|
+
return /^\w+$/.test(s.slice(7, -1));
|
|
196
|
+
}
|
|
197
|
+
if (s.startsWith("array<") && s.endsWith(">")) {
|
|
198
|
+
return parseManagedArraySchema(s) !== null;
|
|
199
|
+
}
|
|
200
|
+
return false;
|
|
201
|
+
}
|
|
202
|
+
var COMPONENT_OWNER_REGISTRY = /* @__PURE__ */ Symbol.for("forgeax.ecs.componentOwnerRegistry");
|
|
203
|
+
var ownerSymbols = globalThis;
|
|
204
|
+
var ownerRegistry = ownerSymbols[COMPONENT_OWNER_REGISTRY] ?? (() => {
|
|
205
|
+
const registry = {
|
|
206
|
+
nextId: 1,
|
|
207
|
+
ids: /* @__PURE__ */ new WeakMap(),
|
|
208
|
+
schemas: /* @__PURE__ */ new WeakMap()
|
|
209
|
+
};
|
|
210
|
+
ownerSymbols[COMPONENT_OWNER_REGISTRY] = registry;
|
|
211
|
+
return registry;
|
|
212
|
+
})();
|
|
213
|
+
var entityDefinitionSeen = false;
|
|
214
|
+
var componentDefinedBeforeEntity = false;
|
|
215
|
+
function isComponentDefinitionOrderValid() {
|
|
216
|
+
return !componentDefinedBeforeEntity;
|
|
217
|
+
}
|
|
218
|
+
function componentId(component) {
|
|
219
|
+
const id = ownerRegistry.ids.get(component);
|
|
220
|
+
if (id === void 0) throw new Error(`Component identity missing for '${component.name}'.`);
|
|
221
|
+
return id;
|
|
222
|
+
}
|
|
223
|
+
function componentSchema(component) {
|
|
224
|
+
const schema = ownerRegistry.schemas.get(component);
|
|
225
|
+
if (schema === void 0) throw new Error(`Component schema missing for '${component.name}'.`);
|
|
226
|
+
return schema;
|
|
227
|
+
}
|
|
228
|
+
var VIEW_CTORS = {
|
|
229
|
+
f32: Float32Array,
|
|
230
|
+
f64: Float64Array,
|
|
231
|
+
i32: Int32Array,
|
|
232
|
+
u32: Uint32Array,
|
|
233
|
+
i16: Int16Array,
|
|
234
|
+
u16: Uint16Array,
|
|
235
|
+
i8: Int8Array,
|
|
236
|
+
u8: Uint8Array,
|
|
237
|
+
bool: Uint8Array,
|
|
238
|
+
enum: Uint32Array,
|
|
239
|
+
ref: Uint32Array
|
|
240
|
+
};
|
|
241
|
+
function scalarRow(t) {
|
|
242
|
+
return {
|
|
243
|
+
byteSize: FIELD_SIZE_BYTES[t],
|
|
244
|
+
viewCtor: VIEW_CTORS[t],
|
|
245
|
+
storage: t,
|
|
246
|
+
isScalar: true,
|
|
247
|
+
// The scalar `ref` shares its key with the vocab `ref<T>` family; mark
|
|
248
|
+
// it as managed so the single row covers both.
|
|
249
|
+
isManaged: t === "ref",
|
|
250
|
+
isBuffer: false,
|
|
251
|
+
isEntityRef: false,
|
|
252
|
+
isArray: false
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
var TYPE_METADATA = Object.freeze({
|
|
256
|
+
f32: scalarRow("f32"),
|
|
257
|
+
f64: scalarRow("f64"),
|
|
258
|
+
i32: scalarRow("i32"),
|
|
259
|
+
u32: scalarRow("u32"),
|
|
260
|
+
i16: scalarRow("i16"),
|
|
261
|
+
u16: scalarRow("u16"),
|
|
262
|
+
i8: scalarRow("i8"),
|
|
263
|
+
u8: scalarRow("u8"),
|
|
264
|
+
bool: scalarRow("bool"),
|
|
265
|
+
enum: scalarRow("enum"),
|
|
266
|
+
ref: scalarRow("ref"),
|
|
267
|
+
entity: {
|
|
268
|
+
byteSize: 4,
|
|
269
|
+
viewCtor: Uint32Array,
|
|
270
|
+
storage: "u32",
|
|
271
|
+
isScalar: false,
|
|
272
|
+
isManaged: false,
|
|
273
|
+
isBuffer: false,
|
|
274
|
+
isEntityRef: true,
|
|
275
|
+
isArray: false
|
|
276
|
+
},
|
|
277
|
+
string: {
|
|
278
|
+
byteSize: 4,
|
|
279
|
+
viewCtor: Uint32Array,
|
|
280
|
+
storage: "u32",
|
|
281
|
+
isScalar: false,
|
|
282
|
+
isManaged: true,
|
|
283
|
+
isBuffer: false,
|
|
284
|
+
isEntityRef: false,
|
|
285
|
+
isArray: false
|
|
286
|
+
},
|
|
287
|
+
buffer: {
|
|
288
|
+
byteSize: 4,
|
|
289
|
+
viewCtor: Uint32Array,
|
|
290
|
+
storage: "u32",
|
|
291
|
+
isScalar: false,
|
|
292
|
+
isManaged: false,
|
|
293
|
+
isBuffer: true,
|
|
294
|
+
isEntityRef: false,
|
|
295
|
+
isArray: false
|
|
296
|
+
},
|
|
297
|
+
// feat-20260614-ecs-shared-component-and-unique-rename M3 (plan-strategy
|
|
298
|
+
// D-3): independent `'shared'` row, NOT a reuse of the `'ref'` (post-M2:
|
|
299
|
+
// `'unique<T>'` family) row. `isManaged: true` so write-barrier dispatch
|
|
300
|
+
// routes shared<T> fields through release on despawn / removeComponent /
|
|
301
|
+
// set-overwrite, but the M4 sub-dispatch in releaseManagedFieldOnRow will
|
|
302
|
+
// separate shared (rc--) from unique (direct slot drop) using the
|
|
303
|
+
// fieldType.startsWith('shared<') predicate. Keeping the meta key
|
|
304
|
+
// independent preserves the "meta key = release semantics" invariant
|
|
305
|
+
// (architecture-principles.md #1 SSOT).
|
|
306
|
+
shared: {
|
|
307
|
+
byteSize: 4,
|
|
308
|
+
viewCtor: Uint32Array,
|
|
309
|
+
storage: "u32",
|
|
310
|
+
isScalar: false,
|
|
311
|
+
isManaged: true,
|
|
312
|
+
isBuffer: false,
|
|
313
|
+
isEntityRef: false,
|
|
314
|
+
isArray: false
|
|
315
|
+
},
|
|
316
|
+
array: {
|
|
317
|
+
byteSize: 4,
|
|
318
|
+
viewCtor: Uint32Array,
|
|
319
|
+
storage: "u32",
|
|
320
|
+
isScalar: false,
|
|
321
|
+
isManaged: false,
|
|
322
|
+
isBuffer: false,
|
|
323
|
+
isEntityRef: false,
|
|
324
|
+
isArray: true
|
|
325
|
+
}
|
|
326
|
+
});
|
|
327
|
+
function fieldSpecType(fieldName, spec) {
|
|
328
|
+
if (typeof spec === "string") return spec;
|
|
329
|
+
const t = spec.type;
|
|
330
|
+
if (typeof t !== "string") {
|
|
331
|
+
throw new SchemaUnsupportedFieldError(
|
|
332
|
+
fieldName,
|
|
333
|
+
`<field-descriptor missing 'type'> (expected { type, default?, meta? })`
|
|
334
|
+
);
|
|
335
|
+
}
|
|
336
|
+
return t;
|
|
337
|
+
}
|
|
338
|
+
function defineComponent(name, fields, options) {
|
|
339
|
+
const storage = options?.storage ?? "table";
|
|
340
|
+
assertComponentStorage(storage);
|
|
341
|
+
if (storage === "sparse" && Object.keys(fields).length !== 0) {
|
|
342
|
+
throw new SparseStorageRequiresTagError(name);
|
|
343
|
+
}
|
|
344
|
+
const schema = {};
|
|
345
|
+
const reflectedFields = {};
|
|
346
|
+
const collectedMeta = {};
|
|
347
|
+
const collectedDefaults = {};
|
|
348
|
+
for (const fieldName of Object.keys(fields)) {
|
|
349
|
+
const spec = fields[fieldName];
|
|
350
|
+
const fieldType = fieldSpecType(fieldName, spec);
|
|
351
|
+
let arrayMeta;
|
|
352
|
+
if (TYPE_METADATA[fieldType]?.isScalar === true) ; else if (fieldType === "string") ; else if (fieldType.startsWith("array<") && fieldType.endsWith(">")) {
|
|
353
|
+
const parsed = parseManagedArraySchema(fieldType);
|
|
354
|
+
if (parsed === null) {
|
|
355
|
+
const elementType = fieldType.slice(6, -1);
|
|
356
|
+
throw new ManagedArrayElementTypeNotAllowedError(fieldName, elementType);
|
|
357
|
+
}
|
|
358
|
+
arrayMeta = deepFreeze(
|
|
359
|
+
parsed.length === void 0 ? { elementType: parsed.elementType } : { elementType: parsed.elementType, length: parsed.length }
|
|
360
|
+
);
|
|
361
|
+
} else if (!isSchemaVocabKeyword(fieldType)) {
|
|
362
|
+
throw new SchemaUnsupportedFieldError(fieldName, fieldType);
|
|
363
|
+
}
|
|
364
|
+
schema[fieldName] = fieldType;
|
|
365
|
+
const row = {
|
|
366
|
+
type: fieldType
|
|
367
|
+
};
|
|
368
|
+
if (typeof spec !== "string") {
|
|
369
|
+
const desc = spec;
|
|
370
|
+
if ("default" in desc) {
|
|
371
|
+
row.default = desc.default;
|
|
372
|
+
collectedDefaults[fieldName] = desc.default;
|
|
373
|
+
}
|
|
374
|
+
if (desc.shape !== void 0) row.shape = desc.shape;
|
|
375
|
+
if (desc.meta !== void 0) {
|
|
376
|
+
Object.assign(collectedMeta, desc.meta);
|
|
377
|
+
}
|
|
378
|
+
if (desc.transient !== void 0) row.transient = desc.transient;
|
|
379
|
+
if (desc.labels !== void 0) row.labels = deepFreeze({ ...desc.labels });
|
|
380
|
+
}
|
|
381
|
+
if (arrayMeta !== void 0) row.arrayMeta = arrayMeta;
|
|
382
|
+
reflectedFields[fieldName] = Object.freeze(row);
|
|
383
|
+
}
|
|
384
|
+
if (name === "Entity") {
|
|
385
|
+
entityDefinitionSeen = true;
|
|
386
|
+
} else if (!entityDefinitionSeen) {
|
|
387
|
+
componentDefinedBeforeEntity = true;
|
|
388
|
+
}
|
|
389
|
+
const id = name === "Entity" ? 0 : ownerRegistry.nextId++;
|
|
390
|
+
const frozenDefaults = Object.keys(collectedDefaults).length === 0 ? void 0 : deepFreeze(collectedDefaults);
|
|
391
|
+
if (options?.meta !== void 0) {
|
|
392
|
+
Object.assign(collectedMeta, options.meta);
|
|
393
|
+
}
|
|
394
|
+
const frozenSchema = deepFreeze(schema);
|
|
395
|
+
const frozenFields = deepFreeze(reflectedFields);
|
|
396
|
+
const meta = collectedMeta;
|
|
397
|
+
const token = Object.freeze({ name, fields: frozenFields, storage });
|
|
398
|
+
ownerRegistry.ids.set(token, id);
|
|
399
|
+
ownerRegistry.schemas.set(token, frozenSchema);
|
|
400
|
+
registerComponentDefinition(token, {
|
|
401
|
+
fields: frozenFields,
|
|
402
|
+
defaults: frozenDefaults,
|
|
403
|
+
policy: { transient: options?.transient ?? false, meta }
|
|
404
|
+
});
|
|
405
|
+
return Object.freeze(token);
|
|
406
|
+
}
|
|
407
|
+
var ComponentInUseError = class extends Error {
|
|
408
|
+
name = "ComponentInUseError";
|
|
409
|
+
code = "component-in-use";
|
|
410
|
+
expected = "the component to have no live entity or scheduled-system references";
|
|
411
|
+
hint = "Remove owning systems and component values before disposing the registration lease.";
|
|
412
|
+
detail;
|
|
413
|
+
constructor(componentName) {
|
|
414
|
+
super(`Component ${componentName} is still in use.`);
|
|
415
|
+
this.detail = { componentName };
|
|
416
|
+
}
|
|
417
|
+
};
|
|
418
|
+
var ComponentNameConflictError = class extends Error {
|
|
419
|
+
name = "ComponentNameConflictError";
|
|
420
|
+
code = "component-name-conflict";
|
|
421
|
+
expected = "one component token per name in a World";
|
|
422
|
+
hint = "Use the token already registered in this World or choose a distinct component name.";
|
|
423
|
+
detail;
|
|
424
|
+
constructor(componentName) {
|
|
425
|
+
super(`Component ${componentName} is already registered with a different token.`);
|
|
426
|
+
this.detail = { componentName };
|
|
427
|
+
}
|
|
428
|
+
};
|
|
429
|
+
var ComponentCatalog = class {
|
|
430
|
+
constructor(inUse) {
|
|
431
|
+
this.inUse = inUse;
|
|
432
|
+
}
|
|
433
|
+
inUse;
|
|
434
|
+
registrations = /* @__PURE__ */ new Map();
|
|
435
|
+
register(component) {
|
|
436
|
+
const current = this.registrations.get(component.name);
|
|
437
|
+
if (current !== void 0 && current.component !== component) {
|
|
438
|
+
return err(new ComponentNameConflictError(component.name));
|
|
439
|
+
}
|
|
440
|
+
if (current === void 0) {
|
|
441
|
+
this.registrations.set(component.name, { component, owners: 1 });
|
|
442
|
+
} else {
|
|
443
|
+
current.owners += 1;
|
|
444
|
+
}
|
|
445
|
+
let active = true;
|
|
446
|
+
return ok({
|
|
447
|
+
component,
|
|
448
|
+
dispose: () => {
|
|
449
|
+
if (!active) return ok(void 0);
|
|
450
|
+
const registration = this.registrations.get(component.name);
|
|
451
|
+
if (registration === void 0 || registration.component !== component) {
|
|
452
|
+
active = false;
|
|
453
|
+
return ok(void 0);
|
|
454
|
+
}
|
|
455
|
+
if (registration.owners > 1) {
|
|
456
|
+
registration.owners -= 1;
|
|
457
|
+
active = false;
|
|
458
|
+
return ok(void 0);
|
|
459
|
+
}
|
|
460
|
+
if (this.inUse(component)) return err(new ComponentInUseError(component.name));
|
|
461
|
+
this.registrations.delete(component.name);
|
|
462
|
+
active = false;
|
|
463
|
+
return ok(void 0);
|
|
464
|
+
}
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
resolve(name) {
|
|
468
|
+
return this.registrations.get(name)?.component;
|
|
469
|
+
}
|
|
470
|
+
entries() {
|
|
471
|
+
return new Map(
|
|
472
|
+
[...this.registrations].map(([name, registration]) => [name, registration.component])
|
|
473
|
+
);
|
|
474
|
+
}
|
|
475
|
+
};
|
|
476
|
+
|
|
477
|
+
export { ComponentCatalog, ComponentInUseError, ComponentNameConflictError, MANAGED_ARRAY_ELEMENT_TYPES, TYPE_METADATA, bufferFieldByteLength, componentDefinition, componentId, componentSchema, defineComponent, fieldTypeToMetaKey, isComponentDefinitionOrderValid, isEntityField, isManagedArrayField, isManagedBufferField, isManagedField, isSchemaVocabKeyword, parseManagedArraySchema };
|
|
478
|
+
//# sourceMappingURL=internal.mjs.map
|
|
479
|
+
//# sourceMappingURL=internal.mjs.map
|