rig-review 1.4.4 → 1.5.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/docs/PANELS.md +2 -2
- package/docs/PARTS_VIEW.md +85 -0
- package/docs/WORKFLOWS.md +3 -0
- package/package.json +2 -1
- package/src/build.ts +3 -3
- package/src/cli.ts +18 -1
- package/src/parts-server.ts +65 -0
- package/src/parts-view.ts +375 -0
- package/web/catalog-en.ts +56 -0
- package/web/catalog-ko.ts +56 -0
- package/web/chest-editor.ts +9 -3
- package/web/compare-picked-tools.ts +5 -3
- package/web/compare.css +1 -1
- package/web/index.html +1 -1
- package/web/main.ts +12 -11
- package/web/parts-flags.ts +31 -0
- package/web/parts-render.ts +57 -0
- package/web/parts.css +51 -0
- package/web/parts.html +38 -0
- package/web/parts.ts +232 -0
- package/web/styles.css +1 -1
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The parts and atlas view (#348): every part as an image, before any rig is built, and the atlas a built rig ships.
|
|
3
|
+
*
|
|
4
|
+
* Two inputs open it:
|
|
5
|
+
* - **parts mode** — a parts package as rig-parts assemble writes it: `parts.json` (draw order, back first) beside
|
|
6
|
+
* `parts/<name>.png`, each PNG cropped to its own box at `x`/`y` in rig pixels;
|
|
7
|
+
* - **atlas mode** — a review package (or rig-parts build root) whose compiled model declares `pages[].regions[]`.
|
|
8
|
+
*
|
|
9
|
+
* Producer flags are read from the files rig-parts writes and shown on their part; nothing is re-measured here:
|
|
10
|
+
* - `mesh_report.json` rows: `contour.bridges.faint[]` (rig-parts #326), each a faint island the mesh left out;
|
|
11
|
+
* - `check.json`: a gate whose `status` is FAIL or WARN, `seam_pairs` and `figure_openings`, on every part they name.
|
|
12
|
+
*
|
|
13
|
+
* The sign-off is `rig-review-parts-verdict/1` (docs/PARTS_VIEW.md), written beside `parts.json` by default. Its
|
|
14
|
+
* `source.sha256` is the sha256 over the UTF-8 lines `<path>\t<sha256>\n`, sorted by path bytewise, where every path
|
|
15
|
+
* is relative to the verdict file's directory. rig-c/create recomputes it, so the definition is fixed here.
|
|
16
|
+
*/
|
|
17
|
+
import { createHash } from 'node:crypto';
|
|
18
|
+
import { existsSync } from 'node:fs';
|
|
19
|
+
import { mkdir, readFile, realpath, rename, stat, writeFile } from 'node:fs/promises';
|
|
20
|
+
import { basename, dirname, isAbsolute, join, posix, relative, resolve, sep } from 'node:path';
|
|
21
|
+
import { loadReview, safeFile } from './manifest.ts';
|
|
22
|
+
|
|
23
|
+
export const PARTS_VERDICT_SCHEMA = 'rig-review-parts-verdict/1';
|
|
24
|
+
export const PARTS_VERDICT_FILE = 'parts-review.json';
|
|
25
|
+
export const PARTS_NOTE_LIMIT = 10000;
|
|
26
|
+
export type PartsViewMode = 'parts' | 'atlas';
|
|
27
|
+
export type PartOutcome = 'pending' | 'clean' | 'flagged';
|
|
28
|
+
export type VerdictStatus = 'pending' | 'approved' | 'changes-requested';
|
|
29
|
+
|
|
30
|
+
/** One file the verdict rests on: `path` relative to the verdict file's directory, POSIX separators. */
|
|
31
|
+
export interface HashedFile { path: string; bytes: number; sha256: string }
|
|
32
|
+
interface LocalFile { abs: string; bytes: number; sha256: string }
|
|
33
|
+
|
|
34
|
+
/** A part (parts mode) or a named region (atlas mode). Boxes are rig px (parts) or page px (atlas). */
|
|
35
|
+
export interface ViewItem {
|
|
36
|
+
name: string;
|
|
37
|
+
/** Draw order, back first (parts mode); the region's place in the atlas file (atlas mode). */
|
|
38
|
+
index: number;
|
|
39
|
+
x: number; y: number; w: number; h: number;
|
|
40
|
+
/** Atlas mode only: the page the region is packed on, and its packing rotation. */
|
|
41
|
+
page?: string; degrees?: number;
|
|
42
|
+
/** Parts mode: served at `/api/parts/image/<index>`. */
|
|
43
|
+
image?: boolean;
|
|
44
|
+
}
|
|
45
|
+
export interface ViewPage { name: string; width: number; height: number; index: number }
|
|
46
|
+
|
|
47
|
+
/** A producer flag on one item. `id` is stable for the same producer file, and is what the verdict records. */
|
|
48
|
+
export type ProducerFlag =
|
|
49
|
+
| { id: string; item: string; source: 'mesh_report'; kind: 'faint'; art: number; maxAlpha: number; box: [number, number, number, number] }
|
|
50
|
+
| { id: string; item: string; source: 'check'; kind: 'check'; path: string; line: string;
|
|
51
|
+
/** The top-level check.json key the line sits under, the gate's status when it is a gate, and the object as written. */
|
|
52
|
+
root: string; status: string | null; entry: Record<string, unknown> };
|
|
53
|
+
|
|
54
|
+
export interface PartsViewPackage {
|
|
55
|
+
mode: PartsViewMode;
|
|
56
|
+
root: string;
|
|
57
|
+
title: string;
|
|
58
|
+
rigSize: [number, number] | null;
|
|
59
|
+
items: ViewItem[];
|
|
60
|
+
pages: ViewPage[];
|
|
61
|
+
flags: ProducerFlag[];
|
|
62
|
+
/** The files the sign-off rests on (parts.json and every part PNG; or the model and every page). */
|
|
63
|
+
files: LocalFile[];
|
|
64
|
+
/** The producer files the flags were read from. */
|
|
65
|
+
flagFiles: LocalFile[];
|
|
66
|
+
/** Where flags were looked for and not found, said in words. */
|
|
67
|
+
flagNotes: string[];
|
|
68
|
+
verdictPath: string;
|
|
69
|
+
/** Absolute paths, served by index. */
|
|
70
|
+
imagePaths: string[];
|
|
71
|
+
pagePaths: string[];
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export interface PartsViewOptions { meshReport?: string; check?: string; verdict?: string }
|
|
75
|
+
|
|
76
|
+
const record = (v: unknown): Record<string, unknown> | null => v && typeof v === 'object' && !Array.isArray(v) ? v as Record<string, unknown> : null;
|
|
77
|
+
const finite = (v: unknown, min: number): v is number => typeof v === 'number' && Number.isFinite(v) && v >= min;
|
|
78
|
+
const refuse = (code: string, message: string): never => { throw new Error(`${code}: ${message}`); };
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* The file's real path, refused by name when it resolves outside `root`. The same invariant `safeFile` holds for a
|
|
82
|
+
* review package: a symlink inside the package may not reach a file outside it, since the view hashes and serves it.
|
|
83
|
+
*/
|
|
84
|
+
export async function insideRoot(root: string, path: string, code: string, what: string): Promise<string> {
|
|
85
|
+
const realRoot = await realpath(root), real = await realpath(path);
|
|
86
|
+
const rel = relative(realRoot, real);
|
|
87
|
+
if (!rel || rel === '..' || rel.startsWith('..' + sep) || isAbsolute(rel)) refuse(code, `${what} resolves outside ${basename(realRoot)}/ (symlinks may not escape the package)`);
|
|
88
|
+
return real;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
async function hashFile(abs: string): Promise<LocalFile> {
|
|
92
|
+
const bytes = await readFile(abs);
|
|
93
|
+
return { abs, bytes: bytes.length, sha256: createHash('sha256').update(bytes).digest('hex') };
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** A part name is a file stem under `parts/`: no separators, no traversal. */
|
|
97
|
+
function partFileName(name: string): string {
|
|
98
|
+
if (!name || name === '.' || name === '..' || /[/\\\x00-\x1f]/.test(name)) refuse('PARTS_NAME_INVALID', `part name ${JSON.stringify(name)} is not a file name under parts/`);
|
|
99
|
+
return name + '.png';
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** `source.sha256`: sha256 over `<path>\t<sha256>\n` lines sorted by path bytewise (UTF-8). */
|
|
103
|
+
export function sourceSha256(files: readonly Pick<HashedFile, 'path' | 'sha256'>[]): string {
|
|
104
|
+
const sorted = [...files].sort((a, b) => Buffer.compare(Buffer.from(a.path, 'utf8'), Buffer.from(b.path, 'utf8')));
|
|
105
|
+
const hash = createHash('sha256');
|
|
106
|
+
for (const f of sorted) hash.update(`${f.path}\t${f.sha256}\n`, 'utf8');
|
|
107
|
+
return hash.digest('hex');
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** `abs` relative to `dir`, with POSIX separators. */
|
|
111
|
+
function relativeTo(dir: string, abs: string): string {
|
|
112
|
+
const rel = relative(dir, abs);
|
|
113
|
+
return sep === '/' ? rel : rel.split(sep).join('/');
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** Faint islands (rig-parts #326) from `mesh_report.json` rows, on the parts the view holds. */
|
|
117
|
+
export function meshReportFlags(rows: unknown, names: ReadonlySet<string>): ProducerFlag[] {
|
|
118
|
+
if (!Array.isArray(rows)) refuse('PARTS_FLAGS_MALFORMED', 'mesh_report.json is not an array of rows');
|
|
119
|
+
const flags: ProducerFlag[] = [];
|
|
120
|
+
for (const raw of rows as unknown[]) {
|
|
121
|
+
const row = record(raw);
|
|
122
|
+
if (!row || typeof row.part !== 'string' || !names.has(row.part)) continue;
|
|
123
|
+
const faint = record(record(row.contour)?.bridges)?.faint;
|
|
124
|
+
if (!Array.isArray(faint)) continue;
|
|
125
|
+
faint.forEach((value, i) => {
|
|
126
|
+
const f = record(value), box = f?.box;
|
|
127
|
+
if (!f || !finite(f.art, 0) || !finite(f.maxAlpha, 0) || !Array.isArray(box) || box.length !== 4 || !box.every(n => finite(n, 0))) return;
|
|
128
|
+
flags.push({ id: `faint:${i}`, item: row.part as string, source: 'mesh_report', kind: 'faint', art: f.art, maxAlpha: f.maxAlpha, box: box as [number, number, number, number] });
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
return flags;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** check.json fields that hold a bone name, never a part's, even when a bone shares a part's name (`hairpin`). */
|
|
135
|
+
const BONE_FIELDS = new Set(['bone', 'bones', 'root', 'tip', 'link', 'links', 'head_bone']);
|
|
136
|
+
/** check.json lists that are problem lines by themselves (rig-parts STABILITY: written when a bar fails or on request). */
|
|
137
|
+
const PROBLEM_LISTS = new Set(['seam_pairs', 'figure_openings']);
|
|
138
|
+
/** Gate statuses that report a problem; PASS, CLEAR, SKIP and REPORTED do not (rig-parts `CheckStatus`). */
|
|
139
|
+
export const PROBLEM_STATUSES = new Set(['FAIL', 'WARN']);
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* The lines of `check.json` that report a problem and name a held part: a gate whose `status` is FAIL or WARN, or an
|
|
143
|
+
* entry of `seam_pairs` / `figure_openings`. Every object inside that names a part by a string field (or a string in
|
|
144
|
+
* an array field), bone fields excepted, is quoted as the producer wrote it. A passing gate is not a flag.
|
|
145
|
+
*/
|
|
146
|
+
export function checkFlags(doc: unknown, names: ReadonlySet<string>): ProducerFlag[] {
|
|
147
|
+
const flags: ProducerFlag[] = [];
|
|
148
|
+
const walk = (value: unknown, path: string, depth: number, root: string, status: string | null): void => {
|
|
149
|
+
if (depth > 32) return;
|
|
150
|
+
if (Array.isArray(value)) { value.forEach((v, i) => walk(v, `${path}[${i}]`, depth + 1, root, status)); return; }
|
|
151
|
+
const obj = record(value);
|
|
152
|
+
if (!obj) return;
|
|
153
|
+
const named = new Set<string>();
|
|
154
|
+
for (const [k, v] of Object.entries(obj)) {
|
|
155
|
+
if (BONE_FIELDS.has(k)) continue;
|
|
156
|
+
if (typeof v === 'string' && names.has(v)) named.add(v);
|
|
157
|
+
else if (Array.isArray(v)) for (const s of v) if (typeof s === 'string' && names.has(s)) named.add(s);
|
|
158
|
+
}
|
|
159
|
+
if (named.size) {
|
|
160
|
+
const text = JSON.stringify(obj);
|
|
161
|
+
const line = text.length > 600 ? text.slice(0, 599) + '…' : text;
|
|
162
|
+
for (const item of named) flags.push({ id: `check:${path}`, item, source: 'check', kind: 'check', path, line, root, status, entry: obj });
|
|
163
|
+
}
|
|
164
|
+
for (const [k, v] of Object.entries(obj)) if (v && typeof v === 'object') walk(v, `${path}.${k}`, depth + 1, root, status);
|
|
165
|
+
};
|
|
166
|
+
for (const [key, value] of Object.entries(record(doc) ?? {})) {
|
|
167
|
+
const status = record(value)?.status;
|
|
168
|
+
if (typeof status === 'string' ? PROBLEM_STATUSES.has(status) : PROBLEM_LISTS.has(key)) walk(value, key, 0, key, typeof status === 'string' ? status : null);
|
|
169
|
+
}
|
|
170
|
+
return flags;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
async function readJson(abs: string, what: string): Promise<unknown> {
|
|
174
|
+
try { return JSON.parse(await readFile(abs, 'utf8')); } catch (e) { return refuse('PARTS_FLAGS_MALFORMED', `${what}: ${e instanceof Error ? e.message : String(e)}`); }
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Flags from the producer files: explicit paths win; otherwise where rig-parts writes them in a build root — `rig`
|
|
179
|
+
* writes `mesh_report.json` beside `parts.json` in `rig/`, and `check` writes `check/check.json` beside `rig/`.
|
|
180
|
+
* `rigDir` is that `rig/` directory (parts mode) or null (atlas mode: explicit paths only, or `buildRoot`'s files).
|
|
181
|
+
*/
|
|
182
|
+
async function producerFlags(rigDir: string | null, buildRoot: string | null, names: ReadonlySet<string>, options: PartsViewOptions): Promise<{ flags: ProducerFlag[]; files: LocalFile[]; notes: string[] }> {
|
|
183
|
+
const flags: ProducerFlag[] = [], files: LocalFile[] = [], notes: string[] = [];
|
|
184
|
+
// A discovered file must resolve inside the directory it was discovered in; a path given on the command line is the user's own choice.
|
|
185
|
+
const pick = async (explicit: string | undefined, candidates: ([string, string] | null)[], what: string): Promise<string | null> => {
|
|
186
|
+
if (explicit !== undefined) return resolve(explicit);
|
|
187
|
+
const found = candidates.find((c): c is [string, string] => !!c && existsSync(c[1]));
|
|
188
|
+
return found ? insideRoot(found[0], found[1], 'PARTS_FLAGS_OUTSIDE', what) : null;
|
|
189
|
+
};
|
|
190
|
+
const mesh = await pick(options.meshReport, [rigDir ? [rigDir, join(rigDir, 'mesh_report.json')] : null, buildRoot ? [buildRoot, join(buildRoot, 'rig', 'mesh_report.json')] : null], 'mesh_report.json');
|
|
191
|
+
if (mesh) { files.push(await hashFile(mesh)); flags.push(...meshReportFlags(await readJson(mesh, 'mesh_report.json'), names)); }
|
|
192
|
+
else notes.push('mesh_report.json');
|
|
193
|
+
const check = await pick(options.check, [rigDir ? [dirname(rigDir), join(dirname(rigDir), 'check', 'check.json')] : null, buildRoot ? [buildRoot, join(buildRoot, 'check', 'check.json')] : null], 'check/check.json');
|
|
194
|
+
if (check) { files.push(await hashFile(check)); flags.push(...checkFlags(await readJson(check, 'check.json'), names)); }
|
|
195
|
+
else notes.push('check.json');
|
|
196
|
+
return { flags, files, notes };
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
async function loadPartsMode(root: string, options: PartsViewOptions): Promise<PartsViewPackage> {
|
|
200
|
+
const partsJson = await insideRoot(root, join(root, 'parts.json'), 'PARTS_FILE_OUTSIDE', 'parts.json');
|
|
201
|
+
const doc = record(await readJson(partsJson, 'parts.json'));
|
|
202
|
+
const list = doc?.parts;
|
|
203
|
+
if (!doc || !Array.isArray(list)) return refuse('PARTS_JSON_MALFORMED', 'parts.json has no parts[] array');
|
|
204
|
+
const size = doc.rig_size;
|
|
205
|
+
const rigSize: [number, number] | null = Array.isArray(size) && size.length === 2 && finite(size[0], 1) && finite(size[1], 1) ? [size[0], size[1]] : null;
|
|
206
|
+
const items: ViewItem[] = [], imagePaths: string[] = [], files: LocalFile[] = [await hashFile(partsJson)];
|
|
207
|
+
const seen = new Set<string>();
|
|
208
|
+
for (const [index, raw] of list.entries()) {
|
|
209
|
+
const p = record(raw);
|
|
210
|
+
if (!p || typeof p.name !== 'string' || !finite(p.x, -1e9) || !finite(p.y, -1e9) || !finite(p.w, 1) || !finite(p.h, 1)) refuse('PARTS_JSON_MALFORMED', `parts[${index}] needs name, x, y, w, h`);
|
|
211
|
+
const part = p as { name: string; x: number; y: number; w: number; h: number };
|
|
212
|
+
if (seen.has(part.name)) refuse('PARTS_JSON_MALFORMED', `part ${part.name} appears twice`);
|
|
213
|
+
seen.add(part.name);
|
|
214
|
+
const abs = join(root, 'parts', partFileName(part.name));
|
|
215
|
+
if (!existsSync(abs)) refuse('PARTS_IMAGE_MISSING', `parts/${part.name}.png is named in parts.json and is not on disk`);
|
|
216
|
+
// Hashed and served by its real path, so a link swapped after load cannot redirect what the page is shown.
|
|
217
|
+
const real = await insideRoot(root, abs, 'PARTS_IMAGE_OUTSIDE', `parts/${part.name}.png`);
|
|
218
|
+
files.push(await hashFile(real));
|
|
219
|
+
imagePaths.push(real);
|
|
220
|
+
items.push({ name: part.name, index, x: part.x, y: part.y, w: part.w, h: part.h, image: true });
|
|
221
|
+
}
|
|
222
|
+
const { flags, files: flagFiles, notes } = await producerFlags(root, null, seen, options);
|
|
223
|
+
return { mode: 'parts', root, title: basename(root) === 'rig' ? basename(dirname(root)) : basename(root), rigSize, items, pages: [], flags, files, flagFiles, flagNotes: notes, verdictPath: options.verdict ? resolve(options.verdict) : join(root, PARTS_VERDICT_FILE), imagePaths, pagePaths: [] };
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
async function loadAtlasMode(input: string, options: PartsViewOptions): Promise<PartsViewPackage> {
|
|
227
|
+
const p = await loadReview(input);
|
|
228
|
+
const modelPath = p.manifest.model;
|
|
229
|
+
if (!modelPath) return refuse('PARTS_VIEW_NO_ATLAS', `${input} holds neither parts.json nor a compiled model with pages`);
|
|
230
|
+
const modelAbs = await safeFile(p.root, modelPath);
|
|
231
|
+
const model = record(JSON.parse(await readFile(modelAbs, 'utf8')));
|
|
232
|
+
const pagesRaw = model?.pages;
|
|
233
|
+
if (!Array.isArray(pagesRaw)) return refuse('PARTS_VIEW_NO_ATLAS', `${modelPath} declares no pages`);
|
|
234
|
+
const pages: ViewPage[] = [], pagePaths: string[] = [], items: ViewItem[] = [], files: LocalFile[] = [await hashFile(modelAbs)];
|
|
235
|
+
const names = new Set<string>();
|
|
236
|
+
for (const raw of pagesRaw) {
|
|
237
|
+
const page = record(raw);
|
|
238
|
+
if (!page || typeof page.name !== 'string' || !finite(page.width, 1) || !finite(page.height, 1) || !Array.isArray(page.regions)) continue;
|
|
239
|
+
const abs = await safeFile(p.root, posix.join(posix.dirname(modelPath), page.name));
|
|
240
|
+
const index = pages.length;
|
|
241
|
+
pages.push({ name: page.name, width: page.width, height: page.height, index });
|
|
242
|
+
pagePaths.push(abs);
|
|
243
|
+
files.push(await hashFile(abs));
|
|
244
|
+
for (const value of page.regions) {
|
|
245
|
+
const r = record(value);
|
|
246
|
+
if (!r || typeof r.name !== 'string' || !finite(r.x, 0) || !finite(r.y, 0) || !finite(r.width, 1) || !finite(r.height, 1)) continue;
|
|
247
|
+
items.push({ name: r.name, index: items.length, x: r.x, y: r.y, w: r.width, h: r.height, page: page.name, degrees: typeof r.degrees === 'number' ? r.degrees : 0 });
|
|
248
|
+
names.add(r.name);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
// A build root opens as its check package (#149); its own rig/ and check/ hold the flags.
|
|
252
|
+
const buildRoot = p.buildRoot ?? null;
|
|
253
|
+
const { flags, files: flagFiles, notes } = await producerFlags(null, buildRoot, names, options);
|
|
254
|
+
return { mode: 'atlas', root: p.root, title: p.manifest.title, rigSize: null, items, pages, flags, files, flagFiles, flagNotes: notes, verdictPath: options.verdict ? resolve(options.verdict) : join(dirname(modelAbs), PARTS_VERDICT_FILE), imagePaths: [], pagePaths };
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Parts mode: a directory holding `parts.json`, or a build root whose `rig/` holds it (assemble writes
|
|
259
|
+
* `<out>/rig/parts.json`). Anything else — a review package, a `check/` folder — is read for its atlas.
|
|
260
|
+
*/
|
|
261
|
+
export async function loadPartsView(input: string, options: PartsViewOptions = {}): Promise<PartsViewPackage> {
|
|
262
|
+
const abs = await realpath(resolve(input)).catch(() => refuse('PARTS_VIEW_INPUT_MISSING', `${input} does not exist`));
|
|
263
|
+
if ((await stat(abs)).isDirectory()) {
|
|
264
|
+
if (existsSync(join(abs, 'parts.json'))) return loadPartsMode(abs, options);
|
|
265
|
+
if (existsSync(join(abs, 'rig', 'parts.json')) && !existsSync(join(abs, 'review.json'))) return loadPartsMode(join(abs, 'rig'), options);
|
|
266
|
+
}
|
|
267
|
+
return loadAtlasMode(input, options);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/** The hashed files as the verdict records them: relative to the verdict file's directory. */
|
|
271
|
+
export function verdictSource(pkg: Pick<PartsViewPackage, 'files' | 'flagFiles' | 'verdictPath'>): { sha256: string; files: HashedFile[]; flags: { path: string; sha256: string }[] } {
|
|
272
|
+
const dir = dirname(pkg.verdictPath);
|
|
273
|
+
const files = pkg.files.map(f => ({ path: relativeTo(dir, f.abs), bytes: f.bytes, sha256: f.sha256 }));
|
|
274
|
+
return { sha256: sourceSha256(files), files, flags: pkg.flagFiles.map(f => ({ path: relativeTo(dir, f.abs), sha256: f.sha256 })) };
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
export interface PartsVerdict {
|
|
278
|
+
schema: typeof PARTS_VERDICT_SCHEMA;
|
|
279
|
+
mode: PartsViewMode;
|
|
280
|
+
tool: { name: '@rig-c/review'; version: string };
|
|
281
|
+
source: ReturnType<typeof verdictSource>;
|
|
282
|
+
status: VerdictStatus;
|
|
283
|
+
parts: Record<string, { outcome: PartOutcome; note: string; flags: string[] }>;
|
|
284
|
+
updatedAt: string;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/** What the page submits: the status and every item's outcome and note. */
|
|
288
|
+
export interface VerdictSubmission { status: VerdictStatus; parts: Record<string, { outcome: PartOutcome; note?: string }> }
|
|
289
|
+
|
|
290
|
+
/** The distinct names, in item order (atlas sequence frames share a name). */
|
|
291
|
+
export const itemNames = (pkg: Pick<PartsViewPackage, 'items'>): string[] => [...new Set(pkg.items.map(i => i.name))];
|
|
292
|
+
|
|
293
|
+
/** Builds the verdict document, or refuses by name. Pure but for the clock. */
|
|
294
|
+
export function buildVerdict(pkg: Pick<PartsViewPackage, 'mode' | 'items' | 'flags' | 'files' | 'flagFiles' | 'verdictPath'>, input: unknown, version: string, now = new Date()): PartsVerdict {
|
|
295
|
+
const body = record(input);
|
|
296
|
+
if (!body) return refuse('PARTS_VERDICT_INVALID', 'expected { status, parts }');
|
|
297
|
+
const status = body.status;
|
|
298
|
+
if (status !== 'pending' && status !== 'approved' && status !== 'changes-requested') return refuse('PARTS_VERDICT_INVALID', 'status is pending, approved or changes-requested');
|
|
299
|
+
const given = record(body.parts);
|
|
300
|
+
if (!given) return refuse('PARTS_VERDICT_INVALID', 'parts is an object keyed by part name');
|
|
301
|
+
const names = itemNames(pkg), known = new Set(names);
|
|
302
|
+
for (const name of Object.keys(given)) if (!known.has(name)) refuse('PARTS_VERDICT_UNKNOWN_PART', `${name} is not a part of this input`);
|
|
303
|
+
const parts: PartsVerdict['parts'] = {};
|
|
304
|
+
for (const name of names) {
|
|
305
|
+
const entry = record(given[name]);
|
|
306
|
+
if (!entry) return refuse('PARTS_VERDICT_MISSING_PART', `${name} has no entry`);
|
|
307
|
+
const outcome = entry.outcome;
|
|
308
|
+
if (outcome !== 'pending' && outcome !== 'clean' && outcome !== 'flagged') return refuse('PARTS_VERDICT_INVALID', `${name}.outcome is pending, clean or flagged`);
|
|
309
|
+
const note = entry.note === undefined ? '' : entry.note;
|
|
310
|
+
if (typeof note !== 'string' || note.length > PARTS_NOTE_LIMIT) return refuse('PARTS_VERDICT_INVALID', `${name}.note is a string of at most ${PARTS_NOTE_LIMIT} characters`);
|
|
311
|
+
if (outcome === 'flagged' && !note.trim()) return refuse('PARTS_VERDICT_NOTE_REQUIRED', `${name} is flagged and has no note saying what is wrong`);
|
|
312
|
+
parts[name] = { outcome, note, flags: [...new Set(pkg.flags.filter(f => f.item === name).map(f => f.id))] };
|
|
313
|
+
}
|
|
314
|
+
const outcomes = Object.values(parts).map(p => p.outcome);
|
|
315
|
+
if (status === 'approved' && outcomes.some(o => o !== 'clean')) refuse('PARTS_VERDICT_NOT_CLEAN', `approved needs every part clean; ${outcomes.filter(o => o !== 'clean').length} are not`);
|
|
316
|
+
if (status === 'changes-requested' && !outcomes.includes('flagged')) refuse('PARTS_VERDICT_NOTHING_FLAGGED', 'changes-requested needs at least one flagged part');
|
|
317
|
+
return { schema: PARTS_VERDICT_SCHEMA, mode: pkg.mode, tool: { name: '@rig-c/review', version }, source: verdictSource(pkg), status, parts, updatedAt: now.toISOString() };
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/** Every file the package was loaded from still has the bytes it was loaded with. */
|
|
321
|
+
export async function assertPartsUnchanged(pkg: Pick<PartsViewPackage, 'files' | 'flagFiles'>): Promise<void> {
|
|
322
|
+
for (const f of [...pkg.files, ...pkg.flagFiles]) {
|
|
323
|
+
const now = await hashFile(f.abs).catch(() => null);
|
|
324
|
+
if (!now || now.sha256 !== f.sha256) refuse('PARTS_VIEW_SOURCE_CHANGED', `${basename(f.abs)} changed after the view opened; reopen it to review what is on disk`);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
async function packageVersion(): Promise<string> {
|
|
329
|
+
return (JSON.parse(await readFile(new URL('../package.json', import.meta.url), 'utf8')) as { version: string }).version;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/** Writes the verdict atomically beside its sources. */
|
|
333
|
+
export async function saveVerdict(pkg: PartsViewPackage, input: unknown): Promise<PartsVerdict> {
|
|
334
|
+
await assertPartsUnchanged(pkg);
|
|
335
|
+
const verdict = buildVerdict(pkg, input, await packageVersion());
|
|
336
|
+
await mkdir(dirname(pkg.verdictPath), { recursive: true });
|
|
337
|
+
const tmp = `${pkg.verdictPath}.${crypto.randomUUID()}.tmp`;
|
|
338
|
+
await writeFile(tmp, JSON.stringify(verdict, null, 2) + '\n');
|
|
339
|
+
await rename(tmp, pkg.verdictPath);
|
|
340
|
+
return verdict;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/** Why a saved verdict is not offered: made on other part files, or on the same files with other producer flags. */
|
|
344
|
+
export type VerdictStale = 'files' | 'flags' | null;
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* The saved verdict, when it was made on exactly these files and these producer flags. create gates on
|
|
348
|
+
* `source.sha256` alone; the page also requires `source.flags`, so a reviewer never sees a sign-off over flags they
|
|
349
|
+
* were not shown.
|
|
350
|
+
*/
|
|
351
|
+
export async function readVerdict(pkg: PartsViewPackage): Promise<{ verdict: PartsVerdict | null; stale: VerdictStale }> {
|
|
352
|
+
let raw: unknown;
|
|
353
|
+
try { raw = JSON.parse(await readFile(pkg.verdictPath, 'utf8')); } catch { return { verdict: null, stale: null }; }
|
|
354
|
+
const v = record(raw), source = record(v?.source), now = verdictSource(pkg);
|
|
355
|
+
if (!v || v.schema !== PARTS_VERDICT_SCHEMA || v.mode !== pkg.mode || source?.sha256 !== now.sha256) return { verdict: null, stale: 'files' };
|
|
356
|
+
if (JSON.stringify(source.flags) !== JSON.stringify(now.flags)) return { verdict: null, stale: 'flags' };
|
|
357
|
+
return { verdict: v as unknown as PartsVerdict, stale: null };
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
/** What the page reads: no absolute path leaves the server but the verdict file's name. */
|
|
361
|
+
export function partsViewJson(pkg: PartsViewPackage, saved: { verdict: PartsVerdict | null; stale: VerdictStale }) {
|
|
362
|
+
return {
|
|
363
|
+
schema: 'rig-review-parts-view/1', mode: pkg.mode, title: pkg.title, rigSize: pkg.rigSize,
|
|
364
|
+
items: pkg.items, pages: pkg.pages, flags: pkg.flags,
|
|
365
|
+
flagSources: pkg.flagFiles.map(f => basename(f.abs)), flagMissing: pkg.flagNotes,
|
|
366
|
+
verdictFile: basename(pkg.verdictPath), verdict: saved.verdict, verdictStale: saved.stale,
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
/** Index → absolute path, for the image routes. */
|
|
371
|
+
export function servedImage(pkg: PartsViewPackage, kind: 'image' | 'page', index: number): string | null {
|
|
372
|
+
const list = kind === 'image' ? pkg.imagePaths : pkg.pagePaths;
|
|
373
|
+
return Number.isInteger(index) && index >= 0 && index < list.length ? list[index]! : null;
|
|
374
|
+
}
|
|
375
|
+
|
package/web/catalog-en.ts
CHANGED
|
@@ -562,6 +562,7 @@ export const enCatalog: Readonly<Record<string, string>> = {
|
|
|
562
562
|
"Create": "Create",
|
|
563
563
|
"Create · key C": "Create · key C",
|
|
564
564
|
"Create: that is a vertex already — click empty space or an edge": "Create: that is a vertex already — click empty space or an edge",
|
|
565
|
+
"Crop": "Crop",
|
|
565
566
|
"Crop height": "Crop height",
|
|
566
567
|
"Crop pixels, x screen-right and y down (<code>family-chest-regions/1</code>). Place the circles with <strong>Chest regions</strong> in the view bar; this block holds names, bones, semi-axes, clip and the contour. Equal semi-axes export as a circle, unequal ones (or a clip) as the generator's 32-sample polygon. Exporting writes nothing into the package and is not an approval.": "Crop pixels, x screen-right and y down (<code>family-chest-regions/1</code>). Place the circles with <strong>Chest regions</strong> in the view bar; this block holds names, bones, semi-axes, clip and the contour. Equal semi-axes export as a circle, unequal ones (or a clip) as the generator's 32-sample polygon. Exporting writes nothing into the package and is not an approval.",
|
|
567
568
|
"Crop width": "Crop width",
|
|
@@ -636,6 +637,7 @@ export const enCatalog: Readonly<Record<string, string>> = {
|
|
|
636
637
|
"Drag to pan · scroll to zoom · cameras synchronized": "Drag to pan · scroll to zoom · cameras synchronized",
|
|
637
638
|
"Dragging the rig pane pans the camera and tells the physics the rig moved, so hair and cloth trail; a click that does not move still selects a part. Hold Space to pan only. Reset returns the runtime start values and re-poses from the current time, clearing the physics history.": "Dragging the rig pane pans the camera and tells the physics the rig moved, so hair and cloth trail; a click that does not move still selects a part. Hold Space to pan only. Reset returns the runtime start values and re-poses from the current time, clearing the physics history.",
|
|
638
639
|
"Draw polygon": "Draw polygon",
|
|
640
|
+
"Draw the chest regions on the rig and edit them there; the same toggle as Chest regions in the view bar": "Draw the chest regions on the rig and edit them there; the same toggle as Chest regions in the view bar",
|
|
639
641
|
"Drawn": "Drawn",
|
|
640
642
|
"Drawn late": "Drawn late",
|
|
641
643
|
"Drawn page: ": "Drawn page: ",
|
|
@@ -906,6 +908,7 @@ export const enCatalog: Readonly<Record<string, string>> = {
|
|
|
906
908
|
"Map taken from the JSON field.": "Map taken from the JSON field.",
|
|
907
909
|
"Maps one inspection axis to its animation time. This does not rotate the camera.": "Maps one inspection axis to its animation time. This does not rotate the camera.",
|
|
908
910
|
"Margin": "Margin",
|
|
911
|
+
"Markers": "Markers",
|
|
909
912
|
"Max edge": "Max edge",
|
|
910
913
|
"Max influence": "Max influence",
|
|
911
914
|
"Medial clip x": "Medial clip x",
|
|
@@ -1020,6 +1023,8 @@ export const enCatalog: Readonly<Record<string, string>> = {
|
|
|
1020
1023
|
"Number of values": "Number of values",
|
|
1021
1024
|
"Numeric source region · opening this link restores a paused inspection": "Numeric source region · opening this link restores a paused inspection",
|
|
1022
1025
|
"OVERLAP {0} under {1}": "OVERLAP {0} under {1}",
|
|
1026
|
+
"Off": "Off",
|
|
1027
|
+
"On": "On",
|
|
1023
1028
|
"On stage": "On stage",
|
|
1024
1029
|
"One-line feedback on chest position": "One-line feedback on chest position",
|
|
1025
1030
|
"One-line feedback on contour curvature": "One-line feedback on contour curvature",
|
|
@@ -3029,4 +3034,55 @@ export const enCatalog: Readonly<Record<string, string>> = {
|
|
|
3029
3034
|
"Copy R's y, core radius and band to L (leaves L's x as is)": "Copy R's y, core radius and band to L (leaves L's x as is)",
|
|
3030
3035
|
"Y·size symmetry": "Y·size symmetry",
|
|
3031
3036
|
"view only, no producer handoff": "view only, no producer handoff",
|
|
3037
|
+
"Page {name}: {width}×{height} px, {count} regions. The background shows through padding; a region box is the packer's, and pixels outside it are bleed.": "Page {name}: {width}×{height} px, {count} regions. The background shows through padding; a region box is the packer's, and pixels outside it are bleed.",
|
|
3038
|
+
"Region {name} on {page} at {x},{y}, {width}×{height} px, with {margin} px of the page around it (dashed: the region box).": "Region {name} on {page} at {x},{y}, {width}×{height} px, with {margin} px of the page around it (dashed: the region box).",
|
|
3039
|
+
"Packed at {degrees}°.": "Packed at {degrees}°.",
|
|
3040
|
+
"{name}: {width}×{height} px at {x},{y} in rig px, draw order {order} of {count}.": "{name}: {width}×{height} px at {x},{y} in rig px, draw order {order} of {count}.",
|
|
3041
|
+
"Tinted: the footprints of {count} parts drawn in front ({names}).": "Tinted: the footprints of {count} parts drawn in front ({names}).",
|
|
3042
|
+
"No part is drawn in front of it.": "No part is drawn in front of it.",
|
|
3043
|
+
"Faint island left out of the mesh: {art} px, brightest alpha {alpha}, at {x},{y} {width}×{height} (part-image px).": "Faint island left out of the mesh: {art} px, brightest alpha {alpha}, at {x},{y} {width}×{height} (part-image px).",
|
|
3044
|
+
"No producer flag names this part.": "No producer flag names this part.",
|
|
3045
|
+
"Read from: {files}.": "Read from: {files}.",
|
|
3046
|
+
"Not found: {files}.": "Not found: {files}.",
|
|
3047
|
+
"Occlusion coverage is not read yet: the producer does not write it.": "Occlusion coverage is not read yet: the producer does not write it.",
|
|
3048
|
+
"Clean": "Clean",
|
|
3049
|
+
"Flagged": "Flagged",
|
|
3050
|
+
"Saved {file}: source {hash}.": "Saved {file}: source {hash}.",
|
|
3051
|
+
"Save failed.": "Save failed.",
|
|
3052
|
+
"Load failed.": "Load failed.",
|
|
3053
|
+
"Parts package, before rigging": "Parts package, before rigging",
|
|
3054
|
+
"Atlas of a built rig": "Atlas of a built rig",
|
|
3055
|
+
"A saved sign-off was made on other files; this review starts fresh.": "A saved sign-off was made on other files; this review starts fresh.",
|
|
3056
|
+
"Saved sign-off loaded.": "Saved sign-off loaded.",
|
|
3057
|
+
"Footprints need a parts package: atlas regions carry no rig placement.": "Footprints need a parts package: atlas regions carry no rig placement.",
|
|
3058
|
+
"Parts": "Parts",
|
|
3059
|
+
"Zoom": "Zoom",
|
|
3060
|
+
"Atlas view": "Atlas view",
|
|
3061
|
+
"Part outcome": "Part outcome",
|
|
3062
|
+
"rig review parts": "rig review parts",
|
|
3063
|
+
"Parts review": "Parts review",
|
|
3064
|
+
"Background": "Background",
|
|
3065
|
+
"Green": "Green",
|
|
3066
|
+
"Magenta": "Magenta",
|
|
3067
|
+
"Black": "Black",
|
|
3068
|
+
"White": "White",
|
|
3069
|
+
"Checker": "Checker",
|
|
3070
|
+
"Alpha only": "Alpha only",
|
|
3071
|
+
"Footprints of parts in front": "Footprints of parts in front",
|
|
3072
|
+
"Region": "Region",
|
|
3073
|
+
"Pages": "Pages",
|
|
3074
|
+
"PRODUCER FLAGS": "PRODUCER FLAGS",
|
|
3075
|
+
"VERDICT": "VERDICT",
|
|
3076
|
+
"Note": "Note",
|
|
3077
|
+
"Sign-off": "Sign-off",
|
|
3078
|
+
"Save sign-off": "Save sign-off",
|
|
3079
|
+
"{under} opens under {above} · {animation} f{frame} ({time} s) · {found} cells found / {allowed} allowed": "{under} opens under {above} · {animation} f{frame} ({time} s) · {found} cells found / {allowed} allowed",
|
|
3080
|
+
"Seam {a} | {b} · {px40} px over 40 · {px80} px over 80": "Seam {a} | {b} · {px40} px over 40 · {px80} px over 80",
|
|
3081
|
+
"rig box {x},{y} {width}×{height}": "rig box {x},{y} {width}×{height}",
|
|
3082
|
+
"{gate} {status} on {part}": "{gate} {status} on {part}",
|
|
3083
|
+
"Check line {path}": "Check line {path}",
|
|
3084
|
+
"Producer line": "Producer line",
|
|
3085
|
+
"Page {name}: {width}×{height} px, 1 region. The background shows through padding; a region box is the packer's, and pixels outside it are bleed.": "Page {name}: {width}×{height} px, 1 region. The background shows through padding; a region box is the packer's, and pixels outside it are bleed.",
|
|
3086
|
+
"Tinted: the footprint of the part drawn in front ({names}).": "Tinted: the footprint of the part drawn in front ({names}).",
|
|
3087
|
+
"The saved sign-off is for different producer flags; this review starts fresh.": "The saved sign-off is for different producer flags; this review starts fresh.",
|
|
3032
3088
|
};
|
package/web/catalog-ko.ts
CHANGED
|
@@ -562,6 +562,7 @@ export const koCatalog: Readonly<Record<string, string>> = {
|
|
|
562
562
|
"Create": "생성",
|
|
563
563
|
"Create · key C": "생성 · 단축키 C",
|
|
564
564
|
"Create: that is a vertex already — click empty space or an edge": "생성: 이미 정점입니다 — 빈 공간이나 엣지를 클릭하세요",
|
|
565
|
+
"Crop": "크롭",
|
|
565
566
|
"Crop height": "크롭 높이",
|
|
566
567
|
"Crop pixels, x screen-right and y down (<code>family-chest-regions/1</code>). Place the circles with <strong>Chest regions</strong> in the view bar; this block holds names, bones, semi-axes, clip and the contour. Equal semi-axes export as a circle, unequal ones (or a clip) as the generator's 32-sample polygon. Exporting writes nothing into the package and is not an approval.": "크롭 픽셀 기준이며 x는 화면 오른쪽, y는 아래쪽입니다(<code>family-chest-regions/1</code>). 뷰 바의 <strong>가슴 영역</strong>으로 원을 배치하세요. 이 블록은 이름, 본, 반축, 클립 및 윤곽을 담습니다. 반축이 같으면 원으로, 다르거나 클립이 있으면 생성기의 32샘플 다각형으로 내보냅니다. 내보내기는 패키지에 아무것도 기록하지 않으며 승인이 아닙니다.",
|
|
567
568
|
"Crop width": "크롭 너비",
|
|
@@ -636,6 +637,7 @@ export const koCatalog: Readonly<Record<string, string>> = {
|
|
|
636
637
|
"Drag to pan · scroll to zoom · cameras synchronized": "드래그하여 이동 · 스크롤하여 확대/축소 · 카메라 동기화됨",
|
|
637
638
|
"Dragging the rig pane pans the camera and tells the physics the rig moved, so hair and cloth trail; a click that does not move still selects a part. Hold Space to pan only. Reset returns the runtime start values and re-poses from the current time, clearing the physics history.": "리그 창을 드래그하면 화면이 이동하면서 리그가 움직인 것으로 물리에 전달되어 머리카락과 옷이 뒤따라 흔들립니다. 움직이지 않은 클릭은 그대로 파트를 선택합니다. Space를 누른 채 드래그하면 화면만 이동합니다. 초기화는 런타임 시작 값으로 되돌리고 물리 히스토리를 지운 뒤 현재 시간부터 다시 포즈를 잡습니다.",
|
|
638
639
|
"Draw polygon": "다각형 그리기",
|
|
640
|
+
"Draw the chest regions on the rig and edit them there; the same toggle as Chest regions in the view bar": "리그에 가슴 영역을 그리고 그 위에서 편집합니다. 뷰 바의 가슴 영역과 같은 토글입니다",
|
|
639
641
|
"Drawn": "그려짐",
|
|
640
642
|
"Drawn late": "지연 그려짐",
|
|
641
643
|
"Drawn page: ": "그려진 페이지: ",
|
|
@@ -906,6 +908,7 @@ export const koCatalog: Readonly<Record<string, string>> = {
|
|
|
906
908
|
"Map taken from the JSON field.": "JSON 필드에서 맵을 가져왔습니다.",
|
|
907
909
|
"Maps one inspection axis to its animation time. This does not rotate the camera.": "하나의 검사 축을 애니메이션 시간에 매핑합니다. 카메라를 회전시키지 않습니다.",
|
|
908
910
|
"Margin": "여백(마진)",
|
|
911
|
+
"Markers": "마커",
|
|
909
912
|
"Max edge": "최대 엣지",
|
|
910
913
|
"Max influence": "최대 영향",
|
|
911
914
|
"Medial clip x": "내측 클립 x",
|
|
@@ -1020,6 +1023,8 @@ export const koCatalog: Readonly<Record<string, string>> = {
|
|
|
1020
1023
|
"Number of values": "값 개수",
|
|
1021
1024
|
"Numeric source region · opening this link restores a paused inspection": "수치 소스 영역 · 이 링크를 열면 일시정지된 검사가 복원됩니다",
|
|
1022
1025
|
"OVERLAP {0} under {1}": "{1} 아래 겹침(OVERLAP) {0}",
|
|
1026
|
+
"Off": "끔",
|
|
1027
|
+
"On": "켬",
|
|
1023
1028
|
"On stage": "스테이지 표시 중",
|
|
1024
1029
|
"One-line feedback on chest position": "가슴 위치에 대한 한 줄 피드백",
|
|
1025
1030
|
"One-line feedback on contour curvature": "윤곽 곡률에 대한 한 줄 피드백",
|
|
@@ -3029,4 +3034,55 @@ export const koCatalog: Readonly<Record<string, string>> = {
|
|
|
3029
3034
|
"Copy R's y, core radius and band to L (leaves L's x as is)": "R의 y, 중심 반경(r), 밴드를 L에 복사합니다(L의 x는 유지)",
|
|
3030
3035
|
"Y·size symmetry": "Y·크기 대칭",
|
|
3031
3036
|
"view only, no producer handoff": "뷰 전용, 프로듀서 핸드오프 없음",
|
|
3037
|
+
"Page {name}: {width}×{height} px, {count} regions. The background shows through padding; a region box is the packer's, and pixels outside it are bleed.": "페이지 {name}: {width}×{height} px, 영역 {count}개. 패딩에는 배경이 비쳐 보이고, 영역 상자는 패커가 정한 것이며 상자 밖의 픽셀은 블리드입니다.",
|
|
3038
|
+
"Region {name} on {page} at {x},{y}, {width}×{height} px, with {margin} px of the page around it (dashed: the region box).": "{page}의 영역 {name}: {x},{y} 위치, {width}×{height} px, 주변 페이지 {margin} px 포함(점선: 영역 상자).",
|
|
3039
|
+
"Packed at {degrees}°.": "{degrees}° 회전되어 패킹됨.",
|
|
3040
|
+
"{name}: {width}×{height} px at {x},{y} in rig px, draw order {order} of {count}.": "{name}: {width}×{height} px, 리그 px 기준 {x},{y} 위치, 그리기 순서 {count}개 중 {order}번째.",
|
|
3041
|
+
"Tinted: the footprints of {count} parts drawn in front ({names}).": "색칠된 부분: 앞에 그려지는 파츠 {count}개의 풋프린트({names}).",
|
|
3042
|
+
"No part is drawn in front of it.": "이 파츠 앞에 그려지는 파츠가 없습니다.",
|
|
3043
|
+
"Faint island left out of the mesh: {art} px, brightest alpha {alpha}, at {x},{y} {width}×{height} (part-image px).": "메시에서 빠진 희미한 섬: {art} px, 최대 알파 {alpha}, 위치 {x},{y} {width}×{height}(파츠 이미지 px).",
|
|
3044
|
+
"No producer flag names this part.": "이 파츠를 가리키는 프로듀서 플래그가 없습니다.",
|
|
3045
|
+
"Read from: {files}.": "읽은 파일: {files}.",
|
|
3046
|
+
"Not found: {files}.": "찾지 못함: {files}.",
|
|
3047
|
+
"Occlusion coverage is not read yet: the producer does not write it.": "가림 커버리지는 아직 읽지 않습니다: 프로듀서가 아직 쓰지 않습니다.",
|
|
3048
|
+
"Clean": "이상 없음",
|
|
3049
|
+
"Flagged": "문제 있음",
|
|
3050
|
+
"Saved {file}: source {hash}.": "{file} 저장됨: 소스 {hash}.",
|
|
3051
|
+
"Save failed.": "저장하지 못했습니다.",
|
|
3052
|
+
"Load failed.": "불러오지 못했습니다.",
|
|
3053
|
+
"Parts package, before rigging": "파츠 패키지, 리깅 전",
|
|
3054
|
+
"Atlas of a built rig": "빌드된 리그의 아틀라스",
|
|
3055
|
+
"A saved sign-off was made on other files; this review starts fresh.": "저장된 승인은 다른 파일에 대해 내려진 것이라, 이번 검수는 처음부터 시작합니다.",
|
|
3056
|
+
"Saved sign-off loaded.": "저장된 승인을 불러왔습니다.",
|
|
3057
|
+
"Footprints need a parts package: atlas regions carry no rig placement.": "풋프린트에는 파츠 패키지가 필요합니다: 아틀라스 영역에는 리그 배치가 없습니다.",
|
|
3058
|
+
"Parts": "파츠",
|
|
3059
|
+
"Zoom": "확대",
|
|
3060
|
+
"Atlas view": "아틀라스 보기",
|
|
3061
|
+
"Part outcome": "파츠 판정",
|
|
3062
|
+
"rig review parts": "rig review 파츠",
|
|
3063
|
+
"Parts review": "파츠 검수",
|
|
3064
|
+
"Background": "배경",
|
|
3065
|
+
"Green": "초록",
|
|
3066
|
+
"Magenta": "마젠타",
|
|
3067
|
+
"Black": "검정",
|
|
3068
|
+
"White": "흰색",
|
|
3069
|
+
"Checker": "체커",
|
|
3070
|
+
"Alpha only": "알파만",
|
|
3071
|
+
"Footprints of parts in front": "앞 파츠의 풋프린트",
|
|
3072
|
+
"Region": "영역",
|
|
3073
|
+
"Pages": "페이지",
|
|
3074
|
+
"PRODUCER FLAGS": "프로듀서 플래그",
|
|
3075
|
+
"VERDICT": "판정",
|
|
3076
|
+
"Note": "메모",
|
|
3077
|
+
"Sign-off": "승인",
|
|
3078
|
+
"Save sign-off": "승인 저장",
|
|
3079
|
+
"{under} opens under {above} · {animation} f{frame} ({time} s) · {found} cells found / {allowed} allowed": "{under}이(가) {above} 아래에서 벌어짐 · {animation} f{frame} ({time}초) · 셀 {found}개 발견 / 허용 {allowed}개",
|
|
3080
|
+
"Seam {a} | {b} · {px40} px over 40 · {px80} px over 80": "이음매 {a} | {b} · 40 초과 {px40} px · 80 초과 {px80} px",
|
|
3081
|
+
"rig box {x},{y} {width}×{height}": "리그 상자 {x},{y} {width}×{height}",
|
|
3082
|
+
"{gate} {status} on {part}": "{part}에서 {gate} {status}",
|
|
3083
|
+
"Check line {path}": "체크 줄 {path}",
|
|
3084
|
+
"Producer line": "프로듀서 원문",
|
|
3085
|
+
"Page {name}: {width}×{height} px, 1 region. The background shows through padding; a region box is the packer's, and pixels outside it are bleed.": "페이지 {name}: {width}×{height} px, 영역 1개. 패딩에는 배경이 비쳐 보이고, 영역 상자는 패커가 정한 것이며 상자 밖의 픽셀은 블리드입니다.",
|
|
3086
|
+
"Tinted: the footprint of the part drawn in front ({names}).": "색칠된 부분: 앞에 그려지는 파츠의 풋프린트({names}).",
|
|
3087
|
+
"The saved sign-off is for different producer flags; this review starts fresh.": "저장된 승인은 다른 프로듀서 플래그에 대해 내려진 것이라, 이번 검수는 처음부터 시작합니다.",
|
|
3032
3088
|
};
|
package/web/chest-editor.ts
CHANGED
|
@@ -227,6 +227,8 @@ export interface ChestEditor {active:()=>boolean;flashing:(side:BustSide)=>boole
|
|
|
227
227
|
|
|
228
228
|
/** The toggle's and Apply's own tooltips, restored when the editor becomes available again (`web/index.html`). */
|
|
229
229
|
const CHEST_EDIT_TITLE='Place the two chest regions on the rig: drag a centre, the core edge or the band';
|
|
230
|
+
/** #345: the detail block's mirror of the toggle, so its state shows where the values are edited. */
|
|
231
|
+
const CHEST_MARKERS_TITLE='Draw the chest regions on the rig and edit them there; the same toggle as Chest regions in the view bar';
|
|
230
232
|
const BUST_APPLY_TITLE='Run the installed producer (rig-parts remesh) on these regions or landmarks into a scratch build and load it here; the package is unchanged';
|
|
231
233
|
|
|
232
234
|
export function bindChestEditor(host:ChestEditorHost):ChestEditor {
|
|
@@ -235,11 +237,14 @@ export function bindChestEditor(host:ChestEditorHost):ChestEditor {
|
|
|
235
237
|
const field=(id:string)=>document.getElementById(id) as HTMLInputElement|null;
|
|
236
238
|
const read:ChestFieldReader=id=>{const f=field(id);return f?{value:f.value}:undefined;};
|
|
237
239
|
const log=node<HTMLElement>('chest-editor-log'),apply=node<HTMLButtonElement>('bust-apply'),reset=node<HTMLButtonElement>('bust-reset');
|
|
240
|
+
// #345: optional, so a page without the detail block still binds.
|
|
241
|
+
const markers=document.getElementById('chest-markers') as HTMLButtonElement|null,unavailableLine=document.getElementById('chest-unavailable');
|
|
238
242
|
let notice:{text:string;error:boolean}|null=null,blocked:string|null=null,busy=false;
|
|
239
243
|
/** #342: a disabled control names its reason in its tooltip, the way an unavailable layout does. */
|
|
240
244
|
const gate=()=>{
|
|
241
|
-
for(const [button,title] of [[toggle,CHEST_EDIT_TITLE],[apply,BUST_APPLY_TITLE]] as const){button.title=blocked??title;if(blocked)button.setAttribute('aria-description',blocked);else button.removeAttribute('aria-description');}
|
|
242
|
-
toggle.disabled=!!blocked;apply.disabled=busy||!!blocked;
|
|
245
|
+
for(const [button,title] of [[toggle,CHEST_EDIT_TITLE],[apply,BUST_APPLY_TITLE],...(markers?[[markers,CHEST_MARKERS_TITLE] as const]:[])] as const){button.title=blocked??title;if(blocked)button.setAttribute('aria-description',blocked);else button.removeAttribute('aria-description');}
|
|
246
|
+
toggle.disabled=!!blocked;apply.disabled=busy||!!blocked;if(markers)markers.disabled=!!blocked;
|
|
247
|
+
if(unavailableLine){unavailableLine.textContent=blocked??'';unavailableLine.hidden=!blocked;}
|
|
243
248
|
};
|
|
244
249
|
const modeInput=field('bust-mode'),landmarkGroups=[...bar.querySelectorAll<HTMLElement>('[data-chest-mode]')],readout=node<HTMLElement>('lm-derived');
|
|
245
250
|
const mode=():ChestMode=>modeInput?.value==='landmarks'?'landmarks':'circles';
|
|
@@ -284,8 +289,9 @@ export function bindChestEditor(host:ChestEditorHost):ChestEditor {
|
|
|
284
289
|
const shown=editorStatus(notice,host.mapping(),m);
|
|
285
290
|
status.textContent=shown.text;status.title=shown.text;status.classList.toggle('error',shown.error);
|
|
286
291
|
};
|
|
287
|
-
const setActive=(on:boolean)=>{active=on;toggle.setAttribute('aria-pressed',String(on));bar.hidden=!on;if(!on){drag=null;landmarkDrag=null;armed=null;delete host.pane.dataset.chestHover;}sync();host.changed();};
|
|
292
|
+
const setActive=(on:boolean)=>{active=on;toggle.setAttribute('aria-pressed',String(on));markers?.setAttribute('aria-pressed',String(on));bar.hidden=!on;if(!on){drag=null;landmarkDrag=null;armed=null;delete host.pane.dataset.chestHover;}sync();host.changed();};
|
|
288
293
|
toggle.addEventListener('click',()=>{if(!blocked)setActive(!active);});
|
|
294
|
+
markers?.addEventListener('click',()=>{if(!blocked)setActive(!active);});
|
|
289
295
|
bar.addEventListener('input',event=>{
|
|
290
296
|
const target=event.target as HTMLInputElement,match=/^bust-([rl])-(x|y|r|band)$/.exec(target.id);if(!match)return;
|
|
291
297
|
const value=Number(target.value);if(!target.value.trim()||!Number.isFinite(value))return;
|
|
@@ -17,7 +17,7 @@ import { partBounds, type PartExplorer } from './part-selection.ts';
|
|
|
17
17
|
import { bindInspectorBlocks, activeBlocksUI, restoreActiveBlocksUI, type InspectorBlocks } from './inspector-blocks.ts';
|
|
18
18
|
import { sourceTextContent, tr } from './i18n.ts';
|
|
19
19
|
import { bindChestEditor, canvasToCrop, bustLabel, bustSides, chestPoseOffset, LANDMARKS, landmarkInputId, posedChestMapping, rowShape, type ChestEditor, type LandmarkKey } from './chest-editor.ts';
|
|
20
|
-
import {
|
|
20
|
+
import { chestOverlayPolygons, chestRegionRows, chestRowId, evaluateChestForm } from './chest-regions-tool.ts';
|
|
21
21
|
import { chestRegionsBinding, cropWorldMapping, type CropWorldMapping } from '../src/chest-regions.ts';
|
|
22
22
|
import { bindMeshEditor, meshEditSource, sha256Hex, type MeshEditor } from './mesh-editor.ts';
|
|
23
23
|
import { meshEditBinding, meshEditText, type MeshEditDocument } from '../src/mesh-edit.ts';
|
|
@@ -644,6 +644,8 @@ export function mountComparePickedTools(host: ComparePickedToolsHost): ComparePi
|
|
|
644
644
|
}
|
|
645
645
|
|
|
646
646
|
function chestRegions(): OverlayRegion[] {
|
|
647
|
+
// #345: the chest overlay is drawn only while the Chest regions toggle is on.
|
|
648
|
+
if (!chestEditor?.active()) return [];
|
|
647
649
|
const style = getComputedStyle(document.documentElement), token = (name: string) => style.getPropertyValue(name).trim();
|
|
648
650
|
return chestOverlayPolygons(chestEvaluation(), activeChestMapping()).map((region, i) => ({
|
|
649
651
|
...region,
|
|
@@ -654,7 +656,7 @@ export function mountComparePickedTools(host: ComparePickedToolsHost): ComparePi
|
|
|
654
656
|
|
|
655
657
|
function chestCircles(): OverlayCircle[] {
|
|
656
658
|
const mapping = activeChestMapping();
|
|
657
|
-
if (!mapping.available) return [];
|
|
659
|
+
if (!mapping.available || !chestEditor?.active()) return [];
|
|
658
660
|
const style = getComputedStyle(document.documentElement), token = (name: string) => style.getPropertyValue(name).trim();
|
|
659
661
|
const colors = (row: number, overlap: boolean) => ({
|
|
660
662
|
stroke: token(overlap ? '--rv-bust-overlap' : row ? '--rv-bust-l' : '--rv-bust-r'),
|
|
@@ -679,7 +681,7 @@ export function mountComparePickedTools(host: ComparePickedToolsHost): ComparePi
|
|
|
679
681
|
center: mapping.toWorld(circle.cx, circle.cy), r: circle.r, ...(circle.ry === undefined ? {} : { ry: circle.ry }), ...(circle.clip === undefined ? {} : { clipX: mapping.toWorld(circle.clip, circle.cy).x }), band: circle.band, label: bustLabel(side, circle), labelRow: row, handles: true, flash: chestEditor!.flashing(side), colors: colors(row, overlap),
|
|
680
682
|
}] : []);
|
|
681
683
|
}
|
|
682
|
-
return
|
|
684
|
+
return [];
|
|
683
685
|
}
|
|
684
686
|
|
|
685
687
|
function chestMarkers(): OverlayMarker[] {
|