rig-review 1.5.0 → 1.5.2
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/src/front.ts +3 -1
- package/web/animation-inspection.ts +4 -2
- package/web/i18n.ts +40 -1
- package/web/main.ts +3 -2
- package/web/part-selection.ts +3 -2
package/package.json
CHANGED
package/src/front.ts
CHANGED
|
@@ -164,7 +164,9 @@ export function startFront(options:{control:string;port:number;nonce:string;fing
|
|
|
164
164
|
}});
|
|
165
165
|
return {origin,stop:()=>server.stop(true),idleMs:()=>performance.now()-last,active:()=>active};
|
|
166
166
|
}
|
|
167
|
-
|
|
167
|
+
/** A missing directory or record means gone; any other read error (readdir or a record) throws, and the caller keeps
|
|
168
|
+
* the front up. A record read that failed with EACCES or ENOTDIR used to count as gone and stopped the front (#354). */
|
|
169
|
+
async function liveInstances(control:string):Promise<boolean>{let names:string[];try{names=await readdir(control);}catch(e){if((e as NodeJS.ErrnoException).code==='ENOENT')return false;throw e;}for(const name of names){if(/^[a-f0-9]{64}\.claim$/.test(name))return true;if(/^[a-f0-9]{64}\.json$/.test(name)){const row=await readRecord(join(control,name),name.slice(0,64));if(row&&running(row.pid))return true;}}return false;}
|
|
168
170
|
export async function runFront(requestPath:string):Promise<void>{
|
|
169
171
|
const spec=await smallJson(requestPath) as FrontRequest;if(spec?.schema!=='rig-review-front-request/1'||!uuid.test(spec.nonce??'')||!hex64.test(spec.fingerprint??'')||!Number.isSafeInteger(spec.port)||spec.port<1||spec.port>65535||!Number.isSafeInteger(spec.idleMs)||spec.idleMs<100)throw new Error('front: invalid request');
|
|
170
172
|
const control=await realpath(spec.control);if(dirname(await realpath(requestPath))!==control||spec.request!==requestPath||spec.record!==join(control,frontName(spec.port)+'.json'))throw new Error('front: invalid state locations');
|
|
@@ -2853,8 +2853,10 @@ export class AnimationInspectionPanel {
|
|
|
2853
2853
|
}
|
|
2854
2854
|
const isSelected=selected?.kind==='bone'&&selected.name===name;
|
|
2855
2855
|
const visible=enabled&&(bonePoints||isSelected);
|
|
2856
|
-
|
|
2857
|
-
|
|
2856
|
+
// #347: placed on every played frame; write only what changed.
|
|
2857
|
+
const hidden=!bonePoints&&!isSelected,pressed=String(isSelected);
|
|
2858
|
+
if(b.hidden!==hidden)b.hidden=hidden;
|
|
2859
|
+
if(b.getAttribute('aria-pressed')!==pressed)b.setAttribute('aria-pressed',pressed);
|
|
2858
2860
|
if(!visible){
|
|
2859
2861
|
order++;
|
|
2860
2862
|
continue;
|
package/web/i18n.ts
CHANGED
|
@@ -516,9 +516,23 @@ function translateCore(text: string, lang: ResolvedLanguage, depth: number): str
|
|
|
516
516
|
return text;
|
|
517
517
|
}
|
|
518
518
|
|
|
519
|
+
/**
|
|
520
|
+
* #347: `tr` is pure over the catalogs, which are built once and never change. Animate re-applies the same
|
|
521
|
+
* strings on every played frame (the DOM observer re-translates each rewritten title, label and text), and a
|
|
522
|
+
* string with no exact entry walks every parameterized pattern, so the results are memoized per language.
|
|
523
|
+
*/
|
|
524
|
+
const TR_CACHE_LIMIT = 8192;
|
|
525
|
+
const trCache: Record<ResolvedLanguage, Map<string, string>> = { en: new Map(), ko: new Map() };
|
|
526
|
+
|
|
519
527
|
export function tr(raw: string, lang: ResolvedLanguage = currentLanguage): string {
|
|
520
528
|
if (!raw) return raw;
|
|
521
|
-
|
|
529
|
+
const cache = trCache[lang];
|
|
530
|
+
const hit = cache.get(raw);
|
|
531
|
+
if (hit !== undefined) return hit;
|
|
532
|
+
const out = translateCore(raw, lang, 0);
|
|
533
|
+
if (cache.size >= TR_CACHE_LIMIT) cache.clear();
|
|
534
|
+
cache.set(raw, out);
|
|
535
|
+
return out;
|
|
522
536
|
}
|
|
523
537
|
|
|
524
538
|
// DOM binding state
|
|
@@ -733,6 +747,31 @@ export function sourceTextContent(node: Node | null | undefined): string {
|
|
|
733
747
|
return raw ? tr(raw, 'en') : '';
|
|
734
748
|
}
|
|
735
749
|
|
|
750
|
+
/**
|
|
751
|
+
* #347: write `value` (English source) as the element's text only when its source text differs. Callers write
|
|
752
|
+
* English and the DOM observer shows it translated, so comparing against `textContent` is always unequal under
|
|
753
|
+
* a translated UI and a played frame would rewrite (and re-translate) unchanged text.
|
|
754
|
+
*/
|
|
755
|
+
export function setSourceText(node: Element, value: string): boolean {
|
|
756
|
+
if ((node.childNodes?.length ?? 0) <= 1 && sourceTextContent(node) === value) return false;
|
|
757
|
+
node.textContent = value;
|
|
758
|
+
return true;
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
/** #347: an attribute's English source: what the caller last wrote, before the DOM observer translated it. */
|
|
762
|
+
export function sourceAttribute(el: Element, attr: string): string | null {
|
|
763
|
+
const current = typeof el.getAttribute === 'function' ? el.getAttribute(attr) : null;
|
|
764
|
+
const entry = elementAttrSource.get(el)?.get(attr);
|
|
765
|
+
return entry && current === entry.lastApplied ? entry.en : current;
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
/** #347: the attribute counterpart of `setSourceText`, for attributes the DOM observer translates. */
|
|
769
|
+
export function setSourceAttribute(el: Element, attr: string, value: string): boolean {
|
|
770
|
+
if (sourceAttribute(el, attr) === value) return false;
|
|
771
|
+
el.setAttribute(attr, value);
|
|
772
|
+
return true;
|
|
773
|
+
}
|
|
774
|
+
|
|
736
775
|
export function applyDomI18n(root: Document | Element = boundRoot ?? document): void {
|
|
737
776
|
if (!root || isApplyingDom) return;
|
|
738
777
|
isApplyingDom = true;
|
package/web/main.ts
CHANGED
|
@@ -31,7 +31,7 @@ import {historyRow,isPatchJob,recordFor,refusedText,restoredOutcomeForJob,retarg
|
|
|
31
31
|
import {meshEditBinding,meshEditText,type MeshEditDocument} from '../src/mesh-edit.ts';
|
|
32
32
|
import {chestRegionsBinding,cropWorldMapping,type CropWorldMapping} from '../src/chest-regions.ts';
|
|
33
33
|
import {bindWorkspaceUI,selectedInspector,type WorkspaceUI} from './workspace-ui.ts';
|
|
34
|
-
import {sourceTextContent,tr} from './i18n.ts';
|
|
34
|
+
import {setSourceText,sourceAttribute,sourceTextContent,tr} from './i18n.ts';
|
|
35
35
|
import {bindInspectorBlocks,activeBlocksUI,restoreActiveBlocksUI,type InspectorBlocks} from './inspector-blocks.ts';
|
|
36
36
|
import {connectControl} from './control.ts';
|
|
37
37
|
import {connectLiveWindow} from './live-connection.ts';
|
|
@@ -81,7 +81,8 @@ const input = (id: string) => el<HTMLInputElement>(id);
|
|
|
81
81
|
const select = (id: string) => el<HTMLSelectElement>(id);
|
|
82
82
|
const button = (id: string) => el<HTMLButtonElement>(id);
|
|
83
83
|
const titledIds = new Set(['message', 'player-state', 'layout-state', 'renderer-state', 'layer-state', 'idle-state', 'control-state', 'draft-state', 'rig-label', 'reference-label', 'coordinates']);
|
|
84
|
-
|
|
84
|
+
// #347: write only a changed source, so a played frame does not rewrite (and re-translate) unchanged text.
|
|
85
|
+
const text = (id: string, value: string) => { const node = el(id); setSourceText(node, value); if (titledIds.has(id) && sourceAttribute(node, 'title') !== value) node.title = value; };
|
|
85
86
|
const option = (value: string, label: string) => { const item = document.createElement('option'); item.value = value; item.textContent = label; return item; };
|
|
86
87
|
const errorText = (error: unknown) => error instanceof Error ? error.message : String(error);
|
|
87
88
|
// First, before any URL use: take the `#cap=` handoff into memory/session storage and strip it.
|
package/web/part-selection.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import type {Json} from '../src/manifest.ts';
|
|
3
3
|
import type {PosedFrame,RigPlayer,PoseBounds,SlotIdentitySnapshot} from '@rig-c/play';
|
|
4
4
|
import {parseControlPart,parsePartIdentity,type ControlPart,type ControlPartIdentity,type PartIdentityReason} from '../src/control.ts';
|
|
5
|
+
import {setSourceAttribute,setSourceText,sourceAttribute} from './i18n.ts';
|
|
5
6
|
export interface PartDeclaration {skin:string;attachment:string;kind:string;path:string|null}
|
|
6
7
|
export interface PartEntry {slot:string;bone:string;setup:string|null;declarations:PartDeclaration[]}
|
|
7
8
|
export interface PartObservation {side:ControlPart['side'];slot:string;mode:ControlPart['mode'];identity:ControlPartIdentity|null;generation:number|null;reason:PartIdentityReason|null;drawn:boolean;kind:string|null;page:string|null;region:string|null;sequence:number|null;vertices:number|null;triangles:number|null;z:number|null;skin:string|null;set:string|null;activeAttachment:{skin:string;attachment:string}|null;identityUnavailable:string|null;bounds:PoseBounds|null;declarations:PartDeclaration[]}
|
|
@@ -127,8 +128,8 @@ export class PartExplorer extends PartInspection {
|
|
|
127
128
|
row.onclick=()=>this.action(()=>{const live=this.live();this.select(live?.side===side&&live.slot===entry.slot?null:{side,slot:entry.slot,mode:this.selected?.mode??'context'});});const item=document.createElement('li');item.append(row);this.list.append(item);this.rows.set(JSON.stringify([side,entry.slot]),row);this.rowEntries.set(row,entry);}this.orderKey='';this.reorder();this.renderSelection(true);this.highlightBone(this.highlightedBone);}
|
|
128
129
|
private statusText():string {const refused=[...this.refused].filter(([side])=>this.visibleSide===null||side===this.visibleSide).map(([side,r])=>`${side==='single'?'':side.toUpperCase()+' '}${r.code}`);if(refused.length)return `Parts unavailable · ${refused.join(' · ')}. The rig keeps drawing whole; selection, Solo and feedback targeting are off ${[...this.refused.values()].some(r=>r.catalog)?'until the package reloads with a matching catalog':'until a frame with a valid identity snapshot'}.`;const shown=this.shownSides();return shown.length?`${shown.reduce((n,[,s])=>n+s.entries.length,0)} declared slots · ${this.rows.size} results`:'No compiled rig catalog available';}
|
|
129
130
|
private reorder(){const keys=this.shownSides().flatMap(([side,state])=>orderedParts(state.entries,state.frame,state.identity).map(entry=>JSON.stringify([side,entry.slot]))).filter(key=>this.rows.has(key)),key=JSON.stringify(keys);if(key===this.orderKey)return;this.orderKey=key;const active=document.activeElement;for(const item of keys){const row=this.rows.get(item)!;this.list.append(row.parentElement!);}if(active instanceof HTMLElement&&this.list.contains(active)&&document.activeElement!==active)active.focus({preventScroll:true});}
|
|
130
|
-
private renderSelection(force=false){const key=this.viewKey();if(!force&&key===this.selectionKey)return;this.selectionKey=key;const status=this.host.querySelector<HTMLElement>('[data-part-status]')!;status
|
|
131
|
-
|
|
131
|
+
private renderSelection(force=false){const key=this.viewKey();if(!force&&key===this.selectionKey)return;this.selectionKey=key;const status=this.host.querySelector<HTMLElement>('[data-part-status]')!;setSourceText(status,this.statusText());if(this.refused.size)this.host.dataset.parts='unavailable';else delete this.host.dataset.parts;const drawnBySide=new Map([...this.sides].map(([side,state])=>[side,new Set(state.frame?.order.map(row=>row.slot)??[])]));this.whole.setAttribute('aria-pressed',String(!this.selected));this.solo.disabled=!this.live();this.solo.checked=this.live()?.mode==='solo';for(const [key,row]of this.rows){row.setAttribute('aria-pressed',String(key===JSON.stringify([this.live()?.side,this.live()?.slot])));const refusal=this.refused.get(row.dataset.side as ControlPart['side']);row.disabled=!!refusal;const parts=this.rowParts.get(row)!;if(refusal){const label=`${row.dataset.side==='single'?'':row.dataset.side!.toUpperCase()+' · '}${row.dataset.slot} · parts unavailable · ${refusal.code}`;if(parts.label.textContent!==label){parts.label.textContent=label;parts.icon.textContent='';delete parts.icon.dataset.thumbnailPlan;}row.title=label;row.setAttribute('aria-label',label);row.dataset.drawn='false';continue;}const state=this.sides.get(row.dataset.side as ControlPart['side']);const drawn=drawnBySide.get(row.dataset.side as ControlPart['side'])?.has(row.dataset.slot!);row.dataset.drawn=String(!!drawn);const entry=this.rowEntries.get(row),identity=entry?partIdentity(state?.identity??null,row.dataset.slot!):null;const glyph=entry?.declarations.some(d=>d.kind==='mesh')?'◈':'◇',source=this.thumbnails.get(row.dataset.side as ControlPart['side']),note=entry&&source?source.show(parts.icon,entry,identity,glyph):null;if(!note&&parts.icon.textContent!==glyph){parts.icon.textContent=glyph;delete parts.icon.dataset.thumbnailPlan;}
|
|
132
|
+
const title=`${row.dataset.slot} · ${state?.frame?drawn?'drawn':'not drawn':'awaiting draw'}${identity?identity.reason?' · '+identity.reason:' · '+identity.skin+' / '+identity.attachment:' · awaiting identity snapshot'}${note?' · '+note:''}`;if(sourceAttribute(row,'title')!==title)row.title=title;const label=`${row.dataset.side==='single'?'':row.dataset.side!.toUpperCase()+' · '}${row.dataset.slot} · ${state?.frame?drawn?'drawn':'not drawn':'awaiting draw'} · ${identity?identity.reason?'no active attachment · '+identity.reason:identity.skin+' / '+identity.attachment:'awaiting identity snapshot'}`;setSourceText(parts.label,label);setSourceAttribute(row,'aria-label',`${glyph} ${label} · ${state?.frame?drawn?'drawn':'not drawn':'awaiting draw'}`);}}
|
|
132
133
|
private renderDetail(){
|
|
133
134
|
const observation=this.observation(),refusal=this.selected?this.refused.get(this.selected.side):[...this.refused.values()][0],key=JSON.stringify([observation,refusal??null,this.statusHint]);if(key===this.detailKey)return;this.detailKey=key;
|
|
134
135
|
// Keep focused controls connected while the selected pose's bounds animate.
|