@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,615 @@
|
|
|
1
|
+
import '@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 componentDefinition(component) {
|
|
14
|
+
const definition = definitions.definitions.get(component);
|
|
15
|
+
if (definition === void 0) {
|
|
16
|
+
throw new Error(`Component definition missing for '${component.name}'.`);
|
|
17
|
+
}
|
|
18
|
+
return definition;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// src/errors/query-and-component-errors.ts
|
|
22
|
+
var ComponentNotDefinedError = class extends Error {
|
|
23
|
+
name = "ComponentNotDefinedError";
|
|
24
|
+
code = "component-not-defined";
|
|
25
|
+
hint;
|
|
26
|
+
expected;
|
|
27
|
+
detail;
|
|
28
|
+
constructor(componentName, opts) {
|
|
29
|
+
const expected = opts?.expected ?? `component '${componentName}' defined before instantiate`;
|
|
30
|
+
const hint = opts?.hint ?? `define the component via defineComponent('${componentName}', ...) before instantiating this SceneAsset`;
|
|
31
|
+
super(
|
|
32
|
+
`instantiate: component not defined.
|
|
33
|
+
code: component-not-defined
|
|
34
|
+
component: ${componentName}
|
|
35
|
+
expected: ${expected}
|
|
36
|
+
hint: ${hint}`
|
|
37
|
+
);
|
|
38
|
+
this.hint = hint;
|
|
39
|
+
this.expected = expected;
|
|
40
|
+
this.detail = { name: componentName };
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
// src/errors/sprite-and-shared-errors.ts
|
|
45
|
+
var SpriteInstancesCountMismatchError = class extends Error {
|
|
46
|
+
name = "SpriteInstancesCountMismatchError";
|
|
47
|
+
code = "sprite-instances-count-mismatch";
|
|
48
|
+
hint;
|
|
49
|
+
expected;
|
|
50
|
+
detail;
|
|
51
|
+
constructor(transformsLength, regionsLength) {
|
|
52
|
+
const hint = "SpriteInstances.transforms (stride 16) and SpriteInstances.regions (stride 4) must describe the same instance count: ensure transforms.length / 16 === regions.length / 4 at the spawn / set site (resize both arrays together).";
|
|
53
|
+
const expected = "transforms.length / 16 === regions.length / 4";
|
|
54
|
+
super(
|
|
55
|
+
`SpriteInstances: per-instance count mismatch between transforms and regions.
|
|
56
|
+
code: sprite-instances-count-mismatch
|
|
57
|
+
transformsLength: ${transformsLength} (count = ${transformsLength / 16})
|
|
58
|
+
regionsLength: ${regionsLength} (count = ${regionsLength / 4})
|
|
59
|
+
expected: ${expected}
|
|
60
|
+
hint: ${hint}`
|
|
61
|
+
);
|
|
62
|
+
this.hint = hint;
|
|
63
|
+
this.expected = expected;
|
|
64
|
+
this.detail = {
|
|
65
|
+
code: "sprite-instances-count-mismatch",
|
|
66
|
+
transformsLength,
|
|
67
|
+
regionsLength,
|
|
68
|
+
expectedStride: { transforms: 16, regions: 4 }
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
var SpriteInstancesRequiresSpriteShaderError = class extends Error {
|
|
73
|
+
name = "SpriteInstancesRequiresSpriteShaderError";
|
|
74
|
+
code = "sprite-instances-requires-sprite-shader";
|
|
75
|
+
hint;
|
|
76
|
+
expected;
|
|
77
|
+
detail;
|
|
78
|
+
constructor(entityId, observedMaterialShaderId) {
|
|
79
|
+
const hint = "bind a MaterialAsset whose first pass `shader` is 'forgeax::sprite' or 'forgeax::sprite-lit' to this entity's MeshRenderer (SpriteInstances requires a sprite-family shader so the per-instance UV region is consumed by the sprite vertex shader path).";
|
|
80
|
+
const expected = "MaterialAsset.passes[0].shader === 'forgeax::sprite' || 'forgeax::sprite-lit'";
|
|
81
|
+
super(
|
|
82
|
+
`SpriteInstances: entity ${entityId} requires a sprite-shaded MaterialAsset.
|
|
83
|
+
code: sprite-instances-requires-sprite-shader
|
|
84
|
+
entityId: ${entityId}
|
|
85
|
+
observedMaterialShaderId: ${observedMaterialShaderId}
|
|
86
|
+
expected: ${expected}
|
|
87
|
+
hint: ${hint}`
|
|
88
|
+
);
|
|
89
|
+
this.hint = hint;
|
|
90
|
+
this.expected = expected;
|
|
91
|
+
this.detail = {
|
|
92
|
+
code: "sprite-instances-requires-sprite-shader",
|
|
93
|
+
entityId,
|
|
94
|
+
observedMaterialShaderId
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
var SpriteInstancesMutuallyExclusiveWithInstancesError = class extends Error {
|
|
99
|
+
name = "SpriteInstancesMutuallyExclusiveWithInstancesError";
|
|
100
|
+
code = "sprite-instances-mutually-exclusive-with-instances";
|
|
101
|
+
hint;
|
|
102
|
+
expected;
|
|
103
|
+
detail;
|
|
104
|
+
constructor(entityId) {
|
|
105
|
+
const hint = "remove Instances or replace with SpriteInstances; SpriteInstances supersedes Instances when per-instance region is needed.";
|
|
106
|
+
const expected = "entity carries Instances XOR SpriteInstances (not both)";
|
|
107
|
+
super(
|
|
108
|
+
`SpriteInstances: entity ${entityId} carries both Instances and SpriteInstances.
|
|
109
|
+
code: sprite-instances-mutually-exclusive-with-instances
|
|
110
|
+
entityId: ${entityId}
|
|
111
|
+
expected: ${expected}
|
|
112
|
+
hint: ${hint}`
|
|
113
|
+
);
|
|
114
|
+
this.hint = hint;
|
|
115
|
+
this.expected = expected;
|
|
116
|
+
this.detail = {
|
|
117
|
+
code: "sprite-instances-mutually-exclusive-with-instances",
|
|
118
|
+
entityId
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
// src/errors/validation-errors.ts
|
|
124
|
+
var SPAWN_LIGHT_INVALID_BOUNDS_POLICY = {
|
|
125
|
+
range: {
|
|
126
|
+
expected: "range >= 0 or Number.POSITIVE_INFINITY",
|
|
127
|
+
hint: (componentName, got) => `${componentName}.range = ${got} is invalid; use Number.POSITIVE_INFINITY for unlimited range, or a non-negative meter value`
|
|
128
|
+
},
|
|
129
|
+
innerOuter: {
|
|
130
|
+
expected: "outerConeDeg > innerConeDeg",
|
|
131
|
+
hint: (componentName, got) => `${componentName}.outerConeDeg <= innerConeDeg (got ${got}); inner cone is the saturated bright region, outer cone is the falloff edge; outerConeDeg > innerConeDeg required`
|
|
132
|
+
},
|
|
133
|
+
outerNinety: {
|
|
134
|
+
expected: "outerConeDeg <= 90 (KHR_lights_punctual upper bound)",
|
|
135
|
+
hint: (componentName, got) => `${componentName}.outerConeDeg = ${got} > 90; a spot light cone wider than 90 degrees becomes a point light; use PointLight instead`
|
|
136
|
+
},
|
|
137
|
+
direction: {
|
|
138
|
+
expected: "direction is a non-zero [x, y, z] vector",
|
|
139
|
+
hint: (componentName, got) => `${componentName}.direction is missing or a zero vector (got ${JSON.stringify(got)}); direction has no default, provide a non-zero direction, e.g. [-0.5, -1, -0.3]`
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
var SpawnLightInvalidBoundsError = class extends Error {
|
|
143
|
+
name = "SpawnLightInvalidBoundsError";
|
|
144
|
+
code = "spawn-light-invalid-bounds";
|
|
145
|
+
hint;
|
|
146
|
+
expected;
|
|
147
|
+
detail;
|
|
148
|
+
constructor(componentName, field, got) {
|
|
149
|
+
const policy = SPAWN_LIGHT_INVALID_BOUNDS_POLICY[field];
|
|
150
|
+
const hint = policy.hint(componentName, got);
|
|
151
|
+
const expectedStr = policy.expected;
|
|
152
|
+
super(
|
|
153
|
+
`${componentName}: spawn payload bound violation.
|
|
154
|
+
code: spawn-light-invalid-bounds
|
|
155
|
+
component: ${componentName}
|
|
156
|
+
field: ${field}
|
|
157
|
+
got: ${got}
|
|
158
|
+
expected: ${expectedStr}
|
|
159
|
+
hint: ${hint}`
|
|
160
|
+
);
|
|
161
|
+
this.hint = hint;
|
|
162
|
+
this.expected = expectedStr;
|
|
163
|
+
this.detail = { field, got };
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
var ResourceInvalidValueError = class extends Error {
|
|
167
|
+
name = "ResourceInvalidValueError";
|
|
168
|
+
code = "resource-invalid-value";
|
|
169
|
+
hint;
|
|
170
|
+
expected;
|
|
171
|
+
detail;
|
|
172
|
+
constructor(expected, hint, detail) {
|
|
173
|
+
const keyClause = detail.receivedKey === void 0 ? "" : ` key: ${detail.receivedKey}
|
|
174
|
+
`;
|
|
175
|
+
super(
|
|
176
|
+
`resource: invalid value.
|
|
177
|
+
code: resource-invalid-value
|
|
178
|
+
` + keyClause + ` receivedMode: ${detail.receivedMode}
|
|
179
|
+
expected: ${expected}
|
|
180
|
+
hint: ${hint}`
|
|
181
|
+
);
|
|
182
|
+
this.hint = hint;
|
|
183
|
+
this.expected = expected;
|
|
184
|
+
this.detail = detail;
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
var SpriteAnimationInvalidError = class _SpriteAnimationInvalidError extends Error {
|
|
188
|
+
name = "SpriteAnimationInvalidError";
|
|
189
|
+
code = "sprite-animation-invalid";
|
|
190
|
+
hint;
|
|
191
|
+
expected;
|
|
192
|
+
detail;
|
|
193
|
+
static resolvePolicy(detail) {
|
|
194
|
+
switch (detail.field) {
|
|
195
|
+
case "regions-length":
|
|
196
|
+
return {
|
|
197
|
+
expected: "SpriteAnimation.regions.length === frameCount * 4",
|
|
198
|
+
hint: `SpriteAnimation.regions.length = ${detail.regionsLength} does not match frameCount * 4 = ${detail.frameCount * 4}; pack 4 floats [uMin, vMin, uW, vH] per frame (see <name>.atlas.meta.json sidecar 'regions' map)`
|
|
199
|
+
};
|
|
200
|
+
case "frame-duration":
|
|
201
|
+
return {
|
|
202
|
+
expected: "SpriteAnimation.frameDuration > 0",
|
|
203
|
+
hint: `SpriteAnimation.frameDuration = ${detail.frameDuration} is invalid; use a positive seconds-per-frame value (e.g. 0.1 = 10 fps)`
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
constructor(detail) {
|
|
208
|
+
const policy = _SpriteAnimationInvalidError.resolvePolicy(detail);
|
|
209
|
+
super(
|
|
210
|
+
`SpriteAnimation: invariant violated.
|
|
211
|
+
code: sprite-animation-invalid
|
|
212
|
+
field: ${detail.field}
|
|
213
|
+
expected: ${policy.expected}
|
|
214
|
+
hint: ${policy.hint}`
|
|
215
|
+
);
|
|
216
|
+
this.hint = policy.hint;
|
|
217
|
+
this.expected = policy.expected;
|
|
218
|
+
this.detail = detail;
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
// src/world-internal.ts
|
|
223
|
+
var worldInternal = /* @__PURE__ */ Symbol.for(
|
|
224
|
+
"forgeax.ecs.worldInternal"
|
|
225
|
+
);
|
|
226
|
+
|
|
227
|
+
// src/errors.ts
|
|
228
|
+
var StaleEntityError = class extends Error {
|
|
229
|
+
name = "StaleEntityError";
|
|
230
|
+
code = "stale-entity";
|
|
231
|
+
hint;
|
|
232
|
+
/** Component name involved in the operation (undefined when the operation does not target a specific component). */
|
|
233
|
+
component;
|
|
234
|
+
/** The component-level operation that triggered this error (e.g. 'get' / 'set' / 'add' / 'remove'). Entity-level operations like `despawn` are not surfaced here — see `EntityHandle` lifecycle errors. */
|
|
235
|
+
operation;
|
|
236
|
+
/** The generation the caller expected (from the entity handle). */
|
|
237
|
+
expectedGeneration;
|
|
238
|
+
/**
|
|
239
|
+
* The actual generation found in the entity pool. `-1` is the sentinel
|
|
240
|
+
* value for entities never allocated (slot was never occupied), as opposed
|
|
241
|
+
* to allocated-then-despawned entities which carry a real (incremented)
|
|
242
|
+
* generation number.
|
|
243
|
+
*/
|
|
244
|
+
actualGeneration;
|
|
245
|
+
constructor(entityId, index, generation, enhanced) {
|
|
246
|
+
const hint = enhanced ? `Entity was despawned. Operation "${enhanced.operation}" on entity ${entityId}` + (enhanced.component ? ` (component: ${enhanced.component})` : "") + ` expected generation ${enhanced.expectedGeneration}, found ${enhanced.actualGeneration}. Check entity lifecycle before access.` : "Entity was despawned. Check entity lifecycle before access.";
|
|
247
|
+
super(
|
|
248
|
+
`Operation on stale entity handle.
|
|
249
|
+
entity: ${entityId} (index=${index}, generation=${generation})
|
|
250
|
+
` + (enhanced ? ` operation: ${enhanced.operation}
|
|
251
|
+
` : "") + (enhanced?.component ? ` component: ${enhanced.component}
|
|
252
|
+
` : "") + ` hint: ${hint}`
|
|
253
|
+
);
|
|
254
|
+
this.hint = hint;
|
|
255
|
+
this.component = enhanced?.component;
|
|
256
|
+
this.operation = enhanced?.operation;
|
|
257
|
+
this.expectedGeneration = enhanced?.expectedGeneration;
|
|
258
|
+
this.actualGeneration = enhanced?.actualGeneration;
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
var ManagedBufferOutOfBoundsError = class extends RangeError {
|
|
262
|
+
name = "ManagedBufferOutOfBoundsError";
|
|
263
|
+
code = "managed-buffer-out-of-bounds";
|
|
264
|
+
hint;
|
|
265
|
+
expected;
|
|
266
|
+
detail;
|
|
267
|
+
constructor(index, size) {
|
|
268
|
+
const hint = `Index ${index} is outside [0, ${size}). Check the field's 'buffer' / 'buffer<N>' declaration matches the access pattern.`;
|
|
269
|
+
const expected = `index in [0, ${size})`;
|
|
270
|
+
super(
|
|
271
|
+
`BufferPool: index out of bounds.
|
|
272
|
+
code: managed-buffer-out-of-bounds
|
|
273
|
+
index: ${index}
|
|
274
|
+
size: ${size}
|
|
275
|
+
expected: ${expected}
|
|
276
|
+
hint: ${hint}`
|
|
277
|
+
);
|
|
278
|
+
this.hint = hint;
|
|
279
|
+
this.expected = expected;
|
|
280
|
+
this.detail = { index, size };
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
var InstanceTransformsStrideMismatchError = class extends Error {
|
|
284
|
+
name = "InstanceTransformsStrideMismatchError";
|
|
285
|
+
code = "instance-transforms-stride-mismatch";
|
|
286
|
+
hint;
|
|
287
|
+
expected;
|
|
288
|
+
detail;
|
|
289
|
+
constructor(actualLength) {
|
|
290
|
+
const hint = `Instances.transforms length ${actualLength} violates stride 16 (mat4); ensure transforms.length % 16 === 0 before render frame; verify world.set / world.push call sites`;
|
|
291
|
+
const expectedStr = "actualLength % 16 === 0";
|
|
292
|
+
super(
|
|
293
|
+
`Instances.transforms: stride mismatch.
|
|
294
|
+
code: instance-transforms-stride-mismatch
|
|
295
|
+
actualLength: ${actualLength}
|
|
296
|
+
expectedStride: 16
|
|
297
|
+
hint: ${hint}`
|
|
298
|
+
);
|
|
299
|
+
this.hint = hint;
|
|
300
|
+
this.expected = expectedStr;
|
|
301
|
+
this.detail = { actualLength, expectedStride: 16 };
|
|
302
|
+
}
|
|
303
|
+
};
|
|
304
|
+
|
|
305
|
+
// src/component.ts
|
|
306
|
+
var FIELD_SIZE_BYTES = {
|
|
307
|
+
f32: 4,
|
|
308
|
+
f64: 8,
|
|
309
|
+
i32: 4,
|
|
310
|
+
u32: 4,
|
|
311
|
+
i16: 2,
|
|
312
|
+
u16: 2,
|
|
313
|
+
i8: 1,
|
|
314
|
+
u8: 1,
|
|
315
|
+
bool: 1,
|
|
316
|
+
enum: 4,
|
|
317
|
+
ref: 4
|
|
318
|
+
};
|
|
319
|
+
var COMPONENT_OWNER_REGISTRY = /* @__PURE__ */ Symbol.for("forgeax.ecs.componentOwnerRegistry");
|
|
320
|
+
var ownerSymbols = globalThis;
|
|
321
|
+
var ownerRegistry = ownerSymbols[COMPONENT_OWNER_REGISTRY] ?? (() => {
|
|
322
|
+
const registry = {
|
|
323
|
+
nextId: 1,
|
|
324
|
+
ids: /* @__PURE__ */ new WeakMap(),
|
|
325
|
+
schemas: /* @__PURE__ */ new WeakMap()
|
|
326
|
+
};
|
|
327
|
+
ownerSymbols[COMPONENT_OWNER_REGISTRY] = registry;
|
|
328
|
+
return registry;
|
|
329
|
+
})();
|
|
330
|
+
function componentId(component) {
|
|
331
|
+
const id = ownerRegistry.ids.get(component);
|
|
332
|
+
if (id === void 0) throw new Error(`Component identity missing for '${component.name}'.`);
|
|
333
|
+
return id;
|
|
334
|
+
}
|
|
335
|
+
function componentSchema(component) {
|
|
336
|
+
const schema = ownerRegistry.schemas.get(component);
|
|
337
|
+
if (schema === void 0) throw new Error(`Component schema missing for '${component.name}'.`);
|
|
338
|
+
return schema;
|
|
339
|
+
}
|
|
340
|
+
var VIEW_CTORS = {
|
|
341
|
+
f32: Float32Array,
|
|
342
|
+
f64: Float64Array,
|
|
343
|
+
i32: Int32Array,
|
|
344
|
+
u32: Uint32Array,
|
|
345
|
+
i16: Int16Array,
|
|
346
|
+
u16: Uint16Array,
|
|
347
|
+
i8: Int8Array,
|
|
348
|
+
u8: Uint8Array,
|
|
349
|
+
bool: Uint8Array,
|
|
350
|
+
enum: Uint32Array,
|
|
351
|
+
ref: Uint32Array
|
|
352
|
+
};
|
|
353
|
+
function scalarRow(t) {
|
|
354
|
+
return {
|
|
355
|
+
byteSize: FIELD_SIZE_BYTES[t],
|
|
356
|
+
viewCtor: VIEW_CTORS[t],
|
|
357
|
+
storage: t,
|
|
358
|
+
isScalar: true,
|
|
359
|
+
// The scalar `ref` shares its key with the vocab `ref<T>` family; mark
|
|
360
|
+
// it as managed so the single row covers both.
|
|
361
|
+
isManaged: t === "ref",
|
|
362
|
+
isBuffer: false,
|
|
363
|
+
isEntityRef: false,
|
|
364
|
+
isArray: false
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
Object.freeze({
|
|
368
|
+
f32: scalarRow("f32"),
|
|
369
|
+
f64: scalarRow("f64"),
|
|
370
|
+
i32: scalarRow("i32"),
|
|
371
|
+
u32: scalarRow("u32"),
|
|
372
|
+
i16: scalarRow("i16"),
|
|
373
|
+
u16: scalarRow("u16"),
|
|
374
|
+
i8: scalarRow("i8"),
|
|
375
|
+
u8: scalarRow("u8"),
|
|
376
|
+
bool: scalarRow("bool"),
|
|
377
|
+
enum: scalarRow("enum"),
|
|
378
|
+
ref: scalarRow("ref"),
|
|
379
|
+
entity: {
|
|
380
|
+
byteSize: 4,
|
|
381
|
+
viewCtor: Uint32Array,
|
|
382
|
+
storage: "u32",
|
|
383
|
+
isScalar: false,
|
|
384
|
+
isManaged: false,
|
|
385
|
+
isBuffer: false,
|
|
386
|
+
isEntityRef: true,
|
|
387
|
+
isArray: false
|
|
388
|
+
},
|
|
389
|
+
string: {
|
|
390
|
+
byteSize: 4,
|
|
391
|
+
viewCtor: Uint32Array,
|
|
392
|
+
storage: "u32",
|
|
393
|
+
isScalar: false,
|
|
394
|
+
isManaged: true,
|
|
395
|
+
isBuffer: false,
|
|
396
|
+
isEntityRef: false,
|
|
397
|
+
isArray: false
|
|
398
|
+
},
|
|
399
|
+
buffer: {
|
|
400
|
+
byteSize: 4,
|
|
401
|
+
viewCtor: Uint32Array,
|
|
402
|
+
storage: "u32",
|
|
403
|
+
isScalar: false,
|
|
404
|
+
isManaged: false,
|
|
405
|
+
isBuffer: true,
|
|
406
|
+
isEntityRef: false,
|
|
407
|
+
isArray: false
|
|
408
|
+
},
|
|
409
|
+
// feat-20260614-ecs-shared-component-and-unique-rename M3 (plan-strategy
|
|
410
|
+
// D-3): independent `'shared'` row, NOT a reuse of the `'ref'` (post-M2:
|
|
411
|
+
// `'unique<T>'` family) row. `isManaged: true` so write-barrier dispatch
|
|
412
|
+
// routes shared<T> fields through release on despawn / removeComponent /
|
|
413
|
+
// set-overwrite, but the M4 sub-dispatch in releaseManagedFieldOnRow will
|
|
414
|
+
// separate shared (rc--) from unique (direct slot drop) using the
|
|
415
|
+
// fieldType.startsWith('shared<') predicate. Keeping the meta key
|
|
416
|
+
// independent preserves the "meta key = release semantics" invariant
|
|
417
|
+
// (architecture-principles.md #1 SSOT).
|
|
418
|
+
shared: {
|
|
419
|
+
byteSize: 4,
|
|
420
|
+
viewCtor: Uint32Array,
|
|
421
|
+
storage: "u32",
|
|
422
|
+
isScalar: false,
|
|
423
|
+
isManaged: true,
|
|
424
|
+
isBuffer: false,
|
|
425
|
+
isEntityRef: false,
|
|
426
|
+
isArray: false
|
|
427
|
+
},
|
|
428
|
+
array: {
|
|
429
|
+
byteSize: 4,
|
|
430
|
+
viewCtor: Uint32Array,
|
|
431
|
+
storage: "u32",
|
|
432
|
+
isScalar: false,
|
|
433
|
+
isManaged: false,
|
|
434
|
+
isBuffer: false,
|
|
435
|
+
isEntityRef: false,
|
|
436
|
+
isArray: true
|
|
437
|
+
}
|
|
438
|
+
});
|
|
439
|
+
var ENTITY_NULL_RAW = 4294967295;
|
|
440
|
+
|
|
441
|
+
// src/component-default-fallback.ts
|
|
442
|
+
function typeDefault(fieldType) {
|
|
443
|
+
if (fieldType === "bool") return false;
|
|
444
|
+
if (fieldType === "entity") return ENTITY_NULL_RAW;
|
|
445
|
+
if (fieldType === "array<entity>") return [];
|
|
446
|
+
return 0;
|
|
447
|
+
}
|
|
448
|
+
function fillComponentDefaults(token, raw) {
|
|
449
|
+
const schema = componentSchema(token);
|
|
450
|
+
const layer2 = componentDefinition(token).defaults;
|
|
451
|
+
const out = /* @__PURE__ */ Object.create(null);
|
|
452
|
+
const rawObj = raw ?? void 0;
|
|
453
|
+
for (const fieldName of Object.keys(schema)) {
|
|
454
|
+
const fieldType = schema[fieldName];
|
|
455
|
+
if (fieldType === void 0) continue;
|
|
456
|
+
if (rawObj !== void 0 && fieldName in rawObj) {
|
|
457
|
+
out[fieldName] = rawObj[fieldName];
|
|
458
|
+
continue;
|
|
459
|
+
}
|
|
460
|
+
if (layer2 !== void 0 && fieldName in layer2) {
|
|
461
|
+
out[fieldName] = layer2[fieldName];
|
|
462
|
+
continue;
|
|
463
|
+
}
|
|
464
|
+
out[fieldName] = typeDefault(fieldType);
|
|
465
|
+
}
|
|
466
|
+
return out;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
// src/projection/index.ts
|
|
470
|
+
function readRenderArrayView(world, entity, component, fieldName) {
|
|
471
|
+
return world[worldInternal].getArrayView(entity, component, fieldName);
|
|
472
|
+
}
|
|
473
|
+
function readProjectionSpans(world, generation, request) {
|
|
474
|
+
const queryResult = world.query({ read: request.components.map((entry) => entry.component) });
|
|
475
|
+
if (!queryResult.ok) throw new Error(queryResult.error.message);
|
|
476
|
+
const spansResult = queryResult.value.spans();
|
|
477
|
+
if (!spansResult.ok) throw new Error(spansResult.error.message);
|
|
478
|
+
const spans = [];
|
|
479
|
+
for (const span of spansResult.value) {
|
|
480
|
+
const fields = {};
|
|
481
|
+
for (const entry of request.components) {
|
|
482
|
+
const shape = span.get(entry.component);
|
|
483
|
+
for (const fieldName of entry.fields) {
|
|
484
|
+
const field = shape[fieldName];
|
|
485
|
+
if (field === void 0) {
|
|
486
|
+
throw new Error(
|
|
487
|
+
`Render projection field '${entry.component.name}.${fieldName}' is unavailable.`
|
|
488
|
+
);
|
|
489
|
+
}
|
|
490
|
+
fields[`${entry.component.name}.${fieldName}`] = field;
|
|
491
|
+
if (request.components.length === 1) fields[fieldName] = field;
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
spans.push({ length: span.length, fields: Object.freeze(fields) });
|
|
495
|
+
}
|
|
496
|
+
return {
|
|
497
|
+
generation,
|
|
498
|
+
sharedRefEpoch: world[worldInternal].getSharedRefs().getMutationEpoch(),
|
|
499
|
+
spans: Object.freeze(spans)
|
|
500
|
+
};
|
|
501
|
+
}
|
|
502
|
+
function createRenderReadLease(world, token = {}) {
|
|
503
|
+
const sharedRefs = world[worldInternal].getSharedRefs();
|
|
504
|
+
const generation = Math.max(1, world[worldInternal].getStructureEpoch());
|
|
505
|
+
let disposed = false;
|
|
506
|
+
let nextCursor = 1;
|
|
507
|
+
const cursors = /* @__PURE__ */ new Map([
|
|
508
|
+
[
|
|
509
|
+
0,
|
|
510
|
+
{ world: world[worldInternal].getChangeCursor(), sharedRefs: sharedRefs.getMutationEpoch() }
|
|
511
|
+
]
|
|
512
|
+
]);
|
|
513
|
+
const assertLive = () => {
|
|
514
|
+
if (disposed) throw new Error("RenderReadLease is disposed.");
|
|
515
|
+
};
|
|
516
|
+
const captureCursor = () => {
|
|
517
|
+
const cursor = nextCursor++;
|
|
518
|
+
cursors.set(cursor, {
|
|
519
|
+
world: world[worldInternal].getChangeCursor(),
|
|
520
|
+
sharedRefs: sharedRefs.getMutationEpoch()
|
|
521
|
+
});
|
|
522
|
+
if (cursors.size > 8) {
|
|
523
|
+
const oldest = cursors.keys().next().value;
|
|
524
|
+
if (typeof oldest === "number" && oldest !== cursor) cursors.delete(oldest);
|
|
525
|
+
}
|
|
526
|
+
return cursor;
|
|
527
|
+
};
|
|
528
|
+
return {
|
|
529
|
+
worldIdentity: world.identity,
|
|
530
|
+
generation,
|
|
531
|
+
inspectCursor() {
|
|
532
|
+
assertLive();
|
|
533
|
+
return captureCursor();
|
|
534
|
+
},
|
|
535
|
+
readChanges(cursor) {
|
|
536
|
+
assertLive();
|
|
537
|
+
const start = cursors.get(cursor);
|
|
538
|
+
if (start === void 0) throw new RangeError(`Unknown RenderReadLease cursor ${cursor}.`);
|
|
539
|
+
const worldRead = world[worldInternal].readChangesSince(start.world);
|
|
540
|
+
const sharedRead = sharedRefs.readChangesSince(start.sharedRefs);
|
|
541
|
+
const next = captureCursor();
|
|
542
|
+
if (worldRead.status === "overflow" || sharedRead.status === "overflow") {
|
|
543
|
+
const oldestAvailable = Math.min(
|
|
544
|
+
worldRead.status === "overflow" ? worldRead.oldestAvailable : Number.MAX_SAFE_INTEGER,
|
|
545
|
+
sharedRead.status === "overflow" ? sharedRead.oldestAvailable : Number.MAX_SAFE_INTEGER
|
|
546
|
+
);
|
|
547
|
+
return {
|
|
548
|
+
status: "overflow",
|
|
549
|
+
cursor: next,
|
|
550
|
+
resync: true,
|
|
551
|
+
oldestAvailable,
|
|
552
|
+
world: worldRead,
|
|
553
|
+
sharedRefs: sharedRead
|
|
554
|
+
};
|
|
555
|
+
}
|
|
556
|
+
return { status: "ok", cursor: next, world: worldRead, sharedRefs: sharedRead };
|
|
557
|
+
},
|
|
558
|
+
querySpans(request) {
|
|
559
|
+
assertLive();
|
|
560
|
+
return readProjectionSpans(world, generation, request);
|
|
561
|
+
},
|
|
562
|
+
dispose() {
|
|
563
|
+
disposed = true;
|
|
564
|
+
cursors.clear();
|
|
565
|
+
}
|
|
566
|
+
};
|
|
567
|
+
}
|
|
568
|
+
function setDerivedComponent(world, entity, component, value) {
|
|
569
|
+
const result = world[worldInternal].setQueryRow(entity, component, value);
|
|
570
|
+
if (!result.ok) return result;
|
|
571
|
+
world[worldInternal].markDerivedComponentChanges(componentId(component), [entity]);
|
|
572
|
+
return result;
|
|
573
|
+
}
|
|
574
|
+
function routeWorldError(world, error, context) {
|
|
575
|
+
world[worldInternal].routeError(error, context);
|
|
576
|
+
}
|
|
577
|
+
function createWorldProjection(world, options = {}) {
|
|
578
|
+
const componentById = options.components === void 0 ? void 0 : new Map(options.components.map((component) => [componentId(component), component]));
|
|
579
|
+
const componentIds = componentById === void 0 ? void 0 : new Set(componentById.keys());
|
|
580
|
+
let cursor = world[worldInternal].getChangeCursor();
|
|
581
|
+
const pollSince = (requestedCursor) => {
|
|
582
|
+
const result = world[worldInternal].readChangesSince(requestedCursor);
|
|
583
|
+
if (result.status === "overflow") {
|
|
584
|
+
cursor = result.cursor;
|
|
585
|
+
return { status: "rebuild", cursor, reason: "journal-overflow" };
|
|
586
|
+
}
|
|
587
|
+
cursor = result.cursor;
|
|
588
|
+
const changes = [];
|
|
589
|
+
for (const record of result.records) {
|
|
590
|
+
if (componentIds !== void 0 && record.kind !== "entity-removed" && (record.componentId === void 0 || !componentIds.has(record.componentId))) {
|
|
591
|
+
continue;
|
|
592
|
+
}
|
|
593
|
+
const component = record.componentId === void 0 ? void 0 : componentById?.get(record.componentId);
|
|
594
|
+
changes.push({
|
|
595
|
+
entity: record.entity,
|
|
596
|
+
kind: record.kind,
|
|
597
|
+
...component === void 0 ? {} : { component },
|
|
598
|
+
...record.componentId === void 0 ? {} : { componentId: record.componentId }
|
|
599
|
+
});
|
|
600
|
+
}
|
|
601
|
+
return { status: "delta", cursor, changes };
|
|
602
|
+
};
|
|
603
|
+
return {
|
|
604
|
+
get cursor() {
|
|
605
|
+
return cursor;
|
|
606
|
+
},
|
|
607
|
+
poll() {
|
|
608
|
+
return pollSince(cursor);
|
|
609
|
+
}
|
|
610
|
+
};
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
export { ComponentNotDefinedError, InstanceTransformsStrideMismatchError, ManagedBufferOutOfBoundsError, ResourceInvalidValueError, SpawnLightInvalidBoundsError, SpriteAnimationInvalidError, SpriteInstancesCountMismatchError, SpriteInstancesMutuallyExclusiveWithInstancesError, SpriteInstancesRequiresSpriteShaderError, StaleEntityError, createRenderReadLease, createWorldProjection, fillComponentDefaults, readRenderArrayView, routeWorldError, setDerivedComponent };
|
|
614
|
+
//# sourceMappingURL=index.mjs.map
|
|
615
|
+
//# sourceMappingURL=index.mjs.map
|