@rig-c/review 4.9.1 → 4.11.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 +5 -5
- package/docs/PANELS.md +3 -1
- package/docs/REVIEW_PACKAGE.md +143 -30
- package/docs/STABILITY.md +110 -3
- package/package.json +2 -2
- package/src/chest-landmarks.ts +9 -4
- package/src/cloth-recipe.ts +27 -7
- package/src/compare-html.ts +1 -1
- package/src/feedback-export.ts +2 -2
- package/src/feedback-validation.ts +11 -6
- package/src/frame-clock.ts +20 -4
- package/src/job-act.ts +60 -71
- package/src/job-api.ts +302 -46
- package/src/job-checkpoint-evidence.ts +17 -0
- package/src/job-cli.ts +3 -2
- package/src/job-contract.ts +107 -7
- package/src/job-front.ts +48 -12
- package/src/job-host.ts +7 -1
- package/src/job-session.ts +136 -26
- package/src/job-source.ts +133 -21
- package/src/job-store.ts +7 -4
- package/src/manifest.ts +59 -7
- package/src/open-workspace-state.ts +6 -1
- package/src/open.ts +3 -3
- package/src/rebuild.ts +42 -10
- package/src/session.ts +9 -4
- package/src/stage-comment.ts +2 -1
- package/web/catalog-en.ts +31 -6
- package/web/catalog-ko.ts +79 -54
- package/web/chest-editor.ts +236 -31
- package/web/cloth-panel.ts +1 -1
- package/web/compare.css +2 -2
- package/web/environment-world.ts +9 -0
- package/web/i18n.ts +1 -3
- package/web/inspection-persistence.ts +19 -6
- package/web/interview-panel.ts +13 -80
- package/web/job-rig-screen.ts +65 -37
- package/web/job-session.ts +204 -64
- package/web/label-placement.ts +25 -8
- package/web/main.ts +350 -114
- package/web/part-selection.ts +2 -1
- package/web/parts-viewport-provider.ts +21 -8
- package/web/rebuild-client.ts +3 -5
- package/web/rig-host.ts +5 -4
- package/web/rig-overlays.ts +3 -2
- package/web/rig-viewport-provider.ts +10 -6
- package/web/stage-comments.ts +24 -21
- package/web/styles.css +23 -51
- package/web/viewport-controller.ts +4 -0
- package/web/workspace-layout.ts +4 -4
- package/web/workspace-ui.ts +8 -6
package/web/part-selection.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import type {Json} from '../src/manifest.ts';
|
|
3
3
|
import type {PosedFrame,RigPlayer,PoseBounds,SlotIdentitySnapshot} from '@rig-c/play';
|
|
4
4
|
import {parseControlPart,parsePartIdentity,type ControlPart,type ControlPartIdentity,type PartIdentityReason} from '../src/control.ts';
|
|
5
|
+
import {formatFixed} from '../src/frame-clock.ts';
|
|
5
6
|
import {t,setSourceAttribute,setSourceText,sourceAttribute} from './i18n.ts';
|
|
6
7
|
export interface PartDeclaration {skin:string;attachment:string;kind:string;path:string|null}
|
|
7
8
|
export interface PartEntry {slot:string;bone:string;setup:string|null;declarations:PartDeclaration[]}
|
|
@@ -195,7 +196,7 @@ const key=this.viewKey();if(!force&&key===this.selectionKey)return;this.selectio
|
|
|
195
196
|
nodes.info.textContent=observation?`${observation.mode==='solo'?'Solo':'In context'} · ${observation.drawn?observation.kind==='mesh'?`${observation.vertices} posed vertices · ${observation.triangles} triangles`:'Region · four posed corners':'Not drawn at current pose'} · Skin: ${observation.skin??'not set'} · Set: ${observation.set??'not set'}`:refusal?`Parts unavailable · ${refusal.message}. The whole rig stays drawn; no slot is selected, soloed or targeted from stale data.`:'Select an actual slot in the parts explorer. Selection preserves animation, time and physics history.';
|
|
196
197
|
for(const node of [nodes.declarations,nodes.bounds,nodes.unavailable,nodes.feedback])node.hidden=!observation;nodes.feedback.disabled=!observation;
|
|
197
198
|
nodes.declarations.textContent=observation?`${observation.activeAttachment?'Resolved public attachment: '+observation.activeAttachment.skin+' / '+observation.activeAttachment.attachment+'.':(observation.identityUnavailable??'No active drawable attachment: '+observation.reason)+'.'} Declared: ${observation.declarations.map(d=>`${d.skin} / ${d.attachment} (${d.kind})`).join('; ')||'none'}. ${observation.page?'Drawn page: '+observation.page:''}${observation.region?' · region '+observation.region:''}${observation.sequence!==null?' · sequence '+observation.sequence:''}`:'';
|
|
198
|
-
nodes.bounds.textContent=observation?observation.bounds
|
|
199
|
+
nodes.bounds.textContent=observation?observation.bounds?t('Selection bounds · world units / Y up: x {0}, y {1}, width {2}, height {3}. Conservative geometry/clip bounds; fit uses the existing 0.25–8× camera range.',[formatFixed(observation.bounds.x,2),formatFixed(observation.bounds.y,2),formatFixed(observation.bounds.width,2),formatFixed(observation.bounds.height,2)]):t('PART_FIT_UNAVAILABLE: no positive drawn bounds at the held pose.'):'';
|
|
199
200
|
}
|
|
200
201
|
|
|
201
202
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Native image policy for the canonical pair. Camera gestures and writes belong to viewport-controller. */
|
|
2
|
-
import {createViewportController,createViewportState,type ViewportState,type ViewportController,type CameraTarget,type ViewportProvider} from './viewport-controller.ts';
|
|
2
|
+
import {createViewportController,createViewportState,formatZoomReadout,type ViewportState,type ViewportController,type CameraTarget,type ViewportProvider} from './viewport-controller.ts';
|
|
3
3
|
import {t} from './i18n.ts';
|
|
4
4
|
|
|
5
5
|
interface PartsFrame {w:number;h:number;world?:{box:{x:number;y:number;width:number;height:number};origin:{x:number;y:number};scale:{x:number;y:number}}}
|
|
@@ -45,7 +45,7 @@ export function createPartsViewportProvider(host:PartsViewportHost,state:Viewpor
|
|
|
45
45
|
if(target==='rig'){state.rigScale=c.zoom;state.displayedCenter={...center};}
|
|
46
46
|
}
|
|
47
47
|
},
|
|
48
|
-
renderControls:controller=>{const zoom=controller.paneCamera(controller.availableCamera()??'rig').zoom;host.el('zoom-value').textContent=
|
|
48
|
+
renderControls:controller=>{const zoom=controller.paneCamera(controller.availableCamera()??'rig').zoom;host.el('zoom-value').textContent=t(formatZoomReadout(controller));host.el('native-one').setAttribute('aria-pressed',String(zoom===1));(host.el('camera-sync') as HTMLInputElement).checked=state.cameraSync;host.el('fit').textContent=t('Fit');}
|
|
49
49
|
};
|
|
50
50
|
return provider;
|
|
51
51
|
}
|
|
@@ -168,10 +168,17 @@ export function bindPartsSubject(host:{
|
|
|
168
168
|
finally{for(const bitmap of bitmaps)bitmap.close();if(navigation===token){busy=false;host.el('stage-layout').setAttribute('aria-busy','false');comments?.refresh();}}
|
|
169
169
|
}
|
|
170
170
|
const redraw=()=>{void paint().catch(()=>{});};
|
|
171
|
-
const commentRegion=(pose:PartsPose,screen:ReturnType<typeof region
|
|
171
|
+
const commentRegion=(pose:PartsPose,screen:ReturnType<typeof region>,bounds?:{x:number;y:number;width:number;height:number})=>{
|
|
172
172
|
const frame=box(),a=unprojectMark(screen,pose.camera),b=unprojectMark({x:screen.x+screen.width,y:screen.y+screen.height},pose.camera);
|
|
173
173
|
const stable=(n:number)=>Math.abs(n-Math.round(n))<1e-6?Math.round(n):n;
|
|
174
|
-
return snapImageRegion(region({x:stable(a.x),y:stable(a.y)},{x:stable(b.x),y:stable(b.y)},{x:0,y:0,width:frame.w,height:frame.h}));
|
|
174
|
+
return snapImageRegion(region({x:stable(a.x),y:stable(a.y)},{x:stable(b.x),y:stable(b.y)},bounds??{x:0,y:0,width:frame.w,height:frame.h}));
|
|
175
|
+
};
|
|
176
|
+
const partsUnionBounds=(names:readonly string[]|undefined,r:ReturnType<typeof snapImageRegion>)=>{
|
|
177
|
+
const matched=(names??[]).flatMap(name=>{const entry=data.items.find(item=>item.name===name);return entry?[entry]:[];});
|
|
178
|
+
if(!matched.length)return undefined;
|
|
179
|
+
const minX=Math.min(...matched.map(i=>i.x)),minY=Math.min(...matched.map(i=>i.y));
|
|
180
|
+
const maxX=Math.max(...matched.map(i=>i.x+i.w)),maxY=Math.max(...matched.map(i=>i.y+i.h));
|
|
181
|
+
return r.x<maxX&&r.x+r.width>minX&&r.y<maxY&&r.y+r.height>minY?{x:minX,y:minY,width:maxX-minX,height:maxY-minY}:undefined;
|
|
175
182
|
};
|
|
176
183
|
const codec:CommentCodec<CommentRow,PartsPose>={
|
|
177
184
|
geometry:true,
|
|
@@ -187,16 +194,22 @@ export function bindPartsSubject(host:{
|
|
|
187
194
|
const hits=new Set<string>(),layers=visible.flatMap(box=>{const img=loaded.get(box.name);return img?[sourceAlpha(box,img)]:[];});
|
|
188
195
|
const stepX=Math.max(1,r.width/32),stepY=Math.max(1,r.height/32);
|
|
189
196
|
for(let y=r.y+.5;y<r.y+r.height;y+=stepY)for(let x=r.x+.5;x<r.x+r.width;x+=stepX){const hit=pickAssembly(layers,x,y);if(hit)hits.add(hit.name);}
|
|
197
|
+
if(!hits.size){
|
|
198
|
+
const overlaps=(entry:Item)=>entry.x<r.x+r.width&&entry.x+entry.w>r.x&&entry.y<r.y+r.height&&entry.y+entry.h>r.y;
|
|
199
|
+
const current=selected!==null?visible.find(entry=>entry.name===selected&&overlaps(entry)):undefined;
|
|
200
|
+
if(current)hits.add(current.name);
|
|
201
|
+
else for(const entry of visible)if(overlaps(entry))hits.add(entry.name);
|
|
202
|
+
}
|
|
190
203
|
return {selected:visible.filter(item=>hits.has(item.name)).map(item=>item.name),candidates};
|
|
191
204
|
},
|
|
192
205
|
create:async(pose,_view,screen,crop,_bookmark,summary,parts)=>{
|
|
193
|
-
const
|
|
206
|
+
const raw=commentRegion(pose,screen),single=pose.view.mode==='item',r=single?raw:commentRegion(pose,screen,partsUnionBounds(parts,raw));
|
|
194
207
|
return prepare({schema:'rig-review-parts-comment/2',id:crypto.randomUUID(),summary,sourceHash:data.sourceHash,parts:partsBinding(single?[pose.item.name]:parts??[]),rigRegion:single?{...r,x:r.x+pose.item.x,y:r.y+pose.item.y}:r,imageRegion:single?r:null,view:structuredClone(pose.view),crop,nativeCrop:null});
|
|
195
208
|
},
|
|
196
209
|
update:(raw,summary,parts,geometry)=>{
|
|
197
210
|
const existing=parsePartsIssue(raw,false,true,false);let updated=existing;
|
|
198
211
|
if(geometry){
|
|
199
|
-
const {pose,screen,crop}=geometry,
|
|
212
|
+
const {pose,screen,crop}=geometry,rawRegion=commentRegion(pose,screen),single=pose.view.mode==='item',r=single?rawRegion:commentRegion(pose,screen,partsUnionBounds(parts,rawRegion));
|
|
200
213
|
if(pose.sourceHash!==existing.sourceHash)throw new Error('PARTS_COMMENT_STALE_SOURCE');
|
|
201
214
|
updated={...existing,rigRegion:single?{...r,x:r.x+pose.item.x,y:r.y+pose.item.y}:r,imageRegion:single?r:null,view:structuredClone(pose.view),crop,nativeCrop:null};
|
|
202
215
|
}
|
|
@@ -213,7 +226,7 @@ export function bindPartsSubject(host:{
|
|
|
213
226
|
...(host.generalComments?{...host.generalComments,refusal:host.refusal}:{}),
|
|
214
227
|
}:undefined,toolbar:host.toolbar,listHost:host.commentsHost,openList:host.openComments,hasPicture:host.hasPicture,toggle:host.el<HTMLButtonElement>('stage-comment'),viewports:{rig:host.el('rig-viewport')},pose,pause:async()=>{},bookmark:()=>null,
|
|
215
228
|
restore:async raw=>{const issue=parsePartsIssue(raw,false,true,false);assertPartsIssueBinding(issue,sourceItems(),data.sourceHash);selected=issue.view.mode==='item'?issue.parts[0]!.name:null;solo=issue.view.mode==='item';comparison=issue.view.comparison??defaultPartsComparison();host.restoreMesh(issue.view.mesh);if(issue.view.visibleLayers){const visible=new Set(issue.view.visibleLayers.map(part=>part.name));hidden.clear();for(const item of data.items)if(!visible.has(item.name))hidden.add(item.name);}await paint();host.viewport.writeCamera('rig',data.painting&&solo?{...issue.view.camera,center:{x:issue.view.camera.center.x+item().x,y:issue.view.camera.center.y+item().y}}:issue.view.camera);host.viewport.activateCamera('rig');if(host.viewport.state.cameraSync)host.viewport.alignCameras();host.viewport.fitCamera();host.selectionChanged();},
|
|
216
|
-
feedback:()=>host.recordComments??host.issues,locked:host.locked,refusal:host.refusal,add:row=>{if(host.recordComments)host.recordComments.push(row);else host.issues.push(row as PartsIssue);},changed:host.changed,error:host.message,blocked:()=>busy||failed||disposed||!!host.submitting?.(),busy:()=>busy,codec});
|
|
229
|
+
feedback:()=>host.recordComments??host.issues,locked:host.locked,refusal:host.refusal,add:row=>{if(host.recordComments)host.recordComments.push(row);else host.issues.push(row as PartsIssue);},changed:host.changed,draftChanged:host.selectionChanged,error:host.message,blocked:()=>busy||failed||disposed||!!host.submitting?.(),busy:()=>busy,codec});
|
|
217
230
|
return {
|
|
218
231
|
frameSize:(target:CameraTarget):PartsFrame|null=>{
|
|
219
232
|
const frame=target==='rig'?drawnFrame:drawnReferenceFrame;if(!frame||!data.painting||!data.rigSize)return frame;
|
|
@@ -224,7 +237,7 @@ export function bindPartsSubject(host:{
|
|
|
224
237
|
return {...frame,world:{box:{x:bounds.x,y:bounds.y,width:bounds.w,height:bounds.h},origin,scale}};
|
|
225
238
|
},
|
|
226
239
|
image:(index:number)=>{const entry=data.items.find(item=>item.index===index);if(!entry)return Promise.reject(new Error('PARTS_IMAGE_UNAVAILABLE'));return image(entry);},
|
|
227
|
-
items:()=>data.items,sourceHash:()=>data.sourceHash,refreshComments:()=>comments?.refresh(),selected:()=>selected,solo:()=>solo,visible:(name:string)=>!hidden.has(name),issues:()=>host.issues,
|
|
240
|
+
items:()=>data.items,sourceHash:()=>data.sourceHash,refreshComments:()=>comments?.refresh(),hasPendingComment:()=>!!comments?.hasPendingComment(),commitDraft:()=>comments?.commitDraft()??Promise.resolve(true),selected:()=>selected,solo:()=>solo,visible:(name:string)=>!hidden.has(name),issues:()=>host.issues,
|
|
228
241
|
select:(name:string|null)=>{selected=name;if(name===null)solo=false;redraw();host.selectionChanged();},
|
|
229
242
|
isolate:(value:boolean)=>{
|
|
230
243
|
solo=value;
|
package/web/rebuild-client.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* the applied history for the page; the server owns every path and the producer's flags.
|
|
5
5
|
*/
|
|
6
6
|
import {setSourceText} from './i18n.ts';
|
|
7
|
+
import {bustLandmarkFields} from './chest-editor.ts';
|
|
7
8
|
import {ellipsePolygon,fitChestEllipse,CHEST_ELLIPSE_MIN_POINTS} from '../src/chest-regions.ts';
|
|
8
9
|
import {deriveBust,parseBustSpec,type BustSpec} from '../src/chest-landmarks.ts';
|
|
9
10
|
import {CONFIG_PATCH_SCHEMA,type ConfigPatch,type PatchCmd,type PatchOp} from '../src/config-patch.ts';
|
|
@@ -28,7 +29,7 @@ export type AnimationSourceView=import('../src/rebuild.ts').AnimationSourceStatu
|
|
|
28
29
|
export interface DraftStatusView {id:string;kind:'draft-rig';at:string;producer:{name:string;version:string};editable:boolean;config:{path:string;sha256:string};config_inputs?:{path:string;sha256:string}[];parts:{path:string;files:{path:string;sha256:string}[]};files:{path:string;sha256:string}[]}
|
|
29
30
|
export interface RebuildStatusView {retarget?:RetargetStatusView;animations?:AnimationSourceView|null;available:boolean;viewOnly?:boolean;handoff:HandoffView|null;draft?:DraftStatusView|null;baseline:BaselineView|null;inputs:{config:string;parts:string|null;rig:string|null;configHash:string}|null;parts:{name:string;regions:unknown[]}[];contour:Record<string,Record<string,unknown>>;meshes?:Record<string,unknown>;constraints?:unknown[]|null;bones?:unknown[]|null;fields?:Record<string,unknown>|null;cuts?:{config:Record<string,unknown>;build:string|null}|null;inspectedCheck?:InspectedCheckView|null;idle?:import('../src/idle-tracks.ts').IdleStatus|null;cloth?:ClothStatusView|null;producer:{package:string;version:string}|null;compiler:{package:string;version:string}|null;reason:string|null}
|
|
30
31
|
/** #111: the cloth recipe form's status — the reader's tags, the recipes as written, each tag's parts and chains, the keypoints, the route and why Apply cannot run. */
|
|
31
|
-
export interface ClothStatusView {targets:string[];targetsRead:boolean;recipes:Record<string,unknown>|null;tags:import('../src/cloth-recipe.ts').ClothTagView[];keypoints:{path:string;sha256:string}|null;route:'build'|'rig';reason:string|null}
|
|
32
|
+
export interface ClothStatusView {targets:string[];targetsRead:boolean;targetsReason?:string|null;recipes:Record<string,unknown>|null;tags:import('../src/cloth-recipe.ts').ClothTagView[];keypoints:{path:string;sha256:string}|null;route:'build'|'rig';reason:string|null}
|
|
32
33
|
export interface RebuildJobView {stageInputHash?:string;files?:FilesDiff|null;remesh?:import('../src/mesh-entry.ts').RemeshCounts|null;check?:CheckSummary|null;id:string;status:'running'|'built'|'refused'|'failed';reused:boolean;lines:string[];producerLine:string|null;hint?:string;exitCode:number|null;wallMs:{remesh:number|null;compile:number|null};build:{modelUrl:string;modelHash:string;files:Record<string,string>}|null;request:{part:string;regions:RegionEntry[];configHash:string;entrySha256:string;bust?:BustSpec};producer:{package:string;version:string};compiler:{package:string;version:string}}
|
|
33
34
|
export interface RebuildRefusal {status:'refused';error:string;producerLine:string|null}
|
|
34
35
|
/** #99 regions or #105 landmarks: exactly one of `regions` and `bust`. */
|
|
@@ -200,10 +201,7 @@ export function seedLandmarks(status:Pick<RebuildStatusView,'parts'|'contour'>,r
|
|
|
200
201
|
if(['apex_r','apex_l','cleavage'].some(k=>(read(`lm-${k}-x`)?.value??'').trim()||(read(`lm-${k}-y`)?.value??'').trim()))return null;
|
|
201
202
|
for(const p of status.parts){
|
|
202
203
|
const bust=(status.contour[p.name]?.contour as Record<string,unknown>|undefined)?.bust as Record<string,unknown>|undefined;if(!bust||typeof bust!=='object')continue;
|
|
203
|
-
const out
|
|
204
|
-
for(const k of ['apex_r','apex_l','cleavage'])if(Array.isArray(bust[k])&&(bust[k] as unknown[]).length===2){out[`lm-${k}-x`]=String((bust[k] as number[])[0]);out[`lm-${k}-y`]=String((bust[k] as number[])[1]);}
|
|
205
|
-
for(const k of ['alpha','clearance'])if(typeof bust[k]==='number')out[`lm-${k}`]=String(bust[k]);
|
|
206
|
-
for(const k of ['bone_r','bone_l'])if(typeof bust[k]==='string')out[`lm-${k}`]=bust[k] as string;
|
|
204
|
+
const out=bustLandmarkFields(bust);
|
|
207
205
|
return Object.keys(out).length?out:null;
|
|
208
206
|
}
|
|
209
207
|
return null;
|
package/web/rig-host.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* (`main.ts`): the job keeps the transport, the screen keeps its own view. Unset, the screen is the package page. */
|
|
3
3
|
import type {ModelAssets, PosedFrame} from '@rig-c/play';
|
|
4
4
|
import type {PartsIssue} from '../src/parts-comment.ts';
|
|
5
|
-
import type {PendingAskV3} from '../src/job-contract.ts';
|
|
5
|
+
import type {JobProgressV3, PendingAskV3} from '../src/job-contract.ts';
|
|
6
6
|
import type {ReviewSession} from '../src/session.ts';
|
|
7
7
|
import type {InspectionBookmark} from './inspection-persistence.ts';
|
|
8
8
|
import type {ControlView} from '../src/control.ts';
|
|
@@ -31,6 +31,7 @@ export interface RigHostScreen {
|
|
|
31
31
|
redraw(): void;
|
|
32
32
|
message(text: string, error?: boolean, diagnostic?: string): void;
|
|
33
33
|
pendingSubjects?(subjects:readonly PendingAskV3['subject'][]):void;
|
|
34
|
+
progress?(value: JobProgressV3 | null):void;
|
|
34
35
|
recordForms?(forms:readonly HTMLFormElement[]):void;
|
|
35
36
|
}
|
|
36
37
|
/** Only the content carried by an act the host has actually committed. This is local UI state, not an act field. */
|
|
@@ -43,12 +44,12 @@ export interface RigHost {
|
|
|
43
44
|
readonly waiting?:boolean;
|
|
44
45
|
readonly subject?:'parts';
|
|
45
46
|
readonly unavailable?:string;
|
|
46
|
-
readonly direction?:{readonly publicationId:string;readonly sourceHash:string};
|
|
47
|
-
readonly verdictComments?:{readonly publicationId:string;readonly sourceHash:string;readonly rows:CommentRow[];readonly available:()=>boolean};
|
|
47
|
+
readonly direction?:{readonly jobId?:string;readonly draftId?:string;readonly publicationId:string;readonly previousPublicationId?:string|null;readonly sourceHash:string};
|
|
48
|
+
readonly verdictComments?:{readonly jobId?:string;readonly draftId?:string;readonly publicationId:string;readonly previousPublicationId?:string|null;readonly sourceHash:string;readonly rows:CommentRow[];readonly available:()=>boolean};
|
|
48
49
|
readonly navigation?:RigHostNavigation;
|
|
49
50
|
/** Derived from the displayed subject's finalized verdict; never a mode or another subject's act. */
|
|
50
51
|
reviewState?(issues:number,sending:boolean):string;
|
|
51
|
-
readonly record?:{readonly publicationId?:string;readonly label:string;readonly sourceHash:string;readonly hasPicture:boolean;readonly missingPicture?:'rig'|'scene';readonly
|
|
52
|
+
readonly record?:{readonly jobId?:string;readonly draftId?:string;readonly publicationId?:string;readonly previousPublicationId?:string|null;readonly label:string;readonly sourceHash:string;readonly hasPicture:boolean;readonly planPicture?:{readonly name:string;readonly src:string};readonly missingPicture?:'rig'|'scene';readonly questionPicture?:true};
|
|
52
53
|
submitParts?(issues:readonly PartsIssue[], general?:readonly string[]):Promise<string>;
|
|
53
54
|
readonly access: InstanceAccess;
|
|
54
55
|
/** UI act authority is separate from a retained backdrop's immutable source access. */
|
package/web/rig-overlays.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/** Inspection graphics from the last successfully drawn public player pose. */
|
|
2
2
|
import {partBounds} from './part-selection.ts';
|
|
3
|
+
import {t} from './i18n.ts';
|
|
3
4
|
import {boxesIntersect,placeLabels,type LabelBox} from './label-placement.ts';
|
|
4
5
|
import type {BoneWorld,PosedFrame,RigPlayer} from '@rig-c/play';
|
|
5
6
|
|
|
@@ -270,7 +271,7 @@ export class RigOverlays {
|
|
|
270
271
|
}
|
|
271
272
|
// Labels avoid each other (#147): a moved label keeps a leader to its point; one with no free slot shows on hover only.
|
|
272
273
|
ctx.font='600 11px ui-monospace, monospace';
|
|
273
|
-
const placed=placeLabels(drawn.map(({marker,at})=>({at,width:ctx.measureText(marker.tag).width+8,pinned:marker.active})),{gap:10,rise:3,bounds:{width,height},obstacles:drawn.map(({marker,at})=>{const r=marker.active?8:6.5;return {x:at.x-r,y:at.y-r,w:r*2,h:r*2};})});
|
|
274
|
+
const placed=placeLabels(drawn.map(({marker,at})=>({at,width:ctx.measureText(t(marker.tag)).width+8,pinned:marker.active})),{gap:10,rise:3,bounds:{width,height},obstacles:drawn.map(({marker,at})=>{const r=marker.active?8:6.5;return {x:at.x-r,y:at.y-r,w:r*2,h:r*2};})});
|
|
274
275
|
// Leaders first, so no leader crosses another joint's label.
|
|
275
276
|
drawn.forEach(({marker,at},i)=>{
|
|
276
277
|
const {box,visible,moved}=placed[i]!;if(!visible||!moved)return;
|
|
@@ -279,7 +280,7 @@ export class RigOverlays {
|
|
|
279
280
|
});
|
|
280
281
|
drawn.forEach(({marker},i)=>{
|
|
281
282
|
const {box,visible}=placed[i]!,c=marker.colors;if(!visible)return;
|
|
282
|
-
ctx.fillStyle=c.labelBg;ctx.fillRect(box.x,box.y,box.w,box.h);ctx.fillStyle=c.stroke;ctx.fillText(marker.tag,box.x+4,box.y+11);
|
|
283
|
+
ctx.fillStyle=c.labelBg;ctx.fillRect(box.x,box.y,box.w,box.h);ctx.fillStyle=c.stroke;ctx.fillText(t(marker.tag),box.x+4,box.y+11);
|
|
283
284
|
});
|
|
284
285
|
}
|
|
285
286
|
ctx.globalAlpha=1;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** Existing compiled rig/reference rendering for the shared inspection viewport. */
|
|
2
2
|
import type {ModelAssets,RigPlayer,PoseBounds,PosedFrame} from '@rig-c/play';
|
|
3
|
-
import type
|
|
3
|
+
import {formatZoomReadout,type CameraTarget,type ViewportProvider,type ViewportState,type ViewportController} from './viewport-controller.ts';
|
|
4
4
|
import {cameraSignature} from './camera-view.ts';
|
|
5
5
|
import {dragImpulse} from '../src/environment.ts';
|
|
6
6
|
import {CLICK_SLOP_PX} from './stage-pick.ts';
|
|
@@ -90,16 +90,20 @@ function render(controller:ViewportController): void {
|
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
function renderControls(controller:ViewportController):void {
|
|
93
|
-
const
|
|
94
|
-
input('camera-sync').checked=state.cameraSync;
|
|
95
|
-
|
|
96
|
-
text(controls?.zoomId??'zoom-value',`${Math.round((target?paneCamera(target).zoom:1)*100)}% · ${label}`);
|
|
93
|
+
const controls=host.cameraControls;
|
|
94
|
+
input('camera-sync').checked=state.cameraSync;
|
|
95
|
+
text(controls?.zoomId??'zoom-value',formatZoomReadout(controller,controls?.targetLabel));
|
|
97
96
|
button('fit').textContent=host.fitLabel??controls?.fitLabel?.(state.cameraSync)??(state.cameraSync?'Fit views':'Fit active');
|
|
97
|
+
renderCaption();
|
|
98
|
+
}
|
|
99
|
+
/** The footer names the camera mode the sync checkbox shows, on the rig and the raster paths alike. */
|
|
100
|
+
function renderCaption():void {
|
|
101
|
+
const controls=host.cameraControls;
|
|
98
102
|
if(controls?.coordinatesId!==null)text(controls?.coordinatesId??'coordinates',state.cameraSync?'Cameras synchronized · drag to pan · scroll to zoom':'Independent cameras · drag to pan · scroll to zoom');
|
|
99
103
|
}
|
|
100
104
|
return {el,message,get nativeScale(){return host.raster?rasterActive():undefined;},
|
|
101
105
|
render:controller=>rasterActive()?raster!.render(controller):render(controller),
|
|
102
|
-
renderControls:controller=>rasterActive()
|
|
106
|
+
renderControls:controller=>{if(rasterActive()){raster!.renderControls(controller);renderCaption();}else renderControls(controller);},
|
|
103
107
|
...(host.panes?{panes:[...host.panes,{target:'reference' as const,viewport:el('reference-viewport'),pane:el('reference-pane')}]}:{}),
|
|
104
108
|
dimensionVisibility:host.dimensionVisibility,
|
|
105
109
|
fitMargins:host.rigMargins,fitMessage:host.fitMessage,pinch:host.pinch,
|
package/web/stage-comments.ts
CHANGED
|
@@ -30,11 +30,12 @@ interface Host<Row extends CommentRow=Feedback,Pose extends CommentUiPose=Commen
|
|
|
30
30
|
pose:(view:StageComment['viewport'])=>Pose|null;pause:()=>Promise<void>;
|
|
31
31
|
bookmark:()=>unknown;restore:(bookmark:unknown,timeOnly?:boolean)=>Promise<void>;
|
|
32
32
|
feedback:()=>Row[];locked:(id:string)=>boolean;
|
|
33
|
-
add:(feedback:Row,side?:'a'|'b')=>void;changed:()=>void|Promise<void>;error:(message:string)=>void;
|
|
33
|
+
add:(feedback:Row,side?:'a'|'b')=>void;changed:()=>void|Promise<void>;draftChanged?:()=>void;error:(message:string)=>void;
|
|
34
34
|
general?:{create:(summary:string)=>Row;matches:(row:Row)=>boolean;rows?:Row[];available?:()=>boolean;refusal?:()=>string|null};
|
|
35
35
|
refusal?:()=>string|null;blocked:()=>boolean;busy?:()=>boolean;busyError?:(message:string)=>void;shortcutBlocked?:()=>boolean;shortcutActive?:()=>boolean;codec?:CommentCodec<Row,Pose>;
|
|
36
36
|
}
|
|
37
37
|
const markOf=(f:Feedback):StageComment|null=>{try{const c=f.context as Record<string,unknown>|undefined;return c?.comment?parseStageComment(c.comment):null;}catch{return null;}};
|
|
38
|
+
const commentLabels:Record<string,string>={setup:'Setup',animate:'Animate',compare:'Compare',rig:'Rig',reference:'Reference',a:'A',b:'B'};
|
|
38
39
|
const copy=<T>(v:T):T=>JSON.parse(JSON.stringify(v));
|
|
39
40
|
const t=(s:string)=>typeof i18nT==='function'?i18nT(s):s;
|
|
40
41
|
const toEn=(s:string)=>typeof i18nTr==='function'?i18nTr(s,'en'):s;
|
|
@@ -67,7 +68,7 @@ async function crop(pose:CommentUiPose,r:MarkRegion):Promise<StageComment['crop'
|
|
|
67
68
|
const bytes=Uint8Array.from(atob(png.split(',')[1]!),c=>c.charCodeAt(0)),sha256=[...new Uint8Array(await crypto.subtle.digest('SHA-256',bytes))].map(n=>n.toString(16).padStart(2,'0')).join('');
|
|
68
69
|
return {path:`comment-crops/${sha256}.png`,sha256,png,width:out.width,height:out.height};
|
|
69
70
|
}
|
|
70
|
-
export function bindStageComments<Row extends CommentRow=Feedback,Pose extends CommentUiPose=CommentPose>(host:Host<Row,Pose>):{refresh:()=>void;dispose:()=>void;active:()=>boolean;draft:()=>boolean}{
|
|
71
|
+
export function bindStageComments<Row extends CommentRow=Feedback,Pose extends CommentUiPose=CommentPose>(host:Host<Row,Pose>):{refresh:()=>void;dispose:()=>void;active:()=>boolean;draft:()=>boolean;hasPendingComment:()=>boolean;commitDraft:()=>Promise<boolean>}{
|
|
71
72
|
const readMark=(row:Row):CommentUiMark|null=>host.codec?host.codec.read(row):markOf(row as unknown as Feedback);
|
|
72
73
|
const toggle=host.toggle??document.getElementById('stage-comment') as HTMLButtonElement;if(!toggle)throw new Error('PARTS_WORKSPACE_NODE_REQUIRED: stage-comment');Object.assign(toggle.style,{whiteSpace:'nowrap',flex:'none'});
|
|
73
74
|
const inline=!!host.listHost;
|
|
@@ -80,13 +81,13 @@ export function bindStageComments<Row extends CommentRow=Feedback,Pose extends C
|
|
|
80
81
|
const refusalNote=document.createElement('small');refusalNote.id='stage-comment-refusal';refusalNote.setAttribute('role','status');refusalNote.hidden=true;Object.assign(refusalNote.style,{position:'absolute',width:'1px',height:'1px',overflow:'hidden',clipPath:'inset(50%)',whiteSpace:'nowrap'});toggle.after(refusalNote);toggle.setAttribute('aria-describedby',refusalNote.id);toggle.setAttribute('aria-controls',list.id);toggle.setAttribute('aria-expanded',String(inline));const originalTitle=toEn(toggle.title);
|
|
81
82
|
const updateRefusal=()=>{const raw=host.refusal?.()??null,reason=raw?t(raw):null,prev=refusalNote.textContent||'',nextTitle=reason??t(originalTitle);toggle.disabled=!!host.busy?.();toggle.setAttribute('aria-busy',String(toggle.disabled));if(toggle.title!==nextTitle)toggle.title=nextTitle;if(refusalNote.title!==(reason??''))refusalNote.title=reason??'';if(refusalNote.textContent!==(reason??''))refusalNote.textContent=reason??'';refusalNote.hidden=!reason;if(!list.hidden&&(reason??'')!==prev)renderList();return reason;};
|
|
82
83
|
const layers=new Map<StageComment['viewport'],HTMLDivElement>();for(const [key,pane]of Object.entries(host.viewports)){const layer=document.createElement('div');layer.className='stage-comment-layer';pane!.append(layer);layers.set(key as StageComment['viewport'],layer);}
|
|
83
|
-
let enabled=false,disposed=false,pending:{view:StageComment['viewport'];start:MarkPoint;end:MarkPoint;mode:string;id:number;interaction:number;settled:Promise<void>}|null=null,composer:HTMLFormElement|null=null,composerReadOnly=false,composerGeneral=false,syncComposerLang:(()=>void)|null=null,draftMark:{view:StageComment['viewport'];mode:string;screen:MarkRegion}|null=null,busy=false,last='',raf=0,interaction=0;
|
|
84
|
+
let enabled=false,disposed=false,pending:{view:StageComment['viewport'];start:MarkPoint;end:MarkPoint;mode:string;id:number;interaction:number;settled:Promise<void>}|null=null,composer:HTMLFormElement|null=null,composerField:HTMLInputElement|null=null,composerSubmit:(()=>Promise<boolean>)|null=null,composerReadOnly=false,composerGeneral=false,syncComposerLang:(()=>void)|null=null,draftMark:{view:StageComment['viewport'];mode:string;screen:MarkRegion}|null=null,busy=false,last='',raf=0,interaction=0;
|
|
84
85
|
let geometryEdit:{view:StageComment['viewport'];screen:MarkRegion;id?:string;update:(screen:MarkRegion)=>void;changed:boolean;camera:string}|null=null;
|
|
85
86
|
let geometryDrag:{id:number;start:MarkPoint;screen:MarkRegion;handle:string}|null=null;
|
|
86
87
|
let suppressPinClick=false;
|
|
87
88
|
let pinPress:{id:number;view:StageComment['viewport'];start:MarkPoint;pin:HTMLButtonElement}|null=null;
|
|
88
89
|
const setCapture=(value:boolean)=>{value=value&&host.hasPicture?.()!==false;enabled=value;toggle.setAttribute('aria-pressed',String(value||!inline&&!list.hidden));for(const pane of Object.values(host.viewports))pane!.classList.toggle('stage-comment-mode',value);};
|
|
89
|
-
const cancel=()=>{++interaction;const previous=pending??(geometryDrag&&geometryEdit?{view:geometryEdit.view,id:geometryDrag.id}:pinPress);geometryEdit=null;geometryDrag=null;pinPress=null;pending=null;if(previous){const pane=host.viewports[previous.view];if(pane?.hasPointerCapture(previous.id))pane.releasePointerCapture(previous.id);}composer?.remove();composer=null;composerReadOnly=false;composerGeneral=false;syncComposerLang=null;draftMark=null;last='';};
|
|
90
|
+
const cancel=()=>{++interaction;const hadComposer=!!composer,previous=pending??(geometryDrag&&geometryEdit?{view:geometryEdit.view,id:geometryDrag.id}:pinPress);geometryEdit=null;geometryDrag=null;pinPress=null;pending=null;if(previous){const pane=host.viewports[previous.view];if(pane?.hasPointerCapture(previous.id))pane.releasePointerCapture(previous.id);}composer?.remove();composer=null;composerField=null;composerSubmit=null;composerReadOnly=false;composerGeneral=false;syncComposerLang=null;draftMark=null;last='';if(hadComposer)host.draftChanged?.();};
|
|
90
91
|
const assertCapture=()=>{const reason=updateRefusal();if(reason){cancel();setCapture(false);host.error(reason);throw new Error(reason);}if(host.blocked())throw new Error(t('COMMENT_BUSY: wait for inspection'));};
|
|
91
92
|
const generalRefusal=()=>host.general?.refusal?.()??null;
|
|
92
93
|
const assertWritable=(reason:string|null)=>{if(reason){setCapture(false);host.error(reason);throw new Error(reason);}if(host.blocked())throw new Error(t('COMMENT_BUSY: wait for inspection'));};
|
|
@@ -135,7 +136,8 @@ export function bindStageComments<Row extends CommentRow=Feedback,Pose extends C
|
|
|
135
136
|
const openComment=async(f:Row)=>{const mark=readMark(f);if(!mark){if(host.general?.matches(f))openComposer(null,{x:0,y:0,width:0,height:0},f);return;}if(list.hidden)setOpen(true);if(list.hidden)return;if(await jump(f)){const reason=updateRefusal();setCapture(!reason&&!host.blocked());const pose=host.pose(mark.viewport),screen=host.codec?.geometry&&pose?region(projectMark(mark.world,pose.camera),projectMark({x:mark.world.x+mark.world.width,y:mark.world.y+mark.world.height},pose.camera)):mark.screen;openComposer(mark.viewport,screen,f,pose?.mode??mark.mode);}};
|
|
136
137
|
const renderList=()=>{placeList();list.setAttribute('aria-label',t('Comments'));list.replaceChildren();const title=document.createElement('strong');title.textContent=t('Comments');list.append(title);const rawReason=host.refusal?.()??null,reason=rawReason?t(rawReason):null;if(reason){const note=document.createElement('small');note.className='stage-comment-refusal-note';note.title=reason;note.textContent=reason;Object.assign(note.style,{display:'block',marginTop:'4px',maxWidth:'100%',whiteSpace:inline?'normal':'nowrap',overflow:'hidden',textOverflow:'ellipsis'});list.append(note);}if(host.general&&host.general.available?.()!==false){const add=document.createElement('button');add.type='button';add.textContent=t('Add general comment');add.dataset.commentGeneral='';add.onclick=()=>openComposer(null,{x:0,y:0,width:0,height:0});list.append(add);}const all=host.feedback().filter(f=>readMark(f)||host.general?.matches(f));if(host.general?.rows)all.push(...host.general.rows);toggle.textContent=t(host.busy?.()?'Comment · C ({0}) · Rendering':'Comment · C ({0})').replace('{0}',String(all.length));if(!all.length){const empty=document.createElement('p');empty.textContent=t(inline?'No comments yet.':reason?'Read only · Escape closes':'Mark a point or region, then type. Enter saves · Escape cancels.');list.append(empty);}for(const [i,f]of all.entries()){
|
|
137
138
|
const mark=readMark(f),row=document.createElement('div');row.className='stage-comment-item';row.dataset.commentId=f.id;
|
|
138
|
-
const
|
|
139
|
+
const [timing,frameReason]=mark&&!host.codec&&!mark.frame?feedbackTimingLabel(f as unknown as Feedback).split(' · '):[];
|
|
140
|
+
const go=document.createElement('button');go.type='button';go.className='stage-comment-summary';if(frameReason)go.title=t(frameReason);go.textContent=!mark?`${i+1} · ${t('General comment')} · ${f.summary}`:host.codec?`${i+1} · ${host.codec.label(f,mark)}`:`${i+1} · ${t(commentLabels[mark.mode]??mark.mode)} · ${t(commentLabels[mark.viewport]??mark.viewport)} · ${mark.frame?t(`F${mark.frame.index} (${mark.frame.basis})`):t(timing!)} · ${f.summary}${frameReason?` · ${t('Frame unavailable')}`:''}`;go.onclick=()=>openComment(f);row.append(go);
|
|
139
141
|
if(host.locked(f.id)){const submitted=document.createElement('span');submitted.textContent=t('Submitted');row.append(submitted);}
|
|
140
142
|
list.append(row);
|
|
141
143
|
}};
|
|
@@ -150,7 +152,7 @@ export function bindStageComments<Row extends CommentRow=Feedback,Pose extends C
|
|
|
150
152
|
const locked=!!existing&&host.locked(existing.id),initialRefusal=existing?(general?generalRefusal():updateRefusal()):null;
|
|
151
153
|
if(existing&&!initialRefusal&&host.blocked()){host.error(t('COMMENT_BUSY: wait for inspection'));return;}
|
|
152
154
|
geometryEdit=null;composer?.remove();composerReadOnly=locked||!!initialRefusal||!generalAvailable;composerGeneral=general;draftMark=view?{view,mode:placementMode!,screen}:null;const generation=interaction;const pane=view?host.viewports[view]!:list,form=composer=document.createElement('form');form.className='stage-comment-composer stage-comment-ui';form.setAttribute('aria-label',t('Comment composer'));if(general)form.style.position='relative';
|
|
153
|
-
const field=document.createElement('input');field.type='text';field.maxLength=1000;field.setAttribute('aria-label',t('Comment text'));field.placeholder=t('Describe this spot…');field.value=existing?.summary??'';
|
|
155
|
+
const field=composerField=document.createElement('input');field.type='text';field.maxLength=1000;field.setAttribute('aria-label',t('Comment text'));field.placeholder=t('Describe this spot…');field.value=existing?.summary??'';field.oninput=()=>host.draftChanged?.();
|
|
154
156
|
if(composerReadOnly){field.readOnly=true;field.setAttribute('aria-readonly','true');}
|
|
155
157
|
const hint=document.createElement('small');hint.textContent=composerReadOnly?'Read only · Escape closes':'Enter saves · Escape cancels';hint.textContent=t(hint.textContent);const error=document.createElement('p');error.setAttribute('role','alert');form.append(field,hint,error);
|
|
156
158
|
const place=()=>{if(general)return;
|
|
@@ -250,7 +252,7 @@ export function bindStageComments<Row extends CommentRow=Feedback,Pose extends C
|
|
|
250
252
|
const chosen = new Set(selectedParts);
|
|
251
253
|
if (chosen.has(name)) chosen.delete(name);else chosen.add(name);
|
|
252
254
|
selectedParts = chipNames.filter(part => chosen.has(part));
|
|
253
|
-
syncChips();place();
|
|
255
|
+
syncChips();place();field.focus();
|
|
254
256
|
};
|
|
255
257
|
return chip;
|
|
256
258
|
}));
|
|
@@ -274,20 +276,19 @@ export function bindStageComments<Row extends CommentRow=Feedback,Pose extends C
|
|
|
274
276
|
prepared=crop(pose,screen);prepared.catch(()=>{});last='';place();
|
|
275
277
|
}};
|
|
276
278
|
}
|
|
277
|
-
|
|
278
|
-
form.onsubmit=async e=>{e.preventDefault();if(busy)return;if(generation!==interaction||view&&host.pose(view)&&host.pose(view!)?.mode!==placementMode){cancel();return;}const summary=field.value.trim();if(!summary){field.focus();return;}try{
|
|
279
|
+
const submitComposer=composerSubmit=async():Promise<boolean>=>{if(busy)return false;if(generation!==interaction||view&&host.pose(view)&&host.pose(view!)?.mode!==placementMode){cancel();return false;}const summary=field.value.trim();if(!summary){field.focus();return false;}try{
|
|
279
280
|
if(selectedParts && !selectedParts.length)throw new Error(t('Select at least one part.'));
|
|
280
281
|
if(existing){
|
|
281
282
|
assertEdit(general);if(host.locked(existing.id))throw new Error(t('COMMENT_SUBMITTED: submitted evidence is immutable'));
|
|
282
283
|
busy=true;field.disabled=true;syncChips();
|
|
283
284
|
if(!general&&host.codec?.update){
|
|
284
285
|
const geometry=geometryEdit?.changed&&pose?{pose,screen:{...screen},crop:(await prepared)!}:undefined;
|
|
285
|
-
if(disposed||generation!==interaction)return;assertEdit(general);
|
|
286
|
+
if(disposed||generation!==interaction)return false;assertEdit(general);
|
|
286
287
|
const replacement=await host.codec.update(copy(existing),summary,selectedParts?.slice(),geometry);
|
|
287
|
-
if(disposed||generation!==interaction)return;
|
|
288
|
+
if(disposed||generation!==interaction)return false;
|
|
288
289
|
assertEdit(general);if(host.locked(existing.id))throw new Error(t('COMMENT_SUBMITTED: submitted evidence is immutable'));
|
|
289
290
|
const all=host.feedback(),index=all.indexOf(existing);
|
|
290
|
-
if(index<0)return;
|
|
291
|
+
if(index<0)return false;
|
|
291
292
|
all.splice(index,1,replacement);
|
|
292
293
|
}else existing.summary=summary;
|
|
293
294
|
}else if(general){
|
|
@@ -296,22 +297,24 @@ export function bindStageComments<Row extends CommentRow=Feedback,Pose extends C
|
|
|
296
297
|
}else{
|
|
297
298
|
assertCapture();if(!pose||!host.codec&&!pose.frame&&!pose.timeBasis)throw new Error(t(pose?.frameReason??'COMMENT_FRAME_UNAVAILABLE: provide an explicit producer clock or a decoded reference frame index'));
|
|
298
299
|
busy=true;field.disabled=true;syncChips();
|
|
299
|
-
if(host.codec){const pixels=await prepared;if(disposed||generation!==interaction)return;assertCapture();const row=await host.codec.create(pose,view!,screen,pixels!,bookmark,summary,selectedParts?.slice());if(disposed||generation!==interaction)return;assertCapture();if(host.pose(view!)?.mode!==placementMode)return;host.add(row);}
|
|
300
|
+
if(host.codec){const pixels=await prepared;if(disposed||generation!==interaction)return false;assertCapture();const row=await host.codec.create(pose,view!,screen,pixels!,bookmark,summary,selectedParts?.slice());if(disposed||generation!==interaction)return false;assertCapture();if(host.pose(view!)?.mode!==placementMode)return false;host.add(row);}
|
|
300
301
|
else {const rigPose=pose as unknown as CommentPose;
|
|
301
302
|
const world=region(unprojectMark(screen,rigPose.camera),unprojectMark({x:screen.x+screen.width,y:screen.y+screen.height},rigPose.camera));
|
|
302
303
|
const slots=rigPose.posed?drawnSlots(rigPose.posed,world):[];
|
|
303
304
|
const comment:StageComment={schema:'rig-review-comment/1',mode:placementMode as StageComment['mode'],viewport:view!,frame:rigPose.frame,...(rigPose.timeBasis?{timeBasis:rigPose.timeBasis}:{}),time:rigPose.time,animation:rigPose.animation,sourceHash:rigPose.sourceHash,modelHash:rigPose.modelHash,referenceHash:rigPose.referenceHash,referenceId:rigPose.referenceId,camera:copy(rigPose.camera),screen,world,slots,crop:(await prepared)!,bookmark};
|
|
304
305
|
assertCapture();
|
|
305
|
-
if(disposed||generation!==interaction||host.pose(view!)?.mode!==placementMode)return;
|
|
306
|
+
if(disposed||generation!==interaction||host.pose(view!)?.mode!==placementMode)return false;
|
|
306
307
|
const n=rigPose.frame?.index??null;host.add({id:crypto.randomUUID(),frameStart:n,frameEnd:n,target:slots[0]?{kind:'slot',name:slots[0].slot}:{kind:'rig',name:rigPose.rig},category:'defect',summary,context:{animation:rigPose.animation,time:rigPose.time,frame:rigPose.frame?.basis==='producer'?n:null,...(turn?{turn:turn as any}:{}),interval:n===null?null:{frameStart:n,frameEnd:n,inclusive:true},comment:comment as any} } as unknown as Row,rigPose.side);
|
|
307
308
|
}
|
|
308
309
|
}
|
|
309
310
|
busy=true;field.disabled=true;syncChips();
|
|
310
311
|
await host.changed();
|
|
311
|
-
if(disposed||generation!==interaction)return;
|
|
312
|
-
cancel();refresh();revealLatest();
|
|
313
|
-
}catch(e){if(disposed||generation!==interaction)return;const
|
|
314
|
-
|
|
312
|
+
if(disposed||generation!==interaction)return false;
|
|
313
|
+
cancel();refresh();revealLatest();return true;
|
|
314
|
+
}catch(e){if(disposed||generation!==interaction)return false;const rawMsg=e instanceof Error?e.message:String(e),msg=/^PARTS_COMMENT_OUT_OF_BOUNDS:/.test(rawMsg)?'PARTS_COMMENT_OUT_OF_BOUNDS: region exceeds original image':/^JOB_[A-Z_]+$/.test(rawMsg)&&t('job.submit.'+rawMsg)!=='job.submit.'+rawMsg?'job.submit.'+rawMsg:rawMsg;errorSource=toEn(msg);error.textContent=t(errorSource);place();host.error(t(errorSource));field.disabled=false;field.focus();return false;}finally{busy=false;if(composer===form)syncChips();}};
|
|
315
|
+
form.onkeydown=e=>{if(e.key==='Escape'){e.preventDefault();e.stopPropagation();cancel();renderPins();pane.focus();}else if(e.key==='Enter'&&!e.isComposing&&!composerReadOnly){e.preventDefault();e.stopPropagation();void submitComposer();}};
|
|
316
|
+
form.onsubmit=e=>{e.preventDefault();return submitComposer();};
|
|
317
|
+
field.focus();last='';host.draftChanged?.();
|
|
315
318
|
};
|
|
316
319
|
const disposers:(()=>void)[]=[];
|
|
317
320
|
for(const [key,pane]of Object.entries(host.viewports)){
|
|
@@ -349,7 +352,7 @@ export function bindStageComments<Row extends CommentRow=Feedback,Pose extends C
|
|
|
349
352
|
}
|
|
350
353
|
if(!pending||pending.id!==e.pointerId)return;e.preventDefault();e.stopImmediatePropagation();pending.end=local(e);draftMark={view,mode:pending.mode,screen:region(pending.start,pending.end)};last='';};
|
|
351
354
|
const up=async(e:PointerEvent)=>{
|
|
352
|
-
if(geometryDrag?.id===e.pointerId){e.preventDefault();e.stopImmediatePropagation();geometryDrag=null;if(pane!.hasPointerCapture(e.pointerId))pane!.releasePointerCapture(e.pointerId);return;}
|
|
355
|
+
if(geometryDrag?.id===e.pointerId){e.preventDefault();e.stopImmediatePropagation();geometryDrag=null;if(pane!.hasPointerCapture(e.pointerId))pane!.releasePointerCapture(e.pointerId);if(composer&&!composerReadOnly)composerField?.focus();return;}
|
|
353
356
|
if(pinPress?.id===e.pointerId){e.preventDefault();e.stopImmediatePropagation();const pin=pinPress.pin;pinPress=null;if(pane!.hasPointerCapture(e.pointerId))pane!.releasePointerCapture(e.pointerId);pin.click();return;}
|
|
354
357
|
if(!pending||pending.id!==e.pointerId)return;e.preventDefault();e.stopImmediatePropagation();const p=pending;pending=null;if(pane!.hasPointerCapture(e.pointerId))pane!.releasePointerCapture(e.pointerId);try{await p.settled;assertCapture();if(disposed||interaction!==p.interaction||!enabled)return;const r=Math.hypot(p.end.x-p.start.x,p.end.y-p.start.y)<4?region(p.start,p.start):region(p.start,p.end);openComposer(view,r,undefined,p.mode);}catch(error){host.error(String(error));cancel();}};
|
|
355
358
|
const abort=(e:PointerEvent)=>{if(pending?.view===view&&pending.id===e.pointerId||geometryDrag?.id===e.pointerId||pinPress?.id===e.pointerId)cancel();};
|
|
@@ -358,7 +361,7 @@ export function bindStageComments<Row extends CommentRow=Feedback,Pose extends C
|
|
|
358
361
|
pane!.addEventListener('pointerdown',down,true);pane!.addEventListener('pointermove',move,true);pane!.addEventListener('pointerup',up,true);pane!.addEventListener('pointercancel',abort,true);pane!.addEventListener('lostpointercapture',abort,true);
|
|
359
362
|
disposers.push(()=>{pane!.removeEventListener('pointerdown',down,true);pane!.removeEventListener('pointermove',move,true);pane!.removeEventListener('pointerup',up,true);pane!.removeEventListener('pointercancel',abort,true);pane!.removeEventListener('lostpointercapture',abort,true);});
|
|
360
363
|
}
|
|
361
|
-
const key=(e:KeyboardEvent)=>{if(host.shortcutActive&&!host.shortcutActive())return;if(e.key==='Escape'&&(pending||composer||pinPress)){e.preventDefault();cancel();renderPins();return;}if(e.defaultPrevented||e.repeat||e.ctrlKey||e.metaKey||e.altKey||textEntryFocused(e.target)||host.shortcutBlocked?.())return;if(e.key.toLowerCase()==='c'){e.preventDefault();setOpen(inline?!enabled:list.hidden);}};
|
|
364
|
+
const key=(e:KeyboardEvent)=>{if(host.shortcutActive&&!host.shortcutActive())return;if(e.key==='Escape'&&(pending||composer||pinPress)){e.preventDefault();cancel();renderPins();return;}if(e.key==='Enter'&&!e.isComposing&&composer&&!composerReadOnly&&!busy&&!textEntryFocused(e.target)){e.preventDefault();void composerSubmit?.();return;}if(e.defaultPrevented||e.repeat||e.ctrlKey||e.metaKey||e.altKey||textEntryFocused(e.target)||host.shortcutBlocked?.())return;if(e.key.toLowerCase()==='c'){e.preventDefault();setOpen(inline?!enabled:list.hidden);}};
|
|
362
365
|
window.addEventListener('blur',cancel);window.addEventListener('resize',placeList);document.addEventListener('keydown',key);toggle.onclick=(e?:MouseEvent)=>{if(e?.detail)toggle.blur?.();setOpen(inline?!enabled:list.hidden);};
|
|
363
366
|
const ro=typeof ResizeObserver==='function'?new ResizeObserver(()=>{if(!disposed&&!list.hidden)placeList();}):null;if(ro){try{ro.observe(host.toolbar);if(workspace)ro.observe(workspace);}catch{}}
|
|
364
367
|
const renderPins=()=>{if(disposed)return;if(enabled&&host.hasPicture?.()===false){cancel();setCapture(false);}if(!list.hidden)placeList();const refusal=updateRefusal();if(refusal&&(enabled||pending||composer&&!composerReadOnly&&!composerGeneral)){cancel();setCapture(false);host.error(refusal);}const all=host.feedback().map(f=>({f,mark:readMark(f)})).filter(x=>x.mark);
|
|
@@ -395,5 +398,5 @@ export function bindStageComments<Row extends CommentRow=Feedback,Pose extends C
|
|
|
395
398
|
}}};
|
|
396
399
|
const paint=()=>{if(disposed)return;renderPins();raf=requestAnimationFrame(paint);};
|
|
397
400
|
const offLang=onLang(()=>{if(disposed)return;updateRefusal();renderList();syncComposerLang?.();last='';renderPins();});
|
|
398
|
-
refresh();paint();return {active:()=>enabled,draft:()=>!!pending||!!composer&&!composerReadOnly,refresh,dispose:()=>{disposed=true;ro?.disconnect();offLang();cancelAnimationFrame(raf);cancel();window.removeEventListener('blur',cancel);window.removeEventListener('resize',placeList);document.removeEventListener('keydown',key);for(const dispose of disposers)dispose();for(const layer of layers.values())layer.remove();toggle.onclick=null;list.remove();refusalNote.remove();}};
|
|
401
|
+
refresh();paint();return {active:()=>enabled,draft:()=>!!pending||!!composer&&!composerReadOnly,hasPendingComment:()=>!!composer&&!composerReadOnly&&!composerGeneral&&!!composerField?.value.trim(),commitDraft:async()=>composer&&!composerReadOnly&&composerSubmit?await composerSubmit():true,refresh,dispose:()=>{disposed=true;ro?.disconnect();offLang();cancelAnimationFrame(raf);cancel();window.removeEventListener('blur',cancel);window.removeEventListener('resize',placeList);document.removeEventListener('keydown',key);for(const dispose of disposers)dispose();for(const layer of layers.values())layer.remove();toggle.onclick=null;list.remove();refusalNote.remove();}};
|
|
399
402
|
}
|