@limrun/ui 0.22.4 → 0.22.6
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 +3 -3
- package/dist/components/remote-control.d.ts +15 -0
- package/dist/core/device-stream.d.ts +1 -0
- package/dist/core/stream-options.d.ts +10 -0
- package/dist/core/stream-utils.d.ts +10 -0
- package/dist/{core-nbvkIrvp.mjs → core-BPDihn1M.mjs} +907 -856
- package/dist/core-_qwksEry.js +2 -0
- package/dist/core.cjs +1 -1
- package/dist/core.js +4 -4
- package/dist/{duo-frame-Bm0hprn9.js → duo-frame-d3lnF2F7.js} +1 -1
- package/dist/{duo-frame-BCmB9_5p.mjs → duo-frame-s8ZpiZc-.mjs} +2 -2
- package/dist/{duo-view-C07GD_5E.mjs → duo-view-B2i1POpD.mjs} +3 -3
- package/dist/{duo-view-tUJbbWoS.js → duo-view-CKlDgO_u.js} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +26 -26
- package/dist/lite.cjs +1 -1
- package/dist/lite.js +2 -2
- package/dist/{macbook-frame-Dm6ko0j9.mjs → macbook-frame-BZhBYM9R.mjs} +1 -1
- package/dist/{macbook-frame-BxJfxUcU.js → macbook-frame-g3h4xP5G.js} +1 -1
- package/dist/remote-control-DmPKov-i.mjs +1723 -0
- package/dist/remote-control-y8mgo_2E.js +1 -0
- package/package.json +1 -1
- package/dist/core-BCBQrYsk.js +0 -2
- package/dist/remote-control-BX6dzHtt.mjs +0 -1712
- package/dist/remote-control-CEVcOPQZ.js +0 -1
package/dist/lite.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./remote-control-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./remote-control-y8mgo_2E.js"),e=require("./core-_qwksEry.js");exports.RemoteControl=r.RemoteControl;exports.AX_UNAVAILABLE_ERROR=e.AX_UNAVAILABLE_ERROR;exports.axElementAtPoint=e.axElementAtPoint;exports.axElementSelectorExpression=e.axElementSelectorExpression;exports.axElementSummary=e.axElementSummary;exports.axElementsEqual=e.axElementsEqual;exports.axSnapshotsEqual=e.axSnapshotsEqual;exports.clampAxFrameForScreen=e.clampAxFrameForScreen;exports.normalizeAndroidTree=e.normalizeAndroidTree;exports.normalizeIosTree=e.normalizeIosTree;
|
package/dist/lite.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as o } from "./remote-control-
|
|
2
|
-
import { A as s, a as m, b as n, c as t, d as l, e as x, f as E, n as A, g as i } from "./core-
|
|
1
|
+
import { R as o } from "./remote-control-DmPKov-i.mjs";
|
|
2
|
+
import { A as s, a as m, b as n, c as t, d as l, e as x, f as E, n as A, g as i } from "./core-BPDihn1M.mjs";
|
|
3
3
|
export {
|
|
4
4
|
s as AX_UNAVAILABLE_ERROR,
|
|
5
5
|
o as RemoteControl,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsxs as _, jsx as M } from "react/jsx-runtime";
|
|
2
2
|
import { useRef as E, useState as ne, useId as ze, useEffect as Pe } from "react";
|
|
3
|
-
import { M as L, l as q, m as $e, a as Ze, b as qe, c as Je, s as Qe, d as et, e as Ce } from "./remote-control-
|
|
3
|
+
import { M as L, l as q, m as $e, a as Ze, b as qe, c as Je, s as Qe, d as et, e as Ce } from "./remote-control-DmPKov-i.mjs";
|
|
4
4
|
import { u as tt, P as ot, c as rt, V as nt, S as st, L as Ie, M as it, D as Re, G as se, B as ct, I as at, a as ie, b as ce, d as Ne, l as lt, T as dt, R as ut, e as F, f as _e, g as ft, h as pt, i as R } from "./model-source-CN_i4mVy.mjs";
|
|
5
5
|
const T = {
|
|
6
6
|
front: { yaw: 0, pitch: 0.1, label: "Front" },
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("react/jsx-runtime"),f=require("react"),c=require("./remote-control-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("react/jsx-runtime"),f=require("react"),c=require("./remote-control-y8mgo_2E.js"),r=require("./model-source-D3_k9qRK.js"),N={front:{yaw:0,pitch:.1,label:"Front"},desk:{yaw:-.5,pitch:.42,label:"Desk"},side:{yaw:-1.15,pitch:.16,label:"Side"}},Oe=28,Ie={environment:.45,hemisphere:1,key:{intensity:2.2,position:[-120,220,260]},rim:{intensity:.7,position:[220,40,-220]}};function Ne(v,j){const n=r.DoubleSide;switch(v){case"screen":return j;case"shell":return new r.MeshStandardMaterial({color:3421498,metalness:.9,roughness:.34,side:n});case"glass":return new r.MeshPhysicalMaterial({color:328966,roughness:.06,clearcoat:1,side:n});case"camera":return new r.MeshStandardMaterial({color:790549,roughness:.2,side:n});case"well":return new r.MeshStandardMaterial({color:1052690,roughness:.9,side:n});case"keys":return new r.MeshStandardMaterial({color:723725,roughness:.7,side:n});case"trackpad":return new r.MeshPhysicalMaterial({color:2895153,metalness:.4,roughness:.3,clearcoat:.6,side:n});case"scoop":return new r.MeshStandardMaterial({color:1579035,metalness:.6,roughness:.5,side:n})}}const je={glass:1,camera:2,screen:2,well:1,keys:2,trackpad:1,scoop:1};function Ge(v){const j=f.useRef(null),n=f.useRef(v);n.current=v;const[te,z]=f.useState(),[xe,ke]=f.useState(!1),re=f.useRef(!1),{view:oe,viewRef:$,chooseView:Se,locked:x,lockedRef:De,setLocked:_e,orbit:ne,drag:Be}=r.useStageView("front"),P=f.useRef(()=>{}),k=f.useRef(c.MACBOOK_LID_OPEN_DEGREES),m=f.useRef(c.MACBOOK_LID_OPEN_DEGREES),[G,Z]=f.useState(c.MACBOOK_LID_OPEN_DEGREES),F=f.useRef(void 0),se=f.useId(),ie=o=>{const u=m.current;k.current=o,F.current={from:u,to:o,start:performance.now(),duration:c.MACBOOK_LID_OPENING_MS*Math.abs(o-u)/c.MACBOOK_LID_OPEN_DEGREES},P.current()};return f.useEffect(()=>P.current(),[oe,x]),f.useEffect(()=>{const o=j.current,u=v.video;if(!o||!u)return;const ce=()=>{ke(!0),n.current.onReady?.()};z(void 0);const S=new r.PerspectiveCamera(Oe,1,10,4e3);let J=1;const K=r.createDeviceStage({container:o,videos:[u],maxPixelRatio:2,lighting:Ie,resize:(e,t)=>{J=e/t,S.aspect=J,S.updateProjectionMatrix()},frame:(e,t)=>Ce(e,t)});if(!K){z("3D rendering is unavailable in this browser. Enable WebGL to use the 3D MacBook."),ce();return}const{renderer:T,scene:ae,invalidate:C}=K;let U=!1;const b=new r.VideoTexture(u);b.colorSpace=r.SRGBColorSpace,b.minFilter=r.LinearFilter,b.magFilter=r.LinearFilter,b.anisotropy=T.capabilities.getMaxAnisotropy();const D=new r.MeshBasicMaterial({map:b,toneMapped:!1,side:r.DoubleSide});D.onBeforeCompile=e=>{e.fragmentShader=e.fragmentShader.replace("#include <map_fragment>",`#include <map_fragment>
|
|
2
2
|
if (vMapUv.x < 0.0 || vMapUv.x > 1.0 || vMapUv.y < 0.0 || vMapUv.y > 1.0) diffuseColor.rgb = vec3(0.0);`)},D.customProgramCacheKey=()=>"macbook-fitted-screen";let I=n.current.aspect,le=0,_=c.streamFit(I,I);const Re=()=>{const e=u.videoWidth&&u.videoHeight?u.videoWidth/u.videoHeight:I;_=c.streamFit(e,I,le),b.repeat.set(_.repeat[0],_.repeat[1]),b.offset.set(_.offset[0],_.offset[1])},g=new r.Group,y=new r.Group,h=new r.Group;h.rotation.x=c.lidRotation(m.current),y.add(h),g.add(y),ae.add(g);const de=[D],Y=[];let X;for(const e of c.macbookMeshes(n.current.aspect)){const t=new r.BufferGeometry,a=new r.InterleavedBuffer(e.vertices,c.MACBOOK_VERTEX_FLOATS);t.setAttribute("position",new r.InterleavedBufferAttribute(a,3,0)),t.setAttribute("normal",new r.InterleavedBufferAttribute(a,3,3)),t.setAttribute("uv",new r.InterleavedBufferAttribute(a,2,6));const s=Ne(e.kind,D),d=je[e.kind];d&&(s.polygonOffset=!0,s.polygonOffsetFactor=-d,s.polygonOffsetUnits=-d);const w=new r.Mesh(t,s);e.kind==="screen"&&(X=w),(e.part==="lid"?h:y).add(w),Y.push(t),s!==D&&Y.push(s)}const ue=new r.Box3,fe=e=>{const t=h.rotation.x;return h.rotation.x=c.lidRotation(c.MACBOOK_LID_OPEN_DEGREES),e.updateMatrixWorld(!0),ue.setFromObject(e),h.rotation.x=t,ue},pe=()=>{g.rotation.set(0,0,0),y.position.set(0,0,0),y.position.copy(fe(g).getCenter(new r.Vector3)).negate()};pe();const Ae=!!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;let Q=!1;const me=()=>{g.visible=!0,!re.current&&n.current.animateLid!==!1&&!Ae&&(m.current=0,h.rotation.x=c.lidRotation(0),Z(0),ie(c.MACBOOK_LID_OPEN_DEGREES)),re.current=!0,Q=!0,C()},Pe=async e=>{const{GLTFLoader:t}=await Promise.resolve().then(()=>require("./GLTFLoader-CfPNHfJQ.js")),{scene:a}=await r.loadModel(new t,e),s=[];if(a.traverse(l=>{if(l instanceof r.Mesh){s.push(l.geometry);for(const ge of Array.isArray(l.material)?l.material:[l.material]){s.push(ge);for(const Le of Object.values(ge))Le instanceof r.Texture&&s.push(Le)}}}),U){for(const l of s)l.dispose();return}de.push(...s);const d=a.getObjectByName("macbook-base"),w=a.getObjectByName("macbook-lid"),M=a.getObjectByName("macbook-screen");if(!d||!w||!(M instanceof r.Mesh))throw new Error("it has no macbook-base, macbook-lid or macbook-screen");for(const l of[...y.children])l!==h&&y.remove(l);h.clear(),y.add(d);for(const l of[...w.children])h.add(l);M.material=D,X=M;const A=M.userData.aspect;typeof A=="number"&&A>0&&(I=A);const E=M.userData.notch;typeof E=="number"&&E>=0&&E<.5&&(le=E);for(const l of Y.splice(0))l.dispose();pe()},ee=n.current.model;ee&&(g.visible=!1,Pe(ee).catch(e=>{U||z(`The MacBook model could not load: ${e instanceof Error?e.message:e}`)}).finally(()=>{U||me()}));const V=new r.Vector3;let O=0;const he=new r.Raycaster,ve=new r.Vector2;let i,B=N[$.current].yaw,R=N[$.current].pitch;P.current=C;const W=e=>{if(!X)return;const t=T.domElement.getBoundingClientRect();ve.set((e.clientX-t.left)/t.width*2-1,1-(e.clientY-t.top)/t.height*2),he.setFromCamera(ve,S);const a=he.intersectObject(y,!0)[0],s=a?.object===X?a.uv:void 0;return s&&c.streamPoint(s.x,s.y,_)},we=e=>{if(C(),i)return;const t=n.current.watchOnly||e.altKey?void 0:W(e);!t&&(De.current||e.button!==0)||(o.focus({preventScroll:!0}),o.setPointerCapture(e.pointerId),i={pointer:e.pointerId,kind:t?"screen":"orbit",clientX:e.clientX,clientY:e.clientY,x:t?.x??0,y:t?.y??0},t&&n.current.pointer("down",t.x,t.y,e.buttons))},Me=e=>{if(C(),!i){const t=n.current.watchOnly?void 0:W(e);T.domElement.style.cursor=t?"none":"",t&&n.current.pointer("move",t.x,t.y,0);return}if(i.pointer===e.pointerId){if(i.kind==="screen"){const t=W(e);t&&(i.x=t.x,i.y=t.y),n.current.pointer("move",i.x,i.y,e.buttons)}else Be(e.clientX-i.clientX,e.clientY-i.clientY,1.2);i.clientX=e.clientX,i.clientY=e.clientY}},L=e=>{C(),!(!i||e&&i.pointer!==e.pointerId)&&(i.kind==="screen"&&n.current.pointer("up",i.x,i.y,e?.buttons??0),i=void 0)},Ee=e=>{if(n.current.watchOnly||e.ctrlKey)return;const t=W(e);if(!t)return;e.preventDefault();const a=e.deltaMode===WheelEvent.DOM_DELTA_LINE?16:e.deltaMode===WheelEvent.DOM_DELTA_PAGE?o.clientHeight:1;n.current.scroll(t.x,t.y,e.deltaX*a,e.deltaY*a)},q=e=>e.stopPropagation(),ye=["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","touchcancel"];for(const e of ye)o.addEventListener(e,q);const be=e=>e.preventDefault(),H=()=>{L(),n.current.onBlur()};o.addEventListener("pointerdown",we),o.addEventListener("pointermove",Me),o.addEventListener("pointerup",L),o.addEventListener("pointercancel",L),o.addEventListener("lostpointercapture",L),o.addEventListener("wheel",Ee,{passive:!1}),o.addEventListener("wheel",q),o.addEventListener("contextmenu",be),o.addEventListener("focusout",H),window.addEventListener("blur",H);const Ce=(e,t)=>{const a=N[$.current];let s=!1;const d=F.current;if(d){const l=d.duration>0?(e-d.start)/d.duration:1;m.current=d.from+(d.to-d.from)*c.lidEase(l),l>=1?F.current=void 0:s=!0,Z(m.current)}else m.current!==k.current&&(m.current=r.MathUtils.damp(m.current,k.current,14,t),Math.abs(m.current-k.current)<.05?m.current=k.current:s=!0);h.rotation.x=c.lidRotation(m.current);const w=a.yaw+ne.yaw,M=a.pitch+ne.pitch;B=r.MathUtils.damp(B,w,10,t),R=r.MathUtils.damp(R,M,10,t),Math.abs(B-w)<5e-4&&(B=w),Math.abs(R-M)<5e-4&&(R=M),Re(),g.rotation.set(R,B,0,"XYZ"),fe(g).getSize(V);const A=Math.tan(r.MathUtils.degToRad(Oe/2)),E=Math.max(V.y/2/A,V.x/2/(A*J))*1.12+V.z/2;return O=O?r.MathUtils.damp(O,E,10,t):E,Math.abs(O-E)<.01&&(O=E),S.position.set(0,0,O),S.lookAt(0,0,0),T.render(ae,S),Q&&(Q=!1,ce()),s||B!==w||R!==M||O!==E};return K.start(),ee||me(),()=>{U=!0,P.current=()=>{},L();for(const e of ye)o.removeEventListener(e,q);o.removeEventListener("pointerdown",we),o.removeEventListener("pointermove",Me),o.removeEventListener("pointerup",L),o.removeEventListener("pointercancel",L),o.removeEventListener("lostpointercapture",L),o.removeEventListener("wheel",Ee),o.removeEventListener("wheel",q),o.removeEventListener("contextmenu",be),o.removeEventListener("focusout",H),window.removeEventListener("blur",H);for(const e of[...de,...Y])e.dispose();b.dispose(),K.dispose()}},[v.video,v.aspect,v.model]),p.jsxs("div",{className:"rc-duo rc-macbook-3d",style:xe?void 0:{visibility:"hidden"},children:[p.jsx("div",{ref:j,className:"rc-duo-stage","data-position-locked":x,tabIndex:0,role:"application","aria-label":"MacBook running macOS. Use the screen to control the guest. Drag around the MacBook to turn it when position is unlocked.",onKeyDown:v.onKeyDown,onKeyUp:v.onKeyUp}),p.jsxs("div",{className:"rc-duo-controls",onPointerDown:o=>o.stopPropagation(),children:[p.jsxs("div",{className:"rc-duo-hinge",children:[p.jsx("button",{type:"button",className:"rc-duo-fold",onClick:()=>ie(G<45?c.MACBOOK_LID_OPEN_DEGREES:0),children:G<45?"Open":"Close"}),p.jsx("label",{htmlFor:se,children:"Lid"}),p.jsx("input",{id:se,type:"range",min:0,max:c.MACBOOK_LID_MAX_DEGREES,step:1,value:Math.round(G),onChange:o=>{const u=Number(o.target.value);F.current=void 0,k.current=u,Z(u),P.current()}}),p.jsxs("output",{children:[Math.round(G),"°"]})]}),p.jsxs("div",{className:"rc-duo-views",children:[Object.keys(N).map(o=>p.jsx("button",{type:"button","aria-pressed":oe===o,onClick:()=>{Se(o)},children:N[o].label},o)),p.jsx("button",{type:"button",className:"rc-duo-lock","aria-pressed":x,title:x?"Position is locked. The screen still controls macOS.":"Drag around the MacBook to turn it. Alt-drag turns it from the screen.",onClick:()=>_e(!x),children:x?"Position locked":"Lock position"})]})]}),te&&p.jsx("div",{role:"alert",className:"rc-duo-error",children:te})]})}exports.default=Ge;
|