@forgeax/engine-pack 0.1.23 → 0.1.24
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 +12 -6
- package/dist/__tests__/material-cook-receipt-layer-plan.unit.test.d.ts +2 -0
- package/dist/__tests__/material-cook-receipt-layer-plan.unit.test.d.ts.map +1 -0
- package/dist/__tests__/pack-authoring-gateway.unit.test.d.ts +2 -0
- package/dist/__tests__/pack-authoring-gateway.unit.test.d.ts.map +1 -0
- package/dist/__tests__/pack-authoring.unit.test.d.ts +2 -0
- package/dist/__tests__/pack-authoring.unit.test.d.ts.map +1 -0
- package/dist/__tests__/pack-scanner.unit.test.d.ts +2 -0
- package/dist/__tests__/pack-scanner.unit.test.d.ts.map +1 -0
- package/dist/build.d.ts +3 -3
- package/dist/build.d.ts.map +1 -1
- package/dist/build.mjs +331 -290
- package/dist/build.mjs.map +1 -1
- package/dist/cli-asset.mjs +33 -35
- package/dist/cli-asset.mjs.map +1 -1
- package/dist/evidence/material-cook.d.ts +11 -0
- package/dist/evidence/material-cook.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +69 -26
- package/dist/index.mjs.map +1 -1
- package/dist/material-cook.d.ts +1 -1
- package/dist/material-cook.d.ts.map +1 -1
- package/dist/material-cook.mjs +50 -3
- package/dist/material-cook.mjs.map +1 -1
- package/dist/{parameterized-pack-node.d.ts → pack-authoring-node.d.ts} +7 -7
- package/dist/pack-authoring-node.d.ts.map +1 -0
- package/dist/{parameterized-pack-node.mjs → pack-authoring-node.mjs} +59 -63
- package/dist/pack-authoring-node.mjs.map +1 -0
- package/dist/{parameterized-pack.d.ts → pack-authoring.d.ts} +28 -31
- package/dist/pack-authoring.d.ts.map +1 -0
- package/dist/pack-authoring.mjs +1137 -0
- package/dist/pack-authoring.mjs.map +1 -0
- package/dist/runtime.mjs +1 -1
- package/dist/runtime.mjs.map +1 -1
- package/dist/scanner.d.ts +8 -8
- package/dist/scanner.d.ts.map +1 -1
- package/dist/scanner.mjs +29 -31
- package/dist/scanner.mjs.map +1 -1
- package/dist/schema.mjs +1 -1
- package/dist/schema.mjs.map +1 -1
- package/dist/scriptable-pack-node.d.ts +4 -4
- package/dist/scriptable-pack-node.d.ts.map +1 -1
- package/dist/scriptable-pack-node.mjs +18 -20
- package/dist/scriptable-pack-node.mjs.map +1 -1
- package/dist/scriptable-pack.d.ts +3 -2
- package/dist/scriptable-pack.d.ts.map +1 -1
- package/dist/scriptable-pack.mjs +19 -23
- package/dist/scriptable-pack.mjs.map +1 -1
- package/package.json +2 -7
- package/schema/pack.schema.json +1 -1
- package/src/__tests__/material-cook-receipt-layer-plan.unit.test.ts +16 -0
- package/src/__tests__/material-cook-schema.unit.test.ts +62 -0
- package/src/__tests__/{parameterized-pack-authoring-gateway.unit.test.ts → pack-authoring-gateway.unit.test.ts} +9 -9
- package/src/__tests__/{parameterized-pack.unit.test.ts → pack-authoring.unit.test.ts} +10 -10
- package/src/__tests__/{parameterized-pack-scanner.unit.test.ts → pack-scanner.unit.test.ts} +6 -6
- package/src/__tests__/scanner-inventory.contract.test.ts +2 -4
- package/src/__tests__/scanner-inventory.test.ts +7 -6
- package/src/__tests__/scriptable-pack-cli.integration.test.ts +1 -1
- package/src/build.ts +8 -8
- package/src/catalog-builder.ts +3 -3
- package/src/cli-asset.ts +5 -5
- package/src/evidence/material-cook.ts +79 -3
- package/src/evidence/source-inventory.ts +3 -3
- package/src/index.ts +4 -1
- package/src/material-cook.ts +1 -0
- package/src/{parameterized-pack-node.ts → pack-authoring-node.ts} +71 -73
- package/src/{parameterized-pack.ts → pack-authoring.ts} +59 -74
- package/src/scanner.ts +26 -28
- package/src/schema/material-cook.schema.json +4 -1
- package/src/scriptable-pack-node.ts +25 -25
- package/src/scriptable-pack.ts +3 -2
- package/dist/__tests__/parameterized-pack-authoring-gateway.unit.test.d.ts +0 -2
- package/dist/__tests__/parameterized-pack-authoring-gateway.unit.test.d.ts.map +0 -1
- package/dist/__tests__/parameterized-pack-scanner.unit.test.d.ts +0 -2
- package/dist/__tests__/parameterized-pack-scanner.unit.test.d.ts.map +0 -1
- package/dist/__tests__/parameterized-pack.unit.test.d.ts +0 -2
- package/dist/__tests__/parameterized-pack.unit.test.d.ts.map +0 -1
- package/dist/parameterized-pack-node.d.ts.map +0 -1
- package/dist/parameterized-pack-node.mjs.map +0 -1
- package/dist/parameterized-pack.d.ts.map +0 -1
package/dist/build.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ok, err, catalogOperationsFor, authoringCapabilityForAssetKind, MATERIAL_TEXTURE_SLOTS, projectCookProductEvidence, projectAssetEvidence, validateSourceOverrideMap, PACK_ERROR_HINTS, catalogEntryDigest, AssetError, ImportError } from '@forgeax/engine-types';
|
|
1
|
+
import { ok, err, catalogOperationsFor, authoringCapabilityForAssetKind, MATERIAL_TEXTURE_SLOTS, projectCookProductEvidence, projectAssetEvidence, validateSourceOverrideMap, PACK_ERROR_HINTS, catalogEntryDigest, deriveStandardLayerPlan, AssetError, ImportError } from '@forgeax/engine-types';
|
|
2
2
|
import { dirname, resolve, isAbsolute, relative, join, basename, sep, extname } from 'path';
|
|
3
3
|
import { sha1 } from '@noble/hashes/legacy.js';
|
|
4
4
|
import { uuidv7obj } from 'uuidv7';
|
|
@@ -7461,10 +7461,10 @@ function definePack(definition) {
|
|
|
7461
7461
|
validated.value
|
|
7462
7462
|
);
|
|
7463
7463
|
}
|
|
7464
|
-
function
|
|
7464
|
+
function projectScriptablePackMeta(definition, sourcePath) {
|
|
7465
7465
|
return {
|
|
7466
7466
|
schemaVersion: "2.0.0",
|
|
7467
|
-
kind: "
|
|
7467
|
+
kind: "scriptable-pack-source",
|
|
7468
7468
|
packageId: PackageId.format(definition.packageId),
|
|
7469
7469
|
source: sourcePath,
|
|
7470
7470
|
..."parameters" in definition ? {
|
|
@@ -7561,7 +7561,7 @@ function validatePackDefinition(value, sourcePath) {
|
|
|
7561
7561
|
})
|
|
7562
7562
|
);
|
|
7563
7563
|
}
|
|
7564
|
-
function
|
|
7564
|
+
function hasPackParameters(value) {
|
|
7565
7565
|
return isRecord(value) && Array.isArray(value.parameters) && value.parameters.length > 0;
|
|
7566
7566
|
}
|
|
7567
7567
|
function resolvePackParameterValues(definition, overrides = {}, inheritedValues) {
|
|
@@ -7704,7 +7704,7 @@ function parsePackJsonAsset(value, sourceKey2) {
|
|
|
7704
7704
|
};
|
|
7705
7705
|
return ok(withArtifacts);
|
|
7706
7706
|
}
|
|
7707
|
-
function
|
|
7707
|
+
function parsePackSourceJson(value) {
|
|
7708
7708
|
if (!isRecord(value))
|
|
7709
7709
|
return jsonError("$", "a v3 pack.json object", value, "document is not an object");
|
|
7710
7710
|
if (value.schemaVersion !== "3.0.0")
|
|
@@ -7783,10 +7783,8 @@ function parseParameterizedPackJson(value) {
|
|
|
7783
7783
|
values: Object.freeze({ ...value.values })
|
|
7784
7784
|
});
|
|
7785
7785
|
}
|
|
7786
|
-
var parsePackJson = parseParameterizedPackJson;
|
|
7787
|
-
var parsePackAuthoringJson = parseParameterizedPackJson;
|
|
7788
7786
|
function projectDirectPackJson(value) {
|
|
7789
|
-
const parsed = "format" in value ? ok(value) :
|
|
7787
|
+
const parsed = "format" in value ? ok(value) : parsePackSourceJson(value);
|
|
7790
7788
|
if (!parsed.ok) return parsed;
|
|
7791
7789
|
if (parsed.value.format !== "direct") {
|
|
7792
7790
|
return failure(
|
|
@@ -7832,9 +7830,9 @@ async function resolvePackParameterInheritance(subject, readParent) {
|
|
|
7832
7830
|
if (current.format === "direct") {
|
|
7833
7831
|
return failure(
|
|
7834
7832
|
authoringError(
|
|
7835
|
-
"pack-parent-
|
|
7836
|
-
"a
|
|
7837
|
-
"direct packs cannot be instance parents; point the instance at a
|
|
7833
|
+
"pack-parent-has-no-parameters",
|
|
7834
|
+
"a ScriptablePack source with parameters as the parent",
|
|
7835
|
+
"direct packs cannot be instance parents; point the instance at a ScriptablePack source with parameters",
|
|
7838
7836
|
{ packageId: currentId }
|
|
7839
7837
|
)
|
|
7840
7838
|
);
|
|
@@ -7845,7 +7843,7 @@ async function resolvePackParameterInheritance(subject, readParent) {
|
|
|
7845
7843
|
if (descriptors2.value.length === 0) {
|
|
7846
7844
|
return failure(
|
|
7847
7845
|
authoringError(
|
|
7848
|
-
"pack-parent-
|
|
7846
|
+
"pack-parent-has-no-parameters",
|
|
7849
7847
|
"the parent source to declare a non-empty parameter list",
|
|
7850
7848
|
"use clone for an independent zero-parameter Pack instead of creating an empty instance",
|
|
7851
7849
|
{ packageId: currentId }
|
|
@@ -7871,7 +7869,7 @@ async function resolvePackParameterInheritance(subject, readParent) {
|
|
|
7871
7869
|
authoringError(
|
|
7872
7870
|
"pack-parent-not-found",
|
|
7873
7871
|
"the parent packageId to resolve in the source index",
|
|
7874
|
-
"inspect the parent locator or recreate the instance from a live
|
|
7872
|
+
"inspect the parent locator or recreate the instance from a live ScriptablePack with parameters",
|
|
7875
7873
|
{ packageId: currentId, parent: PackageId.format(current.parent) }
|
|
7876
7874
|
)
|
|
7877
7875
|
);
|
|
@@ -7913,7 +7911,7 @@ async function resolvePackParameterInheritance(subject, readParent) {
|
|
|
7913
7911
|
return visit(subject, []);
|
|
7914
7912
|
}
|
|
7915
7913
|
var resolvePackInheritance = resolvePackParameterInheritance;
|
|
7916
|
-
var
|
|
7914
|
+
var PACK_AUTHORING_OPERATION_IDS = [
|
|
7917
7915
|
"asset.list",
|
|
7918
7916
|
"asset.inspect",
|
|
7919
7917
|
"asset.resolve",
|
|
@@ -7925,7 +7923,7 @@ var PARAMETERIZED_PACK_OPERATION_IDS = [
|
|
|
7925
7923
|
"asset-source.rebuild",
|
|
7926
7924
|
"asset-source.cold-cook"
|
|
7927
7925
|
];
|
|
7928
|
-
function
|
|
7926
|
+
function createPackAuthoringGateway(port) {
|
|
7929
7927
|
const requests = /* @__PURE__ */ new Map();
|
|
7930
7928
|
return {
|
|
7931
7929
|
execute(operation) {
|
|
@@ -7991,14 +7989,12 @@ function createParameterizedPackAuthoringGateway(port) {
|
|
|
7991
7989
|
}
|
|
7992
7990
|
};
|
|
7993
7991
|
}
|
|
7994
|
-
var
|
|
7995
|
-
|
|
7996
|
-
|
|
7997
|
-
|
|
7998
|
-
|
|
7999
|
-
|
|
8000
|
-
})
|
|
8001
|
-
);
|
|
7992
|
+
var PACK_AUTHORING_OPERATION_DESCRIPTORS = PACK_AUTHORING_OPERATION_IDS.map((id) => ({
|
|
7993
|
+
id,
|
|
7994
|
+
domain: id.startsWith("asset-source.") ? "session" : "asset",
|
|
7995
|
+
readOnly: id.startsWith("asset."),
|
|
7996
|
+
requiresRevision: !id.startsWith("asset.") && id !== "asset-source.create"
|
|
7997
|
+
}));
|
|
8002
7998
|
|
|
8003
7999
|
// src/scriptable-pack.ts
|
|
8004
8000
|
var SCRIPTABLE_PACK_ASSET_KINDS = [
|
|
@@ -8661,7 +8657,7 @@ var pack_schema_default = {
|
|
|
8661
8657
|
},
|
|
8662
8658
|
parent: {
|
|
8663
8659
|
$ref: "#/$defs/guid36",
|
|
8664
|
-
description: "Parent
|
|
8660
|
+
description: "Parent ScriptablePack packageId for one v3 instance; the source may declare Pack parameters."
|
|
8665
8661
|
},
|
|
8666
8662
|
values: {
|
|
8667
8663
|
type: "object",
|
|
@@ -9028,7 +9024,7 @@ function hydrateFailure(value) {
|
|
|
9028
9024
|
return value;
|
|
9029
9025
|
}
|
|
9030
9026
|
var WorkerScriptablePackExecutor = class {
|
|
9031
|
-
|
|
9027
|
+
supportsPackParameters = true;
|
|
9032
9028
|
worker;
|
|
9033
9029
|
compileRoot;
|
|
9034
9030
|
nextBuildId = 0;
|
|
@@ -9129,7 +9125,7 @@ function scriptablePackWorkerUrl() {
|
|
|
9129
9125
|
const bundledWorker = new URL("./scriptable-pack-worker.mjs", import.meta.url);
|
|
9130
9126
|
return existsSync(fileURLToPath(bundledWorker)) ? bundledWorker : new URL("../dist/scriptable-pack-worker.mjs", import.meta.url);
|
|
9131
9127
|
}
|
|
9132
|
-
function
|
|
9128
|
+
function scriptablePackLoadFailure(sourcePath, reason, phase, diagnostic, timeoutMs) {
|
|
9133
9129
|
return {
|
|
9134
9130
|
code: "pack-parameter-invalid",
|
|
9135
9131
|
expected: "a trusted Pack v2 authoring module with a valid default export",
|
|
@@ -9143,14 +9139,14 @@ function parameterizedLoadFailure(sourcePath, reason, phase, diagnostic, timeout
|
|
|
9143
9139
|
}
|
|
9144
9140
|
};
|
|
9145
9141
|
}
|
|
9146
|
-
async function
|
|
9142
|
+
async function loadScriptablePack(sourcePath, options = {}) {
|
|
9147
9143
|
const timeoutMs = options.timeoutMs ?? 15e3;
|
|
9148
9144
|
const buildTimeoutMs = options.buildTimeoutMs ?? 5e3;
|
|
9149
9145
|
const executor = options.executor ?? new WorkerScriptablePackExecutor();
|
|
9150
9146
|
let disposeReason;
|
|
9151
9147
|
let timeout;
|
|
9152
9148
|
try {
|
|
9153
|
-
const timeoutSignal = /* @__PURE__ */ Symbol("
|
|
9149
|
+
const timeoutSignal = /* @__PURE__ */ Symbol("scriptable-pack-module-timeout");
|
|
9154
9150
|
const loaded = await Promise.race([
|
|
9155
9151
|
executor.load(sourcePath),
|
|
9156
9152
|
new Promise((resolve4) => {
|
|
@@ -9160,7 +9156,7 @@ async function loadParameterizedScriptablePack(sourcePath, options = {}) {
|
|
|
9160
9156
|
if (loaded === timeoutSignal) {
|
|
9161
9157
|
disposeReason = "timeout";
|
|
9162
9158
|
return err(
|
|
9163
|
-
|
|
9159
|
+
scriptablePackLoadFailure(
|
|
9164
9160
|
sourcePath,
|
|
9165
9161
|
"timeout",
|
|
9166
9162
|
"module-load",
|
|
@@ -9187,7 +9183,7 @@ async function loadParameterizedScriptablePack(sourcePath, options = {}) {
|
|
|
9187
9183
|
let buildTimedOut = false;
|
|
9188
9184
|
let buildTimeout;
|
|
9189
9185
|
const timeoutResult = err(
|
|
9190
|
-
|
|
9186
|
+
scriptablePackLoadFailure(
|
|
9191
9187
|
sourcePath,
|
|
9192
9188
|
"timeout",
|
|
9193
9189
|
"build",
|
|
@@ -9196,7 +9192,7 @@ async function loadParameterizedScriptablePack(sourcePath, options = {}) {
|
|
|
9196
9192
|
)
|
|
9197
9193
|
);
|
|
9198
9194
|
try {
|
|
9199
|
-
const invocation = "
|
|
9195
|
+
const invocation = "supportsPackParameters" in executor && executor.supportsPackParameters === true ? build(context.readByGuid, {
|
|
9200
9196
|
packageId: [...context.packageId],
|
|
9201
9197
|
..."values" in context && context.values !== void 0 ? { values: context.values } : {}
|
|
9202
9198
|
}) : definition.build(context);
|
|
@@ -9226,7 +9222,7 @@ async function loadParameterizedScriptablePack(sourcePath, options = {}) {
|
|
|
9226
9222
|
} catch (error) {
|
|
9227
9223
|
disposeReason = "failure";
|
|
9228
9224
|
return err(
|
|
9229
|
-
|
|
9225
|
+
scriptablePackLoadFailure(
|
|
9230
9226
|
sourcePath,
|
|
9231
9227
|
"module-load",
|
|
9232
9228
|
"module-load",
|
|
@@ -9379,7 +9375,7 @@ async function scanValidated(roots, opts = {}, capture) {
|
|
|
9379
9375
|
if (!loaded.ok) return loaded;
|
|
9380
9376
|
const { raw, parsed } = loaded.value;
|
|
9381
9377
|
if (record(parsed) && parsed.schemaVersion === "3.0.0") {
|
|
9382
|
-
const authoring =
|
|
9378
|
+
const authoring = parsePackSourceJson(parsed);
|
|
9383
9379
|
if (!authoring.ok) {
|
|
9384
9380
|
return packErr(
|
|
9385
9381
|
makePackError("pack-malformed-pack", {
|
|
@@ -9623,7 +9619,7 @@ async function scanValidated(roots, opts = {}, capture) {
|
|
|
9623
9619
|
...opts.scriptablePack ?? {},
|
|
9624
9620
|
...capture === void 0 ? { metadataOnly: true } : {}
|
|
9625
9621
|
};
|
|
9626
|
-
const loaded = await
|
|
9622
|
+
const loaded = await loadScriptablePack(sourcePath, loaderOptions);
|
|
9627
9623
|
if (!loaded.ok) {
|
|
9628
9624
|
const diagnostic = loaded.error.detail.diagnostic;
|
|
9629
9625
|
return packErr(
|
|
@@ -9652,12 +9648,12 @@ async function scanValidated(roots, opts = {}, capture) {
|
|
|
9652
9648
|
const packageCollision = registerPackage(
|
|
9653
9649
|
PackageId.format(loaded.value.packageId),
|
|
9654
9650
|
sourcePath,
|
|
9655
|
-
"
|
|
9651
|
+
"scriptable"
|
|
9656
9652
|
);
|
|
9657
9653
|
if (packageCollision !== void 0) return packErr(packageCollision);
|
|
9658
|
-
const meta =
|
|
9654
|
+
const meta = projectScriptablePackMeta(loaded.value, sourcePath);
|
|
9659
9655
|
capture?.declarations.set(sourcePath, {
|
|
9660
|
-
format: "pack.ts
|
|
9656
|
+
format: "pack.ts",
|
|
9661
9657
|
sourcePath,
|
|
9662
9658
|
sourceRevision: `sha256:${createHash("sha256").update(source).digest("hex")}`,
|
|
9663
9659
|
value: meta,
|
|
@@ -9686,15 +9682,15 @@ async function scanValidated(roots, opts = {}, capture) {
|
|
|
9686
9682
|
);
|
|
9687
9683
|
}
|
|
9688
9684
|
const kind = packageKind.get(parentId);
|
|
9689
|
-
if (kind !== "
|
|
9685
|
+
if (kind !== "scriptable" && kind !== "instance") {
|
|
9690
9686
|
return packErr(
|
|
9691
9687
|
makePackError("pack-malformed-pack", {
|
|
9692
9688
|
path: instance.path,
|
|
9693
|
-
reason: "pack-parent-
|
|
9689
|
+
reason: "pack-parent-has-no-parameters",
|
|
9694
9690
|
ajvErrors: [
|
|
9695
9691
|
{
|
|
9696
9692
|
instancePath: "/parent",
|
|
9697
|
-
message: `parent ${instance.parent} is not a
|
|
9693
|
+
message: `parent ${instance.parent} is not a ScriptablePack source with parameters`
|
|
9698
9694
|
}
|
|
9699
9695
|
]
|
|
9700
9696
|
})
|
|
@@ -9764,7 +9760,7 @@ async function scanInventory(roots, opts = {}) {
|
|
|
9764
9760
|
const declaration = declarations.get(sourcePath);
|
|
9765
9761
|
if (declaration?.format !== "pack.json") continue;
|
|
9766
9762
|
if (declaration.value.schemaVersion === "3.0.0") {
|
|
9767
|
-
const parsed =
|
|
9763
|
+
const parsed = parsePackSourceJson(declaration.value);
|
|
9768
9764
|
if (!parsed.ok) {
|
|
9769
9765
|
return packErr(
|
|
9770
9766
|
makePackError("pack-malformed-pack", {
|
|
@@ -9886,7 +9882,7 @@ function projectMeta(rawPath, cwd, base, importerPolicy, sourceDeclaration, sour
|
|
|
9886
9882
|
};
|
|
9887
9883
|
}
|
|
9888
9884
|
function projectSource(path, cwd, base, importerPolicy, visibility, sourceDeclaration, declarations, sourceIdentityFor) {
|
|
9889
|
-
if (sourceDeclaration.format === "pack.ts
|
|
9885
|
+
if (sourceDeclaration.format === "pack.ts") {
|
|
9890
9886
|
return { entries: [] };
|
|
9891
9887
|
}
|
|
9892
9888
|
if (sourceDeclaration.format === "meta.json") {
|
|
@@ -9912,7 +9908,7 @@ function projectSource(path, cwd, base, importerPolicy, visibility, sourceDeclar
|
|
|
9912
9908
|
const parsed = sourceDeclaration.value;
|
|
9913
9909
|
const sourcePath = catalogSourcePathFor(cwd, path, sourceIdentityFor);
|
|
9914
9910
|
if (parsed.schemaVersion === "3.0.0") {
|
|
9915
|
-
const authoring =
|
|
9911
|
+
const authoring = parsePackSourceJson(parsed);
|
|
9916
9912
|
if (!authoring.ok) {
|
|
9917
9913
|
return {
|
|
9918
9914
|
entries: [],
|
|
@@ -10295,6 +10291,24 @@ function calculateCatalogDelta(previous, next, revision) {
|
|
|
10295
10291
|
revisions: revision
|
|
10296
10292
|
};
|
|
10297
10293
|
}
|
|
10294
|
+
var STANDARD_ROOT_MODULES = /* @__PURE__ */ new Set([
|
|
10295
|
+
"forgeax::default-standard-pbr",
|
|
10296
|
+
"forgeax::pbr-skin",
|
|
10297
|
+
"forgeax_material::standard",
|
|
10298
|
+
"forgeax_material::pbr-skin"
|
|
10299
|
+
]);
|
|
10300
|
+
function isStandardRootModule(module) {
|
|
10301
|
+
return STANDARD_ROOT_MODULES.has(module);
|
|
10302
|
+
}
|
|
10303
|
+
function isStandardMaterialRecord(record2) {
|
|
10304
|
+
return record2.resolved.passes.some((pass) => isStandardRootModule(pass.program.module));
|
|
10305
|
+
}
|
|
10306
|
+
function materialLayerPlanIdentity(record2) {
|
|
10307
|
+
if (!isStandardMaterialRecord(record2)) {
|
|
10308
|
+
return void 0;
|
|
10309
|
+
}
|
|
10310
|
+
return deriveStandardLayerPlan(record2.resolved.parameters, record2.resolved.passes).identity;
|
|
10311
|
+
}
|
|
10298
10312
|
function unique(values) {
|
|
10299
10313
|
return [...new Set(values)].sort();
|
|
10300
10314
|
}
|
|
@@ -10425,6 +10439,12 @@ function validateMaterialCookReceipt(value, expected = {}) {
|
|
|
10425
10439
|
if (derivedInterface.layoutIdentity !== identity.layoutIdentity) {
|
|
10426
10440
|
return invalid("receipt.derivedInterface.layoutIdentity", derivedInterface.layoutIdentity);
|
|
10427
10441
|
}
|
|
10442
|
+
if (derivedInterface.layerPlanIdentity !== void 0 && (typeof derivedInterface.layerPlanIdentity !== "string" || derivedInterface.layerPlanIdentity.length === 0)) {
|
|
10443
|
+
return invalid(
|
|
10444
|
+
"receipt.derivedInterface.layerPlanIdentity",
|
|
10445
|
+
derivedInterface.layerPlanIdentity
|
|
10446
|
+
);
|
|
10447
|
+
}
|
|
10428
10448
|
for (const field of ["sourceClosure", "profile", "compilerVersion"]) {
|
|
10429
10449
|
const fieldValue = candidate[field];
|
|
10430
10450
|
if (field === "sourceClosure" && !Array.isArray(fieldValue) || field !== "sourceClosure" && typeof fieldValue !== "string") {
|
|
@@ -10450,7 +10470,10 @@ function validateMaterialCookReceipt(value, expected = {}) {
|
|
|
10450
10470
|
profile: candidate.profile,
|
|
10451
10471
|
compilerVersion: candidate.compilerVersion,
|
|
10452
10472
|
identity,
|
|
10453
|
-
derivedInterface: {
|
|
10473
|
+
derivedInterface: {
|
|
10474
|
+
layoutIdentity: derivedInterface.layoutIdentity,
|
|
10475
|
+
...derivedInterface.layerPlanIdentity === void 0 ? {} : { layerPlanIdentity: derivedInterface.layerPlanIdentity }
|
|
10476
|
+
}
|
|
10454
10477
|
});
|
|
10455
10478
|
}
|
|
10456
10479
|
function validateCookedMaterialRecord(value) {
|
|
@@ -10493,6 +10516,26 @@ function validateCookedMaterialRecord(value) {
|
|
|
10493
10516
|
artifactDigest: artifact.digest
|
|
10494
10517
|
});
|
|
10495
10518
|
if (!receiptResult.ok) return receiptResult;
|
|
10519
|
+
const resolved = candidate.resolved;
|
|
10520
|
+
if (!Array.isArray(resolved.passes)) return invalid("resolved.passes", resolved.passes);
|
|
10521
|
+
if (!Array.isArray(resolved.parameters))
|
|
10522
|
+
return invalid("resolved.parameters", resolved.parameters);
|
|
10523
|
+
if (resolved.values === null || typeof resolved.values !== "object" || Array.isArray(resolved.values))
|
|
10524
|
+
return invalid("resolved.values", resolved.values);
|
|
10525
|
+
let expectedLayerPlanIdentity;
|
|
10526
|
+
try {
|
|
10527
|
+
expectedLayerPlanIdentity = materialLayerPlanIdentity({
|
|
10528
|
+
resolved
|
|
10529
|
+
});
|
|
10530
|
+
} catch (error) {
|
|
10531
|
+
return invalid("resolved.layerPlanIdentity", error instanceof Error ? error.message : error);
|
|
10532
|
+
}
|
|
10533
|
+
if (expectedLayerPlanIdentity !== void 0 && receiptResult.value.derivedInterface.layerPlanIdentity !== expectedLayerPlanIdentity) {
|
|
10534
|
+
return invalid(
|
|
10535
|
+
"receipt.derivedInterface.layerPlanIdentity",
|
|
10536
|
+
receiptResult.value.derivedInterface.layerPlanIdentity
|
|
10537
|
+
);
|
|
10538
|
+
}
|
|
10496
10539
|
if (candidate.artifactDigest !== void 0 && candidate.artifactDigest !== artifact.digest)
|
|
10497
10540
|
return invalid("artifactDigest", candidate.artifactDigest);
|
|
10498
10541
|
if (candidate.publicationGeneration !== void 0 && receiptResult.value.identity.cookGeneration !== candidate.publicationGeneration)
|
|
@@ -10786,230 +10829,6 @@ function decodeMeshBinHeader(bytes, sourceKey2 = "<unknown mesh source>") {
|
|
|
10786
10829
|
}
|
|
10787
10830
|
};
|
|
10788
10831
|
}
|
|
10789
|
-
function failure4(code, expected, hint, detail) {
|
|
10790
|
-
return { ok: false, error: { code, expected, hint, detail } };
|
|
10791
|
-
}
|
|
10792
|
-
function sorted(value) {
|
|
10793
|
-
if (value instanceof Uint8Array) return Buffer.from(value).toString("base64");
|
|
10794
|
-
if (Array.isArray(value)) return value.map(sorted);
|
|
10795
|
-
if (value !== null && typeof value === "object") {
|
|
10796
|
-
const output = {};
|
|
10797
|
-
for (const key of Object.keys(value).sort()) {
|
|
10798
|
-
output[key] = sorted(value[key]);
|
|
10799
|
-
}
|
|
10800
|
-
return output;
|
|
10801
|
-
}
|
|
10802
|
-
return value;
|
|
10803
|
-
}
|
|
10804
|
-
function packageUrl(base, packagePath) {
|
|
10805
|
-
const prefix = base === "/" ? "" : `/${base.replace(/^\/+|\/+$/g, "")}`;
|
|
10806
|
-
return `${prefix}/${packagePath.replace(/^\/+/, "")}`;
|
|
10807
|
-
}
|
|
10808
|
-
function safePath(path) {
|
|
10809
|
-
const normalized = path.replaceAll("\\", "/");
|
|
10810
|
-
return normalized.length > 0 && !normalized.startsWith("/") && !/^[A-Za-z]:\//.test(normalized) && !normalized.split("/").includes("..");
|
|
10811
|
-
}
|
|
10812
|
-
function digest(assets) {
|
|
10813
|
-
const pack = { schemaVersion: "2.0.0", kind: "internal-text-package", assets };
|
|
10814
|
-
const hash = createHash("sha256").update(
|
|
10815
|
-
JSON.stringify(
|
|
10816
|
-
sorted({
|
|
10817
|
-
...pack,
|
|
10818
|
-
assets: pack.assets.map((asset) => ({
|
|
10819
|
-
...asset,
|
|
10820
|
-
artifacts: Object.fromEntries(
|
|
10821
|
-
Object.entries(asset.artifacts).map(([key, artifact]) => [
|
|
10822
|
-
key,
|
|
10823
|
-
{
|
|
10824
|
-
mediaType: artifact.mediaType,
|
|
10825
|
-
...artifact.assetCodec === void 0 ? {} : { assetCodec: artifact.assetCodec },
|
|
10826
|
-
byteLength: artifact.bytes.byteLength
|
|
10827
|
-
}
|
|
10828
|
-
])
|
|
10829
|
-
)
|
|
10830
|
-
}))
|
|
10831
|
-
})
|
|
10832
|
-
)
|
|
10833
|
-
);
|
|
10834
|
-
for (const [key, artifact] of assets.flatMap(
|
|
10835
|
-
(asset) => Object.entries(asset.artifacts).map(
|
|
10836
|
-
([localKey, body]) => [`${asset.guid}/${localKey}`, body]
|
|
10837
|
-
)
|
|
10838
|
-
).sort(([left], [right]) => left.localeCompare(right))) {
|
|
10839
|
-
hash.update(key).update(artifact.bytes);
|
|
10840
|
-
}
|
|
10841
|
-
return `sha256:${hash.digest("hex")}`;
|
|
10842
|
-
}
|
|
10843
|
-
function packageDocument(assets, artifactPath) {
|
|
10844
|
-
return {
|
|
10845
|
-
schemaVersion: "2.0.0",
|
|
10846
|
-
kind: "internal-text-package",
|
|
10847
|
-
assets: assets.map((asset) => ({
|
|
10848
|
-
guid: asset.guid,
|
|
10849
|
-
kind: asset.kind,
|
|
10850
|
-
...asset.name === void 0 ? {} : { name: asset.name },
|
|
10851
|
-
payload: asset.payload,
|
|
10852
|
-
refs: asset.refs,
|
|
10853
|
-
artifacts: Object.fromEntries(
|
|
10854
|
-
Object.entries(asset.artifacts).map(([key, artifact]) => [
|
|
10855
|
-
key,
|
|
10856
|
-
{
|
|
10857
|
-
path: artifactPath(asset.guid, key),
|
|
10858
|
-
mediaType: artifact.mediaType,
|
|
10859
|
-
...artifact.assetCodec === void 0 ? {} : { assetCodec: artifact.assetCodec },
|
|
10860
|
-
contentEncoding: "identity",
|
|
10861
|
-
byteLength: artifact.bytes.byteLength,
|
|
10862
|
-
integrity: {
|
|
10863
|
-
algorithm: "sha256",
|
|
10864
|
-
digest: `sha256:${createHash("sha256").update(artifact.bytes).digest("hex")}`
|
|
10865
|
-
}
|
|
10866
|
-
}
|
|
10867
|
-
])
|
|
10868
|
-
)
|
|
10869
|
-
}))
|
|
10870
|
-
};
|
|
10871
|
-
}
|
|
10872
|
-
function transportArtifacts(assets, artifactPath) {
|
|
10873
|
-
return assets.flatMap(
|
|
10874
|
-
(asset) => Object.entries(asset.artifacts).flatMap(([localKey, artifact]) => [
|
|
10875
|
-
{
|
|
10876
|
-
guid: asset.guid,
|
|
10877
|
-
localKey,
|
|
10878
|
-
path: artifactPath(asset.guid, localKey),
|
|
10879
|
-
mediaType: artifact.mediaType,
|
|
10880
|
-
...artifact.assetCodec === void 0 ? {} : { assetCodec: artifact.assetCodec },
|
|
10881
|
-
bytes: artifact.bytes
|
|
10882
|
-
}
|
|
10883
|
-
])
|
|
10884
|
-
);
|
|
10885
|
-
}
|
|
10886
|
-
async function finalizePackageProduct(product, policy) {
|
|
10887
|
-
if (product.sourceRevision.trim().length === 0) {
|
|
10888
|
-
return failure4(
|
|
10889
|
-
"missing-source-revision",
|
|
10890
|
-
"a non-empty source revision",
|
|
10891
|
-
"rebuild the inventory and provide the producer source revision",
|
|
10892
|
-
{}
|
|
10893
|
-
);
|
|
10894
|
-
}
|
|
10895
|
-
const seen = /* @__PURE__ */ new Set();
|
|
10896
|
-
for (const asset of product.assets) {
|
|
10897
|
-
const guid = asset.guid.toLowerCase();
|
|
10898
|
-
if (seen.has(guid)) {
|
|
10899
|
-
return failure4(
|
|
10900
|
-
"duplicate-guid",
|
|
10901
|
-
"one terminal product row per GUID",
|
|
10902
|
-
"repair the inventory or producer output before finalization",
|
|
10903
|
-
{ guid }
|
|
10904
|
-
);
|
|
10905
|
-
}
|
|
10906
|
-
seen.add(guid);
|
|
10907
|
-
for (const [key, artifact] of Object.entries(asset.artifacts)) {
|
|
10908
|
-
if (!safePath(key) || !(artifact.bytes instanceof Uint8Array)) {
|
|
10909
|
-
return failure4(
|
|
10910
|
-
"invalid-artifact",
|
|
10911
|
-
"asset-local artifact keys and byte bodies",
|
|
10912
|
-
"repair the producer artifact before finalization",
|
|
10913
|
-
{ guid, key }
|
|
10914
|
-
);
|
|
10915
|
-
}
|
|
10916
|
-
}
|
|
10917
|
-
}
|
|
10918
|
-
for (const guid of seen) {
|
|
10919
|
-
if (!product.receipts.some((receipt) => receipt.guid.toLowerCase() === guid)) {
|
|
10920
|
-
return failure4(
|
|
10921
|
-
"missing-receipt",
|
|
10922
|
-
"one receipt for every terminal product GUID",
|
|
10923
|
-
"preserve the producer receipt when handing the product to engine-pack",
|
|
10924
|
-
{ guid }
|
|
10925
|
-
);
|
|
10926
|
-
}
|
|
10927
|
-
}
|
|
10928
|
-
const assets = [...product.assets].sort((left, right) => left.guid.localeCompare(right.guid));
|
|
10929
|
-
const document = packageDocument(assets, policy.artifactPath);
|
|
10930
|
-
const packageBytes = new TextEncoder().encode(JSON.stringify(sorted(document)));
|
|
10931
|
-
if (policy.sink !== void 0) {
|
|
10932
|
-
for (const asset of assets) {
|
|
10933
|
-
for (const [key, artifact] of Object.entries(asset.artifacts)) {
|
|
10934
|
-
const path = policy.artifactPath(asset.guid, key);
|
|
10935
|
-
if (!safePath(path)) {
|
|
10936
|
-
return failure4(
|
|
10937
|
-
"invalid-artifact",
|
|
10938
|
-
"package-relative artifact output paths",
|
|
10939
|
-
"repair the finalizer artifact path policy",
|
|
10940
|
-
{ guid: asset.guid, key }
|
|
10941
|
-
);
|
|
10942
|
-
}
|
|
10943
|
-
await policy.sink(path, artifact.bytes);
|
|
10944
|
-
}
|
|
10945
|
-
}
|
|
10946
|
-
if (!safePath(policy.packagePath)) {
|
|
10947
|
-
return failure4(
|
|
10948
|
-
"invalid-artifact",
|
|
10949
|
-
"a package-relative package path",
|
|
10950
|
-
"repair the finalizer package path policy",
|
|
10951
|
-
{ key: policy.packagePath }
|
|
10952
|
-
);
|
|
10953
|
-
}
|
|
10954
|
-
await policy.sink(policy.packagePath, packageBytes);
|
|
10955
|
-
}
|
|
10956
|
-
return {
|
|
10957
|
-
ok: true,
|
|
10958
|
-
value: {
|
|
10959
|
-
pack: document,
|
|
10960
|
-
packageUrl: packageUrl(policy.base, policy.packagePath),
|
|
10961
|
-
digest: digest(product.assets),
|
|
10962
|
-
receipts: product.receipts,
|
|
10963
|
-
diagnostics: product.diagnostics,
|
|
10964
|
-
sourceRevision: product.sourceRevision,
|
|
10965
|
-
...product.sourceKey === void 0 ? {} : { sourceKey: product.sourceKey }
|
|
10966
|
-
}
|
|
10967
|
-
};
|
|
10968
|
-
}
|
|
10969
|
-
async function finalizePackageTransportSource(input, policy) {
|
|
10970
|
-
const sourceRevision = packageTransportRevision(input);
|
|
10971
|
-
const product = {
|
|
10972
|
-
assets: input.assets,
|
|
10973
|
-
receipts: input.receipts ?? input.assets.map((asset) => ({
|
|
10974
|
-
guid: asset.guid,
|
|
10975
|
-
origin: "sourceMeta",
|
|
10976
|
-
status: "succeeded",
|
|
10977
|
-
inputFingerprint: sourceRevision
|
|
10978
|
-
})),
|
|
10979
|
-
diagnostics: input.diagnostics ?? [],
|
|
10980
|
-
sourceRevision,
|
|
10981
|
-
...input.sourceKey === void 0 ? {} : { sourceKey: input.sourceKey }
|
|
10982
|
-
};
|
|
10983
|
-
const finalized = await finalizePackageProduct(product, policy);
|
|
10984
|
-
if (!finalized.ok) throw finalized.error;
|
|
10985
|
-
return {
|
|
10986
|
-
pack: finalized.value.pack,
|
|
10987
|
-
packageUrl: finalized.value.packageUrl,
|
|
10988
|
-
artifacts: transportArtifacts(product.assets, policy.artifactPath),
|
|
10989
|
-
digest: finalized.value.digest,
|
|
10990
|
-
receipts: finalized.value.receipts,
|
|
10991
|
-
sourceRevision,
|
|
10992
|
-
semantic: JSON.stringify(sorted(finalized.value.pack))
|
|
10993
|
-
};
|
|
10994
|
-
}
|
|
10995
|
-
function revisionStable(value) {
|
|
10996
|
-
if (value instanceof Uint8Array) {
|
|
10997
|
-
return {
|
|
10998
|
-
byteLength: value.byteLength,
|
|
10999
|
-
digest: createHash("sha256").update(value).digest("hex")
|
|
11000
|
-
};
|
|
11001
|
-
}
|
|
11002
|
-
if (Array.isArray(value)) return value.map(revisionStable);
|
|
11003
|
-
if (value !== null && typeof value === "object") {
|
|
11004
|
-
return Object.fromEntries(
|
|
11005
|
-
Object.entries(value).sort(([left], [right]) => left.localeCompare(right)).map(([key, item]) => [key, revisionStable(item)])
|
|
11006
|
-
);
|
|
11007
|
-
}
|
|
11008
|
-
return value;
|
|
11009
|
-
}
|
|
11010
|
-
function packageTransportRevision(value) {
|
|
11011
|
-
return createHash("sha256").update(JSON.stringify(revisionStable(value))).digest("hex");
|
|
11012
|
-
}
|
|
11013
10832
|
function isRecord3(value) {
|
|
11014
10833
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
11015
10834
|
}
|
|
@@ -11141,7 +10960,7 @@ function scanFailure(operation, cause) {
|
|
|
11141
10960
|
const value = cause !== null && typeof cause === "object" ? cause : {};
|
|
11142
10961
|
const detail = value.detail !== null && typeof value.detail === "object" ? value.detail : {};
|
|
11143
10962
|
const reason = isRecord3(detail) && typeof detail.reason === "string" ? detail.reason : void 0;
|
|
11144
|
-
const code = reason === "pack-parent-not-found" || reason === "pack-parent-cycle" || reason === "pack-parent-
|
|
10963
|
+
const code = reason === "pack-parent-not-found" || reason === "pack-parent-cycle" || reason === "pack-parent-has-no-parameters" ? reason : value.code === "pack-guid-collision" ? "pack-guid-collision" : "pack-parameter-invalid";
|
|
11145
10964
|
return makeError(
|
|
11146
10965
|
code,
|
|
11147
10966
|
typeof value.expected === "string" ? value.expected : "a valid Pack Source Index",
|
|
@@ -11313,7 +11132,7 @@ async function createSnapshot(options, operation) {
|
|
|
11313
11132
|
const directAssets = [];
|
|
11314
11133
|
for (const [sourcePath, declaration] of scanned.value.declarations) {
|
|
11315
11134
|
const relativePath = relative(resolve(options.gameRoot), sourcePath).split(sep).join("/");
|
|
11316
|
-
if (declaration.format === "pack.ts
|
|
11135
|
+
if (declaration.format === "pack.ts") {
|
|
11317
11136
|
subjects.set(packageKey(declaration.definition.packageId), {
|
|
11318
11137
|
format: "source",
|
|
11319
11138
|
packageId: declaration.definition.packageId,
|
|
@@ -11324,7 +11143,7 @@ async function createSnapshot(options, operation) {
|
|
|
11324
11143
|
continue;
|
|
11325
11144
|
}
|
|
11326
11145
|
if (declaration.format !== "pack.json" || declaration.value.schemaVersion !== "3.0.0") continue;
|
|
11327
|
-
const parsed =
|
|
11146
|
+
const parsed = parsePackSourceJson(declaration.value);
|
|
11328
11147
|
if (!parsed.ok) return err(parsed.error);
|
|
11329
11148
|
if (parsed.value.format === "direct") {
|
|
11330
11149
|
const projected = projectDirectPackJson(parsed.value);
|
|
@@ -12037,7 +11856,7 @@ function revisionConflict(operation, path, actual) {
|
|
|
12037
11856
|
function directJson(packageId2, assets) {
|
|
12038
11857
|
return { schemaVersion: "3.0.0", packageId: PackageId.format(packageId2), assets };
|
|
12039
11858
|
}
|
|
12040
|
-
function
|
|
11859
|
+
function packSourceScaffold(packageId2, parameters) {
|
|
12041
11860
|
const parameterSource = parameters === void 0 ? "" : "\n parameters: " + JSON.stringify(
|
|
12042
11861
|
parameters.map((parameter) => jsonValue2(parameter)),
|
|
12043
11862
|
null,
|
|
@@ -12125,13 +11944,13 @@ async function executeRaw(options, operation) {
|
|
|
12125
11944
|
makeError(
|
|
12126
11945
|
"pack-parameter-invalid",
|
|
12127
11946
|
"direct create to contain assets only",
|
|
12128
|
-
"use pack.ts for a
|
|
11947
|
+
"use pack.ts for a ScriptablePack source or create-instance for parent+values",
|
|
12129
11948
|
{ requestId: operation.requestId }
|
|
12130
11949
|
)
|
|
12131
11950
|
);
|
|
12132
11951
|
}
|
|
12133
11952
|
const assets = operation.initialAssets ?? {};
|
|
12134
|
-
const parsed =
|
|
11953
|
+
const parsed = parsePackSourceJson(directJson(identity.value, assets));
|
|
12135
11954
|
if (!parsed.ok) return err(parsed.error);
|
|
12136
11955
|
if (parsed.value.format !== "direct") {
|
|
12137
11956
|
return err(
|
|
@@ -12187,7 +12006,7 @@ async function executeRaw(options, operation) {
|
|
|
12187
12006
|
}
|
|
12188
12007
|
parameters = validated.value.parameters;
|
|
12189
12008
|
}
|
|
12190
|
-
source =
|
|
12009
|
+
source = packSourceScaffold(identity.value, parameters);
|
|
12191
12010
|
const serialized = parameters === void 0 ? void 0 : serializedParameters({
|
|
12192
12011
|
schemaVersion: "2.0.0",
|
|
12193
12012
|
packageId: identity.value,
|
|
@@ -12283,7 +12102,7 @@ async function executeRaw(options, operation) {
|
|
|
12283
12102
|
)
|
|
12284
12103
|
);
|
|
12285
12104
|
}
|
|
12286
|
-
const parsed =
|
|
12105
|
+
const parsed = parsePackSourceJson(parsedValue);
|
|
12287
12106
|
if (!parsed.ok) return err(parsed.error);
|
|
12288
12107
|
source = `${JSON.stringify(
|
|
12289
12108
|
parsed.value.format === "direct" ? directJson(identity.value, parsed.value.assets) : {
|
|
@@ -12343,7 +12162,7 @@ async function executeRaw(options, operation) {
|
|
|
12343
12162
|
makeError(
|
|
12344
12163
|
"pack-parent-not-found",
|
|
12345
12164
|
"a parent packageId for the new instance",
|
|
12346
|
-
"pass parentPackageId or parent and point it at a
|
|
12165
|
+
"pass parentPackageId or parent and point it at a ScriptablePack source with parameters",
|
|
12347
12166
|
{ requestId: operation.requestId }
|
|
12348
12167
|
)
|
|
12349
12168
|
);
|
|
@@ -12366,7 +12185,7 @@ async function executeRaw(options, operation) {
|
|
|
12366
12185
|
makeError(
|
|
12367
12186
|
"pack-parent-not-found",
|
|
12368
12187
|
"the parent packageId to exist in the current Source Index",
|
|
12369
|
-
"inspect the Source Index and choose a
|
|
12188
|
+
"inspect the Source Index and choose a ScriptablePack parent with parameters",
|
|
12370
12189
|
{ requestId: operation.requestId, parent: parentText }
|
|
12371
12190
|
)
|
|
12372
12191
|
);
|
|
@@ -12374,8 +12193,8 @@ async function executeRaw(options, operation) {
|
|
|
12374
12193
|
if (parent.format === "source" && !("parameters" in parent.definition)) {
|
|
12375
12194
|
return err(
|
|
12376
12195
|
makeError(
|
|
12377
|
-
"pack-parent-
|
|
12378
|
-
"a non-empty
|
|
12196
|
+
"pack-parent-has-no-parameters",
|
|
12197
|
+
"a ScriptablePack source with a non-empty parameter list as the parent",
|
|
12379
12198
|
"use asset-source.clone for a zero-parameter Pack",
|
|
12380
12199
|
{ requestId: operation.requestId, parent: parentText }
|
|
12381
12200
|
)
|
|
@@ -12384,8 +12203,8 @@ async function executeRaw(options, operation) {
|
|
|
12384
12203
|
if (parent.format === "direct") {
|
|
12385
12204
|
return err(
|
|
12386
12205
|
makeError(
|
|
12387
|
-
"pack-parent-
|
|
12388
|
-
"a
|
|
12206
|
+
"pack-parent-has-no-parameters",
|
|
12207
|
+
"a ScriptablePack source or instance with parameters as the parent",
|
|
12389
12208
|
"direct Packs cannot be instance parents",
|
|
12390
12209
|
{ requestId: operation.requestId, parent: parentText }
|
|
12391
12210
|
)
|
|
@@ -12488,7 +12307,7 @@ async function executeRaw(options, operation) {
|
|
|
12488
12307
|
)
|
|
12489
12308
|
);
|
|
12490
12309
|
}
|
|
12491
|
-
const parsed =
|
|
12310
|
+
const parsed = parsePackSourceJson(json);
|
|
12492
12311
|
if (!parsed.ok) return err(parsed.error);
|
|
12493
12312
|
if (parsed.value.format !== "instance") {
|
|
12494
12313
|
return err(
|
|
@@ -12591,20 +12410,242 @@ async function executeRaw(options, operation) {
|
|
|
12591
12410
|
return err(
|
|
12592
12411
|
makeError(
|
|
12593
12412
|
"pack-parameter-invalid",
|
|
12594
|
-
"a supported
|
|
12595
|
-
"use one of
|
|
12413
|
+
"a supported Pack authoring operation",
|
|
12414
|
+
"use one of PACK_AUTHORING_OPERATION_IDS",
|
|
12596
12415
|
{ requestId: operation.requestId, operation: operation.operation }
|
|
12597
12416
|
)
|
|
12598
12417
|
);
|
|
12599
12418
|
}
|
|
12600
|
-
function
|
|
12419
|
+
function createFileSystemPackAuthoringPort(options) {
|
|
12601
12420
|
return { execute: (operation) => executeRaw(options, operation) };
|
|
12602
12421
|
}
|
|
12603
|
-
function
|
|
12604
|
-
return
|
|
12605
|
-
|
|
12422
|
+
function createFileSystemPackAuthoringGateway(options) {
|
|
12423
|
+
return createPackAuthoringGateway(createFileSystemPackAuthoringPort(options));
|
|
12424
|
+
}
|
|
12425
|
+
function failure4(code, expected, hint, detail) {
|
|
12426
|
+
return { ok: false, error: { code, expected, hint, detail } };
|
|
12427
|
+
}
|
|
12428
|
+
function sorted(value) {
|
|
12429
|
+
if (value instanceof Uint8Array) return Buffer.from(value).toString("base64");
|
|
12430
|
+
if (Array.isArray(value)) return value.map(sorted);
|
|
12431
|
+
if (value !== null && typeof value === "object") {
|
|
12432
|
+
const output = {};
|
|
12433
|
+
for (const key of Object.keys(value).sort()) {
|
|
12434
|
+
output[key] = sorted(value[key]);
|
|
12435
|
+
}
|
|
12436
|
+
return output;
|
|
12437
|
+
}
|
|
12438
|
+
return value;
|
|
12439
|
+
}
|
|
12440
|
+
function packageUrl(base, packagePath) {
|
|
12441
|
+
const prefix = base === "/" ? "" : `/${base.replace(/^\/+|\/+$/g, "")}`;
|
|
12442
|
+
return `${prefix}/${packagePath.replace(/^\/+/, "")}`;
|
|
12443
|
+
}
|
|
12444
|
+
function safePath(path) {
|
|
12445
|
+
const normalized = path.replaceAll("\\", "/");
|
|
12446
|
+
return normalized.length > 0 && !normalized.startsWith("/") && !/^[A-Za-z]:\//.test(normalized) && !normalized.split("/").includes("..");
|
|
12447
|
+
}
|
|
12448
|
+
function digest(assets) {
|
|
12449
|
+
const pack = { schemaVersion: "2.0.0", kind: "internal-text-package", assets };
|
|
12450
|
+
const hash = createHash("sha256").update(
|
|
12451
|
+
JSON.stringify(
|
|
12452
|
+
sorted({
|
|
12453
|
+
...pack,
|
|
12454
|
+
assets: pack.assets.map((asset) => ({
|
|
12455
|
+
...asset,
|
|
12456
|
+
artifacts: Object.fromEntries(
|
|
12457
|
+
Object.entries(asset.artifacts).map(([key, artifact]) => [
|
|
12458
|
+
key,
|
|
12459
|
+
{
|
|
12460
|
+
mediaType: artifact.mediaType,
|
|
12461
|
+
...artifact.assetCodec === void 0 ? {} : { assetCodec: artifact.assetCodec },
|
|
12462
|
+
byteLength: artifact.bytes.byteLength
|
|
12463
|
+
}
|
|
12464
|
+
])
|
|
12465
|
+
)
|
|
12466
|
+
}))
|
|
12467
|
+
})
|
|
12468
|
+
)
|
|
12469
|
+
);
|
|
12470
|
+
for (const [key, artifact] of assets.flatMap(
|
|
12471
|
+
(asset) => Object.entries(asset.artifacts).map(
|
|
12472
|
+
([localKey, body]) => [`${asset.guid}/${localKey}`, body]
|
|
12473
|
+
)
|
|
12474
|
+
).sort(([left], [right]) => left.localeCompare(right))) {
|
|
12475
|
+
hash.update(key).update(artifact.bytes);
|
|
12476
|
+
}
|
|
12477
|
+
return `sha256:${hash.digest("hex")}`;
|
|
12478
|
+
}
|
|
12479
|
+
function packageDocument(assets, artifactPath) {
|
|
12480
|
+
return {
|
|
12481
|
+
schemaVersion: "2.0.0",
|
|
12482
|
+
kind: "internal-text-package",
|
|
12483
|
+
assets: assets.map((asset) => ({
|
|
12484
|
+
guid: asset.guid,
|
|
12485
|
+
kind: asset.kind,
|
|
12486
|
+
...asset.name === void 0 ? {} : { name: asset.name },
|
|
12487
|
+
payload: asset.payload,
|
|
12488
|
+
refs: asset.refs,
|
|
12489
|
+
artifacts: Object.fromEntries(
|
|
12490
|
+
Object.entries(asset.artifacts).map(([key, artifact]) => [
|
|
12491
|
+
key,
|
|
12492
|
+
{
|
|
12493
|
+
path: artifactPath(asset.guid, key),
|
|
12494
|
+
mediaType: artifact.mediaType,
|
|
12495
|
+
...artifact.assetCodec === void 0 ? {} : { assetCodec: artifact.assetCodec },
|
|
12496
|
+
contentEncoding: "identity",
|
|
12497
|
+
byteLength: artifact.bytes.byteLength,
|
|
12498
|
+
integrity: {
|
|
12499
|
+
algorithm: "sha256",
|
|
12500
|
+
digest: `sha256:${createHash("sha256").update(artifact.bytes).digest("hex")}`
|
|
12501
|
+
}
|
|
12502
|
+
}
|
|
12503
|
+
])
|
|
12504
|
+
)
|
|
12505
|
+
}))
|
|
12506
|
+
};
|
|
12507
|
+
}
|
|
12508
|
+
function transportArtifacts(assets, artifactPath) {
|
|
12509
|
+
return assets.flatMap(
|
|
12510
|
+
(asset) => Object.entries(asset.artifacts).flatMap(([localKey, artifact]) => [
|
|
12511
|
+
{
|
|
12512
|
+
guid: asset.guid,
|
|
12513
|
+
localKey,
|
|
12514
|
+
path: artifactPath(asset.guid, localKey),
|
|
12515
|
+
mediaType: artifact.mediaType,
|
|
12516
|
+
...artifact.assetCodec === void 0 ? {} : { assetCodec: artifact.assetCodec },
|
|
12517
|
+
bytes: artifact.bytes
|
|
12518
|
+
}
|
|
12519
|
+
])
|
|
12606
12520
|
);
|
|
12607
12521
|
}
|
|
12522
|
+
async function finalizePackageProduct(product, policy) {
|
|
12523
|
+
if (product.sourceRevision.trim().length === 0) {
|
|
12524
|
+
return failure4(
|
|
12525
|
+
"missing-source-revision",
|
|
12526
|
+
"a non-empty source revision",
|
|
12527
|
+
"rebuild the inventory and provide the producer source revision",
|
|
12528
|
+
{}
|
|
12529
|
+
);
|
|
12530
|
+
}
|
|
12531
|
+
const seen = /* @__PURE__ */ new Set();
|
|
12532
|
+
for (const asset of product.assets) {
|
|
12533
|
+
const guid = asset.guid.toLowerCase();
|
|
12534
|
+
if (seen.has(guid)) {
|
|
12535
|
+
return failure4(
|
|
12536
|
+
"duplicate-guid",
|
|
12537
|
+
"one terminal product row per GUID",
|
|
12538
|
+
"repair the inventory or producer output before finalization",
|
|
12539
|
+
{ guid }
|
|
12540
|
+
);
|
|
12541
|
+
}
|
|
12542
|
+
seen.add(guid);
|
|
12543
|
+
for (const [key, artifact] of Object.entries(asset.artifacts)) {
|
|
12544
|
+
if (!safePath(key) || !(artifact.bytes instanceof Uint8Array)) {
|
|
12545
|
+
return failure4(
|
|
12546
|
+
"invalid-artifact",
|
|
12547
|
+
"asset-local artifact keys and byte bodies",
|
|
12548
|
+
"repair the producer artifact before finalization",
|
|
12549
|
+
{ guid, key }
|
|
12550
|
+
);
|
|
12551
|
+
}
|
|
12552
|
+
}
|
|
12553
|
+
}
|
|
12554
|
+
for (const guid of seen) {
|
|
12555
|
+
if (!product.receipts.some((receipt) => receipt.guid.toLowerCase() === guid)) {
|
|
12556
|
+
return failure4(
|
|
12557
|
+
"missing-receipt",
|
|
12558
|
+
"one receipt for every terminal product GUID",
|
|
12559
|
+
"preserve the producer receipt when handing the product to engine-pack",
|
|
12560
|
+
{ guid }
|
|
12561
|
+
);
|
|
12562
|
+
}
|
|
12563
|
+
}
|
|
12564
|
+
const assets = [...product.assets].sort((left, right) => left.guid.localeCompare(right.guid));
|
|
12565
|
+
const document = packageDocument(assets, policy.artifactPath);
|
|
12566
|
+
const packageBytes = new TextEncoder().encode(JSON.stringify(sorted(document)));
|
|
12567
|
+
if (policy.sink !== void 0) {
|
|
12568
|
+
for (const asset of assets) {
|
|
12569
|
+
for (const [key, artifact] of Object.entries(asset.artifacts)) {
|
|
12570
|
+
const path = policy.artifactPath(asset.guid, key);
|
|
12571
|
+
if (!safePath(path)) {
|
|
12572
|
+
return failure4(
|
|
12573
|
+
"invalid-artifact",
|
|
12574
|
+
"package-relative artifact output paths",
|
|
12575
|
+
"repair the finalizer artifact path policy",
|
|
12576
|
+
{ guid: asset.guid, key }
|
|
12577
|
+
);
|
|
12578
|
+
}
|
|
12579
|
+
await policy.sink(path, artifact.bytes);
|
|
12580
|
+
}
|
|
12581
|
+
}
|
|
12582
|
+
if (!safePath(policy.packagePath)) {
|
|
12583
|
+
return failure4(
|
|
12584
|
+
"invalid-artifact",
|
|
12585
|
+
"a package-relative package path",
|
|
12586
|
+
"repair the finalizer package path policy",
|
|
12587
|
+
{ key: policy.packagePath }
|
|
12588
|
+
);
|
|
12589
|
+
}
|
|
12590
|
+
await policy.sink(policy.packagePath, packageBytes);
|
|
12591
|
+
}
|
|
12592
|
+
return {
|
|
12593
|
+
ok: true,
|
|
12594
|
+
value: {
|
|
12595
|
+
pack: document,
|
|
12596
|
+
packageUrl: packageUrl(policy.base, policy.packagePath),
|
|
12597
|
+
digest: digest(product.assets),
|
|
12598
|
+
receipts: product.receipts,
|
|
12599
|
+
diagnostics: product.diagnostics,
|
|
12600
|
+
sourceRevision: product.sourceRevision,
|
|
12601
|
+
...product.sourceKey === void 0 ? {} : { sourceKey: product.sourceKey }
|
|
12602
|
+
}
|
|
12603
|
+
};
|
|
12604
|
+
}
|
|
12605
|
+
async function finalizePackageTransportSource(input, policy) {
|
|
12606
|
+
const sourceRevision = packageTransportRevision(input);
|
|
12607
|
+
const product = {
|
|
12608
|
+
assets: input.assets,
|
|
12609
|
+
receipts: input.receipts ?? input.assets.map((asset) => ({
|
|
12610
|
+
guid: asset.guid,
|
|
12611
|
+
origin: "sourceMeta",
|
|
12612
|
+
status: "succeeded",
|
|
12613
|
+
inputFingerprint: sourceRevision
|
|
12614
|
+
})),
|
|
12615
|
+
diagnostics: input.diagnostics ?? [],
|
|
12616
|
+
sourceRevision,
|
|
12617
|
+
...input.sourceKey === void 0 ? {} : { sourceKey: input.sourceKey }
|
|
12618
|
+
};
|
|
12619
|
+
const finalized = await finalizePackageProduct(product, policy);
|
|
12620
|
+
if (!finalized.ok) throw finalized.error;
|
|
12621
|
+
return {
|
|
12622
|
+
pack: finalized.value.pack,
|
|
12623
|
+
packageUrl: finalized.value.packageUrl,
|
|
12624
|
+
artifacts: transportArtifacts(product.assets, policy.artifactPath),
|
|
12625
|
+
digest: finalized.value.digest,
|
|
12626
|
+
receipts: finalized.value.receipts,
|
|
12627
|
+
sourceRevision,
|
|
12628
|
+
semantic: JSON.stringify(sorted(finalized.value.pack))
|
|
12629
|
+
};
|
|
12630
|
+
}
|
|
12631
|
+
function revisionStable(value) {
|
|
12632
|
+
if (value instanceof Uint8Array) {
|
|
12633
|
+
return {
|
|
12634
|
+
byteLength: value.byteLength,
|
|
12635
|
+
digest: createHash("sha256").update(value).digest("hex")
|
|
12636
|
+
};
|
|
12637
|
+
}
|
|
12638
|
+
if (Array.isArray(value)) return value.map(revisionStable);
|
|
12639
|
+
if (value !== null && typeof value === "object") {
|
|
12640
|
+
return Object.fromEntries(
|
|
12641
|
+
Object.entries(value).sort(([left], [right]) => left.localeCompare(right)).map(([key, item]) => [key, revisionStable(item)])
|
|
12642
|
+
);
|
|
12643
|
+
}
|
|
12644
|
+
return value;
|
|
12645
|
+
}
|
|
12646
|
+
function packageTransportRevision(value) {
|
|
12647
|
+
return createHash("sha256").update(JSON.stringify(revisionStable(value))).digest("hex");
|
|
12648
|
+
}
|
|
12608
12649
|
function parsePackV2(value) {
|
|
12609
12650
|
if (!validatePackV2(value)) {
|
|
12610
12651
|
return err({
|
|
@@ -12725,6 +12766,6 @@ function createRuntimePackPublication(input) {
|
|
|
12725
12766
|
};
|
|
12726
12767
|
}
|
|
12727
12768
|
|
|
12728
|
-
export { AssetGuid, MESH_BIN_DIGEST_BYTES, MESH_BIN_HEADER_V4_BYTES, MESH_BIN_PROJECTION_VERSION, MESH_BIN_VERSION,
|
|
12769
|
+
export { AssetGuid, MESH_BIN_DIGEST_BYTES, MESH_BIN_HEADER_V4_BYTES, MESH_BIN_PROJECTION_VERSION, MESH_BIN_VERSION, PACK_AUTHORING_OPERATION_DESCRIPTORS, PACK_AUTHORING_OPERATION_IDS, PACK_PARAMETER_TYPES, PACK_SOURCE_KEY_RE, PackageId, SCRIPTABLE_PACK_ASSET_KINDS, STANDARD_SCRIPTABLE_PACK_SCAN_OPTIONS, buildCatalogProjection, buildOfflineAssetEvidence, calculateCatalogDelta, calculateTopologyDiff, catalogProjectionFor, catalogSourcePathFor, collectMaterialCookRefs, createFileSystemPackAuthoringGateway, createFileSystemPackAuthoringPort, createMaterialArtifactDigest, createPackAuthoringGateway, createRuntimePackPublication, currentProjectionFor, decodeMeshBinHeader, definePack, definePackageId, diffTopology, finalizePackageProduct, finalizePackageTransportSource, findReservedAssetKindConflict, hasPackParameters, inventoryDigest, isScriptablePackAssetKind, isValidAssetGuidString, isValidPackSourceKey, metaPathForGuid, packageTransportRevision, packageVerification, parsePackSourceJson, parsePackV2, projectAssetRefs, projectCookedMaterialRecord, projectCookedPackageEntry, projectDirectPackJson, projectExternalCatalogEntries, projectPackageCatalog, projectRuntimeCatalogRow, projectSceneEntityRefs, projectScriptablePackMeta, projectScriptablePackSceneComponents, resolveAssetSource, resolvePackInheritance, resolvePackParameterInheritance, resolvePackParameterValues, scanInventory, serializeCookedMaterialRecord, serializeMaterialCookReceipt, syncAuthorInventory, validateArtifactPath, validateAuthorInventory, validateCookedMaterialRecord, validateMaterialCookReceipt, validateMeta, validatePack, validatePackDefinition, validatePackV2, validateProducerContract, validateProducerOutputs, writeMeshBinHeader };
|
|
12729
12770
|
//# sourceMappingURL=build.mjs.map
|
|
12730
12771
|
//# sourceMappingURL=build.mjs.map
|