@forgeax/engine-import 0.1.4 → 0.1.6
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-host.unit.test.d.ts +2 -0
- package/dist/__tests__/scriptable-pack-host.unit.test.d.ts.map +1 -0
- package/dist/build-production.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +158 -93
- package/dist/index.mjs.map +1 -1
- package/dist/scriptable-pack-host.d.ts +10 -2
- package/dist/scriptable-pack-host.d.ts.map +1 -1
- package/package.json +7 -7
- package/src/__tests__/scriptable-pack-host.unit.test.ts +86 -0
- package/src/build-production.ts +6 -0
- package/src/index.ts +1 -0
- package/src/scriptable-pack-host.ts +85 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-production.d.ts","sourceRoot":"","sources":["../src/build-production.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,kBAAkB,
|
|
1
|
+
{"version":3,"file":"build-production.d.ts","sourceRoot":"","sources":["../src/build-production.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,kBAAkB,EAMxB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AACvE,OAAO,KAAK,EACV,wBAAwB,EAExB,cAAc,EACd,gBAAgB,EAChB,mBAAmB,EACpB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAgB/D,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAA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GAAG,YAAY,CAAC,CAAC;IAC9E,QAAQ,CAAC,IAAI,EAAE,mBAAmB,CAAC;IACnC,QAAQ,CAAC,IAAI,EAAE,CAAC,OAAO,EAAE,sBAAsB,KAAK,KAAK,CAAC;CAC3D;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClD,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC;IACtD,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;IACpC,QAAQ,CAAC,WAAW,EAAE,wBAAwB,CAAC;CAChD;AAuYD,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,sBAAsB,GAC9B,OAAO,CAAC,cAAc,EAAE,CAAC,CAqB3B"}
|
package/dist/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export { ImporterRegistry } from './importer-registry.js';
|
|
|
9
9
|
export { type MeshBinEncodeError, packMeshBinV4, } from './mesh-bin.js';
|
|
10
10
|
export { projectImportProductForBuild } from './pack-projection.js';
|
|
11
11
|
export { type AssetOutputInput, type AssetOutputPayload, type AssetOutputProducer, AssetOutputProducerRegistry, type AssetOutputProduct, type BuildScriptablePackOptions, buildScriptablePack, type ScriptablePackAssetSnapshot, type ScriptablePackAssetSnapshotSource, type ScriptablePackBuildBridgeResult, type ScriptablePackBuildProduct, type ScriptablePackDomainError, type ScriptablePackExternalEvidence, type ScriptablePackExternalUsage, type ScriptablePackSourceClosureEntry, type ScriptablePackStagedOutput, } from './scriptable-pack.js';
|
|
12
|
-
export { type AuthoredPackTransport, type CookedAuthoredPack, canonicalScriptableSourcePath, declaredPackExternalOutputs, materializePreparedScriptablePack, type PreparedScriptablePack, prepareAuthoredPackTransport, produceScriptablePackProducts, projectScriptablePackPublication, readCookedAuthoredPack, type ScriptablePackInput, type ScriptablePackPublicationFacts, type ScriptablePackTransportPaths, type ScriptablePackTransportPolicy, type ScriptablePackTransportSink, scriptablePackInputs, } from './scriptable-pack-host.js';
|
|
12
|
+
export { type AuthoredPackTransport, type CookedAuthoredPack, canonicalScriptableSourcePath, declaredPackExternalOutputs, materializePreparedScriptablePack, type PreparedScriptablePack, prepareAuthoredPackTransport, produceScriptablePackProducts, projectScriptablePackPublication, readCookedAuthoredPack, type ScriptablePackExternalImportOptions, type ScriptablePackInput, type ScriptablePackPublicationFacts, type ScriptablePackTransportPaths, type ScriptablePackTransportPolicy, type ScriptablePackTransportSink, scriptablePackInputs, } from './scriptable-pack-host.js';
|
|
13
13
|
export { createSceneAssetOutputProducer, createStandardAssetOutputProducerRegistry, materialAssetOutputProducer, meshAssetOutputProducer, } from './scriptable-pack-output-producers.js';
|
|
14
14
|
export { createScriptablePackStagedAssetSnapshotSource, type ScriptablePackSnapshotError, type ScriptablePackStagedOwner, type ScriptablePackStagedSnapshotOptions, } from './scriptable-pack-staged-snapshot.js';
|
|
15
15
|
export { produceScriptableSourcePackage, type ScriptableSourcePackageProduct, type ScriptableSourcePackageResult, } from './scriptable-source-package.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAgBA,YAAY,EACV,aAAa,EACb,cAAc,EACd,KAAK,EACL,cAAc,EACd,aAAa,EACb,SAAS,EACT,aAAa,EACb,SAAS,EACT,mBAAmB,EACnB,mBAAmB,EACnB,YAAY,EACZ,UAAU,EACV,aAAa,EACb,SAAS,EACT,YAAY,EACZ,YAAY,EACZ,UAAU,GACX,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,KAAK,WAAW,EAChB,kBAAkB,EAClB,KAAK,aAAa,EAClB,WAAW,EACX,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,QAAQ,EACb,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,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,sBAAsB,EACtB,oBAAoB,EACpB,KAAK,0BAA0B,EAC/B,KAAK,yBAAyB,EAC9B,KAAK,0BAA0B,EAC/B,KAAK,2BAA2B,EAChC,KAAK,oBAAoB,EACzB,yBAAyB,GAC1B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,2BAA2B,EAC3B,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,EAC3B,KAAK,yBAAyB,EAC9B,KAAK,wBAAwB,EAC7B,KAAK,uBAAuB,EAC5B,kBAAkB,GACnB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,uBAAuB,EACvB,wBAAwB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,wBAAwB,EACxB,wBAAwB,EACxB,KAAK,uBAAuB,EAC5B,KAAK,6BAA6B,EAClC,sBAAsB,GACvB,MAAM,iCAAiC,CAAC"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ok, validateSourceOverrideMap, ImportError, IMPORT_ERROR_HINTS, canonicalizeSourceOverrides, err, AssetError, MATERIAL_TEXTURE_SLOTS } from '@forgeax/engine-types';
|
|
2
2
|
export { IMPORT_ERROR_HINTS, ImportError } from '@forgeax/engine-types';
|
|
3
3
|
import { resolve, dirname } from 'path';
|
|
4
|
-
import { upgradeLegacyAuthoredPack, finalizePackageTransportSource, projectCookedPackageEntry, buildCatalogProjection, createRuntimePackPublication, metaPathForGuid } from '@forgeax/engine-pack/build';
|
|
4
|
+
import { upgradeLegacyAuthoredPack, loadAssetConfig, resolveAssetSource, finalizePackageTransportSource, 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';
|
|
@@ -1642,6 +1642,96 @@ async function produceScriptableSourcePackage(options) {
|
|
|
1642
1642
|
externalEvidence: built.value.externalEvidence
|
|
1643
1643
|
});
|
|
1644
1644
|
}
|
|
1645
|
+
function parseProducerReadiness(value) {
|
|
1646
|
+
if (value === void 0 || value === "before-consume" || value === "on-demand") {
|
|
1647
|
+
return { ok: true, value: value ?? "before-consume" };
|
|
1648
|
+
}
|
|
1649
|
+
return {
|
|
1650
|
+
ok: false,
|
|
1651
|
+
error: {
|
|
1652
|
+
code: "producer-readiness-invalid",
|
|
1653
|
+
expected: "'before-consume' or 'on-demand'",
|
|
1654
|
+
hint: "set producerReadiness to before-consume or on-demand",
|
|
1655
|
+
detail: { value }
|
|
1656
|
+
}
|
|
1657
|
+
};
|
|
1658
|
+
}
|
|
1659
|
+
function finalizeSourcePackage(product, finalizer, artifactUrl) {
|
|
1660
|
+
if (finalizer === void 0) return ok(product);
|
|
1661
|
+
const result = finalizer(product, { artifactUrl });
|
|
1662
|
+
if (!result.ok) return err(result.error);
|
|
1663
|
+
return ok({
|
|
1664
|
+
...product,
|
|
1665
|
+
assets: product.assets.map(
|
|
1666
|
+
(asset, index) => index === 0 ? { ...asset, payload: result.value.asset } : asset
|
|
1667
|
+
)
|
|
1668
|
+
});
|
|
1669
|
+
}
|
|
1670
|
+
function closureError(declaredGuids, producedGuids) {
|
|
1671
|
+
const declared = new Set(declaredGuids.map((guid) => guid.toLowerCase()));
|
|
1672
|
+
const produced = new Set(producedGuids.map((guid) => guid.toLowerCase()));
|
|
1673
|
+
const counts = /* @__PURE__ */ new Map();
|
|
1674
|
+
for (const guid of producedGuids) {
|
|
1675
|
+
const key = guid.toLowerCase();
|
|
1676
|
+
counts.set(key, (counts.get(key) ?? 0) + 1);
|
|
1677
|
+
}
|
|
1678
|
+
const duplicateGuids = [...counts.entries()].filter(([, count]) => count > 1).map(([guid]) => guid);
|
|
1679
|
+
return {
|
|
1680
|
+
code: "source-package-guid-closure-mismatch",
|
|
1681
|
+
expected: "the importer to return exactly one asset for every declared Meta GUID",
|
|
1682
|
+
hint: "repair the Meta declaration or importer output, then rebuild the whole source package",
|
|
1683
|
+
detail: {
|
|
1684
|
+
stage: "closure",
|
|
1685
|
+
declaredGuids,
|
|
1686
|
+
producedGuids,
|
|
1687
|
+
missingGuids: declaredGuids.filter((guid) => !produced.has(guid.toLowerCase())),
|
|
1688
|
+
unexpectedGuids: producedGuids.filter((guid) => !declared.has(guid.toLowerCase())),
|
|
1689
|
+
duplicateGuids
|
|
1690
|
+
}
|
|
1691
|
+
};
|
|
1692
|
+
}
|
|
1693
|
+
function producedGuidsFromImportFailure(declaredGuids, detail) {
|
|
1694
|
+
if ("missingGuids" in detail) {
|
|
1695
|
+
return declaredGuids.filter((guid) => !detail.missingGuids.includes(guid));
|
|
1696
|
+
}
|
|
1697
|
+
if ("unexpectedGuids" in detail) return [...declaredGuids, ...detail.unexpectedGuids];
|
|
1698
|
+
return [];
|
|
1699
|
+
}
|
|
1700
|
+
async function produceSourcePackage(input) {
|
|
1701
|
+
const declaredGuids = input.meta.subAssets.map((asset) => asset.guid);
|
|
1702
|
+
const result = await runImport(input.meta, input.registry, input.fs);
|
|
1703
|
+
if (!result.ok) {
|
|
1704
|
+
const producedGuids2 = producedGuidsFromImportFailure(declaredGuids, result.error.detail);
|
|
1705
|
+
return {
|
|
1706
|
+
ok: false,
|
|
1707
|
+
error: closureError(declaredGuids, producedGuids2)
|
|
1708
|
+
};
|
|
1709
|
+
}
|
|
1710
|
+
if ("skipped" in result.value) {
|
|
1711
|
+
return { ok: false, error: closureError(declaredGuids, []) };
|
|
1712
|
+
}
|
|
1713
|
+
const producedGuids = result.value.product.assets.map((asset) => asset.guid);
|
|
1714
|
+
const declaredSet = new Set(declaredGuids.map((guid) => guid.toLowerCase()));
|
|
1715
|
+
const producedSet = new Set(producedGuids.map((guid) => guid.toLowerCase()));
|
|
1716
|
+
const hasDuplicate = new Set(producedGuids.map((guid) => guid.toLowerCase())).size !== producedGuids.length;
|
|
1717
|
+
const complete = !hasDuplicate && declaredGuids.length === producedGuids.length && declaredGuids.every((guid) => producedSet.has(guid.toLowerCase())) && producedGuids.every((guid) => declaredSet.has(guid.toLowerCase()));
|
|
1718
|
+
if (!complete) return { ok: false, error: closureError(declaredGuids, producedGuids) };
|
|
1719
|
+
const product = result.value.product;
|
|
1720
|
+
const anchorGuid = [...declaredGuids].sort((left, right) => left.localeCompare(right))[0];
|
|
1721
|
+
if (anchorGuid === void 0)
|
|
1722
|
+
return { ok: false, error: closureError(declaredGuids, producedGuids) };
|
|
1723
|
+
return {
|
|
1724
|
+
ok: true,
|
|
1725
|
+
value: {
|
|
1726
|
+
anchorGuid,
|
|
1727
|
+
declaredGuids,
|
|
1728
|
+
product
|
|
1729
|
+
}
|
|
1730
|
+
};
|
|
1731
|
+
}
|
|
1732
|
+
function sourcePackageAssetsByGuid(source) {
|
|
1733
|
+
return new Map(source.product.assets.map((asset) => [asset.guid.toLowerCase(), asset]));
|
|
1734
|
+
}
|
|
1645
1735
|
|
|
1646
1736
|
// src/scriptable-pack-host.ts
|
|
1647
1737
|
function canonicalScriptableSourcePath(sourcePath) {
|
|
@@ -1747,11 +1837,71 @@ async function readCookedAuthoredPack(authoredPack, cookers = [], sourcePath) {
|
|
|
1747
1837
|
refsByGuid
|
|
1748
1838
|
} : void 0;
|
|
1749
1839
|
}
|
|
1750
|
-
async function declaredPackExternalOutputs(declarations, cookers = [], requiredGuids = []) {
|
|
1840
|
+
async function declaredPackExternalOutputs(declarations, cookers = [], requiredGuids = [], externalImport) {
|
|
1751
1841
|
if (requiredGuids.length === 0) return [];
|
|
1752
1842
|
const required = new Set(requiredGuids.map((guid) => AssetGuid.format(guid).toLowerCase()));
|
|
1753
1843
|
const outputs = [];
|
|
1754
1844
|
for (const declaration of declarations.values()) {
|
|
1845
|
+
if (declaration.format === "meta.json") {
|
|
1846
|
+
if (externalImport === void 0) continue;
|
|
1847
|
+
if (!declaration.value.subAssets.some((asset) => required.has(asset.guid.toLowerCase()))) {
|
|
1848
|
+
continue;
|
|
1849
|
+
}
|
|
1850
|
+
const assetPaths = externalImport.assetPaths ?? loadAssetConfig(process.cwd()).paths;
|
|
1851
|
+
const resolved = resolveAssetSource(
|
|
1852
|
+
declaration.sourcePath,
|
|
1853
|
+
declaration.value.source,
|
|
1854
|
+
assetPaths
|
|
1855
|
+
);
|
|
1856
|
+
if (!resolved.ok) {
|
|
1857
|
+
throw new AssetError({
|
|
1858
|
+
code: "asset-not-imported",
|
|
1859
|
+
expected: `a resolvable source for Meta dependency ${declaration.sourcePath}`,
|
|
1860
|
+
hint: "repair the Meta source path before rebuilding the ScriptablePack"
|
|
1861
|
+
});
|
|
1862
|
+
}
|
|
1863
|
+
const meta = {
|
|
1864
|
+
importer: declaration.value.importer,
|
|
1865
|
+
source: resolved.value,
|
|
1866
|
+
sourceRevision: declaration.sourceRevision,
|
|
1867
|
+
...declaration.value.packageId === void 0 ? {} : { packageId: declaration.value.packageId },
|
|
1868
|
+
...declaration.value.provenance === void 0 ? {} : { provenance: declaration.value.provenance },
|
|
1869
|
+
...declaration.value.revision === void 0 ? {} : { revision: declaration.value.revision },
|
|
1870
|
+
...declaration.value.diagnostics === void 0 ? {} : { diagnostics: declaration.value.diagnostics },
|
|
1871
|
+
importSettings: declaration.value.importSettings,
|
|
1872
|
+
...declaration.value.sourceOverrides === void 0 ? {} : { sourceOverrides: declaration.value.sourceOverrides },
|
|
1873
|
+
subAssets: declaration.value.subAssets.map(({ guid, sourceIndex, sourceKey, kind }) => ({
|
|
1874
|
+
guid,
|
|
1875
|
+
sourceIndex,
|
|
1876
|
+
...sourceKey === void 0 ? {} : { sourceKey },
|
|
1877
|
+
kind
|
|
1878
|
+
})),
|
|
1879
|
+
buildPack: false
|
|
1880
|
+
};
|
|
1881
|
+
const sourcePackage = await produceSourcePackage({
|
|
1882
|
+
meta,
|
|
1883
|
+
registry: externalImport.importerRegistry,
|
|
1884
|
+
fs: externalImport.fsForImport
|
|
1885
|
+
});
|
|
1886
|
+
if (!sourcePackage.ok) {
|
|
1887
|
+
throw new AssetError({
|
|
1888
|
+
code: "asset-not-imported",
|
|
1889
|
+
expected: `the ${declaration.value.importer} importer to produce Meta dependency outputs`,
|
|
1890
|
+
hint: `repair ${declaration.sourcePath} before rebuilding the ScriptablePack`
|
|
1891
|
+
});
|
|
1892
|
+
}
|
|
1893
|
+
for (const asset of sourcePackage.value.product.assets) {
|
|
1894
|
+
const key = asset.guid.toLowerCase();
|
|
1895
|
+
if (!required.has(key)) continue;
|
|
1896
|
+
const parsed = AssetGuid.parse(asset.guid);
|
|
1897
|
+
if (!parsed.ok) throw parsed.error;
|
|
1898
|
+
outputs.push({
|
|
1899
|
+
guid: parsed.value,
|
|
1900
|
+
asset: { kind: asset.kind, ...asset.payload }
|
|
1901
|
+
});
|
|
1902
|
+
}
|
|
1903
|
+
continue;
|
|
1904
|
+
}
|
|
1755
1905
|
if (declaration.format !== "pack.json") continue;
|
|
1756
1906
|
const declaredAssets = declaration.value.assets.filter(
|
|
1757
1907
|
(asset) => required.has(asset.guid.toLowerCase())
|
|
@@ -1947,96 +2097,6 @@ async function produceScriptablePackProducts(sources, declaredExternalOutputs =
|
|
|
1947
2097
|
}
|
|
1948
2098
|
return ok(prepared);
|
|
1949
2099
|
}
|
|
1950
|
-
function parseProducerReadiness(value) {
|
|
1951
|
-
if (value === void 0 || value === "before-consume" || value === "on-demand") {
|
|
1952
|
-
return { ok: true, value: value ?? "before-consume" };
|
|
1953
|
-
}
|
|
1954
|
-
return {
|
|
1955
|
-
ok: false,
|
|
1956
|
-
error: {
|
|
1957
|
-
code: "producer-readiness-invalid",
|
|
1958
|
-
expected: "'before-consume' or 'on-demand'",
|
|
1959
|
-
hint: "set producerReadiness to before-consume or on-demand",
|
|
1960
|
-
detail: { value }
|
|
1961
|
-
}
|
|
1962
|
-
};
|
|
1963
|
-
}
|
|
1964
|
-
function finalizeSourcePackage(product, finalizer, artifactUrl) {
|
|
1965
|
-
if (finalizer === void 0) return ok(product);
|
|
1966
|
-
const result = finalizer(product, { artifactUrl });
|
|
1967
|
-
if (!result.ok) return err(result.error);
|
|
1968
|
-
return ok({
|
|
1969
|
-
...product,
|
|
1970
|
-
assets: product.assets.map(
|
|
1971
|
-
(asset, index) => index === 0 ? { ...asset, payload: result.value.asset } : asset
|
|
1972
|
-
)
|
|
1973
|
-
});
|
|
1974
|
-
}
|
|
1975
|
-
function closureError(declaredGuids, producedGuids) {
|
|
1976
|
-
const declared = new Set(declaredGuids.map((guid) => guid.toLowerCase()));
|
|
1977
|
-
const produced = new Set(producedGuids.map((guid) => guid.toLowerCase()));
|
|
1978
|
-
const counts = /* @__PURE__ */ new Map();
|
|
1979
|
-
for (const guid of producedGuids) {
|
|
1980
|
-
const key = guid.toLowerCase();
|
|
1981
|
-
counts.set(key, (counts.get(key) ?? 0) + 1);
|
|
1982
|
-
}
|
|
1983
|
-
const duplicateGuids = [...counts.entries()].filter(([, count]) => count > 1).map(([guid]) => guid);
|
|
1984
|
-
return {
|
|
1985
|
-
code: "source-package-guid-closure-mismatch",
|
|
1986
|
-
expected: "the importer to return exactly one asset for every declared Meta GUID",
|
|
1987
|
-
hint: "repair the Meta declaration or importer output, then rebuild the whole source package",
|
|
1988
|
-
detail: {
|
|
1989
|
-
stage: "closure",
|
|
1990
|
-
declaredGuids,
|
|
1991
|
-
producedGuids,
|
|
1992
|
-
missingGuids: declaredGuids.filter((guid) => !produced.has(guid.toLowerCase())),
|
|
1993
|
-
unexpectedGuids: producedGuids.filter((guid) => !declared.has(guid.toLowerCase())),
|
|
1994
|
-
duplicateGuids
|
|
1995
|
-
}
|
|
1996
|
-
};
|
|
1997
|
-
}
|
|
1998
|
-
function producedGuidsFromImportFailure(declaredGuids, detail) {
|
|
1999
|
-
if ("missingGuids" in detail) {
|
|
2000
|
-
return declaredGuids.filter((guid) => !detail.missingGuids.includes(guid));
|
|
2001
|
-
}
|
|
2002
|
-
if ("unexpectedGuids" in detail) return [...declaredGuids, ...detail.unexpectedGuids];
|
|
2003
|
-
return [];
|
|
2004
|
-
}
|
|
2005
|
-
async function produceSourcePackage(input) {
|
|
2006
|
-
const declaredGuids = input.meta.subAssets.map((asset) => asset.guid);
|
|
2007
|
-
const result = await runImport(input.meta, input.registry, input.fs);
|
|
2008
|
-
if (!result.ok) {
|
|
2009
|
-
const producedGuids2 = producedGuidsFromImportFailure(declaredGuids, result.error.detail);
|
|
2010
|
-
return {
|
|
2011
|
-
ok: false,
|
|
2012
|
-
error: closureError(declaredGuids, producedGuids2)
|
|
2013
|
-
};
|
|
2014
|
-
}
|
|
2015
|
-
if ("skipped" in result.value) {
|
|
2016
|
-
return { ok: false, error: closureError(declaredGuids, []) };
|
|
2017
|
-
}
|
|
2018
|
-
const producedGuids = result.value.product.assets.map((asset) => asset.guid);
|
|
2019
|
-
const declaredSet = new Set(declaredGuids.map((guid) => guid.toLowerCase()));
|
|
2020
|
-
const producedSet = new Set(producedGuids.map((guid) => guid.toLowerCase()));
|
|
2021
|
-
const hasDuplicate = new Set(producedGuids.map((guid) => guid.toLowerCase())).size !== producedGuids.length;
|
|
2022
|
-
const complete = !hasDuplicate && declaredGuids.length === producedGuids.length && declaredGuids.every((guid) => producedSet.has(guid.toLowerCase())) && producedGuids.every((guid) => declaredSet.has(guid.toLowerCase()));
|
|
2023
|
-
if (!complete) return { ok: false, error: closureError(declaredGuids, producedGuids) };
|
|
2024
|
-
const product = result.value.product;
|
|
2025
|
-
const anchorGuid = [...declaredGuids].sort((left, right) => left.localeCompare(right))[0];
|
|
2026
|
-
if (anchorGuid === void 0)
|
|
2027
|
-
return { ok: false, error: closureError(declaredGuids, producedGuids) };
|
|
2028
|
-
return {
|
|
2029
|
-
ok: true,
|
|
2030
|
-
value: {
|
|
2031
|
-
anchorGuid,
|
|
2032
|
-
declaredGuids,
|
|
2033
|
-
product
|
|
2034
|
-
}
|
|
2035
|
-
};
|
|
2036
|
-
}
|
|
2037
|
-
function sourcePackageAssetsByGuid(source) {
|
|
2038
|
-
return new Map(source.product.assets.map((asset) => [asset.guid.toLowerCase(), asset]));
|
|
2039
|
-
}
|
|
2040
2100
|
|
|
2041
2101
|
// src/build-production.ts
|
|
2042
2102
|
function scriptableArtifactPath(guid, key) {
|
|
@@ -2076,7 +2136,12 @@ async function buildAuthoredPackages(context) {
|
|
|
2076
2136
|
await declaredPackExternalOutputs(
|
|
2077
2137
|
context.inventory.sourceDeclarations,
|
|
2078
2138
|
context.cookers,
|
|
2079
|
-
inputs.flatMap((input) => Object.values(input.definition.externalAssets))
|
|
2139
|
+
inputs.flatMap((input) => Object.values(input.definition.externalAssets)),
|
|
2140
|
+
{
|
|
2141
|
+
importerRegistry: context.importerRegistry,
|
|
2142
|
+
fsForImport: context.fsForImport,
|
|
2143
|
+
assetPaths: loadAssetConfig(context.cwd).paths
|
|
2144
|
+
}
|
|
2080
2145
|
)
|
|
2081
2146
|
);
|
|
2082
2147
|
if (!preparedResult.ok) throw context.fail(preparedResult.error);
|