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