@forgeax/engine-import 0.1.7 → 0.1.20
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/.tsbuildinfo +1 -1
- package/dist/__tests__/scriptable-pack-texture.unit.test.d.ts +2 -0
- package/dist/__tests__/scriptable-pack-texture.unit.test.d.ts.map +1 -0
- package/dist/__tests__/source-package-errors.unit.test.d.ts +2 -0
- package/dist/__tests__/source-package-errors.unit.test.d.ts.map +1 -0
- package/dist/browser.mjs +5 -2
- package/dist/browser.mjs.map +1 -1
- package/dist/build-production.d.ts.map +1 -1
- package/dist/catalog-inventory.d.ts +1 -1
- package/dist/catalog-inventory.d.ts.map +1 -1
- package/dist/import-runner.d.ts +9 -0
- package/dist/import-runner.d.ts.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +140 -45
- package/dist/index.mjs.map +1 -1
- package/dist/scriptable-pack-host.d.ts +1 -1
- 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/source-package-errors.d.ts +2 -0
- package/dist/source-package-errors.d.ts.map +1 -1
- package/dist/source-path.d.ts +12 -0
- package/dist/source-path.d.ts.map +1 -0
- package/package.json +7 -7
- package/src/__tests__/import-dependencies.test.ts +34 -0
- package/src/__tests__/scriptable-pack-product.contract.test.ts +4 -5
- package/src/__tests__/scriptable-pack-production-producers.unit.test.ts +4 -5
- package/src/__tests__/scriptable-pack-texture.unit.test.ts +96 -0
- package/src/__tests__/source-package-errors.unit.test.ts +62 -0
- package/src/build-production.ts +38 -14
- package/src/catalog-inventory.ts +2 -0
- package/src/import-runner.ts +15 -2
- package/src/index.ts +6 -0
- package/src/scriptable-pack-host.ts +6 -2
- package/src/scriptable-pack-output-producers.ts +54 -16
- package/src/source-package-errors.ts +37 -0
- package/src/source-path.ts +36 -0
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ok, validateSourceOverrideMap, ImportError, IMPORT_ERROR_HINTS, canonicalizeSourceOverrides, err, AssetError, MATERIAL_TEXTURE_SLOTS } from '@forgeax/engine-types';
|
|
1
|
+
import { ok, validateSourceOverrideMap, ImportError, IMPORT_ERROR_HINTS, canonicalizeSourceOverrides, err, AssetError, MATERIAL_TEXTURE_SLOTS, deriveTextureLayout } from '@forgeax/engine-types';
|
|
2
2
|
export { IMPORT_ERROR_HINTS, ImportError } from '@forgeax/engine-types';
|
|
3
|
-
import { resolve, dirname } from 'path';
|
|
4
|
-
import { upgradeLegacyAuthoredPack, loadAssetConfig, resolveAssetSource, finalizePackageTransportSource, projectCookedPackageEntry, buildCatalogProjection, createRuntimePackPublication, metaPathForGuid } from '@forgeax/engine-pack/build';
|
|
3
|
+
import { resolve, isAbsolute, relative, dirname } from 'path';
|
|
4
|
+
import { upgradeLegacyAuthoredPack, loadAssetConfig, resolveAssetSource, finalizePackageTransportSource, catalogSourcePathFor, projectCookedPackageEntry, buildCatalogProjection, createRuntimePackPublication, metaPathForGuid } from '@forgeax/engine-pack/build';
|
|
5
5
|
import { createHash } from 'crypto';
|
|
6
6
|
import { stat, mkdir, writeFile, rename, rm } from 'fs/promises';
|
|
7
7
|
import { createAcceptedPublication, ddcOutputDigest, DdcGenerationSession, DdcLifecycle } from '@forgeax/engine-ddc';
|
|
@@ -178,6 +178,9 @@ function normalizeDependencyPath(path) {
|
|
|
178
178
|
}
|
|
179
179
|
return parts.join("/");
|
|
180
180
|
}
|
|
181
|
+
function dependencyIdentity(fs, sourcePath) {
|
|
182
|
+
return normalizeDependencyPath(fs.sourceIdentityFor?.(sourcePath) ?? sourcePath);
|
|
183
|
+
}
|
|
181
184
|
function errResult(error) {
|
|
182
185
|
return { ok: false, error };
|
|
183
186
|
}
|
|
@@ -315,7 +318,7 @@ async function runImport(meta, registry, fs) {
|
|
|
315
318
|
}
|
|
316
319
|
const dependencies = /* @__PURE__ */ new Set();
|
|
317
320
|
const readSource = async (sourcePath) => {
|
|
318
|
-
dependencies.add(
|
|
321
|
+
dependencies.add(dependencyIdentity(fs, sourcePath));
|
|
319
322
|
try {
|
|
320
323
|
return await fs.readSource(sourcePath);
|
|
321
324
|
} catch (error) {
|
|
@@ -326,7 +329,7 @@ async function runImport(meta, registry, fs) {
|
|
|
326
329
|
let inner;
|
|
327
330
|
try {
|
|
328
331
|
if (fs.readSibling) {
|
|
329
|
-
dependencies.add(
|
|
332
|
+
dependencies.add(dependencyIdentity(fs, joinSiblingPath(meta.source, uri)));
|
|
330
333
|
inner = await fs.readSibling(meta.source, uri);
|
|
331
334
|
} else {
|
|
332
335
|
inner = await readSource(joinSiblingPath(meta.source, uri));
|
|
@@ -1278,23 +1281,40 @@ function ref(guid, fieldName, arrayIndex) {
|
|
|
1278
1281
|
function bytes(value) {
|
|
1279
1282
|
return Uint8Array.from(value);
|
|
1280
1283
|
}
|
|
1284
|
+
function textureProduct(input) {
|
|
1285
|
+
if (input.asset.kind !== "texture") throw new TypeError("expected TextureAsset");
|
|
1286
|
+
const texture = input.asset;
|
|
1287
|
+
const layout = deriveTextureLayout({
|
|
1288
|
+
shape: texture.shape,
|
|
1289
|
+
format: texture.format,
|
|
1290
|
+
mips: texture.mips,
|
|
1291
|
+
actualByteLength: texture.data.byteLength,
|
|
1292
|
+
order: "mip-major,image-major,row-major"
|
|
1293
|
+
});
|
|
1294
|
+
if (!layout.ok) {
|
|
1295
|
+
const expectedBytes = layout.error.code === "texture-packing-invalid" ? layout.error.detail.expectedBytes : texture.data.byteLength;
|
|
1296
|
+
const actualBytes = layout.error.code === "texture-packing-invalid" ? layout.error.detail.actualBytes : texture.data.byteLength;
|
|
1297
|
+
throw new TypeError(
|
|
1298
|
+
`texture data is not canonical: expected ${expectedBytes} bytes, got ${actualBytes}`
|
|
1299
|
+
);
|
|
1300
|
+
}
|
|
1301
|
+
return {
|
|
1302
|
+
payload: texture,
|
|
1303
|
+
refs: [],
|
|
1304
|
+
artifacts: {
|
|
1305
|
+
body: {
|
|
1306
|
+
mediaType: texture.format === "r8unorm" ? "application/x-forgeax-r8" : `application/x-forgeax-${texture.format}`,
|
|
1307
|
+
assetCodec: { name: texture.format, version: "1" },
|
|
1308
|
+
bytes: bytes(texture.data)
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
};
|
|
1312
|
+
}
|
|
1281
1313
|
function ordinaryPodProduct(input) {
|
|
1282
1314
|
const asset = input.asset;
|
|
1283
1315
|
switch (asset.kind) {
|
|
1284
|
-
case "texture":
|
|
1285
|
-
|
|
1286
|
-
return {
|
|
1287
|
-
payload: texture,
|
|
1288
|
-
refs: [],
|
|
1289
|
-
artifacts: {
|
|
1290
|
-
body: {
|
|
1291
|
-
mediaType: "image/raw",
|
|
1292
|
-
assetCodec: { name: "raw-image", version: "1" },
|
|
1293
|
-
bytes: bytes(texture.data)
|
|
1294
|
-
}
|
|
1295
|
-
}
|
|
1296
|
-
};
|
|
1297
|
-
}
|
|
1316
|
+
case "texture":
|
|
1317
|
+
return textureProduct(input);
|
|
1298
1318
|
case "equirect": {
|
|
1299
1319
|
const equirect = asset;
|
|
1300
1320
|
return {
|
|
@@ -1449,6 +1469,11 @@ var materialAssetOutputProducer = createSafeProducer(
|
|
|
1449
1469
|
materialProduct
|
|
1450
1470
|
);
|
|
1451
1471
|
var meshAssetOutputProducer = createSafeProducer("mesh", "mesh-binary/4", meshProduct);
|
|
1472
|
+
var textureAssetOutputProducer = createSafeProducer(
|
|
1473
|
+
"texture",
|
|
1474
|
+
"texture-pack/1",
|
|
1475
|
+
textureProduct
|
|
1476
|
+
);
|
|
1452
1477
|
function createSceneAssetOutputProducer(sceneComponents = []) {
|
|
1453
1478
|
const schemas = new Map(
|
|
1454
1479
|
sceneComponents.map((component) => [component.name, component.fields])
|
|
@@ -1459,9 +1484,9 @@ function createStandardAssetOutputProducerRegistry(sceneComponents = []) {
|
|
|
1459
1484
|
const registry = new AssetOutputProducerRegistry();
|
|
1460
1485
|
registry.register(materialAssetOutputProducer);
|
|
1461
1486
|
registry.register(meshAssetOutputProducer);
|
|
1487
|
+
registry.register(textureAssetOutputProducer);
|
|
1462
1488
|
registry.register(createSceneAssetOutputProducer(sceneComponents));
|
|
1463
1489
|
for (const kind of [
|
|
1464
|
-
"texture",
|
|
1465
1490
|
"equirect",
|
|
1466
1491
|
"sampler",
|
|
1467
1492
|
"font",
|
|
@@ -1740,11 +1765,13 @@ function canonicalScriptableSourcePath(sourcePath) {
|
|
|
1740
1765
|
const markerIndex = normalized.indexOf(marker);
|
|
1741
1766
|
return markerIndex < 0 ? normalized : normalized.slice(markerIndex + 1);
|
|
1742
1767
|
}
|
|
1743
|
-
function scriptablePackInputs(sourcePaths, declarations, cwd, generationFor, policyFor) {
|
|
1768
|
+
function scriptablePackInputs(sourcePaths, declarations, cwd, generationFor, policyFor, sourceIdentityFor) {
|
|
1744
1769
|
return sourcePaths.flatMap((sourcePath) => {
|
|
1745
1770
|
const declaration = declarations.get(resolve(cwd, sourcePath));
|
|
1746
1771
|
if (declaration?.format !== "pack.ts") return [];
|
|
1747
|
-
const
|
|
1772
|
+
const projected = sourceIdentityFor?.(sourcePath);
|
|
1773
|
+
const catalogSourcePath = projected === void 0 || isAbsolute(projected) ? relative(cwd, sourcePath) : projected;
|
|
1774
|
+
const displaySourcePath = canonicalScriptableSourcePath(catalogSourcePath);
|
|
1748
1775
|
return [
|
|
1749
1776
|
{
|
|
1750
1777
|
sourcePath: resolve(cwd, sourcePath),
|
|
@@ -2097,6 +2124,22 @@ async function produceScriptablePackProducts(sources, declaredExternalOutputs =
|
|
|
2097
2124
|
}
|
|
2098
2125
|
return ok(prepared);
|
|
2099
2126
|
}
|
|
2127
|
+
function normalizeCatalogPath(path) {
|
|
2128
|
+
return path.replaceAll("\\", "/").replace(/^\.\//, "");
|
|
2129
|
+
}
|
|
2130
|
+
function sourceDeclarationForCatalogPath(sourcePath, declarations, sourceIdentityFor, cwd = process.cwd()) {
|
|
2131
|
+
const normalized = normalizeCatalogPath(sourcePath);
|
|
2132
|
+
const direct = declarations.get(resolve(cwd, sourcePath));
|
|
2133
|
+
if (direct !== void 0) {
|
|
2134
|
+
return { sourcePath: resolve(cwd, sourcePath), declaration: direct };
|
|
2135
|
+
}
|
|
2136
|
+
for (const [physicalPath, declaration] of declarations) {
|
|
2137
|
+
if (catalogSourcePathFor(cwd, physicalPath, sourceIdentityFor) === normalized) {
|
|
2138
|
+
return { sourcePath: physicalPath, declaration };
|
|
2139
|
+
}
|
|
2140
|
+
}
|
|
2141
|
+
return void 0;
|
|
2142
|
+
}
|
|
2100
2143
|
|
|
2101
2144
|
// src/build-production.ts
|
|
2102
2145
|
function scriptableArtifactPath(guid, key) {
|
|
@@ -2114,11 +2157,7 @@ function runtimePublicationFor(context, input) {
|
|
|
2114
2157
|
});
|
|
2115
2158
|
}
|
|
2116
2159
|
async function buildAuthoredPackages(context) {
|
|
2117
|
-
const scriptableSources = [
|
|
2118
|
-
...new Set(
|
|
2119
|
-
context.inventory.entries.filter((entry) => entry.sourcePath.endsWith(".pack.ts")).map((entry) => entry.sourcePath)
|
|
2120
|
-
)
|
|
2121
|
-
];
|
|
2160
|
+
const scriptableSources = [...context.inventory.sourceDeclarations.entries()].filter(([, declaration]) => declaration.format === "pack.ts").map(([sourcePath]) => sourcePath);
|
|
2122
2161
|
if (scriptableSources.length === 0) return /* @__PURE__ */ new Map();
|
|
2123
2162
|
const inputs = scriptablePackInputs(
|
|
2124
2163
|
scriptableSources,
|
|
@@ -2129,7 +2168,8 @@ async function buildAuthoredPackages(context) {
|
|
|
2129
2168
|
base: context.basePrefix === "" ? "/" : context.basePrefix,
|
|
2130
2169
|
packagePath: `assets/${product.anchorGuid}.pack.json`,
|
|
2131
2170
|
artifactPath: scriptableArtifactPath
|
|
2132
|
-
})
|
|
2171
|
+
}),
|
|
2172
|
+
context.fsForImport.sourceIdentityFor
|
|
2133
2173
|
);
|
|
2134
2174
|
const preparedResult = await produceScriptablePackProducts(
|
|
2135
2175
|
inputs,
|
|
@@ -2207,7 +2247,7 @@ async function buildAuthoredPackages(context) {
|
|
|
2207
2247
|
}
|
|
2208
2248
|
return result;
|
|
2209
2249
|
}
|
|
2210
|
-
function updateImportedEntries(entries, guids, packageUrl, projection = {}, refsByGuid, publication) {
|
|
2250
|
+
function updateImportedEntries(entries, guids, packageUrl, projection = {}, refsByGuid, publication, sourcePath) {
|
|
2211
2251
|
const selected = new Set(guids.map((guid) => guid.toLowerCase()));
|
|
2212
2252
|
for (let index = 0; index < entries.length; index += 1) {
|
|
2213
2253
|
const entry = entries[index];
|
|
@@ -2217,6 +2257,7 @@ function updateImportedEntries(entries, guids, packageUrl, projection = {}, refs
|
|
|
2217
2257
|
...entry,
|
|
2218
2258
|
packageUrl,
|
|
2219
2259
|
...projection,
|
|
2260
|
+
...sourcePath === void 0 ? {} : { sourcePath },
|
|
2220
2261
|
...publication === void 0 ? {} : { publication },
|
|
2221
2262
|
...refs === void 0 ? {} : { refs }
|
|
2222
2263
|
};
|
|
@@ -2243,13 +2284,20 @@ async function emitPackDocument(work, options) {
|
|
|
2243
2284
|
packageUrl,
|
|
2244
2285
|
options.projection,
|
|
2245
2286
|
options.refsByGuid,
|
|
2246
|
-
options.publication
|
|
2287
|
+
options.publication,
|
|
2288
|
+
options.sourcePath
|
|
2247
2289
|
);
|
|
2248
2290
|
return packageUrl;
|
|
2249
2291
|
}
|
|
2250
2292
|
async function emitAuthoredPack(work, guidSeen, entry) {
|
|
2251
|
-
const
|
|
2252
|
-
|
|
2293
|
+
const sourceDeclaration = sourceDeclarationForCatalogPath(
|
|
2294
|
+
entry.sourcePath,
|
|
2295
|
+
work.context.inventory.sourceDeclarations,
|
|
2296
|
+
work.context.fsForImport.sourceIdentityFor,
|
|
2297
|
+
work.context.cwd
|
|
2298
|
+
);
|
|
2299
|
+
const packPath = sourceDeclaration?.sourcePath ?? resolve(work.context.cwd, entry.sourcePath);
|
|
2300
|
+
const declaration = sourceDeclaration?.declaration;
|
|
2253
2301
|
if (declaration?.format !== "pack.json") {
|
|
2254
2302
|
throw work.context.fail({
|
|
2255
2303
|
code: "catalog-declaration-missing",
|
|
@@ -2272,8 +2320,8 @@ async function emitAuthoredPack(work, guidSeen, entry) {
|
|
|
2272
2320
|
const authoredPack = prepared.finalized?.pack ?? prepared.pack;
|
|
2273
2321
|
const runtimePublication = authoredPack.assets === void 0 || authoredPack.assets.length === 0 ? void 0 : runtimePublicationFor(work.context, {
|
|
2274
2322
|
pack: { assets: authoredPack.assets },
|
|
2275
|
-
sourcePath:
|
|
2276
|
-
sourceRevision:
|
|
2323
|
+
sourcePath: entry.sourcePath,
|
|
2324
|
+
sourceRevision: declaration.sourceRevision,
|
|
2277
2325
|
packageUrl: prepared.finalized?.packageUrl ?? `${work.context.basePrefix === "/" ? "" : work.context.basePrefix}/assets/${outputGuid}.pack.json`,
|
|
2278
2326
|
...prepared.finalized?.digest === void 0 ? {} : { digest: prepared.finalized.digest }
|
|
2279
2327
|
});
|
|
@@ -2291,7 +2339,7 @@ async function emitAuthoredPack(work, guidSeen, entry) {
|
|
|
2291
2339
|
guidSeen.add(guid.toLowerCase());
|
|
2292
2340
|
}
|
|
2293
2341
|
}
|
|
2294
|
-
async function emitFinalizedOwner(work, metaPath, subAssets, sourcePackage, ownerFinalizer) {
|
|
2342
|
+
async function emitFinalizedOwner(work, metaPath, sourcePath, subAssets, sourcePackage, ownerFinalizer) {
|
|
2295
2343
|
const ownerGuid = subAssets[0]?.guid;
|
|
2296
2344
|
if (ownerGuid === void 0) return;
|
|
2297
2345
|
const artifactPaths = /* @__PURE__ */ new Map();
|
|
@@ -2334,7 +2382,10 @@ async function emitFinalizedOwner(work, metaPath, subAssets, sourcePackage, owne
|
|
|
2334
2382
|
);
|
|
2335
2383
|
const runtimePublication = runtimePublicationFor(work.context, {
|
|
2336
2384
|
pack: { assets: ownerPackage.pack.assets },
|
|
2337
|
-
|
|
2385
|
+
// The Catalog entry identifies the imported source, while metaPath is the
|
|
2386
|
+
// sidecar declaration that drove the import. Keep publication fences on
|
|
2387
|
+
// the Catalog identity in production just as the dev importer does.
|
|
2388
|
+
sourcePath,
|
|
2338
2389
|
sourceRevision: ownerPackage.sourceRevision,
|
|
2339
2390
|
packageUrl: ownerPackage.packageUrl,
|
|
2340
2391
|
digest: ownerPackage.digest
|
|
@@ -2352,7 +2403,8 @@ async function emitFinalizedOwner(work, metaPath, subAssets, sourcePackage, owne
|
|
|
2352
2403
|
asset.refs.map((ref2) => ref2.guid)
|
|
2353
2404
|
])
|
|
2354
2405
|
),
|
|
2355
|
-
publication: runtimePublication.publication
|
|
2406
|
+
publication: runtimePublication.publication,
|
|
2407
|
+
sourcePath
|
|
2356
2408
|
});
|
|
2357
2409
|
}
|
|
2358
2410
|
async function emitBuildEntry(work, guidSeen, entry) {
|
|
@@ -2383,7 +2435,14 @@ async function emitBuildEntry(work, guidSeen, entry) {
|
|
|
2383
2435
|
if (!sourcePackage.ok) throw work.context.fail(sourcePackage.error);
|
|
2384
2436
|
const ownerFinalizer = work.context.importerRegistry.get(runMeta.importer)?.finalize;
|
|
2385
2437
|
if (ownerFinalizer !== void 0) {
|
|
2386
|
-
await emitFinalizedOwner(
|
|
2438
|
+
await emitFinalizedOwner(
|
|
2439
|
+
work,
|
|
2440
|
+
metaPath,
|
|
2441
|
+
canonicalScriptableSourcePath(entry.sourcePath),
|
|
2442
|
+
subAssets,
|
|
2443
|
+
sourcePackage.value,
|
|
2444
|
+
ownerFinalizer
|
|
2445
|
+
);
|
|
2387
2446
|
return;
|
|
2388
2447
|
}
|
|
2389
2448
|
const finalized = await finalizePackageTransportSource(
|
|
@@ -2397,9 +2456,12 @@ async function emitBuildEntry(work, guidSeen, entry) {
|
|
|
2397
2456
|
}
|
|
2398
2457
|
);
|
|
2399
2458
|
const productByGuid = sourcePackageAssetsByGuid(sourcePackage.value);
|
|
2459
|
+
const canonicalSourcePath = canonicalScriptableSourcePath(entry.sourcePath);
|
|
2400
2460
|
const runtimePublication = runtimePublicationFor(work.context, {
|
|
2401
2461
|
pack: { assets: finalized.pack.assets },
|
|
2402
|
-
|
|
2462
|
+
// See emitFinalizedOwner: the sidecar path is an import driver, not the
|
|
2463
|
+
// stable source identity carried by the Catalog row.
|
|
2464
|
+
sourcePath: canonicalSourcePath,
|
|
2403
2465
|
sourceRevision: finalized.sourceRevision,
|
|
2404
2466
|
packageUrl: finalized.packageUrl,
|
|
2405
2467
|
digest: finalized.digest
|
|
@@ -2414,7 +2476,8 @@ async function emitBuildEntry(work, guidSeen, entry) {
|
|
|
2414
2476
|
refsByGuid: new Map(
|
|
2415
2477
|
[...productByGuid].map(([guid2, asset]) => [guid2, asset.refs.map((ref2) => ref2.guid)])
|
|
2416
2478
|
),
|
|
2417
|
-
publication: runtimePublication.publication
|
|
2479
|
+
publication: runtimePublication.publication,
|
|
2480
|
+
sourcePath: canonicalSourcePath
|
|
2418
2481
|
});
|
|
2419
2482
|
}
|
|
2420
2483
|
async function produceBuildAssets(context) {
|
|
@@ -2481,12 +2544,13 @@ function catalogImporterPolicy(importer, hostImporterKeys) {
|
|
|
2481
2544
|
hint: "wire the provider through the host importer registry before building the Catalog"
|
|
2482
2545
|
};
|
|
2483
2546
|
}
|
|
2484
|
-
async function buildCatalogResult(roots, base = "/", registeredImporterKeys = /* @__PURE__ */ new Set(), scanOptions = {}, catalogVisibility = () => true) {
|
|
2547
|
+
async function buildCatalogResult(roots, base = "/", registeredImporterKeys = /* @__PURE__ */ new Set(), scanOptions = {}, catalogVisibility = () => true, sourceIdentityFor) {
|
|
2485
2548
|
const options = {
|
|
2486
2549
|
base,
|
|
2487
2550
|
scanOptions,
|
|
2488
2551
|
importerPolicy: (importer) => catalogImporterPolicy(importer, registeredImporterKeys),
|
|
2489
|
-
visibility: catalogVisibility
|
|
2552
|
+
visibility: catalogVisibility,
|
|
2553
|
+
...sourceIdentityFor === void 0 ? {} : { sourceIdentityFor }
|
|
2490
2554
|
};
|
|
2491
2555
|
return buildCatalogProjection(roots, options);
|
|
2492
2556
|
}
|
|
@@ -2615,7 +2679,38 @@ function importFailureCode(error) {
|
|
|
2615
2679
|
return "source-package-conversion-failed";
|
|
2616
2680
|
}
|
|
2617
2681
|
}
|
|
2682
|
+
var IMPORT_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
2683
|
+
"importer-not-registered",
|
|
2684
|
+
"source-read-failed",
|
|
2685
|
+
"import-produced-no-assets",
|
|
2686
|
+
"guid-mismatch",
|
|
2687
|
+
"mesh-material-slot-topology-change",
|
|
2688
|
+
"import-internal-error",
|
|
2689
|
+
"source-validation-failed",
|
|
2690
|
+
"unknown-source-key",
|
|
2691
|
+
"duplicate-source-key",
|
|
2692
|
+
"invalid-source-overrides",
|
|
2693
|
+
"invalid-source-override-payload"
|
|
2694
|
+
]);
|
|
2695
|
+
function findNormalizableCause(error, seen = /* @__PURE__ */ new Set()) {
|
|
2696
|
+
if (error === null || typeof error !== "object" || seen.has(error)) return void 0;
|
|
2697
|
+
seen.add(error);
|
|
2698
|
+
if (isSourcePackageError(error) || isScriptablePackFailure(error) || isImportError(error)) {
|
|
2699
|
+
return error;
|
|
2700
|
+
}
|
|
2701
|
+
const cause = error.cause;
|
|
2702
|
+
return cause === void 0 ? void 0 : findNormalizableCause(cause, seen);
|
|
2703
|
+
}
|
|
2704
|
+
function containsSourcePackageError(error, seen = /* @__PURE__ */ new Set()) {
|
|
2705
|
+
if (error === null || typeof error !== "object" || seen.has(error)) return false;
|
|
2706
|
+
seen.add(error);
|
|
2707
|
+
if (isSourcePackageError(error) || isImportError(error)) return true;
|
|
2708
|
+
const cause = error.cause;
|
|
2709
|
+
return cause !== void 0 && containsSourcePackageError(cause, seen);
|
|
2710
|
+
}
|
|
2618
2711
|
function normalizeSourcePackageError(error, context) {
|
|
2712
|
+
const cause = findNormalizableCause(error);
|
|
2713
|
+
if (cause !== void 0 && cause !== error) return normalizeSourcePackageError(cause, context);
|
|
2619
2714
|
if (isSourcePackageError(error)) return error;
|
|
2620
2715
|
if (isScriptablePackFailure(error)) {
|
|
2621
2716
|
return sourcePackageError("source-package-conversion-failed", context, {
|
|
@@ -2644,7 +2739,7 @@ function contextErrorStage(error) {
|
|
|
2644
2739
|
return error instanceof SyntaxError ? "source-package-meta-invalid" : "source-package-conversion-failed";
|
|
2645
2740
|
}
|
|
2646
2741
|
function isImportError(error) {
|
|
2647
|
-
return error !== null && typeof error === "object" && "code" in error && "expected" in error && "hint" in error && "detail" in error;
|
|
2742
|
+
return error !== null && typeof error === "object" && "code" in error && typeof error.code === "string" && IMPORT_ERROR_CODES.has(error.code) && "expected" in error && "hint" in error && "detail" in error;
|
|
2648
2743
|
}
|
|
2649
2744
|
function isScriptablePackFailure(error) {
|
|
2650
2745
|
return error !== null && typeof error === "object" && "code" in error && typeof error.code === "string" && error.code.startsWith("pack-source-") && "expected" in error && typeof error.expected === "string" && "hint" in error && typeof error.hint === "string" && "detail" in error;
|
|
@@ -2659,7 +2754,7 @@ async function inspectAfterSupersededCommit(candidate) {
|
|
|
2659
2754
|
if (head.state === "current" && head.currentKey === candidate.lease.desiredKey) return head;
|
|
2660
2755
|
const deadline = Date.now() + PUBLICATION_SETTLE_TIMEOUT_MS;
|
|
2661
2756
|
while (Date.now() < deadline && head.activeLease !== void 0 && head.activeLease.attempt !== candidate.lease.attempt && head.activeLease.desiredKey === candidate.lease.desiredKey) {
|
|
2662
|
-
await new Promise((
|
|
2757
|
+
await new Promise((resolve4) => setTimeout(resolve4, PUBLICATION_SETTLE_POLL_MS));
|
|
2663
2758
|
head = await inspectHead(candidate.root, candidate.lease.guid, candidate.lease.desiredKey);
|
|
2664
2759
|
if (head.state === "current" && head.currentKey === candidate.lease.desiredKey) return head;
|
|
2665
2760
|
}
|
|
@@ -2844,6 +2939,6 @@ async function restoreImportPublication(candidate) {
|
|
|
2844
2939
|
await candidate.ddc.session.restoreEntry(candidate.ddc);
|
|
2845
2940
|
}
|
|
2846
2941
|
|
|
2847
|
-
export { AssetOutputProducerRegistry, DEFAULT_CATALOG_IMPORTER_KEYS, ImporterRegistry, SHADER_RESERVED_IMPORTER_KEY, buildCatalogResult, buildScriptablePack, canonicalScriptableSourcePath, catalogImporterPolicy, commitImportPublication, createImportProduct, createSceneAssetOutputProducer, createScriptablePackStagedAssetSnapshotSource, createStandardAssetOutputProducerRegistry, declaredPackExternalOutputs, discardImportPublication, finalizeImportProducts, finalizeSourcePackage, materialAssetOutputProducer, materializePreparedScriptablePack, meshAssetOutputProducer, normaliseForPack, normalizeSourcePackageError, packMeshBinV4, parseProducerReadiness, prepareAuthoredPackTransport, produceBuildAssets, produceScriptablePackProducts, produceScriptableSourcePackage, produceSourcePackage, projectImportProductForBuild, projectScriptablePackPublication, publishImportPublication, readCookedAuthoredPack, restoreImportPublication, runImport, scriptablePackInputs, sourcePackageAssetsByGuid, sourcePackageError, stageImportPublication };
|
|
2942
|
+
export { AssetOutputProducerRegistry, DEFAULT_CATALOG_IMPORTER_KEYS, ImporterRegistry, SHADER_RESERVED_IMPORTER_KEY, buildCatalogResult, buildScriptablePack, canonicalScriptableSourcePath, catalogImporterPolicy, commitImportPublication, containsSourcePackageError, createImportProduct, createSceneAssetOutputProducer, createScriptablePackStagedAssetSnapshotSource, createStandardAssetOutputProducerRegistry, declaredPackExternalOutputs, discardImportPublication, finalizeImportProducts, finalizeSourcePackage, materialAssetOutputProducer, materializePreparedScriptablePack, meshAssetOutputProducer, normaliseForPack, normalizeSourcePackageError, packMeshBinV4, parseProducerReadiness, prepareAuthoredPackTransport, produceBuildAssets, produceScriptablePackProducts, produceScriptableSourcePackage, produceSourcePackage, projectImportProductForBuild, projectScriptablePackPublication, publishImportPublication, readCookedAuthoredPack, restoreImportPublication, runImport, scriptablePackInputs, sourceDeclarationForCatalogPath, sourcePackageAssetsByGuid, sourcePackageError, stageImportPublication, textureAssetOutputProducer };
|
|
2848
2943
|
//# sourceMappingURL=index.mjs.map
|
|
2849
2944
|
//# sourceMappingURL=index.mjs.map
|