rig-review 4.0.2 → 4.2.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.
@@ -140,9 +140,9 @@ export type ViewControlsOptions = {layout:'rigStep1';viewSwitch:ViewSwitchConfig
140
140
  /** One creation site for each common control; hosts retain adjacent tools and camera/event binding. */
141
141
  export function createViewControls(options:ViewControlsOptions) {
142
142
  const rig=options.layout==='rigStep1',compare=options.layout==='legacyCompareStep3';
143
- const zoomIn=actionButton(compare?'+':t(rig?'Zoom in':'job.zoomIn'),null);zoomIn.id='zoom-in';
144
- const zoomOut=actionButton(compare?'−':t(rig?'Zoom out':'job.zoomOut'),null);zoomOut.id='zoom-out';
145
- const fit=actionButton(t(compare?'Fit synchronized views':'Fit'),null);fit.id='fit';
143
+ const zoomIn=actionButton(t(rig||compare?'Zoom in':'job.zoomIn'),null);zoomIn.id='zoom-in';
144
+ const zoomOut=actionButton(t(rig||compare?'Zoom out':'job.zoomOut'),null);zoomOut.id='zoom-out';
145
+ const fit=actionButton(t('Fit'),null);fit.id='fit';
146
146
  const value=panelMake(rig||compare?'output':'span',{id:compare?'zoom-label':'zoom-value',textContent:rig||compare?'100%':''});
147
147
  const sync=panelMake('input',{id:'camera-sync',type:'checkbox'});
148
148
  const syncLabel=labelledControl(t('Sync cameras'),sync,true);
@@ -166,11 +166,14 @@ export function createViewControls(options:ViewControlsOptions) {
166
166
  item.button.disabled=!!reason;item.button.title=reason??'';
167
167
  if(reason)item.button.setAttribute('aria-description',reason);else item.button.removeAttribute('aria-description');
168
168
  };
169
- if(rig){
170
- const config=options.viewSwitch;
171
- viewSwitch=panelMake('details',{id:'view-menu',className:'view-menu'});
172
- const groups=config.groups.filter(group=>!group.hidden).map(group=>group.modes.filter(mode=>!mode.hidden)).filter(modes=>modes.length);
173
- const current=groups.flat().find(mode=>mode.id===config.currentMode);
169
+ let config=rig?options.viewSwitch:null;
170
+ const configure=(next:ViewSwitchConfig)=>{
171
+ config=next;modes.clear();
172
+ for(const item of viewSwitch!.querySelectorAll?.('button')??[])(item as HTMLButtonElement).onclick=null;
173
+ if(viewSwitch!.children.length)viewSwitch!.replaceChildren();
174
+ viewSwitch!.open=false;
175
+ const groups=next.groups.filter(group=>!group.hidden).map(group=>group.modes.filter(mode=>!mode.hidden)).filter(modes=>modes.length);
176
+ const current=groups.flat().find(mode=>mode.id===next.currentMode);
174
177
  const label=viewLabel=panelMake('span',{id:'view-menu-label',textContent:current?t(current.labelKey):''});
175
178
  const summary=panelMake('summary',{},t('View switch')+' ',label);summary.setAttribute('aria-label',t('View layout'));
176
179
  const list=panelMake('div',{className:'view-menu-list'});list.setAttribute('role','group');list.setAttribute('aria-label',t('View'));
@@ -179,7 +182,7 @@ export function createViewControls(options:ViewControlsOptions) {
179
182
  for(const mode of group){
180
183
  const button=actionButton(t(mode.labelKey),()=>{
181
184
  if(button.disabled)return;
182
- setMode(mode.id);viewSwitch!.open=false;config.onChange?.(mode.id);
185
+ setMode(mode.id);viewSwitch!.open=false;next.onChange?.(mode.id);
183
186
  });
184
187
  button.dataset.view=mode.id;button.setAttribute('aria-pressed',String(mode.pressed));
185
188
  modes.set(mode.id,{mode,button,group});
@@ -187,10 +190,18 @@ export function createViewControls(options:ViewControlsOptions) {
187
190
  list.append(button);
188
191
  }
189
192
  }
190
- viewSwitch.append(summary,list);
193
+ viewSwitch!.append(summary,list);
194
+ };
195
+ const replaceViewSwitch=(next:ViewSwitchConfig)=>{
196
+ if(!viewSwitch||!config)return ()=>{};
197
+ const previous=config;configure(next);let active=true;
198
+ return ()=>{if(!active)return;active=false;if(config===next)configure(previous);};
199
+ };
200
+ if(rig){
201
+ viewSwitch=panelMake('details',{id:'view-menu',className:'view-menu'});configure(options.viewSwitch);
191
202
  zoomGroup!.append(zoomIn,zoomOut,fit,nativeOne!,viewSwitch,value);
192
- }else if(compare)zoomGroup!.append(syncLabel,zoomOut,value,zoomIn,fit);
193
- return {zoomButtons,zoomGroup,syncLabel,value,nativeOne,viewSwitch,viewModeIds:[...modes.keys()],setMode,setDisabled};
203
+ }else if(compare)zoomGroup!.append(syncLabel,zoomIn,zoomOut,fit,value);
204
+ return {zoomButtons,zoomGroup,syncLabel,value,nativeOne,viewSwitch,get viewModeIds(){return [...modes.keys()];},setMode,setDisabled,replaceViewSwitch};
194
205
  }
195
206
 
196
207
  // Nested or separately disposed pan binders must not restore another binder's override.
@@ -288,9 +299,9 @@ export function bindInspectorTabs(changed:()=>void,beforeChange:()=>void=()=>{},
288
299
  if(user)row.reveal?.(id);
289
300
  };
290
301
  const key=(tab:InspectorTabItem,event:KeyboardEvent)=>{
291
- if(tab.attribute==='aria-pressed')return;const index=tabs.indexOf(tab);
292
- const next=event.key==='ArrowRight'?(index+1)%tabs.length:event.key==='ArrowLeft'?(index+tabs.length-1)%tabs.length:event.key==='Home'?0:event.key==='End'?tabs.length-1:null;
293
- if(next===null)return;event.preventDefault();const target=tabs[next];if(target){if(row.reveal)target.button.focus();activate(target.id,true);if(!row.reveal)target.button.focus();}
302
+ if(tab.attribute==='aria-pressed')return;const visible=tabs.filter(item=>!item.button.hidden),index=visible.indexOf(tab);if(index<0)return;
303
+ const next=event.key==='ArrowRight'?(index+1)%visible.length:event.key==='ArrowLeft'?(index+visible.length-1)%visible.length:event.key==='Home'?0:event.key==='End'?visible.length-1:null;
304
+ if(next===null)return;event.preventDefault();const target=visible[next];if(target){if(row.reveal)target.button.focus();activate(target.id,true);if(!row.reveal)target.button.focus();}
294
305
  };
295
306
  if(root){
296
307
  const tabOf=(event:Event)=>{const button=(event.target as Element|null)?.closest?.('button[data-block-target]');return tabs.find(tab=>tab.button===button);};
@@ -1,7 +1,7 @@
1
1
  /** Browser workspace presentation. Source selection, player clocks and review decisions stay with the page. */
2
2
  import {WorkspacePreferenceStore,panelBounds,type WorkspaceLanguage,type WorkspacePanels,type WorkspacePreferences,type WorkspaceTheme} from './workspace-preferences.ts';
3
3
  import {allocateWorkspaceLayout,bindWorkspaceSeparator,bindWorkspaceDrawer,defaultWorkspaceColumns,InspectorScrollMemory,inspectorTabs,workspaceMinimums,type InspectorTab,type WorkspaceColumns,type WorkspacePanel,type SeparatorRange} from './workspace-layout.ts';
4
- import {bindDomI18n,getLinkLanguage,setLanguagePreference,setLinkLanguage,tr,onLanguageChange} from './i18n.ts';
4
+ import {bindDomI18n,getLinkLanguage,resolveLanguage,setLanguagePreference,setLinkLanguage,tr,onLanguageChange} from './i18n.ts';
5
5
  import {panelMake,actionButton,labelledControl} from './view-controls.ts';
6
6
 
7
7
  /** Header availability belongs to the shared shell, independently of the removed step chips. */
@@ -35,12 +35,12 @@ export function mountStatusBar(options:WorkspaceStatusBarOptions|{placement:'inl
35
35
 
36
36
  export type WorkspaceHeaderCompatibility = 'rigStep1'|'legacyCompareStep3'|'legacyPartsStep2'|'legacyInterviewStep4'|'legacyOwnerStep6';
37
37
  export interface WorkspaceHeaderOptions {
38
- compatibility:WorkspaceHeaderCompatibility;embedded?:boolean;title?:string;revision?:string;
38
+ compatibility:WorkspaceHeaderCompatibility;embedded?:boolean;pendingActRow?:boolean;title?:string;revision?:string;
39
39
  /** Only the stopped compare host supplies its existing domain controls and actions. */
40
40
  compare?:{modeSwitch:HTMLElement;buildPicker:HTMLElement;actions:HTMLElement};
41
41
  }
42
42
  export interface WorkspaceHeader {
43
- header:HTMLElement;title:HTMLElement;subtitle:HTMLElement|null;modeSwitch:HTMLElement|null;dirty:HTMLElement|null;
43
+ header:HTMLElement;actRow:HTMLElement|null;title:HTMLElement;subtitle:HTMLElement|null;modeSwitch:HTMLElement|null;dirty:HTMLElement|null;
44
44
  stages:HTMLElement|null;status:HTMLParagraphElement|null;language:HTMLSelectElement|null;languageLabel:HTMLLabelElement|null;
45
45
  dispose:()=>void;
46
46
  }
@@ -89,15 +89,17 @@ export function mountWorkspaceShell(options:WorkspaceHeaderOptions):WorkspaceHea
89
89
  if(!parts){
90
90
  language=panelMake('select');
91
91
  if(settingsLanguage){language.id='settings-language';language.dataset.appPreference='';}
92
- for(const value of settingsLanguage?['system','en','ko']:['en','ko']){
93
- const text=settingsLanguage?(value==='system'?'System':value==='en'?'English':'한국어'):interview?(value==='en'?'English':'한국어'):'';
92
+ for(const value of ['en','ko']){
93
+ // Owner ruling #873: the top-bar choice is En or Kr, with no System option.
94
+ const text=settingsLanguage?(value==='en'?'En':'Kr'):interview?(value==='en'?'English':'한국어'):'';
94
95
  language.append(panelMake('option',{value,textContent:text}));
95
96
  }
96
- if(settingsLanguage){languageLabel=labelledControl('Language ',language);if(rig)header.append(languageLabel);}
97
+ if(settingsLanguage){if(rig){language.setAttribute('aria-label','Language');header.append(language);}else languageLabel=labelledControl('Language ',language);}
97
98
  else{if(interview)header.append('\n ');header.append(language);if(interview)header.append('\n ');}
98
99
  }
99
100
  if(options.embedded){if(rig||parts)header.hidden=true;else if(interview)language!.hidden=true;}
100
- return {header,title,subtitle,modeSwitch,dirty,stages,status,language,languageLabel,dispose(){header.remove();languageLabel?.remove();}};
101
+ const actRow=rig&&options.pendingActRow?panelMake('div',{id:'workspace-act-row',className:'workspace-act-row',hidden:true}):null;
102
+ return {header,actRow,title,subtitle,modeSwitch,dirty,stages,status,language,languageLabel,dispose(){header.remove();actRow?.remove();languageLabel?.remove();}};
101
103
  }
102
104
 
103
105
  /** Reachable effective bounds, accounting for the other panel's saved desired size. */
@@ -152,6 +154,7 @@ export function bindWorkspaceUI(options:{root?:HTMLElement;regions?:WorkspaceReg
152
154
  if(!sharedLanguage.closest('header'))settingsBody.firstElementChild!.after(sharedLanguage.parentElement!);
153
155
  sourceList.append(settings);
154
156
  const theme=require<HTMLSelectElement>('settings-theme'),language=sharedLanguage,sync=require<HTMLInputElement>('settings-sync'),idle=require<HTMLInputElement>('settings-idle'),status=require('settings-state');
157
+ let languageMigrated=false;
155
158
  const store=new WorkspacePreferenceStore({onStatus:value=>{status.textContent=tr(value.detail);}});let desired={...store.get().panels};
156
159
  const stack=document.createElement('div');stack.className='workspace-stage-stack';for(const child of [...main.children])if(child!==inspector)stack.append(child);main.prepend(stack);
157
160
  const triggers=document.createElement('div');triggers.className='workspace-drawer-triggers';triggers.setAttribute('aria-label','Workspace panels');stack.prepend(triggers);
@@ -175,7 +178,7 @@ export function bindWorkspaceUI(options:{root?:HTMLElement;regions?:WorkspaceReg
175
178
  if(bottom){try{collapsed=localStorage.getItem(bottomCollapseKey)==='true';}catch{}}
176
179
  const memory=new InspectorScrollMemory();const active=():InspectorTab=>{const tab=selectedInspector(scope) as InspectorTab|undefined;return tab&&tabs.includes(tab)?tab:tabs[0]!;};
177
180
  let disposed=false,frame=0,applying=false,available={width:0,height:0},effective=allocateWorkspaceLayout(available,desired,columns);
178
- const panelFor=(tab:InspectorTab)=>{const section=require('inspector-'+tab);return (typeof section.querySelector==='function'?section.querySelector<HTMLElement>('.animate-blocks-panel'):null)??section;};
181
+ const panelFor=(tab:InspectorTab)=>require('inspector-'+tab);
179
182
  const userByTab=new Map<InspectorTab,boolean>(),extentByTab=new Map<InspectorTab,string>(),extentOf=(panel:HTMLElement)=>`${panel.scrollWidth}:${panel.scrollHeight}:${panel.clientWidth}:${panel.clientHeight}`;
180
183
  const capture=()=>{if(!tabs.length)return;const tab=active(),section=require('inspector-'+tab),panel=panelFor(tab),saved=memory.snapshot()[tab];if(!section.hidden&&(!saved||saved.x<=Math.max(0,panel.scrollWidth-panel.clientWidth)&&saved.y<=Math.max(0,panel.scrollHeight-panel.clientHeight)))memory.capture(tab,panel,false);};
181
184
  const restore=()=>{if(disposed||!tabs.length)return;const tab=active(),panel=panelFor(tab);if(panel.clientWidth>0||panel.clientHeight>0)extentByTab.set(tab,extentOf(panel));memory.restore(tab,panel);};
@@ -205,15 +208,20 @@ export function bindWorkspaceUI(options:{root?:HTMLElement;regions?:WorkspaceReg
205
208
  let bottomHeight=effective.inspectorHeight;
206
209
  if(bottom){
207
210
  const compact=collapsed||effective.inspectorMode==='drawer';bottomBody!.hidden=collapsed;
208
- const actTarget=dialogs.inspectorHeight.open?bottom.actHome:bottomHeading!;if(bottom.act.parentElement!==actTarget)actTarget.append(bottom.act);
209
- inspector.dataset.collapsed=String(compact);bottom.collapse.setAttribute('aria-expanded',String(!collapsed));bottom.collapse.textContent=tr(collapsed?'Expand bottom panel':'Collapse bottom panel');
211
+ const actTarget=bottom.actHome.id==='workspace-act-row'||dialogs.inspectorHeight.open?bottom.actHome:bottomHeading!;if(bottom.act.parentElement!==actTarget)actTarget.append(bottom.act);
212
+ const collapseLabel=tr(collapsed?'Expand bottom panel':'Collapse bottom panel');
213
+ inspector.dataset.collapsed=String(compact);bottom.collapse.setAttribute('aria-expanded',String(!collapsed));bottom.collapse.textContent=collapsed?'⌃':'⌄';bottom.collapse.setAttribute('aria-label',collapseLabel);bottom.collapse.setAttribute('title',collapseLabel);
210
214
  if(compact)bottomHeight=bottomHeading!.getBoundingClientRect().height;
211
215
  }
212
216
  main.style.gridTemplateRows=`minmax(0,1fr) ${effective.inspectorMode==='panel'&&!collapsed?gap:0}px ${bottomHeight}px`;
213
217
  layout.dataset.stageMinimum=String(effective.stageMinimumSatisfied);for(const binding of bindings)binding.refresh();options.changed();restore();
214
218
  }finally{applying=false;}
215
219
  }
216
- const renderSettings=()=>{const value=store.get();setLanguagePreference(value.language);settingsToggle.setAttribute('aria-expanded',String(!value.settingsCollapsed));settingsBody.hidden=value.settingsCollapsed;settings.dataset.collapsed=String(value.settingsCollapsed);theme.value=options.currentTheme?.()??value.theme;language.value=getLinkLanguage()??value.language;sync.checked=value.defaultCameraSync;idle.checked=value.defaultIdleRepeat;status.textContent=tr(store.status().detail);};
220
+ const renderSettings=()=>{const value=store.get();
221
+ // A stored or default 'system' becomes the browser's language once (ko → ko, else en) and is kept (#873).
222
+ const shown=value.language==='system'?resolveLanguage('system'):value.language;
223
+ if(value.language==='system'&&!languageMigrated){languageMigrated=true;store.update({language:shown});}
224
+ setLanguagePreference(shown);settingsToggle.setAttribute('aria-expanded',String(!value.settingsCollapsed));settingsBody.hidden=value.settingsCollapsed;settings.dataset.collapsed=String(value.settingsCollapsed);theme.value=options.currentTheme?.()??value.theme;language.value=getLinkLanguage()??shown;sync.checked=value.defaultCameraSync;idle.checked=value.defaultIdleRepeat;status.textContent=tr(store.status().detail);};
217
225
  const revealInspector=()=>{
218
226
  if(bottom&&collapsed){collapsed=false;try{localStorage.setItem(bottomCollapseKey,'false');}catch{}apply();}
219
227
  if(effective.inspectorMode==='drawer'&&!dialogs.inspectorHeight.open){for(const dialog of Object.values(dialogs))if(dialog.open)dialog.close();buttons.inspectorHeight.click();if(bottom)apply();}