@rig-c/review 1.13.0 → 1.14.1
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/WORKFLOWS.md +18 -0
- package/package.json +1 -1
- package/src/build.ts +2 -2
- package/src/cli.ts +13 -4
- package/src/front.ts +18 -7
- package/src/interview-routes.ts +20 -7
- package/src/interview-server.ts +3 -4
- package/src/joined-project.ts +75 -0
- package/src/open.ts +9 -6
- package/src/rebuild.ts +4 -2
- package/src/server.ts +27 -2
- package/web/catalog-en.ts +5 -2
- package/web/catalog-ko.ts +5 -2
- package/web/index.html +1 -1
- package/web/interview-panel.ts +8 -1
- package/web/interview.css +2 -0
- package/web/interview.ts +16 -3
- package/web/main.ts +10 -5
- package/web/stage-nav.ts +41 -9
- package/web/styles.css +13 -0
- package/web/turn-pad.ts +1 -1
package/web/stage-nav.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/** Four inspection stages. Existing tools remain mounted; navigation never submits or applies. */
|
|
2
2
|
import {getLanguage,onLanguageChange,t} from './i18n.ts';
|
|
3
|
-
import {
|
|
3
|
+
import {interviewErrors} from './interview-panel.ts';
|
|
4
|
+
import {pageInstanceAccess,type InstanceAccess} from './instance-access.ts';
|
|
4
5
|
export const reviewStages = ['1 Parts + mesh','2 Interview','3 Rig + animation','4 Direction'] as const;
|
|
5
6
|
export type ReviewStage = 1|2|3|4;
|
|
6
7
|
export interface StagePartsState {
|
|
@@ -16,13 +17,13 @@ export function stagePartsSelectionIndex(data:{inspectionSourceHash?:string;item
|
|
|
16
17
|
if(i<0||data.inspectionSourceHash!==saved.inspectionSourceHash||!m||(['skin','slot','attachment']as const).some(k=>m[k]!==saved.mapping[k]))throw new Error('STAGE_DRAFT_MISMATCH');
|
|
17
18
|
return i;
|
|
18
19
|
}
|
|
19
|
-
export function stageReason(stage:ReviewStage,model:boolean,direction=false):string|null {
|
|
20
|
-
if(stage===2)return 'INTERVIEW_UNAVAILABLE:
|
|
20
|
+
export function stageReason(stage:ReviewStage,model:boolean,direction=false,interview=false):string|null {
|
|
21
|
+
if(stage===2&&!interview)return 'INTERVIEW_UNAVAILABLE: No interview is attached to this inspection.';
|
|
21
22
|
if(stage===4&&!direction)return 'DIRECTION_UNAVAILABLE: no direction inspection contract is installed.';
|
|
22
23
|
if(stage===3&&!model)return 'MODEL_UNAVAILABLE: no compiled model is supplied in this inspection.';
|
|
23
24
|
return null;
|
|
24
25
|
}
|
|
25
|
-
export function bindStageNav(options:{interviewOnly?:boolean;partsOnly?:boolean;model:boolean;direction?:(active:boolean)=>void;side?:()=> 'a'|'b';setup?:()=>void;draftBuild?:()=>string;correction?:(request:{part:string;sourceHash:string;buildId:string;instrument:string})=>Promise<void>}):()=>void {
|
|
26
|
+
export function bindStageNav(options:{interviewOnly?:boolean;interview?:boolean;access?:InstanceAccess;partsOnly?:boolean;model:boolean;direction?:(active:boolean)=>void;side?:()=> 'a'|'b';setup?:()=>void;draftBuild?:()=>string;correction?:(request:{part:string;sourceHash:string;buildId:string;instrument:string})=>Promise<void>}):()=>void {
|
|
26
27
|
const host=document.querySelector<HTMLElement>('[data-stage-nav]');if(!host)return ()=>{};
|
|
27
28
|
if(options.interviewOnly){
|
|
28
29
|
const button=document.createElement('button');button.type='button';button.dataset.reviewStage='2';button.setAttribute('aria-current','step');host.append(button);
|
|
@@ -32,8 +33,9 @@ export function bindStageNav(options:{interviewOnly?:boolean;partsOnly?:boolean;
|
|
|
32
33
|
}
|
|
33
34
|
const embedded=new URL(location.href).searchParams.get('stageEmbed')==='1';
|
|
34
35
|
if(embedded){host.hidden=true;return ()=>{};}
|
|
35
|
-
const access=pageInstanceAccess(),panel=document.createElement('section');panel.className='review-stage-panel';panel.hidden=true;panel.setAttribute('aria-live','polite');document.body.append(panel);
|
|
36
|
+
const access=options.access??pageInstanceAccess(),panel=document.createElement('section');panel.className='review-stage-panel';panel.hidden=true;panel.setAttribute('aria-live','polite');document.body.append(panel);
|
|
36
37
|
const status=document.createElement('p');status.setAttribute('role','status');panel.append(status);
|
|
38
|
+
let interview:HTMLIFrameElement|undefined,interviewError:string|null=null,entry=0;
|
|
37
39
|
const sourcePicker=document.getElementById('mode-build-picker');
|
|
38
40
|
const frames=new Map<string,HTMLIFrameElement>();let lastFrame:HTMLIFrameElement|null=null;let current:ReviewStage=options.partsOnly?1:3;
|
|
39
41
|
const workspace=document.querySelector<HTMLElement>(options.partsOnly?'.pv-layout':'.layout');const wasInert=workspace?.inert??false;
|
|
@@ -41,14 +43,44 @@ export function bindStageNav(options:{interviewOnly?:boolean;partsOnly?:boolean;
|
|
|
41
43
|
const mesh=document.createElement('button');mesh.type='button';mesh.onclick=()=>{show(3);options.setup?.();};panel.append(mesh);
|
|
42
44
|
const render=()=>{buttons.forEach((b,i)=>{b.textContent=t(reviewStages[i]!);b.setAttribute('aria-current',current===i+1?'step':'false');});host.setAttribute('aria-label',t('Inspection stages'));if(sourcePicker)sourcePicker.setAttribute('aria-label',t(current===1?'Atlas source build':'Picked build for Setup and Animate'));mesh.textContent=t('Open setup mesh instruments');};
|
|
43
45
|
const place=()=>{panel.style.top=`${(host.closest('header')??host).getBoundingClientRect().bottom}px`;};
|
|
46
|
+
const reasonFor=(stage:ReviewStage)=>stageReason(stage,options.model,!!options.direction,!!options.interview);
|
|
47
|
+
const setFrameLanguage=(frame:HTMLIFrameElement)=>frame.contentWindow?.postMessage({type:'review-stage-language',language:getLanguage()},location.origin);
|
|
48
|
+
async function showInterview(revision:number) {
|
|
49
|
+
try {
|
|
50
|
+
const response=await fetch(access.route('/api/interview'));
|
|
51
|
+
if(!response.ok){const {error}=await response.json();throw new Error(error);}
|
|
52
|
+
if(revision!==entry)return;
|
|
53
|
+
if(!interview){
|
|
54
|
+
interview=document.createElement('iframe');
|
|
55
|
+
interview.title=t('interview.title');interview.className='review-interview-frame';
|
|
56
|
+
const url=new URL(access.route('/stage-interview.html'),location.href);
|
|
57
|
+
url.searchParams.set('stageEmbed','1');url.searchParams.set('lang',getLanguage());
|
|
58
|
+
if(access.capability)url.hash='cap='+access.capability;
|
|
59
|
+
const frame=interview;
|
|
60
|
+
frame.src=url.href;frame.addEventListener('load',()=>setFrameLanguage(frame));
|
|
61
|
+
panel.append(frame);
|
|
62
|
+
}
|
|
63
|
+
status.textContent='';showParts();interview.hidden=false;panel.classList.add('with-interview');
|
|
64
|
+
} catch(error) {
|
|
65
|
+
if(revision!==entry)return;
|
|
66
|
+
interviewError=error instanceof Error ? (error.message==='INTERVIEW_OPTIONS_STALE' ? error.message : interviewErrors[error.message]??'interview.failed') : 'interview.failed';
|
|
67
|
+
status.textContent=t(interviewError);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
44
70
|
function show(stage:ReviewStage):void {
|
|
45
|
-
current=stage;document.documentElement.dataset.inspectionStage=String(stage);render();place();const reason=
|
|
71
|
+
current=stage;document.documentElement.dataset.inspectionStage=String(stage);render();place();const reason=reasonFor(stage);const revision=++entry;interviewError=null;
|
|
46
72
|
options.direction?.(stage===4);
|
|
47
73
|
panel.hidden=!reason&&(stage===(options.partsOnly?1:3)||stage===4);
|
|
48
74
|
if(workspace)workspace.inert=!panel.hidden||wasInert;
|
|
49
75
|
status.textContent=reason?t(reason):stage===1&&!options.partsOnly?t(options.correction?'Draft rig · structure evidence only':'Atlas inspection, read only — inspected package. Applied scratch atlas, pre-rig parts, mesh sign-off and draft corrections are unavailable here.'):'';mesh.hidden=stage!==1||!options.model||!!options.partsOnly;
|
|
50
76
|
for(const frame of frames.values())frame.hidden=true;
|
|
51
|
-
if(
|
|
77
|
+
if(interview)interview.hidden=true;
|
|
78
|
+
panel.classList.remove('with-interview');
|
|
79
|
+
if(stage===1&&!options.partsOnly)showParts();
|
|
80
|
+
if(stage===2&&!reason){status.textContent=t('interview.loading');void showInterview(revision);}
|
|
81
|
+
}
|
|
82
|
+
function showParts(){
|
|
83
|
+
const saved=(lastFrame?.contentWindow as StagePartsWindow|null)?.rigReviewStageParts?.snapshot()??null;const side=options.side?.(),key=(side??'single')+':'+(options.draftBuild?.()??'inspected');let frame=frames.get(key);if(!frame){if(options.correction){for(const old of frames.values())old.remove();frames.clear();}frame=document.createElement('iframe');frame.title=t('Parts and atlas inspection');frame.src=access.route('/stage-parts.html')+'?stageEmbed=1&lang='+getLanguage()+(side?'&side='+side:'');frame.addEventListener('load',()=>{frame!.contentWindow?.postMessage({type:'review-stage-language',language:getLanguage()},location.origin);frame!.contentWindow?.postMessage({type:'review-stage-source',buildId:options.draftBuild?.()??'inspected',state:saved},location.origin);});frames.set(key,frame);panel.append(frame);}else if(options.correction){frame.contentWindow?.postMessage({type:'review-stage-revalidate',state:lastFrame!==frame?saved:null},location.origin);}frame.hidden=false;lastFrame=frame;
|
|
52
84
|
}
|
|
53
85
|
const correction=async(event:MessageEvent)=>{if(event.origin!==location.origin||![...frames.values()].some(f=>f.contentWindow===event.source)||event.data?.type!=='review-stage-correction'||!options.correction)return;const r=event.data;if(typeof r.part!=='string'||typeof r.sourceHash!=='string'||typeof r.buildId!=='string'||!['chest','mesh','delta'].includes(r.instrument))return;try{await options.correction(r);show(3);}catch(error){status.textContent=error instanceof Error?error.message:String(error);}};
|
|
54
86
|
window.addEventListener('message',correction);
|
|
@@ -61,7 +93,7 @@ export function bindStageNav(options:{interviewOnly?:boolean;partsOnly?:boolean;
|
|
|
61
93
|
// Legacy bookmark/control restoration writes these canonical attributes even when a mode is unchanged.
|
|
62
94
|
const canonical=new MutationObserver(()=>{if(current!==3&&!options.partsOnly&&!pickingSource)show(3);});
|
|
63
95
|
document.querySelectorAll('[data-inspector]').forEach(button=>canonical.observe(button,{attributes:true,attributeFilter:['aria-selected','aria-pressed']}));
|
|
64
|
-
const language=onLanguageChange(()=>{render();if(!panel.hidden)status.textContent=t(
|
|
96
|
+
const language=onLanguageChange(()=>{render();if(!panel.hidden)status.textContent=t(reasonFor(current)??(current===2?(interviewError??(interview&&!interview.hidden?'':'interview.loading')):current===1&&options.correction?'Draft rig · structure evidence only':current===1?'Atlas inspection, read only — inspected package. Applied scratch atlas, pre-rig parts, mesh sign-off and draft corrections are unavailable here.':''));for(const f of frames.values()){f.title=t('Parts and atlas inspection');setFrameLanguage(f);}if(interview){interview.title=t('interview.title');setFrameLanguage(interview);}});
|
|
65
97
|
window.addEventListener('resize',place);show(current);
|
|
66
|
-
return ()=>{window.removeEventListener('message',correction);language();canonical.disconnect();sourcePicker?.querySelectorAll('[data-build-side]').forEach(button=>button.removeEventListener('click',sourceChanged));delete document.documentElement.dataset.inspectionStage;if(workspace)workspace.inert=wasInert;panel.remove();window.removeEventListener('resize',place);document.querySelectorAll('[data-mode],[data-inspector]').forEach(b=>b.removeEventListener('click',legacy));};
|
|
98
|
+
return ()=>{entry++;window.removeEventListener('message',correction);language();canonical.disconnect();sourcePicker?.querySelectorAll('[data-build-side]').forEach(button=>button.removeEventListener('click',sourceChanged));delete document.documentElement.dataset.inspectionStage;if(workspace)workspace.inert=wasInert;panel.remove();window.removeEventListener('resize',place);document.querySelectorAll('[data-mode],[data-inspector]').forEach(b=>b.removeEventListener('click',legacy));};
|
|
67
99
|
}
|
package/web/styles.css
CHANGED
|
@@ -415,3 +415,16 @@ main{position:relative}.toolbar{anchor-name:--stage-comment-bar}#stage-comment{w
|
|
|
415
415
|
#direction-panel{flex:none;max-height:40%;overflow:auto;padding:.5rem .75rem;overflow-wrap:anywhere}
|
|
416
416
|
#direction-panel ul{margin:.4rem 0;padding-inline-start:1.4rem}
|
|
417
417
|
#direction-panel pre{max-height:12rem;overflow:auto}
|
|
418
|
+
.review-stage-panel.with-interview {
|
|
419
|
+
display: grid;
|
|
420
|
+
grid-template: min-content minmax(240px, 1fr) / minmax(0, 1fr) minmax(0, 1fr);
|
|
421
|
+
gap: 12px;
|
|
422
|
+
}
|
|
423
|
+
.review-stage-panel.with-interview[hidden] { display: none; }
|
|
424
|
+
.review-stage-panel.with-interview > p { grid-column: 1 / -1; margin: 0; }
|
|
425
|
+
.review-stage-panel.with-interview > iframe { height: 100%; grid-area: 2 / 1; }
|
|
426
|
+
.review-stage-panel.with-interview > .review-interview-frame { grid-area: 2 / 2; }
|
|
427
|
+
@media (max-width: 65rem) {
|
|
428
|
+
.review-stage-panel.with-interview { grid-template: min-content repeat(2, minmax(420px, 1fr)) / minmax(0, 1fr); }
|
|
429
|
+
.review-stage-panel.with-interview > .review-interview-frame { grid-area: 3 / 1; }
|
|
430
|
+
}
|
package/web/turn-pad.ts
CHANGED
|
@@ -11,7 +11,7 @@ export function bindTurnPad(options:{host:HTMLElement;stages:HTMLElement[];dials
|
|
|
11
11
|
const smoothLabel=document.createElement('label'),smooth=document.createElement('input');smooth.type='checkbox';smooth.checked=true;smooth.setAttribute('aria-label','Turn smoothing');smoothLabel.append(smooth,' Smoothing ω₀ ');
|
|
12
12
|
const omega=document.createElement('input');omega.type='number';omega.min='1';omega.max='100';omega.step='1';omega.value='20';omega.setAttribute('aria-label','Turn smoothing omega');smoothLabel.append(omega,' s⁻¹');panel.append(smoothLabel);
|
|
13
13
|
const rows=new Map<TurnAxis,{dial:TurnDial;number:HTMLInputElement;output:HTMLOutputElement;target:HTMLOutputElement}>();
|
|
14
|
-
for(const d of dials){const label=document.createElement('label');label.textContent=`${d.axis} · ${d.bone} [${d.min}, ${d.max}] ${d.channel==='rotation'?'°':d.channel}`;const number=document.createElement('input');number.type='number';number.min=String(d.min);number.max=String(d.max);number.step='any';number.value='0';number.setAttribute('aria-label',`Turn ${d.axis} value`);label.title=d.provenance??'';const width=`${turnDialWidthCh(d)}ch`;const output=document.createElement('output');output.dataset.turnAxis=d.axis;output.style.width=width;output.style.minWidth=width;output.setAttribute('aria-label',`Current ${d.axis}`);const target=document.createElement('output');target.dataset.turnTarget=d.axis;target.style.width=width;target.style.minWidth=width;label.append(number,' Applied ',output,' · target ',target);panel.append(label);rows.set(d.axis,{dial:d,number,output,target});number.onchange=()=>{try{if(!number.value.trim())throw new Error('TURN_VALUE_REQUIRED');state.exact(d.axis,Number(number.value));commit();}catch(error){options.error(String(error));render();}};}
|
|
14
|
+
for(const d of dials){const label=document.createElement('label');label.textContent=`${d.axis} · ${d.bone} [${formatTurnValue(d.min,d)}, ${formatTurnValue(d.max,d)}] ${d.channel==='rotation'?'°':d.channel}`;const number=document.createElement('input');number.type='number';number.min=String(d.min);number.max=String(d.max);number.step='any';number.value='0';number.setAttribute('aria-label',`Turn ${d.axis} value`);label.title=d.provenance??'';const width=`${turnDialWidthCh(d)}ch`;const output=document.createElement('output');output.dataset.turnAxis=d.axis;output.style.width=width;output.style.minWidth=width;output.setAttribute('aria-label',`Current ${d.axis}`);const target=document.createElement('output');target.dataset.turnTarget=d.axis;target.style.width=width;target.style.minWidth=width;label.append(number,' Applied ',output,' · target ',target);panel.append(label);rows.set(d.axis,{dial:d,number,output,target});number.onchange=()=>{try{if(!number.value.trim())throw new Error('TURN_VALUE_REQUIRED');state.exact(d.axis,Number(number.value));commit();}catch(error){options.error(String(error));render();}};}
|
|
15
15
|
function render():void {hold.setAttribute('aria-pressed',String(state.held));smooth.checked=state.smoothing!==0;omega.disabled=!smooth.checked;if(state.smoothing)omega.value=String(state.smoothing);for(const [axis,row] of rows){const value=state.values[axis]!,targetValue=state.targets[axis]!;row.output.value=formatTurnValue(value,row.dial);row.output.dataset.value=String(value);row.target.value=formatTurnValue(targetValue,row.dial);row.target.dataset.value=String(targetValue);if(document.activeElement!==row.number)row.number.value=String(targetValue);}}
|
|
16
16
|
let saveTimer:ReturnType<typeof setTimeout>|undefined;
|
|
17
17
|
function commit():void {options.draw(state);render();if(saveTimer)clearTimeout(saveTimer);saveTimer=setTimeout(options.save,150);}
|