@forgeax/engine-import 0.1.20 → 0.1.23
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 +91 -3
- package/dist/__tests__/ies-contract.unit.test.d.ts +2 -0
- package/dist/__tests__/ies-contract.unit.test.d.ts.map +1 -0
- package/dist/__tests__/ies-producer.unit.test.d.ts +2 -0
- package/dist/__tests__/ies-producer.unit.test.d.ts.map +1 -0
- package/dist/__tests__/mesh-lod-contract.unit.test.d.ts +2 -0
- package/dist/__tests__/mesh-lod-contract.unit.test.d.ts.map +1 -0
- package/dist/__tests__/mesh-lod-reimport.integration.test.d.ts +2 -0
- package/dist/__tests__/mesh-lod-reimport.integration.test.d.ts.map +1 -0
- package/dist/__tests__/parameterized-scriptable-pack.unit.test.d.ts +2 -0
- package/dist/__tests__/parameterized-scriptable-pack.unit.test.d.ts.map +1 -0
- package/dist/__tests__/scriptable-pack-file-snapshot.unit.test.d.ts +2 -0
- package/dist/__tests__/scriptable-pack-file-snapshot.unit.test.d.ts.map +1 -0
- package/dist/__tests__/source-package-publication-lod.integration.test.d.ts +2 -0
- package/dist/__tests__/source-package-publication-lod.integration.test.d.ts.map +1 -0
- package/dist/browser.d.ts +1 -0
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.mjs +230 -3
- package/dist/browser.mjs.map +1 -1
- package/dist/build-production.d.ts +1 -8
- package/dist/build-production.d.ts.map +1 -1
- package/dist/ies/ies-importer.d.ts +4 -0
- package/dist/ies/ies-importer.d.ts.map +1 -0
- package/dist/ies/parse-lm63.d.ts +13 -0
- package/dist/ies/parse-lm63.d.ts.map +1 -0
- package/dist/ies/resample-type-c.d.ts +4 -0
- package/dist/ies/resample-type-c.d.ts.map +1 -0
- package/dist/import-runner.d.ts.map +1 -1
- package/dist/index.d.ts +11 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +2550 -1029
- package/dist/index.mjs.map +1 -1
- package/dist/mesh-bin.d.ts.map +1 -1
- package/dist/mesh-bin.mjs +29 -1
- package/dist/mesh-bin.mjs.map +1 -1
- package/dist/mesh-lod.d.ts +60 -0
- package/dist/mesh-lod.d.ts.map +1 -0
- package/dist/parameterized-scriptable-pack.d.ts +68 -0
- package/dist/parameterized-scriptable-pack.d.ts.map +1 -0
- package/dist/scriptable-pack-file-snapshot.d.ts +71 -0
- package/dist/scriptable-pack-file-snapshot.d.ts.map +1 -0
- package/dist/scriptable-pack-host.d.ts +70 -39
- package/dist/scriptable-pack-host.d.ts.map +1 -1
- package/dist/scriptable-pack-output-producers.d.ts +1 -0
- package/dist/scriptable-pack-output-producers.d.ts.map +1 -1
- package/dist/scriptable-pack-staged-snapshot.d.ts +2 -2
- package/dist/scriptable-pack-staged-snapshot.d.ts.map +1 -1
- package/dist/scriptable-pack.d.ts +13 -26
- package/dist/scriptable-pack.d.ts.map +1 -1
- package/dist/source-package-errors.d.ts.map +1 -1
- package/dist/source-package-publication.d.ts.map +1 -1
- package/package.json +8 -7
- package/src/__tests__/ies-contract.unit.test.ts +31 -0
- package/src/__tests__/ies-producer.unit.test.ts +104 -0
- package/src/__tests__/mesh-bin.test.ts +69 -0
- package/src/__tests__/mesh-lod-contract.unit.test.ts +92 -0
- package/src/__tests__/mesh-lod-reimport.integration.test.ts +15 -0
- package/src/__tests__/parameterized-scriptable-pack.unit.test.ts +270 -0
- package/src/__tests__/scriptable-pack-file-snapshot.unit.test.ts +177 -0
- package/src/__tests__/scriptable-pack-host.unit.test.ts +196 -4
- package/src/__tests__/scriptable-pack-production-producers.unit.test.ts +7 -1
- package/src/__tests__/scriptable-pack-staged-snapshot.unit.test.ts +43 -12
- package/src/__tests__/source-package-publication-lod.integration.test.ts +29 -0
- package/src/__tests__/source-package-publication.integration.test.ts +26 -1
- package/src/browser.ts +5 -0
- package/src/build-production.ts +498 -141
- package/src/ies/ies-importer.ts +126 -0
- package/src/ies/parse-lm63.ts +98 -0
- package/src/ies/resample-type-c.ts +108 -0
- package/src/import-runner.ts +58 -0
- package/src/index.ts +49 -19
- package/src/mesh-bin.ts +38 -0
- package/src/mesh-lod.ts +265 -0
- package/src/parameterized-scriptable-pack.ts +725 -0
- package/src/scriptable-pack-file-snapshot.ts +346 -0
- package/src/scriptable-pack-host.ts +790 -343
- package/src/scriptable-pack-output-producers.ts +58 -1
- package/src/scriptable-pack-staged-snapshot.ts +12 -11
- package/src/scriptable-pack.ts +16 -485
- package/src/source-package-errors.ts +6 -0
- package/src/source-package-publication.ts +32 -2
- package/dist/.tsbuildinfo +0 -1
- package/dist/__tests__/scriptable-pack-product.contract.test.d.ts +0 -2
- package/dist/__tests__/scriptable-pack-product.contract.test.d.ts.map +0 -1
- package/dist/__tests__/scriptable-pack.integration.test.d.ts +0 -2
- package/dist/__tests__/scriptable-pack.integration.test.d.ts.map +0 -1
- package/dist/scriptable-source-package.d.ts +0 -14
- package/dist/scriptable-source-package.d.ts.map +0 -1
- package/src/__tests__/scriptable-pack-product.contract.test.ts +0 -46
- package/src/__tests__/scriptable-pack.integration.test.ts +0 -435
- package/src/scriptable-source-package.ts +0 -88
|
@@ -8,6 +8,7 @@ import type {
|
|
|
8
8
|
AudioClipAsset,
|
|
9
9
|
EquirectAsset,
|
|
10
10
|
FontAsset,
|
|
11
|
+
IesProfileAsset,
|
|
11
12
|
ImportedArtifactBody,
|
|
12
13
|
MaterialAsset,
|
|
13
14
|
MaterialTextureReference,
|
|
@@ -111,7 +112,9 @@ function materialProduct(input: AssetOutputInput): AssetOutputProduct {
|
|
|
111
112
|
? new Set<string>(MATERIAL_TEXTURE_SLOTS)
|
|
112
113
|
: new Set(
|
|
113
114
|
material.parameters
|
|
114
|
-
.filter(
|
|
115
|
+
.filter(
|
|
116
|
+
(parameter) => parameter.type === 'texture' || parameter.type === 'texture_cube',
|
|
117
|
+
)
|
|
115
118
|
.map((parameter) => parameter.name),
|
|
116
119
|
);
|
|
117
120
|
|
|
@@ -170,6 +173,13 @@ function meshProduct(input: AssetOutputInput): AssetOutputProduct {
|
|
|
170
173
|
sourceField: { fieldName: 'materialSlots', arrayIndex: slotIndex },
|
|
171
174
|
});
|
|
172
175
|
}
|
|
176
|
+
const seenRefs = new Set(refs.map((reference) => reference.guid.toLowerCase()));
|
|
177
|
+
for (const [lodIndex, lod] of (mesh.lods ?? []).entries()) {
|
|
178
|
+
const guid = formatGuid(lod.mesh);
|
|
179
|
+
if (seenRefs.has(guid.toLowerCase())) continue;
|
|
180
|
+
seenRefs.add(guid.toLowerCase());
|
|
181
|
+
refs.push({ guid, sourceField: { fieldName: 'lods', arrayIndex: lodIndex } });
|
|
182
|
+
}
|
|
173
183
|
return {
|
|
174
184
|
payload: mesh,
|
|
175
185
|
refs,
|
|
@@ -215,6 +225,34 @@ function sceneProduct(
|
|
|
215
225
|
};
|
|
216
226
|
}
|
|
217
227
|
|
|
228
|
+
function containsAssetGuid(value: unknown): boolean {
|
|
229
|
+
if (typeof value === 'string') return AssetGuid.parse(value).ok;
|
|
230
|
+
if (Array.isArray(value)) return value.some(containsAssetGuid);
|
|
231
|
+
if (value !== null && typeof value === 'object') {
|
|
232
|
+
return Object.values(value as Record<string, unknown>).some(containsAssetGuid);
|
|
233
|
+
}
|
|
234
|
+
return false;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Direct v3 scenes migrated from Pack v2 already carry runtime ref indices in
|
|
239
|
+
* their component payload. There is no component-schema authority in a JSON
|
|
240
|
+
* direct entry, so preserve that transport shape and let the entry's explicit
|
|
241
|
+
* refs provide the closure. A GUID-bearing scene is still sent through the
|
|
242
|
+
* schema-backed producer and therefore fails closed when no schema is present.
|
|
243
|
+
*/
|
|
244
|
+
function preExternalizedSceneProduct(input: AssetOutputInput): AssetOutputProduct {
|
|
245
|
+
if (input.asset.kind !== 'scene') throw new TypeError('expected SceneAsset');
|
|
246
|
+
if (containsAssetGuid(input.asset)) {
|
|
247
|
+
throw new TypeError('direct scene payload must use explicit refs with runtime indices');
|
|
248
|
+
}
|
|
249
|
+
return {
|
|
250
|
+
payload: { ...(input.asset as SceneAsset), kind: 'scene' },
|
|
251
|
+
refs: [],
|
|
252
|
+
artifacts: {},
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
|
|
218
256
|
function createSafeProducer(
|
|
219
257
|
kind: AssetOutputProducer['kind'],
|
|
220
258
|
version: string,
|
|
@@ -438,6 +476,20 @@ function ordinaryPodProduct(input: AssetOutputInput): AssetOutputProduct {
|
|
|
438
476
|
},
|
|
439
477
|
};
|
|
440
478
|
}
|
|
479
|
+
case 'ies-profile': {
|
|
480
|
+
const profile = asset as IesProfileAsset;
|
|
481
|
+
return {
|
|
482
|
+
payload: profile,
|
|
483
|
+
refs: [],
|
|
484
|
+
artifacts: {
|
|
485
|
+
body: {
|
|
486
|
+
mediaType: 'application/octet-stream',
|
|
487
|
+
assetCodec: { name: 'forgeax-ies-profile', version: '1' },
|
|
488
|
+
bytes: bytes(profile.data),
|
|
489
|
+
},
|
|
490
|
+
},
|
|
491
|
+
};
|
|
492
|
+
}
|
|
441
493
|
case 'material':
|
|
442
494
|
case 'mesh':
|
|
443
495
|
case 'scene':
|
|
@@ -466,6 +518,10 @@ export function createSceneAssetOutputProducer(
|
|
|
466
518
|
return createSafeProducer('scene', 'scene-pack/3', (input) => sceneProduct(input, schemas));
|
|
467
519
|
}
|
|
468
520
|
|
|
521
|
+
export function createPreExternalizedSceneAssetOutputProducer(): AssetOutputProducer {
|
|
522
|
+
return createSafeProducer('scene', 'scene-pack/3', preExternalizedSceneProduct);
|
|
523
|
+
}
|
|
524
|
+
|
|
469
525
|
export function createStandardAssetOutputProducerRegistry(
|
|
470
526
|
sceneComponents: readonly ScriptablePackSceneComponent[] = [],
|
|
471
527
|
): AssetOutputProducerRegistry {
|
|
@@ -487,6 +543,7 @@ export function createStandardAssetOutputProducerRegistry(
|
|
|
487
543
|
'animation-graph',
|
|
488
544
|
'audio',
|
|
489
545
|
'particle-effect',
|
|
546
|
+
'ies-profile',
|
|
490
547
|
] as const) {
|
|
491
548
|
registry.register(createSafeProducer(kind, 'ordinary-pod/1', ordinaryPodProduct));
|
|
492
549
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AssetGuid } from '@forgeax/engine-pack/guid';
|
|
2
|
-
import type {
|
|
2
|
+
import type { PackAuthoringError } from '@forgeax/engine-pack/source';
|
|
3
3
|
import type { Asset, AssetGuid as AssetGuidType, ImportError, Result } from '@forgeax/engine-types';
|
|
4
4
|
import { AssetError, err, ok } from '@forgeax/engine-types';
|
|
5
5
|
import type {
|
|
@@ -12,7 +12,7 @@ import type {
|
|
|
12
12
|
export type ScriptablePackSnapshotError =
|
|
13
13
|
| AssetError
|
|
14
14
|
| ImportError
|
|
15
|
-
|
|
|
15
|
+
| PackAuthoringError
|
|
16
16
|
| ScriptablePackDomainError;
|
|
17
17
|
|
|
18
18
|
export interface ScriptablePackStagedOwner {
|
|
@@ -50,21 +50,22 @@ async function assetDigest(asset: Asset): Promise<string> {
|
|
|
50
50
|
return `sha256:${Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, '0')).join('')}`;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
function cycleError(
|
|
53
|
+
function cycleError(
|
|
54
|
+
stack: readonly string[],
|
|
55
|
+
owner: string,
|
|
56
|
+
guid: string,
|
|
57
|
+
): ScriptablePackDomainError {
|
|
54
58
|
const cycleStart = stack.indexOf(owner);
|
|
55
59
|
const cycle = [...stack.slice(cycleStart), owner];
|
|
56
60
|
return {
|
|
57
|
-
code: 'pack-
|
|
58
|
-
expected: '
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
retryable: false,
|
|
62
|
-
recoveryActions: ['inspect-content-dependency-graph', 'edit-source'],
|
|
63
|
-
detail: { sourcePath: owner, sourceKey: guid, incomingRefs: cycle },
|
|
61
|
+
code: 'pack-content-dependency-stalled',
|
|
62
|
+
expected: 'the content dependency worklist to make progress',
|
|
63
|
+
hint: 'inspect the waiting GUID and pending subjects, then break the content-read cycle',
|
|
64
|
+
detail: { waitingGuids: [guid], pendingSubjects: cycle, iterations: 1 },
|
|
64
65
|
};
|
|
65
66
|
}
|
|
66
67
|
|
|
67
|
-
function missingOutputError(owner: string, guid: string):
|
|
68
|
+
function missingOutputError(owner: string, guid: string): ScriptablePackDomainError {
|
|
68
69
|
return {
|
|
69
70
|
code: 'pack-source-output-invalid',
|
|
70
71
|
expected: `owner ${owner} to stage every declared output including ${guid}`,
|