@aixnn/aixautots 0.6.3 → 0.6.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{automation-queue-BxrSIkG3.d.ts → automation-queue-aYRO9JLj.d.ts} +2 -2
- package/dist/chunk-7CN37G3W.js +102 -0
- package/dist/{chunk-JTFZSFFA.js → chunk-7H4CYM42.js} +414 -5
- package/dist/{chunk-FW23FLAF.js → chunk-D7J4EQTA.js} +1 -1
- package/dist/{chunk-B2BOVLI6.js → chunk-F76N3GOA.js} +1077 -313
- package/dist/{chunk-P2Y655SL.js → chunk-FBWJUW4X.js} +578 -141
- package/dist/{chunk-T3QVYTOT.js → chunk-IFARWPMU.js} +364 -0
- package/dist/{chunk-LTZCKFAZ.js → chunk-LMSN6Z3N.js} +668 -103
- package/dist/{chunk-Q63FQ7B5.js → chunk-LWTL4AIC.js} +254 -13
- package/dist/{chunk-EVHTAXQG.js → chunk-SKTL6ACT.js} +5 -1
- package/dist/{chunk-6S3XLY5O.js → chunk-X5KVYWUK.js} +4 -5
- package/dist/chunk-YWA47ARA.js +1148 -0
- package/dist/{config-CLi5IhmO.d.ts → config-B7t1Ln3w.d.ts} +177 -8
- package/dist/core/index.d.ts +21 -16
- package/dist/core/index.js +2 -4
- package/dist/{device-normalize-BaThgnH7.d.ts → device-normalize-CuGflfZA.d.ts} +1 -1
- package/dist/device-session-OFGN4KUD.js +1 -0
- package/dist/i18n/index.js +1 -1
- package/dist/{mirror-session-BP7Rd3Jk.d.ts → mirror-session-DK0OQvA3.d.ts} +11 -3
- package/dist/react/index.d.ts +10 -8
- package/dist/react/index.js +3 -6
- package/dist/{script-debugger-DtUGxK9i.d.ts → script-debugger-6hoLEwEz.d.ts} +1 -1
- package/dist/{task-agent-runner-DzV_OUZ7.d.ts → task-agent-runner-BwRW88rl.d.ts} +5 -3
- package/dist/{types-C2WXVcam.d.ts → types-BbtVr3QM.d.ts} +34 -3
- package/dist/ui/billing.d.ts +1 -1
- package/dist/ui/billing.js +5 -8
- package/dist/ui/device-create.d.ts +4 -3
- package/dist/ui/device-create.js +7 -8
- package/dist/ui/device-mirror.d.ts +16 -2
- package/dist/ui/device-mirror.js +6 -7
- package/dist/ui/devices.d.ts +5 -5
- package/dist/ui/devices.js +10 -12
- package/dist/ui/editor.d.ts +2 -2
- package/dist/ui/editor.js +7 -10
- package/dist/ui/index.d.ts +4 -4
- package/dist/ui/index.js +9 -14
- package/dist/ui/inspector.js +5 -8
- package/dist/ui/market.js +4 -7
- package/dist/ui/mirror.d.ts +3 -3
- package/dist/ui/primitives/index.d.ts +1 -1
- package/dist/ui/primitives/index.js +1 -1
- package/dist/ui/script-studio.js +6 -9
- package/dist/ui/scripts.d.ts +1 -1
- package/dist/ui/scripts.js +5 -8
- package/dist/ui/tasks.js +10 -12
- package/package.json +1 -1
- package/dist/chunk-A5VNENHD.js +0 -229
- package/dist/chunk-BUW45GM2.js +0 -341
- package/dist/chunk-LAZ3RQ7X.js +0 -668
- package/dist/chunk-VVJ4TK6D.js +0 -583
- package/dist/device-session-CVT7OY4H.js +0 -2
package/dist/chunk-VVJ4TK6D.js
DELETED
|
@@ -1,583 +0,0 @@
|
|
|
1
|
-
import { MirrorView, ControlBar } from './chunk-E7WMHM63.js';
|
|
2
|
-
import { useMirror, useDevices } from './chunk-Q63FQ7B5.js';
|
|
3
|
-
import { useClient } from './chunk-A5VNENHD.js';
|
|
4
|
-
import { useState, useRef, useEffect, useCallback, useMemo } from 'react';
|
|
5
|
-
import { RotateCw, Minimize2, Maximize2, X } from 'lucide-react';
|
|
6
|
-
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
7
|
-
|
|
8
|
-
var PHASES = {
|
|
9
|
-
android: [
|
|
10
|
-
[25, "\u6B63\u5728\u8FDE\u63A5\u8BBE\u5907\u2026"],
|
|
11
|
-
[55, "\u5EFA\u7ACB\u52A0\u5BC6\u901A\u9053\u2026"],
|
|
12
|
-
[80, "\u62C9\u53D6\u5B9E\u65F6\u753B\u9762\u2026"],
|
|
13
|
-
[95, "\u5373\u5C06\u5448\u73B0\u2026"]
|
|
14
|
-
],
|
|
15
|
-
ios: [
|
|
16
|
-
[25, "\u6B63\u5728\u8FDE\u63A5\u8BBE\u5907\u2026"],
|
|
17
|
-
[55, "\u5EFA\u7ACB\u52A0\u5BC6\u901A\u9053\u2026"],
|
|
18
|
-
[80, "\u62C9\u53D6\u5B9E\u65F6\u753B\u9762\u2026"],
|
|
19
|
-
[95, "\u5373\u5C06\u5448\u73B0\u2026"]
|
|
20
|
-
]
|
|
21
|
-
};
|
|
22
|
-
function phaseLabel(phases, p) {
|
|
23
|
-
for (const [ceil, label] of phases) if (p <= ceil) return label;
|
|
24
|
-
return "\u5373\u5C06\u5448\u73B0\u2026";
|
|
25
|
-
}
|
|
26
|
-
function DeviceBootSplash({ error, expectedMs = 3e3, platform = "android", className }) {
|
|
27
|
-
const [pct, setPct] = useState(4);
|
|
28
|
-
const startRef = useRef(Date.now());
|
|
29
|
-
const phases = PHASES[platform];
|
|
30
|
-
useEffect(() => {
|
|
31
|
-
if (error) return;
|
|
32
|
-
startRef.current = Date.now();
|
|
33
|
-
setPct(4);
|
|
34
|
-
const id = setInterval(() => {
|
|
35
|
-
const elapsed = Date.now() - startRef.current;
|
|
36
|
-
const target = 95 * (1 - Math.exp(-elapsed / (expectedMs * 0.55)));
|
|
37
|
-
setPct((prev) => Math.max(prev, Math.min(95, Math.round(target))));
|
|
38
|
-
}, 250);
|
|
39
|
-
return () => clearInterval(id);
|
|
40
|
-
}, [error, expectedMs]);
|
|
41
|
-
if (error) {
|
|
42
|
-
return /* @__PURE__ */ jsxs(
|
|
43
|
-
"div",
|
|
44
|
-
{
|
|
45
|
-
className: `flex h-full w-full flex-col items-center justify-center gap-3 bg-black/80 px-6 text-center ${className ?? ""}`,
|
|
46
|
-
children: [
|
|
47
|
-
/* @__PURE__ */ jsx("div", { className: "text-2xl", children: "\u26A0\uFE0F" }),
|
|
48
|
-
/* @__PURE__ */ jsxs("div", { className: "text-sm text-white/80", children: [
|
|
49
|
-
"\u8FDE\u63A5\u5931\u8D25\uFF1A",
|
|
50
|
-
error
|
|
51
|
-
] }),
|
|
52
|
-
/* @__PURE__ */ jsx("div", { className: "text-xs text-white/40", children: "\u8BBE\u5907\u9700\u5728\u7EBF\uFF1B\u82E5\u521A\u521B\u5EFA\uFF0C\u8BF7\u7B49\u5F85\u542F\u52A8\u5B8C\u6210\u540E\u91CD\u8BD5" })
|
|
53
|
-
]
|
|
54
|
-
}
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
return /* @__PURE__ */ jsxs(
|
|
58
|
-
"div",
|
|
59
|
-
{
|
|
60
|
-
className: `flex h-full w-full flex-col items-center justify-center gap-5 bg-gradient-to-b from-zinc-900 to-black px-8 ${className ?? ""}`,
|
|
61
|
-
children: [
|
|
62
|
-
/* @__PURE__ */ jsxs("div", { className: "relative flex items-center justify-center", children: [
|
|
63
|
-
/* @__PURE__ */ jsx(
|
|
64
|
-
"span",
|
|
65
|
-
{
|
|
66
|
-
className: `absolute h-20 w-20 animate-ping rounded-full ${platform === "ios" ? "bg-sky-300/20" : "bg-emerald-400/20"}`
|
|
67
|
-
}
|
|
68
|
-
),
|
|
69
|
-
/* @__PURE__ */ jsx(
|
|
70
|
-
"span",
|
|
71
|
-
{
|
|
72
|
-
className: `absolute h-16 w-16 animate-pulse rounded-full ${platform === "ios" ? "bg-sky-300/10" : "bg-emerald-400/10"}`
|
|
73
|
-
}
|
|
74
|
-
),
|
|
75
|
-
platform === "ios" ? /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", className: "h-12 w-12 text-sky-200", fill: "currentColor", "aria-hidden": true, children: /* @__PURE__ */ jsx("path", { d: "M16.37 12.78c-.02-2.05 1.67-3.03 1.75-3.08-.95-1.39-2.43-1.58-2.96-1.6-1.26-.13-2.46.74-3.1.74-.64 0-1.62-.72-2.66-.7-1.37.02-2.63.8-3.33 2.02-1.42 2.47-.36 6.12 1.02 8.13.67.98 1.48 2.08 2.53 2.04 1.02-.04 1.4-.66 2.63-.66 1.22 0 1.57.66 2.65.64 1.09-.02 1.79-1 2.46-1.98.77-1.13 1.09-2.23 1.11-2.29-.02-.01-2.13-.82-2.15-3.25ZM14.4 6.45c.56-.68.94-1.62.84-2.56-.81.03-1.79.54-2.37 1.21-.52.6-.97 1.56-.85 2.48.9.07 1.82-.46 2.38-1.13Z" }) }) : /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", className: "h-12 w-12 text-emerald-400", fill: "currentColor", "aria-hidden": true, children: /* @__PURE__ */ jsx("path", { d: "M6 9a6 6 0 0 1 12 0v6a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1V9Zm2.5-3.2 -1-1.6a.4.4 0 0 1 .7-.4l1.05 1.7a6.7 6.7 0 0 1 3.5 0l1.05-1.7a.4.4 0 1 1 .7.4l-1 1.6A6 6 0 0 0 8.5 5.8ZM9.5 9.2a.9.9 0 1 0 0 1.8.9.9 0 0 0 0-1.8Zm5 0a.9.9 0 1 0 0 1.8.9.9 0 0 0 0-1.8ZM5 11a1 1 0 0 1 1 1v4a1 1 0 1 1-2 0v-4a1 1 0 0 1 1-1Zm14 0a1 1 0 0 1 1 1v4a1 1 0 1 1-2 0v-4a1 1 0 0 1 1-1ZM9 17h6a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1 1 1 0 1 1-2 0h-2a1 1 0 1 1-2 0 1 1 0 0 1-1-1v-2a1 1 0 0 1 1-1Z" }) })
|
|
76
|
-
] }),
|
|
77
|
-
/* @__PURE__ */ jsxs("div", { className: "w-full max-w-[220px] space-y-2", children: [
|
|
78
|
-
/* @__PURE__ */ jsx("div", { className: "h-1.5 w-full overflow-hidden rounded-full bg-white/10", children: /* @__PURE__ */ jsx(
|
|
79
|
-
"div",
|
|
80
|
-
{
|
|
81
|
-
className: `h-full rounded-full transition-[width] duration-300 ease-out ${platform === "ios" ? "bg-sky-300" : "bg-emerald-400"}`,
|
|
82
|
-
style: { width: `${pct}%` }
|
|
83
|
-
}
|
|
84
|
-
) }),
|
|
85
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between text-xs", children: [
|
|
86
|
-
/* @__PURE__ */ jsx("span", { className: "text-white/70", children: phaseLabel(phases, pct) }),
|
|
87
|
-
/* @__PURE__ */ jsxs("span", { className: "tabular-nums text-white/40", children: [
|
|
88
|
-
pct,
|
|
89
|
-
"%"
|
|
90
|
-
] })
|
|
91
|
-
] })
|
|
92
|
-
] }),
|
|
93
|
-
/* @__PURE__ */ jsx("div", { className: "text-[11px] text-white/30", children: "\u6B63\u5728\u8FDE\u63A5\u5B9E\u65F6\u753B\u9762\uFF0C\u5C31\u7EEA\u540E\u81EA\u52A8\u663E\u793A" })
|
|
94
|
-
]
|
|
95
|
-
}
|
|
96
|
-
);
|
|
97
|
-
}
|
|
98
|
-
function useClipboardSync(deviceId, active) {
|
|
99
|
-
const client = useClient();
|
|
100
|
-
const [error, setError] = useState(null);
|
|
101
|
-
const [conflict, setConflict] = useState(false);
|
|
102
|
-
const resolveRef = useRef(() => {
|
|
103
|
-
});
|
|
104
|
-
useEffect(() => {
|
|
105
|
-
setError(null);
|
|
106
|
-
setConflict(false);
|
|
107
|
-
if (!active) return;
|
|
108
|
-
let stopped = false;
|
|
109
|
-
let busy = false;
|
|
110
|
-
let pending = false;
|
|
111
|
-
let generation = 0;
|
|
112
|
-
let preferred;
|
|
113
|
-
let copyVersion = 0;
|
|
114
|
-
let observedCopyVersion = 0;
|
|
115
|
-
let timer;
|
|
116
|
-
let local;
|
|
117
|
-
let remote;
|
|
118
|
-
const visible = () => !stopped && document.hasFocus() && document.visibilityState !== "hidden";
|
|
119
|
-
const poll = async () => {
|
|
120
|
-
if (busy) {
|
|
121
|
-
pending = true;
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
busy = true;
|
|
125
|
-
const choice = preferred;
|
|
126
|
-
const observedVersion = copyVersion;
|
|
127
|
-
preferred = void 0;
|
|
128
|
-
clearTimeout(timer);
|
|
129
|
-
try {
|
|
130
|
-
if (!visible()) return;
|
|
131
|
-
if (!navigator.clipboard?.readText) throw new Error("\u6D4F\u89C8\u5668\u4E0D\u652F\u6301\u526A\u8D34\u677F\uFF0C\u8BF7\u4F7F\u7528 HTTPS \u5E76\u5141\u8BB8\u526A\u8D34\u677F\u6743\u9650");
|
|
132
|
-
const version = generation;
|
|
133
|
-
const host = await navigator.clipboard.readText();
|
|
134
|
-
if (!visible() || version !== generation) return;
|
|
135
|
-
const device = await client.devices.op(deviceId, { op: "get_clipboard" });
|
|
136
|
-
if (!visible() || version !== generation) return;
|
|
137
|
-
const latest = await navigator.clipboard.readText();
|
|
138
|
-
if (!visible() || version !== generation || latest !== host) {
|
|
139
|
-
pending = true;
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
if (local === void 0 || remote === void 0) {
|
|
143
|
-
local = host;
|
|
144
|
-
remote = device.text;
|
|
145
|
-
observedCopyVersion = observedVersion;
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
const selected = choice && choice.local === host && choice.remote === device.text && choice.copyVersion === copyVersion ? choice.side : void 0;
|
|
149
|
-
const ambiguousCopy = copyVersion !== observedCopyVersion && host === local && selected === void 0;
|
|
150
|
-
const hostChanged = selected === "local" || selected !== "device" && host !== local;
|
|
151
|
-
const deviceChanged = selected === "device" || selected !== "local" && device.text !== remote;
|
|
152
|
-
if (host === device.text) {
|
|
153
|
-
local = remote = host;
|
|
154
|
-
} else if (hostChanged && deviceChanged || ambiguousCopy) {
|
|
155
|
-
local = host;
|
|
156
|
-
remote = device.text;
|
|
157
|
-
observedCopyVersion = observedVersion;
|
|
158
|
-
setConflict(true);
|
|
159
|
-
throw new Error("\u4E24\u7AEF\u540C\u65F6\u590D\u5236\uFF0C\u65E0\u6CD5\u5224\u5B9A\u5148\u540E\uFF1B\u8BF7\u9009\u62E9\u9700\u8981\u4FDD\u7559\u7684\u5185\u5BB9");
|
|
160
|
-
} else if (hostChanged) {
|
|
161
|
-
await client.devices.op(deviceId, { op: "set_clipboard", text: host, expected_text: device.text });
|
|
162
|
-
if (!visible()) return;
|
|
163
|
-
local = remote = host;
|
|
164
|
-
} else if (deviceChanged) {
|
|
165
|
-
await navigator.clipboard.writeText(device.text);
|
|
166
|
-
if (!visible()) return;
|
|
167
|
-
local = remote = device.text;
|
|
168
|
-
}
|
|
169
|
-
if (host === device.text || hostChanged || deviceChanged) {
|
|
170
|
-
observedCopyVersion = observedVersion;
|
|
171
|
-
if (!stopped) {
|
|
172
|
-
setError(null);
|
|
173
|
-
setConflict(false);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
} catch (e) {
|
|
177
|
-
if (!stopped) setError(e instanceof Error ? e.message : String(e));
|
|
178
|
-
} finally {
|
|
179
|
-
busy = false;
|
|
180
|
-
if (!stopped) {
|
|
181
|
-
timer = setTimeout(poll, pending ? 0 : 700);
|
|
182
|
-
pending = false;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
};
|
|
186
|
-
resolveRef.current = (side) => {
|
|
187
|
-
if (local === void 0 || remote === void 0) return;
|
|
188
|
-
preferred = { side, local, remote, copyVersion: observedCopyVersion };
|
|
189
|
-
void poll();
|
|
190
|
-
};
|
|
191
|
-
const changed = () => {
|
|
192
|
-
generation++;
|
|
193
|
-
void poll();
|
|
194
|
-
};
|
|
195
|
-
const copied = () => {
|
|
196
|
-
copyVersion++;
|
|
197
|
-
changed();
|
|
198
|
-
};
|
|
199
|
-
const focus = () => {
|
|
200
|
-
if (visible()) changed();
|
|
201
|
-
};
|
|
202
|
-
navigator.clipboard?.addEventListener?.("clipboardchange", copied);
|
|
203
|
-
window.addEventListener("focus", focus);
|
|
204
|
-
document.addEventListener("visibilitychange", focus);
|
|
205
|
-
void poll();
|
|
206
|
-
return () => {
|
|
207
|
-
stopped = true;
|
|
208
|
-
resolveRef.current = () => {
|
|
209
|
-
};
|
|
210
|
-
clearTimeout(timer);
|
|
211
|
-
navigator.clipboard?.removeEventListener?.("clipboardchange", copied);
|
|
212
|
-
window.removeEventListener("focus", focus);
|
|
213
|
-
document.removeEventListener("visibilitychange", focus);
|
|
214
|
-
};
|
|
215
|
-
}, [deviceId, active, client]);
|
|
216
|
-
return { error, conflict, resolveConflict: (side) => resolveRef.current(side) };
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
// src/core/quality-auto.ts
|
|
220
|
-
var RTT_HIGH = 0.15;
|
|
221
|
-
var RTT_LOW = 0.04;
|
|
222
|
-
var HYSTERESIS = 0.03;
|
|
223
|
-
function pickAutoProfile(rtt, current) {
|
|
224
|
-
if (current === "low_latency") {
|
|
225
|
-
if (rtt >= RTT_HIGH - HYSTERESIS) return "low_latency";
|
|
226
|
-
return rtt < RTT_LOW ? "high_quality" : "balanced";
|
|
227
|
-
}
|
|
228
|
-
if (current === "high_quality") {
|
|
229
|
-
if (rtt <= RTT_LOW + HYSTERESIS) return "high_quality";
|
|
230
|
-
return rtt > RTT_HIGH ? "low_latency" : "balanced";
|
|
231
|
-
}
|
|
232
|
-
if (rtt > RTT_HIGH) return "low_latency";
|
|
233
|
-
if (rtt < RTT_LOW) return "high_quality";
|
|
234
|
-
return "balanced";
|
|
235
|
-
}
|
|
236
|
-
var PROFILE_LABELS = {
|
|
237
|
-
balanced: "\u5E73\u8861",
|
|
238
|
-
low_latency: "\u4F4E\u5EF6\u8FDF",
|
|
239
|
-
high_quality: "\u9AD8\u753B\u8D28"
|
|
240
|
-
};
|
|
241
|
-
var DEFAULT_SIZE = { width: 1080, height: 2340 };
|
|
242
|
-
var AUTO_QUALITY_FIRST_CHECK_MS = 2e3;
|
|
243
|
-
var AUTO_QUALITY_INTERVAL_MS = 8e3;
|
|
244
|
-
var AUTO_QUALITY_MIN_SWITCH_INTERVAL_MS = 15e3;
|
|
245
|
-
function MirrorSurface({ deviceId, platform = "android", onSize, videoAspect, shortcutBar, className }) {
|
|
246
|
-
const { stream, error, sendInput, setQuality, session } = useMirror(deviceId);
|
|
247
|
-
const [clipboardSync, setClipboardSync] = useState(false);
|
|
248
|
-
const { error: clipboardError, conflict: clipboardConflict, resolveConflict } = useClipboardSync(deviceId, clipboardSync && !!stream);
|
|
249
|
-
const [size, setSize] = useState(DEFAULT_SIZE);
|
|
250
|
-
const [hasFrame, setHasFrame] = useState(false);
|
|
251
|
-
useEffect(() => {
|
|
252
|
-
setHasFrame(false);
|
|
253
|
-
setVolume(0);
|
|
254
|
-
}, [deviceId, stream]);
|
|
255
|
-
useEffect(() => {
|
|
256
|
-
setSize(DEFAULT_SIZE);
|
|
257
|
-
onSize?.(DEFAULT_SIZE);
|
|
258
|
-
}, [deviceId, onSize]);
|
|
259
|
-
const [profile, setProfile] = useState("balanced");
|
|
260
|
-
const manualRef = useRef(false);
|
|
261
|
-
const changeProfile = useCallback(
|
|
262
|
-
(p, manual) => {
|
|
263
|
-
if (manual) manualRef.current = true;
|
|
264
|
-
setProfile(p);
|
|
265
|
-
setQuality(p);
|
|
266
|
-
},
|
|
267
|
-
[setQuality]
|
|
268
|
-
);
|
|
269
|
-
const landscape = size.width > size.height;
|
|
270
|
-
const [volume, setVolume] = useState(0);
|
|
271
|
-
const audioEnabledRef = useRef(false);
|
|
272
|
-
useEffect(() => () => {
|
|
273
|
-
if (audioEnabledRef.current) sendInput({ t: "audio", enabled: false });
|
|
274
|
-
audioEnabledRef.current = false;
|
|
275
|
-
}, [stream, sendInput]);
|
|
276
|
-
const [hasAudio, setHasAudio] = useState(false);
|
|
277
|
-
useEffect(() => {
|
|
278
|
-
const update = () => setHasAudio(!!stream?.getAudioTracks().some((t) => t.readyState === "live"));
|
|
279
|
-
update();
|
|
280
|
-
stream?.addEventListener("addtrack", update);
|
|
281
|
-
stream?.addEventListener("removetrack", update);
|
|
282
|
-
return () => {
|
|
283
|
-
stream?.removeEventListener("addtrack", update);
|
|
284
|
-
stream?.removeEventListener("removetrack", update);
|
|
285
|
-
};
|
|
286
|
-
}, [stream]);
|
|
287
|
-
const toggleOrientation = useCallback(() => {
|
|
288
|
-
sendInput({ t: "rotate", orientation: landscape ? "portrait" : "landscape" });
|
|
289
|
-
}, [sendInput, landscape]);
|
|
290
|
-
useEffect(() => {
|
|
291
|
-
manualRef.current = false;
|
|
292
|
-
setProfile("balanced");
|
|
293
|
-
setVolume(0);
|
|
294
|
-
}, [deviceId]);
|
|
295
|
-
const profileRef = useRef(profile);
|
|
296
|
-
useEffect(() => {
|
|
297
|
-
profileRef.current = profile;
|
|
298
|
-
}, [profile]);
|
|
299
|
-
useEffect(() => {
|
|
300
|
-
if (!stream || !session) return;
|
|
301
|
-
let cancelled = false;
|
|
302
|
-
let lastSwitchAt = 0;
|
|
303
|
-
const check = async () => {
|
|
304
|
-
if (cancelled || manualRef.current) return;
|
|
305
|
-
const rtt = await session.currentRtt();
|
|
306
|
-
if (cancelled || rtt === null || manualRef.current) return;
|
|
307
|
-
const next = pickAutoProfile(rtt, profileRef.current);
|
|
308
|
-
if (next === profileRef.current) return;
|
|
309
|
-
const now = Date.now();
|
|
310
|
-
if (now - lastSwitchAt < AUTO_QUALITY_MIN_SWITCH_INTERVAL_MS) return;
|
|
311
|
-
lastSwitchAt = now;
|
|
312
|
-
changeProfile(next, false);
|
|
313
|
-
};
|
|
314
|
-
const first = setTimeout(check, AUTO_QUALITY_FIRST_CHECK_MS);
|
|
315
|
-
const interval = setInterval(check, AUTO_QUALITY_INTERVAL_MS);
|
|
316
|
-
return () => {
|
|
317
|
-
cancelled = true;
|
|
318
|
-
clearTimeout(first);
|
|
319
|
-
clearInterval(interval);
|
|
320
|
-
};
|
|
321
|
-
}, [stream, session, changeProfile]);
|
|
322
|
-
const reportSize = useCallback(
|
|
323
|
-
(real) => {
|
|
324
|
-
if (real.width > 0 && real.height > 0) {
|
|
325
|
-
setSize(real);
|
|
326
|
-
onSize?.(real);
|
|
327
|
-
}
|
|
328
|
-
},
|
|
329
|
-
[onSize]
|
|
330
|
-
);
|
|
331
|
-
const handleFirstFrame = useCallback(
|
|
332
|
-
(real) => {
|
|
333
|
-
setHasFrame(true);
|
|
334
|
-
reportSize(real);
|
|
335
|
-
},
|
|
336
|
-
[reportSize]
|
|
337
|
-
);
|
|
338
|
-
return /* @__PURE__ */ jsxs("div", { className: `flex min-h-0 flex-col items-center gap-2 ${className ?? ""}`, children: [
|
|
339
|
-
/* @__PURE__ */ jsxs("div", { className: "flex min-h-0 w-full flex-1 items-stretch justify-center gap-2", children: [
|
|
340
|
-
shortcutBar,
|
|
341
|
-
/* @__PURE__ */ jsxs(
|
|
342
|
-
"div",
|
|
343
|
-
{
|
|
344
|
-
className: `relative min-h-0 overflow-hidden rounded-lg ${videoAspect ? "h-full" : "h-full flex-1"}`,
|
|
345
|
-
style: videoAspect ? { aspectRatio: String(videoAspect) } : void 0,
|
|
346
|
-
children: [
|
|
347
|
-
stream && /* @__PURE__ */ jsx(
|
|
348
|
-
MirrorView,
|
|
349
|
-
{
|
|
350
|
-
stream,
|
|
351
|
-
volume: volume / 100,
|
|
352
|
-
deviceSize: size,
|
|
353
|
-
onInput: sendInput,
|
|
354
|
-
onFirstFrame: handleFirstFrame,
|
|
355
|
-
onResize: reportSize,
|
|
356
|
-
continuousTouch: platform === "android",
|
|
357
|
-
className: "h-full w-full"
|
|
358
|
-
}
|
|
359
|
-
),
|
|
360
|
-
(!stream || !hasFrame) && /* @__PURE__ */ jsx("div", { className: "absolute inset-0", children: /* @__PURE__ */ jsx(
|
|
361
|
-
DeviceBootSplash,
|
|
362
|
-
{
|
|
363
|
-
error: error ? error.message : null,
|
|
364
|
-
platform,
|
|
365
|
-
className: "rounded-lg"
|
|
366
|
-
}
|
|
367
|
-
) })
|
|
368
|
-
]
|
|
369
|
-
}
|
|
370
|
-
)
|
|
371
|
-
] }),
|
|
372
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center justify-center gap-2", children: [
|
|
373
|
-
/* @__PURE__ */ jsx(
|
|
374
|
-
ControlBar,
|
|
375
|
-
{
|
|
376
|
-
platform,
|
|
377
|
-
onBack: () => sendInput({ t: "back" }),
|
|
378
|
-
onHome: () => sendInput({ t: "home" }),
|
|
379
|
-
onMenu: () => sendInput({ t: "key", code: "app_switch" })
|
|
380
|
-
}
|
|
381
|
-
),
|
|
382
|
-
/* @__PURE__ */ jsx(
|
|
383
|
-
"select",
|
|
384
|
-
{
|
|
385
|
-
"aria-label": "\u753B\u8D28\u6863\u4F4D",
|
|
386
|
-
value: profile,
|
|
387
|
-
onChange: (e) => changeProfile(e.target.value, true),
|
|
388
|
-
className: "rounded border border-border bg-secondary px-2 py-1 text-xs text-foreground outline-none hover:bg-card",
|
|
389
|
-
children: Object.keys(PROFILE_LABELS).map((p) => /* @__PURE__ */ jsx("option", { value: p, children: PROFILE_LABELS[p] }, p))
|
|
390
|
-
}
|
|
391
|
-
),
|
|
392
|
-
/* @__PURE__ */ jsxs("label", { className: "flex items-center gap-1 text-xs text-foreground", children: [
|
|
393
|
-
"\u97F3\u91CF",
|
|
394
|
-
/* @__PURE__ */ jsx(
|
|
395
|
-
"input",
|
|
396
|
-
{
|
|
397
|
-
type: "range",
|
|
398
|
-
"aria-label": "\u64AD\u653E\u97F3\u91CF",
|
|
399
|
-
min: 0,
|
|
400
|
-
max: 100,
|
|
401
|
-
value: volume,
|
|
402
|
-
disabled: !stream,
|
|
403
|
-
onChange: (e) => {
|
|
404
|
-
const next = Number(e.target.value);
|
|
405
|
-
if (audioEnabledRef.current !== next > 0) sendInput({ t: "audio", enabled: next > 0 });
|
|
406
|
-
audioEnabledRef.current = next > 0;
|
|
407
|
-
setVolume(next);
|
|
408
|
-
},
|
|
409
|
-
className: "w-20"
|
|
410
|
-
}
|
|
411
|
-
),
|
|
412
|
-
/* @__PURE__ */ jsx("span", { children: volume > 0 && !hasAudio ? "\u7B49\u5F85\u97F3\u9891\u6D41" : `${volume}%` })
|
|
413
|
-
] }),
|
|
414
|
-
/* @__PURE__ */ jsxs("label", { className: "flex items-center gap-1 text-xs text-foreground", children: [
|
|
415
|
-
/* @__PURE__ */ jsx("input", { type: "checkbox", checked: clipboardSync, onChange: (e) => setClipboardSync(e.target.checked) }),
|
|
416
|
-
"\u53CC\u5411\u540C\u6B65\u526A\u8D34\u677F"
|
|
417
|
-
] }),
|
|
418
|
-
clipboardConflict && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
419
|
-
/* @__PURE__ */ jsx("button", { type: "button", onClick: () => resolveConflict("local"), className: "text-xs underline", children: "\u4FDD\u7559\u672C\u673A\u526A\u8D34\u677F" }),
|
|
420
|
-
/* @__PURE__ */ jsx("button", { type: "button", onClick: () => resolveConflict("device"), className: "text-xs underline", children: "\u4FDD\u7559\u8BBE\u5907\u526A\u8D34\u677F" })
|
|
421
|
-
] }),
|
|
422
|
-
clipboardError && /* @__PURE__ */ jsxs("span", { role: "status", className: "text-xs text-destructive", children: [
|
|
423
|
-
"\u526A\u8D34\u677F\u540C\u6B65\u5931\u8D25\uFF1A",
|
|
424
|
-
clipboardError
|
|
425
|
-
] }),
|
|
426
|
-
platform === "android" && /* @__PURE__ */ jsxs(
|
|
427
|
-
"button",
|
|
428
|
-
{
|
|
429
|
-
type: "button",
|
|
430
|
-
onClick: toggleOrientation,
|
|
431
|
-
"aria-label": landscape ? "\u5207\u56DE\u7AD6\u5C4F" : "\u5207\u6362\u6A2A\u5C4F",
|
|
432
|
-
title: landscape ? "\u5207\u56DE\u7AD6\u5C4F" : "\u5207\u6362\u6A2A\u5C4F",
|
|
433
|
-
"aria-pressed": landscape,
|
|
434
|
-
className: `flex items-center gap-1 rounded border border-border px-2 py-1 text-xs outline-none hover:bg-card ${landscape ? "bg-primary/15 text-primary" : "bg-secondary text-foreground"}`,
|
|
435
|
-
children: [
|
|
436
|
-
/* @__PURE__ */ jsx(RotateCw, { className: "h-3.5 w-3.5" }),
|
|
437
|
-
landscape ? "\u7AD6\u5C4F" : "\u6A2A\u5C4F"
|
|
438
|
-
]
|
|
439
|
-
}
|
|
440
|
-
)
|
|
441
|
-
] })
|
|
442
|
-
] });
|
|
443
|
-
}
|
|
444
|
-
function DeviceMirror({ deviceId, deviceName, platform = "android", shortcutBar, onClose }) {
|
|
445
|
-
const open = deviceId !== null;
|
|
446
|
-
const client = useClient();
|
|
447
|
-
const { data: devices } = useDevices();
|
|
448
|
-
const [size, setSize] = useState({ width: 1080, height: 2340 });
|
|
449
|
-
const overlayRef = useRef(null);
|
|
450
|
-
const [fullscreen, setFullscreen] = useState(false);
|
|
451
|
-
const sleepTimeoutMin = useMemo(() => {
|
|
452
|
-
if (!deviceId) return 30;
|
|
453
|
-
const d = devices?.find((dv) => dv.external_id === deviceId);
|
|
454
|
-
const v = d?.meta?.sleep_timeout_min;
|
|
455
|
-
return typeof v === "number" ? v : 30;
|
|
456
|
-
}, [devices, deviceId]);
|
|
457
|
-
const lastActivityRef = useRef(Date.now());
|
|
458
|
-
const resetActivity = useCallback(() => {
|
|
459
|
-
lastActivityRef.current = Date.now();
|
|
460
|
-
}, []);
|
|
461
|
-
useEffect(() => {
|
|
462
|
-
if (!open || !deviceId || sleepTimeoutMin === 0) return;
|
|
463
|
-
const ms = sleepTimeoutMin * 60 * 1e3;
|
|
464
|
-
const id = setInterval(() => {
|
|
465
|
-
if (Date.now() - lastActivityRef.current >= ms) {
|
|
466
|
-
void client.devices.sleep(deviceId).then(() => onClose()).catch(() => {
|
|
467
|
-
});
|
|
468
|
-
clearInterval(id);
|
|
469
|
-
}
|
|
470
|
-
}, 1e4);
|
|
471
|
-
return () => clearInterval(id);
|
|
472
|
-
}, [open, deviceId, sleepTimeoutMin, onClose, client]);
|
|
473
|
-
const enterFullscreen = useCallback(async () => {
|
|
474
|
-
const el = overlayRef.current;
|
|
475
|
-
if (!el) return;
|
|
476
|
-
try {
|
|
477
|
-
if (el.requestFullscreen) await el.requestFullscreen();
|
|
478
|
-
else if (el.webkitRequestFullscreen) await el.webkitRequestFullscreen();
|
|
479
|
-
} catch {
|
|
480
|
-
}
|
|
481
|
-
}, []);
|
|
482
|
-
const exitFullscreen = useCallback(async () => {
|
|
483
|
-
const doc = document;
|
|
484
|
-
try {
|
|
485
|
-
if (doc.fullscreenElement && doc.exitFullscreen) await doc.exitFullscreen();
|
|
486
|
-
else if (doc.webkitFullscreenElement && doc.webkitExitFullscreen) await doc.webkitExitFullscreen();
|
|
487
|
-
} catch {
|
|
488
|
-
}
|
|
489
|
-
}, []);
|
|
490
|
-
const toggleFullscreen = useCallback(() => {
|
|
491
|
-
if (fullscreen) void exitFullscreen();
|
|
492
|
-
else void enterFullscreen();
|
|
493
|
-
}, [fullscreen, enterFullscreen, exitFullscreen]);
|
|
494
|
-
useEffect(() => {
|
|
495
|
-
const onFsChange = () => {
|
|
496
|
-
const doc = document;
|
|
497
|
-
const fsEl = doc.fullscreenElement || doc.webkitFullscreenElement || null;
|
|
498
|
-
setFullscreen(fsEl === overlayRef.current);
|
|
499
|
-
};
|
|
500
|
-
document.addEventListener("fullscreenchange", onFsChange);
|
|
501
|
-
document.addEventListener("webkitfullscreenchange", onFsChange);
|
|
502
|
-
return () => {
|
|
503
|
-
document.removeEventListener("fullscreenchange", onFsChange);
|
|
504
|
-
document.removeEventListener("webkitfullscreenchange", onFsChange);
|
|
505
|
-
};
|
|
506
|
-
}, []);
|
|
507
|
-
useEffect(() => {
|
|
508
|
-
if (!open) return;
|
|
509
|
-
const onKey = (e) => {
|
|
510
|
-
resetActivity();
|
|
511
|
-
if (e.key === "Escape" && !fullscreen) onClose();
|
|
512
|
-
};
|
|
513
|
-
window.addEventListener("keydown", onKey);
|
|
514
|
-
return () => window.removeEventListener("keydown", onKey);
|
|
515
|
-
}, [open, onClose, resetActivity, fullscreen]);
|
|
516
|
-
useEffect(() => {
|
|
517
|
-
if (!open) void exitFullscreen();
|
|
518
|
-
}, [open, exitFullscreen]);
|
|
519
|
-
const stop = useCallback((e) => e.stopPropagation(), []);
|
|
520
|
-
if (!open) return null;
|
|
521
|
-
const aspect = size.width > 0 && size.height > 0 ? size.width / size.height : 9 / 16;
|
|
522
|
-
return /* @__PURE__ */ jsx(
|
|
523
|
-
"div",
|
|
524
|
-
{
|
|
525
|
-
ref: overlayRef,
|
|
526
|
-
className: "fixed inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-sm",
|
|
527
|
-
onClick: onClose,
|
|
528
|
-
onMouseMove: resetActivity,
|
|
529
|
-
onPointerDown: resetActivity,
|
|
530
|
-
children: /* @__PURE__ */ jsxs(
|
|
531
|
-
"div",
|
|
532
|
-
{
|
|
533
|
-
className: `flex flex-col items-center ${fullscreen ? "h-full w-full gap-1 py-2" : "gap-3"}`,
|
|
534
|
-
onClick: stop,
|
|
535
|
-
children: [
|
|
536
|
-
/* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between gap-3 px-2 text-white/90", children: [
|
|
537
|
-
/* @__PURE__ */ jsxs("span", { className: "text-sm font-medium truncate max-w-[50vw]", children: [
|
|
538
|
-
deviceName || deviceId,
|
|
539
|
-
" \xB7 \u5B9E\u65F6\u955C\u50CF"
|
|
540
|
-
] }),
|
|
541
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
|
|
542
|
-
/* @__PURE__ */ jsx(
|
|
543
|
-
"button",
|
|
544
|
-
{
|
|
545
|
-
type: "button",
|
|
546
|
-
"aria-label": fullscreen ? "\u9000\u51FA\u5168\u5C4F" : "\u5168\u5C4F",
|
|
547
|
-
title: fullscreen ? "\u9000\u51FA\u5168\u5C4F" : "\u5168\u5C4F",
|
|
548
|
-
onClick: toggleFullscreen,
|
|
549
|
-
className: "rounded p-1 hover:bg-white/10",
|
|
550
|
-
children: fullscreen ? /* @__PURE__ */ jsx(Minimize2, { className: "h-5 w-5" }) : /* @__PURE__ */ jsx(Maximize2, { className: "h-5 w-5" })
|
|
551
|
-
}
|
|
552
|
-
),
|
|
553
|
-
/* @__PURE__ */ jsx(
|
|
554
|
-
"button",
|
|
555
|
-
{
|
|
556
|
-
type: "button",
|
|
557
|
-
"aria-label": "\u5173\u95ED",
|
|
558
|
-
onClick: onClose,
|
|
559
|
-
className: "rounded p-1 hover:bg-white/10",
|
|
560
|
-
children: /* @__PURE__ */ jsx(X, { className: "h-5 w-5" })
|
|
561
|
-
}
|
|
562
|
-
)
|
|
563
|
-
] })
|
|
564
|
-
] }),
|
|
565
|
-
/* @__PURE__ */ jsx("div", { className: `min-h-0 ${fullscreen ? "flex-1" : ""}`, style: fullscreen ? void 0 : { height: "80vh" }, children: /* @__PURE__ */ jsx(
|
|
566
|
-
MirrorSurface,
|
|
567
|
-
{
|
|
568
|
-
deviceId,
|
|
569
|
-
platform,
|
|
570
|
-
onSize: setSize,
|
|
571
|
-
videoAspect: aspect,
|
|
572
|
-
shortcutBar,
|
|
573
|
-
className: "h-full"
|
|
574
|
-
}
|
|
575
|
-
) })
|
|
576
|
-
]
|
|
577
|
-
}
|
|
578
|
-
)
|
|
579
|
-
}
|
|
580
|
-
);
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
export { DeviceBootSplash, DeviceMirror, MirrorSurface };
|