@limrun/ui 0.19.0 → 0.20.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +103 -0
- package/dist/{GLTFLoader-BEplsEG3.mjs → GLTFLoader-CEdCEYr6.mjs} +1 -1
- package/dist/{GLTFLoader-CC3leQFv.js → GLTFLoader-yqDaHF46.js} +1 -1
- package/dist/components/remote-control.d.ts +4 -68
- package/dist/core/device-stream.d.ts +30 -0
- package/dist/core/playback-subscription.d.ts +7 -0
- package/dist/core/stream-options.d.ts +62 -0
- package/dist/core/stream-types.d.ts +66 -0
- package/dist/core/stream-utils.d.ts +6 -0
- package/dist/core/use-playback-stats.d.ts +3 -6
- package/dist/core-BqXmROsc.mjs +2162 -0
- package/dist/core-D7ODbXln.js +2 -0
- package/dist/core.cjs +1 -0
- package/dist/core.d.ts +12 -0
- package/dist/core.js +21 -0
- package/dist/{duo-frame-BZ-XDtxc.js → duo-frame-BMVxq-Qi.js} +2 -2
- package/dist/{duo-frame-CB8dL8T-.mjs → duo-frame-DCl_2GS3.mjs} +3 -3
- package/dist/{duo-view-BEWqEQI2.mjs → duo-view-DhzmW9X6.mjs} +64 -64
- package/dist/duo-view-UZazbOh-.js +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +2 -2
- package/dist/lite.cjs +1 -1
- package/dist/lite.js +7 -6
- package/dist/remote-control-Cl8nEKUE.js +1 -0
- package/dist/remote-control-aGoEKYFB.mjs +1128 -0
- package/package.json +15 -7
- package/dist/duo-view-DCJT-n1Z.js +0 -1
- package/dist/remote-control-CdnZRsWd.mjs +0 -2920
- package/dist/remote-control-DUG1S1Jq.js +0 -2
|
@@ -0,0 +1,1128 @@
|
|
|
1
|
+
import { jsx as f, jsxs as $, Fragment as ft } from "react/jsx-runtime";
|
|
2
|
+
import { f as Kt, c as pt, d as Vt, b as Bt, h as jt, i as Gt, s as ye, j as qt, e as Qt, k as Y, l as je, m as Zt, o as Le, p as R, q as He, a as Jt, r as en, t as m, u as tn } from "./core-BqXmROsc.mjs";
|
|
3
|
+
import { memo as Ge, useState as N, useEffect as x, useMemo as we, useCallback as nn, lazy as on, forwardRef as rn, useRef as _, useImperativeHandle as cn, Suspense as sn } from "react";
|
|
4
|
+
import { createPortal as an } from "react-dom";
|
|
5
|
+
import './index.css';const ln = async (d) => {
|
|
6
|
+
if (!d) return !1;
|
|
7
|
+
try {
|
|
8
|
+
if (typeof navigator < "u" && navigator.clipboard?.writeText)
|
|
9
|
+
return await navigator.clipboard.writeText(d), !0;
|
|
10
|
+
} catch {
|
|
11
|
+
}
|
|
12
|
+
try {
|
|
13
|
+
const r = document.createElement("textarea");
|
|
14
|
+
r.value = d, r.style.position = "fixed", r.style.opacity = "0", document.body.appendChild(r), r.select();
|
|
15
|
+
const p = document.execCommand("copy");
|
|
16
|
+
return document.body.removeChild(r), p;
|
|
17
|
+
} catch {
|
|
18
|
+
return !1;
|
|
19
|
+
}
|
|
20
|
+
}, dn = Ge(
|
|
21
|
+
function({ element: r, screen: p, highlighted: h, selected: k, selectable: K, onClick: I }) {
|
|
22
|
+
const T = Kt(r.frame, p);
|
|
23
|
+
if (!T) return null;
|
|
24
|
+
const U = pt(r);
|
|
25
|
+
return /* @__PURE__ */ f(
|
|
26
|
+
"button",
|
|
27
|
+
{
|
|
28
|
+
type: "button",
|
|
29
|
+
className: r.enabled ? "rc-inspect-box" : "rc-inspect-box rc-inspect-box-disabled",
|
|
30
|
+
"data-ax-id": r.id,
|
|
31
|
+
"data-ax-path": r.path,
|
|
32
|
+
"data-ax-label": r.label || void 0,
|
|
33
|
+
"data-ax-role": r.role || void 0,
|
|
34
|
+
"data-highlighted": h ? "true" : "false",
|
|
35
|
+
"data-selected": k ? "true" : "false",
|
|
36
|
+
"aria-label": U,
|
|
37
|
+
onClick: (H) => {
|
|
38
|
+
K && (H.preventDefault(), H.stopPropagation(), I(r, { x: H.clientX, y: H.clientY }));
|
|
39
|
+
},
|
|
40
|
+
style: {
|
|
41
|
+
left: `${T.x / p.width * 100}%`,
|
|
42
|
+
top: `${T.y / p.height * 100}%`,
|
|
43
|
+
width: `${T.width / p.width * 100}%`,
|
|
44
|
+
height: `${T.height / p.height * 100}%`
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
},
|
|
49
|
+
(d, r) => d.highlighted === r.highlighted && d.selected === r.selected && d.selectable === r.selectable && d.screen.width === r.screen.width && d.screen.height === r.screen.height && d.onClick === r.onClick && Vt(d.element, r.element)
|
|
50
|
+
), un = 260, hn = 220, fn = 6, pn = 8, mn = Ge(function({
|
|
51
|
+
element: r,
|
|
52
|
+
platform: p,
|
|
53
|
+
anchor: h,
|
|
54
|
+
cursorAnchored: k,
|
|
55
|
+
showActions: K,
|
|
56
|
+
onTap: I
|
|
57
|
+
}) {
|
|
58
|
+
const [T, U] = N(null);
|
|
59
|
+
x(() => {
|
|
60
|
+
if (!T) return;
|
|
61
|
+
const A = window.setTimeout(() => U(null), 1100);
|
|
62
|
+
return () => window.clearTimeout(A);
|
|
63
|
+
}, [T]);
|
|
64
|
+
const H = we(() => {
|
|
65
|
+
const A = un, F = hn, X = fn, g = pn, Q = typeof window < "u" ? window.innerWidth : 1024, oe = typeof window < "u" ? window.innerHeight : 768, Z = h.x + X + A <= Q - g, J = h.y - X - F >= g;
|
|
66
|
+
let de = Z ? h.x + X : h.x - X, Ae = J ? h.y - X : h.y + X;
|
|
67
|
+
const Me = `translate(${Z ? "0" : "-100%"}, ${J ? "-100%" : "0"})`;
|
|
68
|
+
return de = Math.max(g + (Z ? 0 : A), Math.min(Q - g - (Z ? A : 0), de)), Ae = Math.max(g + (J ? F : 0), Math.min(oe - g - (J ? 0 : F), Ae)), { left: `${de}px`, top: `${Ae}px`, transform: Me };
|
|
69
|
+
}, [h.x, h.y]), M = we(() => Bt(r, p), [r, p]), W = p === "ios" ? r.selectors.AXUniqueId : r.selectors.resourceId, B = p === "ios" ? "AXUniqueId" : "resourceId", q = nn(async (A, F) => {
|
|
70
|
+
if (!A) return;
|
|
71
|
+
await ln(A) && U(F);
|
|
72
|
+
}, []), S = jt(r), Te = r.label || r.value || S, ne = pt(r);
|
|
73
|
+
return an(
|
|
74
|
+
/* @__PURE__ */ $(
|
|
75
|
+
"div",
|
|
76
|
+
{
|
|
77
|
+
className: "rc-inspect-card",
|
|
78
|
+
"data-cursor-anchored": k ? "true" : "false",
|
|
79
|
+
style: H,
|
|
80
|
+
onClick: (A) => A.stopPropagation(),
|
|
81
|
+
onMouseDown: (A) => A.stopPropagation(),
|
|
82
|
+
onMouseMove: (A) => A.stopPropagation(),
|
|
83
|
+
children: [
|
|
84
|
+
/* @__PURE__ */ $("div", { className: "rc-inspect-card-header", children: [
|
|
85
|
+
/* @__PURE__ */ f("span", { className: "rc-inspect-card-role", children: S }),
|
|
86
|
+
!r.enabled && /* @__PURE__ */ f("span", { className: "rc-inspect-card-tag", children: "disabled" }),
|
|
87
|
+
r.focused && /* @__PURE__ */ f("span", { className: "rc-inspect-card-tag rc-inspect-card-tag-blue", children: "focused" })
|
|
88
|
+
] }),
|
|
89
|
+
/* @__PURE__ */ f("p", { className: "rc-inspect-card-title", title: ne, children: Te }),
|
|
90
|
+
W && /* @__PURE__ */ $("div", { className: "rc-inspect-card-row", children: [
|
|
91
|
+
/* @__PURE__ */ $("span", { className: "rc-inspect-card-row-label", children: [
|
|
92
|
+
B,
|
|
93
|
+
":"
|
|
94
|
+
] }),
|
|
95
|
+
/* @__PURE__ */ f("span", { className: "rc-inspect-card-row-value", children: W })
|
|
96
|
+
] }),
|
|
97
|
+
r.value && r.value !== r.label && /* @__PURE__ */ $("div", { className: "rc-inspect-card-row", children: [
|
|
98
|
+
/* @__PURE__ */ f("span", { className: "rc-inspect-card-row-label", children: "value:" }),
|
|
99
|
+
/* @__PURE__ */ f("span", { className: "rc-inspect-card-row-value", children: r.value })
|
|
100
|
+
] }),
|
|
101
|
+
/* @__PURE__ */ $("div", { className: "rc-inspect-card-row", children: [
|
|
102
|
+
/* @__PURE__ */ f("span", { className: "rc-inspect-card-row-label", children: "frame:" }),
|
|
103
|
+
/* @__PURE__ */ $("span", { className: "rc-inspect-card-row-value", children: [
|
|
104
|
+
Math.round(r.frame.width),
|
|
105
|
+
"×",
|
|
106
|
+
Math.round(r.frame.height),
|
|
107
|
+
" @ ",
|
|
108
|
+
Math.round(r.frame.x),
|
|
109
|
+
",",
|
|
110
|
+
Math.round(r.frame.y)
|
|
111
|
+
] })
|
|
112
|
+
] }),
|
|
113
|
+
K && /* @__PURE__ */ $("div", { className: "rc-inspect-card-actions", children: [
|
|
114
|
+
/* @__PURE__ */ f(
|
|
115
|
+
"button",
|
|
116
|
+
{
|
|
117
|
+
type: "button",
|
|
118
|
+
className: "rc-inspect-card-btn rc-inspect-card-btn-primary",
|
|
119
|
+
onClick: () => I(r, h),
|
|
120
|
+
children: "Tap"
|
|
121
|
+
}
|
|
122
|
+
),
|
|
123
|
+
/* @__PURE__ */ f(
|
|
124
|
+
"button",
|
|
125
|
+
{
|
|
126
|
+
type: "button",
|
|
127
|
+
className: T === "selector" ? "rc-inspect-card-btn rc-inspect-card-btn-copied" : "rc-inspect-card-btn",
|
|
128
|
+
disabled: !M,
|
|
129
|
+
title: M ?? "No usable selector for this element",
|
|
130
|
+
onClick: () => q(M ?? void 0, "selector"),
|
|
131
|
+
children: T === "selector" ? "Copied!" : "Copy selector"
|
|
132
|
+
}
|
|
133
|
+
),
|
|
134
|
+
/* @__PURE__ */ f(
|
|
135
|
+
"button",
|
|
136
|
+
{
|
|
137
|
+
type: "button",
|
|
138
|
+
className: T === "id" ? "rc-inspect-card-btn rc-inspect-card-btn-copied" : "rc-inspect-card-btn",
|
|
139
|
+
disabled: !W,
|
|
140
|
+
title: W ?? `No ${B}`,
|
|
141
|
+
onClick: () => q(W, "id"),
|
|
142
|
+
children: T === "id" ? "Copied!" : `Copy ${B}`
|
|
143
|
+
}
|
|
144
|
+
)
|
|
145
|
+
] })
|
|
146
|
+
]
|
|
147
|
+
}
|
|
148
|
+
),
|
|
149
|
+
document.body
|
|
150
|
+
);
|
|
151
|
+
}), gn = Ge(function({
|
|
152
|
+
snapshot: r,
|
|
153
|
+
geometry: p,
|
|
154
|
+
highlightedId: h,
|
|
155
|
+
selectedId: k,
|
|
156
|
+
mode: K,
|
|
157
|
+
cursorPosition: I,
|
|
158
|
+
frozenCursorPosition: T,
|
|
159
|
+
onSelectChange: U,
|
|
160
|
+
onTapElement: H
|
|
161
|
+
}) {
|
|
162
|
+
const M = K === "select", W = M ? h !== null && h !== k : h !== null, B = M ? h ?? k : h, q = we(() => {
|
|
163
|
+
const g = /* @__PURE__ */ new Map();
|
|
164
|
+
if (!r) return g;
|
|
165
|
+
for (const Q of r.elements) g.set(Q.id, Q);
|
|
166
|
+
return g;
|
|
167
|
+
}, [r]), S = we(() => B ? q.get(B) ?? null : null, [B, q]);
|
|
168
|
+
if (!(!!r && !!p && r.screen.width > 0 && r.screen.height > 0 && r.elements.length > 0)) return null;
|
|
169
|
+
const ne = W ? I : T ?? I, A = W, F = M && !W && k !== null, X = (g) => {
|
|
170
|
+
M && g.target === g.currentTarget && U(null, null);
|
|
171
|
+
};
|
|
172
|
+
return /* @__PURE__ */ $(ft, { children: [
|
|
173
|
+
/* @__PURE__ */ f(
|
|
174
|
+
"div",
|
|
175
|
+
{
|
|
176
|
+
className: M ? "rc-inspect-overlay rc-inspect-overlay-select" : "rc-inspect-overlay",
|
|
177
|
+
style: {
|
|
178
|
+
left: `${p.left}px`,
|
|
179
|
+
top: `${p.top}px`,
|
|
180
|
+
width: `${p.width}px`,
|
|
181
|
+
height: `${p.height}px`
|
|
182
|
+
},
|
|
183
|
+
onClick: X,
|
|
184
|
+
children: r.elements.map((g) => /* @__PURE__ */ f(
|
|
185
|
+
dn,
|
|
186
|
+
{
|
|
187
|
+
element: g,
|
|
188
|
+
screen: r.screen,
|
|
189
|
+
highlighted: g.id === h,
|
|
190
|
+
selected: g.id === k,
|
|
191
|
+
selectable: M,
|
|
192
|
+
onClick: U
|
|
193
|
+
},
|
|
194
|
+
g.id
|
|
195
|
+
))
|
|
196
|
+
}
|
|
197
|
+
),
|
|
198
|
+
S && ne && /* @__PURE__ */ f(
|
|
199
|
+
mn,
|
|
200
|
+
{
|
|
201
|
+
element: S,
|
|
202
|
+
platform: r.platform,
|
|
203
|
+
anchor: ne,
|
|
204
|
+
cursorAnchored: A,
|
|
205
|
+
showActions: F,
|
|
206
|
+
onTap: H
|
|
207
|
+
}
|
|
208
|
+
)
|
|
209
|
+
] });
|
|
210
|
+
}), vn = on(() => import("./duo-view-DhzmW9X6.mjs").then((d) => d.d)), We = (d) => Object.entries(m).find(
|
|
211
|
+
([p, h]) => p.startsWith("ACTION_") && h === d
|
|
212
|
+
)?.[0] ?? String(d), ut = 1920, ht = 1200, yn = (d, r) => d === ut && r === ht || d === ht && r === ut, wn = {
|
|
213
|
+
ios: {
|
|
214
|
+
videoBorderRadiusMultiplier: 0.15,
|
|
215
|
+
loadingLogoSize: "20%",
|
|
216
|
+
// Video position as percentage of frame dimensions
|
|
217
|
+
videoPosition: {
|
|
218
|
+
portrait: { heightMultiplier: 0.9678 },
|
|
219
|
+
landscape: { widthMultiplier: 0.9678 }
|
|
220
|
+
}
|
|
221
|
+
},
|
|
222
|
+
android: {
|
|
223
|
+
videoBorderRadiusMultiplier: 0.13,
|
|
224
|
+
loadingLogoSize: "40%",
|
|
225
|
+
// Video position as percentage of frame dimensions
|
|
226
|
+
videoPosition: {
|
|
227
|
+
portrait: { heightMultiplier: 0.967 },
|
|
228
|
+
landscape: { widthMultiplier: 0.962 }
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
function Tn(d) {
|
|
233
|
+
const r = d.code, p = en[r];
|
|
234
|
+
if (!p)
|
|
235
|
+
return je(`Unknown event.code: ${r}, key: ${d.key}`), null;
|
|
236
|
+
let h = R.META_NONE;
|
|
237
|
+
const k = r >= "KeyA" && r <= "KeyZ", K = d.getModifierState("CapsLock"), I = d.shiftKey;
|
|
238
|
+
let T = I;
|
|
239
|
+
return k && (T = I !== K), T && (h |= R.META_SHIFT_ON), d.ctrlKey && (h |= R.META_CTRL_ON), d.altKey && (h |= R.META_ALT_ON), d.metaKey && (h |= R.META_META_ON), { keycode: p, metaState: h };
|
|
240
|
+
}
|
|
241
|
+
const Rn = rn(
|
|
242
|
+
({
|
|
243
|
+
className: d,
|
|
244
|
+
url: r,
|
|
245
|
+
token: p,
|
|
246
|
+
sessionId: h,
|
|
247
|
+
openUrl: k,
|
|
248
|
+
showFrame: K = !0,
|
|
249
|
+
deviceModel: I,
|
|
250
|
+
duoModelUrl: T,
|
|
251
|
+
autoReconnect: U = !1,
|
|
252
|
+
jitterBufferTargetMs: H,
|
|
253
|
+
onPlaybackStats: M,
|
|
254
|
+
onTerminated: W,
|
|
255
|
+
assets: B,
|
|
256
|
+
onConnectionStateChange: q,
|
|
257
|
+
inspectMode: S,
|
|
258
|
+
onAxSnapshotChange: Te,
|
|
259
|
+
onInspectSelectionChange: ne,
|
|
260
|
+
onAxStatusChange: A,
|
|
261
|
+
axPollIntervalMs: F,
|
|
262
|
+
axMaxBackoffMs: X,
|
|
263
|
+
androidElementTreeOptions: g,
|
|
264
|
+
onCameraDemandChange: Q,
|
|
265
|
+
onCameraStats: oe,
|
|
266
|
+
onTrace: Z,
|
|
267
|
+
microphoneEnabled: J = !1,
|
|
268
|
+
onMicrophoneStateChange: de
|
|
269
|
+
}, Ae) => {
|
|
270
|
+
const be = _(null), E = _(null), Me = _(null), [mt, gt] = N(!1), z = I === "iphone-duo" || mt, Oe = _(null), [qe, vt] = N(null), [Qe, yt] = N(), [wt, Tt] = N(!1), [At, bt] = N(!1), [Ct, Nt] = N(!1), [Ze, Je] = N(!1), [Rt, et] = N(!1), [Et, xe] = N({}), $e = _(null), O = _(/* @__PURE__ */ new Map()), re = _(!1), [It, Mt] = N(!1), b = _(null), ue = _(null), Ce = _({
|
|
271
|
+
handle: () => {
|
|
272
|
+
},
|
|
273
|
+
end: () => {
|
|
274
|
+
}
|
|
275
|
+
}), [ie, _e] = N(null), [tt, Ue] = N(null), [Fe, Ne] = N(null), [ze, Se] = N(null), [Ot, nt] = N(null), [_t, ot] = N(null), Pe = _(null), j = _(void 0), rt = (e) => {
|
|
276
|
+
Pe.current = e, j.current === void 0 && (j.current = window.requestAnimationFrame(() => {
|
|
277
|
+
j.current = void 0, ot(Pe.current);
|
|
278
|
+
}));
|
|
279
|
+
}, [St, he] = N(null), ce = _(null);
|
|
280
|
+
ce.current = tt;
|
|
281
|
+
const fe = _(ne);
|
|
282
|
+
fe.current = ne;
|
|
283
|
+
const Re = S === !0 || S === "hover-only", Pt = S === "hover-only" ? "hover-only" : "select", ee = we(() => Gt(r), [r]), kt = we(
|
|
284
|
+
() => h || Array.from(crypto.getRandomValues(new Uint32Array(4)), (e) => e.toString(36)).join(""),
|
|
285
|
+
[h]
|
|
286
|
+
), pe = wn[ee], Ee = B?.[ee], it = ee === "android" && Rt ? Ze ? Ee?.tabletFrameLandscape : Ee?.tabletFrame : Ze ? Ee?.frameLandscape : Ee?.frame, ct = Ee?.loadingLogo, ke = !z && K && !!it, v = _(null), V = (e) => v.current?.sendControl(e), Ke = (e, n) => v.current?.sendDuoControl(e, n) ?? Promise.reject(new Error("Simulator disconnected")), st = -10, at = (e, n) => {
|
|
287
|
+
const o = Ie();
|
|
288
|
+
if (!o) return;
|
|
289
|
+
const t = ge(o, e, n);
|
|
290
|
+
if (!t) return;
|
|
291
|
+
const { videoX: c, videoY: s, videoWidth: i, videoHeight: a } = t, l = He(
|
|
292
|
+
m.ACTION_DOWN,
|
|
293
|
+
st,
|
|
294
|
+
i,
|
|
295
|
+
a,
|
|
296
|
+
c,
|
|
297
|
+
s,
|
|
298
|
+
1,
|
|
299
|
+
m.BUTTON_PRIMARY,
|
|
300
|
+
m.BUTTON_PRIMARY
|
|
301
|
+
);
|
|
302
|
+
l && V(l), window.setTimeout(() => {
|
|
303
|
+
const u = He(
|
|
304
|
+
m.ACTION_UP,
|
|
305
|
+
st,
|
|
306
|
+
i,
|
|
307
|
+
a,
|
|
308
|
+
c,
|
|
309
|
+
s,
|
|
310
|
+
0,
|
|
311
|
+
m.BUTTON_PRIMARY,
|
|
312
|
+
m.BUTTON_PRIMARY
|
|
313
|
+
);
|
|
314
|
+
u && V(u);
|
|
315
|
+
}, 60);
|
|
316
|
+
}, Yt = (e, n) => {
|
|
317
|
+
const o = Ie();
|
|
318
|
+
if (!o || n.screen.width <= 0 || n.screen.height <= 0) return;
|
|
319
|
+
const t = e.frame.x + e.frame.width / 2, c = e.frame.y + e.frame.height / 2, s = t / n.screen.width * o.actualWidth, i = c / n.screen.height * o.actualHeight, a = o.videoRect.left + o.offsetX + s, l = o.videoRect.top + o.offsetY + i;
|
|
320
|
+
at(a, l);
|
|
321
|
+
}, Ye = -1, Xe = -2, se = -3, me = (e, n, o, t, c, s) => {
|
|
322
|
+
const i = He(
|
|
323
|
+
e,
|
|
324
|
+
n,
|
|
325
|
+
o,
|
|
326
|
+
t,
|
|
327
|
+
c,
|
|
328
|
+
s,
|
|
329
|
+
1,
|
|
330
|
+
// pressure
|
|
331
|
+
m.BUTTON_PRIMARY,
|
|
332
|
+
m.BUTTON_PRIMARY
|
|
333
|
+
);
|
|
334
|
+
i && (Y("[rc-touch] sendSingleTouch", {
|
|
335
|
+
action: e,
|
|
336
|
+
actionName: We(e),
|
|
337
|
+
pointerId: n,
|
|
338
|
+
x: c,
|
|
339
|
+
y: s,
|
|
340
|
+
video: { width: o, height: t }
|
|
341
|
+
}), V(i));
|
|
342
|
+
}, ae = (e, n, o) => {
|
|
343
|
+
if (!o) return;
|
|
344
|
+
const { videoX: t, videoY: c, videoWidth: s, videoHeight: i } = o;
|
|
345
|
+
let a = null, l = null, u = 1;
|
|
346
|
+
const C = m.BUTTON_PRIMARY;
|
|
347
|
+
switch (n) {
|
|
348
|
+
case "down":
|
|
349
|
+
e !== se && Ce.current.end(), a = O.current.size === 0 ? m.ACTION_DOWN : m.ACTION_POINTER_DOWN, l = { x: t, y: c }, O.current.set(e, l), e === -1 && E.current?.focus();
|
|
350
|
+
break;
|
|
351
|
+
case "move":
|
|
352
|
+
O.current.has(e) && (a = m.ACTION_MOVE, l = { x: t, y: c }, O.current.set(e, l));
|
|
353
|
+
break;
|
|
354
|
+
case "up":
|
|
355
|
+
case "cancel":
|
|
356
|
+
O.current.has(e) && (l = O.current.get(e), O.current.delete(e), n === "cancel" ? a = m.ACTION_CANCEL : a = O.current.size === 0 ? m.ACTION_UP : m.ACTION_POINTER_UP);
|
|
357
|
+
break;
|
|
358
|
+
}
|
|
359
|
+
if (a !== null && l !== null) {
|
|
360
|
+
Y("[rc-touch][mouse->touch] sending", {
|
|
361
|
+
pointerId: e,
|
|
362
|
+
eventType: n,
|
|
363
|
+
action: a,
|
|
364
|
+
actionName: We(a),
|
|
365
|
+
positionToSend: l,
|
|
366
|
+
video: { width: s, height: i },
|
|
367
|
+
altHeld: re.current,
|
|
368
|
+
activePointersAfter: Array.from(O.current.entries()).map(([P, w]) => ({
|
|
369
|
+
id: P,
|
|
370
|
+
x: w.x,
|
|
371
|
+
y: w.y
|
|
372
|
+
}))
|
|
373
|
+
});
|
|
374
|
+
const y = He(
|
|
375
|
+
a,
|
|
376
|
+
e,
|
|
377
|
+
s,
|
|
378
|
+
i,
|
|
379
|
+
l.x,
|
|
380
|
+
l.y,
|
|
381
|
+
u,
|
|
382
|
+
C,
|
|
383
|
+
C
|
|
384
|
+
);
|
|
385
|
+
y && (Y("[rc-touch][mouse->touch] buffer", {
|
|
386
|
+
pointerId: e,
|
|
387
|
+
actionName: We(a),
|
|
388
|
+
byteLength: y.byteLength
|
|
389
|
+
}), V(y));
|
|
390
|
+
} else (n === "up" || n === "cancel") && O.current.delete(e);
|
|
391
|
+
}, Ve = (e) => {
|
|
392
|
+
if (re.current !== e && (re.current = e, Mt(e), e || _e(null), Y("[rc-touch][alt] updateAltHeld", {
|
|
393
|
+
nextHeld: e,
|
|
394
|
+
activePointerIds: Array.from(O.current.keys())
|
|
395
|
+
}), ee === "ios" && v.current?.getState().controlReady)) {
|
|
396
|
+
const n = e ? R.ACTION_DOWN : R.ACTION_UP, o = Le(
|
|
397
|
+
n,
|
|
398
|
+
R.KEYCODE_ALT_LEFT,
|
|
399
|
+
0,
|
|
400
|
+
R.META_NONE
|
|
401
|
+
);
|
|
402
|
+
Y("[rc-touch][alt] sending Indigo modifier keycode", {
|
|
403
|
+
action: n,
|
|
404
|
+
keycode: R.KEYCODE_ALT_LEFT
|
|
405
|
+
}), o && V(o);
|
|
406
|
+
}
|
|
407
|
+
}, Ie = () => {
|
|
408
|
+
const e = E.current, n = be.current;
|
|
409
|
+
if (!e || !n) return null;
|
|
410
|
+
const o = e.videoWidth, t = e.videoHeight;
|
|
411
|
+
if (!o || !t) return null;
|
|
412
|
+
const c = e.getBoundingClientRect(), s = n.getBoundingClientRect(), i = c.width, a = c.height, l = o / t, u = i / a;
|
|
413
|
+
let C = i, y = a;
|
|
414
|
+
l > u ? y = i / l : C = a * l;
|
|
415
|
+
const P = (i - C) / 2, w = (a - y) / 2;
|
|
416
|
+
return {
|
|
417
|
+
videoWidth: o,
|
|
418
|
+
videoHeight: t,
|
|
419
|
+
videoRect: c,
|
|
420
|
+
containerRect: s,
|
|
421
|
+
actualWidth: C,
|
|
422
|
+
actualHeight: y,
|
|
423
|
+
offsetX: P,
|
|
424
|
+
offsetY: w
|
|
425
|
+
};
|
|
426
|
+
}, ge = (e, n, o) => {
|
|
427
|
+
const t = n - e.videoRect.left - e.offsetX, c = o - e.videoRect.top - e.offsetY, s = Math.max(0, Math.min(e.actualWidth, t)), i = Math.max(0, Math.min(e.actualHeight, c)), a = Math.max(
|
|
428
|
+
0,
|
|
429
|
+
Math.min(e.videoWidth, s / e.actualWidth * e.videoWidth)
|
|
430
|
+
), l = Math.max(
|
|
431
|
+
0,
|
|
432
|
+
Math.min(e.videoHeight, i / e.actualHeight * e.videoHeight)
|
|
433
|
+
);
|
|
434
|
+
return {
|
|
435
|
+
videoX: a,
|
|
436
|
+
videoY: l,
|
|
437
|
+
videoWidth: e.videoWidth,
|
|
438
|
+
videoHeight: e.videoHeight
|
|
439
|
+
};
|
|
440
|
+
}, Xt = (e, n, o) => {
|
|
441
|
+
const t = n - e.videoRect.left - e.offsetX, c = o - e.videoRect.top - e.offsetY, s = Math.max(0, Math.min(e.actualWidth, t)), i = Math.max(0, Math.min(e.actualHeight, c)), a = Math.max(
|
|
442
|
+
0,
|
|
443
|
+
Math.min(e.videoWidth, s / e.actualWidth * e.videoWidth)
|
|
444
|
+
), l = Math.max(
|
|
445
|
+
0,
|
|
446
|
+
Math.min(e.videoHeight, i / e.actualHeight * e.videoHeight)
|
|
447
|
+
), u = e.videoWidth - a, C = e.videoHeight - l, y = e.videoRect.left + e.offsetX, P = e.videoRect.top + e.offsetY, w = y - e.containerRect.left + s, G = P - e.containerRect.top + i, le = y - e.containerRect.left + (e.actualWidth - s), L = P - e.containerRect.top + (e.actualHeight - i);
|
|
448
|
+
return {
|
|
449
|
+
containerX: w,
|
|
450
|
+
containerY: G,
|
|
451
|
+
mirrorContainerX: le,
|
|
452
|
+
mirrorContainerY: L,
|
|
453
|
+
videoX: a,
|
|
454
|
+
videoY: l,
|
|
455
|
+
mirrorVideoX: u,
|
|
456
|
+
mirrorVideoY: C,
|
|
457
|
+
videoWidth: e.videoWidth,
|
|
458
|
+
videoHeight: e.videoHeight
|
|
459
|
+
};
|
|
460
|
+
}, Dt = (e, n, o, t, c, s, i) => {
|
|
461
|
+
const a = tn(e, n, o, t, c, s, i);
|
|
462
|
+
Y("[rc-touch2] sendTwoFingerMessage (iOS)", {
|
|
463
|
+
actionName: We(e),
|
|
464
|
+
video: { width: n, height: o },
|
|
465
|
+
p0: { x: t, y: c },
|
|
466
|
+
p1: { x: s, y: i },
|
|
467
|
+
byteLength: a.byteLength
|
|
468
|
+
}), V(a);
|
|
469
|
+
}, ve = (e, n, o, t, c, s, i, a, l) => {
|
|
470
|
+
if (Y("[rc-touch2] applyTwoFingerEvent", {
|
|
471
|
+
platform: ee,
|
|
472
|
+
eventType: e,
|
|
473
|
+
video: { width: n, height: o },
|
|
474
|
+
p0: { x: t, y: c, id: a },
|
|
475
|
+
p1: { x: s, y: i, id: l }
|
|
476
|
+
}), e === "down" && Ce.current.end(), ee === "ios") {
|
|
477
|
+
const u = e === "down" ? m.ACTION_DOWN : e === "move" ? m.ACTION_MOVE : m.ACTION_UP;
|
|
478
|
+
Dt(u, n, o, t, c, s, i);
|
|
479
|
+
} else
|
|
480
|
+
e === "down" ? (me(m.ACTION_DOWN, a, n, o, t, c), me(m.ACTION_POINTER_DOWN, l, n, o, s, i)) : e === "move" ? (me(m.ACTION_MOVE, a, n, o, t, c), me(m.ACTION_MOVE, l, n, o, s, i)) : (me(m.ACTION_POINTER_UP, l, n, o, s, i), me(m.ACTION_UP, a, n, o, t, c));
|
|
481
|
+
}, Lt = (e, n, o) => {
|
|
482
|
+
if (!re.current) {
|
|
483
|
+
ie !== null && _e(null);
|
|
484
|
+
return;
|
|
485
|
+
}
|
|
486
|
+
const t = Xt(e, n, o);
|
|
487
|
+
_e(t);
|
|
488
|
+
}, Ht = (e, n, o) => {
|
|
489
|
+
const t = ce.current;
|
|
490
|
+
if (!t || t.screen.width <= 0 || t.screen.height <= 0) return null;
|
|
491
|
+
const c = n - e.videoRect.left - e.offsetX, s = o - e.videoRect.top - e.offsetY;
|
|
492
|
+
if (c < 0 || s < 0 || c > e.actualWidth || s > e.actualHeight) return null;
|
|
493
|
+
const i = c / e.actualWidth * t.screen.width, a = s / e.actualHeight * t.screen.height;
|
|
494
|
+
return Jt(t, i, a);
|
|
495
|
+
}, te = (e) => {
|
|
496
|
+
if (z) return;
|
|
497
|
+
e.preventDefault(), e.stopPropagation();
|
|
498
|
+
const n = Ie();
|
|
499
|
+
if ((S === !0 || S === "hover-only") && !("touches" in e))
|
|
500
|
+
if (e.type === "mousemove") {
|
|
501
|
+
if (rt({ x: e.clientX, y: e.clientY }), n) {
|
|
502
|
+
const t = Ht(n, e.clientX, e.clientY);
|
|
503
|
+
Ne(t?.id ?? null);
|
|
504
|
+
}
|
|
505
|
+
} else e.type === "mouseleave" && (rt(null), Ne(null));
|
|
506
|
+
if (S !== !0 && (!("touches" in e) && n && (e.type === "mousemove" ? Lt(n, e.clientX, e.clientY) : e.type === "mouseleave" && _e(null)), !(!v.current?.getState().controlReady || !E.current || !n)))
|
|
507
|
+
if ("touches" in e) {
|
|
508
|
+
const t = e.touches, c = e.changedTouches;
|
|
509
|
+
let s;
|
|
510
|
+
switch (e.type) {
|
|
511
|
+
case "touchstart":
|
|
512
|
+
s = "down";
|
|
513
|
+
break;
|
|
514
|
+
case "touchmove":
|
|
515
|
+
s = "move";
|
|
516
|
+
break;
|
|
517
|
+
case "touchend":
|
|
518
|
+
s = "up";
|
|
519
|
+
break;
|
|
520
|
+
case "touchcancel":
|
|
521
|
+
s = "cancel";
|
|
522
|
+
break;
|
|
523
|
+
default:
|
|
524
|
+
return;
|
|
525
|
+
}
|
|
526
|
+
if (t.length === 2) {
|
|
527
|
+
const i = t[0], a = t[1], l = ge(n, i.clientX, i.clientY), u = ge(n, a.clientX, a.clientY);
|
|
528
|
+
if (!l || !u) return;
|
|
529
|
+
b.current ? b.current.source === "real-touch" && (b.current.finger0 = { x: l.videoX, y: l.videoY }, b.current.finger1 = { x: u.videoX, y: u.videoY }, ve(
|
|
530
|
+
"move",
|
|
531
|
+
l.videoWidth,
|
|
532
|
+
l.videoHeight,
|
|
533
|
+
l.videoX,
|
|
534
|
+
l.videoY,
|
|
535
|
+
u.videoX,
|
|
536
|
+
u.videoY,
|
|
537
|
+
b.current.pointerId0,
|
|
538
|
+
b.current.pointerId1
|
|
539
|
+
)) : (b.current = {
|
|
540
|
+
finger0: { x: l.videoX, y: l.videoY },
|
|
541
|
+
finger1: { x: u.videoX, y: u.videoY },
|
|
542
|
+
videoSize: { width: l.videoWidth, height: l.videoHeight },
|
|
543
|
+
source: "real-touch",
|
|
544
|
+
pointerId0: i.identifier,
|
|
545
|
+
pointerId1: a.identifier
|
|
546
|
+
}, ve(
|
|
547
|
+
"down",
|
|
548
|
+
l.videoWidth,
|
|
549
|
+
l.videoHeight,
|
|
550
|
+
l.videoX,
|
|
551
|
+
l.videoY,
|
|
552
|
+
u.videoX,
|
|
553
|
+
u.videoY,
|
|
554
|
+
i.identifier,
|
|
555
|
+
a.identifier
|
|
556
|
+
));
|
|
557
|
+
} else if (t.length < 2 && b.current?.source === "real-touch") {
|
|
558
|
+
const i = b.current;
|
|
559
|
+
ve(
|
|
560
|
+
"up",
|
|
561
|
+
i.videoSize.width,
|
|
562
|
+
i.videoSize.height,
|
|
563
|
+
i.finger0.x,
|
|
564
|
+
i.finger0.y,
|
|
565
|
+
i.finger1.x,
|
|
566
|
+
i.finger1.y,
|
|
567
|
+
i.pointerId0,
|
|
568
|
+
i.pointerId1
|
|
569
|
+
), b.current = null;
|
|
570
|
+
return;
|
|
571
|
+
} else {
|
|
572
|
+
if (t.length > 2)
|
|
573
|
+
return;
|
|
574
|
+
{
|
|
575
|
+
const i = c[0];
|
|
576
|
+
if (i) {
|
|
577
|
+
const a = ge(n, i.clientX, i.clientY);
|
|
578
|
+
ae(i.identifier, s, a);
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
} else {
|
|
583
|
+
let c = null;
|
|
584
|
+
const s = b.current?.source === "alt-mouse";
|
|
585
|
+
switch (e.type) {
|
|
586
|
+
case "mousedown":
|
|
587
|
+
e.button === 0 && (c = "down");
|
|
588
|
+
break;
|
|
589
|
+
case "mousemove":
|
|
590
|
+
(s || O.current.has(-1)) && (c = "move");
|
|
591
|
+
break;
|
|
592
|
+
case "mouseup":
|
|
593
|
+
e.button === 0 && (c = "up");
|
|
594
|
+
break;
|
|
595
|
+
case "mouseleave":
|
|
596
|
+
(s || O.current.has(-1)) && (c = "up");
|
|
597
|
+
break;
|
|
598
|
+
}
|
|
599
|
+
if (c) {
|
|
600
|
+
const i = ge(n, e.clientX, e.clientY);
|
|
601
|
+
if (!i)
|
|
602
|
+
return;
|
|
603
|
+
Y("[rc-touch][mouse] event", {
|
|
604
|
+
domType: e.type,
|
|
605
|
+
eventType: c,
|
|
606
|
+
button: e.button,
|
|
607
|
+
buttons: e.buttons,
|
|
608
|
+
client: { x: e.clientX, y: e.clientY },
|
|
609
|
+
altHeldRef: re.current,
|
|
610
|
+
inTwoFingerMode: s,
|
|
611
|
+
geometry: {
|
|
612
|
+
videoX: i.videoX,
|
|
613
|
+
videoY: i.videoY,
|
|
614
|
+
videoWidth: i.videoWidth,
|
|
615
|
+
videoHeight: i.videoHeight
|
|
616
|
+
},
|
|
617
|
+
activePointerIds: Array.from(O.current.keys())
|
|
618
|
+
}), re.current || s ? Wt(c, i) : ae(-1, c, i);
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
}, Wt = (e, n) => {
|
|
622
|
+
const { videoX: o, videoY: t, videoWidth: c, videoHeight: s } = n, i = c - o, a = s - t;
|
|
623
|
+
if (e === "down") {
|
|
624
|
+
b.current = {
|
|
625
|
+
finger0: { x: o, y: t },
|
|
626
|
+
finger1: { x: i, y: a },
|
|
627
|
+
videoSize: { width: c, height: s },
|
|
628
|
+
source: "alt-mouse",
|
|
629
|
+
pointerId0: Ye,
|
|
630
|
+
pointerId1: Xe
|
|
631
|
+
}, E.current?.focus(), ve(
|
|
632
|
+
"down",
|
|
633
|
+
c,
|
|
634
|
+
s,
|
|
635
|
+
o,
|
|
636
|
+
t,
|
|
637
|
+
i,
|
|
638
|
+
a,
|
|
639
|
+
Ye,
|
|
640
|
+
Xe
|
|
641
|
+
);
|
|
642
|
+
return;
|
|
643
|
+
}
|
|
644
|
+
if (e === "move") {
|
|
645
|
+
b.current?.source === "alt-mouse" && (b.current.finger0 = { x: o, y: t }, b.current.finger1 = { x: i, y: a }, ve(
|
|
646
|
+
"move",
|
|
647
|
+
c,
|
|
648
|
+
s,
|
|
649
|
+
o,
|
|
650
|
+
t,
|
|
651
|
+
i,
|
|
652
|
+
a,
|
|
653
|
+
Ye,
|
|
654
|
+
Xe
|
|
655
|
+
));
|
|
656
|
+
return;
|
|
657
|
+
}
|
|
658
|
+
if (e === "up" || e === "cancel") {
|
|
659
|
+
const l = b.current;
|
|
660
|
+
if (l?.source === "alt-mouse") {
|
|
661
|
+
const { finger0: u, finger1: C, videoSize: y } = l;
|
|
662
|
+
ve(
|
|
663
|
+
"up",
|
|
664
|
+
y.width,
|
|
665
|
+
y.height,
|
|
666
|
+
u.x,
|
|
667
|
+
u.y,
|
|
668
|
+
C.x,
|
|
669
|
+
C.y,
|
|
670
|
+
Ye,
|
|
671
|
+
Xe
|
|
672
|
+
), b.current = null;
|
|
673
|
+
}
|
|
674
|
+
return;
|
|
675
|
+
}
|
|
676
|
+
}, xt = 150, lt = () => {
|
|
677
|
+
const e = ue.current;
|
|
678
|
+
e && (window.clearTimeout(e.endTimer), ae(se, "up", e.pos), ue.current = null);
|
|
679
|
+
}, $t = (e) => {
|
|
680
|
+
if (e.ctrlKey || re.current || b.current) return;
|
|
681
|
+
const n = O.current.size;
|
|
682
|
+
if (n > 1 || n === 1 && !O.current.has(se)) return;
|
|
683
|
+
const o = Ie();
|
|
684
|
+
if (!o) return;
|
|
685
|
+
const t = e.clientX - o.videoRect.left - o.offsetX, c = e.clientY - o.videoRect.top - o.offsetY;
|
|
686
|
+
if (t < 0 || t > o.actualWidth || c < 0 || c > o.actualHeight)
|
|
687
|
+
return;
|
|
688
|
+
const s = ge(o, e.clientX, e.clientY);
|
|
689
|
+
if (!s) return;
|
|
690
|
+
e.preventDefault();
|
|
691
|
+
const i = (e.deltaMode === 1 ? 16 : e.deltaMode === 2 ? o.actualWidth : 1) * (o.videoWidth / o.actualWidth), a = (e.deltaMode === 1 ? 16 : e.deltaMode === 2 ? o.actualHeight : 1) * (o.videoHeight / o.actualHeight), l = -e.deltaX * i, u = -e.deltaY * a, C = (L) => {
|
|
692
|
+
window.clearTimeout(L.endTimer), L.endTimer = window.setTimeout(lt, xt);
|
|
693
|
+
};
|
|
694
|
+
if (l === 0 && u === 0) {
|
|
695
|
+
ue.current && C(ue.current);
|
|
696
|
+
return;
|
|
697
|
+
}
|
|
698
|
+
const y = () => ({
|
|
699
|
+
videoWidth: s.videoWidth,
|
|
700
|
+
videoHeight: s.videoHeight,
|
|
701
|
+
videoX: Math.abs(l) > Math.abs(u) ? Math.min(Math.max(s.videoX, s.videoWidth * 0.2), s.videoWidth * 0.8) : s.videoX,
|
|
702
|
+
videoY: Math.abs(u) >= Math.abs(l) ? Math.min(Math.max(s.videoY, s.videoHeight * 0.2), s.videoHeight * 0.8) : s.videoY
|
|
703
|
+
}), P = (L) => ({
|
|
704
|
+
...L,
|
|
705
|
+
videoX: Math.min(Math.max(L.videoX + l, 0), L.videoWidth),
|
|
706
|
+
videoY: Math.min(Math.max(L.videoY + u, 0), L.videoHeight)
|
|
707
|
+
});
|
|
708
|
+
let w = ue.current;
|
|
709
|
+
if (w)
|
|
710
|
+
window.clearTimeout(w.endTimer);
|
|
711
|
+
else {
|
|
712
|
+
const L = y();
|
|
713
|
+
ae(se, "down", L), w = { pos: L, endTimer: 0 }, ue.current = w;
|
|
714
|
+
}
|
|
715
|
+
let G = w.pos, le = P(G);
|
|
716
|
+
le.videoX === G.videoX && le.videoY === G.videoY && (ae(se, "up", G), G = y(), ae(se, "down", G), le = P(G)), ae(se, "move", le), w.pos = le, C(w);
|
|
717
|
+
};
|
|
718
|
+
x(() => {
|
|
719
|
+
Ce.current = { handle: $t, end: lt };
|
|
720
|
+
}), x(() => {
|
|
721
|
+
const e = be.current;
|
|
722
|
+
if (!e) return;
|
|
723
|
+
const n = (o) => Ce.current.handle(o);
|
|
724
|
+
return e.addEventListener("wheel", n, { passive: !1 }), () => {
|
|
725
|
+
Ce.current.end(), e.removeEventListener("wheel", n);
|
|
726
|
+
};
|
|
727
|
+
}, []), x(() => {
|
|
728
|
+
const e = (t) => {
|
|
729
|
+
t.key === "Alt" && Ve(!0);
|
|
730
|
+
}, n = (t) => {
|
|
731
|
+
t.key === "Alt" && Ve(!1);
|
|
732
|
+
}, o = () => {
|
|
733
|
+
Ve(!1);
|
|
734
|
+
};
|
|
735
|
+
return window.addEventListener("keydown", e, !0), window.addEventListener("keyup", n, !0), window.addEventListener("blur", o), () => {
|
|
736
|
+
window.removeEventListener("keydown", e, !0), window.removeEventListener("keyup", n, !0), window.removeEventListener("blur", o);
|
|
737
|
+
};
|
|
738
|
+
}, []);
|
|
739
|
+
const De = (e) => {
|
|
740
|
+
e.preventDefault(), e.stopPropagation();
|
|
741
|
+
const n = document.activeElement === E.current || z && document.activeElement === e.currentTarget;
|
|
742
|
+
if (Y("Keyboard event:", {
|
|
743
|
+
type: e.type,
|
|
744
|
+
key: e.key,
|
|
745
|
+
keyCode: e.keyCode,
|
|
746
|
+
code: e.code,
|
|
747
|
+
target: e.target.tagName,
|
|
748
|
+
focused: n
|
|
749
|
+
}), !n) {
|
|
750
|
+
je("Simulator input not focused, skipping keyboard event");
|
|
751
|
+
return;
|
|
752
|
+
}
|
|
753
|
+
if (!v.current?.getState().controlReady) {
|
|
754
|
+
je("Data channel not ready for keyboard event:", v.current?.getState().connection);
|
|
755
|
+
return;
|
|
756
|
+
}
|
|
757
|
+
if (e.type === "keydown") {
|
|
758
|
+
if (e.key.toLowerCase() === "v" && (e.metaKey || e.ctrlKey)) {
|
|
759
|
+
Y("Paste shortcut detected"), navigator.clipboard.readText().then((t) => {
|
|
760
|
+
if (t) {
|
|
761
|
+
Y(
|
|
762
|
+
"Pasting text via SET_CLIPBOARD:",
|
|
763
|
+
t.substring(0, 20) + (t.length > 20 ? "..." : "")
|
|
764
|
+
);
|
|
765
|
+
const c = Zt(t, !0);
|
|
766
|
+
V(c);
|
|
767
|
+
}
|
|
768
|
+
}).catch((t) => {
|
|
769
|
+
console.error("Failed to read clipboard contents: ", t);
|
|
770
|
+
});
|
|
771
|
+
return;
|
|
772
|
+
}
|
|
773
|
+
if (e.key.toLowerCase() === "m" && (e.metaKey || e.ctrlKey)) {
|
|
774
|
+
Y("Menu shortcut detected");
|
|
775
|
+
const t = Le(
|
|
776
|
+
R.ACTION_DOWN,
|
|
777
|
+
R.MENU,
|
|
778
|
+
0,
|
|
779
|
+
R.META_NONE
|
|
780
|
+
// Modifiers are handled by the shortcut check, not passed down
|
|
781
|
+
);
|
|
782
|
+
V(t);
|
|
783
|
+
const c = Le(
|
|
784
|
+
R.ACTION_UP,
|
|
785
|
+
R.MENU,
|
|
786
|
+
0,
|
|
787
|
+
R.META_NONE
|
|
788
|
+
);
|
|
789
|
+
V(c);
|
|
790
|
+
return;
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
const o = Tn(e);
|
|
794
|
+
if (o) {
|
|
795
|
+
const { keycode: t, metaState: c } = o, s = e.type === "keydown" ? R.ACTION_DOWN : R.ACTION_UP;
|
|
796
|
+
Y(`Sending Keycode: key=${e.key}, code=${t}, action=${s}, meta=${c}`);
|
|
797
|
+
const i = Le(
|
|
798
|
+
s,
|
|
799
|
+
t,
|
|
800
|
+
0,
|
|
801
|
+
// repeat count, typically 0 for single presses
|
|
802
|
+
c
|
|
803
|
+
);
|
|
804
|
+
V(i);
|
|
805
|
+
} else
|
|
806
|
+
Y(`Ignoring unhandled key event: type=${e.type}, key=${e.key}`);
|
|
807
|
+
}, Ut = (e) => {
|
|
808
|
+
e.stopPropagation(), v.current?.reconnect();
|
|
809
|
+
}, D = _({
|
|
810
|
+
onAxSnapshotChange: Te,
|
|
811
|
+
onAxStatusChange: A,
|
|
812
|
+
onCameraDemandChange: Q,
|
|
813
|
+
onCameraStats: oe,
|
|
814
|
+
onMicrophoneStateChange: de,
|
|
815
|
+
onTrace: Z,
|
|
816
|
+
onTerminated: W,
|
|
817
|
+
onConnectionStateChange: q,
|
|
818
|
+
onPlaybackStats: M
|
|
819
|
+
});
|
|
820
|
+
D.current = {
|
|
821
|
+
onAxSnapshotChange: Te,
|
|
822
|
+
onAxStatusChange: A,
|
|
823
|
+
onCameraDemandChange: Q,
|
|
824
|
+
onCameraStats: oe,
|
|
825
|
+
onMicrophoneStateChange: de,
|
|
826
|
+
onTrace: Z,
|
|
827
|
+
onTerminated: W,
|
|
828
|
+
onConnectionStateChange: q,
|
|
829
|
+
onPlaybackStats: M
|
|
830
|
+
};
|
|
831
|
+
const Be = !!Z;
|
|
832
|
+
x(() => {
|
|
833
|
+
$e.current = null, Je(!1), et(!1), xe({});
|
|
834
|
+
}, [r, I]), x(() => {
|
|
835
|
+
let e = !0;
|
|
836
|
+
ce.current !== null && (ce.current = null, Ue(null), ye("onAxSnapshotChange", D.current.onAxSnapshotChange, null));
|
|
837
|
+
const n = qt({
|
|
838
|
+
url: r,
|
|
839
|
+
token: p,
|
|
840
|
+
sessionId: kt,
|
|
841
|
+
deviceModel: I,
|
|
842
|
+
autoReconnect: U,
|
|
843
|
+
jitterBufferTargetMs: H,
|
|
844
|
+
openUrl: k,
|
|
845
|
+
inspectMode: S,
|
|
846
|
+
axPollIntervalMs: F,
|
|
847
|
+
axMaxBackoffMs: X,
|
|
848
|
+
androidElementTreeOptions: g,
|
|
849
|
+
microphoneEnabled: J,
|
|
850
|
+
onStateChange: (t) => {
|
|
851
|
+
(t.videoReady || t.connection === "idle" || t.connection === "connecting" || t.connection === "reconnecting") && Tt(t.videoReady), bt(t.connection === "failed"), Nt(t.connection === "terminated"), gt(t.duo), vt(t.duoState), yt(t.duoError);
|
|
852
|
+
},
|
|
853
|
+
onAxSnapshotChange: (t) => {
|
|
854
|
+
e && (Ue((c) => Qt(c, t) ? c : t), D.current.onAxSnapshotChange?.(t));
|
|
855
|
+
},
|
|
856
|
+
onAxStatusChange: (...t) => D.current.onAxStatusChange?.(...t),
|
|
857
|
+
onCameraDemandChange: (...t) => D.current.onCameraDemandChange?.(...t),
|
|
858
|
+
onCameraStats: oe ? (...t) => D.current.onCameraStats?.(...t) : void 0,
|
|
859
|
+
onMicrophoneStateChange: (...t) => D.current.onMicrophoneStateChange?.(...t),
|
|
860
|
+
onTrace: Be ? (...t) => D.current.onTrace?.(...t) : void 0,
|
|
861
|
+
onTerminated: () => D.current.onTerminated?.(),
|
|
862
|
+
onConnectionStateChange: (...t) => D.current.onConnectionStateChange?.(...t),
|
|
863
|
+
onPlaybackStats: M ? (...t) => D.current.onPlaybackStats?.(...t) : void 0
|
|
864
|
+
});
|
|
865
|
+
v.current = n;
|
|
866
|
+
const o = E.current ? n.attachVideo(E.current) : void 0;
|
|
867
|
+
return n.start(), () => {
|
|
868
|
+
e = !1, n.dispose(), o?.(), v.current = null;
|
|
869
|
+
};
|
|
870
|
+
}, [r, p, h, I, Be]), x(() => {
|
|
871
|
+
if (z && Oe.current)
|
|
872
|
+
return v.current?.attachVideo(Oe.current, "inner");
|
|
873
|
+
}, [z, r, p, h, I, Be]), x(() => {
|
|
874
|
+
v.current?.updateOptions({
|
|
875
|
+
openUrl: k,
|
|
876
|
+
axPollIntervalMs: F,
|
|
877
|
+
axMaxBackoffMs: X,
|
|
878
|
+
androidElementTreeOptions: g,
|
|
879
|
+
autoReconnect: U,
|
|
880
|
+
jitterBufferTargetMs: H,
|
|
881
|
+
microphoneEnabled: J,
|
|
882
|
+
inspectMode: S,
|
|
883
|
+
onPlaybackStats: M ? (...e) => D.current.onPlaybackStats?.(...e) : void 0,
|
|
884
|
+
onCameraStats: oe ? (...e) => D.current.onCameraStats?.(...e) : void 0
|
|
885
|
+
});
|
|
886
|
+
}, [
|
|
887
|
+
U,
|
|
888
|
+
H,
|
|
889
|
+
J,
|
|
890
|
+
S,
|
|
891
|
+
!!M,
|
|
892
|
+
!!oe,
|
|
893
|
+
k,
|
|
894
|
+
F,
|
|
895
|
+
X,
|
|
896
|
+
g
|
|
897
|
+
]);
|
|
898
|
+
const dt = () => {
|
|
899
|
+
const e = Ie();
|
|
900
|
+
if (!e) {
|
|
901
|
+
nt(null);
|
|
902
|
+
return;
|
|
903
|
+
}
|
|
904
|
+
const n = {
|
|
905
|
+
left: e.videoRect.left - e.containerRect.left + e.offsetX,
|
|
906
|
+
top: e.videoRect.top - e.containerRect.top + e.offsetY,
|
|
907
|
+
width: e.actualWidth,
|
|
908
|
+
height: e.actualHeight
|
|
909
|
+
};
|
|
910
|
+
nt(
|
|
911
|
+
(o) => o && o.left === n.left && o.top === n.top && o.width === n.width && o.height === n.height ? o : n
|
|
912
|
+
);
|
|
913
|
+
};
|
|
914
|
+
x(() => {
|
|
915
|
+
const e = E.current, n = Me.current, o = be.current;
|
|
916
|
+
if (!e) return;
|
|
917
|
+
const t = () => {
|
|
918
|
+
const i = e.videoWidth > 0 && e.videoHeight > 0;
|
|
919
|
+
i && ($e.current = { width: e.videoWidth, height: e.videoHeight });
|
|
920
|
+
const a = $e.current, l = a ? `${a.width} / ${a.height}` : void 0;
|
|
921
|
+
if (!ke || !n) {
|
|
922
|
+
xe(
|
|
923
|
+
!i && a ? {
|
|
924
|
+
aspectRatio: l,
|
|
925
|
+
contain: "size",
|
|
926
|
+
containIntrinsicSize: `${a.width}px ${a.height}px`
|
|
927
|
+
} : {}
|
|
928
|
+
), dt();
|
|
929
|
+
return;
|
|
930
|
+
}
|
|
931
|
+
const u = n.clientWidth, C = n.clientHeight;
|
|
932
|
+
if (u === 0 || C === 0) return;
|
|
933
|
+
const y = a ? a.width > a.height : !1;
|
|
934
|
+
Je(y), et(
|
|
935
|
+
ee === "android" && !!a && yn(a.width, a.height)
|
|
936
|
+
);
|
|
937
|
+
const P = y ? pe.videoPosition.landscape : pe.videoPosition.portrait;
|
|
938
|
+
let w = { aspectRatio: l };
|
|
939
|
+
P.heightMultiplier ? (w.height = `${C * P.heightMultiplier}px`, w.width = "auto") : P.widthMultiplier && (w.width = `${u * P.widthMultiplier}px`, w.height = "auto"), w.borderRadius = `${y ? C * pe.videoBorderRadiusMultiplier : u * pe.videoBorderRadiusMultiplier}px`, xe(w), dt();
|
|
940
|
+
}, c = new ResizeObserver(() => {
|
|
941
|
+
t();
|
|
942
|
+
});
|
|
943
|
+
n && c.observe(n), c.observe(e), o && c.observe(o), n && n.addEventListener("load", t), e.addEventListener("loadedmetadata", t), e.addEventListener("resize", t);
|
|
944
|
+
const s = () => v.current?.bumpActivity();
|
|
945
|
+
return e.addEventListener("resize", s), t(), () => {
|
|
946
|
+
c.disconnect(), e.removeEventListener("loadedmetadata", t), e.removeEventListener("resize", t), e.removeEventListener("resize", s), n && n.removeEventListener("load", t);
|
|
947
|
+
};
|
|
948
|
+
}, [pe, ke, r, I]), x(() => {
|
|
949
|
+
Re || (Ue(null), Ne(null), Se(null), ot(null), he(null), Pe.current = null, j.current !== void 0 && (window.cancelAnimationFrame(j.current), j.current = void 0));
|
|
950
|
+
}, [Re]), x(() => () => {
|
|
951
|
+
j.current !== void 0 && (window.cancelAnimationFrame(j.current), j.current = void 0);
|
|
952
|
+
}, []), x(() => {
|
|
953
|
+
if (!Re) return;
|
|
954
|
+
const e = (n) => {
|
|
955
|
+
n.key === "Escape" && (ze || Fe) && (Se(null), Ne(null), he(null), ye("onInspectSelectionChange", fe.current, null));
|
|
956
|
+
};
|
|
957
|
+
return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
|
|
958
|
+
}, [Re, ze, Fe]);
|
|
959
|
+
const Ft = () => {
|
|
960
|
+
E.current && E.current.focus();
|
|
961
|
+
};
|
|
962
|
+
cn(Ae, () => ({
|
|
963
|
+
openUrl: (e) => v.current?.openUrl(e),
|
|
964
|
+
sendKeyEvent: (e) => v.current?.sendKeyEvent(e),
|
|
965
|
+
screenshot: (e) => v.current?.screenshot(e) ?? Promise.reject(new Error("Simulator disconnected")),
|
|
966
|
+
terminateApp: (e) => v.current?.terminateApp(e) ?? Promise.reject(new Error("Simulator disconnected")),
|
|
967
|
+
reconnect: () => v.current?.reconnect(),
|
|
968
|
+
refreshAxTree: () => v.current?.refreshAxTree() ?? Promise.reject(new Error("Simulator disconnected")),
|
|
969
|
+
getAxSnapshot: () => v.current?.getAxSnapshot() ?? null,
|
|
970
|
+
setInspectHighlight: (e) => {
|
|
971
|
+
Ne(e?.id ?? null);
|
|
972
|
+
},
|
|
973
|
+
setInspectSelection: (e) => {
|
|
974
|
+
Se(e?.id ?? null), he(e ? Pe.current : null);
|
|
975
|
+
const n = ce.current;
|
|
976
|
+
e && n ? ye("onInspectSelectionChange", fe.current, { element: e, snapshot: n }) : ye("onInspectSelectionChange", fe.current, null);
|
|
977
|
+
},
|
|
978
|
+
getAxStatus: () => v.current?.getAxStatus() ?? "idle"
|
|
979
|
+
}));
|
|
980
|
+
const zt = It && ie !== null;
|
|
981
|
+
return /* @__PURE__ */ $(
|
|
982
|
+
"div",
|
|
983
|
+
{
|
|
984
|
+
ref: be,
|
|
985
|
+
className: ["rc-container", d].filter(Boolean).join(" "),
|
|
986
|
+
style: { touchAction: "none" },
|
|
987
|
+
onMouseDown: te,
|
|
988
|
+
onMouseMove: te,
|
|
989
|
+
onMouseUp: te,
|
|
990
|
+
onMouseLeave: te,
|
|
991
|
+
onTouchStart: te,
|
|
992
|
+
onTouchMove: te,
|
|
993
|
+
onTouchEnd: te,
|
|
994
|
+
onTouchCancel: te,
|
|
995
|
+
children: [
|
|
996
|
+
zt && ie && /* @__PURE__ */ $(ft, { children: [
|
|
997
|
+
/* @__PURE__ */ f(
|
|
998
|
+
"div",
|
|
999
|
+
{
|
|
1000
|
+
className: "rc-touch-indicator",
|
|
1001
|
+
style: {
|
|
1002
|
+
left: `${ie.containerX}px`,
|
|
1003
|
+
top: `${ie.containerY}px`
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
),
|
|
1007
|
+
/* @__PURE__ */ f(
|
|
1008
|
+
"div",
|
|
1009
|
+
{
|
|
1010
|
+
className: "rc-touch-indicator",
|
|
1011
|
+
style: {
|
|
1012
|
+
left: `${ie.mirrorContainerX}px`,
|
|
1013
|
+
top: `${ie.mirrorContainerY}px`
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
)
|
|
1017
|
+
] }),
|
|
1018
|
+
ke && /* @__PURE__ */ f(
|
|
1019
|
+
"img",
|
|
1020
|
+
{
|
|
1021
|
+
ref: Me,
|
|
1022
|
+
src: it,
|
|
1023
|
+
alt: "",
|
|
1024
|
+
className: ee === "ios" ? "rc-phone-frame rc-phone-frame-ios" : "rc-phone-frame",
|
|
1025
|
+
draggable: !1
|
|
1026
|
+
}
|
|
1027
|
+
),
|
|
1028
|
+
/* @__PURE__ */ f(
|
|
1029
|
+
"video",
|
|
1030
|
+
{
|
|
1031
|
+
ref: E,
|
|
1032
|
+
className: ["rc-video", !ke && "rc-video-frameless", !wt && "rc-video-loading"].filter(Boolean).join(" "),
|
|
1033
|
+
style: {
|
|
1034
|
+
...Et,
|
|
1035
|
+
...z ? { opacity: 0, width: 1, height: 1, pointerEvents: "none" } : {},
|
|
1036
|
+
...ct ? {
|
|
1037
|
+
backgroundImage: `url("${ct}")`,
|
|
1038
|
+
backgroundRepeat: "no-repeat",
|
|
1039
|
+
backgroundPosition: "center",
|
|
1040
|
+
backgroundSize: pe.loadingLogoSize
|
|
1041
|
+
} : {}
|
|
1042
|
+
},
|
|
1043
|
+
autoPlay: !0,
|
|
1044
|
+
playsInline: !0,
|
|
1045
|
+
muted: !0,
|
|
1046
|
+
tabIndex: z ? -1 : 0,
|
|
1047
|
+
onKeyDown: De,
|
|
1048
|
+
onKeyUp: De,
|
|
1049
|
+
onClick: Ft,
|
|
1050
|
+
onFocus: () => {
|
|
1051
|
+
E.current && (E.current.style.outline = "none");
|
|
1052
|
+
},
|
|
1053
|
+
onBlur: () => {
|
|
1054
|
+
E.current && (E.current.style.outline = "none");
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
),
|
|
1058
|
+
z && /* @__PURE__ */ f(
|
|
1059
|
+
"video",
|
|
1060
|
+
{
|
|
1061
|
+
ref: Oe,
|
|
1062
|
+
autoPlay: !0,
|
|
1063
|
+
playsInline: !0,
|
|
1064
|
+
muted: !0,
|
|
1065
|
+
style: { position: "absolute", width: 1, height: 1, opacity: 0, pointerEvents: "none" }
|
|
1066
|
+
}
|
|
1067
|
+
),
|
|
1068
|
+
z && qe && /* @__PURE__ */ f(sn, { fallback: /* @__PURE__ */ f("div", { children: "Loading iPhone Duo…" }), children: /* @__PURE__ */ f(
|
|
1069
|
+
vn,
|
|
1070
|
+
{
|
|
1071
|
+
showFrame: K,
|
|
1072
|
+
modelUrl: T,
|
|
1073
|
+
outer: E.current,
|
|
1074
|
+
inner: Oe.current,
|
|
1075
|
+
state: qe,
|
|
1076
|
+
setAngle: (e) => Ke("setHingeAngle", { angleDegrees: e }),
|
|
1077
|
+
setOrientation: (e) => Ke("setDuoOrientation", { orientation: e }),
|
|
1078
|
+
button: (e, n) => Ke("performActions", {
|
|
1079
|
+
actions: [{ type: n ? "buttonDown" : "buttonUp", button: e }]
|
|
1080
|
+
}),
|
|
1081
|
+
touch: (e, n, o, t) => {
|
|
1082
|
+
v.current?.sendDisplayTouch(e, n, o, t);
|
|
1083
|
+
},
|
|
1084
|
+
onKeyDown: De,
|
|
1085
|
+
onKeyUp: De
|
|
1086
|
+
}
|
|
1087
|
+
) }),
|
|
1088
|
+
z && Qe && /* @__PURE__ */ f("div", { role: "alert", className: "rc-duo-error", children: Qe }),
|
|
1089
|
+
!z && Re && /* @__PURE__ */ f(
|
|
1090
|
+
gn,
|
|
1091
|
+
{
|
|
1092
|
+
snapshot: tt,
|
|
1093
|
+
geometry: Ot,
|
|
1094
|
+
highlightedId: Fe,
|
|
1095
|
+
selectedId: ze,
|
|
1096
|
+
mode: Pt,
|
|
1097
|
+
cursorPosition: _t,
|
|
1098
|
+
frozenCursorPosition: St,
|
|
1099
|
+
onSelectChange: (e, n) => {
|
|
1100
|
+
Se(e?.id ?? null), e && n ? he(n) : e || he(null);
|
|
1101
|
+
const o = ce.current;
|
|
1102
|
+
e && o ? ye("onInspectSelectionChange", fe.current, {
|
|
1103
|
+
element: e,
|
|
1104
|
+
snapshot: o
|
|
1105
|
+
}) : ye("onInspectSelectionChange", fe.current, null);
|
|
1106
|
+
},
|
|
1107
|
+
onTapElement: (e, n) => {
|
|
1108
|
+
if (n) {
|
|
1109
|
+
at(n.x, n.y);
|
|
1110
|
+
return;
|
|
1111
|
+
}
|
|
1112
|
+
const o = ce.current;
|
|
1113
|
+
o && Yt(e, o);
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1116
|
+
),
|
|
1117
|
+
Ct ? /* @__PURE__ */ $("div", { className: "rc-terminated", role: "status", children: [
|
|
1118
|
+
/* @__PURE__ */ f("div", { className: "rc-terminated-title", children: "Instance terminated" }),
|
|
1119
|
+
/* @__PURE__ */ f("div", { className: "rc-terminated-message", children: "This instance no longer exists and can't be reconnected." })
|
|
1120
|
+
] }) : At && /* @__PURE__ */ f("button", { type: "button", className: "rc-retry-button", onClick: Ut, children: "Retry" })
|
|
1121
|
+
]
|
|
1122
|
+
}
|
|
1123
|
+
);
|
|
1124
|
+
}
|
|
1125
|
+
);
|
|
1126
|
+
export {
|
|
1127
|
+
Rn as R
|
|
1128
|
+
};
|