@forgeax/engine-import 0.1.21 → 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.
Files changed (91) hide show
  1. package/README.md +91 -3
  2. package/dist/__tests__/ies-contract.unit.test.d.ts +2 -0
  3. package/dist/__tests__/ies-contract.unit.test.d.ts.map +1 -0
  4. package/dist/__tests__/ies-producer.unit.test.d.ts +2 -0
  5. package/dist/__tests__/ies-producer.unit.test.d.ts.map +1 -0
  6. package/dist/__tests__/mesh-lod-contract.unit.test.d.ts +2 -0
  7. package/dist/__tests__/mesh-lod-contract.unit.test.d.ts.map +1 -0
  8. package/dist/__tests__/mesh-lod-reimport.integration.test.d.ts +2 -0
  9. package/dist/__tests__/mesh-lod-reimport.integration.test.d.ts.map +1 -0
  10. package/dist/__tests__/parameterized-scriptable-pack.unit.test.d.ts +2 -0
  11. package/dist/__tests__/parameterized-scriptable-pack.unit.test.d.ts.map +1 -0
  12. package/dist/__tests__/scriptable-pack-file-snapshot.unit.test.d.ts +2 -0
  13. package/dist/__tests__/scriptable-pack-file-snapshot.unit.test.d.ts.map +1 -0
  14. package/dist/__tests__/source-package-publication-lod.integration.test.d.ts +2 -0
  15. package/dist/__tests__/source-package-publication-lod.integration.test.d.ts.map +1 -0
  16. package/dist/browser.d.ts +1 -0
  17. package/dist/browser.d.ts.map +1 -1
  18. package/dist/browser.mjs +230 -3
  19. package/dist/browser.mjs.map +1 -1
  20. package/dist/build-production.d.ts +1 -8
  21. package/dist/build-production.d.ts.map +1 -1
  22. package/dist/ies/ies-importer.d.ts +4 -0
  23. package/dist/ies/ies-importer.d.ts.map +1 -0
  24. package/dist/ies/parse-lm63.d.ts +13 -0
  25. package/dist/ies/parse-lm63.d.ts.map +1 -0
  26. package/dist/ies/resample-type-c.d.ts +4 -0
  27. package/dist/ies/resample-type-c.d.ts.map +1 -0
  28. package/dist/import-runner.d.ts.map +1 -1
  29. package/dist/index.d.ts +11 -6
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/index.mjs +2547 -1028
  32. package/dist/index.mjs.map +1 -1
  33. package/dist/mesh-bin.d.ts.map +1 -1
  34. package/dist/mesh-bin.mjs +29 -1
  35. package/dist/mesh-bin.mjs.map +1 -1
  36. package/dist/mesh-lod.d.ts +60 -0
  37. package/dist/mesh-lod.d.ts.map +1 -0
  38. package/dist/parameterized-scriptable-pack.d.ts +68 -0
  39. package/dist/parameterized-scriptable-pack.d.ts.map +1 -0
  40. package/dist/scriptable-pack-file-snapshot.d.ts +71 -0
  41. package/dist/scriptable-pack-file-snapshot.d.ts.map +1 -0
  42. package/dist/scriptable-pack-host.d.ts +70 -39
  43. package/dist/scriptable-pack-host.d.ts.map +1 -1
  44. package/dist/scriptable-pack-output-producers.d.ts +1 -0
  45. package/dist/scriptable-pack-output-producers.d.ts.map +1 -1
  46. package/dist/scriptable-pack-staged-snapshot.d.ts +2 -2
  47. package/dist/scriptable-pack-staged-snapshot.d.ts.map +1 -1
  48. package/dist/scriptable-pack.d.ts +13 -26
  49. package/dist/scriptable-pack.d.ts.map +1 -1
  50. package/dist/source-package-errors.d.ts.map +1 -1
  51. package/dist/source-package-publication.d.ts.map +1 -1
  52. package/package.json +8 -7
  53. package/src/__tests__/ies-contract.unit.test.ts +31 -0
  54. package/src/__tests__/ies-producer.unit.test.ts +104 -0
  55. package/src/__tests__/mesh-bin.test.ts +69 -0
  56. package/src/__tests__/mesh-lod-contract.unit.test.ts +92 -0
  57. package/src/__tests__/mesh-lod-reimport.integration.test.ts +15 -0
  58. package/src/__tests__/parameterized-scriptable-pack.unit.test.ts +270 -0
  59. package/src/__tests__/scriptable-pack-file-snapshot.unit.test.ts +177 -0
  60. package/src/__tests__/scriptable-pack-host.unit.test.ts +196 -4
  61. package/src/__tests__/scriptable-pack-production-producers.unit.test.ts +2 -0
  62. package/src/__tests__/scriptable-pack-staged-snapshot.unit.test.ts +43 -12
  63. package/src/__tests__/source-package-publication-lod.integration.test.ts +29 -0
  64. package/src/__tests__/source-package-publication.integration.test.ts +26 -1
  65. package/src/browser.ts +5 -0
  66. package/src/build-production.ts +498 -141
  67. package/src/ies/ies-importer.ts +126 -0
  68. package/src/ies/parse-lm63.ts +98 -0
  69. package/src/ies/resample-type-c.ts +108 -0
  70. package/src/import-runner.ts +58 -0
  71. package/src/index.ts +49 -19
  72. package/src/mesh-bin.ts +38 -0
  73. package/src/mesh-lod.ts +265 -0
  74. package/src/parameterized-scriptable-pack.ts +725 -0
  75. package/src/scriptable-pack-file-snapshot.ts +346 -0
  76. package/src/scriptable-pack-host.ts +790 -343
  77. package/src/scriptable-pack-output-producers.ts +55 -0
  78. package/src/scriptable-pack-staged-snapshot.ts +12 -11
  79. package/src/scriptable-pack.ts +16 -485
  80. package/src/source-package-errors.ts +6 -0
  81. package/src/source-package-publication.ts +32 -2
  82. package/dist/.tsbuildinfo +0 -1
  83. package/dist/__tests__/scriptable-pack-product.contract.test.d.ts +0 -2
  84. package/dist/__tests__/scriptable-pack-product.contract.test.d.ts.map +0 -1
  85. package/dist/__tests__/scriptable-pack.integration.test.d.ts +0 -2
  86. package/dist/__tests__/scriptable-pack.integration.test.d.ts.map +0 -1
  87. package/dist/scriptable-source-package.d.ts +0 -14
  88. package/dist/scriptable-source-package.d.ts.map +0 -1
  89. package/src/__tests__/scriptable-pack-product.contract.test.ts +0 -46
  90. package/src/__tests__/scriptable-pack.integration.test.ts +0 -435
  91. 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,
@@ -172,6 +173,13 @@ function meshProduct(input: AssetOutputInput): AssetOutputProduct {
172
173
  sourceField: { fieldName: 'materialSlots', arrayIndex: slotIndex },
173
174
  });
174
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
+ }
175
183
  return {
176
184
  payload: mesh,
177
185
  refs,
@@ -217,6 +225,34 @@ function sceneProduct(
217
225
  };
218
226
  }
219
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
+
220
256
  function createSafeProducer(
221
257
  kind: AssetOutputProducer['kind'],
222
258
  version: string,
@@ -440,6 +476,20 @@ function ordinaryPodProduct(input: AssetOutputInput): AssetOutputProduct {
440
476
  },
441
477
  };
442
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
+ }
443
493
  case 'material':
444
494
  case 'mesh':
445
495
  case 'scene':
@@ -468,6 +518,10 @@ export function createSceneAssetOutputProducer(
468
518
  return createSafeProducer('scene', 'scene-pack/3', (input) => sceneProduct(input, schemas));
469
519
  }
470
520
 
521
+ export function createPreExternalizedSceneAssetOutputProducer(): AssetOutputProducer {
522
+ return createSafeProducer('scene', 'scene-pack/3', preExternalizedSceneProduct);
523
+ }
524
+
471
525
  export function createStandardAssetOutputProducerRegistry(
472
526
  sceneComponents: readonly ScriptablePackSceneComponent[] = [],
473
527
  ): AssetOutputProducerRegistry {
@@ -489,6 +543,7 @@ export function createStandardAssetOutputProducerRegistry(
489
543
  'animation-graph',
490
544
  'audio',
491
545
  'particle-effect',
546
+ 'ies-profile',
492
547
  ] as const) {
493
548
  registry.register(createSafeProducer(kind, 'ordinary-pod/1', ordinaryPodProduct));
494
549
  }
@@ -1,5 +1,5 @@
1
1
  import { AssetGuid } from '@forgeax/engine-pack/guid';
2
- import type { ScriptablePackError } from '@forgeax/engine-pack/source';
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
- | ScriptablePackError
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(stack: readonly string[], owner: string, guid: string): ScriptablePackError {
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-source-build-cycle',
58
- expected: 'an acyclic graph of ScriptablePack content dependencies',
59
- actual: cycle.join(' -> '),
60
- hint: 'break one content read edge or convert it to a reference-only dependency',
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): ScriptablePackError {
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}`,