@aixnn/aixautots 0.6.1 → 0.6.3

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.
@@ -1,6 +1,6 @@
1
1
  import { useAixT } from './chunk-T3QVYTOT.js';
2
2
  import { LogConsole } from './chunk-FW23FLAF.js';
3
- import { MirrorSurface, DeviceMirror } from './chunk-M7CKUC4U.js';
3
+ import { MirrorSurface, DeviceMirror } from './chunk-VVJ4TK6D.js';
4
4
  import { ControlBar, MirrorView } from './chunk-E7WMHM63.js';
5
5
  import { createProxyProbeGuard, proxySummaryFromDevice, isProxyApplyStatus, proxyCapabilityReason, proxyProbeExitIp, proxyProbeMessage, DeviceCreate, isProxyProbeUnsupported, isRedactedProxyUrl, isSupportedProxyUrl, redactProxyUrl } from './chunk-P2Y655SL.js';
6
6
  import { cn, Badge, Button, Dialog, Input, Popover, Select, useToast, ToastViewport, Drawer } from './chunk-EVHTAXQG.js';
@@ -3,7 +3,7 @@ import { useMirror, useDevices } from './chunk-Q63FQ7B5.js';
3
3
  import { useClient } from './chunk-A5VNENHD.js';
4
4
  import { useState, useRef, useEffect, useCallback, useMemo } from 'react';
5
5
  import { RotateCw, Minimize2, Maximize2, X } from 'lucide-react';
6
- import { jsxs, jsx } from 'react/jsx-runtime';
6
+ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
7
7
 
8
8
  var PHASES = {
9
9
  android: [
@@ -95,6 +95,126 @@ function DeviceBootSplash({ error, expectedMs = 3e3, platform = "android", class
95
95
  }
96
96
  );
97
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
+ }
98
218
 
99
219
  // src/core/quality-auto.ts
100
220
  var RTT_HIGH = 0.15;
@@ -124,6 +244,8 @@ var AUTO_QUALITY_INTERVAL_MS = 8e3;
124
244
  var AUTO_QUALITY_MIN_SWITCH_INTERVAL_MS = 15e3;
125
245
  function MirrorSurface({ deviceId, platform = "android", onSize, videoAspect, shortcutBar, className }) {
126
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);
127
249
  const [size, setSize] = useState(DEFAULT_SIZE);
128
250
  const [hasFrame, setHasFrame] = useState(false);
129
251
  useEffect(() => {
@@ -277,7 +399,7 @@ function MirrorSurface({ deviceId, platform = "android", onSize, videoAspect, sh
277
399
  min: 0,
278
400
  max: 100,
279
401
  value: volume,
280
- disabled: !hasAudio,
402
+ disabled: !stream,
281
403
  onChange: (e) => {
282
404
  const next = Number(e.target.value);
283
405
  if (audioEnabledRef.current !== next > 0) sendInput({ t: "audio", enabled: next > 0 });
@@ -287,7 +409,19 @@ function MirrorSurface({ deviceId, platform = "android", onSize, videoAspect, sh
287
409
  className: "w-20"
288
410
  }
289
411
  ),
290
- /* @__PURE__ */ jsx("span", { children: hasAudio ? `${volume}%` : "\u65E0\u97F3\u9891\u6D41" })
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
291
425
  ] }),
292
426
  platform === "android" && /* @__PURE__ */ jsxs(
293
427
  "button",
@@ -1,4 +1,4 @@
1
- export { DeviceBootSplash, DeviceMirror, MirrorSurface } from '../chunk-M7CKUC4U.js';
1
+ export { DeviceBootSplash, DeviceMirror, MirrorSurface } from '../chunk-VVJ4TK6D.js';
2
2
  import '../chunk-OEZFYKL6.js';
3
3
  import '../chunk-E7WMHM63.js';
4
4
  import '../chunk-Q63FQ7B5.js';
@@ -1,7 +1,7 @@
1
- export { BulkInstallAppsDialog, DeleteDeviceDialog, DeviceCard, DeviceConnect, DeviceDetailDrawer, DeviceEditDialog, DeviceSelector, DeviceTerminal, DevicesPage, FileManager, FingerprintPanel, GroupMirrorModal, NodeRegister, RecycleBinPanel, RefreshParamsButton, RunScriptDialog, ScriptParamForm, SharedParamsForm, ShortcutBar, ShortcutEditDialog, ShortcutRunDialog, TagEditor, TaskAgentDialog, resolveSharedRow, variablesToParams } from '../chunk-VKPKHUHU.js';
1
+ export { BulkInstallAppsDialog, DeleteDeviceDialog, DeviceCard, DeviceConnect, DeviceDetailDrawer, DeviceEditDialog, DeviceSelector, DeviceTerminal, DevicesPage, FileManager, FingerprintPanel, GroupMirrorModal, NodeRegister, RecycleBinPanel, RefreshParamsButton, RunScriptDialog, ScriptParamForm, SharedParamsForm, ShortcutBar, ShortcutEditDialog, ShortcutRunDialog, TagEditor, TaskAgentDialog, resolveSharedRow, variablesToParams } from '../chunk-LTZCKFAZ.js';
2
2
  import '../chunk-T3QVYTOT.js';
3
3
  import '../chunk-FW23FLAF.js';
4
- import '../chunk-M7CKUC4U.js';
4
+ import '../chunk-VVJ4TK6D.js';
5
5
  import '../chunk-OEZFYKL6.js';
6
6
  import '../chunk-E7WMHM63.js';
7
7
  import '../chunk-P2Y655SL.js';
package/dist/ui/tasks.js CHANGED
@@ -1,7 +1,7 @@
1
- import { SharedParamsForm, resolveSharedRow } from '../chunk-VKPKHUHU.js';
1
+ import { SharedParamsForm, resolveSharedRow } from '../chunk-LTZCKFAZ.js';
2
2
  import { useAixT } from '../chunk-T3QVYTOT.js';
3
3
  import '../chunk-FW23FLAF.js';
4
- import '../chunk-M7CKUC4U.js';
4
+ import '../chunk-VVJ4TK6D.js';
5
5
  import '../chunk-OEZFYKL6.js';
6
6
  import '../chunk-E7WMHM63.js';
7
7
  import '../chunk-P2Y655SL.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aixnn/aixautots",
3
- "version": "0.6.1",
3
+ "version": "0.6.3",
4
4
  "type": "module",
5
5
  "license": "UNLICENSED",
6
6
  "publishConfig": {