@forgeax/engine-pack 0.1.23 → 0.1.25

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.
Files changed (157) hide show
  1. package/README.md +12 -6
  2. package/dist/build.d.ts +4 -4
  3. package/dist/build.d.ts.map +1 -1
  4. package/dist/build.mjs +390 -294
  5. package/dist/build.mjs.map +1 -1
  6. package/dist/cli-asset.mjs +33 -35
  7. package/dist/cli-asset.mjs.map +1 -1
  8. package/dist/evidence/material-cook.d.ts +26 -0
  9. package/dist/evidence/material-cook.d.ts.map +1 -1
  10. package/dist/index.d.ts +2 -2
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.mjs +121 -27
  13. package/dist/index.mjs.map +1 -1
  14. package/dist/material-cook.d.ts +1 -1
  15. package/dist/material-cook.d.ts.map +1 -1
  16. package/dist/material-cook.mjs +102 -4
  17. package/dist/material-cook.mjs.map +1 -1
  18. package/dist/{parameterized-pack-node.d.ts → pack-authoring-node.d.ts} +7 -7
  19. package/dist/pack-authoring-node.d.ts.map +1 -0
  20. package/dist/{parameterized-pack-node.mjs → pack-authoring-node.mjs} +59 -63
  21. package/dist/pack-authoring-node.mjs.map +1 -0
  22. package/dist/{parameterized-pack.d.ts → pack-authoring.d.ts} +28 -31
  23. package/dist/pack-authoring.d.ts.map +1 -0
  24. package/dist/pack-authoring.mjs +1137 -0
  25. package/dist/pack-authoring.mjs.map +1 -0
  26. package/dist/runtime.mjs +1 -1
  27. package/dist/runtime.mjs.map +1 -1
  28. package/dist/scanner.d.ts +11 -9
  29. package/dist/scanner.d.ts.map +1 -1
  30. package/dist/scanner.mjs +36 -34
  31. package/dist/scanner.mjs.map +1 -1
  32. package/dist/schema.mjs +1 -1
  33. package/dist/schema.mjs.map +1 -1
  34. package/dist/scriptable-pack-node.d.ts +4 -4
  35. package/dist/scriptable-pack-node.d.ts.map +1 -1
  36. package/dist/scriptable-pack-node.mjs +18 -20
  37. package/dist/scriptable-pack-node.mjs.map +1 -1
  38. package/dist/scriptable-pack.d.ts +3 -2
  39. package/dist/scriptable-pack.d.ts.map +1 -1
  40. package/dist/scriptable-pack.mjs +19 -23
  41. package/dist/scriptable-pack.mjs.map +1 -1
  42. package/package.json +2 -7
  43. package/schema/pack.schema.json +1 -1
  44. package/src/__tests__/material-cook-receipt-layer-plan.unit.test.ts +16 -0
  45. package/src/__tests__/material-cook-schema.unit.test.ts +62 -0
  46. package/src/__tests__/material-declaration-boundary.unit.test.ts +35 -0
  47. package/src/__tests__/material-surface-consumer-census.test.ts +24 -0
  48. package/src/__tests__/material-surface-publication.unit.test.ts +159 -0
  49. package/src/__tests__/material-surface-wire.unit.test.ts +30 -0
  50. package/src/__tests__/{parameterized-pack-authoring-gateway.unit.test.ts → pack-authoring-gateway.unit.test.ts} +9 -9
  51. package/src/__tests__/{parameterized-pack.unit.test.ts → pack-authoring.unit.test.ts} +10 -10
  52. package/src/__tests__/{parameterized-pack-scanner.unit.test.ts → pack-scanner.unit.test.ts} +6 -6
  53. package/src/__tests__/scanner-inventory.contract.test.ts +2 -4
  54. package/src/__tests__/scanner-inventory.test.ts +7 -6
  55. package/src/__tests__/scriptable-pack-cli.integration.test.ts +1 -1
  56. package/src/build.ts +10 -8
  57. package/src/catalog-builder.ts +3 -3
  58. package/src/cli-asset.ts +5 -5
  59. package/src/evidence/material-cook.ts +170 -7
  60. package/src/evidence/source-inventory.ts +3 -3
  61. package/src/index.ts +6 -1
  62. package/src/material-cook.ts +3 -0
  63. package/src/{parameterized-pack-node.ts → pack-authoring-node.ts} +71 -73
  64. package/src/{parameterized-pack.ts → pack-authoring.ts} +59 -74
  65. package/src/scanner.ts +33 -31
  66. package/src/schema/material-cook.schema.json +47 -1
  67. package/src/scriptable-pack-node.ts +25 -25
  68. package/src/scriptable-pack.ts +3 -2
  69. package/dist/__tests__/ai-recovery.unit.test.d.ts +0 -2
  70. package/dist/__tests__/ai-recovery.unit.test.d.ts.map +0 -1
  71. package/dist/__tests__/artifact-path.test.d.ts +0 -2
  72. package/dist/__tests__/artifact-path.test.d.ts.map +0 -1
  73. package/dist/__tests__/asset-evidence-error-hints.test.d.ts +0 -2
  74. package/dist/__tests__/asset-evidence-error-hints.test.d.ts.map +0 -1
  75. package/dist/__tests__/asset-evidence-lifecycle.test.d.ts +0 -2
  76. package/dist/__tests__/asset-evidence-lifecycle.test.d.ts.map +0 -1
  77. package/dist/__tests__/asset-evidence-schema.test.d.ts +0 -2
  78. package/dist/__tests__/asset-evidence-schema.test.d.ts.map +0 -1
  79. package/dist/__tests__/atlas-cli-region-mismatch.test.d.ts +0 -2
  80. package/dist/__tests__/atlas-cli-region-mismatch.test.d.ts.map +0 -1
  81. package/dist/__tests__/atlas-error-code-owner.test-d.d.ts +0 -2
  82. package/dist/__tests__/atlas-error-code-owner.test-d.d.ts.map +0 -1
  83. package/dist/__tests__/cli-asset-evidence.integration.test.d.ts +0 -2
  84. package/dist/__tests__/cli-asset-evidence.integration.test.d.ts.map +0 -1
  85. package/dist/__tests__/cli.unit.test.d.ts +0 -2
  86. package/dist/__tests__/cli.unit.test.d.ts.map +0 -1
  87. package/dist/__tests__/evidence-source-inventory.unit.test.d.ts +0 -2
  88. package/dist/__tests__/evidence-source-inventory.unit.test.d.ts.map +0 -1
  89. package/dist/__tests__/guid-collision.unit.test.d.ts +0 -2
  90. package/dist/__tests__/guid-collision.unit.test.d.ts.map +0 -1
  91. package/dist/__tests__/guid-validator-surface.unit.test.d.ts +0 -2
  92. package/dist/__tests__/guid-validator-surface.unit.test.d.ts.map +0 -1
  93. package/dist/__tests__/inventory-schema.test.d.ts +0 -2
  94. package/dist/__tests__/inventory-schema.test.d.ts.map +0 -1
  95. package/dist/__tests__/material-cook-dependencies.unit.test.d.ts +0 -2
  96. package/dist/__tests__/material-cook-dependencies.unit.test.d.ts.map +0 -1
  97. package/dist/__tests__/material-cook-receipt.unit.test.d.ts +0 -2
  98. package/dist/__tests__/material-cook-receipt.unit.test.d.ts.map +0 -1
  99. package/dist/__tests__/material-cook-schema.unit.test.d.ts +0 -2
  100. package/dist/__tests__/material-cook-schema.unit.test.d.ts.map +0 -1
  101. package/dist/__tests__/mesh-bin-consumer-surface.unit.test.d.ts +0 -2
  102. package/dist/__tests__/mesh-bin-consumer-surface.unit.test.d.ts.map +0 -1
  103. package/dist/__tests__/mesh-bin-contract.unit.test.d.ts +0 -2
  104. package/dist/__tests__/mesh-bin-contract.unit.test.d.ts.map +0 -1
  105. package/dist/__tests__/meta-schema-optional.test.d.ts +0 -2
  106. package/dist/__tests__/meta-schema-optional.test.d.ts.map +0 -1
  107. package/dist/__tests__/meta-source-overrides.unit.test.d.ts +0 -2
  108. package/dist/__tests__/meta-source-overrides.unit.test.d.ts.map +0 -1
  109. package/dist/__tests__/native-cooker-registry.test.d.ts +0 -2
  110. package/dist/__tests__/native-cooker-registry.test.d.ts.map +0 -1
  111. package/dist/__tests__/offline-evidence-artifact-verification-owner.test-d.d.ts +0 -2
  112. package/dist/__tests__/offline-evidence-artifact-verification-owner.test-d.d.ts.map +0 -1
  113. package/dist/__tests__/offline-evidence.integration.test.d.ts +0 -2
  114. package/dist/__tests__/offline-evidence.integration.test.d.ts.map +0 -1
  115. package/dist/__tests__/owner-chain.integration.test.d.ts +0 -2
  116. package/dist/__tests__/owner-chain.integration.test.d.ts.map +0 -1
  117. package/dist/__tests__/pack-v2-fixture-migration.test.d.ts +0 -2
  118. package/dist/__tests__/pack-v2-fixture-migration.test.d.ts.map +0 -1
  119. package/dist/__tests__/pack-v2-schema.test.d.ts +0 -2
  120. package/dist/__tests__/pack-v2-schema.test.d.ts.map +0 -1
  121. package/dist/__tests__/pack.unit.test.d.ts +0 -2
  122. package/dist/__tests__/pack.unit.test.d.ts.map +0 -1
  123. package/dist/__tests__/package-finalizer.contract.test.d.ts +0 -2
  124. package/dist/__tests__/package-finalizer.contract.test.d.ts.map +0 -1
  125. package/dist/__tests__/parameterized-pack-authoring-gateway.unit.test.d.ts +0 -2
  126. package/dist/__tests__/parameterized-pack-authoring-gateway.unit.test.d.ts.map +0 -1
  127. package/dist/__tests__/parameterized-pack-scanner.unit.test.d.ts +0 -2
  128. package/dist/__tests__/parameterized-pack-scanner.unit.test.d.ts.map +0 -1
  129. package/dist/__tests__/parameterized-pack.unit.test.d.ts +0 -2
  130. package/dist/__tests__/parameterized-pack.unit.test.d.ts.map +0 -1
  131. package/dist/__tests__/producer-contract-schema.unit.test.d.ts +0 -2
  132. package/dist/__tests__/producer-contract-schema.unit.test.d.ts.map +0 -1
  133. package/dist/__tests__/resolve-asset-source.test.d.ts +0 -2
  134. package/dist/__tests__/resolve-asset-source.test.d.ts.map +0 -1
  135. package/dist/__tests__/runtime-projection.unit.test.d.ts +0 -2
  136. package/dist/__tests__/runtime-projection.unit.test.d.ts.map +0 -1
  137. package/dist/__tests__/runtime.browser.test.d.ts +0 -2
  138. package/dist/__tests__/runtime.browser.test.d.ts.map +0 -1
  139. package/dist/__tests__/scanner-blacklist.test.d.ts +0 -2
  140. package/dist/__tests__/scanner-blacklist.test.d.ts.map +0 -1
  141. package/dist/__tests__/scanner-inventory.contract.test.d.ts +0 -2
  142. package/dist/__tests__/scanner-inventory.contract.test.d.ts.map +0 -1
  143. package/dist/__tests__/scanner-inventory.test.d.ts +0 -2
  144. package/dist/__tests__/scanner-inventory.test.d.ts.map +0 -1
  145. package/dist/__tests__/scanner-mount-cycle.test.d.ts +0 -2
  146. package/dist/__tests__/scanner-mount-cycle.test.d.ts.map +0 -1
  147. package/dist/__tests__/scriptable-pack-cli.integration.test.d.ts +0 -2
  148. package/dist/__tests__/scriptable-pack-cli.integration.test.d.ts.map +0 -1
  149. package/dist/__tests__/scriptable-pack-ddc-key.unit.test.d.ts +0 -2
  150. package/dist/__tests__/scriptable-pack-ddc-key.unit.test.d.ts.map +0 -1
  151. package/dist/__tests__/topology-actions.unit.test.d.ts +0 -2
  152. package/dist/__tests__/topology-actions.unit.test.d.ts.map +0 -1
  153. package/dist/__tests__/topology.unit.test.d.ts +0 -2
  154. package/dist/__tests__/topology.unit.test.d.ts.map +0 -1
  155. package/dist/parameterized-pack-node.d.ts.map +0 -1
  156. package/dist/parameterized-pack-node.mjs.map +0 -1
  157. 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 projectParameterizedPackMeta(definition, sourcePath) {
7464
+ function projectScriptablePackMeta(definition, sourcePath) {
7465
7465
  return {
7466
7466
  schemaVersion: "2.0.0",
7467
- kind: "parameterized-pack-source",
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 isParameterizedPack(value) {
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 parseParameterizedPackJson(value) {
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) : parseParameterizedPackJson(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-not-parameterized",
7836
- "a parameterized Pack source as the parent",
7837
- "direct packs cannot be instance parents; point the instance at a parameterized source",
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-not-parameterized",
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 parameterized Pack",
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 PARAMETERIZED_PACK_OPERATION_IDS = [
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 createParameterizedPackAuthoringGateway(port) {
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 PARAMETERIZED_PACK_OPERATION_DESCRIPTORS = PARAMETERIZED_PACK_OPERATION_IDS.map(
7995
- (id) => ({
7996
- id,
7997
- domain: id.startsWith("asset-source.") ? "session" : "asset",
7998
- readOnly: id.startsWith("asset."),
7999
- requiresRevision: !id.startsWith("asset.") && id !== "asset-source.create"
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 parameterized Pack packageId for one v3 instance."
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
- supportsParameterizedContext = true;
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 parameterizedLoadFailure(sourcePath, reason, phase, diagnostic, timeoutMs) {
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 loadParameterizedScriptablePack(sourcePath, options = {}) {
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("parameterized-pack-module-timeout");
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
- parameterizedLoadFailure(
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
- parameterizedLoadFailure(
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 = "supportsParameterizedContext" in executor && executor.supportsParameterizedContext === true ? build(context.readByGuid, {
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
- parameterizedLoadFailure(
9225
+ scriptablePackLoadFailure(
9230
9226
  sourcePath,
9231
9227
  "module-load",
9232
9228
  "module-load",
@@ -9249,9 +9245,13 @@ function packErr(error) {
9249
9245
  function record(value) {
9250
9246
  return value !== null && typeof value === "object" && !Array.isArray(value);
9251
9247
  }
9252
- var STANDARD_SCRIPTABLE_PACK_SCAN_OPTIONS = Object.freeze(
9253
- {}
9254
- );
9248
+ var STANDARD_SCRIPTABLE_PACK_SCAN_OPTIONS = Object.freeze({
9249
+ // Scriptable Packs execute in an isolated worker. A cold worker must
9250
+ // compile the authored source closure before it can return metadata;
9251
+ // heavy procedural packs otherwise make the shared catalog fall back to
9252
+ // an empty degraded projection at the old 15-second budget.
9253
+ timeoutMs: 6e4
9254
+ });
9255
9255
  var BLACKLIST = /* @__PURE__ */ new Set([
9256
9256
  "node_modules",
9257
9257
  "__tests__",
@@ -9379,7 +9379,7 @@ async function scanValidated(roots, opts = {}, capture) {
9379
9379
  if (!loaded.ok) return loaded;
9380
9380
  const { raw, parsed } = loaded.value;
9381
9381
  if (record(parsed) && parsed.schemaVersion === "3.0.0") {
9382
- const authoring = parseParameterizedPackJson(parsed);
9382
+ const authoring = parsePackSourceJson(parsed);
9383
9383
  if (!authoring.ok) {
9384
9384
  return packErr(
9385
9385
  makePackError("pack-malformed-pack", {
@@ -9623,7 +9623,7 @@ async function scanValidated(roots, opts = {}, capture) {
9623
9623
  ...opts.scriptablePack ?? {},
9624
9624
  ...capture === void 0 ? { metadataOnly: true } : {}
9625
9625
  };
9626
- const loaded = await loadParameterizedScriptablePack(sourcePath, loaderOptions);
9626
+ const loaded = await loadScriptablePack(sourcePath, loaderOptions);
9627
9627
  if (!loaded.ok) {
9628
9628
  const diagnostic = loaded.error.detail.diagnostic;
9629
9629
  return packErr(
@@ -9652,12 +9652,12 @@ async function scanValidated(roots, opts = {}, capture) {
9652
9652
  const packageCollision = registerPackage(
9653
9653
  PackageId.format(loaded.value.packageId),
9654
9654
  sourcePath,
9655
- "parameterized"
9655
+ "scriptable"
9656
9656
  );
9657
9657
  if (packageCollision !== void 0) return packErr(packageCollision);
9658
- const meta = projectParameterizedPackMeta(loaded.value, sourcePath);
9658
+ const meta = projectScriptablePackMeta(loaded.value, sourcePath);
9659
9659
  capture?.declarations.set(sourcePath, {
9660
- format: "pack.ts-parameterized",
9660
+ format: "pack.ts",
9661
9661
  sourcePath,
9662
9662
  sourceRevision: `sha256:${createHash("sha256").update(source).digest("hex")}`,
9663
9663
  value: meta,
@@ -9686,15 +9686,15 @@ async function scanValidated(roots, opts = {}, capture) {
9686
9686
  );
9687
9687
  }
9688
9688
  const kind = packageKind.get(parentId);
9689
- if (kind !== "parameterized" && kind !== "instance") {
9689
+ if (kind !== "scriptable" && kind !== "instance") {
9690
9690
  return packErr(
9691
9691
  makePackError("pack-malformed-pack", {
9692
9692
  path: instance.path,
9693
- reason: "pack-parent-not-parameterized",
9693
+ reason: "pack-parent-has-no-parameters",
9694
9694
  ajvErrors: [
9695
9695
  {
9696
9696
  instancePath: "/parent",
9697
- message: `parent ${instance.parent} is not a parameterized Pack`
9697
+ message: `parent ${instance.parent} is not a ScriptablePack source with parameters`
9698
9698
  }
9699
9699
  ]
9700
9700
  })
@@ -9764,7 +9764,7 @@ async function scanInventory(roots, opts = {}) {
9764
9764
  const declaration = declarations.get(sourcePath);
9765
9765
  if (declaration?.format !== "pack.json") continue;
9766
9766
  if (declaration.value.schemaVersion === "3.0.0") {
9767
- const parsed = parseParameterizedPackJson(declaration.value);
9767
+ const parsed = parsePackSourceJson(declaration.value);
9768
9768
  if (!parsed.ok) {
9769
9769
  return packErr(
9770
9770
  makePackError("pack-malformed-pack", {
@@ -9886,7 +9886,7 @@ function projectMeta(rawPath, cwd, base, importerPolicy, sourceDeclaration, sour
9886
9886
  };
9887
9887
  }
9888
9888
  function projectSource(path, cwd, base, importerPolicy, visibility, sourceDeclaration, declarations, sourceIdentityFor) {
9889
- if (sourceDeclaration.format === "pack.ts-parameterized") {
9889
+ if (sourceDeclaration.format === "pack.ts") {
9890
9890
  return { entries: [] };
9891
9891
  }
9892
9892
  if (sourceDeclaration.format === "meta.json") {
@@ -9912,7 +9912,7 @@ function projectSource(path, cwd, base, importerPolicy, visibility, sourceDeclar
9912
9912
  const parsed = sourceDeclaration.value;
9913
9913
  const sourcePath = catalogSourcePathFor(cwd, path, sourceIdentityFor);
9914
9914
  if (parsed.schemaVersion === "3.0.0") {
9915
- const authoring = parseParameterizedPackJson(parsed);
9915
+ const authoring = parsePackSourceJson(parsed);
9916
9916
  if (!authoring.ok) {
9917
9917
  return {
9918
9918
  entries: [],
@@ -10295,6 +10295,25 @@ function calculateCatalogDelta(previous, next, revision) {
10295
10295
  revisions: revision
10296
10296
  };
10297
10297
  }
10298
+ var STANDARD_ROOT_MODULES = /* @__PURE__ */ new Set([
10299
+ "forgeax::default-standard-pbr",
10300
+ "forgeax::pbr-skin",
10301
+ "forgeax_material::standard",
10302
+ "forgeax_material::pbr-skin",
10303
+ "forgeax::default-shadow-caster"
10304
+ ]);
10305
+ function isStandardRootModule(module) {
10306
+ return STANDARD_ROOT_MODULES.has(module);
10307
+ }
10308
+ function isStandardMaterialRecord(record2) {
10309
+ return record2.resolved.passes.some((pass) => isStandardRootModule(pass.program.module));
10310
+ }
10311
+ function materialLayerPlanIdentity(record2) {
10312
+ if (!isStandardMaterialRecord(record2)) {
10313
+ return void 0;
10314
+ }
10315
+ return deriveStandardLayerPlan(record2.resolved.parameters, record2.resolved.passes).identity;
10316
+ }
10298
10317
  function unique(values) {
10299
10318
  return [...new Set(values)].sort();
10300
10319
  }
@@ -10369,6 +10388,14 @@ function invalid(field, actual) {
10369
10388
  }
10370
10389
  });
10371
10390
  }
10391
+ function normalizeArtifactBytes(value) {
10392
+ if (Array.isArray(value)) {
10393
+ return value.every((byte) => Number.isInteger(byte) && byte >= 0 && byte <= 255) ? Uint8Array.from(value) : void 0;
10394
+ }
10395
+ if (!ArrayBuffer.isView(value)) return void 0;
10396
+ const view = value;
10397
+ return new Uint8Array(view.buffer, view.byteOffset, view.byteLength).slice();
10398
+ }
10372
10399
  var IDENTITY_FIELDS = [
10373
10400
  "materialContractDigest",
10374
10401
  "sourceRevision",
@@ -10425,6 +10452,12 @@ function validateMaterialCookReceipt(value, expected = {}) {
10425
10452
  if (derivedInterface.layoutIdentity !== identity.layoutIdentity) {
10426
10453
  return invalid("receipt.derivedInterface.layoutIdentity", derivedInterface.layoutIdentity);
10427
10454
  }
10455
+ if (derivedInterface.layerPlanIdentity !== void 0 && (typeof derivedInterface.layerPlanIdentity !== "string" || derivedInterface.layerPlanIdentity.length === 0)) {
10456
+ return invalid(
10457
+ "receipt.derivedInterface.layerPlanIdentity",
10458
+ derivedInterface.layerPlanIdentity
10459
+ );
10460
+ }
10428
10461
  for (const field of ["sourceClosure", "profile", "compilerVersion"]) {
10429
10462
  const fieldValue = candidate[field];
10430
10463
  if (field === "sourceClosure" && !Array.isArray(fieldValue) || field !== "sourceClosure" && typeof fieldValue !== "string") {
@@ -10450,7 +10483,10 @@ function validateMaterialCookReceipt(value, expected = {}) {
10450
10483
  profile: candidate.profile,
10451
10484
  compilerVersion: candidate.compilerVersion,
10452
10485
  identity,
10453
- derivedInterface: { layoutIdentity: derivedInterface.layoutIdentity }
10486
+ derivedInterface: {
10487
+ layoutIdentity: derivedInterface.layoutIdentity,
10488
+ ...derivedInterface.layerPlanIdentity === void 0 ? {} : { layerPlanIdentity: derivedInterface.layerPlanIdentity }
10489
+ }
10454
10490
  });
10455
10491
  }
10456
10492
  function validateCookedMaterialRecord(value) {
@@ -10465,6 +10501,33 @@ function validateCookedMaterialRecord(value) {
10465
10501
  return invalid("publicationGeneration", candidate.publicationGeneration);
10466
10502
  if (candidate.specializationKey !== void 0 && typeof candidate.specializationKey !== "string")
10467
10503
  return invalid("specializationKey");
10504
+ if (candidate.variantContext !== void 0) {
10505
+ if (candidate.variantContext === null || typeof candidate.variantContext !== "object")
10506
+ return invalid("variantContext");
10507
+ const context = candidate.variantContext;
10508
+ if (context.backend !== "webgpu" && context.backend !== "webgl2" && context.backend !== "wgpu-native" || context.capability !== "storage-buffer" && context.capability !== "uniform-fallback")
10509
+ return invalid("variantContext", candidate.variantContext);
10510
+ }
10511
+ if (candidate.variants !== void 0) {
10512
+ if (!Array.isArray(candidate.variants)) return invalid("variants");
10513
+ for (const [index, value2] of candidate.variants.entries()) {
10514
+ if (value2 === null || typeof value2 !== "object") return invalid(`variants[${index}]`);
10515
+ const variant = value2;
10516
+ const context = variant.context;
10517
+ if (context === null || typeof context !== "object")
10518
+ return invalid(`variants[${index}].context`);
10519
+ const contextRecord = context;
10520
+ if (contextRecord.backend !== "webgpu" && contextRecord.backend !== "webgl2" && contextRecord.backend !== "wgpu-native" || contextRecord.capability !== "storage-buffer" && contextRecord.capability !== "uniform-fallback")
10521
+ return invalid(`variants[${index}].context`, context);
10522
+ if (typeof variant.specializationKey !== "string" || variant.specializationKey.length === 0)
10523
+ return invalid(`variants[${index}].specializationKey`);
10524
+ if (variant.artifact === null || typeof variant.artifact !== "object")
10525
+ return invalid(`variants[${index}].artifact`);
10526
+ const variantArtifact = variant.artifact;
10527
+ if (typeof variantArtifact.mediaType !== "string" || typeof variantArtifact.path !== "string" || typeof variantArtifact.digest !== "string" || normalizeArtifactBytes(variantArtifact.bytes) === void 0)
10528
+ return invalid(`variants[${index}].artifact`);
10529
+ }
10530
+ }
10468
10531
  if (candidate.artifactDigest !== void 0 && typeof candidate.artifactDigest !== "string")
10469
10532
  return invalid("artifactDigest");
10470
10533
  if (candidate.sourceClosure !== void 0 && (!Array.isArray(candidate.sourceClosure) || candidate.sourceClosure.some((path) => typeof path !== "string")))
@@ -10493,6 +10556,26 @@ function validateCookedMaterialRecord(value) {
10493
10556
  artifactDigest: artifact.digest
10494
10557
  });
10495
10558
  if (!receiptResult.ok) return receiptResult;
10559
+ const resolved = candidate.resolved;
10560
+ if (!Array.isArray(resolved.passes)) return invalid("resolved.passes", resolved.passes);
10561
+ if (!Array.isArray(resolved.parameters))
10562
+ return invalid("resolved.parameters", resolved.parameters);
10563
+ if (resolved.values === null || typeof resolved.values !== "object" || Array.isArray(resolved.values))
10564
+ return invalid("resolved.values", resolved.values);
10565
+ let expectedLayerPlanIdentity;
10566
+ try {
10567
+ expectedLayerPlanIdentity = materialLayerPlanIdentity({
10568
+ resolved
10569
+ });
10570
+ } catch (error) {
10571
+ return invalid("resolved.layerPlanIdentity", error instanceof Error ? error.message : error);
10572
+ }
10573
+ if (expectedLayerPlanIdentity !== void 0 && receiptResult.value.derivedInterface.layerPlanIdentity !== expectedLayerPlanIdentity) {
10574
+ return invalid(
10575
+ "receipt.derivedInterface.layerPlanIdentity",
10576
+ receiptResult.value.derivedInterface.layerPlanIdentity
10577
+ );
10578
+ }
10496
10579
  if (candidate.artifactDigest !== void 0 && candidate.artifactDigest !== artifact.digest)
10497
10580
  return invalid("artifactDigest", candidate.artifactDigest);
10498
10581
  if (candidate.publicationGeneration !== void 0 && receiptResult.value.identity.cookGeneration !== candidate.publicationGeneration)
@@ -10501,8 +10584,21 @@ function validateCookedMaterialRecord(value) {
10501
10584
  ...candidate,
10502
10585
  artifact: {
10503
10586
  ...artifact,
10504
- bytes: ArrayBuffer.isView(artifact.bytes) ? Uint8Array.from(artifact.bytes) : Uint8Array.from(artifact.bytes)
10587
+ bytes: normalizeArtifactBytes(artifact.bytes)
10505
10588
  },
10589
+ ...Array.isArray(candidate.variants) ? {
10590
+ variants: candidate.variants.map((value2) => {
10591
+ const variant = value2;
10592
+ const variantArtifact = variant.artifact;
10593
+ return {
10594
+ ...variant,
10595
+ artifact: {
10596
+ ...variantArtifact,
10597
+ bytes: normalizeArtifactBytes(variantArtifact.bytes)
10598
+ }
10599
+ };
10600
+ })
10601
+ } : {},
10506
10602
  receipt: receiptResult.value
10507
10603
  };
10508
10604
  return ok(normalized);
@@ -10512,6 +10608,8 @@ function projectCookedMaterialRecord(record2) {
10512
10608
  resolved: record2.resolved,
10513
10609
  refs: record2.refs,
10514
10610
  artifact: record2.artifact,
10611
+ ...record2.variantContext === void 0 ? {} : { variantContext: record2.variantContext },
10612
+ ...record2.variants === void 0 ? {} : { variants: record2.variants },
10515
10613
  receipt: record2.receipt,
10516
10614
  schemaVersion: record2.schemaVersion
10517
10615
  };
@@ -10786,230 +10884,6 @@ function decodeMeshBinHeader(bytes, sourceKey2 = "<unknown mesh source>") {
10786
10884
  }
10787
10885
  };
10788
10886
  }
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
10887
  function isRecord3(value) {
11014
10888
  return value !== null && typeof value === "object" && !Array.isArray(value);
11015
10889
  }
@@ -11141,7 +11015,7 @@ function scanFailure(operation, cause) {
11141
11015
  const value = cause !== null && typeof cause === "object" ? cause : {};
11142
11016
  const detail = value.detail !== null && typeof value.detail === "object" ? value.detail : {};
11143
11017
  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-not-parameterized" ? reason : value.code === "pack-guid-collision" ? "pack-guid-collision" : "pack-parameter-invalid";
11018
+ 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
11019
  return makeError(
11146
11020
  code,
11147
11021
  typeof value.expected === "string" ? value.expected : "a valid Pack Source Index",
@@ -11313,7 +11187,7 @@ async function createSnapshot(options, operation) {
11313
11187
  const directAssets = [];
11314
11188
  for (const [sourcePath, declaration] of scanned.value.declarations) {
11315
11189
  const relativePath = relative(resolve(options.gameRoot), sourcePath).split(sep).join("/");
11316
- if (declaration.format === "pack.ts-parameterized") {
11190
+ if (declaration.format === "pack.ts") {
11317
11191
  subjects.set(packageKey(declaration.definition.packageId), {
11318
11192
  format: "source",
11319
11193
  packageId: declaration.definition.packageId,
@@ -11324,7 +11198,7 @@ async function createSnapshot(options, operation) {
11324
11198
  continue;
11325
11199
  }
11326
11200
  if (declaration.format !== "pack.json" || declaration.value.schemaVersion !== "3.0.0") continue;
11327
- const parsed = parseParameterizedPackJson(declaration.value);
11201
+ const parsed = parsePackSourceJson(declaration.value);
11328
11202
  if (!parsed.ok) return err(parsed.error);
11329
11203
  if (parsed.value.format === "direct") {
11330
11204
  const projected = projectDirectPackJson(parsed.value);
@@ -12037,7 +11911,7 @@ function revisionConflict(operation, path, actual) {
12037
11911
  function directJson(packageId2, assets) {
12038
11912
  return { schemaVersion: "3.0.0", packageId: PackageId.format(packageId2), assets };
12039
11913
  }
12040
- function parameterizedScaffold(packageId2, parameters) {
11914
+ function packSourceScaffold(packageId2, parameters) {
12041
11915
  const parameterSource = parameters === void 0 ? "" : "\n parameters: " + JSON.stringify(
12042
11916
  parameters.map((parameter) => jsonValue2(parameter)),
12043
11917
  null,
@@ -12125,13 +11999,13 @@ async function executeRaw(options, operation) {
12125
11999
  makeError(
12126
12000
  "pack-parameter-invalid",
12127
12001
  "direct create to contain assets only",
12128
- "use pack.ts for a parameterized source or create-instance for parent+values",
12002
+ "use pack.ts for a ScriptablePack source or create-instance for parent+values",
12129
12003
  { requestId: operation.requestId }
12130
12004
  )
12131
12005
  );
12132
12006
  }
12133
12007
  const assets = operation.initialAssets ?? {};
12134
- const parsed = parseParameterizedPackJson(directJson(identity.value, assets));
12008
+ const parsed = parsePackSourceJson(directJson(identity.value, assets));
12135
12009
  if (!parsed.ok) return err(parsed.error);
12136
12010
  if (parsed.value.format !== "direct") {
12137
12011
  return err(
@@ -12187,7 +12061,7 @@ async function executeRaw(options, operation) {
12187
12061
  }
12188
12062
  parameters = validated.value.parameters;
12189
12063
  }
12190
- source = parameterizedScaffold(identity.value, parameters);
12064
+ source = packSourceScaffold(identity.value, parameters);
12191
12065
  const serialized = parameters === void 0 ? void 0 : serializedParameters({
12192
12066
  schemaVersion: "2.0.0",
12193
12067
  packageId: identity.value,
@@ -12283,7 +12157,7 @@ async function executeRaw(options, operation) {
12283
12157
  )
12284
12158
  );
12285
12159
  }
12286
- const parsed = parseParameterizedPackJson(parsedValue);
12160
+ const parsed = parsePackSourceJson(parsedValue);
12287
12161
  if (!parsed.ok) return err(parsed.error);
12288
12162
  source = `${JSON.stringify(
12289
12163
  parsed.value.format === "direct" ? directJson(identity.value, parsed.value.assets) : {
@@ -12343,7 +12217,7 @@ async function executeRaw(options, operation) {
12343
12217
  makeError(
12344
12218
  "pack-parent-not-found",
12345
12219
  "a parent packageId for the new instance",
12346
- "pass parentPackageId or parent and point it at a parameterized source",
12220
+ "pass parentPackageId or parent and point it at a ScriptablePack source with parameters",
12347
12221
  { requestId: operation.requestId }
12348
12222
  )
12349
12223
  );
@@ -12366,7 +12240,7 @@ async function executeRaw(options, operation) {
12366
12240
  makeError(
12367
12241
  "pack-parent-not-found",
12368
12242
  "the parent packageId to exist in the current Source Index",
12369
- "inspect the Source Index and choose a parameterized parent",
12243
+ "inspect the Source Index and choose a ScriptablePack parent with parameters",
12370
12244
  { requestId: operation.requestId, parent: parentText }
12371
12245
  )
12372
12246
  );
@@ -12374,8 +12248,8 @@ async function executeRaw(options, operation) {
12374
12248
  if (parent.format === "source" && !("parameters" in parent.definition)) {
12375
12249
  return err(
12376
12250
  makeError(
12377
- "pack-parent-not-parameterized",
12378
- "a non-empty parameterized Pack source as the parent",
12251
+ "pack-parent-has-no-parameters",
12252
+ "a ScriptablePack source with a non-empty parameter list as the parent",
12379
12253
  "use asset-source.clone for a zero-parameter Pack",
12380
12254
  { requestId: operation.requestId, parent: parentText }
12381
12255
  )
@@ -12384,8 +12258,8 @@ async function executeRaw(options, operation) {
12384
12258
  if (parent.format === "direct") {
12385
12259
  return err(
12386
12260
  makeError(
12387
- "pack-parent-not-parameterized",
12388
- "a parameterized Pack source or instance as the parent",
12261
+ "pack-parent-has-no-parameters",
12262
+ "a ScriptablePack source or instance with parameters as the parent",
12389
12263
  "direct Packs cannot be instance parents",
12390
12264
  { requestId: operation.requestId, parent: parentText }
12391
12265
  )
@@ -12488,7 +12362,7 @@ async function executeRaw(options, operation) {
12488
12362
  )
12489
12363
  );
12490
12364
  }
12491
- const parsed = parseParameterizedPackJson(json);
12365
+ const parsed = parsePackSourceJson(json);
12492
12366
  if (!parsed.ok) return err(parsed.error);
12493
12367
  if (parsed.value.format !== "instance") {
12494
12368
  return err(
@@ -12591,20 +12465,242 @@ async function executeRaw(options, operation) {
12591
12465
  return err(
12592
12466
  makeError(
12593
12467
  "pack-parameter-invalid",
12594
- "a supported parameterized Pack operation",
12595
- "use one of PARAMETERIZED_PACK_OPERATION_IDS",
12468
+ "a supported Pack authoring operation",
12469
+ "use one of PACK_AUTHORING_OPERATION_IDS",
12596
12470
  { requestId: operation.requestId, operation: operation.operation }
12597
12471
  )
12598
12472
  );
12599
12473
  }
12600
- function createFileSystemParameterizedPackAuthoringPort(options) {
12474
+ function createFileSystemPackAuthoringPort(options) {
12601
12475
  return { execute: (operation) => executeRaw(options, operation) };
12602
12476
  }
12603
- function createFileSystemParameterizedPackAuthoringGateway(options) {
12604
- return createParameterizedPackAuthoringGateway(
12605
- createFileSystemParameterizedPackAuthoringPort(options)
12477
+ function createFileSystemPackAuthoringGateway(options) {
12478
+ return createPackAuthoringGateway(createFileSystemPackAuthoringPort(options));
12479
+ }
12480
+ function failure4(code, expected, hint, detail) {
12481
+ return { ok: false, error: { code, expected, hint, detail } };
12482
+ }
12483
+ function sorted(value) {
12484
+ if (value instanceof Uint8Array) return Buffer.from(value).toString("base64");
12485
+ if (Array.isArray(value)) return value.map(sorted);
12486
+ if (value !== null && typeof value === "object") {
12487
+ const output = {};
12488
+ for (const key of Object.keys(value).sort()) {
12489
+ output[key] = sorted(value[key]);
12490
+ }
12491
+ return output;
12492
+ }
12493
+ return value;
12494
+ }
12495
+ function packageUrl(base, packagePath) {
12496
+ const prefix = base === "/" ? "" : `/${base.replace(/^\/+|\/+$/g, "")}`;
12497
+ return `${prefix}/${packagePath.replace(/^\/+/, "")}`;
12498
+ }
12499
+ function safePath(path) {
12500
+ const normalized = path.replaceAll("\\", "/");
12501
+ return normalized.length > 0 && !normalized.startsWith("/") && !/^[A-Za-z]:\//.test(normalized) && !normalized.split("/").includes("..");
12502
+ }
12503
+ function digest(assets) {
12504
+ const pack = { schemaVersion: "2.0.0", kind: "internal-text-package", assets };
12505
+ const hash = createHash("sha256").update(
12506
+ JSON.stringify(
12507
+ sorted({
12508
+ ...pack,
12509
+ assets: pack.assets.map((asset) => ({
12510
+ ...asset,
12511
+ artifacts: Object.fromEntries(
12512
+ Object.entries(asset.artifacts).map(([key, artifact]) => [
12513
+ key,
12514
+ {
12515
+ mediaType: artifact.mediaType,
12516
+ ...artifact.assetCodec === void 0 ? {} : { assetCodec: artifact.assetCodec },
12517
+ byteLength: artifact.bytes.byteLength
12518
+ }
12519
+ ])
12520
+ )
12521
+ }))
12522
+ })
12523
+ )
12524
+ );
12525
+ for (const [key, artifact] of assets.flatMap(
12526
+ (asset) => Object.entries(asset.artifacts).map(
12527
+ ([localKey, body]) => [`${asset.guid}/${localKey}`, body]
12528
+ )
12529
+ ).sort(([left], [right]) => left.localeCompare(right))) {
12530
+ hash.update(key).update(artifact.bytes);
12531
+ }
12532
+ return `sha256:${hash.digest("hex")}`;
12533
+ }
12534
+ function packageDocument(assets, artifactPath) {
12535
+ return {
12536
+ schemaVersion: "2.0.0",
12537
+ kind: "internal-text-package",
12538
+ assets: assets.map((asset) => ({
12539
+ guid: asset.guid,
12540
+ kind: asset.kind,
12541
+ ...asset.name === void 0 ? {} : { name: asset.name },
12542
+ payload: asset.payload,
12543
+ refs: asset.refs,
12544
+ artifacts: Object.fromEntries(
12545
+ Object.entries(asset.artifacts).map(([key, artifact]) => [
12546
+ key,
12547
+ {
12548
+ path: artifactPath(asset.guid, key),
12549
+ mediaType: artifact.mediaType,
12550
+ ...artifact.assetCodec === void 0 ? {} : { assetCodec: artifact.assetCodec },
12551
+ contentEncoding: "identity",
12552
+ byteLength: artifact.bytes.byteLength,
12553
+ integrity: {
12554
+ algorithm: "sha256",
12555
+ digest: `sha256:${createHash("sha256").update(artifact.bytes).digest("hex")}`
12556
+ }
12557
+ }
12558
+ ])
12559
+ )
12560
+ }))
12561
+ };
12562
+ }
12563
+ function transportArtifacts(assets, artifactPath) {
12564
+ return assets.flatMap(
12565
+ (asset) => Object.entries(asset.artifacts).flatMap(([localKey, artifact]) => [
12566
+ {
12567
+ guid: asset.guid,
12568
+ localKey,
12569
+ path: artifactPath(asset.guid, localKey),
12570
+ mediaType: artifact.mediaType,
12571
+ ...artifact.assetCodec === void 0 ? {} : { assetCodec: artifact.assetCodec },
12572
+ bytes: artifact.bytes
12573
+ }
12574
+ ])
12606
12575
  );
12607
12576
  }
12577
+ async function finalizePackageProduct(product, policy) {
12578
+ if (product.sourceRevision.trim().length === 0) {
12579
+ return failure4(
12580
+ "missing-source-revision",
12581
+ "a non-empty source revision",
12582
+ "rebuild the inventory and provide the producer source revision",
12583
+ {}
12584
+ );
12585
+ }
12586
+ const seen = /* @__PURE__ */ new Set();
12587
+ for (const asset of product.assets) {
12588
+ const guid = asset.guid.toLowerCase();
12589
+ if (seen.has(guid)) {
12590
+ return failure4(
12591
+ "duplicate-guid",
12592
+ "one terminal product row per GUID",
12593
+ "repair the inventory or producer output before finalization",
12594
+ { guid }
12595
+ );
12596
+ }
12597
+ seen.add(guid);
12598
+ for (const [key, artifact] of Object.entries(asset.artifacts)) {
12599
+ if (!safePath(key) || !(artifact.bytes instanceof Uint8Array)) {
12600
+ return failure4(
12601
+ "invalid-artifact",
12602
+ "asset-local artifact keys and byte bodies",
12603
+ "repair the producer artifact before finalization",
12604
+ { guid, key }
12605
+ );
12606
+ }
12607
+ }
12608
+ }
12609
+ for (const guid of seen) {
12610
+ if (!product.receipts.some((receipt) => receipt.guid.toLowerCase() === guid)) {
12611
+ return failure4(
12612
+ "missing-receipt",
12613
+ "one receipt for every terminal product GUID",
12614
+ "preserve the producer receipt when handing the product to engine-pack",
12615
+ { guid }
12616
+ );
12617
+ }
12618
+ }
12619
+ const assets = [...product.assets].sort((left, right) => left.guid.localeCompare(right.guid));
12620
+ const document = packageDocument(assets, policy.artifactPath);
12621
+ const packageBytes = new TextEncoder().encode(JSON.stringify(sorted(document)));
12622
+ if (policy.sink !== void 0) {
12623
+ for (const asset of assets) {
12624
+ for (const [key, artifact] of Object.entries(asset.artifacts)) {
12625
+ const path = policy.artifactPath(asset.guid, key);
12626
+ if (!safePath(path)) {
12627
+ return failure4(
12628
+ "invalid-artifact",
12629
+ "package-relative artifact output paths",
12630
+ "repair the finalizer artifact path policy",
12631
+ { guid: asset.guid, key }
12632
+ );
12633
+ }
12634
+ await policy.sink(path, artifact.bytes);
12635
+ }
12636
+ }
12637
+ if (!safePath(policy.packagePath)) {
12638
+ return failure4(
12639
+ "invalid-artifact",
12640
+ "a package-relative package path",
12641
+ "repair the finalizer package path policy",
12642
+ { key: policy.packagePath }
12643
+ );
12644
+ }
12645
+ await policy.sink(policy.packagePath, packageBytes);
12646
+ }
12647
+ return {
12648
+ ok: true,
12649
+ value: {
12650
+ pack: document,
12651
+ packageUrl: packageUrl(policy.base, policy.packagePath),
12652
+ digest: digest(product.assets),
12653
+ receipts: product.receipts,
12654
+ diagnostics: product.diagnostics,
12655
+ sourceRevision: product.sourceRevision,
12656
+ ...product.sourceKey === void 0 ? {} : { sourceKey: product.sourceKey }
12657
+ }
12658
+ };
12659
+ }
12660
+ async function finalizePackageTransportSource(input, policy) {
12661
+ const sourceRevision = packageTransportRevision(input);
12662
+ const product = {
12663
+ assets: input.assets,
12664
+ receipts: input.receipts ?? input.assets.map((asset) => ({
12665
+ guid: asset.guid,
12666
+ origin: "sourceMeta",
12667
+ status: "succeeded",
12668
+ inputFingerprint: sourceRevision
12669
+ })),
12670
+ diagnostics: input.diagnostics ?? [],
12671
+ sourceRevision,
12672
+ ...input.sourceKey === void 0 ? {} : { sourceKey: input.sourceKey }
12673
+ };
12674
+ const finalized = await finalizePackageProduct(product, policy);
12675
+ if (!finalized.ok) throw finalized.error;
12676
+ return {
12677
+ pack: finalized.value.pack,
12678
+ packageUrl: finalized.value.packageUrl,
12679
+ artifacts: transportArtifacts(product.assets, policy.artifactPath),
12680
+ digest: finalized.value.digest,
12681
+ receipts: finalized.value.receipts,
12682
+ sourceRevision,
12683
+ semantic: JSON.stringify(sorted(finalized.value.pack))
12684
+ };
12685
+ }
12686
+ function revisionStable(value) {
12687
+ if (value instanceof Uint8Array) {
12688
+ return {
12689
+ byteLength: value.byteLength,
12690
+ digest: createHash("sha256").update(value).digest("hex")
12691
+ };
12692
+ }
12693
+ if (Array.isArray(value)) return value.map(revisionStable);
12694
+ if (value !== null && typeof value === "object") {
12695
+ return Object.fromEntries(
12696
+ Object.entries(value).sort(([left], [right]) => left.localeCompare(right)).map(([key, item]) => [key, revisionStable(item)])
12697
+ );
12698
+ }
12699
+ return value;
12700
+ }
12701
+ function packageTransportRevision(value) {
12702
+ return createHash("sha256").update(JSON.stringify(revisionStable(value))).digest("hex");
12703
+ }
12608
12704
  function parsePackV2(value) {
12609
12705
  if (!validatePackV2(value)) {
12610
12706
  return err({
@@ -12725,6 +12821,6 @@ function createRuntimePackPublication(input) {
12725
12821
  };
12726
12822
  }
12727
12823
 
12728
- export { AssetGuid, MESH_BIN_DIGEST_BYTES, MESH_BIN_HEADER_V4_BYTES, MESH_BIN_PROJECTION_VERSION, MESH_BIN_VERSION, PACK_PARAMETER_TYPES, PACK_SOURCE_KEY_RE, PARAMETERIZED_PACK_OPERATION_DESCRIPTORS, PARAMETERIZED_PACK_OPERATION_IDS, PackageId, SCRIPTABLE_PACK_ASSET_KINDS, STANDARD_SCRIPTABLE_PACK_SCAN_OPTIONS, buildCatalogProjection, buildOfflineAssetEvidence, calculateCatalogDelta, calculateTopologyDiff, catalogProjectionFor, catalogSourcePathFor, collectMaterialCookRefs, createFileSystemParameterizedPackAuthoringGateway, createFileSystemParameterizedPackAuthoringPort, createMaterialArtifactDigest, createParameterizedPackAuthoringGateway, createRuntimePackPublication, currentProjectionFor, decodeMeshBinHeader, definePack, definePackageId, diffTopology, finalizePackageProduct, finalizePackageTransportSource, findReservedAssetKindConflict, inventoryDigest, isParameterizedPack, isScriptablePackAssetKind, isValidAssetGuidString, isValidPackSourceKey, metaPathForGuid, packageTransportRevision, packageVerification, parsePackAuthoringJson, parsePackJson, parsePackV2, parseParameterizedPackJson, projectAssetRefs, projectCookedMaterialRecord, projectCookedPackageEntry, projectDirectPackJson, projectExternalCatalogEntries, projectPackageCatalog, projectParameterizedPackMeta, projectRuntimeCatalogRow, projectSceneEntityRefs, projectScriptablePackSceneComponents, resolveAssetSource, resolvePackInheritance, resolvePackParameterInheritance, resolvePackParameterValues, scanInventory, serializeCookedMaterialRecord, serializeMaterialCookReceipt, syncAuthorInventory, validateArtifactPath, validateAuthorInventory, validateCookedMaterialRecord, validateMaterialCookReceipt, validateMeta, validatePack, validatePackDefinition, validatePackV2, validateProducerContract, validateProducerOutputs, writeMeshBinHeader };
12824
+ 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
12825
  //# sourceMappingURL=build.mjs.map
12730
12826
  //# sourceMappingURL=build.mjs.map