@forgeax/engine-import 0.1.24 → 0.1.26
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 +4 -1
- package/dist/build-production.d.ts.map +1 -1
- package/dist/index.mjs +52 -5
- package/dist/index.mjs.map +1 -1
- package/dist/scriptable-pack-build.d.ts +5 -0
- package/dist/scriptable-pack-build.d.ts.map +1 -1
- package/dist/scriptable-pack-host.d.ts +2 -0
- package/dist/scriptable-pack-host.d.ts.map +1 -1
- package/dist/scriptable-pack-output-producers.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/__tests__/scriptable-pack-host.unit.test.ts +48 -0
- package/src/__tests__/scriptable-pack-output-producers.unit.test.ts +6 -7
- package/src/__tests__/scriptable-pack-production-producers.unit.test.ts +1 -1
- package/src/build-production.ts +1 -0
- package/src/scriptable-pack-build.ts +54 -3
- package/src/scriptable-pack-host.ts +10 -0
- package/src/scriptable-pack-output-producers.ts +4 -2
package/README.md
CHANGED
|
@@ -145,7 +145,10 @@ Domain producers return structured `ImportError`; the generic bridge contains no
|
|
|
145
145
|
|
|
146
146
|
`createStandardAssetOutputProducerRegistry(sceneComponents)` registers the production
|
|
147
147
|
Material, Mesh, and Scene producers. Material output derives
|
|
148
|
-
parent/texture/sampler refs
|
|
148
|
+
parent/texture/sampler refs. Material texture references serialize as
|
|
149
|
+
`{ texture: refsIndex, sampler?: refsIndex }`, including GUID string shorthand;
|
|
150
|
+
bare numeric values remain scalars in children without a local parameter schema.
|
|
151
|
+
Mesh output derives default-material refs and emits
|
|
149
152
|
the `mesh-binary/4` body; Scene output uses the definition-bound neutral schema
|
|
150
153
|
through the shared ECS externalization contract. A specialized host may instead
|
|
151
154
|
register only the admitted kinds:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-production.d.ts","sourceRoot":"","sources":["../src/build-production.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,kBAAkB,EAKxB,MAAM,4BAA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CAAC,OAAO,EAAE,sBAAsB,KAAK,KAAK,CAAC;CAC3D;AA+vBD,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,sBAAsB,GAC9B,OAAO,CAAC,cAAc,EAAE,CAAC,CAkB3B"}
|
package/dist/index.mjs
CHANGED
|
@@ -785,6 +785,9 @@ function record(value) {
|
|
|
785
785
|
function isAsset(value) {
|
|
786
786
|
return record(value) && typeof value.kind === "string" && isScriptablePackAssetKind(value.kind);
|
|
787
787
|
}
|
|
788
|
+
function needsMaterialCook(asset) {
|
|
789
|
+
return asset.kind === "material" && Array.isArray(asset.passes) && !isEngineMaterial(asset);
|
|
790
|
+
}
|
|
788
791
|
function clone(value) {
|
|
789
792
|
return structuredClone(value);
|
|
790
793
|
}
|
|
@@ -1009,6 +1012,9 @@ async function buildScriptablePack(options) {
|
|
|
1009
1012
|
const imported = [];
|
|
1010
1013
|
const stagedOutputs = [];
|
|
1011
1014
|
const localGuids = /* @__PURE__ */ new Set();
|
|
1015
|
+
const materialCookerRegistry = new NativeCookerRegistry();
|
|
1016
|
+
for (const cooker of options.cookers ?? []) materialCookerRegistry.register(cooker);
|
|
1017
|
+
const nativeFingerprints = /* @__PURE__ */ new Map();
|
|
1012
1018
|
for (const sourceKey of Object.keys(built.value).sort()) {
|
|
1013
1019
|
if (!isValidPackSourceKey(sourceKey))
|
|
1014
1020
|
return err(sourceKeyFailure(options.sourcePath, sourceKey));
|
|
@@ -1084,12 +1090,40 @@ async function buildScriptablePack(options) {
|
|
|
1084
1090
|
const invalidProduct2 = productError(options.sourcePath, sourceKey, producer, produced.value);
|
|
1085
1091
|
if (invalidProduct2 !== void 0) return err(invalidProduct2);
|
|
1086
1092
|
const product2 = produced.value;
|
|
1093
|
+
let payload = product2.payload;
|
|
1094
|
+
let artifacts2 = product2.artifacts;
|
|
1095
|
+
if (needsMaterialCook(asset) && materialCookerRegistry.get("material") !== void 0) {
|
|
1096
|
+
const cooked = await materialCookerRegistry.runDraft("material", {
|
|
1097
|
+
guid,
|
|
1098
|
+
source: asset,
|
|
1099
|
+
sourceKey,
|
|
1100
|
+
sourcePath: options.sourcePath,
|
|
1101
|
+
refs: product2.refs.map((reference) => reference.guid)
|
|
1102
|
+
});
|
|
1103
|
+
if (!cooked.ok) return err(cooked.error);
|
|
1104
|
+
if (cooked.value.guid.toLowerCase() !== normalizedGuid) {
|
|
1105
|
+
return err({
|
|
1106
|
+
code: "pack-source-output-invalid",
|
|
1107
|
+
expected: "the authored material cooker to preserve the derived AssetGuid",
|
|
1108
|
+
hint: "repair the native material cooker output GUID and rebuild the Pack",
|
|
1109
|
+
detail: {
|
|
1110
|
+
sourcePath: options.sourcePath,
|
|
1111
|
+
sourceKey,
|
|
1112
|
+
expectedGuid: guid,
|
|
1113
|
+
actualGuid: cooked.value.guid
|
|
1114
|
+
}
|
|
1115
|
+
});
|
|
1116
|
+
}
|
|
1117
|
+
payload = cooked.value.payload;
|
|
1118
|
+
artifacts2 = cooked.value.artifacts;
|
|
1119
|
+
nativeFingerprints.set(sourceKey, cooked.value.inputFingerprint);
|
|
1120
|
+
}
|
|
1087
1121
|
imported.push({
|
|
1088
1122
|
guid,
|
|
1089
1123
|
kind: asset.kind,
|
|
1090
|
-
payload
|
|
1124
|
+
payload,
|
|
1091
1125
|
refs: product2.refs,
|
|
1092
|
-
artifacts:
|
|
1126
|
+
artifacts: artifacts2
|
|
1093
1127
|
});
|
|
1094
1128
|
stagedOutputs.push({
|
|
1095
1129
|
guid: AssetGuid.derive(subjectPackageId, sourceKey),
|
|
@@ -1120,7 +1154,7 @@ async function buildScriptablePack(options) {
|
|
|
1120
1154
|
digest: read.digest
|
|
1121
1155
|
})
|
|
1122
1156
|
);
|
|
1123
|
-
const
|
|
1157
|
+
const authoredInputFingerprint = await digest({
|
|
1124
1158
|
packageId: PackageId.format(subjectPackageId),
|
|
1125
1159
|
sourcePath: options.sourcePath,
|
|
1126
1160
|
sourceClosure: options.sourceClosure ?? [],
|
|
@@ -1133,6 +1167,12 @@ async function buildScriptablePack(options) {
|
|
|
1133
1167
|
authoringContractVersion: options.authoringContractVersion ?? "scriptable-pack/1",
|
|
1134
1168
|
producerVersions: options.outputs.versions()
|
|
1135
1169
|
});
|
|
1170
|
+
const inputFingerprint = nativeFingerprints.size === 0 ? authoredInputFingerprint : await digest({
|
|
1171
|
+
sourceRevision: authoredInputFingerprint,
|
|
1172
|
+
nativeCookers: [...nativeFingerprints.entries()].sort(
|
|
1173
|
+
([left], [right]) => left.localeCompare(right)
|
|
1174
|
+
)
|
|
1175
|
+
});
|
|
1136
1176
|
const refs = imported.flatMap((asset) => asset.refs);
|
|
1137
1177
|
const artifacts = Object.fromEntries(
|
|
1138
1178
|
imported.flatMap(
|
|
@@ -1214,6 +1254,7 @@ async function buildScriptablePackWorklist(options) {
|
|
|
1214
1254
|
...subject.inheritedValues === void 0 ? {} : { inheritedValues: subject.inheritedValues },
|
|
1215
1255
|
...subject.sourceClosure === void 0 ? {} : { sourceClosure: subject.sourceClosure },
|
|
1216
1256
|
outputs: options.outputs,
|
|
1257
|
+
...options.cookers === void 0 ? {} : { cookers: options.cookers },
|
|
1217
1258
|
assetSource: stagedSource(staged, options.assetSource),
|
|
1218
1259
|
availableGuids: /* @__PURE__ */ new Set([...availableGuids, ...staged.keys()]),
|
|
1219
1260
|
deferReferenceValidation: true
|
|
@@ -1572,7 +1613,9 @@ function materialProduct(input) {
|
|
|
1572
1613
|
for (const fieldName of Object.keys(material.values ?? {}).sort()) {
|
|
1573
1614
|
const value = material.values?.[fieldName];
|
|
1574
1615
|
if (typeof value === "string" && textureFields.has(fieldName)) {
|
|
1575
|
-
values[fieldName] =
|
|
1616
|
+
values[fieldName] = {
|
|
1617
|
+
texture: addMaterialRef(value, { componentName: "<material>", fieldName })
|
|
1618
|
+
};
|
|
1576
1619
|
} else if (value !== null && typeof value === "object" && !Array.isArray(value) && "texture" in value) {
|
|
1577
1620
|
const texture = value;
|
|
1578
1621
|
values[fieldName] = {
|
|
@@ -1905,7 +1948,7 @@ function ordinaryPodProduct(input) {
|
|
|
1905
1948
|
}
|
|
1906
1949
|
var materialAssetOutputProducer = createSafeProducer(
|
|
1907
1950
|
"material",
|
|
1908
|
-
"material-pack/
|
|
1951
|
+
"material-pack/2",
|
|
1909
1952
|
materialProduct
|
|
1910
1953
|
);
|
|
1911
1954
|
var meshAssetOutputProducer = createSafeProducer("mesh", "mesh-binary/4", meshProduct);
|
|
@@ -2191,6 +2234,8 @@ async function readCookedAuthoredPack(authoredPack, cookers = [], sourcePath) {
|
|
|
2191
2234
|
continue;
|
|
2192
2235
|
}
|
|
2193
2236
|
if (isEngineOwnedMaterial(asset)) {
|
|
2237
|
+
hasCookedAsset = true;
|
|
2238
|
+
refsByGuid.set(asset.guid.toLowerCase(), [...asset.refs]);
|
|
2194
2239
|
assets.push({
|
|
2195
2240
|
guid: asset.guid,
|
|
2196
2241
|
kind: asset.kind,
|
|
@@ -2679,6 +2724,7 @@ async function produceScriptablePackProducts(options) {
|
|
|
2679
2724
|
(source) => projectScriptablePackSceneComponents(source.definition.sceneComponents)
|
|
2680
2725
|
)
|
|
2681
2726
|
),
|
|
2727
|
+
...options.cookers === void 0 ? {} : { cookers: options.cookers },
|
|
2682
2728
|
...assetSource === void 0 ? {} : { assetSource },
|
|
2683
2729
|
availableGuids,
|
|
2684
2730
|
...options.incomingRefs === void 0 ? {} : { incomingRefs: options.incomingRefs },
|
|
@@ -2980,6 +3026,7 @@ async function buildPackSources(context) {
|
|
|
2980
3026
|
const built = await produceScriptablePackProducts({
|
|
2981
3027
|
sources: inputs,
|
|
2982
3028
|
declaredExternalOutputs: externalOutputs,
|
|
3029
|
+
cookers: context.cookers,
|
|
2983
3030
|
availableGuids
|
|
2984
3031
|
});
|
|
2985
3032
|
if (!built.ok) dynamicFailure(context, built.error);
|