@limrun/ui 0.22.4 → 0.22.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/README.md +3 -3
- package/dist/components/remote-control.d.ts +15 -0
- package/dist/core/device-stream.d.ts +1 -0
- package/dist/core/stream-options.d.ts +10 -0
- package/dist/core/stream-utils.d.ts +10 -0
- package/dist/{core-nbvkIrvp.mjs → core-BPDihn1M.mjs} +907 -856
- package/dist/core-_qwksEry.js +2 -0
- package/dist/core.cjs +1 -1
- package/dist/core.js +4 -4
- package/dist/{duo-frame-Bm0hprn9.js → duo-frame-d3lnF2F7.js} +1 -1
- package/dist/{duo-frame-BCmB9_5p.mjs → duo-frame-s8ZpiZc-.mjs} +2 -2
- package/dist/{duo-view-C07GD_5E.mjs → duo-view-B2i1POpD.mjs} +3 -3
- package/dist/{duo-view-tUJbbWoS.js → duo-view-CKlDgO_u.js} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +26 -26
- package/dist/lite.cjs +1 -1
- package/dist/lite.js +2 -2
- package/dist/{macbook-frame-Dm6ko0j9.mjs → macbook-frame-BZhBYM9R.mjs} +1 -1
- package/dist/{macbook-frame-BxJfxUcU.js → macbook-frame-g3h4xP5G.js} +1 -1
- package/dist/remote-control-DmPKov-i.mjs +1723 -0
- package/dist/remote-control-y8mgo_2E.js +1 -0
- package/package.json +1 -1
- package/dist/core-BCBQrYsk.js +0 -2
- package/dist/remote-control-BX6dzHtt.mjs +0 -1712
- package/dist/remote-control-CEVcOPQZ.js +0 -1
|
@@ -19,11 +19,11 @@ const ee = {
|
|
|
19
19
|
INJECT_MAC_KEY: 41,
|
|
20
20
|
// macOS: wheel and trackpad scrolling, as pixel deltas.
|
|
21
21
|
INJECT_MAC_SCROLL: 42
|
|
22
|
-
},
|
|
22
|
+
}, Qe = {
|
|
23
23
|
DOWN: 0,
|
|
24
24
|
UP: 1,
|
|
25
25
|
MOVE: 2
|
|
26
|
-
},
|
|
26
|
+
}, ze = {
|
|
27
27
|
ACTION_DOWN: 0,
|
|
28
28
|
ACTION_UP: 1,
|
|
29
29
|
ACTION_MOVE: 2,
|
|
@@ -33,7 +33,7 @@ const ee = {
|
|
|
33
33
|
BUTTON_PRIMARY: 1,
|
|
34
34
|
BUTTON_SECONDARY: 2,
|
|
35
35
|
BUTTON_TERTIARY: 4
|
|
36
|
-
},
|
|
36
|
+
}, a = {
|
|
37
37
|
// Actions
|
|
38
38
|
ACTION_DOWN: 0,
|
|
39
39
|
ACTION_UP: 1,
|
|
@@ -259,113 +259,113 @@ const ee = {
|
|
|
259
259
|
KEYCODE_SLEEP: 223,
|
|
260
260
|
KEYCODE_WAKEUP: 224,
|
|
261
261
|
KEYCODE_SOFT_SLEEP: 276
|
|
262
|
-
},
|
|
263
|
-
KeyA:
|
|
264
|
-
KeyB:
|
|
265
|
-
KeyC:
|
|
266
|
-
KeyD:
|
|
267
|
-
KeyE:
|
|
268
|
-
KeyF:
|
|
269
|
-
KeyG:
|
|
270
|
-
KeyH:
|
|
271
|
-
KeyI:
|
|
272
|
-
KeyJ:
|
|
273
|
-
KeyK:
|
|
274
|
-
KeyL:
|
|
275
|
-
KeyM:
|
|
276
|
-
KeyN:
|
|
277
|
-
KeyO:
|
|
278
|
-
KeyP:
|
|
279
|
-
KeyQ:
|
|
280
|
-
KeyR:
|
|
281
|
-
KeyS:
|
|
282
|
-
KeyT:
|
|
283
|
-
KeyU:
|
|
284
|
-
KeyV:
|
|
285
|
-
KeyW:
|
|
286
|
-
KeyX:
|
|
287
|
-
KeyY:
|
|
288
|
-
KeyZ:
|
|
289
|
-
Digit0:
|
|
290
|
-
Digit1:
|
|
291
|
-
Digit2:
|
|
292
|
-
Digit3:
|
|
293
|
-
Digit4:
|
|
294
|
-
Digit5:
|
|
295
|
-
Digit6:
|
|
296
|
-
Digit7:
|
|
297
|
-
Digit8:
|
|
298
|
-
Digit9:
|
|
299
|
-
Backquote:
|
|
300
|
-
Minus:
|
|
301
|
-
Equal:
|
|
302
|
-
BracketLeft:
|
|
303
|
-
BracketRight:
|
|
304
|
-
Backslash:
|
|
305
|
-
Semicolon:
|
|
306
|
-
Quote:
|
|
307
|
-
Comma:
|
|
308
|
-
Period:
|
|
309
|
-
Slash:
|
|
310
|
-
Space:
|
|
311
|
-
Tab:
|
|
312
|
-
Escape:
|
|
313
|
-
ArrowUp:
|
|
314
|
-
ArrowDown:
|
|
315
|
-
ArrowLeft:
|
|
316
|
-
ArrowRight:
|
|
317
|
-
Enter:
|
|
318
|
-
Backspace:
|
|
319
|
-
Delete:
|
|
320
|
-
Home:
|
|
321
|
-
End:
|
|
322
|
-
PageUp:
|
|
323
|
-
PageDown:
|
|
324
|
-
Insert:
|
|
325
|
-
F1:
|
|
326
|
-
F2:
|
|
327
|
-
F3:
|
|
328
|
-
F4:
|
|
329
|
-
F5:
|
|
330
|
-
F6:
|
|
331
|
-
F7:
|
|
332
|
-
F8:
|
|
333
|
-
F9:
|
|
334
|
-
F10:
|
|
335
|
-
F11:
|
|
336
|
-
F12:
|
|
337
|
-
ShiftLeft:
|
|
338
|
-
ShiftRight:
|
|
339
|
-
ControlLeft:
|
|
340
|
-
ControlRight:
|
|
341
|
-
AltLeft:
|
|
342
|
-
AltRight:
|
|
343
|
-
MetaLeft:
|
|
344
|
-
MetaRight:
|
|
262
|
+
}, rr = {
|
|
263
|
+
KeyA: a.KEYCODE_A,
|
|
264
|
+
KeyB: a.KEYCODE_B,
|
|
265
|
+
KeyC: a.KEYCODE_C,
|
|
266
|
+
KeyD: a.KEYCODE_D,
|
|
267
|
+
KeyE: a.KEYCODE_E,
|
|
268
|
+
KeyF: a.KEYCODE_F,
|
|
269
|
+
KeyG: a.KEYCODE_G,
|
|
270
|
+
KeyH: a.KEYCODE_H,
|
|
271
|
+
KeyI: a.KEYCODE_I,
|
|
272
|
+
KeyJ: a.KEYCODE_J,
|
|
273
|
+
KeyK: a.KEYCODE_K,
|
|
274
|
+
KeyL: a.KEYCODE_L,
|
|
275
|
+
KeyM: a.KEYCODE_M,
|
|
276
|
+
KeyN: a.KEYCODE_N,
|
|
277
|
+
KeyO: a.KEYCODE_O,
|
|
278
|
+
KeyP: a.KEYCODE_P,
|
|
279
|
+
KeyQ: a.KEYCODE_Q,
|
|
280
|
+
KeyR: a.KEYCODE_R,
|
|
281
|
+
KeyS: a.KEYCODE_S,
|
|
282
|
+
KeyT: a.KEYCODE_T,
|
|
283
|
+
KeyU: a.KEYCODE_U,
|
|
284
|
+
KeyV: a.KEYCODE_V,
|
|
285
|
+
KeyW: a.KEYCODE_W,
|
|
286
|
+
KeyX: a.KEYCODE_X,
|
|
287
|
+
KeyY: a.KEYCODE_Y,
|
|
288
|
+
KeyZ: a.KEYCODE_Z,
|
|
289
|
+
Digit0: a.KEYCODE_0,
|
|
290
|
+
Digit1: a.KEYCODE_1,
|
|
291
|
+
Digit2: a.KEYCODE_2,
|
|
292
|
+
Digit3: a.KEYCODE_3,
|
|
293
|
+
Digit4: a.KEYCODE_4,
|
|
294
|
+
Digit5: a.KEYCODE_5,
|
|
295
|
+
Digit6: a.KEYCODE_6,
|
|
296
|
+
Digit7: a.KEYCODE_7,
|
|
297
|
+
Digit8: a.KEYCODE_8,
|
|
298
|
+
Digit9: a.KEYCODE_9,
|
|
299
|
+
Backquote: a.KEYCODE_GRAVE,
|
|
300
|
+
Minus: a.KEYCODE_MINUS,
|
|
301
|
+
Equal: a.KEYCODE_EQUALS,
|
|
302
|
+
BracketLeft: a.KEYCODE_LEFT_BRACKET,
|
|
303
|
+
BracketRight: a.KEYCODE_RIGHT_BRACKET,
|
|
304
|
+
Backslash: a.KEYCODE_BACKSLASH,
|
|
305
|
+
Semicolon: a.KEYCODE_SEMICOLON,
|
|
306
|
+
Quote: a.KEYCODE_APOSTROPHE,
|
|
307
|
+
Comma: a.KEYCODE_COMMA,
|
|
308
|
+
Period: a.KEYCODE_PERIOD,
|
|
309
|
+
Slash: a.KEYCODE_SLASH,
|
|
310
|
+
Space: a.KEYCODE_SPACE,
|
|
311
|
+
Tab: a.KEYCODE_TAB,
|
|
312
|
+
Escape: a.KEYCODE_ESCAPE,
|
|
313
|
+
ArrowUp: a.DPAD_UP,
|
|
314
|
+
ArrowDown: a.DPAD_DOWN,
|
|
315
|
+
ArrowLeft: a.DPAD_LEFT,
|
|
316
|
+
ArrowRight: a.DPAD_RIGHT,
|
|
317
|
+
Enter: a.ENTER,
|
|
318
|
+
Backspace: a.DEL,
|
|
319
|
+
Delete: a.FORWARD_DEL,
|
|
320
|
+
Home: a.KEYCODE_MOVE_HOME,
|
|
321
|
+
End: a.KEYCODE_MOVE_END,
|
|
322
|
+
PageUp: a.KEYCODE_PAGE_UP,
|
|
323
|
+
PageDown: a.KEYCODE_PAGE_DOWN,
|
|
324
|
+
Insert: a.KEYCODE_INSERT,
|
|
325
|
+
F1: a.KEYCODE_F1,
|
|
326
|
+
F2: a.KEYCODE_F2,
|
|
327
|
+
F3: a.KEYCODE_F3,
|
|
328
|
+
F4: a.KEYCODE_F4,
|
|
329
|
+
F5: a.KEYCODE_F5,
|
|
330
|
+
F6: a.KEYCODE_F6,
|
|
331
|
+
F7: a.KEYCODE_F7,
|
|
332
|
+
F8: a.KEYCODE_F8,
|
|
333
|
+
F9: a.KEYCODE_F9,
|
|
334
|
+
F10: a.KEYCODE_F10,
|
|
335
|
+
F11: a.KEYCODE_F11,
|
|
336
|
+
F12: a.KEYCODE_F12,
|
|
337
|
+
ShiftLeft: a.KEYCODE_SHIFT_LEFT,
|
|
338
|
+
ShiftRight: a.KEYCODE_SHIFT_RIGHT,
|
|
339
|
+
ControlLeft: a.KEYCODE_CTRL_LEFT,
|
|
340
|
+
ControlRight: a.KEYCODE_CTRL_RIGHT,
|
|
341
|
+
AltLeft: a.KEYCODE_ALT_LEFT,
|
|
342
|
+
AltRight: a.KEYCODE_ALT_RIGHT,
|
|
343
|
+
MetaLeft: a.KEYCODE_META_LEFT,
|
|
344
|
+
MetaRight: a.KEYCODE_META_RIGHT,
|
|
345
345
|
// Windows/Command key
|
|
346
|
-
ContextMenu:
|
|
346
|
+
ContextMenu: a.MENU,
|
|
347
347
|
// Often the Menu key
|
|
348
348
|
// Numpad mappings
|
|
349
|
-
Numpad0:
|
|
350
|
-
Numpad1:
|
|
351
|
-
Numpad2:
|
|
352
|
-
Numpad3:
|
|
353
|
-
Numpad4:
|
|
354
|
-
Numpad5:
|
|
355
|
-
Numpad6:
|
|
356
|
-
Numpad7:
|
|
357
|
-
Numpad8:
|
|
358
|
-
Numpad9:
|
|
359
|
-
NumpadDivide:
|
|
360
|
-
NumpadMultiply:
|
|
361
|
-
NumpadSubtract:
|
|
362
|
-
NumpadAdd:
|
|
363
|
-
NumpadDecimal:
|
|
364
|
-
NumpadComma:
|
|
349
|
+
Numpad0: a.KEYCODE_NUMPAD_0,
|
|
350
|
+
Numpad1: a.KEYCODE_NUMPAD_1,
|
|
351
|
+
Numpad2: a.KEYCODE_NUMPAD_2,
|
|
352
|
+
Numpad3: a.KEYCODE_NUMPAD_3,
|
|
353
|
+
Numpad4: a.KEYCODE_NUMPAD_4,
|
|
354
|
+
Numpad5: a.KEYCODE_NUMPAD_5,
|
|
355
|
+
Numpad6: a.KEYCODE_NUMPAD_6,
|
|
356
|
+
Numpad7: a.KEYCODE_NUMPAD_7,
|
|
357
|
+
Numpad8: a.KEYCODE_NUMPAD_8,
|
|
358
|
+
Numpad9: a.KEYCODE_NUMPAD_9,
|
|
359
|
+
NumpadDivide: a.KEYCODE_NUMPAD_DIVIDE,
|
|
360
|
+
NumpadMultiply: a.KEYCODE_NUMPAD_MULTIPLY,
|
|
361
|
+
NumpadSubtract: a.KEYCODE_NUMPAD_SUBTRACT,
|
|
362
|
+
NumpadAdd: a.KEYCODE_NUMPAD_ADD,
|
|
363
|
+
NumpadDecimal: a.KEYCODE_NUMPAD_DOT,
|
|
364
|
+
NumpadComma: a.KEYCODE_NUMPAD_COMMA,
|
|
365
365
|
// Some numpads have comma
|
|
366
|
-
NumpadEnter:
|
|
367
|
-
NumpadEqual:
|
|
368
|
-
},
|
|
366
|
+
NumpadEnter: a.KEYCODE_NUMPAD_ENTER,
|
|
367
|
+
NumpadEqual: a.KEYCODE_NUMPAD_EQUALS
|
|
368
|
+
}, nr = {
|
|
369
369
|
KeyA: 0,
|
|
370
370
|
KeyS: 1,
|
|
371
371
|
KeyD: 2,
|
|
@@ -480,50 +480,50 @@ const ee = {
|
|
|
480
480
|
ArrowDown: 125,
|
|
481
481
|
ArrowUp: 126
|
|
482
482
|
};
|
|
483
|
-
function
|
|
484
|
-
return
|
|
483
|
+
function wt(t) {
|
|
484
|
+
return nr[t];
|
|
485
485
|
}
|
|
486
|
-
function
|
|
487
|
-
const
|
|
486
|
+
function ir(t, e, r, o, u, l, i = 1, E = 0, D = 0) {
|
|
487
|
+
const p = new ArrayBuffer(32), S = new DataView(p);
|
|
488
488
|
let w = 0;
|
|
489
489
|
S.setUint8(w, ee.INJECT_TOUCH_EVENT), w += 1;
|
|
490
|
-
const N = t ===
|
|
491
|
-
return S.setUint8(w, N), w += 1, S.setBigInt64(w, BigInt(e), !0), w += 8, S.setInt32(w, Math.round(u), !0), w += 4, S.setInt32(w, Math.round(l), !0), w += 4, S.setUint16(w,
|
|
490
|
+
const N = t === ze.ACTION_POINTER_DOWN ? ze.ACTION_DOWN : t === ze.ACTION_POINTER_UP ? ze.ACTION_UP : t;
|
|
491
|
+
return S.setUint8(w, N), w += 1, S.setBigInt64(w, BigInt(e), !0), w += 8, S.setInt32(w, Math.round(u), !0), w += 4, S.setInt32(w, Math.round(l), !0), w += 4, S.setUint16(w, r, !0), w += 2, S.setUint16(w, o, !0), w += 2, S.setInt16(w, Math.round(i * 65535), !0), w += 2, S.setInt32(w, E, !0), w += 4, S.setInt32(w, D, !0), p;
|
|
492
492
|
}
|
|
493
|
-
function
|
|
494
|
-
const E = new ArrayBuffer(24),
|
|
495
|
-
let
|
|
496
|
-
return
|
|
493
|
+
function Xr(t, e, r, o, u, l, i) {
|
|
494
|
+
const E = new ArrayBuffer(24), D = new DataView(E);
|
|
495
|
+
let p = 0;
|
|
496
|
+
return D.setUint8(p, ee.INJECT_TWO_FINGER_TOUCH_EVENT), p += 1, D.setUint8(p, t), p += 1, D.setInt32(p, Math.round(o), !0), p += 4, D.setInt32(p, Math.round(u), !0), p += 4, D.setInt32(p, Math.round(l), !0), p += 4, D.setInt32(p, Math.round(i), !0), p += 4, D.setUint16(p, e, !0), p += 2, D.setUint16(p, r, !0), p += 2, D.setUint16(p, 0, !0), E;
|
|
497
497
|
}
|
|
498
|
-
function
|
|
499
|
-
const
|
|
498
|
+
function or(t, e = !0) {
|
|
499
|
+
const o = new TextEncoder().encode(t), u = new ArrayBuffer(14 + o.length), l = new DataView(u);
|
|
500
500
|
let i = 0;
|
|
501
|
-
return l.setUint8(i, ee.SET_CLIPBOARD), i += 1, l.setBigInt64(i, BigInt(0), !1), i += 8, l.setUint8(i, e ? 1 : 0), i += 1, l.setUint32(i,
|
|
501
|
+
return l.setUint8(i, ee.SET_CLIPBOARD), i += 1, l.setBigInt64(i, BigInt(0), !1), i += 8, l.setUint8(i, e ? 1 : 0), i += 1, l.setUint32(i, o.length, !1), i += 4, new Uint8Array(u, i).set(o), u;
|
|
502
502
|
}
|
|
503
|
-
function
|
|
503
|
+
function lt(t, e, r = 0, o = 0) {
|
|
504
504
|
const u = new ArrayBuffer(14), l = new DataView(u);
|
|
505
505
|
let i = 0;
|
|
506
|
-
return l.setUint8(i, ee.INJECT_KEYCODE), i += 1, l.setUint8(i, t), i += 1, l.setInt32(i, e, !0), i += 4, l.setInt32(i,
|
|
506
|
+
return l.setUint8(i, ee.INJECT_KEYCODE), i += 1, l.setUint8(i, t), i += 1, l.setInt32(i, e, !0), i += 4, l.setInt32(i, r, !0), i += 4, l.setInt32(i, o, !0), u;
|
|
507
507
|
}
|
|
508
|
-
function
|
|
508
|
+
function Qr(t, e, r, o, u, l) {
|
|
509
509
|
const i = new ArrayBuffer(18), E = new DataView(i);
|
|
510
|
-
return E.setUint8(0, ee.INJECT_MOUSE_EVENT), E.setUint8(1, t), E.setInt32(2, Math.round(
|
|
510
|
+
return E.setUint8(0, ee.INJECT_MOUSE_EVENT), E.setUint8(1, t), E.setInt32(2, Math.round(o), !0), E.setInt32(6, Math.round(u), !0), E.setUint16(10, e, !0), E.setUint16(12, r, !0), E.setInt32(14, l, !0), i;
|
|
511
511
|
}
|
|
512
|
-
function
|
|
513
|
-
const
|
|
514
|
-
return
|
|
512
|
+
function ar(t, e) {
|
|
513
|
+
const r = new ArrayBuffer(4), o = new DataView(r);
|
|
514
|
+
return o.setUint8(0, ee.INJECT_MAC_KEY), o.setUint8(1, t), o.setUint16(2, e, !0), r;
|
|
515
515
|
}
|
|
516
|
-
function
|
|
516
|
+
function zr(t, e, r, o, u, l) {
|
|
517
517
|
const i = new ArrayBuffer(21), E = new DataView(i);
|
|
518
|
-
return E.setUint8(0, ee.INJECT_MAC_SCROLL), E.setInt32(1, Math.round(
|
|
518
|
+
return E.setUint8(0, ee.INJECT_MAC_SCROLL), E.setInt32(1, Math.round(r), !0), E.setInt32(5, Math.round(o), !0), E.setUint16(9, t, !0), E.setUint16(11, e, !0), E.setFloat32(13, u, !0), E.setFloat32(17, l, !0), i;
|
|
519
519
|
}
|
|
520
|
-
function
|
|
520
|
+
function Zr(t) {
|
|
521
521
|
return t?.displays.find((e) => e.id === (t.angleDegrees < 90 ? "outer" : "inner"));
|
|
522
522
|
}
|
|
523
|
-
function
|
|
523
|
+
function sr(t) {
|
|
524
524
|
return t === 2 ? 2 : t === 3 ? 1 : t === 4 ? 3 : 0;
|
|
525
525
|
}
|
|
526
|
-
class
|
|
526
|
+
class en {
|
|
527
527
|
constructor(e) {
|
|
528
528
|
this.send = e;
|
|
529
529
|
}
|
|
@@ -534,44 +534,44 @@ class Vn {
|
|
|
534
534
|
get active() {
|
|
535
535
|
return this.held !== void 0;
|
|
536
536
|
}
|
|
537
|
-
setDisplay(e,
|
|
538
|
-
(this.screenId !== e?.screenId || this.turns !==
|
|
537
|
+
setDisplay(e, r = sr(e?.orientation)) {
|
|
538
|
+
(this.screenId !== e?.screenId || this.turns !== r) && this.release(), this.screenId = e?.screenId, this.turns = r;
|
|
539
539
|
}
|
|
540
540
|
/** Coordinates are normalized; native input already accounts for the viewer's rotation. */
|
|
541
|
-
touch(e,
|
|
541
|
+
touch(e, r, o, u = !1) {
|
|
542
542
|
if (this.screenId === void 0) return;
|
|
543
|
-
const l =
|
|
543
|
+
const l = cr(r, o, u ? 0 : this.turns);
|
|
544
544
|
e === "begin" && (this.release(), this.held = { screenId: this.screenId, ...l }), this.held && (Object.assign(this.held, l), e === "end" ? this.release() : this.send(e === "begin" ? 0 : 2, this.held.screenId, l.x, l.y));
|
|
545
545
|
}
|
|
546
546
|
/** Call on pointer cancellation, lost capture, disconnect, and viewer disposal. */
|
|
547
547
|
release() {
|
|
548
548
|
if (!this.held) return;
|
|
549
|
-
const { screenId: e, x:
|
|
550
|
-
this.held = void 0, this.send(1, e,
|
|
549
|
+
const { screenId: e, x: r, y: o } = this.held;
|
|
550
|
+
this.held = void 0, this.send(1, e, r, o);
|
|
551
551
|
}
|
|
552
552
|
}
|
|
553
|
-
const
|
|
554
|
-
function
|
|
555
|
-
return t = Math.max(0, Math.min(1, t)), e = Math.max(0, Math.min(1, e)),
|
|
553
|
+
const tn = { width: 164.6, height: 117.8, depth: 5.2 };
|
|
554
|
+
function cr(t, e, r) {
|
|
555
|
+
return t = Math.max(0, Math.min(1, t)), e = Math.max(0, Math.min(1, e)), r === 1 ? { x: e, y: 1 - t } : r === 2 ? { x: 1 - t, y: 1 - e } : r === 3 ? { x: 1 - e, y: t } : { x: t, y: e };
|
|
556
556
|
}
|
|
557
|
-
function
|
|
557
|
+
function lr(t) {
|
|
558
558
|
return Number.isFinite(t) && t >= 0 && t <= 180;
|
|
559
559
|
}
|
|
560
|
-
function
|
|
560
|
+
function rn(t, e) {
|
|
561
561
|
return { x: Math.max(0, Math.min(1, t)), y: Math.max(0, Math.min(1, 1 - e)) };
|
|
562
562
|
}
|
|
563
|
-
function
|
|
564
|
-
return e && (t || !
|
|
563
|
+
function nn(t, e, r) {
|
|
564
|
+
return e && (t || !r) ? "touch" : t ? "ignore" : "orbit";
|
|
565
565
|
}
|
|
566
|
-
function
|
|
567
|
-
if (!Number.isInteger(t) || t < 0 || t > 3 || !Number.isInteger(e) || e < 1 || e > 255 || !Number.isFinite(
|
|
566
|
+
function dr(t, e, r, o) {
|
|
567
|
+
if (!Number.isInteger(t) || t < 0 || t > 3 || !Number.isInteger(e) || e < 1 || e > 255 || !Number.isFinite(r) || !Number.isFinite(o) || r < 0 || r > 1 || o < 0 || o > 1)
|
|
568
568
|
throw new RangeError("Invalid display touch coordinates");
|
|
569
569
|
const u = new ArrayBuffer(12), l = new DataView(u);
|
|
570
|
-
return l.setUint8(0, 19), l.setUint8(1, t), l.setUint8(2, e), l.setFloat32(4,
|
|
570
|
+
return l.setUint8(0, 19), l.setUint8(1, t), l.setUint8(2, e), l.setFloat32(4, r, !0), l.setFloat32(8, o, !0), u;
|
|
571
571
|
}
|
|
572
|
-
class
|
|
573
|
-
constructor(e,
|
|
574
|
-
this.send = e, this.failed =
|
|
572
|
+
class on {
|
|
573
|
+
constructor(e, r) {
|
|
574
|
+
this.send = e, this.failed = r;
|
|
575
575
|
}
|
|
576
576
|
send;
|
|
577
577
|
failed;
|
|
@@ -579,7 +579,7 @@ class Gn {
|
|
|
579
579
|
running = !1;
|
|
580
580
|
stopped = !1;
|
|
581
581
|
set(e) {
|
|
582
|
-
this.stopped || !
|
|
582
|
+
this.stopped || !lr(e) || (this.latest = e, this.flush());
|
|
583
583
|
}
|
|
584
584
|
stop() {
|
|
585
585
|
this.stopped = !0, this.latest = void 0;
|
|
@@ -600,14 +600,14 @@ class Gn {
|
|
|
600
600
|
}
|
|
601
601
|
}
|
|
602
602
|
}
|
|
603
|
-
const
|
|
603
|
+
const an = {
|
|
604
604
|
side: "Sleep/Wake",
|
|
605
605
|
volumeUp: "Volume Up",
|
|
606
606
|
volumeDown: "Volume Down"
|
|
607
607
|
};
|
|
608
|
-
class
|
|
609
|
-
constructor(e,
|
|
610
|
-
this.send = e, this.failed =
|
|
608
|
+
class sn {
|
|
609
|
+
constructor(e, r) {
|
|
610
|
+
this.send = e, this.failed = r;
|
|
611
611
|
}
|
|
612
612
|
send;
|
|
613
613
|
failed;
|
|
@@ -623,155 +623,155 @@ class Xn {
|
|
|
623
623
|
const e = this.held;
|
|
624
624
|
this.held = void 0, this.enqueue(e, !1);
|
|
625
625
|
}
|
|
626
|
-
enqueue(e,
|
|
627
|
-
this.tail = this.tail.then(() => this.send(e,
|
|
626
|
+
enqueue(e, r) {
|
|
627
|
+
this.tail = this.tail.then(() => this.send(e, r)).catch(this.failed);
|
|
628
628
|
}
|
|
629
629
|
}
|
|
630
|
-
const
|
|
631
|
-
const e = t.find((
|
|
630
|
+
const dt = "Accessibility unavailable on this device.", Ze = 500, Pt = (t, e) => Math.abs(t.x - e.x) < 0.5 && Math.abs(t.y - e.y) < 0.5 && Math.abs(t.width - e.width) < 0.5 && Math.abs(t.height - e.height) < 0.5, ur = (t) => Math.max(0, t.width) * Math.max(0, t.height), fr = (t) => {
|
|
631
|
+
const e = t.find((r) => r.frame && r.frame.width > 0 && r.frame.height > 0);
|
|
632
632
|
return e?.frame ? ((Math.abs(e.frame.x) > 0.5 || Math.abs(e.frame.y) > 0.5) && console.warn(
|
|
633
633
|
`[ax-tree] iOS root frame is not anchored at (0,0): (${e.frame.x},${e.frame.y}). Element positions may be slightly off from the rendered video.`
|
|
634
634
|
), { x: 0, y: 0, width: e.frame.width, height: e.frame.height }) : { x: 0, y: 0, width: 1, height: 1 };
|
|
635
|
-
},
|
|
635
|
+
}, Er = (t) => {
|
|
636
636
|
const e = {};
|
|
637
637
|
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;
|
|
638
|
-
},
|
|
638
|
+
}, hr = (t) => {
|
|
639
639
|
const e = {};
|
|
640
|
-
for (const [
|
|
641
|
-
|
|
640
|
+
for (const [r, o] of Object.entries(t))
|
|
641
|
+
r !== "children" && (e[r] = o);
|
|
642
642
|
return e;
|
|
643
643
|
};
|
|
644
|
-
function
|
|
645
|
-
const e = Array.isArray(t) ? t : [t],
|
|
646
|
-
if (
|
|
644
|
+
function pr(t) {
|
|
645
|
+
const e = Array.isArray(t) ? t : [t], r = fr(e), o = [], u = (l, i) => {
|
|
646
|
+
if (o.length >= Ze) return;
|
|
647
647
|
const E = l.frame;
|
|
648
|
-
if (E && E.width > 0 && E.height > 0 && !
|
|
649
|
-
const
|
|
650
|
-
|
|
648
|
+
if (E && E.width > 0 && E.height > 0 && !Pt(E, r)) {
|
|
649
|
+
const p = l.role_description || l.role || "", S = (typeof l.AXLabel == "string" ? l.AXLabel : "") || (typeof l.title == "string" ? l.title : "") || "";
|
|
650
|
+
o.push({
|
|
651
651
|
id: typeof l.AXUniqueId == "string" && l.AXUniqueId.length > 0 ? l.AXUniqueId : i,
|
|
652
652
|
path: i,
|
|
653
653
|
label: S,
|
|
654
654
|
value: typeof l.AXValue == "string" ? l.AXValue : "",
|
|
655
|
-
role:
|
|
655
|
+
role: p,
|
|
656
656
|
type: typeof l.type == "string" ? l.type : "",
|
|
657
657
|
enabled: l.enabled !== !1,
|
|
658
658
|
focused: l.focused === !0,
|
|
659
659
|
frame: { x: E.x, y: E.y, width: E.width, height: E.height },
|
|
660
|
-
selectors:
|
|
661
|
-
raw:
|
|
660
|
+
selectors: Er(l),
|
|
661
|
+
raw: hr(l)
|
|
662
662
|
});
|
|
663
663
|
}
|
|
664
|
-
const
|
|
665
|
-
for (let
|
|
666
|
-
u(
|
|
664
|
+
const D = Array.isArray(l.children) ? l.children : [];
|
|
665
|
+
for (let p = 0; p < D.length && o.length < Ze; p++)
|
|
666
|
+
u(D[p], `${i}.${p}`);
|
|
667
667
|
};
|
|
668
|
-
for (let l = 0; l < e.length &&
|
|
668
|
+
for (let l = 0; l < e.length && o.length < Ze; l++)
|
|
669
669
|
u(e[l], String(l));
|
|
670
670
|
return {
|
|
671
671
|
platform: "ios",
|
|
672
|
-
screen: { width:
|
|
673
|
-
elements:
|
|
672
|
+
screen: { width: r.width, height: r.height },
|
|
673
|
+
elements: o,
|
|
674
674
|
capturedAt: Date.now()
|
|
675
675
|
};
|
|
676
676
|
}
|
|
677
|
-
const
|
|
678
|
-
let e = { x: 0, y: 0, width: 1, height: 1 },
|
|
679
|
-
for (const
|
|
680
|
-
const u =
|
|
677
|
+
const mr = (t) => {
|
|
678
|
+
let e = { x: 0, y: 0, width: 1, height: 1 }, r = 0;
|
|
679
|
+
for (const o of t) {
|
|
680
|
+
const u = o.parsedBounds;
|
|
681
681
|
if (!u) continue;
|
|
682
682
|
const l = u.right - u.left, i = u.bottom - u.top, E = Math.max(0, l) * Math.max(0, i);
|
|
683
|
-
E >
|
|
683
|
+
E > r && (r = E, e = { x: 0, y: 0, width: l, height: i });
|
|
684
684
|
}
|
|
685
685
|
return e;
|
|
686
|
-
},
|
|
686
|
+
}, Cr = (t) => {
|
|
687
687
|
const e = {};
|
|
688
688
|
return typeof t.resourceId == "string" && t.resourceId.length > 0 && (e.resourceId = t.resourceId), typeof t.contentDesc == "string" && t.contentDesc.length > 0 && (e.contentDesc = t.contentDesc), typeof t.text == "string" && t.text.length > 0 && (e.text = t.text), typeof t.className == "string" && t.className.length > 0 && (e.className = t.className), e;
|
|
689
689
|
};
|
|
690
|
-
function
|
|
691
|
-
const e =
|
|
692
|
-
for (let
|
|
693
|
-
const u = t[
|
|
690
|
+
function Or(t) {
|
|
691
|
+
const e = mr(t), r = [];
|
|
692
|
+
for (let o = 0; o < t.length && r.length < Ze; o++) {
|
|
693
|
+
const u = t[o], l = u.parsedBounds;
|
|
694
694
|
if (!l) continue;
|
|
695
695
|
const i = Math.max(0, l.right - l.left), E = Math.max(0, l.bottom - l.top);
|
|
696
696
|
if (i <= 0 || E <= 0) continue;
|
|
697
|
-
const
|
|
698
|
-
if (
|
|
699
|
-
const
|
|
700
|
-
|
|
701
|
-
id: u.resourceId && u.resourceId.length > 0 ? u.resourceId : u.contentDesc && u.contentDesc.length > 0 ? `cd:${u.contentDesc}` : String(
|
|
702
|
-
path: String(
|
|
703
|
-
label:
|
|
697
|
+
const D = { x: l.left, y: l.top, width: i, height: E };
|
|
698
|
+
if (Pt(D, { x: 0, y: 0, width: e.width, height: e.height })) continue;
|
|
699
|
+
const p = u.contentDesc || u.text || "", S = u.className || "";
|
|
700
|
+
r.push({
|
|
701
|
+
id: u.resourceId && u.resourceId.length > 0 ? u.resourceId : u.contentDesc && u.contentDesc.length > 0 ? `cd:${u.contentDesc}` : String(o),
|
|
702
|
+
path: String(o),
|
|
703
|
+
label: p,
|
|
704
704
|
value: typeof u.text == "string" ? u.text : "",
|
|
705
705
|
role: S,
|
|
706
706
|
type: S,
|
|
707
707
|
enabled: u.enabled !== !1,
|
|
708
708
|
focused: u.focused === !0,
|
|
709
|
-
frame:
|
|
710
|
-
selectors:
|
|
709
|
+
frame: D,
|
|
710
|
+
selectors: Cr(u),
|
|
711
711
|
raw: { ...u }
|
|
712
712
|
});
|
|
713
713
|
}
|
|
714
714
|
return {
|
|
715
715
|
platform: "android",
|
|
716
716
|
screen: { width: e.width, height: e.height },
|
|
717
|
-
elements:
|
|
717
|
+
elements: r,
|
|
718
718
|
capturedAt: Date.now()
|
|
719
719
|
};
|
|
720
720
|
}
|
|
721
|
-
function
|
|
722
|
-
const
|
|
723
|
-
return i > 0 && E > 0 ? { x:
|
|
721
|
+
function cn(t, e) {
|
|
722
|
+
const r = Math.max(0, t.x), o = Math.max(0, t.y), u = Math.min(e.width, t.x + t.width), l = Math.min(e.height, t.y + t.height), i = Math.max(0, u - r), E = Math.max(0, l - o);
|
|
723
|
+
return i > 0 && E > 0 ? { x: r, y: o, width: i, height: E } : null;
|
|
724
724
|
}
|
|
725
|
-
function
|
|
725
|
+
function Dr(t, e) {
|
|
726
726
|
if (t === e) return !0;
|
|
727
727
|
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;
|
|
728
|
-
const
|
|
729
|
-
return
|
|
728
|
+
const r = t.frame, o = e.frame;
|
|
729
|
+
return r.x === o.x && r.y === o.y && r.width === o.width && r.height === o.height;
|
|
730
730
|
}
|
|
731
|
-
function
|
|
731
|
+
function _r(t, e) {
|
|
732
732
|
if (t === e) return !0;
|
|
733
733
|
if (!t || !e || t.platform !== e.platform || t.screen.width !== e.screen.width || t.screen.height !== e.screen.height || t.elements.length !== e.elements.length) return !1;
|
|
734
|
-
for (let
|
|
735
|
-
if (!
|
|
734
|
+
for (let r = 0; r < t.elements.length; r++)
|
|
735
|
+
if (!Dr(t.elements[r], e.elements[r])) return !1;
|
|
736
736
|
return !0;
|
|
737
737
|
}
|
|
738
|
-
function
|
|
739
|
-
let
|
|
738
|
+
function ln(t, e, r) {
|
|
739
|
+
let o = null, u = 1 / 0;
|
|
740
740
|
for (const l of t.elements) {
|
|
741
741
|
const i = l.frame;
|
|
742
|
-
if (e < i.x ||
|
|
743
|
-
const E =
|
|
744
|
-
E < u && (u = E,
|
|
742
|
+
if (e < i.x || r < i.y || e > i.x + i.width || r > i.y + i.height) continue;
|
|
743
|
+
const E = ur(i);
|
|
744
|
+
E < u && (u = E, o = l);
|
|
745
745
|
}
|
|
746
|
-
return
|
|
746
|
+
return o;
|
|
747
747
|
}
|
|
748
|
-
function
|
|
748
|
+
function dn(t, e) {
|
|
749
749
|
if (e === "ios") {
|
|
750
750
|
if (t.selectors.AXUniqueId)
|
|
751
751
|
return `client.tapElement({ AXUniqueId: ${JSON.stringify(t.selectors.AXUniqueId)} })`;
|
|
752
752
|
if (t.selectors.AXLabel) {
|
|
753
|
-
const
|
|
754
|
-
return `client.tapElement({ AXLabel: ${JSON.stringify(t.selectors.AXLabel)}${
|
|
753
|
+
const r = t.selectors.className ? `, type: ${JSON.stringify(t.selectors.className)}` : "";
|
|
754
|
+
return `client.tapElement({ AXLabel: ${JSON.stringify(t.selectors.AXLabel)}${r} })`;
|
|
755
755
|
}
|
|
756
756
|
return null;
|
|
757
757
|
}
|
|
758
758
|
return t.selectors.resourceId ? `client.tap({ selector: { resourceId: ${JSON.stringify(t.selectors.resourceId)} } })` : t.selectors.contentDesc ? `client.tap({ selector: { contentDesc: ${JSON.stringify(t.selectors.contentDesc)} } })` : t.selectors.text ? `client.tap({ selector: { text: ${JSON.stringify(t.selectors.text)} } })` : null;
|
|
759
759
|
}
|
|
760
|
-
function
|
|
760
|
+
function gr(t) {
|
|
761
761
|
const e = t.role || t.type || "";
|
|
762
762
|
if (!e) return "element";
|
|
763
|
-
let
|
|
764
|
-
return
|
|
763
|
+
let r = e.replace(/^AX/, "");
|
|
764
|
+
return r.includes(".") && (r = r.split(".").pop()), r === "GenericElement" ? "Element" : (r = r.replace(/([a-z])([A-Z])/g, "$1 $2"), r);
|
|
765
765
|
}
|
|
766
|
-
const
|
|
767
|
-
function
|
|
768
|
-
const e =
|
|
769
|
-
if (!
|
|
770
|
-
const
|
|
771
|
-
return `${e} · ${
|
|
766
|
+
const Nt = 80;
|
|
767
|
+
function un(t) {
|
|
768
|
+
const e = gr(t), r = t.label || t.value || "";
|
|
769
|
+
if (!r) return e;
|
|
770
|
+
const o = r.length > Nt ? r.slice(0, Nt).trimEnd() + "…" : r;
|
|
771
|
+
return `${e} · ${o}`;
|
|
772
772
|
}
|
|
773
|
-
const
|
|
774
|
-
class
|
|
773
|
+
const Tr = 500, yr = 2e3, bt = 5e3, Sr = 8e3, Kr = 1200, Ar = 250, vr = () => `ax-rc-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
774
|
+
class Mr {
|
|
775
775
|
platform;
|
|
776
776
|
send;
|
|
777
777
|
onSnapshot;
|
|
@@ -798,7 +798,7 @@ class Dn {
|
|
|
798
798
|
// identical-to-current transitions are no-ops.
|
|
799
799
|
status = "idle";
|
|
800
800
|
constructor(e) {
|
|
801
|
-
this.platform = e.platform, this.send = e.send, this.onSnapshot = e.onSnapshot, this.onStatusChange = e.onStatusChange, this.baseIntervalMs = e.baseIntervalMs ??
|
|
801
|
+
this.platform = e.platform, this.send = e.send, this.onSnapshot = e.onSnapshot, this.onStatusChange = e.onStatusChange, this.baseIntervalMs = e.baseIntervalMs ?? Tr, this.maxBackoffMs = e.maxBackoffMs ?? yr, this.androidElementTreeOptions = e.androidElementTreeOptions, this.currentInterval = this.baseIntervalMs;
|
|
802
802
|
}
|
|
803
803
|
start() {
|
|
804
804
|
this.running || (this.running = !0, this.currentInterval = this.baseIntervalMs, this.boostUntilMs = 0, this.setStatus("starting"), this.runOnce());
|
|
@@ -809,12 +809,12 @@ class Dn {
|
|
|
809
809
|
getStatus() {
|
|
810
810
|
return this.status;
|
|
811
811
|
}
|
|
812
|
-
setStatus(e,
|
|
812
|
+
setStatus(e, r) {
|
|
813
813
|
if (this.status !== e && (this.status = e, !!this.onStatusChange))
|
|
814
814
|
try {
|
|
815
|
-
this.onStatusChange(e,
|
|
816
|
-
} catch (
|
|
817
|
-
console.error("[AxFetcher] onStatusChange threw:",
|
|
815
|
+
this.onStatusChange(e, r);
|
|
816
|
+
} catch (o) {
|
|
817
|
+
console.error("[AxFetcher] onStatusChange threw:", o);
|
|
818
818
|
}
|
|
819
819
|
}
|
|
820
820
|
// Called after any user-driven action that's likely to change the UI
|
|
@@ -830,9 +830,9 @@ class Dn {
|
|
|
830
830
|
bumpActivity() {
|
|
831
831
|
if (!this.running) return;
|
|
832
832
|
const e = Date.now();
|
|
833
|
-
this.boostUntilMs = e +
|
|
834
|
-
const
|
|
835
|
-
if (e - this.lastBumpAtMs <
|
|
833
|
+
this.boostUntilMs = e + Kr;
|
|
834
|
+
const r = Math.max(150, Math.floor(this.baseIntervalMs / 2));
|
|
835
|
+
if (e - this.lastBumpAtMs < r) {
|
|
836
836
|
this.currentInterval = this.baseIntervalMs;
|
|
837
837
|
return;
|
|
838
838
|
}
|
|
@@ -858,19 +858,19 @@ class Dn {
|
|
|
858
858
|
// Returns true when the message was a response we were waiting for.
|
|
859
859
|
handleMessage(e) {
|
|
860
860
|
if (!e || typeof e.id != "string") return !1;
|
|
861
|
-
const
|
|
862
|
-
if (!this.pending.get(
|
|
861
|
+
const r = e.id;
|
|
862
|
+
if (!this.pending.get(r)) return !1;
|
|
863
863
|
if (this.platform === "ios") {
|
|
864
864
|
if (e.type !== "elementTreeResult") return !1;
|
|
865
865
|
const E = typeof e.error == "string" ? e.error : null;
|
|
866
866
|
if (E)
|
|
867
|
-
return this.settleReject(
|
|
868
|
-
const
|
|
867
|
+
return this.settleReject(r, new Error(E)), !0;
|
|
868
|
+
const D = typeof e.json == "string" ? e.json : "";
|
|
869
869
|
try {
|
|
870
|
-
const
|
|
871
|
-
this.settleResolve(
|
|
872
|
-
} catch (
|
|
873
|
-
this.settleReject(
|
|
870
|
+
const p = JSON.parse(D), S = pr(p);
|
|
871
|
+
this.settleResolve(r, S);
|
|
872
|
+
} catch (p) {
|
|
873
|
+
this.settleReject(r, p instanceof Error ? p : new Error(String(p)));
|
|
874
874
|
}
|
|
875
875
|
return !0;
|
|
876
876
|
}
|
|
@@ -878,14 +878,14 @@ class Dn {
|
|
|
878
878
|
const u = e.error;
|
|
879
879
|
if (u && typeof u == "object") {
|
|
880
880
|
const E = typeof u.message == "string" ? u.message : "getElementTree failed";
|
|
881
|
-
return this.settleReject(
|
|
881
|
+
return this.settleReject(r, new Error(E)), !0;
|
|
882
882
|
}
|
|
883
883
|
const l = e.payload, i = Array.isArray(l?.nodes) ? l.nodes : [];
|
|
884
884
|
try {
|
|
885
|
-
const E =
|
|
886
|
-
this.settleResolve(
|
|
885
|
+
const E = Or(i);
|
|
886
|
+
this.settleResolve(r, E);
|
|
887
887
|
} catch (E) {
|
|
888
|
-
this.settleReject(
|
|
888
|
+
this.settleReject(r, E instanceof Error ? E : new Error(String(E)));
|
|
889
889
|
}
|
|
890
890
|
return !0;
|
|
891
891
|
}
|
|
@@ -893,15 +893,15 @@ class Dn {
|
|
|
893
893
|
return this.platform === "ios" ? { type: "elementTree", id: e } : { type: "getElementTree", id: e, ...this.androidElementTreeOptions };
|
|
894
894
|
}
|
|
895
895
|
async requestOnce() {
|
|
896
|
-
const e =
|
|
897
|
-
return new Promise((
|
|
896
|
+
const e = vr();
|
|
897
|
+
return new Promise((r, o) => {
|
|
898
898
|
const u = window.setTimeout(
|
|
899
899
|
() => {
|
|
900
|
-
this.pending.delete(e),
|
|
900
|
+
this.pending.delete(e), o(new Error("elementTree request timed out"));
|
|
901
901
|
},
|
|
902
|
-
|
|
902
|
+
Sr + (this.androidElementTreeOptions?.waitForIdleTimeoutMs ?? 0)
|
|
903
903
|
);
|
|
904
|
-
this.pending.set(e, { resolve:
|
|
904
|
+
this.pending.set(e, { resolve: r, reject: o, timer: u }), this.send(this.buildRequest(e)) || (window.clearTimeout(u), this.pending.delete(e), o(new Error("elementTree send failed (WebSocket not open)")));
|
|
905
905
|
});
|
|
906
906
|
}
|
|
907
907
|
async runOnce() {
|
|
@@ -913,197 +913,197 @@ class Dn {
|
|
|
913
913
|
this.deliver(e);
|
|
914
914
|
} catch (e) {
|
|
915
915
|
if (!this.running) return;
|
|
916
|
-
const
|
|
917
|
-
this.currentInterval =
|
|
916
|
+
const r = e instanceof Error ? e.message : String(e), o = /unavailable|not (yet )?running|failed|timeout/i.test(r);
|
|
917
|
+
this.currentInterval = o ? bt : Math.min(this.currentInterval * 2, this.maxBackoffMs), this.setStatus(o ? "unavailable" : "error", r);
|
|
918
918
|
} finally {
|
|
919
919
|
this.inflight = !1, this.scheduleNext();
|
|
920
920
|
}
|
|
921
921
|
}
|
|
922
922
|
}
|
|
923
923
|
deliver(e) {
|
|
924
|
-
const
|
|
925
|
-
if (
|
|
926
|
-
this.currentInterval = Math.min(this.currentInterval * 2, this.maxBackoffMs), this.lastSnapshot = e, e.errors?.includes(
|
|
924
|
+
const r = this.lastSnapshot;
|
|
925
|
+
if (_r(r, e)) {
|
|
926
|
+
this.currentInterval = Math.min(this.currentInterval * 2, this.maxBackoffMs), this.lastSnapshot = e, e.errors?.includes(dt) || this.setStatus("ready");
|
|
927
927
|
return;
|
|
928
928
|
}
|
|
929
|
-
this.lastSnapshot = e, this.currentInterval = this.baseIntervalMs, e.errors?.includes(
|
|
929
|
+
this.lastSnapshot = e, this.currentInterval = this.baseIntervalMs, e.errors?.includes(dt) ? (this.currentInterval = bt, this.setStatus("unavailable", dt)) : this.setStatus("ready"), this.onSnapshot(e);
|
|
930
930
|
}
|
|
931
931
|
scheduleNext() {
|
|
932
932
|
if (!this.running) return;
|
|
933
933
|
this.timer !== void 0 && window.clearTimeout(this.timer);
|
|
934
|
-
const e = Date.now() < this.boostUntilMs ? Math.min(
|
|
934
|
+
const e = Date.now() < this.boostUntilMs ? Math.min(Ar, this.currentInterval) : this.currentInterval;
|
|
935
935
|
this.timer = window.setTimeout(() => {
|
|
936
936
|
this.timer = void 0, this.runOnce();
|
|
937
937
|
}, e);
|
|
938
938
|
}
|
|
939
|
-
settleResolve(e,
|
|
940
|
-
const
|
|
941
|
-
|
|
939
|
+
settleResolve(e, r) {
|
|
940
|
+
const o = this.pending.get(e);
|
|
941
|
+
o && (window.clearTimeout(o.timer), this.pending.delete(e), o.resolve(r));
|
|
942
942
|
}
|
|
943
|
-
settleReject(e,
|
|
944
|
-
const
|
|
945
|
-
|
|
943
|
+
settleReject(e, r) {
|
|
944
|
+
const o = this.pending.get(e);
|
|
945
|
+
o && (window.clearTimeout(o.timer), this.pending.delete(e), o.reject(r));
|
|
946
946
|
}
|
|
947
947
|
failAllPending(e) {
|
|
948
|
-
for (const [
|
|
949
|
-
window.clearTimeout(
|
|
948
|
+
for (const [r, o] of this.pending.entries())
|
|
949
|
+
window.clearTimeout(o.timer), o.reject(new Error(e)), this.pending.delete(r);
|
|
950
950
|
}
|
|
951
951
|
}
|
|
952
|
-
function
|
|
952
|
+
function Yt(t, e) {
|
|
953
953
|
if (e != null && (!Number.isFinite(e) || e < 0 || e > 4e3)) {
|
|
954
954
|
console.warn("RemoteControl: jitterBufferTargetMs must be a finite number between 0 and 4000.");
|
|
955
955
|
return;
|
|
956
956
|
}
|
|
957
957
|
if (!("jitterBufferTarget" in t)) return;
|
|
958
|
-
const
|
|
958
|
+
const r = e ?? null;
|
|
959
959
|
try {
|
|
960
|
-
t.jitterBufferTarget !==
|
|
961
|
-
} catch (
|
|
962
|
-
console.warn("RemoteControl: could not set the jitter buffer target.",
|
|
960
|
+
t.jitterBufferTarget !== r && (t.jitterBufferTarget = r);
|
|
961
|
+
} catch (o) {
|
|
962
|
+
console.warn("RemoteControl: could not set the jitter buffer target.", o);
|
|
963
963
|
}
|
|
964
964
|
}
|
|
965
|
-
const
|
|
966
|
-
`,
|
|
967
|
-
function
|
|
965
|
+
const Lt = `(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())}})();
|
|
966
|
+
`, It = typeof self < "u" && self.Blob && new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);", Lt], { type: "text/javascript;charset=utf-8" });
|
|
967
|
+
function wr(t) {
|
|
968
968
|
let e;
|
|
969
969
|
try {
|
|
970
|
-
if (e =
|
|
971
|
-
const
|
|
970
|
+
if (e = It && (self.URL || self.webkitURL).createObjectURL(It), !e) throw "";
|
|
971
|
+
const r = new Worker(e, {
|
|
972
972
|
name: t?.name
|
|
973
973
|
});
|
|
974
|
-
return
|
|
974
|
+
return r.addEventListener("error", () => {
|
|
975
975
|
(self.URL || self.webkitURL).revokeObjectURL(e);
|
|
976
|
-
}),
|
|
976
|
+
}), r;
|
|
977
977
|
} catch {
|
|
978
978
|
return new Worker(
|
|
979
|
-
"data:text/javascript;charset=utf-8," + encodeURIComponent(
|
|
979
|
+
"data:text/javascript;charset=utf-8," + encodeURIComponent(Lt),
|
|
980
980
|
{
|
|
981
981
|
name: t?.name
|
|
982
982
|
}
|
|
983
983
|
);
|
|
984
984
|
}
|
|
985
985
|
}
|
|
986
|
-
function
|
|
987
|
-
const { MediaStreamTrackProcessor:
|
|
988
|
-
let i, E,
|
|
986
|
+
function Nr(t, e, r) {
|
|
987
|
+
const { MediaStreamTrackProcessor: o, MediaStreamTrackGenerator: u } = globalThis, l = e.getVideoTracks()[0];
|
|
988
|
+
let i, E, D, p, S = !1;
|
|
989
989
|
const w = () => {
|
|
990
|
-
S || (S = !0, i?.stop(), E?.stop(),
|
|
991
|
-
}, N = (
|
|
992
|
-
t.srcObject =
|
|
990
|
+
S || (S = !0, i?.stop(), E?.stop(), D && (D.postMessage({ type: "stop" }), p = setTimeout(() => D?.terminate(), 1e3)));
|
|
991
|
+
}, N = (_) => {
|
|
992
|
+
t.srcObject = _, t.play().catch(() => {
|
|
993
993
|
});
|
|
994
|
-
},
|
|
995
|
-
S || (w(),
|
|
994
|
+
}, V = (_) => {
|
|
995
|
+
S || (w(), r(_), N(e));
|
|
996
996
|
};
|
|
997
997
|
try {
|
|
998
|
-
if (l &&
|
|
998
|
+
if (l && o && u) {
|
|
999
999
|
i = l.clone();
|
|
1000
|
-
const
|
|
1001
|
-
E = H,
|
|
1002
|
-
L.type === "error" ?
|
|
1003
|
-
},
|
|
1004
|
-
|
|
1000
|
+
const _ = new o({ track: i, maxBufferSize: 1 }), H = new u({ kind: "video" });
|
|
1001
|
+
E = H, D = new wr(), D.onmessage = ({ data: L }) => {
|
|
1002
|
+
L.type === "error" ? V(new Error(L.message)) : L.type === "stopped" && (clearTimeout(p), D?.terminate());
|
|
1003
|
+
}, D.onerror = (L) => V(new Error(L.message)), D.postMessage({ type: "start", readable: _.readable, writable: H.writable }, [
|
|
1004
|
+
_.readable,
|
|
1005
1005
|
H.writable
|
|
1006
1006
|
]), N(new MediaStream(e.getTracks().map((L) => L === l ? H : L)));
|
|
1007
1007
|
} else
|
|
1008
1008
|
N(e);
|
|
1009
|
-
} catch (
|
|
1010
|
-
|
|
1009
|
+
} catch (_) {
|
|
1010
|
+
V(_);
|
|
1011
1011
|
}
|
|
1012
1012
|
return w;
|
|
1013
1013
|
}
|
|
1014
|
-
function
|
|
1014
|
+
function Pe(t) {
|
|
1015
1015
|
return typeof t == "number" && Number.isFinite(t);
|
|
1016
1016
|
}
|
|
1017
|
-
function
|
|
1018
|
-
if (!(!
|
|
1017
|
+
function Se(t, e) {
|
|
1018
|
+
if (!(!Pe(t) || !Pe(e) || t < e || e < 0))
|
|
1019
1019
|
return t - e;
|
|
1020
1020
|
}
|
|
1021
|
-
class
|
|
1021
|
+
class br {
|
|
1022
1022
|
previous = /* @__PURE__ */ new Map();
|
|
1023
1023
|
reset() {
|
|
1024
1024
|
this.previous.clear();
|
|
1025
1025
|
}
|
|
1026
|
-
read(e,
|
|
1026
|
+
read(e, r, o) {
|
|
1027
1027
|
const u = { timestamp: 0, video: [], audio: [] };
|
|
1028
|
-
|
|
1028
|
+
o == null ? u.requestedTargetMs = null : Pe(o) && o >= 0 && o <= 4e3 && (u.requestedTargetMs = o);
|
|
1029
1029
|
const l = /* @__PURE__ */ new Map();
|
|
1030
1030
|
return e.forEach((i) => {
|
|
1031
|
-
if (i.type !== "inbound-rtp" || !
|
|
1031
|
+
if (i.type !== "inbound-rtp" || !Pe(i.timestamp)) return;
|
|
1032
1032
|
const E = i.kind ?? i.mediaType;
|
|
1033
1033
|
if (E !== "video" && E !== "audio") return;
|
|
1034
|
-
const
|
|
1035
|
-
if (!
|
|
1036
|
-
const S = this.previous.get(i.id), N = S?.trackId ===
|
|
1034
|
+
const D = r.filter((P) => P.kind === E), p = i.trackIdentifier ? D.find((P) => P.trackId === i.trackIdentifier) : i.mid != null ? D.find((P) => P.mid === i.mid) : D.length === 1 ? D[0] : void 0;
|
|
1035
|
+
if (!p) return;
|
|
1036
|
+
const S = this.previous.get(i.id), N = S?.trackId === p.trackId && S.stats.ssrc === i.ssrc ? S.stats : void 0, V = N ? i.timestamp - N.timestamp : void 0, _ = {
|
|
1037
1037
|
id: i.id,
|
|
1038
|
-
trackId:
|
|
1038
|
+
trackId: p.trackId,
|
|
1039
1039
|
timestamp: i.timestamp
|
|
1040
1040
|
};
|
|
1041
|
-
if (
|
|
1042
|
-
|
|
1043
|
-
const P =
|
|
1044
|
-
P !== void 0 && P > 0 && B !== void 0 && (
|
|
1045
|
-
const
|
|
1046
|
-
|
|
1041
|
+
if (V !== void 0 && V > 0) {
|
|
1042
|
+
_.intervalMs = V;
|
|
1043
|
+
const P = Se(i.jitterBufferEmittedCount, N?.jitterBufferEmittedCount), B = Se(i.jitterBufferDelay, N?.jitterBufferDelay);
|
|
1044
|
+
P !== void 0 && P > 0 && B !== void 0 && (_.bufferDelayMs = B / P * 1e3);
|
|
1045
|
+
const x = Se(i.bytesReceived, N?.bytesReceived);
|
|
1046
|
+
x !== void 0 && (_.bitrateBps = x * 8e3 / V);
|
|
1047
1047
|
}
|
|
1048
1048
|
if (E === "video") {
|
|
1049
|
-
const P = { ...
|
|
1050
|
-
if (
|
|
1051
|
-
const B =
|
|
1052
|
-
B !== void 0 && (P.fps = B * 1e3 /
|
|
1049
|
+
const P = { ..._, display: p.display ?? "primary" };
|
|
1050
|
+
if (_.intervalMs !== void 0) {
|
|
1051
|
+
const B = Se(i.framesDecoded, N?.framesDecoded);
|
|
1052
|
+
B !== void 0 && (P.fps = B * 1e3 / _.intervalMs), P.droppedFrames = Se(i.framesDropped, N?.framesDropped), P.freezes = Se(i.freezeCount, N?.freezeCount);
|
|
1053
1053
|
}
|
|
1054
1054
|
u.video.push(P);
|
|
1055
|
-
} else u.audio.push(
|
|
1055
|
+
} else u.audio.push(_);
|
|
1056
1056
|
u.timestamp = Math.max(u.timestamp, i.timestamp), l.set(
|
|
1057
1057
|
i.id,
|
|
1058
|
-
N && i.timestamp <= N.timestamp ? S : { stats: i, trackId:
|
|
1058
|
+
N && i.timestamp <= N.timestamp ? S : { stats: i, trackId: p.trackId }
|
|
1059
1059
|
);
|
|
1060
1060
|
const H = i.transportId ? e.get(i.transportId) : void 0, L = H?.selectedCandidatePairId ? e.get(H.selectedCandidatePairId) : void 0;
|
|
1061
|
-
L?.state === "succeeded" &&
|
|
1061
|
+
L?.state === "succeeded" && Pe(L.currentRoundTripTime) && L.currentRoundTripTime >= 0 && (u.rttMs = L.currentRoundTripTime * 1e3);
|
|
1062
1062
|
}), this.previous = l, u.video.length || u.audio.length ? u : null;
|
|
1063
1063
|
}
|
|
1064
1064
|
}
|
|
1065
|
-
const
|
|
1066
|
-
function
|
|
1067
|
-
const { peer:
|
|
1068
|
-
let i, E = !1,
|
|
1069
|
-
const
|
|
1065
|
+
const ut = /* @__PURE__ */ new WeakSet();
|
|
1066
|
+
function Yr(t, e, r) {
|
|
1067
|
+
const { peer: o, displays: u } = t, l = new br();
|
|
1068
|
+
let i, E = !1, D = !1, p = !1, S = 0, w = !1, N = !1;
|
|
1069
|
+
const V = () => !E && !document.hidden && o.connectionState === "connected", _ = (B) => {
|
|
1070
1070
|
if (!(!B && !w)) {
|
|
1071
1071
|
w = B !== null;
|
|
1072
1072
|
try {
|
|
1073
1073
|
e()?.(B);
|
|
1074
|
-
} catch (
|
|
1075
|
-
console.error('[RemoteControl] customer callback "onPlaybackStats" threw:',
|
|
1074
|
+
} catch (x) {
|
|
1075
|
+
console.error('[RemoteControl] customer callback "onPlaybackStats" threw:', x);
|
|
1076
1076
|
}
|
|
1077
1077
|
}
|
|
1078
1078
|
}, H = () => {
|
|
1079
|
-
|
|
1079
|
+
D = !1, S++, clearTimeout(i), l.reset(), _(null);
|
|
1080
1080
|
}, L = async () => {
|
|
1081
|
-
if (
|
|
1082
|
-
if (
|
|
1081
|
+
if (p || !V()) return;
|
|
1082
|
+
if (ut.has(o)) {
|
|
1083
1083
|
i = setTimeout(() => {
|
|
1084
1084
|
L();
|
|
1085
1085
|
}, 2e3);
|
|
1086
1086
|
return;
|
|
1087
1087
|
}
|
|
1088
|
-
|
|
1088
|
+
p = !0, ut.add(o);
|
|
1089
1089
|
const B = S;
|
|
1090
1090
|
try {
|
|
1091
|
-
const
|
|
1092
|
-
if (B !== S || !
|
|
1093
|
-
const se =
|
|
1094
|
-
(
|
|
1095
|
-
).map((
|
|
1096
|
-
trackId:
|
|
1097
|
-
kind:
|
|
1098
|
-
mid:
|
|
1099
|
-
display: u.get(
|
|
1091
|
+
const x = await o.getStats();
|
|
1092
|
+
if (B !== S || !V()) return;
|
|
1093
|
+
const se = o.getTransceivers().filter(
|
|
1094
|
+
(I) => (I.currentDirection === "recvonly" || I.currentDirection === "sendrecv") && I.receiver.track.readyState !== "ended"
|
|
1095
|
+
).map((I) => ({
|
|
1096
|
+
trackId: I.receiver.track.id,
|
|
1097
|
+
kind: I.receiver.track.kind,
|
|
1098
|
+
mid: I.mid,
|
|
1099
|
+
display: u.get(I.receiver)
|
|
1100
1100
|
}));
|
|
1101
|
-
|
|
1102
|
-
} catch (
|
|
1103
|
-
if (B !== S || !
|
|
1104
|
-
N || console.warn("[RemoteControl] could not read playback stats:",
|
|
1101
|
+
_(l.read(x, se, r())), N = !1;
|
|
1102
|
+
} catch (x) {
|
|
1103
|
+
if (B !== S || !V()) return;
|
|
1104
|
+
N || console.warn("[RemoteControl] could not read playback stats:", x), N = !0, l.reset(), _(null);
|
|
1105
1105
|
} finally {
|
|
1106
|
-
|
|
1106
|
+
p = !1, ut.delete(o), D && V() && (i = setTimeout(
|
|
1107
1107
|
() => {
|
|
1108
1108
|
L();
|
|
1109
1109
|
},
|
|
@@ -1111,60 +1111,60 @@ function yn(t, e, n) {
|
|
|
1111
1111
|
));
|
|
1112
1112
|
}
|
|
1113
1113
|
}, P = () => {
|
|
1114
|
-
if (!
|
|
1114
|
+
if (!V()) {
|
|
1115
1115
|
H();
|
|
1116
1116
|
return;
|
|
1117
1117
|
}
|
|
1118
|
-
|
|
1118
|
+
D || (D = !0, L());
|
|
1119
1119
|
};
|
|
1120
|
-
return document.addEventListener("visibilitychange", P),
|
|
1121
|
-
E = !0, document.removeEventListener("visibilitychange", P),
|
|
1120
|
+
return document.addEventListener("visibilitychange", P), o.addEventListener("connectionstatechange", P), P(), () => {
|
|
1121
|
+
E = !0, document.removeEventListener("visibilitychange", P), o.removeEventListener("connectionstatechange", P), H();
|
|
1122
1122
|
};
|
|
1123
1123
|
}
|
|
1124
|
-
function
|
|
1125
|
-
const
|
|
1124
|
+
function Ir(t, e) {
|
|
1125
|
+
const r = t.createDataChannel("latency-trace-v1", {
|
|
1126
1126
|
ordered: !0,
|
|
1127
1127
|
negotiated: !0,
|
|
1128
1128
|
id: 2
|
|
1129
1129
|
});
|
|
1130
|
-
let
|
|
1131
|
-
return
|
|
1130
|
+
let o = !1, u = !1, l = 0;
|
|
1131
|
+
return r.onmessage = (i) => {
|
|
1132
1132
|
if (u) return;
|
|
1133
1133
|
let E;
|
|
1134
1134
|
try {
|
|
1135
1135
|
E = JSON.parse(i.data);
|
|
1136
|
-
} catch (
|
|
1137
|
-
console.warn("Invalid latency trace message",
|
|
1136
|
+
} catch (D) {
|
|
1137
|
+
console.warn("Invalid latency trace message", D);
|
|
1138
1138
|
return;
|
|
1139
1139
|
}
|
|
1140
1140
|
E && typeof E == "object" && !Array.isArray(E) && e(E);
|
|
1141
|
-
},
|
|
1142
|
-
u = !0,
|
|
1141
|
+
}, r.onclose = () => {
|
|
1142
|
+
u = !0, o = !1;
|
|
1143
1143
|
}, {
|
|
1144
1144
|
accept(i) {
|
|
1145
|
-
|
|
1145
|
+
o = !u && i === 1;
|
|
1146
1146
|
},
|
|
1147
1147
|
wrap(i) {
|
|
1148
|
-
if (!
|
|
1149
|
-
const E = new DataView(i),
|
|
1150
|
-
if (!
|
|
1148
|
+
if (!o || i.byteLength === 0) return i;
|
|
1149
|
+
const E = new DataView(i), D = E.getUint8(0), p = D === ee.INJECT_MOUSE_EVENT || D === ee.INJECT_MAC_KEY || D === ee.INJECT_MAC_SCROLL, S = i.byteLength === 32 && D === ee.INJECT_TOUCH_EVENT && E.getUint8(1) <= 2;
|
|
1150
|
+
if (!p && !S) return i;
|
|
1151
1151
|
const w = new ArrayBuffer(6 + i.byteLength), N = new DataView(w);
|
|
1152
1152
|
return N.setUint8(0, 240), N.setUint8(1, 1), N.setUint32(2, ++l, !0), new Uint8Array(w, 6).set(new Uint8Array(i)), w;
|
|
1153
1153
|
},
|
|
1154
1154
|
close() {
|
|
1155
|
-
u = !0,
|
|
1155
|
+
u = !0, o = !1, r.onmessage = null, r.onclose = null, r.close();
|
|
1156
1156
|
}
|
|
1157
1157
|
};
|
|
1158
1158
|
}
|
|
1159
|
-
class
|
|
1159
|
+
class Rr {
|
|
1160
1160
|
generation = 0;
|
|
1161
1161
|
tail = Promise.resolve();
|
|
1162
1162
|
get currentGeneration() {
|
|
1163
1163
|
return this.generation;
|
|
1164
1164
|
}
|
|
1165
1165
|
enqueue(e) {
|
|
1166
|
-
const
|
|
1167
|
-
return this.append(
|
|
1166
|
+
const r = ++this.generation;
|
|
1167
|
+
return this.append(r, e);
|
|
1168
1168
|
}
|
|
1169
1169
|
/**
|
|
1170
1170
|
* Queues related work without superseding an already queued request.
|
|
@@ -1175,11 +1175,11 @@ class Kn {
|
|
|
1175
1175
|
enqueueCurrent(e) {
|
|
1176
1176
|
return this.append(this.generation, e);
|
|
1177
1177
|
}
|
|
1178
|
-
append(e,
|
|
1179
|
-
const
|
|
1178
|
+
append(e, r) {
|
|
1179
|
+
const o = {
|
|
1180
1180
|
generation: e,
|
|
1181
1181
|
isCurrent: () => e === this.generation
|
|
1182
|
-
}, u = this.tail.then(() =>
|
|
1182
|
+
}, u = this.tail.then(() => r(o));
|
|
1183
1183
|
return this.tail = u.catch(() => {
|
|
1184
1184
|
}), u;
|
|
1185
1185
|
}
|
|
@@ -1187,23 +1187,23 @@ class Kn {
|
|
|
1187
1187
|
++this.generation;
|
|
1188
1188
|
}
|
|
1189
1189
|
}
|
|
1190
|
-
function
|
|
1190
|
+
function kr(t) {
|
|
1191
1191
|
if (!t || typeof t != "object") return null;
|
|
1192
1192
|
const e = t;
|
|
1193
1193
|
if (e.type !== "cameraRequest" || typeof e.active != "boolean") return null;
|
|
1194
|
-
const
|
|
1195
|
-
return (e.facingMode === "user" || e.facingMode === "environment") && (
|
|
1194
|
+
const r = { active: e.active };
|
|
1195
|
+
return (e.facingMode === "user" || e.facingMode === "environment") && (r.facingMode = e.facingMode), r;
|
|
1196
1196
|
}
|
|
1197
|
-
function
|
|
1197
|
+
function Ur(t) {
|
|
1198
1198
|
const e = {
|
|
1199
1199
|
frameRate: { ideal: 30, max: 30 }
|
|
1200
1200
|
};
|
|
1201
1201
|
return t?.facingMode && (e.facingMode = { ideal: t.facingMode }), e;
|
|
1202
1202
|
}
|
|
1203
|
-
function
|
|
1203
|
+
function Pr(t, e) {
|
|
1204
1204
|
return !t || t.facingMode !== e.facingMode;
|
|
1205
1205
|
}
|
|
1206
|
-
function
|
|
1206
|
+
function Lr(t) {
|
|
1207
1207
|
const e = t.getSettings();
|
|
1208
1208
|
return {
|
|
1209
1209
|
width: e.width,
|
|
@@ -1214,78 +1214,110 @@ function wn(t) {
|
|
|
1214
1214
|
facingMode: e.facingMode
|
|
1215
1215
|
};
|
|
1216
1216
|
}
|
|
1217
|
-
function
|
|
1217
|
+
function Fr(t) {
|
|
1218
1218
|
return {
|
|
1219
1219
|
type: "cameraResult",
|
|
1220
1220
|
granted: !0,
|
|
1221
|
-
camera:
|
|
1221
|
+
camera: Lr(t)
|
|
1222
1222
|
};
|
|
1223
1223
|
}
|
|
1224
1224
|
const le = (...t) => {
|
|
1225
1225
|
window.debugRemoteControl && console.log(...t);
|
|
1226
1226
|
}, y = (...t) => {
|
|
1227
1227
|
window.debugRemoteControl && console.warn(...t);
|
|
1228
|
-
},
|
|
1228
|
+
}, Rt = ["click", "keydown"], et = /* @__PURE__ */ new WeakMap(), Br = (t) => {
|
|
1229
|
+
et.get(t)?.();
|
|
1230
|
+
}, Ft = (t, e) => {
|
|
1231
|
+
if (et.has(t)) {
|
|
1232
|
+
Promise.resolve(t.play()).catch(() => {
|
|
1233
|
+
});
|
|
1234
|
+
return;
|
|
1235
|
+
}
|
|
1236
|
+
Promise.resolve(t.play()).catch((r) => {
|
|
1237
|
+
if (r?.name !== "NotAllowedError" || t.muted) return;
|
|
1238
|
+
t.muted = !0, Promise.resolve(t.play()).catch(() => {
|
|
1239
|
+
});
|
|
1240
|
+
const o = t.ownerDocument, u = () => {
|
|
1241
|
+
l(), t.muted = !1, Ft(t, e);
|
|
1242
|
+
}, l = () => {
|
|
1243
|
+
for (const i of Rt) o.removeEventListener(i, u, !0);
|
|
1244
|
+
et.delete(t);
|
|
1245
|
+
};
|
|
1246
|
+
for (const i of Rt) o.addEventListener(i, u, !0);
|
|
1247
|
+
et.set(t, l), e();
|
|
1248
|
+
});
|
|
1249
|
+
}, F = (t, e, ...r) => {
|
|
1229
1250
|
if (e)
|
|
1230
1251
|
try {
|
|
1231
|
-
e(...
|
|
1232
|
-
} catch (
|
|
1233
|
-
console.error(`[RemoteControl] customer callback "${t}" threw:`,
|
|
1252
|
+
e(...r);
|
|
1253
|
+
} catch (o) {
|
|
1254
|
+
console.error(`[RemoteControl] customer callback "${t}" threw:`, o);
|
|
1234
1255
|
}
|
|
1235
|
-
},
|
|
1236
|
-
const
|
|
1237
|
-
return
|
|
1238
|
-
},
|
|
1239
|
-
function
|
|
1256
|
+
}, xr = (t) => t.includes("/android_") ? "android" : t.includes("/macos_") ? "macos" : "ios", kt = (t, e) => {
|
|
1257
|
+
const r = new URL(t);
|
|
1258
|
+
return r.searchParams.set("token", e), r.toString();
|
|
1259
|
+
}, ft = 3, Wr = 1e3, qr = 15e3, Vr = 3e3, $r = 4e3;
|
|
1260
|
+
function Ut() {
|
|
1240
1261
|
const t = crypto.getRandomValues(new Uint8Array(16));
|
|
1241
1262
|
t[6] = t[6] & 15 | 64, t[8] = t[8] & 63 | 128;
|
|
1242
|
-
const e = Array.from(t, (
|
|
1263
|
+
const e = Array.from(t, (r) => r.toString(16).padStart(2, "0")).join("");
|
|
1243
1264
|
return `${e.slice(0, 8)}-${e.slice(8, 12)}-${e.slice(12, 16)}-${e.slice(16, 20)}-${e.slice(20)}`;
|
|
1244
1265
|
}
|
|
1245
|
-
function
|
|
1266
|
+
function fn(t) {
|
|
1246
1267
|
let e = { ...t };
|
|
1247
|
-
const { url:
|
|
1268
|
+
const { url: r, deviceModel: o } = e;
|
|
1248
1269
|
let u = e.token;
|
|
1249
|
-
const l = e.watchOnly ?? !1, i = e.sessionId ??
|
|
1250
|
-
let
|
|
1270
|
+
const l = e.watchOnly ?? !1, i = e.sessionId ?? Ut(), E = e.platform ?? xr(r ?? "");
|
|
1271
|
+
let D = {
|
|
1251
1272
|
connection: "idle",
|
|
1252
1273
|
videoReady: !1,
|
|
1253
1274
|
controlReady: !1,
|
|
1254
1275
|
duo: !1,
|
|
1255
1276
|
duoState: null
|
|
1256
1277
|
};
|
|
1257
|
-
const
|
|
1258
|
-
|
|
1259
|
-
}, S = (
|
|
1278
|
+
const p = (n) => {
|
|
1279
|
+
D = { ...D, ...n }, F("onStateChange", e.onStateChange, D);
|
|
1280
|
+
}, S = (n) => p({ videoReady: n }), w = (n) => p({ duoState: n }), N = (n) => p({ duoError: n }), V = (n) => p({ duo: n }), _ = (n) => le(n);
|
|
1260
1281
|
let H = null, L;
|
|
1261
1282
|
const P = () => {
|
|
1262
|
-
L?.(), L = H && e.onPlaybackStats ?
|
|
1283
|
+
L?.(), L = H && e.onPlaybackStats ? Yr(
|
|
1263
1284
|
H,
|
|
1264
1285
|
() => e.onPlaybackStats,
|
|
1265
1286
|
() => e.jitterBufferTargetMs
|
|
1266
1287
|
) : void 0;
|
|
1267
|
-
}, B = /* @__PURE__ */ new Map(),
|
|
1268
|
-
let
|
|
1269
|
-
const
|
|
1270
|
-
f.stop?.(), f.stop =
|
|
1271
|
-
},
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1288
|
+
}, B = /* @__PURE__ */ new Map(), x = /* @__PURE__ */ new Set(), se = /* @__PURE__ */ new Set(), I = /* @__PURE__ */ new Map();
|
|
1289
|
+
let Ee = !1;
|
|
1290
|
+
const Le = /* @__PURE__ */ new Map(), Et = (n, f, c) => {
|
|
1291
|
+
f.stop?.(), f.stop = Nr(n, c, (d) => y("Video playback fallback:", d));
|
|
1292
|
+
}, Ke = /* @__PURE__ */ new Set();
|
|
1293
|
+
let Ae = null;
|
|
1294
|
+
const ht = (n) => {
|
|
1295
|
+
n.srcObject = Ae, Ae && Ft(n, () => F("onSpeakerBlocked", e.onSpeakerBlocked));
|
|
1296
|
+
}, Bt = () => {
|
|
1297
|
+
Le.clear(), Ae = null;
|
|
1298
|
+
for (const n of Ke) n.srcObject = null;
|
|
1299
|
+
for (const [n, f] of B)
|
|
1300
|
+
f.clear?.(), f.stop?.(), f.stop = void 0, n.srcObject = null;
|
|
1301
|
+
};
|
|
1302
|
+
let he = !1, ve = !1, Fe = 0, g = null, pe = null;
|
|
1303
|
+
const pt = () => {
|
|
1304
|
+
E !== "ios" || !pe || pe !== g || pe.readyState === WebSocket.OPEN && pe.send(
|
|
1305
|
+
JSON.stringify({ type: "speakerAudio", sessionId: i, enabled: !(e.speakerMuted ?? !0) })
|
|
1306
|
+
);
|
|
1275
1307
|
};
|
|
1276
|
-
let
|
|
1277
|
-
const
|
|
1278
|
-
let
|
|
1279
|
-
const
|
|
1280
|
-
if (
|
|
1281
|
-
|
|
1282
|
-
const f = ++
|
|
1308
|
+
let R = null, W = null, Be = null, me, Me, we, xe, Ce, de = 0, We = 0, re = !1, ue = null, Q = null, fe;
|
|
1309
|
+
const tt = new Rr();
|
|
1310
|
+
let Ne = null, qe = null, rt = !l && (e.microphoneEnabled ?? !1), nt = !1, be = null, te = null, Ve = 0, mt = Promise.resolve(), Oe = null, Ye = !1, ne = /* @__PURE__ */ new Map(), Z = /* @__PURE__ */ new Map(), ce = /* @__PURE__ */ new Map(), ie = /* @__PURE__ */ new Map(), $ = null, Ie = null, Ct = 0;
|
|
1311
|
+
const $e = (n) => {
|
|
1312
|
+
if (n === null && Ie === null) return;
|
|
1313
|
+
Ie = n;
|
|
1314
|
+
const f = ++Ct;
|
|
1283
1315
|
queueMicrotask(() => {
|
|
1284
|
-
f ===
|
|
1316
|
+
f === Ct && F("onAxSnapshotChange", e.onAxSnapshotChange, n);
|
|
1285
1317
|
});
|
|
1286
1318
|
};
|
|
1287
|
-
let
|
|
1288
|
-
const
|
|
1319
|
+
let De = null, _e = /* @__PURE__ */ new Map();
|
|
1320
|
+
const xt = (n, f) => new Promise((c, d) => {
|
|
1289
1321
|
if (l) {
|
|
1290
1322
|
d(new Error("Device is watch-only"));
|
|
1291
1323
|
return;
|
|
@@ -1295,62 +1327,62 @@ function tr(t) {
|
|
|
1295
1327
|
d(new Error("Simulator disconnected"));
|
|
1296
1328
|
return;
|
|
1297
1329
|
}
|
|
1298
|
-
const
|
|
1299
|
-
|
|
1330
|
+
const m = Ut(), C = setTimeout(() => {
|
|
1331
|
+
_e.delete(m), d(new Error("Device control timed out"));
|
|
1300
1332
|
}, 5e3);
|
|
1301
|
-
|
|
1302
|
-
}),
|
|
1303
|
-
|
|
1304
|
-
}, oe = (
|
|
1305
|
-
l || !
|
|
1306
|
-
},
|
|
1333
|
+
_e.set(m, { resolve: c, reject: d, timer: C }), K.send(JSON.stringify({ type: n, id: m, ...f }));
|
|
1334
|
+
}), ge = (n) => {
|
|
1335
|
+
De !== n && (De = n, p({ connection: n }), F("onConnectionStateChange", e.onConnectionStateChange, n));
|
|
1336
|
+
}, oe = (n) => {
|
|
1337
|
+
l || !W || W.readyState !== "open" || (W.send(Be?.wrap(n) ?? n), $?.bumpActivity());
|
|
1338
|
+
}, Wt = () => {
|
|
1307
1339
|
g && g.readyState === WebSocket.OPEN && g.send(
|
|
1308
1340
|
JSON.stringify({
|
|
1309
1341
|
type: "keepAlive",
|
|
1310
1342
|
sessionId: i
|
|
1311
1343
|
})
|
|
1312
1344
|
);
|
|
1313
|
-
},
|
|
1314
|
-
|
|
1315
|
-
},
|
|
1316
|
-
|
|
1317
|
-
},
|
|
1318
|
-
|
|
1319
|
-
},
|
|
1320
|
-
|
|
1321
|
-
},
|
|
1322
|
-
|
|
1323
|
-
},
|
|
1324
|
-
|
|
1325
|
-
},
|
|
1326
|
-
|
|
1327
|
-
}, J = (
|
|
1328
|
-
for (const f of
|
|
1345
|
+
}, Ot = () => {
|
|
1346
|
+
me && window.clearInterval(me), me = window.setInterval(Wt, 1e4);
|
|
1347
|
+
}, Re = () => {
|
|
1348
|
+
me && (window.clearInterval(me), me = void 0);
|
|
1349
|
+
}, He = () => {
|
|
1350
|
+
Me && (window.clearTimeout(Me), Me = void 0);
|
|
1351
|
+
}, Je = () => {
|
|
1352
|
+
we && (window.clearTimeout(we), we = void 0);
|
|
1353
|
+
}, ke = () => {
|
|
1354
|
+
xe && (window.clearInterval(xe), xe = void 0);
|
|
1355
|
+
}, Ue = () => {
|
|
1356
|
+
Ce !== void 0 && (window.clearTimeout(Ce), Ce = void 0);
|
|
1357
|
+
}, qt = () => {
|
|
1358
|
+
Ye || (Ye = !0, ke(), S(!0), ge("connected"));
|
|
1359
|
+
}, J = (n) => {
|
|
1360
|
+
for (const f of n.getTracks())
|
|
1329
1361
|
try {
|
|
1330
1362
|
f.stop();
|
|
1331
1363
|
} catch (c) {
|
|
1332
1364
|
y("track.stop() failed:", c);
|
|
1333
1365
|
}
|
|
1334
|
-
},
|
|
1335
|
-
const
|
|
1336
|
-
|
|
1337
|
-
},
|
|
1338
|
-
const f =
|
|
1366
|
+
}, Vt = () => {
|
|
1367
|
+
const n = Q;
|
|
1368
|
+
n && (Q = null, J(n));
|
|
1369
|
+
}, Dt = (n) => {
|
|
1370
|
+
const f = mt.then(n).catch((c) => {
|
|
1339
1371
|
y("microphone operation failed:", c);
|
|
1340
1372
|
});
|
|
1341
|
-
return
|
|
1342
|
-
},
|
|
1373
|
+
return mt = f, f;
|
|
1374
|
+
}, it = () => rt || nt, _t = (n) => {
|
|
1343
1375
|
const f = `ui-mic-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
|
|
1344
|
-
|
|
1345
|
-
},
|
|
1346
|
-
const
|
|
1376
|
+
Oe = f, n.send(JSON.stringify({ type: "microphoneStart", id: f }));
|
|
1377
|
+
}, ot = () => Dt(() => $t()), $t = async () => {
|
|
1378
|
+
const n = Ve, f = () => n === Ve && it(), c = (h) => {
|
|
1347
1379
|
F("onMicrophoneStateChange", e.onMicrophoneStateChange, {
|
|
1348
1380
|
active: !1,
|
|
1349
1381
|
error: h
|
|
1350
1382
|
});
|
|
1351
1383
|
};
|
|
1352
1384
|
if (!f()) return;
|
|
1353
|
-
const d = g, K =
|
|
1385
|
+
const d = g, K = be;
|
|
1354
1386
|
if (!d || d.readyState !== WebSocket.OPEN || !K || te) return;
|
|
1355
1387
|
if (!navigator.mediaDevices || typeof navigator.mediaDevices.getUserMedia != "function") {
|
|
1356
1388
|
console.warn(
|
|
@@ -1358,29 +1390,29 @@ function tr(t) {
|
|
|
1358
1390
|
), c("Microphone capture requires a secure context (https)");
|
|
1359
1391
|
return;
|
|
1360
1392
|
}
|
|
1361
|
-
let
|
|
1393
|
+
let m = null;
|
|
1362
1394
|
try {
|
|
1363
|
-
|
|
1395
|
+
m = await navigator.mediaDevices.getUserMedia({ audio: !0, video: !1 });
|
|
1364
1396
|
} catch (h) {
|
|
1365
1397
|
console.warn("[RemoteControl] microphone getUserMedia denied/failed:", h);
|
|
1366
1398
|
}
|
|
1367
1399
|
if (!f()) {
|
|
1368
|
-
|
|
1400
|
+
m && J(m);
|
|
1369
1401
|
return;
|
|
1370
1402
|
}
|
|
1371
|
-
if (!
|
|
1403
|
+
if (!m) {
|
|
1372
1404
|
c("Microphone permission denied or no device available");
|
|
1373
1405
|
return;
|
|
1374
1406
|
}
|
|
1375
|
-
const C =
|
|
1407
|
+
const C = m.getAudioTracks()[0] ?? null;
|
|
1376
1408
|
if (!C) {
|
|
1377
|
-
J(
|
|
1409
|
+
J(m), c("Captured stream has no audio track");
|
|
1378
1410
|
return;
|
|
1379
1411
|
}
|
|
1380
1412
|
try {
|
|
1381
1413
|
await K.replaceTrack(C);
|
|
1382
1414
|
} catch (h) {
|
|
1383
|
-
y("replaceTrack(audioTrack) failed:", h), J(
|
|
1415
|
+
y("replaceTrack(audioTrack) failed:", h), J(m), c("Failed to attach the microphone track to the connection");
|
|
1384
1416
|
return;
|
|
1385
1417
|
}
|
|
1386
1418
|
if (!f()) {
|
|
@@ -1389,17 +1421,17 @@ function tr(t) {
|
|
|
1389
1421
|
} catch (h) {
|
|
1390
1422
|
y("replaceTrack(null) on stale mic attach failed:", h);
|
|
1391
1423
|
}
|
|
1392
|
-
J(
|
|
1424
|
+
J(m);
|
|
1393
1425
|
return;
|
|
1394
1426
|
}
|
|
1395
|
-
te =
|
|
1396
|
-
te ===
|
|
1397
|
-
},
|
|
1427
|
+
te = m, C.onended = () => {
|
|
1428
|
+
te === m && Ge("microphone capture ended by the browser");
|
|
1429
|
+
}, _t(d), F("onMicrophoneStateChange", e.onMicrophoneStateChange, {
|
|
1398
1430
|
active: !0,
|
|
1399
1431
|
label: C.label || void 0
|
|
1400
1432
|
});
|
|
1401
|
-
},
|
|
1402
|
-
const f =
|
|
1433
|
+
}, Ge = (n) => (++Ve, Oe = null, Dt(async () => {
|
|
1434
|
+
const f = be, c = te;
|
|
1403
1435
|
if (te = null, f && c)
|
|
1404
1436
|
try {
|
|
1405
1437
|
await f.replaceTrack(null);
|
|
@@ -1412,14 +1444,14 @@ function tr(t) {
|
|
|
1412
1444
|
const K = `ui-mic-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
|
|
1413
1445
|
d.send(JSON.stringify({ type: "microphoneStop", id: K }));
|
|
1414
1446
|
}
|
|
1415
|
-
(c ||
|
|
1447
|
+
(c || n) && F("onMicrophoneStateChange", e.onMicrophoneStateChange, {
|
|
1416
1448
|
active: !1,
|
|
1417
|
-
...
|
|
1449
|
+
...n !== void 0 && { error: n }
|
|
1418
1450
|
});
|
|
1419
|
-
})),
|
|
1451
|
+
})), gt = (n, f) => {
|
|
1420
1452
|
let c;
|
|
1421
1453
|
try {
|
|
1422
|
-
c =
|
|
1454
|
+
c = Fr(f), console.info(
|
|
1423
1455
|
`[RemoteControl] camera capture: ${c.camera?.width}x${c.camera?.height} @ ${c.camera?.frameRate ?? "?"}fps` + (c.camera?.label ? ` — ${c.camera.label}` : "")
|
|
1424
1456
|
);
|
|
1425
1457
|
} catch (d) {
|
|
@@ -1431,109 +1463,109 @@ function tr(t) {
|
|
|
1431
1463
|
}
|
|
1432
1464
|
};
|
|
1433
1465
|
}
|
|
1434
|
-
|
|
1435
|
-
},
|
|
1436
|
-
if (!
|
|
1437
|
-
const f =
|
|
1466
|
+
n.send(JSON.stringify(c)), F("onCameraDemandChange", e.onCameraDemandChange, !0, !0, c.camera);
|
|
1467
|
+
}, Ht = (n) => {
|
|
1468
|
+
if (!n) return;
|
|
1469
|
+
const f = n.indexOf("/"), d = (f >= 0 ? n.slice(f + 1) : n).toUpperCase();
|
|
1438
1470
|
return d === "HEVC" ? "H265" : d;
|
|
1439
|
-
},
|
|
1440
|
-
const
|
|
1441
|
-
if (!
|
|
1471
|
+
}, Jt = async () => {
|
|
1472
|
+
const n = ue, f = e.onCameraStats;
|
|
1473
|
+
if (!n || !f) return;
|
|
1442
1474
|
let c;
|
|
1443
1475
|
try {
|
|
1444
|
-
c = await
|
|
1476
|
+
c = await n.getStats();
|
|
1445
1477
|
} catch {
|
|
1446
1478
|
return;
|
|
1447
1479
|
}
|
|
1448
|
-
let d, K,
|
|
1480
|
+
let d, K, m;
|
|
1449
1481
|
if (c.forEach((U) => {
|
|
1450
|
-
U.type === "outbound-rtp" && U.kind === "video" ? d = U : U.type === "remote-inbound-rtp" && U.kind === "video" && (
|
|
1482
|
+
U.type === "outbound-rtp" && U.kind === "video" ? d = U : U.type === "remote-inbound-rtp" && U.kind === "video" && (m = U);
|
|
1451
1483
|
}), d?.codecId) {
|
|
1452
1484
|
const U = c.get(d.codecId);
|
|
1453
1485
|
U && (K = U.mimeType);
|
|
1454
1486
|
}
|
|
1455
1487
|
if (!d) return;
|
|
1456
|
-
const C = d.timestamp ?? Date.now(), h =
|
|
1457
|
-
let
|
|
1488
|
+
const C = d.timestamp ?? Date.now(), h = qe;
|
|
1489
|
+
let k, b, G;
|
|
1458
1490
|
if (h && C > h.timestamp) {
|
|
1459
1491
|
const U = (C - h.timestamp) / 1e3;
|
|
1460
|
-
if (typeof d.framesEncoded == "number" && typeof h.framesEncoded == "number" && (
|
|
1461
|
-
const A = d.packetsSent - h.packetsSent,
|
|
1462
|
-
A > 0 && (G = Math.max(0, Math.min(100,
|
|
1492
|
+
if (typeof d.framesEncoded == "number" && typeof h.framesEncoded == "number" && (k = Math.max(0, (d.framesEncoded - h.framesEncoded) / U)), typeof d.bytesSent == "number" && typeof h.bytesSent == "number" && (b = Math.max(0, (d.bytesSent - h.bytesSent) * 8 / U)), typeof d.packetsSent == "number" && typeof h.packetsSent == "number" && m && typeof m.packetsLost == "number" && typeof h.packetsLost == "number") {
|
|
1493
|
+
const A = d.packetsSent - h.packetsSent, Xe = m.packetsLost - h.packetsLost;
|
|
1494
|
+
A > 0 && (G = Math.max(0, Math.min(100, Xe / A * 100)));
|
|
1463
1495
|
}
|
|
1464
1496
|
}
|
|
1465
|
-
|
|
1497
|
+
qe = {
|
|
1466
1498
|
timestamp: C,
|
|
1467
1499
|
framesEncoded: d.framesEncoded,
|
|
1468
1500
|
bytesSent: d.bytesSent,
|
|
1469
1501
|
packetsSent: d.packetsSent,
|
|
1470
|
-
packetsLost:
|
|
1502
|
+
packetsLost: m?.packetsLost
|
|
1471
1503
|
};
|
|
1472
|
-
const
|
|
1473
|
-
codec:
|
|
1504
|
+
const M = {
|
|
1505
|
+
codec: Ht(K),
|
|
1474
1506
|
encoderImplementation: d.encoderImplementation,
|
|
1475
1507
|
hardwareAccelerated: typeof d.powerEfficientEncoder == "boolean" ? d.powerEfficientEncoder : void 0,
|
|
1476
|
-
framesPerSecond:
|
|
1508
|
+
framesPerSecond: k,
|
|
1477
1509
|
framesEncoded: d.framesEncoded,
|
|
1478
1510
|
bitrateBps: b,
|
|
1479
1511
|
width: d.frameWidth,
|
|
1480
1512
|
height: d.frameHeight,
|
|
1481
1513
|
qualityLimitationReason: d.qualityLimitationReason,
|
|
1482
|
-
rttMs: typeof
|
|
1514
|
+
rttMs: typeof m?.roundTripTime == "number" ? m.roundTripTime * 1e3 : void 0,
|
|
1483
1515
|
packetsLostPct: G
|
|
1484
1516
|
};
|
|
1485
|
-
F("onCameraStats", e.onCameraStats,
|
|
1486
|
-
},
|
|
1487
|
-
|
|
1488
|
-
|
|
1517
|
+
F("onCameraStats", e.onCameraStats, M);
|
|
1518
|
+
}, Tt = () => {
|
|
1519
|
+
Ne === null && (qe = null, Ne = setInterval(() => {
|
|
1520
|
+
Jt();
|
|
1489
1521
|
}, 1e3));
|
|
1490
|
-
},
|
|
1491
|
-
|
|
1492
|
-
},
|
|
1493
|
-
const
|
|
1494
|
-
if (!
|
|
1495
|
-
if (!
|
|
1496
|
-
const
|
|
1522
|
+
}, je = () => {
|
|
1523
|
+
Ne !== null && (clearInterval(Ne), Ne = null), qe = null, F("onCameraStats", e.onCameraStats, null);
|
|
1524
|
+
}, Gt = (n, f, c, d) => tt.enqueue(async ({ isCurrent: K }) => {
|
|
1525
|
+
const m = () => K() && d() && g === f && ue === c;
|
|
1526
|
+
if (!m()) return;
|
|
1527
|
+
if (!n.active) {
|
|
1528
|
+
const M = Q;
|
|
1497
1529
|
try {
|
|
1498
1530
|
await c.replaceTrack(null);
|
|
1499
1531
|
} catch (U) {
|
|
1500
1532
|
y("replaceTrack(null) on camera detach failed:", U);
|
|
1501
1533
|
}
|
|
1502
|
-
if (Q ===
|
|
1534
|
+
if (Q === M && (Q = null, fe = void 0, M && J(M)), je(), !m()) return;
|
|
1503
1535
|
F("onCameraDemandChange", e.onCameraDemandChange, !1);
|
|
1504
1536
|
return;
|
|
1505
1537
|
}
|
|
1506
1538
|
F("onCameraDemandChange", e.onCameraDemandChange, !0);
|
|
1507
|
-
const C = Q, h = C?.getVideoTracks()[0],
|
|
1508
|
-
if (h?.readyState === "live" &&
|
|
1509
|
-
fe =
|
|
1539
|
+
const C = Q, h = C?.getVideoTracks()[0], k = fe;
|
|
1540
|
+
if (h?.readyState === "live" && k && !Pr(k, n)) {
|
|
1541
|
+
fe = n, gt(f, h), Tt();
|
|
1510
1542
|
return;
|
|
1511
1543
|
}
|
|
1512
1544
|
if (C) {
|
|
1513
1545
|
try {
|
|
1514
1546
|
await c.replaceTrack(null);
|
|
1515
|
-
} catch (
|
|
1516
|
-
y("replaceTrack(null) before camera switch failed:",
|
|
1547
|
+
} catch (M) {
|
|
1548
|
+
y("replaceTrack(null) before camera switch failed:", M);
|
|
1517
1549
|
}
|
|
1518
|
-
if (Q === C && (Q = null, fe = void 0, J(C)),
|
|
1550
|
+
if (Q === C && (Q = null, fe = void 0, J(C)), je(), !m()) return;
|
|
1519
1551
|
}
|
|
1520
1552
|
if (!navigator.mediaDevices || typeof navigator.mediaDevices.getUserMedia != "function") {
|
|
1521
1553
|
if (console.warn(
|
|
1522
1554
|
"[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."
|
|
1523
|
-
), !
|
|
1555
|
+
), !m()) return;
|
|
1524
1556
|
f.send(JSON.stringify({ type: "cameraResult", granted: !1 })), F("onCameraDemandChange", e.onCameraDemandChange, !0, !1);
|
|
1525
1557
|
return;
|
|
1526
1558
|
}
|
|
1527
1559
|
let b = null;
|
|
1528
1560
|
try {
|
|
1529
1561
|
b = await navigator.mediaDevices.getUserMedia({
|
|
1530
|
-
video:
|
|
1562
|
+
video: Ur(n),
|
|
1531
1563
|
audio: !1
|
|
1532
1564
|
});
|
|
1533
|
-
} catch (
|
|
1534
|
-
console.warn("[RemoteControl] getUserMedia denied/failed:",
|
|
1565
|
+
} catch (M) {
|
|
1566
|
+
console.warn("[RemoteControl] getUserMedia denied/failed:", M);
|
|
1535
1567
|
}
|
|
1536
|
-
if (!
|
|
1568
|
+
if (!m()) {
|
|
1537
1569
|
b && J(b);
|
|
1538
1570
|
return;
|
|
1539
1571
|
}
|
|
@@ -1543,7 +1575,7 @@ function tr(t) {
|
|
|
1543
1575
|
}
|
|
1544
1576
|
const G = b.getVideoTracks()[0] ?? null;
|
|
1545
1577
|
if (!G) {
|
|
1546
|
-
if (J(b), !
|
|
1578
|
+
if (J(b), !m()) return;
|
|
1547
1579
|
f.send(JSON.stringify({ type: "cameraResult", granted: !1 })), F("onCameraDemandChange", e.onCameraDemandChange, !0, !1);
|
|
1548
1580
|
return;
|
|
1549
1581
|
}
|
|
@@ -1553,157 +1585,157 @@ function tr(t) {
|
|
|
1553
1585
|
}
|
|
1554
1586
|
try {
|
|
1555
1587
|
await c.replaceTrack(G);
|
|
1556
|
-
} catch (
|
|
1557
|
-
if (y("replaceTrack(videoTrack) failed:",
|
|
1588
|
+
} catch (M) {
|
|
1589
|
+
if (y("replaceTrack(videoTrack) failed:", M), J(b), !m()) return;
|
|
1558
1590
|
f.send(JSON.stringify({ type: "cameraResult", granted: !1 })), F("onCameraDemandChange", e.onCameraDemandChange, !0, !1);
|
|
1559
1591
|
return;
|
|
1560
1592
|
}
|
|
1561
|
-
if (!
|
|
1593
|
+
if (!m()) {
|
|
1562
1594
|
try {
|
|
1563
1595
|
await c.replaceTrack(null);
|
|
1564
|
-
} catch (
|
|
1565
|
-
y("replaceTrack(null) for stale camera attach failed:",
|
|
1596
|
+
} catch (M) {
|
|
1597
|
+
y("replaceTrack(null) for stale camera attach failed:", M);
|
|
1566
1598
|
}
|
|
1567
1599
|
J(b);
|
|
1568
1600
|
return;
|
|
1569
1601
|
}
|
|
1570
1602
|
try {
|
|
1571
|
-
const
|
|
1572
|
-
(!
|
|
1573
|
-
} catch (
|
|
1574
|
-
y("setParameters on outbound camera failed:",
|
|
1603
|
+
const M = c.getParameters();
|
|
1604
|
+
(!M.encodings || M.encodings.length === 0) && (M.encodings = [{}]), M.encodings[0].maxBitrate = 8e6, M.encodings[0].maxFramerate = 30, M.degradationPreference = "maintain-framerate", await c.setParameters(M);
|
|
1605
|
+
} catch (M) {
|
|
1606
|
+
y("setParameters on outbound camera failed:", M);
|
|
1575
1607
|
}
|
|
1576
|
-
if (!
|
|
1608
|
+
if (!m()) {
|
|
1577
1609
|
try {
|
|
1578
1610
|
await c.replaceTrack(null);
|
|
1579
|
-
} catch (
|
|
1580
|
-
y("replaceTrack(null) for stale camera finalize failed:",
|
|
1611
|
+
} catch (M) {
|
|
1612
|
+
y("replaceTrack(null) for stale camera finalize failed:", M);
|
|
1581
1613
|
}
|
|
1582
1614
|
J(b);
|
|
1583
1615
|
return;
|
|
1584
1616
|
}
|
|
1585
|
-
Q = b, fe =
|
|
1586
|
-
Q === b &&
|
|
1587
|
-
if (!(!
|
|
1617
|
+
Q = b, fe = n, G.onended = () => {
|
|
1618
|
+
Q === b && tt.enqueueCurrent(async ({ isCurrent: M }) => {
|
|
1619
|
+
if (!(!M() || Q !== b || !d() || g !== f || ue !== c)) {
|
|
1588
1620
|
try {
|
|
1589
1621
|
await c.replaceTrack(null);
|
|
1590
1622
|
} catch (U) {
|
|
1591
1623
|
y("replaceTrack(null) after camera ended failed:", U);
|
|
1592
1624
|
}
|
|
1593
|
-
!
|
|
1625
|
+
!M() || Q !== b || !d() || g !== f || ue !== c || (Q = null, fe = void 0, J(b), je(), f.send(JSON.stringify({ type: "cameraResult", granted: !1 })), F("onCameraDemandChange", e.onCameraDemandChange, !0, !1));
|
|
1594
1626
|
}
|
|
1595
|
-
}).catch((
|
|
1596
|
-
},
|
|
1597
|
-
}),
|
|
1598
|
-
for (const
|
|
1627
|
+
}).catch((M) => y("camera ended cleanup failed:", M));
|
|
1628
|
+
}, m() && (gt(f, G), Tt());
|
|
1629
|
+
}), Te = () => {
|
|
1630
|
+
for (const n of se) n();
|
|
1599
1631
|
se.clear();
|
|
1600
|
-
for (const
|
|
1601
|
-
|
|
1602
|
-
for (const
|
|
1603
|
-
|
|
1604
|
-
for (const
|
|
1605
|
-
|
|
1606
|
-
Z.clear(),
|
|
1607
|
-
for (const
|
|
1608
|
-
clearTimeout(
|
|
1609
|
-
|
|
1632
|
+
for (const n of I.values()) clearTimeout(n);
|
|
1633
|
+
I.clear();
|
|
1634
|
+
for (const n of Z.values())
|
|
1635
|
+
n(new Error("Simulator disconnected"));
|
|
1636
|
+
for (const n of ie.values())
|
|
1637
|
+
n(new Error("Simulator disconnected"));
|
|
1638
|
+
Z.clear(), ne.clear(), ie.clear(), ce.clear(), L?.(), L = void 0, Bt(), H = null;
|
|
1639
|
+
for (const n of _e.values())
|
|
1640
|
+
clearTimeout(n.timer), n.reject(new Error("Simulator disconnected"));
|
|
1641
|
+
_e.clear(), w(null), p({ controlReady: !1, videoReady: !1 }), Je(), Ue(), ke(), $ && ($.stop(), $ = null), Ie !== null && $e(null), tt.invalidate(), je(), Vt(), fe = void 0, ue = null, ++Ve, nt = !1, Oe = null, te && (J(te), te = null, F("onMicrophoneStateChange", e.onMicrophoneStateChange, {
|
|
1610
1642
|
active: !1
|
|
1611
|
-
})),
|
|
1612
|
-
},
|
|
1613
|
-
document.hidden ?
|
|
1614
|
-
},
|
|
1643
|
+
})), be = null, pe = null, g && (g.onopen = null, g.onmessage = null, g.onerror = null, g.onclose = null, g.close(), g = null), Be?.close(), Be = null, R && (R.onconnectionstatechange = null, R.oniceconnectionstatechange = null, R.ontrack = null, R.onicecandidate = null, R.close(), R = null), W && (W.onopen = null, W.onclose = null, W.onerror = null, W.close(), W = null);
|
|
1644
|
+
}, yt = () => {
|
|
1645
|
+
document.hidden ? Re() : Ot();
|
|
1646
|
+
}, jt = async () => {
|
|
1615
1647
|
if (e.transport) return e.transport.isTerminated?.() ?? !1;
|
|
1616
1648
|
if (typeof navigator < "u" && navigator.onLine === !1)
|
|
1617
1649
|
return !1;
|
|
1618
|
-
let
|
|
1650
|
+
let n;
|
|
1619
1651
|
try {
|
|
1620
|
-
const d = new URL(
|
|
1621
|
-
d.protocol = d.protocol === "wss:" ? "https:" : d.protocol === "ws:" ? "http:" : d.protocol,
|
|
1652
|
+
const d = new URL(r);
|
|
1653
|
+
d.protocol = d.protocol === "wss:" ? "https:" : d.protocol === "ws:" ? "http:" : d.protocol, n = kt(d.toString(), u);
|
|
1622
1654
|
} catch {
|
|
1623
1655
|
return !1;
|
|
1624
1656
|
}
|
|
1625
|
-
const f = new AbortController(), c = window.setTimeout(() => f.abort(),
|
|
1657
|
+
const f = new AbortController(), c = window.setTimeout(() => f.abort(), $r);
|
|
1626
1658
|
try {
|
|
1627
|
-
return (await fetch(
|
|
1659
|
+
return (await fetch(n, { method: "GET", cache: "no-store", signal: f.signal })).status === 404;
|
|
1628
1660
|
} catch {
|
|
1629
1661
|
return !1;
|
|
1630
1662
|
} finally {
|
|
1631
1663
|
window.clearTimeout(c);
|
|
1632
1664
|
}
|
|
1633
|
-
},
|
|
1634
|
-
|
|
1635
|
-
},
|
|
1636
|
-
if (
|
|
1637
|
-
|
|
1638
|
-
const
|
|
1639
|
-
|
|
1640
|
-
|
|
1665
|
+
}, Xt = () => {
|
|
1666
|
+
he || (he = !0, de += 1, He(), Je(), Ue(), Te(), _("Instance terminated"), Re(), ge("terminated"), F("onTerminated", e.onTerminated));
|
|
1667
|
+
}, Qt = () => {
|
|
1668
|
+
if (he || ve) return;
|
|
1669
|
+
ve = !0;
|
|
1670
|
+
const n = Fe;
|
|
1671
|
+
jt().catch(() => !1).then((f) => {
|
|
1672
|
+
n === Fe && (ve = !1, f && Xt());
|
|
1641
1673
|
});
|
|
1642
|
-
},
|
|
1643
|
-
if (
|
|
1674
|
+
}, ye = (n, f) => {
|
|
1675
|
+
if (he || f !== de)
|
|
1644
1676
|
return;
|
|
1645
|
-
if (
|
|
1677
|
+
if (Qt(), re) {
|
|
1646
1678
|
if (e.autoReconnect === !1) {
|
|
1647
|
-
|
|
1679
|
+
_(`Connection failed after it was established: ${n}`), Re(), ge("failed"), Te();
|
|
1648
1680
|
return;
|
|
1649
1681
|
}
|
|
1650
|
-
|
|
1682
|
+
_(`Reconnecting after established session dropped: ${n}`), re = !1, We = -1;
|
|
1651
1683
|
}
|
|
1652
|
-
|
|
1653
|
-
const c =
|
|
1654
|
-
if (c >=
|
|
1655
|
-
|
|
1684
|
+
He();
|
|
1685
|
+
const c = We + 1;
|
|
1686
|
+
if (c >= ft) {
|
|
1687
|
+
_(`Connection failed after ${ft} attempts: ${n}`), Re(), ge("failed"), Te();
|
|
1656
1688
|
return;
|
|
1657
1689
|
}
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
},
|
|
1661
|
-
},
|
|
1690
|
+
_(`Retrying connection (${c + 1}/${ft})`), ge("reconnecting"), Te(), Me = window.setTimeout(() => {
|
|
1691
|
+
Me = void 0, f === de && St(c);
|
|
1692
|
+
}, Wr);
|
|
1693
|
+
}, St = async (n = 0) => {
|
|
1662
1694
|
const { openUrl: f, axPollIntervalMs: c, axMaxBackoffMs: d, androidElementTreeOptions: K } = e;
|
|
1663
|
-
if (
|
|
1664
|
-
const
|
|
1665
|
-
de =
|
|
1666
|
-
const C = () =>
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
},
|
|
1695
|
+
if (he) return;
|
|
1696
|
+
const m = de + 1;
|
|
1697
|
+
de = m, We = n, re = !1, n === 0 && De !== "reconnecting" && ge("connecting"), He(), Je(), ke(), Ye = !1, S(!1), Te();
|
|
1698
|
+
const C = () => m === de;
|
|
1699
|
+
we = window.setTimeout(() => {
|
|
1700
|
+
we = void 0, !(!C() || re) && ye("Connection did not succeed within 15 seconds", m);
|
|
1701
|
+
}, qr);
|
|
1670
1702
|
try {
|
|
1671
|
-
const h = e.transport ? await e.transport.connect() : new WebSocket(
|
|
1703
|
+
const h = e.transport ? await e.transport.connect() : new WebSocket(kt(r, u));
|
|
1672
1704
|
if (!C()) {
|
|
1673
1705
|
h.close();
|
|
1674
1706
|
return;
|
|
1675
1707
|
}
|
|
1676
|
-
if (g = h, await new Promise((
|
|
1677
|
-
let
|
|
1678
|
-
const
|
|
1679
|
-
se.add(
|
|
1708
|
+
if (g = h, await new Promise((O, s) => {
|
|
1709
|
+
let Y = !1;
|
|
1710
|
+
const q = () => v(() => s(new Error("Connection stopped")));
|
|
1711
|
+
se.add(q);
|
|
1680
1712
|
const T = window.setTimeout(
|
|
1681
|
-
() =>
|
|
1713
|
+
() => v(() => s(new Error("WebSocket connection timeout"))),
|
|
1682
1714
|
3e4
|
|
1683
|
-
),
|
|
1684
|
-
|
|
1715
|
+
), v = (z) => {
|
|
1716
|
+
Y || (Y = !0, se.delete(q), window.clearTimeout(T), z());
|
|
1685
1717
|
};
|
|
1686
1718
|
h.onopen = () => {
|
|
1687
|
-
!C() || g !== h ||
|
|
1719
|
+
!C() || g !== h || v(O);
|
|
1688
1720
|
}, h.onerror = (z) => {
|
|
1689
|
-
!C() || g !== h || (
|
|
1721
|
+
!C() || g !== h || (_("WebSocket error: " + z), v(() => s(new Error("WebSocket connection failed"))));
|
|
1690
1722
|
}, h.onclose = () => {
|
|
1691
|
-
!C() || g !== h || (
|
|
1692
|
-
}, h.readyState === WebSocket.OPEN ?
|
|
1723
|
+
!C() || g !== h || (_("WebSocket closed"), v(() => s(new Error("WebSocket closed before connection was established"))));
|
|
1724
|
+
}, h.readyState === WebSocket.OPEN ? v(O) : h.readyState !== WebSocket.CONNECTING && v(() => s(new Error("WebSocket is closed")));
|
|
1693
1725
|
}), !C() || g !== h)
|
|
1694
1726
|
return;
|
|
1695
|
-
h.onerror = (
|
|
1696
|
-
!C() || g !== h ||
|
|
1727
|
+
h.onerror = (O) => {
|
|
1728
|
+
!C() || g !== h || _("WebSocket error: " + O);
|
|
1697
1729
|
}, h.onclose = () => {
|
|
1698
|
-
!C() || g !== h ||
|
|
1730
|
+
!C() || g !== h || _("WebSocket closed");
|
|
1699
1731
|
};
|
|
1700
|
-
const
|
|
1701
|
-
let
|
|
1702
|
-
const
|
|
1703
|
-
se.add(
|
|
1732
|
+
const k = new Promise((O, s) => {
|
|
1733
|
+
let Y = !1;
|
|
1734
|
+
const q = () => T(() => s(new Error("Connection stopped")));
|
|
1735
|
+
se.add(q);
|
|
1704
1736
|
const T = (j) => {
|
|
1705
|
-
|
|
1706
|
-
},
|
|
1737
|
+
Y || (Y = !0, se.delete(q), window.clearTimeout(v), h.removeEventListener("message", z), j());
|
|
1738
|
+
}, v = window.setTimeout(
|
|
1707
1739
|
() => T(() => s(new Error("RTCConfiguration timeout"))),
|
|
1708
1740
|
3e4
|
|
1709
1741
|
), z = (j) => {
|
|
@@ -1711,10 +1743,10 @@ function tr(t) {
|
|
|
1711
1743
|
try {
|
|
1712
1744
|
const X = JSON.parse(j.data);
|
|
1713
1745
|
if (X.type === "signalingError" && X.requestType === "requestRtcConfiguration" && X.sessionId === i) {
|
|
1714
|
-
const
|
|
1715
|
-
T(() => s(new Error(
|
|
1746
|
+
const tr = typeof X.error == "string" ? X.error : "Unable to load streaming configuration";
|
|
1747
|
+
T(() => s(new Error(tr)));
|
|
1716
1748
|
} else X.type === "rtcConfiguration" && T(
|
|
1717
|
-
() =>
|
|
1749
|
+
() => O({
|
|
1718
1750
|
rtcConfiguration: X.rtcConfiguration,
|
|
1719
1751
|
cameraSupported: X.cameraSupported === !0,
|
|
1720
1752
|
foldSupported: X.foldSupported === !0
|
|
@@ -1733,45 +1765,45 @@ function tr(t) {
|
|
|
1733
1765
|
}), {
|
|
1734
1766
|
rtcConfiguration: b,
|
|
1735
1767
|
cameraSupported: G,
|
|
1736
|
-
foldSupported:
|
|
1737
|
-
} = await
|
|
1768
|
+
foldSupported: M
|
|
1769
|
+
} = await k;
|
|
1738
1770
|
if (!C() || g !== h)
|
|
1739
1771
|
return;
|
|
1740
|
-
const U =
|
|
1741
|
-
|
|
1772
|
+
const U = o === "iphone-duo" || M;
|
|
1773
|
+
V(U);
|
|
1742
1774
|
const A = new RTCPeerConnection({ ...b, iceTransportPolicy: "relay" });
|
|
1743
|
-
|
|
1744
|
-
const
|
|
1745
|
-
H =
|
|
1746
|
-
const
|
|
1775
|
+
R = A;
|
|
1776
|
+
const Xe = { peer: A, displays: /* @__PURE__ */ new Map() };
|
|
1777
|
+
H = Xe, P(), A.addTransceiver("audio", { direction: "recvonly" });
|
|
1778
|
+
const at = E === "ios", Zt = A.addTransceiver("video", { direction: "recvonly" }), er = U ? A.addTransceiver("video", { direction: "recvonly" }) : null, Mt = !l && (E === "ios" || G), st = Mt ? A.addTransceiver("video", {
|
|
1747
1779
|
direction: "sendonly"
|
|
1748
1780
|
}) : null;
|
|
1749
|
-
if (ue =
|
|
1781
|
+
if (ue = st?.sender ?? null, be = (Mt ? A.addTransceiver("audio", {
|
|
1750
1782
|
direction: "sendonly"
|
|
1751
1783
|
}) : null)?.sender ?? null, RTCRtpReceiver.getCapabilities) {
|
|
1752
|
-
const
|
|
1753
|
-
if (
|
|
1754
|
-
const
|
|
1755
|
-
const
|
|
1784
|
+
const O = RTCRtpReceiver.getCapabilities("video");
|
|
1785
|
+
if (O && O.codecs) {
|
|
1786
|
+
const Y = O.codecs.sort((q, T) => {
|
|
1787
|
+
const v = (z) => {
|
|
1756
1788
|
const j = z.mimeType.toLowerCase();
|
|
1757
1789
|
return j.includes("h265") || j.includes("hevc") ? 1 : j.includes("h264") || j.includes("avc") ? 2 : 3;
|
|
1758
1790
|
};
|
|
1759
|
-
return
|
|
1791
|
+
return v(q) - v(T);
|
|
1760
1792
|
});
|
|
1761
|
-
|
|
1793
|
+
Zt.setCodecPreferences(Y), er?.setCodecPreferences(Y), le("Set codec preferences:", Y.map((q) => q.mimeType).join(", "));
|
|
1762
1794
|
}
|
|
1763
1795
|
}
|
|
1764
|
-
if (
|
|
1765
|
-
const
|
|
1766
|
-
if (
|
|
1767
|
-
const s = /* @__PURE__ */ new Set(["42e01f", "42e028", "640c1f"]),
|
|
1768
|
-
const
|
|
1769
|
-
return
|
|
1770
|
-
},
|
|
1796
|
+
if (st && RTCRtpSender.getCapabilities) {
|
|
1797
|
+
const O = RTCRtpSender.getCapabilities("video");
|
|
1798
|
+
if (O && O.codecs) {
|
|
1799
|
+
const s = /* @__PURE__ */ new Set(["42e01f", "42e028", "640c1f"]), Y = (T) => {
|
|
1800
|
+
const v = T.mimeType.toLowerCase(), j = (T.sdpFmtpLine || "").toLowerCase().match(/profile-level-id=([0-9a-f]{6})/), X = j ? j[1] : "";
|
|
1801
|
+
return v === "video/h265" || v === "video/hevc" ? 1 : v === "video/h264" && s.has(X) ? 2 : v === "video/h264" ? 3 : v === "video/vp9" ? 4 : v === "video/vp8" ? 5 : v === "video/rtx" || v === "video/red" || v === "video/ulpfec" ? 0 : 6;
|
|
1802
|
+
}, q = [...O.codecs].sort((T, v) => Y(T) - Y(v));
|
|
1771
1803
|
try {
|
|
1772
|
-
|
|
1804
|
+
st.setCodecPreferences(q), le(
|
|
1773
1805
|
"Outbound camera codec preferences:",
|
|
1774
|
-
|
|
1806
|
+
q.map((T) => `${T.mimeType}${T.sdpFmtpLine ? `[${T.sdpFmtpLine}]` : ""}`).join(", ")
|
|
1775
1807
|
);
|
|
1776
1808
|
} catch (T) {
|
|
1777
1809
|
y("Failed to set outbound camera codec preferences:", T);
|
|
@@ -1783,14 +1815,14 @@ function tr(t) {
|
|
|
1783
1815
|
negotiated: !0,
|
|
1784
1816
|
id: 1
|
|
1785
1817
|
});
|
|
1786
|
-
|
|
1787
|
-
const
|
|
1788
|
-
C() &&
|
|
1818
|
+
W = ae;
|
|
1819
|
+
const ct = !l && !U && e.onTrace ? Ir(A, (O) => {
|
|
1820
|
+
C() && R === A && F("onTrace", e.onTrace, O);
|
|
1789
1821
|
}) : null;
|
|
1790
|
-
if (
|
|
1791
|
-
if (!C() ||
|
|
1822
|
+
if (Be = ct, ae.onopen = () => {
|
|
1823
|
+
if (!C() || W !== ae || g !== h)
|
|
1792
1824
|
return;
|
|
1793
|
-
|
|
1825
|
+
re = !0, p({ controlReady: !l }), Je(), _("Control channel opened"), U && h.send(JSON.stringify({ type: "getFoldState", id: "duo-capabilities" })), !$ && E !== "macos" && ($ = new Mr({
|
|
1794
1826
|
platform: E,
|
|
1795
1827
|
baseIntervalMs: c,
|
|
1796
1828
|
maxBackoffMs: d,
|
|
@@ -1803,24 +1835,24 @@ function tr(t) {
|
|
|
1803
1835
|
return !1;
|
|
1804
1836
|
}
|
|
1805
1837
|
},
|
|
1806
|
-
onSnapshot:
|
|
1807
|
-
onStatusChange: (s,
|
|
1808
|
-
F("onAxStatusChange", e.onAxStatusChange, s,
|
|
1838
|
+
onSnapshot: $e,
|
|
1839
|
+
onStatusChange: (s, Y) => {
|
|
1840
|
+
F("onAxStatusChange", e.onAxStatusChange, s, Y);
|
|
1809
1841
|
}
|
|
1810
1842
|
}), (e.inspectMode === !0 || e.inspectMode === "hover-only") && $.start());
|
|
1811
|
-
const
|
|
1812
|
-
!C() ||
|
|
1843
|
+
const O = () => {
|
|
1844
|
+
!C() || Ye || W !== ae || g !== h || h.readyState !== WebSocket.OPEN || h.send(JSON.stringify({ type: "requestFrame", sessionId: i }));
|
|
1813
1845
|
};
|
|
1814
|
-
if (
|
|
1815
|
-
if (!C() ||
|
|
1816
|
-
|
|
1846
|
+
if (O(), ke(), xe = window.setInterval(() => {
|
|
1847
|
+
if (!C() || Ye || W !== ae || g !== h || h.readyState !== WebSocket.OPEN) {
|
|
1848
|
+
ke();
|
|
1817
1849
|
return;
|
|
1818
1850
|
}
|
|
1819
|
-
|
|
1851
|
+
O();
|
|
1820
1852
|
}, 250), !l && f) {
|
|
1821
1853
|
try {
|
|
1822
1854
|
const s = decodeURIComponent(f);
|
|
1823
|
-
|
|
1855
|
+
_("Opening URL"), h.send(
|
|
1824
1856
|
JSON.stringify({
|
|
1825
1857
|
type: "openUrl",
|
|
1826
1858
|
url: s,
|
|
@@ -1839,95 +1871,99 @@ function tr(t) {
|
|
|
1839
1871
|
$?.bumpActivity();
|
|
1840
1872
|
}
|
|
1841
1873
|
}, ae.onclose = () => {
|
|
1842
|
-
!C() ||
|
|
1843
|
-
}, ae.onerror = (
|
|
1844
|
-
!C() ||
|
|
1874
|
+
!C() || W !== ae || (p({ controlReady: !1 }), _("Control channel closed"));
|
|
1875
|
+
}, ae.onerror = (O) => {
|
|
1876
|
+
!C() || W !== ae || (console.error("Control channel error:", O), _("Control channel error: " + O));
|
|
1845
1877
|
}, A.onconnectionstatechange = () => {
|
|
1846
|
-
!C() ||
|
|
1878
|
+
!C() || R !== A || (_("Connection state: " + A.connectionState), A.connectionState === "failed" && re && ye("WebRTC connection entered failed state", m));
|
|
1847
1879
|
}, A.oniceconnectionstatechange = () => {
|
|
1848
|
-
if (!C() ||
|
|
1880
|
+
if (!C() || R !== A)
|
|
1849
1881
|
return;
|
|
1850
|
-
const
|
|
1851
|
-
if (
|
|
1852
|
-
|
|
1882
|
+
const O = A.iceConnectionState;
|
|
1883
|
+
if (_("ICE state: " + O), O === "connected" || O === "completed") {
|
|
1884
|
+
Ue(), it() && !te && ot();
|
|
1853
1885
|
return;
|
|
1854
1886
|
}
|
|
1855
|
-
if (
|
|
1856
|
-
|
|
1887
|
+
if (O === "failed") {
|
|
1888
|
+
Ue(), re && ye("ICE connection entered failed state", m);
|
|
1857
1889
|
return;
|
|
1858
1890
|
}
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
},
|
|
1862
|
-
}, A.ontrack = (
|
|
1863
|
-
if (!C() ||
|
|
1891
|
+
O === "disconnected" && re && e.autoReconnect !== !1 && Ce === void 0 && (Ce = window.setTimeout(() => {
|
|
1892
|
+
Ce = void 0, !(!C() || R !== A) && A.iceConnectionState === "disconnected" && ye("ICE stayed disconnected past grace period", m);
|
|
1893
|
+
}, Vr));
|
|
1894
|
+
}, A.ontrack = (O) => {
|
|
1895
|
+
if (!C() || R !== A)
|
|
1864
1896
|
return;
|
|
1865
|
-
|
|
1866
|
-
const s =
|
|
1867
|
-
if (
|
|
1868
|
-
const
|
|
1869
|
-
|
|
1870
|
-
for (const [T,
|
|
1871
|
-
|
|
1897
|
+
Yt(O.receiver, e.jitterBufferTargetMs);
|
|
1898
|
+
const s = O.track.id === "duo-inner" || O.streams.some((Y) => Y.id === "duo-inner");
|
|
1899
|
+
if (O.track.kind === "video" && Xe.displays.set(O.receiver, s ? "inner" : "primary"), _("Received remote track: " + O.track.kind), O.track.kind === "video") {
|
|
1900
|
+
const Y = s ? "inner" : "primary", q = U ? new MediaStream([O.track]) : O.streams[0] ?? new MediaStream([O.track]);
|
|
1901
|
+
Le.set(Y, q);
|
|
1902
|
+
for (const [T, v] of B)
|
|
1903
|
+
v.display === Y && Et(T, v, q);
|
|
1904
|
+
}
|
|
1905
|
+
if (O.track.kind === "audio" && at) {
|
|
1906
|
+
Ae = new MediaStream([O.track]);
|
|
1907
|
+
for (const Y of Ke) ht(Y);
|
|
1872
1908
|
}
|
|
1873
|
-
}, A.onicecandidate = (
|
|
1874
|
-
if (!(!C() ||
|
|
1875
|
-
if (
|
|
1909
|
+
}, A.onicecandidate = (O) => {
|
|
1910
|
+
if (!(!C() || R !== A || g !== h))
|
|
1911
|
+
if (O.candidate && h.readyState === WebSocket.OPEN) {
|
|
1876
1912
|
const s = {
|
|
1877
1913
|
type: "candidate",
|
|
1878
|
-
candidate:
|
|
1879
|
-
sdpMid:
|
|
1880
|
-
sdpMLineIndex:
|
|
1914
|
+
candidate: O.candidate.candidate,
|
|
1915
|
+
sdpMid: O.candidate.sdpMid,
|
|
1916
|
+
sdpMLineIndex: O.candidate.sdpMLineIndex,
|
|
1881
1917
|
sessionId: i
|
|
1882
1918
|
};
|
|
1883
|
-
h.send(JSON.stringify(s)),
|
|
1919
|
+
h.send(JSON.stringify(s)), _("Sent ICE candidate");
|
|
1884
1920
|
} else
|
|
1885
|
-
|
|
1886
|
-
}, h.onmessage = async (
|
|
1921
|
+
_("ICE candidate gathering completed");
|
|
1922
|
+
}, h.onmessage = async (O) => {
|
|
1887
1923
|
if (!C() || g !== h)
|
|
1888
1924
|
return;
|
|
1889
1925
|
let s;
|
|
1890
1926
|
try {
|
|
1891
|
-
s = JSON.parse(
|
|
1892
|
-
} catch (
|
|
1893
|
-
y("Error parsing message:",
|
|
1927
|
+
s = JSON.parse(O.data);
|
|
1928
|
+
} catch (Y) {
|
|
1929
|
+
y("Error parsing message:", Y);
|
|
1894
1930
|
return;
|
|
1895
1931
|
}
|
|
1896
1932
|
if (!$?.handleMessage(s))
|
|
1897
|
-
switch (
|
|
1933
|
+
switch (_("Received: " + s.type), s.type) {
|
|
1898
1934
|
case "performActionsResult":
|
|
1899
1935
|
case "foldStateResult":
|
|
1900
1936
|
case "foldStateChanged": {
|
|
1901
1937
|
if (!U) break;
|
|
1902
1938
|
s.state ? (w(s.state), N(void 0)) : s.id === "duo-capabilities" && N(s.error || "This instance does not support native iPhone Duo displays.");
|
|
1903
|
-
const T =
|
|
1904
|
-
T && (clearTimeout(T.timer),
|
|
1939
|
+
const T = _e.get(s.id);
|
|
1940
|
+
T && (clearTimeout(T.timer), _e.delete(s.id), s.error ? T.reject(new Error(s.error)) : T.resolve());
|
|
1905
1941
|
break;
|
|
1906
1942
|
}
|
|
1907
1943
|
case "signalingError": {
|
|
1908
1944
|
if (s.requestType !== "offer" || s.sessionId !== i)
|
|
1909
1945
|
break;
|
|
1910
1946
|
const T = typeof s.error == "string" ? s.error : "Unable to establish the streaming connection";
|
|
1911
|
-
|
|
1947
|
+
_("Error: " + T), ye(T, m);
|
|
1912
1948
|
break;
|
|
1913
1949
|
}
|
|
1914
1950
|
case "answer":
|
|
1915
|
-
if (!
|
|
1916
|
-
|
|
1951
|
+
if (!R || R !== A) {
|
|
1952
|
+
_("No peer connection, skipping answer");
|
|
1917
1953
|
break;
|
|
1918
1954
|
}
|
|
1919
|
-
if (
|
|
1955
|
+
if (ct?.accept(s.latencyTraceVersion), await A.setRemoteDescription(
|
|
1920
1956
|
new RTCSessionDescription({
|
|
1921
1957
|
type: "answer",
|
|
1922
1958
|
sdp: s.sdp
|
|
1923
1959
|
})
|
|
1924
|
-
), !C() ||
|
|
1960
|
+
), !C() || R !== A)
|
|
1925
1961
|
return;
|
|
1926
|
-
|
|
1962
|
+
_("Set remote description"), pe = h, (e.speakerMuted ?? !0) || pt();
|
|
1927
1963
|
break;
|
|
1928
1964
|
case "candidate":
|
|
1929
|
-
if (!
|
|
1930
|
-
|
|
1965
|
+
if (!R || R !== A) {
|
|
1966
|
+
_("No peer connection, skipping candidate");
|
|
1931
1967
|
break;
|
|
1932
1968
|
}
|
|
1933
1969
|
if (await A.addIceCandidate(
|
|
@@ -1936,9 +1972,9 @@ function tr(t) {
|
|
|
1936
1972
|
sdpMid: s.sdpMid,
|
|
1937
1973
|
sdpMLineIndex: s.sdpMLineIndex
|
|
1938
1974
|
})
|
|
1939
|
-
), !C() ||
|
|
1975
|
+
), !C() || R !== A)
|
|
1940
1976
|
return;
|
|
1941
|
-
|
|
1977
|
+
_("Added ICE candidate");
|
|
1942
1978
|
break;
|
|
1943
1979
|
case "screenshot":
|
|
1944
1980
|
case "screenshotResult": {
|
|
@@ -1946,27 +1982,27 @@ function tr(t) {
|
|
|
1946
1982
|
y("Received invalid screenshot success message:", s);
|
|
1947
1983
|
break;
|
|
1948
1984
|
}
|
|
1949
|
-
const T =
|
|
1985
|
+
const T = Hr(s);
|
|
1950
1986
|
if (T) {
|
|
1951
1987
|
const j = Z.get(s.id);
|
|
1952
1988
|
if (typeof j != "function") {
|
|
1953
1989
|
y(`Received screenshot error for unknown or handled id: ${s.id}`);
|
|
1954
1990
|
break;
|
|
1955
1991
|
}
|
|
1956
|
-
y(`Received screenshot error for id ${s.id}: ${T}`), j(new Error(T)),
|
|
1992
|
+
y(`Received screenshot error for id ${s.id}: ${T}`), j(new Error(T)), ne.delete(s.id), Z.delete(s.id), clearTimeout(I.get(s.id)), I.delete(s.id);
|
|
1957
1993
|
break;
|
|
1958
1994
|
}
|
|
1959
|
-
const
|
|
1960
|
-
if (!
|
|
1995
|
+
const v = Jr(s);
|
|
1996
|
+
if (!v) {
|
|
1961
1997
|
y("Received screenshot message without image data:", s);
|
|
1962
1998
|
break;
|
|
1963
1999
|
}
|
|
1964
|
-
const z =
|
|
2000
|
+
const z = ne.get(s.id);
|
|
1965
2001
|
if (typeof z != "function") {
|
|
1966
2002
|
y(`Received screenshot data for unknown or handled id: ${s.id}`);
|
|
1967
2003
|
break;
|
|
1968
2004
|
}
|
|
1969
|
-
le(`Received screenshot data for id ${s.id}`), z(
|
|
2005
|
+
le(`Received screenshot data for id ${s.id}`), z(v), ne.delete(s.id), Z.delete(s.id), clearTimeout(I.get(s.id)), I.delete(s.id);
|
|
1970
2006
|
break;
|
|
1971
2007
|
}
|
|
1972
2008
|
case "screenshotError":
|
|
@@ -1974,44 +2010,44 @@ function tr(t) {
|
|
|
1974
2010
|
y("Received invalid screenshot error message:", s);
|
|
1975
2011
|
break;
|
|
1976
2012
|
}
|
|
1977
|
-
const
|
|
1978
|
-
if (typeof
|
|
2013
|
+
const Y = Z.get(s.id);
|
|
2014
|
+
if (typeof Y != "function") {
|
|
1979
2015
|
y(`Received screenshot error for unknown or handled id: ${s.id}`);
|
|
1980
2016
|
break;
|
|
1981
2017
|
}
|
|
1982
|
-
y(`Received screenshot error for id ${s.id}: ${s.message}`),
|
|
2018
|
+
y(`Received screenshot error for id ${s.id}: ${s.message}`), Y(new Error(s.message)), ne.delete(s.id), Z.delete(s.id), clearTimeout(I.get(s.id)), I.delete(s.id);
|
|
1983
2019
|
break;
|
|
1984
2020
|
case "cameraRequest": {
|
|
1985
2021
|
const T = ue;
|
|
1986
2022
|
if (!T)
|
|
1987
2023
|
break;
|
|
1988
|
-
const
|
|
1989
|
-
if (!
|
|
2024
|
+
const v = kr(s);
|
|
2025
|
+
if (!v) {
|
|
1990
2026
|
y("Received invalid cameraRequest:", s);
|
|
1991
2027
|
break;
|
|
1992
2028
|
}
|
|
1993
|
-
console.info("[RemoteControl] cameraRequest received:",
|
|
2029
|
+
console.info("[RemoteControl] cameraRequest received:", v.active, v.facingMode), await Gt(v, h, T, C);
|
|
1994
2030
|
break;
|
|
1995
2031
|
}
|
|
1996
2032
|
case "microphoneRequest": {
|
|
1997
|
-
if (!
|
|
2033
|
+
if (!be)
|
|
1998
2034
|
break;
|
|
1999
2035
|
const T = s.active === !0;
|
|
2000
|
-
if (
|
|
2001
|
-
|
|
2036
|
+
if (nt = T, console.info("[RemoteControl] microphoneRequest received, active=", T), !T) {
|
|
2037
|
+
rt || await Ge();
|
|
2002
2038
|
break;
|
|
2003
2039
|
}
|
|
2004
2040
|
if (te) {
|
|
2005
|
-
|
|
2041
|
+
_t(h);
|
|
2006
2042
|
break;
|
|
2007
2043
|
}
|
|
2008
|
-
await
|
|
2044
|
+
await ot();
|
|
2009
2045
|
break;
|
|
2010
2046
|
}
|
|
2011
2047
|
case "microphoneStartResult": {
|
|
2012
|
-
if (
|
|
2048
|
+
if (Oe === null || s.id !== Oe)
|
|
2013
2049
|
break;
|
|
2014
|
-
|
|
2050
|
+
Oe = null, typeof s.error == "string" && (console.warn("[RemoteControl] microphoneStart rejected by host:", s.error), Ge(s.error));
|
|
2015
2051
|
break;
|
|
2016
2052
|
}
|
|
2017
2053
|
case "terminateAppResult":
|
|
@@ -2025,146 +2061,159 @@ function tr(t) {
|
|
|
2025
2061
|
y(`Received terminateApp error for unknown or handled id: ${s.id}`);
|
|
2026
2062
|
break;
|
|
2027
2063
|
}
|
|
2028
|
-
y(`Received terminateApp error for id ${s.id}: ${s.error}`), T(new Error(s.error)), ce.delete(s.id), ie.delete(s.id), clearTimeout(
|
|
2064
|
+
y(`Received terminateApp error for id ${s.id}: ${s.error}`), T(new Error(s.error)), ce.delete(s.id), ie.delete(s.id), clearTimeout(I.get(s.id)), I.delete(s.id);
|
|
2029
2065
|
break;
|
|
2030
2066
|
}
|
|
2031
|
-
const
|
|
2032
|
-
if (typeof
|
|
2067
|
+
const q = ce.get(s.id);
|
|
2068
|
+
if (typeof q != "function") {
|
|
2033
2069
|
y(`Received terminateApp result for unknown or handled id: ${s.id}`);
|
|
2034
2070
|
break;
|
|
2035
2071
|
}
|
|
2036
|
-
le(`Received terminateApp success for id ${s.id}`),
|
|
2072
|
+
le(`Received terminateApp success for id ${s.id}`), q(), ce.delete(s.id), ie.delete(s.id), clearTimeout(I.get(s.id)), I.delete(s.id);
|
|
2037
2073
|
break;
|
|
2038
2074
|
default:
|
|
2039
2075
|
y(`Received unhandled message type: ${s.type}`, s);
|
|
2040
2076
|
break;
|
|
2041
2077
|
}
|
|
2042
|
-
},
|
|
2043
|
-
const
|
|
2078
|
+
}, R === A) {
|
|
2079
|
+
const O = await A.createOffer({
|
|
2044
2080
|
offerToReceiveVideo: !0,
|
|
2045
|
-
|
|
2081
|
+
// This legacy option overrides transceiver directions: false turns
|
|
2082
|
+
// the speaker's receive-only audio section inactive.
|
|
2083
|
+
offerToReceiveAudio: at
|
|
2046
2084
|
});
|
|
2047
|
-
if (!C() ||
|
|
2085
|
+
if (!C() || R !== A || (await A.setLocalDescription(O), !C() || R !== A))
|
|
2048
2086
|
return;
|
|
2049
2087
|
C() && g === h && h.readyState === WebSocket.OPEN && h.send(
|
|
2050
2088
|
JSON.stringify({
|
|
2051
2089
|
type: "offer",
|
|
2052
2090
|
...U ? { displayStreams: !0 } : {},
|
|
2053
|
-
...
|
|
2054
|
-
|
|
2091
|
+
...at ? { speakerAudio: !0 } : {},
|
|
2092
|
+
...ct ? { latencyTraceVersion: 1 } : {},
|
|
2093
|
+
sdp: O.sdp,
|
|
2055
2094
|
sessionId: i
|
|
2056
2095
|
})
|
|
2057
|
-
),
|
|
2096
|
+
), _("Sent offer");
|
|
2058
2097
|
}
|
|
2059
2098
|
} catch (h) {
|
|
2060
2099
|
if (!C() || h instanceof Error && h.message === "Connection stopped")
|
|
2061
2100
|
return;
|
|
2062
|
-
const
|
|
2063
|
-
|
|
2101
|
+
const k = h instanceof Error ? h.message : String(h);
|
|
2102
|
+
_("Error: " + k), ye(k, m);
|
|
2064
2103
|
}
|
|
2065
|
-
},
|
|
2066
|
-
if (
|
|
2067
|
-
|
|
2068
|
-
},
|
|
2069
|
-
|
|
2070
|
-
},
|
|
2071
|
-
if (
|
|
2072
|
-
if (
|
|
2104
|
+
}, Kt = () => {
|
|
2105
|
+
if (Ee) throw new Error("Device stream is disposed");
|
|
2106
|
+
Fe++, ve = !1, $e(null), De !== "reconnecting" && (De = null), document.addEventListener("visibilitychange", yt), document.hidden || Ot(), he = !1, St(0);
|
|
2107
|
+
}, At = () => {
|
|
2108
|
+
Fe++, ve = !1, Re(), document.removeEventListener("visibilitychange", yt), de += 1, We = 0, re = !1, He(), Ue(), Te(), De = null, p({ connection: "idle", videoReady: !1, controlReady: !1 }), _("Stopped");
|
|
2109
|
+
}, zt = (n) => {
|
|
2110
|
+
if (Ee) throw new Error("Device stream is disposed");
|
|
2111
|
+
if (Ke.has(n)) throw new Error("Audio element is already attached");
|
|
2112
|
+
Ke.add(n), Ae && ht(n);
|
|
2113
|
+
let f = !1;
|
|
2114
|
+
const c = () => {
|
|
2115
|
+
f || (f = !0, x.delete(c), Ke.delete(n), Br(n), n.srcObject = null);
|
|
2116
|
+
};
|
|
2117
|
+
return x.add(c), c;
|
|
2118
|
+
}, vt = (n, f = "primary") => {
|
|
2119
|
+
if (Ee) throw new Error("Device stream is disposed");
|
|
2120
|
+
if (B.has(n)) throw new Error("Video element is already attached");
|
|
2073
2121
|
const c = { display: f };
|
|
2074
|
-
B.set(
|
|
2122
|
+
B.set(n, c);
|
|
2075
2123
|
const d = () => {
|
|
2076
|
-
f === "primary" &&
|
|
2124
|
+
f === "primary" && Le.has(f) && qt();
|
|
2077
2125
|
};
|
|
2078
|
-
|
|
2079
|
-
const K =
|
|
2080
|
-
K &&
|
|
2081
|
-
let
|
|
2126
|
+
n.addEventListener("loadeddata", d);
|
|
2127
|
+
const K = Le.get(f);
|
|
2128
|
+
K && Et(n, c, K);
|
|
2129
|
+
let m = !1;
|
|
2082
2130
|
const C = () => {
|
|
2083
|
-
|
|
2131
|
+
m || (m = !0, x.delete(C), n.removeEventListener("loadeddata", d), c.stop?.(), B.delete(n), n.srcObject = null);
|
|
2084
2132
|
};
|
|
2085
|
-
return
|
|
2133
|
+
return x.add(C), C;
|
|
2086
2134
|
};
|
|
2087
2135
|
return {
|
|
2088
|
-
start:
|
|
2089
|
-
stop:
|
|
2090
|
-
attachVideo:
|
|
2091
|
-
|
|
2136
|
+
start: Kt,
|
|
2137
|
+
stop: At,
|
|
2138
|
+
attachVideo: vt,
|
|
2139
|
+
attachAudio: zt,
|
|
2140
|
+
attachFrameSink: (n, f = "primary") => {
|
|
2092
2141
|
const c = document.createElement("video");
|
|
2093
2142
|
c.muted = !0, c.playsInline = !0, c.autoplay = !0;
|
|
2094
|
-
const d =
|
|
2095
|
-
let K = !1,
|
|
2143
|
+
const d = vt(c, f);
|
|
2144
|
+
let K = !1, m = 0, C = 0;
|
|
2096
2145
|
const h = () => {
|
|
2097
|
-
c.cancelVideoFrameCallback?.(
|
|
2098
|
-
},
|
|
2146
|
+
c.cancelVideoFrameCallback?.(m), cancelAnimationFrame(C);
|
|
2147
|
+
}, k = () => {
|
|
2099
2148
|
K || !c.srcObject || (c.readyState >= 2 && c.videoWidth > 0 && F(
|
|
2100
2149
|
"present",
|
|
2101
|
-
(...
|
|
2150
|
+
(...M) => n.present(...M),
|
|
2102
2151
|
c,
|
|
2103
2152
|
c.videoWidth,
|
|
2104
2153
|
c.videoHeight,
|
|
2105
2154
|
f
|
|
2106
|
-
), !(K || !c.srcObject) && (c.requestVideoFrameCallback ?
|
|
2155
|
+
), !(K || !c.srcObject) && (c.requestVideoFrameCallback ? m = c.requestVideoFrameCallback(k) : C = requestAnimationFrame(k)));
|
|
2107
2156
|
}, b = () => {
|
|
2108
|
-
h(),
|
|
2157
|
+
h(), k();
|
|
2109
2158
|
};
|
|
2110
2159
|
B.get(c).clear = h, c.addEventListener("loadeddata", b);
|
|
2111
2160
|
const G = () => {
|
|
2112
|
-
K || (K = !0,
|
|
2161
|
+
K || (K = !0, x.delete(G), h(), c.removeEventListener("loadeddata", b), d(), c.remove());
|
|
2113
2162
|
};
|
|
2114
|
-
return
|
|
2163
|
+
return x.delete(d), x.add(G), c.readyState >= 2 && b(), G;
|
|
2115
2164
|
},
|
|
2116
2165
|
dispose: () => {
|
|
2117
|
-
if (!
|
|
2118
|
-
|
|
2119
|
-
for (const
|
|
2120
|
-
|
|
2166
|
+
if (!Ee) {
|
|
2167
|
+
Ee = !0, At();
|
|
2168
|
+
for (const n of x) n();
|
|
2169
|
+
x.clear();
|
|
2121
2170
|
}
|
|
2122
2171
|
},
|
|
2123
|
-
getState: () =>
|
|
2172
|
+
getState: () => D,
|
|
2124
2173
|
/** A new token applies to the next connection attempt and termination probe. */
|
|
2125
2174
|
updateOptions: ({
|
|
2126
|
-
token:
|
|
2175
|
+
token: n,
|
|
2127
2176
|
...f
|
|
2128
2177
|
}) => {
|
|
2129
|
-
if (
|
|
2130
|
-
|
|
2178
|
+
if (Ee) throw new Error("Device stream is disposed");
|
|
2179
|
+
n !== void 0 && !e.transport && (u = n);
|
|
2131
2180
|
const c = e;
|
|
2132
2181
|
if (e = { ...e, ...f }, c.jitterBufferTargetMs !== e.jitterBufferTargetMs)
|
|
2133
|
-
for (const d of
|
|
2134
|
-
(d.currentDirection === "recvonly" || d.currentDirection === "sendrecv") &&
|
|
2135
|
-
!!c.onPlaybackStats != !!e.onPlaybackStats && P(), !!c.microphoneEnabled != !!e.microphoneEnabled && (
|
|
2182
|
+
for (const d of R?.getTransceivers() ?? [])
|
|
2183
|
+
(d.currentDirection === "recvonly" || d.currentDirection === "sendrecv") && Yt(d.receiver, e.jitterBufferTargetMs);
|
|
2184
|
+
!!c.onPlaybackStats != !!e.onPlaybackStats && P(), !!c.microphoneEnabled != !!e.microphoneEnabled && (rt = !l && (e.microphoneEnabled ?? !1), it() ? ot() : Ge()), (c.speakerMuted ?? !0) !== (e.speakerMuted ?? !0) && pt(), !!c.inspectMode != !!e.inspectMode && (e.inspectMode ? $?.start() : ($?.stop(), Ie !== null && $e(null)));
|
|
2136
2185
|
},
|
|
2137
2186
|
sendControl: oe,
|
|
2138
|
-
sendTouch: (
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2187
|
+
sendTouch: (n, f, c, d, K, m = 0) => oe(
|
|
2188
|
+
ir(
|
|
2189
|
+
n === "begin" ? 0 : n === "end" ? 1 : 2,
|
|
2190
|
+
m,
|
|
2142
2191
|
d,
|
|
2143
2192
|
K,
|
|
2144
2193
|
f,
|
|
2145
2194
|
c,
|
|
2146
|
-
|
|
2195
|
+
n === "end" ? 0 : 1
|
|
2147
2196
|
)
|
|
2148
2197
|
),
|
|
2149
|
-
sendText: (
|
|
2150
|
-
sendDisplayTouch: (
|
|
2151
|
-
sendDuoControl:
|
|
2152
|
-
pressButton: (
|
|
2153
|
-
const f = { home: 3, back: 4, recents: 187, power: 26 }[
|
|
2154
|
-
oe(
|
|
2198
|
+
sendText: (n) => oe(or(n)),
|
|
2199
|
+
sendDisplayTouch: (n, f, c, d) => oe(dr(n, f, c, d)),
|
|
2200
|
+
sendDuoControl: xt,
|
|
2201
|
+
pressButton: (n) => {
|
|
2202
|
+
const f = { home: 3, back: 4, recents: 187, power: 26 }[n];
|
|
2203
|
+
oe(lt(0, f, 0, 0)), oe(lt(1, f, 0, 0));
|
|
2155
2204
|
},
|
|
2156
2205
|
rotate: () => oe(new Uint8Array([11]).buffer),
|
|
2157
2206
|
bumpActivity: () => $?.bumpActivity(),
|
|
2158
2207
|
getAxStatus: () => $?.getStatus() ?? "idle",
|
|
2159
|
-
openUrl: (
|
|
2208
|
+
openUrl: (n) => {
|
|
2160
2209
|
if (!l) {
|
|
2161
2210
|
if (!g || g.readyState !== WebSocket.OPEN) {
|
|
2162
2211
|
y("WebSocket not open, cannot send open_url command.");
|
|
2163
2212
|
return;
|
|
2164
2213
|
}
|
|
2165
2214
|
try {
|
|
2166
|
-
const f = decodeURIComponent(
|
|
2167
|
-
|
|
2215
|
+
const f = decodeURIComponent(n);
|
|
2216
|
+
_("Opening URL"), g.send(
|
|
2168
2217
|
JSON.stringify({
|
|
2169
2218
|
type: "openUrl",
|
|
2170
2219
|
url: f,
|
|
@@ -2172,10 +2221,10 @@ function tr(t) {
|
|
|
2172
2221
|
})
|
|
2173
2222
|
);
|
|
2174
2223
|
} catch (f) {
|
|
2175
|
-
y("Error decoding or sending URL :", { error: f, url:
|
|
2224
|
+
y("Error decoding or sending URL :", { error: f, url: n }), g.send(
|
|
2176
2225
|
JSON.stringify({
|
|
2177
2226
|
type: "openUrl",
|
|
2178
|
-
url:
|
|
2227
|
+
url: n,
|
|
2179
2228
|
sessionId: i
|
|
2180
2229
|
})
|
|
2181
2230
|
);
|
|
@@ -2183,44 +2232,44 @@ function tr(t) {
|
|
|
2183
2232
|
$?.bumpActivity();
|
|
2184
2233
|
}
|
|
2185
2234
|
},
|
|
2186
|
-
sendKeyEvent: (
|
|
2187
|
-
if (!
|
|
2188
|
-
y("Data channel not ready for imperative key command:",
|
|
2235
|
+
sendKeyEvent: (n) => {
|
|
2236
|
+
if (!W || W.readyState !== "open") {
|
|
2237
|
+
y("Data channel not ready for imperative key command:", W?.readyState);
|
|
2189
2238
|
return;
|
|
2190
2239
|
}
|
|
2191
2240
|
if (E === "macos") {
|
|
2192
|
-
const
|
|
2193
|
-
if (
|
|
2194
|
-
y(`Unknown event.code for imperative command: ${
|
|
2241
|
+
const m = wt(n.code);
|
|
2242
|
+
if (m === void 0) {
|
|
2243
|
+
y(`Unknown event.code for imperative command: ${n.code}`);
|
|
2195
2244
|
return;
|
|
2196
2245
|
}
|
|
2197
2246
|
const C = [
|
|
2198
|
-
[
|
|
2199
|
-
[
|
|
2200
|
-
[
|
|
2201
|
-
[
|
|
2202
|
-
].filter(([
|
|
2203
|
-
if (
|
|
2204
|
-
for (const
|
|
2205
|
-
h(
|
|
2247
|
+
[n.metaKey, "Meta"],
|
|
2248
|
+
[n.ctrlKey, "Control"],
|
|
2249
|
+
[n.altKey, "Alt"],
|
|
2250
|
+
[n.shiftKey, "Shift"]
|
|
2251
|
+
].filter(([k, b]) => k && !n.code.startsWith(b)).map(([, k]) => wt(`${k}Left`)), h = (k, b) => oe(ar(k, b));
|
|
2252
|
+
if (n.type === "keydown") {
|
|
2253
|
+
for (const k of C) h(Qe.DOWN, k);
|
|
2254
|
+
h(Qe.DOWN, m);
|
|
2206
2255
|
} else {
|
|
2207
|
-
h(
|
|
2208
|
-
for (const
|
|
2256
|
+
h(Qe.UP, m);
|
|
2257
|
+
for (const k of [...C].reverse()) h(Qe.UP, k);
|
|
2209
2258
|
}
|
|
2210
2259
|
return;
|
|
2211
2260
|
}
|
|
2212
|
-
const f =
|
|
2261
|
+
const f = rr[n.code];
|
|
2213
2262
|
if (!f) {
|
|
2214
|
-
y(`Unknown event.code for imperative command: ${
|
|
2263
|
+
y(`Unknown event.code for imperative command: ${n.code}`);
|
|
2215
2264
|
return;
|
|
2216
2265
|
}
|
|
2217
|
-
let c =
|
|
2218
|
-
|
|
2219
|
-
const d =
|
|
2266
|
+
let c = a.META_NONE;
|
|
2267
|
+
n.shiftKey && (c |= a.META_SHIFT_ON), n.altKey && (c |= a.META_ALT_ON), n.ctrlKey && (c |= a.META_CTRL_ON), n.metaKey && (c |= a.META_META_ON);
|
|
2268
|
+
const d = n.type === "keydown" ? a.ACTION_DOWN : a.ACTION_UP;
|
|
2220
2269
|
le(
|
|
2221
|
-
`Sending Imperative Key Command: code=${
|
|
2270
|
+
`Sending Imperative Key Command: code=${n.code}, keycode=${f}, action=${d}, meta=${c}`
|
|
2222
2271
|
);
|
|
2223
|
-
const K =
|
|
2272
|
+
const K = lt(
|
|
2224
2273
|
d,
|
|
2225
2274
|
f,
|
|
2226
2275
|
0,
|
|
@@ -2229,99 +2278,101 @@ function tr(t) {
|
|
|
2229
2278
|
);
|
|
2230
2279
|
K && oe(K);
|
|
2231
2280
|
},
|
|
2232
|
-
screenshot: (
|
|
2281
|
+
screenshot: (n) => new Promise((f, c) => {
|
|
2233
2282
|
if (!g || g.readyState !== WebSocket.OPEN)
|
|
2234
2283
|
return y("WebSocket not open, cannot send screenshot command."), c(new Error("WebSocket is not connected or connection is not open."));
|
|
2235
2284
|
const d = `ui-ss-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`, K = {
|
|
2236
|
-
type:
|
|
2237
|
-
...
|
|
2285
|
+
type: n ? "screenshotDisplay" : "screenshot",
|
|
2286
|
+
...n ? { display: n } : {},
|
|
2238
2287
|
id: d
|
|
2239
2288
|
};
|
|
2240
|
-
|
|
2289
|
+
ne.set(d, f), Z.set(d, c), le("Sending screenshot request:", K);
|
|
2241
2290
|
try {
|
|
2242
2291
|
g.send(JSON.stringify(K));
|
|
2243
|
-
} catch (
|
|
2244
|
-
y("Failed to send screenshot request immediately:",
|
|
2292
|
+
} catch (m) {
|
|
2293
|
+
y("Failed to send screenshot request immediately:", m), ne.delete(d), Z.delete(d), c(m);
|
|
2245
2294
|
return;
|
|
2246
2295
|
}
|
|
2247
|
-
|
|
2296
|
+
I.set(
|
|
2248
2297
|
d,
|
|
2249
2298
|
setTimeout(() => {
|
|
2250
|
-
|
|
2299
|
+
I.delete(d), ne.has(d) && (y(`Screenshot request timed out for id ${d}`), Z.get(d)?.(new Error("Screenshot request timed out")), ne.delete(d), Z.delete(d));
|
|
2251
2300
|
}, 3e4)
|
|
2252
2301
|
);
|
|
2253
2302
|
}),
|
|
2254
|
-
terminateApp: (
|
|
2303
|
+
terminateApp: (n) => l ? Promise.reject(new Error("Device is watch-only")) : new Promise((f, c) => {
|
|
2255
2304
|
if (!g || g.readyState !== WebSocket.OPEN)
|
|
2256
2305
|
return y("WebSocket not open, cannot send terminateApp command."), c(new Error("WebSocket is not connected or connection is not open."));
|
|
2257
2306
|
const d = `ui-term-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`, K = {
|
|
2258
2307
|
type: "terminateApp",
|
|
2259
2308
|
id: d,
|
|
2260
|
-
bundleId:
|
|
2309
|
+
bundleId: n
|
|
2261
2310
|
};
|
|
2262
2311
|
ce.set(d, f), ie.set(d, c), le("Sending terminateApp request:", K);
|
|
2263
2312
|
try {
|
|
2264
2313
|
g.send(JSON.stringify(K));
|
|
2265
|
-
} catch (
|
|
2266
|
-
y("Failed to send terminateApp request immediately:",
|
|
2314
|
+
} catch (m) {
|
|
2315
|
+
y("Failed to send terminateApp request immediately:", m), ce.delete(d), ie.delete(d), c(m);
|
|
2267
2316
|
return;
|
|
2268
2317
|
}
|
|
2269
|
-
$?.bumpActivity(),
|
|
2318
|
+
$?.bumpActivity(), I.set(
|
|
2270
2319
|
d,
|
|
2271
2320
|
setTimeout(() => {
|
|
2272
|
-
|
|
2321
|
+
I.delete(d), ce.has(d) && (y(`terminateApp request timed out for id ${d}`), ie.get(d)?.(new Error("terminateApp request timed out")), ce.delete(d), ie.delete(d));
|
|
2273
2322
|
}, 3e4)
|
|
2274
2323
|
);
|
|
2275
2324
|
}),
|
|
2276
|
-
reconnect: () =>
|
|
2325
|
+
reconnect: () => Kt(),
|
|
2277
2326
|
refreshAxTree: async () => {
|
|
2278
|
-
const
|
|
2279
|
-
if (!
|
|
2327
|
+
const n = $;
|
|
2328
|
+
if (!n)
|
|
2280
2329
|
throw new Error("Inspect mode is not active");
|
|
2281
|
-
return
|
|
2330
|
+
return n.refresh();
|
|
2282
2331
|
},
|
|
2283
|
-
getAxSnapshot: () =>
|
|
2332
|
+
getAxSnapshot: () => Ie
|
|
2284
2333
|
};
|
|
2285
2334
|
}
|
|
2286
|
-
const
|
|
2335
|
+
const Hr = (t) => typeof t.message == "string" ? t.message : typeof t.error == "string" ? t.error : null, Jr = (t) => typeof t.dataUri == "string" ? { dataUri: t.dataUri } : typeof t.base64 == "string" ? t.base64.startsWith("data:") ? { dataUri: t.base64 } : { dataUri: `data:${t.base64.startsWith("/9j/") ? "image/jpeg" : "image/png"};base64,${t.base64}` } : null;
|
|
2287
2336
|
export {
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
dn as
|
|
2305
|
-
un as
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2337
|
+
dt as A,
|
|
2338
|
+
wt as B,
|
|
2339
|
+
or as C,
|
|
2340
|
+
tn as D,
|
|
2341
|
+
lt as E,
|
|
2342
|
+
a as F,
|
|
2343
|
+
ir as G,
|
|
2344
|
+
on as H,
|
|
2345
|
+
rr as I,
|
|
2346
|
+
ze as J,
|
|
2347
|
+
Xr as K,
|
|
2348
|
+
ee as L,
|
|
2349
|
+
Qe as M,
|
|
2350
|
+
dr as N,
|
|
2351
|
+
cr as O,
|
|
2352
|
+
ln as a,
|
|
2353
|
+
dn as b,
|
|
2354
|
+
un as c,
|
|
2355
|
+
Dr as d,
|
|
2356
|
+
_r as e,
|
|
2357
|
+
cn as f,
|
|
2358
|
+
pr as g,
|
|
2359
|
+
en as h,
|
|
2360
|
+
Zr as i,
|
|
2361
|
+
sr as j,
|
|
2362
|
+
sn as k,
|
|
2363
|
+
an as l,
|
|
2364
|
+
nn as m,
|
|
2365
|
+
Or as n,
|
|
2366
|
+
Qr as o,
|
|
2367
|
+
rn as p,
|
|
2368
|
+
zr as q,
|
|
2369
|
+
gr as r,
|
|
2370
|
+
xr as s,
|
|
2371
|
+
ar as t,
|
|
2321
2372
|
F as u,
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2373
|
+
fn as v,
|
|
2374
|
+
Br as w,
|
|
2375
|
+
Ft as x,
|
|
2376
|
+
le as y,
|
|
2377
|
+
y as z
|
|
2327
2378
|
};
|