@limrun/ui 0.17.1 → 0.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -0
- package/dist/{GLTFLoader-Cfw5hgaY.mjs → GLTFLoader-8J-xzNti.mjs} +1 -1
- package/dist/{GLTFLoader-C8IUEj4c.js → GLTFLoader-DRVkwp64.js} +1 -1
- package/dist/components/remote-control.d.ts +2 -0
- package/dist/core/latency-trace.d.ts +6 -0
- package/dist/core/video-playback.d.ts +1 -0
- package/dist/core/video-playback.worker.d.ts +1 -0
- package/dist/{duo-frame-Do1d2J-W.js → duo-frame-BFXPC17N.js} +2 -2
- package/dist/{duo-frame-dYldPOq-.mjs → duo-frame-D17Tat2r.mjs} +3 -3
- package/dist/{duo-view--EopHG5S.js → duo-view-D-T1cLtl.js} +1 -1
- package/dist/{duo-view-BNktEtvj.mjs → duo-view-XeO_m-1d.mjs} +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.js +2 -2
- package/dist/lite.cjs +1 -1
- package/dist/lite.js +1 -1
- package/dist/remote-control-BWu73g2Z.mjs +2770 -0
- package/dist/remote-control-CFF1nIoN.js +2 -0
- package/package.json +4 -3
- package/dist/remote-control-CwGLAbIU.js +0 -1
- package/dist/remote-control-MECm114K.mjs +0 -2674
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsxs as wr, jsx as Jn } from "react/jsx-runtime";
|
|
2
2
|
import { useRef as en, useState as cs, useEffect as Ea } from "react";
|
|
3
|
-
import { D as Tu, h as Au, i as Cr, k as wu, p as Cu } from "./remote-control-
|
|
4
|
-
import { h as Ru, u as Pu, D as Iu, a as Du, f as Lu } from "./duo-view-
|
|
3
|
+
import { D as Tu, h as Au, i as Cr, k as wu, p as Cu } from "./remote-control-BWu73g2Z.mjs";
|
|
4
|
+
import { h as Ru, u as Pu, D as Iu, a as Du, f as Lu } from "./duo-view-XeO_m-1d.mjs";
|
|
5
5
|
const To = "183", Nu = 0, ec = 1, Uu = 2, ls = 1, Fu = 2, ir = 3, Xn = 0, Oe = 1, hn = 2, Pn = 0, Li = 1, nc = 2, ic = 3, rc = 4, Ou = 5, ri = 100, Bu = 101, zu = 102, Vu = 103, ku = 104, Gu = 200, Hu = 201, Wu = 202, Xu = 203, Ta = 204, Aa = 205, qu = 206, Yu = 207, Zu = 208, Ju = 209, $u = 210, Ku = 211, ju = 212, Qu = 213, th = 214, wa = 0, Ca = 1, Ra = 2, Ui = 3, Pa = 4, Ia = 5, Da = 6, La = 7, Pl = 0, eh = 1, nh = 2, dn = 0, Il = 1, Dl = 2, Ll = 3, Ao = 4, Nl = 5, Ul = 6, Fl = 7, sc = "attached", ih = "detached", Ol = 300, li = 301, Fi = 302, us = 303, Us = 304, As = 306, Na = 1e3, An = 1001, Ua = 1002, Ce = 1003, rh = 1004, Rr = 1005, ve = 1006, Fs = 1007, oi = 1008, He = 1009, Bl = 1010, zl = 1011, fr = 1012, wo = 1013, mn = 1014, We = 1015, Dn = 1016, Co = 1017, Ro = 1018, dr = 1020, Vl = 35902, kl = 35899, Gl = 1021, Hl = 1022, Xe = 1023, Ln = 1026, ci = 1027, Po = 1028, Io = 1029, Oi = 1030, Do = 1031, Lo = 1033, hs = 33776, fs = 33777, ds = 33778, ps = 33779, Fa = 35840, Oa = 35841, Ba = 35842, za = 35843, Va = 36196, ka = 37492, Ga = 37496, Ha = 37488, Wa = 37489, Xa = 37490, qa = 37491, Ya = 37808, Za = 37809, Ja = 37810, $a = 37811, Ka = 37812, ja = 37813, Qa = 37814, to = 37815, eo = 37816, no = 37817, io = 37818, ro = 37819, so = 37820, ao = 37821, oo = 36492, co = 36494, lo = 36495, uo = 36283, ho = 36284, fo = 36285, po = 36286, gs = 2300, mo = 2301, Os = 2302, ac = 2303, oc = 2400, cc = 2401, lc = 2402, sh = 2500, ah = 0, oh = 1, uc = 2, ch = 3200, Wl = 0, lh = 1, Hn = "", Fe = "srgb", Bi = "srgb-linear", _s = "linear", re = "srgb", mi = 7680, hc = 519, uh = 512, hh = 513, fh = 514, No = 515, dh = 516, ph = 517, Uo = 518, mh = 519, go = 35044, fc = 35048, dc = "300 es", fn = 2e3, pr = 2001;
|
|
6
6
|
function gh(i) {
|
|
7
7
|
for (let t = i.length - 1; t >= 0; --t)
|
|
@@ -26256,7 +26256,7 @@ function T0(i, t, e) {
|
|
|
26256
26256
|
},
|
|
26257
26257
|
// Imported appearances replace the rigid body while live screens and the hinge remain under our control.
|
|
26258
26258
|
loadAppearance: async (mt) => {
|
|
26259
|
-
const { GLTFLoader: st } = await import("./GLTFLoader-
|
|
26259
|
+
const { GLTFLoader: st } = await import("./GLTFLoader-8J-xzNti.mjs"), { scene: F } = await new st().loadAsync(mt), $ = /* @__PURE__ */ new Set();
|
|
26260
26260
|
if (F.traverse((J) => {
|
|
26261
26261
|
if (J instanceof Ee) {
|
|
26262
26262
|
$.add(J.geometry);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const n=require("react/jsx-runtime"),d=require("react"),E=require("./remote-control-CwGLAbIU.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-Do1d2J-W.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
|
+
"use strict";const n=require("react/jsx-runtime"),d=require("react"),E=require("./remote-control-CFF1nIoN.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-BFXPC17N.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,6 +1,6 @@
|
|
|
1
1
|
import { jsx as o, jsxs as v, Fragment as R } from "react/jsx-runtime";
|
|
2
2
|
import nt, { useId as Z, useState as H, useRef as M, useEffect as W, useCallback as ot, useLayoutEffect as it, Suspense as at, lazy as st } from "react";
|
|
3
|
-
import { H as ct, D as G, h as dt, i as z, j as ut } from "./remote-control-
|
|
3
|
+
import { H as ct, D as G, h as dt, i as z, j as ut } from "./remote-control-BWu73g2Z.mjs";
|
|
4
4
|
function lt(t, n, r) {
|
|
5
5
|
const [c, a] = H(t), i = M({ nativeAngle: t, send: n, failed: r });
|
|
6
6
|
i.current = { nativeAngle: t, send: n, failed: r };
|
|
@@ -398,7 +398,7 @@ 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-D17Tat2r.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: [
|