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