@limrun/ui 0.22.5 → 0.22.7
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/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-B3nWmNki.js +2 -0
- package/dist/{core-nbvkIrvp.mjs → core-B7MkSLE_.mjs} +950 -899
- package/dist/core.cjs +1 -1
- package/dist/core.js +4 -4
- package/dist/{duo-frame-Bm0hprn9.js → duo-frame-Bpou_8n1.js} +1 -1
- package/dist/{duo-frame-BCmB9_5p.mjs → duo-frame-BvOU1zvh.mjs} +2 -2
- package/dist/{duo-view-tUJbbWoS.js → duo-view-DbnkRRU-.js} +1 -1
- package/dist/{duo-view-C07GD_5E.mjs → duo-view-DuGDgUyB.mjs} +3 -3
- package/dist/index.cjs +1 -1
- package/dist/index.js +2 -2
- package/dist/lite.cjs +1 -1
- package/dist/lite.js +2 -2
- package/dist/{macbook-frame-Dm6ko0j9.mjs → macbook-frame-Bhu3fUB7.mjs} +1 -1
- package/dist/{macbook-frame-BxJfxUcU.js → macbook-frame-DASJ960L.js} +1 -1
- package/dist/remote-control-D_851mel.js +1 -0
- package/dist/remote-control-cQIifCub.mjs +1723 -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
|
@@ -0,0 +1,1723 @@
|
|
|
1
|
+
import { jsxs as oe, jsx as b, Fragment as Eo } from "react/jsx-runtime";
|
|
2
|
+
import { M as te, o as hn, q as fn, f as mn, c as No, d as pn, b as gn, r as yn, s as vn, t as To, u as Xe, v as bn, w as wn, x as Mn, e as An, y as q, z as zt, B as Tn, C as Cn, E as Et, F as B, G as Nt, a as Rn, I as On, J as I, K as En } from "./core-B7MkSLE_.mjs";
|
|
3
|
+
import { useReducer as Nn, useRef as x, useCallback as It, memo as jt, useState as D, useEffect as ee, useMemo as Be, lazy as ko, forwardRef as kn, useLayoutEffect as _n, useImperativeHandle as Sn, Suspense as Co } from "react";
|
|
4
|
+
import { createPortal as In } from "react-dom";
|
|
5
|
+
import './index.css';const re = {
|
|
6
|
+
sideBezel: 1.7,
|
|
7
|
+
topBezel: 2.4,
|
|
8
|
+
chin: 2.4,
|
|
9
|
+
baseHeight: 2.2,
|
|
10
|
+
baseOverhang: 4,
|
|
11
|
+
screenRadius: 0.9,
|
|
12
|
+
lidThickness: 0.7
|
|
13
|
+
}, Ft = 100 + 2 * re.sideBezel, at = Ft + 2 * re.baseOverhang, Vt = re.topBezel + re.chin + re.baseHeight, xn = (Vt - 2 * re.topBezel) / 2, ai = 8;
|
|
14
|
+
function Pn(a) {
|
|
15
|
+
const t = 100 / a, c = t + re.topBezel + re.chin;
|
|
16
|
+
return {
|
|
17
|
+
screenHeight: t,
|
|
18
|
+
lidHeight: c,
|
|
19
|
+
// A closed lid covers the base back to front.
|
|
20
|
+
depth: c
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
const Hn = Math.PI / 2, li = 135, di = 100, ui = 2400;
|
|
24
|
+
function hi(a) {
|
|
25
|
+
return Hn - a * Math.PI / 180;
|
|
26
|
+
}
|
|
27
|
+
function fi(a) {
|
|
28
|
+
const t = Math.max(0, Math.min(1, a));
|
|
29
|
+
return 1 - Math.pow(1 - t, 3);
|
|
30
|
+
}
|
|
31
|
+
function $e(a, t, c, l = 6) {
|
|
32
|
+
const p = [], v = [
|
|
33
|
+
[a / 2 - c.top, t / 2 - c.top, c.top, 0],
|
|
34
|
+
[-a / 2 + c.top, t / 2 - c.top, c.top, Math.PI / 2],
|
|
35
|
+
[-a / 2 + c.bottom, -t / 2 + c.bottom, c.bottom, Math.PI],
|
|
36
|
+
[a / 2 - c.bottom, -t / 2 + c.bottom, c.bottom, Math.PI * 1.5]
|
|
37
|
+
];
|
|
38
|
+
for (const [m, w, T, N] of v)
|
|
39
|
+
for (let _ = 0; _ <= l; _++) {
|
|
40
|
+
const E = N + _ * Math.PI / 2 / l;
|
|
41
|
+
p.push({ x: m + T * Math.cos(E), y: w + T * Math.sin(E), nx: Math.cos(E), ny: Math.sin(E) });
|
|
42
|
+
}
|
|
43
|
+
return p;
|
|
44
|
+
}
|
|
45
|
+
function mi(a) {
|
|
46
|
+
const { screenHeight: t, lidHeight: c, depth: l } = Pn(a), p = [], v = (u, y, M) => p.push({ part: u, kind: y, vertices: new Float32Array(M) }), m = (u, y, M, W, P) => {
|
|
47
|
+
const Y = M.map((J) => J.x), Z = M.map((J) => J.y), [ae, U, me, Te] = [Math.min(...Y), Math.max(...Y), Math.min(...Z), Math.max(...Z)], pe = (ae + U) / 2, F = (me + Te) / 2, ge = (J, Oe) => [
|
|
48
|
+
...W(J, Oe),
|
|
49
|
+
...P,
|
|
50
|
+
(J - ae) / (U - ae || 1),
|
|
51
|
+
(Oe - me) / (Te - me || 1)
|
|
52
|
+
], H = [];
|
|
53
|
+
for (let J = 0; J < M.length; J++) {
|
|
54
|
+
const Oe = M[J], lt = M[(J + 1) % M.length];
|
|
55
|
+
for (const ne of [ge(pe, F), ge(Oe.x, Oe.y), ge(lt.x, lt.y)]) H.push(...ne);
|
|
56
|
+
}
|
|
57
|
+
v(u, y, H);
|
|
58
|
+
}, w = (u, y, M, W, P, Y, Z) => {
|
|
59
|
+
const ae = [];
|
|
60
|
+
for (let U = 0; U < M.length; U++) {
|
|
61
|
+
const me = M[U], Te = M[(U + 1) % M.length], pe = (F, ge) => [...W(F.x, F.y, ge), ...P(F.nx, F.ny), 0, 0];
|
|
62
|
+
for (const F of [
|
|
63
|
+
pe(me, Y),
|
|
64
|
+
pe(Te, Y),
|
|
65
|
+
pe(Te, Z),
|
|
66
|
+
pe(me, Y),
|
|
67
|
+
pe(Te, Z),
|
|
68
|
+
pe(me, Z)
|
|
69
|
+
])
|
|
70
|
+
ae.push(...F);
|
|
71
|
+
}
|
|
72
|
+
v(u, y, ae);
|
|
73
|
+
}, T = $e(Ft, c, { top: 2.2, bottom: 0.4 }), N = (u) => u + c / 2, _ = re.lidThickness;
|
|
74
|
+
w(
|
|
75
|
+
"lid",
|
|
76
|
+
"shell",
|
|
77
|
+
T,
|
|
78
|
+
(u, y, M) => [u, N(y), M],
|
|
79
|
+
(u, y) => [u, y, 0],
|
|
80
|
+
-_,
|
|
81
|
+
0
|
|
82
|
+
), m("lid", "shell", T, (u, y) => [u, N(y), -_], [0, 0, -1]), m(
|
|
83
|
+
"lid",
|
|
84
|
+
"glass",
|
|
85
|
+
$e(Ft - 0.5, c - 0.5, { top: 1.95, bottom: 0.2 }),
|
|
86
|
+
(u, y) => [u, N(y), 0.01],
|
|
87
|
+
[0, 0, 1]
|
|
88
|
+
);
|
|
89
|
+
const E = re.chin;
|
|
90
|
+
m(
|
|
91
|
+
"lid",
|
|
92
|
+
"screen",
|
|
93
|
+
$e(100, t, { top: re.screenRadius, bottom: 0 }),
|
|
94
|
+
(u, y) => [u, E + t / 2 + y, 0.02],
|
|
95
|
+
[0, 0, 1]
|
|
96
|
+
), m(
|
|
97
|
+
"lid",
|
|
98
|
+
"camera",
|
|
99
|
+
$e(0.5, 0.5, { top: 0.25, bottom: 0.25 }, 4),
|
|
100
|
+
(u, y) => [u, c - re.topBezel / 2 + y, 0.02],
|
|
101
|
+
[0, 0, 1]
|
|
102
|
+
);
|
|
103
|
+
const L = $e(at, l + _, { top: 3, bottom: 3 }), K = (u) => (l - _) / 2 - u;
|
|
104
|
+
w(
|
|
105
|
+
"base",
|
|
106
|
+
"shell",
|
|
107
|
+
L,
|
|
108
|
+
(u, y, M) => [u, M, K(y)],
|
|
109
|
+
(u, y) => [u, 0, -y],
|
|
110
|
+
-2.2,
|
|
111
|
+
0
|
|
112
|
+
), m("base", "shell", L, (u, y) => [u, 0, K(y)], [0, 1, 0]), m("base", "shell", L, (u, y) => [u, -2.2, K(y)], [0, -1, 0]);
|
|
113
|
+
const ce = (u, y, M, W, P, Y, Z) => m("base", u, $e(W, P, { top: Z, bottom: Z }, 3), (ae, U) => [y + ae, Y, M - U], [0, 1, 0]), Ae = at * 0.72, fe = l * 0.08, C = [0.55, 1, 1, 1, 1, 1], se = l * 0.4 / C.reduce((u, y) => u + y, 0);
|
|
114
|
+
ce("well", 0, fe + l * 0.4 / 2, Ae + 1.4, l * 0.4 + 1.4, 0.01, 0.8);
|
|
115
|
+
let j = fe;
|
|
116
|
+
for (const [u, y] of C.entries()) {
|
|
117
|
+
const M = y * se, W = Ae / 14;
|
|
118
|
+
for (let P = 0; P < 14; P++) {
|
|
119
|
+
if (u === 5 && P > 4 && P < 9) continue;
|
|
120
|
+
const Y = u === 5 && P === 4 ? 5 : 1;
|
|
121
|
+
ce(
|
|
122
|
+
"keys",
|
|
123
|
+
-Ae / 2 + W * (P + Y / 2),
|
|
124
|
+
j + M / 2,
|
|
125
|
+
W * Y - 0.5,
|
|
126
|
+
M - 0.5,
|
|
127
|
+
0.03,
|
|
128
|
+
0.3
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
j += M;
|
|
132
|
+
}
|
|
133
|
+
ce("trackpad", 0, l * 0.72, at * 0.4, l * 0.36, 0.01, 1.2), m(
|
|
134
|
+
"base",
|
|
135
|
+
"scoop",
|
|
136
|
+
$e(14, 0.9, { top: 0, bottom: 0.45 }, 3),
|
|
137
|
+
(u, y) => [u, -0.45 + y, l + 0.01],
|
|
138
|
+
[0, 0, 1]
|
|
139
|
+
);
|
|
140
|
+
const S = /* @__PURE__ */ new Map();
|
|
141
|
+
for (const u of p) {
|
|
142
|
+
const y = `${u.part}:${u.kind}`;
|
|
143
|
+
S.set(y, [...S.get(y) ?? [], u]);
|
|
144
|
+
}
|
|
145
|
+
return [...S.values()].map((u) => {
|
|
146
|
+
const y = new Float32Array(u.reduce((W, P) => W + P.vertices.length, 0));
|
|
147
|
+
let M = 0;
|
|
148
|
+
for (const W of u)
|
|
149
|
+
y.set(W.vertices, M), M += W.vertices.length;
|
|
150
|
+
return { part: u[0].part, kind: u[0].kind, vertices: y };
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
function pi(a, t, c = 0) {
|
|
154
|
+
const l = a >= t ? 1 : a / t, p = a >= t ? t / a : 1, v = (1 - l) / 2, m = c > 0 ? 1 - p : (1 - p) / 2;
|
|
155
|
+
return { repeat: [1 / l, 1 / p], offset: [(0 - v) / l, (0 - m) / p] };
|
|
156
|
+
}
|
|
157
|
+
function gi(a, t, c) {
|
|
158
|
+
const l = a * c.repeat[0] + c.offset[0], p = t * c.repeat[1] + c.offset[1], v = 1e-9;
|
|
159
|
+
if (l < -v || l > 1 + v || p < -v || p > 1 + v) return;
|
|
160
|
+
const m = (w) => Math.max(0, Math.min(1, w));
|
|
161
|
+
return { x: m(l), y: m(1 - p) };
|
|
162
|
+
}
|
|
163
|
+
const Dn = 150, Wn = 8;
|
|
164
|
+
class Ln {
|
|
165
|
+
constructor(t, c = () => !1) {
|
|
166
|
+
this.send = t, this.blocked = c;
|
|
167
|
+
}
|
|
168
|
+
send;
|
|
169
|
+
blocked;
|
|
170
|
+
// The last pointer event sent, whose buttons the guest holds.
|
|
171
|
+
last;
|
|
172
|
+
gesture;
|
|
173
|
+
screen;
|
|
174
|
+
pointer(t, c, l) {
|
|
175
|
+
const p = t === te.UP && !!this.last?.buttons;
|
|
176
|
+
this.blocked() && !p || (this.last = { ...c, buttons: l }, this.send(hn(t, c.width, c.height, c.x, c.y, l)));
|
|
177
|
+
}
|
|
178
|
+
scroll(t, c, l) {
|
|
179
|
+
this.blocked() || this.send(fn(t.width, t.height, t.x, t.y, c, l));
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* A touch event, its fingers in client coordinates. Returns true when a finger lands on the screen
|
|
183
|
+
* and starts a gesture, so the caller can give the screen the keyboard.
|
|
184
|
+
*/
|
|
185
|
+
touch(t, c, l) {
|
|
186
|
+
const p = this.gesture;
|
|
187
|
+
if (c.length >= 2) {
|
|
188
|
+
const m = {
|
|
189
|
+
x: c.reduce((w, T) => w + T.x, 0) / c.length,
|
|
190
|
+
y: c.reduce((w, T) => w + T.y, 0) / c.length
|
|
191
|
+
};
|
|
192
|
+
if (p?.mode === "scroll") {
|
|
193
|
+
const w = l.map(m.x, m.y);
|
|
194
|
+
w && t === "touchmove" && this.scroll(w, (p.x - m.x) * l.scale, (p.y - m.y) * l.scale);
|
|
195
|
+
} else p?.mode === "press" ? this.lift(p, l) : p?.mode === "pending" && clearTimeout(p.timer);
|
|
196
|
+
return this.gesture = { mode: "scroll", ...m }, !1;
|
|
197
|
+
}
|
|
198
|
+
const v = c[0];
|
|
199
|
+
if (v && t === "touchstart" && !p)
|
|
200
|
+
return this.blocked() || !l.contains(v.x, v.y) ? !1 : (this.screen = l, this.gesture = {
|
|
201
|
+
mode: "pending",
|
|
202
|
+
x: v.x,
|
|
203
|
+
y: v.y,
|
|
204
|
+
timer: setTimeout(() => this.press(), Dn)
|
|
205
|
+
}, !0);
|
|
206
|
+
if (v && p?.mode === "pending") {
|
|
207
|
+
if (Math.hypot(v.x - p.x, v.y - p.y) < Wn) return !1;
|
|
208
|
+
this.press();
|
|
209
|
+
}
|
|
210
|
+
if (v && this.gesture?.mode === "press") {
|
|
211
|
+
this.gesture = { mode: "press", x: v.x, y: v.y };
|
|
212
|
+
const m = l.map(v.x, v.y);
|
|
213
|
+
return m && this.pointer(te.MOVE, m, 1), !1;
|
|
214
|
+
}
|
|
215
|
+
if (c.length === 0) {
|
|
216
|
+
p?.mode === "pending" && (t === "touchcancel" ? clearTimeout(p.timer) : this.press());
|
|
217
|
+
const m = this.gesture;
|
|
218
|
+
m?.mode === "press" && this.lift(m, l), this.gesture = void 0;
|
|
219
|
+
}
|
|
220
|
+
return !1;
|
|
221
|
+
}
|
|
222
|
+
/** Drops a pending touch and lets go of any button the guest holds, where it was pressed. */
|
|
223
|
+
release() {
|
|
224
|
+
clearTimeout(this.gesture?.timer), this.gesture = void 0;
|
|
225
|
+
const t = this.last;
|
|
226
|
+
t?.buttons && this.pointer(te.UP, t, 0);
|
|
227
|
+
}
|
|
228
|
+
// A pending finger's press, where it landed.
|
|
229
|
+
press() {
|
|
230
|
+
const t = this.gesture;
|
|
231
|
+
if (t?.mode !== "pending") return;
|
|
232
|
+
clearTimeout(t.timer), this.gesture = { mode: "press", x: t.x, y: t.y };
|
|
233
|
+
const c = this.screen?.map(t.x, t.y);
|
|
234
|
+
c && this.pointer(te.DOWN, c, 1);
|
|
235
|
+
}
|
|
236
|
+
lift(t, c) {
|
|
237
|
+
const l = c.map(t.x, t.y);
|
|
238
|
+
l && this.pointer(te.UP, l, 0);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
function Yn(a, t) {
|
|
242
|
+
return t.type === "choose" ? t.mode === a.mode ? a : t.mode === "3d" ? { ...a, mode: "3d", selection: a.selection + 1 } : { ...a, mode: "2d" } : a.mode !== "3d" || t.selection !== a.selection || a.ready === t.selection ? a : { ...a, ready: t.selection };
|
|
243
|
+
}
|
|
244
|
+
function Xn(a) {
|
|
245
|
+
const [t, c] = Nn(Yn, { mode: "2d", selection: 0, ready: 0 }), l = x(t);
|
|
246
|
+
l.current = t;
|
|
247
|
+
const p = x(a);
|
|
248
|
+
p.current = a;
|
|
249
|
+
const { mode: v, selection: m, ready: w } = t, T = It((E) => c({ type: "choose", mode: E }), []), N = It(() => {
|
|
250
|
+
const E = l.current;
|
|
251
|
+
E.mode !== "3d" || E.selection !== m || E.ready === m || (p.current?.(), c({ type: "ready", selection: m }));
|
|
252
|
+
}, [m]), _ = v === "3d" && w !== m;
|
|
253
|
+
return { mode: v, shown: v === "3d" && !_ ? "3d" : "2d", loading: _, choose: T, onReady: N };
|
|
254
|
+
}
|
|
255
|
+
function $n({ view: a, label: t }) {
|
|
256
|
+
return /* @__PURE__ */ oe("div", { className: "rc-duo-mode", role: "group", "aria-label": t, children: [
|
|
257
|
+
/* @__PURE__ */ b("button", { type: "button", "aria-pressed": a.mode === "2d", onClick: () => a.choose("2d"), children: "2D" }),
|
|
258
|
+
/* @__PURE__ */ b(
|
|
259
|
+
"button",
|
|
260
|
+
{
|
|
261
|
+
type: "button",
|
|
262
|
+
"aria-pressed": a.mode === "3d",
|
|
263
|
+
"aria-busy": a.loading,
|
|
264
|
+
title: a.loading ? "Loading 3D" : void 0,
|
|
265
|
+
onClick: () => a.choose("3d"),
|
|
266
|
+
children: "3D"
|
|
267
|
+
}
|
|
268
|
+
)
|
|
269
|
+
] });
|
|
270
|
+
}
|
|
271
|
+
const Bn = async (a) => {
|
|
272
|
+
if (!a) return !1;
|
|
273
|
+
try {
|
|
274
|
+
if (typeof navigator < "u" && navigator.clipboard?.writeText)
|
|
275
|
+
return await navigator.clipboard.writeText(a), !0;
|
|
276
|
+
} catch {
|
|
277
|
+
}
|
|
278
|
+
try {
|
|
279
|
+
const t = document.createElement("textarea");
|
|
280
|
+
t.value = a, t.style.position = "fixed", t.style.opacity = "0", document.body.appendChild(t), t.select();
|
|
281
|
+
const c = document.execCommand("copy");
|
|
282
|
+
return document.body.removeChild(t), c;
|
|
283
|
+
} catch {
|
|
284
|
+
return !1;
|
|
285
|
+
}
|
|
286
|
+
}, Kn = jt(
|
|
287
|
+
function({ element: t, screen: c, highlighted: l, selected: p, selectable: v, onClick: m }) {
|
|
288
|
+
const w = mn(t.frame, c);
|
|
289
|
+
if (!w) return null;
|
|
290
|
+
const T = No(t);
|
|
291
|
+
return /* @__PURE__ */ b(
|
|
292
|
+
"button",
|
|
293
|
+
{
|
|
294
|
+
type: "button",
|
|
295
|
+
className: t.enabled ? "rc-inspect-box" : "rc-inspect-box rc-inspect-box-disabled",
|
|
296
|
+
"data-ax-id": t.id,
|
|
297
|
+
"data-ax-path": t.path,
|
|
298
|
+
"data-ax-label": t.label || void 0,
|
|
299
|
+
"data-ax-role": t.role || void 0,
|
|
300
|
+
"data-highlighted": l ? "true" : "false",
|
|
301
|
+
"data-selected": p ? "true" : "false",
|
|
302
|
+
"aria-label": T,
|
|
303
|
+
onClick: (N) => {
|
|
304
|
+
v && (N.preventDefault(), N.stopPropagation(), m(t, { x: N.clientX, y: N.clientY }));
|
|
305
|
+
},
|
|
306
|
+
style: {
|
|
307
|
+
left: `${w.x / c.width * 100}%`,
|
|
308
|
+
top: `${w.y / c.height * 100}%`,
|
|
309
|
+
width: `${w.width / c.width * 100}%`,
|
|
310
|
+
height: `${w.height / c.height * 100}%`
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
);
|
|
314
|
+
},
|
|
315
|
+
(a, t) => a.highlighted === t.highlighted && a.selected === t.selected && a.selectable === t.selectable && a.screen.width === t.screen.width && a.screen.height === t.screen.height && a.onClick === t.onClick && pn(a.element, t.element)
|
|
316
|
+
), Un = 260, zn = 220, Fn = 6, Vn = 8, jn = jt(function({
|
|
317
|
+
element: t,
|
|
318
|
+
platform: c,
|
|
319
|
+
anchor: l,
|
|
320
|
+
cursorAnchored: p,
|
|
321
|
+
showActions: v,
|
|
322
|
+
onTap: m
|
|
323
|
+
}) {
|
|
324
|
+
const [w, T] = D(null);
|
|
325
|
+
ee(() => {
|
|
326
|
+
if (!w) return;
|
|
327
|
+
const C = window.setTimeout(() => T(null), 1100);
|
|
328
|
+
return () => window.clearTimeout(C);
|
|
329
|
+
}, [w]);
|
|
330
|
+
const N = Be(() => {
|
|
331
|
+
const C = Un, se = zn, j = Fn, S = Vn, u = typeof window < "u" ? window.innerWidth : 1024, y = typeof window < "u" ? window.innerHeight : 768, M = l.x + j + C <= u - S, W = l.y - j - se >= S;
|
|
332
|
+
let P = M ? l.x + j : l.x - j, Y = W ? l.y - j : l.y + j;
|
|
333
|
+
const U = `translate(${M ? "0" : "-100%"}, ${W ? "-100%" : "0"})`;
|
|
334
|
+
return P = Math.max(S + (M ? 0 : C), Math.min(u - S - (M ? C : 0), P)), Y = Math.max(S + (W ? se : 0), Math.min(y - S - (W ? 0 : se), Y)), { left: `${P}px`, top: `${Y}px`, transform: U };
|
|
335
|
+
}, [l.x, l.y]), _ = Be(() => gn(t, c), [t, c]), E = c === "ios" ? t.selectors.AXUniqueId : t.selectors.resourceId, L = c === "ios" ? "AXUniqueId" : "resourceId", K = It(async (C, se) => {
|
|
336
|
+
if (!C) return;
|
|
337
|
+
await Bn(C) && T(se);
|
|
338
|
+
}, []), ce = yn(t), Ae = t.label || t.value || ce, fe = No(t);
|
|
339
|
+
return In(
|
|
340
|
+
/* @__PURE__ */ oe(
|
|
341
|
+
"div",
|
|
342
|
+
{
|
|
343
|
+
className: "rc-inspect-card",
|
|
344
|
+
"data-cursor-anchored": p ? "true" : "false",
|
|
345
|
+
style: N,
|
|
346
|
+
onClick: (C) => C.stopPropagation(),
|
|
347
|
+
onMouseDown: (C) => C.stopPropagation(),
|
|
348
|
+
onMouseMove: (C) => C.stopPropagation(),
|
|
349
|
+
children: [
|
|
350
|
+
/* @__PURE__ */ oe("div", { className: "rc-inspect-card-header", children: [
|
|
351
|
+
/* @__PURE__ */ b("span", { className: "rc-inspect-card-role", children: ce }),
|
|
352
|
+
!t.enabled && /* @__PURE__ */ b("span", { className: "rc-inspect-card-tag", children: "disabled" }),
|
|
353
|
+
t.focused && /* @__PURE__ */ b("span", { className: "rc-inspect-card-tag rc-inspect-card-tag-blue", children: "focused" })
|
|
354
|
+
] }),
|
|
355
|
+
/* @__PURE__ */ b("p", { className: "rc-inspect-card-title", title: fe, children: Ae }),
|
|
356
|
+
E && /* @__PURE__ */ oe("div", { className: "rc-inspect-card-row", children: [
|
|
357
|
+
/* @__PURE__ */ oe("span", { className: "rc-inspect-card-row-label", children: [
|
|
358
|
+
L,
|
|
359
|
+
":"
|
|
360
|
+
] }),
|
|
361
|
+
/* @__PURE__ */ b("span", { className: "rc-inspect-card-row-value", children: E })
|
|
362
|
+
] }),
|
|
363
|
+
t.value && t.value !== t.label && /* @__PURE__ */ oe("div", { className: "rc-inspect-card-row", children: [
|
|
364
|
+
/* @__PURE__ */ b("span", { className: "rc-inspect-card-row-label", children: "value:" }),
|
|
365
|
+
/* @__PURE__ */ b("span", { className: "rc-inspect-card-row-value", children: t.value })
|
|
366
|
+
] }),
|
|
367
|
+
/* @__PURE__ */ oe("div", { className: "rc-inspect-card-row", children: [
|
|
368
|
+
/* @__PURE__ */ b("span", { className: "rc-inspect-card-row-label", children: "frame:" }),
|
|
369
|
+
/* @__PURE__ */ oe("span", { className: "rc-inspect-card-row-value", children: [
|
|
370
|
+
Math.round(t.frame.width),
|
|
371
|
+
"×",
|
|
372
|
+
Math.round(t.frame.height),
|
|
373
|
+
" @ ",
|
|
374
|
+
Math.round(t.frame.x),
|
|
375
|
+
",",
|
|
376
|
+
Math.round(t.frame.y)
|
|
377
|
+
] })
|
|
378
|
+
] }),
|
|
379
|
+
v && /* @__PURE__ */ oe("div", { className: "rc-inspect-card-actions", children: [
|
|
380
|
+
/* @__PURE__ */ b(
|
|
381
|
+
"button",
|
|
382
|
+
{
|
|
383
|
+
type: "button",
|
|
384
|
+
className: "rc-inspect-card-btn rc-inspect-card-btn-primary",
|
|
385
|
+
disabled: !m,
|
|
386
|
+
onClick: () => m?.(t, l),
|
|
387
|
+
children: "Tap"
|
|
388
|
+
}
|
|
389
|
+
),
|
|
390
|
+
/* @__PURE__ */ b(
|
|
391
|
+
"button",
|
|
392
|
+
{
|
|
393
|
+
type: "button",
|
|
394
|
+
className: w === "selector" ? "rc-inspect-card-btn rc-inspect-card-btn-copied" : "rc-inspect-card-btn",
|
|
395
|
+
disabled: !_,
|
|
396
|
+
title: _ ?? "No usable selector for this element",
|
|
397
|
+
onClick: () => K(_ ?? void 0, "selector"),
|
|
398
|
+
children: w === "selector" ? "Copied!" : "Copy selector"
|
|
399
|
+
}
|
|
400
|
+
),
|
|
401
|
+
/* @__PURE__ */ b(
|
|
402
|
+
"button",
|
|
403
|
+
{
|
|
404
|
+
type: "button",
|
|
405
|
+
className: w === "id" ? "rc-inspect-card-btn rc-inspect-card-btn-copied" : "rc-inspect-card-btn",
|
|
406
|
+
disabled: !E,
|
|
407
|
+
title: E ?? `No ${L}`,
|
|
408
|
+
onClick: () => K(E, "id"),
|
|
409
|
+
children: w === "id" ? "Copied!" : `Copy ${L}`
|
|
410
|
+
}
|
|
411
|
+
)
|
|
412
|
+
] })
|
|
413
|
+
]
|
|
414
|
+
}
|
|
415
|
+
),
|
|
416
|
+
document.body
|
|
417
|
+
);
|
|
418
|
+
}), Gn = jt(function({
|
|
419
|
+
snapshot: t,
|
|
420
|
+
geometry: c,
|
|
421
|
+
highlightedId: l,
|
|
422
|
+
selectedId: p,
|
|
423
|
+
mode: v,
|
|
424
|
+
cursorPosition: m,
|
|
425
|
+
frozenCursorPosition: w,
|
|
426
|
+
onSelectChange: T,
|
|
427
|
+
onTapElement: N
|
|
428
|
+
}) {
|
|
429
|
+
const _ = v === "select", E = _ ? l !== null && l !== p : l !== null, L = _ ? l ?? p : l, K = Be(() => {
|
|
430
|
+
const S = /* @__PURE__ */ new Map();
|
|
431
|
+
if (!t) return S;
|
|
432
|
+
for (const u of t.elements) S.set(u.id, u);
|
|
433
|
+
return S;
|
|
434
|
+
}, [t]), ce = Be(() => L ? K.get(L) ?? null : null, [L, K]);
|
|
435
|
+
if (!(!!t && !!c && t.screen.width > 0 && t.screen.height > 0 && t.elements.length > 0)) return null;
|
|
436
|
+
const fe = E ? m : w ?? m, C = E, se = _ && !E && p !== null, j = (S) => {
|
|
437
|
+
_ && S.target === S.currentTarget && T(null, null);
|
|
438
|
+
};
|
|
439
|
+
return /* @__PURE__ */ oe(Eo, { children: [
|
|
440
|
+
/* @__PURE__ */ b(
|
|
441
|
+
"div",
|
|
442
|
+
{
|
|
443
|
+
className: _ ? "rc-inspect-overlay rc-inspect-overlay-select" : "rc-inspect-overlay",
|
|
444
|
+
style: {
|
|
445
|
+
left: `${c.left}px`,
|
|
446
|
+
top: `${c.top}px`,
|
|
447
|
+
width: `${c.width}px`,
|
|
448
|
+
height: `${c.height}px`
|
|
449
|
+
},
|
|
450
|
+
onClick: j,
|
|
451
|
+
children: t.elements.map((S) => /* @__PURE__ */ b(
|
|
452
|
+
Kn,
|
|
453
|
+
{
|
|
454
|
+
element: S,
|
|
455
|
+
screen: t.screen,
|
|
456
|
+
highlighted: S.id === l,
|
|
457
|
+
selected: S.id === p,
|
|
458
|
+
selectable: _,
|
|
459
|
+
onClick: T
|
|
460
|
+
},
|
|
461
|
+
S.id
|
|
462
|
+
))
|
|
463
|
+
}
|
|
464
|
+
),
|
|
465
|
+
ce && fe && /* @__PURE__ */ b(
|
|
466
|
+
jn,
|
|
467
|
+
{
|
|
468
|
+
element: ce,
|
|
469
|
+
platform: t.platform,
|
|
470
|
+
anchor: fe,
|
|
471
|
+
cursorAnchored: C,
|
|
472
|
+
showActions: se,
|
|
473
|
+
onTap: N
|
|
474
|
+
}
|
|
475
|
+
)
|
|
476
|
+
] });
|
|
477
|
+
});
|
|
478
|
+
function qn(a, t) {
|
|
479
|
+
if (!t.startsWith("lim_st_")) return !1;
|
|
480
|
+
try {
|
|
481
|
+
const c = new URL(a).pathname.split("/").map(decodeURIComponent).find((N) => /^(ios|android)_[a-z0-9_]+$/.test(N));
|
|
482
|
+
if (!c) return !1;
|
|
483
|
+
const l = c.split("_")[0], p = t.slice(7).split(".");
|
|
484
|
+
if (p.length !== 3 || p.some((N) => !N)) return !1;
|
|
485
|
+
const v = atob(p[1].replace(/-/g, "+").replace(/_/g, "/")), m = JSON.parse(
|
|
486
|
+
new TextDecoder().decode(Uint8Array.from(v, (N) => N.charCodeAt(0)))
|
|
487
|
+
);
|
|
488
|
+
if (!m || typeof m != "object" || !("scopes" in m)) return !1;
|
|
489
|
+
const w = m.scopes;
|
|
490
|
+
if (!Array.isArray(w) || !w.every((N) => typeof N == "string")) return !1;
|
|
491
|
+
let T = !1;
|
|
492
|
+
for (const N of w) {
|
|
493
|
+
const [_, E, L, K] = N.split(":");
|
|
494
|
+
if (!(K !== void 0 || _ !== l && _ !== "*") && !(E !== c && E !== "*")) {
|
|
495
|
+
if (L === "stream" || L === "all") return !1;
|
|
496
|
+
L === "watch" && (T = !0);
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
return T;
|
|
500
|
+
} catch {
|
|
501
|
+
return !1;
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
const Zn = ko(() => import("./duo-view-DuGDgUyB.mjs").then((a) => a.d)), Jn = ko(() => import("./macbook-frame-Bhu3fUB7.mjs")), kt = (a) => Object.entries(I).find(
|
|
505
|
+
([c, l]) => c.startsWith("ACTION_") && l === a
|
|
506
|
+
)?.[0] ?? String(a), Ro = 1920, Oo = 1200, Qn = (a, t) => a === Ro && t === Oo || a === Oo && t === Ro, ei = {
|
|
507
|
+
ios: {
|
|
508
|
+
videoBorderRadiusMultiplier: 0.15,
|
|
509
|
+
loadingLogoSize: "20%",
|
|
510
|
+
// Video position as percentage of frame dimensions
|
|
511
|
+
videoPosition: {
|
|
512
|
+
portrait: { heightMultiplier: 0.9678 },
|
|
513
|
+
landscape: { widthMultiplier: 0.9678 }
|
|
514
|
+
}
|
|
515
|
+
},
|
|
516
|
+
android: {
|
|
517
|
+
videoBorderRadiusMultiplier: 0.13,
|
|
518
|
+
loadingLogoSize: "40%",
|
|
519
|
+
// Video position as percentage of frame dimensions
|
|
520
|
+
videoPosition: {
|
|
521
|
+
portrait: { heightMultiplier: 0.967 },
|
|
522
|
+
landscape: { widthMultiplier: 0.962 }
|
|
523
|
+
}
|
|
524
|
+
},
|
|
525
|
+
// A macOS virtual machine is a desktop display. Its MacBook Pro frame is drawn in CSS around
|
|
526
|
+
// whatever size the guest display has; see MACBOOK below.
|
|
527
|
+
macos: {
|
|
528
|
+
videoBorderRadiusMultiplier: 0,
|
|
529
|
+
loadingLogoSize: "10%",
|
|
530
|
+
videoPosition: {
|
|
531
|
+
portrait: { heightMultiplier: 1 },
|
|
532
|
+
landscape: { widthMultiplier: 1 }
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
}, ti = {
|
|
536
|
+
"iphone-se": {
|
|
537
|
+
videoBorderRadiusMultiplier: 0,
|
|
538
|
+
loadingLogoSize: "20%",
|
|
539
|
+
videoPosition: {
|
|
540
|
+
portrait: { heightMultiplier: 667 / 889 },
|
|
541
|
+
landscape: { widthMultiplier: 667 / 889 }
|
|
542
|
+
},
|
|
543
|
+
// The SE has no home indicator, so its frame's home button is the way home: 64 points across,
|
|
544
|
+
// centered in the bottom bezel 389 points below the frame's center.
|
|
545
|
+
homeButton: { offset: 389 / 889, diameter: 64 / 889 }
|
|
546
|
+
},
|
|
547
|
+
"iphone-17e": {
|
|
548
|
+
videoBorderRadiusMultiplier: 47.33 / 452,
|
|
549
|
+
loadingLogoSize: "20%",
|
|
550
|
+
videoPosition: {
|
|
551
|
+
portrait: { heightMultiplier: 844 / 888 },
|
|
552
|
+
landscape: { widthMultiplier: 844 / 888 }
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
}, Ut = 16 / 10, _t = 44, oi = {
|
|
556
|
+
videoBorderRadiusMultiplier: 32 / 1837,
|
|
557
|
+
loadingLogoSize: "40%",
|
|
558
|
+
videoPosition: {
|
|
559
|
+
portrait: { heightMultiplier: 2560 / 2798 },
|
|
560
|
+
landscape: { widthMultiplier: 2560 / 2798 }
|
|
561
|
+
}
|
|
562
|
+
};
|
|
563
|
+
function ni(a) {
|
|
564
|
+
const t = a.code, c = On[t];
|
|
565
|
+
if (!c)
|
|
566
|
+
return zt(`Unknown event.code: ${t}, key: ${a.key}`), null;
|
|
567
|
+
let l = B.META_NONE;
|
|
568
|
+
const p = t >= "KeyA" && t <= "KeyZ", v = a.getModifierState("CapsLock"), m = a.shiftKey;
|
|
569
|
+
let w = m;
|
|
570
|
+
return p && (w = m !== v), w && (l |= B.META_SHIFT_ON), a.ctrlKey && (l |= B.META_CTRL_ON), a.altKey && (l |= B.META_ALT_ON), a.metaKey && (l |= B.META_META_ON), { keycode: c, metaState: l };
|
|
571
|
+
}
|
|
572
|
+
function St(a, t) {
|
|
573
|
+
const c = Object.keys(a);
|
|
574
|
+
return c.length === Object.keys(t).length && c.every((l) => a[l] === t[l]);
|
|
575
|
+
}
|
|
576
|
+
const yi = kn(
|
|
577
|
+
({
|
|
578
|
+
className: a,
|
|
579
|
+
url: t,
|
|
580
|
+
token: c,
|
|
581
|
+
sessionId: l,
|
|
582
|
+
openUrl: p,
|
|
583
|
+
watchOnly: v = !1,
|
|
584
|
+
showFrame: m = !0,
|
|
585
|
+
animateLid: w = !0,
|
|
586
|
+
deviceModel: T,
|
|
587
|
+
duoModelUrl: N,
|
|
588
|
+
macbookModelUrl: _,
|
|
589
|
+
autoReconnect: E,
|
|
590
|
+
jitterBufferTargetMs: L,
|
|
591
|
+
onPlaybackStats: K,
|
|
592
|
+
onTerminated: ce,
|
|
593
|
+
assets: Ae,
|
|
594
|
+
onConnectionStateChange: fe,
|
|
595
|
+
inspectMode: C,
|
|
596
|
+
onAxSnapshotChange: se,
|
|
597
|
+
onInspectSelectionChange: j,
|
|
598
|
+
onAxStatusChange: S,
|
|
599
|
+
axPollIntervalMs: u,
|
|
600
|
+
axMaxBackoffMs: y,
|
|
601
|
+
androidElementTreeOptions: M,
|
|
602
|
+
onCameraDemandChange: W,
|
|
603
|
+
onCameraStats: P,
|
|
604
|
+
onTrace: Y,
|
|
605
|
+
microphoneEnabled: Z = !1,
|
|
606
|
+
onMicrophoneStateChange: ae,
|
|
607
|
+
speakerMuted: U = !0,
|
|
608
|
+
onSpeakerBlocked: me
|
|
609
|
+
}, Te) => {
|
|
610
|
+
const pe = Be(() => qn(t, c), [t, c]), F = v || pe, ge = x(null), H = x(null), J = x(null), [Oe, lt] = D(!1), ne = T === "iphone-duo" || Oe, dt = T === "iphone-duo" ? T : void 0, ut = x(null), ht = x(null), [Gt, _o] = D(null), [qt, So] = D(), [Io, xo] = D(!1), [Po, Ho] = D(!1), [Do, Wo] = D(!1), [xt, Zt] = D(!1), [Jt, Qt] = D(!1), [Lo, eo] = D({}), [to, oo] = D(null), [Pt, Yo] = D(null), [no, Xo] = D(null), [io, ro] = D(null), et = Xn(() => vt.current?.release()), ft = x(!1), Ht = x(null), V = x(/* @__PURE__ */ new Map()), Ee = x(!1), [$o, Bo] = D(!1), X = x(null), Ke = x(null), tt = x({
|
|
611
|
+
handle: () => {
|
|
612
|
+
},
|
|
613
|
+
end: () => {
|
|
614
|
+
}
|
|
615
|
+
}), [Ne, mt] = D(null), [co, Dt] = D(null), [Wt, ot] = D(null), [Lt, pt] = D(null), [Ko, so] = D(null), [Uo, ao] = D(null), gt = x(null), be = x(void 0), lo = (e) => {
|
|
616
|
+
gt.current = e, be.current === void 0 && (be.current = window.requestAnimationFrame(() => {
|
|
617
|
+
be.current = void 0, ao(gt.current);
|
|
618
|
+
}));
|
|
619
|
+
}, [zo, Ue] = D(null), ke = x(null);
|
|
620
|
+
ke.current = co;
|
|
621
|
+
const ze = x(j);
|
|
622
|
+
ze.current = j;
|
|
623
|
+
const _e = C === !0 || C === "hover-only", uo = x(_e);
|
|
624
|
+
uo.current = _e;
|
|
625
|
+
const Fo = C === "hover-only" ? "hover-only" : "select", z = Be(() => vn(t), [t]), Vo = Be(
|
|
626
|
+
() => l || Array.from(crypto.getRandomValues(new Uint32Array(4)), (e) => e.toString(36)).join(""),
|
|
627
|
+
[l]
|
|
628
|
+
), nt = z === "ios" && T && T !== "iphone-duo" ? T : void 0, Se = z === "android" && Jt ? oi : nt ? ti[nt] : ei[z], le = Ae?.[z], ho = nt && le?.modelFrames?.[nt], fo = z === "android" && Jt ? xt ? le?.tabletFrameLandscape : le?.tabletFrame : nt ? xt ? ho?.frameLandscape : ho?.frame : xt ? le?.frameLandscape : le?.frame, mo = le?.loadingLogo, it = !ne && z !== "macos" && m && !!fo, ye = z === "macos" && m, Ie = ye && le?.frame && le.screen ? { src: le.frame, screen: le.screen } : void 0, Yt = x(null), jo = ye && et.mode === "3d", xe = ye && et.shown === "3d";
|
|
629
|
+
ft.current = xe;
|
|
630
|
+
const po = et.choose;
|
|
631
|
+
ee(() => {
|
|
632
|
+
ye || po("2d");
|
|
633
|
+
}, [ye, po]);
|
|
634
|
+
const R = x(null), ue = (e) => R.current?.sendControl(e), yt = x(/* @__PURE__ */ new Set()), go = x(!1);
|
|
635
|
+
go.current = C === !0;
|
|
636
|
+
const vt = x(null);
|
|
637
|
+
vt.current || (vt.current = new Ln(
|
|
638
|
+
(e) => R.current?.sendControl(e),
|
|
639
|
+
() => go.current
|
|
640
|
+
));
|
|
641
|
+
const Pe = vt.current;
|
|
642
|
+
ee(() => () => Pe.release(), [Pe]);
|
|
643
|
+
const rt = It(() => {
|
|
644
|
+
for (const e of yt.current)
|
|
645
|
+
R.current?.sendControl(To(te.UP, e));
|
|
646
|
+
yt.current.clear();
|
|
647
|
+
}, []), Xt = (e, o) => R.current?.sendDuoControl(e, o) ?? Promise.reject(new Error("Simulator disconnected")), yo = -10, vo = (e, o) => {
|
|
648
|
+
const n = Ve();
|
|
649
|
+
if (!n) return;
|
|
650
|
+
const r = we(n, e, o);
|
|
651
|
+
if (!r) return;
|
|
652
|
+
const { videoX: i, videoY: d, videoWidth: s, videoHeight: h } = r, f = Nt(
|
|
653
|
+
I.ACTION_DOWN,
|
|
654
|
+
yo,
|
|
655
|
+
s,
|
|
656
|
+
h,
|
|
657
|
+
i,
|
|
658
|
+
d,
|
|
659
|
+
1,
|
|
660
|
+
I.BUTTON_PRIMARY,
|
|
661
|
+
I.BUTTON_PRIMARY
|
|
662
|
+
);
|
|
663
|
+
f && ue(f), window.setTimeout(() => {
|
|
664
|
+
const A = Nt(
|
|
665
|
+
I.ACTION_UP,
|
|
666
|
+
yo,
|
|
667
|
+
s,
|
|
668
|
+
h,
|
|
669
|
+
i,
|
|
670
|
+
d,
|
|
671
|
+
0,
|
|
672
|
+
I.BUTTON_PRIMARY,
|
|
673
|
+
I.BUTTON_PRIMARY
|
|
674
|
+
);
|
|
675
|
+
A && ue(A);
|
|
676
|
+
}, 60);
|
|
677
|
+
}, Go = (e, o) => {
|
|
678
|
+
const n = Ve();
|
|
679
|
+
if (!n || o.screen.width <= 0 || o.screen.height <= 0) return;
|
|
680
|
+
const r = e.frame.x + e.frame.width / 2, i = e.frame.y + e.frame.height / 2, d = r / o.screen.width * n.actualWidth, s = i / o.screen.height * n.actualHeight, h = n.videoRect.left + n.offsetX + d, f = n.videoRect.top + n.offsetY + s;
|
|
681
|
+
vo(h, f);
|
|
682
|
+
}, bt = -1, wt = -2, He = -3, Fe = (e, o, n, r, i, d) => {
|
|
683
|
+
const s = Nt(
|
|
684
|
+
e,
|
|
685
|
+
o,
|
|
686
|
+
n,
|
|
687
|
+
r,
|
|
688
|
+
i,
|
|
689
|
+
d,
|
|
690
|
+
1,
|
|
691
|
+
// pressure
|
|
692
|
+
I.BUTTON_PRIMARY,
|
|
693
|
+
I.BUTTON_PRIMARY
|
|
694
|
+
);
|
|
695
|
+
s && (q("[rc-touch] sendSingleTouch", {
|
|
696
|
+
action: e,
|
|
697
|
+
actionName: kt(e),
|
|
698
|
+
pointerId: o,
|
|
699
|
+
x: i,
|
|
700
|
+
y: d,
|
|
701
|
+
video: { width: n, height: r }
|
|
702
|
+
}), ue(s));
|
|
703
|
+
}, De = (e, o, n) => {
|
|
704
|
+
if (!n) return;
|
|
705
|
+
const { videoX: r, videoY: i, videoWidth: d, videoHeight: s } = n;
|
|
706
|
+
let h = null, f = null, A = 1;
|
|
707
|
+
const k = I.BUTTON_PRIMARY;
|
|
708
|
+
switch (o) {
|
|
709
|
+
case "down":
|
|
710
|
+
e !== He && tt.current.end(), h = V.current.size === 0 ? I.ACTION_DOWN : I.ACTION_POINTER_DOWN, f = { x: r, y: i }, V.current.set(e, f), e === -1 && H.current?.focus();
|
|
711
|
+
break;
|
|
712
|
+
case "move":
|
|
713
|
+
V.current.has(e) && (h = I.ACTION_MOVE, f = { x: r, y: i }, V.current.set(e, f));
|
|
714
|
+
break;
|
|
715
|
+
case "up":
|
|
716
|
+
case "cancel":
|
|
717
|
+
V.current.has(e) && (f = V.current.get(e), V.current.delete(e), o === "cancel" ? h = I.ACTION_CANCEL : h = V.current.size === 0 ? I.ACTION_UP : I.ACTION_POINTER_UP);
|
|
718
|
+
break;
|
|
719
|
+
}
|
|
720
|
+
if (h !== null && f !== null) {
|
|
721
|
+
q("[rc-touch][mouse->touch] sending", {
|
|
722
|
+
pointerId: e,
|
|
723
|
+
eventType: o,
|
|
724
|
+
action: h,
|
|
725
|
+
actionName: kt(h),
|
|
726
|
+
positionToSend: f,
|
|
727
|
+
video: { width: d, height: s },
|
|
728
|
+
altHeld: Ee.current,
|
|
729
|
+
activePointersAfter: Array.from(V.current.entries()).map(([ie, $]) => ({
|
|
730
|
+
id: ie,
|
|
731
|
+
x: $.x,
|
|
732
|
+
y: $.y
|
|
733
|
+
}))
|
|
734
|
+
});
|
|
735
|
+
const g = Nt(
|
|
736
|
+
h,
|
|
737
|
+
e,
|
|
738
|
+
d,
|
|
739
|
+
s,
|
|
740
|
+
f.x,
|
|
741
|
+
f.y,
|
|
742
|
+
A,
|
|
743
|
+
k,
|
|
744
|
+
k
|
|
745
|
+
);
|
|
746
|
+
g && (q("[rc-touch][mouse->touch] buffer", {
|
|
747
|
+
pointerId: e,
|
|
748
|
+
actionName: kt(h),
|
|
749
|
+
byteLength: g.byteLength
|
|
750
|
+
}), ue(g));
|
|
751
|
+
} else (o === "up" || o === "cancel") && V.current.delete(e);
|
|
752
|
+
}, $t = (e) => {
|
|
753
|
+
if (Ee.current !== e && (Ee.current = e, Bo(e), e || mt(null), q("[rc-touch][alt] updateAltHeld", {
|
|
754
|
+
nextHeld: e,
|
|
755
|
+
activePointerIds: Array.from(V.current.keys())
|
|
756
|
+
}), z === "ios" && R.current?.getState().controlReady)) {
|
|
757
|
+
const o = e ? B.ACTION_DOWN : B.ACTION_UP, n = Et(
|
|
758
|
+
o,
|
|
759
|
+
B.KEYCODE_ALT_LEFT,
|
|
760
|
+
0,
|
|
761
|
+
B.META_NONE
|
|
762
|
+
);
|
|
763
|
+
q("[rc-touch][alt] sending Indigo modifier keycode", {
|
|
764
|
+
action: o,
|
|
765
|
+
keycode: B.KEYCODE_ALT_LEFT
|
|
766
|
+
}), n && ue(n);
|
|
767
|
+
}
|
|
768
|
+
}, Ve = () => {
|
|
769
|
+
const e = H.current, o = ge.current;
|
|
770
|
+
if (!e || !o) return null;
|
|
771
|
+
const n = e.videoWidth, r = e.videoHeight;
|
|
772
|
+
if (!n || !r) return null;
|
|
773
|
+
const i = e.getBoundingClientRect(), d = o.getBoundingClientRect(), s = i.width, h = i.height, f = n / r, A = s / h;
|
|
774
|
+
let k = s, g = h;
|
|
775
|
+
f > A ? g = s / f : k = h * f;
|
|
776
|
+
const ie = (s - k) / 2, $ = (h - g) / 2;
|
|
777
|
+
return {
|
|
778
|
+
videoWidth: n,
|
|
779
|
+
videoHeight: r,
|
|
780
|
+
videoRect: i,
|
|
781
|
+
containerRect: d,
|
|
782
|
+
actualWidth: k,
|
|
783
|
+
actualHeight: g,
|
|
784
|
+
offsetX: ie,
|
|
785
|
+
offsetY: $
|
|
786
|
+
};
|
|
787
|
+
}, we = (e, o, n) => {
|
|
788
|
+
const r = o - e.videoRect.left - e.offsetX, i = n - e.videoRect.top - e.offsetY, d = Math.max(0, Math.min(e.actualWidth, r)), s = Math.max(0, Math.min(e.actualHeight, i)), h = Math.max(
|
|
789
|
+
0,
|
|
790
|
+
Math.min(e.videoWidth, d / e.actualWidth * e.videoWidth)
|
|
791
|
+
), f = Math.max(
|
|
792
|
+
0,
|
|
793
|
+
Math.min(e.videoHeight, s / e.actualHeight * e.videoHeight)
|
|
794
|
+
);
|
|
795
|
+
return {
|
|
796
|
+
videoX: h,
|
|
797
|
+
videoY: f,
|
|
798
|
+
videoWidth: e.videoWidth,
|
|
799
|
+
videoHeight: e.videoHeight
|
|
800
|
+
};
|
|
801
|
+
}, qo = (e, o, n) => {
|
|
802
|
+
const r = o - e.videoRect.left - e.offsetX, i = n - e.videoRect.top - e.offsetY, d = Math.max(0, Math.min(e.actualWidth, r)), s = Math.max(0, Math.min(e.actualHeight, i)), h = Math.max(
|
|
803
|
+
0,
|
|
804
|
+
Math.min(e.videoWidth, d / e.actualWidth * e.videoWidth)
|
|
805
|
+
), f = Math.max(
|
|
806
|
+
0,
|
|
807
|
+
Math.min(e.videoHeight, s / e.actualHeight * e.videoHeight)
|
|
808
|
+
), A = e.videoWidth - h, k = e.videoHeight - f, g = e.videoRect.left + e.offsetX, ie = e.videoRect.top + e.offsetY, $ = g - e.containerRect.left + d, Q = ie - e.containerRect.top + s, de = g - e.containerRect.left + (e.actualWidth - d), O = ie - e.containerRect.top + (e.actualHeight - s);
|
|
809
|
+
return {
|
|
810
|
+
containerX: $,
|
|
811
|
+
containerY: Q,
|
|
812
|
+
mirrorContainerX: de,
|
|
813
|
+
mirrorContainerY: O,
|
|
814
|
+
videoX: h,
|
|
815
|
+
videoY: f,
|
|
816
|
+
mirrorVideoX: A,
|
|
817
|
+
mirrorVideoY: k,
|
|
818
|
+
videoWidth: e.videoWidth,
|
|
819
|
+
videoHeight: e.videoHeight
|
|
820
|
+
};
|
|
821
|
+
}, Zo = (e, o, n, r, i, d, s) => {
|
|
822
|
+
const h = En(e, o, n, r, i, d, s);
|
|
823
|
+
q("[rc-touch2] sendTwoFingerMessage (iOS)", {
|
|
824
|
+
actionName: kt(e),
|
|
825
|
+
video: { width: o, height: n },
|
|
826
|
+
p0: { x: r, y: i },
|
|
827
|
+
p1: { x: d, y: s },
|
|
828
|
+
byteLength: h.byteLength
|
|
829
|
+
}), ue(h);
|
|
830
|
+
}, je = (e, o, n, r, i, d, s, h, f) => {
|
|
831
|
+
if (q("[rc-touch2] applyTwoFingerEvent", {
|
|
832
|
+
platform: z,
|
|
833
|
+
eventType: e,
|
|
834
|
+
video: { width: o, height: n },
|
|
835
|
+
p0: { x: r, y: i, id: h },
|
|
836
|
+
p1: { x: d, y: s, id: f }
|
|
837
|
+
}), e === "down" && tt.current.end(), z === "ios") {
|
|
838
|
+
const A = e === "down" ? I.ACTION_DOWN : e === "move" ? I.ACTION_MOVE : I.ACTION_UP;
|
|
839
|
+
Zo(A, o, n, r, i, d, s);
|
|
840
|
+
} else
|
|
841
|
+
e === "down" ? (Fe(I.ACTION_DOWN, h, o, n, r, i), Fe(I.ACTION_POINTER_DOWN, f, o, n, d, s)) : e === "move" ? (Fe(I.ACTION_MOVE, h, o, n, r, i), Fe(I.ACTION_MOVE, f, o, n, d, s)) : (Fe(I.ACTION_POINTER_UP, f, o, n, d, s), Fe(I.ACTION_UP, h, o, n, r, i));
|
|
842
|
+
}, Jo = (e, o, n) => {
|
|
843
|
+
if (!Ee.current) {
|
|
844
|
+
Ne !== null && mt(null);
|
|
845
|
+
return;
|
|
846
|
+
}
|
|
847
|
+
const r = qo(e, o, n);
|
|
848
|
+
mt(r);
|
|
849
|
+
}, Qo = (e, o, n) => {
|
|
850
|
+
const r = ke.current;
|
|
851
|
+
if (!r || r.screen.width <= 0 || r.screen.height <= 0) return null;
|
|
852
|
+
const i = o - e.videoRect.left - e.offsetX, d = n - e.videoRect.top - e.offsetY;
|
|
853
|
+
if (i < 0 || d < 0 || i > e.actualWidth || d > e.actualHeight) return null;
|
|
854
|
+
const s = i / e.actualWidth * r.screen.width, h = d / e.actualHeight * r.screen.height;
|
|
855
|
+
return Rn(r, s, h);
|
|
856
|
+
}, en = (e) => ({
|
|
857
|
+
map: (o, n) => {
|
|
858
|
+
const r = we(e, o, n);
|
|
859
|
+
if (r)
|
|
860
|
+
return {
|
|
861
|
+
x: r.videoX,
|
|
862
|
+
y: r.videoY,
|
|
863
|
+
width: r.videoWidth,
|
|
864
|
+
height: r.videoHeight
|
|
865
|
+
};
|
|
866
|
+
},
|
|
867
|
+
// A finger on the frame, or a letterbox bar, is not on the guest's screen.
|
|
868
|
+
contains: (o, n) => {
|
|
869
|
+
const r = o - e.videoRect.left - e.offsetX, i = n - e.videoRect.top - e.offsetY;
|
|
870
|
+
return r >= 0 && r <= e.actualWidth && i >= 0 && i <= e.actualHeight;
|
|
871
|
+
},
|
|
872
|
+
scale: e.actualWidth > 0 ? e.videoWidth / e.actualWidth : 1
|
|
873
|
+
}), Ce = (e) => {
|
|
874
|
+
if (ne || ft.current) return;
|
|
875
|
+
e.preventDefault(), e.stopPropagation();
|
|
876
|
+
const o = Ve();
|
|
877
|
+
if ((C === !0 || C === "hover-only") && !("touches" in e))
|
|
878
|
+
if (e.type === "mousemove") {
|
|
879
|
+
if (lo({ x: e.clientX, y: e.clientY }), o) {
|
|
880
|
+
const r = Qo(o, e.clientX, e.clientY);
|
|
881
|
+
ot(r?.id ?? null);
|
|
882
|
+
}
|
|
883
|
+
} else e.type === "mouseleave" && (lo(null), ot(null));
|
|
884
|
+
if (C !== !0) {
|
|
885
|
+
if (z === "macos") {
|
|
886
|
+
if (!o || !R.current?.getState().controlReady) return;
|
|
887
|
+
if ("touches" in e) {
|
|
888
|
+
const s = Array.from(e.touches, (h) => ({ x: h.clientX, y: h.clientY }));
|
|
889
|
+
Pe.touch(e.type, s, en(o)) && H.current?.focus();
|
|
890
|
+
return;
|
|
891
|
+
}
|
|
892
|
+
const r = we(o, e.clientX, e.clientY);
|
|
893
|
+
if (!r) return;
|
|
894
|
+
const i = e.type === "mousedown" ? te.DOWN : e.type === "mouseup" ? te.UP : te.MOVE, d = e.type === "mouseleave" ? 0 : e.buttons;
|
|
895
|
+
e.type === "mousedown" && H.current?.focus(), Pe.pointer(
|
|
896
|
+
i,
|
|
897
|
+
{
|
|
898
|
+
x: r.videoX,
|
|
899
|
+
y: r.videoY,
|
|
900
|
+
width: r.videoWidth,
|
|
901
|
+
height: r.videoHeight
|
|
902
|
+
},
|
|
903
|
+
d
|
|
904
|
+
);
|
|
905
|
+
return;
|
|
906
|
+
}
|
|
907
|
+
if (!("touches" in e) && o && (e.type === "mousemove" ? Jo(o, e.clientX, e.clientY) : e.type === "mouseleave" && mt(null)), !(!R.current?.getState().controlReady || !H.current || !o))
|
|
908
|
+
if ("touches" in e) {
|
|
909
|
+
const r = e.touches, i = e.changedTouches;
|
|
910
|
+
let d;
|
|
911
|
+
switch (e.type) {
|
|
912
|
+
case "touchstart":
|
|
913
|
+
d = "down";
|
|
914
|
+
break;
|
|
915
|
+
case "touchmove":
|
|
916
|
+
d = "move";
|
|
917
|
+
break;
|
|
918
|
+
case "touchend":
|
|
919
|
+
d = "up";
|
|
920
|
+
break;
|
|
921
|
+
case "touchcancel":
|
|
922
|
+
d = "cancel";
|
|
923
|
+
break;
|
|
924
|
+
default:
|
|
925
|
+
return;
|
|
926
|
+
}
|
|
927
|
+
if (r.length === 2) {
|
|
928
|
+
const s = r[0], h = r[1], f = we(o, s.clientX, s.clientY), A = we(o, h.clientX, h.clientY);
|
|
929
|
+
if (!f || !A) return;
|
|
930
|
+
X.current ? X.current.source === "real-touch" && (X.current.finger0 = { x: f.videoX, y: f.videoY }, X.current.finger1 = { x: A.videoX, y: A.videoY }, je(
|
|
931
|
+
"move",
|
|
932
|
+
f.videoWidth,
|
|
933
|
+
f.videoHeight,
|
|
934
|
+
f.videoX,
|
|
935
|
+
f.videoY,
|
|
936
|
+
A.videoX,
|
|
937
|
+
A.videoY,
|
|
938
|
+
X.current.pointerId0,
|
|
939
|
+
X.current.pointerId1
|
|
940
|
+
)) : (X.current = {
|
|
941
|
+
finger0: { x: f.videoX, y: f.videoY },
|
|
942
|
+
finger1: { x: A.videoX, y: A.videoY },
|
|
943
|
+
videoSize: { width: f.videoWidth, height: f.videoHeight },
|
|
944
|
+
source: "real-touch",
|
|
945
|
+
pointerId0: s.identifier,
|
|
946
|
+
pointerId1: h.identifier
|
|
947
|
+
}, je(
|
|
948
|
+
"down",
|
|
949
|
+
f.videoWidth,
|
|
950
|
+
f.videoHeight,
|
|
951
|
+
f.videoX,
|
|
952
|
+
f.videoY,
|
|
953
|
+
A.videoX,
|
|
954
|
+
A.videoY,
|
|
955
|
+
s.identifier,
|
|
956
|
+
h.identifier
|
|
957
|
+
));
|
|
958
|
+
} else if (r.length < 2 && X.current?.source === "real-touch") {
|
|
959
|
+
const s = X.current;
|
|
960
|
+
je(
|
|
961
|
+
"up",
|
|
962
|
+
s.videoSize.width,
|
|
963
|
+
s.videoSize.height,
|
|
964
|
+
s.finger0.x,
|
|
965
|
+
s.finger0.y,
|
|
966
|
+
s.finger1.x,
|
|
967
|
+
s.finger1.y,
|
|
968
|
+
s.pointerId0,
|
|
969
|
+
s.pointerId1
|
|
970
|
+
), X.current = null;
|
|
971
|
+
return;
|
|
972
|
+
} else {
|
|
973
|
+
if (r.length > 2)
|
|
974
|
+
return;
|
|
975
|
+
{
|
|
976
|
+
const s = i[0];
|
|
977
|
+
if (s) {
|
|
978
|
+
const h = we(o, s.clientX, s.clientY);
|
|
979
|
+
De(s.identifier, d, h);
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
}
|
|
983
|
+
} else {
|
|
984
|
+
let i = null;
|
|
985
|
+
const d = X.current?.source === "alt-mouse";
|
|
986
|
+
switch (e.type) {
|
|
987
|
+
case "mousedown":
|
|
988
|
+
e.button === 0 && (i = "down");
|
|
989
|
+
break;
|
|
990
|
+
case "mousemove":
|
|
991
|
+
(d || V.current.has(-1)) && (i = "move");
|
|
992
|
+
break;
|
|
993
|
+
case "mouseup":
|
|
994
|
+
e.button === 0 && (i = "up");
|
|
995
|
+
break;
|
|
996
|
+
case "mouseleave":
|
|
997
|
+
(d || V.current.has(-1)) && (i = "up");
|
|
998
|
+
break;
|
|
999
|
+
}
|
|
1000
|
+
if (i) {
|
|
1001
|
+
const s = we(o, e.clientX, e.clientY);
|
|
1002
|
+
if (!s)
|
|
1003
|
+
return;
|
|
1004
|
+
q("[rc-touch][mouse] event", {
|
|
1005
|
+
domType: e.type,
|
|
1006
|
+
eventType: i,
|
|
1007
|
+
button: e.button,
|
|
1008
|
+
buttons: e.buttons,
|
|
1009
|
+
client: { x: e.clientX, y: e.clientY },
|
|
1010
|
+
altHeldRef: Ee.current,
|
|
1011
|
+
inTwoFingerMode: d,
|
|
1012
|
+
geometry: {
|
|
1013
|
+
videoX: s.videoX,
|
|
1014
|
+
videoY: s.videoY,
|
|
1015
|
+
videoWidth: s.videoWidth,
|
|
1016
|
+
videoHeight: s.videoHeight
|
|
1017
|
+
},
|
|
1018
|
+
activePointerIds: Array.from(V.current.keys())
|
|
1019
|
+
}), Ee.current || d ? tn(i, s) : De(-1, i, s);
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
1023
|
+
}, tn = (e, o) => {
|
|
1024
|
+
const { videoX: n, videoY: r, videoWidth: i, videoHeight: d } = o, s = i - n, h = d - r;
|
|
1025
|
+
if (e === "down") {
|
|
1026
|
+
X.current = {
|
|
1027
|
+
finger0: { x: n, y: r },
|
|
1028
|
+
finger1: { x: s, y: h },
|
|
1029
|
+
videoSize: { width: i, height: d },
|
|
1030
|
+
source: "alt-mouse",
|
|
1031
|
+
pointerId0: bt,
|
|
1032
|
+
pointerId1: wt
|
|
1033
|
+
}, H.current?.focus(), je(
|
|
1034
|
+
"down",
|
|
1035
|
+
i,
|
|
1036
|
+
d,
|
|
1037
|
+
n,
|
|
1038
|
+
r,
|
|
1039
|
+
s,
|
|
1040
|
+
h,
|
|
1041
|
+
bt,
|
|
1042
|
+
wt
|
|
1043
|
+
);
|
|
1044
|
+
return;
|
|
1045
|
+
}
|
|
1046
|
+
if (e === "move") {
|
|
1047
|
+
X.current?.source === "alt-mouse" && (X.current.finger0 = { x: n, y: r }, X.current.finger1 = { x: s, y: h }, je(
|
|
1048
|
+
"move",
|
|
1049
|
+
i,
|
|
1050
|
+
d,
|
|
1051
|
+
n,
|
|
1052
|
+
r,
|
|
1053
|
+
s,
|
|
1054
|
+
h,
|
|
1055
|
+
bt,
|
|
1056
|
+
wt
|
|
1057
|
+
));
|
|
1058
|
+
return;
|
|
1059
|
+
}
|
|
1060
|
+
if (e === "up" || e === "cancel") {
|
|
1061
|
+
const f = X.current;
|
|
1062
|
+
if (f?.source === "alt-mouse") {
|
|
1063
|
+
const { finger0: A, finger1: k, videoSize: g } = f;
|
|
1064
|
+
je(
|
|
1065
|
+
"up",
|
|
1066
|
+
g.width,
|
|
1067
|
+
g.height,
|
|
1068
|
+
A.x,
|
|
1069
|
+
A.y,
|
|
1070
|
+
k.x,
|
|
1071
|
+
k.y,
|
|
1072
|
+
bt,
|
|
1073
|
+
wt
|
|
1074
|
+
), X.current = null;
|
|
1075
|
+
}
|
|
1076
|
+
return;
|
|
1077
|
+
}
|
|
1078
|
+
}, on = 150, bo = () => {
|
|
1079
|
+
const e = Ke.current;
|
|
1080
|
+
e && (window.clearTimeout(e.endTimer), De(He, "up", e.pos), Ke.current = null);
|
|
1081
|
+
}, nn = (e) => {
|
|
1082
|
+
if (!R.current?.getState().controlReady || e.ctrlKey) return;
|
|
1083
|
+
if (z === "macos") {
|
|
1084
|
+
if (ft.current) return;
|
|
1085
|
+
const O = Ve();
|
|
1086
|
+
if (!O) return;
|
|
1087
|
+
const We = e.clientX - O.videoRect.left - O.offsetX, Me = e.clientY - O.videoRect.top - O.offsetY;
|
|
1088
|
+
if (We < 0 || We > O.actualWidth || Me < 0 || Me > O.actualHeight)
|
|
1089
|
+
return;
|
|
1090
|
+
const ve = we(O, e.clientX, e.clientY);
|
|
1091
|
+
if (!ve) return;
|
|
1092
|
+
e.preventDefault();
|
|
1093
|
+
const qe = e.deltaMode === WheelEvent.DOM_DELTA_LINE ? 16 : e.deltaMode === WheelEvent.DOM_DELTA_PAGE ? O.actualHeight : 1;
|
|
1094
|
+
Pe.scroll(
|
|
1095
|
+
{ x: ve.videoX, y: ve.videoY, width: ve.videoWidth, height: ve.videoHeight },
|
|
1096
|
+
e.deltaX * qe,
|
|
1097
|
+
e.deltaY * qe
|
|
1098
|
+
);
|
|
1099
|
+
return;
|
|
1100
|
+
}
|
|
1101
|
+
if (Ee.current || X.current) return;
|
|
1102
|
+
const o = V.current.size;
|
|
1103
|
+
if (o > 1 || o === 1 && !V.current.has(He)) return;
|
|
1104
|
+
const n = Ve();
|
|
1105
|
+
if (!n) return;
|
|
1106
|
+
const r = e.clientX - n.videoRect.left - n.offsetX, i = e.clientY - n.videoRect.top - n.offsetY;
|
|
1107
|
+
if (r < 0 || r > n.actualWidth || i < 0 || i > n.actualHeight)
|
|
1108
|
+
return;
|
|
1109
|
+
const d = we(n, e.clientX, e.clientY);
|
|
1110
|
+
if (!d) return;
|
|
1111
|
+
e.preventDefault();
|
|
1112
|
+
const s = (e.deltaMode === 1 ? 16 : e.deltaMode === 2 ? n.actualWidth : 1) * (n.videoWidth / n.actualWidth), h = (e.deltaMode === 1 ? 16 : e.deltaMode === 2 ? n.actualHeight : 1) * (n.videoHeight / n.actualHeight), f = -e.deltaX * s, A = -e.deltaY * h, k = (O) => {
|
|
1113
|
+
window.clearTimeout(O.endTimer), O.endTimer = window.setTimeout(bo, on);
|
|
1114
|
+
};
|
|
1115
|
+
if (f === 0 && A === 0) {
|
|
1116
|
+
Ke.current && k(Ke.current);
|
|
1117
|
+
return;
|
|
1118
|
+
}
|
|
1119
|
+
const g = () => ({
|
|
1120
|
+
videoWidth: d.videoWidth,
|
|
1121
|
+
videoHeight: d.videoHeight,
|
|
1122
|
+
videoX: Math.abs(f) > Math.abs(A) ? Math.min(Math.max(d.videoX, d.videoWidth * 0.2), d.videoWidth * 0.8) : d.videoX,
|
|
1123
|
+
videoY: Math.abs(A) >= Math.abs(f) ? Math.min(Math.max(d.videoY, d.videoHeight * 0.2), d.videoHeight * 0.8) : d.videoY
|
|
1124
|
+
}), ie = (O) => ({
|
|
1125
|
+
...O,
|
|
1126
|
+
videoX: Math.min(Math.max(O.videoX + f, 0), O.videoWidth),
|
|
1127
|
+
videoY: Math.min(Math.max(O.videoY + A, 0), O.videoHeight)
|
|
1128
|
+
});
|
|
1129
|
+
let $ = Ke.current;
|
|
1130
|
+
if ($)
|
|
1131
|
+
window.clearTimeout($.endTimer);
|
|
1132
|
+
else {
|
|
1133
|
+
const O = g();
|
|
1134
|
+
De(He, "down", O), $ = { pos: O, endTimer: 0 }, Ke.current = $;
|
|
1135
|
+
}
|
|
1136
|
+
let Q = $.pos, de = ie(Q);
|
|
1137
|
+
de.videoX === Q.videoX && de.videoY === Q.videoY && (De(He, "up", Q), Q = g(), De(He, "down", Q), de = ie(Q)), De(He, "move", de), $.pos = de, k($);
|
|
1138
|
+
};
|
|
1139
|
+
ee(() => {
|
|
1140
|
+
tt.current = { handle: nn, end: bo };
|
|
1141
|
+
}), ee(() => {
|
|
1142
|
+
const e = ge.current;
|
|
1143
|
+
if (!e) return;
|
|
1144
|
+
const o = (n) => tt.current.handle(n);
|
|
1145
|
+
return e.addEventListener("wheel", o, { passive: !1 }), () => {
|
|
1146
|
+
tt.current.end(), e.removeEventListener("wheel", o);
|
|
1147
|
+
};
|
|
1148
|
+
}, []), ee(() => {
|
|
1149
|
+
const e = (i) => {
|
|
1150
|
+
i.key === "Alt" && $t(!0);
|
|
1151
|
+
}, o = (i) => {
|
|
1152
|
+
i.key === "Alt" && $t(!1);
|
|
1153
|
+
}, n = () => {
|
|
1154
|
+
$t(!1), rt();
|
|
1155
|
+
}, r = () => {
|
|
1156
|
+
document.hidden && rt();
|
|
1157
|
+
};
|
|
1158
|
+
return window.addEventListener("keydown", e, !0), window.addEventListener("keyup", o, !0), window.addEventListener("blur", n), document.addEventListener("visibilitychange", r), () => {
|
|
1159
|
+
window.removeEventListener("keydown", e, !0), window.removeEventListener("keyup", o, !0), window.removeEventListener("blur", n), document.removeEventListener("visibilitychange", r);
|
|
1160
|
+
};
|
|
1161
|
+
}, [rt]);
|
|
1162
|
+
const Ge = (e) => {
|
|
1163
|
+
e.preventDefault(), e.stopPropagation();
|
|
1164
|
+
const o = document.activeElement === H.current || (ne || ft.current) && document.activeElement === e.currentTarget;
|
|
1165
|
+
if (q("Keyboard event:", {
|
|
1166
|
+
type: e.type,
|
|
1167
|
+
key: e.key,
|
|
1168
|
+
keyCode: e.keyCode,
|
|
1169
|
+
code: e.code,
|
|
1170
|
+
target: e.target.tagName,
|
|
1171
|
+
focused: o
|
|
1172
|
+
}), !o) {
|
|
1173
|
+
zt("Simulator input not focused, skipping keyboard event");
|
|
1174
|
+
return;
|
|
1175
|
+
}
|
|
1176
|
+
if (!R.current?.getState().controlReady) {
|
|
1177
|
+
zt("Data channel not ready for keyboard event:", R.current?.getState().connection);
|
|
1178
|
+
return;
|
|
1179
|
+
}
|
|
1180
|
+
if (z === "macos") {
|
|
1181
|
+
if (e.type === "keydown" && e.repeat) return;
|
|
1182
|
+
const r = Tn(e.code);
|
|
1183
|
+
if (r === void 0) {
|
|
1184
|
+
q(`Ignoring unmapped key for macOS: code=${e.code}`);
|
|
1185
|
+
return;
|
|
1186
|
+
}
|
|
1187
|
+
e.type === "keydown" ? yt.current.add(r) : yt.current.delete(r), ue(
|
|
1188
|
+
To(
|
|
1189
|
+
e.type === "keydown" ? te.DOWN : te.UP,
|
|
1190
|
+
r
|
|
1191
|
+
)
|
|
1192
|
+
);
|
|
1193
|
+
return;
|
|
1194
|
+
}
|
|
1195
|
+
if (e.type === "keydown") {
|
|
1196
|
+
if (e.key.toLowerCase() === "v" && (e.metaKey || e.ctrlKey)) {
|
|
1197
|
+
q("Paste shortcut detected"), navigator.clipboard.readText().then((r) => {
|
|
1198
|
+
if (r) {
|
|
1199
|
+
q(
|
|
1200
|
+
"Pasting text via SET_CLIPBOARD:",
|
|
1201
|
+
r.substring(0, 20) + (r.length > 20 ? "..." : "")
|
|
1202
|
+
);
|
|
1203
|
+
const i = Cn(r, !0);
|
|
1204
|
+
ue(i);
|
|
1205
|
+
}
|
|
1206
|
+
}).catch((r) => {
|
|
1207
|
+
console.error("Failed to read clipboard contents: ", r);
|
|
1208
|
+
});
|
|
1209
|
+
return;
|
|
1210
|
+
}
|
|
1211
|
+
if (e.key.toLowerCase() === "m" && (e.metaKey || e.ctrlKey)) {
|
|
1212
|
+
q("Menu shortcut detected");
|
|
1213
|
+
const r = Et(
|
|
1214
|
+
B.ACTION_DOWN,
|
|
1215
|
+
B.MENU,
|
|
1216
|
+
0,
|
|
1217
|
+
B.META_NONE
|
|
1218
|
+
// Modifiers are handled by the shortcut check, not passed down
|
|
1219
|
+
);
|
|
1220
|
+
ue(r);
|
|
1221
|
+
const i = Et(
|
|
1222
|
+
B.ACTION_UP,
|
|
1223
|
+
B.MENU,
|
|
1224
|
+
0,
|
|
1225
|
+
B.META_NONE
|
|
1226
|
+
);
|
|
1227
|
+
ue(i);
|
|
1228
|
+
return;
|
|
1229
|
+
}
|
|
1230
|
+
}
|
|
1231
|
+
const n = ni(e);
|
|
1232
|
+
if (n) {
|
|
1233
|
+
const { keycode: r, metaState: i } = n, d = e.type === "keydown" ? B.ACTION_DOWN : B.ACTION_UP;
|
|
1234
|
+
q(`Sending Keycode: key=${e.key}, code=${r}, action=${d}, meta=${i}`);
|
|
1235
|
+
const s = Et(
|
|
1236
|
+
d,
|
|
1237
|
+
r,
|
|
1238
|
+
0,
|
|
1239
|
+
// repeat count, typically 0 for single presses
|
|
1240
|
+
i
|
|
1241
|
+
);
|
|
1242
|
+
ue(s);
|
|
1243
|
+
} else
|
|
1244
|
+
q(`Ignoring unhandled key event: type=${e.type}, key=${e.key}`);
|
|
1245
|
+
}, rn = (e) => {
|
|
1246
|
+
e.stopPropagation(), R.current?.reconnect();
|
|
1247
|
+
}, G = x({
|
|
1248
|
+
onSpeakerBlocked: me,
|
|
1249
|
+
onAxSnapshotChange: se,
|
|
1250
|
+
onAxStatusChange: S,
|
|
1251
|
+
onCameraDemandChange: W,
|
|
1252
|
+
onCameraStats: P,
|
|
1253
|
+
onMicrophoneStateChange: ae,
|
|
1254
|
+
onTrace: Y,
|
|
1255
|
+
onTerminated: ce,
|
|
1256
|
+
onConnectionStateChange: fe,
|
|
1257
|
+
onPlaybackStats: K
|
|
1258
|
+
});
|
|
1259
|
+
G.current = {
|
|
1260
|
+
onSpeakerBlocked: me,
|
|
1261
|
+
onAxSnapshotChange: se,
|
|
1262
|
+
onAxStatusChange: S,
|
|
1263
|
+
onCameraDemandChange: W,
|
|
1264
|
+
onCameraStats: P,
|
|
1265
|
+
onMicrophoneStateChange: ae,
|
|
1266
|
+
onTrace: Y,
|
|
1267
|
+
onTerminated: ce,
|
|
1268
|
+
onConnectionStateChange: fe,
|
|
1269
|
+
onPlaybackStats: K
|
|
1270
|
+
};
|
|
1271
|
+
const Bt = !!Y;
|
|
1272
|
+
ee(() => {
|
|
1273
|
+
Ht.current = null, Zt(!1), Qt(!1), eo({}), oo(null);
|
|
1274
|
+
}, [t, dt]), ee(() => {
|
|
1275
|
+
let e = !0;
|
|
1276
|
+
ke.current !== null && (ke.current = null, Dt(null), Xe("onAxSnapshotChange", G.current.onAxSnapshotChange, null));
|
|
1277
|
+
const o = bn({
|
|
1278
|
+
url: t,
|
|
1279
|
+
token: c,
|
|
1280
|
+
sessionId: Vo,
|
|
1281
|
+
watchOnly: F,
|
|
1282
|
+
deviceModel: dt,
|
|
1283
|
+
autoReconnect: E,
|
|
1284
|
+
jitterBufferTargetMs: L,
|
|
1285
|
+
openUrl: p,
|
|
1286
|
+
inspectMode: C,
|
|
1287
|
+
axPollIntervalMs: u,
|
|
1288
|
+
axMaxBackoffMs: y,
|
|
1289
|
+
androidElementTreeOptions: M,
|
|
1290
|
+
microphoneEnabled: Z,
|
|
1291
|
+
speakerMuted: U,
|
|
1292
|
+
onStateChange: (i) => {
|
|
1293
|
+
(i.videoReady || i.connection === "idle" || i.connection === "connecting" || i.connection === "reconnecting") && xo(i.videoReady), Ho(i.connection === "failed"), Wo(i.connection === "terminated"), lt(i.duo), _o(i.duoState), So(i.duoError);
|
|
1294
|
+
},
|
|
1295
|
+
onAxSnapshotChange: (i) => {
|
|
1296
|
+
e && (Dt((d) => An(d, i) ? d : i), G.current.onAxSnapshotChange?.(i));
|
|
1297
|
+
},
|
|
1298
|
+
onAxStatusChange: (...i) => G.current.onAxStatusChange?.(...i),
|
|
1299
|
+
onCameraDemandChange: (...i) => G.current.onCameraDemandChange?.(...i),
|
|
1300
|
+
onCameraStats: P ? (...i) => G.current.onCameraStats?.(...i) : void 0,
|
|
1301
|
+
onMicrophoneStateChange: (...i) => G.current.onMicrophoneStateChange?.(...i),
|
|
1302
|
+
onSpeakerBlocked: () => G.current.onSpeakerBlocked?.(),
|
|
1303
|
+
onTrace: Bt ? (...i) => G.current.onTrace?.(...i) : void 0,
|
|
1304
|
+
onTerminated: () => G.current.onTerminated?.(),
|
|
1305
|
+
onConnectionStateChange: (...i) => G.current.onConnectionStateChange?.(...i),
|
|
1306
|
+
onPlaybackStats: K ? (...i) => G.current.onPlaybackStats?.(...i) : void 0
|
|
1307
|
+
});
|
|
1308
|
+
R.current = o;
|
|
1309
|
+
const n = H.current ? o.attachVideo(H.current) : void 0, r = ht.current ? o.attachAudio(ht.current) : void 0;
|
|
1310
|
+
return o.start(), () => {
|
|
1311
|
+
e = !1, o.dispose(), n?.(), r?.(), R.current = null;
|
|
1312
|
+
};
|
|
1313
|
+
}, [t, l, dt, Bt, F]), _n(() => {
|
|
1314
|
+
R.current?.updateOptions({ speakerMuted: U });
|
|
1315
|
+
const e = ht.current;
|
|
1316
|
+
e && (wn(e), e.muted = U, !U && e.srcObject && Mn(e, () => Xe("onSpeakerBlocked", G.current.onSpeakerBlocked)));
|
|
1317
|
+
}, [U]), ee(() => {
|
|
1318
|
+
if (ne && ut.current)
|
|
1319
|
+
return R.current?.attachVideo(ut.current, "inner");
|
|
1320
|
+
}, [ne, t, l, dt, Bt, F]), ee(() => {
|
|
1321
|
+
R.current?.updateOptions({
|
|
1322
|
+
token: c,
|
|
1323
|
+
openUrl: p,
|
|
1324
|
+
axPollIntervalMs: u,
|
|
1325
|
+
axMaxBackoffMs: y,
|
|
1326
|
+
androidElementTreeOptions: M,
|
|
1327
|
+
autoReconnect: E,
|
|
1328
|
+
jitterBufferTargetMs: L,
|
|
1329
|
+
microphoneEnabled: Z,
|
|
1330
|
+
inspectMode: C,
|
|
1331
|
+
onPlaybackStats: K ? (...e) => G.current.onPlaybackStats?.(...e) : void 0,
|
|
1332
|
+
onCameraStats: P ? (...e) => G.current.onCameraStats?.(...e) : void 0
|
|
1333
|
+
});
|
|
1334
|
+
}, [
|
|
1335
|
+
c,
|
|
1336
|
+
E,
|
|
1337
|
+
L,
|
|
1338
|
+
Z,
|
|
1339
|
+
C,
|
|
1340
|
+
!!K,
|
|
1341
|
+
!!P,
|
|
1342
|
+
p,
|
|
1343
|
+
u,
|
|
1344
|
+
y,
|
|
1345
|
+
M
|
|
1346
|
+
]);
|
|
1347
|
+
const ct = () => {
|
|
1348
|
+
if (!uo.current) return;
|
|
1349
|
+
const e = Ve();
|
|
1350
|
+
if (!e) {
|
|
1351
|
+
so(null);
|
|
1352
|
+
return;
|
|
1353
|
+
}
|
|
1354
|
+
const o = {
|
|
1355
|
+
left: e.videoRect.left - e.containerRect.left + e.offsetX,
|
|
1356
|
+
top: e.videoRect.top - e.containerRect.top + e.offsetY,
|
|
1357
|
+
width: e.actualWidth,
|
|
1358
|
+
height: e.actualHeight
|
|
1359
|
+
};
|
|
1360
|
+
so(
|
|
1361
|
+
(n) => n && n.left === o.left && n.top === o.top && n.width === o.width && n.height === o.height ? n : o
|
|
1362
|
+
);
|
|
1363
|
+
};
|
|
1364
|
+
ee(() => {
|
|
1365
|
+
const e = H.current, o = J.current, n = ge.current;
|
|
1366
|
+
if (!e) return;
|
|
1367
|
+
const r = (k) => eo((g) => St(g, k) ? g : k), i = (k) => oo((g) => g && k && St(g, k) ? g : k), d = (k) => Yo((g) => g && k && St(g, k) ? g : k), s = () => {
|
|
1368
|
+
const k = e.videoWidth > 0 && e.videoHeight > 0;
|
|
1369
|
+
k && (Ht.current = { width: e.videoWidth, height: e.videoHeight });
|
|
1370
|
+
const g = Ht.current, ie = g ? `${g.width} / ${g.height}` : void 0, $ = Yt.current;
|
|
1371
|
+
if (Ie && n) {
|
|
1372
|
+
if (ro(g ? g.width / g.height : Ut), !$?.naturalWidth) return;
|
|
1373
|
+
const Le = $.naturalWidth / $.naturalHeight, Mt = n.clientHeight - _t, Ye = n.clientHeight > 0 ? Math.min(n.clientWidth, Mt * Le) : n.clientWidth;
|
|
1374
|
+
if (Ye <= 0) return;
|
|
1375
|
+
const Ze = Ye / Le, Re = n.clientHeight > 0 ? _t / 2 : 0, { screen: he } = Ie, At = he.notch ?? 0, Je = he.left * Ye, Qe = he.top * Ze, Tt = he.width * Ye, Ct = he.height * Ze, Mo = g ? g.width / g.height : Ut, Rt = Math.min(Tt, Ct * Mo), Kt = Rt / Mo, an = Je + (Tt - Rt) / 2, ln = At > 0 ? Qe : Qe + (Ct - Kt) / 2, Ao = (st, Ot, dn, un) => `translate(calc(-50% + ${st + dn / 2 - Ye / 2}px), calc(-50% + ${Ot + un / 2 - Ze / 2 + Re}px))`;
|
|
1376
|
+
r({
|
|
1377
|
+
width: `${Rt}px`,
|
|
1378
|
+
height: `${Kt}px`,
|
|
1379
|
+
transform: Ao(an, ln, Rt, Kt)
|
|
1380
|
+
}), Xo((st) => {
|
|
1381
|
+
const Ot = {
|
|
1382
|
+
width: `${Tt}px`,
|
|
1383
|
+
height: `${Ct}px`,
|
|
1384
|
+
transform: Ao(Je, Qe, Tt, Ct)
|
|
1385
|
+
};
|
|
1386
|
+
return st && St(st, Ot) ? st : Ot;
|
|
1387
|
+
}), d({
|
|
1388
|
+
width: `${Ye}px`,
|
|
1389
|
+
height: `${Ze}px`,
|
|
1390
|
+
transform: Re ? `translateY(${Re}px)` : void 0
|
|
1391
|
+
}), i(null), ct();
|
|
1392
|
+
return;
|
|
1393
|
+
}
|
|
1394
|
+
if (ye && n) {
|
|
1395
|
+
const Le = g ? g.width / g.height : Ut, Mt = n.clientWidth * 100 / at, Ze = (n.clientHeight - _t) / (1 / Le + Vt / 100), Re = n.clientHeight > 0 ? Math.min(Mt, Ze) : Mt;
|
|
1396
|
+
if (Re <= 0) return;
|
|
1397
|
+
const he = Re / 100, At = Re / Le, Je = n.clientHeight > 0 ? _t / 2 : 0, Qe = `${he * re.screenRadius}px`;
|
|
1398
|
+
r({
|
|
1399
|
+
aspectRatio: `${Le}`,
|
|
1400
|
+
width: `${Re}px`,
|
|
1401
|
+
height: `${At}px`,
|
|
1402
|
+
borderRadius: `${Qe} ${Qe} 0 0`,
|
|
1403
|
+
transform: `translate(-50%, calc(-50% - ${he * xn - Je}px))`
|
|
1404
|
+
}), d({
|
|
1405
|
+
width: `${he * at}px`,
|
|
1406
|
+
height: `${At + he * Vt}px`,
|
|
1407
|
+
transform: Je ? `translateY(${Je}px)` : void 0,
|
|
1408
|
+
"--rc-macbook-unit": `${he}px`
|
|
1409
|
+
}), ro(Le), i(null), ct();
|
|
1410
|
+
return;
|
|
1411
|
+
}
|
|
1412
|
+
if (d(null), !it || !o) {
|
|
1413
|
+
r(
|
|
1414
|
+
!k && g ? {
|
|
1415
|
+
aspectRatio: ie,
|
|
1416
|
+
contain: "size",
|
|
1417
|
+
containIntrinsicSize: `${g.width}px ${g.height}px`
|
|
1418
|
+
} : {}
|
|
1419
|
+
), i(null), ct();
|
|
1420
|
+
return;
|
|
1421
|
+
}
|
|
1422
|
+
const Q = o.clientWidth, de = o.clientHeight;
|
|
1423
|
+
if (Q === 0 || de === 0) return;
|
|
1424
|
+
const O = g ? g.width > g.height : !1;
|
|
1425
|
+
Zt(O), Qt(
|
|
1426
|
+
z === "android" && !!g && Qn(g.width, g.height)
|
|
1427
|
+
);
|
|
1428
|
+
const We = O ? Se.videoPosition.landscape : Se.videoPosition.portrait;
|
|
1429
|
+
let Me = { aspectRatio: ie };
|
|
1430
|
+
We.heightMultiplier ? (Me.height = `${de * We.heightMultiplier}px`, Me.width = "auto") : We.widthMultiplier && (Me.width = `${Q * We.widthMultiplier}px`, Me.height = "auto"), Me.borderRadius = `${O ? de * Se.videoBorderRadiusMultiplier : Q * Se.videoBorderRadiusMultiplier}px`, r(Me);
|
|
1431
|
+
const ve = Se.homeButton, qe = O ? Q : de, wo = `calc(50% + ${qe * (ve?.offset ?? 0)}px)`;
|
|
1432
|
+
i(
|
|
1433
|
+
ve ? {
|
|
1434
|
+
width: `${qe * ve.diameter}px`,
|
|
1435
|
+
height: `${qe * ve.diameter}px`,
|
|
1436
|
+
left: O ? wo : "50%",
|
|
1437
|
+
top: O ? "50%" : wo
|
|
1438
|
+
} : null
|
|
1439
|
+
), ct();
|
|
1440
|
+
}, h = new ResizeObserver(() => {
|
|
1441
|
+
s();
|
|
1442
|
+
});
|
|
1443
|
+
o && h.observe(o), h.observe(e), n && h.observe(n), o && o.addEventListener("load", s);
|
|
1444
|
+
const f = Yt.current;
|
|
1445
|
+
f?.addEventListener("load", s), e.addEventListener("loadedmetadata", s), e.addEventListener("resize", s);
|
|
1446
|
+
const A = () => R.current?.bumpActivity();
|
|
1447
|
+
return e.addEventListener("resize", A), s(), () => {
|
|
1448
|
+
h.disconnect(), e.removeEventListener("loadedmetadata", s), e.removeEventListener("resize", s), e.removeEventListener("resize", A), o && o.removeEventListener("load", s), f?.removeEventListener("load", s);
|
|
1449
|
+
};
|
|
1450
|
+
}, [Se, it, ye, Ie?.src, xe, t, T]), ee(() => {
|
|
1451
|
+
_e ? ct() : (Dt(null), ot(null), pt(null), ao(null), Ue(null), gt.current = null, be.current !== void 0 && (window.cancelAnimationFrame(be.current), be.current = void 0));
|
|
1452
|
+
}, [_e]), ee(() => () => {
|
|
1453
|
+
be.current !== void 0 && (window.cancelAnimationFrame(be.current), be.current = void 0);
|
|
1454
|
+
}, []), ee(() => {
|
|
1455
|
+
if (!_e) return;
|
|
1456
|
+
const e = (o) => {
|
|
1457
|
+
o.key === "Escape" && (Lt || Wt) && (pt(null), ot(null), Ue(null), Xe("onInspectSelectionChange", ze.current, null));
|
|
1458
|
+
};
|
|
1459
|
+
return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
|
|
1460
|
+
}, [_e, Lt, Wt]);
|
|
1461
|
+
const cn = () => {
|
|
1462
|
+
H.current && H.current.focus();
|
|
1463
|
+
};
|
|
1464
|
+
Sn(Te, () => ({
|
|
1465
|
+
openUrl: (e) => R.current?.openUrl(e),
|
|
1466
|
+
sendKeyEvent: (e) => R.current?.sendKeyEvent(e),
|
|
1467
|
+
screenshot: (e) => R.current?.screenshot(e) ?? Promise.reject(new Error("Simulator disconnected")),
|
|
1468
|
+
terminateApp: (e) => R.current?.terminateApp(e) ?? Promise.reject(new Error("Simulator disconnected")),
|
|
1469
|
+
reconnect: () => R.current?.reconnect(),
|
|
1470
|
+
refreshAxTree: () => R.current?.refreshAxTree() ?? Promise.reject(new Error("Simulator disconnected")),
|
|
1471
|
+
getAxSnapshot: () => R.current?.getAxSnapshot() ?? null,
|
|
1472
|
+
setInspectHighlight: (e) => {
|
|
1473
|
+
ot(e?.id ?? null);
|
|
1474
|
+
},
|
|
1475
|
+
setInspectSelection: (e) => {
|
|
1476
|
+
pt(e?.id ?? null), Ue(e ? gt.current : null);
|
|
1477
|
+
const o = ke.current;
|
|
1478
|
+
e && o ? Xe("onInspectSelectionChange", ze.current, { element: e, snapshot: o }) : Xe("onInspectSelectionChange", ze.current, null);
|
|
1479
|
+
},
|
|
1480
|
+
getAxStatus: () => R.current?.getAxStatus() ?? "idle"
|
|
1481
|
+
}));
|
|
1482
|
+
const sn = $o && Ne !== null;
|
|
1483
|
+
return /* @__PURE__ */ oe(
|
|
1484
|
+
"div",
|
|
1485
|
+
{
|
|
1486
|
+
ref: ge,
|
|
1487
|
+
className: ["rc-container", a].filter(Boolean).join(" "),
|
|
1488
|
+
style: { touchAction: "none" },
|
|
1489
|
+
onMouseDown: Ce,
|
|
1490
|
+
onMouseMove: Ce,
|
|
1491
|
+
onMouseUp: Ce,
|
|
1492
|
+
onMouseLeave: Ce,
|
|
1493
|
+
onTouchStart: Ce,
|
|
1494
|
+
onTouchMove: Ce,
|
|
1495
|
+
onTouchEnd: Ce,
|
|
1496
|
+
onTouchCancel: Ce,
|
|
1497
|
+
onContextMenu: z === "macos" ? (e) => e.preventDefault() : void 0,
|
|
1498
|
+
children: [
|
|
1499
|
+
sn && Ne && /* @__PURE__ */ oe(Eo, { children: [
|
|
1500
|
+
/* @__PURE__ */ b(
|
|
1501
|
+
"div",
|
|
1502
|
+
{
|
|
1503
|
+
className: "rc-touch-indicator",
|
|
1504
|
+
style: {
|
|
1505
|
+
left: `${Ne.containerX}px`,
|
|
1506
|
+
top: `${Ne.containerY}px`
|
|
1507
|
+
}
|
|
1508
|
+
}
|
|
1509
|
+
),
|
|
1510
|
+
/* @__PURE__ */ b(
|
|
1511
|
+
"div",
|
|
1512
|
+
{
|
|
1513
|
+
className: "rc-touch-indicator",
|
|
1514
|
+
style: {
|
|
1515
|
+
left: `${Ne.mirrorContainerX}px`,
|
|
1516
|
+
top: `${Ne.mirrorContainerY}px`
|
|
1517
|
+
}
|
|
1518
|
+
}
|
|
1519
|
+
)
|
|
1520
|
+
] }),
|
|
1521
|
+
it && /* @__PURE__ */ b(
|
|
1522
|
+
"img",
|
|
1523
|
+
{
|
|
1524
|
+
ref: J,
|
|
1525
|
+
src: fo,
|
|
1526
|
+
alt: "",
|
|
1527
|
+
className: z === "ios" ? "rc-phone-frame rc-phone-frame-ios" : "rc-phone-frame",
|
|
1528
|
+
draggable: !1
|
|
1529
|
+
}
|
|
1530
|
+
),
|
|
1531
|
+
Ie && !xe && no && /* @__PURE__ */ b("div", { className: "rc-macbook-screen", style: no, "aria-hidden": "true" }),
|
|
1532
|
+
Ie && !xe && /* @__PURE__ */ b(
|
|
1533
|
+
"img",
|
|
1534
|
+
{
|
|
1535
|
+
ref: Yt,
|
|
1536
|
+
src: Ie.src,
|
|
1537
|
+
alt: "",
|
|
1538
|
+
className: "rc-macbook-image",
|
|
1539
|
+
style: Pt ?? { visibility: "hidden" },
|
|
1540
|
+
draggable: !1
|
|
1541
|
+
}
|
|
1542
|
+
),
|
|
1543
|
+
ye && !Ie && Pt && !xe && /* @__PURE__ */ oe("div", { className: "rc-macbook", style: Pt, "aria-hidden": "true", children: [
|
|
1544
|
+
/* @__PURE__ */ b("div", { className: "rc-macbook-lid", children: /* @__PURE__ */ b("div", { className: "rc-macbook-camera" }) }),
|
|
1545
|
+
/* @__PURE__ */ b("div", { className: "rc-macbook-base" })
|
|
1546
|
+
] }),
|
|
1547
|
+
it && to && !F && /* @__PURE__ */ b(
|
|
1548
|
+
"button",
|
|
1549
|
+
{
|
|
1550
|
+
type: "button",
|
|
1551
|
+
className: "rc-home-button",
|
|
1552
|
+
"aria-label": "Home",
|
|
1553
|
+
title: "Home",
|
|
1554
|
+
style: to,
|
|
1555
|
+
onMouseDown: (e) => e.stopPropagation(),
|
|
1556
|
+
onTouchStart: (e) => e.stopPropagation(),
|
|
1557
|
+
onTouchEnd: (e) => {
|
|
1558
|
+
e.stopPropagation(), e.preventDefault(), R.current?.pressButton("home");
|
|
1559
|
+
},
|
|
1560
|
+
onClick: (e) => {
|
|
1561
|
+
e.stopPropagation(), R.current?.pressButton("home");
|
|
1562
|
+
}
|
|
1563
|
+
}
|
|
1564
|
+
),
|
|
1565
|
+
/* @__PURE__ */ b(
|
|
1566
|
+
"video",
|
|
1567
|
+
{
|
|
1568
|
+
ref: H,
|
|
1569
|
+
className: [
|
|
1570
|
+
"rc-video",
|
|
1571
|
+
!it && !ye && "rc-video-frameless",
|
|
1572
|
+
!Io && (z === "macos" ? "rc-video-loading-desktop" : "rc-video-loading")
|
|
1573
|
+
].filter(Boolean).join(" "),
|
|
1574
|
+
style: {
|
|
1575
|
+
...Lo,
|
|
1576
|
+
...ne || xe ? { opacity: 0, width: 1, height: 1, pointerEvents: "none" } : {},
|
|
1577
|
+
...mo ? {
|
|
1578
|
+
backgroundImage: `url("${mo}")`,
|
|
1579
|
+
backgroundRepeat: "no-repeat",
|
|
1580
|
+
backgroundPosition: "center",
|
|
1581
|
+
backgroundSize: Se.loadingLogoSize
|
|
1582
|
+
} : {}
|
|
1583
|
+
},
|
|
1584
|
+
autoPlay: !0,
|
|
1585
|
+
playsInline: !0,
|
|
1586
|
+
muted: !0,
|
|
1587
|
+
tabIndex: ne || xe ? -1 : 0,
|
|
1588
|
+
onKeyDown: Ge,
|
|
1589
|
+
onKeyUp: Ge,
|
|
1590
|
+
onClick: cn,
|
|
1591
|
+
onFocus: () => {
|
|
1592
|
+
H.current && (H.current.style.outline = "none");
|
|
1593
|
+
},
|
|
1594
|
+
onBlur: () => {
|
|
1595
|
+
H.current && (H.current.style.outline = "none"), rt();
|
|
1596
|
+
}
|
|
1597
|
+
}
|
|
1598
|
+
),
|
|
1599
|
+
jo && io && /* @__PURE__ */ b(Co, { fallback: null, children: /* @__PURE__ */ b(
|
|
1600
|
+
Jn,
|
|
1601
|
+
{
|
|
1602
|
+
video: H.current,
|
|
1603
|
+
aspect: io,
|
|
1604
|
+
model: _ ?? le?.model,
|
|
1605
|
+
animateLid: w,
|
|
1606
|
+
watchOnly: F,
|
|
1607
|
+
onReady: et.onReady,
|
|
1608
|
+
pointer: (e, o, n, r) => {
|
|
1609
|
+
const i = H.current;
|
|
1610
|
+
!i?.videoWidth || !R.current?.getState().controlReady || Pe.pointer(
|
|
1611
|
+
e === "down" ? te.DOWN : e === "up" ? te.UP : te.MOVE,
|
|
1612
|
+
{
|
|
1613
|
+
x: o * i.videoWidth,
|
|
1614
|
+
y: n * i.videoHeight,
|
|
1615
|
+
width: i.videoWidth,
|
|
1616
|
+
height: i.videoHeight
|
|
1617
|
+
},
|
|
1618
|
+
r
|
|
1619
|
+
);
|
|
1620
|
+
},
|
|
1621
|
+
scroll: (e, o, n, r) => {
|
|
1622
|
+
const i = H.current;
|
|
1623
|
+
!i?.videoWidth || !R.current?.getState().controlReady || Pe.scroll(
|
|
1624
|
+
{
|
|
1625
|
+
x: e * i.videoWidth,
|
|
1626
|
+
y: o * i.videoHeight,
|
|
1627
|
+
width: i.videoWidth,
|
|
1628
|
+
height: i.videoHeight
|
|
1629
|
+
},
|
|
1630
|
+
n,
|
|
1631
|
+
r
|
|
1632
|
+
);
|
|
1633
|
+
},
|
|
1634
|
+
onKeyDown: Ge,
|
|
1635
|
+
onKeyUp: Ge,
|
|
1636
|
+
onBlur: rt
|
|
1637
|
+
}
|
|
1638
|
+
) }),
|
|
1639
|
+
ye && /* @__PURE__ */ b($n, { view: et, label: "MacBook rendering" }),
|
|
1640
|
+
/* @__PURE__ */ b("audio", { ref: ht, muted: !0, hidden: !0 }),
|
|
1641
|
+
ne && /* @__PURE__ */ b(
|
|
1642
|
+
"video",
|
|
1643
|
+
{
|
|
1644
|
+
ref: ut,
|
|
1645
|
+
autoPlay: !0,
|
|
1646
|
+
playsInline: !0,
|
|
1647
|
+
muted: !0,
|
|
1648
|
+
style: { position: "absolute", width: 1, height: 1, opacity: 0, pointerEvents: "none" }
|
|
1649
|
+
}
|
|
1650
|
+
),
|
|
1651
|
+
ne && Gt && /* @__PURE__ */ b(Co, { fallback: /* @__PURE__ */ b("div", { children: "Loading iPhone Duo…" }), children: /* @__PURE__ */ b(
|
|
1652
|
+
Zn,
|
|
1653
|
+
{
|
|
1654
|
+
watchOnly: F,
|
|
1655
|
+
showFrame: m,
|
|
1656
|
+
model: N ?? le?.model,
|
|
1657
|
+
outer: H.current,
|
|
1658
|
+
inner: ut.current,
|
|
1659
|
+
state: Gt,
|
|
1660
|
+
setAngle: (e) => Xt("setHingeAngle", { angleDegrees: e }),
|
|
1661
|
+
setOrientation: (e) => Xt("setDuoOrientation", { orientation: e }),
|
|
1662
|
+
button: (e, o) => Xt("performActions", {
|
|
1663
|
+
actions: [{ type: o ? "buttonDown" : "buttonUp", button: e }]
|
|
1664
|
+
}),
|
|
1665
|
+
touch: (e, o, n, r) => {
|
|
1666
|
+
R.current?.sendDisplayTouch(e, o, n, r);
|
|
1667
|
+
},
|
|
1668
|
+
onKeyDown: Ge,
|
|
1669
|
+
onKeyUp: Ge
|
|
1670
|
+
}
|
|
1671
|
+
) }),
|
|
1672
|
+
ne && qt && /* @__PURE__ */ b("div", { role: "alert", className: "rc-duo-error", children: qt }),
|
|
1673
|
+
!ne && _e && /* @__PURE__ */ b(
|
|
1674
|
+
Gn,
|
|
1675
|
+
{
|
|
1676
|
+
snapshot: co,
|
|
1677
|
+
geometry: Ko,
|
|
1678
|
+
highlightedId: Wt,
|
|
1679
|
+
selectedId: Lt,
|
|
1680
|
+
mode: Fo,
|
|
1681
|
+
cursorPosition: Uo,
|
|
1682
|
+
frozenCursorPosition: zo,
|
|
1683
|
+
onSelectChange: (e, o) => {
|
|
1684
|
+
pt(e?.id ?? null), e && o ? Ue(o) : e || Ue(null);
|
|
1685
|
+
const n = ke.current;
|
|
1686
|
+
e && n ? Xe("onInspectSelectionChange", ze.current, {
|
|
1687
|
+
element: e,
|
|
1688
|
+
snapshot: n
|
|
1689
|
+
}) : Xe("onInspectSelectionChange", ze.current, null);
|
|
1690
|
+
},
|
|
1691
|
+
onTapElement: F ? void 0 : ((e, o) => {
|
|
1692
|
+
if (o) {
|
|
1693
|
+
vo(o.x, o.y);
|
|
1694
|
+
return;
|
|
1695
|
+
}
|
|
1696
|
+
const n = ke.current;
|
|
1697
|
+
n && Go(e, n);
|
|
1698
|
+
})
|
|
1699
|
+
}
|
|
1700
|
+
),
|
|
1701
|
+
Do ? /* @__PURE__ */ oe("div", { className: "rc-terminated", role: "status", children: [
|
|
1702
|
+
/* @__PURE__ */ b("div", { className: "rc-terminated-title", children: "Instance terminated" }),
|
|
1703
|
+
/* @__PURE__ */ b("div", { className: "rc-terminated-message", children: "This instance no longer exists and can't be reconnected." })
|
|
1704
|
+
] }) : Po && /* @__PURE__ */ b("button", { type: "button", className: "rc-retry-button", onClick: rn, children: "Retry" })
|
|
1705
|
+
]
|
|
1706
|
+
}
|
|
1707
|
+
);
|
|
1708
|
+
}
|
|
1709
|
+
);
|
|
1710
|
+
export {
|
|
1711
|
+
$n as D,
|
|
1712
|
+
di as M,
|
|
1713
|
+
yi as R,
|
|
1714
|
+
ai as a,
|
|
1715
|
+
li as b,
|
|
1716
|
+
ui as c,
|
|
1717
|
+
fi as d,
|
|
1718
|
+
pi as e,
|
|
1719
|
+
hi as l,
|
|
1720
|
+
mi as m,
|
|
1721
|
+
gi as s,
|
|
1722
|
+
Xn as u
|
|
1723
|
+
};
|