rig-review 1.16.3 → 1.16.4
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/package.json +1 -1
- package/web/stage-nav.ts +9 -3
package/package.json
CHANGED
package/web/stage-nav.ts
CHANGED
|
@@ -25,6 +25,13 @@ export function stageReason(stage:ReviewStage,model:boolean,direction=false,inte
|
|
|
25
25
|
if(stage===3&&!model)return 'MODEL_UNAVAILABLE: no compiled model is supplied in this inspection.';
|
|
26
26
|
return null;
|
|
27
27
|
}
|
|
28
|
+
function stageFrameRoute(access:InstanceAccess,path:'/stage-parts.html'|'/stage-interview.html',side?:'a'|'b'):string {
|
|
29
|
+
const query=new URLSearchParams({stageEmbed:'1',lang:getLanguage()});
|
|
30
|
+
if(side)query.set('side',side);
|
|
31
|
+
// Managed paths already identify the slot and their front accepts only the closed stage query.
|
|
32
|
+
if(access.base==='/'&&/^[a-f0-9]{64}$/.test(access.key))query.set('handoff',access.key);
|
|
33
|
+
return access.route(path)+'?'+query;
|
|
34
|
+
}
|
|
28
35
|
export function bindStageNav(options:{preRig?:boolean;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 {
|
|
29
36
|
const host=document.querySelector<HTMLElement>('[data-stage-nav]');if(!host)return ()=>{};
|
|
30
37
|
if(options.interviewOnly){
|
|
@@ -55,8 +62,7 @@ export function bindStageNav(options:{preRig?:boolean;interviewOnly?:boolean;int
|
|
|
55
62
|
if(!interview){
|
|
56
63
|
interview=document.createElement('iframe');
|
|
57
64
|
interview.title=t('interview.title');interview.className='review-interview-frame';
|
|
58
|
-
const url=new URL(access
|
|
59
|
-
url.searchParams.set('stageEmbed','1');url.searchParams.set('lang',getLanguage());
|
|
65
|
+
const url=new URL(stageFrameRoute(access,'/stage-interview.html'),location.href);
|
|
60
66
|
if(access.capability)url.hash='cap='+access.capability;
|
|
61
67
|
const frame=interview;
|
|
62
68
|
frame.src=url.href;frame.addEventListener('load',()=>setFrameLanguage(frame));
|
|
@@ -82,7 +88,7 @@ export function bindStageNav(options:{preRig?:boolean;interviewOnly?:boolean;int
|
|
|
82
88
|
if(stage===2&&!reason){status.textContent=t('interview.loading');void showInterview(revision);}
|
|
83
89
|
}
|
|
84
90
|
function showParts(){
|
|
85
|
-
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
|
|
91
|
+
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=stageFrameRoute(access,'/stage-parts.html',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||options.preRig){frame.contentWindow?.postMessage({type:'review-stage-revalidate',state:lastFrame!==frame?saved:null},location.origin);}frame.hidden=false;lastFrame=frame;
|
|
86
92
|
}
|
|
87
93
|
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);}};
|
|
88
94
|
window.addEventListener('message',correction);
|