@rig-c/review 2.7.1 → 2.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18,15 +18,17 @@ export interface CommentUiMark extends Partial<Omit<StageComment,'mode'>> {mode:
18
18
  export interface CommentCodec<Row extends CommentRow,Pose extends CommentUiPose> {
19
19
  read:(row:Row)=>CommentUiMark|null;signature:(pose:Pose)=>unknown;matches:(mark:CommentUiMark,pose:Pose,row:Row)=>boolean;
20
20
  label:(row:Row,mark:CommentUiMark)=>string;
21
- create:(pose:Pose,view:StageComment['viewport'],screen:MarkRegion,crop:StageComment['crop'],bookmark:unknown,summary:string)=>Promise<Row>;
21
+ chips?:(pose:Pose,screen:MarkRegion,existing?:Row)=>{selected:string[];candidates:string[]};
22
+ update?:(row:Row,summary:string,parts?:string[])=>Promise<Row>|Row;
23
+ create:(pose:Pose,view:StageComment['viewport'],screen:MarkRegion,crop:StageComment['crop'],bookmark:unknown,summary:string,parts?:string[])=>Promise<Row>;
22
24
  }
23
25
  interface Host<Row extends CommentRow=Feedback,Pose extends CommentUiPose=CommentPose> {
24
- toolbar:HTMLElement;viewports:Partial<Record<StageComment['viewport'],HTMLElement>>;
26
+ toolbar:HTMLElement;toggle?:HTMLButtonElement;listHost?:HTMLElement;viewports:Partial<Record<StageComment['viewport'],HTMLElement>>;
25
27
  pose:(view:StageComment['viewport'])=>Pose|null;pause:()=>Promise<void>;
26
28
  bookmark:()=>unknown;restore:(bookmark:unknown,timeOnly?:boolean)=>Promise<void>;
27
29
  feedback:()=>Row[];locked:(id:string)=>boolean;
28
30
  add:(feedback:Row,side?:'a'|'b')=>void;changed:()=>void;error:(message:string)=>void;
29
- refusal?:()=>string|null;blocked:()=>boolean;shortcutBlocked?:()=>boolean;codec?:CommentCodec<Row,Pose>;
31
+ refusal?:()=>string|null;blocked:()=>boolean;busy?:()=>boolean;busyError?:(message:string)=>void;shortcutBlocked?:()=>boolean;shortcutActive?:()=>boolean;codec?:CommentCodec<Row,Pose>;
30
32
  }
31
33
  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;}};
32
34
  const copy=<T>(v:T):T=>JSON.parse(JSON.stringify(v));
@@ -61,24 +63,46 @@ async function crop(pose:CommentUiPose,r:MarkRegion):Promise<StageComment['crop'
61
63
  }
62
64
  export function bindStageComments<Row extends CommentRow=Feedback,Pose extends CommentUiPose=CommentPose>(host:Host<Row,Pose>):{refresh:()=>void;dispose:()=>void;active:()=>boolean;draft:()=>boolean}{
63
65
  const readMark=(row:Row):CommentUiMark|null=>host.codec?host.codec.read(row):markOf(row as unknown as Feedback);
64
- const toggle=document.getElementById('stage-comment') as HTMLButtonElement;Object.assign(toggle.style,{whiteSpace:'nowrap',flex:'none'});
65
- const list=document.createElement('section');list.id='stage-comment-list';list.className='stage-comment-list stage-comment-ui';list.setAttribute('aria-label',t('Stage comments'));list.hidden=true;
66
+ 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'});
67
+ const inline=!!host.listHost;
68
+ const list=document.createElement('section');list.id='stage-comment-list';list.className='stage-comment-list stage-comment-ui';list.classList.toggle('stage-comment-list-inline',inline);list.setAttribute('aria-label',t(inline?'Issues':'Stage comments'));list.hidden=!inline;
66
69
  // An absolute overlay is not stage chrome: workspace measures stack children
67
70
  // to allocate Inspector height. Keep the list in its positioned main instead,
68
71
  // anchored below the toolbar even when the bar wraps (#284).
69
- const workspace=host.toolbar.closest('main');if(workspace)workspace.append(list);else host.toolbar.after(list);
70
- const placeList=()=>{const bar=host.toolbar.getBoundingClientRect?.(),parent=(workspace??host.toolbar).getBoundingClientRect?.();if(bar&&parent&&Number.isFinite(bar.bottom)&&Number.isFinite(parent.top)&&bar.bottom>parent.top){const topPx=`${Math.ceil(bar.bottom-parent.top)+5}px`;if(list.style.top!==topPx)list.style.top=topPx;}};
71
- 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','false');const originalTitle=toEn(toggle.title);
72
- const updateRefusal=()=>{const raw=host.refusal?.()??null,reason=raw?t(raw):null,prev=refusalNote.textContent||'',nextTitle=reason??t(originalTitle);toggle.disabled=false;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;};
72
+ const workspace=host.toolbar.closest('main');if(host.listHost)host.listHost.append(list);else if(workspace)workspace.append(list);else host.toolbar.after(list);
73
+ const placeList=()=>{if(inline)return;const bar=host.toolbar.getBoundingClientRect?.(),parent=(workspace??host.toolbar).getBoundingClientRect?.();if(bar&&parent&&Number.isFinite(bar.bottom)&&Number.isFinite(parent.top)&&bar.bottom>parent.top){const topPx=`${Math.ceil(bar.bottom-parent.top)+5}px`;if(list.style.top!==topPx)list.style.top=topPx;}};
74
+ 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);
75
+ 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;};
73
76
  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);}
74
77
  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,syncComposerLang:(()=>void)|null=null,draftMark:{view:StageComment['viewport'];mode:string;screen:MarkRegion}|null=null,busy=false,last='',raf=0,interaction=0;
75
- const setCapture=(value:boolean)=>{enabled=value;toggle.setAttribute('aria-pressed',String(value||!list.hidden));for(const pane of Object.values(host.viewports))pane!.classList.toggle('stage-comment-mode',value);};
78
+ const setCapture=(value:boolean)=>{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);};
76
79
  const cancel=()=>{++interaction;const previous=pending;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;syncComposerLang=null;draftMark=null;last='';};
77
80
  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'));};
78
81
  const assertEdit=()=>{const reason=updateRefusal();if(reason){setCapture(false);host.error(reason);throw new Error(reason);}if(host.blocked())throw new Error(t('COMMENT_BUSY: wait for inspection'));};
79
- const jump=async(f:Row):Promise<boolean>=>{const mark=readMark(f);if(!mark)return false;const panes=Object.values(host.viewports).map(p=>({pane:p!,visibility:p!.style.visibility}));try{cancel();for(const {pane}of panes)pane.style.visibility='hidden';await host.restore(mark.bookmark,mark.frame===null);last='';return true;}catch(error){host.error(String(error));return false;}finally{for(const {pane,visibility}of panes)pane.style.visibility=visibility;}};
82
+ let jumpGeneration = 0;
83
+ let hiddenPanes: {pane: HTMLElement; visibility: string}[] | null = null;
84
+ const jump = async (row: Row): Promise<boolean> => {
85
+ const mark = readMark(row);if (!mark) return false;
86
+ cancel();const generation = interaction, request = ++jumpGeneration;
87
+ hiddenPanes ??= Object.values(host.viewports).map(pane => ({pane: pane!, visibility: pane!.style.visibility}));
88
+ try {
89
+ for (const {pane} of hiddenPanes) pane.style.visibility = 'hidden';
90
+ await host.restore(mark.bookmark, mark.frame === null);
91
+ if (disposed || request !== jumpGeneration || generation !== interaction) return false;
92
+ last = '';return true;
93
+ } catch (error) {
94
+ if (!disposed && request === jumpGeneration) host.error(String(error));
95
+ return false;
96
+ } finally {
97
+ if (request === jumpGeneration) {
98
+ if (!disposed) for (const {pane, visibility} of hiddenPanes!) pane.style.visibility = visibility;
99
+ hiddenPanes = null;
100
+ }
101
+ }
102
+ };
80
103
  const setOpen=(value:boolean)=>{
81
- if(!value){cancel();list.hidden=true;toggle.setAttribute('aria-expanded','false');setCapture(false);return;}
104
+ if(!value){cancel();list.hidden=!inline;toggle.setAttribute('aria-expanded',String(inline));setCapture(false);return;}
105
+ if(host.busy?.()){(host.busyError??host.error)(t('COMMENT_BUSY: close the active editor or wait for the inspection to settle'));return;}
82
106
  if(host.shortcutBlocked?.()){host.error(t('COMMENT_BUSY: close the active editor or wait for the inspection to settle'));return;}
83
107
  const reason=updateRefusal();
84
108
  if(!reason&&host.blocked()){host.error(t('COMMENT_BUSY: close the active editor or wait for the inspection to settle'));return;}
@@ -87,7 +111,7 @@ export function bindStageComments<Row extends CommentRow=Feedback,Pose extends C
87
111
  setCapture(true);
88
112
  };
89
113
  const openComment=async(f:Row)=>{const mark=readMark(f);if(!mark)return;if(list.hidden)setOpen(true);if(list.hidden)return;if(await jump(f)){const reason=updateRefusal();setCapture(!reason&&!host.blocked());openComposer(mark.viewport,mark.screen,f,host.pose(mark.viewport)?.mode??mark.mode);}};
90
- const renderList=()=>{placeList();list.setAttribute('aria-label',t('Stage 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:'nowrap',overflow:'hidden',textOverflow:'ellipsis'});list.append(note);}const all=host.feedback().filter(f=>readMark(f));toggle.textContent=t(`Comment · C (${all.length})`);if(!all.length){const empty=document.createElement('p');empty.textContent=t(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()){
114
+ const renderList=()=>{placeList();list.setAttribute('aria-label',t(inline?'Issues':'Stage comments'));list.replaceChildren();const title=document.createElement('strong');title.textContent=t(inline?'Issues':'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);}const all=host.feedback().filter(f=>readMark(f));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 issues 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()){
91
115
  const mark=readMark(f)!,row=document.createElement('div');row.className='stage-comment-item';row.dataset.commentId=f.id;
92
116
  const go=document.createElement('button');go.type='button';go.className='stage-comment-summary';go.textContent=host.codec?`${i+1} · ${host.codec.label(f,mark)}`:`${i+1} · ${mark.mode.toUpperCase()} · ${mark.viewport.toUpperCase()} · ${mark.frame?`F${mark.frame.index} (${mark.frame.basis})`:t(feedbackTimingLabel(f as unknown as Feedback))} · ${f.summary}`;go.onclick=()=>openComment(f);row.append(go);
93
117
  if(host.locked(f.id)){const submitted=document.createElement('span');submitted.textContent=t('Submitted');row.append(submitted);}
@@ -120,23 +144,53 @@ export function bindStageComments<Row extends CommentRow=Feedback,Pose extends C
120
144
  }
121
145
  // Capture all view context now; camera or dial changes while typing cannot rebind the mark.
122
146
  const pose=host.pose(view),bookmark=copy(host.bookmark()),turn=pose?.turn===undefined?null:copy(pose.turn);
147
+ const initialParts = pose ? host.codec?.chips?.(pose, screen, existing) : undefined;
148
+ let selectedParts = initialParts?.selected.slice();
149
+ const chipBox = initialParts ? document.createElement('div') : null;
150
+ const chipNames = initialParts ? [...new Set([...initialParts.selected, ...initialParts.candidates])] : [];
151
+ const syncChips = () => {
152
+ if (!chipBox || !initialParts) return;
153
+ chipBox.setAttribute('aria-label', t('Issue parts'));
154
+ chipBox.replaceChildren(...chipNames.map(name => {
155
+ const chip = document.createElement('button');
156
+ chip.type = 'button';chip.textContent = name;chip.dataset.commentPart = name;chip.disabled = composerReadOnly || busy;
157
+ chip.setAttribute('aria-pressed', String(selectedParts!.includes(name)));
158
+ chip.onclick = () => {
159
+ if (busy || composerReadOnly) return;
160
+ const chosen = new Set(selectedParts);
161
+ if (chosen.has(name)) chosen.delete(name);else chosen.add(name);
162
+ selectedParts = chipNames.filter(part => chosen.has(part));
163
+ syncChips();place();
164
+ };
165
+ return chip;
166
+ }));
167
+ };
168
+ if (chipBox) {chipBox.className = 'stage-comment-parts';chipBox.setAttribute('role', 'group');form.append(chipBox);syncChips();}
123
169
  if(initialRefusal){errorSource=toEn(host.refusal?.()??initialRefusal);error.textContent=t(errorSource);host.error(t(errorSource));}
124
170
  else if(!host.codec&&!existing&&pose&&!pose.frame&&!pose.timeBasis){errorSource=toEn(pose.frameReason??'COMMENT_FRAME_UNAVAILABLE: no explicit frame index');error.textContent=t(errorSource);}
125
- syncComposerLang=()=>{if(composer!==form)return;form.setAttribute('aria-label',t('Comment composer'));field.setAttribute('aria-label',t('Comment text'));field.placeholder=t('Describe this spot…');hint.textContent=t(composerReadOnly?'Read only · Escape closes':'Enter saves · Escape cancels');if(removeBtn)removeBtn.textContent=t('Delete');if(errorSource)error.textContent=t(errorSource);};
171
+ syncComposerLang=()=>{if(composer!==form)return;form.setAttribute('aria-label',t('Comment composer'));field.setAttribute('aria-label',t('Comment text'));field.placeholder=t('Describe this spot…');hint.textContent=t(composerReadOnly?'Read only · Escape closes':'Enter saves · Escape cancels');if(removeBtn)removeBtn.textContent=t('Delete');if(errorSource)error.textContent=t(errorSource);syncChips();};
126
172
  pane.append(form);place();
127
173
  const previous=existing?readMark(existing):null;
128
174
  const prepared=previous?Promise.resolve(previous.crop):pose?crop(pose,screen):Promise.reject(new Error('COMMENT_VIEW_UNAVAILABLE'));
129
175
  prepared.catch(()=>{});
130
176
  form.onkeydown=e=>{if(e.key==='Escape'){e.preventDefault();e.stopPropagation();setOpen(false);pane.focus();}};
131
177
  form.onsubmit=async e=>{e.preventDefault();if(busy)return;if(generation!==interaction||host.pose(view)&&host.pose(view)?.mode!==placementMode){cancel();return;}const summary=field.value.trim();if(!summary){field.focus();return;}try{
178
+ if(selectedParts && !selectedParts.length)throw new Error(t('Select at least one part.'));
132
179
  if(existing){
133
180
  assertEdit();if(host.locked(existing.id))throw new Error(t('COMMENT_SUBMITTED: submitted evidence is immutable'));
134
- busy=true;field.disabled=true;
135
- existing.summary=summary;
181
+ busy=true;field.disabled=true;syncChips();
182
+ if(host.codec?.update){
183
+ const replacement=await host.codec.update(copy(existing),summary,selectedParts?.slice());
184
+ if(disposed||generation!==interaction)return;
185
+ assertEdit();if(host.locked(existing.id))throw new Error(t('COMMENT_SUBMITTED: submitted evidence is immutable'));
186
+ const all=host.feedback(),index=all.indexOf(existing);
187
+ if(index<0)return;
188
+ all.splice(index,1,replacement);
189
+ }else existing.summary=summary;
136
190
  }else{
137
191
  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'));
138
- busy=true;field.disabled=true;
139
- if(host.codec){const row=await host.codec.create(pose,view,screen,await prepared,bookmark,summary);assertCapture();if(disposed||generation!==interaction||host.pose(view)?.mode!==placementMode)return;host.add(row);}
192
+ busy=true;field.disabled=true;syncChips();
193
+ 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);}
140
194
  else {const rigPose=pose as unknown as CommentPose;
141
195
  const world=region(unprojectMark(screen,rigPose.camera),unprojectMark({x:screen.x+screen.width,y:screen.y+screen.height},rigPose.camera));
142
196
  const slots=rigPose.posed?drawnSlots(rigPose.posed,world):[];
@@ -147,21 +201,21 @@ export function bindStageComments<Row extends CommentRow=Feedback,Pose extends C
147
201
  }
148
202
  }
149
203
  cancel();host.changed();refresh();
150
- }catch(e){const msg=e instanceof Error?e.message:String(e);errorSource=toEn(msg);error.textContent=t(errorSource);place();if(locked)host.error(t(errorSource));field.disabled=false;field.focus();}finally{busy=false;}};
204
+ }catch(e){if(disposed||generation!==interaction)return;const msg=e instanceof Error?e.message:String(e);errorSource=toEn(msg);error.textContent=t(errorSource);place();if(locked)host.error(t(errorSource));field.disabled=false;field.focus();}finally{busy=false;if(composer===form)syncChips();}};
151
205
  field.focus();last='';
152
206
  };
153
207
  const disposers:(()=>void)[]=[];
154
208
  for(const [key,pane]of Object.entries(host.viewports)){
155
209
  const view=key as StageComment['viewport'],local=(e:PointerEvent)=>{const r=pane!.getBoundingClientRect();return {x:Math.max(0,Math.min(pane!.clientWidth,e.clientX-r.left-pane!.clientLeft)),y:Math.max(0,Math.min(pane!.clientHeight,e.clientY-r.top-pane!.clientTop))};};
156
- const down=(e:PointerEvent)=>{if(e.button!==0||!e.isPrimary||(e.target as Element)?.closest?.('.stage-comment-ui,button,input'))return;if(enabled||!list.hidden){try{assertCapture();}catch{return;}}if(!enabled||host.blocked())return;e.preventDefault();e.stopImmediatePropagation();cancel();const at=local(e),mode=host.pose(view)?.mode;if(!mode)return;const generation=interaction;pending={view,start:at,end:at,mode,id:e.pointerId,interaction:generation,settled:host.pause()};pending.settled.catch(e=>{if(interaction===generation&&!disposed)host.error(String(e));});pane!.setPointerCapture(e.pointerId);};
210
+ const down=(e:PointerEvent)=>{if(e.button!==0||!e.isPrimary||(e.target as Element)?.closest?.('.stage-comment-ui,button,input'))return;if(enabled||!inline&&!list.hidden){try{assertCapture();}catch{return;}}if(!enabled||host.blocked())return;e.preventDefault();e.stopImmediatePropagation();cancel();const at=local(e),mode=host.pose(view)?.mode;if(!mode)return;const generation=interaction;pending={view,start:at,end:at,mode,id:e.pointerId,interaction:generation,settled:host.pause()};pending.settled.catch(e=>{if(interaction===generation&&!disposed)host.error(String(e));});pane!.setPointerCapture(e.pointerId);};
157
211
  const move=(e:PointerEvent)=>{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='';};
158
212
  const up=async(e:PointerEvent)=>{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();}};
159
213
  const abort=(e:PointerEvent)=>{if(pending?.view===view&&pending.id===e.pointerId)cancel();};
160
214
  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);
161
215
  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);});
162
216
  }
163
- const key=(e:KeyboardEvent)=>{if(e.key==='Escape'&&(pending||composer||(enabled||!list.hidden)&&!host.shortcutBlocked?.()&&!textEntryFocused(e.target))){e.preventDefault();setOpen(false);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(list.hidden);}};
164
- window.addEventListener('blur',cancel);window.addEventListener('resize',placeList);document.addEventListener('keydown',key);toggle.onclick=()=>setOpen(list.hidden);
217
+ const key=(e:KeyboardEvent)=>{if(host.shortcutActive&&!host.shortcutActive())return;if(e.key==='Escape'&&(pending||composer||(enabled||!inline&&!list.hidden)&&!host.shortcutBlocked?.()&&!textEntryFocused(e.target))){e.preventDefault();setOpen(false);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);}};
218
+ window.addEventListener('blur',cancel);window.addEventListener('resize',placeList);document.addEventListener('keydown',key);toggle.onclick=()=>setOpen(inline?!enabled:list.hidden);
165
219
  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{}}
166
220
  const renderPins=()=>{if(disposed)return;if(!list.hidden)placeList();const refusal=updateRefusal();if(refusal&&(enabled||pending||composer&&!composerReadOnly)){cancel();setCapture(false);host.error(refusal);}const all=host.feedback().map(f=>({f,mark:readMark(f)})).filter(x=>x.mark);
167
221
  // #356: a pose reads the pane's size (a forced layout after the played frame's writes); with no mark, draft or pending
@@ -175,5 +229,5 @@ export function bindStageComments<Row extends CommentRow=Feedback,Pose extends C
175
229
  }if(draftMark)layers.get(draftMark.view)?.append(rectElement(draftMark.screen));}};
176
230
  const paint=()=>{if(disposed)return;renderPins();raf=requestAnimationFrame(paint);};
177
231
  const offLang=onLang(()=>{if(disposed)return;updateRefusal();renderList();syncComposerLang?.();last='';renderPins();});
178
- 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();list.remove();refusalNote.remove();}};
232
+ 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();}};
179
233
  }
package/web/styles.css CHANGED
@@ -459,8 +459,6 @@ body.job-window{display:grid;grid-template-rows:auto auto minmax(0,1fr);height:1
459
459
  .job-window .job-forms .job-source,.job-window .job-history{overflow-wrap:anywhere;font-family:var(--font-mono);font-size:11px;color:var(--fg-muted)}
460
460
  .job-window .job-history{white-space:pre-wrap;color:var(--warn)}
461
461
  .job-window .job-direction{white-space:pre-wrap;overflow-wrap:anywhere}
462
- .job-window .job-part-images{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px}
463
- .job-window .job-part-images img{width:100%;height:auto;background:var(--rv-media-bg)}
464
462
  @media(max-width:780px){.job-window .job-inspection{grid-template-columns:160px minmax(0,1fr)}.job-window .job-stage #stage-layout{grid-template-columns:minmax(0,1fr);grid-template-rows:repeat(2,minmax(0,1fr))}}
465
463
 
466
464
 
@@ -476,3 +474,13 @@ body.job-window{display:grid;grid-template-rows:auto auto minmax(0,1fr);height:1
476
474
  transform: none;
477
475
  opacity: 1;
478
476
  }
477
+
478
+ /* Parts publications reuse the shared parts columns and fill the job workspace. */
479
+ .job-window .job-inspection[data-job-parts-workspace]{flex:1;grid-template-columns:240px minmax(0,1fr) 300px;grid-template-rows:minmax(0,1fr);min-height:0;min-width:0}
480
+ .job-window .job-inspection[data-job-parts-workspace]>.job-forms{grid-column:3;grid-row:1;min-height:0;min-width:0;border-top:0;border-left:1px solid var(--border)}
481
+
482
+ /* Both job and standalone hosts use the existing parts workspace presentation. */
483
+ .job-window [data-job-parts-workspace]{--panel:var(--rv-panel);--line:var(--border);--text:var(--fg);--muted:var(--fg-muted);--accent:var(--link);--flag:var(--warn);--clean:var(--pass)}
484
+ .job-window .job-parts-stage{display:flex;flex-direction:column;flex:1;min-height:180px;min-width:0;position:relative}
485
+ .job-window .job-parts-stage>main{display:flex;flex:1;min-height:0;min-width:0}
486
+ .job-window [data-job-parts-workspace] [hidden]{display:none!important}
@@ -25,7 +25,7 @@ export interface ViewportProvider {
25
25
  message:(value:string,error?:boolean)=>void;
26
26
  }
27
27
  export interface ViewportController {
28
- state:ViewportState;paneFrame:(target:CameraTarget,hidden?:boolean)=>CameraFrame|null;paneCamera:(target:CameraTarget)=>{zoom:number;center:ViewPoint|null};writeCamera:(target:CameraTarget,value:{zoom:number;center:ViewPoint|null})=>void;activateCamera:(target:CameraTarget)=>void;availableCamera:()=>CameraTarget|null;alignCameras:()=>void;renderCameraControls:()=>void;setCameraSync:(value:boolean)=>void;cameraAction:(action:()=>void)=>void;updateCamera:(target:CameraTarget,value:CameraSignature)=>void;zoomCamera:(factor:number,target?:CameraTarget|null,point?:CameraPoint|null)=>void;panCamera:(target:CameraTarget,dx:number,dy:number)=>void;fitActiveCamera:(target?:CameraTarget|null)=>void;zoomViewport:(target:CameraTarget,deltaY:number,point?:CameraPoint|null)=>void;fitCamera:()=>void;numericView:()=>ControlView;renderNumericView:()=>void;bindControls:()=>void;bindNavigation:(carryRig?:PanCarry,enabled?:()=>boolean)=>()=>void;observeResize:()=>ResizeObserver;
28
+ state:ViewportState;paneFrame:(target:CameraTarget,hidden?:boolean)=>CameraFrame|null;paneCamera:(target:CameraTarget)=>{zoom:number;center:ViewPoint|null};writeCamera:(target:CameraTarget,value:{zoom:number;center:ViewPoint|null})=>void;activateCamera:(target:CameraTarget)=>void;availableCamera:()=>CameraTarget|null;alignCameras:()=>void;renderCameraControls:()=>void;setCameraSync:(value:boolean)=>void;cameraAction:(action:()=>void)=>void;updateCamera:(target:CameraTarget,value:CameraSignature)=>void;zoomCamera:(factor:number,target?:CameraTarget|null,point?:CameraPoint|null)=>void;panCamera:(target:CameraTarget,dx:number,dy:number)=>void;fitActiveCamera:(target?:CameraTarget|null)=>void;zoomViewport:(target:CameraTarget,deltaY:number,point?:CameraPoint|null)=>void;fitCamera:()=>void;numericView:()=>ControlView;renderNumericView:()=>void;bindControls:()=>()=>void;bindNavigation:(carryRig?:PanCarry,enabled?:()=>boolean)=>()=>void;observeResize:()=>ResizeObserver;
29
29
  }
30
30
 
31
31
  export function createViewportController(provider:ViewportProvider,state=createViewportState()):ViewportController {
@@ -72,16 +72,25 @@ function zoomViewport(target:CameraTarget,deltaY:number,point?:CameraPoint|null)
72
72
  provider.render(api);
73
73
  }
74
74
  function numericView():ControlView {
75
+ // ResizeObserver delivery can follow a pointer event. Keep native-image evidence
76
+ // on the same freshly rendered layout before exporting its camera coordinates.
77
+ if(provider.nativeScale&&provider.layoutKey()!==state.cameraLayout)fitCamera();
75
78
  const numeric=(target:CameraTarget)=>{const frame=paneFrame(target,true);if(!frame)return null;const camera=paneCamera(target);if(provider.nativeScale){const center=camera.center??frame.center;return {space:frame.space,center,zoom:camera.zoom,viewport:{width:frame.width,height:frame.height},visible:{x:center.x-frame.width/camera.zoom/2,y:center.y-frame.height/camera.zoom/2,width:frame.width/camera.zoom,height:frame.height/camera.zoom}};}return numericCamera(frame.space,camera.center??frame.center,camera.zoom,frame.baseScale*camera.zoom,frame.width,frame.height);};
76
79
  return {schema:'rig-review-view/1',cameraSync:state.cameraSync,activeCamera:state.activeCamera,cameras:{rig:numeric('rig'),a:null,b:null,reference:numeric('reference')}};
77
80
  }
78
81
  function renderNumericView():void {const node=document.getElementById('view-coordinates');if(node)node.textContent=JSON.stringify(numericView(),null,2);}
79
82
 
80
- function bindControls():void {
83
+ function bindControls():()=>void {
81
84
  button('zoom-in').onclick=()=>cameraAction(()=>zoomCamera(1.25));button('zoom-out').onclick=()=>cameraAction(()=>zoomCamera(1/1.25));button('fit').onclick=()=>cameraAction(()=>fitActiveCamera());
82
85
  input('camera-sync').onchange=()=>cameraAction(()=>setCameraSync(input('camera-sync').checked));
83
- for(const target of targets())for(const event of ['pointerdown','focusin'] as const)paneNodes(target).viewport.addEventListener(event,()=>activateCamera(target));
84
- for(const {target,viewport}of panes())viewport.addEventListener('wheel',event=>{event.preventDefault();const rect=viewport.getBoundingClientRect();cameraAction(()=>zoomViewport(target,event.deltaY,{x:event.clientX-rect.left,y:event.clientY-rect.top}));},{passive:false});
86
+ const disposers:(()=>void)[]=[];
87
+ for(const {target,viewport}of panes()){
88
+ const activate=()=>activateCamera(target);
89
+ const wheel=(event:WheelEvent)=>{event.preventDefault();const rect=viewport.getBoundingClientRect();cameraAction(()=>zoomViewport(target,event.deltaY,{x:event.clientX-rect.left,y:event.clientY-rect.top}));};
90
+ for(const event of ['pointerdown','focusin'] as const){viewport.addEventListener(event,activate);disposers.push(()=>viewport.removeEventListener(event,activate));}
91
+ viewport.addEventListener('wheel',wheel,{passive:false});disposers.push(()=>viewport.removeEventListener('wheel',wheel));
92
+ }
93
+ return ()=>{for(const dispose of disposers)dispose();for(const id of ['zoom-in','zoom-out','fit'])button(id).onclick=null;input('camera-sync').onchange=null;};
85
94
  }
86
95
  function bindNavigation(carryRig?:PanCarry,enabled:()=>boolean=()=>true):()=>void {
87
96
  const disposers:(()=>void)[]=[];disposers.push(bindStageLayout(el('stage-layout'),fitCamera));