@limrun/ui 0.18.0 → 0.18.2
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 +11 -0
- package/dist/{GLTFLoader-CI7KZuj2.js → GLTFLoader--3fP8K2r.js} +1 -1
- package/dist/{GLTFLoader-CVxkzHPb.mjs → GLTFLoader-C62L6gT7.mjs} +1 -1
- package/dist/components/remote-control.d.ts +2 -0
- package/dist/core/latency-trace.d.ts +6 -0
- package/dist/{duo-frame-CL_SeVHJ.mjs → duo-frame-B6jf62Rq.mjs} +3 -3
- package/dist/{duo-frame-DVe7DjQB.js → duo-frame-DAmRgZuT.js} +2 -2
- package/dist/{duo-view-C0jN3Y-c.mjs → duo-view-DSZO0-zg.mjs} +2 -2
- package/dist/{duo-view-C4b_Z6im.js → duo-view-hTVLMDcc.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 +1 -1
- package/dist/remote-control-B3_Hzmx8.js +2 -0
- package/dist/{remote-control-BtsTgZoS.mjs → remote-control-BFxEfAdr.mjs} +1025 -980
- package/package.json +1 -1
- package/dist/remote-control-DR3iVCzB.js +0 -2
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { memo as
|
|
3
|
-
import { createPortal as
|
|
4
|
-
import './index.css';function
|
|
1
|
+
import { jsx as P, jsxs as ue, Fragment as $r } from "react/jsx-runtime";
|
|
2
|
+
import { memo as cr, useState as G, useEffect as me, useMemo as ke, useCallback as Un, lazy as Ln, forwardRef as xn, useRef as v, useImperativeHandle as Fn, Suspense as Wn } from "react";
|
|
3
|
+
import { createPortal as Hn } from "react-dom";
|
|
4
|
+
import './index.css';function Xr(r) {
|
|
5
5
|
var t, c, a = "";
|
|
6
6
|
if (typeof r == "string" || typeof r == "number") a += r;
|
|
7
7
|
else if (typeof r == "object") if (Array.isArray(r)) {
|
|
8
8
|
var m = r.length;
|
|
9
|
-
for (t = 0; t < m; t++) r[t] && (c =
|
|
9
|
+
for (t = 0; t < m; t++) r[t] && (c = Xr(r[t])) && (a && (a += " "), a += c);
|
|
10
10
|
} else for (c in r) r[c] && (a && (a += " "), a += c);
|
|
11
11
|
return a;
|
|
12
12
|
}
|
|
13
|
-
function
|
|
14
|
-
for (var r, t, c = 0, a = "", m = arguments.length; c < m; c++) (r = arguments[c]) && (t =
|
|
13
|
+
function Pe() {
|
|
14
|
+
for (var r, t, c = 0, a = "", m = arguments.length; c < m; c++) (r = arguments[c]) && (t = Xr(r)) && (a && (a += " "), a += t);
|
|
15
15
|
return a;
|
|
16
16
|
}
|
|
17
|
-
const
|
|
18
|
-
function
|
|
17
|
+
const $o = { width: 164.6, height: 117.8, depth: 5.2 };
|
|
18
|
+
function Xo(r, t, c) {
|
|
19
19
|
return r = Math.max(0, Math.min(1, r)), t = Math.max(0, Math.min(1, t)), c === 1 ? { x: t, y: 1 - r } : c === 2 ? { x: 1 - r, y: 1 - t } : c === 3 ? { x: 1 - t, y: r } : { x: r, y: t };
|
|
20
20
|
}
|
|
21
|
-
function
|
|
21
|
+
function $n(r) {
|
|
22
22
|
return Number.isFinite(r) && r >= 0 && r <= 180;
|
|
23
23
|
}
|
|
24
|
-
function
|
|
24
|
+
function Bo(r, t) {
|
|
25
25
|
return { x: Math.max(0, Math.min(1, r)), y: Math.max(0, Math.min(1, 1 - t)) };
|
|
26
26
|
}
|
|
27
|
-
function
|
|
27
|
+
function qo(r, t, c) {
|
|
28
28
|
return t && (r || !c) ? "touch" : r ? "ignore" : "orbit";
|
|
29
29
|
}
|
|
30
|
-
function
|
|
30
|
+
function Xn(r, t, c, a) {
|
|
31
31
|
if (!Number.isInteger(r) || r < 0 || r > 3 || !Number.isInteger(t) || t < 1 || t > 255 || !Number.isFinite(c) || !Number.isFinite(a) || c < 0 || c > 1 || a < 0 || a > 1)
|
|
32
32
|
throw new RangeError("Invalid display touch coordinates");
|
|
33
33
|
const m = new ArrayBuffer(12), p = new DataView(m);
|
|
34
34
|
return p.setUint8(0, 19), p.setUint8(1, r), p.setUint8(2, t), p.setFloat32(4, c, !0), p.setFloat32(8, a, !0), m;
|
|
35
35
|
}
|
|
36
|
-
class
|
|
36
|
+
class Vo {
|
|
37
37
|
constructor(t, c) {
|
|
38
38
|
this.send = t, this.failed = c;
|
|
39
39
|
}
|
|
@@ -43,7 +43,7 @@ class Wo {
|
|
|
43
43
|
running = !1;
|
|
44
44
|
stopped = !1;
|
|
45
45
|
set(t) {
|
|
46
|
-
this.stopped ||
|
|
46
|
+
this.stopped || !$n(t) || (this.latest = t, this.flush());
|
|
47
47
|
}
|
|
48
48
|
stop() {
|
|
49
49
|
this.stopped = !0, this.latest = void 0;
|
|
@@ -64,12 +64,12 @@ class Wo {
|
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
-
const
|
|
67
|
+
const Go = {
|
|
68
68
|
side: "Sleep/Wake",
|
|
69
69
|
volumeUp: "Volume Up",
|
|
70
70
|
volumeDown: "Volume Down"
|
|
71
71
|
};
|
|
72
|
-
class
|
|
72
|
+
class Jo {
|
|
73
73
|
constructor(t, c) {
|
|
74
74
|
this.send = t, this.failed = c;
|
|
75
75
|
}
|
|
@@ -91,13 +91,13 @@ class $o {
|
|
|
91
91
|
this.tail = this.tail.then(() => this.send(t, c)).catch(this.failed);
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
|
-
const
|
|
94
|
+
const xt = {
|
|
95
95
|
INJECT_KEYCODE: 0,
|
|
96
96
|
INJECT_TOUCH_EVENT: 2,
|
|
97
97
|
// iOS-specific: send two touch points in one message (Option/Alt+drag pinch)
|
|
98
98
|
INJECT_TWO_FINGER_TOUCH_EVENT: 18,
|
|
99
99
|
SET_CLIPBOARD: 9
|
|
100
|
-
},
|
|
100
|
+
}, K = {
|
|
101
101
|
ACTION_DOWN: 0,
|
|
102
102
|
ACTION_UP: 1,
|
|
103
103
|
ACTION_MOVE: 2,
|
|
@@ -233,7 +233,7 @@ const Pt = {
|
|
|
233
233
|
KEYCODE_NUMPAD_COMMA: 159,
|
|
234
234
|
KEYCODE_NUMPAD_ENTER: 160,
|
|
235
235
|
KEYCODE_NUMPAD_EQUALS: 161
|
|
236
|
-
},
|
|
236
|
+
}, Br = {
|
|
237
237
|
KeyA: s.KEYCODE_A,
|
|
238
238
|
KeyB: s.KEYCODE_B,
|
|
239
239
|
KeyC: s.KEYCODE_C,
|
|
@@ -339,12 +339,12 @@ const Pt = {
|
|
|
339
339
|
// Some numpads have comma
|
|
340
340
|
NumpadEnter: s.KEYCODE_NUMPAD_ENTER,
|
|
341
341
|
NumpadEqual: s.KEYCODE_NUMPAD_EQUALS
|
|
342
|
-
},
|
|
343
|
-
`,
|
|
344
|
-
function
|
|
342
|
+
}, qr = `(function(){"use strict";let e,t;self.onmessage=async({data:s})=>{s.type==="start"?(e=new AbortController,t=s.readable.pipeTo(s.writable,{signal:e.signal}).catch(o=>{e?.signal.aborted||self.postMessage({type:"error",message:String(o)})})):s.type==="stop"&&(e?.abort(),await t,self.postMessage({type:"stopped"}),self.close())}})();
|
|
343
|
+
`, Ur = typeof self < "u" && self.Blob && new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);", qr], { type: "text/javascript;charset=utf-8" });
|
|
344
|
+
function Bn(r) {
|
|
345
345
|
let t;
|
|
346
346
|
try {
|
|
347
|
-
if (t =
|
|
347
|
+
if (t = Ur && (self.URL || self.webkitURL).createObjectURL(Ur), !t) throw "";
|
|
348
348
|
const c = new Worker(t, {
|
|
349
349
|
name: r?.name
|
|
350
350
|
});
|
|
@@ -353,100 +353,137 @@ function Fn(r) {
|
|
|
353
353
|
}), c;
|
|
354
354
|
} catch {
|
|
355
355
|
return new Worker(
|
|
356
|
-
"data:text/javascript;charset=utf-8," + encodeURIComponent(
|
|
356
|
+
"data:text/javascript;charset=utf-8," + encodeURIComponent(qr),
|
|
357
357
|
{
|
|
358
358
|
name: r?.name
|
|
359
359
|
}
|
|
360
360
|
);
|
|
361
361
|
}
|
|
362
362
|
}
|
|
363
|
-
function
|
|
363
|
+
function qn(r, t, c) {
|
|
364
364
|
const { MediaStreamTrackProcessor: a, MediaStreamTrackGenerator: m } = globalThis, p = t.getVideoTracks()[0];
|
|
365
|
-
let
|
|
365
|
+
let g, C, w, O, M = !1;
|
|
366
366
|
const S = () => {
|
|
367
|
-
M || (M = !0,
|
|
368
|
-
},
|
|
367
|
+
M || (M = !0, g?.stop(), C?.stop(), w && (w.postMessage({ type: "stop" }), O = setTimeout(() => w?.terminate(), 1e3)));
|
|
368
|
+
}, X = (J) => {
|
|
369
369
|
r.srcObject = J, r.play().catch(() => {
|
|
370
370
|
});
|
|
371
|
-
},
|
|
372
|
-
M || (S(), c(J),
|
|
371
|
+
}, ce = (J) => {
|
|
372
|
+
M || (S(), c(J), X(t));
|
|
373
373
|
};
|
|
374
374
|
try {
|
|
375
375
|
if (p && a && m) {
|
|
376
|
-
|
|
377
|
-
const J = new a({ track:
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
},
|
|
376
|
+
g = p.clone();
|
|
377
|
+
const J = new a({ track: g, maxBufferSize: 1 }), fe = new m({ kind: "video" });
|
|
378
|
+
C = fe, w = new Bn(), w.onmessage = ({ data: ee }) => {
|
|
379
|
+
ee.type === "error" ? ce(new Error(ee.message)) : ee.type === "stopped" && (clearTimeout(O), w?.terminate());
|
|
380
|
+
}, w.onerror = (ee) => ce(new Error(ee.message)), w.postMessage({ type: "start", readable: J.readable, writable: fe.writable }, [
|
|
381
381
|
J.readable,
|
|
382
|
-
|
|
383
|
-
]),
|
|
382
|
+
fe.writable
|
|
383
|
+
]), X(new MediaStream(t.getTracks().map((ee) => ee === p ? fe : ee)));
|
|
384
384
|
} else
|
|
385
|
-
|
|
385
|
+
X(t);
|
|
386
386
|
} catch (J) {
|
|
387
|
-
|
|
387
|
+
ce(J);
|
|
388
388
|
}
|
|
389
389
|
return S;
|
|
390
390
|
}
|
|
391
|
-
function
|
|
392
|
-
const
|
|
391
|
+
function Vn(r, t) {
|
|
392
|
+
const c = r.createDataChannel("latency-trace-v1", {
|
|
393
|
+
ordered: !0,
|
|
394
|
+
negotiated: !0,
|
|
395
|
+
id: 2
|
|
396
|
+
});
|
|
397
|
+
let a = !1, m = !1, p = 0;
|
|
398
|
+
return c.onmessage = (g) => {
|
|
399
|
+
if (m) return;
|
|
400
|
+
let C;
|
|
401
|
+
try {
|
|
402
|
+
C = JSON.parse(g.data);
|
|
403
|
+
} catch (w) {
|
|
404
|
+
console.warn("Invalid latency trace message", w);
|
|
405
|
+
return;
|
|
406
|
+
}
|
|
407
|
+
C && typeof C == "object" && !Array.isArray(C) && t(C);
|
|
408
|
+
}, c.onclose = () => {
|
|
409
|
+
m = !0, a = !1;
|
|
410
|
+
}, {
|
|
411
|
+
accept(g) {
|
|
412
|
+
a = !m && g === 1;
|
|
413
|
+
},
|
|
414
|
+
wrap(g) {
|
|
415
|
+
if (!a || g.byteLength !== 32) return g;
|
|
416
|
+
const C = new DataView(g);
|
|
417
|
+
if (C.getUint8(0) !== 2 || C.getUint8(1) > 2) return g;
|
|
418
|
+
const w = new ArrayBuffer(38), O = new DataView(w);
|
|
419
|
+
return O.setUint8(0, 240), O.setUint8(1, 1), O.setUint32(2, ++p, !0), new Uint8Array(w, 6).set(new Uint8Array(g)), w;
|
|
420
|
+
},
|
|
421
|
+
close() {
|
|
422
|
+
m = !0, a = !1, c.onmessage = null, c.onclose = null, c.close();
|
|
423
|
+
}
|
|
424
|
+
};
|
|
425
|
+
}
|
|
426
|
+
function Pt(r, t, c, a, m, p, g = 1, C = 0, w = 0) {
|
|
427
|
+
const O = new ArrayBuffer(32), M = new DataView(O);
|
|
393
428
|
let S = 0;
|
|
394
|
-
|
|
429
|
+
M.setUint8(S, xt.INJECT_TOUCH_EVENT), S += 1;
|
|
430
|
+
const X = r === K.ACTION_POINTER_DOWN ? K.ACTION_DOWN : r === K.ACTION_POINTER_UP ? K.ACTION_UP : r;
|
|
431
|
+
return M.setUint8(S, X), S += 1, M.setBigInt64(S, BigInt(t), !0), S += 8, M.setInt32(S, Math.round(m), !0), S += 4, M.setInt32(S, Math.round(p), !0), S += 4, M.setUint16(S, c, !0), S += 2, M.setUint16(S, a, !0), S += 2, M.setInt16(S, Math.round(g * 65535), !0), S += 2, M.setInt32(S, C, !0), S += 4, M.setInt32(S, w, !0), O;
|
|
395
432
|
}
|
|
396
|
-
function
|
|
397
|
-
const
|
|
398
|
-
let
|
|
399
|
-
return
|
|
433
|
+
function Gn(r, t, c, a, m, p, g) {
|
|
434
|
+
const C = new ArrayBuffer(24), w = new DataView(C);
|
|
435
|
+
let O = 0;
|
|
436
|
+
return w.setUint8(O, xt.INJECT_TWO_FINGER_TOUCH_EVENT), O += 1, w.setUint8(O, r), O += 1, w.setInt32(O, Math.round(a), !0), O += 4, w.setInt32(O, Math.round(m), !0), O += 4, w.setInt32(O, Math.round(p), !0), O += 4, w.setInt32(O, Math.round(g), !0), O += 4, w.setUint16(O, t, !0), O += 2, w.setUint16(O, c, !0), O += 2, w.setUint16(O, 0, !0), C;
|
|
400
437
|
}
|
|
401
|
-
function
|
|
438
|
+
function Jn(r, t = !0) {
|
|
402
439
|
const a = new TextEncoder().encode(r), m = new ArrayBuffer(14 + a.length), p = new DataView(m);
|
|
403
|
-
let
|
|
404
|
-
return p.setUint8(
|
|
440
|
+
let g = 0;
|
|
441
|
+
return p.setUint8(g, xt.SET_CLIPBOARD), g += 1, p.setBigInt64(g, BigInt(0), !1), g += 8, p.setUint8(g, t ? 1 : 0), g += 1, p.setUint32(g, a.length, !1), g += 4, new Uint8Array(m, g).set(a), m;
|
|
405
442
|
}
|
|
406
|
-
function
|
|
443
|
+
function gt(r, t, c = 0, a = 0) {
|
|
407
444
|
const m = new ArrayBuffer(14), p = new DataView(m);
|
|
408
|
-
let
|
|
409
|
-
return p.setUint8(
|
|
445
|
+
let g = 0;
|
|
446
|
+
return p.setUint8(g, xt.INJECT_KEYCODE), g += 1, p.setUint8(g, r), g += 1, p.setInt32(g, t, !0), g += 4, p.setInt32(g, c, !0), g += 4, p.setInt32(g, a, !0), m;
|
|
410
447
|
}
|
|
411
|
-
const
|
|
448
|
+
const or = "Accessibility unavailable on this device.", Lt = 500, Vr = (r, t) => Math.abs(r.x - t.x) < 0.5 && Math.abs(r.y - t.y) < 0.5 && Math.abs(r.width - t.width) < 0.5 && Math.abs(r.height - t.height) < 0.5, jn = (r) => Math.max(0, r.width) * Math.max(0, r.height), zn = (r) => {
|
|
412
449
|
const t = r.find((c) => c.frame && c.frame.width > 0 && c.frame.height > 0);
|
|
413
450
|
return t?.frame ? ((Math.abs(t.frame.x) > 0.5 || Math.abs(t.frame.y) > 0.5) && console.warn(
|
|
414
451
|
`[ax-tree] iOS root frame is not anchored at (0,0): (${t.frame.x},${t.frame.y}). Element positions may be slightly off from the rendered video.`
|
|
415
452
|
), { x: 0, y: 0, width: t.frame.width, height: t.frame.height }) : { x: 0, y: 0, width: 1, height: 1 };
|
|
416
|
-
},
|
|
453
|
+
}, Qn = (r) => {
|
|
417
454
|
const t = {};
|
|
418
455
|
return typeof r.AXUniqueId == "string" && r.AXUniqueId.length > 0 && (t.AXUniqueId = r.AXUniqueId), typeof r.AXLabel == "string" && r.AXLabel.length > 0 && (t.AXLabel = r.AXLabel), typeof r.type == "string" && r.type.length > 0 && (t.className = r.type), t;
|
|
419
|
-
},
|
|
456
|
+
}, Zn = (r) => {
|
|
420
457
|
const t = {};
|
|
421
458
|
for (const [c, a] of Object.entries(r))
|
|
422
459
|
c !== "children" && (t[c] = a);
|
|
423
460
|
return t;
|
|
424
461
|
};
|
|
425
|
-
function
|
|
426
|
-
const t = Array.isArray(r) ? r : [r], c =
|
|
427
|
-
if (a.length >=
|
|
428
|
-
const
|
|
429
|
-
if (
|
|
430
|
-
const
|
|
462
|
+
function eo(r) {
|
|
463
|
+
const t = Array.isArray(r) ? r : [r], c = zn(t), a = [], m = (p, g) => {
|
|
464
|
+
if (a.length >= Lt) return;
|
|
465
|
+
const C = p.frame;
|
|
466
|
+
if (C && C.width > 0 && C.height > 0 && !Vr(C, c)) {
|
|
467
|
+
const O = p.role_description || p.role || "", M = (typeof p.AXLabel == "string" ? p.AXLabel : "") || (typeof p.title == "string" ? p.title : "") || "";
|
|
431
468
|
a.push({
|
|
432
|
-
id: typeof p.AXUniqueId == "string" && p.AXUniqueId.length > 0 ? p.AXUniqueId :
|
|
433
|
-
path:
|
|
469
|
+
id: typeof p.AXUniqueId == "string" && p.AXUniqueId.length > 0 ? p.AXUniqueId : g,
|
|
470
|
+
path: g,
|
|
434
471
|
label: M,
|
|
435
472
|
value: typeof p.AXValue == "string" ? p.AXValue : "",
|
|
436
|
-
role:
|
|
473
|
+
role: O,
|
|
437
474
|
type: typeof p.type == "string" ? p.type : "",
|
|
438
475
|
enabled: p.enabled !== !1,
|
|
439
476
|
focused: p.focused === !0,
|
|
440
|
-
frame: { x:
|
|
441
|
-
selectors:
|
|
442
|
-
raw:
|
|
477
|
+
frame: { x: C.x, y: C.y, width: C.width, height: C.height },
|
|
478
|
+
selectors: Qn(p),
|
|
479
|
+
raw: Zn(p)
|
|
443
480
|
});
|
|
444
481
|
}
|
|
445
|
-
const
|
|
446
|
-
for (let
|
|
447
|
-
m(
|
|
482
|
+
const w = Array.isArray(p.children) ? p.children : [];
|
|
483
|
+
for (let O = 0; O < w.length && a.length < Lt; O++)
|
|
484
|
+
m(w[O], `${g}.${O}`);
|
|
448
485
|
};
|
|
449
|
-
for (let p = 0; p < t.length && a.length <
|
|
486
|
+
for (let p = 0; p < t.length && a.length < Lt; p++)
|
|
450
487
|
m(t[p], String(p));
|
|
451
488
|
return {
|
|
452
489
|
platform: "ios",
|
|
@@ -455,40 +492,40 @@ function Gn(r) {
|
|
|
455
492
|
capturedAt: Date.now()
|
|
456
493
|
};
|
|
457
494
|
}
|
|
458
|
-
const
|
|
495
|
+
const to = (r) => {
|
|
459
496
|
let t = { x: 0, y: 0, width: 1, height: 1 }, c = 0;
|
|
460
497
|
for (const a of r) {
|
|
461
498
|
const m = a.parsedBounds;
|
|
462
499
|
if (!m) continue;
|
|
463
|
-
const p = m.right - m.left,
|
|
464
|
-
|
|
500
|
+
const p = m.right - m.left, g = m.bottom - m.top, C = Math.max(0, p) * Math.max(0, g);
|
|
501
|
+
C > c && (c = C, t = { x: 0, y: 0, width: p, height: g });
|
|
465
502
|
}
|
|
466
503
|
return t;
|
|
467
|
-
},
|
|
504
|
+
}, ro = (r) => {
|
|
468
505
|
const t = {};
|
|
469
506
|
return typeof r.resourceId == "string" && r.resourceId.length > 0 && (t.resourceId = r.resourceId), typeof r.contentDesc == "string" && r.contentDesc.length > 0 && (t.contentDesc = r.contentDesc), typeof r.text == "string" && r.text.length > 0 && (t.text = r.text), typeof r.className == "string" && r.className.length > 0 && (t.className = r.className), t;
|
|
470
507
|
};
|
|
471
|
-
function
|
|
472
|
-
const t =
|
|
473
|
-
for (let a = 0; a < r.length && c.length <
|
|
508
|
+
function no(r) {
|
|
509
|
+
const t = to(r), c = [];
|
|
510
|
+
for (let a = 0; a < r.length && c.length < Lt; a++) {
|
|
474
511
|
const m = r[a], p = m.parsedBounds;
|
|
475
512
|
if (!p) continue;
|
|
476
|
-
const
|
|
477
|
-
if (
|
|
478
|
-
const
|
|
479
|
-
if (
|
|
480
|
-
const
|
|
513
|
+
const g = Math.max(0, p.right - p.left), C = Math.max(0, p.bottom - p.top);
|
|
514
|
+
if (g <= 0 || C <= 0) continue;
|
|
515
|
+
const w = { x: p.left, y: p.top, width: g, height: C };
|
|
516
|
+
if (Vr(w, { x: 0, y: 0, width: t.width, height: t.height })) continue;
|
|
517
|
+
const O = m.contentDesc || m.text || "", M = m.className || "";
|
|
481
518
|
c.push({
|
|
482
519
|
id: m.resourceId && m.resourceId.length > 0 ? m.resourceId : m.contentDesc && m.contentDesc.length > 0 ? `cd:${m.contentDesc}` : String(a),
|
|
483
520
|
path: String(a),
|
|
484
|
-
label:
|
|
521
|
+
label: O,
|
|
485
522
|
value: typeof m.text == "string" ? m.text : "",
|
|
486
523
|
role: M,
|
|
487
524
|
type: M,
|
|
488
525
|
enabled: m.enabled !== !1,
|
|
489
526
|
focused: m.focused === !0,
|
|
490
|
-
frame:
|
|
491
|
-
selectors:
|
|
527
|
+
frame: w,
|
|
528
|
+
selectors: ro(m),
|
|
492
529
|
raw: { ...m }
|
|
493
530
|
});
|
|
494
531
|
}
|
|
@@ -499,34 +536,34 @@ function zn(r) {
|
|
|
499
536
|
capturedAt: Date.now()
|
|
500
537
|
};
|
|
501
538
|
}
|
|
502
|
-
function
|
|
503
|
-
const c = Math.max(0, r.x), a = Math.max(0, r.y), m = Math.min(t.width, r.x + r.width), p = Math.min(t.height, r.y + r.height),
|
|
504
|
-
return
|
|
539
|
+
function oo(r, t) {
|
|
540
|
+
const c = Math.max(0, r.x), a = Math.max(0, r.y), m = Math.min(t.width, r.x + r.width), p = Math.min(t.height, r.y + r.height), g = Math.max(0, m - c), C = Math.max(0, p - a);
|
|
541
|
+
return g > 0 && C > 0 ? { x: c, y: a, width: g, height: C } : null;
|
|
505
542
|
}
|
|
506
|
-
function
|
|
543
|
+
function Gr(r, t) {
|
|
507
544
|
if (r === t) return !0;
|
|
508
545
|
if (r.id !== t.id || r.path !== t.path || r.label !== t.label || r.value !== t.value || r.role !== t.role || r.type !== t.type || r.enabled !== t.enabled || r.focused !== t.focused) return !1;
|
|
509
546
|
const c = r.frame, a = t.frame;
|
|
510
547
|
return c.x === a.x && c.y === a.y && c.width === a.width && c.height === a.height;
|
|
511
548
|
}
|
|
512
|
-
function
|
|
549
|
+
function Jr(r, t) {
|
|
513
550
|
if (r === t) return !0;
|
|
514
551
|
if (!r || !t || r.platform !== t.platform || r.screen.width !== t.screen.width || r.screen.height !== t.screen.height || r.elements.length !== t.elements.length) return !1;
|
|
515
552
|
for (let c = 0; c < r.elements.length; c++)
|
|
516
|
-
if (!
|
|
553
|
+
if (!Gr(r.elements[c], t.elements[c])) return !1;
|
|
517
554
|
return !0;
|
|
518
555
|
}
|
|
519
|
-
function
|
|
556
|
+
function io(r, t, c) {
|
|
520
557
|
let a = null, m = 1 / 0;
|
|
521
558
|
for (const p of r.elements) {
|
|
522
|
-
const
|
|
523
|
-
if (t <
|
|
524
|
-
const
|
|
525
|
-
|
|
559
|
+
const g = p.frame;
|
|
560
|
+
if (t < g.x || c < g.y || t > g.x + g.width || c > g.y + g.height) continue;
|
|
561
|
+
const C = jn(g);
|
|
562
|
+
C < m && (m = C, a = p);
|
|
526
563
|
}
|
|
527
564
|
return a;
|
|
528
565
|
}
|
|
529
|
-
function
|
|
566
|
+
function co(r, t) {
|
|
530
567
|
if (t === "ios") {
|
|
531
568
|
if (r.selectors.AXUniqueId)
|
|
532
569
|
return `client.tapElement({ AXUniqueId: ${JSON.stringify(r.selectors.AXUniqueId)} })`;
|
|
@@ -538,21 +575,21 @@ function eo(r, t) {
|
|
|
538
575
|
}
|
|
539
576
|
return r.selectors.resourceId ? `client.tap({ selector: { resourceId: ${JSON.stringify(r.selectors.resourceId)} } })` : r.selectors.contentDesc ? `client.tap({ selector: { contentDesc: ${JSON.stringify(r.selectors.contentDesc)} } })` : r.selectors.text ? `client.tap({ selector: { text: ${JSON.stringify(r.selectors.text)} } })` : null;
|
|
540
577
|
}
|
|
541
|
-
function
|
|
578
|
+
function jr(r) {
|
|
542
579
|
const t = r.role || r.type || "";
|
|
543
580
|
if (!t) return "element";
|
|
544
581
|
let c = t.replace(/^AX/, "");
|
|
545
582
|
return c.includes(".") && (c = c.split(".").pop()), c === "GenericElement" ? "Element" : (c = c.replace(/([a-z])([A-Z])/g, "$1 $2"), c);
|
|
546
583
|
}
|
|
547
|
-
const
|
|
548
|
-
function
|
|
549
|
-
const t =
|
|
584
|
+
const Lr = 80;
|
|
585
|
+
function zr(r) {
|
|
586
|
+
const t = jr(r), c = r.label || r.value || "";
|
|
550
587
|
if (!c) return t;
|
|
551
|
-
const a = c.length >
|
|
588
|
+
const a = c.length > Lr ? c.slice(0, Lr).trimEnd() + "…" : c;
|
|
552
589
|
return `${t} · ${a}`;
|
|
553
590
|
}
|
|
554
|
-
const
|
|
555
|
-
class
|
|
591
|
+
const so = 500, ao = 2e3, xr = 5e3, uo = 8e3, lo = 1200, fo = 250, ho = () => `ax-rc-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
592
|
+
class po {
|
|
556
593
|
platform;
|
|
557
594
|
send;
|
|
558
595
|
onSnapshot;
|
|
@@ -579,7 +616,7 @@ class so {
|
|
|
579
616
|
// identical-to-current transitions are no-ops.
|
|
580
617
|
status = "idle";
|
|
581
618
|
constructor(t) {
|
|
582
|
-
this.platform = t.platform, this.send = t.send, this.onSnapshot = t.onSnapshot, this.onStatusChange = t.onStatusChange, this.baseIntervalMs = t.baseIntervalMs ??
|
|
619
|
+
this.platform = t.platform, this.send = t.send, this.onSnapshot = t.onSnapshot, this.onStatusChange = t.onStatusChange, this.baseIntervalMs = t.baseIntervalMs ?? so, this.maxBackoffMs = t.maxBackoffMs ?? ao, this.androidElementTreeOptions = t.androidElementTreeOptions, this.currentInterval = this.baseIntervalMs;
|
|
583
620
|
}
|
|
584
621
|
start() {
|
|
585
622
|
this.running || (this.running = !0, this.currentInterval = this.baseIntervalMs, this.boostUntilMs = 0, this.setStatus("starting"), this.runOnce());
|
|
@@ -611,7 +648,7 @@ class so {
|
|
|
611
648
|
bumpActivity() {
|
|
612
649
|
if (!this.running) return;
|
|
613
650
|
const t = Date.now();
|
|
614
|
-
this.boostUntilMs = t +
|
|
651
|
+
this.boostUntilMs = t + lo;
|
|
615
652
|
const c = Math.max(150, Math.floor(this.baseIntervalMs / 2));
|
|
616
653
|
if (t - this.lastBumpAtMs < c) {
|
|
617
654
|
this.currentInterval = this.baseIntervalMs;
|
|
@@ -643,30 +680,30 @@ class so {
|
|
|
643
680
|
if (!this.pending.get(c)) return !1;
|
|
644
681
|
if (this.platform === "ios") {
|
|
645
682
|
if (t.type !== "elementTreeResult") return !1;
|
|
646
|
-
const
|
|
647
|
-
if (
|
|
648
|
-
return this.settleReject(c, new Error(
|
|
649
|
-
const
|
|
683
|
+
const C = typeof t.error == "string" ? t.error : null;
|
|
684
|
+
if (C)
|
|
685
|
+
return this.settleReject(c, new Error(C)), !0;
|
|
686
|
+
const w = typeof t.json == "string" ? t.json : "";
|
|
650
687
|
try {
|
|
651
|
-
const
|
|
688
|
+
const O = JSON.parse(w), M = eo(O);
|
|
652
689
|
this.settleResolve(c, M);
|
|
653
|
-
} catch (
|
|
654
|
-
this.settleReject(c,
|
|
690
|
+
} catch (O) {
|
|
691
|
+
this.settleReject(c, O instanceof Error ? O : new Error(String(O)));
|
|
655
692
|
}
|
|
656
693
|
return !0;
|
|
657
694
|
}
|
|
658
695
|
if (t.type !== "getElementTreeResult") return !1;
|
|
659
696
|
const m = t.error;
|
|
660
697
|
if (m && typeof m == "object") {
|
|
661
|
-
const
|
|
662
|
-
return this.settleReject(c, new Error(
|
|
698
|
+
const C = typeof m.message == "string" ? m.message : "getElementTree failed";
|
|
699
|
+
return this.settleReject(c, new Error(C)), !0;
|
|
663
700
|
}
|
|
664
|
-
const p = t.payload,
|
|
701
|
+
const p = t.payload, g = Array.isArray(p?.nodes) ? p.nodes : [];
|
|
665
702
|
try {
|
|
666
|
-
const
|
|
667
|
-
this.settleResolve(c,
|
|
668
|
-
} catch (
|
|
669
|
-
this.settleReject(c,
|
|
703
|
+
const C = no(g);
|
|
704
|
+
this.settleResolve(c, C);
|
|
705
|
+
} catch (C) {
|
|
706
|
+
this.settleReject(c, C instanceof Error ? C : new Error(String(C)));
|
|
670
707
|
}
|
|
671
708
|
return !0;
|
|
672
709
|
}
|
|
@@ -674,13 +711,13 @@ class so {
|
|
|
674
711
|
return this.platform === "ios" ? { type: "elementTree", id: t } : { type: "getElementTree", id: t, ...this.androidElementTreeOptions };
|
|
675
712
|
}
|
|
676
713
|
async requestOnce() {
|
|
677
|
-
const t =
|
|
714
|
+
const t = ho();
|
|
678
715
|
return new Promise((c, a) => {
|
|
679
716
|
const m = window.setTimeout(
|
|
680
717
|
() => {
|
|
681
718
|
this.pending.delete(t), a(new Error("elementTree request timed out"));
|
|
682
719
|
},
|
|
683
|
-
|
|
720
|
+
uo + (this.androidElementTreeOptions?.waitForIdleTimeoutMs ?? 0)
|
|
684
721
|
);
|
|
685
722
|
this.pending.set(t, { resolve: c, reject: a, timer: m }), this.send(this.buildRequest(t)) || (window.clearTimeout(m), this.pending.delete(t), a(new Error("elementTree send failed (WebSocket not open)")));
|
|
686
723
|
});
|
|
@@ -695,7 +732,7 @@ class so {
|
|
|
695
732
|
} catch (t) {
|
|
696
733
|
if (!this.running) return;
|
|
697
734
|
const c = t instanceof Error ? t.message : String(t), a = /unavailable|not (yet )?running|failed|timeout/i.test(c);
|
|
698
|
-
this.currentInterval = a ?
|
|
735
|
+
this.currentInterval = a ? xr : Math.min(this.currentInterval * 2, this.maxBackoffMs), this.setStatus(a ? "unavailable" : "error", c);
|
|
699
736
|
} finally {
|
|
700
737
|
this.inflight = !1, this.scheduleNext();
|
|
701
738
|
}
|
|
@@ -703,16 +740,16 @@ class so {
|
|
|
703
740
|
}
|
|
704
741
|
deliver(t) {
|
|
705
742
|
const c = this.lastSnapshot;
|
|
706
|
-
if (
|
|
707
|
-
this.currentInterval = Math.min(this.currentInterval * 2, this.maxBackoffMs), this.lastSnapshot = t, t.errors?.includes(
|
|
743
|
+
if (Jr(c, t)) {
|
|
744
|
+
this.currentInterval = Math.min(this.currentInterval * 2, this.maxBackoffMs), this.lastSnapshot = t, t.errors?.includes(or) || this.setStatus("ready");
|
|
708
745
|
return;
|
|
709
746
|
}
|
|
710
|
-
this.lastSnapshot = t, this.currentInterval = this.baseIntervalMs, t.errors?.includes(
|
|
747
|
+
this.lastSnapshot = t, this.currentInterval = this.baseIntervalMs, t.errors?.includes(or) ? (this.currentInterval = xr, this.setStatus("unavailable", or)) : this.setStatus("ready"), this.onSnapshot(t);
|
|
711
748
|
}
|
|
712
749
|
scheduleNext() {
|
|
713
750
|
if (!this.running) return;
|
|
714
751
|
this.timer !== void 0 && window.clearTimeout(this.timer);
|
|
715
|
-
const t = Date.now() < this.boostUntilMs ? Math.min(
|
|
752
|
+
const t = Date.now() < this.boostUntilMs ? Math.min(fo, this.currentInterval) : this.currentInterval;
|
|
716
753
|
this.timer = window.setTimeout(() => {
|
|
717
754
|
this.timer = void 0, this.runOnce();
|
|
718
755
|
}, t);
|
|
@@ -730,7 +767,7 @@ class so {
|
|
|
730
767
|
window.clearTimeout(a.timer), a.reject(new Error(t)), this.pending.delete(c);
|
|
731
768
|
}
|
|
732
769
|
}
|
|
733
|
-
class
|
|
770
|
+
class mo {
|
|
734
771
|
generation = 0;
|
|
735
772
|
tail = Promise.resolve();
|
|
736
773
|
get currentGeneration() {
|
|
@@ -761,23 +798,23 @@ class ao {
|
|
|
761
798
|
++this.generation;
|
|
762
799
|
}
|
|
763
800
|
}
|
|
764
|
-
function
|
|
801
|
+
function Eo(r) {
|
|
765
802
|
if (!r || typeof r != "object") return null;
|
|
766
803
|
const t = r;
|
|
767
804
|
if (t.type !== "cameraRequest" || typeof t.active != "boolean") return null;
|
|
768
805
|
const c = { active: t.active };
|
|
769
806
|
return (t.facingMode === "user" || t.facingMode === "environment") && (c.facingMode = t.facingMode), c;
|
|
770
807
|
}
|
|
771
|
-
function
|
|
808
|
+
function go(r) {
|
|
772
809
|
const t = {
|
|
773
810
|
frameRate: { ideal: 30, max: 30 }
|
|
774
811
|
};
|
|
775
812
|
return r?.facingMode && (t.facingMode = { ideal: r.facingMode }), t;
|
|
776
813
|
}
|
|
777
|
-
function
|
|
814
|
+
function yo(r, t) {
|
|
778
815
|
return !r || r.facingMode !== t.facingMode;
|
|
779
816
|
}
|
|
780
|
-
function
|
|
817
|
+
function Co(r) {
|
|
781
818
|
const t = r.getSettings();
|
|
782
819
|
return {
|
|
783
820
|
width: t.width,
|
|
@@ -788,14 +825,14 @@ function ho(r) {
|
|
|
788
825
|
facingMode: t.facingMode
|
|
789
826
|
};
|
|
790
827
|
}
|
|
791
|
-
function
|
|
828
|
+
function vo(r) {
|
|
792
829
|
return {
|
|
793
830
|
type: "cameraResult",
|
|
794
831
|
granted: !0,
|
|
795
|
-
camera:
|
|
832
|
+
camera: Co(r)
|
|
796
833
|
};
|
|
797
834
|
}
|
|
798
|
-
const
|
|
835
|
+
const Oo = async (r) => {
|
|
799
836
|
if (!r) return !1;
|
|
800
837
|
try {
|
|
801
838
|
if (typeof navigator < "u" && navigator.clipboard?.writeText)
|
|
@@ -810,90 +847,90 @@ const mo = async (r) => {
|
|
|
810
847
|
} catch {
|
|
811
848
|
return !1;
|
|
812
849
|
}
|
|
813
|
-
},
|
|
814
|
-
function({ element: t, screen: c, highlighted: a, selected: m, selectable: p, onClick:
|
|
815
|
-
const
|
|
816
|
-
if (!
|
|
817
|
-
const
|
|
818
|
-
return /* @__PURE__ */
|
|
850
|
+
}, _o = cr(
|
|
851
|
+
function({ element: t, screen: c, highlighted: a, selected: m, selectable: p, onClick: g }) {
|
|
852
|
+
const C = oo(t.frame, c);
|
|
853
|
+
if (!C) return null;
|
|
854
|
+
const w = zr(t);
|
|
855
|
+
return /* @__PURE__ */ P(
|
|
819
856
|
"button",
|
|
820
857
|
{
|
|
821
858
|
type: "button",
|
|
822
|
-
className:
|
|
859
|
+
className: Pe("rc-inspect-box", !t.enabled && "rc-inspect-box-disabled"),
|
|
823
860
|
"data-ax-id": t.id,
|
|
824
861
|
"data-ax-path": t.path,
|
|
825
862
|
"data-ax-label": t.label || void 0,
|
|
826
863
|
"data-ax-role": t.role || void 0,
|
|
827
864
|
"data-highlighted": a ? "true" : "false",
|
|
828
865
|
"data-selected": m ? "true" : "false",
|
|
829
|
-
"aria-label":
|
|
830
|
-
onClick: (
|
|
831
|
-
p && (
|
|
866
|
+
"aria-label": w,
|
|
867
|
+
onClick: (O) => {
|
|
868
|
+
p && (O.preventDefault(), O.stopPropagation(), g(t, { x: O.clientX, y: O.clientY }));
|
|
832
869
|
},
|
|
833
870
|
style: {
|
|
834
|
-
left: `${
|
|
835
|
-
top: `${
|
|
836
|
-
width: `${
|
|
837
|
-
height: `${
|
|
871
|
+
left: `${C.x / c.width * 100}%`,
|
|
872
|
+
top: `${C.y / c.height * 100}%`,
|
|
873
|
+
width: `${C.width / c.width * 100}%`,
|
|
874
|
+
height: `${C.height / c.height * 100}%`
|
|
838
875
|
}
|
|
839
876
|
}
|
|
840
877
|
);
|
|
841
878
|
},
|
|
842
|
-
(r, t) => r.highlighted === t.highlighted && r.selected === t.selected && r.selectable === t.selectable && r.screen.width === t.screen.width && r.screen.height === t.screen.height && r.onClick === t.onClick &&
|
|
843
|
-
),
|
|
879
|
+
(r, t) => r.highlighted === t.highlighted && r.selected === t.selected && r.selectable === t.selectable && r.screen.width === t.screen.width && r.screen.height === t.screen.height && r.onClick === t.onClick && Gr(r.element, t.element)
|
|
880
|
+
), To = 260, wo = 220, Do = 6, Ao = 8, bo = cr(function({
|
|
844
881
|
element: t,
|
|
845
882
|
platform: c,
|
|
846
883
|
anchor: a,
|
|
847
884
|
cursorAnchored: m,
|
|
848
885
|
showActions: p,
|
|
849
|
-
onTap:
|
|
886
|
+
onTap: g
|
|
850
887
|
}) {
|
|
851
|
-
const [
|
|
852
|
-
|
|
853
|
-
if (!
|
|
854
|
-
const
|
|
855
|
-
return () => window.clearTimeout(
|
|
856
|
-
}, [
|
|
857
|
-
const
|
|
858
|
-
const
|
|
859
|
-
let
|
|
860
|
-
const
|
|
861
|
-
return
|
|
862
|
-
}, [a.x, a.y]), M =
|
|
863
|
-
if (!
|
|
864
|
-
await
|
|
865
|
-
}, []), J =
|
|
866
|
-
return
|
|
867
|
-
/* @__PURE__ */
|
|
888
|
+
const [C, w] = G(null);
|
|
889
|
+
me(() => {
|
|
890
|
+
if (!C) return;
|
|
891
|
+
const B = window.setTimeout(() => w(null), 1100);
|
|
892
|
+
return () => window.clearTimeout(B);
|
|
893
|
+
}, [C]);
|
|
894
|
+
const O = ke(() => {
|
|
895
|
+
const B = To, Ee = wo, se = Do, H = Ao, ge = typeof window < "u" ? window.innerWidth : 1024, tt = typeof window < "u" ? window.innerHeight : 768, De = a.x + se + B <= ge - H, Ue = a.y - se - Ee >= H;
|
|
896
|
+
let _e = De ? a.x + se : a.x - se, W = Ue ? a.y - se : a.y + se;
|
|
897
|
+
const Wt = `translate(${De ? "0" : "-100%"}, ${Ue ? "-100%" : "0"})`;
|
|
898
|
+
return _e = Math.max(H + (De ? 0 : B), Math.min(ge - H - (De ? B : 0), _e)), W = Math.max(H + (Ue ? Ee : 0), Math.min(tt - H - (Ue ? 0 : Ee), W)), { left: `${_e}px`, top: `${W}px`, transform: Wt };
|
|
899
|
+
}, [a.x, a.y]), M = ke(() => co(t, c), [t, c]), S = c === "ios" ? t.selectors.AXUniqueId : t.selectors.resourceId, X = c === "ios" ? "AXUniqueId" : "resourceId", ce = Un(async (B, Ee) => {
|
|
900
|
+
if (!B) return;
|
|
901
|
+
await Oo(B) && w(Ee);
|
|
902
|
+
}, []), J = jr(t), fe = t.label || t.value || J, ee = zr(t);
|
|
903
|
+
return Hn(
|
|
904
|
+
/* @__PURE__ */ ue(
|
|
868
905
|
"div",
|
|
869
906
|
{
|
|
870
907
|
className: "rc-inspect-card",
|
|
871
908
|
"data-cursor-anchored": m ? "true" : "false",
|
|
872
|
-
style:
|
|
873
|
-
onClick: (
|
|
874
|
-
onMouseDown: (
|
|
875
|
-
onMouseMove: (
|
|
909
|
+
style: O,
|
|
910
|
+
onClick: (B) => B.stopPropagation(),
|
|
911
|
+
onMouseDown: (B) => B.stopPropagation(),
|
|
912
|
+
onMouseMove: (B) => B.stopPropagation(),
|
|
876
913
|
children: [
|
|
877
|
-
/* @__PURE__ */
|
|
878
|
-
/* @__PURE__ */
|
|
879
|
-
!t.enabled && /* @__PURE__ */
|
|
880
|
-
t.focused && /* @__PURE__ */
|
|
914
|
+
/* @__PURE__ */ ue("div", { className: "rc-inspect-card-header", children: [
|
|
915
|
+
/* @__PURE__ */ P("span", { className: "rc-inspect-card-role", children: J }),
|
|
916
|
+
!t.enabled && /* @__PURE__ */ P("span", { className: "rc-inspect-card-tag", children: "disabled" }),
|
|
917
|
+
t.focused && /* @__PURE__ */ P("span", { className: "rc-inspect-card-tag rc-inspect-card-tag-blue", children: "focused" })
|
|
881
918
|
] }),
|
|
882
|
-
/* @__PURE__ */
|
|
883
|
-
S && /* @__PURE__ */
|
|
884
|
-
/* @__PURE__ */
|
|
885
|
-
|
|
919
|
+
/* @__PURE__ */ P("p", { className: "rc-inspect-card-title", title: ee, children: fe }),
|
|
920
|
+
S && /* @__PURE__ */ ue("div", { className: "rc-inspect-card-row", children: [
|
|
921
|
+
/* @__PURE__ */ ue("span", { className: "rc-inspect-card-row-label", children: [
|
|
922
|
+
X,
|
|
886
923
|
":"
|
|
887
924
|
] }),
|
|
888
|
-
/* @__PURE__ */
|
|
925
|
+
/* @__PURE__ */ P("span", { className: "rc-inspect-card-row-value", children: S })
|
|
889
926
|
] }),
|
|
890
|
-
t.value && t.value !== t.label && /* @__PURE__ */
|
|
891
|
-
/* @__PURE__ */
|
|
892
|
-
/* @__PURE__ */
|
|
927
|
+
t.value && t.value !== t.label && /* @__PURE__ */ ue("div", { className: "rc-inspect-card-row", children: [
|
|
928
|
+
/* @__PURE__ */ P("span", { className: "rc-inspect-card-row-label", children: "value:" }),
|
|
929
|
+
/* @__PURE__ */ P("span", { className: "rc-inspect-card-row-value", children: t.value })
|
|
893
930
|
] }),
|
|
894
|
-
/* @__PURE__ */
|
|
895
|
-
/* @__PURE__ */
|
|
896
|
-
/* @__PURE__ */
|
|
931
|
+
/* @__PURE__ */ ue("div", { className: "rc-inspect-card-row", children: [
|
|
932
|
+
/* @__PURE__ */ P("span", { className: "rc-inspect-card-row-label", children: "frame:" }),
|
|
933
|
+
/* @__PURE__ */ ue("span", { className: "rc-inspect-card-row-value", children: [
|
|
897
934
|
Math.round(t.frame.width),
|
|
898
935
|
"×",
|
|
899
936
|
Math.round(t.frame.height),
|
|
@@ -903,36 +940,36 @@ const mo = async (r) => {
|
|
|
903
940
|
Math.round(t.frame.y)
|
|
904
941
|
] })
|
|
905
942
|
] }),
|
|
906
|
-
p && /* @__PURE__ */
|
|
907
|
-
/* @__PURE__ */
|
|
943
|
+
p && /* @__PURE__ */ ue("div", { className: "rc-inspect-card-actions", children: [
|
|
944
|
+
/* @__PURE__ */ P(
|
|
908
945
|
"button",
|
|
909
946
|
{
|
|
910
947
|
type: "button",
|
|
911
948
|
className: "rc-inspect-card-btn rc-inspect-card-btn-primary",
|
|
912
|
-
onClick: () =>
|
|
949
|
+
onClick: () => g(t, a),
|
|
913
950
|
children: "Tap"
|
|
914
951
|
}
|
|
915
952
|
),
|
|
916
|
-
/* @__PURE__ */
|
|
953
|
+
/* @__PURE__ */ P(
|
|
917
954
|
"button",
|
|
918
955
|
{
|
|
919
956
|
type: "button",
|
|
920
|
-
className:
|
|
957
|
+
className: Pe("rc-inspect-card-btn", C === "selector" && "rc-inspect-card-btn-copied"),
|
|
921
958
|
disabled: !M,
|
|
922
959
|
title: M ?? "No usable selector for this element",
|
|
923
|
-
onClick: () =>
|
|
924
|
-
children:
|
|
960
|
+
onClick: () => ce(M ?? void 0, "selector"),
|
|
961
|
+
children: C === "selector" ? "Copied!" : "Copy selector"
|
|
925
962
|
}
|
|
926
963
|
),
|
|
927
|
-
/* @__PURE__ */
|
|
964
|
+
/* @__PURE__ */ P(
|
|
928
965
|
"button",
|
|
929
966
|
{
|
|
930
967
|
type: "button",
|
|
931
|
-
className:
|
|
968
|
+
className: Pe("rc-inspect-card-btn", C === "id" && "rc-inspect-card-btn-copied"),
|
|
932
969
|
disabled: !S,
|
|
933
|
-
title: S ?? `No ${
|
|
934
|
-
onClick: () =>
|
|
935
|
-
children:
|
|
970
|
+
title: S ?? `No ${X}`,
|
|
971
|
+
onClick: () => ce(S, "id"),
|
|
972
|
+
children: C === "id" ? "Copied!" : `Copy ${X}`
|
|
936
973
|
}
|
|
937
974
|
)
|
|
938
975
|
] })
|
|
@@ -941,68 +978,68 @@ const mo = async (r) => {
|
|
|
941
978
|
),
|
|
942
979
|
document.body
|
|
943
980
|
);
|
|
944
|
-
}),
|
|
981
|
+
}), So = cr(function({
|
|
945
982
|
snapshot: t,
|
|
946
983
|
geometry: c,
|
|
947
984
|
highlightedId: a,
|
|
948
985
|
selectedId: m,
|
|
949
986
|
mode: p,
|
|
950
|
-
cursorPosition:
|
|
951
|
-
frozenCursorPosition:
|
|
952
|
-
onSelectChange:
|
|
953
|
-
onTapElement:
|
|
987
|
+
cursorPosition: g,
|
|
988
|
+
frozenCursorPosition: C,
|
|
989
|
+
onSelectChange: w,
|
|
990
|
+
onTapElement: O
|
|
954
991
|
}) {
|
|
955
|
-
const M = p === "select", S = M ? a !== null && a !== m : a !== null,
|
|
992
|
+
const M = p === "select", S = M ? a !== null && a !== m : a !== null, X = M ? a ?? m : a, ce = ke(() => {
|
|
956
993
|
const H = /* @__PURE__ */ new Map();
|
|
957
994
|
if (!t) return H;
|
|
958
|
-
for (const
|
|
995
|
+
for (const ge of t.elements) H.set(ge.id, ge);
|
|
959
996
|
return H;
|
|
960
|
-
}, [t]), J =
|
|
997
|
+
}, [t]), J = ke(() => X ? ce.get(X) ?? null : null, [X, ce]);
|
|
961
998
|
if (!(!!t && !!c && t.screen.width > 0 && t.screen.height > 0 && t.elements.length > 0)) return null;
|
|
962
|
-
const
|
|
963
|
-
M && H.target === H.currentTarget &&
|
|
999
|
+
const ee = S ? g : C ?? g, B = S, Ee = M && !S && m !== null, se = (H) => {
|
|
1000
|
+
M && H.target === H.currentTarget && w(null, null);
|
|
964
1001
|
};
|
|
965
|
-
return /* @__PURE__ */
|
|
966
|
-
/* @__PURE__ */
|
|
1002
|
+
return /* @__PURE__ */ ue($r, { children: [
|
|
1003
|
+
/* @__PURE__ */ P(
|
|
967
1004
|
"div",
|
|
968
1005
|
{
|
|
969
|
-
className:
|
|
1006
|
+
className: Pe("rc-inspect-overlay", M && "rc-inspect-overlay-select"),
|
|
970
1007
|
style: {
|
|
971
1008
|
left: `${c.left}px`,
|
|
972
1009
|
top: `${c.top}px`,
|
|
973
1010
|
width: `${c.width}px`,
|
|
974
1011
|
height: `${c.height}px`
|
|
975
1012
|
},
|
|
976
|
-
onClick:
|
|
977
|
-
children: t.elements.map((H) => /* @__PURE__ */
|
|
978
|
-
|
|
1013
|
+
onClick: se,
|
|
1014
|
+
children: t.elements.map((H) => /* @__PURE__ */ P(
|
|
1015
|
+
_o,
|
|
979
1016
|
{
|
|
980
1017
|
element: H,
|
|
981
1018
|
screen: t.screen,
|
|
982
1019
|
highlighted: H.id === a,
|
|
983
1020
|
selected: H.id === m,
|
|
984
1021
|
selectable: M,
|
|
985
|
-
onClick:
|
|
1022
|
+
onClick: w
|
|
986
1023
|
},
|
|
987
1024
|
H.id
|
|
988
1025
|
))
|
|
989
1026
|
}
|
|
990
1027
|
),
|
|
991
|
-
J &&
|
|
992
|
-
|
|
1028
|
+
J && ee && /* @__PURE__ */ P(
|
|
1029
|
+
bo,
|
|
993
1030
|
{
|
|
994
1031
|
element: J,
|
|
995
1032
|
platform: t.platform,
|
|
996
|
-
anchor:
|
|
997
|
-
cursorAnchored:
|
|
998
|
-
showActions:
|
|
999
|
-
onTap:
|
|
1033
|
+
anchor: ee,
|
|
1034
|
+
cursorAnchored: B,
|
|
1035
|
+
showActions: Ee,
|
|
1036
|
+
onTap: O
|
|
1000
1037
|
}
|
|
1001
1038
|
)
|
|
1002
1039
|
] });
|
|
1003
|
-
}),
|
|
1040
|
+
}), Mo = Ln(() => import("./duo-view-DSZO0-zg.mjs").then((r) => r.d)), F = (...r) => {
|
|
1004
1041
|
window.debugRemoteControl && console.log(...r);
|
|
1005
|
-
},
|
|
1042
|
+
}, A = (...r) => {
|
|
1006
1043
|
window.debugRemoteControl && console.warn(...r);
|
|
1007
1044
|
}, L = (r, t, ...c) => {
|
|
1008
1045
|
if (t)
|
|
@@ -1011,12 +1048,12 @@ const mo = async (r) => {
|
|
|
1011
1048
|
} catch (a) {
|
|
1012
1049
|
console.error(`[RemoteControl] customer callback "${r}" threw:`, a);
|
|
1013
1050
|
}
|
|
1014
|
-
},
|
|
1051
|
+
}, Ut = (r) => Object.entries(K).find(
|
|
1015
1052
|
([c, a]) => c.startsWith("ACTION_") && a === r
|
|
1016
|
-
)?.[0] ?? String(r),
|
|
1053
|
+
)?.[0] ?? String(r), Ro = (r) => r.includes("/android_") ? "android" : "ios", Fr = (r, t) => {
|
|
1017
1054
|
const c = new URL(r);
|
|
1018
1055
|
return c.searchParams.set("token", t), c.toString();
|
|
1019
|
-
},
|
|
1056
|
+
}, Wr = 1920, Hr = 1200, ir = 3, No = 1e3, Io = 15e3, Yo = 3e3, Ko = 4e3, ko = (r, t) => r === Wr && t === Hr || r === Hr && t === Wr, Po = {
|
|
1020
1057
|
ios: {
|
|
1021
1058
|
videoBorderRadiusMultiplier: 0.15,
|
|
1022
1059
|
loadingLogoSize: "20%",
|
|
@@ -1036,16 +1073,16 @@ const mo = async (r) => {
|
|
|
1036
1073
|
}
|
|
1037
1074
|
}
|
|
1038
1075
|
};
|
|
1039
|
-
function
|
|
1040
|
-
const t = r.code, c =
|
|
1076
|
+
function Uo(r) {
|
|
1077
|
+
const t = r.code, c = Br[t];
|
|
1041
1078
|
if (!c)
|
|
1042
|
-
return
|
|
1079
|
+
return A(`Unknown event.code: ${t}, key: ${r.key}`), null;
|
|
1043
1080
|
let a = s.META_NONE;
|
|
1044
|
-
const m = t >= "KeyA" && t <= "KeyZ", p = r.getModifierState("CapsLock"),
|
|
1045
|
-
let
|
|
1046
|
-
return m && (
|
|
1081
|
+
const m = t >= "KeyA" && t <= "KeyZ", p = r.getModifierState("CapsLock"), g = r.shiftKey;
|
|
1082
|
+
let C = g;
|
|
1083
|
+
return m && (C = g !== p), C && (a |= s.META_SHIFT_ON), r.ctrlKey && (a |= s.META_CTRL_ON), r.altKey && (a |= s.META_ALT_ON), r.metaKey && (a |= s.META_META_ON), { keycode: c, metaState: a };
|
|
1047
1084
|
}
|
|
1048
|
-
const
|
|
1085
|
+
const jo = xn(
|
|
1049
1086
|
({
|
|
1050
1087
|
className: r,
|
|
1051
1088
|
url: t,
|
|
@@ -1053,115 +1090,118 @@ const Xo = Kn(
|
|
|
1053
1090
|
sessionId: a,
|
|
1054
1091
|
openUrl: m,
|
|
1055
1092
|
showFrame: p = !0,
|
|
1056
|
-
deviceModel:
|
|
1057
|
-
duoModelUrl:
|
|
1058
|
-
autoReconnect:
|
|
1059
|
-
onTerminated:
|
|
1093
|
+
deviceModel: g,
|
|
1094
|
+
duoModelUrl: C,
|
|
1095
|
+
autoReconnect: w = !1,
|
|
1096
|
+
onTerminated: O,
|
|
1060
1097
|
assets: M,
|
|
1061
1098
|
onConnectionStateChange: S,
|
|
1062
|
-
inspectMode:
|
|
1063
|
-
onAxSnapshotChange:
|
|
1099
|
+
inspectMode: X,
|
|
1100
|
+
onAxSnapshotChange: ce,
|
|
1064
1101
|
onInspectSelectionChange: J,
|
|
1065
|
-
onAxStatusChange:
|
|
1066
|
-
axPollIntervalMs:
|
|
1067
|
-
axMaxBackoffMs:
|
|
1068
|
-
androidElementTreeOptions:
|
|
1069
|
-
onCameraDemandChange:
|
|
1102
|
+
onAxStatusChange: fe,
|
|
1103
|
+
axPollIntervalMs: ee,
|
|
1104
|
+
axMaxBackoffMs: B,
|
|
1105
|
+
androidElementTreeOptions: Ee,
|
|
1106
|
+
onCameraDemandChange: se,
|
|
1070
1107
|
onCameraStats: H,
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1108
|
+
onTrace: ge,
|
|
1109
|
+
microphoneEnabled: tt = !1,
|
|
1110
|
+
onMicrophoneStateChange: De
|
|
1111
|
+
}, Ue) => {
|
|
1112
|
+
const _e = v(null), W = v(null), rt = v(/* @__PURE__ */ new Map()), Ft = v(null), [Wt, Qr] = G(!1), ye = g === "iphone-duo" || Wt, nt = v(null), [sr, ar] = G(null), [ur, lr] = G(), Le = v(
|
|
1075
1113
|
/* @__PURE__ */ new Map()
|
|
1076
|
-
),
|
|
1077
|
-
const l =
|
|
1114
|
+
), Ht = (e, i) => new Promise((o, n) => {
|
|
1115
|
+
const l = D.current;
|
|
1078
1116
|
if (!l || l.readyState !== WebSocket.OPEN) {
|
|
1079
1117
|
n(new Error("Simulator disconnected"));
|
|
1080
1118
|
return;
|
|
1081
1119
|
}
|
|
1082
1120
|
const u = crypto.randomUUID(), f = setTimeout(() => {
|
|
1083
|
-
|
|
1121
|
+
Le.current.delete(u), n(new Error("Device control timed out"));
|
|
1084
1122
|
}, 5e3);
|
|
1085
|
-
|
|
1086
|
-
}), [
|
|
1087
|
-
|
|
1088
|
-
const
|
|
1089
|
-
|
|
1090
|
-
const
|
|
1091
|
-
|
|
1092
|
-
const
|
|
1093
|
-
|
|
1094
|
-
const
|
|
1095
|
-
|
|
1096
|
-
const
|
|
1123
|
+
Le.current.set(u, { resolve: o, reject: n, timer: f }), l.send(JSON.stringify({ type: e, id: u, ...i }));
|
|
1124
|
+
}), [Zr, $t] = G(!1), [en, yt] = G(!1), [tn, dr] = G(!1), xe = v(!1), Xt = v(!1), [fr, rn] = G(!1), [nn, on] = G(!1), [cn, hr] = G({}), D = v(null), x = v(null), U = v(null), Ct = v(null), Bt = v(ge);
|
|
1125
|
+
Bt.current = ge;
|
|
1126
|
+
const sn = !!ge, Fe = v(void 0), ot = v(void 0), it = v(void 0), vt = v(void 0), We = v(void 0), Ae = v(0), Ot = v(0), Ce = v(!1), qt = v(w);
|
|
1127
|
+
qt.current = w;
|
|
1128
|
+
const be = v(null), ne = v(null), Se = v(void 0), Vt = ke(() => new mo(), []), ve = v(se);
|
|
1129
|
+
ve.current = se;
|
|
1130
|
+
const _t = v(H);
|
|
1131
|
+
_t.current = H;
|
|
1132
|
+
const ct = v(null), Tt = v(null), Gt = v(tt);
|
|
1133
|
+
Gt.current = tt;
|
|
1134
|
+
const Jt = v(!1), st = v(De);
|
|
1135
|
+
st.current = De;
|
|
1136
|
+
const at = v(null), he = v(null), wt = v(0), pr = v(Promise.resolve()), He = v(null), ut = v(!1), Te = v(/* @__PURE__ */ new Map()), Oe = v(/* @__PURE__ */ new Map()), Me = v(/* @__PURE__ */ new Map()), Re = v(/* @__PURE__ */ new Map()), Z = v(/* @__PURE__ */ new Map()), Ne = v(!1), [an, un] = G(!1), q = v(null), $e = v(null), lt = v({
|
|
1097
1137
|
handle: () => {
|
|
1098
1138
|
},
|
|
1099
1139
|
end: () => {
|
|
1100
1140
|
}
|
|
1101
|
-
}), [
|
|
1102
|
-
|
|
1103
|
-
|
|
1141
|
+
}), [Ie, Dt] = G(null), te = v(null), [mr, Er] = G(null), [jt, dt] = G(null), [zt, At] = G(null), [ln, gr] = G(null), [dn, yr] = G(null), bt = v(null), ae = v(void 0), Cr = (e) => {
|
|
1142
|
+
bt.current = e, ae.current === void 0 && (ae.current = window.requestAnimationFrame(() => {
|
|
1143
|
+
ae.current = void 0, yr(bt.current);
|
|
1104
1144
|
}));
|
|
1105
|
-
}, [
|
|
1106
|
-
|
|
1107
|
-
const
|
|
1108
|
-
|
|
1109
|
-
const
|
|
1110
|
-
|
|
1111
|
-
const
|
|
1112
|
-
|
|
1113
|
-
const
|
|
1114
|
-
|
|
1115
|
-
const
|
|
1116
|
-
|
|
1117
|
-
const
|
|
1118
|
-
|
|
1119
|
-
const
|
|
1120
|
-
|
|
1121
|
-
},
|
|
1145
|
+
}, [fn, Xe] = G(null), Be = v(X);
|
|
1146
|
+
Be.current = X;
|
|
1147
|
+
const qe = v(null);
|
|
1148
|
+
qe.current = mr;
|
|
1149
|
+
const Qt = v(ce);
|
|
1150
|
+
Qt.current = ce;
|
|
1151
|
+
const Ve = v(J);
|
|
1152
|
+
Ve.current = J;
|
|
1153
|
+
const vr = v(fe);
|
|
1154
|
+
vr.current = fe;
|
|
1155
|
+
const Or = v(O);
|
|
1156
|
+
Or.current = O;
|
|
1157
|
+
const _r = v(S);
|
|
1158
|
+
_r.current = S;
|
|
1159
|
+
const Zt = v(null), Ge = (e) => {
|
|
1160
|
+
Zt.current !== e && (Zt.current = e, L("onConnectionStateChange", _r.current, e));
|
|
1161
|
+
}, ft = X === !0 || X === "hover-only", hn = X === "hover-only" ? "hover-only" : "select", le = ke(
|
|
1122
1162
|
() => a || Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15),
|
|
1123
1163
|
[a]
|
|
1124
|
-
),
|
|
1125
|
-
|
|
1126
|
-
},
|
|
1127
|
-
!
|
|
1128
|
-
},
|
|
1129
|
-
const o =
|
|
1164
|
+
), pe = ke(() => Ro(t), [t]), Je = Po[pe], ht = M?.[pe], Tr = pe === "android" && nn ? fr ? ht?.tabletFrameLandscape : ht?.tabletFrame : fr ? ht?.frameLandscape : ht?.frame, wr = ht?.loadingLogo, St = !ye && p && !!Tr, k = (e) => {
|
|
1165
|
+
F(e);
|
|
1166
|
+
}, de = (e) => {
|
|
1167
|
+
!U.current || U.current.readyState !== "open" || (U.current.send(Ct.current?.wrap(e) ?? e), te.current?.bumpActivity());
|
|
1168
|
+
}, Dr = -10, Ar = (e, i) => {
|
|
1169
|
+
const o = pt();
|
|
1130
1170
|
if (!o) return;
|
|
1131
|
-
const n =
|
|
1171
|
+
const n = ze(o, e, i);
|
|
1132
1172
|
if (!n) return;
|
|
1133
|
-
const { videoX: l, videoY: u, videoWidth: f, videoHeight: E } = n,
|
|
1134
|
-
|
|
1135
|
-
|
|
1173
|
+
const { videoX: l, videoY: u, videoWidth: f, videoHeight: E } = n, y = Pt(
|
|
1174
|
+
K.ACTION_DOWN,
|
|
1175
|
+
Dr,
|
|
1136
1176
|
f,
|
|
1137
1177
|
E,
|
|
1138
1178
|
l,
|
|
1139
1179
|
u,
|
|
1140
1180
|
1,
|
|
1141
|
-
|
|
1142
|
-
|
|
1181
|
+
K.BUTTON_PRIMARY,
|
|
1182
|
+
K.BUTTON_PRIMARY
|
|
1143
1183
|
);
|
|
1144
|
-
|
|
1145
|
-
const h =
|
|
1146
|
-
|
|
1147
|
-
|
|
1184
|
+
y && de(y), window.setTimeout(() => {
|
|
1185
|
+
const h = Pt(
|
|
1186
|
+
K.ACTION_UP,
|
|
1187
|
+
Dr,
|
|
1148
1188
|
f,
|
|
1149
1189
|
E,
|
|
1150
1190
|
l,
|
|
1151
1191
|
u,
|
|
1152
1192
|
0,
|
|
1153
|
-
|
|
1154
|
-
|
|
1193
|
+
K.BUTTON_PRIMARY,
|
|
1194
|
+
K.BUTTON_PRIMARY
|
|
1155
1195
|
);
|
|
1156
|
-
h &&
|
|
1196
|
+
h && de(h);
|
|
1157
1197
|
}, 60);
|
|
1158
|
-
},
|
|
1159
|
-
const o =
|
|
1198
|
+
}, pn = (e, i) => {
|
|
1199
|
+
const o = pt();
|
|
1160
1200
|
if (!o || i.screen.width <= 0 || i.screen.height <= 0) return;
|
|
1161
|
-
const n = e.frame.x + e.frame.width / 2, l = e.frame.y + e.frame.height / 2, u = n / i.screen.width * o.actualWidth, f = l / i.screen.height * o.actualHeight, E = o.videoRect.left + o.offsetX + u,
|
|
1162
|
-
|
|
1163
|
-
},
|
|
1164
|
-
const f =
|
|
1201
|
+
const n = e.frame.x + e.frame.width / 2, l = e.frame.y + e.frame.height / 2, u = n / i.screen.width * o.actualWidth, f = l / i.screen.height * o.actualHeight, E = o.videoRect.left + o.offsetX + u, y = o.videoRect.top + o.offsetY + f;
|
|
1202
|
+
Ar(E, y);
|
|
1203
|
+
}, Mt = -1, Rt = -2, Ye = -3, je = (e, i, o, n, l, u) => {
|
|
1204
|
+
const f = Pt(
|
|
1165
1205
|
e,
|
|
1166
1206
|
i,
|
|
1167
1207
|
o,
|
|
@@ -1170,182 +1210,182 @@ const Xo = Kn(
|
|
|
1170
1210
|
u,
|
|
1171
1211
|
1,
|
|
1172
1212
|
// pressure
|
|
1173
|
-
|
|
1174
|
-
|
|
1213
|
+
K.BUTTON_PRIMARY,
|
|
1214
|
+
K.BUTTON_PRIMARY
|
|
1175
1215
|
);
|
|
1176
|
-
f && (
|
|
1216
|
+
f && (F("[rc-touch] sendSingleTouch", {
|
|
1177
1217
|
action: e,
|
|
1178
|
-
actionName:
|
|
1218
|
+
actionName: Ut(e),
|
|
1179
1219
|
pointerId: i,
|
|
1180
1220
|
x: l,
|
|
1181
1221
|
y: u,
|
|
1182
1222
|
video: { width: o, height: n }
|
|
1183
|
-
}),
|
|
1184
|
-
},
|
|
1223
|
+
}), de(f));
|
|
1224
|
+
}, Ke = (e, i, o) => {
|
|
1185
1225
|
if (!o) return;
|
|
1186
1226
|
const { videoX: n, videoY: l, videoWidth: u, videoHeight: f } = o;
|
|
1187
|
-
let E = null,
|
|
1188
|
-
const R =
|
|
1227
|
+
let E = null, y = null, h = 1;
|
|
1228
|
+
const R = K.BUTTON_PRIMARY;
|
|
1189
1229
|
switch (i) {
|
|
1190
1230
|
case "down":
|
|
1191
|
-
e !==
|
|
1231
|
+
e !== Ye && lt.current.end(), E = Z.current.size === 0 ? K.ACTION_DOWN : K.ACTION_POINTER_DOWN, y = { x: n, y: l }, Z.current.set(e, y), e === -1 && W.current?.focus();
|
|
1192
1232
|
break;
|
|
1193
1233
|
case "move":
|
|
1194
|
-
|
|
1234
|
+
Z.current.has(e) && (E = K.ACTION_MOVE, y = { x: n, y: l }, Z.current.set(e, y));
|
|
1195
1235
|
break;
|
|
1196
1236
|
case "up":
|
|
1197
1237
|
case "cancel":
|
|
1198
|
-
|
|
1238
|
+
Z.current.has(e) && (y = Z.current.get(e), Z.current.delete(e), i === "cancel" ? E = K.ACTION_CANCEL : E = Z.current.size === 0 ? K.ACTION_UP : K.ACTION_POINTER_UP);
|
|
1199
1239
|
break;
|
|
1200
1240
|
}
|
|
1201
|
-
if (E !== null &&
|
|
1202
|
-
|
|
1241
|
+
if (E !== null && y !== null) {
|
|
1242
|
+
F("[rc-touch][mouse->touch] sending", {
|
|
1203
1243
|
pointerId: e,
|
|
1204
1244
|
eventType: i,
|
|
1205
1245
|
action: E,
|
|
1206
|
-
actionName:
|
|
1207
|
-
positionToSend:
|
|
1246
|
+
actionName: Ut(E),
|
|
1247
|
+
positionToSend: y,
|
|
1208
1248
|
video: { width: u, height: f },
|
|
1209
|
-
altHeld:
|
|
1210
|
-
activePointersAfter: Array.from(
|
|
1249
|
+
altHeld: Ne.current,
|
|
1250
|
+
activePointersAfter: Array.from(Z.current.entries()).map(([N, $]) => ({
|
|
1211
1251
|
id: N,
|
|
1212
1252
|
x: $.x,
|
|
1213
1253
|
y: $.y
|
|
1214
1254
|
}))
|
|
1215
1255
|
});
|
|
1216
|
-
const
|
|
1256
|
+
const _ = Pt(
|
|
1217
1257
|
E,
|
|
1218
1258
|
e,
|
|
1219
1259
|
u,
|
|
1220
1260
|
f,
|
|
1221
|
-
|
|
1222
|
-
|
|
1261
|
+
y.x,
|
|
1262
|
+
y.y,
|
|
1223
1263
|
h,
|
|
1224
1264
|
R,
|
|
1225
1265
|
R
|
|
1226
1266
|
);
|
|
1227
|
-
|
|
1267
|
+
_ && (F("[rc-touch][mouse->touch] buffer", {
|
|
1228
1268
|
pointerId: e,
|
|
1229
|
-
actionName:
|
|
1230
|
-
byteLength:
|
|
1231
|
-
}),
|
|
1232
|
-
} else (i === "up" || i === "cancel") &&
|
|
1233
|
-
},
|
|
1234
|
-
if (
|
|
1269
|
+
actionName: Ut(E),
|
|
1270
|
+
byteLength: _.byteLength
|
|
1271
|
+
}), de(_));
|
|
1272
|
+
} else (i === "up" || i === "cancel") && Z.current.delete(e);
|
|
1273
|
+
}, er = (e) => {
|
|
1274
|
+
if (Ne.current !== e && (Ne.current = e, un(e), e || Dt(null), F("[rc-touch][alt] updateAltHeld", {
|
|
1235
1275
|
nextHeld: e,
|
|
1236
|
-
activePointerIds: Array.from(
|
|
1237
|
-
}),
|
|
1238
|
-
const i = e ? s.ACTION_DOWN : s.ACTION_UP, o =
|
|
1276
|
+
activePointerIds: Array.from(Z.current.keys())
|
|
1277
|
+
}), pe === "ios" && U.current && U.current.readyState === "open")) {
|
|
1278
|
+
const i = e ? s.ACTION_DOWN : s.ACTION_UP, o = gt(
|
|
1239
1279
|
i,
|
|
1240
1280
|
s.KEYCODE_ALT_LEFT,
|
|
1241
1281
|
0,
|
|
1242
1282
|
s.META_NONE
|
|
1243
1283
|
);
|
|
1244
|
-
|
|
1284
|
+
F("[rc-touch][alt] sending Indigo modifier keycode", {
|
|
1245
1285
|
action: i,
|
|
1246
1286
|
keycode: s.KEYCODE_ALT_LEFT
|
|
1247
|
-
}), o &&
|
|
1287
|
+
}), o && de(o);
|
|
1248
1288
|
}
|
|
1249
|
-
},
|
|
1250
|
-
const e =
|
|
1289
|
+
}, pt = () => {
|
|
1290
|
+
const e = W.current, i = _e.current;
|
|
1251
1291
|
if (!e || !i) return null;
|
|
1252
1292
|
const o = e.videoWidth, n = e.videoHeight;
|
|
1253
1293
|
if (!o || !n) return null;
|
|
1254
|
-
const l = e.getBoundingClientRect(), u = i.getBoundingClientRect(), f = l.width, E = l.height,
|
|
1255
|
-
let R = f,
|
|
1256
|
-
|
|
1257
|
-
const N = (f - R) / 2, $ = (E -
|
|
1294
|
+
const l = e.getBoundingClientRect(), u = i.getBoundingClientRect(), f = l.width, E = l.height, y = o / n, h = f / E;
|
|
1295
|
+
let R = f, _ = E;
|
|
1296
|
+
y > h ? _ = f / y : R = E * y;
|
|
1297
|
+
const N = (f - R) / 2, $ = (E - _) / 2;
|
|
1258
1298
|
return {
|
|
1259
1299
|
videoWidth: o,
|
|
1260
1300
|
videoHeight: n,
|
|
1261
1301
|
videoRect: l,
|
|
1262
1302
|
containerRect: u,
|
|
1263
1303
|
actualWidth: R,
|
|
1264
|
-
actualHeight:
|
|
1304
|
+
actualHeight: _,
|
|
1265
1305
|
offsetX: N,
|
|
1266
1306
|
offsetY: $
|
|
1267
1307
|
};
|
|
1268
|
-
},
|
|
1308
|
+
}, ze = (e, i, o) => {
|
|
1269
1309
|
const n = i - e.videoRect.left - e.offsetX, l = o - e.videoRect.top - e.offsetY, u = Math.max(0, Math.min(e.actualWidth, n)), f = Math.max(0, Math.min(e.actualHeight, l)), E = Math.max(
|
|
1270
1310
|
0,
|
|
1271
1311
|
Math.min(e.videoWidth, u / e.actualWidth * e.videoWidth)
|
|
1272
|
-
),
|
|
1312
|
+
), y = Math.max(
|
|
1273
1313
|
0,
|
|
1274
1314
|
Math.min(e.videoHeight, f / e.actualHeight * e.videoHeight)
|
|
1275
1315
|
);
|
|
1276
1316
|
return {
|
|
1277
1317
|
videoX: E,
|
|
1278
|
-
videoY:
|
|
1318
|
+
videoY: y,
|
|
1279
1319
|
videoWidth: e.videoWidth,
|
|
1280
1320
|
videoHeight: e.videoHeight
|
|
1281
1321
|
};
|
|
1282
|
-
},
|
|
1322
|
+
}, mn = (e, i, o) => {
|
|
1283
1323
|
const n = i - e.videoRect.left - e.offsetX, l = o - e.videoRect.top - e.offsetY, u = Math.max(0, Math.min(e.actualWidth, n)), f = Math.max(0, Math.min(e.actualHeight, l)), E = Math.max(
|
|
1284
1324
|
0,
|
|
1285
1325
|
Math.min(e.videoWidth, u / e.actualWidth * e.videoWidth)
|
|
1286
|
-
),
|
|
1326
|
+
), y = Math.max(
|
|
1287
1327
|
0,
|
|
1288
1328
|
Math.min(e.videoHeight, f / e.actualHeight * e.videoHeight)
|
|
1289
|
-
), h = e.videoWidth - E, R = e.videoHeight -
|
|
1329
|
+
), h = e.videoWidth - E, R = e.videoHeight - y, _ = e.videoRect.left + e.offsetX, N = e.videoRect.top + e.offsetY, $ = _ - e.containerRect.left + u, oe = N - e.containerRect.top + f, j = _ - e.containerRect.left + (e.actualWidth - u), z = N - e.containerRect.top + (e.actualHeight - f);
|
|
1290
1330
|
return {
|
|
1291
1331
|
containerX: $,
|
|
1292
|
-
containerY:
|
|
1332
|
+
containerY: oe,
|
|
1293
1333
|
mirrorContainerX: j,
|
|
1294
|
-
mirrorContainerY:
|
|
1334
|
+
mirrorContainerY: z,
|
|
1295
1335
|
videoX: E,
|
|
1296
|
-
videoY:
|
|
1336
|
+
videoY: y,
|
|
1297
1337
|
mirrorVideoX: h,
|
|
1298
1338
|
mirrorVideoY: R,
|
|
1299
1339
|
videoWidth: e.videoWidth,
|
|
1300
1340
|
videoHeight: e.videoHeight
|
|
1301
1341
|
};
|
|
1302
|
-
},
|
|
1303
|
-
const E =
|
|
1304
|
-
|
|
1305
|
-
actionName:
|
|
1342
|
+
}, En = (e, i, o, n, l, u, f) => {
|
|
1343
|
+
const E = Gn(e, i, o, n, l, u, f);
|
|
1344
|
+
F("[rc-touch2] sendTwoFingerMessage (iOS)", {
|
|
1345
|
+
actionName: Ut(e),
|
|
1306
1346
|
video: { width: i, height: o },
|
|
1307
1347
|
p0: { x: n, y: l },
|
|
1308
1348
|
p1: { x: u, y: f },
|
|
1309
1349
|
byteLength: E.byteLength
|
|
1310
|
-
}),
|
|
1311
|
-
},
|
|
1312
|
-
if (
|
|
1313
|
-
platform:
|
|
1350
|
+
}), de(E);
|
|
1351
|
+
}, Qe = (e, i, o, n, l, u, f, E, y) => {
|
|
1352
|
+
if (F("[rc-touch2] applyTwoFingerEvent", {
|
|
1353
|
+
platform: pe,
|
|
1314
1354
|
eventType: e,
|
|
1315
1355
|
video: { width: i, height: o },
|
|
1316
1356
|
p0: { x: n, y: l, id: E },
|
|
1317
|
-
p1: { x: u, y: f, id:
|
|
1318
|
-
}), e === "down" &&
|
|
1319
|
-
const h = e === "down" ?
|
|
1320
|
-
|
|
1357
|
+
p1: { x: u, y: f, id: y }
|
|
1358
|
+
}), e === "down" && lt.current.end(), pe === "ios") {
|
|
1359
|
+
const h = e === "down" ? K.ACTION_DOWN : e === "move" ? K.ACTION_MOVE : K.ACTION_UP;
|
|
1360
|
+
En(h, i, o, n, l, u, f);
|
|
1321
1361
|
} else
|
|
1322
|
-
e === "down" ? (
|
|
1323
|
-
},
|
|
1324
|
-
if (!
|
|
1325
|
-
|
|
1362
|
+
e === "down" ? (je(K.ACTION_DOWN, E, i, o, n, l), je(K.ACTION_POINTER_DOWN, y, i, o, u, f)) : e === "move" ? (je(K.ACTION_MOVE, E, i, o, n, l), je(K.ACTION_MOVE, y, i, o, u, f)) : (je(K.ACTION_POINTER_UP, y, i, o, u, f), je(K.ACTION_UP, E, i, o, n, l));
|
|
1363
|
+
}, gn = (e, i, o) => {
|
|
1364
|
+
if (!Ne.current) {
|
|
1365
|
+
Ie !== null && Dt(null);
|
|
1326
1366
|
return;
|
|
1327
1367
|
}
|
|
1328
|
-
const n =
|
|
1329
|
-
|
|
1330
|
-
},
|
|
1331
|
-
const n =
|
|
1368
|
+
const n = mn(e, i, o);
|
|
1369
|
+
Dt(n);
|
|
1370
|
+
}, yn = (e, i, o) => {
|
|
1371
|
+
const n = qe.current;
|
|
1332
1372
|
if (!n || n.screen.width <= 0 || n.screen.height <= 0) return null;
|
|
1333
1373
|
const l = i - e.videoRect.left - e.offsetX, u = o - e.videoRect.top - e.offsetY;
|
|
1334
1374
|
if (l < 0 || u < 0 || l > e.actualWidth || u > e.actualHeight) return null;
|
|
1335
1375
|
const f = l / e.actualWidth * n.screen.width, E = u / e.actualHeight * n.screen.height;
|
|
1336
|
-
return
|
|
1337
|
-
},
|
|
1338
|
-
if (
|
|
1376
|
+
return io(n, f, E);
|
|
1377
|
+
}, we = (e) => {
|
|
1378
|
+
if (ye) return;
|
|
1339
1379
|
e.preventDefault(), e.stopPropagation();
|
|
1340
|
-
const i =
|
|
1341
|
-
if ((
|
|
1380
|
+
const i = pt();
|
|
1381
|
+
if ((Be.current === !0 || Be.current === "hover-only") && !("touches" in e))
|
|
1342
1382
|
if (e.type === "mousemove") {
|
|
1343
|
-
if (
|
|
1344
|
-
const n =
|
|
1345
|
-
|
|
1383
|
+
if (Cr({ x: e.clientX, y: e.clientY }), i) {
|
|
1384
|
+
const n = yn(i, e.clientX, e.clientY);
|
|
1385
|
+
dt(n?.id ?? null);
|
|
1346
1386
|
}
|
|
1347
|
-
} else e.type === "mouseleave" && (
|
|
1348
|
-
if (
|
|
1387
|
+
} else e.type === "mouseleave" && (Cr(null), dt(null));
|
|
1388
|
+
if (Be.current !== !0 && (!("touches" in e) && i && (e.type === "mousemove" ? gn(i, e.clientX, e.clientY) : e.type === "mouseleave" && Dt(null)), !(!U.current || U.current.readyState !== "open" || !W.current || !i)))
|
|
1349
1389
|
if ("touches" in e) {
|
|
1350
1390
|
const n = e.touches, l = e.changedTouches;
|
|
1351
1391
|
let u;
|
|
@@ -1366,39 +1406,39 @@ const Xo = Kn(
|
|
|
1366
1406
|
return;
|
|
1367
1407
|
}
|
|
1368
1408
|
if (n.length === 2) {
|
|
1369
|
-
const f = n[0], E = n[1],
|
|
1370
|
-
if (!
|
|
1371
|
-
|
|
1409
|
+
const f = n[0], E = n[1], y = ze(i, f.clientX, f.clientY), h = ze(i, E.clientX, E.clientY);
|
|
1410
|
+
if (!y || !h) return;
|
|
1411
|
+
q.current ? q.current.source === "real-touch" && (q.current.finger0 = { x: y.videoX, y: y.videoY }, q.current.finger1 = { x: h.videoX, y: h.videoY }, Qe(
|
|
1372
1412
|
"move",
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1413
|
+
y.videoWidth,
|
|
1414
|
+
y.videoHeight,
|
|
1415
|
+
y.videoX,
|
|
1416
|
+
y.videoY,
|
|
1377
1417
|
h.videoX,
|
|
1378
1418
|
h.videoY,
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
)) : (
|
|
1382
|
-
finger0: { x:
|
|
1419
|
+
q.current.pointerId0,
|
|
1420
|
+
q.current.pointerId1
|
|
1421
|
+
)) : (q.current = {
|
|
1422
|
+
finger0: { x: y.videoX, y: y.videoY },
|
|
1383
1423
|
finger1: { x: h.videoX, y: h.videoY },
|
|
1384
|
-
videoSize: { width:
|
|
1424
|
+
videoSize: { width: y.videoWidth, height: y.videoHeight },
|
|
1385
1425
|
source: "real-touch",
|
|
1386
1426
|
pointerId0: f.identifier,
|
|
1387
1427
|
pointerId1: E.identifier
|
|
1388
|
-
},
|
|
1428
|
+
}, Qe(
|
|
1389
1429
|
"down",
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1430
|
+
y.videoWidth,
|
|
1431
|
+
y.videoHeight,
|
|
1432
|
+
y.videoX,
|
|
1433
|
+
y.videoY,
|
|
1394
1434
|
h.videoX,
|
|
1395
1435
|
h.videoY,
|
|
1396
1436
|
f.identifier,
|
|
1397
1437
|
E.identifier
|
|
1398
1438
|
));
|
|
1399
|
-
} else if (n.length < 2 &&
|
|
1400
|
-
const f =
|
|
1401
|
-
|
|
1439
|
+
} else if (n.length < 2 && q.current?.source === "real-touch") {
|
|
1440
|
+
const f = q.current;
|
|
1441
|
+
Qe(
|
|
1402
1442
|
"up",
|
|
1403
1443
|
f.videoSize.width,
|
|
1404
1444
|
f.videoSize.height,
|
|
@@ -1408,7 +1448,7 @@ const Xo = Kn(
|
|
|
1408
1448
|
f.finger1.y,
|
|
1409
1449
|
f.pointerId0,
|
|
1410
1450
|
f.pointerId1
|
|
1411
|
-
),
|
|
1451
|
+
), q.current = null;
|
|
1412
1452
|
return;
|
|
1413
1453
|
} else {
|
|
1414
1454
|
if (n.length > 2)
|
|
@@ -1416,39 +1456,39 @@ const Xo = Kn(
|
|
|
1416
1456
|
{
|
|
1417
1457
|
const f = l[0];
|
|
1418
1458
|
if (f) {
|
|
1419
|
-
const E =
|
|
1420
|
-
|
|
1459
|
+
const E = ze(i, f.clientX, f.clientY);
|
|
1460
|
+
Ke(f.identifier, u, E);
|
|
1421
1461
|
}
|
|
1422
1462
|
}
|
|
1423
1463
|
}
|
|
1424
1464
|
} else {
|
|
1425
1465
|
let l = null;
|
|
1426
|
-
const u =
|
|
1466
|
+
const u = q.current?.source === "alt-mouse";
|
|
1427
1467
|
switch (e.type) {
|
|
1428
1468
|
case "mousedown":
|
|
1429
1469
|
e.button === 0 && (l = "down");
|
|
1430
1470
|
break;
|
|
1431
1471
|
case "mousemove":
|
|
1432
|
-
(u ||
|
|
1472
|
+
(u || Z.current.has(-1)) && (l = "move");
|
|
1433
1473
|
break;
|
|
1434
1474
|
case "mouseup":
|
|
1435
1475
|
e.button === 0 && (l = "up");
|
|
1436
1476
|
break;
|
|
1437
1477
|
case "mouseleave":
|
|
1438
|
-
(u ||
|
|
1478
|
+
(u || Z.current.has(-1)) && (l = "up");
|
|
1439
1479
|
break;
|
|
1440
1480
|
}
|
|
1441
1481
|
if (l) {
|
|
1442
|
-
const f =
|
|
1482
|
+
const f = ze(i, e.clientX, e.clientY);
|
|
1443
1483
|
if (!f)
|
|
1444
1484
|
return;
|
|
1445
|
-
|
|
1485
|
+
F("[rc-touch][mouse] event", {
|
|
1446
1486
|
domType: e.type,
|
|
1447
1487
|
eventType: l,
|
|
1448
1488
|
button: e.button,
|
|
1449
1489
|
buttons: e.buttons,
|
|
1450
1490
|
client: { x: e.clientX, y: e.clientY },
|
|
1451
|
-
altHeldRef:
|
|
1491
|
+
altHeldRef: Ne.current,
|
|
1452
1492
|
inTwoFingerMode: u,
|
|
1453
1493
|
geometry: {
|
|
1454
1494
|
videoX: f.videoX,
|
|
@@ -1456,21 +1496,21 @@ const Xo = Kn(
|
|
|
1456
1496
|
videoWidth: f.videoWidth,
|
|
1457
1497
|
videoHeight: f.videoHeight
|
|
1458
1498
|
},
|
|
1459
|
-
activePointerIds: Array.from(
|
|
1460
|
-
}),
|
|
1499
|
+
activePointerIds: Array.from(Z.current.keys())
|
|
1500
|
+
}), Ne.current || u ? Cn(l, f) : Ke(-1, l, f);
|
|
1461
1501
|
}
|
|
1462
1502
|
}
|
|
1463
|
-
},
|
|
1503
|
+
}, Cn = (e, i) => {
|
|
1464
1504
|
const { videoX: o, videoY: n, videoWidth: l, videoHeight: u } = i, f = l - o, E = u - n;
|
|
1465
1505
|
if (e === "down") {
|
|
1466
|
-
|
|
1506
|
+
q.current = {
|
|
1467
1507
|
finger0: { x: o, y: n },
|
|
1468
1508
|
finger1: { x: f, y: E },
|
|
1469
1509
|
videoSize: { width: l, height: u },
|
|
1470
1510
|
source: "alt-mouse",
|
|
1471
|
-
pointerId0:
|
|
1472
|
-
pointerId1:
|
|
1473
|
-
},
|
|
1511
|
+
pointerId0: Mt,
|
|
1512
|
+
pointerId1: Rt
|
|
1513
|
+
}, W.current?.focus(), Qe(
|
|
1474
1514
|
"down",
|
|
1475
1515
|
l,
|
|
1476
1516
|
u,
|
|
@@ -1478,13 +1518,13 @@ const Xo = Kn(
|
|
|
1478
1518
|
n,
|
|
1479
1519
|
f,
|
|
1480
1520
|
E,
|
|
1481
|
-
|
|
1482
|
-
|
|
1521
|
+
Mt,
|
|
1522
|
+
Rt
|
|
1483
1523
|
);
|
|
1484
1524
|
return;
|
|
1485
1525
|
}
|
|
1486
1526
|
if (e === "move") {
|
|
1487
|
-
|
|
1527
|
+
q.current?.source === "alt-mouse" && (q.current.finger0 = { x: o, y: n }, q.current.finger1 = { x: f, y: E }, Qe(
|
|
1488
1528
|
"move",
|
|
1489
1529
|
l,
|
|
1490
1530
|
u,
|
|
@@ -1492,96 +1532,96 @@ const Xo = Kn(
|
|
|
1492
1532
|
n,
|
|
1493
1533
|
f,
|
|
1494
1534
|
E,
|
|
1495
|
-
|
|
1496
|
-
|
|
1535
|
+
Mt,
|
|
1536
|
+
Rt
|
|
1497
1537
|
));
|
|
1498
1538
|
return;
|
|
1499
1539
|
}
|
|
1500
1540
|
if (e === "up" || e === "cancel") {
|
|
1501
|
-
const
|
|
1502
|
-
if (
|
|
1503
|
-
const { finger0: h, finger1: R, videoSize:
|
|
1504
|
-
|
|
1541
|
+
const y = q.current;
|
|
1542
|
+
if (y?.source === "alt-mouse") {
|
|
1543
|
+
const { finger0: h, finger1: R, videoSize: _ } = y;
|
|
1544
|
+
Qe(
|
|
1505
1545
|
"up",
|
|
1506
|
-
|
|
1507
|
-
|
|
1546
|
+
_.width,
|
|
1547
|
+
_.height,
|
|
1508
1548
|
h.x,
|
|
1509
1549
|
h.y,
|
|
1510
1550
|
R.x,
|
|
1511
1551
|
R.y,
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
),
|
|
1552
|
+
Mt,
|
|
1553
|
+
Rt
|
|
1554
|
+
), q.current = null;
|
|
1515
1555
|
}
|
|
1516
1556
|
return;
|
|
1517
1557
|
}
|
|
1518
|
-
},
|
|
1519
|
-
const e =
|
|
1520
|
-
e && (window.clearTimeout(e.endTimer), Ye
|
|
1521
|
-
},
|
|
1522
|
-
if (e.ctrlKey ||
|
|
1523
|
-
const i =
|
|
1524
|
-
if (i > 1 || i === 1 && !
|
|
1525
|
-
const o =
|
|
1558
|
+
}, vn = 150, br = () => {
|
|
1559
|
+
const e = $e.current;
|
|
1560
|
+
e && (window.clearTimeout(e.endTimer), Ke(Ye, "up", e.pos), $e.current = null);
|
|
1561
|
+
}, On = (e) => {
|
|
1562
|
+
if (e.ctrlKey || Ne.current || q.current) return;
|
|
1563
|
+
const i = Z.current.size;
|
|
1564
|
+
if (i > 1 || i === 1 && !Z.current.has(Ye)) return;
|
|
1565
|
+
const o = pt();
|
|
1526
1566
|
if (!o) return;
|
|
1527
1567
|
const n = e.clientX - o.videoRect.left - o.offsetX, l = e.clientY - o.videoRect.top - o.offsetY;
|
|
1528
1568
|
if (n < 0 || n > o.actualWidth || l < 0 || l > o.actualHeight)
|
|
1529
1569
|
return;
|
|
1530
|
-
const u =
|
|
1570
|
+
const u = ze(o, e.clientX, e.clientY);
|
|
1531
1571
|
if (!u) return;
|
|
1532
1572
|
e.preventDefault();
|
|
1533
|
-
const f = (e.deltaMode === 1 ? 16 : e.deltaMode === 2 ? o.actualWidth : 1) * (o.videoWidth / o.actualWidth), E = (e.deltaMode === 1 ? 16 : e.deltaMode === 2 ? o.actualHeight : 1) * (o.videoHeight / o.actualHeight),
|
|
1534
|
-
window.clearTimeout(
|
|
1573
|
+
const f = (e.deltaMode === 1 ? 16 : e.deltaMode === 2 ? o.actualWidth : 1) * (o.videoWidth / o.actualWidth), E = (e.deltaMode === 1 ? 16 : e.deltaMode === 2 ? o.actualHeight : 1) * (o.videoHeight / o.actualHeight), y = -e.deltaX * f, h = -e.deltaY * E, R = (z) => {
|
|
1574
|
+
window.clearTimeout(z.endTimer), z.endTimer = window.setTimeout(br, vn);
|
|
1535
1575
|
};
|
|
1536
|
-
if (
|
|
1537
|
-
|
|
1576
|
+
if (y === 0 && h === 0) {
|
|
1577
|
+
$e.current && R($e.current);
|
|
1538
1578
|
return;
|
|
1539
1579
|
}
|
|
1540
|
-
const
|
|
1580
|
+
const _ = () => ({
|
|
1541
1581
|
videoWidth: u.videoWidth,
|
|
1542
1582
|
videoHeight: u.videoHeight,
|
|
1543
|
-
videoX: Math.abs(
|
|
1544
|
-
videoY: Math.abs(h) >= Math.abs(
|
|
1545
|
-
}), N = (
|
|
1546
|
-
...
|
|
1547
|
-
videoX: Math.min(Math.max(
|
|
1548
|
-
videoY: Math.min(Math.max(
|
|
1583
|
+
videoX: Math.abs(y) > Math.abs(h) ? Math.min(Math.max(u.videoX, u.videoWidth * 0.2), u.videoWidth * 0.8) : u.videoX,
|
|
1584
|
+
videoY: Math.abs(h) >= Math.abs(y) ? Math.min(Math.max(u.videoY, u.videoHeight * 0.2), u.videoHeight * 0.8) : u.videoY
|
|
1585
|
+
}), N = (z) => ({
|
|
1586
|
+
...z,
|
|
1587
|
+
videoX: Math.min(Math.max(z.videoX + y, 0), z.videoWidth),
|
|
1588
|
+
videoY: Math.min(Math.max(z.videoY + h, 0), z.videoHeight)
|
|
1549
1589
|
});
|
|
1550
|
-
let $ =
|
|
1590
|
+
let $ = $e.current;
|
|
1551
1591
|
if ($)
|
|
1552
1592
|
window.clearTimeout($.endTimer);
|
|
1553
1593
|
else {
|
|
1554
|
-
const
|
|
1555
|
-
Ye
|
|
1594
|
+
const z = _();
|
|
1595
|
+
Ke(Ye, "down", z), $ = { pos: z, endTimer: 0 }, $e.current = $;
|
|
1556
1596
|
}
|
|
1557
|
-
let
|
|
1558
|
-
j.videoX ===
|
|
1597
|
+
let oe = $.pos, j = N(oe);
|
|
1598
|
+
j.videoX === oe.videoX && j.videoY === oe.videoY && (Ke(Ye, "up", oe), oe = _(), Ke(Ye, "down", oe), j = N(oe)), Ke(Ye, "move", j), $.pos = j, R($);
|
|
1559
1599
|
};
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
}),
|
|
1563
|
-
const e =
|
|
1600
|
+
me(() => {
|
|
1601
|
+
lt.current = { handle: On, end: br };
|
|
1602
|
+
}), me(() => {
|
|
1603
|
+
const e = _e.current;
|
|
1564
1604
|
if (!e) return;
|
|
1565
|
-
const i = (o) =>
|
|
1605
|
+
const i = (o) => lt.current.handle(o);
|
|
1566
1606
|
return e.addEventListener("wheel", i, { passive: !1 }), () => {
|
|
1567
|
-
|
|
1607
|
+
lt.current.end(), e.removeEventListener("wheel", i);
|
|
1568
1608
|
};
|
|
1569
|
-
}, []),
|
|
1609
|
+
}, []), me(() => {
|
|
1570
1610
|
const e = (n) => {
|
|
1571
|
-
n.key === "Alt" &&
|
|
1611
|
+
n.key === "Alt" && er(!0);
|
|
1572
1612
|
}, i = (n) => {
|
|
1573
|
-
n.key === "Alt" &&
|
|
1613
|
+
n.key === "Alt" && er(!1);
|
|
1574
1614
|
}, o = () => {
|
|
1575
|
-
|
|
1615
|
+
er(!1);
|
|
1576
1616
|
};
|
|
1577
1617
|
return window.addEventListener("keydown", e, !0), window.addEventListener("keyup", i, !0), window.addEventListener("blur", o), () => {
|
|
1578
1618
|
window.removeEventListener("keydown", e, !0), window.removeEventListener("keyup", i, !0), window.removeEventListener("blur", o);
|
|
1579
1619
|
};
|
|
1580
1620
|
}, []);
|
|
1581
|
-
const
|
|
1621
|
+
const Nt = (e) => {
|
|
1582
1622
|
e.preventDefault(), e.stopPropagation();
|
|
1583
|
-
const i = document.activeElement ===
|
|
1584
|
-
if (
|
|
1623
|
+
const i = document.activeElement === W.current || ye && document.activeElement === e.currentTarget;
|
|
1624
|
+
if (F("Keyboard event:", {
|
|
1585
1625
|
type: e.type,
|
|
1586
1626
|
key: e.key,
|
|
1587
1627
|
keyCode: e.keyCode,
|
|
@@ -1589,23 +1629,23 @@ const Xo = Kn(
|
|
|
1589
1629
|
target: e.target.tagName,
|
|
1590
1630
|
focused: i
|
|
1591
1631
|
}), !i) {
|
|
1592
|
-
|
|
1632
|
+
A("Simulator input not focused, skipping keyboard event");
|
|
1593
1633
|
return;
|
|
1594
1634
|
}
|
|
1595
|
-
if (!
|
|
1596
|
-
|
|
1635
|
+
if (!U.current || U.current.readyState !== "open") {
|
|
1636
|
+
A("Data channel not ready for keyboard event:", U.current?.readyState);
|
|
1597
1637
|
return;
|
|
1598
1638
|
}
|
|
1599
1639
|
if (e.type === "keydown") {
|
|
1600
1640
|
if (e.key.toLowerCase() === "v" && (e.metaKey || e.ctrlKey)) {
|
|
1601
|
-
|
|
1641
|
+
F("Paste shortcut detected"), navigator.clipboard.readText().then((n) => {
|
|
1602
1642
|
if (n) {
|
|
1603
|
-
|
|
1643
|
+
F(
|
|
1604
1644
|
"Pasting text via SET_CLIPBOARD:",
|
|
1605
1645
|
n.substring(0, 20) + (n.length > 20 ? "..." : "")
|
|
1606
1646
|
);
|
|
1607
|
-
const l =
|
|
1608
|
-
|
|
1647
|
+
const l = Jn(n, !0);
|
|
1648
|
+
de(l);
|
|
1609
1649
|
}
|
|
1610
1650
|
}).catch((n) => {
|
|
1611
1651
|
console.error("Failed to read clipboard contents: ", n);
|
|
@@ -1613,88 +1653,88 @@ const Xo = Kn(
|
|
|
1613
1653
|
return;
|
|
1614
1654
|
}
|
|
1615
1655
|
if (e.key.toLowerCase() === "m" && (e.metaKey || e.ctrlKey)) {
|
|
1616
|
-
|
|
1617
|
-
const n =
|
|
1656
|
+
F("Menu shortcut detected");
|
|
1657
|
+
const n = gt(
|
|
1618
1658
|
s.ACTION_DOWN,
|
|
1619
1659
|
s.MENU,
|
|
1620
1660
|
0,
|
|
1621
1661
|
s.META_NONE
|
|
1622
1662
|
// Modifiers are handled by the shortcut check, not passed down
|
|
1623
1663
|
);
|
|
1624
|
-
|
|
1625
|
-
const l =
|
|
1664
|
+
de(n);
|
|
1665
|
+
const l = gt(
|
|
1626
1666
|
s.ACTION_UP,
|
|
1627
1667
|
s.MENU,
|
|
1628
1668
|
0,
|
|
1629
1669
|
s.META_NONE
|
|
1630
1670
|
);
|
|
1631
|
-
|
|
1671
|
+
de(l);
|
|
1632
1672
|
return;
|
|
1633
1673
|
}
|
|
1634
1674
|
}
|
|
1635
|
-
const o =
|
|
1675
|
+
const o = Uo(e);
|
|
1636
1676
|
if (o) {
|
|
1637
1677
|
const { keycode: n, metaState: l } = o, u = e.type === "keydown" ? s.ACTION_DOWN : s.ACTION_UP;
|
|
1638
|
-
|
|
1639
|
-
const f =
|
|
1678
|
+
F(`Sending Keycode: key=${e.key}, code=${n}, action=${u}, meta=${l}`);
|
|
1679
|
+
const f = gt(
|
|
1640
1680
|
u,
|
|
1641
1681
|
n,
|
|
1642
1682
|
0,
|
|
1643
1683
|
// repeat count, typically 0 for single presses
|
|
1644
1684
|
l
|
|
1645
1685
|
);
|
|
1646
|
-
|
|
1686
|
+
de(f);
|
|
1647
1687
|
} else
|
|
1648
|
-
|
|
1649
|
-
},
|
|
1650
|
-
|
|
1688
|
+
F(`Ignoring unhandled key event: type=${e.type}, key=${e.key}`);
|
|
1689
|
+
}, _n = () => {
|
|
1690
|
+
D.current && D.current.readyState === WebSocket.OPEN && D.current.send(
|
|
1651
1691
|
JSON.stringify({
|
|
1652
1692
|
type: "keepAlive",
|
|
1653
|
-
sessionId:
|
|
1693
|
+
sessionId: le
|
|
1654
1694
|
})
|
|
1655
1695
|
);
|
|
1656
|
-
},
|
|
1657
|
-
|
|
1658
|
-
},
|
|
1659
|
-
|
|
1660
|
-
},
|
|
1661
|
-
|
|
1662
|
-
},
|
|
1663
|
-
|
|
1664
|
-
},
|
|
1665
|
-
|
|
1666
|
-
},
|
|
1667
|
-
|
|
1668
|
-
},
|
|
1669
|
-
|
|
1670
|
-
},
|
|
1696
|
+
}, Sr = () => {
|
|
1697
|
+
Fe.current && window.clearInterval(Fe.current), Fe.current = window.setInterval(_n, 1e4);
|
|
1698
|
+
}, Mr = () => {
|
|
1699
|
+
Fe.current && (window.clearInterval(Fe.current), Fe.current = void 0);
|
|
1700
|
+
}, It = () => {
|
|
1701
|
+
ot.current && (window.clearTimeout(ot.current), ot.current = void 0);
|
|
1702
|
+
}, Yt = () => {
|
|
1703
|
+
it.current && (window.clearTimeout(it.current), it.current = void 0);
|
|
1704
|
+
}, mt = () => {
|
|
1705
|
+
vt.current && (window.clearInterval(vt.current), vt.current = void 0);
|
|
1706
|
+
}, Et = () => {
|
|
1707
|
+
We.current !== void 0 && (window.clearTimeout(We.current), We.current = void 0);
|
|
1708
|
+
}, Tn = () => {
|
|
1709
|
+
ut.current || (ut.current = !0, mt(), $t(!0), Ge("connected"));
|
|
1710
|
+
}, re = (e) => {
|
|
1671
1711
|
for (const i of e.getTracks())
|
|
1672
1712
|
try {
|
|
1673
1713
|
i.stop();
|
|
1674
1714
|
} catch (o) {
|
|
1675
|
-
|
|
1715
|
+
A("track.stop() failed:", o);
|
|
1676
1716
|
}
|
|
1677
|
-
},
|
|
1678
|
-
const e =
|
|
1679
|
-
e && (
|
|
1680
|
-
},
|
|
1681
|
-
const i =
|
|
1682
|
-
|
|
1717
|
+
}, wn = () => {
|
|
1718
|
+
const e = ne.current;
|
|
1719
|
+
e && (ne.current = null, re(e));
|
|
1720
|
+
}, Rr = (e) => {
|
|
1721
|
+
const i = pr.current.then(e).catch((o) => {
|
|
1722
|
+
A("microphone operation failed:", o);
|
|
1683
1723
|
});
|
|
1684
|
-
return
|
|
1685
|
-
},
|
|
1724
|
+
return pr.current = i, i;
|
|
1725
|
+
}, tr = () => Gt.current || Jt.current, Nr = (e) => {
|
|
1686
1726
|
const i = `ui-mic-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
|
|
1687
|
-
|
|
1688
|
-
},
|
|
1689
|
-
const e =
|
|
1690
|
-
L("onMicrophoneStateChange",
|
|
1727
|
+
He.current = i, e.send(JSON.stringify({ type: "microphoneStart", id: i }));
|
|
1728
|
+
}, rr = () => Rr(() => Dn()), Dn = async () => {
|
|
1729
|
+
const e = wt.current, i = () => e === wt.current && tr(), o = (E) => {
|
|
1730
|
+
L("onMicrophoneStateChange", st.current, {
|
|
1691
1731
|
active: !1,
|
|
1692
1732
|
error: E
|
|
1693
1733
|
});
|
|
1694
1734
|
};
|
|
1695
1735
|
if (!i()) return;
|
|
1696
|
-
const n =
|
|
1697
|
-
if (!n || n.readyState !== WebSocket.OPEN || !l ||
|
|
1736
|
+
const n = D.current, l = at.current;
|
|
1737
|
+
if (!n || n.readyState !== WebSocket.OPEN || !l || he.current) return;
|
|
1698
1738
|
if (!navigator.mediaDevices || typeof navigator.mediaDevices.getUserMedia != "function") {
|
|
1699
1739
|
console.warn(
|
|
1700
1740
|
"[RemoteControl] navigator.mediaDevices.getUserMedia unavailable. getUserMedia requires a secure context (https or http://localhost)."
|
|
@@ -1708,7 +1748,7 @@ const Xo = Kn(
|
|
|
1708
1748
|
console.warn("[RemoteControl] microphone getUserMedia denied/failed:", E);
|
|
1709
1749
|
}
|
|
1710
1750
|
if (!i()) {
|
|
1711
|
-
u &&
|
|
1751
|
+
u && re(u);
|
|
1712
1752
|
return;
|
|
1713
1753
|
}
|
|
1714
1754
|
if (!u) {
|
|
@@ -1717,56 +1757,56 @@ const Xo = Kn(
|
|
|
1717
1757
|
}
|
|
1718
1758
|
const f = u.getAudioTracks()[0] ?? null;
|
|
1719
1759
|
if (!f) {
|
|
1720
|
-
|
|
1760
|
+
re(u), o("Captured stream has no audio track");
|
|
1721
1761
|
return;
|
|
1722
1762
|
}
|
|
1723
1763
|
try {
|
|
1724
1764
|
await l.replaceTrack(f);
|
|
1725
1765
|
} catch (E) {
|
|
1726
|
-
|
|
1766
|
+
A("replaceTrack(audioTrack) failed:", E), re(u), o("Failed to attach the microphone track to the connection");
|
|
1727
1767
|
return;
|
|
1728
1768
|
}
|
|
1729
1769
|
if (!i()) {
|
|
1730
1770
|
try {
|
|
1731
1771
|
await l.replaceTrack(null);
|
|
1732
1772
|
} catch (E) {
|
|
1733
|
-
|
|
1773
|
+
A("replaceTrack(null) on stale mic attach failed:", E);
|
|
1734
1774
|
}
|
|
1735
|
-
|
|
1775
|
+
re(u);
|
|
1736
1776
|
return;
|
|
1737
1777
|
}
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
},
|
|
1778
|
+
he.current = u, f.onended = () => {
|
|
1779
|
+
he.current === u && Kt("microphone capture ended by the browser");
|
|
1780
|
+
}, Nr(n), L("onMicrophoneStateChange", st.current, {
|
|
1741
1781
|
active: !0,
|
|
1742
1782
|
label: f.label || void 0
|
|
1743
1783
|
});
|
|
1744
|
-
},
|
|
1745
|
-
const i =
|
|
1746
|
-
if (
|
|
1784
|
+
}, Kt = (e) => (++wt.current, He.current = null, Rr(async () => {
|
|
1785
|
+
const i = at.current, o = he.current;
|
|
1786
|
+
if (he.current = null, i && o)
|
|
1747
1787
|
try {
|
|
1748
1788
|
await i.replaceTrack(null);
|
|
1749
1789
|
} catch (l) {
|
|
1750
|
-
|
|
1790
|
+
A("replaceTrack(null) on mic detach failed:", l);
|
|
1751
1791
|
}
|
|
1752
|
-
o &&
|
|
1753
|
-
const n =
|
|
1792
|
+
o && re(o);
|
|
1793
|
+
const n = D.current;
|
|
1754
1794
|
if (o && n && n.readyState === WebSocket.OPEN) {
|
|
1755
1795
|
const l = `ui-mic-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
|
|
1756
1796
|
n.send(JSON.stringify({ type: "microphoneStop", id: l }));
|
|
1757
1797
|
}
|
|
1758
|
-
(o || e) && L("onMicrophoneStateChange",
|
|
1798
|
+
(o || e) && L("onMicrophoneStateChange", st.current, {
|
|
1759
1799
|
active: !1,
|
|
1760
1800
|
...e !== void 0 && { error: e }
|
|
1761
1801
|
});
|
|
1762
|
-
})),
|
|
1802
|
+
})), Ir = (e, i) => {
|
|
1763
1803
|
let o;
|
|
1764
1804
|
try {
|
|
1765
|
-
o =
|
|
1805
|
+
o = vo(i), console.info(
|
|
1766
1806
|
`[RemoteControl] camera capture: ${o.camera?.width}x${o.camera?.height} @ ${o.camera?.frameRate ?? "?"}fps` + (o.camera?.label ? ` — ${o.camera.label}` : "")
|
|
1767
1807
|
);
|
|
1768
1808
|
} catch (n) {
|
|
1769
|
-
|
|
1809
|
+
A("getSettings() on outbound camera track failed:", n), o = {
|
|
1770
1810
|
type: "cameraResult",
|
|
1771
1811
|
granted: !0,
|
|
1772
1812
|
camera: {
|
|
@@ -1775,12 +1815,12 @@ const Xo = Kn(
|
|
|
1775
1815
|
};
|
|
1776
1816
|
}
|
|
1777
1817
|
e.send(JSON.stringify(o)), L("onCameraDemandChange", ve.current, !0, !0, o.camera);
|
|
1778
|
-
},
|
|
1818
|
+
}, An = (e) => {
|
|
1779
1819
|
if (!e) return;
|
|
1780
1820
|
const i = e.indexOf("/"), n = (i >= 0 ? e.slice(i + 1) : e).toUpperCase();
|
|
1781
1821
|
return n === "HEVC" ? "H265" : n;
|
|
1782
|
-
},
|
|
1783
|
-
const e =
|
|
1822
|
+
}, bn = async () => {
|
|
1823
|
+
const e = be.current, i = _t.current;
|
|
1784
1824
|
if (!e || !i) return;
|
|
1785
1825
|
let o;
|
|
1786
1826
|
try {
|
|
@@ -1796,27 +1836,27 @@ const Xo = Kn(
|
|
|
1796
1836
|
N && (l = N.mimeType);
|
|
1797
1837
|
}
|
|
1798
1838
|
if (!n) return;
|
|
1799
|
-
const f = n.timestamp ?? Date.now(), E =
|
|
1800
|
-
let
|
|
1839
|
+
const f = n.timestamp ?? Date.now(), E = Tt.current;
|
|
1840
|
+
let y, h, R;
|
|
1801
1841
|
if (E && f > E.timestamp) {
|
|
1802
1842
|
const N = (f - E.timestamp) / 1e3;
|
|
1803
|
-
if (typeof n.framesEncoded == "number" && typeof E.framesEncoded == "number" && (
|
|
1804
|
-
const $ = n.packetsSent - E.packetsSent,
|
|
1805
|
-
$ > 0 && (R = Math.max(0, Math.min(100,
|
|
1843
|
+
if (typeof n.framesEncoded == "number" && typeof E.framesEncoded == "number" && (y = Math.max(0, (n.framesEncoded - E.framesEncoded) / N)), typeof n.bytesSent == "number" && typeof E.bytesSent == "number" && (h = Math.max(0, (n.bytesSent - E.bytesSent) * 8 / N)), typeof n.packetsSent == "number" && typeof E.packetsSent == "number" && u && typeof u.packetsLost == "number" && typeof E.packetsLost == "number") {
|
|
1844
|
+
const $ = n.packetsSent - E.packetsSent, oe = u.packetsLost - E.packetsLost;
|
|
1845
|
+
$ > 0 && (R = Math.max(0, Math.min(100, oe / $ * 100)));
|
|
1806
1846
|
}
|
|
1807
1847
|
}
|
|
1808
|
-
|
|
1848
|
+
Tt.current = {
|
|
1809
1849
|
timestamp: f,
|
|
1810
1850
|
framesEncoded: n.framesEncoded,
|
|
1811
1851
|
bytesSent: n.bytesSent,
|
|
1812
1852
|
packetsSent: n.packetsSent,
|
|
1813
1853
|
packetsLost: u?.packetsLost
|
|
1814
1854
|
};
|
|
1815
|
-
const
|
|
1816
|
-
codec:
|
|
1855
|
+
const _ = {
|
|
1856
|
+
codec: An(l),
|
|
1817
1857
|
encoderImplementation: n.encoderImplementation,
|
|
1818
1858
|
hardwareAccelerated: typeof n.powerEfficientEncoder == "boolean" ? n.powerEfficientEncoder : void 0,
|
|
1819
|
-
framesPerSecond:
|
|
1859
|
+
framesPerSecond: y,
|
|
1820
1860
|
framesEncoded: n.framesEncoded,
|
|
1821
1861
|
bitrateBps: h,
|
|
1822
1862
|
width: n.frameWidth,
|
|
@@ -1825,40 +1865,40 @@ const Xo = Kn(
|
|
|
1825
1865
|
rttMs: typeof u?.roundTripTime == "number" ? u.roundTripTime * 1e3 : void 0,
|
|
1826
1866
|
packetsLostPct: R
|
|
1827
1867
|
};
|
|
1828
|
-
L("onCameraStats",
|
|
1829
|
-
},
|
|
1830
|
-
|
|
1831
|
-
|
|
1868
|
+
L("onCameraStats", _t.current, _);
|
|
1869
|
+
}, Yr = () => {
|
|
1870
|
+
ct.current === null && (Tt.current = null, ct.current = setInterval(() => {
|
|
1871
|
+
bn();
|
|
1832
1872
|
}, 1e3));
|
|
1833
|
-
},
|
|
1834
|
-
|
|
1835
|
-
},
|
|
1836
|
-
const u = () => l() && n() &&
|
|
1873
|
+
}, kt = () => {
|
|
1874
|
+
ct.current !== null && (clearInterval(ct.current), ct.current = null), Tt.current = null, L("onCameraStats", _t.current, null);
|
|
1875
|
+
}, Sn = (e, i, o, n) => Vt.enqueue(async ({ isCurrent: l }) => {
|
|
1876
|
+
const u = () => l() && n() && D.current === i && be.current === o;
|
|
1837
1877
|
if (!u()) return;
|
|
1838
1878
|
if (!e.active) {
|
|
1839
|
-
const
|
|
1879
|
+
const _ = ne.current;
|
|
1840
1880
|
try {
|
|
1841
1881
|
await o.replaceTrack(null);
|
|
1842
1882
|
} catch (N) {
|
|
1843
|
-
|
|
1883
|
+
A("replaceTrack(null) on camera detach failed:", N);
|
|
1844
1884
|
}
|
|
1845
|
-
if (
|
|
1885
|
+
if (ne.current === _ && (ne.current = null, Se.current = void 0, _ && re(_)), kt(), !u()) return;
|
|
1846
1886
|
L("onCameraDemandChange", ve.current, !1);
|
|
1847
1887
|
return;
|
|
1848
1888
|
}
|
|
1849
1889
|
L("onCameraDemandChange", ve.current, !0);
|
|
1850
|
-
const f =
|
|
1851
|
-
if (E?.readyState === "live" &&
|
|
1852
|
-
|
|
1890
|
+
const f = ne.current, E = f?.getVideoTracks()[0], y = Se.current;
|
|
1891
|
+
if (E?.readyState === "live" && y && !yo(y, e)) {
|
|
1892
|
+
Se.current = e, Ir(i, E), Yr();
|
|
1853
1893
|
return;
|
|
1854
1894
|
}
|
|
1855
1895
|
if (f) {
|
|
1856
1896
|
try {
|
|
1857
1897
|
await o.replaceTrack(null);
|
|
1858
|
-
} catch (
|
|
1859
|
-
|
|
1898
|
+
} catch (_) {
|
|
1899
|
+
A("replaceTrack(null) before camera switch failed:", _);
|
|
1860
1900
|
}
|
|
1861
|
-
if (
|
|
1901
|
+
if (ne.current === f && (ne.current = null, Se.current = void 0, re(f)), kt(), !u()) return;
|
|
1862
1902
|
}
|
|
1863
1903
|
if (!navigator.mediaDevices || typeof navigator.mediaDevices.getUserMedia != "function") {
|
|
1864
1904
|
if (console.warn(
|
|
@@ -1870,14 +1910,14 @@ const Xo = Kn(
|
|
|
1870
1910
|
let h = null;
|
|
1871
1911
|
try {
|
|
1872
1912
|
h = await navigator.mediaDevices.getUserMedia({
|
|
1873
|
-
video:
|
|
1913
|
+
video: go(e),
|
|
1874
1914
|
audio: !1
|
|
1875
1915
|
});
|
|
1876
|
-
} catch (
|
|
1877
|
-
console.warn("[RemoteControl] getUserMedia denied/failed:",
|
|
1916
|
+
} catch (_) {
|
|
1917
|
+
console.warn("[RemoteControl] getUserMedia denied/failed:", _);
|
|
1878
1918
|
}
|
|
1879
1919
|
if (!u()) {
|
|
1880
|
-
h &&
|
|
1920
|
+
h && re(h);
|
|
1881
1921
|
return;
|
|
1882
1922
|
}
|
|
1883
1923
|
if (!h) {
|
|
@@ -1886,7 +1926,7 @@ const Xo = Kn(
|
|
|
1886
1926
|
}
|
|
1887
1927
|
const R = h.getVideoTracks()[0] ?? null;
|
|
1888
1928
|
if (!R) {
|
|
1889
|
-
if (
|
|
1929
|
+
if (re(h), !u()) return;
|
|
1890
1930
|
i.send(JSON.stringify({ type: "cameraResult", granted: !1 })), L("onCameraDemandChange", ve.current, !0, !1);
|
|
1891
1931
|
return;
|
|
1892
1932
|
}
|
|
@@ -1896,68 +1936,68 @@ const Xo = Kn(
|
|
|
1896
1936
|
}
|
|
1897
1937
|
try {
|
|
1898
1938
|
await o.replaceTrack(R);
|
|
1899
|
-
} catch (
|
|
1900
|
-
if (
|
|
1939
|
+
} catch (_) {
|
|
1940
|
+
if (A("replaceTrack(videoTrack) failed:", _), re(h), !u()) return;
|
|
1901
1941
|
i.send(JSON.stringify({ type: "cameraResult", granted: !1 })), L("onCameraDemandChange", ve.current, !0, !1);
|
|
1902
1942
|
return;
|
|
1903
1943
|
}
|
|
1904
1944
|
if (!u()) {
|
|
1905
1945
|
try {
|
|
1906
1946
|
await o.replaceTrack(null);
|
|
1907
|
-
} catch (
|
|
1908
|
-
|
|
1947
|
+
} catch (_) {
|
|
1948
|
+
A("replaceTrack(null) for stale camera attach failed:", _);
|
|
1909
1949
|
}
|
|
1910
|
-
|
|
1950
|
+
re(h);
|
|
1911
1951
|
return;
|
|
1912
1952
|
}
|
|
1913
1953
|
try {
|
|
1914
|
-
const
|
|
1915
|
-
(!
|
|
1916
|
-
} catch (
|
|
1917
|
-
|
|
1954
|
+
const _ = o.getParameters();
|
|
1955
|
+
(!_.encodings || _.encodings.length === 0) && (_.encodings = [{}]), _.encodings[0].maxBitrate = 8e6, _.encodings[0].maxFramerate = 30, _.degradationPreference = "maintain-framerate", await o.setParameters(_);
|
|
1956
|
+
} catch (_) {
|
|
1957
|
+
A("setParameters on outbound camera failed:", _);
|
|
1918
1958
|
}
|
|
1919
1959
|
if (!u()) {
|
|
1920
1960
|
try {
|
|
1921
1961
|
await o.replaceTrack(null);
|
|
1922
|
-
} catch (
|
|
1923
|
-
|
|
1962
|
+
} catch (_) {
|
|
1963
|
+
A("replaceTrack(null) for stale camera finalize failed:", _);
|
|
1924
1964
|
}
|
|
1925
|
-
|
|
1965
|
+
re(h);
|
|
1926
1966
|
return;
|
|
1927
1967
|
}
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
if (!(!
|
|
1968
|
+
ne.current = h, Se.current = e, R.onended = () => {
|
|
1969
|
+
ne.current === h && Vt.enqueueCurrent(async ({ isCurrent: _ }) => {
|
|
1970
|
+
if (!(!_() || ne.current !== h || !n() || D.current !== i || be.current !== o)) {
|
|
1931
1971
|
try {
|
|
1932
1972
|
await o.replaceTrack(null);
|
|
1933
1973
|
} catch (N) {
|
|
1934
|
-
|
|
1974
|
+
A("replaceTrack(null) after camera ended failed:", N);
|
|
1935
1975
|
}
|
|
1936
|
-
!
|
|
1976
|
+
!_() || ne.current !== h || !n() || D.current !== i || be.current !== o || (ne.current = null, Se.current = void 0, re(h), kt(), i.send(JSON.stringify({ type: "cameraResult", granted: !1 })), L("onCameraDemandChange", ve.current, !0, !1));
|
|
1937
1977
|
}
|
|
1938
|
-
}).catch((
|
|
1939
|
-
}, u() && (
|
|
1940
|
-
}),
|
|
1941
|
-
for (const e of
|
|
1942
|
-
|
|
1943
|
-
for (const e of
|
|
1978
|
+
}).catch((_) => A("camera ended cleanup failed:", _));
|
|
1979
|
+
}, u() && (Ir(i, R), Yr());
|
|
1980
|
+
}), Ze = () => {
|
|
1981
|
+
for (const e of rt.current.values()) e();
|
|
1982
|
+
rt.current.clear();
|
|
1983
|
+
for (const e of Le.current.values())
|
|
1944
1984
|
clearTimeout(e.timer), e.reject(new Error("Simulator disconnected"));
|
|
1945
|
-
|
|
1985
|
+
Le.current.clear(), ar(null), nt.current && (nt.current.srcObject = null), Yt(), Et(), mt(), te.current && (te.current.stop(), te.current = null), Vt.invalidate(), kt(), wn(), Se.current = void 0, be.current = null, ++wt.current, Jt.current = !1, He.current = null, he.current && (re(he.current), he.current = null, L("onMicrophoneStateChange", st.current, {
|
|
1946
1986
|
active: !1
|
|
1947
|
-
})),
|
|
1948
|
-
},
|
|
1949
|
-
document.hidden ?
|
|
1950
|
-
},
|
|
1987
|
+
})), at.current = null, ae.current !== void 0 && (window.cancelAnimationFrame(ae.current), ae.current = void 0), D.current && (D.current.onopen = null, D.current.onmessage = null, D.current.onerror = null, D.current.onclose = null, D.current.close(), D.current = null), Ct.current?.close(), Ct.current = null, x.current && (x.current.onconnectionstatechange = null, x.current.oniceconnectionstatechange = null, x.current.ontrack = null, x.current.onicecandidate = null, x.current.close(), x.current = null), W.current && (W.current.srcObject = null), U.current && (U.current.onopen = null, U.current.onclose = null, U.current.onerror = null, U.current.close(), U.current = null);
|
|
1988
|
+
}, Kr = () => {
|
|
1989
|
+
document.hidden ? Mr() : Sr();
|
|
1990
|
+
}, Mn = async () => {
|
|
1951
1991
|
if (typeof navigator < "u" && navigator.onLine === !1)
|
|
1952
1992
|
return !1;
|
|
1953
1993
|
let e;
|
|
1954
1994
|
try {
|
|
1955
1995
|
const n = new URL(t);
|
|
1956
|
-
n.protocol = n.protocol === "wss:" ? "https:" : n.protocol === "ws:" ? "http:" : n.protocol, e =
|
|
1996
|
+
n.protocol = n.protocol === "wss:" ? "https:" : n.protocol === "ws:" ? "http:" : n.protocol, e = Fr(n.toString(), c);
|
|
1957
1997
|
} catch {
|
|
1958
1998
|
return !1;
|
|
1959
1999
|
}
|
|
1960
|
-
const i = new AbortController(), o = window.setTimeout(() => i.abort(),
|
|
2000
|
+
const i = new AbortController(), o = window.setTimeout(() => i.abort(), Ko);
|
|
1961
2001
|
try {
|
|
1962
2002
|
return (await fetch(e, { method: "GET", cache: "no-store", signal: i.signal })).status === 404;
|
|
1963
2003
|
} catch {
|
|
@@ -1965,88 +2005,88 @@ const Xo = Kn(
|
|
|
1965
2005
|
} finally {
|
|
1966
2006
|
window.clearTimeout(o);
|
|
1967
2007
|
}
|
|
1968
|
-
},
|
|
1969
|
-
|
|
1970
|
-
},
|
|
1971
|
-
|
|
1972
|
-
|
|
2008
|
+
}, Rn = () => {
|
|
2009
|
+
xe.current || (xe.current = !0, dr(!0), yt(!1), Ae.current += 1, It(), Yt(), Et(), Ze(), k("Instance terminated"), Ge("terminated"), L("onTerminated", Or.current));
|
|
2010
|
+
}, Nn = () => {
|
|
2011
|
+
xe.current || Xt.current || (Xt.current = !0, Mn().then((e) => {
|
|
2012
|
+
Xt.current = !1, e && Rn();
|
|
1973
2013
|
}));
|
|
1974
|
-
},
|
|
1975
|
-
if (
|
|
2014
|
+
}, et = (e, i) => {
|
|
2015
|
+
if (xe.current || i !== Ae.current)
|
|
1976
2016
|
return;
|
|
1977
|
-
if (
|
|
1978
|
-
if (!
|
|
1979
|
-
|
|
2017
|
+
if (Nn(), Ce.current) {
|
|
2018
|
+
if (!qt.current) {
|
|
2019
|
+
k(`Connection failed after it was established: ${e}`), yt(!0), Ge("failed"), Ze();
|
|
1980
2020
|
return;
|
|
1981
2021
|
}
|
|
1982
|
-
|
|
2022
|
+
k(`Reconnecting after established session dropped: ${e}`), Ce.current = !1, Ot.current = -1;
|
|
1983
2023
|
}
|
|
1984
|
-
|
|
1985
|
-
const o =
|
|
1986
|
-
if (o >=
|
|
1987
|
-
|
|
2024
|
+
It();
|
|
2025
|
+
const o = Ot.current + 1;
|
|
2026
|
+
if (o >= ir) {
|
|
2027
|
+
k(`Connection failed after ${ir} attempts: ${e}`), yt(!0), Ge("failed"), Ze();
|
|
1988
2028
|
return;
|
|
1989
2029
|
}
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
},
|
|
1993
|
-
},
|
|
1994
|
-
if (
|
|
1995
|
-
const i =
|
|
1996
|
-
|
|
1997
|
-
const o = () => i ===
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
},
|
|
2030
|
+
k(`Retrying connection (${o + 1}/${ir})`), Ge("reconnecting"), Ze(), ot.current = window.setTimeout(() => {
|
|
2031
|
+
ot.current = void 0, i === Ae.current && kr(o);
|
|
2032
|
+
}, No);
|
|
2033
|
+
}, kr = async (e = 0) => {
|
|
2034
|
+
if (xe.current) return;
|
|
2035
|
+
const i = Ae.current + 1;
|
|
2036
|
+
Ae.current = i, Ot.current = e, Ce.current = !1, yt(!1), e === 0 && Zt.current !== "reconnecting" && Ge("connecting"), It(), Yt(), mt(), ut.current = !1, $t(!1), Ze();
|
|
2037
|
+
const o = () => i === Ae.current;
|
|
2038
|
+
it.current = window.setTimeout(() => {
|
|
2039
|
+
it.current = void 0, !(!o() || Ce.current) && et("Connection did not succeed within 15 seconds", i);
|
|
2040
|
+
}, Io);
|
|
2001
2041
|
try {
|
|
2002
|
-
const n = new WebSocket(
|
|
2003
|
-
if (
|
|
2042
|
+
const n = new WebSocket(Fr(t, c));
|
|
2043
|
+
if (D.current = n, await new Promise((T, d) => {
|
|
2004
2044
|
let Y = !1;
|
|
2005
|
-
const
|
|
2006
|
-
Y || (Y = !0, window.clearTimeout(
|
|
2045
|
+
const Q = window.setTimeout(() => d(new Error("WebSocket connection timeout")), 3e4), b = (I) => {
|
|
2046
|
+
Y || (Y = !0, window.clearTimeout(Q), I());
|
|
2007
2047
|
};
|
|
2008
2048
|
n.onopen = () => {
|
|
2009
|
-
!o() ||
|
|
2049
|
+
!o() || D.current !== n || b(T);
|
|
2010
2050
|
}, n.onerror = (I) => {
|
|
2011
|
-
!o() ||
|
|
2051
|
+
!o() || D.current !== n || (k("WebSocket error: " + I), b(() => d(new Error("WebSocket connection failed"))));
|
|
2012
2052
|
}, n.onclose = () => {
|
|
2013
|
-
!o() ||
|
|
2053
|
+
!o() || D.current !== n || (k("WebSocket closed"), b(() => d(new Error("WebSocket closed before connection was established"))));
|
|
2014
2054
|
};
|
|
2015
|
-
}), !o() ||
|
|
2055
|
+
}), !o() || D.current !== n)
|
|
2016
2056
|
return;
|
|
2017
|
-
n.onerror = (
|
|
2018
|
-
!o() ||
|
|
2057
|
+
n.onerror = (T) => {
|
|
2058
|
+
!o() || D.current !== n || k("WebSocket error: " + T);
|
|
2019
2059
|
}, n.onclose = () => {
|
|
2020
|
-
!o() ||
|
|
2060
|
+
!o() || D.current !== n || k("WebSocket closed");
|
|
2021
2061
|
};
|
|
2022
|
-
const l = new Promise((
|
|
2062
|
+
const l = new Promise((T, d) => {
|
|
2023
2063
|
const Y = (I) => {
|
|
2024
|
-
window.clearTimeout(
|
|
2025
|
-
},
|
|
2064
|
+
window.clearTimeout(Q), n.removeEventListener("message", b), I();
|
|
2065
|
+
}, Q = window.setTimeout(
|
|
2026
2066
|
() => Y(() => d(new Error("RTCConfiguration timeout"))),
|
|
2027
2067
|
3e4
|
|
2028
|
-
),
|
|
2029
|
-
if (!(!o() ||
|
|
2068
|
+
), b = (I) => {
|
|
2069
|
+
if (!(!o() || D.current !== n))
|
|
2030
2070
|
try {
|
|
2031
|
-
const
|
|
2032
|
-
if (
|
|
2033
|
-
const
|
|
2034
|
-
Y(() => d(new Error(
|
|
2035
|
-
} else
|
|
2036
|
-
() =>
|
|
2037
|
-
rtcConfiguration:
|
|
2038
|
-
cameraSupported:
|
|
2039
|
-
foldSupported:
|
|
2071
|
+
const V = JSON.parse(I.data);
|
|
2072
|
+
if (V.type === "signalingError" && V.requestType === "requestRtcConfiguration" && V.sessionId === le) {
|
|
2073
|
+
const ie = typeof V.error == "string" ? V.error : "Unable to load streaming configuration";
|
|
2074
|
+
Y(() => d(new Error(ie)));
|
|
2075
|
+
} else V.type === "rtcConfiguration" && Y(
|
|
2076
|
+
() => T({
|
|
2077
|
+
rtcConfiguration: V.rtcConfiguration,
|
|
2078
|
+
cameraSupported: V.cameraSupported === !0,
|
|
2079
|
+
foldSupported: V.foldSupported === !0
|
|
2040
2080
|
})
|
|
2041
2081
|
);
|
|
2042
|
-
} catch (
|
|
2043
|
-
console.error("Error handling RTC configuration:",
|
|
2082
|
+
} catch (V) {
|
|
2083
|
+
console.error("Error handling RTC configuration:", V), Y(() => d(V));
|
|
2044
2084
|
}
|
|
2045
2085
|
};
|
|
2046
|
-
n.addEventListener("message",
|
|
2086
|
+
n.addEventListener("message", b), n.send(
|
|
2047
2087
|
JSON.stringify({
|
|
2048
2088
|
type: "requestRtcConfiguration",
|
|
2049
|
-
sessionId:
|
|
2089
|
+
sessionId: le
|
|
2050
2090
|
})
|
|
2051
2091
|
);
|
|
2052
2092
|
}), {
|
|
@@ -2054,46 +2094,46 @@ const Xo = Kn(
|
|
|
2054
2094
|
cameraSupported: f,
|
|
2055
2095
|
foldSupported: E
|
|
2056
2096
|
} = await l;
|
|
2057
|
-
if (!o() ||
|
|
2097
|
+
if (!o() || D.current !== n)
|
|
2058
2098
|
return;
|
|
2059
|
-
const
|
|
2060
|
-
|
|
2099
|
+
const y = g === "iphone-duo" || E;
|
|
2100
|
+
Qr(y);
|
|
2061
2101
|
const h = new RTCPeerConnection({ ...u, iceTransportPolicy: "relay" });
|
|
2062
|
-
|
|
2063
|
-
const R = h.addTransceiver("video", { direction: "recvonly" }),
|
|
2102
|
+
x.current = h, h.addTransceiver("audio", { direction: "recvonly" });
|
|
2103
|
+
const R = h.addTransceiver("video", { direction: "recvonly" }), _ = y ? h.addTransceiver("video", { direction: "recvonly" }) : null, N = pe === "ios" || f, $ = N ? h.addTransceiver("video", {
|
|
2064
2104
|
direction: "sendonly"
|
|
2065
2105
|
}) : null;
|
|
2066
|
-
|
|
2067
|
-
const
|
|
2106
|
+
be.current = $?.sender ?? null;
|
|
2107
|
+
const oe = N ? h.addTransceiver("audio", {
|
|
2068
2108
|
direction: "sendonly"
|
|
2069
2109
|
}) : null;
|
|
2070
|
-
if (
|
|
2071
|
-
const
|
|
2072
|
-
if (
|
|
2073
|
-
const Y =
|
|
2074
|
-
const I = (
|
|
2075
|
-
const
|
|
2076
|
-
return
|
|
2110
|
+
if (at.current = oe?.sender ?? null, RTCRtpReceiver.getCapabilities) {
|
|
2111
|
+
const T = RTCRtpReceiver.getCapabilities("video");
|
|
2112
|
+
if (T && T.codecs) {
|
|
2113
|
+
const Y = T.codecs.sort((Q, b) => {
|
|
2114
|
+
const I = (V) => {
|
|
2115
|
+
const ie = V.mimeType.toLowerCase();
|
|
2116
|
+
return ie.includes("vp9") ? 1 : ie.includes("h265") || ie.includes("hevc") ? 2 : ie.includes("h264") || ie.includes("avc") ? 3 : 4;
|
|
2077
2117
|
};
|
|
2078
|
-
return I(
|
|
2118
|
+
return I(Q) - I(b);
|
|
2079
2119
|
});
|
|
2080
|
-
R.setCodecPreferences(Y),
|
|
2120
|
+
R.setCodecPreferences(Y), _?.setCodecPreferences(Y), F("Set codec preferences:", Y.map((Q) => Q.mimeType).join(", "));
|
|
2081
2121
|
}
|
|
2082
2122
|
}
|
|
2083
2123
|
if ($ && RTCRtpSender.getCapabilities) {
|
|
2084
|
-
const
|
|
2085
|
-
if (
|
|
2086
|
-
const d = /* @__PURE__ */ new Set(["42e01f", "42e028", "640c1f"]), Y = (
|
|
2087
|
-
const I =
|
|
2088
|
-
return I === "video/h265" || I === "video/hevc" ? 1 : I === "video/h264" && d.has(
|
|
2089
|
-
},
|
|
2124
|
+
const T = RTCRtpSender.getCapabilities("video");
|
|
2125
|
+
if (T && T.codecs) {
|
|
2126
|
+
const d = /* @__PURE__ */ new Set(["42e01f", "42e028", "640c1f"]), Y = (b) => {
|
|
2127
|
+
const I = b.mimeType.toLowerCase(), ie = (b.sdpFmtpLine || "").toLowerCase().match(/profile-level-id=([0-9a-f]{6})/), Pn = ie ? ie[1] : "";
|
|
2128
|
+
return I === "video/h265" || I === "video/hevc" ? 1 : I === "video/h264" && d.has(Pn) ? 2 : I === "video/h264" ? 3 : I === "video/vp9" ? 4 : I === "video/vp8" ? 5 : I === "video/rtx" || I === "video/red" || I === "video/ulpfec" ? 0 : 6;
|
|
2129
|
+
}, Q = [...T.codecs].sort((b, I) => Y(b) - Y(I));
|
|
2090
2130
|
try {
|
|
2091
|
-
$.setCodecPreferences(
|
|
2131
|
+
$.setCodecPreferences(Q), F(
|
|
2092
2132
|
"Outbound camera codec preferences:",
|
|
2093
|
-
|
|
2133
|
+
Q.map((b) => `${b.mimeType}${b.sdpFmtpLine ? `[${b.sdpFmtpLine}]` : ""}`).join(", ")
|
|
2094
2134
|
);
|
|
2095
|
-
} catch (
|
|
2096
|
-
|
|
2135
|
+
} catch (b) {
|
|
2136
|
+
A("Failed to set outbound camera codec preferences:", b);
|
|
2097
2137
|
}
|
|
2098
2138
|
}
|
|
2099
2139
|
}
|
|
@@ -2102,48 +2142,52 @@ const Xo = Kn(
|
|
|
2102
2142
|
negotiated: !0,
|
|
2103
2143
|
id: 1
|
|
2104
2144
|
});
|
|
2105
|
-
|
|
2106
|
-
|
|
2145
|
+
U.current = j;
|
|
2146
|
+
const z = !y && Bt.current ? Vn(h, (T) => {
|
|
2147
|
+
o() && x.current === h && L("onTrace", Bt.current, T);
|
|
2148
|
+
}) : null;
|
|
2149
|
+
if (Ct.current = z, j.onopen = () => {
|
|
2150
|
+
if (!o() || U.current !== j || D.current !== n)
|
|
2107
2151
|
return;
|
|
2108
|
-
|
|
2109
|
-
platform:
|
|
2110
|
-
baseIntervalMs:
|
|
2111
|
-
maxBackoffMs:
|
|
2112
|
-
androidElementTreeOptions:
|
|
2152
|
+
Ce.current = !0, Yt(), k("Control channel opened"), y && n.send(JSON.stringify({ type: "getFoldState", id: "duo-capabilities" })), te.current || (te.current = new po({
|
|
2153
|
+
platform: pe,
|
|
2154
|
+
baseIntervalMs: ee,
|
|
2155
|
+
maxBackoffMs: B,
|
|
2156
|
+
androidElementTreeOptions: Ee,
|
|
2113
2157
|
send: (d) => {
|
|
2114
|
-
if (!
|
|
2158
|
+
if (!D.current || D.current.readyState !== WebSocket.OPEN) return !1;
|
|
2115
2159
|
try {
|
|
2116
|
-
return
|
|
2160
|
+
return D.current.send(JSON.stringify(d)), !0;
|
|
2117
2161
|
} catch {
|
|
2118
2162
|
return !1;
|
|
2119
2163
|
}
|
|
2120
2164
|
},
|
|
2121
2165
|
onSnapshot: (d) => {
|
|
2122
|
-
|
|
2123
|
-
L("onAxSnapshotChange",
|
|
2166
|
+
Er((Y) => Jr(Y, d) ? Y : d), queueMicrotask(() => {
|
|
2167
|
+
L("onAxSnapshotChange", Qt.current, d);
|
|
2124
2168
|
});
|
|
2125
2169
|
},
|
|
2126
2170
|
onStatusChange: (d, Y) => {
|
|
2127
|
-
L("onAxStatusChange",
|
|
2171
|
+
L("onAxStatusChange", vr.current, d, Y);
|
|
2128
2172
|
}
|
|
2129
|
-
}), (
|
|
2130
|
-
const
|
|
2131
|
-
!o() ||
|
|
2173
|
+
}), (Be.current === !0 || Be.current === "hover-only") && te.current.start());
|
|
2174
|
+
const T = () => {
|
|
2175
|
+
!o() || ut.current || U.current !== j || D.current !== n || n.readyState !== WebSocket.OPEN || n.send(JSON.stringify({ type: "requestFrame", sessionId: le }));
|
|
2132
2176
|
};
|
|
2133
|
-
if (
|
|
2134
|
-
if (!o() ||
|
|
2135
|
-
|
|
2177
|
+
if (T(), mt(), vt.current = window.setInterval(() => {
|
|
2178
|
+
if (!o() || ut.current || U.current !== j || D.current !== n || n.readyState !== WebSocket.OPEN) {
|
|
2179
|
+
mt();
|
|
2136
2180
|
return;
|
|
2137
2181
|
}
|
|
2138
|
-
|
|
2182
|
+
T();
|
|
2139
2183
|
}, 250), m) {
|
|
2140
2184
|
try {
|
|
2141
2185
|
const d = decodeURIComponent(m);
|
|
2142
|
-
|
|
2186
|
+
k("Opening URL"), n.send(
|
|
2143
2187
|
JSON.stringify({
|
|
2144
2188
|
type: "openUrl",
|
|
2145
2189
|
url: d,
|
|
2146
|
-
sessionId:
|
|
2190
|
+
sessionId: le
|
|
2147
2191
|
})
|
|
2148
2192
|
);
|
|
2149
2193
|
} catch (d) {
|
|
@@ -2151,103 +2195,103 @@ const Xo = Kn(
|
|
|
2151
2195
|
JSON.stringify({
|
|
2152
2196
|
type: "openUrl",
|
|
2153
2197
|
url: m,
|
|
2154
|
-
sessionId:
|
|
2198
|
+
sessionId: le
|
|
2155
2199
|
})
|
|
2156
2200
|
);
|
|
2157
2201
|
}
|
|
2158
|
-
|
|
2202
|
+
te.current?.bumpActivity();
|
|
2159
2203
|
}
|
|
2160
2204
|
}, j.onclose = () => {
|
|
2161
|
-
!o() ||
|
|
2162
|
-
}, j.onerror = (
|
|
2163
|
-
!o() ||
|
|
2205
|
+
!o() || U.current !== j || k("Control channel closed");
|
|
2206
|
+
}, j.onerror = (T) => {
|
|
2207
|
+
!o() || U.current !== j || (console.error("Control channel error:", T), k("Control channel error: " + T));
|
|
2164
2208
|
}, h.onconnectionstatechange = () => {
|
|
2165
|
-
!o() ||
|
|
2209
|
+
!o() || x.current !== h || (k("Connection state: " + h.connectionState), h.connectionState === "failed" && Ce.current && et("WebRTC connection entered failed state", i));
|
|
2166
2210
|
}, h.oniceconnectionstatechange = () => {
|
|
2167
|
-
if (!o() ||
|
|
2211
|
+
if (!o() || x.current !== h)
|
|
2168
2212
|
return;
|
|
2169
|
-
const
|
|
2170
|
-
if (
|
|
2171
|
-
|
|
2213
|
+
const T = h.iceConnectionState;
|
|
2214
|
+
if (k("ICE state: " + T), T === "connected" || T === "completed") {
|
|
2215
|
+
Et(), tr() && !he.current && rr();
|
|
2172
2216
|
return;
|
|
2173
2217
|
}
|
|
2174
|
-
if (
|
|
2175
|
-
|
|
2218
|
+
if (T === "failed") {
|
|
2219
|
+
Et(), Ce.current && et("ICE connection entered failed state", i);
|
|
2176
2220
|
return;
|
|
2177
2221
|
}
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
},
|
|
2181
|
-
}, h.ontrack = (
|
|
2182
|
-
if (!(!o() ||
|
|
2183
|
-
|
|
2184
|
-
const Y =
|
|
2222
|
+
T === "disconnected" && Ce.current && qt.current && We.current === void 0 && (We.current = window.setTimeout(() => {
|
|
2223
|
+
We.current = void 0, !(!o() || x.current !== h) && h.iceConnectionState === "disconnected" && et("ICE stayed disconnected past grace period", i);
|
|
2224
|
+
}, Yo));
|
|
2225
|
+
}, h.ontrack = (T) => {
|
|
2226
|
+
if (!(!o() || x.current !== h) && (k("Received remote track: " + T.track.kind), T.track.kind === "video" && W.current)) {
|
|
2227
|
+
F(`[${(/* @__PURE__ */ new Date()).toISOString()}] Video track received:`, T.track);
|
|
2228
|
+
const Y = T.track.id === "duo-inner" || T.streams.some((Q) => Q.id === "duo-inner") ? nt.current : W.current;
|
|
2185
2229
|
if (Y) {
|
|
2186
|
-
const
|
|
2187
|
-
|
|
2230
|
+
const Q = y ? new MediaStream([T.track]) : T.streams[0] ?? new MediaStream([T.track]);
|
|
2231
|
+
rt.current.get(Y)?.(), rt.current.set(
|
|
2188
2232
|
Y,
|
|
2189
|
-
|
|
2233
|
+
qn(Y, Q, (b) => A("Video playback fallback:", b))
|
|
2190
2234
|
);
|
|
2191
2235
|
}
|
|
2192
2236
|
}
|
|
2193
|
-
}, h.onicecandidate = (
|
|
2194
|
-
if (!(!o() ||
|
|
2195
|
-
if (
|
|
2237
|
+
}, h.onicecandidate = (T) => {
|
|
2238
|
+
if (!(!o() || x.current !== h || D.current !== n))
|
|
2239
|
+
if (T.candidate && n.readyState === WebSocket.OPEN) {
|
|
2196
2240
|
const d = {
|
|
2197
2241
|
type: "candidate",
|
|
2198
|
-
candidate:
|
|
2199
|
-
sdpMid:
|
|
2200
|
-
sdpMLineIndex:
|
|
2201
|
-
sessionId:
|
|
2242
|
+
candidate: T.candidate.candidate,
|
|
2243
|
+
sdpMid: T.candidate.sdpMid,
|
|
2244
|
+
sdpMLineIndex: T.candidate.sdpMLineIndex,
|
|
2245
|
+
sessionId: le
|
|
2202
2246
|
};
|
|
2203
|
-
n.send(JSON.stringify(d)),
|
|
2247
|
+
n.send(JSON.stringify(d)), k("Sent ICE candidate");
|
|
2204
2248
|
} else
|
|
2205
|
-
|
|
2206
|
-
}, n.onmessage = async (
|
|
2207
|
-
if (!o() ||
|
|
2249
|
+
k("ICE candidate gathering completed");
|
|
2250
|
+
}, n.onmessage = async (T) => {
|
|
2251
|
+
if (!o() || D.current !== n)
|
|
2208
2252
|
return;
|
|
2209
2253
|
let d;
|
|
2210
2254
|
try {
|
|
2211
|
-
d = JSON.parse(
|
|
2255
|
+
d = JSON.parse(T.data);
|
|
2212
2256
|
} catch (Y) {
|
|
2213
|
-
|
|
2257
|
+
A("Error parsing message:", Y);
|
|
2214
2258
|
return;
|
|
2215
2259
|
}
|
|
2216
|
-
if (!
|
|
2217
|
-
switch (
|
|
2260
|
+
if (!te.current?.handleMessage(d))
|
|
2261
|
+
switch (k("Received: " + d.type), d.type) {
|
|
2218
2262
|
case "performActionsResult":
|
|
2219
2263
|
case "foldStateResult":
|
|
2220
2264
|
case "foldStateChanged": {
|
|
2221
|
-
if (!
|
|
2222
|
-
d.state ? (
|
|
2223
|
-
const
|
|
2224
|
-
|
|
2265
|
+
if (!y) break;
|
|
2266
|
+
d.state ? (ar(d.state), lr(void 0)) : d.id === "duo-capabilities" && lr(d.error || "This instance does not support native iPhone Duo displays.");
|
|
2267
|
+
const b = Le.current.get(d.id);
|
|
2268
|
+
b && (clearTimeout(b.timer), Le.current.delete(d.id), d.error ? b.reject(new Error(d.error)) : b.resolve());
|
|
2225
2269
|
break;
|
|
2226
2270
|
}
|
|
2227
2271
|
case "signalingError": {
|
|
2228
|
-
if (d.requestType !== "offer" || d.sessionId !==
|
|
2272
|
+
if (d.requestType !== "offer" || d.sessionId !== le)
|
|
2229
2273
|
break;
|
|
2230
|
-
const
|
|
2231
|
-
|
|
2274
|
+
const b = typeof d.error == "string" ? d.error : "Unable to establish the streaming connection";
|
|
2275
|
+
k("Error: " + b), et(b, i);
|
|
2232
2276
|
break;
|
|
2233
2277
|
}
|
|
2234
2278
|
case "answer":
|
|
2235
|
-
if (!
|
|
2236
|
-
|
|
2279
|
+
if (!x.current || x.current !== h) {
|
|
2280
|
+
k("No peer connection, skipping answer");
|
|
2237
2281
|
break;
|
|
2238
2282
|
}
|
|
2239
|
-
if (await h.setRemoteDescription(
|
|
2283
|
+
if (z?.accept(d.latencyTraceVersion), await h.setRemoteDescription(
|
|
2240
2284
|
new RTCSessionDescription({
|
|
2241
2285
|
type: "answer",
|
|
2242
2286
|
sdp: d.sdp
|
|
2243
2287
|
})
|
|
2244
|
-
), !o() ||
|
|
2288
|
+
), !o() || x.current !== h)
|
|
2245
2289
|
return;
|
|
2246
|
-
|
|
2290
|
+
k("Set remote description");
|
|
2247
2291
|
break;
|
|
2248
2292
|
case "candidate":
|
|
2249
|
-
if (!
|
|
2250
|
-
|
|
2293
|
+
if (!x.current || x.current !== h) {
|
|
2294
|
+
k("No peer connection, skipping candidate");
|
|
2251
2295
|
break;
|
|
2252
2296
|
}
|
|
2253
2297
|
if (await h.addIceCandidate(
|
|
@@ -2256,147 +2300,148 @@ const Xo = Kn(
|
|
|
2256
2300
|
sdpMid: d.sdpMid,
|
|
2257
2301
|
sdpMLineIndex: d.sdpMLineIndex
|
|
2258
2302
|
})
|
|
2259
|
-
), !o() ||
|
|
2303
|
+
), !o() || x.current !== h)
|
|
2260
2304
|
return;
|
|
2261
|
-
|
|
2305
|
+
k("Added ICE candidate");
|
|
2262
2306
|
break;
|
|
2263
2307
|
case "screenshot":
|
|
2264
2308
|
case "screenshotResult": {
|
|
2265
2309
|
if (typeof d.id != "string") {
|
|
2266
|
-
|
|
2310
|
+
A("Received invalid screenshot success message:", d);
|
|
2267
2311
|
break;
|
|
2268
2312
|
}
|
|
2269
|
-
const
|
|
2270
|
-
if (
|
|
2271
|
-
const
|
|
2272
|
-
if (!
|
|
2273
|
-
|
|
2313
|
+
const b = Lo(d);
|
|
2314
|
+
if (b) {
|
|
2315
|
+
const ie = Oe.current.get(d.id);
|
|
2316
|
+
if (!ie) {
|
|
2317
|
+
A(`Received screenshot error for unknown or handled id: ${d.id}`);
|
|
2274
2318
|
break;
|
|
2275
2319
|
}
|
|
2276
|
-
|
|
2320
|
+
A(`Received screenshot error for id ${d.id}: ${b}`), ie(new Error(b)), Te.current.delete(d.id), Oe.current.delete(d.id);
|
|
2277
2321
|
break;
|
|
2278
2322
|
}
|
|
2279
|
-
const I =
|
|
2323
|
+
const I = xo(d);
|
|
2280
2324
|
if (!I) {
|
|
2281
|
-
|
|
2325
|
+
A("Received screenshot message without image data:", d);
|
|
2282
2326
|
break;
|
|
2283
2327
|
}
|
|
2284
|
-
const
|
|
2285
|
-
if (!
|
|
2286
|
-
|
|
2328
|
+
const V = Te.current.get(d.id);
|
|
2329
|
+
if (!V) {
|
|
2330
|
+
A(`Received screenshot data for unknown or handled id: ${d.id}`);
|
|
2287
2331
|
break;
|
|
2288
2332
|
}
|
|
2289
|
-
|
|
2333
|
+
F(`Received screenshot data for id ${d.id}`), V(I), Te.current.delete(d.id), Oe.current.delete(d.id);
|
|
2290
2334
|
break;
|
|
2291
2335
|
}
|
|
2292
2336
|
case "screenshotError":
|
|
2293
2337
|
if (typeof d.id != "string" || typeof d.message != "string") {
|
|
2294
|
-
|
|
2338
|
+
A("Received invalid screenshot error message:", d);
|
|
2295
2339
|
break;
|
|
2296
2340
|
}
|
|
2297
2341
|
const Y = Oe.current.get(d.id);
|
|
2298
2342
|
if (!Y) {
|
|
2299
|
-
|
|
2343
|
+
A(`Received screenshot error for unknown or handled id: ${d.id}`);
|
|
2300
2344
|
break;
|
|
2301
2345
|
}
|
|
2302
|
-
|
|
2346
|
+
A(`Received screenshot error for id ${d.id}: ${d.message}`), Y(new Error(d.message)), Te.current.delete(d.id), Oe.current.delete(d.id);
|
|
2303
2347
|
break;
|
|
2304
2348
|
case "cameraRequest": {
|
|
2305
|
-
const
|
|
2306
|
-
if (!
|
|
2349
|
+
const b = be.current;
|
|
2350
|
+
if (!b)
|
|
2307
2351
|
break;
|
|
2308
|
-
const I =
|
|
2352
|
+
const I = Eo(d);
|
|
2309
2353
|
if (!I) {
|
|
2310
|
-
|
|
2354
|
+
A("Received invalid cameraRequest:", d);
|
|
2311
2355
|
break;
|
|
2312
2356
|
}
|
|
2313
|
-
console.info("[RemoteControl] cameraRequest received:", I.active, I.facingMode), await
|
|
2357
|
+
console.info("[RemoteControl] cameraRequest received:", I.active, I.facingMode), await Sn(I, n, b, o);
|
|
2314
2358
|
break;
|
|
2315
2359
|
}
|
|
2316
2360
|
case "microphoneRequest": {
|
|
2317
|
-
if (!
|
|
2361
|
+
if (!at.current)
|
|
2318
2362
|
break;
|
|
2319
|
-
const
|
|
2320
|
-
if (
|
|
2321
|
-
|
|
2363
|
+
const b = d.active === !0;
|
|
2364
|
+
if (Jt.current = b, console.info("[RemoteControl] microphoneRequest received, active=", b), !b) {
|
|
2365
|
+
Gt.current || await Kt();
|
|
2322
2366
|
break;
|
|
2323
2367
|
}
|
|
2324
|
-
if (
|
|
2325
|
-
|
|
2368
|
+
if (he.current) {
|
|
2369
|
+
Nr(n);
|
|
2326
2370
|
break;
|
|
2327
2371
|
}
|
|
2328
|
-
await
|
|
2372
|
+
await rr();
|
|
2329
2373
|
break;
|
|
2330
2374
|
}
|
|
2331
2375
|
case "microphoneStartResult": {
|
|
2332
|
-
if (
|
|
2376
|
+
if (He.current === null || d.id !== He.current)
|
|
2333
2377
|
break;
|
|
2334
|
-
|
|
2378
|
+
He.current = null, typeof d.error == "string" && (console.warn("[RemoteControl] microphoneStart rejected by host:", d.error), Kt(d.error));
|
|
2335
2379
|
break;
|
|
2336
2380
|
}
|
|
2337
2381
|
case "terminateAppResult":
|
|
2338
2382
|
if (typeof d.id != "string") {
|
|
2339
|
-
|
|
2383
|
+
A("Received invalid terminateApp result message:", d);
|
|
2340
2384
|
break;
|
|
2341
2385
|
}
|
|
2342
2386
|
if (typeof d.error == "string") {
|
|
2343
|
-
const
|
|
2344
|
-
if (!
|
|
2345
|
-
|
|
2387
|
+
const b = Re.current.get(d.id);
|
|
2388
|
+
if (!b) {
|
|
2389
|
+
A(`Received terminateApp error for unknown or handled id: ${d.id}`);
|
|
2346
2390
|
break;
|
|
2347
2391
|
}
|
|
2348
|
-
|
|
2392
|
+
A(`Received terminateApp error for id ${d.id}: ${d.error}`), b(new Error(d.error)), Me.current.delete(d.id), Re.current.delete(d.id);
|
|
2349
2393
|
break;
|
|
2350
2394
|
}
|
|
2351
|
-
const
|
|
2352
|
-
if (!
|
|
2353
|
-
|
|
2395
|
+
const Q = Me.current.get(d.id);
|
|
2396
|
+
if (!Q) {
|
|
2397
|
+
A(`Received terminateApp result for unknown or handled id: ${d.id}`);
|
|
2354
2398
|
break;
|
|
2355
2399
|
}
|
|
2356
|
-
|
|
2400
|
+
F(`Received terminateApp success for id ${d.id}`), Q(), Me.current.delete(d.id), Re.current.delete(d.id);
|
|
2357
2401
|
break;
|
|
2358
2402
|
default:
|
|
2359
|
-
|
|
2403
|
+
A(`Received unhandled message type: ${d.type}`, d);
|
|
2360
2404
|
break;
|
|
2361
2405
|
}
|
|
2362
|
-
},
|
|
2363
|
-
const
|
|
2406
|
+
}, x.current === h) {
|
|
2407
|
+
const T = await h.createOffer({
|
|
2364
2408
|
offerToReceiveVideo: !0,
|
|
2365
2409
|
offerToReceiveAudio: !1
|
|
2366
2410
|
});
|
|
2367
|
-
if (!o() ||
|
|
2411
|
+
if (!o() || x.current !== h || (await h.setLocalDescription(T), !o() || x.current !== h))
|
|
2368
2412
|
return;
|
|
2369
|
-
o() &&
|
|
2413
|
+
o() && D.current === n && n.readyState === WebSocket.OPEN && n.send(
|
|
2370
2414
|
JSON.stringify({
|
|
2371
2415
|
type: "offer",
|
|
2372
|
-
...
|
|
2373
|
-
|
|
2374
|
-
|
|
2416
|
+
...y ? { displayStreams: !0 } : {},
|
|
2417
|
+
...z ? { latencyTraceVersion: 1 } : {},
|
|
2418
|
+
sdp: T.sdp,
|
|
2419
|
+
sessionId: le
|
|
2375
2420
|
})
|
|
2376
|
-
),
|
|
2421
|
+
), k("Sent offer");
|
|
2377
2422
|
}
|
|
2378
2423
|
} catch (n) {
|
|
2379
2424
|
if (!o())
|
|
2380
2425
|
return;
|
|
2381
2426
|
const l = n instanceof Error ? n.message : String(n);
|
|
2382
|
-
|
|
2427
|
+
k("Error: " + l), et(l, i);
|
|
2383
2428
|
}
|
|
2384
|
-
},
|
|
2385
|
-
|
|
2386
|
-
},
|
|
2387
|
-
|
|
2388
|
-
},
|
|
2389
|
-
e.stopPropagation(),
|
|
2429
|
+
}, nr = () => {
|
|
2430
|
+
xe.current = !1, dr(!1), kr(0);
|
|
2431
|
+
}, In = () => {
|
|
2432
|
+
Ae.current += 1, Ot.current = 0, Ce.current = !1, It(), Et(), Ze(), k("Stopped");
|
|
2433
|
+
}, Yn = (e) => {
|
|
2434
|
+
e.stopPropagation(), nr();
|
|
2390
2435
|
};
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
}, [
|
|
2394
|
-
|
|
2395
|
-
}), [t, c, a,
|
|
2396
|
-
const
|
|
2397
|
-
const e =
|
|
2436
|
+
me(() => {
|
|
2437
|
+
tr() ? rr() : Kt();
|
|
2438
|
+
}, [tt]), me(() => ($t(!1), nr(), document.hidden || Sr(), document.addEventListener("visibilitychange", Kr), () => {
|
|
2439
|
+
Mr(), In(), document.removeEventListener("visibilitychange", Kr);
|
|
2440
|
+
}), [t, c, a, g, sn]);
|
|
2441
|
+
const Pr = () => {
|
|
2442
|
+
const e = pt();
|
|
2398
2443
|
if (!e) {
|
|
2399
|
-
|
|
2444
|
+
gr(null);
|
|
2400
2445
|
return;
|
|
2401
2446
|
}
|
|
2402
2447
|
const i = {
|
|
@@ -2405,325 +2450,325 @@ const Xo = Kn(
|
|
|
2405
2450
|
width: e.actualWidth,
|
|
2406
2451
|
height: e.actualHeight
|
|
2407
2452
|
};
|
|
2408
|
-
|
|
2453
|
+
gr(
|
|
2409
2454
|
(o) => o && o.left === i.left && o.top === i.top && o.width === i.width && o.height === i.height ? o : i
|
|
2410
2455
|
);
|
|
2411
2456
|
};
|
|
2412
|
-
|
|
2413
|
-
const e =
|
|
2457
|
+
me(() => {
|
|
2458
|
+
const e = W.current, i = Ft.current, o = _e.current;
|
|
2414
2459
|
if (!e) return;
|
|
2415
2460
|
const n = () => {
|
|
2416
|
-
if (!
|
|
2417
|
-
|
|
2461
|
+
if (!St || !i) {
|
|
2462
|
+
hr({}), Pr();
|
|
2418
2463
|
return;
|
|
2419
2464
|
}
|
|
2420
2465
|
const f = i.clientWidth, E = i.clientHeight;
|
|
2421
2466
|
if (f === 0 || E === 0) return;
|
|
2422
|
-
const
|
|
2423
|
-
|
|
2424
|
-
|
|
2467
|
+
const y = e.videoWidth > e.videoHeight;
|
|
2468
|
+
rn(y), on(
|
|
2469
|
+
pe === "android" && ko(e.videoWidth, e.videoHeight)
|
|
2425
2470
|
);
|
|
2426
|
-
const h =
|
|
2471
|
+
const h = y ? Je.videoPosition.landscape : Je.videoPosition.portrait;
|
|
2427
2472
|
let R = {};
|
|
2428
|
-
h.heightMultiplier ? (R.height = `${E * h.heightMultiplier}px`, R.width = "auto") : h.widthMultiplier && (R.width = `${f * h.widthMultiplier}px`, R.height = "auto"), R.borderRadius = `${
|
|
2473
|
+
h.heightMultiplier ? (R.height = `${E * h.heightMultiplier}px`, R.width = "auto") : h.widthMultiplier && (R.width = `${f * h.widthMultiplier}px`, R.height = "auto"), R.borderRadius = `${y ? E * Je.videoBorderRadiusMultiplier : f * Je.videoBorderRadiusMultiplier}px`, hr(R), Pr();
|
|
2429
2474
|
}, l = new ResizeObserver(() => {
|
|
2430
2475
|
n();
|
|
2431
2476
|
});
|
|
2432
2477
|
i && l.observe(i), l.observe(e), o && l.observe(o), i && i.addEventListener("load", n), e.addEventListener("loadedmetadata", n), e.addEventListener("resize", n);
|
|
2433
|
-
const u = () =>
|
|
2478
|
+
const u = () => te.current?.bumpActivity();
|
|
2434
2479
|
return e.addEventListener("resize", u), n(), () => {
|
|
2435
2480
|
l.disconnect(), e.removeEventListener("loadedmetadata", n), e.removeEventListener("resize", n), e.removeEventListener("resize", u), i && i.removeEventListener("load", n);
|
|
2436
2481
|
};
|
|
2437
|
-
}, [
|
|
2438
|
-
const e =
|
|
2439
|
-
|
|
2440
|
-
}, [
|
|
2441
|
-
|
|
2442
|
-
}, []),
|
|
2443
|
-
if (!
|
|
2482
|
+
}, [Je, St]), me(() => {
|
|
2483
|
+
const e = te.current;
|
|
2484
|
+
ft ? e?.start() : (e?.stop(), Er(null), dt(null), At(null), yr(null), Xe(null), bt.current = null, ae.current !== void 0 && (window.cancelAnimationFrame(ae.current), ae.current = void 0), L("onAxSnapshotChange", Qt.current, null));
|
|
2485
|
+
}, [ft]), me(() => () => {
|
|
2486
|
+
ae.current !== void 0 && (window.cancelAnimationFrame(ae.current), ae.current = void 0);
|
|
2487
|
+
}, []), me(() => {
|
|
2488
|
+
if (!ft) return;
|
|
2444
2489
|
const e = (i) => {
|
|
2445
|
-
i.key === "Escape" && (
|
|
2490
|
+
i.key === "Escape" && (zt || jt) && (At(null), dt(null), Xe(null), L("onInspectSelectionChange", Ve.current, null));
|
|
2446
2491
|
};
|
|
2447
2492
|
return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
|
|
2448
|
-
}, [
|
|
2449
|
-
const
|
|
2450
|
-
|
|
2493
|
+
}, [ft, zt, jt]);
|
|
2494
|
+
const Kn = () => {
|
|
2495
|
+
W.current && W.current.focus();
|
|
2451
2496
|
};
|
|
2452
|
-
|
|
2497
|
+
Fn(Ue, () => ({
|
|
2453
2498
|
openUrl: (e) => {
|
|
2454
|
-
if (!
|
|
2455
|
-
|
|
2499
|
+
if (!D.current || D.current.readyState !== WebSocket.OPEN) {
|
|
2500
|
+
A("WebSocket not open, cannot send open_url command via ref.");
|
|
2456
2501
|
return;
|
|
2457
2502
|
}
|
|
2458
2503
|
try {
|
|
2459
2504
|
const i = decodeURIComponent(e);
|
|
2460
|
-
|
|
2505
|
+
k("Opening URL"), D.current.send(
|
|
2461
2506
|
JSON.stringify({
|
|
2462
2507
|
type: "openUrl",
|
|
2463
2508
|
url: i,
|
|
2464
|
-
sessionId:
|
|
2509
|
+
sessionId: le
|
|
2465
2510
|
})
|
|
2466
2511
|
);
|
|
2467
2512
|
} catch (i) {
|
|
2468
|
-
|
|
2513
|
+
A("Error decoding or sending URL via ref:", { error: i, url: e }), D.current.send(
|
|
2469
2514
|
JSON.stringify({
|
|
2470
2515
|
type: "openUrl",
|
|
2471
2516
|
url: e,
|
|
2472
|
-
sessionId:
|
|
2517
|
+
sessionId: le
|
|
2473
2518
|
})
|
|
2474
2519
|
);
|
|
2475
2520
|
}
|
|
2476
|
-
|
|
2521
|
+
te.current?.bumpActivity();
|
|
2477
2522
|
},
|
|
2478
2523
|
sendKeyEvent: (e) => {
|
|
2479
|
-
if (!
|
|
2480
|
-
|
|
2524
|
+
if (!U.current || U.current.readyState !== "open") {
|
|
2525
|
+
A("Data channel not ready for imperative key command:", U.current?.readyState);
|
|
2481
2526
|
return;
|
|
2482
2527
|
}
|
|
2483
|
-
const i =
|
|
2528
|
+
const i = Br[e.code];
|
|
2484
2529
|
if (!i) {
|
|
2485
|
-
|
|
2530
|
+
A(`Unknown event.code for imperative command: ${e.code}`);
|
|
2486
2531
|
return;
|
|
2487
2532
|
}
|
|
2488
2533
|
let o = s.META_NONE;
|
|
2489
2534
|
e.shiftKey && (o |= s.META_SHIFT_ON), e.altKey && (o |= s.META_ALT_ON), e.ctrlKey && (o |= s.META_CTRL_ON), e.metaKey && (o |= s.META_META_ON);
|
|
2490
2535
|
const n = e.type === "keydown" ? s.ACTION_DOWN : s.ACTION_UP;
|
|
2491
|
-
|
|
2536
|
+
F(
|
|
2492
2537
|
`Sending Imperative Key Command: code=${e.code}, keycode=${i}, action=${n}, meta=${o}`
|
|
2493
2538
|
);
|
|
2494
|
-
const l =
|
|
2539
|
+
const l = gt(
|
|
2495
2540
|
n,
|
|
2496
2541
|
i,
|
|
2497
2542
|
0,
|
|
2498
2543
|
// repeat count, typically 0 for single presses
|
|
2499
2544
|
o
|
|
2500
2545
|
);
|
|
2501
|
-
l &&
|
|
2546
|
+
l && de(l);
|
|
2502
2547
|
},
|
|
2503
2548
|
screenshot: (e) => new Promise((i, o) => {
|
|
2504
|
-
if (!
|
|
2505
|
-
return
|
|
2549
|
+
if (!D.current || D.current.readyState !== WebSocket.OPEN)
|
|
2550
|
+
return A("WebSocket not open, cannot send screenshot command."), o(new Error("WebSocket is not connected or connection is not open."));
|
|
2506
2551
|
const n = `ui-ss-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`, l = {
|
|
2507
2552
|
type: e ? "screenshotDisplay" : "screenshot",
|
|
2508
2553
|
...e ? { display: e } : {},
|
|
2509
2554
|
id: n
|
|
2510
2555
|
};
|
|
2511
|
-
|
|
2556
|
+
Te.current.set(n, i), Oe.current.set(n, o), F("Sending screenshot request:", l);
|
|
2512
2557
|
try {
|
|
2513
|
-
|
|
2558
|
+
D.current.send(JSON.stringify(l));
|
|
2514
2559
|
} catch (u) {
|
|
2515
|
-
|
|
2560
|
+
A("Failed to send screenshot request immediately:", u), Te.current.delete(n), Oe.current.delete(n), o(u);
|
|
2516
2561
|
return;
|
|
2517
2562
|
}
|
|
2518
2563
|
setTimeout(() => {
|
|
2519
|
-
|
|
2564
|
+
Te.current.has(n) && (A(`Screenshot request timed out for id ${n}`), Oe.current.get(n)?.(new Error("Screenshot request timed out")), Te.current.delete(n), Oe.current.delete(n));
|
|
2520
2565
|
}, 3e4);
|
|
2521
2566
|
}),
|
|
2522
2567
|
terminateApp: (e) => new Promise((i, o) => {
|
|
2523
|
-
if (!
|
|
2524
|
-
return
|
|
2568
|
+
if (!D.current || D.current.readyState !== WebSocket.OPEN)
|
|
2569
|
+
return A("WebSocket not open, cannot send terminateApp command."), o(new Error("WebSocket is not connected or connection is not open."));
|
|
2525
2570
|
const n = `ui-term-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`, l = {
|
|
2526
2571
|
type: "terminateApp",
|
|
2527
2572
|
id: n,
|
|
2528
2573
|
bundleId: e
|
|
2529
2574
|
};
|
|
2530
|
-
|
|
2575
|
+
Me.current.set(n, i), Re.current.set(n, o), F("Sending terminateApp request:", l);
|
|
2531
2576
|
try {
|
|
2532
|
-
|
|
2577
|
+
D.current.send(JSON.stringify(l));
|
|
2533
2578
|
} catch (u) {
|
|
2534
|
-
|
|
2579
|
+
A("Failed to send terminateApp request immediately:", u), Me.current.delete(n), Re.current.delete(n), o(u);
|
|
2535
2580
|
return;
|
|
2536
2581
|
}
|
|
2537
|
-
|
|
2538
|
-
|
|
2582
|
+
te.current?.bumpActivity(), setTimeout(() => {
|
|
2583
|
+
Me.current.has(n) && (A(`terminateApp request timed out for id ${n}`), Re.current.get(n)?.(new Error("terminateApp request timed out")), Me.current.delete(n), Re.current.delete(n));
|
|
2539
2584
|
}, 3e4);
|
|
2540
2585
|
}),
|
|
2541
|
-
reconnect: () =>
|
|
2586
|
+
reconnect: () => nr(),
|
|
2542
2587
|
refreshAxTree: async () => {
|
|
2543
|
-
const e =
|
|
2588
|
+
const e = te.current;
|
|
2544
2589
|
if (!e)
|
|
2545
2590
|
throw new Error("Inspect mode is not active");
|
|
2546
2591
|
return e.refresh();
|
|
2547
2592
|
},
|
|
2548
|
-
getAxSnapshot: () =>
|
|
2593
|
+
getAxSnapshot: () => qe.current,
|
|
2549
2594
|
setInspectHighlight: (e) => {
|
|
2550
|
-
|
|
2595
|
+
dt(e?.id ?? null);
|
|
2551
2596
|
},
|
|
2552
2597
|
setInspectSelection: (e) => {
|
|
2553
|
-
|
|
2554
|
-
const i =
|
|
2555
|
-
e && i ? L("onInspectSelectionChange",
|
|
2598
|
+
At(e?.id ?? null), Xe(e ? bt.current : null);
|
|
2599
|
+
const i = qe.current;
|
|
2600
|
+
e && i ? L("onInspectSelectionChange", Ve.current, { element: e, snapshot: i }) : L("onInspectSelectionChange", Ve.current, null);
|
|
2556
2601
|
},
|
|
2557
|
-
getAxStatus: () =>
|
|
2602
|
+
getAxStatus: () => te.current?.getStatus() ?? "idle"
|
|
2558
2603
|
}));
|
|
2559
|
-
const
|
|
2560
|
-
return /* @__PURE__ */
|
|
2604
|
+
const kn = an && Ie !== null;
|
|
2605
|
+
return /* @__PURE__ */ ue(
|
|
2561
2606
|
"div",
|
|
2562
2607
|
{
|
|
2563
|
-
ref:
|
|
2564
|
-
className:
|
|
2608
|
+
ref: _e,
|
|
2609
|
+
className: Pe("rc-container", r),
|
|
2565
2610
|
style: { touchAction: "none" },
|
|
2566
|
-
onMouseDown:
|
|
2567
|
-
onMouseMove:
|
|
2568
|
-
onMouseUp:
|
|
2569
|
-
onMouseLeave:
|
|
2570
|
-
onTouchStart:
|
|
2571
|
-
onTouchMove:
|
|
2572
|
-
onTouchEnd:
|
|
2573
|
-
onTouchCancel:
|
|
2611
|
+
onMouseDown: we,
|
|
2612
|
+
onMouseMove: we,
|
|
2613
|
+
onMouseUp: we,
|
|
2614
|
+
onMouseLeave: we,
|
|
2615
|
+
onTouchStart: we,
|
|
2616
|
+
onTouchMove: we,
|
|
2617
|
+
onTouchEnd: we,
|
|
2618
|
+
onTouchCancel: we,
|
|
2574
2619
|
children: [
|
|
2575
|
-
|
|
2576
|
-
/* @__PURE__ */
|
|
2620
|
+
kn && Ie && /* @__PURE__ */ ue($r, { children: [
|
|
2621
|
+
/* @__PURE__ */ P(
|
|
2577
2622
|
"div",
|
|
2578
2623
|
{
|
|
2579
2624
|
className: "rc-touch-indicator",
|
|
2580
2625
|
style: {
|
|
2581
|
-
left: `${
|
|
2582
|
-
top: `${
|
|
2626
|
+
left: `${Ie.containerX}px`,
|
|
2627
|
+
top: `${Ie.containerY}px`
|
|
2583
2628
|
}
|
|
2584
2629
|
}
|
|
2585
2630
|
),
|
|
2586
|
-
/* @__PURE__ */
|
|
2631
|
+
/* @__PURE__ */ P(
|
|
2587
2632
|
"div",
|
|
2588
2633
|
{
|
|
2589
2634
|
className: "rc-touch-indicator",
|
|
2590
2635
|
style: {
|
|
2591
|
-
left: `${
|
|
2592
|
-
top: `${
|
|
2636
|
+
left: `${Ie.mirrorContainerX}px`,
|
|
2637
|
+
top: `${Ie.mirrorContainerY}px`
|
|
2593
2638
|
}
|
|
2594
2639
|
}
|
|
2595
2640
|
)
|
|
2596
2641
|
] }),
|
|
2597
|
-
|
|
2642
|
+
St && /* @__PURE__ */ P(
|
|
2598
2643
|
"img",
|
|
2599
2644
|
{
|
|
2600
|
-
ref:
|
|
2601
|
-
src:
|
|
2645
|
+
ref: Ft,
|
|
2646
|
+
src: Tr,
|
|
2602
2647
|
alt: "",
|
|
2603
|
-
className:
|
|
2648
|
+
className: pe === "ios" ? Pe("rc-phone-frame", "rc-phone-frame-ios") : "rc-phone-frame",
|
|
2604
2649
|
draggable: !1
|
|
2605
2650
|
}
|
|
2606
2651
|
),
|
|
2607
|
-
/* @__PURE__ */
|
|
2652
|
+
/* @__PURE__ */ P(
|
|
2608
2653
|
"video",
|
|
2609
2654
|
{
|
|
2610
|
-
ref:
|
|
2611
|
-
className:
|
|
2655
|
+
ref: W,
|
|
2656
|
+
className: Pe(
|
|
2612
2657
|
"rc-video",
|
|
2613
|
-
!
|
|
2614
|
-
!
|
|
2658
|
+
!St && "rc-video-frameless",
|
|
2659
|
+
!Zr && "rc-video-loading"
|
|
2615
2660
|
),
|
|
2616
2661
|
style: {
|
|
2617
|
-
...
|
|
2618
|
-
...
|
|
2619
|
-
...
|
|
2620
|
-
backgroundImage: `url("${
|
|
2662
|
+
...cn,
|
|
2663
|
+
...ye ? { opacity: 0, width: 1, height: 1, pointerEvents: "none" } : {},
|
|
2664
|
+
...wr ? {
|
|
2665
|
+
backgroundImage: `url("${wr}")`,
|
|
2621
2666
|
backgroundRepeat: "no-repeat",
|
|
2622
2667
|
backgroundPosition: "center",
|
|
2623
|
-
backgroundSize:
|
|
2668
|
+
backgroundSize: Je.loadingLogoSize
|
|
2624
2669
|
} : {}
|
|
2625
2670
|
},
|
|
2626
2671
|
autoPlay: !0,
|
|
2627
2672
|
playsInline: !0,
|
|
2628
2673
|
muted: !0,
|
|
2629
|
-
tabIndex:
|
|
2630
|
-
onKeyDown:
|
|
2631
|
-
onKeyUp:
|
|
2632
|
-
onClick:
|
|
2633
|
-
onLoadedData:
|
|
2674
|
+
tabIndex: ye ? -1 : 0,
|
|
2675
|
+
onKeyDown: Nt,
|
|
2676
|
+
onKeyUp: Nt,
|
|
2677
|
+
onClick: Kn,
|
|
2678
|
+
onLoadedData: Tn,
|
|
2634
2679
|
onFocus: () => {
|
|
2635
|
-
|
|
2680
|
+
W.current && (W.current.style.outline = "none");
|
|
2636
2681
|
},
|
|
2637
2682
|
onBlur: () => {
|
|
2638
|
-
|
|
2683
|
+
W.current && (W.current.style.outline = "none");
|
|
2639
2684
|
}
|
|
2640
2685
|
}
|
|
2641
2686
|
),
|
|
2642
|
-
|
|
2687
|
+
ye && /* @__PURE__ */ P(
|
|
2643
2688
|
"video",
|
|
2644
2689
|
{
|
|
2645
|
-
ref:
|
|
2690
|
+
ref: nt,
|
|
2646
2691
|
autoPlay: !0,
|
|
2647
2692
|
playsInline: !0,
|
|
2648
2693
|
muted: !0,
|
|
2649
2694
|
style: { position: "absolute", width: 1, height: 1, opacity: 0, pointerEvents: "none" }
|
|
2650
2695
|
}
|
|
2651
2696
|
),
|
|
2652
|
-
|
|
2653
|
-
|
|
2697
|
+
ye && sr && /* @__PURE__ */ P(Wn, { fallback: /* @__PURE__ */ P("div", { children: "Loading iPhone Duo…" }), children: /* @__PURE__ */ P(
|
|
2698
|
+
Mo,
|
|
2654
2699
|
{
|
|
2655
2700
|
showFrame: p,
|
|
2656
|
-
modelUrl:
|
|
2657
|
-
outer:
|
|
2658
|
-
inner:
|
|
2659
|
-
state:
|
|
2660
|
-
setAngle: (e) =>
|
|
2661
|
-
setOrientation: (e) =>
|
|
2662
|
-
button: (e, i) =>
|
|
2701
|
+
modelUrl: C,
|
|
2702
|
+
outer: W.current,
|
|
2703
|
+
inner: nt.current,
|
|
2704
|
+
state: sr,
|
|
2705
|
+
setAngle: (e) => Ht("setHingeAngle", { angleDegrees: e }),
|
|
2706
|
+
setOrientation: (e) => Ht("setDuoOrientation", { orientation: e }),
|
|
2707
|
+
button: (e, i) => Ht("performActions", {
|
|
2663
2708
|
actions: [{ type: i ? "buttonDown" : "buttonUp", button: e }]
|
|
2664
2709
|
}),
|
|
2665
2710
|
touch: (e, i, o, n) => {
|
|
2666
|
-
const l =
|
|
2667
|
-
l?.readyState === "open" && l.send(
|
|
2711
|
+
const l = U.current;
|
|
2712
|
+
l?.readyState === "open" && l.send(Xn(e, i, o, n));
|
|
2668
2713
|
},
|
|
2669
|
-
onKeyDown:
|
|
2670
|
-
onKeyUp:
|
|
2714
|
+
onKeyDown: Nt,
|
|
2715
|
+
onKeyUp: Nt
|
|
2671
2716
|
}
|
|
2672
2717
|
) }),
|
|
2673
|
-
|
|
2674
|
-
!
|
|
2675
|
-
|
|
2718
|
+
ye && ur && /* @__PURE__ */ P("div", { role: "alert", className: "rc-duo-error", children: ur }),
|
|
2719
|
+
!ye && ft && /* @__PURE__ */ P(
|
|
2720
|
+
So,
|
|
2676
2721
|
{
|
|
2677
|
-
snapshot:
|
|
2678
|
-
geometry:
|
|
2679
|
-
highlightedId:
|
|
2680
|
-
selectedId:
|
|
2681
|
-
mode:
|
|
2682
|
-
cursorPosition:
|
|
2683
|
-
frozenCursorPosition:
|
|
2722
|
+
snapshot: mr,
|
|
2723
|
+
geometry: ln,
|
|
2724
|
+
highlightedId: jt,
|
|
2725
|
+
selectedId: zt,
|
|
2726
|
+
mode: hn,
|
|
2727
|
+
cursorPosition: dn,
|
|
2728
|
+
frozenCursorPosition: fn,
|
|
2684
2729
|
onSelectChange: (e, i) => {
|
|
2685
|
-
|
|
2686
|
-
const o =
|
|
2687
|
-
e && o ? L("onInspectSelectionChange",
|
|
2730
|
+
At(e?.id ?? null), e && i ? Xe(i) : e || Xe(null);
|
|
2731
|
+
const o = qe.current;
|
|
2732
|
+
e && o ? L("onInspectSelectionChange", Ve.current, {
|
|
2688
2733
|
element: e,
|
|
2689
2734
|
snapshot: o
|
|
2690
|
-
}) : L("onInspectSelectionChange",
|
|
2735
|
+
}) : L("onInspectSelectionChange", Ve.current, null);
|
|
2691
2736
|
},
|
|
2692
2737
|
onTapElement: (e, i) => {
|
|
2693
2738
|
if (i) {
|
|
2694
|
-
|
|
2739
|
+
Ar(i.x, i.y);
|
|
2695
2740
|
return;
|
|
2696
2741
|
}
|
|
2697
|
-
const o =
|
|
2698
|
-
o &&
|
|
2742
|
+
const o = qe.current;
|
|
2743
|
+
o && pn(e, o);
|
|
2699
2744
|
}
|
|
2700
2745
|
}
|
|
2701
2746
|
),
|
|
2702
|
-
|
|
2703
|
-
/* @__PURE__ */
|
|
2704
|
-
/* @__PURE__ */
|
|
2705
|
-
] }) :
|
|
2747
|
+
tn ? /* @__PURE__ */ ue("div", { className: "rc-terminated", role: "status", children: [
|
|
2748
|
+
/* @__PURE__ */ P("div", { className: "rc-terminated-title", children: "Instance terminated" }),
|
|
2749
|
+
/* @__PURE__ */ P("div", { className: "rc-terminated-message", children: "This instance no longer exists and can't be reconnected." })
|
|
2750
|
+
] }) : en && /* @__PURE__ */ P("button", { type: "button", className: "rc-retry-button", onClick: Yn, children: "Retry" })
|
|
2706
2751
|
]
|
|
2707
2752
|
}
|
|
2708
2753
|
);
|
|
2709
2754
|
}
|
|
2710
|
-
),
|
|
2755
|
+
), Lo = (r) => typeof r.message == "string" ? r.message : typeof r.error == "string" ? r.error : null, xo = (r) => typeof r.dataUri == "string" ? { dataUri: r.dataUri } : typeof r.base64 == "string" ? r.base64.startsWith("data:") ? { dataUri: r.base64 } : { dataUri: `data:${r.base64.startsWith("/9j/") ? "image/jpeg" : "image/png"};base64,${r.base64}` } : null;
|
|
2711
2756
|
export {
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2757
|
+
or as A,
|
|
2758
|
+
$o as D,
|
|
2759
|
+
Vo as H,
|
|
2760
|
+
jo as R,
|
|
2761
|
+
io as a,
|
|
2762
|
+
co as b,
|
|
2763
|
+
zr as c,
|
|
2764
|
+
Gr as d,
|
|
2765
|
+
Jr as e,
|
|
2766
|
+
oo as f,
|
|
2767
|
+
eo as g,
|
|
2768
|
+
Jo as h,
|
|
2769
|
+
Go as i,
|
|
2770
|
+
Xo as j,
|
|
2771
|
+
qo as k,
|
|
2772
|
+
no as n,
|
|
2773
|
+
Bo as p
|
|
2729
2774
|
};
|