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