@rig-c/review 4.11.0 → 4.12.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 +15 -11
- package/docs/REVIEW_PACKAGE.md +37 -1
- package/docs/STABILITY.md +28 -0
- package/package.json +2 -2
- package/src/job-act.ts +4 -2
- package/src/job-api.ts +4 -2
- package/src/job-contract.ts +3 -0
- package/src/job-front.ts +5 -1
- package/src/job-source.ts +10 -2
- package/src/stage-comment.ts +32 -4
- package/web/catalog-en.ts +8 -2
- package/web/catalog-ko.ts +8 -2
- package/web/inspector-blocks.ts +9 -7
- package/web/interview-panel.ts +2 -2
- package/web/job-rig-screen.ts +6 -1
- package/web/job-session.ts +13 -6
- package/web/label-placement.ts +2 -1
- package/web/main.ts +112 -63
- package/web/rig-host.ts +1 -1
- package/web/stage-comments.ts +6 -2
- package/web/styles.css +22 -1
- package/web/workspace-layout.ts +8 -6
- package/web/workspace-preferences.ts +10 -8
- package/web/workspace-ui.ts +50 -24
package/web/styles.css
CHANGED
|
@@ -121,7 +121,7 @@ main{min-height:0;overflow:hidden;display:flex;flex-direction:column}
|
|
|
121
121
|
.workspace-drawer:not([open]){display:none}.workspace-drawer[open]{display:flex;flex-direction:column;gap:var(--space-2)}
|
|
122
122
|
.workspace-drawer[data-panel=inspectorHeight][open]:not(:modal){inset:auto 0 0;height:min(36dvh,360px);margin:0 auto}
|
|
123
123
|
.workspace-drawer::backdrop{background:var(--rv-backdrop)}
|
|
124
|
-
#job-record-asks{
|
|
124
|
+
#job-record-asks form[data-job-ask]+form[data-job-ask]{margin-top:var(--space-3);padding-top:var(--space-3);border-top:1px solid var(--border)}
|
|
125
125
|
#job-record-asks fieldset{min-width:0;margin:0;padding:0 var(--space-1) var(--space-1);border:0}
|
|
126
126
|
#job-record-asks fieldset>:first-child{margin-top:0}
|
|
127
127
|
#job-record-asks fieldset>button+button{margin-left:var(--space-2)}
|
|
@@ -563,6 +563,14 @@ main{position:relative}.toolbar{anchor-name:--stage-comment-bar}#stage-comment{w
|
|
|
563
563
|
.workspace-act-row .review-dialog-actions{min-width:0;gap:var(--space-2);justify-content:flex-end}
|
|
564
564
|
.workspace-act-row .review-message:not(.error){display:none}
|
|
565
565
|
.workspace-act-row .review-message.error{max-width:none;white-space:normal;overflow:visible;text-overflow:clip;overflow-wrap:anywhere}
|
|
566
|
+
/* A refusal in the row never widens it nor changes its height (#1040, #1041): while one shows, the row is one grid line.
|
|
567
|
+
* The ask gives way first (one line, ellipsized, full text in its title, at least 12ch); the refusal, the save state and
|
|
568
|
+
* the answers keep their content width, so the refusal reads in full while it fits and only then clamps to two lines. */
|
|
569
|
+
.workspace-act-row .workspace-act-bar:has(.review-message.error){display:grid;grid-template-columns:minmax(12ch,1fr);grid-auto-flow:column;grid-auto-columns:auto;align-items:center}
|
|
570
|
+
.workspace-act-row .workspace-act-bar:has(.review-message.error) .review-dialog-actions{display:contents}
|
|
571
|
+
.workspace-act-row .workspace-act-bar:has(.review-message.error) #workspace-ask-headline{grid-column:1;grid-row:1;min-width:0;white-space:nowrap!important;overflow:hidden;text-overflow:ellipsis;overflow-wrap:normal}
|
|
572
|
+
.workspace-act-row .workspace-act-bar:has(.review-message.error) .review-message.error{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;line-clamp:2;overflow:hidden;line-height:1.25;max-height:var(--control-height);overflow-wrap:normal}
|
|
573
|
+
.workspace-act-row .workspace-act-bar:has(.review-message.error) :is(.review-draft-state,#save,#request-changes){min-width:max-content}
|
|
566
574
|
.workspace-act-row .review-draft-state{min-width:0;max-width:none;white-space:normal;overflow:visible;text-overflow:clip;overflow-wrap:anywhere}
|
|
567
575
|
.workspace-act-row .workspace-act-bar:has(.review-draft-state[data-save-state=failed]){display:grid;grid-template-columns:minmax(0,1fr) auto auto auto;align-items:center}
|
|
568
576
|
.workspace-act-row .workspace-act-bar:has(.review-draft-state[data-save-state=failed]) #workspace-ask-headline{grid-column:1;grid-row:1}
|
|
@@ -595,3 +603,16 @@ main{position:relative}.toolbar{anchor-name:--stage-comment-bar}#stage-comment{w
|
|
|
595
603
|
.interview-question[data-answered]::before{margin-right:var(--space-1)}
|
|
596
604
|
.animation-zoom-buttons button[aria-pressed=true],.animation-pose-buttons button[aria-pressed=true]{background:var(--rv-control)}
|
|
597
605
|
.animation-zoom-buttons button[aria-pressed=true]:hover,.animation-pose-buttons button[aria-pressed=true]:hover{background:var(--rv-control-hover)}
|
|
606
|
+
/* #1041: the right panel is communication with the AI (question on top, Comments below), one column by container query. */
|
|
607
|
+
.workspace-layout>.workspace-communication{grid-column:5;grid-row:1;display:flex;flex-direction:column;min-width:0;min-height:0;overflow:auto;border-left:1px solid var(--border);background:var(--rv-panel);container-type:inline-size}
|
|
608
|
+
.workspace-communication[hidden]{display:none!important}
|
|
609
|
+
.workspace-drawer>.workspace-communication{display:flex;flex-direction:column;flex:1;min-height:0;overflow:auto;container-type:inline-size}
|
|
610
|
+
.workspace-drawer[data-panel=communicationWidth][open]:not(:modal){inset:0 0 0 auto;width:min(94vw,420px);height:auto;max-height:none;margin:0}
|
|
611
|
+
.workspace-communication>.workspace-interview-panel{flex:none;overflow:visible;border-bottom:1px solid var(--border)}
|
|
612
|
+
.workspace-communication>.workspace-interview-panel[hidden]{display:none}
|
|
613
|
+
.workspace-communication>#inspector-feedback.workspace-review-panel{flex:none;overflow:visible;display:grid;grid-template-columns:minmax(0,1fr)}
|
|
614
|
+
@container (max-width:720px){
|
|
615
|
+
.workspace-communication .workspace-interview-panel>.interview-answer{grid-template-columns:minmax(0,1fr);grid-template-rows:auto}
|
|
616
|
+
.workspace-communication .workspace-interview-panel .interview-answer-fields{grid-column:1;grid-row:auto}
|
|
617
|
+
.workspace-communication .workspace-interview-panel .interview-answer>p[role=status]{grid-column:1;grid-row:auto}
|
|
618
|
+
}
|
package/web/workspace-layout.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/** Effective workspace geometry and local DOM bindings. Never stores source or global preferences. */
|
|
2
2
|
import {parseWorkspacePanels,panelBounds,type WorkspacePanels} from './workspace-preferences.ts';
|
|
3
3
|
export type WorkspacePanel=keyof WorkspacePanels;
|
|
4
|
+
/** Desired sizes; a page without the communication column may omit its width (the saved default applies). */
|
|
5
|
+
export type DesiredWorkspacePanels=Omit<WorkspacePanels,'communicationWidth'>&{communicationWidth?:number};
|
|
4
6
|
/** `separator` is the drawn thickness of every resize handle in CSS pixels; its hit area is wider (styles.css `::after`). */
|
|
5
7
|
export const workspaceMinimums=Object.freeze({stageWidth:240,stageHeight:180,separator:4});
|
|
6
8
|
export interface SeparatorRange {min:number;max:number;value:number;enabled:boolean}
|
|
@@ -12,17 +14,17 @@ export interface WorkspaceColumns {left:WorkspaceColumnKey|null;right:WorkspaceC
|
|
|
12
14
|
export const defaultWorkspaceColumns:Readonly<WorkspaceColumns>=Object.freeze({left:'leftWidth',right:'rightWidth'});
|
|
13
15
|
export type WorkspacePanelMode='panel'|'drawer'|'absent';
|
|
14
16
|
/** Sizes and modes are keyed by saved panel, not by side; `absent` panels have width 0 and no separator. */
|
|
15
|
-
export interface EffectiveWorkspaceLayout {leftWidth:number;rightWidth:number;inspectorHeight:number;stageWidth:number;stageHeight:number;leftMode:WorkspacePanelMode;rightMode:WorkspacePanelMode;inspectorMode:'panel'|'drawer';stageMinimumSatisfied:boolean;separators:Record<WorkspacePanel,SeparatorRange>}
|
|
17
|
+
export interface EffectiveWorkspaceLayout {leftWidth:number;rightWidth:number;communicationWidth:number;inspectorHeight:number;stageWidth:number;stageHeight:number;leftMode:WorkspacePanelMode;rightMode:WorkspacePanelMode;communicationMode:WorkspacePanelMode;inspectorMode:'panel'|'drawer';stageMinimumSatisfied:boolean;separators:Record<WorkspacePanel,SeparatorRange>}
|
|
16
18
|
const clamp=(value:number,min:number,max:number)=>Math.max(min,Math.min(max,value));
|
|
17
19
|
export function parseWorkspaceColumns(value:WorkspaceColumns):WorkspaceColumns {
|
|
18
|
-
const ok=(v:unknown)=>v===null||v==='leftWidth'||v==='rightWidth';
|
|
19
|
-
if(!value||!ok(value.left)||!ok(value.right)||value.left!==null&&value.left===value.right)throw new Error(`WORKSPACE_COLUMNS: left ${String(value?.left)} / right ${String(value?.right)}; required distinct leftWidth, rightWidth or null`);
|
|
20
|
+
const ok=(v:unknown)=>v===null||v==='leftWidth'||v==='rightWidth'||v==='communicationWidth';
|
|
21
|
+
if(!value||!ok(value.left)||!ok(value.right)||value.left!==null&&value.left===value.right)throw new Error(`WORKSPACE_COLUMNS: left ${String(value?.left)} / right ${String(value?.right)}; required distinct leftWidth, rightWidth, communicationWidth or null`);
|
|
20
22
|
return {left:value.left,right:value.right};
|
|
21
23
|
}
|
|
22
24
|
/** Input rectangle excludes app chrome. Drawer triggers must remain outside collapsed panel content.
|
|
23
25
|
* Collapse the left column, then the right one when minima cannot coexist; Inspector becomes a drawer below its minimum.
|
|
24
26
|
* Returned clamps never replace the user's desired desktop sizes. */
|
|
25
|
-
export function allocateWorkspaceLayout(available:{width:number;height:number},desired:
|
|
27
|
+
export function allocateWorkspaceLayout(available:{width:number;height:number},desired:DesiredWorkspacePanels,columns:WorkspaceColumns=defaultWorkspaceColumns):EffectiveWorkspaceLayout {
|
|
26
28
|
const panels=parseWorkspacePanels(desired),{left:leftKey,right:rightKey}=parseWorkspaceColumns(columns),{width,height}=available,{stageWidth:minWidth,stageHeight:minHeight,separator}=workspaceMinimums;
|
|
27
29
|
if(![width,height].every(n=>Number.isFinite(n)&&n>=0&&n<=65536))throw new Error('WORKSPACE_RECTANGLE: finite 0..65536 CSS pixels required');
|
|
28
30
|
const boundLeft=leftKey?panelBounds[leftKey].min:0,boundRight=rightKey?panelBounds[rightKey].min:0;
|
|
@@ -35,10 +37,10 @@ export function allocateWorkspaceLayout(available:{width:number;height:number},d
|
|
|
35
37
|
const inspector=height>=minHeight+panelBounds.inspectorHeight.min+separator,inspectorHeight=inspector?Math.min(panels.inspectorHeight,height-minHeight-separator):0;
|
|
36
38
|
const stageWidth=Math.max(0,width-leftSize-rightSize-count*separator),stageHeight=Math.max(0,height-inspectorHeight-(inspector?separator:0));
|
|
37
39
|
const range=(visible:boolean,key:WorkspacePanel,value:number,max:number):SeparatorRange=>visible?{min:panelBounds[key].min,max:Math.max(panelBounds[key].min,Math.min(panelBounds[key].max,max)),value,enabled:true}:{min:0,max:0,value:0,enabled:false};
|
|
38
|
-
const size:Record<WorkspaceColumnKey,number>={leftWidth:0,rightWidth:0},mode:Record<WorkspaceColumnKey,WorkspacePanelMode>={leftWidth:'absent',rightWidth:'absent'},separators:Record<WorkspacePanel,SeparatorRange>={leftWidth:range(false,'leftWidth',0,0),rightWidth:range(false,'rightWidth',0,0),inspectorHeight:range(inspector,'inspectorHeight',inspectorHeight,height-minHeight-separator)};
|
|
40
|
+
const size:Record<WorkspaceColumnKey,number>={leftWidth:0,rightWidth:0,communicationWidth:0},mode:Record<WorkspaceColumnKey,WorkspacePanelMode>={leftWidth:'absent',rightWidth:'absent',communicationWidth:'absent'},separators:Record<WorkspacePanel,SeparatorRange>={leftWidth:range(false,'leftWidth',0,0),rightWidth:range(false,'rightWidth',0,0),communicationWidth:range(false,'communicationWidth',0,0),inspectorHeight:range(inspector,'inspectorHeight',inspectorHeight,height-minHeight-separator)};
|
|
39
41
|
if(leftKey){size[leftKey]=leftSize;mode[leftKey]=left?'panel':'drawer';separators[leftKey]=range(left,leftKey,leftSize,width-rightSize-count*separator-minWidth);}
|
|
40
42
|
if(rightKey){size[rightKey]=rightSize;mode[rightKey]=right?'panel':'drawer';separators[rightKey]=range(right,rightKey,rightSize,width-leftSize-count*separator-minWidth);}
|
|
41
|
-
return {leftWidth:size.leftWidth,rightWidth:size.rightWidth,inspectorHeight,stageWidth,stageHeight,leftMode:mode.leftWidth,rightMode:mode.rightWidth,inspectorMode:inspector?'panel':'drawer',stageMinimumSatisfied:width>=minWidth&&height>=minHeight,separators};
|
|
43
|
+
return {leftWidth:size.leftWidth,rightWidth:size.rightWidth,communicationWidth:size.communicationWidth,inspectorHeight,stageWidth,stageHeight,leftMode:mode.leftWidth,rightMode:mode.rightWidth,communicationMode:mode.communicationWidth,inspectorMode:inspector?'panel':'drawer',stageMinimumSatisfied:width>=minWidth&&height>=minHeight,separators};
|
|
42
44
|
}
|
|
43
45
|
export interface WorkspaceSeparatorOptions {element:HTMLElement;panel:WorkspacePanel;controls:string;label:string;range:()=>SeparatorRange;resize:(desired:number)=>void;desired?:()=>number;resolveDesired?:(effective:number,context:{range:SeparatorRange;desired:number})=>number;commit?:(desired:number)=>void;side?:'left'|'right';events?:Pick<EventTarget,'addEventListener'|'removeEventListener'>|null;step?:number;coarseStep?:number}
|
|
44
46
|
/** Arrow keys act only on the separator itself. Right/bottom boundaries grow inward.
|
|
@@ -5,19 +5,20 @@ export type WorkspaceTheme='system'|'dark'|'light';
|
|
|
5
5
|
export type WorkspaceLanguage='system'|'en'|'ko';
|
|
6
6
|
/** Saved field names are part of the stored record and do not move with the panels.
|
|
7
7
|
* `rightWidth` is the parts explorer's width wherever the page shows it (the single review page shows
|
|
8
|
-
* it on the left); `leftWidth` is the compare page's sources column
|
|
9
|
-
|
|
10
|
-
export
|
|
11
|
-
export const
|
|
8
|
+
* it on the left); `leftWidth` is the compare page's sources column; `communicationWidth` is the single page's right
|
|
9
|
+
* communication panel (question, comments, record forms; #1041). */
|
|
10
|
+
export interface WorkspacePanels {leftWidth:number;rightWidth:number;inspectorHeight:number;communicationWidth:number}
|
|
11
|
+
export const panelBounds=Object.freeze({leftWidth:Object.freeze({min:120,max:720}),rightWidth:Object.freeze({min:180,max:900}),inspectorHeight:Object.freeze({min:120,max:900}),communicationWidth:Object.freeze({min:280,max:640})});
|
|
12
|
+
export const defaultWorkspacePanels:Readonly<WorkspacePanels>=Object.freeze({leftWidth:170,rightWidth:260,inspectorHeight:240,communicationWidth:360});
|
|
12
13
|
/** Earlier defaults (280, then 350, then 120 and 240 on the #709 branch): an unstamped stored value equal to one loads as today's default. */
|
|
13
|
-
const legacyDefaultInspectorHeights:ReadonlySet<number>=new Set([280,350,120,240]);
|
|
14
|
+
const legacyDefaultInspectorHeights:ReadonlySet<number>=new Set([280,350,120,240,262]);
|
|
14
15
|
type Flag='defaultCameraSync'|'defaultIdleRepeat'|'settingsCollapsed';
|
|
15
16
|
type Field='theme'|'language'|Flag|keyof WorkspacePanels;
|
|
16
|
-
const fields:readonly Field[]=['theme','language','defaultCameraSync','defaultIdleRepeat','settingsCollapsed','leftWidth','rightWidth','inspectorHeight'];
|
|
17
|
+
const fields:readonly Field[]=['theme','language','defaultCameraSync','defaultIdleRepeat','settingsCollapsed','leftWidth','rightWidth','inspectorHeight','communicationWidth'];
|
|
17
18
|
const flags:readonly Flag[]=['defaultCameraSync','defaultIdleRepeat','settingsCollapsed'];
|
|
18
19
|
/** Fields added after the record shipped. A stored record that predates one has neither the value nor its
|
|
19
20
|
* stamp: it loads with the default value at revision 0, exactly as if that field had never been edited. */
|
|
20
|
-
const addedFields:ReadonlySet<Field>=new Set(['settingsCollapsed','language']);
|
|
21
|
+
const addedFields:ReadonlySet<Field>=new Set(['settingsCollapsed','language','communicationWidth']);
|
|
21
22
|
interface FieldStamp {revision:number;writer:string}
|
|
22
23
|
export interface WorkspacePreferences {schema:'rig-review-preferences/1';revision:number;theme:WorkspaceTheme;language:WorkspaceLanguage;defaultCameraSync:boolean;defaultIdleRepeat:boolean;settingsCollapsed:boolean;panels:WorkspacePanels;stamps:Record<Field,FieldStamp>}
|
|
23
24
|
export interface WorkspacePreferencePatch {theme?:WorkspaceTheme;language?:WorkspaceLanguage;defaultCameraSync?:boolean;defaultIdleRepeat?:boolean;settingsCollapsed?:boolean;panels?:Partial<WorkspacePanels>}
|
|
@@ -31,7 +32,8 @@ const theme=(v:unknown):WorkspaceTheme=>{if(v!=='system'&&v!=='dark'&&v!=='light
|
|
|
31
32
|
const language=(v:unknown):WorkspaceLanguage=>{if(v!=='system'&&v!=='en'&&v!=='ko')throw new Error('PREFERENCES_LANGUAGE: expected system, en or ko');return v;};
|
|
32
33
|
const boolean=(v:unknown,label:string):boolean=>{if(typeof v!=='boolean')throw new Error(`${label}: expected boolean`);return v;};
|
|
33
34
|
const panel=(v:unknown,key:keyof WorkspacePanels):number=>{const {min,max}=panelBounds[key];if(typeof v!=='number'||!Number.isFinite(v)||v<min||v>max)throw new Error(`PREFERENCES_PANEL: ${key} requires finite ${min}..${max} CSS pixels`);return v;};
|
|
34
|
-
export function parseWorkspacePanels(value:unknown):WorkspacePanels {const o=object(value,'panels');closed(o,Object.keys(panelBounds),'panels');return {leftWidth:panel(o.leftWidth,'leftWidth'),rightWidth:panel(o.rightWidth,'rightWidth'),inspectorHeight:panel(o.inspectorHeight,'inspectorHeight')
|
|
35
|
+
export function parseWorkspacePanels(value:unknown):WorkspacePanels {const o=object(value,'panels');closed(o,Object.keys(panelBounds),'panels');return {leftWidth:panel(o.leftWidth,'leftWidth'),rightWidth:panel(o.rightWidth,'rightWidth'),inspectorHeight:panel(o.inspectorHeight,'inspectorHeight'),
|
|
36
|
+
communicationWidth:'communicationWidth'in o?panel(o.communicationWidth,'communicationWidth'):defaultWorkspacePanels.communicationWidth};}
|
|
35
37
|
export function defaultWorkspacePreferences():WorkspacePreferences {return {schema:workspacePreferenceKey,revision:0,theme:'system',language:'system',defaultCameraSync:true,defaultIdleRepeat:true,settingsCollapsed:true,panels:{...defaultWorkspacePanels},stamps:Object.fromEntries(fields.map(field=>[field,{revision:0,writer:''}])) as Record<Field,FieldStamp>};}
|
|
36
38
|
const clone=(v:WorkspacePreferences):WorkspacePreferences=>({...v,panels:{...v.panels},stamps:Object.fromEntries(fields.map(field=>[field,{...v.stamps[field]}])) as Record<Field,FieldStamp>});
|
|
37
39
|
function leaf(value:WorkspacePreferences,field:Field):WorkspaceTheme|WorkspaceLanguage|boolean|number {return field in panelBounds?value.panels[field as keyof WorkspacePanels]:value[field as 'theme'|'language'|Flag];}
|
package/web/workspace-ui.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** Browser workspace presentation. Source selection, player clocks and review decisions stay with the page. */
|
|
2
|
-
import {WorkspacePreferenceStore,panelBounds,type WorkspaceLanguage,type WorkspacePanels,type WorkspacePreferences,type WorkspaceTheme} from './workspace-preferences.ts';
|
|
3
|
-
import {allocateWorkspaceLayout,bindWorkspaceSeparator,bindWorkspaceDrawer,defaultWorkspaceColumns,InspectorScrollMemory,inspectorTabs,settleAnimationFrames,workspaceMinimums,type InspectorTab,type WorkspaceColumns,type WorkspacePanel,type SeparatorRange} from './workspace-layout.ts';
|
|
2
|
+
import {WorkspacePreferenceStore,panelBounds,defaultWorkspacePanels,type WorkspaceLanguage,type WorkspacePanels,type WorkspacePreferences,type WorkspaceTheme} from './workspace-preferences.ts';
|
|
3
|
+
import {allocateWorkspaceLayout,bindWorkspaceSeparator,bindWorkspaceDrawer,defaultWorkspaceColumns,InspectorScrollMemory,inspectorTabs,settleAnimationFrames,workspaceMinimums,type InspectorTab,type WorkspaceColumns,type WorkspacePanel,type SeparatorRange,type DesiredWorkspacePanels} from './workspace-layout.ts';
|
|
4
4
|
import {bindDomI18n,getLinkLanguage,resolveLanguage,setLanguagePreference,setLinkLanguage,tr,onLanguageChange} from './i18n.ts';
|
|
5
5
|
import {panelMake,actionButton,labelledControl} from './view-controls.ts';
|
|
6
6
|
|
|
@@ -35,7 +35,7 @@ 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;
|
|
38
|
+
compatibility:WorkspaceHeaderCompatibility;embedded?: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
|
}
|
|
@@ -98,19 +98,19 @@ export function mountWorkspaceShell(options:WorkspaceHeaderOptions):WorkspaceHea
|
|
|
98
98
|
else{if(interview)header.append('\n ');header.append(language);if(interview)header.append('\n ');}
|
|
99
99
|
}
|
|
100
100
|
if(options.embedded){if(rig||parts)header.hidden=true;else if(interview)language!.hidden=true;}
|
|
101
|
-
const actRow=rig
|
|
101
|
+
const actRow=rig?panelMake('div',{id:'workspace-act-row',className:'workspace-act-row',hidden:true}):null;
|
|
102
102
|
return {header,actRow,title,subtitle,modeSwitch,dirty,stages,status,language,languageLabel,dispose(){header.remove();actRow?.remove();languageLabel?.remove();}};
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
/** Reachable effective bounds, accounting for the other panel's saved desired size. */
|
|
106
|
-
export function workspaceResizeRange(available:{width:number;height:number},desired:
|
|
106
|
+
export function workspaceResizeRange(available:{width:number;height:number},desired:DesiredWorkspacePanels,panel:WorkspacePanel,columns:WorkspaceColumns=defaultWorkspaceColumns):SeparatorRange {
|
|
107
107
|
const base=allocateWorkspaceLayout(available,desired,columns),range=base.separators[panel];if(!range.enabled)return range;
|
|
108
108
|
const low=allocateWorkspaceLayout(available,{...desired,[panel]:panelBounds[panel].min},columns)[panel],high=allocateWorkspaceLayout(available,{...desired,[panel]:panelBounds[panel].max},columns)[panel];
|
|
109
109
|
return {min:low,max:high,value:base[panel],enabled:high>low};
|
|
110
110
|
}
|
|
111
111
|
/** Invert the allocator instead of storing an already-clamped pixel value as a desktop desire. */
|
|
112
|
-
export function workspaceResizeTarget(available:{width:number;height:number},desired:
|
|
113
|
-
const range=workspaceResizeRange(available,desired,panel,columns);if(!range.enabled)return desired[panel];
|
|
112
|
+
export function workspaceResizeTarget(available:{width:number;height:number},desired:DesiredWorkspacePanels,panel:WorkspacePanel,target:number,columns:WorkspaceColumns=defaultWorkspaceColumns):number {
|
|
113
|
+
const range=workspaceResizeRange(available,desired,panel,columns);if(!range.enabled)return desired[panel]??defaultWorkspacePanels[panel];
|
|
114
114
|
if(target<=range.min)return panelBounds[panel].min;if(target>=range.max)return panelBounds[panel].max;
|
|
115
115
|
let low:number=panelBounds[panel].min,high:number=panelBounds[panel].max;
|
|
116
116
|
for(let i=0;i<48;i++){const mid=(low+high)/2,value=allocateWorkspaceLayout(available,{...desired,[panel]:mid},columns)[panel];if(value<target)low=mid;else high=mid;}
|
|
@@ -122,12 +122,21 @@ export function selectedInspector(root:Pick<Document,'querySelector'>=document):
|
|
|
122
122
|
}
|
|
123
123
|
export interface WorkspaceUI {
|
|
124
124
|
defaults:()=>WorkspacePreferences;beforeTab:()=>void;afterTab:()=>void;scroll:()=>string;restoreScroll:(value:unknown)=>void;
|
|
125
|
-
revealInspector:()=>void;refresh:()=>void;
|
|
125
|
+
revealInspector:()=>void;refresh:()=>void;
|
|
126
|
+
/** Open the communication panel (#1041) and lay the workspace out now, before the caller arms anything on the stage. */
|
|
127
|
+
revealCommunication:()=>void;
|
|
128
|
+
/** Lay the workspace out now, so a region that just appeared above the stage never leaves it under its minimum for a frame. */
|
|
129
|
+
layoutNow:()=>void;element:(id:string)=>HTMLElement|null;settle:()=>Promise<void>;dispose:()=>void;
|
|
126
130
|
}
|
|
127
131
|
/** Caller-owned shell regions. The left preference may retain a migrated screen's saved width. */
|
|
128
132
|
export interface WorkspaceRegions {
|
|
129
133
|
layout:HTMLElement;left:HTMLElement;main:HTMLElement;stage:HTMLElement;bottom:HTMLElement;right?:HTMLElement;
|
|
130
134
|
columns?:WorkspaceColumns;
|
|
135
|
+
/** With `columns.right` = `communicationWidth`, the right region is the communication panel (#1041): it is laid out
|
|
136
|
+
* only while this returns true, or after `revealCommunication`, and otherwise the stage takes its width. */
|
|
137
|
+
rightPending?:()=>boolean;
|
|
138
|
+
/** False while no subject has mounted its blocks (a job waiting for its first publication): the frame keeps its bottom heading so it does not jump (#904). */
|
|
139
|
+
bottomBound?:()=>boolean;
|
|
131
140
|
}
|
|
132
141
|
/** `currentTheme`, when given, is the appearance the Settings theme select shows; otherwise it shows the saved default. */
|
|
133
142
|
export function bindWorkspaceUI(options:{root?:HTMLElement;regions?:WorkspaceRegions;changed:()=>void;defaultTheme:(theme:WorkspaceTheme)=>void;currentTheme?:()=>WorkspaceTheme|undefined;language?:HTMLSelectElement;bottomPanel?:{kind:string;strip:HTMLElement;act:HTMLElement;actHome:HTMLElement;collapse:HTMLButtonElement}}):WorkspaceUI {
|
|
@@ -160,11 +169,18 @@ export function bindWorkspaceUI(options:{root?:HTMLElement;regions?:WorkspaceReg
|
|
|
160
169
|
const triggers=document.createElement('div');triggers.className='workspace-drawer-triggers';triggers.setAttribute('aria-label','Workspace panels');stack.prepend(triggers);
|
|
161
170
|
const panels:Partial<Record<WorkspacePanel,HTMLElement>>={};if(columns.left)panels[columns.left]=left;if(columns.right&&explorer)panels[columns.right]=explorer;panels.inspectorHeight=inspector;
|
|
162
171
|
const sides:Partial<Record<WorkspacePanel,'left'|'right'>>={};if(columns.left)sides[columns.left]='left';if(columns.right&&explorer)sides[columns.right]='right';
|
|
163
|
-
const labels:Record<WorkspacePanel,string>=
|
|
172
|
+
const labels:Record<WorkspacePanel,string>={leftWidth:'Sources and settings',rightWidth:explorerLeft||columns.left==='rightWidth'?'Parts and settings':'Parts explorer',inspectorHeight:'Inspector',communicationWidth:'Communication'};
|
|
164
173
|
const handles={} as Record<WorkspacePanel,HTMLElement>,buttons={} as Record<WorkspacePanel,HTMLButtonElement>,disposers:(()=>void)[]=[];
|
|
165
174
|
const present=Object.keys(panels) as WorkspacePanel[],node=(panel:WorkspacePanel)=>panels[panel]!;
|
|
166
175
|
const bottom=options.bottomPanel,bottomBody=bottom?inspector.querySelector<HTMLElement>('.inspector-body')!:null,bottomHeading=bottom?bottom.strip.parentElement!:null;
|
|
167
|
-
|
|
176
|
+
// The communication panel: present while something is pending or after an explicit reveal (C, a pending ask).
|
|
177
|
+
const communicationKey=columns.right==='communicationWidth'&&explorer?'communicationWidth' as const:null;let communicationRevealed=false;
|
|
178
|
+
const communicationShown=()=>!!communicationKey&&(communicationRevealed||!!regions?.rightPending?.());
|
|
179
|
+
const hasInterviewForm=()=>!!explorer&&!!communicationKey&&!!explorer.querySelector('[data-interview-main]');
|
|
180
|
+
// A bottom panel with no view-controller block collapses to nothing; the stage takes the height.
|
|
181
|
+
const controls=(node:HTMLElement):boolean=>[...node.children].some(child=>{const item=child as HTMLElement;if(item.hidden)return false;
|
|
182
|
+
return item.tagName==='BUTTON'&&(item.dataset.blockTarget!==undefined||item.dataset.inspector!==undefined)&&!(item as HTMLButtonElement).disabled||controls(item);});
|
|
183
|
+
const bottomEmpty=()=>!!bottom&®ions?.bottomBound?.()!==false&&!controls(bottom.strip);
|
|
168
184
|
for(const panel of present){
|
|
169
185
|
const handle=document.createElement('div');handle.className='workspace-separator workspace-'+panel+(sides[panel]?' workspace-side-'+sides[panel]:'');handles[panel]=handle;
|
|
170
186
|
if(sides[panel]==='left')node(panel).after(handle);else if(sides[panel]==='right')node(panel).before(handle);else inspector.before(handle);
|
|
@@ -172,13 +188,13 @@ export function bindWorkspaceUI(options:{root?:HTMLElement;regions?:WorkspaceReg
|
|
|
172
188
|
const dialog=document.createElement('dialog');dialog.className='workspace-drawer';dialog.id='workspace-drawer-'+panel;dialog.dataset.panel=panel;const close=document.createElement('button');close.type='button';close.textContent='Close '+labels[panel];close.className='workspace-drawer-close';
|
|
173
189
|
// The drawer's header stays above its scrolling panel: title and the close action.
|
|
174
190
|
const header=document.createElement('div');header.className='sticky-header workspace-drawer-header';const title=document.createElement('span');title.textContent=labels[panel];header.append(title,close);dialog.append(header);document.body.append(dialog);dialogs[panel]=dialog;
|
|
175
|
-
disposers.push(bindWorkspaceDrawer({trigger,drawer:dialog,label:labels[panel],close,modal:()=>panel!==
|
|
191
|
+
disposers.push(bindWorkspaceDrawer({trigger,drawer:dialog,label:labels[panel],close,modal:()=>panel!==communicationKey||!hasInterviewForm()}));
|
|
176
192
|
}
|
|
177
193
|
const bottomCollapseKey=bottom?`rig-review-bottom-collapsed/${bottom.kind}`:'';
|
|
178
194
|
let collapsed=false;
|
|
179
195
|
if(bottom){try{collapsed=localStorage.getItem(bottomCollapseKey)==='true';}catch{}}
|
|
180
196
|
const memory=new InspectorScrollMemory();const active=():InspectorTab=>{const tab=selectedInspector(scope) as InspectorTab|undefined;return tab&&tabs.includes(tab)?tab:tabs[0]!;};
|
|
181
|
-
let disposed=false,frame=0,applying=false,available={width:0,height:0},effective=allocateWorkspaceLayout(available,desired,columns);
|
|
197
|
+
let disposed=false,frame=0,applying=false,available={width:0,height:0},shownColumns:WorkspaceColumns=columns,effective=allocateWorkspaceLayout(available,desired,columns);
|
|
182
198
|
const panelFor=(tab:InspectorTab)=>require('inspector-'+tab);
|
|
183
199
|
const userByTab=new Map<InspectorTab,boolean>(),extentByTab=new Map<InspectorTab,string>(),extentOf=(panel:HTMLElement)=>`${panel.scrollWidth}:${panel.scrollHeight}:${panel.clientWidth}:${panel.clientHeight}`;
|
|
184
200
|
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);};
|
|
@@ -194,27 +210,30 @@ export function bindWorkspaceUI(options:{root?:HTMLElement;regions?:WorkspaceReg
|
|
|
194
210
|
if(drawer&&element.parentElement!==dialog){const focus=element.contains(document.activeElement);dialog.append(element);if(focus)trigger.focus({preventScroll:true});}
|
|
195
211
|
if(!drawer&&element.parentElement===dialog){const focused=element.contains(document.activeElement)||document.activeElement===trigger;if(dialog.open)dialog.close();trigger.setAttribute('aria-expanded','false');if(sides[panel]==='left')layout.prepend(element);else if(sides[panel]==='right')layout.append(element);else main.append(element);if(focused){element.tabIndex=-1;element.focus({preventScroll:true});}}
|
|
196
212
|
};
|
|
197
|
-
const bindings=present.map(panel=>bindWorkspaceSeparator({element:handles[panel],panel,...(sides[panel]?{side:sides[panel]}:{}),controls:node(panel).id,label:'Resize '+labels[panel],range:()=>workspaceResizeRange(available,desired,panel,
|
|
213
|
+
const bindings=present.map(panel=>bindWorkspaceSeparator({element:handles[panel],panel,...(sides[panel]?{side:sides[panel]}:{}),controls:node(panel).id,label:'Resize '+labels[panel],range:()=>workspaceResizeRange(available,desired,panel,shownColumns),resolveDesired:value=>workspaceResizeTarget(available,desired,panel,value,shownColumns),desired:()=>desired[panel],resize:value=>{desired={...desired,[panel]:value};apply();},commit:value=>store.update({panels:{[panel]:value}})}));
|
|
198
214
|
function apply():void {
|
|
199
215
|
if(disposed||applying)return;applying=true;
|
|
200
216
|
try{
|
|
201
217
|
// Chrome shares the center width. It is not charged against the actual stage minimum.
|
|
202
218
|
// Authored JSON can fill the same slot as the rig while Direction metadata stays above it.
|
|
203
219
|
const chrome=[...stack.children].filter(node=>node!==stage&&node.id!=='direction-authored-body'&&!((node as HTMLElement).hidden)).reduce((sum,node)=>sum+(node as HTMLElement).getBoundingClientRect().height,0);
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
const
|
|
220
|
+
const quiet=!!communicationKey&&!communicationShown(),shown:WorkspaceColumns=quiet?{...columns,right:null}:columns;shownColumns=shown;
|
|
221
|
+
if(communicationKey){explorer!.hidden=quiet;handles[communicationKey].hidden=quiet;if(quiet){buttons[communicationKey].hidden=true;if(dialogs[communicationKey].open)dialogs[communicationKey].close();}}
|
|
222
|
+
available={width:Math.max(0,layout.clientWidth),height:Math.max(0,layout.clientHeight-chrome)};effective=allocateWorkspaceLayout(available,desired,shown);
|
|
223
|
+
const mode=(panel:WorkspacePanel)=>effective[panel==='leftWidth'?'leftMode':panel==='rightWidth'?'rightMode':panel==='communicationWidth'?'communicationMode':'inspectorMode'];
|
|
224
|
+
for(const panel of present)if(!(quiet&&panel===communicationKey))dock(panel,mode(panel)==='drawer');
|
|
225
|
+
const gap=workspaceMinimums.separator,side=(key:WorkspaceColumns['left'])=>key&&mode(key)==='panel'?{width:effective[key],separator:gap}:{width:0,separator:0},l=side(shown.left),r=side(shown.right);
|
|
208
226
|
layout.style.setProperty('--workspace-columns',`${l.width}px ${l.separator}px minmax(0,1fr) ${r.separator}px ${r.width}px`);
|
|
209
227
|
let bottomHeight=effective.inspectorHeight;
|
|
210
228
|
if(bottom){
|
|
211
229
|
const compact=collapsed||effective.inspectorMode==='drawer';bottomBody!.hidden=collapsed;
|
|
212
|
-
|
|
230
|
+
if(bottom.act.parentElement!==bottom.actHome)bottom.actHome.append(bottom.act);
|
|
213
231
|
const collapseLabel=tr(collapsed?'Expand bottom panel':'Collapse bottom panel');
|
|
214
232
|
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);
|
|
215
233
|
if(compact)bottomHeight=bottomHeading!.getBoundingClientRect().height;
|
|
216
234
|
}
|
|
217
|
-
|
|
235
|
+
const empty=bottomEmpty();inspector.hidden=empty;if(empty){handles.inspectorHeight.hidden=true;bottomHeight=0;}
|
|
236
|
+
main.style.gridTemplateRows=`minmax(0,1fr) ${effective.inspectorMode==='panel'&&!collapsed&&!empty?gap:0}px ${bottomHeight}px`;
|
|
218
237
|
layout.dataset.stageMinimum=String(effective.stageMinimumSatisfied);for(const binding of bindings)binding.refresh();options.changed();restore();
|
|
219
238
|
}finally{applying=false;}
|
|
220
239
|
}
|
|
@@ -225,9 +244,13 @@ export function bindWorkspaceUI(options:{root?:HTMLElement;regions?:WorkspaceReg
|
|
|
225
244
|
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);};
|
|
226
245
|
const revealInspector=()=>{
|
|
227
246
|
if(bottom&&collapsed){collapsed=false;try{localStorage.setItem(bottomCollapseKey,'false');}catch{}apply();}
|
|
228
|
-
if(hasInterviewForm()&&dialogs.inspectorHeight.open&&dialogs.inspectorHeight.matches(':modal'))dialogs.inspectorHeight.close();
|
|
229
247
|
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();}
|
|
230
248
|
};
|
|
249
|
+
const layoutNow=()=>{if(disposed)return;if(frame){cancelAnimationFrame(frame);frame=0;}apply();};
|
|
250
|
+
const revealCommunication=()=>{
|
|
251
|
+
if(!communicationKey)return;communicationRevealed=true;layoutNow();
|
|
252
|
+
if(effective.communicationMode==='drawer'&&!dialogs[communicationKey].open){for(const dialog of Object.values(dialogs))if(dialog.open)dialog.close();buttons[communicationKey].click();}
|
|
253
|
+
};
|
|
231
254
|
if(bottom){
|
|
232
255
|
const closed=()=>{if(disposed||dialogs.inspectorHeight.open)return;apply();bottom.strip.querySelector<HTMLButtonElement>('[aria-selected=true]')?.focus({preventScroll:true});};
|
|
233
256
|
dialogs.inspectorHeight.addEventListener('close',closed);
|
|
@@ -249,10 +272,13 @@ export function bindWorkspaceUI(options:{root?:HTMLElement;regions?:WorkspaceReg
|
|
|
249
272
|
const content=new MutationObserver(()=>{if(panel.clientWidth<=0&&panel.clientHeight<=0)return;const next=extentOf(panel);if(next!==extentByTab.get(tab)){extentByTab.set(tab,next);if(tab===active())restore();}});content.observe(panel,{childList:true,subtree:true});
|
|
250
273
|
disposers.push(()=>{if(timer)clearTimeout(timer);for(const type of ['wheel','pointerdown','touchstart','keydown','click'])panel.removeEventListener(type,intent,{capture:true});panel.removeEventListener('scroll',scrolled);content.disconnect();});
|
|
251
274
|
}
|
|
252
|
-
const observer=new ResizeObserver(schedule);observer.observe(layout);for(const node of [...stack.children])if(node!==stage)observer.observe(node);
|
|
275
|
+
const observer=new ResizeObserver(schedule);observer.observe(layout);for(const node of [...stack.children])if(node!==stage)observer.observe(node);
|
|
276
|
+
// A region above the stage that is shown or hidden (the chest editor bar, #1035) lays the workspace out before the
|
|
277
|
+
// next frame, so the stage is never drawn under its minimum with a stale allocation.
|
|
278
|
+
const chromeWatch=new MutationObserver(()=>{if(!applying)layoutNow();});chromeWatch.observe(stack,{childList:true});for(const node of [...stack.children])if(node!==stage)chromeWatch.observe(node,{attributes:true,attributeFilter:['hidden']});for(const tab of tabs)observer.observe(panelFor(tab));
|
|
253
279
|
const resumed=()=>{if(!document.hidden)store.refresh();};document.addEventListener('visibilitychange',resumed);schedule();
|
|
254
|
-
return {defaults:()=>store.get(),beforeTab:capture,afterTab:restore,scroll:()=>{capture();return JSON.stringify(memory.snapshot());},restoreScroll(value){if(typeof value!=='string')return;memory.replace(JSON.parse(value));restore();},revealInspector,refresh:schedule,element:id=>require(id,true)??null,
|
|
255
|
-
async settle(){
|
|
256
|
-
dispose(){if(disposed)return;capture();disposed=true;if(frame)cancelAnimationFrame(frame);observer.disconnect();document.removeEventListener('visibilitychange',resumed);unsubscribe();for(const binding of bindings)binding.dispose();for(const dispose of disposers)dispose();for(const dialog of Object.values(dialogs)){if(dialog.open)dialog.close();dialog.remove();}memory.dispose();store.dispose();}
|
|
280
|
+
return {defaults:()=>store.get(),beforeTab:capture,afterTab:restore,scroll:()=>{capture();return JSON.stringify(memory.snapshot());},restoreScroll(value){if(typeof value!=='string')return;memory.replace(JSON.parse(value));restore();},revealInspector,revealCommunication,layoutNow,refresh:schedule,element:id=>require(id,true)??null,
|
|
281
|
+
async settle(){layoutNow();await settleAnimationFrames();if(!disposed)apply();},
|
|
282
|
+
dispose(){if(disposed)return;capture();disposed=true;if(frame)cancelAnimationFrame(frame);observer.disconnect();chromeWatch.disconnect();document.removeEventListener('visibilitychange',resumed);unsubscribe();for(const binding of bindings)binding.dispose();for(const dispose of disposers)dispose();for(const dialog of Object.values(dialogs)){if(dialog.open)dialog.close();dialog.remove();}memory.dispose();store.dispose();}
|
|
257
283
|
};
|
|
258
284
|
}
|