@rig-c/parts 2.34.0 → 2.36.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 +23 -10
- package/docs/AUTHORING.md +79 -24
- package/docs/STABILITY.md +5 -4
- package/package.json +1 -1
- package/src/assemble.ts +270 -59
- package/src/build.ts +157 -8
- package/src/config.ts +40 -12
- package/src/editreceipt.ts +3 -3
- package/src/layers.ts +2 -0
- package/src/occluders.ts +44 -7
- package/src/occluderstage.ts +5 -3
- package/src/parts.ts +118 -14
- package/src/partsource.ts +2 -0
- package/src/provenance.ts +10 -0
- package/src/remesh.ts +10 -5
- package/src/retune.ts +4 -4
- package/src/takelayers.ts +11 -1
package/src/parts.ts
CHANGED
|
@@ -392,6 +392,32 @@ export interface OccluderPlateRecord {
|
|
|
392
392
|
mask_sha256: string;
|
|
393
393
|
}
|
|
394
394
|
|
|
395
|
+
export interface OccluderGrowRecord {
|
|
396
|
+
/** Zero-based index into `config.assemble.occluders`. */
|
|
397
|
+
occluder: number;
|
|
398
|
+
/** The declared `config.assemble.occluders[occluder].image` path. */
|
|
399
|
+
image: string;
|
|
400
|
+
/** The declared positive integer `config.assemble.occluders[occluder].grow` radius in rig px. */
|
|
401
|
+
grow: number;
|
|
402
|
+
/** Rig pixels of the occluder core (`alpha > 128`) before the dilation. */
|
|
403
|
+
covered_px_before: number;
|
|
404
|
+
/** Rig pixels of the occluder core (`alpha > 128`) after the `(2 * grow + 1)^2` dilation. */
|
|
405
|
+
covered_px_after: number;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
export interface OccluderGuardRecord {
|
|
409
|
+
/** Zero-based index into `config.assemble.occluders`. */
|
|
410
|
+
occluder: number;
|
|
411
|
+
/** The declared `config.assemble.occluders[occluder].image` path. */
|
|
412
|
+
image: string;
|
|
413
|
+
/** The declared positive integer `config.assemble.occluders[occluder].guard` radius in rig px. */
|
|
414
|
+
guard: number;
|
|
415
|
+
/** Rig pixels of the occluder core (`alpha > 128`) before the dilation. */
|
|
416
|
+
guarded_px_before: number;
|
|
417
|
+
/** Rig pixels of the under keep mask (`alpha > 128` dilated by `max(grow, guard)`) for this entry. */
|
|
418
|
+
guarded_px_after: number;
|
|
419
|
+
}
|
|
420
|
+
|
|
395
421
|
export interface PartsFile {
|
|
396
422
|
/** Optional on legacy packages; binds the opaque RGB raster assemble actually read. */
|
|
397
423
|
painting_in_rig?: PaintingInRig;
|
|
@@ -411,6 +437,10 @@ export interface PartsFile {
|
|
|
411
437
|
single_run_pad?: SingleRunPad;
|
|
412
438
|
/** Written only when an `assemble.occluders` entry declares `plate` (issue #1237); absent otherwise. */
|
|
413
439
|
occluder_plates?: OccluderPlateRecord[];
|
|
440
|
+
/** Written only when an `assemble.occluders` entry declares `grow > 0` (issue #1251); absent otherwise. */
|
|
441
|
+
occluder_grow?: OccluderGrowRecord[];
|
|
442
|
+
/** Written only when an `assemble.occluders` entry declares `guard > 0` (issue #1259); absent otherwise. */
|
|
443
|
+
occluder_guard?: OccluderGuardRecord[];
|
|
414
444
|
/** Written only when alternate painting sets were assembled (issue #454); absent otherwise. */
|
|
415
445
|
alternates?: AlternatePartsRecord[];
|
|
416
446
|
}
|
|
@@ -447,9 +477,11 @@ export interface SceneRecord {
|
|
|
447
477
|
figure_mask: string;
|
|
448
478
|
}
|
|
449
479
|
|
|
450
|
-
const TOP_KEYS = ['painting_in_rig', 'rig_size', 'scale_rig_per_source', 'parts', 'ghost_px', 'recomposite', 'scene', 'occluder_plates', 'single_run_pad', 'alternates', 'motion_seams', 'cut_ownership'] as const;
|
|
451
|
-
const REQUIRED_TOP_KEYS = TOP_KEYS.filter((k) => k !== 'painting_in_rig' && k !== 'recomposite' && k !== 'scene' && k !== 'single_run_pad' && k !== 'occluder_plates' && k !== 'alternates' && k !== 'motion_seams' && k !== 'cut_ownership');
|
|
480
|
+
const TOP_KEYS = ['painting_in_rig', 'rig_size', 'scale_rig_per_source', 'parts', 'ghost_px', 'recomposite', 'scene', 'occluder_plates', 'occluder_grow', 'occluder_guard', 'single_run_pad', 'alternates', 'motion_seams', 'cut_ownership'] as const;
|
|
481
|
+
const REQUIRED_TOP_KEYS = TOP_KEYS.filter((k) => k !== 'painting_in_rig' && k !== 'recomposite' && k !== 'scene' && k !== 'single_run_pad' && k !== 'occluder_plates' && k !== 'occluder_grow' && k !== 'occluder_guard' && k !== 'alternates' && k !== 'motion_seams' && k !== 'cut_ownership');
|
|
452
482
|
export const OCCLUDER_PLATE_KEYS = ['receipt', 'receipt_sha256', 'occluder_sha256', 'painting_sha256', 'output_sha256', 'mask_sha256'] as const;
|
|
483
|
+
export const OCCLUDER_GROW_KEYS = ['occluder', 'image', 'grow', 'covered_px_before', 'covered_px_after'] as const;
|
|
484
|
+
export const OCCLUDER_GUARD_KEYS = ['occluder', 'image', 'guard', 'guarded_px_before', 'guarded_px_after'] as const;
|
|
453
485
|
export const SINGLE_RUN_PAD_KEYS = ['file_size', 'side', 'left', 'top'] as const;
|
|
454
486
|
export const SCENE_KEYS = ['figure_alpha_above', 'figure_px', 'figure_mask'] as const;
|
|
455
487
|
export const RECOMPOSITE_KEYS = ['mean_abs', 'within_limit', 'within_share', 'error_limit', 'error_px', 'covered_alpha', 'uncovered_error_px', 'hole_count', 'holes_listed', 'holes'] as const;
|
|
@@ -512,20 +544,45 @@ export function tagOf(from: string): string | null {
|
|
|
512
544
|
return f === null || f.run === 'painting' ? null : f.tag;
|
|
513
545
|
}
|
|
514
546
|
|
|
515
|
-
const OWNERSHIP_KEYS = ['edit', 'from', 'into', 'moved_in_opaque_px', 'retained_band_opaque_px', 'cleared_opaque_px', 'under_filled_px', 'under_filled_opaque_px', 'net_cleared_opaque_px'] as const;
|
|
547
|
+
const OWNERSHIP_KEYS = ['edit', 'from', 'into', 'moved_in_opaque_px', 'retained_band_opaque_px', 'cleared_opaque_px', 'under_filled_px', 'under_filled_opaque_px', 'net_cleared_opaque_px', 'under_plate'] as const;
|
|
548
|
+
const REQUIRED_OWNERSHIP_KEYS = OWNERSHIP_KEYS.filter((k) => k !== 'under_plate');
|
|
516
549
|
function orderedOwnership(rows: readonly CutOwnership[]): Array<Record<string, unknown>> {
|
|
517
|
-
return rows.map(r =>
|
|
550
|
+
return rows.map((r) => ({
|
|
551
|
+
...Object.fromEntries(REQUIRED_OWNERSHIP_KEYS.map((k) => [k, r[k]])),
|
|
552
|
+
...(r.under_plate === undefined
|
|
553
|
+
? {}
|
|
554
|
+
: {
|
|
555
|
+
under_plate: Object.fromEntries(OCCLUDER_PLATE_KEYS.map((k) => [k, r.under_plate![k]])),
|
|
556
|
+
}),
|
|
557
|
+
}));
|
|
558
|
+
}
|
|
559
|
+
function checkOccluderPlateEntry(entry: unknown, at: string, fail: (code: string, object: string, detail: string) => void): void {
|
|
560
|
+
if (typeof entry !== 'object' || entry === null || Array.isArray(entry)) {
|
|
561
|
+
fail('PARTS_FIELD_TYPE', at, `is ${show(entry)}; an object is required`);
|
|
562
|
+
return;
|
|
563
|
+
}
|
|
564
|
+
const r = entry as Record<string, unknown>;
|
|
565
|
+
for (const k of Object.keys(r)) if (!(OCCLUDER_PLATE_KEYS as readonly string[]).includes(k)) fail('PARTS_KEY_KNOWN', `${at} key "${k}"`, `is not an occluder_plates field; known: ${OCCLUDER_PLATE_KEYS.join(', ')}`);
|
|
566
|
+
for (const k of OCCLUDER_PLATE_KEYS) if (!(k in r)) fail('PARTS_FIELD_PRESENT', `${at} field "${k}"`, 'is absent and required');
|
|
567
|
+
if ('receipt' in r && (typeof r.receipt !== 'string' || r.receipt.length === 0)) fail('PARTS_FIELD_TYPE', `${at} field "receipt"`, `is ${show(r.receipt)}; a non-empty string path is required`);
|
|
568
|
+
for (const k of ['receipt_sha256', 'occluder_sha256', 'painting_sha256', 'output_sha256', 'mask_sha256'] as const) {
|
|
569
|
+
if (k in r && (typeof r[k] !== 'string' || !/^[a-f0-9]{64}$/.test(r[k] as string))) {
|
|
570
|
+
fail('PARTS_FIELD_TYPE', `${at} field "${k}"`, `is ${show(r[k])}; 64 lowercase hex characters are required`);
|
|
571
|
+
}
|
|
572
|
+
}
|
|
518
573
|
}
|
|
519
574
|
function checkOwnership(raw: unknown, object: string, fail: (code: string, object: string, detail: string) => void): void {
|
|
520
575
|
if (!Array.isArray(raw)) { fail('PARTS_FIELD_TYPE', object, `is ${show(raw)}; an array of indexed cut ownership records is required`); return; }
|
|
521
576
|
const seen = new Set<string>();
|
|
522
577
|
raw.forEach((row, i) => {
|
|
523
578
|
const r = row as CutOwnership | null;
|
|
524
|
-
const
|
|
579
|
+
const keys = r !== null && typeof r === 'object' && !Array.isArray(r) ? Object.keys(r).filter((k) => k !== 'under_plate').sort().join(',') : '';
|
|
580
|
+
const shape = r !== null && typeof r === 'object' && !Array.isArray(r) && keys === [...REQUIRED_OWNERSHIP_KEYS].sort().join(',') &&
|
|
525
581
|
typeof r.edit === 'string' && /^cuts\[\d+\]$/.test(r.edit) && !seen.has(r.edit) && typeof r.from === 'string' && r.from !== '' && typeof r.into === 'string' && r.into !== '' &&
|
|
526
|
-
|
|
582
|
+
REQUIRED_OWNERSHIP_KEYS.slice(3).every(k => Number.isSafeInteger(r[k]) && (k === 'net_cleared_opaque_px' || (r[k] as number) >= 0));
|
|
527
583
|
if (!shape) { fail('PARTS_FIELD_TYPE', `${object}[${i}]`, `is ${show(row)}; a distinct cuts[i] with from/into names, nonnegative move/clear/fill counts and signed net_cleared_opaque_px is required`); return; }
|
|
528
584
|
const q = r as CutOwnership; seen.add(q.edit);
|
|
585
|
+
if ('under_plate' in q && q.under_plate !== undefined) checkOccluderPlateEntry(q.under_plate, `${object}[${i}].under_plate`, fail);
|
|
529
586
|
if (q.moved_in_opaque_px - q.retained_band_opaque_px !== q.cleared_opaque_px || q.cleared_opaque_px - q.under_filled_opaque_px !== q.net_cleared_opaque_px || q.under_filled_opaque_px > q.under_filled_px) {
|
|
530
587
|
fail('PARTS_COUNTS_ADD_UP', `${object}[${i}]`, `moved ${q.moved_in_opaque_px} - retained ${q.retained_band_opaque_px} = ${q.moved_in_opaque_px - q.retained_band_opaque_px} (gross cleared ${q.cleared_opaque_px} required); cleared - opaque fill ${q.under_filled_opaque_px} = ${q.cleared_opaque_px - q.under_filled_opaque_px} (net ${q.net_cleared_opaque_px} required); opaque fill must be at most total fill ${q.under_filled_px}`);
|
|
531
588
|
}
|
|
@@ -587,6 +644,8 @@ export function serializeParts(file: PartsFile): string {
|
|
|
587
644
|
...(file.recomposite === undefined ? {} : { recomposite: serializeRecomposite(file.recomposite) }),
|
|
588
645
|
...(file.scene === undefined ? {} : { scene: Object.fromEntries(SCENE_KEYS.map((k) => [k, (file.scene as SceneRecord)[k]])) }),
|
|
589
646
|
...(file.occluder_plates === undefined ? {} : { occluder_plates: file.occluder_plates.map((p) => Object.fromEntries(OCCLUDER_PLATE_KEYS.map((k) => [k, p[k]]))) }),
|
|
647
|
+
...(file.occluder_grow === undefined ? {} : { occluder_grow: file.occluder_grow.map((g) => Object.fromEntries(OCCLUDER_GROW_KEYS.map((k) => [k, g[k]]))) }),
|
|
648
|
+
...(file.occluder_guard === undefined ? {} : { occluder_guard: file.occluder_guard.map((g) => Object.fromEntries(OCCLUDER_GUARD_KEYS.map((k) => [k, g[k]]))) }),
|
|
590
649
|
...(file.single_run_pad === undefined ? {} : { single_run_pad: Object.fromEntries(SINGLE_RUN_PAD_KEYS.map((k) => [k, (file.single_run_pad as SingleRunPad)[k]])) }),
|
|
591
650
|
...(file.alternates === undefined
|
|
592
651
|
? {}
|
|
@@ -930,19 +989,64 @@ function checkParts(raw: unknown, path: string): PartsFile {
|
|
|
930
989
|
if (!Array.isArray(o.occluder_plates) || o.occluder_plates.length === 0) {
|
|
931
990
|
fail('PARTS_FIELD_TYPE', `${path} field "occluder_plates"`, `is ${show(o.occluder_plates)}; a non-empty array of occluder plate records is required`);
|
|
932
991
|
} else {
|
|
933
|
-
o.occluder_plates.forEach((entry, i) => {
|
|
934
|
-
|
|
992
|
+
o.occluder_plates.forEach((entry, i) => checkOccluderPlateEntry(entry, `${path} occluder_plates[${i}]`, fail));
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
if ('occluder_grow' in o) {
|
|
996
|
+
if (!Array.isArray(o.occluder_grow) || o.occluder_grow.length === 0) {
|
|
997
|
+
fail('PARTS_FIELD_TYPE', `${path} field "occluder_grow"`, `is ${show(o.occluder_grow)}; a non-empty array of occluder grow records is required`);
|
|
998
|
+
} else {
|
|
999
|
+
o.occluder_grow.forEach((entry, i) => {
|
|
1000
|
+
const at = `${path} occluder_grow[${i}]`;
|
|
1001
|
+
if (typeof entry !== 'object' || entry === null || Array.isArray(entry)) {
|
|
1002
|
+
fail('PARTS_FIELD_TYPE', at, `is ${show(entry)}; an object is required`);
|
|
1003
|
+
return;
|
|
1004
|
+
}
|
|
1005
|
+
const r = entry as Record<string, unknown>;
|
|
1006
|
+
for (const k of Object.keys(r)) if (!(OCCLUDER_GROW_KEYS as readonly string[]).includes(k)) fail('PARTS_KEY_KNOWN', `${at} key "${k}"`, `is not an occluder_grow field; known: ${OCCLUDER_GROW_KEYS.join(', ')}`);
|
|
1007
|
+
for (const k of OCCLUDER_GROW_KEYS) if (!(k in r)) fail('PARTS_FIELD_PRESENT', `${at} field "${k}"`, 'is absent and required');
|
|
1008
|
+
if ('occluder' in r && !(typeof r.occluder === 'number' && Number.isInteger(r.occluder) && r.occluder >= 0)) {
|
|
1009
|
+
fail('PARTS_FIELD_TYPE', `${at} field "occluder"`, `is ${show(r.occluder)}; a non-negative integer index is required`);
|
|
1010
|
+
}
|
|
1011
|
+
if ('image' in r && (typeof r.image !== 'string' || r.image.length === 0)) {
|
|
1012
|
+
fail('PARTS_FIELD_TYPE', `${at} field "image"`, `is ${show(r.image)}; a non-empty string path is required`);
|
|
1013
|
+
}
|
|
1014
|
+
if ('grow' in r && !(typeof r.grow === 'number' && Number.isInteger(r.grow) && r.grow > 0)) {
|
|
1015
|
+
fail('PARTS_FIELD_TYPE', `${at} field "grow"`, `is ${show(r.grow)}; a positive integer is required`);
|
|
1016
|
+
}
|
|
1017
|
+
for (const k of ['covered_px_before', 'covered_px_after'] as const) {
|
|
1018
|
+
if (k in r && !(typeof r[k] === 'number' && Number.isInteger(r[k]) && (r[k] as number) >= 0)) {
|
|
1019
|
+
fail('PARTS_FIELD_TYPE', `${at} field "${k}"`, `is ${show(r[k])}; a non-negative integer is required`);
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
});
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
if ('occluder_guard' in o) {
|
|
1026
|
+
if (!Array.isArray(o.occluder_guard) || o.occluder_guard.length === 0) {
|
|
1027
|
+
fail('PARTS_FIELD_TYPE', `${path} field "occluder_guard"`, `is ${show(o.occluder_guard)}; a non-empty array of occluder guard records is required`);
|
|
1028
|
+
} else {
|
|
1029
|
+
o.occluder_guard.forEach((entry, i) => {
|
|
1030
|
+
const at = `${path} occluder_guard[${i}]`;
|
|
935
1031
|
if (typeof entry !== 'object' || entry === null || Array.isArray(entry)) {
|
|
936
1032
|
fail('PARTS_FIELD_TYPE', at, `is ${show(entry)}; an object is required`);
|
|
937
1033
|
return;
|
|
938
1034
|
}
|
|
939
1035
|
const r = entry as Record<string, unknown>;
|
|
940
|
-
for (const k of Object.keys(r)) if (!(
|
|
941
|
-
for (const k of
|
|
942
|
-
if ('
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
1036
|
+
for (const k of Object.keys(r)) if (!(OCCLUDER_GUARD_KEYS as readonly string[]).includes(k)) fail('PARTS_KEY_KNOWN', `${at} key "${k}"`, `is not an occluder_guard field; known: ${OCCLUDER_GUARD_KEYS.join(', ')}`);
|
|
1037
|
+
for (const k of OCCLUDER_GUARD_KEYS) if (!(k in r)) fail('PARTS_FIELD_PRESENT', `${at} field "${k}"`, 'is absent and required');
|
|
1038
|
+
if ('occluder' in r && !(typeof r.occluder === 'number' && Number.isInteger(r.occluder) && r.occluder >= 0)) {
|
|
1039
|
+
fail('PARTS_FIELD_TYPE', `${at} field "occluder"`, `is ${show(r.occluder)}; a non-negative integer index is required`);
|
|
1040
|
+
}
|
|
1041
|
+
if ('image' in r && (typeof r.image !== 'string' || r.image.length === 0)) {
|
|
1042
|
+
fail('PARTS_FIELD_TYPE', `${at} field "image"`, `is ${show(r.image)}; a non-empty string path is required`);
|
|
1043
|
+
}
|
|
1044
|
+
if ('guard' in r && !(typeof r.guard === 'number' && Number.isInteger(r.guard) && r.guard > 0)) {
|
|
1045
|
+
fail('PARTS_FIELD_TYPE', `${at} field "guard"`, `is ${show(r.guard)}; a positive integer is required`);
|
|
1046
|
+
}
|
|
1047
|
+
for (const k of ['guarded_px_before', 'guarded_px_after'] as const) {
|
|
1048
|
+
if (k in r && !(typeof r[k] === 'number' && Number.isInteger(r[k]) && (r[k] as number) >= 0)) {
|
|
1049
|
+
fail('PARTS_FIELD_TYPE', `${at} field "${k}"`, `is ${show(r[k])}; a non-negative integer is required`);
|
|
946
1050
|
}
|
|
947
1051
|
}
|
|
948
1052
|
});
|
package/src/partsource.ts
CHANGED
|
@@ -62,10 +62,12 @@ export function untracedPartSources(cfg: Pick<AssembleConfig, 'assemble' | 'seet
|
|
|
62
62
|
};
|
|
63
63
|
const a = cfg.assemble;
|
|
64
64
|
(a.cuts ?? []).forEach((q, i) => {
|
|
65
|
+
if (typeof q.under === 'object' && q.under !== null) return;
|
|
65
66
|
refuse(`part "${q.into}" (config.assemble.cuts[${i}])`, `its pixels are carved out of part "${q.from}" by a hand-drawn ${q.polygon.length}-point polygon`);
|
|
66
67
|
});
|
|
67
68
|
(a.alternates ?? []).forEach((set, j) => {
|
|
68
69
|
(set.cuts ?? []).forEach((q, i) => {
|
|
70
|
+
if (typeof q.under === 'object' && q.under !== null) return;
|
|
69
71
|
refuse(`part "${q.into}" (config.assemble.alternates[${j}].cuts[${i}], alternate set "${set.name}")`, `its pixels are carved out of part "${q.from}" by a hand-drawn ${q.polygon.length}-point polygon`);
|
|
70
72
|
});
|
|
71
73
|
});
|
package/src/provenance.ts
CHANGED
|
@@ -137,6 +137,15 @@ export function provenanceLines(parts: readonly PartRecord[]): string[] {
|
|
|
137
137
|
return lines;
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
+
export interface CutUnderPlateRecord {
|
|
141
|
+
receipt: string;
|
|
142
|
+
receipt_sha256: string;
|
|
143
|
+
occluder_sha256: string;
|
|
144
|
+
painting_sha256: string;
|
|
145
|
+
output_sha256: string;
|
|
146
|
+
mask_sha256: string;
|
|
147
|
+
}
|
|
148
|
+
|
|
140
149
|
/** Structural cut census, independent of the value partition. Counts are from
|
|
141
150
|
* the original parent partition before limb/fringe/seam processing. */
|
|
142
151
|
export interface CutOwnership {
|
|
@@ -149,6 +158,7 @@ export interface CutOwnership {
|
|
|
149
158
|
under_filled_px: number;
|
|
150
159
|
under_filled_opaque_px: number;
|
|
151
160
|
net_cleared_opaque_px: number;
|
|
161
|
+
under_plate?: CutUnderPlateRecord;
|
|
152
162
|
}
|
|
153
163
|
export function ownershipLines(rows: readonly CutOwnership[]): string[] {
|
|
154
164
|
return rows.map(r => ` ownership: ${r.edit} "${r.from}" -> "${r.into}" moved in ${r.moved_in_opaque_px} opaque px; retained band ${r.retained_band_opaque_px}; gross cleared ${r.cleared_opaque_px} before refill; under filled ${r.under_filled_px} px (${r.under_filled_opaque_px} opaque); net cleared ${r.net_cleared_opaque_px}; independent of RGBA equality`);
|
package/src/remesh.ts
CHANGED
|
@@ -134,6 +134,8 @@ export interface RemeshPlant {
|
|
|
134
134
|
unexpandedStops?: boolean;
|
|
135
135
|
/** Issue #617's mutant: run just before check-input reads the input, after the first snapshot, to change a file under it. */
|
|
136
136
|
beforeInputCheck?: () => void;
|
|
137
|
+
/** Issue #1256's mutant: hand every non-`images/` entry of the tree to `gateThroughRigc` as text, as before. */
|
|
138
|
+
unfilteredGateTexts?: boolean;
|
|
137
139
|
}
|
|
138
140
|
|
|
139
141
|
/** The versions the provenance names: this package's and the rigc that gated the revision (its `--version` line). */
|
|
@@ -866,10 +868,13 @@ export function inputTreeProblems(tree: FileTree, root: string, op: 'remesh' | '
|
|
|
866
868
|
return out;
|
|
867
869
|
}
|
|
868
870
|
|
|
871
|
+
/** The two text files `gateThroughRigc`'s `rigc build` reads (`src/build.ts`), in `readTree` sort order. */
|
|
872
|
+
export const GATE_TEXT_FILES = ['motion.json', 'rig.json'] as const;
|
|
869
873
|
/** A tree's images as the gate takes them (name under `images/`, bytes). */
|
|
870
|
-
const pngsOf = (tree: FileTree): Array<readonly [string, Uint8Array]> => [...tree].filter(([k]) => k.startsWith('images/')).map(([k, b]) => [k.slice('images/'.length), b] as const);
|
|
871
|
-
/** A tree's
|
|
872
|
-
const textsOf = (tree: FileTree): Array<readonly [string, string]> =>
|
|
874
|
+
export const pngsOf = (tree: FileTree): Array<readonly [string, Uint8Array]> => [...tree].filter(([k]) => k.startsWith('images/')).map(([k, b]) => [k.slice('images/'.length), b] as const);
|
|
875
|
+
/** A tree's text inputs for the gate (`rig.json` and `motion.json`; `unfiltered` is the pre-#1256 plant). */
|
|
876
|
+
export const textsOf = (tree: FileTree, unfiltered = false): Array<readonly [string, string]> =>
|
|
877
|
+
[...tree].filter(([k]) => (unfiltered ? !k.startsWith('images/') : (GATE_TEXT_FILES as readonly string[]).includes(k))).map(([k, b]) => [k, text(b)] as const);
|
|
873
878
|
|
|
874
879
|
/**
|
|
875
880
|
* The delta's `mesh_report.json` row (issue #526): the input's row, key for key, with `vertices`, `triangles`, `hull`,
|
|
@@ -973,7 +978,7 @@ export function remeshStage(input: RemeshInput, rigc: RigcRunner, checkBin: stri
|
|
|
973
978
|
refuseIfAny(deltaSourceProblems(doc, part, inAtt, deltaPath));
|
|
974
979
|
log(`rig-parts remesh: ${part} of ${input.rig}, ${tree.size} file(s); the request is a mesh edit of ${doc.ops.length} op(s), the baseline is the input itself`);
|
|
975
980
|
let model = null as string | null;
|
|
976
|
-
const inGate = gateThroughRigc(pngsOf(tree), textsOf(tree), rigc, join(scratch, 'gate-input'), { pageEdges, packShape }, (dir) => {
|
|
981
|
+
const inGate = gateThroughRigc(pngsOf(tree), textsOf(tree, plant.unfilteredGateTexts === true), rigc, join(scratch, 'gate-input'), { pageEdges, packShape }, (dir) => {
|
|
977
982
|
const p = join(dir, RIGC_MODEL_DOCUMENT);
|
|
978
983
|
model = existsSync(p) ? readFileSync(p, 'utf8') : null;
|
|
979
984
|
});
|
|
@@ -1010,7 +1015,7 @@ export function remeshStage(input: RemeshInput, rigc: RigcRunner, checkBin: stri
|
|
|
1010
1015
|
log(` ${part}: v=${before.vertices} t=${before.triangles} hull=${before.hull} -> v=${after.vertices} t=${after.triangles} hull=${after.hull}`);
|
|
1011
1016
|
log(` preserved: ${identical.filter((p) => p !== PROVENANCE_FILE && !(input.recordInputCheck === true && p === INPUT_CHECK_FILE)).length} file(s) byte-identical to the input; rig.json identical outside skins.default.${part}.${part}; mesh_report.json identical but the "${part}" row`);
|
|
1012
1017
|
// 7. The gate and check.
|
|
1013
|
-
const gate = gateThroughRigc(pngsOf(revision), textsOf(revision), rigc, join(scratch, 'gate'), { pageEdges, packShape });
|
|
1018
|
+
const gate = gateThroughRigc(pngsOf(revision), textsOf(revision, plant.unfilteredGateTexts === true), rigc, join(scratch, 'gate'), { pageEdges, packShape });
|
|
1014
1019
|
for (const g of gate) {
|
|
1015
1020
|
log(` rigc ${g.label}, the revision: exit ${g.status}`);
|
|
1016
1021
|
for (const l of g.lines) log(` ${l.trim()}`);
|
package/src/retune.ts
CHANGED
|
@@ -40,7 +40,7 @@ import { dirname, join, resolve, sep } from 'node:path';
|
|
|
40
40
|
import { checkStage, gateThroughRigc, type Log, rigStage } from './build.ts';
|
|
41
41
|
import { type CheckReport, DEFAULT_PACK_SHAPE, DEFAULT_PAGE_EDGES, type PackShape, type PageEdges, rigcRanClause, type RigcRunner } from './check.ts';
|
|
42
42
|
import { PartsError, type Problem, problemLine, refuseIfAny } from './errors.ts';
|
|
43
|
-
import { type CheckSide, carryProvenance, type ParentProvenance, checkHeldProblems, checkSide, checkScope, type FileTree, firstDifference, type HashRow, hashRows, INPUT_CHECK_FILE, type InputCheckBinding, inputCheckHashes, inputCheckMovedProblems, inputCheckOf, inputCheckReusedLine, inputCheckText, inputTreeProblems, perturbed, readTree, sha256 } from './remesh.ts';
|
|
43
|
+
import { type CheckSide, carryProvenance, type ParentProvenance, checkHeldProblems, checkSide, checkScope, type FileTree, firstDifference, type HashRow, hashRows, INPUT_CHECK_FILE, type InputCheckBinding, inputCheckHashes, inputCheckMovedProblems, inputCheckOf, inputCheckReusedLine, inputCheckText, inputTreeProblems, perturbed, pngsOf, readTree, sha256, textsOf } from './remesh.ts';
|
|
44
44
|
import { DEFAULT_IDLE_KEYS, type IdleKeys, rigJsonText } from './rig.ts';
|
|
45
45
|
|
|
46
46
|
/** The provenance file's spec. */
|
|
@@ -89,6 +89,8 @@ export interface RetunePlant {
|
|
|
89
89
|
skipHold?: boolean;
|
|
90
90
|
/** Issue #617's mutant: run just before check-input reads the input, after the first snapshot, to change a file under it. */
|
|
91
91
|
beforeInputCheck?: () => void;
|
|
92
|
+
/** Issue #1256's mutant: hand every non-`images/` entry of the tree to `gateThroughRigc` as text, as before. */
|
|
93
|
+
unfilteredGateTexts?: boolean;
|
|
92
94
|
}
|
|
93
95
|
|
|
94
96
|
/** One constraint the request changed: its name and type, and each field whose value moved, in the rebuild's order. */
|
|
@@ -377,9 +379,7 @@ export function retuneStage(input: RetuneInput, rigc: RigcRunner, checkBin: stri
|
|
|
377
379
|
log(` idle: ${changed.idle.tracks_changed} track(s) changed, duration ${changed.idle.duration[0]} -> ${changed.idle.duration[1]}`);
|
|
378
380
|
log(` preserved: ${identical.filter((p) => p !== RETUNE_FILE && !(input.recordInputCheck === true && p === INPUT_CHECK_FILE)).length} file(s) byte-identical to the input; rig.json identical outside constraints and invariants.detached; motion.json identical outside animations.idle`);
|
|
379
381
|
// 6. The gate and check.
|
|
380
|
-
const
|
|
381
|
-
const texts = [...revision].filter(([k]) => !k.startsWith('images/')).map(([k, b]) => [k, text(b)] as const);
|
|
382
|
-
const gate = gateThroughRigc(pngs, texts, rigc, join(scratch, 'gate'), { pageEdges, packShape });
|
|
382
|
+
const gate = gateThroughRigc(pngsOf(revision), textsOf(revision, plant.unfilteredGateTexts === true), rigc, join(scratch, 'gate'), { pageEdges, packShape });
|
|
383
383
|
for (const g of gate) {
|
|
384
384
|
log(` rigc ${g.label}, the revision: exit ${g.status}`);
|
|
385
385
|
for (const l of g.lines) log(` ${l.trim()}`);
|
package/src/takelayers.ts
CHANGED
|
@@ -289,7 +289,17 @@ export function applyTakenLayers(runs: { full: LayerSet; head: LayerSet; single:
|
|
|
289
289
|
...(transported === undefined ? {} : { transport: transported.transport }),
|
|
290
290
|
split: { occluder: d.occluder, image: occEntry.image, sha256: occEntry.sha256, covered_px: coveredPx, visible_px: visiblePx },
|
|
291
291
|
};
|
|
292
|
-
const replacement: Layer = {
|
|
292
|
+
const replacement: Layer = {
|
|
293
|
+
...baseLayer,
|
|
294
|
+
left: 0,
|
|
295
|
+
top: 0,
|
|
296
|
+
right: set.canvas.w,
|
|
297
|
+
bottom: set.canvas.h,
|
|
298
|
+
pixels: merged,
|
|
299
|
+
opaquePx,
|
|
300
|
+
takenLayers: [source],
|
|
301
|
+
occluderSplit: { occluder: d.occluder, base: baseLayer, donor: donorOnSet, merged },
|
|
302
|
+
};
|
|
293
303
|
lists[d.run] = [...lists[d.run].filter(l => l.name !== d.tag), replacement];
|
|
294
304
|
origins.set(replacement, resolve(base, d.run_dir));
|
|
295
305
|
notes.push(takeLayerNote(source));
|