@forgeax/engine-import 0.1.31 → 0.1.32

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/dist/index.mjs CHANGED
@@ -1,12 +1,12 @@
1
1
  import { ok, err, validateSourceOverrideMap, ImportError, IMPORT_ERROR_HINTS, canonicalizeSourceOverrides, AssetError, IES_PROFILE_HEIGHT, IES_PROFILE_WIDTH, IES_PROFILE_BYTE_LENGTH, MATERIAL_TEXTURE_SLOTS, deriveTextureLayout } from '@forgeax/engine-types';
2
2
  export { IMPORT_ERROR_HINTS, ImportError } from '@forgeax/engine-types';
3
3
  import { resolve, dirname, isAbsolute, relative } from 'path';
4
- import { resolveAssetSource, finalizePackageTransportSource, packageTransportRevision, catalogSourcePathFor, buildCatalogProjection, projectPackageCatalog, createRuntimePackPublication, metaPathForGuid } from '@forgeax/engine-pack/build';
4
+ import { resolveAssetSource, finalizePackageTransportSource, packageTransportRevision, catalogSourcePathFor, buildCatalogProjection, projectPackageCatalog, createRuntimePackPublication, metaPathForGuid, stripRuntimePackLifecycle } from '@forgeax/engine-pack/build';
5
5
  import { AssetGuid as AssetGuid$1, PackageId as PackageId$1 } from '@forgeax/engine-pack/guid';
6
6
  import { resolvePackParameterValues, PackageId, isValidPackSourceKey, isScriptablePackAssetKind, AssetGuid, parsePackSourceJson, projectDirectPackJson, projectScriptablePackSceneComponents, resolvePackParameterInheritance } from '@forgeax/engine-pack/source';
7
7
  import { loadScriptablePack } from '@forgeax/engine-pack/source-node';
8
8
  import { stat, readFile, mkdir, writeFile, rename, rm, readdir } from 'fs/promises';
9
- import { createAcceptedPublication, ddcOutputDigest, DdcLifecycle, DdcGenerationSession } from '@forgeax/engine-ddc';
9
+ import { createAcceptedPublication, ddcOutputDigest, DdcLifecycle, DdcEntryStore, DdcGenerationSession } from '@forgeax/engine-ddc';
10
10
  import { deriveVertexLayoutProjection, normalizeMeshPayload } from '@forgeax/engine-geometry';
11
11
  import { BUILTIN_MESH_ASSETS } from '@forgeax/engine-pack/builtin';
12
12
  import { NativeCookerRegistry } from '@forgeax/engine-pack/native-cooker';
@@ -4420,6 +4420,21 @@ async function stageSourcePackageDdc(input) {
4420
4420
  );
4421
4421
  }
4422
4422
  }
4423
+ async function immutablePackPayload(input) {
4424
+ const semantic = stripRuntimePackLifecycle(input.pack);
4425
+ const existing = await new DdcEntryStore(input.root).read(input.desiredKey);
4426
+ if (existing !== null && existing.guid.toLowerCase() === input.guid.toLowerCase() && canonicalDdcJson(stripRuntimePackLifecycle(existing.payload)) === canonicalDdcJson(semantic)) {
4427
+ return {
4428
+ payload: existing.payload,
4429
+ ...existing.receipt.publicationGeneration === void 0 ? {} : { publicationGeneration: existing.receipt.publicationGeneration }
4430
+ };
4431
+ }
4432
+ const publicationGeneration = input.pack !== null && typeof input.pack === "object" && !Array.isArray(input.pack) && typeof input.pack.generation === "number" && Number.isSafeInteger(input.pack.generation) && input.pack.generation > 0 ? input.pack.generation : void 0;
4433
+ return {
4434
+ payload: semantic,
4435
+ ...publicationGeneration === void 0 ? {} : { publicationGeneration }
4436
+ };
4437
+ }
4423
4438
  async function commitSourcePackageDdc(candidate) {
4424
4439
  try {
4425
4440
  const commit = await candidate.session.commitEntry(candidate, candidate.lease.desiredKey);
@@ -4678,12 +4693,14 @@ async function stageImportPublication(input) {
4678
4693
  };
4679
4694
  }
4680
4695
  const artifacts = validatedArtifacts.value;
4696
+ const selected = await immutablePackPayload(input);
4697
+ const { payload } = selected;
4681
4698
  const staged = await stageSourcePackageDdc({
4682
4699
  root: input.root,
4683
4700
  entry: {
4684
4701
  key: input.desiredKey,
4685
4702
  guid: input.guid,
4686
- payload: input.pack,
4703
+ payload,
4687
4704
  refs: [],
4688
4705
  artifacts,
4689
4706
  receipt: {
@@ -4691,9 +4708,10 @@ async function stageImportPublication(input) {
4691
4708
  key: input.desiredKey,
4692
4709
  producer: "engine-import/source-package-publication",
4693
4710
  inputFingerprint: input.desiredKey,
4711
+ ...selected.publicationGeneration === void 0 ? {} : { publicationGeneration: selected.publicationGeneration },
4694
4712
  outputDigest: ddcOutputDigest({
4695
4713
  guid: input.guid,
4696
- payload: input.pack,
4714
+ payload,
4697
4715
  refs: [],
4698
4716
  artifacts
4699
4717
  })