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