@forgeax/engine-assets-runtime 0.1.4 → 0.1.7
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/README.md +453 -175
- package/dist/.tsbuildinfo +1 -1
- package/dist/__tests__/aabb.unit.test.d.ts +2 -0
- package/dist/__tests__/aabb.unit.test.d.ts.map +1 -0
- package/dist/__tests__/artifact-integrity.unit.test.d.ts +2 -0
- package/dist/__tests__/artifact-integrity.unit.test.d.ts.map +1 -0
- package/dist/__tests__/artifact-io.unit.test.d.ts +2 -0
- package/dist/__tests__/artifact-io.unit.test.d.ts.map +1 -0
- package/dist/__tests__/asset-evidence-sdk.integration.test.d.ts +2 -0
- package/dist/__tests__/asset-evidence-sdk.integration.test.d.ts.map +1 -0
- package/dist/__tests__/asset-evidence.unit.test.d.ts +2 -0
- package/dist/__tests__/asset-evidence.unit.test.d.ts.map +1 -0
- package/dist/__tests__/asset-kind.unit.test.d.ts +2 -0
- package/dist/__tests__/asset-kind.unit.test.d.ts.map +1 -0
- package/dist/__tests__/asset-registry-catalog-reconcile.integration.test.d.ts +2 -0
- package/dist/__tests__/asset-registry-catalog-reconcile.integration.test.d.ts.map +1 -0
- package/dist/__tests__/asset-registry-catalog-reconcile.unit.test.d.ts +2 -0
- package/dist/__tests__/asset-registry-catalog-reconcile.unit.test.d.ts.map +1 -0
- package/dist/__tests__/asset-registry-catalog.unit.test.d.ts +2 -0
- package/dist/__tests__/asset-registry-catalog.unit.test.d.ts.map +1 -0
- package/dist/__tests__/asset-registry.pack-cache.test.d.ts +2 -0
- package/dist/__tests__/asset-registry.pack-cache.test.d.ts.map +1 -0
- package/dist/__tests__/asset-registry.unit.test.d.ts +2 -0
- package/dist/__tests__/asset-registry.unit.test.d.ts.map +1 -0
- package/dist/__tests__/asset-runtime-error-code-owner.test-d.d.ts +2 -0
- package/dist/__tests__/asset-runtime-error-code-owner.test-d.d.ts.map +1 -0
- package/dist/__tests__/catalog-replica.unit.test.d.ts +2 -0
- package/dist/__tests__/catalog-replica.unit.test.d.ts.map +1 -0
- package/dist/__tests__/catalog-source-v2.unit.test.d.ts +2 -0
- package/dist/__tests__/catalog-source-v2.unit.test.d.ts.map +1 -0
- package/dist/__tests__/catalog-source.unit.test.d.ts +2 -0
- package/dist/__tests__/catalog-source.unit.test.d.ts.map +1 -0
- package/dist/__tests__/catalog-subscription-order.unit.test.d.ts +2 -0
- package/dist/__tests__/catalog-subscription-order.unit.test.d.ts.map +1 -0
- package/dist/__tests__/catalog-subscription.unit.test.d.ts +2 -0
- package/dist/__tests__/catalog-subscription.unit.test.d.ts.map +1 -0
- package/dist/__tests__/decode-image-bytes-pass-through.test.d.ts +2 -0
- package/dist/__tests__/decode-image-bytes-pass-through.test.d.ts.map +1 -0
- package/dist/__tests__/decode-image-bytes.browser.test.d.ts +2 -0
- package/dist/__tests__/decode-image-bytes.browser.test.d.ts.map +1 -0
- package/dist/__tests__/decode-image-bytes.test-d.d.ts +2 -0
- package/dist/__tests__/decode-image-bytes.test-d.d.ts.map +1 -0
- package/dist/__tests__/decode-image-bytes.test.d.ts +2 -0
- package/dist/__tests__/decode-image-bytes.test.d.ts.map +1 -0
- package/dist/__tests__/dynamic-texture-store.unit.test.d.ts +2 -0
- package/dist/__tests__/dynamic-texture-store.unit.test.d.ts.map +1 -0
- package/dist/__tests__/errors-asset.unit.test.d.ts +2 -0
- package/dist/__tests__/errors-asset.unit.test.d.ts.map +1 -0
- package/dist/__tests__/inline-pack-loaders.unit.test.d.ts +2 -0
- package/dist/__tests__/inline-pack-loaders.unit.test.d.ts.map +1 -0
- package/dist/__tests__/instantiate-context.unit.test.d.ts +2 -0
- package/dist/__tests__/instantiate-context.unit.test.d.ts.map +1 -0
- package/dist/__tests__/instantiate-publication-fence.unit.test.d.ts +2 -0
- package/dist/__tests__/instantiate-publication-fence.unit.test.d.ts.map +1 -0
- package/dist/__tests__/instantiate.unit.test.d.ts +2 -0
- package/dist/__tests__/instantiate.unit.test.d.ts.map +1 -0
- package/dist/__tests__/loader-input-contract.unit.test.d.ts +2 -0
- package/dist/__tests__/loader-input-contract.unit.test.d.ts.map +1 -0
- package/dist/__tests__/loader-registry.unit.test.d.ts +2 -0
- package/dist/__tests__/loader-registry.unit.test.d.ts.map +1 -0
- package/dist/__tests__/material-dependency-invalidation.unit.test.d.ts +2 -0
- package/dist/__tests__/material-dependency-invalidation.unit.test.d.ts.map +1 -0
- package/dist/__tests__/material-generation-cache.unit.test.d.ts +2 -0
- package/dist/__tests__/material-generation-cache.unit.test.d.ts.map +1 -0
- package/dist/__tests__/material-load-consumer.test-d.d.ts +2 -0
- package/dist/__tests__/material-load-consumer.test-d.d.ts.map +1 -0
- package/dist/__tests__/material-ready.integration.test.d.ts +2 -0
- package/dist/__tests__/material-ready.integration.test.d.ts.map +1 -0
- package/dist/__tests__/material-stale-generation.unit.test.d.ts +2 -0
- package/dist/__tests__/material-stale-generation.unit.test.d.ts.map +1 -0
- package/dist/__tests__/mesh-bin-morph-v3.test.d.ts +2 -0
- package/dist/__tests__/mesh-bin-morph-v3.test.d.ts.map +1 -0
- package/dist/__tests__/mesh-bin.unit.test.d.ts +2 -0
- package/dist/__tests__/mesh-bin.unit.test.d.ts.map +1 -0
- package/dist/__tests__/mipmap-generator.unit.test.d.ts +2 -0
- package/dist/__tests__/mipmap-generator.unit.test.d.ts.map +1 -0
- package/dist/__tests__/pack-artifact-transcode-model-owner.test.d.ts +2 -0
- package/dist/__tests__/pack-artifact-transcode-model-owner.test.d.ts.map +1 -0
- package/dist/__tests__/pack-basis-load.integration.test.d.ts +2 -0
- package/dist/__tests__/pack-basis-load.integration.test.d.ts.map +1 -0
- package/dist/__tests__/payload-validate.unit.test.d.ts +2 -0
- package/dist/__tests__/payload-validate.unit.test.d.ts.map +1 -0
- package/dist/__tests__/plugin.test.d.ts +2 -0
- package/dist/__tests__/plugin.test.d.ts.map +1 -0
- package/dist/__tests__/registry-concurrency.bench.test.d.ts +2 -0
- package/dist/__tests__/registry-concurrency.bench.test.d.ts.map +1 -0
- package/dist/__tests__/registry-failure-retry.integration.test.d.ts +2 -0
- package/dist/__tests__/registry-failure-retry.integration.test.d.ts.map +1 -0
- package/dist/__tests__/registry-load-graph.integration.test.d.ts +2 -0
- package/dist/__tests__/registry-load-graph.integration.test.d.ts.map +1 -0
- package/dist/__tests__/registry-load-state.unit.test.d.ts +2 -0
- package/dist/__tests__/registry-load-state.unit.test.d.ts.map +1 -0
- package/dist/__tests__/registry-package-cache.unit.test.d.ts +2 -0
- package/dist/__tests__/registry-package-cache.unit.test.d.ts.map +1 -0
- package/dist/__tests__/registry-public-ready.unit.test.d.ts +2 -0
- package/dist/__tests__/registry-public-ready.unit.test.d.ts.map +1 -0
- package/dist/__tests__/resolve-asset-handle.unit.test.d.ts +2 -0
- package/dist/__tests__/resolve-asset-handle.unit.test.d.ts.map +1 -0
- package/dist/__tests__/scene-handle-fields.unit.test.d.ts +2 -0
- package/dist/__tests__/scene-handle-fields.unit.test.d.ts.map +1 -0
- package/dist/__tests__/scene-payload.unit.test.d.ts +2 -0
- package/dist/__tests__/scene-payload.unit.test.d.ts.map +1 -0
- package/dist/__tests__/scene-publication-fence.test.d.ts +2 -0
- package/dist/__tests__/scene-publication-fence.test.d.ts.map +1 -0
- package/dist/__tests__/scriptable-pack-public-surface.test-d.d.ts +2 -0
- package/dist/__tests__/scriptable-pack-public-surface.test-d.d.ts.map +1 -0
- package/dist/__tests__/static-rig.integration.test.d.ts +2 -0
- package/dist/__tests__/static-rig.integration.test.d.ts.map +1 -0
- package/dist/__tests__/validate-material.unit.test.d.ts +2 -0
- package/dist/__tests__/validate-material.unit.test.d.ts.map +1 -0
- package/dist/__tests__/video-pack-loader.integration.test.d.ts +2 -0
- package/dist/__tests__/video-pack-loader.integration.test.d.ts.map +1 -0
- package/dist/aabb.d.ts +3 -0
- package/dist/aabb.d.ts.map +1 -0
- package/dist/asset-registry.d.ts +554 -0
- package/dist/asset-registry.d.ts.map +1 -0
- package/dist/builtin-asset-registry.d.ts +22 -0
- package/dist/builtin-asset-registry.d.ts.map +1 -0
- package/dist/catalog-source.d.ts +2 -1
- package/dist/catalog-source.d.ts.map +1 -1
- package/dist/decode-image-bytes.d.ts +57 -0
- package/dist/decode-image-bytes.d.ts.map +1 -0
- package/dist/dynamic-texture-store.d.ts +89 -0
- package/dist/dynamic-texture-store.d.ts.map +1 -0
- package/dist/errors/asset.d.ts +201 -0
- package/dist/errors/asset.d.ts.map +1 -0
- package/dist/handles.d.ts +143 -0
- package/dist/handles.d.ts.map +1 -0
- package/dist/image-error.d.ts +6 -0
- package/dist/image-error.d.ts.map +1 -0
- package/dist/index.d.ts +32 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +7233 -114
- package/dist/index.mjs.map +1 -1
- package/dist/internal.d.ts +1 -1
- package/dist/internal.d.ts.map +1 -1
- package/dist/loader-registry.d.ts +63 -0
- package/dist/loader-registry.d.ts.map +1 -0
- package/dist/loaders/inline-pack.d.ts +72 -0
- package/dist/loaders/inline-pack.d.ts.map +1 -0
- package/dist/loaders/mesh-bin.d.ts +21 -0
- package/dist/loaders/mesh-bin.d.ts.map +1 -0
- package/dist/loaders/pack-artifact.d.ts +20 -0
- package/dist/loaders/pack-artifact.d.ts.map +1 -0
- package/dist/material/dependency-graph.d.ts +9 -0
- package/dist/material/dependency-graph.d.ts.map +1 -0
- package/dist/material/generation-cache.d.ts +24 -0
- package/dist/material/generation-cache.d.ts.map +1 -0
- package/dist/material/inspection.d.ts +24 -0
- package/dist/material/inspection.d.ts.map +1 -0
- package/dist/material/loader.d.ts +59 -0
- package/dist/material/loader.d.ts.map +1 -0
- package/dist/material/runtime-shader.d.ts +14 -0
- package/dist/material/runtime-shader.d.ts.map +1 -0
- package/dist/mesh-bin.d.ts +3 -0
- package/dist/mesh-bin.d.ts.map +1 -0
- package/dist/mipmap-generator.d.ts +132 -0
- package/dist/mipmap-generator.d.ts.map +1 -0
- package/dist/payload-validate.d.ts +60 -0
- package/dist/payload-validate.d.ts.map +1 -0
- package/dist/plugin.d.ts +16 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/registry/artifact-io.d.ts +16 -0
- package/dist/registry/artifact-io.d.ts.map +1 -0
- package/dist/registry/asset-evidence.d.ts +13 -0
- package/dist/registry/asset-evidence.d.ts.map +1 -0
- package/dist/registry/catalog-state.d.ts +47 -0
- package/dist/registry/catalog-state.d.ts.map +1 -0
- package/dist/registry/catalog.d.ts +48 -0
- package/dist/registry/catalog.d.ts.map +1 -0
- package/dist/registry/instantiate.d.ts +153 -0
- package/dist/registry/instantiate.d.ts.map +1 -0
- package/dist/registry/load-by-guid.d.ts +247 -0
- package/dist/registry/load-by-guid.d.ts.map +1 -0
- package/dist/registry/load-state.d.ts +26 -0
- package/dist/registry/load-state.d.ts.map +1 -0
- package/dist/registry/runtime-projection.d.ts +16 -0
- package/dist/registry/runtime-projection.d.ts.map +1 -0
- package/dist/registry/scene-publication-fence.d.ts +38 -0
- package/dist/registry/scene-publication-fence.d.ts.map +1 -0
- package/dist/registry/validate-material.d.ts +77 -0
- package/dist/registry/validate-material.d.ts.map +1 -0
- package/dist/resolve-asset-handle.d.ts +43 -0
- package/dist/resolve-asset-handle.d.ts.map +1 -0
- package/dist/resolve-tileset-runtime.d.ts +23 -0
- package/dist/resolve-tileset-runtime.d.ts.map +1 -0
- package/dist/scene-handle-fields.d.ts +88 -0
- package/dist/scene-handle-fields.d.ts.map +1 -0
- package/dist/scene-payload.d.ts +15 -0
- package/dist/scene-payload.d.ts.map +1 -0
- package/dist/wire-default-loaders.d.ts +29 -0
- package/dist/wire-default-loaders.d.ts.map +1 -0
- package/package.json +22 -9
- package/src/__tests__/aabb.unit.test.ts +97 -0
- package/src/__tests__/artifact-integrity.unit.test.ts +99 -0
- package/src/__tests__/artifact-io.unit.test.ts +127 -0
- package/src/__tests__/asset-evidence-sdk.integration.test.ts +32 -0
- package/src/__tests__/asset-evidence.unit.test.ts +32 -0
- package/src/__tests__/{asset-kind.test.ts → asset-kind.unit.test.ts} +1 -1
- package/src/__tests__/asset-registry-catalog-reconcile.integration.test.ts +74 -0
- package/src/__tests__/asset-registry-catalog-reconcile.unit.test.ts +89 -0
- package/src/__tests__/asset-registry-catalog.unit.test.ts +170 -0
- package/src/__tests__/asset-registry.pack-cache.test.ts +96 -0
- package/src/__tests__/asset-registry.unit.test.ts +511 -0
- package/src/__tests__/asset-runtime-error-code-owner.test-d.ts +63 -0
- package/src/__tests__/catalog-replica.unit.test.ts +196 -0
- package/src/__tests__/catalog-source-v2.unit.test.ts +158 -0
- package/src/__tests__/catalog-source.unit.test.ts +126 -0
- package/src/__tests__/catalog-subscription-order.unit.test.ts +65 -0
- package/src/__tests__/catalog-subscription.unit.test.ts +28 -0
- package/src/__tests__/decode-image-bytes-pass-through.test.ts +34 -0
- package/src/__tests__/decode-image-bytes.browser.test.ts +102 -0
- package/src/__tests__/decode-image-bytes.test-d.ts +108 -0
- package/src/__tests__/decode-image-bytes.test.ts +90 -0
- package/src/__tests__/decode-image-mime-owner.test.ts +2 -5
- package/src/__tests__/dynamic-texture-store.unit.test.ts +115 -0
- package/src/__tests__/errors-asset.unit.test.ts +92 -0
- package/src/__tests__/inline-pack-loaders.unit.test.ts +548 -0
- package/src/__tests__/instantiate-context.unit.test.ts +65 -0
- package/src/__tests__/instantiate-publication-fence.unit.test.ts +158 -0
- package/src/__tests__/instantiate.unit.test.ts +684 -0
- package/src/__tests__/loader-input-contract.unit.test.ts +89 -0
- package/src/__tests__/loader-registry.unit.test.ts +101 -0
- package/src/__tests__/material-dependency-invalidation.unit.test.ts +14 -0
- package/src/__tests__/material-generation-cache.unit.test.ts +46 -0
- package/src/__tests__/material-load-consumer.test-d.ts +42 -0
- package/src/__tests__/material-ready.integration.test.ts +508 -0
- package/src/__tests__/material-stale-generation.unit.test.ts +147 -0
- package/src/__tests__/mesh-bin-morph-v3.test.ts +22 -0
- package/src/__tests__/mesh-bin.unit.test.ts +152 -0
- package/src/__tests__/mipmap-generator.unit.test.ts +202 -0
- package/src/__tests__/pack-artifact-transcode-model-owner.test.ts +32 -0
- package/src/__tests__/pack-basis-load.integration.test.ts +168 -0
- package/src/__tests__/payload-validate.unit.test.ts +285 -0
- package/src/__tests__/plugin.test.ts +55 -0
- package/src/__tests__/registry-concurrency.bench.test.ts +40 -0
- package/src/__tests__/registry-failure-retry.integration.test.ts +69 -0
- package/src/__tests__/registry-load-graph.integration.test.ts +246 -0
- package/src/__tests__/registry-load-state.unit.test.ts +35 -0
- package/src/__tests__/registry-package-cache.unit.test.ts +53 -0
- package/src/__tests__/registry-public-ready.unit.test.ts +38 -0
- package/src/__tests__/resolve-asset-handle.unit.test.ts +238 -0
- package/src/__tests__/scene-handle-fields.unit.test.ts +129 -0
- package/src/__tests__/scene-payload.unit.test.ts +151 -0
- package/src/__tests__/scene-publication-fence.test.ts +129 -0
- package/src/__tests__/scriptable-pack-public-surface.test-d.ts +27 -0
- package/src/__tests__/static-rig.integration.test.ts +8 -0
- package/src/__tests__/validate-material.unit.test.ts +359 -0
- package/src/__tests__/video-pack-loader.integration.test.ts +83 -0
- package/src/aabb.ts +107 -0
- package/src/asset-registry.ts +2045 -0
- package/src/builtin-asset-registry.ts +164 -0
- package/src/catalog-source.ts +14 -70
- package/src/decode-image-bytes.ts +126 -0
- package/src/dynamic-texture-store.ts +234 -0
- package/src/errors/asset.ts +347 -0
- package/src/handles.ts +186 -0
- package/src/image-error.ts +45 -0
- package/src/index.ts +183 -16
- package/src/internal.ts +1 -0
- package/src/loader-registry.ts +157 -0
- package/src/loaders/inline-pack.ts +837 -0
- package/src/loaders/mesh-bin.ts +304 -0
- package/src/loaders/pack-artifact.ts +665 -0
- package/src/material/dependency-graph.ts +46 -0
- package/src/material/generation-cache.ts +177 -0
- package/src/material/inspection.ts +46 -0
- package/src/material/loader.ts +326 -0
- package/src/material/runtime-shader.ts +133 -0
- package/src/mesh-bin.ts +5 -0
- package/src/mipmap-generator.ts +450 -0
- package/src/payload-validate.ts +573 -0
- package/src/plugin.ts +48 -0
- package/src/registry/artifact-io.ts +259 -0
- package/src/registry/asset-evidence.ts +51 -0
- package/src/registry/catalog-state.ts +409 -0
- package/src/registry/catalog.ts +369 -0
- package/src/registry/instantiate.ts +1056 -0
- package/src/registry/load-by-guid.ts +1657 -0
- package/src/registry/load-state.ts +115 -0
- package/src/registry/runtime-projection.ts +63 -0
- package/src/registry/scene-publication-fence.ts +256 -0
- package/src/registry/validate-material.ts +385 -0
- package/src/resolve-asset-handle.ts +147 -0
- package/src/resolve-tileset-runtime.ts +72 -0
- package/src/scene-handle-fields.ts +221 -0
- package/src/scene-payload.ts +207 -0
- package/src/wire-default-loaders.ts +79 -0
- package/dist/__tests__/asset-graph-red.integration.test.d.ts +0 -2
- package/dist/__tests__/asset-graph-red.integration.test.d.ts.map +0 -1
- package/dist/__tests__/asset-kind.test.d.ts +0 -2
- package/dist/__tests__/asset-kind.test.d.ts.map +0 -1
- package/dist/__tests__/asset-registry-core.integration.test.d.ts +0 -2
- package/dist/__tests__/asset-registry-core.integration.test.d.ts.map +0 -1
- package/dist/__tests__/asset-registry-public-api.test-d.d.ts +0 -2
- package/dist/__tests__/asset-registry-public-api.test-d.d.ts.map +0 -1
- package/dist/__tests__/asset-runtime-core-lifecycle.integration.test.d.ts +0 -2
- package/dist/__tests__/asset-runtime-core-lifecycle.integration.test.d.ts.map +0 -1
- package/dist/__tests__/asset-runtime-snapshot.unit.test.d.ts +0 -2
- package/dist/__tests__/asset-runtime-snapshot.unit.test.d.ts.map +0 -1
- package/dist/__tests__/catalog-session-red.unit.test.d.ts +0 -2
- package/dist/__tests__/catalog-session-red.unit.test.d.ts.map +0 -1
- package/dist/__tests__/registry-lifecycle-red.integration.test.d.ts +0 -2
- package/dist/__tests__/registry-lifecycle-red.integration.test.d.ts.map +0 -1
- package/src/__tests__/asset-graph-red.integration.test.ts +0 -113
- package/src/__tests__/asset-registry-core.integration.test.ts +0 -161
- package/src/__tests__/asset-registry-public-api.test-d.ts +0 -31
- package/src/__tests__/asset-runtime-core-lifecycle.integration.test.ts +0 -79
- package/src/__tests__/asset-runtime-snapshot.unit.test.ts +0 -23
- package/src/__tests__/catalog-session-red.unit.test.ts +0 -276
- package/src/__tests__/registry-lifecycle-red.integration.test.ts +0 -80
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
2
|
+
import { LoaderRegistry, type PackLoaderInput } from '../loader-registry';
|
|
3
|
+
import { renderPipelineLoader, tilesetLoader } from '../loaders/pack-artifact';
|
|
4
|
+
|
|
5
|
+
const input: PackLoaderInput = {
|
|
6
|
+
guid: '11111111-1111-4111-8111-111111111111',
|
|
7
|
+
kind: 'host-blob',
|
|
8
|
+
payload: { value: 1 },
|
|
9
|
+
refs: [],
|
|
10
|
+
artifacts: {
|
|
11
|
+
source: {
|
|
12
|
+
descriptor: { path: 'source.bin', mediaType: 'application/octet-stream' },
|
|
13
|
+
bytes: Uint8Array.of(1, 2),
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
describe('uniform Pack v2 loader input', () => {
|
|
19
|
+
it('contains asset-local artifacts and no catalog transport facts', () => {
|
|
20
|
+
expect(input.artifacts.source?.bytes).toEqual(Uint8Array.of(1, 2));
|
|
21
|
+
expect(input).not.toHaveProperty('packageUrl');
|
|
22
|
+
expect(input).not.toHaveProperty('packageUrl');
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('dispatches one uniform input to the registered kind loader', async () => {
|
|
26
|
+
const load = vi.fn().mockResolvedValue({ ok: true, value: { kind: 'host-blob' } });
|
|
27
|
+
const registry = new LoaderRegistry();
|
|
28
|
+
registry.registerPackLoader({ kind: 'host-blob', load });
|
|
29
|
+
const result = await registry.loadPack(input, {} as never);
|
|
30
|
+
expect(result.ok).toBe(true);
|
|
31
|
+
expect(load).toHaveBeenCalledWith(input, {});
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('rejects a malformed render-pipeline artifact descriptor', async () => {
|
|
35
|
+
const result = await renderPipelineLoader.loadPack?.(
|
|
36
|
+
{
|
|
37
|
+
guid: input.guid,
|
|
38
|
+
kind: 'render-pipeline',
|
|
39
|
+
payload: { kind: 'render-pipeline', pipelineId: 'forgeax::urp' },
|
|
40
|
+
refs: [],
|
|
41
|
+
artifacts: {
|
|
42
|
+
body: {
|
|
43
|
+
descriptor: { path: 'pipeline.json', mediaType: 'application/json' },
|
|
44
|
+
bytes: new TextEncoder().encode(
|
|
45
|
+
JSON.stringify({
|
|
46
|
+
kind: 'render-pipeline',
|
|
47
|
+
pipelineId: 'forgeax::urp',
|
|
48
|
+
config: { passCount: 0 },
|
|
49
|
+
}),
|
|
50
|
+
),
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
{} as never,
|
|
55
|
+
);
|
|
56
|
+
expect(result).toMatchObject({ ok: false });
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('rejects a tileset artifact whose atlas list differs from envelope refs', async () => {
|
|
60
|
+
const refs = ['atlas-a', 'atlas-b'];
|
|
61
|
+
const result = await tilesetLoader.loadPack?.(
|
|
62
|
+
{
|
|
63
|
+
guid: input.guid,
|
|
64
|
+
kind: 'tileset',
|
|
65
|
+
payload: { kind: 'tileset' },
|
|
66
|
+
refs,
|
|
67
|
+
artifacts: {
|
|
68
|
+
body: {
|
|
69
|
+
descriptor: { path: 'tileset.json', mediaType: 'application/json' },
|
|
70
|
+
bytes: new TextEncoder().encode(
|
|
71
|
+
JSON.stringify({
|
|
72
|
+
kind: 'tileset',
|
|
73
|
+
atlases: ['atlas-a', 'atlas-other'],
|
|
74
|
+
tileWidth: 1,
|
|
75
|
+
tileHeight: 1,
|
|
76
|
+
columns: 1,
|
|
77
|
+
rows: 1,
|
|
78
|
+
regions: [{ x: 0, y: 0, width: 1, height: 1 }],
|
|
79
|
+
tiles: [{ regionIndex: 0 }],
|
|
80
|
+
}),
|
|
81
|
+
),
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
{} as never,
|
|
86
|
+
);
|
|
87
|
+
expect(result).toMatchObject({ ok: false });
|
|
88
|
+
});
|
|
89
|
+
});
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
// @forgeax/engine-assets-runtime -- LoaderRegistry coverage (fix issue #709).
|
|
2
|
+
// register/get/registeredKinds with fail-fast duplicate ownership semantics.
|
|
3
|
+
|
|
4
|
+
import type { Loader } from '@forgeax/engine-types';
|
|
5
|
+
import { describe, expect, it } from 'vitest';
|
|
6
|
+
import { LoaderRegistry } from '../loader-registry';
|
|
7
|
+
import { createDefaultLoaderRegistry } from '../wire-default-loaders';
|
|
8
|
+
|
|
9
|
+
function loader(kind: string): Loader<unknown> {
|
|
10
|
+
return { kind, load: async () => ({ ok: true, value: undefined }) } as unknown as Loader<unknown>;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
describe('LoaderRegistry', () => {
|
|
14
|
+
it('registers and looks up a loader by kind', () => {
|
|
15
|
+
const reg = new LoaderRegistry();
|
|
16
|
+
const mesh = loader('mesh');
|
|
17
|
+
const dispose = reg.register(mesh);
|
|
18
|
+
expect(reg.get('mesh')).toBe(mesh);
|
|
19
|
+
dispose();
|
|
20
|
+
expect(reg.get('mesh')).toBeUndefined();
|
|
21
|
+
dispose();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('get returns undefined for an unregistered kind', () => {
|
|
25
|
+
expect(new LoaderRegistry().get('nope')).toBeUndefined();
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('registeredKinds returns the kinds in insertion order', () => {
|
|
29
|
+
const reg = new LoaderRegistry();
|
|
30
|
+
reg.register(loader('mesh'));
|
|
31
|
+
reg.register(loader('material'));
|
|
32
|
+
reg.register(loader('scene'));
|
|
33
|
+
expect(reg.registeredKinds()).toEqual(['mesh', 'material', 'scene']);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('rejects duplicate kinds instead of silently replacing the owner', () => {
|
|
37
|
+
const reg = new LoaderRegistry();
|
|
38
|
+
reg.register(loader('mesh'));
|
|
39
|
+
const second = loader('mesh');
|
|
40
|
+
expect(() => reg.register(second)).toThrow(/duplicate loader kind/);
|
|
41
|
+
expect(reg.get('mesh')).not.toBe(second);
|
|
42
|
+
expect(reg.registeredKinds()).toEqual(['mesh']);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('throws TypeError when kind is an empty string', () => {
|
|
46
|
+
expect(() => new LoaderRegistry().register(loader(''))).toThrow(TypeError);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('throws TypeError when load is not a function', () => {
|
|
50
|
+
const bad = { kind: 'mesh', load: 123 } as unknown as Loader<unknown>;
|
|
51
|
+
expect(() => new LoaderRegistry().register(bad)).toThrow(TypeError);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('does not treat a catalog row as a loader input', async () => {
|
|
55
|
+
const reg = new LoaderRegistry();
|
|
56
|
+
reg.registerPackLoader({
|
|
57
|
+
kind: 'mesh',
|
|
58
|
+
load: async (input) => ({ ok: true, value: input.payload }),
|
|
59
|
+
});
|
|
60
|
+
const result = await reg.loadPack(
|
|
61
|
+
{
|
|
62
|
+
guid: 'mesh-guid',
|
|
63
|
+
kind: 'mesh',
|
|
64
|
+
payload: { vertices: [] },
|
|
65
|
+
refs: [],
|
|
66
|
+
artifacts: {},
|
|
67
|
+
},
|
|
68
|
+
{} as never,
|
|
69
|
+
);
|
|
70
|
+
expect(result.ok).toBe(true);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it('wires every ordinary Asset kind into the default loader registry', () => {
|
|
74
|
+
const expectedKinds = [
|
|
75
|
+
'mesh',
|
|
76
|
+
'material',
|
|
77
|
+
'scene',
|
|
78
|
+
'texture',
|
|
79
|
+
'equirect',
|
|
80
|
+
'sampler',
|
|
81
|
+
'font',
|
|
82
|
+
'render-pipeline',
|
|
83
|
+
'tileset',
|
|
84
|
+
'video',
|
|
85
|
+
'skeleton',
|
|
86
|
+
'skin',
|
|
87
|
+
'animation-clip',
|
|
88
|
+
'animation-graph',
|
|
89
|
+
'audio',
|
|
90
|
+
'particle-effect',
|
|
91
|
+
];
|
|
92
|
+
const registry = createDefaultLoaderRegistry();
|
|
93
|
+
expect(
|
|
94
|
+
registry
|
|
95
|
+
.registeredKinds()
|
|
96
|
+
.filter((kind) => kind !== 'ui')
|
|
97
|
+
.sort(),
|
|
98
|
+
).toEqual(expectedKinds.sort());
|
|
99
|
+
expect(registry.get('ui')).toBeDefined();
|
|
100
|
+
});
|
|
101
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { MaterialDependencyGraph } from '../material/dependency-graph.js';
|
|
3
|
+
|
|
4
|
+
describe('material dependency invalidation', () => {
|
|
5
|
+
it('enumerates reverse edges and selectively invalidates descendants', () => {
|
|
6
|
+
const graph = new MaterialDependencyGraph();
|
|
7
|
+
graph.link('mat-child', ['mat-parent', 'texture/albedo', 'shader/module']);
|
|
8
|
+
graph.link('mat-other', ['texture/other']);
|
|
9
|
+
|
|
10
|
+
expect(graph.dependentsOf('mat-parent')).toEqual(['mat-child']);
|
|
11
|
+
expect(graph.invalidate(['mat-parent'])).toEqual(['mat-child']);
|
|
12
|
+
expect(graph.isInvalidated('mat-other')).toBe(false);
|
|
13
|
+
});
|
|
14
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { MaterialGenerationCache } from '../material/generation-cache.js';
|
|
3
|
+
|
|
4
|
+
describe('material generation cache', () => {
|
|
5
|
+
it('reuses promises by material GUID and artifacts by specialization key', async () => {
|
|
6
|
+
const cache = new MaterialGenerationCache();
|
|
7
|
+
const first = cache.resolve('mat-a', 'key-a', async () => ({ value: 1 }));
|
|
8
|
+
const second = cache.resolve('mat-a', 'key-a', async () => ({ value: 2 }));
|
|
9
|
+
|
|
10
|
+
expect(first).toBe(second);
|
|
11
|
+
await expect(first).resolves.toEqual({ value: 1 });
|
|
12
|
+
cache.storeArtifact('key-a', Object.freeze({ bytes: new Uint8Array([1]) }));
|
|
13
|
+
expect(cache.getArtifact('key-a')).toEqual({ bytes: new Uint8Array([1]) });
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it('allows distinct authored GUIDs to share one artifact', () => {
|
|
17
|
+
const cache = new MaterialGenerationCache();
|
|
18
|
+
const artifact = Object.freeze({ bytes: new Uint8Array([1]) });
|
|
19
|
+
|
|
20
|
+
cache.storeArtifact('key-a', artifact);
|
|
21
|
+
cache.linkResolved('mat-a', 'key-a');
|
|
22
|
+
cache.linkResolved('mat-b', 'key-a');
|
|
23
|
+
|
|
24
|
+
expect(cache.getResolvedKey('mat-a')).toBe('key-a');
|
|
25
|
+
expect(cache.getResolvedKey('mat-b')).toBe('key-a');
|
|
26
|
+
expect(cache.getArtifact('key-a')).toBe(artifact);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('evicts a published specialization when a tracked dependency advances', async () => {
|
|
30
|
+
const cache = new MaterialGenerationCache();
|
|
31
|
+
let calls = 0;
|
|
32
|
+
const load = () =>
|
|
33
|
+
cache.loadWithGeneration('mat-a', ['shader/a'], async (generation) => ({
|
|
34
|
+
generation,
|
|
35
|
+
value: ++calls,
|
|
36
|
+
}));
|
|
37
|
+
|
|
38
|
+
const first = await cache.resolve('mat-a', 'key-a', load);
|
|
39
|
+
expect(first).toMatchObject({ ok: true, value: 1 });
|
|
40
|
+
|
|
41
|
+
cache.bump('shader/a');
|
|
42
|
+
const second = await cache.resolve('mat-a', 'key-a', load);
|
|
43
|
+
expect(second).toMatchObject({ ok: true, value: 2 });
|
|
44
|
+
expect(calls).toBe(2);
|
|
45
|
+
});
|
|
46
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { AssetGuid, MaterialAsset } from '@forgeax/engine-types';
|
|
2
|
+
import { describe, expectTypeOf, it } from 'vitest';
|
|
3
|
+
import type { AssetRegistry } from '../index.js';
|
|
4
|
+
import { loadMaterialReadyByGuid } from '../registry/load-by-guid.js';
|
|
5
|
+
|
|
6
|
+
declare const assets: Pick<AssetRegistry, 'loadByGuid'>;
|
|
7
|
+
declare const materialGuid: AssetGuid;
|
|
8
|
+
|
|
9
|
+
describe('MaterialAsset loadByGuid consumer', () => {
|
|
10
|
+
it('narrows the successful load result without a cast', async () => {
|
|
11
|
+
const loaded = await assets.loadByGuid<MaterialAsset>(materialGuid);
|
|
12
|
+
if (!loaded.ok) return;
|
|
13
|
+
|
|
14
|
+
expectTypeOf(loaded.value.values).toMatchTypeOf<MaterialAsset['values']>();
|
|
15
|
+
expectTypeOf(loaded.value.passes).toMatchTypeOf<MaterialAsset['passes']>();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('exposes the complete MaterialReady tuple and closed error union', async () => {
|
|
19
|
+
const ready = await loadMaterialReadyByGuid(assets as AssetRegistry, {
|
|
20
|
+
guid: 'material-guid',
|
|
21
|
+
specializationKey: 'specialization-key',
|
|
22
|
+
});
|
|
23
|
+
if (ready.status === 'Ready') {
|
|
24
|
+
expectTypeOf(ready.materialGuid).toBeString();
|
|
25
|
+
expectTypeOf(ready.publicationGeneration).toBeNumber();
|
|
26
|
+
expectTypeOf(ready.specializationKey).toBeString();
|
|
27
|
+
expectTypeOf(ready.artifactDigest).toBeString();
|
|
28
|
+
expectTypeOf(ready.sourceClosure).toEqualTypeOf<readonly string[]>();
|
|
29
|
+
expectTypeOf(ready.parameterContract).toHaveProperty('parameters');
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
switch (ready.error.code) {
|
|
33
|
+
case 'material-specialization-not-cooked':
|
|
34
|
+
case 'asset-artifact-missing':
|
|
35
|
+
case 'asset-artifact-integrity-mismatch':
|
|
36
|
+
case 'material-cook-record-invalid':
|
|
37
|
+
case 'material-reference-not-ready':
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
expectTypeOf(ready.error.code).toBeNever();
|
|
41
|
+
});
|
|
42
|
+
});
|