@limrun/ui 0.22.2 → 0.22.3

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/dist/lite.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./remote-control-DfhrxDXL.js"),e=require("./core-BCBQrYsk.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;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./remote-control-CEVcOPQZ.js"),e=require("./core-BCBQrYsk.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,4 +1,4 @@
1
- import { R as o } from "./remote-control-CPDca8px.mjs";
1
+ import { R as o } from "./remote-control-BX6dzHtt.mjs";
2
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-nbvkIrvp.mjs";
3
3
  export {
4
4
  s as AX_UNAVAILABLE_ERROR,
@@ -0,0 +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-CEVcOPQZ.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
+ 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;
@@ -1,26 +1,26 @@
1
1
  import { jsxs as _, jsx as M } from "react/jsx-runtime";
2
- import { useRef as E, useState as se, useId as $e, useEffect as Ce } from "react";
3
- import { M as L, l as q, m as Ze, a as qe, b as Je, c as Qe, s as et, d as tt, e as Ie } from "./remote-control-CPDca8px.mjs";
4
- import { u as ot, P as rt, c as nt, V as st, S as it, L as Ne, M as ct, D as Te, G as ie, B as at, I as lt, a as ce, b as ae, d as _e, l as dt, T as ut, R as ft, e as F, f as Fe, g as mt, h as pt, i as R } from "./model-source-CN_i4mVy.mjs";
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-BX6dzHtt.mjs";
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" },
7
7
  desk: { yaw: -0.5, pitch: 0.42, label: "Desk" },
8
8
  side: { yaw: -1.15, pitch: 0.16, label: "Side" }
9
- }, Re = 28, ht = {
9
+ }, Fe = 28, mt = {
10
10
  environment: 0.45,
11
11
  hemisphere: 1,
12
12
  key: { intensity: 2.2, position: [-120, 220, 260] },
13
13
  rim: { intensity: 0.7, position: [220, 40, -220] }
14
14
  };
15
- function vt(f, G) {
16
- const r = Te;
15
+ function ht(f, G) {
16
+ const r = Re;
17
17
  switch (f) {
18
18
  case "screen":
19
19
  return G;
20
20
  case "shell":
21
21
  return new F({ color: 3421498, metalness: 0.9, roughness: 0.34, side: r });
22
22
  case "glass":
23
- return new Fe({ color: 328966, roughness: 0.06, clearcoat: 1, side: r });
23
+ return new _e({ color: 328966, roughness: 0.06, clearcoat: 1, side: r });
24
24
  case "camera":
25
25
  return new F({ color: 790549, roughness: 0.2, side: r });
26
26
  case "well":
@@ -28,7 +28,7 @@ function vt(f, G) {
28
28
  case "keys":
29
29
  return new F({ color: 723725, roughness: 0.7, side: r });
30
30
  case "trackpad":
31
- return new Fe({
31
+ return new _e({
32
32
  color: 2895153,
33
33
  metalness: 0.4,
34
34
  roughness: 0.3,
@@ -39,7 +39,7 @@ function vt(f, G) {
39
39
  return new F({ color: 1579035, metalness: 0.6, roughness: 0.5, side: r });
40
40
  }
41
41
  }
42
- const wt = {
42
+ const vt = {
43
43
  glass: 1,
44
44
  camera: 2,
45
45
  screen: 2,
@@ -48,151 +48,150 @@ const wt = {
48
48
  trackpad: 1,
49
49
  scoop: 1
50
50
  };
51
- function Et(f) {
51
+ function Mt(f) {
52
52
  const G = E(null), r = E(f);
53
53
  r.current = f;
54
- const [le, J] = se(), [Ge, Ye] = se(!1), de = E(!1), {
55
- view: ue,
54
+ const [ae, J] = ne(), [Te, Ge] = ne(!1), le = E(!1), {
55
+ view: de,
56
56
  viewRef: Q,
57
- chooseView: Ke,
57
+ chooseView: Ye,
58
58
  locked: k,
59
- lockedRef: Xe,
60
- setLocked: Ue,
61
- orbit: fe,
62
- drag: Ve
63
- } = ot("front"), C = E(() => {
64
- }), x = E(L), d = E(L), [Y, ee] = se(L), K = E(
59
+ lockedRef: Ke,
60
+ setLocked: Xe,
61
+ orbit: ue,
62
+ drag: Ue
63
+ } = tt("front"), C = E(() => {
64
+ }), x = E(L), d = E(L), [Y, ee] = ne(L), K = E(
65
65
  void 0
66
- ), me = $e(), pe = (o) => {
66
+ ), fe = ze(), pe = (o) => {
67
67
  const l = d.current;
68
68
  x.current = o, K.current = {
69
69
  from: l,
70
70
  to: o,
71
71
  start: performance.now(),
72
- duration: Qe * Math.abs(o - l) / L
72
+ duration: Je * Math.abs(o - l) / L
73
73
  }, C.current();
74
74
  };
75
- return Ce(() => C.current(), [ue, k]), Ce(() => {
75
+ return Pe(() => C.current(), [de, k]), Pe(() => {
76
76
  const o = G.current, l = f.video;
77
77
  if (!o || !l) return;
78
- const he = () => {
79
- Ye(!0), r.current.onReady?.();
78
+ const me = () => {
79
+ Ge(!0), r.current.onReady?.();
80
80
  };
81
81
  J(void 0);
82
- const O = new rt(Re, 1, 10, 4e3);
82
+ const O = new ot(Fe, 1, 10, 4e3);
83
83
  let te = 1;
84
- const X = nt({
84
+ const X = rt({
85
85
  container: o,
86
86
  videos: [l],
87
87
  maxPixelRatio: 2,
88
- lighting: ht,
88
+ lighting: mt,
89
89
  resize: (e, t) => {
90
90
  te = e / t, O.aspect = te, O.updateProjectionMatrix();
91
91
  },
92
- frame: (e, t) => ze(e, t)
92
+ frame: (e, t) => He(e, t)
93
93
  });
94
94
  if (!X) {
95
- J("3D rendering is unavailable in this browser. Enable WebGL to use the 3D MacBook."), he();
95
+ J("3D rendering is unavailable in this browser. Enable WebGL to use the 3D MacBook."), me();
96
96
  return;
97
97
  }
98
- const { renderer: U, scene: ve, invalidate: I } = X;
98
+ const { renderer: U, scene: he, invalidate: I } = X;
99
99
  let V = !1;
100
- const w = new st(l);
101
- w.colorSpace = it, w.minFilter = Ne, w.magFilter = Ne, w.anisotropy = U.capabilities.getMaxAnisotropy();
102
- const S = new ct({
100
+ const w = new nt(l);
101
+ w.colorSpace = st, w.minFilter = Ie, w.magFilter = Ie, w.anisotropy = U.capabilities.getMaxAnisotropy();
102
+ const S = new it({
103
103
  map: w,
104
104
  toneMapped: !1,
105
- side: Te
106
- }), we = { value: !1 };
105
+ side: Re
106
+ });
107
107
  S.onBeforeCompile = (e) => {
108
- e.uniforms.fillAbove = we, e.fragmentShader = `uniform bool fillAbove;
109
- ${e.fragmentShader}`.replace(
108
+ e.fragmentShader = e.fragmentShader.replace(
110
109
  "#include <map_fragment>",
111
110
  `#include <map_fragment>
112
- if (vMapUv.x < 0.0 || vMapUv.x > 1.0 || vMapUv.y < 0.0 || (vMapUv.y > 1.0 && !fillAbove)) diffuseColor.rgb = vec3(0.0);`
111
+ if (vMapUv.x < 0.0 || vMapUv.x > 1.0 || vMapUv.y < 0.0 || vMapUv.y > 1.0) diffuseColor.rgb = vec3(0.0);`
113
112
  );
114
113
  }, S.customProgramCacheKey = () => "macbook-fitted-screen";
115
- let N = r.current.aspect, oe = 0, D = Ie(N, N);
116
- const je = () => {
114
+ let N = r.current.aspect, ve = 0, D = Ce(N, N);
115
+ const Ve = () => {
117
116
  const e = l.videoWidth && l.videoHeight ? l.videoWidth / l.videoHeight : N;
118
- D = Ie(e, N, oe), w.repeat.set(D.repeat[0], D.repeat[1]), w.offset.set(D.offset[0], D.offset[1]);
119
- }, b = new ie(), v = new ie(), u = new ie();
120
- u.rotation.x = q(d.current), v.add(u), b.add(v), ve.add(b);
121
- const be = [S], j = [];
117
+ D = Ce(e, N, ve), w.repeat.set(D.repeat[0], D.repeat[1]), w.offset.set(D.offset[0], D.offset[1]);
118
+ }, y = new se(), v = new se(), u = new se();
119
+ u.rotation.x = q(d.current), v.add(u), y.add(v), he.add(y);
120
+ const we = [S], j = [];
122
121
  let W;
123
- for (const e of Ze(r.current.aspect)) {
124
- const t = new at(), i = new lt(e.vertices, qe);
125
- t.setAttribute("position", new ce(i, 3, 0)), t.setAttribute("normal", new ce(i, 3, 3)), t.setAttribute("uv", new ce(i, 2, 6));
126
- const n = vt(e.kind, S), a = wt[e.kind];
122
+ for (const e of $e(r.current.aspect)) {
123
+ const t = new ct(), i = new at(e.vertices, Ze);
124
+ t.setAttribute("position", new ie(i, 3, 0)), t.setAttribute("normal", new ie(i, 3, 3)), t.setAttribute("uv", new ie(i, 2, 6));
125
+ const n = ht(e.kind, S), a = vt[e.kind];
127
126
  a && (n.polygonOffset = !0, n.polygonOffsetFactor = -a, n.polygonOffsetUnits = -a);
128
- const m = new ae(t, n);
129
- e.kind === "screen" && (W = m), (e.part === "lid" ? u : v).add(m), j.push(t), n !== S && j.push(n);
127
+ const p = new ce(t, n);
128
+ e.kind === "screen" && (W = p), (e.part === "lid" ? u : v).add(p), j.push(t), n !== S && j.push(n);
130
129
  }
131
- const ye = new mt(), ge = (e) => {
130
+ const ye = new ft(), ge = (e) => {
132
131
  const t = u.rotation.x;
133
132
  return u.rotation.x = q(L), e.updateMatrixWorld(!0), ye.setFromObject(e), u.rotation.x = t, ye;
134
- }, Me = () => {
135
- b.rotation.set(0, 0, 0), v.position.set(0, 0, 0), v.position.copy(ge(b).getCenter(new _e())).negate();
133
+ }, be = () => {
134
+ y.rotation.set(0, 0, 0), v.position.set(0, 0, 0), v.position.copy(ge(y).getCenter(new Ne())).negate();
136
135
  };
137
- Me();
138
- const We = !!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
139
- let re = !1;
140
- const Ee = () => {
141
- b.visible = !0, !de.current && r.current.animateLid !== !1 && !We && (d.current = 0, u.rotation.x = q(0), ee(0), pe(L)), de.current = !0, re = !0, I();
142
- }, He = async (e) => {
143
- const { GLTFLoader: t } = await import("./GLTFLoader-B3xbM8m1.mjs"), { scene: i } = await dt(new t(), e), n = [];
136
+ be();
137
+ const je = !!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
138
+ let oe = !1;
139
+ const Me = () => {
140
+ y.visible = !0, !le.current && r.current.animateLid !== !1 && !je && (d.current = 0, u.rotation.x = q(0), ee(0), pe(L)), le.current = !0, oe = !0, I();
141
+ }, We = async (e) => {
142
+ const { GLTFLoader: t } = await import("./GLTFLoader-B3xbM8m1.mjs"), { scene: i } = await lt(new t(), e), n = [];
144
143
  if (i.traverse((c) => {
145
- if (c instanceof ae) {
144
+ if (c instanceof ce) {
146
145
  n.push(c.geometry);
147
146
  for (const Be of Array.isArray(c.material) ? c.material : [c.material]) {
148
147
  n.push(Be);
149
- for (const Pe of Object.values(Be)) Pe instanceof ut && n.push(Pe);
148
+ for (const Ae of Object.values(Be)) Ae instanceof dt && n.push(Ae);
150
149
  }
151
150
  }
152
151
  }), V) {
153
152
  for (const c of n) c.dispose();
154
153
  return;
155
154
  }
156
- be.push(...n);
157
- const a = i.getObjectByName("macbook-base"), m = i.getObjectByName("macbook-lid"), p = i.getObjectByName("macbook-screen");
158
- if (!a || !m || !(p instanceof ae))
155
+ we.push(...n);
156
+ const a = i.getObjectByName("macbook-base"), p = i.getObjectByName("macbook-lid"), m = i.getObjectByName("macbook-screen");
157
+ if (!a || !p || !(m instanceof ce))
159
158
  throw new Error("it has no macbook-base, macbook-lid or macbook-screen");
160
159
  for (const c of [...v.children]) c !== u && v.remove(c);
161
160
  u.clear(), v.add(a);
162
- for (const c of [...m.children]) u.add(c);
163
- p.material = S, W = p;
164
- const P = p.userData.aspect;
161
+ for (const c of [...p.children]) u.add(c);
162
+ m.material = S, W = m;
163
+ const P = m.userData.aspect;
165
164
  typeof P == "number" && P > 0 && (N = P);
166
- const h = p.userData.notch;
167
- typeof h == "number" && h >= 0 && h < 0.5 && (oe = h), we.value = oe > 0;
165
+ const h = m.userData.notch;
166
+ typeof h == "number" && h >= 0 && h < 0.5 && (ve = h);
168
167
  for (const c of j.splice(0)) c.dispose();
169
- Me();
170
- }, ne = r.current.model;
171
- ne && (b.visible = !1, He(ne).catch((e) => {
168
+ be();
169
+ }, re = r.current.model;
170
+ re && (y.visible = !1, We(re).catch((e) => {
172
171
  V || J(
173
172
  `The MacBook model could not load: ${e instanceof Error ? e.message : e}`
174
173
  );
175
174
  }).finally(() => {
176
- V || Ee();
175
+ V || Me();
177
176
  }));
178
- const H = new _e();
179
- let g = 0;
180
- const Le = new ft(), ke = new pt();
181
- let s, A = T[Q.current].yaw, B = T[Q.current].pitch;
177
+ const H = new Ne();
178
+ let b = 0;
179
+ const Ee = new ut(), Le = new pt();
180
+ let s, B = T[Q.current].yaw, A = T[Q.current].pitch;
182
181
  C.current = I;
183
182
  const z = (e) => {
184
183
  if (!W) return;
185
184
  const t = U.domElement.getBoundingClientRect();
186
- ke.set(
185
+ Le.set(
187
186
  (e.clientX - t.left) / t.width * 2 - 1,
188
187
  1 - (e.clientY - t.top) / t.height * 2
189
- ), Le.setFromCamera(ke, O);
190
- const i = Le.intersectObject(v, !0)[0], n = i?.object === W ? i.uv : void 0;
191
- return n && et(n.x, n.y, D);
192
- }, xe = (e) => {
188
+ ), Ee.setFromCamera(Le, O);
189
+ const i = Ee.intersectObject(v, !0)[0], n = i?.object === W ? i.uv : void 0;
190
+ return n && Qe(n.x, n.y, D);
191
+ }, ke = (e) => {
193
192
  if (I(), s) return;
194
193
  const t = r.current.watchOnly || e.altKey ? void 0 : z(e);
195
- !t && (Xe.current || e.button !== 0) || (o.focus({ preventScroll: !0 }), o.setPointerCapture(e.pointerId), s = {
194
+ !t && (Ke.current || e.button !== 0) || (o.focus({ preventScroll: !0 }), o.setPointerCapture(e.pointerId), s = {
196
195
  pointer: e.pointerId,
197
196
  kind: t ? "screen" : "orbit",
198
197
  clientX: e.clientX,
@@ -200,7 +199,7 @@ ${e.fragmentShader}`.replace(
200
199
  x: t?.x ?? 0,
201
200
  y: t?.y ?? 0
202
201
  }, t && r.current.pointer("down", t.x, t.y, e.buttons));
203
- }, Oe = (e) => {
202
+ }, xe = (e) => {
204
203
  if (I(), !s) {
205
204
  const t = r.current.watchOnly ? void 0 : z(e);
206
205
  U.domElement.style.cursor = t ? "none" : "", t && r.current.pointer("move", t.x, t.y, 0);
@@ -211,19 +210,19 @@ ${e.fragmentShader}`.replace(
211
210
  const t = z(e);
212
211
  t && (s.x = t.x, s.y = t.y), r.current.pointer("move", s.x, s.y, e.buttons);
213
212
  } else
214
- Ve(e.clientX - s.clientX, e.clientY - s.clientY, 1.2);
213
+ Ue(e.clientX - s.clientX, e.clientY - s.clientY, 1.2);
215
214
  s.clientX = e.clientX, s.clientY = e.clientY;
216
215
  }
217
- }, y = (e) => {
216
+ }, g = (e) => {
218
217
  I(), !(!s || e && s.pointer !== e.pointerId) && (s.kind === "screen" && r.current.pointer("up", s.x, s.y, e?.buttons ?? 0), s = void 0);
219
- }, Se = (e) => {
218
+ }, Oe = (e) => {
220
219
  if (r.current.watchOnly || e.ctrlKey) return;
221
220
  const t = z(e);
222
221
  if (!t) return;
223
222
  e.preventDefault();
224
223
  const i = e.deltaMode === WheelEvent.DOM_DELTA_LINE ? 16 : e.deltaMode === WheelEvent.DOM_DELTA_PAGE ? o.clientHeight : 1;
225
224
  r.current.scroll(t.x, t.y, e.deltaX * i, e.deltaY * i);
226
- }, $ = (e) => e.stopPropagation(), De = [
225
+ }, $ = (e) => e.stopPropagation(), Se = [
227
226
  "mousedown",
228
227
  "mousemove",
229
228
  "mouseup",
@@ -232,36 +231,36 @@ ${e.fragmentShader}`.replace(
232
231
  "touchend",
233
232
  "touchcancel"
234
233
  ];
235
- for (const e of De) o.addEventListener(e, $);
236
- const Ae = (e) => e.preventDefault(), Z = () => {
237
- y(), r.current.onBlur();
234
+ for (const e of Se) o.addEventListener(e, $);
235
+ const De = (e) => e.preventDefault(), Z = () => {
236
+ g(), r.current.onBlur();
238
237
  };
239
- o.addEventListener("pointerdown", xe), o.addEventListener("pointermove", Oe), o.addEventListener("pointerup", y), o.addEventListener("pointercancel", y), o.addEventListener("lostpointercapture", y), o.addEventListener("wheel", Se, { passive: !1 }), o.addEventListener("wheel", $), o.addEventListener("contextmenu", Ae), o.addEventListener("focusout", Z), window.addEventListener("blur", Z);
240
- const ze = (e, t) => {
238
+ o.addEventListener("pointerdown", ke), o.addEventListener("pointermove", xe), o.addEventListener("pointerup", g), o.addEventListener("pointercancel", g), o.addEventListener("lostpointercapture", g), o.addEventListener("wheel", Oe, { passive: !1 }), o.addEventListener("wheel", $), o.addEventListener("contextmenu", De), o.addEventListener("focusout", Z), window.addEventListener("blur", Z);
239
+ const He = (e, t) => {
241
240
  const i = T[Q.current];
242
241
  let n = !1;
243
242
  const a = K.current;
244
243
  if (a) {
245
244
  const c = a.duration > 0 ? (e - a.start) / a.duration : 1;
246
- d.current = a.from + (a.to - a.from) * tt(c), c >= 1 ? K.current = void 0 : n = !0, ee(d.current);
245
+ d.current = a.from + (a.to - a.from) * et(c), c >= 1 ? K.current = void 0 : n = !0, ee(d.current);
247
246
  } else d.current !== x.current && (d.current = R.damp(d.current, x.current, 14, t), Math.abs(d.current - x.current) < 0.05 ? d.current = x.current : n = !0);
248
247
  u.rotation.x = q(d.current);
249
- const m = i.yaw + fe.yaw, p = i.pitch + fe.pitch;
250
- A = R.damp(A, m, 10, t), B = R.damp(B, p, 10, t), Math.abs(A - m) < 5e-4 && (A = m), Math.abs(B - p) < 5e-4 && (B = p), je(), b.rotation.set(B, A, 0, "XYZ"), ge(b).getSize(H);
251
- const P = Math.tan(R.degToRad(Re / 2)), h = Math.max(H.y / 2 / P, H.x / 2 / (P * te)) * 1.12 + H.z / 2;
252
- return g = g ? R.damp(g, h, 10, t) : h, Math.abs(g - h) < 0.01 && (g = h), O.position.set(0, 0, g), O.lookAt(0, 0, 0), U.render(ve, O), re && (re = !1, he()), n || A !== m || B !== p || g !== h;
248
+ const p = i.yaw + ue.yaw, m = i.pitch + ue.pitch;
249
+ B = R.damp(B, p, 10, t), A = R.damp(A, m, 10, t), Math.abs(B - p) < 5e-4 && (B = p), Math.abs(A - m) < 5e-4 && (A = m), Ve(), y.rotation.set(A, B, 0, "XYZ"), ge(y).getSize(H);
250
+ const P = Math.tan(R.degToRad(Fe / 2)), h = Math.max(H.y / 2 / P, H.x / 2 / (P * te)) * 1.12 + H.z / 2;
251
+ return b = b ? R.damp(b, h, 10, t) : h, Math.abs(b - h) < 0.01 && (b = h), O.position.set(0, 0, b), O.lookAt(0, 0, 0), U.render(he, O), oe && (oe = !1, me()), n || B !== p || A !== m || b !== h;
253
252
  };
254
- return X.start(), ne || Ee(), () => {
253
+ return X.start(), re || Me(), () => {
255
254
  V = !0, C.current = () => {
256
- }, y();
257
- for (const e of De) o.removeEventListener(e, $);
258
- o.removeEventListener("pointerdown", xe), o.removeEventListener("pointermove", Oe), o.removeEventListener("pointerup", y), o.removeEventListener("pointercancel", y), o.removeEventListener("lostpointercapture", y), o.removeEventListener("wheel", Se), o.removeEventListener("wheel", $), o.removeEventListener("contextmenu", Ae), o.removeEventListener("focusout", Z), window.removeEventListener("blur", Z);
259
- for (const e of [...be, ...j]) e.dispose();
255
+ }, g();
256
+ for (const e of Se) o.removeEventListener(e, $);
257
+ o.removeEventListener("pointerdown", ke), o.removeEventListener("pointermove", xe), o.removeEventListener("pointerup", g), o.removeEventListener("pointercancel", g), o.removeEventListener("lostpointercapture", g), o.removeEventListener("wheel", Oe), o.removeEventListener("wheel", $), o.removeEventListener("contextmenu", De), o.removeEventListener("focusout", Z), window.removeEventListener("blur", Z);
258
+ for (const e of [...we, ...j]) e.dispose();
260
259
  w.dispose(), X.dispose();
261
260
  };
262
261
  }, [f.video, f.aspect, f.model]), // The Duo's 3D styles serve every 3D device frame.
263
262
  // Unseen until its first frame, so the host's 2D MacBook shows while the model loads.
264
- /* @__PURE__ */ _("div", { className: "rc-duo rc-macbook-3d", style: Ge ? void 0 : { visibility: "hidden" }, children: [
263
+ /* @__PURE__ */ _("div", { className: "rc-duo rc-macbook-3d", style: Te ? void 0 : { visibility: "hidden" }, children: [
265
264
  /* @__PURE__ */ M(
266
265
  "div",
267
266
  {
@@ -286,14 +285,14 @@ ${e.fragmentShader}`.replace(
286
285
  children: Y < 45 ? "Open" : "Close"
287
286
  }
288
287
  ),
289
- /* @__PURE__ */ M("label", { htmlFor: me, children: "Lid" }),
288
+ /* @__PURE__ */ M("label", { htmlFor: fe, children: "Lid" }),
290
289
  /* @__PURE__ */ M(
291
290
  "input",
292
291
  {
293
- id: me,
292
+ id: fe,
294
293
  type: "range",
295
294
  min: 0,
296
- max: Je,
295
+ max: qe,
297
296
  step: 1,
298
297
  value: Math.round(Y),
299
298
  onChange: (o) => {
@@ -312,9 +311,9 @@ ${e.fragmentShader}`.replace(
312
311
  "button",
313
312
  {
314
313
  type: "button",
315
- "aria-pressed": ue === o,
314
+ "aria-pressed": de === o,
316
315
  onClick: () => {
317
- Ke(o);
316
+ Ye(o);
318
317
  },
319
318
  children: T[o].label
320
319
  },
@@ -327,15 +326,15 @@ ${e.fragmentShader}`.replace(
327
326
  className: "rc-duo-lock",
328
327
  "aria-pressed": k,
329
328
  title: k ? "Position is locked. The screen still controls macOS." : "Drag around the MacBook to turn it. Alt-drag turns it from the screen.",
330
- onClick: () => Ue(!k),
329
+ onClick: () => Xe(!k),
331
330
  children: k ? "Position locked" : "Lock position"
332
331
  }
333
332
  )
334
333
  ] })
335
334
  ] }),
336
- le && /* @__PURE__ */ M("div", { role: "alert", className: "rc-duo-error", children: le })
335
+ ae && /* @__PURE__ */ M("div", { role: "alert", className: "rc-duo-error", children: ae })
337
336
  ] });
338
337
  }
339
338
  export {
340
- Et as default
339
+ Mt as default
341
340
  };