@usemosio/cli-linux-x64 1.0.0-next.2 → 1.0.0-next.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.
Files changed (38) hide show
  1. package/apps/studio/dist/assets/{Workspace-DsbQ04kb.js → Workspace-Dr-hVeFd.js} +1 -1
  2. package/apps/studio/dist/assets/{agent-panel-DUWPbpew.js → agent-panel-DMrVed-J.js} +1 -1
  3. package/apps/studio/dist/assets/{boundary-DuK3AiqM.js → boundary-DL9veUlN.js} +1 -1
  4. package/apps/studio/dist/assets/{index-DPLtb0kT.js → index-C6juWzGV.js} +82 -3
  5. package/apps/studio/dist/assets/{inspector3d-B8pkZTye.js → inspector3d-sqergHSP.js} +1 -1
  6. package/apps/studio/dist/index.html +1 -1
  7. package/bin/mosio +0 -0
  8. package/bin/mosio-agent +0 -0
  9. package/crates/mosio/src/adapters/mosio-three.js +1 -1
  10. package/crates/mosio/src/runtime.js +79 -0
  11. package/fixtures/cloudrun-gpu/audio/music.wav +0 -0
  12. package/fixtures/cloudrun-gpu/audio/vo.wav +0 -0
  13. package/fixtures/cloudrun-gpu/mosio.json +18 -0
  14. package/fixtures/cloudrun-gpu/scenes/cube.html +25 -0
  15. package/fixtures/direct-seek/mosio.json +4 -0
  16. package/fixtures/direct-seek/scenes/clock.html +9 -0
  17. package/fixtures/direct-seek/scenes/meta.html +11 -0
  18. package/fixtures/direct-seek/scenes/pure.html +11 -0
  19. package/fixtures/direct-seek/scenes/slow.html +11 -0
  20. package/fixtures/direct-seek-media/mosio.json +6 -0
  21. package/fixtures/direct-seek-media/scenes/pure.html +11 -0
  22. package/fixtures/gl-readback/mosio.json +16 -0
  23. package/fixtures/gl-readback/scenes/compositor.html +23 -0
  24. package/fixtures/gl-readback/scenes/readback.html +23 -0
  25. package/package.json +1 -1
  26. package/scripts/acceptance/direct-seek.sh +68 -0
  27. package/scripts/acceptance/frames.sh +7 -2
  28. package/scripts/check-error-codes.py +1 -1
  29. package/scripts/check-file-size.sh +0 -4
  30. package/scripts/gen-media-fixtures.sh +1 -0
  31. package/scripts/gl-readback-check.sh +26 -0
  32. package/scripts/platform-smoke.sh +16 -3
  33. package/scripts/user-journey.sh +68 -0
  34. package/skills/mosio-3d/SKILL.md +30 -2
  35. package/skills/mosio-engine/references/checks.md +1 -1
  36. package/skills/mosio-engine/references/project.md +12 -0
  37. package/skills/mosio-engine/references/timeline.md +1 -1
  38. package/skills/mosio-media/references/captions.md +4 -1
@@ -1 +1 @@
1
- import{F as e,N as t,Z as n,a as r,at as i,ct as a,g as o,j as s,t as c,tt as l,v as u,w as d,z as f}from"./feedback-x6ZumR_x.js";import{A as p,vt as m,yt as h}from"./index-DPLtb0kT.js";var g=a(i(),1),_=l();function v(e){let t=e=>e.id??e.name??`?`,n=new Map;for(let r of e)n.set(t(r),{obj:r,key:t(r),children:[]});let r=[];for(let e of n.values()){let t=e.obj.parent?n.get(e.obj.parent):void 0;(t?t.children:r).push(e)}let i=e=>{e.sort((e,t)=>e.key.localeCompare(t.key)),e.forEach(e=>i(e.children))};return i(r),r}function y({objects:n,selected:r,onSelect:i,filter:a=``,live:c=!0}){let l=(0,g.useMemo)(()=>v(n),[n]),[f,p]=(0,g.useState)(new Set),m=e=>!a||e.key.toLowerCase().includes(a.toLowerCase())||e.children.some(m),h=[],y=(e,t)=>{for(let n of e)m(n)&&(h.push({n,depth:t}),f.has(n.key)||y(n.children,t+1))};return y(l,0),(0,_.jsxs)(`div`,{className:`m3d m3d-tree`,role:`tree`,"aria-label":`3D objects`,children:[h.map(({n,depth:a})=>{let l=n.children.length>0,m=n.key.includes(`/`)?n.key.split(`/`).slice(1).join(`/`):n.key;return(0,_.jsxs)(`button`,{role:`treeitem`,"aria-selected":r===n.key,"aria-expanded":l?!f.has(n.key):void 0,className:`m3d-node${n.obj.visible?``:` hidden`}`,style:{paddingLeft:6+a*14},onClick:()=>c&&i?.(n.key),title:n.key,children:[(0,_.jsx)(`span`,{className:`twisty`,onClick:e=>{l&&(e.stopPropagation(),p(e=>{let t=new Set(e);return t.has(n.key)?t.delete(n.key):t.add(n.key),t}))},children:l?f.has(n.key)?(0,_.jsx)(u,{size:11}):(0,_.jsx)(o,{size:11}):null}),n.obj.type===`Mesh`?(0,_.jsx)(t,{size:12}):n.obj.type.includes(`Light`)?(0,_.jsx)(s,{size:12}):(0,_.jsx)(d,{size:12}),(0,_.jsx)(`span`,{className:`nm`,children:m}),n.obj.triangles?(0,_.jsx)(`span`,{className:`meta`,children:n.obj.triangles>=1e3?`${(n.obj.triangles/1e3).toFixed(1)}k`:n.obj.triangles}):null,(0,_.jsx)(`span`,{className:`eye`,children:(0,_.jsx)(e,{size:12,style:n.obj.visible?void 0:{opacity:.35}})})]},n.key)}),h.length===0&&(0,_.jsx)(`span`,{className:`m3d-sub`,style:{padding:8},children:`No objects match.`})]})}var b=(e,t=3)=>e==null||Number.isNaN(e)?`—`:Math.abs(e)<1e-9?`0`:e.toFixed(t).replace(/\.?0+$/,``);function x([e,t,n,r]){let i=1-2*(t*t+n*n),a=2*(e*t-n*r),o=2*(e*n+t*r),s=1-2*(e*e+n*n),c=2*(t*n-e*r),l=2*(t*n+e*r),u=1-2*(e*e+t*t),d=Math.asin(Math.max(-1,Math.min(1,o))),[f,p]=Math.abs(o)<.9999999?[Math.atan2(-c,u),Math.atan2(-a,i)]:[Math.atan2(l,s),0];return[f,d,p].map(e=>e*180/Math.PI)}function S({label:e,children:t,value:n}){return(0,_.jsxs)(`div`,{className:`m3d-field`,children:[(0,_.jsxs)(`div`,{className:`m3d-row`,children:[(0,_.jsx)(`span`,{className:`m3d-label`,children:e}),n!==void 0&&(0,_.jsx)(`span`,{className:`m3d-value`,children:n})]}),t]})}function C({v:e,unit:t=``,digits:n=3}){return(0,_.jsx)(`div`,{className:`m3d-grid3`,children:[`x`,`y`,`z`].map((r,i)=>(0,_.jsxs)(`div`,{className:`m3d-num axis-${r}`,children:[(0,_.jsx)(`span`,{children:r.toUpperCase()}),(0,_.jsxs)(`span`,{children:[b(e[i],n),t]})]},r))})}function w({prop:e,axis:t,value:n,label:r,disabled:i,onCommit:a}){let o=b(n,3),[s,c]=(0,g.useState)(o),l=(0,g.useRef)(!1);return(0,g.useEffect)(()=>c(o),[o]),(0,_.jsxs)(`div`,{className:`m3d-num axis-${t}`,children:[(0,_.jsx)(`span`,{children:t.toUpperCase()}),(0,_.jsx)(`input`,{"data-testid":`m3d-edit-${e}-${t}`,"aria-label":r,inputMode:`decimal`,value:s,disabled:i,onChange:e=>c(e.target.value),onBlur:()=>{if(l.current){l.current=!1;return}let e=s.trim()===``?NaN:Number(s);!Number.isFinite(e)||b(e,3)===o?c(o):a(e)},onKeyDown:e=>{e.key===`Enter`?e.currentTarget.blur():e.key===`Escape`&&(l.current=!0,c(o),e.currentTarget.blur())}})]})}function T({prop:e,title:t,v:n,disabled:r,onEdit:i}){return(0,_.jsx)(`div`,{className:`m3d-grid3`,children:[`x`,`y`,`z`].map((a,o)=>(0,_.jsx)(w,{prop:e,axis:a,value:n[o]??0,label:`${t} ${a.toUpperCase()}`,disabled:r,onCommit:e=>{let t=[n[0]??0,n[1]??0,n[2]??0];t[o]=e,i(t)}},a))})}function E({obj:e,source:n}){return(0,_.jsxs)(`div`,{className:`m3d-header`,children:[(0,_.jsx)(`div`,{className:`m3d-typebadge`,children:e.type.includes(`Light`)?(0,_.jsx)(s,{size:13}):e.type.includes(`Camera`)?(0,_.jsx)(f,{size:13}):e.type===`Mesh`?(0,_.jsx)(t,{size:13}):(0,_.jsx)(d,{size:13})}),(0,_.jsxs)(`div`,{className:`m3d-header-text`,children:[(0,_.jsx)(`span`,{className:`m3d-name`,"data-testid":`m3d-object-id`,children:e.id??e.name??`unnamed`}),(0,_.jsxs)(`span`,{className:`m3d-sub`,children:[e.type,n?` · ${n}`:``]})]})]})}function D({object:e,onAskAgent:t,onEdit:n}){let[r,i]=(0,g.useState)(`local`),[a,o]=(0,g.useState)(!1),[s,c]=(0,g.useState)(!1),l=!!n&&r===`local`,u=e=>async t=>{o(!0),c(!1);try{await n?.(e,t)}catch{c(!0)}finally{o(!1)}},d=t=>e.pinned?.[t]?(0,_.jsx)(`span`,{className:`m3d-sub`,"data-testid":`m3d-pinned-${t}`,children:`Pinned by Studio`}):null,f=e[r],m=(0,g.useMemo)(()=>x(f.quaternion),[f.quaternion]);return(0,_.jsxs)(`div`,{className:`m3d`,style:{display:`flex`,flexDirection:`column`,gap:16},children:[(0,_.jsx)(E,{obj:e,source:e.parent?`child of ${e.parent}`:`root`}),(0,_.jsx)(`div`,{className:`m3d-seg`,role:`group`,"aria-label":`Transform space`,children:[`local`,`world`].map(e=>(0,_.jsx)(`button`,{"aria-pressed":r===e,onClick:()=>i(e),children:e===`local`?`Local`:`World`},e))}),l?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(S,{label:`Position`,value:`m`,children:[(0,_.jsx)(T,{prop:`position`,title:`Position`,v:f.position,disabled:a,onEdit:u(`position`)},s?`pf`:`p`),d(`position`)]}),(0,_.jsxs)(S,{label:`Rotation`,value:`deg, XYZ`,children:[(0,_.jsx)(T,{prop:`rotation`,title:`Rotation`,v:m,disabled:a,onEdit:u(`rotation`)},s?`rf`:`r`),d(`rotation`)]}),(0,_.jsxs)(S,{label:`Scale`,children:[(0,_.jsx)(T,{prop:`scale`,title:`Scale`,v:f.scale,disabled:a,onEdit:u(`scale`)},s?`sf`:`s`),d(`scale`)]}),s&&(0,_.jsx)(`span`,{className:`m3d-tag err`,role:`alert`,children:`Edit failed`})]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(S,{label:`Position`,value:`m`,children:(0,_.jsx)(C,{v:f.position})}),(0,_.jsx)(S,{label:`Rotation`,value:`deg, XYZ`,children:(0,_.jsx)(C,{v:m,digits:1,unit:`°`})}),(0,_.jsx)(S,{label:`Scale`,children:(0,_.jsx)(C,{v:f.scale})})]}),e.bbox&&(0,_.jsx)(S,{label:`Bounds (world)`,value:`${b((e.bbox.max[0]-e.bbox.min[0])*100,1)} × ${b((e.bbox.max[1]-e.bbox.min[1])*100,1)} × ${b((e.bbox.max[2]-e.bbox.min[2])*100,1)} cm`}),e.screen&&`x`in e.screen&&(0,_.jsx)(S,{label:`On screen`,value:e.screen.onscreen?`${Math.round(e.screen.w)}×${Math.round(e.screen.h)} px at ${Math.round(e.screen.x)}, ${Math.round(e.screen.y)}`:`off screen`}),(0,_.jsxs)(`div`,{className:`m3d-row`,children:[(0,_.jsx)(`span`,{className:`m3d-label`,children:`Visibility`}),(0,_.jsxs)(`span`,{className:`m3d-tag ${e.visible?`ok`:``}`,children:[(0,_.jsx)(`span`,{className:`m3d-dot`}),e.visible?`Visible`:`Hidden`]})]}),(0,_.jsx)(p,{title:`Animated transform`,note:`Values are computed from the frame by the scene code.`,link:t?(0,_.jsx)(`button`,{className:`m3d-link`,onClick:()=>e.id&&t(e.id),children:`Ask the agent`}):void 0})]})}function O({camera:e,frame:t}){let n=x(e.quaternion),r=e.fov?18/Math.tan(e.fov/2*Math.PI/180):null;return(0,_.jsxs)(`div`,{className:`m3d`,style:{display:`flex`,flexDirection:`column`,gap:16},children:[(0,_.jsx)(E,{obj:{id:`camera`,name:`camera`,type:e.type},source:t===void 0?void 0:`frame ${t}`}),(0,_.jsxs)(`div`,{className:`m3d-grid2`,children:[(0,_.jsxs)(`div`,{className:`m3d-num`,children:[(0,_.jsx)(`span`,{children:`FOV`}),(0,_.jsxs)(`span`,{children:[b(e.fov,1),`°`]})]}),(0,_.jsxs)(`div`,{className:`m3d-num`,children:[(0,_.jsx)(`span`,{children:`Lens`}),(0,_.jsx)(`span`,{children:r?`${b(r,1)} mm`:`—`})]}),(0,_.jsxs)(`div`,{className:`m3d-num`,children:[(0,_.jsx)(`span`,{children:`Near`}),(0,_.jsx)(`span`,{children:b(e.near)})]}),(0,_.jsxs)(`div`,{className:`m3d-num`,children:[(0,_.jsx)(`span`,{children:`Far`}),(0,_.jsx)(`span`,{children:b(e.far,1)})]})]}),(0,_.jsx)(S,{label:`Position`,value:`m`,children:(0,_.jsx)(C,{v:e.position})}),(0,_.jsx)(S,{label:`Rotation`,value:`deg`,children:(0,_.jsx)(C,{v:n,digits:1,unit:`°`})}),(0,_.jsx)(S,{label:`Looking along`,children:(0,_.jsx)(C,{v:e.direction})}),(0,_.jsx)(S,{label:`Aspect`,value:b(e.aspect,4)})]})}function k({material:e}){let t=e=>e===null?0:Math.round(e*100),n=(e,n)=>(0,_.jsx)(S,{label:e,value:b(n,2),children:(0,_.jsxs)(`div`,{className:`m3d-slider`,children:[(0,_.jsx)(`i`,{style:{width:`${t(n)}%`}}),(0,_.jsx)(`b`,{style:{left:`calc(${t(n)}% - 6px)`}})]})});return(0,_.jsxs)(`div`,{className:`m3d`,style:{display:`flex`,flexDirection:`column`,gap:16},children:[(0,_.jsx)(E,{obj:{id:e.name,name:e.name,type:e.type}}),(0,_.jsxs)(`div`,{className:`m3d-row`,children:[(0,_.jsx)(`span`,{className:`m3d-label`,children:`Base colour`}),(0,_.jsx)(`span`,{className:`m3d-swatch`,style:{background:e.color??`transparent`}}),(0,_.jsx)(`span`,{className:`m3d-value m3d-mono`,children:e.color??`—`})]}),e.emissive&&e.emissive!==`#000000`&&(0,_.jsxs)(`div`,{className:`m3d-row`,children:[(0,_.jsx)(`span`,{className:`m3d-label`,children:`Emissive`}),(0,_.jsx)(`span`,{className:`m3d-swatch`,style:{background:e.emissive}}),(0,_.jsx)(`span`,{className:`m3d-value m3d-mono`,children:e.emissive})]}),n(`Metalness`,e.metalness),n(`Roughness`,e.roughness),n(`Opacity`,e.opacity),(0,_.jsxs)(`div`,{className:`m3d-row`,style:{flexWrap:`wrap`,gap:6},children:[e.transparent&&(0,_.jsx)(`span`,{className:`m3d-tag info`,children:`transparent`}),e.transmission?(0,_.jsxs)(`span`,{className:`m3d-tag info`,children:[`transmission `,b(e.transmission,2)]}):null,Object.entries(e.textures).map(([e,t])=>(0,_.jsx)(`span`,{className:`m3d-tag`,title:t,children:e},e)),Object.keys(e.textures).length===0&&(0,_.jsx)(`span`,{className:`m3d-tag`,children:`no textures`})]})]})}function A({lights:e,environment:t}){return(0,_.jsxs)(`div`,{className:`m3d`,style:{display:`flex`,flexDirection:`column`,gap:12},children:[t&&(0,_.jsxs)(`div`,{className:`m3d-row`,children:[(0,_.jsx)(`span`,{className:`m3d-label`,children:`Environment`}),(0,_.jsx)(`span`,{className:`m3d-tag ${t.environment?`ok`:``}`,children:t.environment?`image-based light`:`none`}),t.background&&(0,_.jsx)(`span`,{className:`m3d-swatch`,title:t.background,style:{background:t.background}})]}),e.map((e,t)=>(0,_.jsxs)(`div`,{className:`m3d-card`,style:{padding:10,gap:8},children:[(0,_.jsxs)(`div`,{className:`m3d-row`,children:[(0,_.jsx)(s,{size:13}),(0,_.jsx)(`span`,{className:`m3d-name`,style:{flex:1},children:e.id??e.name??e.type}),(0,_.jsx)(`span`,{className:`m3d-sub`,children:e.type.replace(`Light`,``)})]}),(0,_.jsxs)(`div`,{className:`m3d-row`,children:[(0,_.jsx)(`span`,{className:`m3d-swatch`,style:{background:e.color}}),(0,_.jsx)(`span`,{className:`m3d-value m3d-mono`,style:{flex:1},children:e.color}),(0,_.jsx)(`span`,{className:`m3d-value`,children:b(e.intensity,2)}),e.castShadow&&(0,_.jsx)(`span`,{className:`m3d-tag info`,children:`shadow`}),!e.visible&&(0,_.jsx)(`span`,{className:`m3d-tag`,children:`off`})]})]},e.id??t))]})}function j({clips:e}){return(0,_.jsx)(`div`,{className:`m3d`,style:{display:`flex`,flexDirection:`column`,gap:8},children:e.map(e=>(0,_.jsxs)(`div`,{className:`m3d-field`,children:[(0,_.jsxs)(`div`,{className:`m3d-row`,children:[(0,_.jsx)(`span`,{className:`m3d-name`,style:{flex:1},children:e.clip}),(0,_.jsxs)(`span`,{className:`m3d-sub`,children:[e.loop??`unscheduled`,` · `,b(e.duration,2),` s`]})]}),(0,_.jsx)(`div`,{className:`m3d-slider`,children:(0,_.jsx)(`i`,{style:{width:`${e.state?e.state.time/e.duration*100:0}%`,opacity:e.state?.4+.6*e.state.weight:.25}})}),e.state&&(0,_.jsxs)(`span`,{className:`m3d-sub`,children:[`t = `,b(e.state.time,2),` s · weight `,b(e.state.weight,2)]})]},e.clip))})}function M({stage:e,selected:t,onAskAgent:n,onEdit:r}){let[i,a]=(0,g.useState)(`object`),o=e.objects.find(e=>e.id===t)??null,s=o?e.materials.find(e=>o.materials.includes(e.name??``))??null:null,c=[[`object`,`Object`],[`material`,`Material`],[`camera`,`Camera`],[`lights`,`Lights`,e.lights.length],[`clips`,`Clips`,e.clips.length]];return(0,_.jsxs)(`div`,{className:`m3d m3d-panel`,style:{height:`100%`},children:[(0,_.jsx)(`div`,{className:`m3d-tabs`,role:`tablist`,children:c.map(([e,t,n])=>(0,_.jsxs)(`button`,{role:`tab`,className:`m3d-tab`,"data-testid":`m3d-tab-${e}`,"aria-selected":i===e,onClick:()=>a(e),children:[t,n?(0,_.jsx)(`span`,{className:`m3d-sub`,children:n}):null]},e))}),(0,_.jsxs)(`div`,{className:`m3d-body`,children:[i===`object`&&(o?(0,_.jsx)(D,{object:o,onAskAgent:n,onEdit:r&&o.id?(e,t)=>r(o.id,e,t):void 0}):(0,_.jsx)(p,{title:`Nothing selected`,note:`Pick an object in the viewer or the object tree.`})),i===`material`&&(s?(0,_.jsx)(k,{material:s}):(0,_.jsx)(p,{title:`No material`,note:o?`This object has no material of its own.`:`Select a mesh to see its material.`})),i===`camera`&&(0,_.jsx)(O,{camera:e.camera,frame:e.frame}),i===`lights`&&(0,_.jsx)(A,{lights:e.lights,environment:e.environment}),i===`clips`&&(e.clips.length?(0,_.jsx)(j,{clips:e.clips}):(0,_.jsx)(p,{title:`No animation clips`,note:`This scene animates in code only.`}))]})]})}function N({player:e,snapshot:i,canEdit:a,editTransform:o}){let[s,l]=(0,g.useState)(null),[u,d]=(0,g.useState)(null),[f,p]=(0,g.useState)(null),[v,b]=(0,g.useState)(null),x=(0,g.useRef)(!1),S=(0,g.useRef)(!1),C=(0,g.useCallback)(async()=>{if(x.current)return void(S.current=!0);x.current=!0;try{do{S.current=!1;try{let t=await e.inspect3d();l(t),b(null)}catch(e){b(String(e?.message??e).slice(0,300))}}while(S.current)}finally{x.current=!1}},[e]);(0,g.useEffect)(()=>{let t=null,n=(n=200)=>{t&&clearTimeout(t),t=setTimeout(()=>{let t=e.store.get();t.status===`ready`&&!t.playing&&C()},n)};n(0);let r=[e.frame.subscribe(()=>n()),e.store.select(e=>e.status,()=>n(50)),e.store.select(e=>e.playing,()=>n())];return()=>{t&&clearTimeout(t),r.forEach(e=>e())}},[e,C,i.tree]),(0,g.useEffect)(()=>e.store.select(e=>e.selection,t=>{t?.at&&e.pick3d(t.at.x,t.at.y).then(e=>{e&&(d(e.id),p(e.scene_id))},()=>{})}),[e]);let w=s?.[0]??null,T=(0,g.useMemo)(()=>{try{let t=m(i.scenes,i.transitions,i.composition.total_frames);return h(t,Math.min(e.frame.get(),Math.max(0,t.totalFrames-1))).layers.at(-1)?.sceneId??null}catch{return null}},[i,s]),E=f??T,D=(0,g.useCallback)(async(e,t,n)=>{if(!E)throw Error(`no scene at this frame`);await o(E,e,t,n);for(let e of[300,1200])setTimeout(()=>void C(),e)},[E,o,C]);return(0,_.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-surface-raised font-sans`,"data-testid":`panel-inspector3d`,"data-3d-selected":u??``,children:[(0,_.jsx)(n,{icon:(0,_.jsx)(t,{size:14,className:`text-text-secondary`}),title:`3D inspector`,meta:w?(0,_.jsx)(r,{tone:`info`,children:`${w.capabilities.backend} · three r${w.capabilities.three} · frame ${w.frame}`}):(0,_.jsx)(r,{tone:`neutral`,children:`No 3D stage`})}),v&&(0,_.jsx)(`div`,{className:`p-3`,children:(0,_.jsx)(c,{tone:`error`,children:v})}),w?(0,_.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,_.jsx)(`div`,{className:`flex max-h-[38%] min-h-24 shrink-0 flex-col overflow-auto border-b border-border-default`,"data-testid":`inspector3d-tree`,children:(0,_.jsx)(y,{objects:w.objects,selected:u,onSelect:e=>(d(e),p(null)),live:!0})}),(0,_.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col [&_.m3d-panel]:w-full [&_.m3d-panel]:border-l-0`,children:(0,_.jsx)(M,{stage:w,selected:u,onEdit:a&&E?D:void 0})})]}):(0,_.jsx)(`div`,{className:`p-3.5`,"data-testid":`inspector3d-empty`,children:(0,_.jsx)(c,{tone:`info`,children:s===null?`Reading the live 3D stage…`:`This frame has no live mosio-three stage. The 3D inspector reads the live preview; exact frames and cached Blender renders carry no live scene.`})})]})}export{N as Studio3DInspector};
1
+ import{F as e,N as t,Z as n,a as r,at as i,ct as a,g as o,j as s,t as c,tt as l,v as u,w as d,z as f}from"./feedback-x6ZumR_x.js";import{A as p,vt as m,yt as h}from"./index-C6juWzGV.js";var g=a(i(),1),_=l();function v(e){let t=e=>e.id??e.name??`?`,n=new Map;for(let r of e)n.set(t(r),{obj:r,key:t(r),children:[]});let r=[];for(let e of n.values()){let t=e.obj.parent?n.get(e.obj.parent):void 0;(t?t.children:r).push(e)}let i=e=>{e.sort((e,t)=>e.key.localeCompare(t.key)),e.forEach(e=>i(e.children))};return i(r),r}function y({objects:n,selected:r,onSelect:i,filter:a=``,live:c=!0}){let l=(0,g.useMemo)(()=>v(n),[n]),[f,p]=(0,g.useState)(new Set),m=e=>!a||e.key.toLowerCase().includes(a.toLowerCase())||e.children.some(m),h=[],y=(e,t)=>{for(let n of e)m(n)&&(h.push({n,depth:t}),f.has(n.key)||y(n.children,t+1))};return y(l,0),(0,_.jsxs)(`div`,{className:`m3d m3d-tree`,role:`tree`,"aria-label":`3D objects`,children:[h.map(({n,depth:a})=>{let l=n.children.length>0,m=n.key.includes(`/`)?n.key.split(`/`).slice(1).join(`/`):n.key;return(0,_.jsxs)(`button`,{role:`treeitem`,"aria-selected":r===n.key,"aria-expanded":l?!f.has(n.key):void 0,className:`m3d-node${n.obj.visible?``:` hidden`}`,style:{paddingLeft:6+a*14},onClick:()=>c&&i?.(n.key),title:n.key,children:[(0,_.jsx)(`span`,{className:`twisty`,onClick:e=>{l&&(e.stopPropagation(),p(e=>{let t=new Set(e);return t.has(n.key)?t.delete(n.key):t.add(n.key),t}))},children:l?f.has(n.key)?(0,_.jsx)(u,{size:11}):(0,_.jsx)(o,{size:11}):null}),n.obj.type===`Mesh`?(0,_.jsx)(t,{size:12}):n.obj.type.includes(`Light`)?(0,_.jsx)(s,{size:12}):(0,_.jsx)(d,{size:12}),(0,_.jsx)(`span`,{className:`nm`,children:m}),n.obj.triangles?(0,_.jsx)(`span`,{className:`meta`,children:n.obj.triangles>=1e3?`${(n.obj.triangles/1e3).toFixed(1)}k`:n.obj.triangles}):null,(0,_.jsx)(`span`,{className:`eye`,children:(0,_.jsx)(e,{size:12,style:n.obj.visible?void 0:{opacity:.35}})})]},n.key)}),h.length===0&&(0,_.jsx)(`span`,{className:`m3d-sub`,style:{padding:8},children:`No objects match.`})]})}var b=(e,t=3)=>e==null||Number.isNaN(e)?`—`:Math.abs(e)<1e-9?`0`:e.toFixed(t).replace(/\.?0+$/,``);function x([e,t,n,r]){let i=1-2*(t*t+n*n),a=2*(e*t-n*r),o=2*(e*n+t*r),s=1-2*(e*e+n*n),c=2*(t*n-e*r),l=2*(t*n+e*r),u=1-2*(e*e+t*t),d=Math.asin(Math.max(-1,Math.min(1,o))),[f,p]=Math.abs(o)<.9999999?[Math.atan2(-c,u),Math.atan2(-a,i)]:[Math.atan2(l,s),0];return[f,d,p].map(e=>e*180/Math.PI)}function S({label:e,children:t,value:n}){return(0,_.jsxs)(`div`,{className:`m3d-field`,children:[(0,_.jsxs)(`div`,{className:`m3d-row`,children:[(0,_.jsx)(`span`,{className:`m3d-label`,children:e}),n!==void 0&&(0,_.jsx)(`span`,{className:`m3d-value`,children:n})]}),t]})}function C({v:e,unit:t=``,digits:n=3}){return(0,_.jsx)(`div`,{className:`m3d-grid3`,children:[`x`,`y`,`z`].map((r,i)=>(0,_.jsxs)(`div`,{className:`m3d-num axis-${r}`,children:[(0,_.jsx)(`span`,{children:r.toUpperCase()}),(0,_.jsxs)(`span`,{children:[b(e[i],n),t]})]},r))})}function w({prop:e,axis:t,value:n,label:r,disabled:i,onCommit:a}){let o=b(n,3),[s,c]=(0,g.useState)(o),l=(0,g.useRef)(!1);return(0,g.useEffect)(()=>c(o),[o]),(0,_.jsxs)(`div`,{className:`m3d-num axis-${t}`,children:[(0,_.jsx)(`span`,{children:t.toUpperCase()}),(0,_.jsx)(`input`,{"data-testid":`m3d-edit-${e}-${t}`,"aria-label":r,inputMode:`decimal`,value:s,disabled:i,onChange:e=>c(e.target.value),onBlur:()=>{if(l.current){l.current=!1;return}let e=s.trim()===``?NaN:Number(s);!Number.isFinite(e)||b(e,3)===o?c(o):a(e)},onKeyDown:e=>{e.key===`Enter`?e.currentTarget.blur():e.key===`Escape`&&(l.current=!0,c(o),e.currentTarget.blur())}})]})}function T({prop:e,title:t,v:n,disabled:r,onEdit:i}){return(0,_.jsx)(`div`,{className:`m3d-grid3`,children:[`x`,`y`,`z`].map((a,o)=>(0,_.jsx)(w,{prop:e,axis:a,value:n[o]??0,label:`${t} ${a.toUpperCase()}`,disabled:r,onCommit:e=>{let t=[n[0]??0,n[1]??0,n[2]??0];t[o]=e,i(t)}},a))})}function E({obj:e,source:n}){return(0,_.jsxs)(`div`,{className:`m3d-header`,children:[(0,_.jsx)(`div`,{className:`m3d-typebadge`,children:e.type.includes(`Light`)?(0,_.jsx)(s,{size:13}):e.type.includes(`Camera`)?(0,_.jsx)(f,{size:13}):e.type===`Mesh`?(0,_.jsx)(t,{size:13}):(0,_.jsx)(d,{size:13})}),(0,_.jsxs)(`div`,{className:`m3d-header-text`,children:[(0,_.jsx)(`span`,{className:`m3d-name`,"data-testid":`m3d-object-id`,children:e.id??e.name??`unnamed`}),(0,_.jsxs)(`span`,{className:`m3d-sub`,children:[e.type,n?` · ${n}`:``]})]})]})}function D({object:e,onAskAgent:t,onEdit:n}){let[r,i]=(0,g.useState)(`local`),[a,o]=(0,g.useState)(!1),[s,c]=(0,g.useState)(!1),l=!!n&&r===`local`,u=e=>async t=>{o(!0),c(!1);try{await n?.(e,t)}catch{c(!0)}finally{o(!1)}},d=t=>e.pinned?.[t]?(0,_.jsx)(`span`,{className:`m3d-sub`,"data-testid":`m3d-pinned-${t}`,children:`Pinned by Studio`}):null,f=e[r],m=(0,g.useMemo)(()=>x(f.quaternion),[f.quaternion]);return(0,_.jsxs)(`div`,{className:`m3d`,style:{display:`flex`,flexDirection:`column`,gap:16},children:[(0,_.jsx)(E,{obj:e,source:e.parent?`child of ${e.parent}`:`root`}),(0,_.jsx)(`div`,{className:`m3d-seg`,role:`group`,"aria-label":`Transform space`,children:[`local`,`world`].map(e=>(0,_.jsx)(`button`,{"aria-pressed":r===e,onClick:()=>i(e),children:e===`local`?`Local`:`World`},e))}),l?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(S,{label:`Position`,value:`m`,children:[(0,_.jsx)(T,{prop:`position`,title:`Position`,v:f.position,disabled:a,onEdit:u(`position`)},s?`pf`:`p`),d(`position`)]}),(0,_.jsxs)(S,{label:`Rotation`,value:`deg, XYZ`,children:[(0,_.jsx)(T,{prop:`rotation`,title:`Rotation`,v:m,disabled:a,onEdit:u(`rotation`)},s?`rf`:`r`),d(`rotation`)]}),(0,_.jsxs)(S,{label:`Scale`,children:[(0,_.jsx)(T,{prop:`scale`,title:`Scale`,v:f.scale,disabled:a,onEdit:u(`scale`)},s?`sf`:`s`),d(`scale`)]}),s&&(0,_.jsx)(`span`,{className:`m3d-tag err`,role:`alert`,children:`Edit failed`})]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(S,{label:`Position`,value:`m`,children:(0,_.jsx)(C,{v:f.position})}),(0,_.jsx)(S,{label:`Rotation`,value:`deg, XYZ`,children:(0,_.jsx)(C,{v:m,digits:1,unit:`°`})}),(0,_.jsx)(S,{label:`Scale`,children:(0,_.jsx)(C,{v:f.scale})})]}),e.bbox&&(0,_.jsx)(S,{label:`Bounds (world)`,value:`${b((e.bbox.max[0]-e.bbox.min[0])*100,1)} × ${b((e.bbox.max[1]-e.bbox.min[1])*100,1)} × ${b((e.bbox.max[2]-e.bbox.min[2])*100,1)} cm`}),e.screen&&`x`in e.screen&&(0,_.jsx)(S,{label:`On screen`,value:e.screen.onscreen?`${Math.round(e.screen.w)}×${Math.round(e.screen.h)} px at ${Math.round(e.screen.x)}, ${Math.round(e.screen.y)}`:`off screen`}),(0,_.jsxs)(`div`,{className:`m3d-row`,children:[(0,_.jsx)(`span`,{className:`m3d-label`,children:`Visibility`}),(0,_.jsxs)(`span`,{className:`m3d-tag ${e.visible?`ok`:``}`,children:[(0,_.jsx)(`span`,{className:`m3d-dot`}),e.visible?`Visible`:`Hidden`]})]}),(0,_.jsx)(p,{title:`Animated transform`,note:`Values are computed from the frame by the scene code.`,link:t?(0,_.jsx)(`button`,{className:`m3d-link`,onClick:()=>e.id&&t(e.id),children:`Ask the agent`}):void 0})]})}function O({camera:e,frame:t}){let n=x(e.quaternion),r=e.fov?18/Math.tan(e.fov/2*Math.PI/180):null;return(0,_.jsxs)(`div`,{className:`m3d`,style:{display:`flex`,flexDirection:`column`,gap:16},children:[(0,_.jsx)(E,{obj:{id:`camera`,name:`camera`,type:e.type},source:t===void 0?void 0:`frame ${t}`}),(0,_.jsxs)(`div`,{className:`m3d-grid2`,children:[(0,_.jsxs)(`div`,{className:`m3d-num`,children:[(0,_.jsx)(`span`,{children:`FOV`}),(0,_.jsxs)(`span`,{children:[b(e.fov,1),`°`]})]}),(0,_.jsxs)(`div`,{className:`m3d-num`,children:[(0,_.jsx)(`span`,{children:`Lens`}),(0,_.jsx)(`span`,{children:r?`${b(r,1)} mm`:`—`})]}),(0,_.jsxs)(`div`,{className:`m3d-num`,children:[(0,_.jsx)(`span`,{children:`Near`}),(0,_.jsx)(`span`,{children:b(e.near)})]}),(0,_.jsxs)(`div`,{className:`m3d-num`,children:[(0,_.jsx)(`span`,{children:`Far`}),(0,_.jsx)(`span`,{children:b(e.far,1)})]})]}),(0,_.jsx)(S,{label:`Position`,value:`m`,children:(0,_.jsx)(C,{v:e.position})}),(0,_.jsx)(S,{label:`Rotation`,value:`deg`,children:(0,_.jsx)(C,{v:n,digits:1,unit:`°`})}),(0,_.jsx)(S,{label:`Looking along`,children:(0,_.jsx)(C,{v:e.direction})}),(0,_.jsx)(S,{label:`Aspect`,value:b(e.aspect,4)})]})}function k({material:e}){let t=e=>e===null?0:Math.round(e*100),n=(e,n)=>(0,_.jsx)(S,{label:e,value:b(n,2),children:(0,_.jsxs)(`div`,{className:`m3d-slider`,children:[(0,_.jsx)(`i`,{style:{width:`${t(n)}%`}}),(0,_.jsx)(`b`,{style:{left:`calc(${t(n)}% - 6px)`}})]})});return(0,_.jsxs)(`div`,{className:`m3d`,style:{display:`flex`,flexDirection:`column`,gap:16},children:[(0,_.jsx)(E,{obj:{id:e.name,name:e.name,type:e.type}}),(0,_.jsxs)(`div`,{className:`m3d-row`,children:[(0,_.jsx)(`span`,{className:`m3d-label`,children:`Base colour`}),(0,_.jsx)(`span`,{className:`m3d-swatch`,style:{background:e.color??`transparent`}}),(0,_.jsx)(`span`,{className:`m3d-value m3d-mono`,children:e.color??`—`})]}),e.emissive&&e.emissive!==`#000000`&&(0,_.jsxs)(`div`,{className:`m3d-row`,children:[(0,_.jsx)(`span`,{className:`m3d-label`,children:`Emissive`}),(0,_.jsx)(`span`,{className:`m3d-swatch`,style:{background:e.emissive}}),(0,_.jsx)(`span`,{className:`m3d-value m3d-mono`,children:e.emissive})]}),n(`Metalness`,e.metalness),n(`Roughness`,e.roughness),n(`Opacity`,e.opacity),(0,_.jsxs)(`div`,{className:`m3d-row`,style:{flexWrap:`wrap`,gap:6},children:[e.transparent&&(0,_.jsx)(`span`,{className:`m3d-tag info`,children:`transparent`}),e.transmission?(0,_.jsxs)(`span`,{className:`m3d-tag info`,children:[`transmission `,b(e.transmission,2)]}):null,Object.entries(e.textures).map(([e,t])=>(0,_.jsx)(`span`,{className:`m3d-tag`,title:t,children:e},e)),Object.keys(e.textures).length===0&&(0,_.jsx)(`span`,{className:`m3d-tag`,children:`no textures`})]})]})}function A({lights:e,environment:t}){return(0,_.jsxs)(`div`,{className:`m3d`,style:{display:`flex`,flexDirection:`column`,gap:12},children:[t&&(0,_.jsxs)(`div`,{className:`m3d-row`,children:[(0,_.jsx)(`span`,{className:`m3d-label`,children:`Environment`}),(0,_.jsx)(`span`,{className:`m3d-tag ${t.environment?`ok`:``}`,children:t.environment?`image-based light`:`none`}),t.background&&(0,_.jsx)(`span`,{className:`m3d-swatch`,title:t.background,style:{background:t.background}})]}),e.map((e,t)=>(0,_.jsxs)(`div`,{className:`m3d-card`,style:{padding:10,gap:8},children:[(0,_.jsxs)(`div`,{className:`m3d-row`,children:[(0,_.jsx)(s,{size:13}),(0,_.jsx)(`span`,{className:`m3d-name`,style:{flex:1},children:e.id??e.name??e.type}),(0,_.jsx)(`span`,{className:`m3d-sub`,children:e.type.replace(`Light`,``)})]}),(0,_.jsxs)(`div`,{className:`m3d-row`,children:[(0,_.jsx)(`span`,{className:`m3d-swatch`,style:{background:e.color}}),(0,_.jsx)(`span`,{className:`m3d-value m3d-mono`,style:{flex:1},children:e.color}),(0,_.jsx)(`span`,{className:`m3d-value`,children:b(e.intensity,2)}),e.castShadow&&(0,_.jsx)(`span`,{className:`m3d-tag info`,children:`shadow`}),!e.visible&&(0,_.jsx)(`span`,{className:`m3d-tag`,children:`off`})]})]},e.id??t))]})}function j({clips:e}){return(0,_.jsx)(`div`,{className:`m3d`,style:{display:`flex`,flexDirection:`column`,gap:8},children:e.map(e=>(0,_.jsxs)(`div`,{className:`m3d-field`,children:[(0,_.jsxs)(`div`,{className:`m3d-row`,children:[(0,_.jsx)(`span`,{className:`m3d-name`,style:{flex:1},children:e.clip}),(0,_.jsxs)(`span`,{className:`m3d-sub`,children:[e.loop??`unscheduled`,` · `,b(e.duration,2),` s`]})]}),(0,_.jsx)(`div`,{className:`m3d-slider`,children:(0,_.jsx)(`i`,{style:{width:`${e.state?e.state.time/e.duration*100:0}%`,opacity:e.state?.4+.6*e.state.weight:.25}})}),e.state&&(0,_.jsxs)(`span`,{className:`m3d-sub`,children:[`t = `,b(e.state.time,2),` s · weight `,b(e.state.weight,2)]})]},e.clip))})}function M({stage:e,selected:t,onAskAgent:n,onEdit:r}){let[i,a]=(0,g.useState)(`object`),o=e.objects.find(e=>e.id===t)??null,s=o?e.materials.find(e=>o.materials.includes(e.name??``))??null:null,c=[[`object`,`Object`],[`material`,`Material`],[`camera`,`Camera`],[`lights`,`Lights`,e.lights.length],[`clips`,`Clips`,e.clips.length]];return(0,_.jsxs)(`div`,{className:`m3d m3d-panel`,style:{height:`100%`},children:[(0,_.jsx)(`div`,{className:`m3d-tabs`,role:`tablist`,children:c.map(([e,t,n])=>(0,_.jsxs)(`button`,{role:`tab`,className:`m3d-tab`,"data-testid":`m3d-tab-${e}`,"aria-selected":i===e,onClick:()=>a(e),children:[t,n?(0,_.jsx)(`span`,{className:`m3d-sub`,children:n}):null]},e))}),(0,_.jsxs)(`div`,{className:`m3d-body`,children:[i===`object`&&(o?(0,_.jsx)(D,{object:o,onAskAgent:n,onEdit:r&&o.id?(e,t)=>r(o.id,e,t):void 0}):(0,_.jsx)(p,{title:`Nothing selected`,note:`Pick an object in the viewer or the object tree.`})),i===`material`&&(s?(0,_.jsx)(k,{material:s}):(0,_.jsx)(p,{title:`No material`,note:o?`This object has no material of its own.`:`Select a mesh to see its material.`})),i===`camera`&&(0,_.jsx)(O,{camera:e.camera,frame:e.frame}),i===`lights`&&(0,_.jsx)(A,{lights:e.lights,environment:e.environment}),i===`clips`&&(e.clips.length?(0,_.jsx)(j,{clips:e.clips}):(0,_.jsx)(p,{title:`No animation clips`,note:`This scene animates in code only.`}))]})]})}function N({player:e,snapshot:i,canEdit:a,editTransform:o}){let[s,l]=(0,g.useState)(null),[u,d]=(0,g.useState)(null),[f,p]=(0,g.useState)(null),[v,b]=(0,g.useState)(null),x=(0,g.useRef)(!1),S=(0,g.useRef)(!1),C=(0,g.useCallback)(async()=>{if(x.current)return void(S.current=!0);x.current=!0;try{do{S.current=!1;try{let t=await e.inspect3d();l(t),b(null)}catch(e){b(String(e?.message??e).slice(0,300))}}while(S.current)}finally{x.current=!1}},[e]);(0,g.useEffect)(()=>{let t=null,n=(n=200)=>{t&&clearTimeout(t),t=setTimeout(()=>{let t=e.store.get();t.status===`ready`&&!t.playing&&C()},n)};n(0);let r=[e.frame.subscribe(()=>n()),e.store.select(e=>e.status,()=>n(50)),e.store.select(e=>e.playing,()=>n())];return()=>{t&&clearTimeout(t),r.forEach(e=>e())}},[e,C,i.tree]),(0,g.useEffect)(()=>e.store.select(e=>e.selection,t=>{t?.at&&e.pick3d(t.at.x,t.at.y).then(e=>{e&&(d(e.id),p(e.scene_id))},()=>{})}),[e]);let w=s?.[0]??null,T=(0,g.useMemo)(()=>{try{let t=m(i.scenes,i.transitions,i.composition.total_frames);return h(t,Math.min(e.frame.get(),Math.max(0,t.totalFrames-1))).layers.at(-1)?.sceneId??null}catch{return null}},[i,s]),E=f??T,D=(0,g.useCallback)(async(e,t,n)=>{if(!E)throw Error(`no scene at this frame`);await o(E,e,t,n);for(let e of[300,1200])setTimeout(()=>void C(),e)},[E,o,C]);return(0,_.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-surface-raised font-sans`,"data-testid":`panel-inspector3d`,"data-3d-selected":u??``,children:[(0,_.jsx)(n,{icon:(0,_.jsx)(t,{size:14,className:`text-text-secondary`}),title:`3D inspector`,meta:w?(0,_.jsx)(r,{tone:`info`,children:`${w.capabilities.backend} · three r${w.capabilities.three} · frame ${w.frame}`}):(0,_.jsx)(r,{tone:`neutral`,children:`No 3D stage`})}),v&&(0,_.jsx)(`div`,{className:`p-3`,children:(0,_.jsx)(c,{tone:`error`,children:v})}),w?(0,_.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,_.jsx)(`div`,{className:`flex max-h-[38%] min-h-24 shrink-0 flex-col overflow-auto border-b border-border-default`,"data-testid":`inspector3d-tree`,children:(0,_.jsx)(y,{objects:w.objects,selected:u,onSelect:e=>(d(e),p(null)),live:!0})}),(0,_.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col [&_.m3d-panel]:w-full [&_.m3d-panel]:border-l-0`,children:(0,_.jsx)(M,{stage:w,selected:u,onEdit:a&&E?D:void 0})})]}):(0,_.jsx)(`div`,{className:`p-3.5`,"data-testid":`inspector3d-empty`,children:(0,_.jsx)(c,{tone:`info`,children:s===null?`Reading the live 3D stage…`:`This frame has no live mosio-three stage. The 3D inspector reads the live preview; exact frames and cached Blender renders carry no live scene.`})})]})}export{N as Studio3DInspector};
@@ -6,7 +6,7 @@
6
6
  <meta name="mosio-studio-token" content="%MOSIO_STUDIO_TOKEN%" />
7
7
  <title>Mosio Studio</title>
8
8
  <link rel="icon" type="image/svg+xml" href="data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2076%2078%27%3E%3Cpath%20d%3D%27M4%2027C4%2023%206%2020%2010%2018L39%205C44%203%2049%206%2049%2012V44C49%2048%2046%2051%2042%2053L13%2065C8%2067%204%2064%204%2059Z%27%20fill%3D%27%236ec2fb%27%2F%3E%3Cpath%20d%3D%27M27%2035C27%2031%2029%2028%2033%2026L62%2013C67%2011%2072%2014%2072%2020V52C72%2056%2069%2059%2065%2061L36%2073C31%2075%2027%2072%2027%2067Z%27%20fill%3D%27%232b62ff%27%2F%3E%3C%2Fsvg%3E" />
9
- <script type="module" crossorigin src="/assets/index-DPLtb0kT.js"></script>
9
+ <script type="module" crossorigin src="/assets/index-C6juWzGV.js"></script>
10
10
  <link rel="modulepreload" crossorigin href="/assets/feedback-x6ZumR_x.js">
11
11
  <link rel="stylesheet" crossorigin href="/assets/index-CjDBKmB_.css">
12
12
  </head>
package/bin/mosio CHANGED
Binary file
package/bin/mosio-agent CHANGED
Binary file
@@ -231,7 +231,7 @@ export async function createStage(opts = {}) {
231
231
  if ((window.__MOSIO_CFG || {}).gpu && backend === "webgl") {
232
232
  const gl = renderer.getContext(), dbg = gl.getExtension("WEBGL_debug_renderer_info");
233
233
  const name = String(dbg ? gl.getParameter(dbg.UNMASKED_RENDERER_WEBGL) : gl.getParameter(gl.RENDERER));
234
- if (/swiftshader|llvmpipe|lavapipe|software/i.test(name)) { setupHandle.done(); failCode("E_GPU_FALLBACK", `GPU profile, but WebGL renders with "${name}"`); return new Promise(() => {}); }
234
+ if (/swiftshader|llvmpipe|lavapipe|software|microsoft basic/i.test(name)) { setupHandle.done(); failCode("E_GPU_FALLBACK", `GPU profile, but WebGL renders with "${name}"`); return new Promise(() => {}); }
235
235
  }
236
236
  // a lost context draws nothing: fail the frame instead of capturing a blank canvas
237
237
  canvas.addEventListener("webglcontextlost", () => H.fail("E_GPU_CONTEXT_LOST", "WebGL context lost"));
@@ -20,6 +20,84 @@
20
20
  const fromLib = () => /\/_lib\//.test(new Error().stack || "");
21
21
  const markClock = (kind) => { if (!fromLib()) { stateful = true; why.add(kind); } };
22
22
 
23
+ // ---- WebGL present by readback (docs/3d/RENDERERS.md) ----
24
+ // On a hardware GPU profile a WebGL canvas drawn from onSeek (outside requestAnimationFrame) is not always
25
+ // composited into the captured frame: on Windows it was captured empty, and drawImage of it kept showing frame 0,
26
+ // while gl.readPixels returned the right image. So there, after every seek, each WebGL canvas is read back with
27
+ // readPixels and shown through a 2D canvas laid exactly over it; the WebGL canvas keeps its place in the layout,
28
+ // invisible, so scripts keep their reference and nothing moves. A canvas opts in on any profile with
29
+ // data-mosio-present="readback" and out with data-mosio-present="compositor".
30
+ const glCanvases = new Map(); // canvas -> its WebGL context
31
+ const isGL = (t) => t === "webgl" || t === "webgl2" || t === "experimental-webgl";
32
+ // a page always has canvases; the SDK tests run this file in a bare context without them
33
+ const CanvasProto = typeof HTMLCanvasElement === "function" ? HTMLCanvasElement.prototype : null;
34
+ const realGetContext = CanvasProto ? CanvasProto.getContext : null;
35
+ const presentMode = (c) => { const a = c.getAttribute("data-mosio-present"); return a === "readback" || a === "compositor" ? a : (cfg.gpu ? "readback" : "compositor"); };
36
+ if (CanvasProto) CanvasProto.getContext = function getContext(type, attrs) {
37
+ // readback after the seek reads the drawing buffer that onSeek left: it must not be cleared by a composite first
38
+ if (isGL(type) && presentMode(this) === "readback") attrs = Object.assign({}, attrs, { preserveDrawingBuffer: true });
39
+ const ctx = realGetContext.call(this, type, attrs);
40
+ if (ctx && isGL(type)) glCanvases.set(this, ctx);
41
+ return ctx;
42
+ };
43
+ const mirrors = new WeakMap();
44
+ const MIRROR_STYLE = ["opacity", "filter", "mixBlendMode", "zIndex", "transform", "transformOrigin", "clipPath", "imageRendering",
45
+ "backgroundColor", "backgroundImage", "backgroundSize", "backgroundPosition", "backgroundRepeat", "backgroundClip", "backgroundOrigin",
46
+ "paddingTop", "paddingRight", "paddingBottom", "paddingLeft", "borderTopLeftRadius", "borderTopRightRadius", "borderBottomRightRadius", "borderBottomLeftRadius",
47
+ ...["Top", "Right", "Bottom", "Left"].flatMap((k) => ["border" + k + "Width", "border" + k + "Style", "border" + k + "Color"])];
48
+ function presentGL() {
49
+ for (const [c, gl] of glCanvases) {
50
+ let m = mirrors.get(c);
51
+ if (presentMode(c) !== "readback" || !c.isConnected) { if (m) m.style.display = "none"; continue; }
52
+ if (gl.isContextLost()) continue;
53
+ if (!m) {
54
+ m = document.createElement("canvas");
55
+ m.setAttribute("data-mosio-mirror", "");
56
+ m.setAttribute("aria-hidden", "true");
57
+ mirrors.set(c, m);
58
+ }
59
+ if (m.previousSibling !== c || m.parentNode !== c.parentNode) c.after(m);
60
+ const cs = getComputedStyle(c);
61
+ // the 2D canvas takes the WebGL canvas's border box in its containing block, with its border, padding,
62
+ // background and visual effects; its content box gets the pixels
63
+ const px = (k) => parseFloat(cs[k]) || 0;
64
+ const w = c.clientWidth - px("paddingLeft") - px("paddingRight"), h = c.clientHeight - px("paddingTop") - px("paddingBottom");
65
+ const st = m.style, fixed = cs.position === "fixed", r = fixed ? c.getBoundingClientRect() : null;
66
+ st.position = fixed ? "fixed" : "absolute";
67
+ st.left = (fixed ? r.left : c.offsetLeft) + "px";
68
+ st.top = (fixed ? r.top : c.offsetTop) + "px";
69
+ st.boxSizing = "content-box";
70
+ st.width = Math.max(0, w) + "px"; st.height = Math.max(0, h) + "px";
71
+ st.margin = "0"; st.pointerEvents = "none";
72
+ st.display = cs.display === "none" ? "none" : "block";
73
+ st.visibility = "visible";
74
+ for (const k of MIRROR_STYLE) st[k] = cs[k];
75
+ if (cs.position === "static") st.zIndex = "auto";
76
+ c.style.setProperty("visibility", "hidden", "important");
77
+ const dw = gl.drawingBufferWidth, dh = gl.drawingBufferHeight;
78
+ if (!dw || !dh) continue;
79
+ if (m.width !== dw) m.width = dw;
80
+ if (m.height !== dh) m.height = dh;
81
+ const buf = new Uint8Array(dw * dh * 4);
82
+ // read the default framebuffer whatever the scene left bound (a render target, a WebGL 2 pack buffer)
83
+ const fb = gl.getParameter(gl.FRAMEBUFFER_BINDING), gl2 = typeof WebGL2RenderingContext !== "undefined" && gl instanceof WebGL2RenderingContext;
84
+ const pack = gl2 ? gl.getParameter(gl.PIXEL_PACK_BUFFER_BINDING) : null;
85
+ if (fb) gl.bindFramebuffer(gl.FRAMEBUFFER, null);
86
+ if (pack) gl.bindBuffer(gl.PIXEL_PACK_BUFFER, null);
87
+ gl.readPixels(0, 0, dw, dh, gl.RGBA, gl.UNSIGNED_BYTE, buf);
88
+ if (fb) gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
89
+ if (pack) gl.bindBuffer(gl.PIXEL_PACK_BUFFER, pack);
90
+ const img = new ImageData(dw, dh), out = img.data, row = dw * 4;
91
+ for (let y = 0; y < dh; y++) out.set(buf.subarray((dh - 1 - y) * row, (dh - y) * row), y * row);
92
+ const at = gl.getContextAttributes() || {};
93
+ if (at.alpha && at.premultipliedAlpha !== false) {
94
+ // the drawing buffer is premultiplied, ImageData is not
95
+ for (let i = 0; i < out.length; i += 4) { const a = out[i + 3]; if (a && a < 255) { out[i] = Math.min(255, Math.round(out[i] * 255 / a)); out[i + 1] = Math.min(255, Math.round(out[i + 1] * 255 / a)); out[i + 2] = Math.min(255, Math.round(out[i + 2] * 255 / a)); } }
96
+ }
97
+ realGetContext.call(m, "2d").putImageData(img, 0, 0);
98
+ }
99
+ }
100
+
23
101
  // ---- seeded PRNG (mulberry32) replaces Math.random ----
24
102
  let s = cfg.seed >>> 0;
25
103
  const random = () => { s = (s + 0x6D2B79F5) >>> 0; let x = s; x = Math.imul(x ^ (x >>> 15), x | 1);
@@ -245,6 +323,7 @@
245
323
  // one style/layout, then drain queued tasks (animation events etc.) so the next BeginFrame sees settled state.
246
324
  // Frames are produced by HeadlessExperimental.beginFrame from the driver, never by the wall clock.
247
325
  document.documentElement.getBoundingClientRect();
326
+ presentGL();
248
327
  // `cfg.barrierDrains` (default 3): the canvas capture measures fewer (docs/design/fast-path.md)
249
328
  for (let i = 0; i < (cfg.barrierDrains ?? 3); i++) await new Promise((r) => realSetTimeout(r, 0));
250
329
  // a <video> frame reaches the compositor on its own schedule after `seeked`: the driver never trusts a
@@ -0,0 +1,18 @@
1
+ {
2
+ "mosio": 1,
3
+ "name": "cloudrun-gpu",
4
+ "description": "GPU image check: three.js on renderer.webgl gpu, a music bed ducked under a voice. Cloud Run job input.",
5
+ "width": 360,
6
+ "height": 640,
7
+ "fps": 30,
8
+ "seed": 7,
9
+ "background": "#0b0d12",
10
+ "libraries": ["three@0.187.0", "mosio-three@0.1.0"],
11
+ "assets": ["audio/music.wav", "audio/vo.wav"],
12
+ "scenes": [{ "id": "cube", "src": "scenes/cube.html", "frames": 45 }],
13
+ "tracks": [
14
+ { "id": "music", "kind": "audio", "duck": { "under": "vo" }, "clips": [{ "id": "bed", "src": "audio/music.wav", "start": 0, "frames": 45 }] },
15
+ { "id": "vo", "kind": "audio", "clips": [{ "id": "line", "src": "audio/vo.wav", "start": 12, "frames": 18 }] }
16
+ ],
17
+ "renderer": { "webgl": "gpu" }
18
+ }
@@ -0,0 +1,25 @@
1
+ <!doctype html>
2
+ <html><head><meta charset="utf-8"><title>cube</title>
3
+ <script type="importmap">{"imports":{"three":"/_lib/three@0.187.0/build/three.module.js","three/addons/":"/_lib/three@0.187.0/examples/jsm/"}}</script>
4
+ <style>html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; background: #0b0d12; } canvas#c { position: absolute; inset: 0; display: block; }</style>
5
+ </head>
6
+ <body>
7
+ <canvas id="c" data-mosio-id="cube/canvas"></canvas>
8
+ <script type="module">
9
+ import * as THREE from "three";
10
+ import { createStage } from "/_lib/mosio-three@0.1.0/mosio-three.js";
11
+ await createStage({
12
+ THREE, canvas: document.getElementById("c"), backend: "webgl", background: "#0b0d12", fov: 35,
13
+ async setup(ctx) {
14
+ ctx.cube = new THREE.Mesh(new THREE.BoxGeometry(0.3, 0.3, 0.3), new THREE.MeshStandardMaterial({ color: "#4f8cff", roughness: 0.35, metalness: 0.1 }));
15
+ ctx.scene.add(ctx.id(ctx.cube, "stage/cube"));
16
+ const key = new THREE.DirectionalLight("#ffffff", 2.2); key.position.set(-0.5, 0.8, 0.6); ctx.scene.add(ctx.id(key, "light/key"));
17
+ ctx.scene.add(ctx.id(new THREE.HemisphereLight("#dfe8ff", "#1a1410", 0.6), "light/ambient"));
18
+ },
19
+ update(t, frame, ctx) {
20
+ ctx.cube.rotation.set(t * 1.1, t * 1.7, 0);
21
+ ctx.camera.position.set(0, 0, 1.4); ctx.camera.lookAt(0, 0, 0);
22
+ },
23
+ });
24
+ </script>
25
+ </body></html>
@@ -0,0 +1,4 @@
1
+ { "mosio": 0, "name": "direct-seek", "description": "Single frames that seek straight to the frame: pure (no seek field, --direct), meta (\"seek\": \"direct\"), clock (\"seek\": \"direct\" but stateful, so it replays), slow (heavy frames: a long replay reports progress on stderr).",
2
+ "width": 320, "height": 180, "fps": 30, "seed": 0, "background": "#102030", "libraries": [], "shared": [], "assets": [],
3
+ "scenes": [ { "id": "pure", "src": "scenes/pure.html", "frames": 300 }, { "id": "meta", "src": "scenes/meta.html", "frames": 300, "seek": "direct" },
4
+ { "id": "clock", "src": "scenes/clock.html", "frames": 60, "seek": "direct" }, { "id": "slow", "src": "scenes/slow.html", "frames": 200 } ], "transitions": [], "audio": [] }
@@ -0,0 +1,9 @@
1
+ <!doctype html><html><head><meta charset="utf-8"><style>* { margin: 0; padding: 0; } html, body { width: 320px; height: 180px; overflow: hidden; background: #102030; } #b { position: absolute; top: 70px; width: 40px; height: 40px; background: #f59e0b; }</style></head>
2
+ <body><div id="b" data-mosio-id="clock/box"></div>
3
+ <script>
4
+ // rAF + performance.now after load: the picture depends on the frames before it, so a direct seek must fall back
5
+ // to replaying from frame 0 even though mosio.json says "seek": "direct".
6
+ let x = 0;
7
+ function tick() { x = (x + 3) % 280; document.getElementById("b").style.left = x + "px"; requestAnimationFrame(tick); }
8
+ requestAnimationFrame(tick);
9
+ </script></body></html>
@@ -0,0 +1,11 @@
1
+ <!doctype html><html><head><meta charset="utf-8"><style>* { margin: 0; padding: 0; } html, body { width: 320px; height: 180px; overflow: hidden; background: #102030; }</style></head>
2
+ <body><canvas width="320" height="180" data-mosio-id="meta/canvas"></canvas>
3
+ <script>
4
+ // The picture is a pure function of the frame number, so any frame can be reached without the frames before it.
5
+ const c = document.querySelector("canvas").getContext("2d");
6
+ __mosio.onSeek((t, f) => {
7
+ c.fillStyle = "#102030"; c.fillRect(0, 0, 320, 180);
8
+ c.fillStyle = "hsl(" + ((f * 7) % 360) + " 80% 55%)"; c.fillRect((f * 3) % 280, 70, 40, 40);
9
+ c.fillStyle = "#ffffff"; c.fillRect(0, 170, Math.round((f / 299) * 320), 10);
10
+ });
11
+ </script></body></html>
@@ -0,0 +1,11 @@
1
+ <!doctype html><html><head><meta charset="utf-8"><style>* { margin: 0; padding: 0; } html, body { width: 320px; height: 180px; overflow: hidden; background: #102030; }</style></head>
2
+ <body><canvas width="320" height="180" data-mosio-id="pure/canvas"></canvas>
3
+ <script>
4
+ // The picture is a pure function of the frame number, so any frame can be reached without the frames before it.
5
+ const c = document.querySelector("canvas").getContext("2d");
6
+ __mosio.onSeek((t, f) => {
7
+ c.fillStyle = "#102030"; c.fillRect(0, 0, 320, 180);
8
+ c.fillStyle = "hsl(" + ((f * 7) % 360) + " 80% 55%)"; c.fillRect((f * 3) % 280, 70, 40, 40);
9
+ c.fillStyle = "#ffffff"; c.fillRect(0, 170, Math.round((f / 299) * 320), 10);
10
+ });
11
+ </script></body></html>
@@ -0,0 +1,11 @@
1
+ <!doctype html><html><head><meta charset="utf-8"><style>* { margin: 0; padding: 0; } html, body { width: 320px; height: 180px; overflow: hidden; background: #102030; }</style></head>
2
+ <body><canvas width="320" height="180" data-mosio-id="slow/canvas"></canvas>
3
+ <script>
4
+ // A heavy frame (tens of ms of CPU per seek), so replaying to a late frame takes seconds: the replay reports progress.
5
+ const c = document.querySelector("canvas").getContext("2d");
6
+ __mosio.onSeek((t, f) => {
7
+ let x = 0; for (let i = 0; i < 2e7; i++) x += Math.sqrt(i);
8
+ c.fillStyle = "#102030"; c.fillRect(0, 0, 320, 180);
9
+ c.fillStyle = "#38bdf8"; c.fillRect((f * 3) % 280, 70, 40, 40 + (x > 0 ? 0 : 1));
10
+ });
11
+ </script></body></html>
@@ -0,0 +1,6 @@
1
+ { "mosio": 0, "name": "direct-seek-media", "description": "media frame with a scene that seeks straight to the frame (\"seek\": \"direct\"): one scene frame instead of the scene's whole run.",
2
+ "width": 320, "height": 180, "fps": 30, "seed": 0, "background": "#000000", "libraries": [], "shared": [], "assets": ["assets/dot.png"],
3
+ "scenes": [ { "id": "pure", "src": "scenes/pure.html", "frames": 300, "seek": "direct" } ],
4
+ "html_layer": { "z": 0 },
5
+ "tracks": [ { "id": "badge", "kind": "video", "z": 1, "clips": [ { "id": "dot", "src": "assets/dot.png", "start": 0, "frames": 300, "fit": "none" } ] } ],
6
+ "transitions": [], "audio": [] }
@@ -0,0 +1,11 @@
1
+ <!doctype html><html><head><meta charset="utf-8"><style>* { margin: 0; padding: 0; } html, body { width: 320px; height: 180px; overflow: hidden; background: #102030; }</style></head>
2
+ <body><canvas width="320" height="180" data-mosio-id="pure/canvas"></canvas>
3
+ <script>
4
+ // The picture is a pure function of the frame number, so any frame can be reached without the frames before it.
5
+ const c = document.querySelector("canvas").getContext("2d");
6
+ __mosio.onSeek((t, f) => {
7
+ c.fillStyle = "#102030"; c.fillRect(0, 0, 320, 180);
8
+ c.fillStyle = "hsl(" + ((f * 7) % 360) + " 80% 55%)"; c.fillRect((f * 3) % 280, 70, 40, 40);
9
+ c.fillStyle = "#ffffff"; c.fillRect(0, 170, Math.round((f / 299) * 320), 10);
10
+ });
11
+ </script></body></html>
@@ -0,0 +1,16 @@
1
+ {
2
+ "mosio": 0,
3
+ "name": "gl-readback",
4
+ "description": "A plain WebGL canvas drawn from onSeek (no adapter), shown through the runtime's readback present and through the compositor. On SwiftShader both must give the same bytes on every frame, and the frames must change (scripts/gl-readback-check.sh).",
5
+ "width": 640, "height": 360, "fps": 30, "seed": 2,
6
+ "background": "#202020",
7
+ "libraries": [],
8
+ "shared": [],
9
+ "assets": [],
10
+ "scenes": [
11
+ { "id": "readback", "src": "scenes/readback.html", "frames": 30 },
12
+ { "id": "compositor", "src": "scenes/compositor.html", "frames": 30 }
13
+ ],
14
+ "transitions": [],
15
+ "audio": []
16
+ }
@@ -0,0 +1,23 @@
1
+ <!doctype html>
2
+ <html lang="en"><head><meta charset="utf-8">
3
+ <style>* { margin: 0; padding: 0; } html, body { width: 640px; height: 360px; overflow: hidden; background: #202020; }
4
+ #stage { position: absolute; left: 40px; top: 30px; width: 400px; height: 240px; }
5
+ #gl { position: absolute; left: 20px; top: 10px; width: 320px; height: 200px; border: 4px solid #f0c020; }
6
+ .over { position: absolute; left: 300px; top: 120px; width: 200px; height: 80px; background: rgba(40, 120, 255, .6); }</style>
7
+ </head><body>
8
+ <div id="stage"><canvas id="gl" width="320" height="200" data-mosio-present="compositor"></canvas></div><div class="over"></div>
9
+ <script>
10
+ // three.js-style: a plain WebGL context without preserveDrawingBuffer, drawn only from onSeek
11
+ const gl = document.getElementById("gl").getContext("webgl", { antialias: false });
12
+ const sh = (type, src) => { const s = gl.createShader(type); gl.shaderSource(s, src); gl.compileShader(s); return s; };
13
+ const p = gl.createProgram();
14
+ gl.attachShader(p, sh(gl.VERTEX_SHADER, "attribute vec2 a; void main(){ gl_Position = vec4(a, 0., 1.); }"));
15
+ gl.attachShader(p, sh(gl.FRAGMENT_SHADER, "precision mediump float; uniform float u_t; void main(){ vec2 uv = gl_FragCoord.xy / vec2(320., 200.); gl_FragColor = vec4(fract(uv.x + u_t), uv.y, fract(u_t * 3.), 1.); }"));
16
+ gl.linkProgram(p); gl.useProgram(p);
17
+ gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer());
18
+ gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-1, -1, 1, -1, -1, 1, 1, 1]), gl.STATIC_DRAW);
19
+ const loc = gl.getAttribLocation(p, "a"); gl.enableVertexAttribArray(loc); gl.vertexAttribPointer(loc, 2, gl.FLOAT, false, 0, 0);
20
+ const ut = gl.getUniformLocation(p, "u_t");
21
+ __mosio.onSeek((t) => { gl.uniform1f(ut, t); gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4); });
22
+ </script>
23
+ </body></html>
@@ -0,0 +1,23 @@
1
+ <!doctype html>
2
+ <html lang="en"><head><meta charset="utf-8">
3
+ <style>* { margin: 0; padding: 0; } html, body { width: 640px; height: 360px; overflow: hidden; background: #202020; }
4
+ #stage { position: absolute; left: 40px; top: 30px; width: 400px; height: 240px; }
5
+ #gl { position: absolute; left: 20px; top: 10px; width: 320px; height: 200px; border: 4px solid #f0c020; }
6
+ .over { position: absolute; left: 300px; top: 120px; width: 200px; height: 80px; background: rgba(40, 120, 255, .6); }</style>
7
+ </head><body>
8
+ <div id="stage"><canvas id="gl" width="320" height="200" data-mosio-present="readback"></canvas></div><div class="over"></div>
9
+ <script>
10
+ // three.js-style: a plain WebGL context without preserveDrawingBuffer, drawn only from onSeek
11
+ const gl = document.getElementById("gl").getContext("webgl", { antialias: false });
12
+ const sh = (type, src) => { const s = gl.createShader(type); gl.shaderSource(s, src); gl.compileShader(s); return s; };
13
+ const p = gl.createProgram();
14
+ gl.attachShader(p, sh(gl.VERTEX_SHADER, "attribute vec2 a; void main(){ gl_Position = vec4(a, 0., 1.); }"));
15
+ gl.attachShader(p, sh(gl.FRAGMENT_SHADER, "precision mediump float; uniform float u_t; void main(){ vec2 uv = gl_FragCoord.xy / vec2(320., 200.); gl_FragColor = vec4(fract(uv.x + u_t), uv.y, fract(u_t * 3.), 1.); }"));
16
+ gl.linkProgram(p); gl.useProgram(p);
17
+ gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer());
18
+ gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-1, -1, 1, -1, -1, 1, 1, 1]), gl.STATIC_DRAW);
19
+ const loc = gl.getAttribLocation(p, "a"); gl.enableVertexAttribArray(loc); gl.vertexAttribPointer(loc, 2, gl.FLOAT, false, 0, 0);
20
+ const ut = gl.getUniformLocation(p, "u_t");
21
+ __mosio.onSeek((t) => { gl.uniform1f(ut, t); gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4); });
22
+ </script>
23
+ </body></html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usemosio/cli-linux-x64",
3
- "version": "1.0.0-next.2",
3
+ "version": "1.0.0-next.4",
4
4
  "license": "MIT OR Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -0,0 +1,68 @@
1
+ #!/usr/bin/env bash
2
+ # frames-5: single frames seek straight to the frame (report 2026-12-04 #5).
3
+ # fixtures/direct-seek: `pure` (no seek field) with --direct, `meta` ("seek": "direct"): frames asked out of order
4
+ # replay no frame and hash identical to the same frames of a sequential run; `clock` ("seek": "direct" but rAF after
5
+ # load) falls back to replay and still matches. `stills` reports "seek": "direct". Without direct seek, a replay that
6
+ # takes long prints a progress line on stderr. fixtures/direct-seek-media: `media frame --frame 290` with a direct
7
+ # scene renders one scene frame (not cached, "exact": false) and matches the composite after a full scene run.
8
+ # Run as root in the sandbox (rendering happens as the `mosio` user); standalone or from frames.sh.
9
+ set -uo pipefail
10
+ REPO="$(cd "$(dirname "$0")/../.." && pwd)"; cd "$REPO"
11
+ OUT=/home/mosio/acc-direct-seek; F="$REPO/fixtures"
12
+ [ -x target/release/mosio ] || cargo build --release --locked 2>&1 | tail -1
13
+ chmod -R o+rX "$REPO"
14
+ scripts/as-user.sh "rm -rf $OUT && mkdir -p $OUT && cp -R $F/direct-seek-media $OUT/media"
15
+ fails=0
16
+ run() { scripts/as-user.sh "$1"; }
17
+ bad() { fails=$((fails+1)); echo " FAIL: $*"; }
18
+ P=$F/direct-seek
19
+ for sc in pure meta clock; do
20
+ run "mosio frames $P --scene $sc --order seq --pages 1 -o $OUT/$sc.seq.json > $OUT/$sc.seq.log 2>&1" || bad "$sc seq: $(tail -c 300 $OUT/$sc.seq.log)"
21
+ done
22
+ sub=250,40,299,7
23
+ for sc in pure meta clock; do
24
+ flag=""; [ $sc = pure ] && flag="--direct"
25
+ n=$(jq -r '.frames|length' $OUT/$sc.seq.json); last=$((n-1)); s=$sub; [ $sc = clock ] && s=50,10,$last
26
+ run "mosio frames $P --scene $sc --frames $s --order seq --pages 1 $flag -o $OUT/$sc.d.json > $OUT/$sc.d.log 2> $OUT/$sc.d.err" || { bad "$sc direct: $(tail -c 300 $OUT/$sc.d.log)"; continue; }
27
+ # manifests list frames by number: compare against the same frames of the sequential run
28
+ want=$(jq -c --argjson idx "[$(echo $s | tr , '\n' | sort -n | paste -sd,)]" '[.frames[$idx[]]]' $OUT/$sc.seq.json)
29
+ got=$(jq -c '.frames' $OUT/$sc.d.json)
30
+ seek=$(jq -r .seek $OUT/$sc.d.log); rep=$(jq -r .stages.replayed_frames $OUT/$sc.d.log)
31
+ if [ $sc = clock ]; then
32
+ [ "$seek" = replay ] && [ "$rep" -gt 0 ] && grep -q "cannot seek directly" $OUT/$sc.d.err && [ "$want" = "$got" ] \
33
+ && echo " clock: stateful scene fell back to replay ($rep frames replayed), frames match" || bad "clock seek=$seek replayed=$rep match=$([ "$want" = "$got" ] && echo y || echo n) $(head -c 300 $OUT/$sc.d.err)"
34
+ else
35
+ [ "$seek" = direct ] && [ "$rep" = 0 ] && [ "$want" = "$got" ] \
36
+ && echo " $sc: frames [$s] seeked directly (0 replayed), identical to the sequential run" || bad "$sc seek=$seek replayed=$rep match=$([ "$want" = "$got" ] && echo y || echo n)"
37
+ fi
38
+ done
39
+ # the replayed path of the same out-of-order request replays (the default for a scene without a seek field)
40
+ run "mosio frames $P --scene pure --frames 299,7 --order seq --pages 1 -o $OUT/pure.r.json > $OUT/pure.r.log 2>&1"
41
+ [ "$(jq -r .seek $OUT/pure.r.log)" = replay ] && [ "$(jq -r .stages.replayed_frames $OUT/pure.r.log)" -ge 299 ] \
42
+ && echo " pure without --direct: replays ($(jq -r .stages.replayed_frames $OUT/pure.r.log) frames)" || bad "pure replay: $(head -c 300 $OUT/pure.r.log)"
43
+ # a replay that takes seconds says what it is doing on stderr, and how to skip it
44
+ run "mosio frames $P --scene slow --frames 190 --order seq --pages 1 -o $OUT/slow.json > $OUT/slow.log 2> $OUT/slow.err" || bad "slow: $(tail -c 300 $OUT/slow.log)"
45
+ if grep -q "scene 'slow' frame 190: replaying frame" $OUT/slow.err && grep -q -- "--direct" $OUT/slow.err; then
46
+ echo " slow replay: $(grep -c replaying $OUT/slow.err) progress lines on stderr in $(jq -r '.wall_ms/1000|floor' $OUT/slow.log) s"
47
+ else bad "slow replay printed no progress ($(jq -r '.wall_ms/1000|floor' $OUT/slow.log 2>/dev/null) s): $(head -c 300 $OUT/slow.err)"; fi
48
+ run "mosio stills $P --scene meta --at 290 -o $OUT/stills > $OUT/stills.json 2>&1" || bad "stills: $(tail -c 300 $OUT/stills.json)"
49
+ [ "$(jq -r '.stills[0].seek' $OUT/stills.json)" = direct ] && echo " stills: meta frame 290 seeked directly" || bad "stills seek=$(jq -r '.stills[0].seek' $OUT/stills.json)"
50
+ run "mosio stills $P --scene pure --at 290 --direct -o $OUT/stills2 > $OUT/stills2.json 2>&1"
51
+ [ "$(jq -r '.stills[0].seek' $OUT/stills2.json)" = direct ] && echo " stills --direct: pure frame 290 seeked directly" || bad "stills --direct seek=$(jq -r '.stills[0].seek' $OUT/stills2.json)"
52
+ # media frame: a 16x16 PNG clip over the scene (fixture assets are generated, never committed)
53
+ run "mkdir -p $OUT/media/assets && python3 -I -c '
54
+ import zlib, struct, sys
55
+ c = lambda t, d: struct.pack(\">I\", len(d)) + t + d + struct.pack(\">I\", zlib.crc32(t + d) & 0xffffffff)
56
+ raw = b\"\".join(b\"\\x00\" + bytes([230, 60, 60, 255]) * 16 for _ in range(16))
57
+ open(sys.argv[1], \"wb\").write(b\"\\x89PNG\\r\\n\\x1a\\n\" + c(b\"IHDR\", struct.pack(\">IIBBBBB\", 16, 16, 8, 6, 0, 0, 0)) + c(b\"IDAT\", zlib.compress(raw)) + c(b\"IEND\", b\"\"))
58
+ ' $OUT/media/assets/dot.png"
59
+ run "mosio media frame $OUT/media --frame 290 -o $OUT/m-direct.png > $OUT/m-direct.json 2>&1" || bad "media frame direct: $(tail -c 300 $OUT/m-direct.json)"
60
+ if [ "$(jq -r '.scene_frames_seeked[0]' $OUT/m-direct.json)" = pure ] && [ "$(jq -r .exact $OUT/m-direct.json)" = false ]; then
61
+ echo " media frame: scene 'pure' frame seeked directly ($(jq -r '.ms|floor' $OUT/m-direct.json) ms)"
62
+ else bad "media frame direct: $(head -c 400 $OUT/m-direct.json)"; fi
63
+ # the same composite after the scene's full run (seek field removed): pixels agree
64
+ run "jq 'del(.scenes[0].seek)' $OUT/media/mosio.json > $OUT/media/m.json && mv $OUT/media/m.json $OUT/media/mosio.json"
65
+ run "mosio media frame $OUT/media --frame 290 -o $OUT/m-run.png > $OUT/m-run.json 2> $OUT/m-run.err" || bad "media frame run: $(tail -c 300 $OUT/m-run.json)"
66
+ [ "$(jq -r '.scene_runs_rendered[0]' $OUT/m-run.json)" = pure ] && [ "$(jq -r .rgba_blake3 $OUT/m-run.json)" = "$(jq -r .rgba_blake3 $OUT/m-direct.json)" ] \
67
+ && grep -q "no cached run" $OUT/m-run.err && echo " media frame: full scene run gives the same pixels, and says so on stderr" || bad "media frame run: $(head -c 300 $OUT/m-run.json) $(head -c 200 $OUT/m-run.err)"
68
+ [ $fails = 0 ]
@@ -7,6 +7,9 @@
7
7
  # f4 undeclared read, f5 script error
8
8
  # frames-4 frame 0 on a fresh page == frame 0 after seeking elsewhere (GSAP tl.set at 0); a shared-module syntax error names its file (frame0.sh)
9
9
  # frames-3 doctor reports the pinned renderer; pages run with the Chromium sandbox on (non-root)
10
+ # frames-5 single frames seek straight to the frame with --direct or "seek": "direct"; stateful scenes fall back to
11
+ # replay; a long replay reports progress on stderr; media frame seeks one scene frame (direct-seek.sh)
12
+ # frames-6 a plain WebGL canvas through the readback present == through the compositor, frames change (gl-readback-check.sh)
10
13
  set -uo pipefail
11
14
  REPO="$(cd "$(dirname "$0")/../.." && pwd)"; cd "$REPO"
12
15
  OUT=/home/mosio/acc-frames; F="$REPO/fixtures"
@@ -50,6 +53,8 @@ fault f5-script-error E_SCENE_SCRIPT_ERROR ""
50
53
  for f in f1-slow-font f2-never-resolving-handle; do echo " $f detail: $(jq -r .error $OUT/fault-$f.json | head -c 220)"; done
51
54
  scripts/as-user.sh "mosio doctor > $OUT/doctor.json" ; R[frames-3]=$( [ "$(jq -r '.checks[]|select(.name=="chrome.sandbox").status' $OUT/doctor.json)" = ok ] && echo PASS || echo FAIL)
52
55
  scripts/acceptance/frame0.sh && R[frames-4]=PASS || R[frames-4]=FAIL
53
- for k in frames-1 frames-2 frames-3 frames-4; do echo "== $k ${R[$k]}"; done
54
- jq -n --arg a1 "${R[frames-1]}" --arg a2 "${R[frames-2]}" --arg a3 "${R[frames-3]}" --arg a4 "${R[frames-4]}" '{"frames-1":$a1,"frames-2":$a2,"frames-3":$a3,"frames-4":$a4}' > $OUT/summary.json
56
+ scripts/acceptance/direct-seek.sh && R[frames-5]=PASS || R[frames-5]=FAIL
57
+ run "$REPO/scripts/gl-readback-check.sh \$(command -v mosio) $OUT/gl-readback" && R[frames-6]=PASS || R[frames-6]=FAIL
58
+ for k in frames-1 frames-2 frames-3 frames-4 frames-5 frames-6; do echo "== $k ${R[$k]}"; done
59
+ jq -n --arg a1 "${R[frames-1]}" --arg a2 "${R[frames-2]}" --arg a3 "${R[frames-3]}" --arg a4 "${R[frames-4]}" --arg a5 "${R[frames-5]}" --arg a6 "${R[frames-6]}" '{"frames-1":$a1,"frames-2":$a2,"frames-3":$a3,"frames-4":$a4,"frames-5":$a5,"frames-6":$a6}' > $OUT/summary.json
55
60
  ! grep -q FAIL $OUT/summary.json
@@ -121,7 +121,7 @@ def collect():
121
121
  if not f or "node_modules" in f or "fixtures/" in f or f.endswith("check-error-codes.py"):
122
122
  continue
123
123
  p = os.path.join(ROOT, f)
124
- if f.startswith("crates/") and f.endswith(".rs") and "/src/" in f and not f.endswith("_tests.rs"):
124
+ if f.startswith("crates/") and f.endswith(".rs") and "/src/" in f and not f.endswith("_tests.rs") and not f.endswith("/tests.rs"):
125
125
  for c, h in rust_codes(f, open(p).read()).items():
126
126
  emitted.setdefault(c, ("Rust", f, h))
127
127
  if h and not emitted[c][2]:
@@ -16,20 +16,16 @@ ALLOWLIST=(
16
16
  crates/mosio-agent/src/tools.rs
17
17
  crates/mosio/src/artifact.rs
18
18
  crates/mosio/src/beats.rs
19
- crates/mosio/src/blender.rs
20
19
  crates/mosio/src/camera_inspect.rs
21
20
  crates/mosio/src/captions.rs
22
- crates/mosio/src/cutout.rs
23
21
  crates/mosio/src/encode.rs
24
22
  crates/mosio/src/hub_serve.rs
25
23
  crates/mosio/src/inspect.rs
26
24
  crates/mosio/src/media.rs
27
25
  crates/mosio/src/media_edit.rs
28
26
  crates/mosio/src/merge/html.rs
29
- crates/mosio/src/regbuild.rs
30
27
  crates/mosio/src/registry.rs
31
28
  crates/mosio/src/regpublish.rs
32
- crates/mosio/src/remote.rs
33
29
  crates/mosio/tests/registry_ns_cli.rs
34
30
  crates/mosio/tests/registry_publish_cli.rs
35
31
  packages/player/src/player.ts
@@ -144,6 +144,7 @@ place nm-mixed assets/photo.jpg=photo.jpg assets/cam-a.mp4=cam-a.mp4 assets/badg
144
144
  place nm-external assets/phone.mp4=phone.mp4 assets/cube=cube
145
145
  place nm-audio assets/music.wav=music.wav assets/voiceover.wav=voiceover.wav assets/room.m4a=room.m4a assets/cam-a.mp4=cam-a.mp4 assets/photo.jpg=photo.jpg
146
146
  place nm-sync assets/ntsc-2997.mp4=ntsc-2997.mp4
147
+ place direct-seek-media assets/dot.png=badge.png
147
148
  place nm-speed assets/ntsc-2997.mp4=ntsc-2997.mp4
148
149
  place nm-entropy assets/photo.jpg=photo.jpg
149
150
  place nm-hybrid-demo assets/phone.mp4=phone.mp4 assets/cam-a.mp4=cam-a.mp4 assets/lowerthird.webm=lowerthird.webm \
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env bash
2
+ # WebGL present by readback (runtime.js presentGL): fixtures/gl-readback draws a plain WebGL canvas from onSeek, once
3
+ # shown through the readback mirror and once through the compositor. On the CPU baseline (SwiftShader) the compositor
4
+ # path is the reference, so both scenes must give the same bytes on every checked frame, and the frames must differ
5
+ # from each other (a mirror stuck on frame 0 was the Windows GPU symptom). Runs on Linux (ci-frames) and Windows (smoke).
6
+ #
7
+ # scripts/gl-readback-check.sh <mosio> <out-dir>
8
+ set -euo pipefail
9
+ MOSIO=$1
10
+ OUT=$2
11
+ REPO=$(cd "$(dirname "$0")/.." && pwd)
12
+ PY=$(command -v python3 || command -v python)
13
+ mkdir -p "$OUT"
14
+ for s in readback compositor; do
15
+ "$MOSIO" frames "$REPO/fixtures/gl-readback" --scene "$s" --frames 0,7,15,29 -o "$OUT/$s.json" > "$OUT/$s.log" 2>&1 || { cat "$OUT/$s.log" >&2; exit 1; }
16
+ done
17
+ "$MOSIO" oracle compare "$OUT/readback.json" "$OUT/compositor.json" > "$OUT/compare.json" || true
18
+ "$PY" - "$OUT" <<'PY'
19
+ import json, sys, os
20
+ out = sys.argv[1]
21
+ cmp = json.load(open(os.path.join(out, "compare.json")))
22
+ rb = json.load(open(os.path.join(out, "readback.json")))["frames"]
23
+ ok = cmp.get("equal") is True and len(rb) == 4 and len(set(rb)) == 4
24
+ print("[gl-readback] readback == compositor: %s; distinct frames: %d of %d" % (cmp.get("equal"), len(set(rb)), len(rb)))
25
+ sys.exit(0 if ok else 1)
26
+ PY