@limrun/ui 0.20.4 → 0.20.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{GLTFLoader-HYStnvvW.js → GLTFLoader-CDlCzcwQ.js} +1 -1
- package/dist/{GLTFLoader-BoPozIl8.mjs → GLTFLoader-k2LXj_Q8.mjs} +1 -1
- package/dist/core/device-stream.d.ts +4 -1
- package/dist/core-Bdivxz74.js +2 -0
- package/dist/{core-DuukW7sF.mjs → core-BpV73M0K.mjs} +328 -321
- package/dist/core.cjs +1 -1
- package/dist/core.js +1 -1
- package/dist/{duo-frame-xMRcGXf4.mjs → duo-frame-Sz0TWot-.mjs} +3 -3
- package/dist/{duo-frame-n5_DJUKk.js → duo-frame-gXvPDImv.js} +2 -2
- package/dist/{duo-view-Cy8dvjCI.js → duo-view-BMPB0h3C.js} +1 -1
- package/dist/{duo-view-CvOd3jDJ.mjs → duo-view-DWqQXwdZ.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 +2 -2
- package/dist/remote-control-CTn0dIkj.js +1 -0
- package/dist/remote-control-VZ7b8hFe.mjs +1175 -0
- package/package.json +1 -1
- package/dist/core-OsPKiOsB.js +0 -2
- package/dist/remote-control-CRqEQ8NT.mjs +0 -1159
- package/dist/remote-control-CiWHN9Do.js +0 -1
|
@@ -356,27 +356,27 @@ const je = {
|
|
|
356
356
|
NumpadEnter: i.KEYCODE_NUMPAD_ENTER,
|
|
357
357
|
NumpadEqual: i.KEYCODE_NUMPAD_EQUALS
|
|
358
358
|
};
|
|
359
|
-
function Vt(t, e, n,
|
|
359
|
+
function Vt(t, e, n, c, f, d, a = 1, p = 0, O = 0) {
|
|
360
360
|
const h = new ArrayBuffer(32), K = new DataView(h);
|
|
361
361
|
let w = 0;
|
|
362
362
|
K.setUint8(w, je.INJECT_TOUCH_EVENT), w += 1;
|
|
363
363
|
const I = t === Ge.ACTION_POINTER_DOWN ? Ge.ACTION_DOWN : t === Ge.ACTION_POINTER_UP ? Ge.ACTION_UP : t;
|
|
364
|
-
return K.setUint8(w, I), w += 1, K.setBigInt64(w, BigInt(e), !0), w += 8, K.setInt32(w, Math.round(f), !0), w += 4, K.setInt32(w, Math.round(
|
|
364
|
+
return K.setUint8(w, I), w += 1, K.setBigInt64(w, BigInt(e), !0), w += 8, K.setInt32(w, Math.round(f), !0), w += 4, K.setInt32(w, Math.round(d), !0), w += 4, K.setUint16(w, n, !0), w += 2, K.setUint16(w, c, !0), w += 2, K.setInt16(w, Math.round(a * 65535), !0), w += 2, K.setInt32(w, p, !0), w += 4, K.setInt32(w, O, !0), h;
|
|
365
365
|
}
|
|
366
|
-
function Un(t, e, n,
|
|
367
|
-
const
|
|
366
|
+
function Un(t, e, n, c, f, d, a) {
|
|
367
|
+
const p = new ArrayBuffer(24), O = new DataView(p);
|
|
368
368
|
let h = 0;
|
|
369
|
-
return O.setUint8(h, je.INJECT_TWO_FINGER_TOUCH_EVENT), h += 1, O.setUint8(h, t), h += 1, O.setInt32(h, Math.round(
|
|
369
|
+
return O.setUint8(h, je.INJECT_TWO_FINGER_TOUCH_EVENT), h += 1, O.setUint8(h, t), h += 1, O.setInt32(h, Math.round(c), !0), h += 4, O.setInt32(h, Math.round(f), !0), h += 4, O.setInt32(h, Math.round(d), !0), h += 4, O.setInt32(h, Math.round(a), !0), h += 4, O.setUint16(h, e, !0), h += 2, O.setUint16(h, n, !0), h += 2, O.setUint16(h, 0, !0), p;
|
|
370
370
|
}
|
|
371
371
|
function Ht(t, e = !0) {
|
|
372
|
-
const
|
|
372
|
+
const c = new TextEncoder().encode(t), f = new ArrayBuffer(14 + c.length), d = new DataView(f);
|
|
373
373
|
let a = 0;
|
|
374
|
-
return
|
|
374
|
+
return d.setUint8(a, je.SET_CLIPBOARD), a += 1, d.setBigInt64(a, BigInt(0), !1), a += 8, d.setUint8(a, e ? 1 : 0), a += 1, d.setUint32(a, c.length, !1), a += 4, new Uint8Array(f, a).set(c), f;
|
|
375
375
|
}
|
|
376
|
-
function rt(t, e, n = 0,
|
|
377
|
-
const f = new ArrayBuffer(14),
|
|
376
|
+
function rt(t, e, n = 0, c = 0) {
|
|
377
|
+
const f = new ArrayBuffer(14), d = new DataView(f);
|
|
378
378
|
let a = 0;
|
|
379
|
-
return
|
|
379
|
+
return d.setUint8(a, je.INJECT_KEYCODE), a += 1, d.setUint8(a, t), a += 1, d.setInt32(a, e, !0), a += 4, d.setInt32(a, n, !0), a += 4, d.setInt32(a, c, !0), f;
|
|
380
380
|
}
|
|
381
381
|
function Pn(t) {
|
|
382
382
|
return t?.displays.find((e) => e.id === (t.angleDegrees < 90 ? "outer" : "inner"));
|
|
@@ -399,16 +399,16 @@ class Ln {
|
|
|
399
399
|
(this.screenId !== e?.screenId || this.turns !== n) && this.release(), this.screenId = e?.screenId, this.turns = n;
|
|
400
400
|
}
|
|
401
401
|
/** Coordinates are normalized; native input already accounts for the viewer's rotation. */
|
|
402
|
-
touch(e, n,
|
|
402
|
+
touch(e, n, c, f = !1) {
|
|
403
403
|
if (this.screenId === void 0) return;
|
|
404
|
-
const
|
|
405
|
-
e === "begin" && (this.release(), this.held = { screenId: this.screenId, ...
|
|
404
|
+
const d = Jt(n, c, f ? 0 : this.turns);
|
|
405
|
+
e === "begin" && (this.release(), this.held = { screenId: this.screenId, ...d }), this.held && (Object.assign(this.held, d), e === "end" ? this.release() : this.send(e === "begin" ? 0 : 2, this.held.screenId, d.x, d.y));
|
|
406
406
|
}
|
|
407
407
|
/** Call on pointer cancellation, lost capture, disconnect, and viewer disposal. */
|
|
408
408
|
release() {
|
|
409
409
|
if (!this.held) return;
|
|
410
|
-
const { screenId: e, x: n, y:
|
|
411
|
-
this.held = void 0, this.send(1, e, n,
|
|
410
|
+
const { screenId: e, x: n, y: c } = this.held;
|
|
411
|
+
this.held = void 0, this.send(1, e, n, c);
|
|
412
412
|
}
|
|
413
413
|
}
|
|
414
414
|
const Fn = { width: 164.6, height: 117.8, depth: 5.2 };
|
|
@@ -424,11 +424,11 @@ function Bn(t, e) {
|
|
|
424
424
|
function xn(t, e, n) {
|
|
425
425
|
return e && (t || !n) ? "touch" : t ? "ignore" : "orbit";
|
|
426
426
|
}
|
|
427
|
-
function Xt(t, e, n,
|
|
428
|
-
if (!Number.isInteger(t) || t < 0 || t > 3 || !Number.isInteger(e) || e < 1 || e > 255 || !Number.isFinite(n) || !Number.isFinite(
|
|
427
|
+
function Xt(t, e, n, c) {
|
|
428
|
+
if (!Number.isInteger(t) || t < 0 || t > 3 || !Number.isInteger(e) || e < 1 || e > 255 || !Number.isFinite(n) || !Number.isFinite(c) || n < 0 || n > 1 || c < 0 || c > 1)
|
|
429
429
|
throw new RangeError("Invalid display touch coordinates");
|
|
430
|
-
const f = new ArrayBuffer(12),
|
|
431
|
-
return
|
|
430
|
+
const f = new ArrayBuffer(12), d = new DataView(f);
|
|
431
|
+
return d.setUint8(0, 19), d.setUint8(1, t), d.setUint8(2, e), d.setFloat32(4, n, !0), d.setFloat32(8, c, !0), f;
|
|
432
432
|
}
|
|
433
433
|
class Wn {
|
|
434
434
|
constructor(e, n) {
|
|
@@ -498,50 +498,50 @@ const it = "Accessibility unavailable on this device.", Je = 500, At = (t, e) =>
|
|
|
498
498
|
return typeof t.AXUniqueId == "string" && t.AXUniqueId.length > 0 && (e.AXUniqueId = t.AXUniqueId), typeof t.AXLabel == "string" && t.AXLabel.length > 0 && (e.AXLabel = t.AXLabel), typeof t.type == "string" && t.type.length > 0 && (e.className = t.type), e;
|
|
499
499
|
}, en = (t) => {
|
|
500
500
|
const e = {};
|
|
501
|
-
for (const [n,
|
|
502
|
-
n !== "children" && (e[n] =
|
|
501
|
+
for (const [n, c] of Object.entries(t))
|
|
502
|
+
n !== "children" && (e[n] = c);
|
|
503
503
|
return e;
|
|
504
504
|
};
|
|
505
505
|
function tn(t) {
|
|
506
|
-
const e = Array.isArray(t) ? t : [t], n = zt(e),
|
|
507
|
-
if (
|
|
508
|
-
const
|
|
509
|
-
if (
|
|
510
|
-
const h =
|
|
511
|
-
|
|
512
|
-
id: typeof
|
|
506
|
+
const e = Array.isArray(t) ? t : [t], n = zt(e), c = [], f = (d, a) => {
|
|
507
|
+
if (c.length >= Je) return;
|
|
508
|
+
const p = d.frame;
|
|
509
|
+
if (p && p.width > 0 && p.height > 0 && !At(p, n)) {
|
|
510
|
+
const h = d.role_description || d.role || "", K = (typeof d.AXLabel == "string" ? d.AXLabel : "") || (typeof d.title == "string" ? d.title : "") || "";
|
|
511
|
+
c.push({
|
|
512
|
+
id: typeof d.AXUniqueId == "string" && d.AXUniqueId.length > 0 ? d.AXUniqueId : a,
|
|
513
513
|
path: a,
|
|
514
514
|
label: K,
|
|
515
|
-
value: typeof
|
|
515
|
+
value: typeof d.AXValue == "string" ? d.AXValue : "",
|
|
516
516
|
role: h,
|
|
517
|
-
type: typeof
|
|
518
|
-
enabled:
|
|
519
|
-
focused:
|
|
520
|
-
frame: { x:
|
|
521
|
-
selectors: Zt(
|
|
522
|
-
raw: en(
|
|
517
|
+
type: typeof d.type == "string" ? d.type : "",
|
|
518
|
+
enabled: d.enabled !== !1,
|
|
519
|
+
focused: d.focused === !0,
|
|
520
|
+
frame: { x: p.x, y: p.y, width: p.width, height: p.height },
|
|
521
|
+
selectors: Zt(d),
|
|
522
|
+
raw: en(d)
|
|
523
523
|
});
|
|
524
524
|
}
|
|
525
|
-
const O = Array.isArray(
|
|
526
|
-
for (let h = 0; h < O.length &&
|
|
525
|
+
const O = Array.isArray(d.children) ? d.children : [];
|
|
526
|
+
for (let h = 0; h < O.length && c.length < Je; h++)
|
|
527
527
|
f(O[h], `${a}.${h}`);
|
|
528
528
|
};
|
|
529
|
-
for (let
|
|
530
|
-
f(e[
|
|
529
|
+
for (let d = 0; d < e.length && c.length < Je; d++)
|
|
530
|
+
f(e[d], String(d));
|
|
531
531
|
return {
|
|
532
532
|
platform: "ios",
|
|
533
533
|
screen: { width: n.width, height: n.height },
|
|
534
|
-
elements:
|
|
534
|
+
elements: c,
|
|
535
535
|
capturedAt: Date.now()
|
|
536
536
|
};
|
|
537
537
|
}
|
|
538
538
|
const nn = (t) => {
|
|
539
539
|
let e = { x: 0, y: 0, width: 1, height: 1 }, n = 0;
|
|
540
|
-
for (const
|
|
541
|
-
const f =
|
|
540
|
+
for (const c of t) {
|
|
541
|
+
const f = c.parsedBounds;
|
|
542
542
|
if (!f) continue;
|
|
543
|
-
const
|
|
544
|
-
|
|
543
|
+
const d = f.right - f.left, a = f.bottom - f.top, p = Math.max(0, d) * Math.max(0, a);
|
|
544
|
+
p > n && (n = p, e = { x: 0, y: 0, width: d, height: a });
|
|
545
545
|
}
|
|
546
546
|
return e;
|
|
547
547
|
}, rn = (t) => {
|
|
@@ -550,17 +550,17 @@ const nn = (t) => {
|
|
|
550
550
|
};
|
|
551
551
|
function on(t) {
|
|
552
552
|
const e = nn(t), n = [];
|
|
553
|
-
for (let
|
|
554
|
-
const f = t[
|
|
555
|
-
if (!
|
|
556
|
-
const a = Math.max(0,
|
|
557
|
-
if (a <= 0 ||
|
|
558
|
-
const O = { x:
|
|
553
|
+
for (let c = 0; c < t.length && n.length < Je; c++) {
|
|
554
|
+
const f = t[c], d = f.parsedBounds;
|
|
555
|
+
if (!d) continue;
|
|
556
|
+
const a = Math.max(0, d.right - d.left), p = Math.max(0, d.bottom - d.top);
|
|
557
|
+
if (a <= 0 || p <= 0) continue;
|
|
558
|
+
const O = { x: d.left, y: d.top, width: a, height: p };
|
|
559
559
|
if (At(O, { x: 0, y: 0, width: e.width, height: e.height })) continue;
|
|
560
560
|
const h = f.contentDesc || f.text || "", K = f.className || "";
|
|
561
561
|
n.push({
|
|
562
|
-
id: f.resourceId && f.resourceId.length > 0 ? f.resourceId : f.contentDesc && f.contentDesc.length > 0 ? `cd:${f.contentDesc}` : String(
|
|
563
|
-
path: String(
|
|
562
|
+
id: f.resourceId && f.resourceId.length > 0 ? f.resourceId : f.contentDesc && f.contentDesc.length > 0 ? `cd:${f.contentDesc}` : String(c),
|
|
563
|
+
path: String(c),
|
|
564
564
|
label: h,
|
|
565
565
|
value: typeof f.text == "string" ? f.text : "",
|
|
566
566
|
role: K,
|
|
@@ -580,14 +580,14 @@ function on(t) {
|
|
|
580
580
|
};
|
|
581
581
|
}
|
|
582
582
|
function Vn(t, e) {
|
|
583
|
-
const n = Math.max(0, t.x),
|
|
584
|
-
return a > 0 &&
|
|
583
|
+
const n = Math.max(0, t.x), c = Math.max(0, t.y), f = Math.min(e.width, t.x + t.width), d = Math.min(e.height, t.y + t.height), a = Math.max(0, f - n), p = Math.max(0, d - c);
|
|
584
|
+
return a > 0 && p > 0 ? { x: n, y: c, width: a, height: p } : null;
|
|
585
585
|
}
|
|
586
586
|
function an(t, e) {
|
|
587
587
|
if (t === e) return !0;
|
|
588
588
|
if (t.id !== e.id || t.path !== e.path || t.label !== e.label || t.value !== e.value || t.role !== e.role || t.type !== e.type || t.enabled !== e.enabled || t.focused !== e.focused) return !1;
|
|
589
|
-
const n = t.frame,
|
|
590
|
-
return n.x ===
|
|
589
|
+
const n = t.frame, c = e.frame;
|
|
590
|
+
return n.x === c.x && n.y === c.y && n.width === c.width && n.height === c.height;
|
|
591
591
|
}
|
|
592
592
|
function sn(t, e) {
|
|
593
593
|
if (t === e) return !0;
|
|
@@ -597,14 +597,14 @@ function sn(t, e) {
|
|
|
597
597
|
return !0;
|
|
598
598
|
}
|
|
599
599
|
function Hn(t, e, n) {
|
|
600
|
-
let
|
|
601
|
-
for (const
|
|
602
|
-
const a =
|
|
600
|
+
let c = null, f = 1 / 0;
|
|
601
|
+
for (const d of t.elements) {
|
|
602
|
+
const a = d.frame;
|
|
603
603
|
if (e < a.x || n < a.y || e > a.x + a.width || n > a.y + a.height) continue;
|
|
604
|
-
const
|
|
605
|
-
|
|
604
|
+
const p = Qt(a);
|
|
605
|
+
p < f && (f = p, c = d);
|
|
606
606
|
}
|
|
607
|
-
return
|
|
607
|
+
return c;
|
|
608
608
|
}
|
|
609
609
|
function Gn(t, e) {
|
|
610
610
|
if (e === "ios") {
|
|
@@ -628,11 +628,11 @@ const gt = 80;
|
|
|
628
628
|
function Jn(t) {
|
|
629
629
|
const e = cn(t), n = t.label || t.value || "";
|
|
630
630
|
if (!n) return e;
|
|
631
|
-
const
|
|
632
|
-
return `${e} · ${
|
|
631
|
+
const c = n.length > gt ? n.slice(0, gt).trimEnd() + "…" : n;
|
|
632
|
+
return `${e} · ${c}`;
|
|
633
633
|
}
|
|
634
634
|
const ln = 500, dn = 2e3, Tt = 5e3, un = 8e3, fn = 1200, En = 250, hn = () => `ax-rc-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
635
|
-
class
|
|
635
|
+
class pn {
|
|
636
636
|
platform;
|
|
637
637
|
send;
|
|
638
638
|
onSnapshot;
|
|
@@ -674,8 +674,8 @@ class mn {
|
|
|
674
674
|
if (this.status !== e && (this.status = e, !!this.onStatusChange))
|
|
675
675
|
try {
|
|
676
676
|
this.onStatusChange(e, n);
|
|
677
|
-
} catch (
|
|
678
|
-
console.error("[AxFetcher] onStatusChange threw:",
|
|
677
|
+
} catch (c) {
|
|
678
|
+
console.error("[AxFetcher] onStatusChange threw:", c);
|
|
679
679
|
}
|
|
680
680
|
}
|
|
681
681
|
// Called after any user-driven action that's likely to change the UI
|
|
@@ -723,9 +723,9 @@ class mn {
|
|
|
723
723
|
if (!this.pending.get(n)) return !1;
|
|
724
724
|
if (this.platform === "ios") {
|
|
725
725
|
if (e.type !== "elementTreeResult") return !1;
|
|
726
|
-
const
|
|
727
|
-
if (
|
|
728
|
-
return this.settleReject(n, new Error(
|
|
726
|
+
const p = typeof e.error == "string" ? e.error : null;
|
|
727
|
+
if (p)
|
|
728
|
+
return this.settleReject(n, new Error(p)), !0;
|
|
729
729
|
const O = typeof e.json == "string" ? e.json : "";
|
|
730
730
|
try {
|
|
731
731
|
const h = JSON.parse(O), K = tn(h);
|
|
@@ -738,15 +738,15 @@ class mn {
|
|
|
738
738
|
if (e.type !== "getElementTreeResult") return !1;
|
|
739
739
|
const f = e.error;
|
|
740
740
|
if (f && typeof f == "object") {
|
|
741
|
-
const
|
|
742
|
-
return this.settleReject(n, new Error(
|
|
741
|
+
const p = typeof f.message == "string" ? f.message : "getElementTree failed";
|
|
742
|
+
return this.settleReject(n, new Error(p)), !0;
|
|
743
743
|
}
|
|
744
|
-
const
|
|
744
|
+
const d = e.payload, a = Array.isArray(d?.nodes) ? d.nodes : [];
|
|
745
745
|
try {
|
|
746
|
-
const
|
|
747
|
-
this.settleResolve(n,
|
|
748
|
-
} catch (
|
|
749
|
-
this.settleReject(n,
|
|
746
|
+
const p = on(a);
|
|
747
|
+
this.settleResolve(n, p);
|
|
748
|
+
} catch (p) {
|
|
749
|
+
this.settleReject(n, p instanceof Error ? p : new Error(String(p)));
|
|
750
750
|
}
|
|
751
751
|
return !0;
|
|
752
752
|
}
|
|
@@ -755,14 +755,14 @@ class mn {
|
|
|
755
755
|
}
|
|
756
756
|
async requestOnce() {
|
|
757
757
|
const e = hn();
|
|
758
|
-
return new Promise((n,
|
|
758
|
+
return new Promise((n, c) => {
|
|
759
759
|
const f = window.setTimeout(
|
|
760
760
|
() => {
|
|
761
|
-
this.pending.delete(e),
|
|
761
|
+
this.pending.delete(e), c(new Error("elementTree request timed out"));
|
|
762
762
|
},
|
|
763
763
|
un + (this.androidElementTreeOptions?.waitForIdleTimeoutMs ?? 0)
|
|
764
764
|
);
|
|
765
|
-
this.pending.set(e, { resolve: n, reject:
|
|
765
|
+
this.pending.set(e, { resolve: n, reject: c, timer: f }), this.send(this.buildRequest(e)) || (window.clearTimeout(f), this.pending.delete(e), c(new Error("elementTree send failed (WebSocket not open)")));
|
|
766
766
|
});
|
|
767
767
|
}
|
|
768
768
|
async runOnce() {
|
|
@@ -774,8 +774,8 @@ class mn {
|
|
|
774
774
|
this.deliver(e);
|
|
775
775
|
} catch (e) {
|
|
776
776
|
if (!this.running) return;
|
|
777
|
-
const n = e instanceof Error ? e.message : String(e),
|
|
778
|
-
this.currentInterval =
|
|
777
|
+
const n = e instanceof Error ? e.message : String(e), c = /unavailable|not (yet )?running|failed|timeout/i.test(n);
|
|
778
|
+
this.currentInterval = c ? Tt : Math.min(this.currentInterval * 2, this.maxBackoffMs), this.setStatus(c ? "unavailable" : "error", n);
|
|
779
779
|
} finally {
|
|
780
780
|
this.inflight = !1, this.scheduleNext();
|
|
781
781
|
}
|
|
@@ -798,16 +798,16 @@ class mn {
|
|
|
798
798
|
}, e);
|
|
799
799
|
}
|
|
800
800
|
settleResolve(e, n) {
|
|
801
|
-
const
|
|
802
|
-
|
|
801
|
+
const c = this.pending.get(e);
|
|
802
|
+
c && (window.clearTimeout(c.timer), this.pending.delete(e), c.resolve(n));
|
|
803
803
|
}
|
|
804
804
|
settleReject(e, n) {
|
|
805
|
-
const
|
|
806
|
-
|
|
805
|
+
const c = this.pending.get(e);
|
|
806
|
+
c && (window.clearTimeout(c.timer), this.pending.delete(e), c.reject(n));
|
|
807
807
|
}
|
|
808
808
|
failAllPending(e) {
|
|
809
|
-
for (const [n,
|
|
810
|
-
window.clearTimeout(
|
|
809
|
+
for (const [n, c] of this.pending.entries())
|
|
810
|
+
window.clearTimeout(c.timer), c.reject(new Error(e)), this.pending.delete(n);
|
|
811
811
|
}
|
|
812
812
|
}
|
|
813
813
|
function yt(t, e) {
|
|
@@ -819,13 +819,13 @@ function yt(t, e) {
|
|
|
819
819
|
const n = e ?? null;
|
|
820
820
|
try {
|
|
821
821
|
t.jitterBufferTarget !== n && (t.jitterBufferTarget = n);
|
|
822
|
-
} catch (
|
|
823
|
-
console.warn("RemoteControl: could not set the jitter buffer target.",
|
|
822
|
+
} catch (c) {
|
|
823
|
+
console.warn("RemoteControl: could not set the jitter buffer target.", c);
|
|
824
824
|
}
|
|
825
825
|
}
|
|
826
826
|
const Mt = `(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())}})();
|
|
827
827
|
`, St = typeof self < "u" && self.Blob && new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);", Mt], { type: "text/javascript;charset=utf-8" });
|
|
828
|
-
function
|
|
828
|
+
function mn(t) {
|
|
829
829
|
let e;
|
|
830
830
|
try {
|
|
831
831
|
if (e = St && (self.URL || self.webkitURL).createObjectURL(St), !e) throw "";
|
|
@@ -845,10 +845,10 @@ function pn(t) {
|
|
|
845
845
|
}
|
|
846
846
|
}
|
|
847
847
|
function Cn(t, e, n) {
|
|
848
|
-
const { MediaStreamTrackProcessor:
|
|
849
|
-
let a,
|
|
848
|
+
const { MediaStreamTrackProcessor: c, MediaStreamTrackGenerator: f } = globalThis, d = e.getVideoTracks()[0];
|
|
849
|
+
let a, p, O, h, K = !1;
|
|
850
850
|
const w = () => {
|
|
851
|
-
K || (K = !0, a?.stop(),
|
|
851
|
+
K || (K = !0, a?.stop(), p?.stop(), O && (O.postMessage({ type: "stop" }), h = setTimeout(() => O?.terminate(), 1e3)));
|
|
852
852
|
}, I = (D) => {
|
|
853
853
|
t.srcObject = D, t.play().catch(() => {
|
|
854
854
|
});
|
|
@@ -856,15 +856,15 @@ function Cn(t, e, n) {
|
|
|
856
856
|
K || (w(), n(D), I(e));
|
|
857
857
|
};
|
|
858
858
|
try {
|
|
859
|
-
if (
|
|
860
|
-
a =
|
|
861
|
-
const D = new
|
|
862
|
-
|
|
859
|
+
if (d && c && f) {
|
|
860
|
+
a = d.clone();
|
|
861
|
+
const D = new c({ track: a, maxBufferSize: 1 }), V = new f({ kind: "video" });
|
|
862
|
+
p = V, O = new mn(), O.onmessage = ({ data: P }) => {
|
|
863
863
|
P.type === "error" ? W(new Error(P.message)) : P.type === "stopped" && (clearTimeout(h), O?.terminate());
|
|
864
864
|
}, O.onerror = (P) => W(new Error(P.message)), O.postMessage({ type: "start", readable: D.readable, writable: V.writable }, [
|
|
865
865
|
D.readable,
|
|
866
866
|
V.writable
|
|
867
|
-
]), I(new MediaStream(e.getTracks().map((P) => P ===
|
|
867
|
+
]), I(new MediaStream(e.getTracks().map((P) => P === d ? V : P)));
|
|
868
868
|
} else
|
|
869
869
|
I(e);
|
|
870
870
|
} catch (D) {
|
|
@@ -884,15 +884,15 @@ class On {
|
|
|
884
884
|
reset() {
|
|
885
885
|
this.previous.clear();
|
|
886
886
|
}
|
|
887
|
-
read(e, n,
|
|
887
|
+
read(e, n, c) {
|
|
888
888
|
const f = { timestamp: 0, video: [], audio: [] };
|
|
889
|
-
|
|
890
|
-
const
|
|
889
|
+
c == null ? f.requestedTargetMs = null : Re(c) && c >= 0 && c <= 4e3 && (f.requestedTargetMs = c);
|
|
890
|
+
const d = /* @__PURE__ */ new Map();
|
|
891
891
|
return e.forEach((a) => {
|
|
892
892
|
if (a.type !== "inbound-rtp" || !Re(a.timestamp)) return;
|
|
893
|
-
const
|
|
894
|
-
if (
|
|
895
|
-
const O = n.filter((k) => k.kind ===
|
|
893
|
+
const p = a.kind ?? a.mediaType;
|
|
894
|
+
if (p !== "video" && p !== "audio") return;
|
|
895
|
+
const O = n.filter((k) => k.kind === p), h = a.trackIdentifier ? O.find((k) => k.trackId === a.trackIdentifier) : a.mid != null ? O.find((k) => k.mid === a.mid) : O.length === 1 ? O[0] : void 0;
|
|
896
896
|
if (!h) return;
|
|
897
897
|
const K = this.previous.get(a.id), I = K?.trackId === h.trackId && K.stats.ssrc === a.ssrc ? K.stats : void 0, W = I ? a.timestamp - I.timestamp : void 0, D = {
|
|
898
898
|
id: a.id,
|
|
@@ -906,7 +906,7 @@ class On {
|
|
|
906
906
|
const q = ge(a.bytesReceived, I?.bytesReceived);
|
|
907
907
|
q !== void 0 && (D.bitrateBps = q * 8e3 / W);
|
|
908
908
|
}
|
|
909
|
-
if (
|
|
909
|
+
if (p === "video") {
|
|
910
910
|
const k = { ...D, display: h.display ?? "primary" };
|
|
911
911
|
if (D.intervalMs !== void 0) {
|
|
912
912
|
const F = ge(a.framesDecoded, I?.framesDecoded);
|
|
@@ -914,20 +914,20 @@ class On {
|
|
|
914
914
|
}
|
|
915
915
|
f.video.push(k);
|
|
916
916
|
} else f.audio.push(D);
|
|
917
|
-
f.timestamp = Math.max(f.timestamp, a.timestamp),
|
|
917
|
+
f.timestamp = Math.max(f.timestamp, a.timestamp), d.set(
|
|
918
918
|
a.id,
|
|
919
919
|
I && a.timestamp <= I.timestamp ? K : { stats: a, trackId: h.trackId }
|
|
920
920
|
);
|
|
921
921
|
const V = a.transportId ? e.get(a.transportId) : void 0, P = V?.selectedCandidatePairId ? e.get(V.selectedCandidatePairId) : void 0;
|
|
922
922
|
P?.state === "succeeded" && Re(P.currentRoundTripTime) && P.currentRoundTripTime >= 0 && (f.rttMs = P.currentRoundTripTime * 1e3);
|
|
923
|
-
}), this.previous =
|
|
923
|
+
}), this.previous = d, f.video.length || f.audio.length ? f : null;
|
|
924
924
|
}
|
|
925
925
|
}
|
|
926
926
|
const ot = /* @__PURE__ */ new WeakSet();
|
|
927
927
|
function Dn(t, e, n) {
|
|
928
|
-
const { peer:
|
|
929
|
-
let a,
|
|
930
|
-
const W = () => !
|
|
928
|
+
const { peer: c, displays: f } = t, d = new On();
|
|
929
|
+
let a, p = !1, O = !1, h = !1, K = 0, w = !1, I = !1;
|
|
930
|
+
const W = () => !p && !document.hidden && c.connectionState === "connected", D = (F) => {
|
|
931
931
|
if (!(!F && !w)) {
|
|
932
932
|
w = F !== null;
|
|
933
933
|
try {
|
|
@@ -937,21 +937,21 @@ function Dn(t, e, n) {
|
|
|
937
937
|
}
|
|
938
938
|
}
|
|
939
939
|
}, V = () => {
|
|
940
|
-
O = !1, K++, clearTimeout(a),
|
|
940
|
+
O = !1, K++, clearTimeout(a), d.reset(), D(null);
|
|
941
941
|
}, P = async () => {
|
|
942
942
|
if (h || !W()) return;
|
|
943
|
-
if (ot.has(
|
|
943
|
+
if (ot.has(c)) {
|
|
944
944
|
a = setTimeout(() => {
|
|
945
945
|
P();
|
|
946
946
|
}, 2e3);
|
|
947
947
|
return;
|
|
948
948
|
}
|
|
949
|
-
h = !0, ot.add(
|
|
949
|
+
h = !0, ot.add(c);
|
|
950
950
|
const F = K;
|
|
951
951
|
try {
|
|
952
|
-
const q = await
|
|
952
|
+
const q = await c.getStats();
|
|
953
953
|
if (F !== K || !W()) return;
|
|
954
|
-
const oe =
|
|
954
|
+
const oe = c.getTransceivers().filter(
|
|
955
955
|
(Y) => (Y.currentDirection === "recvonly" || Y.currentDirection === "sendrecv") && Y.receiver.track.readyState !== "ended"
|
|
956
956
|
).map((Y) => ({
|
|
957
957
|
trackId: Y.receiver.track.id,
|
|
@@ -959,12 +959,12 @@ function Dn(t, e, n) {
|
|
|
959
959
|
mid: Y.mid,
|
|
960
960
|
display: f.get(Y.receiver)
|
|
961
961
|
}));
|
|
962
|
-
D(
|
|
962
|
+
D(d.read(q, oe, n())), I = !1;
|
|
963
963
|
} catch (q) {
|
|
964
964
|
if (F !== K || !W()) return;
|
|
965
|
-
I || console.warn("[RemoteControl] could not read playback stats:", q), I = !0,
|
|
965
|
+
I || console.warn("[RemoteControl] could not read playback stats:", q), I = !0, d.reset(), D(null);
|
|
966
966
|
} finally {
|
|
967
|
-
h = !1, ot.delete(
|
|
967
|
+
h = !1, ot.delete(c), O && W() && (a = setTimeout(
|
|
968
968
|
() => {
|
|
969
969
|
P();
|
|
970
970
|
},
|
|
@@ -978,8 +978,8 @@ function Dn(t, e, n) {
|
|
|
978
978
|
}
|
|
979
979
|
O || (O = !0, P());
|
|
980
980
|
};
|
|
981
|
-
return document.addEventListener("visibilitychange", k),
|
|
982
|
-
|
|
981
|
+
return document.addEventListener("visibilitychange", k), c.addEventListener("connectionstatechange", k), k(), () => {
|
|
982
|
+
p = !0, document.removeEventListener("visibilitychange", k), c.removeEventListener("connectionstatechange", k), V();
|
|
983
983
|
};
|
|
984
984
|
}
|
|
985
985
|
function _n(t, e) {
|
|
@@ -988,32 +988,32 @@ function _n(t, e) {
|
|
|
988
988
|
negotiated: !0,
|
|
989
989
|
id: 2
|
|
990
990
|
});
|
|
991
|
-
let
|
|
991
|
+
let c = !1, f = !1, d = 0;
|
|
992
992
|
return n.onmessage = (a) => {
|
|
993
993
|
if (f) return;
|
|
994
|
-
let
|
|
994
|
+
let p;
|
|
995
995
|
try {
|
|
996
|
-
|
|
996
|
+
p = JSON.parse(a.data);
|
|
997
997
|
} catch (O) {
|
|
998
998
|
console.warn("Invalid latency trace message", O);
|
|
999
999
|
return;
|
|
1000
1000
|
}
|
|
1001
|
-
|
|
1001
|
+
p && typeof p == "object" && !Array.isArray(p) && e(p);
|
|
1002
1002
|
}, n.onclose = () => {
|
|
1003
|
-
f = !0,
|
|
1003
|
+
f = !0, c = !1;
|
|
1004
1004
|
}, {
|
|
1005
1005
|
accept(a) {
|
|
1006
|
-
|
|
1006
|
+
c = !f && a === 1;
|
|
1007
1007
|
},
|
|
1008
1008
|
wrap(a) {
|
|
1009
|
-
if (!
|
|
1010
|
-
const
|
|
1011
|
-
if (
|
|
1009
|
+
if (!c || a.byteLength !== 32) return a;
|
|
1010
|
+
const p = new DataView(a);
|
|
1011
|
+
if (p.getUint8(0) !== 2 || p.getUint8(1) > 2) return a;
|
|
1012
1012
|
const O = new ArrayBuffer(38), h = new DataView(O);
|
|
1013
|
-
return h.setUint8(0, 240), h.setUint8(1, 1), h.setUint32(2, ++
|
|
1013
|
+
return h.setUint8(0, 240), h.setUint8(1, 1), h.setUint32(2, ++d, !0), new Uint8Array(O, 6).set(new Uint8Array(a)), O;
|
|
1014
1014
|
},
|
|
1015
1015
|
close() {
|
|
1016
|
-
f = !0,
|
|
1016
|
+
f = !0, c = !1, n.onmessage = null, n.onclose = null, n.close();
|
|
1017
1017
|
}
|
|
1018
1018
|
};
|
|
1019
1019
|
}
|
|
@@ -1037,10 +1037,10 @@ class gn {
|
|
|
1037
1037
|
return this.append(this.generation, e);
|
|
1038
1038
|
}
|
|
1039
1039
|
append(e, n) {
|
|
1040
|
-
const
|
|
1040
|
+
const c = {
|
|
1041
1041
|
generation: e,
|
|
1042
1042
|
isCurrent: () => e === this.generation
|
|
1043
|
-
}, f = this.tail.then(() => n(
|
|
1043
|
+
}, f = this.tail.then(() => n(c));
|
|
1044
1044
|
return this.tail = f.catch(() => {
|
|
1045
1045
|
}), f;
|
|
1046
1046
|
}
|
|
@@ -1090,8 +1090,8 @@ const ce = (...t) => {
|
|
|
1090
1090
|
if (e)
|
|
1091
1091
|
try {
|
|
1092
1092
|
e(...n);
|
|
1093
|
-
} catch (
|
|
1094
|
-
console.error(`[RemoteControl] customer callback "${t}" threw:`,
|
|
1093
|
+
} catch (c) {
|
|
1094
|
+
console.error(`[RemoteControl] customer callback "${t}" threw:`, c);
|
|
1095
1095
|
}
|
|
1096
1096
|
}, An = (t) => t.includes("/android_") ? "android" : "ios", vt = (t, e) => {
|
|
1097
1097
|
const n = new URL(t);
|
|
@@ -1105,7 +1105,9 @@ function Kt() {
|
|
|
1105
1105
|
}
|
|
1106
1106
|
function jn(t) {
|
|
1107
1107
|
let e = { ...t };
|
|
1108
|
-
const { url: n,
|
|
1108
|
+
const { url: n, deviceModel: c } = e;
|
|
1109
|
+
let f = e.token;
|
|
1110
|
+
const d = e.watchOnly ?? !1, a = e.sessionId ?? Kt(), p = e.platform ?? An(n ?? "");
|
|
1109
1111
|
let O = {
|
|
1110
1112
|
connection: "idle",
|
|
1111
1113
|
videoReady: !1,
|
|
@@ -1125,8 +1127,8 @@ function jn(t) {
|
|
|
1125
1127
|
) : void 0;
|
|
1126
1128
|
}, F = /* @__PURE__ */ new Map(), q = /* @__PURE__ */ new Set(), oe = /* @__PURE__ */ new Set(), Y = /* @__PURE__ */ new Map();
|
|
1127
1129
|
let Te = !1;
|
|
1128
|
-
const Ie = /* @__PURE__ */ new Map(), st = (r, u,
|
|
1129
|
-
u.stop?.(), u.stop = Cn(r,
|
|
1130
|
+
const Ie = /* @__PURE__ */ new Map(), st = (r, u, s) => {
|
|
1131
|
+
u.stop?.(), u.stop = Cn(r, s, (l) => y("Video playback fallback:", l));
|
|
1130
1132
|
}, wt = () => {
|
|
1131
1133
|
Ie.clear();
|
|
1132
1134
|
for (const [r, u] of F)
|
|
@@ -1134,7 +1136,7 @@ function jn(t) {
|
|
|
1134
1136
|
};
|
|
1135
1137
|
let fe = !1, ye = !1, ke = 0, g = null, b = null, B = null, Ue = null, Ee, Se, ve, Pe, he, le = 0, Le = 0, te = !1, de = null, Q = null, ue;
|
|
1136
1138
|
const Xe = new gn();
|
|
1137
|
-
let Ke = null, Fe = null, Qe = !
|
|
1139
|
+
let Ke = null, Fe = null, Qe = !d && (e.microphoneEnabled ?? !1), ze = !1, Ae = null, ee = null, Be = 0, ct = Promise.resolve(), pe = null, Me = !1, ne = /* @__PURE__ */ new Map(), Z = /* @__PURE__ */ new Map(), ae = /* @__PURE__ */ new Map(), re = /* @__PURE__ */ new Map(), $ = null, we = null, lt = 0;
|
|
1138
1140
|
const xe = (r) => {
|
|
1139
1141
|
if (r === null && we === null) return;
|
|
1140
1142
|
we = r;
|
|
@@ -1143,25 +1145,25 @@ function jn(t) {
|
|
|
1143
1145
|
u === lt && L("onAxSnapshotChange", e.onAxSnapshotChange, r);
|
|
1144
1146
|
});
|
|
1145
1147
|
};
|
|
1146
|
-
let
|
|
1147
|
-
const Yt = (r, u) => new Promise((
|
|
1148
|
-
if (
|
|
1149
|
-
|
|
1148
|
+
let me = null, Ce = /* @__PURE__ */ new Map();
|
|
1149
|
+
const Yt = (r, u) => new Promise((s, l) => {
|
|
1150
|
+
if (d) {
|
|
1151
|
+
l(new Error("Device is watch-only"));
|
|
1150
1152
|
return;
|
|
1151
1153
|
}
|
|
1152
1154
|
const S = g;
|
|
1153
1155
|
if (!S || S.readyState !== WebSocket.OPEN) {
|
|
1154
|
-
|
|
1156
|
+
l(new Error("Simulator disconnected"));
|
|
1155
1157
|
return;
|
|
1156
1158
|
}
|
|
1157
|
-
const
|
|
1158
|
-
Ce.delete(
|
|
1159
|
+
const m = Kt(), C = setTimeout(() => {
|
|
1160
|
+
Ce.delete(m), l(new Error("Device control timed out"));
|
|
1159
1161
|
}, 5e3);
|
|
1160
|
-
Ce.set(
|
|
1162
|
+
Ce.set(m, { resolve: s, reject: l, timer: C }), S.send(JSON.stringify({ type: r, id: m, ...u }));
|
|
1161
1163
|
}), Oe = (r) => {
|
|
1162
|
-
|
|
1164
|
+
me !== r && (me = r, h({ connection: r }), L("onConnectionStateChange", e.onConnectionStateChange, r));
|
|
1163
1165
|
}, se = (r) => {
|
|
1164
|
-
|
|
1166
|
+
d || !B || B.readyState !== "open" || (B.send(Ue?.wrap(r) ?? r), $?.bumpActivity());
|
|
1165
1167
|
}, bt = () => {
|
|
1166
1168
|
g && g.readyState === WebSocket.OPEN && g.send(
|
|
1167
1169
|
JSON.stringify({
|
|
@@ -1187,59 +1189,59 @@ function jn(t) {
|
|
|
1187
1189
|
for (const u of r.getTracks())
|
|
1188
1190
|
try {
|
|
1189
1191
|
u.stop();
|
|
1190
|
-
} catch (
|
|
1191
|
-
y("track.stop() failed:",
|
|
1192
|
+
} catch (s) {
|
|
1193
|
+
y("track.stop() failed:", s);
|
|
1192
1194
|
}
|
|
1193
1195
|
}, Rt = () => {
|
|
1194
1196
|
const r = Q;
|
|
1195
1197
|
r && (Q = null, H(r));
|
|
1196
1198
|
}, ut = (r) => {
|
|
1197
|
-
const u = ct.then(r).catch((
|
|
1198
|
-
y("microphone operation failed:",
|
|
1199
|
+
const u = ct.then(r).catch((s) => {
|
|
1200
|
+
y("microphone operation failed:", s);
|
|
1199
1201
|
});
|
|
1200
1202
|
return ct = u, u;
|
|
1201
1203
|
}, Ze = () => Qe || ze, ft = (r) => {
|
|
1202
1204
|
const u = `ui-mic-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
|
|
1203
|
-
|
|
1205
|
+
pe = u, r.send(JSON.stringify({ type: "microphoneStart", id: u }));
|
|
1204
1206
|
}, et = () => ut(() => It()), It = async () => {
|
|
1205
|
-
const r = Be, u = () => r === Be && Ze(),
|
|
1207
|
+
const r = Be, u = () => r === Be && Ze(), s = (E) => {
|
|
1206
1208
|
L("onMicrophoneStateChange", e.onMicrophoneStateChange, {
|
|
1207
1209
|
active: !1,
|
|
1208
1210
|
error: E
|
|
1209
1211
|
});
|
|
1210
1212
|
};
|
|
1211
1213
|
if (!u()) return;
|
|
1212
|
-
const
|
|
1213
|
-
if (!
|
|
1214
|
+
const l = g, S = Ae;
|
|
1215
|
+
if (!l || l.readyState !== WebSocket.OPEN || !S || ee) return;
|
|
1214
1216
|
if (!navigator.mediaDevices || typeof navigator.mediaDevices.getUserMedia != "function") {
|
|
1215
1217
|
console.warn(
|
|
1216
1218
|
"[RemoteControl] navigator.mediaDevices.getUserMedia unavailable. getUserMedia requires a secure context (https or http://localhost)."
|
|
1217
|
-
),
|
|
1219
|
+
), s("Microphone capture requires a secure context (https)");
|
|
1218
1220
|
return;
|
|
1219
1221
|
}
|
|
1220
|
-
let
|
|
1222
|
+
let m = null;
|
|
1221
1223
|
try {
|
|
1222
|
-
|
|
1224
|
+
m = await navigator.mediaDevices.getUserMedia({ audio: !0, video: !1 });
|
|
1223
1225
|
} catch (E) {
|
|
1224
1226
|
console.warn("[RemoteControl] microphone getUserMedia denied/failed:", E);
|
|
1225
1227
|
}
|
|
1226
1228
|
if (!u()) {
|
|
1227
|
-
|
|
1229
|
+
m && H(m);
|
|
1228
1230
|
return;
|
|
1229
1231
|
}
|
|
1230
|
-
if (!
|
|
1231
|
-
|
|
1232
|
+
if (!m) {
|
|
1233
|
+
s("Microphone permission denied or no device available");
|
|
1232
1234
|
return;
|
|
1233
1235
|
}
|
|
1234
|
-
const C =
|
|
1236
|
+
const C = m.getAudioTracks()[0] ?? null;
|
|
1235
1237
|
if (!C) {
|
|
1236
|
-
H(
|
|
1238
|
+
H(m), s("Captured stream has no audio track");
|
|
1237
1239
|
return;
|
|
1238
1240
|
}
|
|
1239
1241
|
try {
|
|
1240
1242
|
await S.replaceTrack(C);
|
|
1241
1243
|
} catch (E) {
|
|
1242
|
-
y("replaceTrack(audioTrack) failed:", E), H(
|
|
1244
|
+
y("replaceTrack(audioTrack) failed:", E), H(m), s("Failed to attach the microphone track to the connection");
|
|
1243
1245
|
return;
|
|
1244
1246
|
}
|
|
1245
1247
|
if (!u()) {
|
|
@@ -1248,41 +1250,41 @@ function jn(t) {
|
|
|
1248
1250
|
} catch (E) {
|
|
1249
1251
|
y("replaceTrack(null) on stale mic attach failed:", E);
|
|
1250
1252
|
}
|
|
1251
|
-
H(
|
|
1253
|
+
H(m);
|
|
1252
1254
|
return;
|
|
1253
1255
|
}
|
|
1254
|
-
ee =
|
|
1255
|
-
ee ===
|
|
1256
|
-
}, ft(
|
|
1256
|
+
ee = m, C.onended = () => {
|
|
1257
|
+
ee === m && $e("microphone capture ended by the browser");
|
|
1258
|
+
}, ft(l), L("onMicrophoneStateChange", e.onMicrophoneStateChange, {
|
|
1257
1259
|
active: !0,
|
|
1258
1260
|
label: C.label || void 0
|
|
1259
1261
|
});
|
|
1260
|
-
}, $e = (r) => (++Be,
|
|
1261
|
-
const u = Ae,
|
|
1262
|
-
if (ee = null, u &&
|
|
1262
|
+
}, $e = (r) => (++Be, pe = null, ut(async () => {
|
|
1263
|
+
const u = Ae, s = ee;
|
|
1264
|
+
if (ee = null, u && s)
|
|
1263
1265
|
try {
|
|
1264
1266
|
await u.replaceTrack(null);
|
|
1265
1267
|
} catch (S) {
|
|
1266
1268
|
y("replaceTrack(null) on mic detach failed:", S);
|
|
1267
1269
|
}
|
|
1268
|
-
|
|
1269
|
-
const
|
|
1270
|
-
if (
|
|
1270
|
+
s && H(s);
|
|
1271
|
+
const l = g;
|
|
1272
|
+
if (s && l && l.readyState === WebSocket.OPEN) {
|
|
1271
1273
|
const S = `ui-mic-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
|
|
1272
|
-
|
|
1274
|
+
l.send(JSON.stringify({ type: "microphoneStop", id: S }));
|
|
1273
1275
|
}
|
|
1274
|
-
(
|
|
1276
|
+
(s || r) && L("onMicrophoneStateChange", e.onMicrophoneStateChange, {
|
|
1275
1277
|
active: !1,
|
|
1276
1278
|
...r !== void 0 && { error: r }
|
|
1277
1279
|
});
|
|
1278
1280
|
})), Et = (r, u) => {
|
|
1279
|
-
let
|
|
1281
|
+
let s;
|
|
1280
1282
|
try {
|
|
1281
|
-
|
|
1282
|
-
`[RemoteControl] camera capture: ${
|
|
1283
|
+
s = Kn(u), console.info(
|
|
1284
|
+
`[RemoteControl] camera capture: ${s.camera?.width}x${s.camera?.height} @ ${s.camera?.frameRate ?? "?"}fps` + (s.camera?.label ? ` — ${s.camera.label}` : "")
|
|
1283
1285
|
);
|
|
1284
|
-
} catch (
|
|
1285
|
-
y("getSettings() on outbound camera track failed:",
|
|
1286
|
+
} catch (l) {
|
|
1287
|
+
y("getSettings() on outbound camera track failed:", l), s = {
|
|
1286
1288
|
type: "cameraResult",
|
|
1287
1289
|
granted: !0,
|
|
1288
1290
|
camera: {
|
|
@@ -1290,55 +1292,55 @@ function jn(t) {
|
|
|
1290
1292
|
}
|
|
1291
1293
|
};
|
|
1292
1294
|
}
|
|
1293
|
-
r.send(JSON.stringify(
|
|
1295
|
+
r.send(JSON.stringify(s)), L("onCameraDemandChange", e.onCameraDemandChange, !0, !0, s.camera);
|
|
1294
1296
|
}, kt = (r) => {
|
|
1295
1297
|
if (!r) return;
|
|
1296
|
-
const u = r.indexOf("/"),
|
|
1297
|
-
return
|
|
1298
|
+
const u = r.indexOf("/"), l = (u >= 0 ? r.slice(u + 1) : r).toUpperCase();
|
|
1299
|
+
return l === "HEVC" ? "H265" : l;
|
|
1298
1300
|
}, Ut = async () => {
|
|
1299
1301
|
const r = de, u = e.onCameraStats;
|
|
1300
1302
|
if (!r || !u) return;
|
|
1301
|
-
let
|
|
1303
|
+
let s;
|
|
1302
1304
|
try {
|
|
1303
|
-
|
|
1305
|
+
s = await r.getStats();
|
|
1304
1306
|
} catch {
|
|
1305
1307
|
return;
|
|
1306
1308
|
}
|
|
1307
|
-
let
|
|
1308
|
-
if (
|
|
1309
|
-
N.type === "outbound-rtp" && N.kind === "video" ?
|
|
1310
|
-
}),
|
|
1311
|
-
const N =
|
|
1309
|
+
let l, S, m;
|
|
1310
|
+
if (s.forEach((N) => {
|
|
1311
|
+
N.type === "outbound-rtp" && N.kind === "video" ? l = N : N.type === "remote-inbound-rtp" && N.kind === "video" && (m = N);
|
|
1312
|
+
}), l?.codecId) {
|
|
1313
|
+
const N = s.get(l.codecId);
|
|
1312
1314
|
N && (S = N.mimeType);
|
|
1313
1315
|
}
|
|
1314
|
-
if (!
|
|
1315
|
-
const C =
|
|
1316
|
+
if (!l) return;
|
|
1317
|
+
const C = l.timestamp ?? Date.now(), E = Fe;
|
|
1316
1318
|
let J, U, j;
|
|
1317
1319
|
if (E && C > E.timestamp) {
|
|
1318
1320
|
const N = (C - E.timestamp) / 1e3;
|
|
1319
|
-
if (typeof
|
|
1320
|
-
const v =
|
|
1321
|
+
if (typeof l.framesEncoded == "number" && typeof E.framesEncoded == "number" && (J = Math.max(0, (l.framesEncoded - E.framesEncoded) / N)), typeof l.bytesSent == "number" && typeof E.bytesSent == "number" && (U = Math.max(0, (l.bytesSent - E.bytesSent) * 8 / N)), typeof l.packetsSent == "number" && typeof E.packetsSent == "number" && m && typeof m.packetsLost == "number" && typeof E.packetsLost == "number") {
|
|
1322
|
+
const v = l.packetsSent - E.packetsSent, He = m.packetsLost - E.packetsLost;
|
|
1321
1323
|
v > 0 && (j = Math.max(0, Math.min(100, He / v * 100)));
|
|
1322
1324
|
}
|
|
1323
1325
|
}
|
|
1324
1326
|
Fe = {
|
|
1325
1327
|
timestamp: C,
|
|
1326
|
-
framesEncoded:
|
|
1327
|
-
bytesSent:
|
|
1328
|
-
packetsSent:
|
|
1329
|
-
packetsLost:
|
|
1328
|
+
framesEncoded: l.framesEncoded,
|
|
1329
|
+
bytesSent: l.bytesSent,
|
|
1330
|
+
packetsSent: l.packetsSent,
|
|
1331
|
+
packetsLost: m?.packetsLost
|
|
1330
1332
|
};
|
|
1331
1333
|
const M = {
|
|
1332
1334
|
codec: kt(S),
|
|
1333
|
-
encoderImplementation:
|
|
1334
|
-
hardwareAccelerated: typeof
|
|
1335
|
+
encoderImplementation: l.encoderImplementation,
|
|
1336
|
+
hardwareAccelerated: typeof l.powerEfficientEncoder == "boolean" ? l.powerEfficientEncoder : void 0,
|
|
1335
1337
|
framesPerSecond: J,
|
|
1336
|
-
framesEncoded:
|
|
1338
|
+
framesEncoded: l.framesEncoded,
|
|
1337
1339
|
bitrateBps: U,
|
|
1338
|
-
width:
|
|
1339
|
-
height:
|
|
1340
|
-
qualityLimitationReason:
|
|
1341
|
-
rttMs: typeof
|
|
1340
|
+
width: l.frameWidth,
|
|
1341
|
+
height: l.frameHeight,
|
|
1342
|
+
qualityLimitationReason: l.qualityLimitationReason,
|
|
1343
|
+
rttMs: typeof m?.roundTripTime == "number" ? m.roundTripTime * 1e3 : void 0,
|
|
1342
1344
|
packetsLostPct: j
|
|
1343
1345
|
};
|
|
1344
1346
|
L("onCameraStats", e.onCameraStats, M);
|
|
@@ -1348,17 +1350,17 @@ function jn(t) {
|
|
|
1348
1350
|
}, 1e3));
|
|
1349
1351
|
}, Ve = () => {
|
|
1350
1352
|
Ke !== null && (clearInterval(Ke), Ke = null), Fe = null, L("onCameraStats", e.onCameraStats, null);
|
|
1351
|
-
}, Pt = (r, u,
|
|
1352
|
-
const
|
|
1353
|
-
if (!
|
|
1353
|
+
}, Pt = (r, u, s, l) => Xe.enqueue(async ({ isCurrent: S }) => {
|
|
1354
|
+
const m = () => S() && l() && g === u && de === s;
|
|
1355
|
+
if (!m()) return;
|
|
1354
1356
|
if (!r.active) {
|
|
1355
1357
|
const M = Q;
|
|
1356
1358
|
try {
|
|
1357
|
-
await
|
|
1359
|
+
await s.replaceTrack(null);
|
|
1358
1360
|
} catch (N) {
|
|
1359
1361
|
y("replaceTrack(null) on camera detach failed:", N);
|
|
1360
1362
|
}
|
|
1361
|
-
if (Q === M && (Q = null, ue = void 0, M && H(M)), Ve(), !
|
|
1363
|
+
if (Q === M && (Q = null, ue = void 0, M && H(M)), Ve(), !m()) return;
|
|
1362
1364
|
L("onCameraDemandChange", e.onCameraDemandChange, !1);
|
|
1363
1365
|
return;
|
|
1364
1366
|
}
|
|
@@ -1370,16 +1372,16 @@ function jn(t) {
|
|
|
1370
1372
|
}
|
|
1371
1373
|
if (C) {
|
|
1372
1374
|
try {
|
|
1373
|
-
await
|
|
1375
|
+
await s.replaceTrack(null);
|
|
1374
1376
|
} catch (M) {
|
|
1375
1377
|
y("replaceTrack(null) before camera switch failed:", M);
|
|
1376
1378
|
}
|
|
1377
|
-
if (Q === C && (Q = null, ue = void 0, H(C)), Ve(), !
|
|
1379
|
+
if (Q === C && (Q = null, ue = void 0, H(C)), Ve(), !m()) return;
|
|
1378
1380
|
}
|
|
1379
1381
|
if (!navigator.mediaDevices || typeof navigator.mediaDevices.getUserMedia != "function") {
|
|
1380
1382
|
if (console.warn(
|
|
1381
1383
|
"[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."
|
|
1382
|
-
), !
|
|
1384
|
+
), !m()) return;
|
|
1383
1385
|
u.send(JSON.stringify({ type: "cameraResult", granted: !1 })), L("onCameraDemandChange", e.onCameraDemandChange, !0, !1);
|
|
1384
1386
|
return;
|
|
1385
1387
|
}
|
|
@@ -1392,7 +1394,7 @@ function jn(t) {
|
|
|
1392
1394
|
} catch (M) {
|
|
1393
1395
|
console.warn("[RemoteControl] getUserMedia denied/failed:", M);
|
|
1394
1396
|
}
|
|
1395
|
-
if (!
|
|
1397
|
+
if (!m()) {
|
|
1396
1398
|
U && H(U);
|
|
1397
1399
|
return;
|
|
1398
1400
|
}
|
|
@@ -1402,7 +1404,7 @@ function jn(t) {
|
|
|
1402
1404
|
}
|
|
1403
1405
|
const j = U.getVideoTracks()[0] ?? null;
|
|
1404
1406
|
if (!j) {
|
|
1405
|
-
if (H(U), !
|
|
1407
|
+
if (H(U), !m()) return;
|
|
1406
1408
|
u.send(JSON.stringify({ type: "cameraResult", granted: !1 })), L("onCameraDemandChange", e.onCameraDemandChange, !0, !1);
|
|
1407
1409
|
return;
|
|
1408
1410
|
}
|
|
@@ -1411,15 +1413,15 @@ function jn(t) {
|
|
|
1411
1413
|
} catch {
|
|
1412
1414
|
}
|
|
1413
1415
|
try {
|
|
1414
|
-
await
|
|
1416
|
+
await s.replaceTrack(j);
|
|
1415
1417
|
} catch (M) {
|
|
1416
|
-
if (y("replaceTrack(videoTrack) failed:", M), H(U), !
|
|
1418
|
+
if (y("replaceTrack(videoTrack) failed:", M), H(U), !m()) return;
|
|
1417
1419
|
u.send(JSON.stringify({ type: "cameraResult", granted: !1 })), L("onCameraDemandChange", e.onCameraDemandChange, !0, !1);
|
|
1418
1420
|
return;
|
|
1419
1421
|
}
|
|
1420
|
-
if (!
|
|
1422
|
+
if (!m()) {
|
|
1421
1423
|
try {
|
|
1422
|
-
await
|
|
1424
|
+
await s.replaceTrack(null);
|
|
1423
1425
|
} catch (M) {
|
|
1424
1426
|
y("replaceTrack(null) for stale camera attach failed:", M);
|
|
1425
1427
|
}
|
|
@@ -1427,14 +1429,14 @@ function jn(t) {
|
|
|
1427
1429
|
return;
|
|
1428
1430
|
}
|
|
1429
1431
|
try {
|
|
1430
|
-
const M =
|
|
1431
|
-
(!M.encodings || M.encodings.length === 0) && (M.encodings = [{}]), M.encodings[0].maxBitrate = 8e6, M.encodings[0].maxFramerate = 30, M.degradationPreference = "maintain-framerate", await
|
|
1432
|
+
const M = s.getParameters();
|
|
1433
|
+
(!M.encodings || M.encodings.length === 0) && (M.encodings = [{}]), M.encodings[0].maxBitrate = 8e6, M.encodings[0].maxFramerate = 30, M.degradationPreference = "maintain-framerate", await s.setParameters(M);
|
|
1432
1434
|
} catch (M) {
|
|
1433
1435
|
y("setParameters on outbound camera failed:", M);
|
|
1434
1436
|
}
|
|
1435
|
-
if (!
|
|
1437
|
+
if (!m()) {
|
|
1436
1438
|
try {
|
|
1437
|
-
await
|
|
1439
|
+
await s.replaceTrack(null);
|
|
1438
1440
|
} catch (M) {
|
|
1439
1441
|
y("replaceTrack(null) for stale camera finalize failed:", M);
|
|
1440
1442
|
}
|
|
@@ -1443,16 +1445,16 @@ function jn(t) {
|
|
|
1443
1445
|
}
|
|
1444
1446
|
Q = U, ue = r, j.onended = () => {
|
|
1445
1447
|
Q === U && Xe.enqueueCurrent(async ({ isCurrent: M }) => {
|
|
1446
|
-
if (!(!M() || Q !== U || !
|
|
1448
|
+
if (!(!M() || Q !== U || !l() || g !== u || de !== s)) {
|
|
1447
1449
|
try {
|
|
1448
|
-
await
|
|
1450
|
+
await s.replaceTrack(null);
|
|
1449
1451
|
} catch (N) {
|
|
1450
1452
|
y("replaceTrack(null) after camera ended failed:", N);
|
|
1451
1453
|
}
|
|
1452
|
-
!M() || Q !== U || !
|
|
1454
|
+
!M() || Q !== U || !l() || g !== u || de !== s || (Q = null, ue = void 0, H(U), Ve(), u.send(JSON.stringify({ type: "cameraResult", granted: !1 })), L("onCameraDemandChange", e.onCameraDemandChange, !0, !1));
|
|
1453
1455
|
}
|
|
1454
1456
|
}).catch((M) => y("camera ended cleanup failed:", M));
|
|
1455
|
-
},
|
|
1457
|
+
}, m() && (Et(u, j), ht());
|
|
1456
1458
|
}), De = () => {
|
|
1457
1459
|
for (const r of oe) r();
|
|
1458
1460
|
oe.clear();
|
|
@@ -1465,10 +1467,10 @@ function jn(t) {
|
|
|
1465
1467
|
Z.clear(), ne.clear(), re.clear(), ae.clear(), P?.(), P = void 0, wt(), V = null;
|
|
1466
1468
|
for (const r of Ce.values())
|
|
1467
1469
|
clearTimeout(r.timer), r.reject(new Error("Simulator disconnected"));
|
|
1468
|
-
Ce.clear(), w(null), h({ controlReady: !1, videoReady: !1 }), qe(), Ne(), be(), $ && ($.stop(), $ = null), we !== null && xe(null), Xe.invalidate(), Ve(), Rt(), ue = void 0, de = null, ++Be, ze = !1,
|
|
1470
|
+
Ce.clear(), w(null), h({ controlReady: !1, videoReady: !1 }), qe(), Ne(), be(), $ && ($.stop(), $ = null), we !== null && xe(null), Xe.invalidate(), Ve(), Rt(), ue = void 0, de = null, ++Be, ze = !1, pe = null, ee && (H(ee), ee = null, L("onMicrophoneStateChange", e.onMicrophoneStateChange, {
|
|
1469
1471
|
active: !1
|
|
1470
1472
|
})), Ae = null, g && (g.onopen = null, g.onmessage = null, g.onerror = null, g.onclose = null, g.close(), g = null), Ue?.close(), Ue = null, b && (b.onconnectionstatechange = null, b.oniceconnectionstatechange = null, b.ontrack = null, b.onicecandidate = null, b.close(), b = null), B && (B.onopen = null, B.onclose = null, B.onerror = null, B.close(), B = null);
|
|
1471
|
-
},
|
|
1473
|
+
}, pt = () => {
|
|
1472
1474
|
document.hidden ? Ye() : dt();
|
|
1473
1475
|
}, Lt = async () => {
|
|
1474
1476
|
if (e.transport) return e.transport.isTerminated?.() ?? !1;
|
|
@@ -1476,18 +1478,18 @@ function jn(t) {
|
|
|
1476
1478
|
return !1;
|
|
1477
1479
|
let r;
|
|
1478
1480
|
try {
|
|
1479
|
-
const
|
|
1480
|
-
|
|
1481
|
+
const l = new URL(n);
|
|
1482
|
+
l.protocol = l.protocol === "wss:" ? "https:" : l.protocol === "ws:" ? "http:" : l.protocol, r = vt(l.toString(), f);
|
|
1481
1483
|
} catch {
|
|
1482
1484
|
return !1;
|
|
1483
1485
|
}
|
|
1484
|
-
const u = new AbortController(),
|
|
1486
|
+
const u = new AbortController(), s = window.setTimeout(() => u.abort(), bn);
|
|
1485
1487
|
try {
|
|
1486
1488
|
return (await fetch(r, { method: "GET", cache: "no-store", signal: u.signal })).status === 404;
|
|
1487
1489
|
} catch {
|
|
1488
1490
|
return !1;
|
|
1489
1491
|
} finally {
|
|
1490
|
-
window.clearTimeout(
|
|
1492
|
+
window.clearTimeout(s);
|
|
1491
1493
|
}
|
|
1492
1494
|
}, Ft = () => {
|
|
1493
1495
|
fe || (fe = !0, le += 1, We(), qe(), Ne(), De(), D("Instance terminated"), Ye(), Oe("terminated"), L("onTerminated", e.onTerminated));
|
|
@@ -1509,25 +1511,25 @@ function jn(t) {
|
|
|
1509
1511
|
D(`Reconnecting after established session dropped: ${r}`), te = !1, Le = -1;
|
|
1510
1512
|
}
|
|
1511
1513
|
We();
|
|
1512
|
-
const
|
|
1513
|
-
if (
|
|
1514
|
+
const s = Le + 1;
|
|
1515
|
+
if (s >= at) {
|
|
1514
1516
|
D(`Connection failed after ${at} attempts: ${r}`), Ye(), Oe("failed"), De();
|
|
1515
1517
|
return;
|
|
1516
1518
|
}
|
|
1517
|
-
D(`Retrying connection (${
|
|
1518
|
-
Se = void 0, u === le &&
|
|
1519
|
+
D(`Retrying connection (${s + 1}/${at})`), Oe("reconnecting"), De(), Se = window.setTimeout(() => {
|
|
1520
|
+
Se = void 0, u === le && mt(s);
|
|
1519
1521
|
}, Mn);
|
|
1520
|
-
},
|
|
1521
|
-
const { openUrl: u, axPollIntervalMs:
|
|
1522
|
+
}, mt = async (r = 0) => {
|
|
1523
|
+
const { openUrl: u, axPollIntervalMs: s, axMaxBackoffMs: l, androidElementTreeOptions: S } = e;
|
|
1522
1524
|
if (fe) return;
|
|
1523
|
-
const
|
|
1524
|
-
le =
|
|
1525
|
-
const C = () =>
|
|
1525
|
+
const m = le + 1;
|
|
1526
|
+
le = m, Le = r, te = !1, r === 0 && me !== "reconnecting" && Oe("connecting"), We(), qe(), be(), Me = !1, K(!1), De();
|
|
1527
|
+
const C = () => m === le;
|
|
1526
1528
|
ve = window.setTimeout(() => {
|
|
1527
|
-
ve = void 0, !(!C() || te) && _e("Connection did not succeed within 15 seconds",
|
|
1529
|
+
ve = void 0, !(!C() || te) && _e("Connection did not succeed within 15 seconds", m);
|
|
1528
1530
|
}, wn);
|
|
1529
1531
|
try {
|
|
1530
|
-
const E = e.transport ? await e.transport.connect() : new WebSocket(vt(n,
|
|
1532
|
+
const E = e.transport ? await e.transport.connect() : new WebSocket(vt(n, f));
|
|
1531
1533
|
if (!C()) {
|
|
1532
1534
|
E.close();
|
|
1533
1535
|
return;
|
|
@@ -1596,13 +1598,13 @@ function jn(t) {
|
|
|
1596
1598
|
} = await J;
|
|
1597
1599
|
if (!C() || g !== E)
|
|
1598
1600
|
return;
|
|
1599
|
-
const N =
|
|
1601
|
+
const N = c === "iphone-duo" || M;
|
|
1600
1602
|
W(N);
|
|
1601
1603
|
const v = new RTCPeerConnection({ ...U, iceTransportPolicy: "relay" });
|
|
1602
1604
|
b = v;
|
|
1603
1605
|
const He = { peer: v, displays: /* @__PURE__ */ new Map() };
|
|
1604
1606
|
V = He, k(), v.addTransceiver("audio", { direction: "recvonly" });
|
|
1605
|
-
const xt = v.addTransceiver("video", { direction: "recvonly" }), Wt = N ? v.addTransceiver("video", { direction: "recvonly" }) : null, _t = !
|
|
1607
|
+
const xt = v.addTransceiver("video", { direction: "recvonly" }), Wt = N ? v.addTransceiver("video", { direction: "recvonly" }) : null, _t = !d && (p === "ios" || j), tt = _t ? v.addTransceiver("video", {
|
|
1606
1608
|
direction: "sendonly"
|
|
1607
1609
|
}) : null;
|
|
1608
1610
|
if (de = tt?.sender ?? null, Ae = (_t ? v.addTransceiver("audio", {
|
|
@@ -1643,16 +1645,16 @@ function jn(t) {
|
|
|
1643
1645
|
id: 1
|
|
1644
1646
|
});
|
|
1645
1647
|
B = ie;
|
|
1646
|
-
const nt = !
|
|
1648
|
+
const nt = !d && !N && e.onTrace ? _n(v, (_) => {
|
|
1647
1649
|
C() && b === v && L("onTrace", e.onTrace, _);
|
|
1648
1650
|
}) : null;
|
|
1649
1651
|
if (Ue = nt, ie.onopen = () => {
|
|
1650
1652
|
if (!C() || B !== ie || g !== E)
|
|
1651
1653
|
return;
|
|
1652
|
-
te = !0, h({ controlReady: !
|
|
1653
|
-
platform:
|
|
1654
|
-
baseIntervalMs:
|
|
1655
|
-
maxBackoffMs:
|
|
1654
|
+
te = !0, h({ controlReady: !d }), qe(), D("Control channel opened"), N && E.send(JSON.stringify({ type: "getFoldState", id: "duo-capabilities" })), $ || ($ = new pn({
|
|
1655
|
+
platform: p,
|
|
1656
|
+
baseIntervalMs: s,
|
|
1657
|
+
maxBackoffMs: l,
|
|
1656
1658
|
androidElementTreeOptions: S,
|
|
1657
1659
|
send: (o) => {
|
|
1658
1660
|
if (!g || g.readyState !== WebSocket.OPEN) return !1;
|
|
@@ -1676,7 +1678,7 @@ function jn(t) {
|
|
|
1676
1678
|
return;
|
|
1677
1679
|
}
|
|
1678
1680
|
_();
|
|
1679
|
-
}, 250), !
|
|
1681
|
+
}, 250), !d && u) {
|
|
1680
1682
|
try {
|
|
1681
1683
|
const o = decodeURIComponent(u);
|
|
1682
1684
|
D("Opening URL"), E.send(
|
|
@@ -1702,7 +1704,7 @@ function jn(t) {
|
|
|
1702
1704
|
}, ie.onerror = (_) => {
|
|
1703
1705
|
!C() || B !== ie || (console.error("Control channel error:", _), D("Control channel error: " + _));
|
|
1704
1706
|
}, v.onconnectionstatechange = () => {
|
|
1705
|
-
!C() || b !== v || (D("Connection state: " + v.connectionState), v.connectionState === "failed" && te && _e("WebRTC connection entered failed state",
|
|
1707
|
+
!C() || b !== v || (D("Connection state: " + v.connectionState), v.connectionState === "failed" && te && _e("WebRTC connection entered failed state", m));
|
|
1706
1708
|
}, v.oniceconnectionstatechange = () => {
|
|
1707
1709
|
if (!C() || b !== v)
|
|
1708
1710
|
return;
|
|
@@ -1712,11 +1714,11 @@ function jn(t) {
|
|
|
1712
1714
|
return;
|
|
1713
1715
|
}
|
|
1714
1716
|
if (_ === "failed") {
|
|
1715
|
-
Ne(), te && _e("ICE connection entered failed state",
|
|
1717
|
+
Ne(), te && _e("ICE connection entered failed state", m);
|
|
1716
1718
|
return;
|
|
1717
1719
|
}
|
|
1718
1720
|
_ === "disconnected" && te && e.autoReconnect !== !1 && he === void 0 && (he = window.setTimeout(() => {
|
|
1719
|
-
he = void 0, !(!C() || b !== v) && v.iceConnectionState === "disconnected" && _e("ICE stayed disconnected past grace period",
|
|
1721
|
+
he = void 0, !(!C() || b !== v) && v.iceConnectionState === "disconnected" && _e("ICE stayed disconnected past grace period", m);
|
|
1720
1722
|
}, Yn));
|
|
1721
1723
|
}, v.ontrack = (_) => {
|
|
1722
1724
|
if (!C() || b !== v)
|
|
@@ -1767,7 +1769,7 @@ function jn(t) {
|
|
|
1767
1769
|
if (o.requestType !== "offer" || o.sessionId !== a)
|
|
1768
1770
|
break;
|
|
1769
1771
|
const T = typeof o.error == "string" ? o.error : "Unable to establish the streaming connection";
|
|
1770
|
-
D("Error: " + T), _e(T,
|
|
1772
|
+
D("Error: " + T), _e(T, m);
|
|
1771
1773
|
break;
|
|
1772
1774
|
}
|
|
1773
1775
|
case "answer":
|
|
@@ -1868,9 +1870,9 @@ function jn(t) {
|
|
|
1868
1870
|
break;
|
|
1869
1871
|
}
|
|
1870
1872
|
case "microphoneStartResult": {
|
|
1871
|
-
if (
|
|
1873
|
+
if (pe === null || o.id !== pe)
|
|
1872
1874
|
break;
|
|
1873
|
-
|
|
1875
|
+
pe = null, typeof o.error == "string" && (console.warn("[RemoteControl] microphoneStart rejected by host:", o.error), $e(o.error));
|
|
1874
1876
|
break;
|
|
1875
1877
|
}
|
|
1876
1878
|
case "terminateAppResult":
|
|
@@ -1919,27 +1921,27 @@ function jn(t) {
|
|
|
1919
1921
|
if (!C() || E instanceof Error && E.message === "Connection stopped")
|
|
1920
1922
|
return;
|
|
1921
1923
|
const J = E instanceof Error ? E.message : String(E);
|
|
1922
|
-
D("Error: " + J), _e(J,
|
|
1924
|
+
D("Error: " + J), _e(J, m);
|
|
1923
1925
|
}
|
|
1924
1926
|
}, Ct = () => {
|
|
1925
1927
|
if (Te) throw new Error("Device stream is disposed");
|
|
1926
|
-
ke++, ye = !1, xe(null),
|
|
1928
|
+
ke++, ye = !1, xe(null), me !== "reconnecting" && (me = null), document.addEventListener("visibilitychange", pt), document.hidden || dt(), fe = !1, mt(0);
|
|
1927
1929
|
}, Ot = () => {
|
|
1928
|
-
ke++, ye = !1, Ye(), document.removeEventListener("visibilitychange",
|
|
1930
|
+
ke++, ye = !1, Ye(), document.removeEventListener("visibilitychange", pt), le += 1, Le = 0, te = !1, We(), Ne(), De(), me = null, h({ connection: "idle", videoReady: !1, controlReady: !1 }), D("Stopped");
|
|
1929
1931
|
}, Dt = (r, u = "primary") => {
|
|
1930
1932
|
if (Te) throw new Error("Device stream is disposed");
|
|
1931
1933
|
if (F.has(r)) throw new Error("Video element is already attached");
|
|
1932
|
-
const
|
|
1933
|
-
F.set(r,
|
|
1934
|
-
const
|
|
1934
|
+
const s = { display: u };
|
|
1935
|
+
F.set(r, s);
|
|
1936
|
+
const l = () => {
|
|
1935
1937
|
u === "primary" && Ie.has(u) && Nt();
|
|
1936
1938
|
};
|
|
1937
|
-
r.addEventListener("loadeddata",
|
|
1939
|
+
r.addEventListener("loadeddata", l);
|
|
1938
1940
|
const S = Ie.get(u);
|
|
1939
|
-
S && st(r,
|
|
1940
|
-
let
|
|
1941
|
+
S && st(r, s, S);
|
|
1942
|
+
let m = !1;
|
|
1941
1943
|
const C = () => {
|
|
1942
|
-
|
|
1944
|
+
m || (m = !0, q.delete(C), r.removeEventListener("loadeddata", l), s.stop?.(), F.delete(r), r.srcObject = null);
|
|
1943
1945
|
};
|
|
1944
1946
|
return q.add(C), C;
|
|
1945
1947
|
};
|
|
@@ -1948,29 +1950,29 @@ function jn(t) {
|
|
|
1948
1950
|
stop: Ot,
|
|
1949
1951
|
attachVideo: Dt,
|
|
1950
1952
|
attachFrameSink: (r, u = "primary") => {
|
|
1951
|
-
const
|
|
1952
|
-
|
|
1953
|
-
const
|
|
1954
|
-
let S = !1,
|
|
1953
|
+
const s = document.createElement("video");
|
|
1954
|
+
s.muted = !0, s.playsInline = !0, s.autoplay = !0;
|
|
1955
|
+
const l = Dt(s, u);
|
|
1956
|
+
let S = !1, m = 0, C = 0;
|
|
1955
1957
|
const E = () => {
|
|
1956
|
-
|
|
1958
|
+
s.cancelVideoFrameCallback?.(m), cancelAnimationFrame(C);
|
|
1957
1959
|
}, J = () => {
|
|
1958
|
-
S || !
|
|
1960
|
+
S || !s.srcObject || (s.readyState >= 2 && s.videoWidth > 0 && L(
|
|
1959
1961
|
"present",
|
|
1960
1962
|
(...M) => r.present(...M),
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1963
|
+
s,
|
|
1964
|
+
s.videoWidth,
|
|
1965
|
+
s.videoHeight,
|
|
1964
1966
|
u
|
|
1965
|
-
), !(S || !
|
|
1967
|
+
), !(S || !s.srcObject) && (s.requestVideoFrameCallback ? m = s.requestVideoFrameCallback(J) : C = requestAnimationFrame(J)));
|
|
1966
1968
|
}, U = () => {
|
|
1967
1969
|
E(), J();
|
|
1968
1970
|
};
|
|
1969
|
-
F.get(
|
|
1971
|
+
F.get(s).clear = E, s.addEventListener("loadeddata", U);
|
|
1970
1972
|
const j = () => {
|
|
1971
|
-
S || (S = !0, q.delete(j), E(),
|
|
1973
|
+
S || (S = !0, q.delete(j), E(), s.removeEventListener("loadeddata", U), l(), s.remove());
|
|
1972
1974
|
};
|
|
1973
|
-
return q.delete(
|
|
1975
|
+
return q.delete(l), q.add(j), s.readyState >= 2 && U(), j;
|
|
1974
1976
|
},
|
|
1975
1977
|
dispose: () => {
|
|
1976
1978
|
if (!Te) {
|
|
@@ -1980,28 +1982,33 @@ function jn(t) {
|
|
|
1980
1982
|
}
|
|
1981
1983
|
},
|
|
1982
1984
|
getState: () => O,
|
|
1983
|
-
|
|
1985
|
+
/** A new token applies to the next connection attempt and termination probe. */
|
|
1986
|
+
updateOptions: ({
|
|
1987
|
+
token: r,
|
|
1988
|
+
...u
|
|
1989
|
+
}) => {
|
|
1984
1990
|
if (Te) throw new Error("Device stream is disposed");
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1991
|
+
r !== void 0 && !e.transport && (f = r);
|
|
1992
|
+
const s = e;
|
|
1993
|
+
if (e = { ...e, ...u }, s.jitterBufferTargetMs !== e.jitterBufferTargetMs)
|
|
1994
|
+
for (const l of b?.getTransceivers() ?? [])
|
|
1995
|
+
(l.currentDirection === "recvonly" || l.currentDirection === "sendrecv") && yt(l.receiver, e.jitterBufferTargetMs);
|
|
1996
|
+
!!s.onPlaybackStats != !!e.onPlaybackStats && k(), !!s.microphoneEnabled != !!e.microphoneEnabled && (Qe = !d && (e.microphoneEnabled ?? !1), Ze() ? et() : $e()), !!s.inspectMode != !!e.inspectMode && (e.inspectMode ? $?.start() : ($?.stop(), we !== null && xe(null)));
|
|
1990
1997
|
},
|
|
1991
1998
|
sendControl: se,
|
|
1992
|
-
sendTouch: (r, u,
|
|
1999
|
+
sendTouch: (r, u, s, l, S, m = 0) => se(
|
|
1993
2000
|
Vt(
|
|
1994
2001
|
r === "begin" ? 0 : r === "end" ? 1 : 2,
|
|
1995
|
-
|
|
1996
|
-
|
|
2002
|
+
m,
|
|
2003
|
+
l,
|
|
1997
2004
|
S,
|
|
1998
2005
|
u,
|
|
1999
|
-
|
|
2006
|
+
s,
|
|
2000
2007
|
r === "end" ? 0 : 1
|
|
2001
2008
|
)
|
|
2002
2009
|
),
|
|
2003
2010
|
sendText: (r) => se(Ht(r)),
|
|
2004
|
-
sendDisplayTouch: (r, u,
|
|
2011
|
+
sendDisplayTouch: (r, u, s, l) => se(Xt(r, u, s, l)),
|
|
2005
2012
|
sendDuoControl: Yt,
|
|
2006
2013
|
pressButton: (r) => {
|
|
2007
2014
|
const u = { home: 3, back: 4, recents: 187, power: 26 }[r];
|
|
@@ -2011,7 +2018,7 @@ function jn(t) {
|
|
|
2011
2018
|
bumpActivity: () => $?.bumpActivity(),
|
|
2012
2019
|
getAxStatus: () => $?.getStatus() ?? "idle",
|
|
2013
2020
|
openUrl: (r) => {
|
|
2014
|
-
if (!
|
|
2021
|
+
if (!d) {
|
|
2015
2022
|
if (!g || g.readyState !== WebSocket.OPEN) {
|
|
2016
2023
|
y("WebSocket not open, cannot send open_url command.");
|
|
2017
2024
|
return;
|
|
@@ -2047,62 +2054,62 @@ function jn(t) {
|
|
|
2047
2054
|
y(`Unknown event.code for imperative command: ${r.code}`);
|
|
2048
2055
|
return;
|
|
2049
2056
|
}
|
|
2050
|
-
let
|
|
2051
|
-
r.shiftKey && (
|
|
2052
|
-
const
|
|
2057
|
+
let s = i.META_NONE;
|
|
2058
|
+
r.shiftKey && (s |= i.META_SHIFT_ON), r.altKey && (s |= i.META_ALT_ON), r.ctrlKey && (s |= i.META_CTRL_ON), r.metaKey && (s |= i.META_META_ON);
|
|
2059
|
+
const l = r.type === "keydown" ? i.ACTION_DOWN : i.ACTION_UP;
|
|
2053
2060
|
ce(
|
|
2054
|
-
`Sending Imperative Key Command: code=${r.code}, keycode=${u}, action=${
|
|
2061
|
+
`Sending Imperative Key Command: code=${r.code}, keycode=${u}, action=${l}, meta=${s}`
|
|
2055
2062
|
);
|
|
2056
2063
|
const S = rt(
|
|
2057
|
-
|
|
2064
|
+
l,
|
|
2058
2065
|
u,
|
|
2059
2066
|
0,
|
|
2060
2067
|
// repeat count, typically 0 for single presses
|
|
2061
|
-
|
|
2068
|
+
s
|
|
2062
2069
|
);
|
|
2063
2070
|
S && se(S);
|
|
2064
2071
|
},
|
|
2065
|
-
screenshot: (r) => new Promise((u,
|
|
2072
|
+
screenshot: (r) => new Promise((u, s) => {
|
|
2066
2073
|
if (!g || g.readyState !== WebSocket.OPEN)
|
|
2067
|
-
return y("WebSocket not open, cannot send screenshot command."),
|
|
2068
|
-
const
|
|
2074
|
+
return y("WebSocket not open, cannot send screenshot command."), s(new Error("WebSocket is not connected or connection is not open."));
|
|
2075
|
+
const l = `ui-ss-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`, S = {
|
|
2069
2076
|
type: r ? "screenshotDisplay" : "screenshot",
|
|
2070
2077
|
...r ? { display: r } : {},
|
|
2071
|
-
id:
|
|
2078
|
+
id: l
|
|
2072
2079
|
};
|
|
2073
|
-
ne.set(
|
|
2080
|
+
ne.set(l, u), Z.set(l, s), ce("Sending screenshot request:", S);
|
|
2074
2081
|
try {
|
|
2075
2082
|
g.send(JSON.stringify(S));
|
|
2076
|
-
} catch (
|
|
2077
|
-
y("Failed to send screenshot request immediately:",
|
|
2083
|
+
} catch (m) {
|
|
2084
|
+
y("Failed to send screenshot request immediately:", m), ne.delete(l), Z.delete(l), s(m);
|
|
2078
2085
|
return;
|
|
2079
2086
|
}
|
|
2080
2087
|
Y.set(
|
|
2081
|
-
|
|
2088
|
+
l,
|
|
2082
2089
|
setTimeout(() => {
|
|
2083
|
-
Y.delete(
|
|
2090
|
+
Y.delete(l), ne.has(l) && (y(`Screenshot request timed out for id ${l}`), Z.get(l)?.(new Error("Screenshot request timed out")), ne.delete(l), Z.delete(l));
|
|
2084
2091
|
}, 3e4)
|
|
2085
2092
|
);
|
|
2086
2093
|
}),
|
|
2087
|
-
terminateApp: (r) =>
|
|
2094
|
+
terminateApp: (r) => d ? Promise.reject(new Error("Device is watch-only")) : new Promise((u, s) => {
|
|
2088
2095
|
if (!g || g.readyState !== WebSocket.OPEN)
|
|
2089
|
-
return y("WebSocket not open, cannot send terminateApp command."),
|
|
2090
|
-
const
|
|
2096
|
+
return y("WebSocket not open, cannot send terminateApp command."), s(new Error("WebSocket is not connected or connection is not open."));
|
|
2097
|
+
const l = `ui-term-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`, S = {
|
|
2091
2098
|
type: "terminateApp",
|
|
2092
|
-
id:
|
|
2099
|
+
id: l,
|
|
2093
2100
|
bundleId: r
|
|
2094
2101
|
};
|
|
2095
|
-
ae.set(
|
|
2102
|
+
ae.set(l, u), re.set(l, s), ce("Sending terminateApp request:", S);
|
|
2096
2103
|
try {
|
|
2097
2104
|
g.send(JSON.stringify(S));
|
|
2098
|
-
} catch (
|
|
2099
|
-
y("Failed to send terminateApp request immediately:",
|
|
2105
|
+
} catch (m) {
|
|
2106
|
+
y("Failed to send terminateApp request immediately:", m), ae.delete(l), re.delete(l), s(m);
|
|
2100
2107
|
return;
|
|
2101
2108
|
}
|
|
2102
2109
|
$?.bumpActivity(), Y.set(
|
|
2103
|
-
|
|
2110
|
+
l,
|
|
2104
2111
|
setTimeout(() => {
|
|
2105
|
-
Y.delete(
|
|
2112
|
+
Y.delete(l), ae.has(l) && (y(`terminateApp request timed out for id ${l}`), re.get(l)?.(new Error("terminateApp request timed out")), ae.delete(l), re.delete(l));
|
|
2106
2113
|
}, 3e4)
|
|
2107
2114
|
);
|
|
2108
2115
|
}),
|