rig-review 1.7.0 → 1.9.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/PARTS_VIEW.md +80 -28
- package/package.json +1 -1
- package/src/parts-view.ts +51 -11
- package/web/catalog-en.ts +16 -0
- package/web/catalog-ko.ts +20 -4
- package/web/parts-flags.ts +9 -1
- package/web/parts-render.ts +22 -0
- package/web/parts.css +7 -3
- package/web/parts.html +2 -0
- package/web/parts.ts +103 -18
package/docs/PARTS_VIEW.md
CHANGED
|
@@ -32,41 +32,70 @@ is written), `--painting <png>` (the original painting), `--format json|issue` (
|
|
|
32
32
|
region's own view keeps 4 page pixels around its box (dashed) so bleed is visible. Clicking a region opens it.
|
|
33
33
|
- **Producer flags**, read from the files rig-parts writes and shown on the part they name. None is re-measured here. Each reads as one labelled line (an opening's parts, animation, frame and cells; a seam pair's pixel counts; a gate's name, status and readings), with the producer's object verbatim under a collapsed **Producer line**.
|
|
34
34
|
|
|
35
|
+
The [23-part EN/KO comparison](https://github.com/rig-c/review/tree/main/tests/fixtures/parts-approve-all-evidence) records the same 1600×1100 initial view against installed 1.8.0: row height 49.375 → 26.1875 px, with all 23 after rows on one line (`tests/parts-approve-all-browser.ts`).
|
|
36
|
+
|
|
35
37
|
### Producer row groups
|
|
36
38
|
|
|
37
|
-
The sidebar
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
39
|
+
The sidebar counts **only mesh-report flags and explicit part findings**. A check row counts only
|
|
40
|
+
when `row_scope: "part"`, `row_kind: "finding"` and a valid `row_subjects` array names that part.
|
|
41
|
+
A block status, a JSON path, a reason or a legacy part/slot/bone field never determines classification.
|
|
42
|
+
Counts stay separate by source, for example **mesh 1 · check 1**; an absent report is not shown as zero.
|
|
43
|
+
A part with no counted flags has no count badge, even when it has other readings.
|
|
44
|
+
|
|
45
|
+
Rows appear beneath **mesh_report.json** / **check.json**, with collapsed categories and producer-root groups:
|
|
46
|
+
- **Part findings**: the explicitly attributed findings counted in the badge.
|
|
47
|
+
- **Pair readings**: pair findings on both explicit subjects, never counted.
|
|
48
|
+
- **Check evidence**: every evidence row and every rig row (including rig findings), never counted.
|
|
49
|
+
Subject-bound evidence appears on its subjects; rig rows have no implied part and are visible on every selection.
|
|
50
|
+
- **Unclassified check rows**: incomplete or invalid metadata, never counted. In a mixed document an object row
|
|
51
|
+
without a complete tuple remains visible here globally, without guessed subject attribution. The tuple requires
|
|
52
|
+
scope part/pair/rig, kind finding/evidence, and respectively 1/2/0 distinct nonempty string subjects.
|
|
53
|
+
If any subject is not held in this view, the entire tuple is unclassified globally, including a pair with one held subject. No partial or substitute attribution is made.
|
|
54
|
+
|
|
55
|
+
The reader walks all roots regardless of block status, nested observation arrays, alternate sets and
|
|
56
|
+
`requirements.lines` dictionaries. Singleton summaries are not rows, except that a top-level FAIL/WARN gate
|
|
57
|
+
without a tuple is preserved globally as unclassified, even in a labelled document. Its status does not make
|
|
58
|
+
it a classified finding. Each headline preserves root, exact path,
|
|
59
|
+
producer string fields and measurements. **Block** labels the enclosing block status; it never overrides the
|
|
60
|
+
row's kind. **Producer line** holds the full original row object. Producer values are never translated.
|
|
61
|
+
|
|
62
|
+
A document with no row metadata keeps #380's source-root extraction and attribution, explicitly **unclassified**.
|
|
63
|
+
It can retain unavailable support and informational pairs; none becomes a counted finding. The public legacy
|
|
64
|
+
[`parts-check-380.json`](https://github.com/rig-c/review/blob/main/tests/fixtures/parts-check-380.json) remains a
|
|
65
|
+
synthetic compatibility fixture. Its 11 historical check attributions remain in the verdict wire collection,
|
|
66
|
+
while its sidebar check finding count is absent (only the back defect's mesh flag counts).
|
|
67
|
+
|
|
68
|
+
The fixture contract is pinned to published **@rig-c/parts@2.17.0**, source
|
|
69
|
+
[`971b3a7`](https://github.com/rig-c/parts/tree/971b3a7fab1109adf5be11750886687a7addb306),
|
|
70
|
+
whose [consumer row table](https://github.com/rig-c/parts/blob/971b3a7fab1109adf5be11750886687a7addb306/docs/AUTHORING.md#consumer-check-rows-issue-1089)
|
|
71
|
+
and `src/checkrow.ts` define the fields. This is an evidence pin, not a runtime dependency or automatic install.
|
|
72
|
+
`tests/fixtures/parts-check-385-real.json` is the byte-exact public synthetic-rig check output from the installed
|
|
73
|
+
producer; check exit **1** is its deliberately planted stretch finding, not a green rig. The measurement packet's
|
|
74
|
+
exit 0 means capture completed. The separate `parts-check-385.json` is a clearly synthetic six-combination matrix,
|
|
75
|
+
including status/subject decoys. `parts-check-385.provenance.json` records hashes, source and the reproduction recipe.
|
|
76
|
+
`tests/parts-classification.test.ts` guards the actual DOM callers, API, classification and unchanged wire binding;
|
|
77
|
+
`tests/parts-classification-browser.ts` supplies real bilingual screenshots and collapsed/expanded/legacy checks.
|
|
78
|
+
Representative public screenshots: [English collapsed](https://github.com/rig-c/review/blob/main/tests/fixtures/parts-check-385-evidence/collapsed-en.png),
|
|
79
|
+
[English expanded](https://github.com/rig-c/review/blob/main/tests/fixtures/parts-check-385-evidence/expanded-en.png),
|
|
80
|
+
[Korean collapsed](https://github.com/rig-c/review/blob/main/tests/fixtures/parts-check-385-evidence/collapsed-ko.png),
|
|
81
|
+
[Korean expanded](https://github.com/rig-c/review/blob/main/tests/fixtures/parts-check-385-evidence/expanded-ko.png).
|
|
82
|
+
|
|
83
|
+
Classification is a separate read-only `readings` collection in the view response. The historical `flags`
|
|
84
|
+
collection and `buildVerdict` extraction remain unchanged: verdict/2 `parts.<name>.flags`, source file hashes,
|
|
85
|
+
comment serialization and create consumption keep their existing semantics. Display counts are not verdict IDs
|
|
86
|
+
or an approval decision. Changing the check document still invalidates an offered saved sign-off.
|
|
87
|
+
|
|
88
|
+
| Stored flag ID | Read from | Existing verdict/2 extraction (unchanged) |
|
|
62
89
|
| --- | --- | --- |
|
|
63
|
-
| `faint:<i>` | `mesh_report.json` beside `parts.json`
|
|
64
|
-
| `check:<path>` | `check/check.json` beside `rig/` |
|
|
90
|
+
| `faint:<i>` | `mesh_report.json` beside `parts.json` | a faint island the mesh left out |
|
|
91
|
+
| `check:<path>` | `check/check.json` beside `rig/` | historical FAIL/WARN gates or seam/opening lists naming a part by a non-bone string field; this is not the new sidebar classification |
|
|
65
92
|
|
|
66
93
|
The occlusion-coverage report (rig-c/parts#998) is not read yet; the footprint toggle stands without it.
|
|
67
94
|
|
|
68
95
|
## The sign-off
|
|
69
96
|
|
|
97
|
+
**Approve all** marks every pending part and available mesh clean, then saves an explicit approved sign-off. It preserves notes and existing clean outcomes; any flagged part or mesh refuses with `PARTS_APPROVE_ALL_FLAGGED` before changes are made. Individual approval remains available. `tests/parts-approve-all.test.ts` exercises the page action and unchanged verdict guard; `tests/parts-approve-all-browser.ts` checks the real save and refusal flows.
|
|
98
|
+
|
|
70
99
|
Each item is **pending**, **clean** or **flagged** with a note (a note is optional on clean). **Save sign-off**
|
|
71
100
|
writes `parts-review.json` beside `parts.json` (atlas mode: beside the model), or to `--verdict`:
|
|
72
101
|
|
|
@@ -92,7 +121,7 @@ writes `parts-review.json` beside `parts.json` (atlas mode: beside the model), o
|
|
|
92
121
|
verdict file's directory**, POSIX separators. A part added, removed or repainted after sign-off changes the hash.
|
|
93
122
|
- `source.sha256` is the SHA-256 of the UTF-8 lines `<path>\t<sha256>\n`, one per `source.files` entry, sorted by path
|
|
94
123
|
bytewise. Consumers recompute it from the files on disk.
|
|
95
|
-
- `source.flags` lists the producer files the flags were read from; `parts.<name>.flags` the
|
|
124
|
+
- `source.flags` lists the producer files the flags were read from; `parts.<name>.flags` the historical producer-attribution IDs defined above, not the classified sidebar count.
|
|
96
125
|
- `status`: `approved` only when every part is clean; `changes-requested` only with at least one part flagged;
|
|
97
126
|
otherwise `pending`.
|
|
98
127
|
|
|
@@ -278,3 +307,26 @@ separate stale warning. `PARTS_PAINTING_OUTSIDE` and `PARTS_PAINTING_PNG` refuse
|
|
|
278
307
|
painting inputs. `tests/parts-comments.test.ts` covers these read and cross-encoding boundaries;
|
|
279
308
|
`tests/parts-async-navigation.test.ts` guards reordered painting loads and actionable atlas clicks.
|
|
280
309
|
A downstream create consumer must support verdict/2 before a review release can ship.
|
|
310
|
+
|
|
311
|
+
### Assembled package
|
|
312
|
+
|
|
313
|
+
**Assembled** toggles the existing rig/reference pair from the selected part to the declared
|
|
314
|
+
`rig_size` canvas. Parts draw back to front in package order at their exact fractional rig-pixel
|
|
315
|
+
placements. The checkbox beside each part controls assembly visibility only; the verdict remains
|
|
316
|
+
per part. List rows occupy one line, with full part names available to assistive technology and on hover, separate source counts and the outcome badge. The former **Visible / 표시** caption is removed; the checkbox retains its per-part accessible name (`tests/parts-approve-all.test.ts`, with full-list geometry in `tests/parts-approve-all-browser.ts`). A tap selects the frontmost visible part with nonzero native source alpha, including
|
|
317
|
+
through transparent holes; drags remain camera gestures. The selected part's alpha edge is a
|
|
318
|
+
separate outline, outside the comparison raster. Background, alpha-only, Fit, 1:1 and the shared
|
|
319
|
+
camera controls remain available. `tests/parts-assembly.test.ts` guards fractional placement,
|
|
320
|
+
order controls, picking, hidden layers, separate outline pixels and per-part verdict invariance.
|
|
321
|
+
|
|
322
|
+
With `--painting`, the reference pane and optional Overlay use the same whole-canvas visual
|
|
323
|
+
mapping described above. No producer resampler, Difference or assembled verdict is added.
|
|
324
|
+
Without painting the reference keeps `PARTS_REFERENCE_UNAVAILABLE`; atlas assembly is disabled
|
|
325
|
+
because atlas regions carry no rig placement, and missing `rig_size` is named separately.
|
|
326
|
+
Comments remain bound to individual original PNGs: switch out of assembly to capture one;
|
|
327
|
+
restoring a saved comment returns to its individual part view. Assembly visibility is temporary
|
|
328
|
+
inspection state and is never saved into a verdict or comment. `tests/parts-assembly-browser.ts`
|
|
329
|
+
checks real EN/KO assembly/reference pixels against an independent browser draw after a
|
|
330
|
+
base-vs-base control, tap/hole/hide selection, pan, camera preservation, background, alpha,
|
|
331
|
+
verdict save and missing-input refusals. Existing `tests/parts-comparison.test.ts` and
|
|
332
|
+
`tests/parts-comments.test.ts` retain the painting-size and protected-input guards.
|
package/package.json
CHANGED
package/src/parts-view.ts
CHANGED
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
*
|
|
9
9
|
* Producer flags are read from the files rig-parts writes and shown on their part; nothing is re-measured here:
|
|
10
10
|
* - `mesh_report.json` rows: `contour.bridges.faint[]` (rig-parts #326), each a faint island the mesh left out;
|
|
11
|
-
* - `check.json`:
|
|
11
|
+
* - `check.json`: read-only row metadata drives display counts; the historical FAIL/WARN extraction below
|
|
12
|
+
* stays separate for verdict/2 compatibility. No display classification rewrites saved flag IDs.
|
|
12
13
|
*
|
|
13
14
|
* The sign-off is `rig-review-parts-verdict/2` (docs/PARTS_VIEW.md), written beside `parts.json` by default. Its
|
|
14
15
|
* `source.sha256` is the sha256 over the UTF-8 lines `<path>\t<sha256>\n`, sorted by path bytewise, where every path
|
|
@@ -56,7 +57,8 @@ export type ProducerFlag =
|
|
|
56
57
|
| { id: string; item: string; source: 'mesh_report'; kind: 'faint'; art: number; maxAlpha: number; box: [number, number, number, number] }
|
|
57
58
|
| { id: string; item: string; source: 'check'; kind: 'check'; path: string; line: string;
|
|
58
59
|
/** The top-level check.json key the line sits under, the gate's status when it is a gate, and the object as written. */
|
|
59
|
-
root: string; status: string | null; entry: Record<string, unknown
|
|
60
|
+
root: string; status: string | null; entry: Record<string, unknown>;
|
|
61
|
+
classification?: 'part' | 'pair' | 'evidence' | 'unclassified' };
|
|
60
62
|
|
|
61
63
|
export interface PartsViewPackage {
|
|
62
64
|
painting?:{sha256:string;width:number;height:number;abs:string};
|
|
@@ -67,6 +69,8 @@ export interface PartsViewPackage {
|
|
|
67
69
|
items: ViewItem[];
|
|
68
70
|
pages: ViewPage[];
|
|
69
71
|
flags: ProducerFlag[];
|
|
72
|
+
/** Read-only check presentation; never serialized into verdict/2. */
|
|
73
|
+
readings?: ProducerFlag[];
|
|
70
74
|
/** The files the sign-off rests on (parts.json and every part PNG; or the model and every page). */
|
|
71
75
|
files: LocalFile[];
|
|
72
76
|
/** The producer files the flags were read from. */
|
|
@@ -180,6 +184,42 @@ export function checkFlags(doc: unknown, names: ReadonlySet<string>): ProducerFl
|
|
|
180
184
|
return flags;
|
|
181
185
|
}
|
|
182
186
|
|
|
187
|
+
/** Additive check-row metadata is authoritative only as a complete valid tuple.
|
|
188
|
+
* Walk all roots (including PASS/SKIP), nested arrays, sets and requirements.lines.
|
|
189
|
+
* Legacy extraction and verdict IDs deliberately remain in checkFlags above.
|
|
190
|
+
*/
|
|
191
|
+
export function checkReadings(doc: unknown, names: ReadonlySet<string>): ProducerFlag[] {
|
|
192
|
+
const rows: ProducerFlag[] = [];
|
|
193
|
+
let labelled = false;
|
|
194
|
+
const visit = (value: unknown, path: string, root: string, status: string | null, row = false, depth = 0): void => {
|
|
195
|
+
if (depth > 32) return;
|
|
196
|
+
if (Array.isArray(value)) { value.forEach((v, i) => visit(v, `${path}[${i}]`, root, status, true, depth + 1)); return; }
|
|
197
|
+
const obj = record(value); if (!obj) return;
|
|
198
|
+
const hasMetadata = ['row_scope', 'row_kind', 'row_subjects'].some(k => Object.hasOwn(obj, k));
|
|
199
|
+
labelled ||= hasMetadata;
|
|
200
|
+
// Preserve failed/warning root gates even when only their child rows carry metadata.
|
|
201
|
+
const unlabelledProblemRoot = path === root && !hasMetadata && PROBLEM_STATUSES.has(String(obj.status));
|
|
202
|
+
if (hasMetadata || row || unlabelledProblemRoot) {
|
|
203
|
+
const scope = obj.row_scope, kind = obj.row_kind, subjects = obj.row_subjects;
|
|
204
|
+
const valid = ['part', 'pair', 'rig'].includes(String(scope)) && ['finding', 'evidence'].includes(String(kind)) &&
|
|
205
|
+
Array.isArray(subjects) && subjects.length === (scope === 'part' ? 1 : scope === 'pair' ? 2 : 0) &&
|
|
206
|
+
subjects.every(s => typeof s === 'string' && s.length > 0 && names.has(s)) && new Set(subjects).size === subjects.length;
|
|
207
|
+
const classification = !valid ? 'unclassified' : scope === 'rig' || kind === 'evidence' ? 'evidence' : scope === 'part' ? 'part' : 'pair';
|
|
208
|
+
// Invalid/missing metadata or any unheld subject has no implied attribution. Keep the whole row globally unclassified.
|
|
209
|
+
const items = valid ? (subjects as string[]).filter(s => names.has(s)) : [];
|
|
210
|
+
for (const item of items.length ? items : ['']) rows.push({id: `check:${path}`, item, source:'check', kind:'check', path, root, status, entry:obj, line:JSON.stringify(obj), classification});
|
|
211
|
+
}
|
|
212
|
+
for (const [key, child] of Object.entries(obj)) {
|
|
213
|
+
// requirements.lines is the producer's dictionary of individual rows, not an array.
|
|
214
|
+
if (key === 'lines' && /(?:^|\.)requirements$/.test(path) && record(child)) {
|
|
215
|
+
for (const [name, entry] of Object.entries(child as Record<string, unknown>)) visit(entry, `${path}.lines.${name}`, root, status, true, depth + 1);
|
|
216
|
+
} else visit(child, path ? `${path}.${key}` : key, root, status, false, depth + 1);
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
for (const [root, value] of Object.entries(record(doc) ?? {})) visit(value, root, root, typeof record(value)?.status === 'string' ? record(value)!.status as string : null);
|
|
220
|
+
return labelled ? rows : checkFlags(doc, names).map(f => ({...f, classification:'unclassified' as const, ...(f.kind === 'check' ? {line:JSON.stringify(f.entry)} : {})}));
|
|
221
|
+
}
|
|
222
|
+
|
|
183
223
|
async function readJson(abs: string, what: string): Promise<unknown> {
|
|
184
224
|
try { return JSON.parse(await readFile(abs, 'utf8')); } catch (e) { return refuse('PARTS_FLAGS_MALFORMED', `${what}: ${e instanceof Error ? e.message : String(e)}`); }
|
|
185
225
|
}
|
|
@@ -189,8 +229,8 @@ async function readJson(abs: string, what: string): Promise<unknown> {
|
|
|
189
229
|
* writes `mesh_report.json` beside `parts.json` in `rig/`, and `check` writes `check/check.json` beside `rig/`.
|
|
190
230
|
* `rigDir` is that `rig/` directory (parts mode) or null (atlas mode: explicit paths only, or `buildRoot`'s files).
|
|
191
231
|
*/
|
|
192
|
-
async function producerFlags(rigDir: string | null, buildRoot: string | null, names: ReadonlySet<string>, options: PartsViewOptions): Promise<{ flags: ProducerFlag[]; files: LocalFile[]; notes: string[] }> {
|
|
193
|
-
const flags: ProducerFlag[] = [], files: LocalFile[] = [], notes: string[] = [];
|
|
232
|
+
async function producerFlags(rigDir: string | null, buildRoot: string | null, names: ReadonlySet<string>, options: PartsViewOptions): Promise<{ flags: ProducerFlag[]; readings: ProducerFlag[]; files: LocalFile[]; notes: string[] }> {
|
|
233
|
+
const flags: ProducerFlag[] = [], readings: ProducerFlag[] = [], files: LocalFile[] = [], notes: string[] = [];
|
|
194
234
|
// 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.
|
|
195
235
|
const pick = async (explicit: string | undefined, candidates: ([string, string] | null)[], what: string): Promise<string | null> => {
|
|
196
236
|
if (explicit !== undefined) return resolve(explicit);
|
|
@@ -201,9 +241,9 @@ async function producerFlags(rigDir: string | null, buildRoot: string | null, na
|
|
|
201
241
|
if (mesh) { files.push(await hashFile(mesh)); flags.push(...meshReportFlags(await readJson(mesh, 'mesh_report.json'), names)); }
|
|
202
242
|
else notes.push('mesh_report.json');
|
|
203
243
|
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');
|
|
204
|
-
if (check) { files.push(await hashFile(check));
|
|
244
|
+
if (check) { files.push(await hashFile(check)); const doc = await readJson(check, 'check.json'); flags.push(...checkFlags(doc, names)); readings.push(...checkReadings(doc, names)); }
|
|
205
245
|
else notes.push('check.json');
|
|
206
|
-
return { flags, files, notes };
|
|
246
|
+
return { flags, readings, files, notes };
|
|
207
247
|
}
|
|
208
248
|
|
|
209
249
|
/** Exact attachment identity and UV-derived geometry; never reconstruct through weights. */
|
|
@@ -300,7 +340,7 @@ async function loadPartsMode(root: string, options: PartsViewOptions): Promise<P
|
|
|
300
340
|
assertOriginalPaintingSize(png!.width,png!.height,rigSize,doc.scale_rig_per_source);
|
|
301
341
|
const file={abs:abs!,bytes:bytes!.length,sha256:createHash('sha256').update(bytes!).digest('hex')};painting={...file,width:png!.width,height:png!.height};files.push(file);
|
|
302
342
|
}
|
|
303
|
-
const { flags, files: flagFiles, notes } = await producerFlags(root, null, seen, options);
|
|
343
|
+
const { flags, readings, files: flagFiles, notes } = await producerFlags(root, null, seen, options);
|
|
304
344
|
const protectedPaths = [join(root, 'rig.json'), join(root, 'config.json'), join(root, 'review.json'), join(root, 'report.json')];
|
|
305
345
|
if (basename(root) === 'rig') protectedPaths.push(...['parts.json', 'config.json', 'review.json', 'report.json'].map(name => join(dirname(root), name)));
|
|
306
346
|
if (options.rig !== undefined) protectedPaths.push(resolve(options.rig));
|
|
@@ -319,7 +359,7 @@ async function loadPartsMode(root: string, options: PartsViewOptions): Promise<P
|
|
|
319
359
|
files.push({ abs: rigPath, bytes: rigBytes.length, sha256: createHash('sha256').update(rigBytes).digest('hex') });
|
|
320
360
|
if (report) files.push(report);
|
|
321
361
|
}
|
|
322
|
-
return { ...(painting?{painting}:{}),mode: 'parts', root, title: basename(root) === 'rig' ? basename(dirname(root)) : basename(root), rigSize, items, pages: [], flags, files, flagFiles, flagNotes: notes, protectedPaths, verdictPath, imagePaths, pagePaths: [] };
|
|
362
|
+
return { ...(painting?{painting}:{}),mode: 'parts', root, title: basename(root) === 'rig' ? basename(dirname(root)) : basename(root), rigSize, items, pages: [], flags, readings, files, flagFiles, flagNotes: notes, protectedPaths, verdictPath, imagePaths, pagePaths: [] };
|
|
323
363
|
}
|
|
324
364
|
|
|
325
365
|
async function loadAtlasMode(input: string, options: PartsViewOptions): Promise<PartsViewPackage> {
|
|
@@ -356,12 +396,12 @@ export async function loadPartsAtlas(p: ReviewPackage, options: PartsViewOptions
|
|
|
356
396
|
}
|
|
357
397
|
// A build root opens as its check package (#149); its own rig/ and check/ hold the flags.
|
|
358
398
|
const buildRoot = p.buildRoot ?? null;
|
|
359
|
-
const { flags, files: flagFiles, notes } = await producerFlags(null, buildRoot, names, options);
|
|
399
|
+
const { flags, readings, files: flagFiles, notes } = await producerFlags(null, buildRoot, names, options);
|
|
360
400
|
const protectedPaths = [...p.files].map(path => resolve(p.root, path));
|
|
361
401
|
protectedPaths.push(...['rig.json', 'config.json', 'report.json', 'review.json'].map(name => join(p.root, name)));
|
|
362
402
|
if (p.handoff) protectedPaths.push(...p.handoff.record.files.map(file => resolve(p.root, file.path)));
|
|
363
403
|
if (buildRoot) protectedPaths.push(...['parts.json', 'config.json', 'rig/rig.json', 'rig/parts.json'].map(name => join(buildRoot, name)));
|
|
364
|
-
return { mode: 'atlas', root: p.root, title: p.manifest.title, rigSize: null, items, pages, flags, files, flagFiles, flagNotes: notes, protectedPaths, verdictPath: options.verdict ? resolve(options.verdict) : join(dirname(modelAbs), PARTS_VERDICT_FILE), imagePaths: [], pagePaths };
|
|
404
|
+
return { mode: 'atlas', root: p.root, title: p.manifest.title, rigSize: null, items, pages, flags, readings, files, flagFiles, flagNotes: notes, protectedPaths, verdictPath: options.verdict ? resolve(options.verdict) : join(dirname(modelAbs), PARTS_VERDICT_FILE), imagePaths: [], pagePaths };
|
|
365
405
|
}
|
|
366
406
|
|
|
367
407
|
/**
|
|
@@ -517,7 +557,7 @@ export function partsViewJson(pkg: PartsViewPackage, saved: { verdict: PartsVerd
|
|
|
517
557
|
schema: 'rig-review-parts-view/1', mode: pkg.mode, title: pkg.title, rigSize: pkg.rigSize,
|
|
518
558
|
painting:pkg.painting?{sha256:pkg.painting.sha256,width:pkg.painting.width,height:pkg.painting.height}:null,
|
|
519
559
|
sourceHash:verdictSource(pkg).sha256,
|
|
520
|
-
items:pkg.items.map(item=>({...item,...(pkg.mode==='parts'?{imageHash:pkg.files.find(f=>f.abs===pkg.imagePaths[item.index])?.sha256}:{})})), pages: pkg.pages, flags: pkg.flags,
|
|
560
|
+
items:pkg.items.map(item=>({...item,...(pkg.mode==='parts'?{imageHash:pkg.files.find(f=>f.abs===pkg.imagePaths[item.index])?.sha256}:{})})), pages: pkg.pages, flags: pkg.flags, readings: pkg.readings ?? [],
|
|
521
561
|
flagSources: pkg.flagFiles.map(f => basename(f.abs)), flagMissing: pkg.flagNotes,
|
|
522
562
|
verdictFile: basename(pkg.verdictPath), verdict: saved.verdict, verdictStale: saved.stale,
|
|
523
563
|
};
|
package/web/catalog-en.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export const enCatalog: Readonly<Record<string, string>> = {
|
|
2
|
+
"Approve all": "Approve all",
|
|
3
|
+
"PARTS_APPROVE_ALL_FLAGGED: resolve flagged part and mesh outcomes before approving all.": "PARTS_APPROVE_ALL_FLAGGED: resolve flagged part and mesh outcomes before approving all.",
|
|
2
4
|
"Atlas source build": "Atlas source build",
|
|
3
5
|
"1 Parts + mesh": "1 Parts + mesh",
|
|
4
6
|
"2 Interview": "2 Interview",
|
|
@@ -3138,4 +3140,18 @@ export const enCatalog: Readonly<Record<string, string>> = {
|
|
|
3138
3140
|
"PARTS_COMPARISON_UNAVAILABLE: original painting required": "PARTS_COMPARISON_UNAVAILABLE: original painting required",
|
|
3139
3141
|
"PARTS_COMPARISON_INVALID: part/overlay mode and opacity 0..1 required": "PARTS_COMPARISON_INVALID: part/overlay mode and opacity 0..1 required",
|
|
3140
3142
|
"PARTS_PAINT_FAILED: view could not be rendered; select the part to retry": "PARTS_PAINT_FAILED: view could not be rendered; select the part to retry",
|
|
3143
|
+
"Assembled": "Assembled",
|
|
3144
|
+
"Visible": "Visible",
|
|
3145
|
+
"Show {name} in assembly": "Show {name} in assembly",
|
|
3146
|
+
"Assembly unavailable: atlas regions carry no rig placement.": "Assembly unavailable: atlas regions carry no rig placement.",
|
|
3147
|
+
"Assembly unavailable: rig_size is not declared.": "Assembly unavailable: rig_size is not declared.",
|
|
3148
|
+
"Assembled package \u00b7 {count} visible parts. Selection and verdict remain per part.": "Assembled package · {count} visible parts. Selection and verdict remain per part.",
|
|
3149
|
+
"PARTS_COMMENT_UNAVAILABLE: select the individual part view to comment": "PARTS_COMMENT_UNAVAILABLE: select the individual part view to comment",
|
|
3150
|
+
"Mesh flags": "Mesh flags",
|
|
3151
|
+
"Part findings": "Part findings",
|
|
3152
|
+
"Pair readings": "Pair readings",
|
|
3153
|
+
"Check evidence": "Check evidence",
|
|
3154
|
+
"Unclassified check rows": "Unclassified check rows",
|
|
3155
|
+
"Badges count only mesh flags and explicit part findings. Pair readings and check evidence are not counted.": "Badges count only mesh flags and explicit part findings. Pair readings and check evidence are not counted.",
|
|
3156
|
+
"Missing or invalid row metadata: source-root rows remain unclassified and are not counted.": "Missing or invalid row metadata: source-root rows remain unclassified and are not counted.",
|
|
3141
3157
|
};
|
package/web/catalog-ko.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export const koCatalog: Readonly<Record<string, string>> = {
|
|
2
|
+
"Approve all": "모두 승인",
|
|
3
|
+
"PARTS_APPROVE_ALL_FLAGGED: resolve flagged part and mesh outcomes before approving all.": "PARTS_APPROVE_ALL_FLAGGED: 모두 승인하기 전에 파츠와 메시의 문제 표시를 해결해 주세요.",
|
|
2
4
|
"Atlas source build": "아틀라스 소스 빌드",
|
|
3
5
|
"1 Parts + mesh": "1 파츠 + 메시",
|
|
4
6
|
"2 Interview": "2 인터뷰",
|
|
@@ -1236,7 +1238,7 @@ export const koCatalog: Readonly<Record<string, string>> = {
|
|
|
1236
1238
|
"This part is not a contour mesh, so chest regions and bust motion cannot be rebuilt on it. The builder chooses each part's mesh kind in the config. Nothing is wrong with this rig.": "이 파츠는 윤곽(contour) 메시가 아니어서 흉부 영역과 가슴 움직임을 다시 빌드할 수 없습니다. 파츠마다 메시 종류는 빌더가 설정에서 정합니다. 이 리그에는 문제가 없습니다.",
|
|
1237
1239
|
"REBUILD_PART_AMBIGUOUS: the config states {0} contour meshes and the designated bones name none of them alone": "REBUILD_PART_AMBIGUOUS: 설정에 윤곽 메시 {0}개가 선언되어 있으며 지정된 본들이 어느 하나를 단독으로 가리키지 않습니다",
|
|
1238
1240
|
"REBUILD_PART_AMBIGUOUS: the config states {0} contour meshes and the landmark bones name none of them alone": "REBUILD_PART_AMBIGUOUS: 설정에 윤곽 메시 {0}개가 선언되어 있으며 랜드마크 본들이 어느 하나를 단독으로 가리키지 않습니다",
|
|
1239
|
-
"REBUILD_REGION_DUPLICATE: {0} (two regions of the chest part carry this name)": "REBUILD_REGION_DUPLICATE: {0} (가슴
|
|
1241
|
+
"REBUILD_REGION_DUPLICATE: {0} (two regions of the chest part carry this name)": "REBUILD_REGION_DUPLICATE: {0} (가슴 파츠의 두 영역이 이 이름을 사용합니다)",
|
|
1240
1242
|
"REBUILD_REGION_INCOMPLETE: no region has a centre": "REBUILD_REGION_INCOMPLETE: 중심이 지정된 영역이 없습니다",
|
|
1241
1243
|
"REBUILD_REGION_INCOMPLETE: {0} bone": "REBUILD_REGION_INCOMPLETE: {0} 본",
|
|
1242
1244
|
"REBUILD_REGION_INCOMPLETE: {0} name": "REBUILD_REGION_INCOMPLETE: {0} 이름",
|
|
@@ -3115,7 +3117,7 @@ export const koCatalog: Readonly<Record<string, string>> = {
|
|
|
3115
3117
|
"Mesh note": "메시 메모",
|
|
3116
3118
|
"1:1": "1:1",
|
|
3117
3119
|
"Export issue": "이슈 내보내기",
|
|
3118
|
-
"PARTS_COMMENT_UNAVAILABLE: original part image required": "PARTS_COMMENT_UNAVAILABLE: 원본
|
|
3120
|
+
"PARTS_COMMENT_UNAVAILABLE: original part image required": "PARTS_COMMENT_UNAVAILABLE: 원본 파츠 이미지가 필요합니다",
|
|
3119
3121
|
"PARTS_REFERENCE_UNAVAILABLE: supply --painting to compare the original painting": "PARTS_REFERENCE_UNAVAILABLE: 원화 비교에는 --painting 입력이 필요해요",
|
|
3120
3122
|
"PARTS_COMMENT_STALE_SOURCE: reopen the bound source": "PARTS_COMMENT_STALE_SOURCE: 연결된 원본을 다시 열어 주세요",
|
|
3121
3123
|
"PARTS_COMMENT_STALE_SOURCE: original PNG changed": "PARTS_COMMENT_STALE_SOURCE: 원본 PNG가 변경됐어요",
|
|
@@ -3125,7 +3127,7 @@ export const koCatalog: Readonly<Record<string, string>> = {
|
|
|
3125
3127
|
"PARTS_COMMENT_CROP_LIMIT: native crop exceeds 16 million pixels": "PARTS_COMMENT_CROP_LIMIT: 네이티브 크롭이 1,600만 픽셀을 넘어요",
|
|
3126
3128
|
"Export JSON": "JSON 내보내기",
|
|
3127
3129
|
"PARTS_CAMERA_RANGE: native zoom outside supported range": "PARTS_CAMERA_RANGE: 네이티브 배율이 지원 범위 밖이에요",
|
|
3128
|
-
"Comments on this part: {count}": "이
|
|
3130
|
+
"Comments on this part: {count}": "이 파츠의 코멘트: {count}",
|
|
3129
3131
|
"COMMENT_CROP_STATE_UNAVAILABLE: stored crop cannot be read": "COMMENT_CROP_STATE_UNAVAILABLE: 저장된 크롭을 읽을 수 없어요",
|
|
3130
3132
|
"PARTS_COMMENT_NATIVE_CROP_TAMPERED: native crop differs from bound original": "PARTS_COMMENT_NATIVE_CROP_TAMPERED: 네이티브 크롭이 연결된 원본과 달라요",
|
|
3131
3133
|
"PARTS_VERDICT_READ: saved verdict cannot be read": "PARTS_VERDICT_READ: 저장된 판정을 읽을 수 없어요",
|
|
@@ -3136,6 +3138,20 @@ export const koCatalog: Readonly<Record<string, string>> = {
|
|
|
3136
3138
|
"Overlay": "오버레이",
|
|
3137
3139
|
"Part opacity": "파츠 불투명도",
|
|
3138
3140
|
"PARTS_COMPARISON_UNAVAILABLE: original painting required": "PARTS_COMPARISON_UNAVAILABLE: 원본 원화가 필요해요",
|
|
3139
|
-
"PARTS_COMPARISON_INVALID: part/overlay mode and opacity 0..1 required": "PARTS_COMPARISON_INVALID:
|
|
3141
|
+
"PARTS_COMPARISON_INVALID: part/overlay mode and opacity 0..1 required": "PARTS_COMPARISON_INVALID: 파츠/오버레이 모드와 0..1 불투명도가 필요합니다",
|
|
3140
3142
|
"PARTS_PAINT_FAILED: view could not be rendered; select the part to retry": "PARTS_PAINT_FAILED: 화면을 그리지 못했어요. 파츠를 선택해 다시 시도해 주세요",
|
|
3143
|
+
"Assembled": "조립 보기",
|
|
3144
|
+
"Visible": "표시",
|
|
3145
|
+
"Show {name} in assembly": "조립 보기에서 {name} 표시",
|
|
3146
|
+
"Assembly unavailable: atlas regions carry no rig placement.": "조립 불가: 아틀라스 영역에는 리그 배치 정보가 없어요.",
|
|
3147
|
+
"Assembly unavailable: rig_size is not declared.": "조립 불가: rig_size가 선언되지 않았어요.",
|
|
3148
|
+
"Assembled package \u00b7 {count} visible parts. Selection and verdict remain per part.": "조립 패키지 · 파츠 {count}개 표시. 선택과 판정은 파츠별로 유지돼요.",
|
|
3149
|
+
"PARTS_COMMENT_UNAVAILABLE: select the individual part view to comment": "PARTS_COMMENT_UNAVAILABLE: 댓글을 쓰려면 개별 파츠 보기로 전환해 주세요",
|
|
3150
|
+
"Mesh flags": "메시 플래그",
|
|
3151
|
+
"Part findings": "파츠 발견 사항",
|
|
3152
|
+
"Pair readings": "쌍 측정값",
|
|
3153
|
+
"Check evidence": "검사 근거",
|
|
3154
|
+
"Unclassified check rows": "미분류 검사 행",
|
|
3155
|
+
"Badges count only mesh flags and explicit part findings. Pair readings and check evidence are not counted.": "배지는 메시 플래그와 명시된 파츠 발견 사항만 세요. 쌍 측정값과 검사 근거는 세지 않아요.",
|
|
3156
|
+
"Missing or invalid row metadata: source-root rows remain unclassified and are not counted.": "행 메타데이터가 없거나 잘못됐어요. 소스·루트별 행은 미분류로 유지하고 세지 않아요.",
|
|
3141
3157
|
};
|
package/web/parts-flags.ts
CHANGED
|
@@ -7,7 +7,7 @@ type Params = Readonly<Record<string, string | number>>;
|
|
|
7
7
|
export type Translate = (key: string, params?: Params) => string;
|
|
8
8
|
export type LabelledFlag =
|
|
9
9
|
| { kind: 'faint'; item: string; art: number; maxAlpha: number; box: readonly [number, number, number, number] }
|
|
10
|
-
| { kind: 'check'; item: string; path: string; root: string; status: string | null; entry: Readonly<Record<string, unknown
|
|
10
|
+
| { kind: 'check'; item: string; path: string; root: string; status: string | null; entry: Readonly<Record<string, unknown>>; classification?: 'part' | 'pair' | 'evidence' | 'unclassified' };
|
|
11
11
|
|
|
12
12
|
const num = (v: unknown): v is number => typeof v === 'number' && Number.isFinite(v);
|
|
13
13
|
const str = (v: unknown): v is string => typeof v === 'string';
|
|
@@ -38,3 +38,11 @@ function checkReadings(flag: Extract<LabelledFlag, { kind: 'check' }>, t: Transl
|
|
|
38
38
|
}
|
|
39
39
|
return t('Check line {path}', { path: flag.path });
|
|
40
40
|
}
|
|
41
|
+
|
|
42
|
+
/** Presentation only: verdict/2 keeps its original producer IDs and hash binding. */
|
|
43
|
+
export function readingGroup(flag: LabelledFlag): 'mesh' | 'part' | 'pair' | 'evidence' | 'unclassified' {
|
|
44
|
+
return flag.kind === 'faint' ? 'mesh' : flag.classification ?? 'unclassified';
|
|
45
|
+
}
|
|
46
|
+
export function countedFlag(flag: LabelledFlag): boolean {
|
|
47
|
+
return flag.kind === 'faint' || readingGroup(flag) === 'part';
|
|
48
|
+
}
|
package/web/parts-render.ts
CHANGED
|
@@ -109,3 +109,25 @@ export function paintMesh(ctx: Ctx, source: Source, w: number, h: number, mesh:
|
|
|
109
109
|
ctx.stroke();
|
|
110
110
|
for (let i = 0; i < v.length; i += 2) { ctx.beginPath(); ctx.arc(v[i]!, v[i + 1]!, .8, 0, Math.PI * 2); ctx.fill(); }
|
|
111
111
|
}
|
|
112
|
+
|
|
113
|
+
/** Package order is back to front. Placements remain continuous rig pixels. */
|
|
114
|
+
export function paintAssembly(ctx:Ctx,w:number,h:number,layers:readonly {box:Box;image:Source}[],options:{bg:string;alpha:boolean}):void {
|
|
115
|
+
ctx.imageSmoothingEnabled=false;
|
|
116
|
+
if(!options.alpha)paintBackground(ctx,w,h,options.bg);else ctx.clearRect(0,0,w,h);
|
|
117
|
+
for(const {box,image} of layers)ctx.drawImage(image,box.x,box.y);
|
|
118
|
+
if(options.alpha){const data=ctx.getImageData(0,0,w,h),px=data.data;for(let i=0;i<px.length;i+=4){px[i]=px[i+1]=px[i+2]=px[i+3]!;px[i+3]=255;}ctx.putImageData(data,0,0);}
|
|
119
|
+
}
|
|
120
|
+
/** Native source alpha, independent of the sentinel, overlay opacity and selection decoration. */
|
|
121
|
+
export function pickAssembly<T extends Box>(layers:readonly {box:T;alpha:Uint8ClampedArray}[],x:number,y:number,hidden:ReadonlySet<string>=new Set()):T|null {
|
|
122
|
+
for(let i=layers.length-1;i>=0;i--){const {box,alpha}=layers[i]!;if(hidden.has(box.name))continue;const px=Math.floor(x-box.x),py=Math.floor(y-box.y);if(px>=0&&py>=0&&px<box.w&&py<box.h&&alpha[py*box.w+px]!>0)return box;}
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
/** Exposed native-alpha cell edges; decoration is separate from comparison pixels. */
|
|
126
|
+
export function paintAssemblyOutline(ctx:Ctx,box:Box,alpha:Uint8ClampedArray):void {
|
|
127
|
+
const at=(x:number,y:number)=>x>=0&&y>=0&&x<box.w&&y<box.h&&alpha[y*box.w+x]!>0;
|
|
128
|
+
ctx.strokeStyle='#00bfff';ctx.lineWidth=1;ctx.beginPath();
|
|
129
|
+
for(let y=0;y<box.h;y++)for(let x=0;x<box.w;x++)if(at(x,y)){
|
|
130
|
+
const edge=(ax:number,ay:number,bx:number,by:number)=>{ctx.moveTo(box.x+ax,box.y+ay);ctx.lineTo(box.x+bx,box.y+by);};
|
|
131
|
+
if(!at(x,y-1))edge(x,y,x+1,y);if(!at(x,y+1))edge(x,y+1,x+1,y+1);if(!at(x-1,y))edge(x,y,x,y+1);if(!at(x+1,y))edge(x+1,y,x+1,y+1);
|
|
132
|
+
}ctx.stroke();
|
|
133
|
+
}
|
package/web/parts.css
CHANGED
|
@@ -14,13 +14,15 @@ body{margin:0;background:var(--bg);color:var(--text);font:13px/1.4 system-ui,-ap
|
|
|
14
14
|
.pv-side{border-left:1px solid var(--line)}
|
|
15
15
|
h2{font-size:11px;letter-spacing:.06em;color:var(--muted);margin:4px 0 8px}
|
|
16
16
|
#pv-items{list-style:none;margin:0;padding:0}
|
|
17
|
-
#pv-items li
|
|
17
|
+
#pv-items li{display:flex;align-items:center;flex-wrap:nowrap;gap:4px}
|
|
18
|
+
#pv-items li>label{display:flex;flex:none;align-items:center}
|
|
19
|
+
#pv-items li button{min-width:0;flex:1;white-space:nowrap;width:100%;display:grid;grid-template-columns:minmax(0,1fr) auto auto;gap:6px;align-items:center;text-align:left;border:0;background:none;color:inherit;padding:4px 6px;border-radius:5px;cursor:pointer;font:inherit}
|
|
18
20
|
#pv-items li button[aria-current="true"]{background:color-mix(in srgb,var(--accent) 18%,transparent)}
|
|
19
21
|
.pv-name{grid-column:1;grid-row:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
20
|
-
.pv-badge{grid-column:
|
|
22
|
+
.pv-badge{grid-column:3;grid-row:1;font-size:10px;padding:0 5px;border-radius:8px;border:1px solid var(--line);color:var(--muted)}
|
|
21
23
|
.pv-badge[data-outcome="clean"]{color:var(--clean);border-color:var(--clean)}
|
|
22
24
|
.pv-badge[data-outcome="flagged"]{color:var(--flag);border-color:var(--flag)}
|
|
23
|
-
.pv-count{grid-column:
|
|
25
|
+
.pv-count{grid-column:2;grid-row:1;font-size:10px;color:var(--muted);white-space:nowrap}
|
|
24
26
|
.pv-stage{display:flex;flex-direction:column;min-width:0;min-height:0}
|
|
25
27
|
.pv-toolbar{display:flex;flex-wrap:wrap;gap:12px;align-items:center;padding:8px 12px;border-bottom:1px solid var(--line)}
|
|
26
28
|
.pv-field{display:flex;align-items:center;gap:5px}
|
|
@@ -90,3 +92,5 @@ main{position:relative}.toolbar{anchor-name:--stage-comment-bar}#stage-comment{w
|
|
|
90
92
|
#pv-reference{image-rendering:pixelated;image-rendering:crisp-edges;display:block}
|
|
91
93
|
|
|
92
94
|
.pv-comparison{display:flex;flex-wrap:wrap;align-items:center;gap:12px}#pv-opacity{width:100px}
|
|
95
|
+
|
|
96
|
+
.pv-overlay canvas{position:absolute;left:0;top:0;pointer-events:none}
|
package/web/parts.html
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
<aside class="pv-list" aria-label="Parts"><h2 id="pv-list-title">PARTS</h2><ul id="pv-items" data-pv-items></ul></aside>
|
|
9
9
|
<main class="pv-stage">
|
|
10
10
|
<div class="pv-toolbar" role="toolbar" aria-label="View">
|
|
11
|
+
<button type="button" id="pv-assemble" aria-pressed="false">Assembled</button>
|
|
11
12
|
<label class="pv-field">Background <select id="pv-bg" data-pv-bg><option value="green">Green</option><option value="magenta">Magenta</option><option value="black">Black</option><option value="white">White</option><option value="checker">Checker</option></select></label>
|
|
12
13
|
<span class="pv-group" role="group" aria-label="Zoom"><button type="button" id="zoom-out">−</button><span id="zoom-value">1:1</span><button type="button" id="zoom-in">+</button><button type="button" id="fit">Fit</button><button type="button" id="native-one" aria-pressed="true">1:1</button></span>
|
|
13
14
|
<label class="pv-field"><input id="camera-sync" type="checkbox">Sync cameras</label>
|
|
@@ -34,6 +35,7 @@
|
|
|
34
35
|
<p id="pv-comment-count" role="status"></p>
|
|
35
36
|
<label class="pv-label" for="pv-note">Note</label><textarea id="pv-note" rows="4" maxlength="10000"></textarea>
|
|
36
37
|
<label class="pv-label" for="pv-overall">Sign-off</label><select id="pv-overall"><option value="pending">Pending</option><option value="approved">Approved</option><option value="changes-requested">Changes requested</option></select>
|
|
38
|
+
<button id="pv-approve-all" type="button">Approve all</button>
|
|
37
39
|
<button id="pv-save" type="button" class="pv-primary">Save sign-off</button>
|
|
38
40
|
<span><button id="pv-export-json" type="button">Export JSON</button><button id="pv-export-issue" type="button">Export issue</button></span>
|
|
39
41
|
<p id="pv-save-status" class="pv-subtle" role="status"></p>
|
package/web/parts.ts
CHANGED
|
@@ -17,8 +17,8 @@ import {bindStageNav} from './stage-nav.ts';
|
|
|
17
17
|
import { bindDomI18n, onLanguageChange, setLinkLanguage, setLanguagePreference, t } from './i18n.ts';
|
|
18
18
|
import { pageInstanceAccess } from './instance-access.ts';
|
|
19
19
|
import { connectLiveWindow } from './live-connection.ts';
|
|
20
|
-
import { flagLabel } from './parts-flags.ts';
|
|
21
|
-
import { frontParts, paintAlphaOnly, paintBackground, paintPart, paintMesh, paintOverlay, paintPaintingCrop, paintFootprints } from './parts-render.ts';
|
|
20
|
+
import { flagLabel, readingGroup, countedFlag } from './parts-flags.ts';
|
|
21
|
+
import { paintAssembly, pickAssembly, paintAssemblyOutline, frontParts, paintAlphaOnly, paintBackground, paintPart, paintMesh, paintOverlay, paintPaintingCrop, paintFootprints } from './parts-render.ts';
|
|
22
22
|
|
|
23
23
|
type Outcome = 'pending' | 'clean' | 'flagged';
|
|
24
24
|
interface Mesh { vertices: number[]; triangles: number[]; figures: Record<string, unknown> }
|
|
@@ -27,9 +27,9 @@ interface Item { mesh?: Mesh; name: string; index: number; x: number; y: number;
|
|
|
27
27
|
interface Page { name: string; width: number; height: number; index: number }
|
|
28
28
|
type Flag =
|
|
29
29
|
| { id: string; item: string; source: 'mesh_report'; kind: 'faint'; art: number; maxAlpha: number; box: [number, number, number, number] }
|
|
30
|
-
| { id: string; item: string; source: 'check'; kind: 'check'; path: string; line: string; root: string; status: string | null; entry: Record<string, unknown
|
|
30
|
+
| { id: string; item: string; source: 'check'; kind: 'check'; path: string; line: string; root: string; status: string | null; entry: Record<string, unknown>; classification?: 'part' | 'pair' | 'evidence' | 'unclassified' };
|
|
31
31
|
interface ViewData {
|
|
32
|
-
painting:{sha256:string;width:number;height:number}|null;sourceHash:string;mode: 'parts' | 'atlas'; title: string; rigSize: [number, number] | null; items: Item[]; pages: Page[]; flags: Flag[];
|
|
32
|
+
painting:{sha256:string;width:number;height:number}|null;sourceHash:string;mode: 'parts' | 'atlas'; title: string; rigSize: [number, number] | null; items: Item[]; pages: Page[]; flags: Flag[]; readings?: Flag[];
|
|
33
33
|
flagSources: string[]; flagMissing: string[]; verdictFile: string;
|
|
34
34
|
verdict: { comments?:PartsComment[];status: string; parts: Record<string, Entry> } | null; verdictStale: 'files' | 'flags' | null;
|
|
35
35
|
}
|
|
@@ -43,7 +43,7 @@ const stageEmbedded=new URL(location.href).searchParams.get('stageEmbed')==='1';
|
|
|
43
43
|
const stageSide=new URL(location.href).searchParams.get('side');
|
|
44
44
|
const partsApi=stageEmbedded?(stageSide==='a'||stageSide==='b'?`/api/compare/${stageSide}/stage-parts`:'/api/stage-parts'):'/api/parts';
|
|
45
45
|
|
|
46
|
-
const state = { data: null as ViewData | null, selected: 0, zoom: 1, bg: 'green', alpha: false, footprints: false, comparison:defaultPartsComparison(), view: 'item' as 'item' | 'page', page: 0, meshShown: new Set<string>(), verdict: new Map<string, Entry>() };
|
|
46
|
+
const state = { data: null as ViewData | null, selected: 0, zoom: 1, bg: 'green', alpha: false, footprints: false, comparison:defaultPartsComparison(), hidden: new Set<string>(), view: 'item' as 'item' | 'page' | 'assembled', page: 0, meshShown: new Set<string>(), verdict: new Map<string, Entry>() };
|
|
47
47
|
const comments:PartsComment[]=[];let commentUi:ReturnType<typeof bindStageComments>|null=null;let viewport:ReturnType<typeof createPartsViewport>|null=null;let painting=false;
|
|
48
48
|
const images = new Map<string, HTMLImageElement>();
|
|
49
49
|
|
|
@@ -91,11 +91,34 @@ async function paint():Promise<void>{
|
|
|
91
91
|
$('pv-caption').textContent=t(paintFailure);$('pv-save-status').textContent=t(paintFailure);commentUi?.refresh();
|
|
92
92
|
}finally{if(token===paintToken)painting=false;}
|
|
93
93
|
}
|
|
94
|
+
const assemblyAlpha=new Map<string,Uint8ClampedArray>();
|
|
95
|
+
function sourceAlpha(item:Item,img:HTMLImageElement):Uint8ClampedArray {
|
|
96
|
+
const cached=assemblyAlpha.get(item.name);if(cached)return cached;
|
|
97
|
+
const c=document.createElement('canvas');c.width=item.w;c.height=item.h;const ctx=c.getContext('2d')!;ctx.drawImage(img,0,0);
|
|
98
|
+
const rgba=ctx.getImageData(0,0,item.w,item.h).data,alpha=new Uint8ClampedArray(item.w*item.h);for(let i=0;i<alpha.length;i++)alpha[i]=rgba[i*4+3]!;assemblyAlpha.set(item.name,alpha);return alpha;
|
|
99
|
+
}
|
|
100
|
+
|
|
94
101
|
async function paintRaster(token:number): Promise<void> {
|
|
95
102
|
const data = state.data;
|
|
96
103
|
if (!data || !data.items.length) return;
|
|
97
104
|
const canvas = $<HTMLCanvasElement>('pv-canvas'), overlay = $('pv-overlay'), caption = $('pv-caption');
|
|
98
105
|
const item = data.items[state.selected]!;
|
|
106
|
+
if(state.view==='assembled'&&data.mode==='parts'&&data.rigSize){
|
|
107
|
+
const [w,h]=data.rigSize,shown=data.items.filter(i=>!state.hidden.has(i.name));
|
|
108
|
+
const layers=await Promise.all(shown.map(async box=>({box,image:await itemImage(box)})));
|
|
109
|
+
const original=state.comparison.mode==='overlay'&&data.painting?await load('/api/parts/painting'):null;
|
|
110
|
+
if(token!==paintToken)return;
|
|
111
|
+
const ctx=setCanvas(canvas,w,h);
|
|
112
|
+
if(original){
|
|
113
|
+
paintPaintingCrop(ctx,original,paintingRectangle({x:0,y:0,w,h},data.rigSize,data.painting!),w,h,state.bg);
|
|
114
|
+
const assembled=document.createElement('canvas');assembled.width=w;assembled.height=h;const a=assembled.getContext('2d')!;a.imageSmoothingEnabled=false;for(const l of layers)a.drawImage(l.image,l.box.x,l.box.y);ctx.globalAlpha=state.comparison.opacity;ctx.drawImage(assembled,0,0);ctx.globalAlpha=1;
|
|
115
|
+
}else paintAssembly(ctx,w,h,layers,{bg:state.bg,alpha:state.alpha});
|
|
116
|
+
overlay.replaceChildren();
|
|
117
|
+
const selected=layers.find(l=>l.box.name===item.name);
|
|
118
|
+
if(selected){const outline=document.createElement('canvas');outline.width=w;outline.height=h;outline.dataset.assemblyOutline=item.name;paintAssemblyOutline(outline.getContext('2d')!,item,sourceAlpha(item,selected.image));overlay.append(outline);}
|
|
119
|
+
caption.textContent=t('Assembled package · {count} visible parts. Selection and verdict remain per part.',{count:shown.length});
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
99
122
|
if (data.mode === 'atlas' && state.view === 'page') {
|
|
100
123
|
const page = data.pages[state.page]!, img = await pageImage(page.name);
|
|
101
124
|
if (token !== paintToken) return;
|
|
@@ -150,20 +173,21 @@ async function paintRaster(token:number): Promise<void> {
|
|
|
150
173
|
+ (state.footprints ? ' ' + (front.length === 1 ? t('Tinted: the footprint of the part drawn in front ({names}).', { names: front[0]!.name }) : front.length ? t('Tinted: the footprints of {count} parts drawn in front ({names}).', { count: front.length, names: front.map(o => o.name).join(', ') }) : t('No part is drawn in front of it.')) : '');
|
|
151
174
|
}
|
|
152
175
|
|
|
153
|
-
async function paintReference(token:number):Promise<void>{const data=state.data,item=data?.items[state.selected];if(!data?.painting||!item)return;const img=await load('/api/parts/painting');if(token!==paintToken||data!==state.data||item!==state.data?.items[state.selected])return;const canvas=$<HTMLCanvasElement>('pv-reference');canvas.width=
|
|
176
|
+
async function paintReference(token:number):Promise<void>{const data=state.data,item=data?.items[state.selected];if(!data?.painting||!item)return;const img=await load('/api/parts/painting');if(token!==paintToken||data!==state.data||item!==state.data?.items[state.selected])return;const box=state.view==='assembled'?{x:0,y:0,w:data.rigSize![0],h:data.rigSize![1]}:item;const canvas=$<HTMLCanvasElement>('pv-reference');canvas.width=box.w;canvas.height=box.h;const ctx=canvas.getContext('2d')!;paintPaintingCrop(ctx,img,paintingRectangle(box,data.rigSize!,data.painting),box.w,box.h,state.bg);}
|
|
154
177
|
|
|
155
178
|
function renderComparison():void {
|
|
156
179
|
const active=state.data?.mode==='parts'&&!!state.data.painting,overlay=active&&state.comparison.mode==='overlay';
|
|
157
180
|
$('pv-comparison').hidden=!active;for(const b of document.querySelectorAll<HTMLElement>('[data-pv-comparison]'))b.setAttribute('aria-pressed',String(b.dataset.pvComparison===state.comparison.mode));
|
|
158
181
|
$('pv-opacity-control').hidden=!overlay;$<HTMLInputElement>('pv-opacity').value=String(state.comparison.opacity);$('pv-opacity-value').textContent=(state.comparison.opacity*100).toFixed(1)+'%';
|
|
159
182
|
$<HTMLInputElement>('pv-alpha').disabled=overlay;
|
|
160
|
-
const mesh=document.querySelector<HTMLInputElement>('#pv-mesh-control input');if(mesh)mesh.disabled=overlay;
|
|
183
|
+
const mesh=document.querySelector<HTMLInputElement>('#pv-mesh-control input');if(mesh)mesh.disabled=overlay||state.view==='assembled';
|
|
184
|
+
$<HTMLInputElement>('pv-footprints').disabled=state.data?.mode==='atlas'||state.view==='assembled';
|
|
161
185
|
}
|
|
162
186
|
|
|
163
187
|
function renderFlags(): void {
|
|
164
188
|
const data = state.data!, item = data.items[state.selected];
|
|
165
189
|
const list = $('pv-flags');
|
|
166
|
-
const flags = item ? data.flags.filter(f => f.item === item.name) : [];
|
|
190
|
+
const flags = item ? [...data.flags.filter(f => f.kind === 'faint' && f.item === item.name), ...(data.readings ?? data.flags.filter(f => f.kind === 'check')).filter(f => f.item === item.name || f.item === '')] : [];
|
|
167
191
|
const row = (f: Flag): HTMLLIElement => {
|
|
168
192
|
const li = document.createElement('li');
|
|
169
193
|
li.dataset.flagId = f.id; li.dataset.flagSource = f.source;
|
|
@@ -185,8 +209,16 @@ function renderFlags(): void {
|
|
|
185
209
|
sourceItem.dataset.pvSource = source;
|
|
186
210
|
heading.textContent = source === 'mesh_report' ? 'mesh_report.json' : 'check.json';
|
|
187
211
|
sourceItem.append(heading);
|
|
212
|
+
const categories = source === 'mesh_report' ? ['mesh'] as const : ['part', 'pair', 'evidence', 'unclassified'] as const;
|
|
213
|
+
for (const category of categories) {
|
|
214
|
+
const selected = fromSource.filter(f => readingGroup(f) === category);
|
|
215
|
+
if (!selected.length) continue;
|
|
216
|
+
const section = document.createElement('details'), title = document.createElement('summary');
|
|
217
|
+
section.dataset.pvCategory = category;
|
|
218
|
+
title.textContent = t(category === 'mesh' ? 'Mesh flags' : category === 'part' ? 'Part findings' : category === 'pair' ? 'Pair readings' : category === 'evidence' ? 'Check evidence' : 'Unclassified check rows');
|
|
219
|
+
section.append(title);
|
|
188
220
|
const roots = new Map<string, Flag[]>();
|
|
189
|
-
for (const f of
|
|
221
|
+
for (const f of selected) {
|
|
190
222
|
const root = f.kind === 'check' ? f.root : 'contour.bridges.faint';
|
|
191
223
|
const group = roots.get(root) ?? [];
|
|
192
224
|
group.push(f); roots.set(root, group);
|
|
@@ -195,7 +227,9 @@ function renderFlags(): void {
|
|
|
195
227
|
const details = document.createElement('details'), summary = document.createElement('summary'), rows = document.createElement('ul');
|
|
196
228
|
details.dataset.pvRoot = root; details.dataset.flagSource = source;
|
|
197
229
|
summary.textContent = group.length === 1 ? t('{root} · 1 row', { root }) : t('{root} · {count} rows', { root, count: group.length });
|
|
198
|
-
rows.append(...group.map(row)); details.append(summary, rows);
|
|
230
|
+
rows.append(...group.map(row)); details.append(summary, rows); section.append(details);
|
|
231
|
+
}
|
|
232
|
+
sourceItem.append(section);
|
|
199
233
|
}
|
|
200
234
|
return [sourceItem];
|
|
201
235
|
}));
|
|
@@ -204,7 +238,8 @@ function renderFlags(): void {
|
|
|
204
238
|
data.flagSources.length ? t('Read from: {files}.', { files: data.flagSources.join(', ') }) : '',
|
|
205
239
|
data.flagMissing.length ? t('Not found: {files}.', { files: data.flagMissing.join(', ') }) : '',
|
|
206
240
|
t('Occlusion coverage is not read yet: the producer does not write it.'),
|
|
207
|
-
t('
|
|
241
|
+
t('Badges count only mesh flags and explicit part findings. Pair readings and check evidence are not counted.'),
|
|
242
|
+
flags.some(f => readingGroup(f) === 'unclassified') ? t('Missing or invalid row metadata: source-root rows remain unclassified and are not counted.') : '',
|
|
208
243
|
].filter(Boolean).join(' ');
|
|
209
244
|
}
|
|
210
245
|
|
|
@@ -216,7 +251,7 @@ function renderList(): void {
|
|
|
216
251
|
button.type = 'button'; button.dataset.pvItem = item.name; button.title = item.name;
|
|
217
252
|
if (data.items[state.selected]?.name === item.name) button.setAttribute('aria-current', 'true');
|
|
218
253
|
const name = document.createElement('span'); name.className = 'pv-name'; name.textContent = item.name;
|
|
219
|
-
const onItem = data.flags.filter(f => f.item === item.name);
|
|
254
|
+
const onItem = [...data.flags.filter(f => f.kind === 'faint'), ...(data.readings ?? [])].filter(f => f.item === item.name && countedFlag(f));
|
|
220
255
|
const flags = document.createElement('span'); flags.className = 'pv-count';
|
|
221
256
|
// flagSources holds actual basenames (including custom.json); flagMissing canonically names unread kinds.
|
|
222
257
|
const meshRead = !data.flagMissing.includes('mesh_report.json'), checkRead = !data.flagMissing.includes('check.json');
|
|
@@ -231,6 +266,10 @@ function renderList(): void {
|
|
|
231
266
|
button.append(name, flags, badge);
|
|
232
267
|
button.onclick = () => { select(item.index); if (data.mode === 'atlas') setView('item'); };
|
|
233
268
|
li.append(button);
|
|
269
|
+
if(data.mode==='parts'){
|
|
270
|
+
const label=document.createElement('label'),visible=document.createElement('input');visible.type='checkbox';visible.checked=!state.hidden.has(item.name);visible.dataset.pvVisible=item.name;visible.setAttribute('aria-label',t('Show {name} in assembly',{name:item.name}));
|
|
271
|
+
visible.onchange=()=>{if(visible.checked)state.hidden.delete(item.name);else state.hidden.add(item.name);void paint();};label.append(visible);li.append(label);
|
|
272
|
+
}
|
|
234
273
|
return li;
|
|
235
274
|
}));
|
|
236
275
|
}
|
|
@@ -250,7 +289,7 @@ function renderMesh(): void {
|
|
|
250
289
|
const item = state.data!.items[state.selected]!;
|
|
251
290
|
if (!item.mesh) return;
|
|
252
291
|
const control = document.createElement('label'); control.id = 'pv-mesh-control'; control.className = 'pv-field';
|
|
253
|
-
const toggle = document.createElement('input'); toggle.type = 'checkbox'; toggle.checked = state.meshShown.has(item.name); toggle.disabled=state.comparison.mode==='overlay';
|
|
292
|
+
const toggle = document.createElement('input'); toggle.type = 'checkbox'; toggle.checked = state.meshShown.has(item.name); toggle.disabled=state.comparison.mode==='overlay'||state.view==='assembled';
|
|
254
293
|
toggle.onchange = () => { if (toggle.checked) state.meshShown.add(item.name); else state.meshShown.delete(item.name); void paint(); };
|
|
255
294
|
control.append(toggle, t('mesh from rig.json UVs')); document.querySelector('.pv-toolbar')!.append(control);
|
|
256
295
|
const panel = document.createElement('section'); panel.id = 'pv-mesh-panel';
|
|
@@ -277,15 +316,17 @@ function renderMesh(): void {
|
|
|
277
316
|
|
|
278
317
|
function select(index: number): void {
|
|
279
318
|
const data = state.data!;
|
|
280
|
-
const changed=state.selected!==index;state.selected = index;if(changed&&viewport){viewport.writeCamera('rig',{zoom:1,center:null});viewport.writeCamera('reference',{zoom:1,center:null});}
|
|
319
|
+
const changed=state.selected!==index;state.selected = index;if(changed&&viewport&&state.view!=='assembled'){viewport.writeCamera('rig',{zoom:1,center:null});viewport.writeCamera('reference',{zoom:1,center:null});}
|
|
281
320
|
commentUi?.refresh();
|
|
282
321
|
const item = data.items[index]!;
|
|
283
322
|
if (item.page !== undefined) state.page = data.pages.findIndex(p => p.name === item.page);
|
|
284
323
|
renderList(); renderFlags(); renderVerdict(); renderMesh(); renderComparison(); void paint();
|
|
285
324
|
}
|
|
286
325
|
|
|
287
|
-
function setView(view: 'item' | 'page'): void {
|
|
288
|
-
state.
|
|
326
|
+
function setView(view: 'item' | 'page' | 'assembled'): void {
|
|
327
|
+
if(view==='assembled'&&(state.data?.mode!=='parts'||!state.data.rigSize))return;
|
|
328
|
+
if(state.view!==view&&viewport){viewport.writeCamera('rig',{zoom:1,center:null});viewport.writeCamera('reference',{zoom:1,center:null});}
|
|
329
|
+
state.view = view;renderMesh();renderComparison();$('rig-label').textContent=t(view==='assembled'?'Assembled':'Selected part');commentUi?.refresh();
|
|
289
330
|
for (const b of document.querySelectorAll<HTMLButtonElement>('[data-pv-view]')) b.setAttribute('aria-pressed', String(b.dataset.pvView === view));
|
|
290
331
|
void paint();
|
|
291
332
|
}
|
|
@@ -297,6 +338,30 @@ function updateEntry(change: Partial<{ outcome: Outcome; note: string }>): void
|
|
|
297
338
|
renderList();
|
|
298
339
|
}
|
|
299
340
|
|
|
341
|
+
/** Explicit approval only: refuse before changing any pending entry when a flag remains. */
|
|
342
|
+
async function approveAll(): Promise<void> {
|
|
343
|
+
if (stageEmbedded || !state.data) return;
|
|
344
|
+
const entries = state.data.items.map(item => state.verdict.get(item.name));
|
|
345
|
+
if (entries.some(entry => entry?.outcome === 'flagged' || entry?.mesh?.outcome === 'flagged')) {
|
|
346
|
+
const status = $('pv-save-status');
|
|
347
|
+
status.textContent = t('PARTS_APPROVE_ALL_FLAGGED: resolve flagged part and mesh outcomes before approving all.');
|
|
348
|
+
status.dataset.result = 'refused';
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
for (const item of state.data.items) {
|
|
352
|
+
const entry = state.verdict.get(item.name) ?? { outcome: 'pending' as Outcome, note: '' };
|
|
353
|
+
if (entry.outcome === 'pending') entry.outcome = 'clean';
|
|
354
|
+
if (item.mesh) {
|
|
355
|
+
entry.mesh ??= { outcome: 'pending', note: '' };
|
|
356
|
+
if (entry.mesh.outcome === 'pending') entry.mesh.outcome = 'clean';
|
|
357
|
+
}
|
|
358
|
+
state.verdict.set(item.name, entry);
|
|
359
|
+
}
|
|
360
|
+
$<HTMLSelectElement>('pv-overall').value = 'approved';
|
|
361
|
+
renderList(); renderVerdict(); renderMesh();
|
|
362
|
+
await save();
|
|
363
|
+
}
|
|
364
|
+
|
|
300
365
|
async function save(): Promise<void> {
|
|
301
366
|
if(stageEmbedded)return;
|
|
302
367
|
const status = $('pv-save-status');
|
|
@@ -318,6 +383,7 @@ async function boot(): Promise<void> {
|
|
|
318
383
|
header.hidden=true;status.classList.add('pv-embedded-status');header.after(status);
|
|
319
384
|
document.querySelector<HTMLElement>('.pv-layout')!.hidden=true;
|
|
320
385
|
document.querySelector<HTMLElement>('.pv-verdict')!.hidden=true;
|
|
386
|
+
const approveButton=$<HTMLButtonElement>('pv-approve-all');approveButton.disabled=true;
|
|
321
387
|
const saveButton=$<HTMLButtonElement>('pv-save');saveButton.disabled=true;saveButton.title=t('Embedded atlas inspection is read-only. Use the parts command for a separate sign-off.');
|
|
322
388
|
}
|
|
323
389
|
window.addEventListener('message',event=>{if(event.source!==parent||event.origin!==location.origin||event.data?.type!=='review-stage-language'||!['en','ko'].includes(event.data.language))return;setLinkLanguage(null);setLanguagePreference(event.data.language);});
|
|
@@ -335,6 +401,9 @@ async function boot(): Promise<void> {
|
|
|
335
401
|
$('pv-load').textContent = data.verdictStale === 'files' ? t('A saved sign-off was made on other files; this review starts fresh.') : data.verdictStale === 'flags' ? t('The saved sign-off is for different producer flags; this review starts fresh.') : data.verdict ? t('Saved sign-off loaded.') : '';
|
|
336
402
|
if(stageEmbedded){$('pv-load').hidden=$('pv-load').textContent==='';document.querySelector<HTMLElement>('.pv-layout')!.hidden=false;}
|
|
337
403
|
$('pv-atlas-switch').hidden = data.mode !== 'atlas';
|
|
404
|
+
const assemble=$<HTMLButtonElement>('pv-assemble');assemble.disabled=data.mode!=='parts'||!data.rigSize;assemble.title=assemble.disabled?t(data.mode==='atlas'?'Assembly unavailable: atlas regions carry no rig placement.':'Assembly unavailable: rig_size is not declared.'):'';
|
|
405
|
+
assemble.onclick=()=>{setView(state.view==='assembled'?'item':'assembled');assemble.setAttribute('aria-pressed',String(state.view==='assembled'));};
|
|
406
|
+
bindAssemblyPicking();
|
|
338
407
|
for(const button of document.querySelectorAll<HTMLElement>('[data-pv-comparison]'))button.onclick=()=>{state.comparison.mode=button.dataset.pvComparison as 'part'|'overlay';if(state.comparison.mode==='overlay'){state.alpha=false;$<HTMLInputElement>('pv-alpha').checked=false;state.meshShown.delete(state.data!.items[state.selected]!.name);renderMesh();}renderComparison();void paint();};
|
|
339
408
|
$<HTMLInputElement>('pv-opacity').oninput=e=>{state.comparison.opacity=Number((e.target as HTMLInputElement).value);renderComparison();void paint();};
|
|
340
409
|
const footprints = $<HTMLInputElement>('pv-footprints');
|
|
@@ -347,12 +416,28 @@ async function boot(): Promise<void> {
|
|
|
347
416
|
for (const r of document.querySelectorAll<HTMLInputElement>('input[data-pv-outcome]')) r.onchange = () => { if (r.checked) updateEntry({ outcome: r.value as Outcome }); };
|
|
348
417
|
$<HTMLTextAreaElement>('pv-note').oninput = e => updateEntry({ note: (e.target as HTMLTextAreaElement).value });
|
|
349
418
|
$('pv-save').onclick = () => { void save(); };
|
|
419
|
+
$('pv-approve-all').onclick = () => approveAll();
|
|
350
420
|
for(const format of ['json','issue'])$('pv-export-'+format).onclick=async()=>{const res=await fetch(access.route('/api/parts/export?format='+format),{headers:access.headers()});const value=await res.text();if(!res.ok){$('pv-save-status').textContent=value;return;}const url=URL.createObjectURL(new Blob([value],{type:format==='json'?'application/json':'text/markdown'})),a=document.createElement('a');a.href=url;a.download=format==='json'?'parts-review-export.json':'parts-review-export.md';a.click();setTimeout(()=>URL.revokeObjectURL(url),1000);};
|
|
351
421
|
onLanguageChange(() => { if (state.data) select(state.selected); });
|
|
352
422
|
if (data.items.length) select(0);
|
|
353
423
|
document.body.dataset.ready = 'true';
|
|
354
424
|
}
|
|
355
425
|
|
|
426
|
+
/** Observe taps only; the shared controller exclusively owns pan, zoom and pinch. */
|
|
427
|
+
function bindAssemblyPicking():void {
|
|
428
|
+
const pane=$('rig-viewport');let tap:{id:number;x:number;y:number}|null=null;const pointers=new Set<number>();
|
|
429
|
+
pane.addEventListener('pointerdown',e=>{pointers.add(e.pointerId);if(pointers.size===1&&e.button===0)tap={id:e.pointerId,x:e.clientX,y:e.clientY};else tap=null;});
|
|
430
|
+
pane.addEventListener('pointermove',e=>{if(tap&&Math.hypot(e.clientX-tap.x,e.clientY-tap.y)>4)tap=null;});
|
|
431
|
+
pane.addEventListener('pointercancel',e=>{pointers.delete(e.pointerId);tap=null;});
|
|
432
|
+
pane.addEventListener('pointerup',e=>{
|
|
433
|
+
pointers.delete(e.pointerId);const start=tap;tap=null;
|
|
434
|
+
if(!start||start.id!==e.pointerId||Math.hypot(e.clientX-start.x,e.clientY-start.y)>4||state.view!=='assembled'||painting||paintFailure||commentUi?.active())return;
|
|
435
|
+
const data=state.data!,r=$('pv-canvas').getBoundingClientRect(),zoom=viewport!.paneCamera('rig').zoom;
|
|
436
|
+
const layers=data.items.flatMap(box=>{const img=images.get(`${partsApi}/image/${box.index}`);return img?[{box,alpha:sourceAlpha(box,img)}]:[];});
|
|
437
|
+
const hit=pickAssembly(layers,(e.clientX-r.left)/zoom,(e.clientY-r.top)/zoom,state.hidden);if(hit)select(hit.index);
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
|
|
356
441
|
interface PartsPose extends CommentUiPose {item:Item;sourceHash:string;view:PartsComment['view']}
|
|
357
442
|
function setupPartsComments():void {
|
|
358
443
|
const codec:CommentCodec<PartsComment,PartsPose>={
|
|
@@ -364,8 +449,8 @@ function setupPartsComments():void {
|
|
|
364
449
|
};
|
|
365
450
|
const pose=():PartsPose|null=>{const data=state.data,item=data?.items[state.selected],camera=viewport?.numericView().cameras.rig;if(!data||!item||!camera||data.mode!=='parts'||state.view!=='item')return null;return {mode:'parts',camera,item:{...item},sourceHash:data.sourceHash,view:{camera:{zoom:camera.zoom,center:{...camera.center},viewport:{...camera.viewport}},cameraSync:viewport!.state.cameraSync,referenceCamera:(()=>{const c=viewport!.numericView().cameras.reference;return c?{zoom:c.zoom,center:{...c.center},viewport:{...c.viewport}}:null;})(),background:state.bg,alpha:state.alpha,footprints:state.footprints,mesh:state.meshShown.has(item.name),comparison:{...state.comparison}},capture:{pane:$('rig-viewport'),root:$('rig-root'),images:true,canvas:$<HTMLCanvasElement>('pv-canvas'),backend:'canvas2d',nearest:true}};};
|
|
366
451
|
commentUi=bindStageComments({toolbar:document.querySelector<HTMLElement>('.pv-toolbar')!,viewports:{rig:$('rig-viewport')},pose,pause:async()=>{},bookmark:()=>null,
|
|
367
|
-
restore:async(raw)=>{const b=raw as {part:string;imageHash:string;sourceHash:string;view:PartsComment['view']},item=state.data!.items.find(i=>i.name===b.part);if(!item||item.imageHash!==b.imageHash||state.data!.sourceHash!==b.sourceHash)throw new Error('PARTS_COMMENT_STALE_SOURCE: reopen the bound source');select(item.index);state.bg=b.view.background;state.alpha=b.view.alpha;state.footprints=b.view.footprints;state.comparison={...(b.view.comparison??defaultPartsComparison())};renderComparison();if(b.view.mesh)state.meshShown.add(item.name);else state.meshShown.delete(item.name);$<HTMLSelectElement>('pv-bg').value=state.bg;$<HTMLInputElement>('pv-alpha').checked=state.alpha;$<HTMLInputElement>('pv-footprints').checked=state.footprints;renderMesh();viewport!.state.cameraRestoring=true;try{await paint();viewport!.writeCamera('rig',{zoom:b.view.camera.zoom,center:{...b.view.camera.center}});if(b.view.referenceCamera)viewport!.writeCamera('reference',{zoom:b.view.referenceCamera.zoom,center:{...b.view.referenceCamera.center}});viewport!.state.cameraSync=b.view.cameraSync;viewport!.fitCamera();}finally{viewport!.state.cameraRestoring=false;}},
|
|
368
|
-
feedback:()=>comments,locked:()=>false,add:c=>comments.push(c),changed:()=>renderVerdict(),error:m=>{$('pv-save-status').textContent=t(m);},blocked:()=>painting,refusal:()=>paintFailure??(state.data?.mode!=='parts'||stageEmbedded?'PARTS_COMMENT_UNAVAILABLE: original part image required':null),codec});
|
|
452
|
+
restore:async(raw)=>{const b=raw as {part:string;imageHash:string;sourceHash:string;view:PartsComment['view']},item=state.data!.items.find(i=>i.name===b.part);if(!item||item.imageHash!==b.imageHash||state.data!.sourceHash!==b.sourceHash)throw new Error('PARTS_COMMENT_STALE_SOURCE: reopen the bound source');setView('item');$('pv-assemble').setAttribute('aria-pressed','false');select(item.index);state.bg=b.view.background;state.alpha=b.view.alpha;state.footprints=b.view.footprints;state.comparison={...(b.view.comparison??defaultPartsComparison())};renderComparison();if(b.view.mesh)state.meshShown.add(item.name);else state.meshShown.delete(item.name);$<HTMLSelectElement>('pv-bg').value=state.bg;$<HTMLInputElement>('pv-alpha').checked=state.alpha;$<HTMLInputElement>('pv-footprints').checked=state.footprints;renderMesh();viewport!.state.cameraRestoring=true;try{await paint();viewport!.writeCamera('rig',{zoom:b.view.camera.zoom,center:{...b.view.camera.center}});if(b.view.referenceCamera)viewport!.writeCamera('reference',{zoom:b.view.referenceCamera.zoom,center:{...b.view.referenceCamera.center}});viewport!.state.cameraSync=b.view.cameraSync;viewport!.fitCamera();}finally{viewport!.state.cameraRestoring=false;}},
|
|
453
|
+
feedback:()=>comments,locked:()=>false,add:c=>comments.push(c),changed:()=>renderVerdict(),error:m=>{$('pv-save-status').textContent=t(m);},blocked:()=>painting,refusal:()=>paintFailure??(state.view==='assembled'?'PARTS_COMMENT_UNAVAILABLE: select the individual part view to comment':null)??(state.data?.mode!=='parts'||stageEmbedded?'PARTS_COMMENT_UNAVAILABLE: original part image required':null),codec});
|
|
369
454
|
}
|
|
370
455
|
|
|
371
456
|
if (typeof document !== 'undefined' && document.getElementById('parts-app')) void boot();
|