@rig-c/parts 2.45.0 → 2.47.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 +18 -4
- package/docs/AUTHORING.md +142 -65
- package/docs/STABILITY.md +71 -16
- package/package.json +5 -1
- package/src/alternatelayers.ts +2 -1
- package/src/assemble.ts +55 -50
- package/src/assembly-reading.ts +493 -0
- package/src/authoredunit.ts +2 -2
- package/src/build.ts +46 -21
- package/src/check.ts +18 -9
- package/src/config.ts +48 -14
- package/src/configrelocation.ts +48 -2
- package/src/configwrite.ts +6 -4
- package/src/depthworkflow.ts +4 -2
- package/src/editedparts.ts +6 -1
- package/src/inputs.ts +1 -1
- package/src/parts.ts +34 -6
- package/src/partsource.ts +4 -1
- package/src/propose.ts +4 -4
- package/src/takelayers.ts +4 -1
- package/src/takeregion.ts +4 -1
- package/tools/configwrite.ts +22 -14
- package/tools/edited-part-cli.ts +16 -5
- package/tools/neck-propose.ts +2 -0
package/src/build.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { changedAssemblyFields, effectiveAssemblyRules, projectAssemblyConfig, readProjectedAssemblyConfig, type AssemblyLimb, refuseStaleAssembly, type AssemblyRules } from './assembly-reading.ts';
|
|
1
2
|
import { editedPartFrontColourLines, readEditedParts } from './editedparts.ts';
|
|
2
3
|
import { SOURCE_COVER_FILE, sourceCoverReport, type SourceCoverSet } from './sourcecover.ts';
|
|
3
4
|
import { STAGE_MAP_FILE } from './provenance.ts';
|
|
@@ -6,7 +7,6 @@ import { readSetupFigureMask } from './setupfiguremask.ts';
|
|
|
6
7
|
import { EDGE_RESIDUAL_FILE, edgeResidualLines } from './edgeresidual.ts';
|
|
7
8
|
import { SUPPORT_DOMAINS_FILE, writeSupportDomains } from './supportdomains.ts';
|
|
8
9
|
import { COINCIDE_LINE, supportLines } from './coincide.ts';
|
|
9
|
-
import { DEFAULT_SEAM_RULE } from './seamrule.ts';
|
|
10
10
|
import { DEFAULT_PROJECT_RULE } from './projectrule.ts';
|
|
11
11
|
import { type PaintingAllocationReading, type PaintingAllocationEvent, EDGE_CONTRAST, PAINTING_ALLOCATION_FILE, PAINTING_EDGE_COVERAGE_TRANSFER } from './paintingedges.ts';
|
|
12
12
|
import { SETUP_PAINTING_LINE, setupPaintingLines } from './setuppainting.ts';
|
|
@@ -70,7 +70,7 @@ import { createHash } from 'node:crypto';
|
|
|
70
70
|
import { existsSync, mkdirSync, readdirSync, readFileSync, rmSync, statSync, writeFileSync } from 'node:fs';
|
|
71
71
|
import { basename, dirname, join, relative, resolve, sep } from 'node:path';
|
|
72
72
|
import { type AnimFrame, EncodeError, encodeApng, encodeIndexedApng, INDEXED_DEFAULTS } from './apng.ts';
|
|
73
|
-
import { assemble, type AssembleResult, boxOf, cutLines, edgeSplitLines, ERROR_LIMIT, type ExcludedCount, excludedLines, setExclusions, islandLines, setIslandSources, type IslandCount, hiddenLines, SINGLE_RUN_FACE_TAGS, singleRunHeadBox, softOcclusionLine, driftLine, limbLines, FIGURE_MASK_FILE, figureMaskLines, figuresLine, groundWarning, holeKindsLine, holeLines, measurePinholes, measureRecomposite, pinholeProblems, pinholesLine, type ProjectRule, recomposite, recompositeRecord, scenePhrase, type SeamRule, sourceInRig, stageFields, uncoveredLine, underBox } from './assemble.ts';
|
|
73
|
+
import { assemble, type AssembleResult, boxOf, cutLines, edgeSplitLines, ERROR_LIMIT, type ExcludedCount, excludedLines, setExclusions, islandLines, setIslandSources, type IslandCount, hiddenLines, SINGLE_RUN_FACE_TAGS, singleRunHeadBox, softOcclusionLine, driftLine, limbLines, FIGURE_MASK_FILE, figureMaskLines, figuresLine, groundWarning, holeKindsLine, holeLines, measurePinholes, measureRecomposite, pinholeProblems, pinholesLine, type ProjectRule, recomposite, recompositeRecord, scenePhrase, type SeamRule, sourceInRig, projectedStageFields, stageFields, uncoveredLine, underBox } from './assemble.ts';
|
|
74
74
|
import { allocationClause, type Reducer, stageBClause, unboundedClause } from './automesh.ts';
|
|
75
75
|
import { residualClause } from './autoenvelope.ts';
|
|
76
76
|
import { type AutoMotionCase, failingRows, idleSchedule, localRow, motionClause, motionDeformation, motionDocument, motionInput, motionRowText, motionStimulus, motionVerdict, noStimulusProblem, prepareComparison, type ReplayCandidate, runComparison, runPreparedComparison, sourceSelfFailure, stimulusMotion, withStimulus } from './automotion.ts';
|
|
@@ -98,7 +98,7 @@ import {
|
|
|
98
98
|
untestedIntervals,
|
|
99
99
|
} from './autoreplay.ts';
|
|
100
100
|
import { besideIdleLine, checkSummaryLine, inputFileRecord, type InputFileRecord, CLOTH_LINE, type ClothLine, clothWarnText, figureOpeningLines, frameRuns, MOTION_SEAM_LINE, type MotionSeamLine, type MotionSeamPlant, motionSeamRequiredLine, motionSeamWarnText, motionJointContactLines, FOLD_LINE, type FoldsLine, LEVEL_LINE, type LevelLine, LIMB_LINE, type LimbLine, STRESS_LINE, SWEEP_LINE, type SweepLine, buildGateLines, causeLines, environmentLine, IDLE_FPS, IDLE_MAX_PX, maxRgbDiff, REQUIREMENTS_DIR, type CheckReport, type PackLine, DEFAULT_PACK_SHAPE, DEFAULT_PAGE_EDGES, GATE_PROFILE, JUDGEMENT_LINES, type JudgementLine, packedBuildArgs, packedBuildLabel, type PackMode, parsePageSize, readCheckEnvironment, readWindBand, type PackShape, type PageEdges, readFrameSet, rigcFailed, rigcIdentity, rigcRanClause, REPORTED_LINES, type ReportedLine, type RigcRunner, runCheck, SEAM_DIR, SEAM_MEAN_BAR, seamPairText, seamRigPxText, SOURCE_LINE, SEAM_PX_BAR, SEAM_PX_LEVEL, SEAM_PX_LEVEL_HIGH, SPINEBOY_YARDSTICK, STILL_DIR, WIND_BAND_LINE, windBandLines } from './check.ts';
|
|
101
|
-
import { type CharacterConfig, type Cut, type Extend,
|
|
101
|
+
import { type CharacterConfig, type Cut, type Extend, loadConfigAndAnimations, loadConfigWithBytes, loadEarlyConfig, type Patch, type PlanEntry } from './config.ts';
|
|
102
102
|
import { coreCompileGuideLine, failLine, foldName, PartsError, type Problem, refuseIfAny } from './errors.ts';
|
|
103
103
|
import { editedConfigImages, editedRunImages, missingReceipts, readEditorReceipts } from './editreceipt.ts';
|
|
104
104
|
import { untracedPartSources } from './partsource.ts';
|
|
@@ -108,7 +108,7 @@ import { CONTROL_SUFFIX, withAnimations } from './motion.ts';
|
|
|
108
108
|
import type { PaletteError } from './palette.ts';
|
|
109
109
|
import { type LayerSet, readLayers } from './layers.ts';
|
|
110
110
|
import { placeBoneEntriesForSkeleton, poseBoneEntriesForDrawn, REGISTER_OFFSET_BAR, REGISTER_SCALE_BAR, registeredWithinBar, registerSkeleton, SKELETON_LIMB_BONES, skeletonDrawnLength, skeletonLimbJoints } from './limbs.ts';
|
|
111
|
-
import { type AlternatePartsRecord, PAINTING_IN_RIG_FILE, FRONT_SUFFIX, type OccluderPlateRecord, type PartRecord, partImageReference, depthImageReference, readParts, type RecompositeRecord, type SingleRunPad, tagOf, writeParts } from './parts.ts';
|
|
111
|
+
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';
|
|
112
112
|
import { encodePngBytes, readPng, writePng } from './raster/png.ts';
|
|
113
113
|
import type { Raster } from './raster/types.ts';
|
|
114
114
|
import { type Mask, newMask } from './raster/types.ts';
|
|
@@ -237,6 +237,7 @@ export interface AssembleOutputs {
|
|
|
237
237
|
|
|
238
238
|
/** The error map's file name beside a recomposite: `recomposite_rig.png` -> `recomposite_error_rig.png`. */
|
|
239
239
|
export const ERROR_MAP_FILE = 'recomposite_error_rig.png';
|
|
240
|
+
const ASSEMBLE_YIELD_NOTHING = 'ASSEMBLE_YIELD_NOTHING';
|
|
240
241
|
|
|
241
242
|
/**
|
|
242
243
|
* One line per part whose fringe `pushBackFringe` cleared (issue #119), in
|
|
@@ -392,8 +393,7 @@ export interface EmitFillMasksInput {
|
|
|
392
393
|
|
|
393
394
|
export function emitFillMasksStage(input: EmitFillMasksInput, log: Log): Array<{ into: string; path: string; sha256: string; opaquePx: number }> {
|
|
394
395
|
const cfg = loadEarlyConfig(input.config, 'assemble', input.project);
|
|
395
|
-
const seam
|
|
396
|
-
const project = input.project ?? cfg.assemble.project ?? DEFAULT_PROJECT_RULE;
|
|
396
|
+
const { seam, project } = effectiveAssemblyRules(cfg.assemble, input);
|
|
397
397
|
const src = readSource(input.source);
|
|
398
398
|
const read = readRuns(input.full, input.head);
|
|
399
399
|
const takenRuns = applyTakenLayers(read, src, cfg, input.config);
|
|
@@ -440,7 +440,7 @@ export function emitFillMasksStage(input: EmitFillMasksInput, log: Log): Array<{
|
|
|
440
440
|
* (`ASSEMBLE_LIMB_CAP_PRESENT`), or a file that does not decode as a PNG
|
|
441
441
|
* (`ASSEMBLE_LIMB_CAP_DECODES`). The stage holds the image to the cap's box.
|
|
442
442
|
*/
|
|
443
|
-
export function readCaps(configPath: string, limbs: Readonly<Record<string,
|
|
443
|
+
export function readCaps(configPath: string, limbs: Readonly<Record<string, AssemblyLimb>>): Map<string, Raster> {
|
|
444
444
|
const problems: Problem[] = [];
|
|
445
445
|
const out = new Map<string, Raster>();
|
|
446
446
|
for (const [l, limb] of Object.entries(limbs)) {
|
|
@@ -504,16 +504,19 @@ function sourceCoverSet(result: AssembleResult, set: string | null, painting: st
|
|
|
504
504
|
|
|
505
505
|
/** Read, assemble, and write only after every refusal has had its chance. Throws a PartsError on a refusal, having written nothing. */
|
|
506
506
|
export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs, log: Log): AssembleResult {
|
|
507
|
+
// Flag-only figure masks and the region-take tolerance are effective
|
|
508
|
+
// inputs outside the legacy config reading.
|
|
507
509
|
const requirementsFile = input.requirements === undefined ? null : readRequirements(input.requirements);
|
|
508
510
|
const materialAsked = requirementsFile?.cut_material !== undefined;
|
|
509
511
|
// Issue #944: the pinhole bar is measured only when the requirements file declares it required.
|
|
510
512
|
const pinholesAsked = requirementsFile !== null && pinholesRequired(requirementsFile);
|
|
511
513
|
// The early door: assemble runs before propose has drafted bones, meshes,
|
|
512
514
|
// regions and motion, so it requires only what it reads (issue #20).
|
|
513
|
-
const
|
|
515
|
+
const projection = projectAssemblyConfig(loadEarlyConfig(input.config, 'assemble', input.project));
|
|
516
|
+
// The assemble loader requires seethrough before projection.
|
|
517
|
+
const cfg = { ...projection.config, seethrough: projection.config.seethrough! };
|
|
514
518
|
const supportDeclarations = JSON.stringify(cfg.assemble.cuts ?? []);
|
|
515
|
-
const seam
|
|
516
|
-
const project = input.project ?? cfg.assemble.project ?? DEFAULT_PROJECT_RULE;
|
|
519
|
+
const { seam, project } = effectiveAssemblyRules(cfg.assemble, input);
|
|
517
520
|
const requirements = cfg.assemble.ground === 'busy' && project === 'visible'
|
|
518
521
|
? buildRequirements(input.requirements, cfg.requirements, input.config) : null;
|
|
519
522
|
const src = readSource(input.source);
|
|
@@ -526,7 +529,7 @@ export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs,
|
|
|
526
529
|
const takenRuns = applyTakenLayers(read, src, cfg, input.config);
|
|
527
530
|
const runs = applyTakenRegions(takenRuns, src, cfg, input.config, requirementsFile?.setup_painting, receipts, input.source);
|
|
528
531
|
for (const note of runs.notes) log(note.startsWith('WARN ') ? note : `note: ${note}`);
|
|
529
|
-
const fields =
|
|
532
|
+
const fields = projectedStageFields(cfg, runs.single ? { w: src.width, h: src.height } : null);
|
|
530
533
|
const setupPainting = requirements === null || fields.ground !== 'busy' || project !== 'visible' ? undefined
|
|
531
534
|
: readRequirements(requirements.read).setup_painting;
|
|
532
535
|
const figureSupport = setupPainting === undefined ? undefined
|
|
@@ -609,6 +612,8 @@ export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs,
|
|
|
609
612
|
});
|
|
610
613
|
}
|
|
611
614
|
|
|
615
|
+
const scopedYield = typeof fields.yieldRefused === 'object' ? fields.yieldRefused : [];
|
|
616
|
+
const yieldedParts = new Set(result.yieldReadings?.filter(row => row.yielded > 0).map(row => row.part));
|
|
612
617
|
const altProblems: Problem[] = [];
|
|
613
618
|
const allocationReports: Array<{ file: string; report: { set: string; coverageTransfers: PaintingAllocationReading['coverageTransfers'] } & Record<string, unknown> }> = [];
|
|
614
619
|
const altBuilt: Array<{ record: AlternatePartsRecord; images: Array<{ name: string; image: Raster }>; excluded: ExcludedCount[]; islands: IslandCount[]; splits: SplitCount[]; capSplits: SplitCount[]; depthClamps: AssembleResult['depthClamps'] }> = [];
|
|
@@ -715,7 +720,7 @@ export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs,
|
|
|
715
720
|
for (const sg of limb.segments) if (sg.hybrid !== undefined) { coveredSet.add(sg.hybrid.part); generatedBands.push(sg.hybrid.part); }
|
|
716
721
|
}
|
|
717
722
|
let rawCuts = alt.cuts !== undefined ? alt.cuts : fields.cuts.filter((c) => coveredSet.has(c.into) && coveredSet.has(c.from)).map((c) => ({ ...c, under: undefined }));
|
|
718
|
-
let altLimbs: Record<string,
|
|
723
|
+
let altLimbs: Record<string, AssemblyLimb> = {};
|
|
719
724
|
if (fields.limbs !== undefined) {
|
|
720
725
|
for (const [ln, limb] of Object.entries(fields.limbs)) {
|
|
721
726
|
if (limb.segments.every((sg) => coveredSet.has(sg.part))) {
|
|
@@ -782,7 +787,7 @@ export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs,
|
|
|
782
787
|
const originalIslands = alt.parts === undefined || input.setIslands === 'all' ? [] : setIslandSources(fields.limbs ?? {}, originalAltLimbs);
|
|
783
788
|
const altIslands = alternateLayerIslands(originalIslands, selectedLayers.groups);
|
|
784
789
|
// Issue #609: the limbs of those layers the set does not carry — the other leg of a two-leg layer.
|
|
785
|
-
const otherLimbs: Record<string,
|
|
790
|
+
const otherLimbs: Record<string, AssemblyLimb> =
|
|
786
791
|
input.setSplit === 'connectivity'
|
|
787
792
|
? {}
|
|
788
793
|
: Object.fromEntries(Object.entries(fields.limbs ?? {}).filter(([ln, l]) => !(ln in altLimbs) && l.segments.some((sg) => originalIslands.includes(sg.from))));
|
|
@@ -937,6 +942,7 @@ export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs,
|
|
|
937
942
|
}
|
|
938
943
|
throw err;
|
|
939
944
|
}
|
|
945
|
+
for (const row of altRes.yieldReadings ?? []) if (row.yielded > 0) yieldedParts.add(row.part);
|
|
940
946
|
const altMaskProblems = verifyUnderPlateMasks(altRes, altCuts, altUnderPlates, `${alt.at}.cuts`);
|
|
941
947
|
if (altMaskProblems.length > 0) {
|
|
942
948
|
altProblems.push(...altMaskProblems);
|
|
@@ -1071,6 +1077,14 @@ export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs,
|
|
|
1071
1077
|
result.parts.alternates = altBuilt.map((b) => b.record);
|
|
1072
1078
|
}
|
|
1073
1079
|
|
|
1080
|
+
const reading = readProjectedAssemblyConfig(projection, result.parts, input.config, { seam, project });
|
|
1081
|
+
let previousAssembly = undefined;
|
|
1082
|
+
if (existsSync(outs.partsJson)) {
|
|
1083
|
+
try { previousAssembly = readPartsManifest(outs.partsJson).assembly_config; }
|
|
1084
|
+
catch (error) { if (!(error instanceof PartsError)) throw error; }
|
|
1085
|
+
}
|
|
1086
|
+
result.parts.assembly_config = reading;
|
|
1087
|
+
|
|
1074
1088
|
const allocationPath = join(dirname(outs.partsJson), PAINTING_ALLOCATION_FILE);
|
|
1075
1089
|
let previousAllocationFiles: string[] = [];
|
|
1076
1090
|
if (existsSync(allocationPath)) {
|
|
@@ -1099,6 +1113,10 @@ export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs,
|
|
|
1099
1113
|
sha256: createHash('sha256').update(paintingBytes).digest('hex'), resample: 'lanczos3-rgb-opaque' };
|
|
1100
1114
|
writeFileSync(join(dirname(outs.partsJson), PAINTING_IN_RIG_FILE), paintingBytes);
|
|
1101
1115
|
writeParts(outs.partsJson, result.parts);
|
|
1116
|
+
if (previousAssembly !== undefined) {
|
|
1117
|
+
const changes = changedAssemblyFields(previousAssembly, reading);
|
|
1118
|
+
if (changes.length > 0) log(`note: reassembled parts after changes to ${changes.map(name => `config.${name}`).join(', ')}`);
|
|
1119
|
+
}
|
|
1102
1120
|
writeFileSync(join(dirname(outs.partsJson), SOURCE_COVER_FILE), JSON.stringify(sourceCoverReport(sourceCoverSets), null, 2) + '\n');
|
|
1103
1121
|
const stageMapPath = join(dirname(outs.partsJson), STAGE_MAP_FILE);
|
|
1104
1122
|
if (result.stageMap === undefined) rmSync(stageMapPath, { force: true });
|
|
@@ -1214,6 +1232,9 @@ export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs,
|
|
|
1214
1232
|
if (result.figureMask !== undefined) for (const l of figureMaskLines(result.figureMask, scene)) log(l);
|
|
1215
1233
|
log(pinholesLine(pinholes, altBuilt.map((b) => b.record.name)));
|
|
1216
1234
|
for (const d of result.drift) log(driftLine(d));
|
|
1235
|
+
for (const part of scopedYield) {
|
|
1236
|
+
if (!yieldedParts.has(part)) log(`${ASSEMBLE_YIELD_NOTHING}: part ${JSON.stringify(part)} — no eligible projection refusal to yield in the base or alternate sets`);
|
|
1237
|
+
}
|
|
1217
1238
|
for (const d of result.softOcclusion ?? []) log(softOcclusionLine(d));
|
|
1218
1239
|
for (const line of result.cropClipped ?? []) log(line);
|
|
1219
1240
|
// Issue #588: per subset set, one line per limb part cut from a layer of more than one island, then (issue #587) one
|
|
@@ -1232,7 +1253,7 @@ export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs,
|
|
|
1232
1253
|
* base parts at alpha above `OPAQUE_ALPHA_ABOVE`, at their `parts.json` x, y.
|
|
1233
1254
|
*/
|
|
1234
1255
|
function otherLimbsOf(
|
|
1235
|
-
limbs: Readonly<Record<string,
|
|
1256
|
+
limbs: Readonly<Record<string, AssemblyLimb>>,
|
|
1236
1257
|
setPlaced: ReadonlySet<string>,
|
|
1237
1258
|
bones: readonly BoneEntry[],
|
|
1238
1259
|
base: ReadonlyArray<{ record: PartRecord; image: Raster }>,
|
|
@@ -1466,6 +1487,7 @@ export function contourBodyTurnRemedies(lines: readonly string[], cfg: Character
|
|
|
1466
1487
|
}
|
|
1467
1488
|
|
|
1468
1489
|
export interface RigStageInput {
|
|
1490
|
+
assemblyRules?: AssemblyRules;
|
|
1469
1491
|
config: string;
|
|
1470
1492
|
/** The directory holding parts.json and parts/<name>.png. */
|
|
1471
1493
|
parts: string;
|
|
@@ -1855,9 +1877,10 @@ export interface RigInputs {
|
|
|
1855
1877
|
* `src/meshstats.ts`) both start here, so the two read the same config, the same parts and the same images, and a
|
|
1856
1878
|
* PNG that is missing is left out of the map for `buildRig` to refuse by name (`RIG_PNG_PRESENT`).
|
|
1857
1879
|
*/
|
|
1858
|
-
export function readRigInputs(config: string, partsDir: string): RigInputs {
|
|
1880
|
+
export function readRigInputs(config: string, partsDir: string, assemblyRules?: AssemblyRules): RigInputs {
|
|
1859
1881
|
const { config: cfg, animations: from } = loadConfigAndAnimations(config);
|
|
1860
1882
|
const parts = readParts(join(partsDir, 'parts.json'));
|
|
1883
|
+
refuseStaleAssembly(config, parts, cfg, assemblyRules);
|
|
1861
1884
|
const images = new Map<string, Raster>();
|
|
1862
1885
|
const depthProblems: Problem[] = [];
|
|
1863
1886
|
for (const p of parts.parts) {
|
|
@@ -1892,7 +1915,7 @@ export function rigOutputTexts(r: RigOutput, animations: Parameters<typeof withA
|
|
|
1892
1915
|
|
|
1893
1916
|
export function rigStage(input: RigStageInput, rigc: RigcRunner, scratch: string, log: Log): RigOutput {
|
|
1894
1917
|
const pageSize = parsePageSize(input.pageSize);
|
|
1895
|
-
const { cfg, from, parts, images } = readRigInputs(input.config, input.parts);
|
|
1918
|
+
const { cfg, from, parts, images } = readRigInputs(input.config, input.parts, input.assemblyRules);
|
|
1896
1919
|
const first = buildRig(cfg, parts, images, undefined, input.idleKeys ?? DEFAULT_IDLE_KEYS, input.reduce);
|
|
1897
1920
|
const textsOf = (r: RigOutput): Array<[string, string]> => rigOutputTexts(r, from === null ? null : from.table);
|
|
1898
1921
|
const firstTexts = textsOf(first);
|
|
@@ -2062,6 +2085,7 @@ export function rigStage(input: RigStageInput, rigc: RigcRunner, scratch: string
|
|
|
2062
2085
|
// ---------------------------------------------------------------------------
|
|
2063
2086
|
|
|
2064
2087
|
export interface CheckStageInput {
|
|
2088
|
+
assemblyRules?: AssemblyRules;
|
|
2065
2089
|
/** The directory holding rig.json and motion.json. */
|
|
2066
2090
|
rig: string;
|
|
2067
2091
|
/**
|
|
@@ -2346,7 +2370,7 @@ export function checkStage(input: CheckStageInput, rigc: RigcRunner, bin: string
|
|
|
2346
2370
|
const entryLine = versionLines.find((l) => l.startsWith('entry:'));
|
|
2347
2371
|
log(` ${rigcIdentity(bin, v)}${entryLine === undefined ? '' : `; ${entryLine}`}`);
|
|
2348
2372
|
const mode: PackMode = { pageEdges: input.pageEdges ?? DEFAULT_PAGE_EDGES, packShape: input.packShape ?? DEFAULT_PACK_SHAPE, ...(pageSize === undefined ? {} : { pageSize }) };
|
|
2349
|
-
const r = runCheck(input.rig, input.out, rigc, input.parts, mode, input.source, input.requirements, input.seamPairs === true, input.keepStills === true, input.set, input.allSets === true, input.environment, input.requirementsAs, input.config, input.windBand, input.noExtremes === true, input.supportSource, input.supportFigure);
|
|
2373
|
+
const r = runCheck(input.rig, input.out, rigc, input.parts, mode, input.source, input.requirements, input.seamPairs === true, input.keepStills === true, input.set, input.allSets === true, input.environment, input.requirementsAs, input.config, input.windBand, input.noExtremes === true, input.supportSource, input.supportFigure, input.assemblyRules);
|
|
2350
2374
|
if (r.figures.environment !== undefined) log(` ${environmentLine(r.figures.environment)}`);
|
|
2351
2375
|
log(` gate rig-play (rigc ${packedBuildLabel(mode)}), verbatim:`);
|
|
2352
2376
|
for (const l of r.gateHtml) log(l);
|
|
@@ -2899,6 +2923,7 @@ export function build(input: BuildInput, run: BuildRunners, log: Log): BuildResu
|
|
|
2899
2923
|
// cannot be measured without it; a build without that declaration hands it nothing, as before, and writes the same bytes.
|
|
2900
2924
|
let paintingForCheck: string | null = null;
|
|
2901
2925
|
let supportFigure: Mask | undefined;
|
|
2926
|
+
let assemblyRules: Required<AssemblyRules>;
|
|
2902
2927
|
try {
|
|
2903
2928
|
pageSize = parsePageSize(input.pageSize);
|
|
2904
2929
|
// build runs rig next, which needs the whole config, so the full loader is
|
|
@@ -2908,8 +2933,8 @@ export function build(input: BuildInput, run: BuildRunners, log: Log): BuildResu
|
|
|
2908
2933
|
// Issue #556: the flag, or the config's declaration when there is none; both naming other bytes is refused here.
|
|
2909
2934
|
// Issue #607: the bytes this read parsed are the ones check.json's config record hashes, under the path as typed.
|
|
2910
2935
|
const loaded = loadConfigWithBytes(input.config);
|
|
2911
|
-
|
|
2912
|
-
const
|
|
2936
|
+
assemblyRules = effectiveAssemblyRules(loaded.config.assemble, input);
|
|
2937
|
+
const { seam, project } = assemblyRules;
|
|
2913
2938
|
log(`rig-parts build: ${input.config} -> ${out}, seam rule ${seam}, projection rule ${project}, page edges ${input.pageEdges}, pack shape ${input.packShape ?? DEFAULT_PACK_SHAPE}${idleKeys === DEFAULT_IDLE_KEYS ? '' : `, idle keys ${idleKeys}`}${input.loop ? `, with the idle loop${input.leadIn === undefined ? '' : ` after a lead-in of ${input.leadIn} period(s)`}` : ''}`);
|
|
2914
2939
|
configRecord = inputFileRecord(loaded.bytes, input.config);
|
|
2915
2940
|
req = buildRequirements(input.requirements, loaded.config.requirements, input.config);
|
|
@@ -2930,14 +2955,14 @@ export function build(input: BuildInput, run: BuildRunners, log: Log): BuildResu
|
|
|
2930
2955
|
}
|
|
2931
2956
|
|
|
2932
2957
|
try {
|
|
2933
|
-
stages.rig({ config: input.config, parts: out, out: join(out, 'rig'), idleKeys, pageEdges: input.pageEdges, packShape: input.packShape, ...(pageSize === undefined ? {} : { pageSize }), command: 'build' }, run.rig, run.scratch, prefixed('rig'));
|
|
2958
|
+
stages.rig({ config: input.config, assemblyRules, parts: out, out: join(out, 'rig'), idleKeys, pageEdges: input.pageEdges, packShape: input.packShape, ...(pageSize === undefined ? {} : { pageSize }), command: 'build' }, run.rig, run.scratch, prefixed('rig'));
|
|
2934
2959
|
} catch (err) {
|
|
2935
2960
|
return refused('rig', err);
|
|
2936
2961
|
}
|
|
2937
2962
|
|
|
2938
2963
|
let report: CheckReport;
|
|
2939
2964
|
try {
|
|
2940
|
-
report = stages.check({ rig: join(out, 'rig'), parts: out, supportSource: input.source, ...(supportFigure === undefined ? {} : { supportFigure }), out: join(out, 'check'), pageEdges: input.pageEdges, packShape: input.packShape, ...(pageSize === undefined ? {} : { pageSize }), ...(req === null ? {} : { requirements: req.read, requirementsAs: req.recorded }), ...(paintingForCheck === null ? {} : { source: paintingForCheck }), seamPairs: input.seamPairs === true, keepStills: input.keepStills === true, noExtremes: input.noExtremes === true, ...(input.set === undefined ? {} : { set: input.set }), allSets: input.allSets === true, ...(input.environment === undefined ? {} : { environment: input.environment }), ...(input.windBand === undefined ? {} : { windBand: input.windBand }), ...(configRecord === null ? {} : { config: configRecord }) }, run.check, run.checkBin, prefixed('check'));
|
|
2965
|
+
report = stages.check({ rig: join(out, 'rig'), assemblyRules, parts: out, supportSource: input.source, ...(supportFigure === undefined ? {} : { supportFigure }), out: join(out, 'check'), pageEdges: input.pageEdges, packShape: input.packShape, ...(pageSize === undefined ? {} : { pageSize }), ...(req === null ? {} : { requirements: req.read, requirementsAs: req.recorded }), ...(paintingForCheck === null ? {} : { source: paintingForCheck }), seamPairs: input.seamPairs === true, keepStills: input.keepStills === true, noExtremes: input.noExtremes === true, ...(input.set === undefined ? {} : { set: input.set }), allSets: input.allSets === true, ...(input.environment === undefined ? {} : { environment: input.environment }), ...(input.windBand === undefined ? {} : { windBand: input.windBand }), ...(configRecord === null ? {} : { config: configRecord }) }, run.check, run.checkBin, prefixed('check'));
|
|
2941
2966
|
} catch (err) {
|
|
2942
2967
|
return refused('check', err);
|
|
2943
2968
|
}
|
package/src/check.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { refuseStaleAssembly, type AssemblyRules } from './assembly-reading.ts';
|
|
1
2
|
import { checkRow, checkSlotRow, checkSlotParts, serializeCheckRows } from './checkrow.ts';
|
|
2
3
|
import { readSetupFigureMask } from './setupfiguremask.ts';
|
|
3
4
|
import { readSetupBackdrop } from './setupbackdrop.ts';
|
|
@@ -42,7 +43,7 @@ import { baseAnchorMoves, type AnchorRegion } from './baseanchor.ts';
|
|
|
42
43
|
*
|
|
43
44
|
* | output | what |
|
|
44
45
|
* | --- | --- |
|
|
45
|
-
* | `build
|
|
46
|
+
* | `build/`, `build-report.json` | `rigc build --profile rig-play --pack --page-edges free --pack-shape polygon` (or `pot`, `rect`, when the caller names them; {@link PAGE_EDGES}, {@link PACK_SHAPES}) — the packed atlas is the final artifact, and `build-report.json` beside `build/` holds rigc's own `build-report/1` (`--report`) for that primary packed compile on a failing compile as on a green one (issue #1394) |
|
|
46
47
|
* | `gate_spine-html.txt` | that build's gate lines, verbatim — the one gate: rigc's `build` runs it once over the compile and once over the packed pages on disk, and `rig-play` holds every rule `spine` measures (selftest `CH09`) |
|
|
47
48
|
* | `idle_frames/` | `rigc render --animation idle --fps 12 --max 640 --geometry`: `frames.json` + `idle/f*.png` + `idle/geometry.json` (each mesh's skinned vertices, which `TEXTURE_STRETCH` reads, every attachment's posed triangles, which `TIP_OVER_ROOT` and both halves of `STILL_REGIONS_DARK` read since issues #118 and #123, and every bone's world transform, which the face half reads its head bone from) |
|
|
48
49
|
* | `contact.png` | rigc's own contact sheet of that render, copied out |
|
|
@@ -6791,7 +6792,7 @@ function renderExtremes(build: string, out: string, animations: readonly string[
|
|
|
6791
6792
|
* MEASURABLE is a problem. Without it nothing here reads, writes or prints
|
|
6792
6793
|
* anything it did not before.
|
|
6793
6794
|
*/
|
|
6794
|
-
export function runCheck(rigDir: string, outDir: string, rigc: RigcRunner, partsHome?: string, mode: PackMode = DEFAULT_PACK_MODE, source?: string, requirements?: string, seamPairsAsked = false, keepStills = false, set?: string, allSets = false, environment?: string, requirementsAs: string | undefined = requirements, config?: InputFileRecord, windBand?: string, noExtremes = false, supportSource?: string, supportFigure?: Mask): CheckReport {
|
|
6795
|
+
export function runCheck(rigDir: string, outDir: string, rigc: RigcRunner, partsHome?: string, mode: PackMode = DEFAULT_PACK_MODE, source?: string, requirements?: string, seamPairsAsked = false, keepStills = false, set?: string, allSets = false, environment?: string, requirementsAs: string | undefined = requirements, config?: InputFileRecord, windBand?: string, noExtremes = false, supportSource?: string, supportFigure?: Mask, assemblyRules?: AssemblyRules): CheckReport {
|
|
6795
6796
|
const pageSize = parsePageSize(mode.pageSize);
|
|
6796
6797
|
let inp: CheckInputs;
|
|
6797
6798
|
let reqFile: RequirementsFile | null = null;
|
|
@@ -6808,6 +6809,11 @@ export function runCheck(rigDir: string, outDir: string, rigc: RigcRunner, parts
|
|
|
6808
6809
|
return null;
|
|
6809
6810
|
}
|
|
6810
6811
|
};
|
|
6812
|
+
const readInputs = (): CheckInputs => {
|
|
6813
|
+
const inputs = readCheckInputs(rigDir, partsHome, source, set, allSets);
|
|
6814
|
+
if (config !== undefined && inputs.parts !== null) refuseStaleAssembly(config.path, inputs.parts, undefined, assemblyRules);
|
|
6815
|
+
return inputs;
|
|
6816
|
+
};
|
|
6811
6817
|
let setupBackdrop: Raster | undefined;
|
|
6812
6818
|
let setupFigureMask: Uint8Array | undefined;
|
|
6813
6819
|
// Issue #538: the schedule is read once, first, by rigc's own reader; refused, nothing is built or written.
|
|
@@ -6815,12 +6821,12 @@ export function runCheck(rigDir: string, outDir: string, rigc: RigcRunner, parts
|
|
|
6815
6821
|
// Issue #590: the steady-wind band spec is read and resolved before anything is built or written.
|
|
6816
6822
|
const wb = windBand === undefined ? null : take(() => readWindBand(windBand));
|
|
6817
6823
|
if (requirements === undefined) {
|
|
6818
|
-
const got = take(
|
|
6824
|
+
const got = take(readInputs);
|
|
6819
6825
|
if (got !== null && wb !== null) take(() => resolveWindBand(wb, got));
|
|
6820
6826
|
refuseIfAny(refused);
|
|
6821
6827
|
inp = got as CheckInputs;
|
|
6822
6828
|
} else {
|
|
6823
|
-
const got = take(
|
|
6829
|
+
const got = take(readInputs);
|
|
6824
6830
|
reqFile = take(() => readRequirements(requirements));
|
|
6825
6831
|
if (got === null || reqFile === null) {
|
|
6826
6832
|
if (got !== null && wb !== null) take(() => resolveWindBand(wb, got));
|
|
@@ -6892,7 +6898,7 @@ export function runCheck(rigDir: string, outDir: string, rigc: RigcRunner, parts
|
|
|
6892
6898
|
const out = resolve(outDir);
|
|
6893
6899
|
const outExisted = existsSync(out);
|
|
6894
6900
|
mkdirSync(out, { recursive: true });
|
|
6895
|
-
const buildDir = join(out, 'build');
|
|
6901
|
+
const buildDir = join(out, 'build'), buildReportPath = join(out, BUILD_REPORT_FILE);
|
|
6896
6902
|
const idleDir = join(out, 'idle_frames');
|
|
6897
6903
|
const stillDir = join(out, '_still');
|
|
6898
6904
|
const isoDir = join(out, '_isolated');
|
|
@@ -6902,7 +6908,7 @@ export function runCheck(rigDir: string, outDir: string, rigc: RigcRunner, parts
|
|
|
6902
6908
|
const foldDir = join(out, FOLD_SCRATCH);
|
|
6903
6909
|
const seamMotionDir = join(out, MOTION_SEAM_SCRATCH);
|
|
6904
6910
|
const windBandDir = join(out, WIND_BAND_SCRATCH);
|
|
6905
|
-
for (const d of [join(out, 'extremes'), join(out, '_extremes'), buildDir, idleDir, stillDir, isoDir, loopDir, seamDir, keptDir, join(out, 'setup_still_auto'), foldDir, seamMotionDir, windBandDir]) rmSync(d, { recursive: true, force: true });
|
|
6911
|
+
for (const d of [join(out, 'extremes'), join(out, '_extremes'), buildDir, buildReportPath, idleDir, stillDir, isoDir, loopDir, seamDir, keptDir, join(out, 'setup_still_auto'), foldDir, seamMotionDir, windBandDir]) rmSync(d, { recursive: true, force: true });
|
|
6906
6912
|
const written: string[] = [];
|
|
6907
6913
|
const write = (name: string, data: string): void => {
|
|
6908
6914
|
writeFileSync(join(out, name), data);
|
|
@@ -6911,9 +6917,9 @@ export function runCheck(rigDir: string, outDir: string, rigc: RigcRunner, parts
|
|
|
6911
6917
|
|
|
6912
6918
|
try {
|
|
6913
6919
|
// 1. build, packed, under the policy profile
|
|
6914
|
-
const build = rigc(['build', '--rig', inp.rigPath, '--motion', inp.motionPath, '--out', buildDir, ...packedBuildArgs(mode)]);
|
|
6920
|
+
const build = rigc(['build', '--rig', inp.rigPath, '--motion', inp.motionPath, '--out', buildDir, '--report', buildReportPath, ...packedBuildArgs(mode)]);
|
|
6915
6921
|
const gateHtml = buildGateLines(build.out);
|
|
6916
|
-
write('gate_spine-html.txt', `${gateHtml.join('\n')}\n`);
|
|
6922
|
+
write('gate_spine-html.txt', `${gateHtml.join('\n')}\n`); if (existsSync(buildReportPath)) written.push(BUILD_REPORT_FILE);
|
|
6917
6923
|
if (build.status !== 0) refuseIfAny(rigcFailed(packedBuildLabel(mode), build, gateHtml));
|
|
6918
6924
|
const pack = parsePackLines(gateHtml);
|
|
6919
6925
|
refuseIfAny(packEdgeProblems(pack, mode));
|
|
@@ -6965,7 +6971,7 @@ export function runCheck(rigDir: string, outDir: string, rigc: RigcRunner, parts
|
|
|
6965
6971
|
windBandRead = measureWindBand(wb, buildDir, windBandDir, animationNames, rigc);
|
|
6966
6972
|
} catch (err) {
|
|
6967
6973
|
rmSync(windBandDir, { recursive: true, force: true });
|
|
6968
|
-
|
|
6974
|
+
for (const p of [join(out, 'gate_spine-html.txt'), buildReportPath]) rmSync(p, { force: true });
|
|
6969
6975
|
rmSync(buildDir, { recursive: true, force: true });
|
|
6970
6976
|
if (!outExisted) rmSync(out, { recursive: true, force: true });
|
|
6971
6977
|
throw err;
|
|
@@ -9962,3 +9968,6 @@ export function stretchLine(geo: IdleGeometry | null, path: string, problems: Pr
|
|
|
9962
9968
|
per_mesh: rows,
|
|
9963
9969
|
};
|
|
9964
9970
|
}
|
|
9971
|
+
|
|
9972
|
+
/** The compiler's `build-report/1` (`--report`) written beside `build/` on the primary packed compile (issue #1394). */
|
|
9973
|
+
export const BUILD_REPORT_FILE = 'build-report.json';
|
package/src/config.ts
CHANGED
|
@@ -349,7 +349,7 @@ export interface Assemble {
|
|
|
349
349
|
/** Issue #492: composite full:face under head:face on the head canvas to fill transparent holes inside the face silhouette. */
|
|
350
350
|
head_face_underfill?: boolean;
|
|
351
351
|
/** Opt-in: yield original drift-refused front cores and connected non-core rims to an opaque behind holder matching the painting. */
|
|
352
|
-
yield_refused?: boolean;
|
|
352
|
+
yield_refused?: boolean | string[];
|
|
353
353
|
/** Emit the report-only last-writer sidecar; absent or false is off. */
|
|
354
354
|
stage_map?: boolean;
|
|
355
355
|
/** Named plan parts retain their own pixels beneath a drawn-in-front soft occluder. */
|
|
@@ -940,15 +940,15 @@ export function partBoundBones(b: PartBinding): Map<string, string[]> {
|
|
|
940
940
|
* Returns null when `config.turn` is absent, so a rig without a turn block is
|
|
941
941
|
* untouched.
|
|
942
942
|
*/
|
|
943
|
-
export function turnMovingPartPair(
|
|
943
|
+
export function turnMovingPartPair<C extends Pick<ConfigConstraint, 'type'> & { bone?: unknown }>(
|
|
944
944
|
cfg: {
|
|
945
945
|
assemble?: CharacterConfig['assemble'];
|
|
946
946
|
turn?: TurnSpec;
|
|
947
947
|
bones?: BoneEntry[];
|
|
948
948
|
meshes?: Record<string, MeshSpec>;
|
|
949
949
|
regions?: Record<string, RegionSpec>;
|
|
950
|
-
limbs?: Record<string, Limb
|
|
951
|
-
constraints?:
|
|
950
|
+
limbs?: Record<string, Pick<Limb, 'segments'>>;
|
|
951
|
+
constraints?: C[];
|
|
952
952
|
},
|
|
953
953
|
): ((a: string, b: string) => boolean) | null {
|
|
954
954
|
const turn = cfg.turn;
|
|
@@ -1794,7 +1794,7 @@ export interface EarlyConfig {
|
|
|
1794
1794
|
depth?: DepthConfig;
|
|
1795
1795
|
key: string;
|
|
1796
1796
|
seethrough: SeeThrough;
|
|
1797
|
-
assemble: { rig_scale: number; seam?: SeamRule; project?: ProjectRule; ground?: Ground; take?: TakeDeclaration[]; editor_receipts?: EditorReceipts; edited_parts?: EditedParts; head_face_underfill?: boolean; yield_refused?: boolean; stage_map?: boolean; keep_under_occluders?: string[]; require_hidden_extent?: HiddenExtentDeclaration[]; extend_painting?: PaintingExtension[]; occluders?: OccluderDeclaration[]; edge_splits?: EdgeSplit[] };
|
|
1797
|
+
assemble: { rig_scale: number; seam?: SeamRule; project?: ProjectRule; ground?: Ground; take?: TakeDeclaration[]; editor_receipts?: EditorReceipts; edited_parts?: EditedParts; head_face_underfill?: boolean; yield_refused?: boolean | string[]; stage_map?: boolean; keep_under_occluders?: string[]; require_hidden_extent?: HiddenExtentDeclaration[]; extend_painting?: PaintingExtension[]; occluders?: OccluderDeclaration[]; edge_splits?: EdgeSplit[] };
|
|
1798
1798
|
}
|
|
1799
1799
|
|
|
1800
1800
|
/** What plain `assemble` reads: the early config plus the plan `--propose-plan` printed. */
|
|
@@ -1890,9 +1890,7 @@ function parseEarlyConfigFrom(raw: Json, door: EarlyDoor, base: string | null, p
|
|
|
1890
1890
|
if ('take' in a) checkTakeLayers(c, a.take, null, a);
|
|
1891
1891
|
if ('editor_receipts' in a) checkEditorReceipts(c, a.editor_receipts);
|
|
1892
1892
|
if ('edited_parts' in a) checkEditedParts(c, a.edited_parts, a.plan);
|
|
1893
|
-
|
|
1894
|
-
c.fail('CONFIG_FIELD_TYPE', 'config.assemble.yield_refused', `is ${show(a.yield_refused)}; true or false is required`);
|
|
1895
|
-
}
|
|
1893
|
+
checkYieldRefused(c, a);
|
|
1896
1894
|
}
|
|
1897
1895
|
}
|
|
1898
1896
|
}
|
|
@@ -1920,6 +1918,7 @@ function parseEarlyConfigFrom(raw: Json, door: EarlyDoor, base: string | null, p
|
|
|
1920
1918
|
checkAlternates(c, t.assemble.alternates, made, limbs, names?.bones ?? null, names?.chains ?? null, t.regions, t.meshes);
|
|
1921
1919
|
}
|
|
1922
1920
|
const output = new Set([...made.parts.filter(n => !limbs?.consumed.has(n)), ...made.patches, ...made.cuts, ...(limbs?.parts.keys() ?? [])]);
|
|
1921
|
+
if (isPlainObject(t.assemble)) checkYieldRefused(c, t.assemble, new Set([...finalLayerPartNames(made.parts, made.cuts, limbs), ...made.patches]), limbs);
|
|
1923
1922
|
if (isPlainObject(t.assemble) && 'extend_painting' in t.assemble) checkPaintingExtensions(c, t.assemble.extend_painting, new Set([...output].filter(n => !made.patches.includes(n) && !limbs?.consumed.has(n))));
|
|
1924
1923
|
if ('motion_seams' in t) {
|
|
1925
1924
|
c.problems.push(...motionSeamProblems(t.motion_seams, output, 'config.motion_seams', 'CONFIG_MOTION_SEAM'));
|
|
@@ -2141,9 +2140,10 @@ function parseConfigFrom(raw: Json, base: string | null): { config: CharacterCon
|
|
|
2141
2140
|
if (isPlainObject(t.assemble) && 'alternates' in t.assemble) {
|
|
2142
2141
|
checkAlternates(c, t.assemble.alternates, { parts, patches, cuts }, limbs, names.bones, names.chains, t.regions, t.meshes);
|
|
2143
2142
|
}
|
|
2144
|
-
if (isPlainObject(t.assemble)
|
|
2145
|
-
const output =
|
|
2146
|
-
|
|
2143
|
+
if (isPlainObject(t.assemble)) {
|
|
2144
|
+
const output = finalLayerPartNames(parts, cuts, limbs);
|
|
2145
|
+
checkYieldRefused(c, t.assemble, new Set([...output, ...patches]), limbs);
|
|
2146
|
+
if ('extend_painting' in t.assemble) checkPaintingExtensions(c, t.assemble.extend_painting, output);
|
|
2147
2147
|
}
|
|
2148
2148
|
if ('meshes' in t) checkMeshes(c, t.meshes, names.bones, names.chains, t.stops);
|
|
2149
2149
|
if ('regions' in t) checkRegions(c, t.regions, names.bones);
|
|
@@ -2722,6 +2722,43 @@ function checkOccluderFiles(c: Check, assemble: Json, base: string | null): void
|
|
|
2722
2722
|
c.problems.push(...occluderFileProblems(declarations, base));
|
|
2723
2723
|
}
|
|
2724
2724
|
|
|
2725
|
+
function finalLayerPartNames(parts: readonly string[], cuts: readonly string[], limbs: LimbNames | null): Set<string> {
|
|
2726
|
+
return new Set([...parts, ...cuts].filter(name => !limbs?.consumed.has(name)).concat([...(limbs?.parts.keys() ?? [])]));
|
|
2727
|
+
}
|
|
2728
|
+
|
|
2729
|
+
function checkYieldRefused(c: Check, assemble: Record<string, Json>, outputs?: Set<string>, limbs?: LimbNames | null): void {
|
|
2730
|
+
const value = assemble.yield_refused;
|
|
2731
|
+
if (!('yield_refused' in assemble) || typeof value === 'boolean') return;
|
|
2732
|
+
const at = 'config.assemble.yield_refused';
|
|
2733
|
+
if (!Array.isArray(value)) {
|
|
2734
|
+
c.fail('CONFIG_FIELD_TYPE', at, `is ${show(value)}; true, false or a list of final yielding part names is required`);
|
|
2735
|
+
return;
|
|
2736
|
+
}
|
|
2737
|
+
if (value.length === 0) c.fail('CONFIG_FIELD_TYPE', at, 'is []; use false or omit the key to disable yield');
|
|
2738
|
+
const names = outputs === undefined ? undefined : new Set(outputs);
|
|
2739
|
+
if (names !== undefined && Array.isArray(assemble.alternates)) {
|
|
2740
|
+
for (const alternate of assemble.alternates.filter(isPlainObject)) {
|
|
2741
|
+
if (!Array.isArray(alternate.cuts)) continue;
|
|
2742
|
+
for (const cut of alternate.cuts.filter(isPlainObject)) if (typeof cut.into === 'string') names.add(cut.into);
|
|
2743
|
+
}
|
|
2744
|
+
}
|
|
2745
|
+
const seen = new Set<string>();
|
|
2746
|
+
for (const [i, name] of value.entries()) {
|
|
2747
|
+
const entry = `${at}[${i}]`;
|
|
2748
|
+
if (!c.string(entry, name)) continue;
|
|
2749
|
+
if (seen.has(name)) c.fail('CONFIG_PART_UNIQUE', entry, `names ${show(name)} again; each yielding part is named once`);
|
|
2750
|
+
seen.add(name);
|
|
2751
|
+
if (names !== undefined && !names.has(name)) {
|
|
2752
|
+
const limb = limbs?.consumed.get(name);
|
|
2753
|
+
const segments = limb === undefined ? [] : limbs?.chains.get(limb)?.parts ?? [];
|
|
2754
|
+
const detail = limb === undefined
|
|
2755
|
+
? 'a final output part name is required (source tags and aliases are not accepted)'
|
|
2756
|
+
: `config.limbs.${limb} consumes it; list its final segment parts instead (${segments.map(part => show(part)).join(', ')})`;
|
|
2757
|
+
c.fail('CONFIG_NAME_RESOLVES', entry, `names ${show(name)}; ${detail}`);
|
|
2758
|
+
}
|
|
2759
|
+
}
|
|
2760
|
+
}
|
|
2761
|
+
|
|
2725
2762
|
function checkKeepUnderOccluders(c: Check, a: Record<string, Json>, plan: readonly string[] | null): void {
|
|
2726
2763
|
if (!('keep_under_occluders' in a)) return;
|
|
2727
2764
|
const at = 'config.assemble.keep_under_occluders';
|
|
@@ -2924,9 +2961,6 @@ function checkAssemble(c: Check, v: Json, door: 'assemble' | 'full'): { parts: s
|
|
|
2924
2961
|
if ('head_face_underfill' in a && typeof a.head_face_underfill !== 'boolean') {
|
|
2925
2962
|
c.fail('CONFIG_FIELD_TYPE', `${p}.head_face_underfill`, `is ${show(a.head_face_underfill)}; true or false is required`);
|
|
2926
2963
|
}
|
|
2927
|
-
if ('yield_refused' in a && typeof a.yield_refused !== 'boolean') {
|
|
2928
|
-
c.fail('CONFIG_FIELD_TYPE', `${p}.yield_refused`, `is ${show(a.yield_refused)}; true or false is required`);
|
|
2929
|
-
}
|
|
2930
2964
|
if ('stage_map' in a && typeof a.stage_map !== 'boolean') {
|
|
2931
2965
|
c.fail('CONFIG_FIELD_TYPE', `${p}.stage_map`, `is ${show(a.stage_map)}; true or false is required`);
|
|
2932
2966
|
}
|
package/src/configrelocation.ts
CHANGED
|
@@ -6,9 +6,56 @@ function object(value: unknown): value is Record<string, unknown> {
|
|
|
6
6
|
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
+
// The public reference inventory predates assembly fingerprinting. Writers
|
|
10
|
+
// must also preserve these config-relative assembly inputs at their new base.
|
|
11
|
+
function relocateAssemblyFiles(raw: unknown, relocate: (value: string) => string): void {
|
|
12
|
+
const fields = (entry: unknown, keys: readonly string[]): void => {
|
|
13
|
+
if (!object(entry)) return;
|
|
14
|
+
for (const key of keys) {
|
|
15
|
+
const value = entry[key];
|
|
16
|
+
if (typeof value === 'string' && value !== '' && !isAbsolute(value)) entry[key] = relocate(value);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
const entries = (value: unknown): Record<string, unknown>[] => Array.isArray(value) ? value.filter(object) : [];
|
|
20
|
+
const cuts = (value: unknown): void => {
|
|
21
|
+
for (const cut of entries(value)) {
|
|
22
|
+
fields(cut, ['under']);
|
|
23
|
+
fields(cut.under, ['plate']);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
if (!object(raw)) return;
|
|
27
|
+
if (object(raw.assemble)) {
|
|
28
|
+
cuts(raw.assemble.cuts);
|
|
29
|
+
for (const alt of entries(raw.assemble.alternates)) {
|
|
30
|
+
fields(alt, ['source', 'full', 'head', 'skeleton']);
|
|
31
|
+
cuts(alt.cuts);
|
|
32
|
+
}
|
|
33
|
+
for (const take of entries(raw.assemble.take)) {
|
|
34
|
+
fields(take, ['run_dir', 'st_input']);
|
|
35
|
+
fields(take.reference, ['painting']);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (object(raw.limbs)) {
|
|
39
|
+
for (const limb of Object.values(raw.limbs).filter(object)) {
|
|
40
|
+
for (const segment of entries(limb.segments)) fields(segment, ['cap']);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (object(raw.depth)) {
|
|
44
|
+
for (const run of [raw.depth.full, raw.depth.head].filter(object)) {
|
|
45
|
+
fields(run.atlas, ['image']);
|
|
46
|
+
if (object(run.layers)) for (const layer of Object.values(run.layers)) fields(layer, ['image']);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
9
51
|
/** Preserve the public reference inventory while giving writers canonical edited-part paths. */
|
|
10
52
|
export function relocateConfigReferences(raw: unknown, configDir: string, out: string, mode: 'relative' | 'absolute'): void {
|
|
53
|
+
const pathAt = (value: string): string => {
|
|
54
|
+
const target = resolve(configDir, value);
|
|
55
|
+
return mode === 'relative' ? relative(resolve(out), target) || '.' : target;
|
|
56
|
+
};
|
|
11
57
|
const refs = configFileReferences(raw);
|
|
58
|
+
relocateAssemblyFiles(raw, pathAt);
|
|
12
59
|
const assemble = object(raw) ? raw.assemble : undefined;
|
|
13
60
|
const edited = object(assemble) ? assemble.edited_parts : undefined;
|
|
14
61
|
// Do not repair invalid dirs or replace the loader's existing relative-only refusals.
|
|
@@ -19,7 +66,6 @@ export function relocateConfigReferences(raw: unknown, configDir: string, out: s
|
|
|
19
66
|
for (const ref of refs) {
|
|
20
67
|
if (ref.at.startsWith('assemble.edited_parts.receipts[')) continue;
|
|
21
68
|
if (mode === 'absolute' && isAbsolute(ref.value)) continue;
|
|
22
|
-
|
|
23
|
-
ref.set(mode === 'relative' ? relative(resolve(out), target) : target);
|
|
69
|
+
ref.set(pathAt(ref.value));
|
|
24
70
|
}
|
|
25
71
|
}
|
package/src/configwrite.ts
CHANGED
|
@@ -14,7 +14,7 @@ import type { CharacterConfig } from './config.ts';
|
|
|
14
14
|
import { orderedEditedPartReceipt, type EditedPartReceipt } from './editedparts.ts';
|
|
15
15
|
import type { Proposal, PROPOSAL_CONFIG_SECTIONS } from './propose.ts';
|
|
16
16
|
import { PartsError } from './errors.ts';
|
|
17
|
-
import { parseConfig, parseProposalSections } from './config.ts';
|
|
17
|
+
import { parseConfig, parseEarlyConfig, parseProposalSections } from './config.ts';
|
|
18
18
|
import type { ConfigEdit } from './meshdraft.ts';
|
|
19
19
|
|
|
20
20
|
export type ConfigJson = null | boolean | number | string | ConfigJson[] | ConfigObject;
|
|
@@ -88,15 +88,17 @@ function changes(before: ConfigObject, after: ConfigObject, parent = ''): Config
|
|
|
88
88
|
return result;
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
/** The caller validates the returned candidate through its existing config door before saving it.
|
|
92
|
-
|
|
91
|
+
/** The caller validates the returned candidate through its existing config door before saving it.
|
|
92
|
+
* Receipt patches can also read a source config through the assembly door.
|
|
93
|
+
*/
|
|
94
|
+
export function mergeConfigProposal(raw: unknown, patch: ConfigWritePatch, receiptDoor: 'full' | 'assemble' = 'full'): ConfigWriteResult {
|
|
93
95
|
if (!object(raw)) return refuse('config', 'is not an object; an existing config JSON object is required');
|
|
94
96
|
const before = clone(raw, 'config') as ConfigObject;
|
|
95
97
|
const config = clone(before, 'config') as ConfigObject;
|
|
96
98
|
const edits: ConfigEdit[] = [];
|
|
97
99
|
switch (patch.kind) {
|
|
98
100
|
case 'edited-part-receipt': {
|
|
99
|
-
const checked = parseConfig(before);
|
|
101
|
+
const checked = receiptDoor === 'assemble' ? parseEarlyConfig(before, 'assemble') : parseConfig(before);
|
|
100
102
|
const spec = checked.assemble.edited_parts;
|
|
101
103
|
if (spec === undefined) throw new PartsError([{ code: 'EDITED_PART_BLOCK', object: 'config.assemble.edited_parts', detail: 'has no assemble.edited_parts; declare {dir, receipts: []} before recording an edited part' }]);
|
|
102
104
|
const { part } = patch.receipt;
|
package/src/depthworkflow.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import { createHash } from 'node:crypto';
|
|
6
6
|
import { existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, realpathSync, statSync, writeFileSync } from 'node:fs';
|
|
7
7
|
import { basename, dirname, join, relative, resolve, sep } from 'node:path';
|
|
8
|
+
import { refuseStaleAssembly } from './assembly-reading.ts';
|
|
8
9
|
import { loadConfigAndAnimations, parseConfig } from './config.ts';
|
|
9
10
|
import { relocateConfigReferences } from './configrelocation.ts';
|
|
10
11
|
import { depthReading, readSourceDepth } from './depthsheets.ts';
|
|
@@ -223,7 +224,8 @@ export function applyDepth(input: { parts: string; manifest: string; config: str
|
|
|
223
224
|
emptyOutput(input.out, [input.parts, input.config, input.manifest, input.rigConfig, ...Object.values(recipe.parts).flatMap(p => { const map = resolve(dirname(input.config), p.map); return [map, map + '.binding.json']; })]);
|
|
224
225
|
const rawParts = object(readJson(join(input.parts, 'parts.json')), 'parts.json'), file = readParts(join(input.parts, 'parts.json'));
|
|
225
226
|
for (const p of file.parts) if (Object.hasOwn(recipe.parts, p.name) && p.provenance?.depth?.kind === 'authored-unit') fail('DEPTH_AUTHORED_UNIT_CONFLICT', `part "${p.name}"`, 'has provenance.depth.kind "authored-unit"; a transported scalar reference cannot coexist with authored unit depth — retain the unit declaration or supply an explicitly reassembled scalar-compatible input; no automatic transition is made');
|
|
226
|
-
loadConfigAndAnimations(input.rigConfig);
|
|
227
|
+
const { config } = loadConfigAndAnimations(input.rigConfig);
|
|
228
|
+
refuseStaleAssembly(input.rigConfig, file, config);
|
|
227
229
|
const raw = object(readJson(input.rigConfig), 'rig config'), turn = object(raw.turn, 'config.turn');
|
|
228
230
|
for (const [name, group] of Object.entries(recipe.groups)) {
|
|
229
231
|
const target = name === 'head' ? turn : object(turn.body, 'config.turn.body'); target.pivot = group.pivot;
|
|
@@ -231,7 +233,7 @@ export function applyDepth(input: { parts: string; manifest: string; config: str
|
|
|
231
233
|
}
|
|
232
234
|
// Keep relative paths portable when relocating the output directory with its inputs.
|
|
233
235
|
relocateConfigReferences(raw, dirname(input.rigConfig), input.out, 'relative');
|
|
234
|
-
parseConfig(raw);
|
|
236
|
+
refuseStaleAssembly(join(input.out, 'config.json'), file, parseConfig(raw));
|
|
235
237
|
const warnings: string[] = [];
|
|
236
238
|
const writes = new Map<string, Uint8Array>(), rows: Obj[] = [], recs = rawParts.parts as Obj[];
|
|
237
239
|
// Retain auxiliary art (including alternate sets) and diagnostics byte-for-byte.
|
package/src/editedparts.ts
CHANGED
|
@@ -128,7 +128,12 @@ export function replaceEditedParts(
|
|
|
128
128
|
continue;
|
|
129
129
|
}
|
|
130
130
|
const found = sha(encodePngBytes(part.image));
|
|
131
|
-
if (found !== receipt.from_sha256) problems.push({
|
|
131
|
+
if (found !== receipt.from_sha256) problems.push({
|
|
132
|
+
code: 'ASSEMBLE_EDITED_PART_BASELINE', object,
|
|
133
|
+
detail: `the current assembled PNG sha256 is ${found}; receipt from_sha256 ${receipt.from_sha256} is required. ` +
|
|
134
|
+
'The assembled PNG changed since the baseline, typically because an assembly input changed. ' +
|
|
135
|
+
'Use edited-part --parts with the prior manifest and current config to check for ASSEMBLY_CONFIG_STALE and see which assembly fields changed',
|
|
136
|
+
});
|
|
132
137
|
if (image.width !== part.record.w || image.height !== part.record.h) problems.push({ code: 'ASSEMBLE_EDITED_PART_SIZE', object, detail: `edited PNG is ${image.width}x${image.height}; assembled box ${part.record.w}x${part.record.h} is required` });
|
|
133
138
|
const actual = sha(edit.bytes);
|
|
134
139
|
if (actual !== receipt.sha256) problems.push({ code: 'ASSEMBLE_EDITED_PART_SHA256', object, detail: `edited bytes sha256 is ${actual}; receipt sha256 ${receipt.sha256} is required` });
|