rig-parts 2.70.0 → 2.71.0
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/cli.ts +4 -2
- package/docs/AUTHORING.md +2 -0
- package/docs/STABILITY.md +27 -7
- package/package.json +1 -1
- package/src/build.ts +25 -14
- package/src/depthsheets.ts +9 -2
- package/src/layers.ts +34 -6
- package/src/runstamp.ts +56 -8
- package/src/visibility.ts +16 -11
package/cli.ts
CHANGED
|
@@ -62,7 +62,7 @@ import { replacementTreeDigest } from './src/replacementrecord.ts';
|
|
|
62
62
|
import { type ComposeInput, composeStage, IMAGE_SEP, PLATE, PROVENANCES, refusePreviewLoopSeam, SCENE_CAMERA_REPORT_SPEC, SCENE_REPORT_FILE, SCENE_REPORT_SPEC, SCENE_SPEC } from './src/scene.ts';
|
|
63
63
|
import { buildSheet, defaultCaption, type Tile, tilesFrom } from './src/sheet.ts';
|
|
64
64
|
import { loadComparison, requiredProblems, structureLines } from './src/structure.ts';
|
|
65
|
-
import { type ArgvTable, assembleOutputFiles, BUILD_RUN_FILE, CHECK_RUN_FILE, clearComposeRun, clearRunRecord, clearRunStamp, readPackageIdentity, realWhereItExists, recordArgv, rigOutputFiles, RUN_STAMP_FILE, RUN_STAMP_SPEC, type RunStampFileEntry, writeRunRecord, writeRunStamp } from './src/runstamp.ts';
|
|
65
|
+
import { type ArgvTable, assembleOutputFiles, bindAssembleWrapperInputs, BUILD_RUN_FILE, CHECK_RUN_FILE, clearComposeRun, clearRunRecord, clearRunStamp, readPackageIdentity, realWhereItExists, recordArgv, rigOutputFiles, RUN_STAMP_FILE, RUN_STAMP_SPEC, type RunStampFileEntry, writeRunRecord, writeRunStamp } from './src/runstamp.ts';
|
|
66
66
|
import { authorLayerLine } from './src/tags.ts';
|
|
67
67
|
|
|
68
68
|
const EXIT_OK = 0;
|
|
@@ -2357,13 +2357,15 @@ function cmdAssemble(args: string[]): number {
|
|
|
2357
2357
|
clearRunStamp(out);
|
|
2358
2358
|
const pkg = readPackageIdentity(join(import.meta.dir, 'package.json'));
|
|
2359
2359
|
const startedAt = fixedClock ?? new Date().toISOString();
|
|
2360
|
+
let wrapperInputs: ReturnType<typeof bindAssembleWrapperInputs>;
|
|
2360
2361
|
const result = assembleStage(
|
|
2361
2362
|
{ source, full, head, config, ...(flags.has('--requirements') ? { requirements: flags.get('--requirements') as string } : {}), ...(seam === undefined ? {} : { seam: seam as SeamRule }), ...(project === undefined ? {} : { project: project as ProjectRule }), ...(alts.length === 0 ? {} : { alts }) },
|
|
2362
2363
|
{ partsJson: join(out, 'rig', 'parts.json'), partsDir: join(out, 'rig', 'parts'), recomposite: join(out, 'render', 'recomposite_rig.png'), errorMap: join(out, 'render', ERROR_MAP_FILE) },
|
|
2363
2364
|
console.log,
|
|
2365
|
+
(readings) => { wrapperInputs = bindAssembleWrapperInputs(readings); },
|
|
2364
2366
|
);
|
|
2365
2367
|
const finishedAt = fixedClock ?? new Date().toISOString();
|
|
2366
|
-
writeRunStamp({ pkg, command: 'assemble', startedAt, finishedAt, outDir: out, configPath: config, inputs: { cwd: process.cwd(), source, full, head }, outputPaths: assembleOutputFiles(out, result) });
|
|
2368
|
+
writeRunStamp({ pkg, command: 'assemble', startedAt, finishedAt, outDir: out, configPath: config, inputs: { cwd: process.cwd(), source, full, head }, wrapperInputs, outputPaths: assembleOutputFiles(out, result) });
|
|
2367
2369
|
return EXIT_OK;
|
|
2368
2370
|
} catch (err) {
|
|
2369
2371
|
if (staged !== null) {
|
package/docs/AUTHORING.md
CHANGED
|
@@ -5890,6 +5890,8 @@ row in this page's `rule` and `line` tables; the selftest holds that (`TY16`).
|
|
|
5890
5890
|
| <a id="LAYERS_EXPORT_DIR_EMPTY"></a>`LAYERS_EXPORT_DIR_EMPTY` | `layers --export <dir>` was given a file, or a directory that is not empty (issue #359): a file left there could be read in place of the one written | a new directory, or empty it |
|
|
5891
5891
|
| <a id="LAYERS_EXPORT_ROUND_TRIP"></a>`LAYERS_EXPORT_ROUND_TRIP` | the export, read back, differs from the input's reading (the detail names the first difference) — an exporter bug, not an input problem | report it with the input named |
|
|
5892
5892
|
| <a id="ASSEMBLE_SOURCE_PRESENT"></a><a id="ASSEMBLE_SOURCE_DECODES"></a>`ASSEMBLE_SOURCE_PRESENT`, `ASSEMBLE_SOURCE_DECODES` | the painting is missing or not a PNG | `--source` |
|
|
5893
|
+
| <a id="ASSEMBLE_WRAPPER_PNG_CONFLICT"></a>`ASSEMBLE_WRAPPER_PNG_CONFLICT` | standalone `assemble` decoded PNG bytes with two different SHA-256 digests for the same wrapper role (`full` or `head`) and manifest-relative path | keep the PNG bytes stable throughout the run, then re-run `assemble` |
|
|
5894
|
+
| <a id="ASSEMBLE_WRAPPER_PNG_PATH"></a>`ASSEMBLE_WRAPPER_PNG_PATH` | standalone `assemble` cannot record the selected PNG as a canonical slash-delimited path within its wrapper manifest's directory | place the PNG within that directory and use a relative path free of drive prefixes, backslashes and NUL characters |
|
|
5893
5895
|
| <a id="ASSEMBLE_GROUND_PLAIN"></a>`ASSEMBLE_GROUND_PLAIN` | WARN only, never a refusal (issue #996): under project: visible, where paintingEdges reads the ground, with `assemble.ground` absent or `plain`, more than 2 % of the painting's border ring is not one colour (the ring is `SILHOUETTE_BORDER` px wide; a pixel counts when it differs from the ring's median by more than `SILHOUETTE_LIMIT`). Two causes: the ground is not plain, or the figure crosses the border | if it is the ground, declare `assemble.ground: busy`; if the figure crosses the border, leave the ground as it is (the WARN never changes output) |
|
|
5894
5896
|
| <a id="SHEET_SOURCE_PRESENT"></a><a id="SHEET_PNG_PRESENT"></a>`SHEET_SOURCE_PRESENT`, `SHEET_PNG_PRESENT` | `sheet`'s painting, or a part PNG a `parts.json` lists, is missing | `--source`, `--layers` |
|
|
5895
5897
|
|
package/docs/STABILITY.md
CHANGED
|
@@ -1287,7 +1287,7 @@ execution in historical evidence is inferred from a current export.
|
|
|
1287
1287
|
| keyed scene camera | `compose` | optional `camera` in `spine-parts-scene/1` (issue #1596). A camera scene writes `spine-parts-scene-report/2` at the existing `scene.json` path with its keyed camera, sampled coverage and framing verdict, and packed model SHA-256. Scenes without a camera write report /1. Both report specs include `scene_driven` on new writes. The camera path uses Core animation easing and the posed backdrop at each sampled frame. Rig, motion and stock check outputs retain their existing semantics. The compose input receipt stays `rig-compose-run/1`. See [Keyed scene camera](AUTHORING.md#keyed-scene-camera-issue-1596) |
|
|
1288
1288
|
| physics clips and scene repeats | `compose` | Issue #1615 adds `characters[].with_idle` and top-level `repeats` to `spine-parts-scene/1`. Each physics-only side clip requires literal `false` at any character scale or a safe integer count of at least 1 at scale 1. Numeric declarations fold whole periods into `idle` with exact duration equality. Both values retain `<id>:<clip>` subject to the character's scale checks, and the character report row echoes `with_idle` when declared. A scene repeat count is a safe integer of at least 2 on an authored take. Its duration remains the whole take length. Its tracks, deforms and camera keys use the exact duration divided by the count as their period. Repeated camera keys are expanded in report /2, with coverage on the full take clock and per-frame figure measurements. See [Physics clips and scene repeats](AUTHORING.md#physics-clips-and-scene-repeats-issue-1615) |
|
|
1289
1289
|
| `idle.png`, `idle-indexed.png`, `idle.gif` | `loop`, `build --loop` | APNG and GIF encodings of the rendered idle |
|
|
1290
|
-
| `run.json` | `rig`, `assemble` | spec `rig-run/1` (issue #1165, additive): `spec`, `package` (`name`, `version`), `command` (`"rig"` or `"assemble"`), `started_at` and `finished_at` (UTC ISO-8601 millisecond timestamps ending in `Z`, read in the CLI layer), `config` (`path` relative to `--out`, `sha256` of the config file on disk), `parts_input` on standalone `rig` (`path`, `sha256`, issue #1636), `inputs` on `assemble` (issues #1316, #1554,
|
|
1290
|
+
| `run.json` | `rig`, `assemble` | spec `rig-run/1` (issue #1165, additive): `spec`, `package` (`name`, `version`), `command` (`"rig"` or `"assemble"`), `started_at` and `finished_at` (UTC ISO-8601 millisecond timestamps ending in `Z`, read in the CLI layer), `config` (`path` relative to `--out`, `sha256` of the config file on disk), `parts_input` on standalone `rig` (`path`, `sha256`, issue #1636), `inputs` on `assemble` (issues #1316, #1554), `wrapper_pngs` on standalone `assemble` with a wrapper (issue #1645), and `outputs` (`path` relative to `--out`, `sha256` of each written output file on disk, sorted by `path` in code-unit order and excluding `run.json` itself). See the [run stamp contract](#run-stamp-runjson-spec-rig-run1) for the input bindings. The stamp is written only after the command's gate is green. |
|
|
1291
1291
|
| `check-run.json` | `check` | spec `rig-run/2`. Fixed keys in order are `spec`, `package`, `command`, `started_at`, `finished_at`, optional `parts_input` (`path`, `sha256`, issue #1636), `outputs` and `argv`. See the [run record contract](#run-record-check-runjson-and-build-runjson-spec-rig-run2). |
|
|
1292
1292
|
| the difference inventory (`--out`) | `diff-components` | spec `rig-parts-diff-components/1` by default (issue #1005: `stack`, `painting`, `definition`, `error_px`, `uncovered_error_px`, `components` — each `id`, `px`, `box`, `coverage`, `uncovered_px`, `borders` — and `below_floor`, byte-identical to 2.38.1), and spec `rig-parts-diff-components/2` under `--owners` (issue #1291: adds `owners` — each `{part, px}`, the topmost `parts.json` part above `COVERED_ALPHA` per covered pixel, back to front — before `borders` on every component); `--verify` verifies both `/1` and `/2` reports (with `--owners`, `/2` is required), while a `/1`-only reader (`readDiffComponents(text, input, [DIFF_COMPONENTS_SPEC])`) refuses `/2` by name |
|
|
1293
1293
|
| the draft comparison (`--out`) | `diff-drafts` | spec `rig-parts-draft-diff/1` (issue #1369), a stable contract as of 2.45.0: fixed keys in order `spec`, `left` and `right` (each `parts_sha256`, `part_count`, `composite_sha256`), `canvas` (`width`, `height`), `order` (`"same"` or `"changed"`), `parts` (one entry per part name in the union of both sides, sorted by `name` in code-unit order: `name`, `status`, then `left` and `right` on the sides that hold the part, each `sha256`, `box`, `index`, then `pixels_equal` and `pixels` on `changed` only), `composite` and `summary`; no clock and no file paths. The command records no threshold and judges nothing; it exits 0 whenever the report is written. [Draft-to-draft assemble comparison](AUTHORING.md#draft-to-draft-assemble-comparison-issue-1369) defines each field. |
|
|
@@ -1643,14 +1643,15 @@ additive): one `{ "role", "path", "sha256" }` entry (keys in that order) for eac
|
|
|
1643
1643
|
`--source`, `--full` and `--head` that was given, in the fixed order `source`, `full`,
|
|
1644
1644
|
`head` (an input not given is absent from the list, never `null` or guessed), with
|
|
1645
1645
|
`/`-separated `path` relative to `--out` by the `rig-run/2` link rule (naming
|
|
1646
|
-
`<dir>/layers.json` when the input is a directory, issue #1554)
|
|
1647
|
-
`
|
|
1646
|
+
`<dir>/layers.json` when the input is a directory, issue #1554). For wrapper `full`
|
|
1647
|
+
and `head` entries, `sha256` hashes the exact manifest bytes consumed by assemble.
|
|
1648
|
+
The existing paths and PSD file bindings are preserved. Standalone `rig` writes
|
|
1648
1649
|
`parts_input` immediately after `config` (issue #1636), with `path` and `sha256`
|
|
1649
1650
|
in that order. The directory named by `--parts` is rebased relative to `--out`
|
|
1650
1651
|
by the same realpath rule as `config.path`. A directory that coincides with
|
|
1651
1652
|
`--out` is recorded as `.`. The digest follows the [parts input snapshot](#parts-input-snapshot)
|
|
1652
|
-
contract. The config,
|
|
1653
|
-
after writing. A refused run writes no `run.json`. By default, `started_at` and
|
|
1653
|
+
contract. The config, source, PSD input and output hashes use the file bytes on
|
|
1654
|
+
disk after writing. A refused run writes no `run.json`. By default, `started_at` and
|
|
1654
1655
|
`finished_at` record wall-clock
|
|
1655
1656
|
time read in `cli.ts` (`src/` remains pure). With that default, `run.json` is outside
|
|
1656
1657
|
the byte-for-byte
|
|
@@ -1658,6 +1659,25 @@ determinism comparisons (`RG03`, `RG19`, `AS07`); for the same input at the same
|
|
|
1658
1659
|
receipt-relative input layout, two `run.json` files differ only in `started_at` and
|
|
1659
1660
|
`finished_at`.
|
|
1660
1661
|
|
|
1662
|
+
Standalone `assemble` adds the optional top-level `wrapper_pngs` after `inputs`
|
|
1663
|
+
and before `outputs` whenever it uses a wrapper (issue #1645). Each row is
|
|
1664
|
+
`{ "role", "path", "sha256" }`, in that key order. The role is `full` or `head`
|
|
1665
|
+
and identifies the corresponding wrapper manifest. `path` is the canonical,
|
|
1666
|
+
slash-separated path relative to that manifest's directory. It names the PNG
|
|
1667
|
+
selected for decoding, including a fallback when used. `sha256` is the lowercase
|
|
1668
|
+
hex SHA-256 digest of the exact PNG file bytes passed to the decoder. An edit to a PNG
|
|
1669
|
+
at the same path mid-run leaves the recorded digest bound to the bytes consumed.
|
|
1670
|
+
|
|
1671
|
+
Rows cover decoded drawn and hidden layer PNGs and decoded `depth_filename`
|
|
1672
|
+
PNGs when depth is active. Omitting `--head` yields only `full` rows when the
|
|
1673
|
+
full input is a wrapper. Rows sort `full` before `head`, then by `path` in
|
|
1674
|
+
UTF-16 code-unit order within each role. Repeated reads with the same role, path,
|
|
1675
|
+
and digest collapse to one row. Distinct digests for the same role and path
|
|
1676
|
+
refuse the run as `ASSEMBLE_WRAPPER_PNG_CONFLICT`. A selected path that cannot be
|
|
1677
|
+
represented in the required form refuses the run as `ASSEMBLE_WRAPPER_PNG_PATH`.
|
|
1678
|
+
An older wrapper stamp without `wrapper_pngs` leaves its PNGs unbound. An
|
|
1679
|
+
all-PSD run omits `wrapper_pngs`.
|
|
1680
|
+
|
|
1661
1681
|
Set `SOURCE_DATE_EPOCH` to opt into a fixed clock: both timestamps equal that
|
|
1662
1682
|
instant in UTC ISO format, without adding a stamp field. The value must match
|
|
1663
1683
|
`^(0|[1-9][0-9]*)$` and be at most 253402300799 seconds
|
|
@@ -1677,8 +1697,8 @@ neither hashed nor listed. Before the stage starts, the command removes an earli
|
|
|
1677
1697
|
`package.json` without a non-empty `name` and `version` refuses `RUN_STAMP_PACKAGE`
|
|
1678
1698
|
and writes no stamp. `build` and the in-process stages write no `run.json`.
|
|
1679
1699
|
|
|
1680
|
-
`
|
|
1681
|
-
|
|
1700
|
+
The optional `parts_input` and `wrapper_pngs` are additive to `rig-run/1`.
|
|
1701
|
+
Older stamps may omit them.
|
|
1682
1702
|
|
|
1683
1703
|
### Run record (`check-run.json` and `build-run.json`, spec `rig-run/2`)
|
|
1684
1704
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rig-parts",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.71.0",
|
|
4
4
|
"description": "AI-authored 2D character parts from one anime painting and its See-through layer decomposition: measured parts, weighted-mesh rig specs, verified through rig-c before anything is written. A CLI for agents that cannot see the image.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
package/src/build.ts
CHANGED
|
@@ -112,7 +112,7 @@ import { CONTROL_SUFFIX, withAnimations } from './motion.ts';
|
|
|
112
112
|
import type { PaletteError } from './palette.ts';
|
|
113
113
|
import { PartVisibility } from './partvisibility.ts';
|
|
114
114
|
import { readRunVisibility } from './visibility.ts';
|
|
115
|
-
import { type LayerSet, readLayers } from './layers.ts';
|
|
115
|
+
import { type LayerSet, readLayers, type WrapperReadings } from './layers.ts';
|
|
116
116
|
import { placeBoneEntriesForSkeleton, poseBoneEntriesForDrawn, REGISTER_OFFSET_BAR, REGISTER_SCALE_BAR, registeredWithinBar, registerSkeleton, SKELETON_LIMB_BONES, skeletonDrawnLength, skeletonLimbJoints } from './limbs.ts';
|
|
117
117
|
import { type AlternatePartsRecord, PAINTING_IN_RIG_FILE, FRONT_SUFFIX, type OccluderPlateRecord, type PartRecord, partImageReference, depthImageReference, readParts, readPartsManifest, type RecompositeRecord, type SingleRunPad, tagOf, writeParts } from './parts.ts';
|
|
118
118
|
import { encodePngBytes, readPng, writePng } from './raster/png.ts';
|
|
@@ -149,26 +149,33 @@ export function readSource(path: string): Raster {
|
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
+
export type AssembleWrapperReadings = Record<'full' | 'head', WrapperReadings>;
|
|
153
|
+
|
|
152
154
|
/**
|
|
153
155
|
* Read both runs, collecting the refusals of both before throwing. With no
|
|
154
156
|
* head run (`head` null, issue #359) the full run is read once and stands for
|
|
155
157
|
* both, and `single` says so: the stage then holds it to `checkSingleRun`.
|
|
156
158
|
*/
|
|
157
|
-
export function readRuns(full: string, head: string | null, recordVisibility = false): {
|
|
159
|
+
export function readRuns(full: string, head: string | null, recordVisibility = false, wrapperReadings?: AssembleWrapperReadings): {
|
|
158
160
|
full: LayerSet; head: LayerSet; single: boolean; visibility?: PartVisibility;
|
|
159
161
|
} {
|
|
160
162
|
const problems: Problem[] = [];
|
|
161
163
|
let recorded: ReturnType<typeof readRunVisibility>;
|
|
162
|
-
const one = (path: string, verify
|
|
164
|
+
const one = (path: string, verify: boolean, readings?: WrapperReadings): LayerSet | null => {
|
|
163
165
|
try {
|
|
164
166
|
if (verify && !/\.psd$/i.test(path) && existsSync(path)) {
|
|
165
|
-
const
|
|
167
|
+
const isDirectory = statSync(path).isDirectory();
|
|
168
|
+
const wrapperDir = isDirectory ? path : basename(path) === 'layers.json' ? dirname(path) : undefined;
|
|
166
169
|
if (wrapperDir !== undefined) {
|
|
167
|
-
recorded = readRunVisibility(wrapperDir);
|
|
168
|
-
if (recorded !== undefined)
|
|
170
|
+
recorded = readRunVisibility(wrapperDir, readings);
|
|
171
|
+
if (recorded !== undefined) {
|
|
172
|
+
// Visibility takes the wrapper directory even when the CLI names its manifest.
|
|
173
|
+
if (readings?.manifest !== undefined) readings.manifest.givenAsDirectory = isDirectory;
|
|
174
|
+
return recorded.set;
|
|
175
|
+
}
|
|
169
176
|
}
|
|
170
177
|
}
|
|
171
|
-
return readLayers(path);
|
|
178
|
+
return readLayers(path, undefined, readings);
|
|
172
179
|
} catch (err) {
|
|
173
180
|
if (err instanceof PartsError) {
|
|
174
181
|
problems.push(...err.problems);
|
|
@@ -177,8 +184,8 @@ export function readRuns(full: string, head: string | null, recordVisibility = f
|
|
|
177
184
|
throw err;
|
|
178
185
|
}
|
|
179
186
|
};
|
|
180
|
-
const f = one(full, recordVisibility);
|
|
181
|
-
const h = head === null ? f : one(head);
|
|
187
|
+
const f = one(full, recordVisibility, wrapperReadings?.full);
|
|
188
|
+
const h = head === null ? f : one(head, false, wrapperReadings?.head);
|
|
182
189
|
if (problems.length > 0) throw new PartsError(problems);
|
|
183
190
|
const runs = { full: f as LayerSet, head: h as LayerSet, single: head === null };
|
|
184
191
|
if (recorded === undefined) return runs;
|
|
@@ -538,12 +545,12 @@ export function frontOrdered<T extends { record: { name: string } }>(items: read
|
|
|
538
545
|
|
|
539
546
|
/** Bind the pure owner reading to the exact stage inputs. */
|
|
540
547
|
function sourceCoverSet(result: AssembleResult, set: string | null, painting: string,
|
|
541
|
-
runs: ReturnType<typeof readRuns
|
|
548
|
+
runs: ReturnType<typeof readRuns>, wrapperReadings?: AssembleWrapperReadings): SourceCoverSet {
|
|
542
549
|
const inputs: SourceCoverSet['inputs'] = [];
|
|
543
550
|
for (const run of (runs.single ? ['full'] : ['full', 'head']) as Array<'full' | 'head'>) {
|
|
544
551
|
const layers = runs[run];
|
|
545
552
|
inputs.push({ run, file: basename(layers.source),
|
|
546
|
-
sha256: createHash('sha256').update(readFileSync(layers.source)).digest('hex'),
|
|
553
|
+
sha256: wrapperReadings?.[run].manifest?.sha256 ?? createHash('sha256').update(readFileSync(layers.source)).digest('hex'),
|
|
547
554
|
layers: layers.layers.map(layer => ({ layer: layer.name,
|
|
548
555
|
image: layer.file === null ? null : relative(dirname(layers.source), layer.file).split(sep).join('/') })) });
|
|
549
556
|
}
|
|
@@ -554,7 +561,9 @@ function sourceCoverSet(result: AssembleResult, set: string | null, painting: st
|
|
|
554
561
|
}
|
|
555
562
|
|
|
556
563
|
/** Read, assemble, and write only after every refusal has had its chance. Throws a PartsError on a refusal, having written nothing. */
|
|
557
|
-
export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs, log: Log
|
|
564
|
+
export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs, log: Log,
|
|
565
|
+
onWrapperReadings?: (readings: AssembleWrapperReadings) => void,
|
|
566
|
+
): AssembleResult {
|
|
558
567
|
// A --requirements file that reaches assembly must be the one config.requirements
|
|
559
568
|
// names (#1418), so the assembly reading sees what assemble read.
|
|
560
569
|
const requirementsFile = input.requirements === undefined ? null : readRequirements(input.requirements);
|
|
@@ -570,7 +579,8 @@ export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs,
|
|
|
570
579
|
const { seam, project } = effectiveAssemblyRules(cfg.assemble, input);
|
|
571
580
|
const { requirements, effectiveSetup } = resolveAssemblyRequirements(input, cfg, project, requirementsFile);
|
|
572
581
|
const src = readSource(input.source);
|
|
573
|
-
const
|
|
582
|
+
const wrapperReadings = onWrapperReadings === undefined ? undefined : { full: { pngs: [] }, head: { pngs: [] } };
|
|
583
|
+
const read = readRuns(input.full, input.head, true, wrapperReadings);
|
|
574
584
|
// Issue #946: every declared receipt is held to its file, and under `required` every edited image needs one, before anything is assembled.
|
|
575
585
|
const receipts = readEditorReceipts(cfg.assemble.editor_receipts, input.config);
|
|
576
586
|
const editedParts = readEditedParts(cfg.assemble.edited_parts, input.config, cfg.assemble.plan ?? []);
|
|
@@ -603,7 +613,7 @@ export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs,
|
|
|
603
613
|
if (boundPlates.length > 0) result.parts.occluder_plates = boundPlates;
|
|
604
614
|
}
|
|
605
615
|
|
|
606
|
-
const sourceCoverSets = [sourceCoverSet(result, null, input.source, read)];
|
|
616
|
+
const sourceCoverSets = [sourceCoverSet(result, null, input.source, read, wrapperReadings)];
|
|
607
617
|
|
|
608
618
|
// Issue #454: alternate painting sets, assembled before any file is written.
|
|
609
619
|
const configDir = dirname(resolve(input.config));
|
|
@@ -1170,6 +1180,7 @@ export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs,
|
|
|
1170
1180
|
}
|
|
1171
1181
|
}
|
|
1172
1182
|
|
|
1183
|
+
if (wrapperReadings !== undefined) onWrapperReadings?.(wrapperReadings);
|
|
1173
1184
|
// Emit only after green: every refusal above has already thrown.
|
|
1174
1185
|
if (input.resetBuildOutput === true) resetBuildOutput(dirname(outs.partsJson));
|
|
1175
1186
|
makeOutDir(outs.partsDir);
|
package/src/depthsheets.ts
CHANGED
|
@@ -39,7 +39,12 @@ export interface DepthConfig { zScale?: number; full?: DepthRunConfig; head?: De
|
|
|
39
39
|
/** Explicit caller context; never inferred from a filename or sheet presence. */
|
|
40
40
|
export interface DepthBinding { config: DepthConfig; run: 'full' | 'head'; base: string }
|
|
41
41
|
/** Legacy metadata retained without file I/O or value validation until opt-in. */
|
|
42
|
-
export interface DeferredDepthSource {
|
|
42
|
+
export interface DeferredDepthSource {
|
|
43
|
+
filename: unknown;
|
|
44
|
+
base: string;
|
|
45
|
+
/** Bound to the original wrapper's receipt role, even if the layer is transformed. */
|
|
46
|
+
recordDecode?: (path: string, sha256: string) => void;
|
|
47
|
+
}
|
|
43
48
|
export interface DepthSource {
|
|
44
49
|
from: string;
|
|
45
50
|
image: string;
|
|
@@ -173,7 +178,9 @@ export function registerDepthRun(set: LayerSet, run: 'full' | 'head', cfg: Depth
|
|
|
173
178
|
const paths = [join(hint.base, file), join(hint.base, 'parts', `${layer.name}_depth.png`)];
|
|
174
179
|
const found = paths.filter(p => existsSync(p));
|
|
175
180
|
if (found.length === 2 && !readFileSync(found[0]).equals(readFileSync(found[1]))) throw new PartsError([{ code: 'DEPTH_SHEET_UNAMBIGUOUS', object: from, detail: `${paths.join(' and ')} differ; keep one source or identical bytes` }]);
|
|
176
|
-
|
|
181
|
+
const selected = found[0] ?? paths[0];
|
|
182
|
+
sheet = readSourceDepth(selected, layer.pixels, layer.depth);
|
|
183
|
+
hint.recordDecode?.(selected, sheet.sha256);
|
|
177
184
|
}
|
|
178
185
|
if (sheet !== undefined && supplied !== undefined) throw new PartsError([{ code: 'DEPTH_SOURCE_AMBIGUOUS', object: from, detail: 'has both depth_filename and a user declaration; the writer file is authoritative — remove the unused fallback for this layer' }]);
|
|
179
186
|
let near: DepthNear = sheet?.near ?? SEETHROUGH_DEPTH_NEAR, zScale = sheet?.zScale ?? cfg?.zScale;
|
package/src/layers.ts
CHANGED
|
@@ -33,6 +33,7 @@ import type { TakenLayerSource } from './takesource.ts';
|
|
|
33
33
|
* role, and its place in the draw order is read like any other layer's.
|
|
34
34
|
*/
|
|
35
35
|
import { bindDepthRun, type DepthBinding, type DeferredDepthSource, type SourceDepthSheet } from './depthsheets.ts';
|
|
36
|
+
import { createHash } from 'node:crypto';
|
|
36
37
|
import { existsSync, mkdirSync, readdirSync, readFileSync, statSync, writeFileSync } from 'node:fs';
|
|
37
38
|
import { basename, dirname, join } from 'node:path';
|
|
38
39
|
import { initializeCanvas, type Layer as PsdLayer, readPsd, writePsd } from 'ag-psd';
|
|
@@ -199,6 +200,18 @@ const MANIFEST_REQUIRED = ['layers', 'width', 'height'] as const;
|
|
|
199
200
|
const LAYER_KEYS = ['name', 'filename', 'left', 'top', 'right', 'bottom', 'depth_median', 'depth_filename'] as const;
|
|
200
201
|
const LAYER_REQUIRED = ['name', 'filename', 'left', 'top', 'right', 'bottom', 'depth_median'] as const;
|
|
201
202
|
|
|
203
|
+
export interface WrapperManifestReading {
|
|
204
|
+
path: string;
|
|
205
|
+
sha256: string;
|
|
206
|
+
givenAsDirectory: boolean;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/** Optional capture of consumed files for a primary assemble input. Paths retain their reader spelling. */
|
|
210
|
+
export interface WrapperReadings {
|
|
211
|
+
manifest?: WrapperManifestReading;
|
|
212
|
+
pngs: Array<{ path: string; sha256: string }>;
|
|
213
|
+
}
|
|
214
|
+
|
|
202
215
|
/**
|
|
203
216
|
* What the wrapper form's `depth_median` may be, as a refusal quotes it. A
|
|
204
217
|
* See-through run writes a number; an input with no depth — a PSD exported by
|
|
@@ -227,10 +240,15 @@ const DEPTH_RULE = 'a finite number (See-through\'s depth, larger = further back
|
|
|
227
240
|
export function readWrapperLayers(
|
|
228
241
|
path: string, binding?: DepthBinding,
|
|
229
242
|
sealedFiles?: ReadonlyMap<string, Buffer>,
|
|
243
|
+
readings?: WrapperReadings,
|
|
230
244
|
): LayerSet {
|
|
231
245
|
const bytesOf = (file: string): Buffer => sealedFiles?.get(file) ?? readFileSync(file);
|
|
232
|
-
const
|
|
246
|
+
const givenAsDirectory = existsSync(path) && statSync(path).isDirectory();
|
|
247
|
+
const manifestPath = givenAsDirectory ? join(path, 'layers.json') : path;
|
|
233
248
|
const dir = dirname(manifestPath);
|
|
249
|
+
const recordDecode = readings === undefined ? undefined : (file: string, sha256: string): void => {
|
|
250
|
+
readings.pngs.push({ path: file, sha256 });
|
|
251
|
+
};
|
|
234
252
|
const problems: Problem[] = [];
|
|
235
253
|
const refuse = (code: string, object: string, detail: string): void => {
|
|
236
254
|
problems.push({ code, object, detail });
|
|
@@ -241,7 +259,11 @@ export function readWrapperLayers(
|
|
|
241
259
|
}
|
|
242
260
|
let manifest: unknown;
|
|
243
261
|
try {
|
|
244
|
-
|
|
262
|
+
const bytes = bytesOf(manifestPath);
|
|
263
|
+
manifest = JSON.parse(bytes.toString('utf8'));
|
|
264
|
+
if (readings !== undefined) {
|
|
265
|
+
readings.manifest = { path: manifestPath, sha256: createHash('sha256').update(bytes).digest('hex'), givenAsDirectory };
|
|
266
|
+
}
|
|
245
267
|
} catch (err) {
|
|
246
268
|
refuse('LAYERS_MANIFEST_IS_JSON', manifestPath, `does not parse as JSON: ${(err as Error).message}`);
|
|
247
269
|
refuseIfAny(problems);
|
|
@@ -371,6 +393,7 @@ export function readWrapperLayers(
|
|
|
371
393
|
refuse('LAYERS_PNG_DECODES', `layer "${name}"`, (err as Error).message);
|
|
372
394
|
return;
|
|
373
395
|
}
|
|
396
|
+
recordDecode?.(present[0], createHash('sha256').update(bytes[0]).digest('hex'));
|
|
374
397
|
if (pixels.width !== right - left || pixels.height !== bottom - top) {
|
|
375
398
|
refuse(
|
|
376
399
|
'LAYERS_PNG_MATCHES_BBOX',
|
|
@@ -379,8 +402,13 @@ export function readWrapperLayers(
|
|
|
379
402
|
);
|
|
380
403
|
return;
|
|
381
404
|
}
|
|
405
|
+
const depthHint: DeferredDepthSource | undefined = !('depth_filename' in e) ? undefined : {
|
|
406
|
+
filename: e.depth_filename,
|
|
407
|
+
base: dir,
|
|
408
|
+
...(recordDecode === undefined ? {} : { recordDecode }),
|
|
409
|
+
};
|
|
382
410
|
if (hiddenOf !== null) {
|
|
383
|
-
hidden.push({ name, of: hiddenOf.of, file: present[0], pixels, left, top, right, bottom, opaquePx: opaque(pixels), ...(
|
|
411
|
+
hidden.push({ name, of: hiddenOf.of, file: present[0], pixels, left, top, right, bottom, opaquePx: opaque(pixels), ...(depthHint === undefined ? {} : { depthHint }) });
|
|
384
412
|
return;
|
|
385
413
|
}
|
|
386
414
|
read.push({
|
|
@@ -388,7 +416,7 @@ export function readWrapperLayers(
|
|
|
388
416
|
tag: tag as LayerTagReading,
|
|
389
417
|
file: present[0],
|
|
390
418
|
pixels,
|
|
391
|
-
...(
|
|
419
|
+
...(depthHint === undefined ? {} : { depthHint }),
|
|
392
420
|
left,
|
|
393
421
|
top,
|
|
394
422
|
right,
|
|
@@ -576,9 +604,9 @@ export function readPsdLayers(path: string): LayerSet {
|
|
|
576
604
|
}
|
|
577
605
|
|
|
578
606
|
/** Read whichever form `path` is: a `.psd` file, or a wrapper directory / `layers.json`. */
|
|
579
|
-
export function readLayers(path: string, binding?: DepthBinding): LayerSet {
|
|
607
|
+
export function readLayers(path: string, binding?: DepthBinding, readings?: WrapperReadings): LayerSet {
|
|
580
608
|
if (/\.psd$/i.test(path)) { const set = readPsdLayers(path); return binding === undefined ? set : bindDepthRun(set, binding.run, binding.config, binding.base); }
|
|
581
|
-
if (existsSync(path) && (statSync(path).isDirectory() || basename(path) === 'layers.json')) return readWrapperLayers(path, binding);
|
|
609
|
+
if (existsSync(path) && (statSync(path).isDirectory() || basename(path) === 'layers.json')) return readWrapperLayers(path, binding, undefined, readings);
|
|
582
610
|
refuseIfAny([
|
|
583
611
|
{
|
|
584
612
|
code: 'LAYERS_INPUT_KIND',
|
package/src/runstamp.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto';
|
|
2
2
|
import { existsSync, readdirSync, readFileSync, realpathSync, rmSync, statSync, writeFileSync } from 'node:fs';
|
|
3
|
-
import nodePath, { basename, join, relative, resolve, sep } from 'node:path';
|
|
3
|
+
import nodePath, { basename, dirname, join, relative, resolve, sep } from 'node:path';
|
|
4
4
|
import { type AssembleResult, FIGURE_MASK_FILE } from './assemble.ts';
|
|
5
|
-
import { BUILD_RUN_FILE, ERROR_MAP_FILE } from './build.ts';
|
|
5
|
+
import { type AssembleWrapperReadings, BUILD_RUN_FILE, ERROR_MAP_FILE } from './build.ts';
|
|
6
6
|
import { CUT_MATERIAL_SOURCES } from './cutmaterial.ts';
|
|
7
7
|
import { EDGE_RESIDUAL_FILE } from './edgeresidual.ts';
|
|
8
8
|
import { PartsError } from './errors.ts';
|
|
9
|
+
import type { WrapperManifestReading } from './layers.ts';
|
|
9
10
|
import { LAYOUT_FILE } from './limblayout.ts';
|
|
10
11
|
import { argvPathFromOut, linkRuleFor, type PlatformPath, realWhereItExists, recordedConfigPath, recordedInputPath } from './outputpaths.ts';
|
|
11
12
|
import { PAINTING_ALLOCATION_FILE } from './paintingedges.ts';
|
|
@@ -68,6 +69,12 @@ export interface RunStampAssembleInputs {
|
|
|
68
69
|
head?: string | null;
|
|
69
70
|
}
|
|
70
71
|
|
|
72
|
+
type WrapperRole = keyof AssembleWrapperReadings;
|
|
73
|
+
type AssembleWrapperInputs = {
|
|
74
|
+
manifests: Partial<Record<WrapperRole, WrapperManifestReading>>;
|
|
75
|
+
pngs: RunStampInputEntry<WrapperRole>[];
|
|
76
|
+
};
|
|
77
|
+
|
|
71
78
|
export interface RunStamp {
|
|
72
79
|
spec: typeof RUN_STAMP_SPEC;
|
|
73
80
|
package: RunStampPackage;
|
|
@@ -77,6 +84,7 @@ export interface RunStamp {
|
|
|
77
84
|
config: RunStampFileEntry;
|
|
78
85
|
parts_input?: RunStampFileEntry;
|
|
79
86
|
inputs?: RunStampInputEntry[];
|
|
87
|
+
wrapper_pngs?: RunStampInputEntry<WrapperRole>[];
|
|
80
88
|
outputs: RunStampFileEntry[];
|
|
81
89
|
}
|
|
82
90
|
|
|
@@ -90,6 +98,7 @@ export interface RunStampInput {
|
|
|
90
98
|
/** The parts directory as supplied to the stage and its pre-stage digest. */
|
|
91
99
|
partsInput?: RunStampFileEntry;
|
|
92
100
|
inputs?: RunStampAssembleInputs;
|
|
101
|
+
wrapperInputs?: AssembleWrapperInputs;
|
|
93
102
|
outputPaths: readonly string[];
|
|
94
103
|
}
|
|
95
104
|
|
|
@@ -106,28 +115,65 @@ function relativeToOutRoot(outDir: string, targetPath: string): string {
|
|
|
106
115
|
type RunInputPaths<Role extends string> = Array<readonly [Role, string | null | undefined]>;
|
|
107
116
|
|
|
108
117
|
/** Name and hash the same file. A See-through directory names its manifest (issue #1554). */
|
|
109
|
-
function recordInputs<Role extends string>(paths: RunInputPaths<Role>, outDir: string, cwd: string
|
|
118
|
+
function recordInputs<Role extends string>(paths: RunInputPaths<Role>, outDir: string, cwd: string,
|
|
119
|
+
manifests?: Partial<Record<Role, WrapperManifestReading>>,
|
|
120
|
+
): RunStampInputEntry<Role>[] {
|
|
110
121
|
const entries: RunStampInputEntry<Role>[] = [];
|
|
111
122
|
for (const [role, given] of paths) {
|
|
112
123
|
if (given === undefined || given === null) continue;
|
|
113
124
|
const resolved = resolve(cwd, given);
|
|
114
|
-
const
|
|
125
|
+
const manifest = manifests?.[role];
|
|
126
|
+
const isDir = manifest?.givenAsDirectory ?? statSync(resolved).isDirectory();
|
|
115
127
|
entries.push({
|
|
116
128
|
role,
|
|
117
129
|
path: recordedInputPath(given, outDir, cwd, isDir),
|
|
118
|
-
sha256: sha256OnDisk(isDir ? join(resolved, 'layers.json') : resolved),
|
|
130
|
+
sha256: manifest?.sha256 ?? sha256OnDisk(isDir ? join(resolved, 'layers.json') : resolved),
|
|
119
131
|
});
|
|
120
132
|
}
|
|
121
133
|
return entries;
|
|
122
134
|
}
|
|
123
135
|
|
|
124
136
|
/** The ordered inputs (`source`, `full`, and `head` when given) for an `assemble` run stamp. */
|
|
125
|
-
export function buildAssembleInputs(inputs: RunStampAssembleInputs, outDir: string): RunStampInputEntry[] {
|
|
137
|
+
export function buildAssembleInputs(inputs: RunStampAssembleInputs, outDir: string, manifests?: AssembleWrapperInputs['manifests']): RunStampInputEntry[] {
|
|
126
138
|
return recordInputs<RunStampInputRole>([
|
|
127
139
|
['source', inputs.source],
|
|
128
140
|
['full', inputs.full],
|
|
129
141
|
['head', inputs.head],
|
|
130
|
-
], outDir, inputs.cwd ?? process.cwd());
|
|
142
|
+
], outDir, inputs.cwd ?? process.cwd(), manifests);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** Validate the primary wrappers' consumed files before assemble can publish its outputs. */
|
|
146
|
+
export function bindAssembleWrapperInputs(readings: AssembleWrapperReadings): AssembleWrapperInputs | undefined {
|
|
147
|
+
const manifests: AssembleWrapperInputs['manifests'] = {};
|
|
148
|
+
const pngs: AssembleWrapperInputs['pngs'] = [];
|
|
149
|
+
for (const role of ['full', 'head'] as const) {
|
|
150
|
+
const reading = readings[role];
|
|
151
|
+
if (reading.manifest === undefined) continue;
|
|
152
|
+
manifests[role] = reading.manifest;
|
|
153
|
+
const dir = dirname(reading.manifest.path);
|
|
154
|
+
const hashes = new Map<string, string>();
|
|
155
|
+
for (const { path: file, sha256 } of reading.pngs) {
|
|
156
|
+
const path = relative(dir, file).split(sep).join('/');
|
|
157
|
+
if (path === '' || path === '..' || path.startsWith('../') || path.startsWith('/') || /^[a-z]:/i.test(path) || path.includes('\\') || path.includes('\0')) {
|
|
158
|
+
throw new PartsError([{
|
|
159
|
+
code: 'ASSEMBLE_WRAPPER_PNG_PATH',
|
|
160
|
+
object: `${role} wrapper PNG ${JSON.stringify(file)}`,
|
|
161
|
+
detail: `relative path ${JSON.stringify(path)} found; a canonical slash-delimited path within ${JSON.stringify(dir)} without a drive prefix, backslash or NUL is required`,
|
|
162
|
+
}]);
|
|
163
|
+
}
|
|
164
|
+
const previous = hashes.get(path);
|
|
165
|
+
if (previous !== undefined && previous !== sha256) {
|
|
166
|
+
throw new PartsError([{
|
|
167
|
+
code: 'ASSEMBLE_WRAPPER_PNG_CONFLICT',
|
|
168
|
+
object: `${role} wrapper PNG ${JSON.stringify(path)}`,
|
|
169
|
+
detail: `found SHA-256 ${previous} and ${sha256}; one digest per role and path is required`,
|
|
170
|
+
}]);
|
|
171
|
+
}
|
|
172
|
+
hashes.set(path, sha256);
|
|
173
|
+
}
|
|
174
|
+
for (const path of [...hashes.keys()].sort()) pngs.push({ role, path, sha256: hashes.get(path)! });
|
|
175
|
+
}
|
|
176
|
+
return manifests.full === undefined && manifests.head === undefined ? undefined : { manifests, pngs };
|
|
131
177
|
}
|
|
132
178
|
|
|
133
179
|
function sortCodeUnits(paths: readonly string[]): string[] {
|
|
@@ -234,7 +280,8 @@ export function buildRunStamp(input: RunStampInput): RunStamp {
|
|
|
234
280
|
path: rel,
|
|
235
281
|
sha256: sha256OnDisk(join(input.outDir, ...rel.split('/'))),
|
|
236
282
|
}));
|
|
237
|
-
const
|
|
283
|
+
const wrapperInputs = input.command === 'assemble' ? input.wrapperInputs : undefined;
|
|
284
|
+
const inputs = input.inputs === undefined ? undefined : buildAssembleInputs(input.inputs, input.outDir, wrapperInputs?.manifests);
|
|
238
285
|
return {
|
|
239
286
|
spec: RUN_STAMP_SPEC,
|
|
240
287
|
package: {
|
|
@@ -255,6 +302,7 @@ export function buildRunStamp(input: RunStampInput): RunStamp {
|
|
|
255
302
|
},
|
|
256
303
|
}),
|
|
257
304
|
...(inputs === undefined ? {} : { inputs }),
|
|
305
|
+
...(wrapperInputs === undefined ? {} : { wrapper_pngs: wrapperInputs.pngs }),
|
|
258
306
|
outputs,
|
|
259
307
|
};
|
|
260
308
|
}
|
package/src/visibility.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { lstatSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
|
4
4
|
import { join } from 'node:path';
|
|
5
5
|
import { depthSheetProblems } from './depthsheets.ts';
|
|
6
6
|
import { foldName, PartsError, type Problem, refuseIfAny } from './errors.ts';
|
|
7
|
-
import { readWrapperLayers, type Layer, type LayerSet } from './layers.ts';
|
|
7
|
+
import { readWrapperLayers, type Layer, type LayerSet, type WrapperReadings } from './layers.ts';
|
|
8
8
|
import { decodePngBytes } from './raster/png.ts';
|
|
9
9
|
import type { Raster } from './raster/types.ts';
|
|
10
10
|
import { readLayerTag } from './tags.ts';
|
|
@@ -177,9 +177,9 @@ function sourceNames(dir: string, bytes: Buffer): string[] {
|
|
|
177
177
|
return names;
|
|
178
178
|
}
|
|
179
179
|
|
|
180
|
-
function readWrapper(dir: string, sealed: ReadonlyMap<string, Buffer
|
|
180
|
+
function readWrapper(dir: string, sealed: ReadonlyMap<string, Buffer>, readings?: WrapperReadings): ReturnType<typeof readWrapperLayers> {
|
|
181
181
|
try {
|
|
182
|
-
return readWrapperLayers(dir, undefined, sealed);
|
|
182
|
+
return readWrapperLayers(dir, undefined, sealed, readings);
|
|
183
183
|
} catch (error) {
|
|
184
184
|
if (error instanceof PartsError) {
|
|
185
185
|
throw new PartsError(error.problems.map(problem => ({ ...problem, code: 'VISIBILITY_SOURCE' })));
|
|
@@ -248,7 +248,7 @@ function score(crops: readonly Crop[], [width, height]: Pair): Uint8Array[] {
|
|
|
248
248
|
});
|
|
249
249
|
}
|
|
250
250
|
|
|
251
|
-
function buildRecord(dir: string, identity: VisibilityIdentity, saved?: { value: unknown }): RecordFiles {
|
|
251
|
+
function buildRecord(dir: string, identity: VisibilityIdentity, saved?: { value: unknown }, readings?: WrapperReadings): RecordFiles {
|
|
252
252
|
const manifestAt = join(dir, MANIFEST);
|
|
253
253
|
const { prompt_id, input_sha256, graph_sha256 } = identity;
|
|
254
254
|
const run = { spec: SPEC, prompt_id, input_sha256, graph_sha256 } as const;
|
|
@@ -277,7 +277,7 @@ function buildRecord(dir: string, identity: VisibilityIdentity, saved?: { value:
|
|
|
277
277
|
return { tag, at, row, image: image.seal };
|
|
278
278
|
});
|
|
279
279
|
|
|
280
|
-
const set = readWrapper(dir, sealed);
|
|
280
|
+
const set = readWrapper(dir, sealed, readings);
|
|
281
281
|
const canvas: Pair = [set.canvas.w, set.canvas.h];
|
|
282
282
|
if (recorded !== undefined) match(recorded.canvas, canvas, manifestAt + '.canvas');
|
|
283
283
|
if (!canvas.every(Number.isSafeInteger) || !Number.isSafeInteger(canvas[0] * canvas[1])) {
|
|
@@ -302,7 +302,12 @@ function buildRecord(dir: string, identity: VisibilityIdentity, saved?: { value:
|
|
|
302
302
|
}
|
|
303
303
|
const path = `parts/${tag}_depth.png`;
|
|
304
304
|
const sheet = readSealed(dir, path, row && { value: row.depth, at: at + '.depth' });
|
|
305
|
-
|
|
305
|
+
const file = join(dir, path);
|
|
306
|
+
const depth = decodeDepth(sheet.bytes, size, file);
|
|
307
|
+
// The producer stages the wrapper-declared sheet here for visibility,
|
|
308
|
+
// which consumes it independently of the scalar geometry opt-in.
|
|
309
|
+
layer.depthHint?.recordDecode?.(file, sheet.seal.sha256);
|
|
310
|
+
crops.push({ layer, depth, image, sheet: sheet.seal });
|
|
306
311
|
} catch (error) {
|
|
307
312
|
if (!(error instanceof PartsError)) throw error;
|
|
308
313
|
problems.push(...error.problems);
|
|
@@ -355,19 +360,19 @@ export function writeVisibilityRecord(dir: string, identity: VisibilityIdentity)
|
|
|
355
360
|
|
|
356
361
|
/** Verify the run, current source bytes, native grids and exact scored masks. */
|
|
357
362
|
export function readVisibilityRecord(dir: string, identity: VisibilityIdentity): VisibilityManifest;
|
|
358
|
-
export function readVisibilityRecord(dir: string, identity: VisibilityIdentity, includeSamples: true): RecordFiles;
|
|
363
|
+
export function readVisibilityRecord(dir: string, identity: VisibilityIdentity, includeSamples: true, readings?: WrapperReadings): RecordFiles;
|
|
359
364
|
export function readVisibilityRecord(
|
|
360
|
-
dir: string, identity: VisibilityIdentity, includeSamples = false,
|
|
365
|
+
dir: string, identity: VisibilityIdentity, includeSamples = false, readings?: WrapperReadings,
|
|
361
366
|
): VisibilityManifest | RecordFiles {
|
|
362
367
|
checkIdentity(identity);
|
|
363
368
|
const file = join(dir, MANIFEST);
|
|
364
369
|
const value = parse(readBytes(file), file, 'VISIBILITY_MANIFEST');
|
|
365
|
-
const result = buildRecord(dir, identity, { value });
|
|
370
|
+
const result = buildRecord(dir, identity, { value }, readings);
|
|
366
371
|
return includeSamples ? result : result.manifest;
|
|
367
372
|
}
|
|
368
373
|
|
|
369
374
|
/** The expected identity comes from the independent producer metadata. */
|
|
370
|
-
export function readRunVisibility(dir: string): RecordFiles | undefined {
|
|
375
|
+
export function readRunVisibility(dir: string, readings?: WrapperReadings): RecordFiles | undefined {
|
|
371
376
|
const path = join(dir, MANIFEST);
|
|
372
377
|
if (lstatSync(path, { throwIfNoEntry: false }) === undefined) return;
|
|
373
378
|
const meta = join(dir, 'meta.json');
|
|
@@ -380,5 +385,5 @@ export function readRunVisibility(dir: string): RecordFiles | undefined {
|
|
|
380
385
|
!isSha256(uploaded_image_sha256) || !isSha256(graph_sha256)) {
|
|
381
386
|
fail('VISIBILITY_SOURCE', meta, 'requires prompt_id and lowercase SHA-256 uploaded_image_sha256 and graph_sha256 from the producing run');
|
|
382
387
|
}
|
|
383
|
-
return readVisibilityRecord(dir, { prompt_id, input_sha256: uploaded_image_sha256, graph_sha256 }, true);
|
|
388
|
+
return readVisibilityRecord(dir, { prompt_id, input_sha256: uploaded_image_sha256, graph_sha256 }, true, readings);
|
|
384
389
|
}
|