@limrun/ui 0.18.2 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +173 -0
- package/dist/{GLTFLoader-C62L6gT7.mjs → GLTFLoader-BjfxfJc4.mjs} +1 -1
- package/dist/{GLTFLoader--3fP8K2r.js → GLTFLoader-Ccp1cQVL.js} +1 -1
- package/dist/components/remote-control.d.ts +22 -68
- package/dist/core/device-stream.d.ts +30 -0
- package/dist/core/jitter-buffer.d.ts +2 -0
- package/dist/core/playback-stats.d.ts +48 -0
- package/dist/core/playback-subscription.d.ts +7 -0
- package/dist/core/stream-options.d.ts +62 -0
- package/dist/core/stream-types.d.ts +66 -0
- package/dist/core/stream-utils.d.ts +6 -0
- package/dist/core/use-playback-stats.d.ts +4 -0
- package/dist/core-BhHpU_lr.mjs +2113 -0
- package/dist/core-DkhLItUD.js +2 -0
- package/dist/core.cjs +1 -0
- package/dist/core.d.ts +12 -0
- package/dist/core.js +21 -0
- package/dist/{duo-frame-B6jf62Rq.mjs → duo-frame-CMiDITQA.mjs} +3 -3
- package/dist/{duo-frame-DAmRgZuT.js → duo-frame-D9832t6H.js} +2 -2
- package/dist/duo-view-Bhr7zyWr.js +1 -0
- package/dist/{duo-view-DSZO0-zg.mjs → duo-view-tndcvbIi.mjs} +64 -64
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -2
- package/dist/lite.cjs +1 -1
- package/dist/lite.d.ts +1 -0
- package/dist/lite.js +7 -6
- package/dist/remote-control-BBgt4TkM.mjs +1145 -0
- package/dist/remote-control-GLVdY8Xa.js +1 -0
- package/package.json +15 -5
- package/dist/duo-view-hTVLMDcc.js +0 -1
- package/dist/remote-control-B3_Hzmx8.js +0 -2
- package/dist/remote-control-BFxEfAdr.mjs +0 -2774
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const n=require("react/jsx-runtime"),d=require("react"),E=require("./core-DkhLItUD.js");function X(e,o,r){const[c,i]=d.useState(e),s=d.useRef({nativeAngle:e,send:o,failed:r});s.current={nativeAngle:e,send:o,failed:r};const f=d.useRef(void 0),x=d.useRef(!1),l=d.useRef(null);return d.useEffect(()=>(l.current=new E.HingeSender(async p=>{await s.current.send(p),f.current===p&&(f.current=void 0)},p=>{f.current=void 0,s.current.failed(String(p)),i(s.current.nativeAngle)}),()=>l.current?.stop()),[]),d.useEffect(()=>{!x.current&&f.current===void 0&&i(e)},[e]),{angle:c,changeAngle:p=>{s.current.failed(void 0),f.current=p,i(p),l.current?.set(p)},interacting:x}}function Y({angle:e,changeAngle:o,interacting:r,rotate:c,onFold:i,foldTarget:s,onHingeDrag:f,children:x}){const l=d.useId();return n.jsxs("div",{className:"rc-duo-controls",onPointerDown:u=>u.stopPropagation(),children:[n.jsxs("div",{className:"rc-duo-hinge",children:[n.jsx("button",{className:"rc-duo-fold",onClick:i??(()=>o(e<90?180:0)),children:(s??e)<90?"Unfold":"Fold"}),n.jsx("label",{htmlFor:l,children:"Hinge"}),n.jsx("input",{id:l,type:"range",min:0,max:180,step:1,value:e,onPointerDown:u=>{f?.(),r.current=!0,u.currentTarget.setPointerCapture(u.pointerId)},onPointerUp:()=>{r.current=!1},onPointerCancel:()=>{r.current=!1},onLostPointerCapture:()=>{r.current=!1},onChange:u=>o(Number(u.target.value))}),n.jsxs("output",{children:[Math.round(e),"°"]}),n.jsx("button",{className:"rc-duo-rotate","aria-label":"Rotate device",title:"Rotate device",onClick:c,children:n.jsxs("svg",{viewBox:"0 0 24 24",width:"18",height:"18",fill:"none",stroke:"currentColor",strokeWidth:"1.6","aria-hidden":"true",children:[n.jsx("rect",{x:"7",y:"3",width:"10",height:"18",rx:"2"}),n.jsx("path",{d:"M3 9a9 9 0 0 1 3-5M3 4v5h5M21 15a9 9 0 0 1-3 5m3 0v-5h-5"})]})})]}),x&&n.jsx("div",{className:"rc-duo-views","aria-label":"Device view",children:x})]})}function $({button:e}){return n.jsx("svg",{viewBox:"0 0 24 24",width:"24",height:"24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e==="side"?n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"6",y:"10",width:"12",height:"11",rx:"2"}),n.jsx("path",{d:"M8 10V7a4 4 0 0 1 8 0v3"})]}):n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M3 9h4l5-5v16l-5-5H3zM17 12h5"}),e==="volumeUp"&&n.jsx("path",{d:"M19.5 9.5v5"})]})})}function z(e,o,r,c,i,s){return"M"+(e+i)+","+o+"H"+(e+r-s)+"a"+s+","+s+" 0 0 1 "+s+","+s+"V"+(o+c-s)+"a"+s+","+s+" 0 0 1 "+-s+","+s+"H"+(e+i)+"a"+i+","+i+" 0 0 1 "+-i+","+-i+"V"+(o+i)+"a"+i+","+i+" 0 0 1 "+i+","+-i+"Z"}function G({inner:e,width:o,height:r}){const c=d.useId().replace(/:/g,""),i=e?8.4:1.25,s=8.4;return n.jsxs("svg",{className:"rc-duo-flat-frame",viewBox:"0 0 "+o+" "+r,"aria-hidden":"true",children:[n.jsxs("defs",{children:[n.jsxs("linearGradient",{id:c+"-silver",x1:"0",y1:"0",x2:"1",y2:"1",children:[n.jsx("stop",{offset:"0",stopColor:"#62676b"}),n.jsx("stop",{offset:"0.035",stopColor:"#f9faf9"}),n.jsx("stop",{offset:"0.11",stopColor:"#b0b4b6"}),n.jsx("stop",{offset:"0.31",stopColor:"#fdfefd"}),n.jsx("stop",{offset:"0.43",stopColor:"#797f84"}),n.jsx("stop",{offset:"0.51",stopColor:"#e8eaea"}),n.jsx("stop",{offset:"0.7",stopColor:"#979da1"}),n.jsx("stop",{offset:"0.87",stopColor:"#fafbf9"}),n.jsx("stop",{offset:"1",stopColor:"#5f676c"})]}),n.jsxs("linearGradient",{id:c+"-spine",children:[n.jsx("stop",{stopColor:"#4a5154"}),n.jsx("stop",{offset:"0.16",stopColor:"#d6d9d9"}),n.jsx("stop",{offset:"0.4",stopColor:"#f8f9f7"}),n.jsx("stop",{offset:"0.62",stopColor:"#a2a8ab"}),n.jsx("stop",{offset:"0.83",stopColor:"#e4e7e5"}),n.jsx("stop",{offset:"1",stopColor:"#666e72"})]})]}),!e&&n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"-2.3",y:"0.7",width:"3.3",height:r-1.4,rx:"0.85",fill:"url(#"+c+"-spine)",stroke:"#8b9296",strokeWidth:"0.15"}),n.jsx("path",{d:"M-.6 2V"+(r-2),stroke:"#f5f6f4",strokeWidth:"0.22"})]}),n.jsx("path",{d:z(0,0,o,r,i,s),fill:"url(#"+c+"-silver)",stroke:"#696f72",strokeWidth:"0.24"}),n.jsx("path",{d:z(.48,.48,o-.96,r-.96,Math.max(.5,i-.48),s-.48),fill:"none",stroke:"#ffffff",strokeOpacity:"0.85",strokeWidth:"0.2"}),n.jsx("path",{d:z(1.12,1.12,o-2.24,r-2.24,e?7.15:.65,7.15),fill:"#090b0d",stroke:"#34393c",strokeWidth:"0.2"}),[o-16,e?19:16].map(f=>n.jsx(d.Fragment,{children:n.jsx("path",{d:"M"+f+",0.17v0.82M"+f+","+(r-1)+"v0.82",stroke:"#b1b2ac",strokeWidth:"1.1"})},f)),e&&[0,r-.6].map(f=>n.jsx("rect",{x:o/2-2.2,y:f,width:"4.4",height:"0.6",rx:"0.18",fill:"url(#"+c+"-spine)",stroke:"#697074",strokeWidth:"0.14"},f)),n.jsx("path",{d:"M"+(o-.1)+",20h-.9m.9,"+(r-40)+"h-.9",stroke:"#b1b2ac",strokeWidth:"1.05"})]})}function re(e,o,r,c){const i=E.DUO_DIMENSIONS.width/(e?1:2),s=E.DUO_DIMENSIONS.height,f=e?157.5:77.1,x=e?110.8:112.2,l=(o+(e?3:0))%4,u=Math.max(0,Math.min((r-120)/(l%2?s:i),(c-120)/(l%2?i:s))),p=(h,v)=>{h=(h-i/2)*u,v=(v-s/2)*u;const w=l===1?{x:-v,y:h}:l===2?{x:-h,y:-v}:l===3?{x:v,y:-h}:{x:h,y:v};return{x:w.x+r/2,y:w.y+c/2}},S=(l%2?s:i)*u,D=(l%2?i:s)*u,k={min:{x:(r-S)/2,y:(c-D)/2},max:{x:(r+S)/2,y:(c+D)/2}},y=[{button:"volumeDown",x:i-37,y:-.32,width:9.5,height:.65,edge:"top"},{button:"volumeUp",x:i-25,y:-.32,width:9.5,height:.65,edge:"top"},{button:"side",x:i+.35,y:s/2-21,width:.7,height:13,edge:"right"}],g=["top","right","bottom","left"],b=y.map(h=>{const v=g[(g.indexOf(h.edge)+l)%4],w=p(h.x,h.y);return v==="top"&&(w.y=k.min.y-28),v==="bottom"&&(w.y=k.max.y+28),v==="left"&&(w.x=k.min.x-28),v==="right"&&(w.x=k.max.x+28),{button:h.button,edge:v,...w,targetX:w.x,targetY:w.y}}),m=b.filter(h=>h.button!=="side"),j=l%2?"y":"x";m.sort((h,v)=>h[j]-v[j]);const P=l%2?"targetY":"targetX";if(m[1][j]-m[0][j]<44){const h=(m[0][j]+m[1][j])/2;m[0][P]=h-22,m[1][P]=h+22}return{bodyWidth:i,bodyHeight:s,screenWidth:f,screenHeight:x,scale:u,turns:l,buttons:y,guides:b,rect:k,iconSize:Math.min(A(k),12*u)}}function A(e){return Math.max(12,Math.min(24,Math.max(e.max.x-e.min.x,e.max.y-e.min.y)/24))}function Z(e,o,r){return[["top",r.min.y-o,e,r.min.x,r.max.x],["bottom",o-r.max.y,e,r.min.x,r.max.x],["left",r.min.x-e,o,r.min.y,r.max.y],["right",e-r.max.x,o,r.min.y,r.max.y]].filter(([,i,s,f,x])=>i>=-7&&i<=52&&s>=f-12&&s<=x+12).sort((i,s)=>Math.abs(i[1])-Math.abs(s[1]))[0]?.[0]}function B(e){if(!e||e.readyState<2||!e.videoWidth||!e.videoHeight)return;const o=Math.min(1,1024/Math.max(e.videoWidth,e.videoHeight)),r=document.createElement("canvas");try{const c=r.getContext("2d");return c?(r.width=Math.round(e.videoWidth*o),r.height=Math.round(e.videoHeight*o),c.drawImage(e,0,0,r.width,r.height),r):void 0}catch{return}}function ne(e,o){let r=!1,c;const i=u=>{r||(l(),o(u))},s=()=>{if(r)return;const u=B(e);u&&i(u)},f=()=>{c=void 0,s(),r||(c=e?.requestVideoFrameCallback?.(f))},x=setTimeout(()=>i(void 0),2500);c=e?.requestVideoFrameCallback?.(f),e?.addEventListener("loadeddata",s),!e?.requestVideoFrameCallback&&e&&e.readyState>=2&&s();function l(){r=!0,clearTimeout(x),c!==void 0&&e?.cancelVideoFrameCallback(c),e?.removeEventListener("loadeddata",s)}return l}function oe(e,o,r,c,i=!0){const s=d.useRef(void 0),f=d.useRef(c),x=d.useRef({inner:o,frame:r});x.current={inner:o,frame:r};const[l,u]=d.useState(),p=d.useRef(void 0),S=d.useRef(void 0),D=d.useCallback(()=>{clearTimeout(S.current),p.current=void 0,u(void 0)},[]),k=y=>{if(!i||y===o){D();return}if(window.matchMedia?.("(prefers-reduced-motion: reduce)").matches||p.current)return;const g=B(e.current);if(!g)return;const b=x.current;p.current={from:b,to:b,before:g,ready:!1},u(p.current),S.current=setTimeout(D,5e3)};return d.useEffect(()=>()=>clearTimeout(S.current),[]),d.useLayoutEffect(()=>{const y=s.current,g={inner:o,frame:r};s.current=g;const b=f.current!==c;if(f.current=c,!y)return;const m=Math.abs(y.frame.rect.min.x+y.frame.rect.max.x-r.rect.min.x-r.rect.max.x)>.5||Math.abs(y.frame.rect.min.y+y.frame.rect.max.y-r.rect.min.y-r.rect.max.y)>.5;if(!i||m||b){D();return}if(y.inner===o||(u(void 0),!y.frame.scale||!r.scale)||window.matchMedia?.("(prefers-reduced-motion: reduce)").matches)return;const j=p.current?.before??B(e.current),P=p.current?.from??y;clearTimeout(S.current),p.current=void 0,j&&u({from:P,to:g,before:j,ready:!1})},[o,r.scale,r.turns,r.rect.min.x,r.rect.min.y,c,i]),d.useEffect(()=>{if(!l||l.from.inner===o)return;const y=ne(e.current,m=>{m?u(j=>j&&{...j,to:x.current,after:m,ready:!0}):D()}),g=window.matchMedia?.("(prefers-reduced-motion: reduce)"),b=()=>{g?.matches&&u(void 0)};return g?.addEventListener("change",b),()=>{y(),g?.removeEventListener("change",b)}},[l?.from,o]),{motion:l,finish:D,prepare:k}}function se({pose:e,image:o,scale:r}){const{bodyWidth:c,bodyHeight:i,screenWidth:s,screenHeight:f}=e.frame,x=s*r,l=f*r;return n.jsxs("div",{className:"rc-duo-fold-still",style:{width:c*r,height:i*r},children:[n.jsx(G,{inner:e.inner,width:c,height:i}),n.jsx("div",{className:"rc-duo-flat-screen",style:{width:x,height:l,left:(c-s)*r/2,top:(i-f)*r/2,borderRadius:e.inner?5.3*r:[.8,6.6,6.6,.8].map(u=>u*r+"px").join(" ")},children:o&&n.jsx("canvas",{ref:u=>{u&&(u.width=o.width,u.height=o.height,u.getContext("2d")?.drawImage(o,0,0))},style:{width:e.inner?l:x,height:e.inner?x:l,transform:`translate(-50%, -50%) rotate(${e.inner?90:0}deg)`}})})]})}function ie({motion:e,onFinish:o}){const r=d.useRef(null),[c,i]=d.useState(!1);return d.useEffect(()=>{if(i(!1),!e.ready)return;let s=!1,f;return Promise.resolve().then(()=>require("./duo-fold-renderer-DdltAnF7.js")).then(({renderFold:x})=>{s||!r.current||(f=x(r.current,e,o),i(!0))}).catch(()=>{s||o()}),()=>{s=!0,f?.()}},[e.ready,e.from,o]),n.jsxs(n.Fragment,{children:[!c&&n.jsx("div",{className:"rc-duo-fold-hold","aria-hidden":"true",style:{width:e.from.frame.bodyWidth*e.from.frame.scale,height:e.from.frame.bodyHeight*e.from.frame.scale,transform:`translate(-50%, -50%) rotate(${e.from.frame.turns*90}deg)`},children:n.jsx(se,{pose:e.from,image:e.before,scale:e.from.frame.scale})}),n.jsx("canvas",{ref:r,className:"rc-duo-fold-canvas","aria-hidden":"true",style:{visibility:c?"visible":"hidden"}})]})}const ae=d.lazy(()=>Promise.resolve().then(()=>require("./duo-frame-D9832t6H.js")).then(e=>e.duoFrame));function ce(e){const[o,r]=d.useState("2d");return n.jsxs("div",{className:"rc-duo-view",children:[e.showFrame!==!1&&o==="3d"?n.jsx(d.Suspense,{fallback:n.jsx(K,{...e}),children:n.jsx(ae,{...e})}):n.jsx(K,{...e}),e.showFrame!==!1&&n.jsxs("div",{className:"rc-duo-mode",role:"group","aria-label":"Device rendering",children:[n.jsx("button",{type:"button","aria-pressed":o==="2d",onClick:()=>r("2d"),children:"2D"}),n.jsx("button",{type:"button","aria-pressed":o==="3d",onClick:()=>r("3d"),children:"3D"})]})]})}function K(e){const o=e.showFrame!==!1,r=d.useRef(null),c=d.useRef(null),i=d.useRef(e);i.current=e;const[s,f]=d.useState({width:0,height:0}),[x,l]=d.useState(),[u,p]=d.useState(),[S,D]=d.useState(),[k,y]=d.useState(),g=d.useRef(void 0),b=d.useRef(null),m=e.state.displays.find(t=>t.id===(e.state.angleDegrees<90?"outer":"inner")),j=m?.id==="inner"?e.inner:e.outer,P=m?.orientation===2?2:m?.orientation===3?1:m?.orientation===4?3:0,h=m?.id==="inner",v={portrait:0,pud:2,"landscape-left":3,"landscape-right":1}[e.state.orientation],w=o?(v+(h?1:0))%4:P,M=re(h,w,s.width,s.height),H=o?M.screenWidth:(h?m?.height:m?.width)??1,W=o?M.screenHeight:(h?m?.width:m?.height)??1,F=o?M.bodyWidth:H,R=o?M.bodyHeight:W,C=o?M.scale:Math.max(0,Math.min(s.width/(M.turns%2?R:F),s.height/(M.turns%2?F:R))),U=H*C,L=W*C;d.useEffect(()=>{const t=new ResizeObserver(([a])=>{a&&f({width:a.contentRect.width,height:a.contentRect.height})});return r.current&&t.observe(r.current),()=>t.disconnect()},[]),d.useEffect(()=>{const t=c.current;if(!t||!j)return;const a=()=>{t.srcObject!==j.srcObject&&(t.srcObject=j.srcObject),t.play().catch(()=>{}),e.outer?.pause(),e.inner?.pause()};return a(),j.addEventListener("loadedmetadata",a),()=>{j.removeEventListener("loadedmetadata",a),t.pause(),t.srcObject=null;for(const O of[e.outer,e.inner])O?.play().catch(()=>{})}},[j,e.outer,e.inner]);const{motion:N,finish:V,prepare:J}=oe(c,h,M,e.state.orientation,o),{angle:Q,changeAngle:ee,interacting:te}=X(e.state.angleDegrees,async t=>{J(t>=90);try{await e.setAngle(t)}catch(a){throw V(),a}},l),I=()=>{if(!g.current)return;const{screenId:t,x:a,y:O}=g.current;i.current.touch(1,t,a,O),g.current=void 0};d.useEffect(()=>{b.current=new E.DuoButtonSender((a,O)=>i.current.button(a,O),a=>l(String(a)));const t=()=>{I(),b.current?.release(),y(void 0)};return window.addEventListener("blur",t),()=>{t(),window.removeEventListener("blur",t)}},[]),d.useEffect(()=>{I()},[m?.screenId,w]);const T=()=>{b.current?.release(),y(void 0)},_=t=>({onPointerDown:a=>{N||a.button!==0||(a.currentTarget.setPointerCapture(a.pointerId),b.current?.press(t),y(t))},onPointerUp:T,onPointerCancel:T,onLostPointerCapture:T,onBlur:T,onPointerEnter:()=>D(t),onPointerLeave:()=>D(void 0),onFocus:()=>p(M.guides.find(a=>a.button===t)?.edge),onKeyDown:a=>{N||(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),a.repeat||(b.current?.press(t),y(t)))},onKeyUp:a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),T())}}),q=t=>{const a=t.currentTarget.getBoundingClientRect();return E.flatDisplayTouch((t.clientX-a.left)/a.width,(t.clientY-a.top)/a.height,w)};return n.jsxs("div",{className:o?"rc-duo":"rc-duo rc-duo-frameless",children:[n.jsxs("div",{ref:r,className:"rc-duo-flat-stage","data-folding":!!N,"aria-busy":!!N,onPointerMove:t=>{if(!o)return;const a=t.currentTarget.getBoundingClientRect();p(Z(t.clientX-a.left,t.clientY-a.top,M.rect))},onPointerLeave:()=>{p(void 0),D(void 0)},children:[n.jsxs("div",{className:"rc-duo-flat-device","data-display":h?"inner":"outer",style:{width:F*C,height:R*C,transform:"translate(-50%, -50%) rotate("+M.turns*90+"deg)"},children:[o&&n.jsx(G,{inner:h,width:F,height:R}),n.jsx("div",{className:"rc-duo-flat-screen",role:"application","aria-label":"iPhone Duo 2D simulator",tabIndex:0,style:{width:U,height:L,left:(F-H)/2*C,top:(R-W)/2*C,borderRadius:o?h?5.3*C:[.8,6.6,6.6,.8].map(t=>t*C+"px").join(" "):0},onKeyDown:N?void 0:e.onKeyDown,onKeyUp:e.onKeyUp,onPointerDown:t=>{if(N||g.current||t.button!==0||!m)return;t.currentTarget.focus({preventScroll:!0}),t.currentTarget.setPointerCapture(t.pointerId);const a=q(t);g.current={pointer:t.pointerId,screenId:m.screenId,...a},e.touch(0,m.screenId,a.x,a.y)},onPointerMove:t=>{if(g.current?.pointer!==t.pointerId)return;const a=q(t);Object.assign(g.current,a),e.touch(2,g.current.screenId,a.x,a.y)},onPointerUp:t=>{g.current?.pointer===t.pointerId&&I()},onPointerCancel:I,onLostPointerCapture:I,children:n.jsx("video",{ref:c,autoPlay:!0,muted:!0,playsInline:!0,style:{width:h?L:U,height:h?U:L,transform:"translate(-50%, -50%) rotate("+(h?90:0)+"deg)"}})}),o&&M.buttons.map(t=>n.jsx("button",{type:"button",className:"rc-duo-physical","data-duo-button":t.button,"data-edge":t.edge,"data-highlighted":S===t.button,"data-pressed":k===t.button,"aria-label":E.DUO_BUTTONS[t.button]+" physical button",title:E.DUO_BUTTONS[t.button],style:{left:t.x*C,top:t.y*C,width:t.edge==="top"?Math.max(28,t.width*C):28,height:t.edge==="top"?28:Math.max(28,t.height*C)},..._(t.button),children:n.jsx("span",{style:{width:Math.max(2,t.width*C),height:Math.max(2,t.height*C)}})},t.button))]}),o&&M.guides.map(t=>n.jsx("button",{type:"button",className:"rc-duo-hardware","data-duo-button":t.button,"data-visible":u===t.edge,"data-pressed":k===t.button,"aria-label":E.DUO_BUTTONS[t.button],title:E.DUO_BUTTONS[t.button],style:{left:t.targetX,top:t.targetY,"--duo-hardware-icon-size":`${M.iconSize}px`,"--duo-hardware-icon-x":`${t.x-t.targetX}px`,"--duo-hardware-icon-y":`${t.y-t.targetY}px`},..._(t.button),children:n.jsx($,{button:t.button})},t.button)),N&&n.jsx(ie,{motion:N,onFinish:V})]}),o&&n.jsx(Y,{angle:Q,changeAngle:ee,interacting:te,rotate:()=>{e.setOrientation(e.state.orientation==="portrait"?"landscape-left":"portrait").catch(t=>l(String(t)))},children:n.jsx("span",{className:"rc-duo-view-label",children:"Front view"})}),x&&n.jsx("div",{role:"alert",className:"rc-duo-error",children:x})]})}const de=Object.freeze(Object.defineProperty({__proto__:null,default:ce},Symbol.toStringTag,{value:"Module"}));exports.DuoControls=Y;exports.DuoHardwareIcon=$;exports.duoView=de;exports.flatHoverEdge=Z;exports.hardwareIconSize=A;exports.useDuoHinge=X;
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { jsx as o, jsxs as v, Fragment as R } from "react/jsx-runtime";
|
|
2
|
-
import nt, { useId as Z, useState as H, useRef as M, useEffect as W, useCallback as ot, useLayoutEffect as
|
|
3
|
-
import { H as ct, D as G,
|
|
2
|
+
import nt, { useId as Z, useState as H, useRef as M, useEffect as W, useCallback as ot, useLayoutEffect as at, Suspense as it, lazy as st } from "react";
|
|
3
|
+
import { H as ct, D as G, v as dt, w as z, x as ut } from "./core-BhHpU_lr.mjs";
|
|
4
4
|
function lt(t, n, r) {
|
|
5
|
-
const [c,
|
|
6
|
-
|
|
5
|
+
const [c, i] = H(t), a = M({ nativeAngle: t, send: n, failed: r });
|
|
6
|
+
a.current = { nativeAngle: t, send: n, failed: r };
|
|
7
7
|
const l = M(void 0), m = M(!1), u = M(null);
|
|
8
8
|
return W(() => (u.current = new ct(
|
|
9
9
|
async (p) => {
|
|
10
|
-
await
|
|
10
|
+
await a.current.send(p), l.current === p && (l.current = void 0);
|
|
11
11
|
},
|
|
12
12
|
(p) => {
|
|
13
|
-
l.current = void 0,
|
|
13
|
+
l.current = void 0, a.current.failed(String(p)), i(a.current.nativeAngle);
|
|
14
14
|
}
|
|
15
15
|
), () => u.current?.stop()), []), W(() => {
|
|
16
|
-
!m.current && l.current === void 0 &&
|
|
16
|
+
!m.current && l.current === void 0 && i(t);
|
|
17
17
|
}, [t]), { angle: c, changeAngle: (p) => {
|
|
18
|
-
|
|
18
|
+
a.current.failed(void 0), l.current = p, i(p), u.current?.set(p);
|
|
19
19
|
}, interacting: m };
|
|
20
20
|
}
|
|
21
21
|
function ht({
|
|
@@ -23,15 +23,15 @@ function ht({
|
|
|
23
23
|
changeAngle: n,
|
|
24
24
|
interacting: r,
|
|
25
25
|
rotate: c,
|
|
26
|
-
onFold:
|
|
27
|
-
foldTarget:
|
|
26
|
+
onFold: i,
|
|
27
|
+
foldTarget: a,
|
|
28
28
|
onHingeDrag: l,
|
|
29
29
|
children: m
|
|
30
30
|
}) {
|
|
31
31
|
const u = Z();
|
|
32
32
|
return /* @__PURE__ */ v("div", { className: "rc-duo-controls", onPointerDown: (d) => d.stopPropagation(), children: [
|
|
33
33
|
/* @__PURE__ */ v("div", { className: "rc-duo-hinge", children: [
|
|
34
|
-
/* @__PURE__ */ o("button", { className: "rc-duo-fold", onClick:
|
|
34
|
+
/* @__PURE__ */ o("button", { className: "rc-duo-fold", onClick: i ?? (() => n(t < 90 ? 180 : 0)), children: (a ?? t) < 90 ? "Unfold" : "Fold" }),
|
|
35
35
|
/* @__PURE__ */ o("label", { htmlFor: u, children: "Hinge" }),
|
|
36
36
|
/* @__PURE__ */ o(
|
|
37
37
|
"input",
|
|
@@ -104,11 +104,11 @@ function ft({ button: t }) {
|
|
|
104
104
|
}
|
|
105
105
|
);
|
|
106
106
|
}
|
|
107
|
-
function X(t, n, r, c,
|
|
108
|
-
return "M" + (t +
|
|
107
|
+
function X(t, n, r, c, i, a) {
|
|
108
|
+
return "M" + (t + i) + "," + n + "H" + (t + r - a) + "a" + a + "," + a + " 0 0 1 " + a + "," + a + "V" + (n + c - a) + "a" + a + "," + a + " 0 0 1 " + -a + "," + a + "H" + (t + i) + "a" + i + "," + i + " 0 0 1 " + -i + "," + -i + "V" + (n + i) + "a" + i + "," + i + " 0 0 1 " + i + "," + -i + "Z";
|
|
109
109
|
}
|
|
110
110
|
function J({ inner: t, width: n, height: r }) {
|
|
111
|
-
const c = Z().replace(/:/g, ""),
|
|
111
|
+
const c = Z().replace(/:/g, ""), i = t ? 8.4 : 1.25, a = 8.4;
|
|
112
112
|
return /* @__PURE__ */ v("svg", { className: "rc-duo-flat-frame", viewBox: "0 0 " + n + " " + r, "aria-hidden": "true", children: [
|
|
113
113
|
/* @__PURE__ */ v("defs", { children: [
|
|
114
114
|
/* @__PURE__ */ v("linearGradient", { id: c + "-silver", x1: "0", y1: "0", x2: "1", y2: "1", children: [
|
|
@@ -150,7 +150,7 @@ function J({ inner: t, width: n, height: r }) {
|
|
|
150
150
|
/* @__PURE__ */ o(
|
|
151
151
|
"path",
|
|
152
152
|
{
|
|
153
|
-
d: X(0, 0, n, r,
|
|
153
|
+
d: X(0, 0, n, r, i, a),
|
|
154
154
|
fill: "url(#" + c + "-silver)",
|
|
155
155
|
stroke: "#696f72",
|
|
156
156
|
strokeWidth: "0.24"
|
|
@@ -159,7 +159,7 @@ function J({ inner: t, width: n, height: r }) {
|
|
|
159
159
|
/* @__PURE__ */ o(
|
|
160
160
|
"path",
|
|
161
161
|
{
|
|
162
|
-
d: X(0.48, 0.48, n - 0.96, r - 0.96, Math.max(0.5,
|
|
162
|
+
d: X(0.48, 0.48, n - 0.96, r - 0.96, Math.max(0.5, i - 0.48), a - 0.48),
|
|
163
163
|
fill: "none",
|
|
164
164
|
stroke: "#ffffff",
|
|
165
165
|
strokeOpacity: "0.85",
|
|
@@ -208,23 +208,23 @@ function J({ inner: t, width: n, height: r }) {
|
|
|
208
208
|
] });
|
|
209
209
|
}
|
|
210
210
|
function mt(t, n, r, c) {
|
|
211
|
-
const
|
|
211
|
+
const i = G.width / (t ? 1 : 2), a = G.height, l = t ? 157.5 : 77.1, m = t ? 110.8 : 112.2, u = (n + (t ? 3 : 0)) % 4, d = Math.max(
|
|
212
212
|
0,
|
|
213
213
|
Math.min(
|
|
214
|
-
(r - 120) / (u % 2 ?
|
|
215
|
-
(c - 120) / (u % 2 ?
|
|
214
|
+
(r - 120) / (u % 2 ? a : i),
|
|
215
|
+
(c - 120) / (u % 2 ? i : a)
|
|
216
216
|
)
|
|
217
217
|
), p = (h, w) => {
|
|
218
|
-
h = (h -
|
|
218
|
+
h = (h - i / 2) * d, w = (w - a / 2) * d;
|
|
219
219
|
const C = u === 1 ? { x: -w, y: h } : u === 2 ? { x: -h, y: -w } : u === 3 ? { x: w, y: -h } : { x: h, y: w };
|
|
220
220
|
return { x: C.x + r / 2, y: C.y + c / 2 };
|
|
221
|
-
}, F = (u % 2 ?
|
|
221
|
+
}, F = (u % 2 ? a : i) * d, P = (u % 2 ? i : a) * d, N = {
|
|
222
222
|
min: { x: (r - F) / 2, y: (c - P) / 2 },
|
|
223
223
|
max: { x: (r + F) / 2, y: (c + P) / 2 }
|
|
224
224
|
}, y = [
|
|
225
|
-
{ button: "volumeDown", x:
|
|
226
|
-
{ button: "volumeUp", x:
|
|
227
|
-
{ button: "side", x:
|
|
225
|
+
{ button: "volumeDown", x: i - 37, y: -0.32, width: 9.5, height: 0.65, edge: "top" },
|
|
226
|
+
{ button: "volumeUp", x: i - 25, y: -0.32, width: 9.5, height: 0.65, edge: "top" },
|
|
227
|
+
{ button: "side", x: i + 0.35, y: a / 2 - 21, width: 0.7, height: 13, edge: "right" }
|
|
228
228
|
], g = ["top", "right", "bottom", "left"], x = y.map((h) => {
|
|
229
229
|
const w = g[(g.indexOf(h.edge) + u) % 4], C = p(h.x, h.y);
|
|
230
230
|
return w === "top" && (C.y = N.min.y - 28), w === "bottom" && (C.y = N.max.y + 28), w === "left" && (C.x = N.min.x - 28), w === "right" && (C.x = N.max.x + 28), { button: h.button, edge: w, ...C, targetX: C.x, targetY: C.y };
|
|
@@ -236,8 +236,8 @@ function mt(t, n, r, c) {
|
|
|
236
236
|
f[0][S] = h - 22, f[1][S] = h + 22;
|
|
237
237
|
}
|
|
238
238
|
return {
|
|
239
|
-
bodyWidth:
|
|
240
|
-
bodyHeight:
|
|
239
|
+
bodyWidth: i,
|
|
240
|
+
bodyHeight: a,
|
|
241
241
|
screenWidth: l,
|
|
242
242
|
screenHeight: m,
|
|
243
243
|
scale: d,
|
|
@@ -258,8 +258,8 @@ function gt(t, n, r) {
|
|
|
258
258
|
["left", r.min.x - t, n, r.min.y, r.max.y],
|
|
259
259
|
["right", t - r.max.x, n, r.min.y, r.max.y]
|
|
260
260
|
].filter(
|
|
261
|
-
([,
|
|
262
|
-
).sort((
|
|
261
|
+
([, i, a, l, m]) => i >= -7 && i <= 52 && a >= l - 12 && a <= m + 12
|
|
262
|
+
).sort((i, a) => Math.abs(i[1]) - Math.abs(a[1]))[0]?.[0];
|
|
263
263
|
}
|
|
264
264
|
function Y(t) {
|
|
265
265
|
if (!t || t.readyState < 2 || !t.videoWidth || !t.videoHeight) return;
|
|
@@ -273,28 +273,28 @@ function Y(t) {
|
|
|
273
273
|
}
|
|
274
274
|
function yt(t, n) {
|
|
275
275
|
let r = !1, c;
|
|
276
|
-
const
|
|
276
|
+
const i = (d) => {
|
|
277
277
|
r || (u(), n(d));
|
|
278
|
-
},
|
|
278
|
+
}, a = () => {
|
|
279
279
|
if (r) return;
|
|
280
280
|
const d = Y(t);
|
|
281
|
-
d &&
|
|
281
|
+
d && i(d);
|
|
282
282
|
}, l = () => {
|
|
283
|
-
c = void 0,
|
|
284
|
-
}, m = setTimeout(() =>
|
|
285
|
-
c = t?.requestVideoFrameCallback?.(l), t?.addEventListener("loadeddata",
|
|
283
|
+
c = void 0, a(), r || (c = t?.requestVideoFrameCallback?.(l));
|
|
284
|
+
}, m = setTimeout(() => i(void 0), 2500);
|
|
285
|
+
c = t?.requestVideoFrameCallback?.(l), t?.addEventListener("loadeddata", a), !t?.requestVideoFrameCallback && t && t.readyState >= 2 && a();
|
|
286
286
|
function u() {
|
|
287
|
-
r = !0, clearTimeout(m), c !== void 0 && t?.cancelVideoFrameCallback(c), t?.removeEventListener("loadeddata",
|
|
287
|
+
r = !0, clearTimeout(m), c !== void 0 && t?.cancelVideoFrameCallback(c), t?.removeEventListener("loadeddata", a);
|
|
288
288
|
}
|
|
289
289
|
return u;
|
|
290
290
|
}
|
|
291
|
-
function bt(t, n, r, c,
|
|
292
|
-
const
|
|
291
|
+
function bt(t, n, r, c, i = !0) {
|
|
292
|
+
const a = M(void 0), l = M(c), m = M({ inner: n, frame: r });
|
|
293
293
|
m.current = { inner: n, frame: r };
|
|
294
294
|
const [u, d] = H(), p = M(void 0), F = M(void 0), P = ot(() => {
|
|
295
295
|
clearTimeout(F.current), p.current = void 0, d(void 0);
|
|
296
296
|
}, []), N = (y) => {
|
|
297
|
-
if (!
|
|
297
|
+
if (!i || y === n) {
|
|
298
298
|
P();
|
|
299
299
|
return;
|
|
300
300
|
}
|
|
@@ -304,20 +304,20 @@ function bt(t, n, r, c, a = !0) {
|
|
|
304
304
|
const x = m.current;
|
|
305
305
|
p.current = { from: x, to: x, before: g, ready: !1 }, d(p.current), F.current = setTimeout(P, 5e3);
|
|
306
306
|
};
|
|
307
|
-
return W(() => () => clearTimeout(F.current), []),
|
|
308
|
-
const y =
|
|
309
|
-
|
|
307
|
+
return W(() => () => clearTimeout(F.current), []), at(() => {
|
|
308
|
+
const y = a.current, g = { inner: n, frame: r };
|
|
309
|
+
a.current = g;
|
|
310
310
|
const x = l.current !== c;
|
|
311
311
|
if (l.current = c, !y) return;
|
|
312
312
|
const f = Math.abs(y.frame.rect.min.x + y.frame.rect.max.x - r.rect.min.x - r.rect.max.x) > 0.5 || Math.abs(y.frame.rect.min.y + y.frame.rect.max.y - r.rect.min.y - r.rect.max.y) > 0.5;
|
|
313
|
-
if (!
|
|
313
|
+
if (!i || f || x) {
|
|
314
314
|
P();
|
|
315
315
|
return;
|
|
316
316
|
}
|
|
317
317
|
if (y.inner === n || (d(void 0), !y.frame.scale || !r.scale) || window.matchMedia?.("(prefers-reduced-motion: reduce)").matches) return;
|
|
318
318
|
const b = p.current?.before ?? Y(t.current), S = p.current?.from ?? y;
|
|
319
319
|
clearTimeout(F.current), p.current = void 0, b && d({ from: S, to: g, before: b, ready: !1 });
|
|
320
|
-
}, [n, r.scale, r.turns, r.rect.min.x, r.rect.min.y, c,
|
|
320
|
+
}, [n, r.scale, r.turns, r.rect.min.x, r.rect.min.y, c, i]), W(() => {
|
|
321
321
|
if (!u || u.from.inner === n) return;
|
|
322
322
|
const y = yt(t.current, (f) => {
|
|
323
323
|
f ? d((b) => b && { ...b, to: m.current, after: f, ready: !0 }) : P();
|
|
@@ -330,9 +330,9 @@ function bt(t, n, r, c, a = !0) {
|
|
|
330
330
|
}, [u?.from, n]), { motion: u, finish: P, prepare: N };
|
|
331
331
|
}
|
|
332
332
|
function vt({ pose: t, image: n, scale: r }) {
|
|
333
|
-
const { bodyWidth: c, bodyHeight:
|
|
334
|
-
return /* @__PURE__ */ v("div", { className: "rc-duo-fold-still", style: { width: c * r, height:
|
|
335
|
-
/* @__PURE__ */ o(J, { inner: t.inner, width: c, height:
|
|
333
|
+
const { bodyWidth: c, bodyHeight: i, screenWidth: a, screenHeight: l } = t.frame, m = a * r, u = l * r;
|
|
334
|
+
return /* @__PURE__ */ v("div", { className: "rc-duo-fold-still", style: { width: c * r, height: i * r }, children: [
|
|
335
|
+
/* @__PURE__ */ o(J, { inner: t.inner, width: c, height: i }),
|
|
336
336
|
/* @__PURE__ */ o(
|
|
337
337
|
"div",
|
|
338
338
|
{
|
|
@@ -340,8 +340,8 @@ function vt({ pose: t, image: n, scale: r }) {
|
|
|
340
340
|
style: {
|
|
341
341
|
width: m,
|
|
342
342
|
height: u,
|
|
343
|
-
left: (c -
|
|
344
|
-
top: (
|
|
343
|
+
left: (c - a) * r / 2,
|
|
344
|
+
top: (i - l) * r / 2,
|
|
345
345
|
borderRadius: t.inner ? 5.3 * r : [0.8, 6.6, 6.6, 0.8].map((d) => d * r + "px").join(" ")
|
|
346
346
|
},
|
|
347
347
|
children: n && /* @__PURE__ */ o(
|
|
@@ -362,16 +362,16 @@ function vt({ pose: t, image: n, scale: r }) {
|
|
|
362
362
|
] });
|
|
363
363
|
}
|
|
364
364
|
function xt({ motion: t, onFinish: n }) {
|
|
365
|
-
const r = M(null), [c,
|
|
365
|
+
const r = M(null), [c, i] = H(!1);
|
|
366
366
|
return W(() => {
|
|
367
|
-
if (
|
|
368
|
-
let
|
|
367
|
+
if (i(!1), !t.ready) return;
|
|
368
|
+
let a = !1, l;
|
|
369
369
|
return import("./duo-fold-renderer-BXejNHcY.mjs").then(({ renderFold: m }) => {
|
|
370
|
-
|
|
370
|
+
a || !r.current || (l = m(r.current, t, n), i(!0));
|
|
371
371
|
}).catch(() => {
|
|
372
|
-
|
|
372
|
+
a || n();
|
|
373
373
|
}), () => {
|
|
374
|
-
|
|
374
|
+
a = !0, l?.();
|
|
375
375
|
};
|
|
376
376
|
}, [t.ready, t.from, n]), /* @__PURE__ */ v(R, { children: [
|
|
377
377
|
!c && /* @__PURE__ */ o(
|
|
@@ -398,11 +398,11 @@ function xt({ motion: t, onFinish: n }) {
|
|
|
398
398
|
)
|
|
399
399
|
] });
|
|
400
400
|
}
|
|
401
|
-
const wt = st(() => import("./duo-frame-
|
|
401
|
+
const wt = st(() => import("./duo-frame-CMiDITQA.mjs").then((t) => t.ac));
|
|
402
402
|
function Mt(t) {
|
|
403
403
|
const [n, r] = H("2d");
|
|
404
404
|
return /* @__PURE__ */ v("div", { className: "rc-duo-view", children: [
|
|
405
|
-
t.showFrame !== !1 && n === "3d" ? /* @__PURE__ */ o(
|
|
405
|
+
t.showFrame !== !1 && n === "3d" ? /* @__PURE__ */ o(it, { fallback: /* @__PURE__ */ o(A, { ...t }), children: /* @__PURE__ */ o(wt, { ...t }) }) : /* @__PURE__ */ o(A, { ...t }),
|
|
406
406
|
t.showFrame !== !1 && /* @__PURE__ */ v("div", { className: "rc-duo-mode", role: "group", "aria-label": "Device rendering", children: [
|
|
407
407
|
/* @__PURE__ */ o("button", { type: "button", "aria-pressed": n === "2d", onClick: () => r("2d"), children: "2D" }),
|
|
408
408
|
/* @__PURE__ */ o("button", { type: "button", "aria-pressed": n === "3d", onClick: () => r("3d"), children: "3D" })
|
|
@@ -410,15 +410,15 @@ function Mt(t) {
|
|
|
410
410
|
] });
|
|
411
411
|
}
|
|
412
412
|
function A(t) {
|
|
413
|
-
const n = t.showFrame !== !1, r = M(null), c = M(null),
|
|
414
|
-
|
|
415
|
-
const [
|
|
413
|
+
const n = t.showFrame !== !1, r = M(null), c = M(null), i = M(t);
|
|
414
|
+
i.current = t;
|
|
415
|
+
const [a, l] = H({ width: 0, height: 0 }), [m, u] = H(), [d, p] = H(), [F, P] = H(), [N, y] = H(), g = M(void 0), x = M(null), f = t.state.displays.find(
|
|
416
416
|
(e) => e.id === (t.state.angleDegrees < 90 ? "outer" : "inner")
|
|
417
|
-
), b = f?.id === "inner" ? t.inner : t.outer, S = f?.orientation === 2 ? 2 : f?.orientation === 3 ? 1 : f?.orientation === 4 ? 3 : 0, h = f?.id === "inner", w = { portrait: 0, pud: 2, "landscape-left": 3, "landscape-right": 1 }[t.state.orientation], C = n ? (w + (h ? 1 : 0)) % 4 : S, k = mt(h, C,
|
|
417
|
+
), b = f?.id === "inner" ? t.inner : t.outer, S = f?.orientation === 2 ? 2 : f?.orientation === 3 ? 1 : f?.orientation === 4 ? 3 : 0, h = f?.id === "inner", w = { portrait: 0, pud: 2, "landscape-left": 3, "landscape-right": 1 }[t.state.orientation], C = n ? (w + (h ? 1 : 0)) % 4 : S, k = mt(h, C, a.width, a.height), U = n ? k.screenWidth : (h ? f?.height : f?.width) ?? 1, V = n ? k.screenHeight : (h ? f?.width : f?.height) ?? 1, T = n ? k.bodyWidth : U, E = n ? k.bodyHeight : V, D = n ? k.scale : Math.max(
|
|
418
418
|
0,
|
|
419
419
|
Math.min(
|
|
420
|
-
|
|
421
|
-
|
|
420
|
+
a.width / (k.turns % 2 ? E : T),
|
|
421
|
+
a.height / (k.turns % 2 ? T : E)
|
|
422
422
|
)
|
|
423
423
|
), B = U * D, K = V * D;
|
|
424
424
|
W(() => {
|
|
@@ -457,11 +457,11 @@ function A(t) {
|
|
|
457
457
|
), O = () => {
|
|
458
458
|
if (!g.current) return;
|
|
459
459
|
const { screenId: e, x: s, y: j } = g.current;
|
|
460
|
-
|
|
460
|
+
i.current.touch(1, e, s, j), g.current = void 0;
|
|
461
461
|
};
|
|
462
462
|
W(() => {
|
|
463
463
|
x.current = new dt(
|
|
464
|
-
(s, j) =>
|
|
464
|
+
(s, j) => i.current.button(s, j),
|
|
465
465
|
(s) => u(String(s))
|
|
466
466
|
);
|
|
467
467
|
const e = () => {
|