@rig-c/parts 2.44.0 → 2.46.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/README.md +2 -0
- package/cli.ts +142 -33
- package/docs/AUTHORING.md +441 -100
- package/docs/DEPTH.md +33 -6
- package/docs/MIGRATION.md +2 -0
- package/docs/STABILITY.md +405 -51
- package/package.json +5 -1
- package/src/assemble.ts +7 -2
- package/src/assembly-reading.ts +267 -0
- package/src/boundarydepth.ts +113 -0
- package/src/build.ts +27 -13
- package/src/check.ts +305 -81
- package/src/cloth.ts +14 -3
- package/src/config.ts +78 -11
- package/src/configrelocation.ts +48 -2
- package/src/configwrite.ts +9 -7
- package/src/diffdrafts.ts +593 -0
- package/src/editedparts.ts +11 -2
- package/src/externalreceipt.ts +130 -0
- package/src/maskvalues.ts +21 -0
- package/src/outputpaths.ts +40 -0
- package/src/parts.ts +48 -11
- package/src/plate.ts +2 -6
- package/src/propose.ts +169 -12
- package/src/receiptproducer.ts +41 -0
- package/src/remesh-api.ts +33 -0
- package/src/remesh.ts +197 -19
- package/src/remeshdelta.ts +143 -30
- package/src/rig.ts +95 -21
- package/src/scene.ts +45 -9
- package/src/sceneclips.ts +60 -1
- package/src/turn.ts +24 -3
- package/tools/configwrite.ts +22 -14
- package/tools/edited-part-cli.ts +28 -8
- package/tools/neck-propose.ts +2 -0
package/tools/edited-part-cli.ts
CHANGED
|
@@ -2,19 +2,25 @@
|
|
|
2
2
|
import { createHash } from 'node:crypto';
|
|
3
3
|
import { readFileSync } from 'node:fs';
|
|
4
4
|
import { dirname, relative, resolve } from 'node:path';
|
|
5
|
-
import {
|
|
5
|
+
import { refuseStaleAssembly } from '../src/assembly-reading.ts';
|
|
6
|
+
import { CONFIG_REQUIRES, parseConfig, parseEarlyConfig } from '../src/config.ts';
|
|
7
|
+
import type { ConfigObject } from '../src/configwrite.ts';
|
|
6
8
|
import type { EditedPartReceipt } from '../src/editedparts.ts';
|
|
9
|
+
import { receiptProducerJson } from '../src/receiptproducer.ts';
|
|
7
10
|
import { PartsError } from '../src/errors.ts';
|
|
11
|
+
import { readParts } from '../src/parts.ts';
|
|
8
12
|
import { decodePngBytes } from '../src/raster/png.ts';
|
|
9
|
-
import { readConfigWriteTarget, stageConfigWriteBatch, type StagedConfigWriteBatch } from './configwrite.ts';
|
|
13
|
+
import { readConfigWriteTarget, stageConfigWriteBatch, type ConfigWriteRequest, type StagedConfigWriteBatch } from './configwrite.ts';
|
|
10
14
|
|
|
11
15
|
export interface EditedPartInput {
|
|
12
16
|
config: string;
|
|
13
17
|
rigConfig?: string;
|
|
18
|
+
parts?: string;
|
|
14
19
|
part: string;
|
|
15
20
|
file: string;
|
|
16
21
|
from: string;
|
|
17
|
-
editor
|
|
22
|
+
editor?: string;
|
|
23
|
+
producer?: string;
|
|
18
24
|
}
|
|
19
25
|
function refuse(code: string, object: string, detail: string): never {
|
|
20
26
|
throw new PartsError([{ code, object, detail }]);
|
|
@@ -31,30 +37,44 @@ function png(path: string, flag: string): { bytes: Buffer; width: number; height
|
|
|
31
37
|
}
|
|
32
38
|
}
|
|
33
39
|
const hash = (bytes: Uint8Array): string => createHash('sha256').update(bytes).digest('hex');
|
|
40
|
+
const rigSections = CONFIG_REQUIRES.full.filter(field => !CONFIG_REQUIRES.assemble.includes(field));
|
|
34
41
|
export interface EditedPartWriteResult { receipt: EditedPartReceipt; writes: StagedConfigWriteBatch['writes'] }
|
|
35
42
|
|
|
36
43
|
/** Prepare every replacement before even temporary files are written. No assembly or filename discovery. */
|
|
37
44
|
export function writeEditedPart(input: EditedPartInput): EditedPartWriteResult {
|
|
38
45
|
for (const [flag, value] of [
|
|
39
46
|
['--config', input.config], ['--part', input.part], ['--file', input.file],
|
|
40
|
-
['--from', input.from],
|
|
47
|
+
['--from', input.from],
|
|
48
|
+
...(input.editor === undefined ? [] : [['--editor', input.editor]]),
|
|
41
49
|
...(input.rigConfig === undefined ? [] : [['--rig-config', input.rigConfig]]),
|
|
50
|
+
...(input.parts === undefined ? [] : [['--parts', input.parts]]),
|
|
42
51
|
]) if (typeof value !== 'string' || value.trim() === '') refuse('EDITED_PART_ARGUMENT', flag, 'is missing or blank; a non-empty value is required');
|
|
52
|
+
if ((input.editor === undefined) === (input.producer === undefined)) {
|
|
53
|
+
refuse('EDITED_PART_ARGUMENT', 'edited-part', 'requires exactly one of --producer or --editor');
|
|
54
|
+
}
|
|
55
|
+
const author = input.editor === undefined
|
|
56
|
+
? { producer: receiptProducerJson(input.producer!, '--producer') }
|
|
57
|
+
: { editor: input.editor };
|
|
43
58
|
const edited = png(input.file, '--file'), from = png(input.from, '--from');
|
|
44
59
|
if (edited.width !== from.width || edited.height !== from.height) refuse('EDITED_PART_SIZE', input.part,
|
|
45
60
|
`edited PNG is ${edited.width}x${edited.height}; --from PNG dimensions ${from.width}x${from.height} are required`);
|
|
46
|
-
const receipt = { part: input.part, file: input.file, sha256: hash(edited.bytes), from_sha256: hash(from.bytes),
|
|
61
|
+
const receipt = { part: input.part, file: input.file, sha256: hash(edited.bytes), from_sha256: hash(from.bytes), ...author };
|
|
47
62
|
const targets = [input.config, ...(input.rigConfig === undefined ? [] : [input.rigConfig])].map(readConfigWriteTarget);
|
|
48
63
|
const receipts: EditedPartReceipt[] = [];
|
|
49
|
-
const requests = targets.map(target => {
|
|
50
|
-
const
|
|
64
|
+
const requests = targets.map((target, index): ConfigWriteRequest => {
|
|
65
|
+
const raw = target.raw as ConfigObject;
|
|
66
|
+
const receiptDoor = index === 0 && Object.hasOwn(raw, 'seethrough') && !rigSections.every(section => Object.hasOwn(raw, section))
|
|
67
|
+
? 'assemble' : 'full';
|
|
68
|
+
const config = receiptDoor === 'assemble' ? parseEarlyConfig(raw, 'assemble') : parseConfig(raw);
|
|
51
69
|
const spec = config.assemble.edited_parts;
|
|
52
70
|
if (spec === undefined) return refuse('EDITED_PART_BLOCK', target.path, 'has no assemble.edited_parts; declare {dir, receipts: []} before recording an edited part');
|
|
53
71
|
const file = relative(resolve(dirname(target.path), spec.dir), resolve(input.file)).replaceAll('\\', '/');
|
|
54
72
|
const value: EditedPartReceipt = { ...receipt, file };
|
|
55
73
|
receipts.push(value);
|
|
56
|
-
|
|
74
|
+
const patch = { kind: 'edited-part-receipt' as const, receipt: value };
|
|
75
|
+
return { target, patch, receiptDoor };
|
|
57
76
|
});
|
|
77
|
+
if (input.parts !== undefined) refuseStaleAssembly(targets[0].path, readParts(input.parts));
|
|
58
78
|
const staged = stageConfigWriteBatch(requests);
|
|
59
79
|
staged.commit();
|
|
60
80
|
return { receipt: receipts[0], writes: staged.writes };
|
package/tools/neck-propose.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/** Filesystem adapter for the explicit --write-config sampled-turn context. */
|
|
2
2
|
import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
3
3
|
import { dirname, join, resolve } from 'node:path';
|
|
4
|
+
import { readAssemblyConfig } from '../src/assembly-reading.ts';
|
|
4
5
|
import { loadConfig, parseConfig } from '../src/config.ts';
|
|
5
6
|
import { draftIndependentNeck } from '../src/neckdraft.ts';
|
|
6
7
|
import { readRigInputs, readUnders, readCaps } from '../src/build.ts';
|
|
@@ -23,6 +24,7 @@ export function proposeNeck(target: ConfigWriteTarget, args: { source: string; f
|
|
|
23
24
|
try {
|
|
24
25
|
const out = join(args.out, 'rig');
|
|
25
26
|
mkdirSync(join(out, 'parts'), { recursive: true });
|
|
27
|
+
draft.assembled.parts.assembly_config = readAssemblyConfig(draft.config, draft.assembled.parts, target.path);
|
|
26
28
|
writeParts(join(out, 'parts.json'), draft.assembled.parts);
|
|
27
29
|
for (const p of draft.assembled.images) {
|
|
28
30
|
writePng(join(out, 'parts', `${p.record.name}.png`), p.image);
|