@rig-c/review 1.9.0 → 1.10.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/DESIGN.md +38 -14
- package/docs/PANELS.md +37 -13
- package/docs/PARTS_VIEW.md +79 -0
- package/docs/REVIEW_PACKAGE.md +66 -0
- package/package.json +1 -1
- package/src/applied-context.ts +17 -4
- package/src/front.ts +5 -1
- package/src/parts-comment-crops.ts +3 -1
- package/src/parts-comparison.ts +25 -2
- package/src/parts-server.ts +11 -2
- package/src/parts-view.ts +37 -5
- package/src/rebuild.ts +84 -1
- package/src/retune-check.ts +1 -1
- package/src/server.ts +4 -2
- package/src/stage-parts.ts +81 -4
- package/web/catalog-en.ts +38 -1
- package/web/catalog-ko.ts +38 -1
- package/web/chest-editor.ts +3 -0
- package/web/main.ts +59 -13
- package/web/parts.css +7 -0
- package/web/parts.html +2 -1
- package/web/parts.ts +87 -16
- package/web/rebuild-client.ts +15 -7
- package/web/stage-nav.ts +21 -6
package/src/parts-view.ts
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* `source.sha256` is the sha256 over the UTF-8 lines `<path>\t<sha256>\n`, sorted by path bytewise, where every path
|
|
16
16
|
* is relative to the verdict file's directory. rig-c/create recomputes it, so the definition is fixed here.
|
|
17
17
|
*/
|
|
18
|
-
import {assertOriginalPaintingSize} from './parts-comparison.ts';
|
|
18
|
+
import {differencePixels,assertOriginalPaintingSize} from './parts-comparison.ts';
|
|
19
19
|
import {parsePartsComment,assertPartsCommentBinding,type PartsComment} from './parts-comment.ts';
|
|
20
20
|
import {preparePartsComment,validateStoredPartsComment} from './parts-comment-crops.ts';
|
|
21
21
|
import {resolvedCropPath} from './comment-crops.ts';
|
|
@@ -61,6 +61,7 @@ export type ProducerFlag =
|
|
|
61
61
|
classification?: 'part' | 'pair' | 'evidence' | 'unclassified' };
|
|
62
62
|
|
|
63
63
|
export interface PartsViewPackage {
|
|
64
|
+
paintingInRig?: LocalFile & {width:number;height:number;declaredPath:string};
|
|
64
65
|
painting?:{sha256:string;width:number;height:number;abs:string};
|
|
65
66
|
mode: PartsViewMode;
|
|
66
67
|
root: string;
|
|
@@ -333,6 +334,23 @@ async function loadPartsMode(root: string, options: PartsViewOptions): Promise<P
|
|
|
333
334
|
imagePaths.push(real);
|
|
334
335
|
items.push({ name: part.name, index, x: part.x, y: part.y, w: part.w, h: part.h, image: true });
|
|
335
336
|
}
|
|
337
|
+
let paintingInRig:PartsViewPackage['paintingInRig'];
|
|
338
|
+
if(Object.hasOwn(doc,'painting_in_rig')){
|
|
339
|
+
const d=record(doc.painting_in_rig);
|
|
340
|
+
if(!d||Object.keys(d).length!==3||typeof d.path!=='string'||typeof d.sha256!=='string'||!/^[a-f0-9]{64}$/.test(d.sha256)||d.resample!=='lanczos3-rgb-opaque')refuse('PARTS_DIFFERENCE_PROVENANCE','declared path, lowercase SHA-256 and lanczos3-rgb-opaque required');
|
|
341
|
+
try{packagePath(d!.path,'painting_in_rig');}catch{refuse('PARTS_DIFFERENCE_PATH','literal portable inside-package path required');}
|
|
342
|
+
const declaredPath=join(root,d!.path as string);
|
|
343
|
+
const unreadable=()=>refuse('PARTS_DIFFERENCE_PATH','declared painting must be readable inside the package');
|
|
344
|
+
const abs=await safeFile(root,d!.path as string).catch(unreadable);
|
|
345
|
+
const bytes=await readFile(abs).catch(unreadable);
|
|
346
|
+
const sha256=createHash('sha256').update(bytes).digest('hex');
|
|
347
|
+
if(sha256!==d!.sha256)refuse('PARTS_DIFFERENCE_HASH','declared painting hash differs');
|
|
348
|
+
let png:PNG;try{png=PNG.sync.read(bytes);}catch{refuse('PARTS_DIFFERENCE_PNG','declared painting must be RGBA8 PNG');}
|
|
349
|
+
if(bytes[24]!==8||bytes[25]!==6)refuse('PARTS_DIFFERENCE_PNG','declared painting must be RGBA8 PNG');
|
|
350
|
+
if(!rigSize||!rigSize.every(Number.isSafeInteger)||png!.width!==rigSize[0]||png!.height!==rigSize[1])refuse('PARTS_DIFFERENCE_SIZE','declared painting dimensions must equal integer rig_size');
|
|
351
|
+
for(let i=3;i<png!.data.length;i+=4)if(png!.data[i]!==255)refuse('PARTS_DIFFERENCE_ALPHA','declared painting must have alpha 255');
|
|
352
|
+
paintingInRig={abs,declaredPath,bytes:bytes.length,sha256,width:png!.width,height:png!.height};files.push(paintingInRig);
|
|
353
|
+
}
|
|
336
354
|
let painting:PartsViewPackage['painting'];if(options.painting){
|
|
337
355
|
const candidate=resolve(options.painting),rel=relative(resolve(root),candidate);if(!rel||rel==='..'||rel.startsWith('..'+sep)||isAbsolute(rel))refuse('PARTS_PAINTING_OUTSIDE','painting must be inside the parts package');
|
|
338
356
|
let abs:string,bytes:Buffer;try{abs=await insideRoot(root,candidate,'PARTS_PAINTING_OUTSIDE','painting');packagePath(relative(root,abs).split(sep).join('/'),'painting');bytes=await readFile(abs);}catch(error){if(error instanceof Error&&error.message.startsWith('PARTS_PAINTING_OUTSIDE:'))throw error;refuse('PARTS_PAINTING_UNAVAILABLE','painting must be a readable portable package PNG');}
|
|
@@ -359,7 +377,7 @@ async function loadPartsMode(root: string, options: PartsViewOptions): Promise<P
|
|
|
359
377
|
files.push({ abs: rigPath, bytes: rigBytes.length, sha256: createHash('sha256').update(rigBytes).digest('hex') });
|
|
360
378
|
if (report) files.push(report);
|
|
361
379
|
}
|
|
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: [] };
|
|
380
|
+
return { ...(paintingInRig?{paintingInRig}:{}),...(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: [] };
|
|
363
381
|
}
|
|
364
382
|
|
|
365
383
|
async function loadAtlasMode(input: string, options: PartsViewOptions): Promise<PartsViewPackage> {
|
|
@@ -462,7 +480,7 @@ export interface VerdictSubmission { status: VerdictStatus; parts: Record<string
|
|
|
462
480
|
export const itemNames = (pkg: Pick<PartsViewPackage, 'items'>): string[] => [...new Set(pkg.items.map(i => i.name))];
|
|
463
481
|
|
|
464
482
|
/** Builds the verdict document, or refuses by name. Pure but for the clock. */
|
|
465
|
-
export function buildVerdict(pkg: Pick<PartsViewPackage, 'mode' | 'items' | 'flags' | 'files' | 'flagFiles' | 'verdictPath' | 'imagePaths' | 'painting'>, input: unknown, version: string, now = new Date()): PartsVerdict {
|
|
483
|
+
export function buildVerdict(pkg: Pick<PartsViewPackage, 'mode' | 'items' | 'flags' | 'files' | 'flagFiles' | 'verdictPath' | 'imagePaths' | 'painting' | 'paintingInRig'>, input: unknown, version: string, now = new Date()): PartsVerdict {
|
|
466
484
|
const body = record(input);
|
|
467
485
|
if (!body) return refuse('PARTS_VERDICT_INVALID', 'expected { status, parts }');
|
|
468
486
|
const status = body.status;
|
|
@@ -497,12 +515,13 @@ export function buildVerdict(pkg: Pick<PartsViewPackage, 'mode' | 'items' | 'fla
|
|
|
497
515
|
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`);
|
|
498
516
|
if (status === 'changes-requested' && !outcomes.includes('flagged')) refuse('PARTS_VERDICT_NOTHING_FLAGGED', 'changes-requested needs at least one flagged part');
|
|
499
517
|
const comments=body.comments??[];if(!Array.isArray(comments)||comments.length>1000)refuse('PARTS_COMMENT_LIMIT','comments must be an array of at most 1000 entries');
|
|
500
|
-
const ids=new Set<string>();for(const raw of comments as unknown[]){const c=parsePartsComment(raw);if(c.view.comparison?.mode==='overlay'&&!pkg.painting)refuse('PARTS_COMPARISON_UNAVAILABLE','original painting required');const item=pkg.items.find(i=>i.name===c.part);if(!item||pkg.mode!=='parts')refuse('PARTS_COMMENT_UNAVAILABLE','original part required');if(ids.has(c.id))refuse('PARTS_COMMENT_DUPLICATE','duplicate comment id');ids.add(c.id);const file=pkg.files.find(f=>f.abs===pkg.imagePaths[item!.index]);assertPartsCommentBinding(c,item!,file?.sha256??'',verdictSource(pkg).sha256);}
|
|
518
|
+
const ids=new Set<string>();for(const raw of comments as unknown[]){const c=parsePartsComment(raw);if(c.view.comparison?.mode==='overlay'&&!pkg.painting)refuse('PARTS_COMPARISON_UNAVAILABLE','original painting required');if(c.view.comparison?.mode==='difference'&&!pkg.paintingInRig)refuse('PARTS_DIFFERENCE_UNAVAILABLE','declared painting_in_rig required');const item=pkg.items.find(i=>i.name===c.part);if(!item||pkg.mode!=='parts')refuse('PARTS_COMMENT_UNAVAILABLE','original part required');if(ids.has(c.id))refuse('PARTS_COMMENT_DUPLICATE','duplicate comment id');ids.add(c.id);const file=pkg.files.find(f=>f.abs===pkg.imagePaths[item!.index]);assertPartsCommentBinding(c,item!,file?.sha256??'',verdictSource(pkg).sha256);}
|
|
501
519
|
return { schema: PARTS_VERDICT_SCHEMA, mode: pkg.mode, tool: { name: '@rig-c/review', version }, source: verdictSource(pkg), status, parts, comments:comments as PartsComment[], updatedAt: now.toISOString() };
|
|
502
520
|
}
|
|
503
521
|
|
|
504
522
|
/** Every file the package was loaded from still has the bytes it was loaded with. */
|
|
505
|
-
export async function assertPartsUnchanged(pkg: Pick<PartsViewPackage, 'files' | 'flagFiles'>): Promise<void> {
|
|
523
|
+
export async function assertPartsUnchanged(pkg: Pick<PartsViewPackage, 'files' | 'flagFiles' | 'paintingInRig'>): Promise<void> {
|
|
524
|
+
if(pkg.paintingInRig&&await realpath(pkg.paintingInRig.declaredPath).catch(()=>null)!==pkg.paintingInRig.abs)refuse('PARTS_VIEW_SOURCE_CHANGED','declared painting path changed');
|
|
506
525
|
for (const f of [...pkg.files, ...pkg.flagFiles]) {
|
|
507
526
|
const now = await hashFile(f.abs).catch(() => null);
|
|
508
527
|
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`);
|
|
@@ -555,6 +574,7 @@ export async function readVerdict(pkg: PartsViewPackage): Promise<{ verdict: Par
|
|
|
555
574
|
export function partsViewJson(pkg: PartsViewPackage, saved: { verdict: PartsVerdict | null; stale: VerdictStale }) {
|
|
556
575
|
return {
|
|
557
576
|
schema: 'rig-review-parts-view/1', mode: pkg.mode, title: pkg.title, rigSize: pkg.rigSize,
|
|
577
|
+
differenceAvailable:!!pkg.paintingInRig,
|
|
558
578
|
painting:pkg.painting?{sha256:pkg.painting.sha256,width:pkg.painting.width,height:pkg.painting.height}:null,
|
|
559
579
|
sourceHash:verdictSource(pkg).sha256,
|
|
560
580
|
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 ?? [],
|
|
@@ -576,3 +596,15 @@ export function exportPartsVerdict(verdict:PartsVerdict,format:'json'|'issue'):s
|
|
|
576
596
|
if(format==='json')return JSON.stringify({...verdict,comments},null,2)+'\n';
|
|
577
597
|
return [`# Parts review`, `Source: ${verdict.source.sha256}`,`Status: ${verdict.status}`,...Object.entries(verdict.parts).flatMap(([name,p])=>[`\n## ${name}`,`${p.outcome}: ${p.note}`,...comments.filter(c=>c.part===name).flatMap(c=>[`\n### ${c.summary}`,`Part: ${c.part} · image SHA-256: ${c.imageHash}`,`Image region: ${JSON.stringify(c.imageRegion)}`,`Rig region: ${JSON.stringify(c.rigRegion)}`,`Viewport crop: ${c.crop.path} · SHA-256 ${c.crop.sha256}`,`Native crop: ${c.nativeCrop!.path} · SHA-256 ${c.nativeCrop!.sha256}`,`View: ${JSON.stringify(c.view)}`])])].join('\n')+'\n';
|
|
578
598
|
}
|
|
599
|
+
|
|
600
|
+
/** Numeric comparison is decoded from bound original PNG bytes on the server, never browser pixels. */
|
|
601
|
+
export async function partsDifference(pkg:PartsViewPackage,index:number,threshold:number,footprints:boolean){
|
|
602
|
+
await assertPartsUnchanged(pkg);
|
|
603
|
+
if(!pkg.paintingInRig)refuse('PARTS_DIFFERENCE_UNAVAILABLE','declared painting_in_rig required; legacy records remain readable');
|
|
604
|
+
const item=pkg.items[index];if(pkg.mode!=='parts'||!Number.isInteger(index)||!item)refuse('PARTS_DIFFERENCE_UNAVAILABLE','known original part required');
|
|
605
|
+
const decode=async(path:string)=>{const bytes=await readFile(path);if(bytes[24]!==8||bytes[25]!==6)refuse('PARTS_DIFFERENCE_PNG','exact RGBA8 operands required');return PNG.sync.read(bytes);};
|
|
606
|
+
const painting=await decode(pkg.paintingInRig!.abs),part=await decode(pkg.imagePaths[index]!);
|
|
607
|
+
const fronts=footprints?await Promise.all(pkg.items.filter(f=>f.index>index&&f.x<item!.x+item!.w&&f.x+f.w>item!.x&&f.y<item!.y+item!.h&&f.y+f.h>item!.y).map(async box=>({box,raster:await decode(pkg.imagePaths[box.index]!)}))):[];
|
|
608
|
+
const result=differencePixels(part,item!,painting,fronts,threshold,footprints);
|
|
609
|
+
await assertPartsUnchanged(pkg);return result;
|
|
610
|
+
}
|
package/src/rebuild.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import {isDeepStrictEqual} from 'node:util';
|
|
2
|
+
import {recordFor,type AnyJobView} from '../web/rebuild-client.ts';
|
|
1
3
|
/**
|
|
2
4
|
* Apply · Rebuild (issue #99): the user's chest-region designation goes to the installed producer as one mesh entry,
|
|
3
5
|
* `rig-parts remesh` re-fits that one part of the package's gated rig into a scratch revision, `rigc build` compiles
|
|
@@ -263,6 +265,10 @@ export interface AppliedHistory { schema: 'rig-review-applied-history/1'; depth:
|
|
|
263
265
|
export type RebuildStatus = 'running' | 'built' | 'refused' | 'failed';
|
|
264
266
|
export interface RebuildBuild { model: string; modelUrl: string; modelHash: string; files: Record<string, string> }
|
|
265
267
|
export interface RebuildJob {
|
|
268
|
+
files?: FilesDiff | null;
|
|
269
|
+
remesh?: (RemeshCounts & {modelTriangles:number|null}) | null;
|
|
270
|
+
stageInputHash?: string;
|
|
271
|
+
check?: CheckSummary | null;
|
|
266
272
|
schema: typeof REBUILD_SCHEMA; id: string; status: RebuildStatus; reused: boolean;
|
|
267
273
|
request: { part: string; regions: ProducerRegion[]; configHash: string; entrySha256: string; bust?: BustSpec };
|
|
268
274
|
producer: { package: string; version: string }; compiler: { package: string; version: string };
|
|
@@ -277,6 +283,7 @@ export interface RebuildJob {
|
|
|
277
283
|
* inspected one (`diff`) — and, #125, every document the producer writes, per file, with the images by hash (`files`).
|
|
278
284
|
*/
|
|
279
285
|
export interface PatchJob {
|
|
286
|
+
stageInputHash?: string;
|
|
280
287
|
schema: typeof REBUILD_SCHEMA; kind: 'patch'; id: string; status: RebuildStatus; reused: boolean;
|
|
281
288
|
/** #136: the producer op that ran — a `rig` patch runs `retune` when `patchRoute` routes it there, else `rig`; a remesh patch `remesh`. */
|
|
282
289
|
op: AppliedOp;
|
|
@@ -359,6 +366,7 @@ export const BUILD_SOURCE_UNAVAILABLE = 'MODELING_INPUT_UNAVAILABLE: source pain
|
|
|
359
366
|
* motion holds against the inspected rig's.
|
|
360
367
|
*/
|
|
361
368
|
export interface RetargetJob {
|
|
369
|
+
stageInputHash?: string;
|
|
362
370
|
schema: typeof REBUILD_SCHEMA; kind: 'retarget'; id: string; status: RebuildStatus; reused: boolean; op: 'retarget';
|
|
363
371
|
request: { record: RetargetRecord; recordSha256: string; configHash: string };
|
|
364
372
|
producer: { package: string; version: string }; compiler: { package: string; version: string };
|
|
@@ -398,6 +406,8 @@ export function deltaId(input: { sourceHash: string; configHash: string; part: s
|
|
|
398
406
|
}
|
|
399
407
|
/** A delta Apply's job (#135): `remesh --delta`, then the shared tail with the per-file diff (#125); remesh's own gate holds check. */
|
|
400
408
|
export interface DeltaJob {
|
|
409
|
+
stageInputHash?: string;
|
|
410
|
+
check?: CheckSummary | null;
|
|
401
411
|
schema: typeof REBUILD_SCHEMA; kind: 'delta'; id: string; status: RebuildStatus; reused: boolean; op: 'remesh';
|
|
402
412
|
request: { part: string; delta: Record<string, unknown>; deltaSha256: string; configHash: string };
|
|
403
413
|
producer: { package: string; version: string }; compiler: { package: string; version: string };
|
|
@@ -446,6 +456,7 @@ export function animationId(input: { sourceHash: string; configHash: string; ani
|
|
|
446
456
|
return sha256(JSON.stringify([REBUILD_SCHEMA, 'animation', input.sourceHash, input.configHash, input.animationsFromHash, input.opsText, input.producer, input.compiler, ...(input.args?.length ? [input.args] : []), ...(input.environment ? ['environment', input.environment] : [])]));
|
|
447
457
|
}
|
|
448
458
|
export interface AnimationJob {
|
|
459
|
+
stageInputHash?: string;
|
|
449
460
|
schema: typeof REBUILD_SCHEMA; kind: 'animation'; id: string; status: RebuildStatus; reused: boolean; op: 'rig';
|
|
450
461
|
request: { configHash: string; animationsFrom: { path: string; beforeSha256: string; afterSha256: string }; ops: AnimationSourceOp[]; opsSha256: string; args?: string[] };
|
|
451
462
|
producer: { package: string; version: string }; compiler: { package: string; version: string };
|
|
@@ -619,6 +630,15 @@ async function namedDirDigest(root: string, dir: string, field: string): Promise
|
|
|
619
630
|
}
|
|
620
631
|
|
|
621
632
|
/** #115: what a build-routed patch runs with — the handoff's painting and runs, absolute; never from the client. */
|
|
633
|
+
/** Inputs and produced spec share a revision pin; result.json and compiled outputs have their separate records. */
|
|
634
|
+
async function stageInputDigest(dir:string,spec:string):Promise<string>{
|
|
635
|
+
const root=await realpath(dir);
|
|
636
|
+
const rows:[string,string][]=[['revision',await namedDirDigest(root,spec,'scratch revision')]];
|
|
637
|
+
for(const name of ['mesh.json','mesh-edit.json','config.json','patch.json','environment.json']){
|
|
638
|
+
if(await exists(join(dir,name))){const path=await safeFile(await realpath(dir),name);rows.push([name,sha256(await readFile(path))]);}
|
|
639
|
+
}
|
|
640
|
+
return sha256(JSON.stringify(rows));
|
|
641
|
+
}
|
|
622
642
|
export interface BuildPlan { source: string; full: string; head: string | null; inputsHash: string; inputs: AssembledView['inputs'] }
|
|
623
643
|
/**
|
|
624
644
|
* The build's inputs for a patch (`null` refusal line when the handoff declares no painting and full run): the painting
|
|
@@ -864,6 +884,54 @@ export function createRebuilds(p: ReviewPackage, options: RebuildOptions) {
|
|
|
864
884
|
const dir = job ? rebuildDir(options.stateDir, p.sourceHash, job.id) : '';
|
|
865
885
|
return job && job.status === 'built' && job.build ? { id: job.id, build: join(dir, 'build'), modelHash: job.build.modelHash, spec: join(dir, !('kind' in job) ? 'revision' : job.op === 'build' || (job.kind === 'patch' && job.cloth?.route === 'build') ? 'out/rig' : 'rig') } : null;
|
|
866
886
|
}
|
|
887
|
+
/** Stage 1 can read only the revision explicitly drawn by the page, never a pending candidate. */
|
|
888
|
+
async function stageDraft(id: string) {
|
|
889
|
+
await options.unchanged();
|
|
890
|
+
const current = latest();
|
|
891
|
+
if (!current || current.id !== id || busy()) throw new RebuildError('STAGE_DRAFT_STALE', 'the requested scratch build is not the settled applied revision');
|
|
892
|
+
const job = jobs.get(id)!;
|
|
893
|
+
if (!job.stageInputHash || await stageInputDigest(rebuildDir(options.stateDir,p.sourceHash,id),current.spec) !== job.stageInputHash) throw new RebuildError('STAGE_DRAFT_CHANGED', 'scratch revision bytes differ from Apply');
|
|
894
|
+
const now = await hashBuild(current.build, id, assetPrefix);
|
|
895
|
+
if (JSON.stringify(now.files) !== JSON.stringify(job.build!.files)) throw new RebuildError('STAGE_DRAFT_CHANGED', 'scratch build bytes differ from the applied record');
|
|
896
|
+
if (!('check' in job) || !job.check || job.check.pass !== true || job.check.exitCode !== 0) throw new RebuildError('STAGE_DRAFT_UNCHECKED', 'this revision has no successful recorded producer check');
|
|
897
|
+
if (!('kind' in job) || job.kind === 'delta' || (job.kind === 'patch' && job.op === 'remesh')) {
|
|
898
|
+
const carried = await opCarried('remesh', current.spec, null, () => {});
|
|
899
|
+
if (carried && 'refused' in carried) throw new RebuildError('STAGE_DRAFT_CHANGED', carried.refused);
|
|
900
|
+
} else throw new RebuildError('STAGE_DRAFT_OPERATION', 'only applied mesh corrections belong to this inspection');
|
|
901
|
+
return {id, spec: current.spec, model: join(current.build, 'skeleton.model.json'), evidence: snapshot(job)};
|
|
902
|
+
}
|
|
903
|
+
/** Historical evidence is independent of the disposable Undo cache; current-stage reads still use stageDraft. */
|
|
904
|
+
const evidenceBinding={id:p.manifest.id,revision:p.manifest.revision,sourceHash:p.sourceHash,reviewedSource:p.reviewedSource};
|
|
905
|
+
const evidencePath=(id:string)=>join(options.stateDir,'applied-evidence',p.sourceHash,id+'.json');
|
|
906
|
+
const evidenceLimit=1024*1024;
|
|
907
|
+
async function sealApplied(job:RebuildJob|PatchJob|DeltaJob|RetargetJob|AnimationJob):Promise<void>{
|
|
908
|
+
if(!job.build||job.status!=='built')throw new RebuildError('STAGE_DRAFT_STALE','only a settled applied build can be sealed');
|
|
909
|
+
const dir=rebuildDir(options.stateDir,p.sourceHash,job.id);
|
|
910
|
+
const spec=join(dir,!('kind' in job)?'revision':job.op==='build'||(job.kind==='patch'&&job.cloth?.route==='build')?'out/rig':'rig');
|
|
911
|
+
const inputHash='stageInputHash' in job?job.stageInputHash??null:null;
|
|
912
|
+
if(inputHash&&await stageInputDigest(dir,spec)!==inputHash)throw new RebuildError('STAGE_DRAFT_CHANGED','scratch inputs differ before evidence settlement');
|
|
913
|
+
const now=await hashBuild(join(dir,'build'),job.id,assetPrefix);
|
|
914
|
+
if(!isDeepStrictEqual(now.files,job.build.files))throw new RebuildError('STAGE_DRAFT_CHANGED','compiled files differ before evidence settlement');
|
|
915
|
+
const body={schema:'rig-review-applied-evidence/1',binding:evidenceBinding,buildId:job.id,operation:!('kind' in job)?'regions':job.kind==='patch'?job.op:job.kind,inputHash,outputHash:sha256(JSON.stringify(now.files)),modelHash:now.modelHash,check:'check' in job?job.check:null,record:recordFor(job as AnyJobView)};
|
|
916
|
+
const text=JSON.stringify({body,digest:sha256(JSON.stringify(body))})+'\n';
|
|
917
|
+
if(Buffer.byteLength(text)>evidenceLimit)throw new RebuildError('STAGE_DRAFT_STALE','applied evidence exceeds the bounded record size');
|
|
918
|
+
const file=evidencePath(job.id);await mkdir(dirname(file),{recursive:true,mode:0o700});
|
|
919
|
+
const temporary=file+'.'+crypto.randomUUID()+'.tmp';
|
|
920
|
+
try{await writeFile(temporary,text,{mode:0o600,flag:'wx'});await rename(temporary,file);}finally{await rm(temporary,{force:true});}
|
|
921
|
+
}
|
|
922
|
+
/** A made claim names historical settled evidence, not a claim that its build is still current or on disk. */
|
|
923
|
+
async function validateApplied(value:unknown):Promise<void>{
|
|
924
|
+
if(!value||typeof value!=='object'||!('stageInputHash' in value))return;
|
|
925
|
+
const v=value as Record<string,unknown>;
|
|
926
|
+
if(!['rig-review-applied/1','rig-review-applied/3'].includes(String(v.schema))&&!(v.schema==='rig-review-applied/2'&&v.op==='remesh'))return;
|
|
927
|
+
if(typeof v.buildId!=='string'||!/^[a-f0-9]{64}$/.test(v.buildId))throw new RebuildError('STAGE_DRAFT_STALE','invalid applied identity');
|
|
928
|
+
try{
|
|
929
|
+
const file=await safeFile(await realpath(dirname(evidencePath(v.buildId))),v.buildId+'.json');
|
|
930
|
+
if((await lstat(file)).size>evidenceLimit)throw new Error('oversized evidence');
|
|
931
|
+
const seal=JSON.parse(await readFile(file,'utf8')),body=seal.body;
|
|
932
|
+
if(!body||body.schema!=='rig-review-applied-evidence/1'||seal.digest!==sha256(JSON.stringify(body))||!isDeepStrictEqual(body.binding,evidenceBinding)||body.buildId!==v.buildId||body.inputHash!==v.stageInputHash||body.modelHash!==v.modelHash||!isDeepStrictEqual(body.check,v.check)||!isDeepStrictEqual(body.record,v))throw new Error('evidence mismatch');
|
|
933
|
+
}catch{throw new RebuildError('STAGE_DRAFT_STALE','the made claim has no matching sealed applied evidence');}
|
|
934
|
+
}
|
|
867
935
|
/**
|
|
868
936
|
* #166: the line refusing an undo's re-run whose build is not the one its record names (the first differing file by
|
|
869
937
|
* hash), or null — also null for any job that is not an undo's re-run.
|
|
@@ -901,6 +969,8 @@ export function createRebuilds(p: ReviewPackage, options: RebuildOptions) {
|
|
|
901
969
|
else if (stack.at(-1)?.id !== job.id && job.build) stack.push({ id: job.id, body: bodies.get(job.id) ?? null, configHash: job.request.configHash, producer: { ...job.producer }, compiler: { ...job.compiler }, files: { ...job.build.files }, modelHash: job.build.modelHash, job: snapshot(job) });
|
|
902
970
|
latestId = stack.at(-1)?.id ?? null;
|
|
903
971
|
await arrange();
|
|
972
|
+
// Seal only after settlement succeeds; pending candidates and failed settlement have no authority.
|
|
973
|
+
await sealApplied(job);
|
|
904
974
|
}
|
|
905
975
|
async function arrange(): Promise<void> {
|
|
906
976
|
const root = rebuildRoot(options.stateDir, p.sourceHash), kept = keptRoot(options.stateDir, p.sourceHash);
|
|
@@ -990,6 +1060,7 @@ export function createRebuilds(p: ReviewPackage, options: RebuildOptions) {
|
|
|
990
1060
|
try {
|
|
991
1061
|
const stored = JSON.parse(await readFile(resultFile, 'utf8')) as J;
|
|
992
1062
|
if (stored.schema !== REBUILD_SCHEMA || stored.id !== id || stored.status !== 'built' || !stored.build) return null;
|
|
1063
|
+
if ((!('kind' in stored) || stored.kind === 'delta'||(stored.kind==='patch'&&stored.op==='remesh')) && (!Object.hasOwn(stored, 'check')||!stored.stageInputHash)) return null;
|
|
993
1064
|
const now = await hashBuild(join(dir, 'build'), id, assetPrefix);
|
|
994
1065
|
if (JSON.stringify(now.files) !== JSON.stringify(stored.build.files)) return null;
|
|
995
1066
|
const job = { ...stored, build: now, reused: true };
|
|
@@ -1057,6 +1128,7 @@ export function createRebuilds(p: ReviewPackage, options: RebuildOptions) {
|
|
|
1057
1128
|
// The package and its producer inputs must still be the bytes the request was made against.
|
|
1058
1129
|
// The handoff files are in the reviewed identity, so this also catches a config, parts or rig change.
|
|
1059
1130
|
try { await options.unchanged(); } catch { throw new RebuildError('REBUILD_INPUTS_CHANGED', 'the package or its producer handoff changed during the rebuild'); }
|
|
1131
|
+
if(!('kind' in job)||job.kind==='delta'||(job.kind==='patch'&&job.op==='remesh'))job.stageInputHash = await stageInputDigest(dir, join(dir, op.spec));
|
|
1060
1132
|
job.build = await hashBuild(join(dir, 'build'), job.id, assetPrefix);
|
|
1061
1133
|
if (steps.hashed) await steps.hashed();
|
|
1062
1134
|
// #166: an undo's re-run must reproduce the build its record names, file for file; otherwise it is refused, not guessed.
|
|
@@ -1081,6 +1153,7 @@ export function createRebuilds(p: ReviewPackage, options: RebuildOptions) {
|
|
|
1081
1153
|
|
|
1082
1154
|
/** #99: the designation's entry → `rig-parts remesh` → a scratch revision, compiled with the revision's own pack flags. */
|
|
1083
1155
|
function execute(job: RebuildJob, dir: string, inputs: ProducerInputs, resolved: Resolved, entry: string): Promise<void> {
|
|
1156
|
+
let counts:RemeshCounts|null=null;
|
|
1084
1157
|
return apply(job, dir, inputs, resolved, {
|
|
1085
1158
|
cmd: 'remesh', spec: 'revision',
|
|
1086
1159
|
async run(push) {
|
|
@@ -1091,8 +1164,14 @@ export function createRebuilds(p: ReviewPackage, options: RebuildOptions) {
|
|
|
1091
1164
|
wallMs: ms => { job.wallMs.remesh = ms; },
|
|
1092
1165
|
async flags() {
|
|
1093
1166
|
const provenance = object(JSON.parse(await readFile(join(dir, 'revision', 'remesh.json'), 'utf8')), 'remesh.json'), request = object(provenance.request, 'remesh.json request');
|
|
1167
|
+
counts = remeshCounts(provenance);
|
|
1094
1168
|
return { pageEdges: request.page_edges === 'pot' ? 'pot' : 'free', packShape: request.pack_shape === 'rect' ? 'rect' : 'polygon', note: ' (the revision\'s own pack flags)' };
|
|
1095
1169
|
},
|
|
1170
|
+
}, {
|
|
1171
|
+
check: summary => { job.check = summary; },
|
|
1172
|
+
carried: push => opCarried('remesh', join(dir, 'revision'), null, push),
|
|
1173
|
+
diff: files => {job.files=files;},
|
|
1174
|
+
hashed: async()=>{if(counts)job.remesh={...counts,modelTriangles:modelMeshTriangles(JSON.parse(await readFile(join(dir,'build/skeleton.model.json'),'utf8')),counts.part)};},
|
|
1096
1175
|
});
|
|
1097
1176
|
}
|
|
1098
1177
|
|
|
@@ -1480,6 +1559,8 @@ export function createRebuilds(p: ReviewPackage, options: RebuildOptions) {
|
|
|
1480
1559
|
return { pageEdges: request.page_edges === 'pot' ? 'pot' : 'free', packShape: request.pack_shape === 'rect' ? 'rect' : 'polygon', note: ' (remesh.json\'s pack flags)' };
|
|
1481
1560
|
},
|
|
1482
1561
|
}, {
|
|
1562
|
+
check: summary => { job.check = summary; },
|
|
1563
|
+
carried: push => opCarried('remesh', join(dir, 'rig'), null, push),
|
|
1483
1564
|
diff: files => { job.files = files; },
|
|
1484
1565
|
hashed: async () => { if (counts) job.remesh = { ...counts, modelTriangles: modelMeshTriangles(JSON.parse(await readFile(join(dir, 'build', 'skeleton.model.json'), 'utf8')), counts.part) }; },
|
|
1485
1566
|
});
|
|
@@ -1515,6 +1596,7 @@ export function createRebuilds(p: ReviewPackage, options: RebuildOptions) {
|
|
|
1515
1596
|
const reused = await reuse<DeltaJob>(dir, id);
|
|
1516
1597
|
if (reused) { jobs.set(id, reused); latestId = id; bodies.set(id, input); await landed(reused); return { status: 200, body: snapshot(reused) }; }
|
|
1517
1598
|
const job: DeltaJob = { schema: REBUILD_SCHEMA, kind: 'delta', id, status: 'running', reused: false, op: 'remesh', request: { part: request.part, delta: request.delta, deltaSha256: sha256(text), configHash: inputs.configHash }, producer: tool(resolved.producer), compiler: tool(resolved.compiler), lines: [], producerLine: null, exitCode: null, wallMs: { op: null, compile: null }, files: null, remesh: null, build: null };
|
|
1599
|
+
if (!('kind' in job) || job.kind === 'delta') job.check = null;
|
|
1518
1600
|
jobs.set(id, job); running = id; bodies.set(id, input);
|
|
1519
1601
|
void executeDelta(job, dir, inputs, resolved, text).finally(() => { if (running === id) running = null; });
|
|
1520
1602
|
return { status: 202, body: snapshot(job) };
|
|
@@ -1832,6 +1914,7 @@ export function createRebuilds(p: ReviewPackage, options: RebuildOptions) {
|
|
|
1832
1914
|
const reused = await reuse(dir, id);
|
|
1833
1915
|
if (reused) { jobs.set(id, reused); latestId = id; bodies.set(id, input); await landed(reused); return { status: 200, body: snapshot(reused) }; }
|
|
1834
1916
|
const job: RebuildJob = { schema: REBUILD_SCHEMA, id, status: 'running', reused: false, request: { ...request, entrySha256: sha256(entry) }, producer: tool(resolved.producer), compiler: tool(resolved.compiler), lines: [], producerLine: null, exitCode: null, wallMs: { remesh: null, compile: null }, build: null };
|
|
1917
|
+
if (!('kind' in job) || job.kind === 'delta') job.check = null;
|
|
1835
1918
|
jobs.set(id, job); running = id; bodies.set(id, input);
|
|
1836
1919
|
void execute(job, dir, inputs, resolved, entry).finally(() => { if (running === id) running = null; });
|
|
1837
1920
|
return { status: 202, body: snapshot(job) };
|
|
@@ -1853,5 +1936,5 @@ export function createRebuilds(p: ReviewPackage, options: RebuildOptions) {
|
|
|
1853
1936
|
return safeFile(await realpath(join(rebuildDir(options.stateDir, p.sourceHash, id), 'build')), packagePath(name));
|
|
1854
1937
|
}
|
|
1855
1938
|
|
|
1856
|
-
return { describe, start, read, file, running: () => running, busy: () => busy() !== null, baseline: settledBaseline, inspectedCheck: settledInspectedCheck, latest, undo, history, startStrip, readStrip, stripJob, closeStrip, stripFile };
|
|
1939
|
+
return { describe, start, read, file, running: () => running, busy: () => busy() !== null, baseline: settledBaseline, inspectedCheck: settledInspectedCheck, latest, stageDraft, validateApplied, undo, history, startStrip, readStrip, stripJob, closeStrip, stripFile };
|
|
1857
1940
|
}
|
package/src/retune-check.ts
CHANGED
|
@@ -40,7 +40,7 @@ export const provenanceFile = (op: CarryingOp): string => FILE[op];
|
|
|
40
40
|
const isObject = (v: unknown): v is Record<string, unknown> => !!v && typeof v === 'object' && !Array.isArray(v);
|
|
41
41
|
/** check.json's bar keys as review's `checkSummary` reads them: an upper-case name. */
|
|
42
42
|
const BAR = /^[A-Z][A-Z0-9_]+$/;
|
|
43
|
-
const STATUSES = new Set(['PASS', 'FAIL', 'SKIP', 'WARN', 'CLEAR', 'REPORTED']);
|
|
43
|
+
const STATUSES = new Set(['PASS', 'FAIL', 'SKIP', 'WARN', 'CLEAR', 'REPORTED', 'UNCLASSIFIED']);
|
|
44
44
|
|
|
45
45
|
export interface RetuneRevisionRow { path: string; bytes: number; sha256: string }
|
|
46
46
|
export interface CarriedCheck { pass: boolean; line: string; status: Record<string, string> }
|
package/src/server.ts
CHANGED
|
@@ -32,11 +32,11 @@ async function bodyJson(req:Request,limit=1024*1024,what='Session payload exceed
|
|
|
32
32
|
/** `capability` (open workers and foreground CLI serving) gates every non-GET request; tests may omit it.
|
|
33
33
|
* `cwd` is where the producer is looked for after the package's own directories (review's working directory by default). */
|
|
34
34
|
export async function startServer(p:ReviewPackage,options:{port?:number;stateDir?:string;open?:OpenIdentity;initialAnimation?:string;activity?:()=>void;control?:ControlIdentity;capability?:string;cwd?:string;stripConcurrency?:number;graceMs?:number;unopenedTimeoutMs?:number;exitOnClose?:boolean;onClose?:(info:LiveExitInfo)=>void|Promise<void>;log?:(line:string)=>void;viewOnly?:boolean}={}){
|
|
35
|
-
const stageParts=stagePartsRoutes({single:p});
|
|
36
35
|
const bundle=await buildWeb();
|
|
37
36
|
const unchanged=()=>assertReviewUnchanged(p);
|
|
38
37
|
const stateDir=options.stateDir??process.env.RIG_REVIEW_STATE_DIR??join(homedir(),'.local','state','rig-c-review'),starts=[p.root,options.cwd??process.cwd()];
|
|
39
38
|
const rebuilds=createRebuilds(p,{stateDir,starts,unchanged,bones:p.feedbackCatalog.bones,...(options.stripConcurrency?{stripConcurrency:options.stripConcurrency}:{}),...(options.viewOnly??p.viewOnly?{viewOnly:true}:{})});
|
|
39
|
+
const stageParts=stagePartsRoutes({single:p},undefined,rebuilds.stageDraft);
|
|
40
40
|
// Readings (#108): rigc render's readings on the inspected build and on the latest scratch build, into scratch.
|
|
41
41
|
const readings=createReadings(p,{stateDir,starts,unchanged,latest:rebuilds.latest});
|
|
42
42
|
// Bones check (#109): propose --from-config and compare on a scratch copy of the patched handoff config.
|
|
@@ -74,7 +74,9 @@ export async function startServer(p:ReviewPackage,options:{port?:number;stateDir
|
|
|
74
74
|
options.activity?.();const gate=openGate(req,options.open);if(gate){if(gate.status===200){try{await unchanged();}catch{return staleOpenStatus(options.open!);}if(!live.rearmUnopened())return json({error:'Server is closing'},503);}return gate;}
|
|
75
75
|
if(req.method==='PUT'&&url.pathname==='/api/session'){
|
|
76
76
|
if(req.headers.get('origin')!==origin)return json({error:'Same-origin Origin required'},403);
|
|
77
|
-
const input=await bodyJson(req);await unchanged();
|
|
77
|
+
const input=await bodyJson(req);await unchanged();
|
|
78
|
+
if(input&&typeof input==='object'&&Array.isArray((input as any).feedback))for(const feedback of (input as any).feedback)await rebuilds.validateApplied(feedback?.context?.applied);
|
|
79
|
+
return json(await saveSession(p,input,options.stateDir));
|
|
78
80
|
}
|
|
79
81
|
// Apply · Rebuild (#99 regions, #102 {patch}): typed data, never a path; the server runs the installed producer into scratch.
|
|
80
82
|
if(req.method==='POST'&&url.pathname==='/api/rebuild'){
|
package/src/stage-parts.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/** Read-only embedding of the existing atlas inspector. No browser-supplied filesystem paths or verdict writes. */
|
|
2
|
+
import {join} from 'node:path';
|
|
2
3
|
import {readFile} from 'node:fs/promises';
|
|
3
4
|
import {appRoot,buildWeb} from './build.ts';
|
|
4
5
|
import type {ReviewPackage} from './manifest.ts';
|
|
5
|
-
import {loadPartsAtlas,assertPartsUnchanged,partsViewJson,servedImage} from './parts-view.ts';
|
|
6
|
+
import {loadPartsAtlas,loadPartsView,assertPartsUnchanged,partsViewJson,servedImage,type PartsViewPackage} from './parts-view.ts';
|
|
6
7
|
import {serveReference,assertReviewUnchanged} from './reference.ts';
|
|
7
|
-
export function stagePartsRoutes(packages:{single:ReviewPackage}|{a:ReviewPackage;b:ReviewPackage},loadAtlas:typeof loadPartsAtlas=loadPartsAtlas) {
|
|
8
|
+
export function stagePartsRoutes(packages:{single:ReviewPackage}|{a:ReviewPackage;b:ReviewPackage},loadAtlas:typeof loadPartsAtlas=loadPartsAtlas,draft?:DraftReader) {
|
|
9
|
+
const corrections=new Map<string,Promise<{pkg:PartsViewPackage;metadata:unknown}>>();
|
|
8
10
|
const loaded=new Map<string,ReturnType<typeof loadPartsAtlas>>();let bundle:Promise<Blob>|undefined;
|
|
9
11
|
const headers={'X-Content-Type-Options':'nosniff','Cache-Control':'no-store','Referrer-Policy':'no-referrer','Content-Security-Policy':"default-src 'none'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' blob: data:; connect-src 'self'; base-uri 'none'; form-action 'none'; frame-ancestors 'self'"};
|
|
10
12
|
return async(req:Request):Promise<Response|null>=>{
|
|
@@ -19,6 +21,31 @@ export function stagePartsRoutes(packages:{single:ReviewPackage}|{a:ReviewPackag
|
|
|
19
21
|
const key='single' in packages?'single':match[1] as 'a'|'b',p='single' in packages?packages.single:packages[key as 'a'|'b'];
|
|
20
22
|
const kind=match['single' in packages?1:2] as 'image'|'page'|undefined,index=match['single' in packages?2:3];
|
|
21
23
|
try{
|
|
24
|
+
// Single-package Stage 1 uses the declared handoff's real separated parts, not the atlas names.
|
|
25
|
+
if ('single' in packages && p.handoff?.parts && p.handoff.rig) {
|
|
26
|
+
await assertReviewUnchanged(p);
|
|
27
|
+
const build=req.headers.get('X-Review-Stage-Build')??'inspected';
|
|
28
|
+
if(build!=='inspected'&&!/^[a-f0-9]{64}$/.test(build))throw new Error('STAGE_DRAFT_STALE');
|
|
29
|
+
const applied=build==='inspected'?null:await draft?.(build);
|
|
30
|
+
if(build!=='inspected'&&!applied)throw new Error('STAGE_DRAFT_UNAVAILABLE');
|
|
31
|
+
const model=applied?.model??(p.manifest.model?join(p.root,p.manifest.model):null);
|
|
32
|
+
if(!model)throw new Error('STAGE_DRAFT_UNAVAILABLE');
|
|
33
|
+
let promise=corrections.get(build);
|
|
34
|
+
if(!promise){
|
|
35
|
+
promise=(async()=>{
|
|
36
|
+
const rig=join(applied?.spec??p.handoff!.rig!,'rig.json');
|
|
37
|
+
const pkg=await loadPartsView(p.handoff!.parts!,{rig,meshReport:join(applied?.spec??p.handoff!.rig!,'mesh_report.json')});
|
|
38
|
+
const mappings=await draftMappings(model,rig,pkg);
|
|
39
|
+
await assertReviewUnchanged(p);await assertPartsUnchanged(pkg);
|
|
40
|
+
return {pkg,metadata:mappings.length?{label:'Draft rig · structure evidence only',buildId:build,inspectionSourceHash:p.sourceHash,mappings,evidence:applied?.evidence??null}:null};
|
|
41
|
+
})();corrections.set(build,promise);
|
|
42
|
+
}
|
|
43
|
+
const {pkg,metadata}=await promise;
|
|
44
|
+
// Every image is served against the same full pinned draft, including geometry and flags.
|
|
45
|
+
await assertReviewUnchanged(p);await assertPartsUnchanged(pkg);
|
|
46
|
+
if(kind){const file=servedImage(pkg,kind,Number(index));if(!file)return Response.json({error:'PARTS_IMAGE_UNAVAILABLE'},{status:404,headers});const pinned=pkg.files.find(f=>f.abs===file)!;return serveReference(req,file,pinned.sha256,headers);}
|
|
47
|
+
return Response.json({...partsViewJson(pkg,{verdict:null,stale:null}),differenceAvailable:false,readOnly:true,inspectionSourceHash:p.sourceHash,...(metadata?{draft:metadata}:{draftUnavailable:stageDraftRefusals.STAGE_DRAFT_NO_MESH})},{headers});
|
|
48
|
+
}
|
|
22
49
|
let promise=loaded.get(key);
|
|
23
50
|
const initializing=!promise;
|
|
24
51
|
if(!promise){
|
|
@@ -31,7 +58,57 @@ export function stagePartsRoutes(packages:{single:ReviewPackage}|{a:ReviewPackag
|
|
|
31
58
|
if(!kind&&!initializing){await assertReviewUnchanged(p);await assertPartsUnchanged(pkg);}
|
|
32
59
|
if(kind){const model=pkg.files[0]!;await serveReference(new Request(req.url,{method:'HEAD'}),model.abs,model.sha256,headers);}
|
|
33
60
|
if(kind){const file=servedImage(pkg,kind,Number(index));if(!file)return Response.json({error:'PARTS_IMAGE_UNAVAILABLE'},{status:404,headers});const pinned=pkg.files.find(f=>f.abs===file);if(!pinned)throw new Error('Unbound atlas page');return await serveReference(req,file,pinned.sha256,headers);}
|
|
34
|
-
return Response.json({...partsViewJson(pkg,{verdict:null,stale:null}),readOnly:true,inspectionSourceHash:p.sourceHash},{headers});
|
|
35
|
-
}catch{return Response.json({error:'PARTS_ATLAS_UNAVAILABLE: the inspected package has no usable atlas or its source changed.'},{status:409,headers});}
|
|
61
|
+
return Response.json({...partsViewJson(pkg,{verdict:null,stale:null}),differenceAvailable:false,readOnly:true,inspectionSourceHash:p.sourceHash,draftUnavailable:stageDraftRefusals.STAGE_DRAFT_UNAVAILABLE},{headers});
|
|
62
|
+
}catch(error){const code=error instanceof Error?error.message.split(':')[0]:'';const named=stageDraftRefusals[code??'']??(code==='PARTS_MESH_IMAGE_MISMATCH'?stageDraftRefusals.STAGE_DRAFT_MISMATCH:undefined);return Response.json({error:named??'PARTS_ATLAS_UNAVAILABLE: the inspected package has no usable atlas or its source changed.'},{status:409,headers});}
|
|
36
63
|
};
|
|
37
64
|
}
|
|
65
|
+
|
|
66
|
+
export interface DraftSnapshot {id:string;spec:string;model:string;evidence:unknown}
|
|
67
|
+
export type DraftReader=(id:string)=>Promise<DraftSnapshot>;
|
|
68
|
+
/** Closed public refusals; never send paths or producer output through the managed-front error channel. */
|
|
69
|
+
export const stageDraftRefusals:Record<string,string>={
|
|
70
|
+
STAGE_DRAFT_GEOMETRY_UNSUPPORTED:'STAGE_DRAFT_GEOMETRY_UNSUPPORTED: raw indexed vertex geometry is unavailable in this draft connection.',
|
|
71
|
+
STAGE_DRAFT_UNAVAILABLE:'STAGE_DRAFT_UNAVAILABLE: no producer-compatible draft is supplied.',
|
|
72
|
+
STAGE_DRAFT_NO_MESH:'STAGE_DRAFT_NO_MESH: this part has no mesh attachment; direct correction is unavailable.',
|
|
73
|
+
STAGE_DRAFT_MISMATCH:'STAGE_DRAFT_MISMATCH: separated parts and draft mesh identity differ.',
|
|
74
|
+
STAGE_DRAFT_STALE:'STAGE_DRAFT_STALE: the requested revision is pending or no longer applied.',
|
|
75
|
+
STAGE_DRAFT_CHANGED:'STAGE_DRAFT_CHANGED: scratch inputs changed after Apply.',
|
|
76
|
+
STAGE_DRAFT_UNCHECKED:'STAGE_DRAFT_UNCHECKED: this revision has no successful producer check.',
|
|
77
|
+
STAGE_DRAFT_OPERATION:'STAGE_DRAFT_OPERATION: this applied operation is not a mesh correction.',
|
|
78
|
+
};
|
|
79
|
+
/** Same names alone cannot bind a producer operation: exact skin/slot/attachment, raster crop and mesh arrays must agree.
|
|
80
|
+
* Compiler UV decimals round-trip float32; compare the represented float32 values exactly, with no numeric tolerance.
|
|
81
|
+
*/
|
|
82
|
+
async function draftMappings(modelPath:string,rigPath:string,pkg:PartsViewPackage){
|
|
83
|
+
const model=JSON.parse(await readFile(modelPath,'utf8')),rig=JSON.parse(await readFile(rigPath,'utf8'));
|
|
84
|
+
const mappings:{part:string;skin:string;slot:string;attachment:string;vertices:number;triangles:number}[]=[];
|
|
85
|
+
for(const item of pkg.items){
|
|
86
|
+
if(!item.mesh)continue;
|
|
87
|
+
for(const [key,count]of [['vertices',item.mesh.vertices.length/2],['triangles',item.mesh.triangles.length/3]]as const)if(Object.hasOwn(item.mesh.figures,key)&&item.mesh.figures[key]!==count)throw new Error('STAGE_DRAFT_MISMATCH');
|
|
88
|
+
const candidates=[];
|
|
89
|
+
for(const [skin,slots]of Object.entries(rig.skins??{}))for(const [slot,attachments]of Object.entries(slots as Record<string,unknown>)){
|
|
90
|
+
const a=(attachments as Record<string,any>)[item.name];if(a?.type!=='mesh')continue;
|
|
91
|
+
const b=(model.skins as any[])?.find(s=>s.name===skin)?.attachments?.[slot]?.[item.name];
|
|
92
|
+
if(!b||b.kind!=='mesh'||b.width!==a.width||b.height!==a.height||JSON.stringify(b.uvs?.map(Math.fround))!==JSON.stringify(a.uvs.map(Math.fround))||JSON.stringify(b.triangles)!==JSON.stringify(a.triangles))throw new Error('STAGE_DRAFT_MISMATCH');
|
|
93
|
+
if(!matchingVertexGeometry(a,b))throw new Error('STAGE_DRAFT_MISMATCH');
|
|
94
|
+
candidates.push({part:item.name,skin,slot,attachment:item.name,vertices:a.uvs.length/2,triangles:a.triangles.length/3});
|
|
95
|
+
}
|
|
96
|
+
if(candidates.length!==1)throw new Error('STAGE_DRAFT_MISMATCH');
|
|
97
|
+
mappings.push(candidates[0]!);
|
|
98
|
+
}
|
|
99
|
+
return mappings;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** Compare authored components in the compiler's representation; no posing, meshing or weight judgment. */
|
|
103
|
+
function matchingVertexGeometry(a:Record<string,any>,b:Record<string,any>):boolean {
|
|
104
|
+
const equalNumbers=(a:unknown,b:unknown)=>Array.isArray(a)&&Array.isArray(b)&&a.length===b.length&&a.every((v,i)=>typeof v==='number'&&typeof b[i]==='number'&&Math.fround(v)===Math.fround(b[i]));
|
|
105
|
+
if(Array.isArray(a.weights)){
|
|
106
|
+
if(a.weights.length!==a.uvs.length/2||b.vertices?.weighted!==true||!Array.isArray(b.vertices.bindings)||a.weights.length!==b.vertices.bindings.length)return false;
|
|
107
|
+
return a.weights.every((row:unknown,i:number)=>Array.isArray(row)&&Array.isArray(b.vertices.bindings[i])&&row.length>0&&row.length===b.vertices.bindings[i].length&&row.every((v:unknown,j:number)=>{
|
|
108
|
+
const x=v as Record<string,unknown>,y=b.vertices.bindings[i][j];
|
|
109
|
+
return x&&y&&x.bone===y.bone&&equalNumbers([x.x,x.y,x.weight],[y.x,y.y,y.weight]);
|
|
110
|
+
}));
|
|
111
|
+
}
|
|
112
|
+
if(Array.isArray(a.vertices)&&a.vertices.length===a.uvs.length)return b.vertices?.weighted===false&&equalNumbers(a.vertices,b.vertices.xy);
|
|
113
|
+
throw new Error('STAGE_DRAFT_GEOMETRY_UNSUPPORTED');
|
|
114
|
+
}
|
package/web/catalog-en.ts
CHANGED
|
@@ -1,4 +1,42 @@
|
|
|
1
1
|
export const enCatalog: Readonly<Record<string, string>> = {
|
|
2
|
+
"PARTS_DIFFERENCE_PROVENANCE: declared path, lowercase SHA-256 and lanczos3-rgb-opaque required": "PARTS_DIFFERENCE_PROVENANCE: declared path, lowercase SHA-256 and lanczos3-rgb-opaque required",
|
|
3
|
+
"PARTS_DIFFERENCE_PATH: literal portable inside-package path required": "PARTS_DIFFERENCE_PATH: literal portable inside-package path required",
|
|
4
|
+
"PARTS_DIFFERENCE_PATH: declared painting must be readable inside the package": "PARTS_DIFFERENCE_PATH: declared painting must be readable inside the package",
|
|
5
|
+
"PARTS_DIFFERENCE_HASH: declared painting hash differs": "PARTS_DIFFERENCE_HASH: declared painting hash differs",
|
|
6
|
+
"PARTS_DIFFERENCE_PNG: declared painting must be RGBA8 PNG": "PARTS_DIFFERENCE_PNG: declared painting must be RGBA8 PNG",
|
|
7
|
+
"PARTS_DIFFERENCE_SIZE: declared painting dimensions must equal integer rig_size": "PARTS_DIFFERENCE_SIZE: declared painting dimensions must equal integer rig_size",
|
|
8
|
+
"PARTS_DIFFERENCE_ALPHA: declared painting must have alpha 255": "PARTS_DIFFERENCE_ALPHA: declared painting must have alpha 255",
|
|
9
|
+
"PARTS_DIFFERENCE_UNAVAILABLE: declared painting_in_rig required": "PARTS_DIFFERENCE_UNAVAILABLE: declared painting_in_rig required",
|
|
10
|
+
"PARTS_DIFFERENCE_UNAVAILABLE: declared painting_in_rig required; legacy records remain readable": "PARTS_DIFFERENCE_UNAVAILABLE: declared painting_in_rig required; legacy records remain readable",
|
|
11
|
+
"PARTS_DIFFERENCE_UNAVAILABLE: known original part required": "PARTS_DIFFERENCE_UNAVAILABLE: known original part required",
|
|
12
|
+
"PARTS_DIFFERENCE_PNG: exact RGBA8 operands required": "PARTS_DIFFERENCE_PNG: exact RGBA8 operands required",
|
|
13
|
+
"PARTS_DIFFERENCE_ALIGNMENT: integer native placement and exact PNG dimensions required": "PARTS_DIFFERENCE_ALIGNMENT: integer native placement and exact PNG dimensions required",
|
|
14
|
+
"PARTS_DIFFERENCE_ALIGNMENT: nontransparent part pixel lies outside declared rig grid": "PARTS_DIFFERENCE_ALIGNMENT: nontransparent part pixel lies outside declared rig grid",
|
|
15
|
+
"PARTS_COMPARISON_INVALID: part/overlay with opacity 0..1, or difference with integer threshold 0..255 required": "PARTS_COMPARISON_INVALID: part/overlay with opacity 0..1, or difference with integer threshold 0..255 required",
|
|
16
|
+
"PARTS_COMPARISON_INVALID: integer threshold 0..255 required": "PARTS_COMPARISON_INVALID: integer threshold 0..255 required",
|
|
17
|
+
"PARTS_COMPARISON_INVALID: threshold and footprints required": "PARTS_COMPARISON_INVALID: threshold and footprints required",
|
|
18
|
+
"PARTS_VIEW_SOURCE_CHANGED: declared painting path changed": "PARTS_VIEW_SOURCE_CHANGED: declared painting path changed",
|
|
19
|
+
"PARTS_COMPARISON_INVALID: enter an integer threshold from 0 to 255. Last valid value restored.": "PARTS_COMPARISON_INVALID: enter an integer threshold from 0 to 255. Last valid value restored.",
|
|
20
|
+
"Difference": "Difference",
|
|
21
|
+
"Threshold": "Threshold",
|
|
22
|
+
"PARTS_DIFFERENCE_UNAVAILABLE: declared painting_in_rig and individual part view required.": "PARTS_DIFFERENCE_UNAVAILABLE: declared painting_in_rig and individual part view required.",
|
|
23
|
+
"Difference: {count} pixels above threshold · {covered} covered pixels excluded · visual comparison, no automatic verdict.": "Difference: {count} pixels above threshold · {covered} covered pixels excluded · visual comparison, no automatic verdict.",
|
|
24
|
+
|
|
25
|
+
"STAGE_DRAFT_GEOMETRY_UNSUPPORTED: raw indexed vertex geometry is unavailable in this draft connection.": "STAGE_DRAFT_GEOMETRY_UNSUPPORTED: raw indexed vertex geometry is unavailable in this draft connection.",
|
|
26
|
+
"rig-parts remesh --mesh": "rig-parts remesh --mesh",
|
|
27
|
+
"rig-parts remesh --delta": "rig-parts remesh --delta",
|
|
28
|
+
" \u00b7 {0} \u00b7 rig-parts remesh {1}": " \u00b7 {0} \u00b7 rig-parts remesh {1}",
|
|
29
|
+
"Draft rig · structure evidence only": "Draft rig · structure evidence only",
|
|
30
|
+
"Mesh parameters": "Mesh parameters",
|
|
31
|
+
"Correction-record export unavailable: waiting for the shared correction contract.": "Correction-record export unavailable: waiting for the shared correction contract.",
|
|
32
|
+
"REBUILD_PART_NOT_CONTOUR: {0}": "REBUILD_PART_NOT_CONTOUR: {0}",
|
|
33
|
+
"STAGE_DRAFT_NO_MESH: this part has no mesh attachment; direct correction is unavailable.": "STAGE_DRAFT_NO_MESH: this part has no mesh attachment; direct correction is unavailable.",
|
|
34
|
+
"STAGE_DRAFT_UNAVAILABLE: no producer-compatible draft is supplied.": "STAGE_DRAFT_UNAVAILABLE: no producer-compatible draft is supplied.",
|
|
35
|
+
"STAGE_DRAFT_MISMATCH: separated parts and draft mesh identity differ.": "STAGE_DRAFT_MISMATCH: separated parts and draft mesh identity differ.",
|
|
36
|
+
"STAGE_DRAFT_STALE: the requested revision is pending or no longer applied.": "STAGE_DRAFT_STALE: the requested revision is pending or no longer applied.",
|
|
37
|
+
"STAGE_DRAFT_CHANGED: scratch inputs changed after Apply.": "STAGE_DRAFT_CHANGED: scratch inputs changed after Apply.",
|
|
38
|
+
"STAGE_DRAFT_UNCHECKED: this revision has no successful producer check.": "STAGE_DRAFT_UNCHECKED: this revision has no successful producer check.",
|
|
39
|
+
"STAGE_DRAFT_OPERATION: this applied operation is not a mesh correction.": "STAGE_DRAFT_OPERATION: this applied operation is not a mesh correction.",
|
|
2
40
|
"Approve all": "Approve all",
|
|
3
41
|
"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.",
|
|
4
42
|
"Atlas source build": "Atlas source build",
|
|
@@ -2358,7 +2396,6 @@ export const enCatalog: Readonly<Record<string, string>> = {
|
|
|
2358
2396
|
"rig-parts propose --cloth --write-config (entry by entry)": "rig-parts propose --cloth --write-config (entry by entry)",
|
|
2359
2397
|
"rig-parts propose exited {0}": "rig-parts propose exited {0}",
|
|
2360
2398
|
"rig-parts propose exited {0} without a named refusal": "rig-parts propose exited {0} without a named refusal",
|
|
2361
|
-
"rig-parts remesh --delta": "rig-parts remesh --delta",
|
|
2362
2399
|
"rig-parts rig --config config.json": "rig-parts rig --config config.json",
|
|
2363
2400
|
"rig-pose-sequence/1: each person needs a unique id and joints": "rig-pose-sequence/1: each person needs a unique id and joints",
|
|
2364
2401
|
"rig-pose-sequence/1: expected picture-px, top-left, y-down and nonempty frames": "rig-pose-sequence/1: expected picture-px, top-left, y-down and nonempty frames",
|
package/web/catalog-ko.ts
CHANGED
|
@@ -1,4 +1,42 @@
|
|
|
1
1
|
export const koCatalog: Readonly<Record<string, string>> = {
|
|
2
|
+
"PARTS_DIFFERENCE_PROVENANCE: declared path, lowercase SHA-256 and lanczos3-rgb-opaque required": "PARTS_DIFFERENCE_PROVENANCE: 선언된 경로, 소문자 SHA-256, lanczos3-rgb-opaque가 필요해요.",
|
|
3
|
+
"PARTS_DIFFERENCE_PATH: literal portable inside-package path required": "PARTS_DIFFERENCE_PATH: 패키지 안의 이식 가능한 리터럴 경로가 필요해요.",
|
|
4
|
+
"PARTS_DIFFERENCE_PATH: declared painting must be readable inside the package": "PARTS_DIFFERENCE_PATH: 선언된 원화를 패키지 안에서 읽을 수 있어야 해요.",
|
|
5
|
+
"PARTS_DIFFERENCE_HASH: declared painting hash differs": "PARTS_DIFFERENCE_HASH: 원화의 해시가 선언된 값과 달라요.",
|
|
6
|
+
"PARTS_DIFFERENCE_PNG: declared painting must be RGBA8 PNG": "PARTS_DIFFERENCE_PNG: 선언된 원화는 RGBA8 PNG여야 해요.",
|
|
7
|
+
"PARTS_DIFFERENCE_SIZE: declared painting dimensions must equal integer rig_size": "PARTS_DIFFERENCE_SIZE: 선언된 원화의 크기가 정수 rig_size와 같아야 해요.",
|
|
8
|
+
"PARTS_DIFFERENCE_ALPHA: declared painting must have alpha 255": "PARTS_DIFFERENCE_ALPHA: 선언된 원화의 모든 픽셀은 알파가 255여야 해요.",
|
|
9
|
+
"PARTS_DIFFERENCE_UNAVAILABLE: declared painting_in_rig required": "PARTS_DIFFERENCE_UNAVAILABLE: 선언된 painting_in_rig가 필요해요.",
|
|
10
|
+
"PARTS_DIFFERENCE_UNAVAILABLE: declared painting_in_rig required; legacy records remain readable": "PARTS_DIFFERENCE_UNAVAILABLE: 차이 비교에는 선언된 painting_in_rig가 필요해요. 이전 기록은 계속 열 수 있어요.",
|
|
11
|
+
"PARTS_DIFFERENCE_UNAVAILABLE: known original part required": "PARTS_DIFFERENCE_UNAVAILABLE: 패키지에 등록된 원본 파트가 필요해요.",
|
|
12
|
+
"PARTS_DIFFERENCE_PNG: exact RGBA8 operands required": "PARTS_DIFFERENCE_PNG: 비교에 쓰는 이미지는 RGBA8이어야 해요.",
|
|
13
|
+
"PARTS_DIFFERENCE_ALIGNMENT: integer native placement and exact PNG dimensions required": "PARTS_DIFFERENCE_ALIGNMENT: 원본 배치 좌표가 정수이고 PNG 크기가 선언된 크기와 정확히 같아야 해요.",
|
|
14
|
+
"PARTS_DIFFERENCE_ALIGNMENT: nontransparent part pixel lies outside declared rig grid": "PARTS_DIFFERENCE_ALIGNMENT: 파트의 알파가 0보다 큰 픽셀이 선언된 리그 격자 밖에 있어요.",
|
|
15
|
+
"PARTS_COMPARISON_INVALID: part/overlay with opacity 0..1, or difference with integer threshold 0..255 required": "PARTS_COMPARISON_INVALID: 파트 또는 오버레이의 불투명도는 0~1이어야 하고, 차이 비교의 임계값은 0~255 사이 정수여야 해요.",
|
|
16
|
+
"PARTS_COMPARISON_INVALID: integer threshold 0..255 required": "PARTS_COMPARISON_INVALID: 0~255 사이의 정수 임계값이 필요해요.",
|
|
17
|
+
"PARTS_COMPARISON_INVALID: threshold and footprints required": "PARTS_COMPARISON_INVALID: 임계값과 앞 파츠 풋프린트 설정이 필요해요.",
|
|
18
|
+
"PARTS_VIEW_SOURCE_CHANGED: declared painting path changed": "PARTS_VIEW_SOURCE_CHANGED: 선언된 원화 경로가 바뀌었어요.",
|
|
19
|
+
"PARTS_COMPARISON_INVALID: enter an integer threshold from 0 to 255. Last valid value restored.": "PARTS_COMPARISON_INVALID: 0~255 사이의 정수 임계값을 입력해 주세요. 마지막 유효한 값으로 복원했어요.",
|
|
20
|
+
"Difference": "차이",
|
|
21
|
+
"Threshold": "임계값",
|
|
22
|
+
"PARTS_DIFFERENCE_UNAVAILABLE: declared painting_in_rig and individual part view required.": "PARTS_DIFFERENCE_UNAVAILABLE: 선언된 painting_in_rig와 개별 파트 보기가 필요해요.",
|
|
23
|
+
"Difference: {count} pixels above threshold · {covered} covered pixels excluded · visual comparison, no automatic verdict.": "차이: 임계값 초과 {count}픽셀 · 가려진 {covered}픽셀 제외 · 시각적 비교이며 자동 판정이 아니에요.",
|
|
24
|
+
|
|
25
|
+
"STAGE_DRAFT_GEOMETRY_UNSUPPORTED: raw indexed vertex geometry is unavailable in this draft connection.": "STAGE_DRAFT_GEOMETRY_UNSUPPORTED: 이 초안 연결은 원시 인덱스 정점 형상을 지원하지 않아요.",
|
|
26
|
+
"rig-parts remesh --mesh": "rig-parts remesh --mesh",
|
|
27
|
+
"rig-parts remesh --delta": "rig-parts remesh --delta",
|
|
28
|
+
" \u00b7 {0} \u00b7 rig-parts remesh {1}": " \u00b7 {0} \u00b7 rig-parts remesh {1}",
|
|
29
|
+
"Draft rig · structure evidence only": "초안 리그 · 구조 확인 근거만 제공",
|
|
30
|
+
"Mesh parameters": "메시 매개변수",
|
|
31
|
+
"Correction-record export unavailable: waiting for the shared correction contract.": "보정 기록 내보내기 불가: 공통 보정 계약을 기다리고 있어요.",
|
|
32
|
+
"REBUILD_PART_NOT_CONTOUR: {0}": "REBUILD_PART_NOT_CONTOUR: {0} (컨투어 메시가 아님)",
|
|
33
|
+
"STAGE_DRAFT_NO_MESH: this part has no mesh attachment; direct correction is unavailable.": "STAGE_DRAFT_NO_MESH: 이 파츠에는 메시 부착물이 없어 직접 수정할 수 없습니다.",
|
|
34
|
+
"STAGE_DRAFT_UNAVAILABLE: no producer-compatible draft is supplied.": "STAGE_DRAFT_UNAVAILABLE: 제작기와 호환되는 초안이 제공되지 않았어요.",
|
|
35
|
+
"STAGE_DRAFT_MISMATCH: separated parts and draft mesh identity differ.": "STAGE_DRAFT_MISMATCH: 분리 파츠와 초안 메시의 식별 정보가 달라요.",
|
|
36
|
+
"STAGE_DRAFT_STALE: the requested revision is pending or no longer applied.": "STAGE_DRAFT_STALE: 요청한 리비전이 대기 중이거나 더 이상 적용 상태가 아니에요.",
|
|
37
|
+
"STAGE_DRAFT_CHANGED: scratch inputs changed after Apply.": "STAGE_DRAFT_CHANGED: 적용 후 작업 사본의 입력이 변경됐어요.",
|
|
38
|
+
"STAGE_DRAFT_UNCHECKED: this revision has no successful producer check.": "STAGE_DRAFT_UNCHECKED: 이 리비전에는 성공한 제작기 검사 근거가 없어요.",
|
|
39
|
+
"STAGE_DRAFT_OPERATION: this applied operation is not a mesh correction.": "STAGE_DRAFT_OPERATION: 적용된 작업이 메시 보정이 아니에요.",
|
|
2
40
|
"Approve all": "모두 승인",
|
|
3
41
|
"PARTS_APPROVE_ALL_FLAGGED: resolve flagged part and mesh outcomes before approving all.": "PARTS_APPROVE_ALL_FLAGGED: 모두 승인하기 전에 파츠와 메시의 문제 표시를 해결해 주세요.",
|
|
4
42
|
"Atlas source build": "아틀라스 소스 빌드",
|
|
@@ -2358,7 +2396,6 @@ export const koCatalog: Readonly<Record<string, string>> = {
|
|
|
2358
2396
|
"rig-parts propose --cloth --write-config (entry by entry)": "rig-parts propose --cloth --write-config (항목별)",
|
|
2359
2397
|
"rig-parts propose exited {0}": "rig-parts propose가 종료 코드 {0}(으)로 종료됨",
|
|
2360
2398
|
"rig-parts propose exited {0} without a named refusal": "rig-parts propose가 지정된 거부 사유 없이 종료 코드 {0}(으)로 종료됨",
|
|
2361
|
-
"rig-parts remesh --delta": "rig-parts remesh --delta",
|
|
2362
2399
|
"rig-parts rig --config config.json": "rig-parts rig --config config.json",
|
|
2363
2400
|
"rig-pose-sequence/1: each person needs a unique id and joints": "rig-pose-sequence/1: 각 인물에는 고유 ID와 관절이 필요합니다",
|
|
2364
2401
|
"rig-pose-sequence/1: expected picture-px, top-left, y-down and nonempty frames": "rig-pose-sequence/1: picture-px, top-left, y-down 및 비어 있지 않은 프레임이 필요합니다",
|
package/web/chest-editor.ts
CHANGED
|
@@ -214,6 +214,8 @@ export interface ChestEditor {active:()=>boolean;flashing:(side:BustSide)=>boole
|
|
|
214
214
|
mode:()=>ChestMode;
|
|
215
215
|
/** The landmark fields read as the producer's entry and derivation (Landmarks mode). */
|
|
216
216
|
landmarks:()=>LandmarkRead;
|
|
217
|
+
/** A different part has its own designation and no pointer gesture from the previous part. */
|
|
218
|
+
rebind:()=>void;
|
|
217
219
|
/** The point the next click places, for the overlay's highlight. */
|
|
218
220
|
armed:()=>LandmarkKey|null;
|
|
219
221
|
/** Hold a status line (null clears it); `log` is the producer's latest lines. */
|
|
@@ -365,6 +367,7 @@ export function bindChestEditor(host:ChestEditorHost):ChestEditor {
|
|
|
365
367
|
sync();
|
|
366
368
|
return {
|
|
367
369
|
active:()=>active,flashing:side=>flash.has(side),sync,mode,landmarks:()=>readLandmarks(read),armed:()=>{const l=readLandmarks(read);return nextLandmark(armed,'missing' in l?l.missing:[]);},
|
|
370
|
+
rebind:()=>{for(const pointer of [drag?.pointer,landmarkDrag?.pointer])if(pointer!==undefined&&host.pane.hasPointerCapture(pointer))host.pane.releasePointerCapture(pointer);drag=null;landmarkDrag=null;armed=null;notice=null;log.textContent='';log.hidden=true;delete host.pane.dataset.chestHover;sync();},
|
|
368
371
|
notify:(text,error=false,lines)=>{notice=text===null?null:{text,error};if(lines){log.textContent=lines.join('\n');log.hidden=!lines.length;log.scrollTop=log.scrollHeight;}sync();},
|
|
369
372
|
noticeText:()=>notice?.text??'',
|
|
370
373
|
rebuildState:(state)=>{busy=state.busy;apply.setAttribute('aria-busy',String(busy));reset.disabled=busy||!state.applied;gate();},
|