dsh-desktop-enhance 0.6.12 → 0.6.13

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 CHANGED
@@ -4,7 +4,6 @@
4
4
 
5
5
  ## 功能列表
6
6
 
7
-
8
7
  ### 隐藏侧栏新会话
9
8
 
10
9
  默认在手机和电脑端隐藏侧边栏顶部的「新会话」按钮,保留项目下的创建入口。可在插件设置的「对话浏览与视觉」中关闭「隐藏侧栏新会话」恢复按钮。品牌、快捷键和 macOS 收起侧栏后的标题栏入口不变。
@@ -103,15 +102,14 @@ Web 版(浏览器里打开的那种)键位是 **`Cmd+Shift+.`** —— `Cmd+
103
102
 
104
103
  ### 远程接入与手机体验
105
104
 
106
- 设置页按「对话与显示 / 智能建议 / 会话能力 / 远程接入」分 Tab。远程页依次是总开关、行内端口、配对操作和设备卡片,不展示 IP 或完整 URL。
105
+ 设置页按「对话与显示 / 智能建议 / 会话能力 / 远程接入」分 Tab。远程页依次是总开关、行内端口、已授权设备列表,不展示 IP 或完整 URL。
107
106
 
108
- - **独立远程入口**:原生 DSH 只监听回环;远端通过增强插件的独立端口访问,默认 `19388`。首次开启或关闭后的重新开启需要本机操作;运行中已授权远程设备也可管理配对和设备。
109
- - **配对链接长期有效**:跨重启保留,只有主动重置或结束配对才失效。开启配对后才出现复制与重置按钮;复制不会暗中开启配对。没有二维码。
110
- - **设备授权长期有效**:不自动到期,撤销指定设备后关闭其当前代理连接并拒绝后续访问,其他设备不受影响。浏览器清除凭据仍需重新配对。如果不再信任某设备持有的配对链接,还应重置或结束配对,防止它重新申请授权。没有额外的「断开连接」按钮。
107
+ - **独立远程入口**:原生 DSH 只监听回环;远端通过增强插件的独立端口访问,默认 `19388`。首次开启或关闭后的重新开启需要本机操作;运行中已授权远程设备也可管理设备与配置。
108
+ - **一台设备一把钥匙**:「添加设备」生成一条设备记录并复制它的链接;在目标设备打开即用,重复打开不会重复建记录。链接里的钥匙不自动过期,跨重启保留,设置页随时能再复制同一把。
109
+ - **换本机 IP 不必重建设备**:把链接里的地址改成新 IP、钥匙不动即可继续用(浏览器 Cookie 按主机名隔离,新地址首次需打开一次链接)。设备只按「钥匙正确 + 请求来自本机入口」判定;外部主机名与跨站请求一律拒绝。
110
+ - **撤销与重新签发**:撤销会关闭该设备当前连接并拒绝后续访问;怀疑链接泄露时用「重新签发」,旧链接与旧连接同时失效,其他设备不受影响。没有二维码,也没有额外的「断开连接」按钮。
111
111
  - **手机体验自动启用**:竖屏布局、侧栏手势、长按菜单、回车换行和底部选择器不再提供开关,也不读取旧开关设置。触屏回车换行不依赖竖屏布局;鲸鱼仍可拖动并自动记忆位置,不提供重置按钮。
112
112
 
113
- **从 `dsh-lan-remote` 迁移需要本机维护窗口与完整重启。** 先把原生服务改为回环监听,替换旧插件,再开启新远程入口;旧设备重新配对。外部脚本和手机代理不整体搬入,只按新入口调整连接目标。不要同时启用两个插件,也不要把普通 HTTP 局域网接入暴露到不可信网络。
114
-
115
113
  具体安全范围、设置归属与迁移说明见 [远程接入](docs/features/remote-access.md)。
116
114
 
117
115
  ### 异常轮次分叉
package/lib/client.js CHANGED
@@ -31,7 +31,7 @@ window.__ModuleLoader__.load({
31
31
  const remoteZh = {
32
32
  "remote.title": "远程访问",
33
33
  "remote.loading": "正在读取或更新远程状态…",
34
- "remote.unauthorized": "此设备未获授权或授权已失效。请通过有效配对链接重新配对。",
34
+ "remote.unauthorized": "此设备未获授权或钥匙已失效。请在本机设置里重新签发并复制它的链接。",
35
35
  "remote.requestFailed": "远程操作或状态读取失败。请重新打开设置核对实际状态后再试。",
36
36
  "remote.confirmUnavailable": "当前环境无法打开确认框,未执行操作。请使用支持确认的浏览器重试。",
37
37
  "remote.running": "已开启,允许已授权设备访问 DSH。",
@@ -42,43 +42,38 @@ window.__ModuleLoader__.load({
42
42
  "remote.invalidPort": "请输入 1–65535 之间的整数端口。",
43
43
  "remote.savePort": "应用",
44
44
  "remote.refresh": "刷新",
45
- "remote.confirmEnable": "远程设备获授权后拥有本机 DSH 的完整操作权限,包括访问会话和文件、执行工具。局域网使用明文 HTTP,链路中的其他人可能窃听通信及配对凭据。仅在可信网络中开启,不要暴露到公网。确认开启远程访问?",
45
+ "remote.confirmEnable": "远程设备获授权后拥有本机 DSH 的完整操作权限,包括访问会话和文件、执行工具。局域网使用明文 HTTP,链路中的其他人可能窃听通信与设备钥匙。仅在可信网络中开启,不要暴露到公网。确认开启远程访问?",
46
46
  "remote.confirmDisable": "关闭远程访问会断开所有远程连接,当前远程页面也会断开;需在运行 DSH 的本机重新开启。设备授权仍保留。确认关闭?",
47
- "remote.pairingTitle": "设备配对",
48
- "remote.pairingHint": "复制链接到其他设备打开即可配对。链接长期有效,直到重置或结束配对;仅发给可信设备。已有设备不受配对开关影响。",
49
- "remote.startPairing": "开启配对",
50
- "remote.rotate": "重置",
51
- "remote.endPairing": "结束配对",
52
- "remote.confirmRotate": "重置后旧配对链接立即失效,新设备需要新链接。已授权设备不受影响。确认重置?",
53
- "remote.confirmEnd": "结束后当前链接失效,不再接纳新设备。已有设备继续使用。确认结束配对?",
54
- "remote.pairingInactive": "开启配对后即可复制链接。已有设备不受配对开关影响。",
55
- "remote.pairingClosed": "配对已结束,无法复制旧链接。状态已刷新,请按需手动开启配对。",
47
+ "remote.addDevice": "添加设备",
56
48
  "remote.copy": "复制链接",
57
49
  "remote.copied": "链接已复制",
58
50
  "remote.copyFailed": "复制失败,浏览器未允许写入剪贴板。请检查剪贴板权限后重试。",
59
- "remote.devicesTitle": "已配对设备",
60
- "remote.devicesHint": "授权不自动过期。在线状态为刷新时快照;本机与已授权远端均可管理。撤销后如不再信任设备保留的邀请链接,请同时重置或结束配对。",
61
- "remote.noDevices": "还没有配对设备。开启配对并复制链接,在另一台设备上打开即可。",
62
- "remote.createdAt": "配对时间:",
51
+ "remote.reissue": "重新签发",
52
+ "remote.reissued": "已重新签发,新链接已复制;旧链接立即失效。",
53
+ "remote.confirmReissue": "重新签发后旧链接立即失效,这台设备需要用新链接打开一次;其他设备不受影响。确认重新签发?",
54
+ "remote.devicesTitle": "已授权设备",
55
+ "remote.devicesHint": "一台设备一把钥匙:谁拿到链接里的钥匙就能以那台设备远控。换本机 IP 时把链接里的地址改成新 IP、钥匙不变即可继续用。钥匙不自动过期,撤销或重新签发才失效。",
56
+ "remote.noDevices": "还没有设备。点「添加设备」生成一条记录并复制链接,在目标设备上打开即可。",
57
+ "remote.createdAt": "添加时间:",
63
58
  "remote.revoked": "已撤销",
64
59
  "remote.unnamedDevice": "未命名设备",
65
60
  "remote.online": "在线",
66
61
  "remote.offline": "离线",
67
62
  "remote.currentDevice": "当前设备",
68
63
  "remote.revoke": "撤销授权",
69
- "remote.confirmRevoke": "确认撤销此设备的授权?其现有连接将关闭,之后需重新配对。设备仍可能保留邀请链接;如不再信任,请同时重置或结束配对。这不是永久封禁设备。",
70
- "remote.confirmRevokeSelf": "确认撤销当前设备?将退出且需重新配对,其他设备不受影响。若不再信任保留的邀请链接,请先重置或结束配对。",
71
- "remote.selfRevoked": "当前设备授权已撤销,已退出远程管理。需要通过有效链接重新配对。",
72
- "remote.configurationAccepted": "请求已提交,连接即将切换,尚未验证新入口可用。请按新地址重新配对;若无法连接,请在本机检查服务。",
64
+ "remote.confirmRevoke": "确认撤销此设备的授权?它的钥匙、Cookie 与正在运行的连接会立即失效,之后需要重新添加设备。其他设备不受影响。",
65
+ "remote.confirmRevokeSelf": "确认撤销当前设备?你会立即退出,其他设备不受影响。之后需要在别的设备上重新添加这台设备。",
66
+ "remote.selfRevoked": "当前设备授权已撤销,已退出远程管理。需要重新添加设备并复制它的链接。",
67
+ "remote.configurationAccepted": "请求已提交,连接即将切换,尚未验证新入口可用。已授权设备在新地址上仍有效,把链接里的地址改成新入口即可;若无法连接,请在本机检查服务。",
73
68
  "remote.shutdownAccepted": "请求已提交,连接即将切换,远程入口将关闭。需在运行 DSH 的本机重新开启。",
74
69
  "remote.openEntry": "打开新入口",
75
- "remote.permanentAuthorization": "长期授权",
76
- "remote.portSwitchWarning": "应用后连接会断开;新地址需重新配对,请确保能访问运行 DSH 的本机。"
70
+ "remote.permanentAuthorization": "钥匙长期有效",
71
+ "remote.portSwitchWarning": "应用后连接会断开;已授权设备在新入口上仍有效,把链接里的地址改成新入口即可继续用;请确保能访问运行 DSH 的本机。"
77
72
  };
78
73
  const remoteEn = {
79
74
  "remote.title": "Remote access",
80
75
  "remote.loading": "Reading or updating remote status…",
81
- "remote.unauthorized": "This device is not authorized. Pair again with a valid link.",
76
+ "remote.unauthorized": "This device is not authorized. Reissue and copy its link from the local settings page.",
82
77
  "remote.requestFailed": "The operation or status request failed. Reopen settings to check the actual state before retrying.",
83
78
  "remote.confirmUnavailable": "Confirmation is unavailable. Nothing was changed. Retry in a supported browser.",
84
79
  "remote.running": "Enabled. Authorized devices can access DSH.",
@@ -89,38 +84,33 @@ window.__ModuleLoader__.load({
89
84
  "remote.invalidPort": "Enter an integer port between 1 and 65535.",
90
85
  "remote.savePort": "Apply",
91
86
  "remote.refresh": "Refresh",
92
- "remote.confirmEnable": "Authorized devices receive full DSH control, including sessions, files and tools. HTTP is unencrypted and credentials may be intercepted. Use only trusted networks, never expose it to the internet. Enable remote access?",
87
+ "remote.confirmEnable": "Authorized devices receive full DSH control, including sessions, files and tools. HTTP is unencrypted and device keys may be intercepted. Use only trusted networks, never expose it to the internet. Enable remote access?",
93
88
  "remote.confirmDisable": "All remote connections, including this remote page, will close. Re-enable on the computer running DSH. Authorizations are retained. Disable remote access?",
94
- "remote.pairingTitle": "Device pairing",
95
- "remote.pairingHint": "Copy the link to another trusted device. It remains valid until reset or pairing is ended. Existing devices are unaffected.",
96
- "remote.startPairing": "Start pairing",
97
- "remote.rotate": "Reset",
98
- "remote.endPairing": "End pairing",
99
- "remote.confirmRotate": "The old link will stop working immediately. Existing devices are unaffected. Reset the link?",
100
- "remote.confirmEnd": "The current link will stop accepting devices. Existing devices keep access. End pairing?",
101
- "remote.pairingInactive": "Start pairing to copy a link. Existing devices are unaffected.",
102
- "remote.pairingClosed": "Pairing has ended. Status refreshed; start pairing manually if needed.",
89
+ "remote.addDevice": "Add device",
103
90
  "remote.copy": "Copy link",
104
91
  "remote.copied": "Link copied",
105
92
  "remote.copyFailed": "Copy failed. Check browser clipboard permissions and retry.",
106
- "remote.devicesTitle": "Paired devices",
107
- "remote.devicesHint": "Authorization does not expire automatically. Online status is a snapshot. Local and authorized remote clients can manage devices. Reset or end pairing if you no longer trust a revoked device with its retained invitation link.",
108
- "remote.noDevices": "No paired devices. Start pairing and open the copied link on another device.",
109
- "remote.createdAt": "Paired: ",
93
+ "remote.reissue": "Reissue key",
94
+ "remote.reissued": "New link copied; the previous link stopped working immediately.",
95
+ "remote.confirmReissue": "Reissuing invalidates the old link; that device must open the new link once. Other devices are unaffected. Reissue?",
96
+ "remote.devicesTitle": "Authorized devices",
97
+ "remote.devicesHint": "One device, one key: whoever holds the link can control DSH as that device. When this computer gets a new IP, change the address part of the link and keep the key. Keys do not expire; revoke or reissue ends them.",
98
+ "remote.noDevices": "No devices yet. Choose Add device, then open the copied link on the target device.",
99
+ "remote.createdAt": "Added: ",
110
100
  "remote.revoked": "Revoked",
111
101
  "remote.unnamedDevice": "Unnamed device",
112
102
  "remote.online": "Online",
113
103
  "remote.offline": "Offline",
114
104
  "remote.currentDevice": "This device",
115
105
  "remote.revoke": "Revoke authorization",
116
- "remote.confirmRevoke": "Revoke this device? Its connections will close and it must pair again. It may retain an invitation link; reset or end pairing if no longer trusted. This is not a permanent hardware ban.",
117
- "remote.confirmRevokeSelf": "Revoke this device? You will be signed out and must pair again. Other devices are unaffected. Reset or end pairing first if retained invitation links are no longer trusted.",
118
- "remote.selfRevoked": "This device was revoked. Pair again with a valid link to regain access.",
119
- "remote.configurationAccepted": "Request submitted; the connection will switch. The new entry has not been verified. Pair again at the new address; check the service locally if unavailable.",
106
+ "remote.confirmRevoke": "Revoke this device? Its key, cookie and live connections stop immediately, and it must be added again. Other devices are unaffected.",
107
+ "remote.confirmRevokeSelf": "Revoke this device? You are signed out immediately; other devices are unaffected. Add this device again from another device afterwards.",
108
+ "remote.selfRevoked": "This device was revoked. Add it again and copy its link to regain access.",
109
+ "remote.configurationAccepted": "Request submitted; the connection will switch. The new entry has not been verified. Authorized devices stay valid there; change the address part of their links. Check the service locally if unavailable.",
120
110
  "remote.shutdownAccepted": "Request submitted; the remote connection will close. Re-enable on the computer running DSH.",
121
111
  "remote.openEntry": "Open new entry",
122
- "remote.permanentAuthorization": "Persistent authorization",
123
- "remote.portSwitchWarning": "Applying will disconnect this page. Pair again at the new address; make sure you can access the computer running DSH."
112
+ "remote.permanentAuthorization": "Key does not expire",
113
+ "remote.portSwitchWarning": "Applying will disconnect this page. Authorized devices stay valid at the new entry; change the address part of their links. Make sure you can access the computer running DSH."
124
114
  };
125
115
  //#endregion
126
116
  //#region src/client/strings.ts
@@ -2239,7 +2229,7 @@ window.__ModuleLoader__.load({
2239
2229
  setBusy((current) => withoutField(current, field));
2240
2230
  setFailed((current) => matched ? withoutField(current, field) : withField(current, field));
2241
2231
  };
2242
- const confirm = (attempt) => {
2232
+ const judge = (attempt) => {
2243
2233
  if (superseded()) {
2244
2234
  cancel();
2245
2235
  return;
@@ -2258,7 +2248,7 @@ window.__ModuleLoader__.load({
2258
2248
  const id = globalThis.setTimeout(() => {
2259
2249
  timers.current.delete(id);
2260
2250
  pending = 0;
2261
- confirm(attempt);
2251
+ judge(attempt);
2262
2252
  }, 700);
2263
2253
  pending = id;
2264
2254
  timers.current.add(id);
@@ -2268,7 +2258,7 @@ window.__ModuleLoader__.load({
2268
2258
  try {
2269
2259
  written = form.set?.(field, wanted);
2270
2260
  } catch (error) {
2271
- confirm(attempt);
2261
+ judge(attempt);
2272
2262
  return;
2273
2263
  }
2274
2264
  if (written !== null && written !== void 0 && typeof written.then === "function") {
@@ -2276,7 +2266,7 @@ window.__ModuleLoader__.load({
2276
2266
  if (superseded()) return;
2277
2267
  if (attempt !== liveAttempt) return;
2278
2268
  cancel();
2279
- confirm(attempt);
2269
+ judge(attempt);
2280
2270
  };
2281
2271
  written.then((accepted) => {
2282
2272
  if (accepted === false) sooner();
@@ -6652,12 +6642,17 @@ window.__ModuleLoader__.load({
6652
6642
  //#region src/shared/remote.ts
6653
6643
  const REMOTE_MANAGEMENT_ROUTE = "/api/desktop-enhance/remote";
6654
6644
  const DEFAULT_REMOTE_PORT = 19388;
6645
+ function deviceLabel(userAgent) {
6646
+ return [/Edg\//.test(userAgent) ? "Edge" : /Firefox\//.test(userAgent) ? "Firefox" : /Chrome\//.test(userAgent) ? "Chrome" : /Safari/.test(userAgent) ? "Safari" : "", /iPhone|iPad/.test(userAgent) ? "iOS" : /Android/.test(userAgent) ? "Android" : /Macintosh/.test(userAgent) ? "macOS" : /Windows/.test(userAgent) ? "Windows" : ""].filter(Boolean).join(" · ");
6647
+ }
6655
6648
  //#endregion
6656
6649
  //#region src/client/remote/panel.ts
6650
+ function isPlainRecord(value) {
6651
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6652
+ }
6657
6653
  function isStatus(value) {
6658
- if (!value || typeof value !== "object") return false;
6659
- const raw = value;
6660
- return typeof raw.enabled === "boolean" && typeof raw.running === "boolean" && Number.isInteger(raw.port) && Number(raw.port) >= 1 && Number(raw.port) <= 65535 && typeof raw.nativeLoopback === "boolean" && typeof raw.pairing === "boolean" && (raw.management === "local" || raw.management === "remote") && (raw.currentDeviceId === null || typeof raw.currentDeviceId === "string") && (raw.error === null || typeof raw.error === "string") && Array.isArray(raw.devices) && raw.devices.every((device) => device && typeof device === "object" && typeof device.id === "string" && typeof device.name === "string" && typeof device.userAgent === "string" && typeof device.audience === "string" && typeof device.online === "boolean" && Number.isSafeInteger(device.createdAt) && device.createdAt >= 0 && (device.revokedAt === void 0 || Number.isSafeInteger(device.revokedAt) && device.revokedAt >= device.createdAt));
6654
+ if (!isPlainRecord(value)) return false;
6655
+ return typeof value.enabled === "boolean" && typeof value.running === "boolean" && Number.isInteger(value.port) && Number(value.port) >= 1 && Number(value.port) <= 65535 && typeof value.nativeLoopback === "boolean" && (value.management === "local" || value.management === "remote") && (value.currentDeviceId === null || typeof value.currentDeviceId === "string") && (value.error === null || typeof value.error === "string") && Array.isArray(value.devices) && value.devices.every((device) => isPlainRecord(device) && typeof device.id === "string" && typeof device.name === "string" && typeof device.userAgent === "string" && typeof device.online === "boolean" && typeof device.createdAt === "number" && Number.isSafeInteger(device.createdAt) && device.createdAt >= 0 && (device.revokedAt === void 0 || typeof device.revokedAt === "number" && Number.isSafeInteger(device.revokedAt) && device.revokedAt >= device.createdAt));
6661
6656
  }
6662
6657
  async function request(signal, body) {
6663
6658
  const response = await globalThis.fetch(REMOTE_MANAGEMENT_ROUTE, {
@@ -6672,19 +6667,16 @@ window.__ModuleLoader__.load({
6672
6667
  });
6673
6668
  if (response.status === 401 || response.status === 403) throw new Error("remote.unauthorized");
6674
6669
  const data = await response.json();
6675
- if (!response.ok) {
6676
- if (data && typeof data === "object" && "error" in data && data.error === "PAIRING_CLOSED") throw new Error("remote.pairingClosed");
6677
- throw new Error("remote.requestFailed");
6678
- }
6670
+ if (!response.ok) throw new Error("remote.requestFailed");
6679
6671
  return {
6680
6672
  code: response.status,
6681
6673
  data
6682
6674
  };
6683
6675
  }
6684
- function pairingUrl(data) {
6676
+ function deviceUrl(data) {
6685
6677
  if (!data || typeof data !== "object" || !("url" in data) || typeof data.url !== "string") throw new Error("remote.requestFailed");
6686
6678
  const url = new URL(data.url);
6687
- if (!["http:", "https:"].includes(url.protocol) || url.pathname !== "/_desktop-enhance/pair" || url.username || url.password) throw new Error("remote.requestFailed");
6679
+ if (!["http:", "https:"].includes(url.protocol) || url.pathname !== "/_desktop-enhance/device" || url.username || url.password) throw new Error("remote.requestFailed");
6688
6680
  return url.href;
6689
6681
  }
6690
6682
  async function copyToClipboard(url, signal) {
@@ -6720,11 +6712,6 @@ window.__ModuleLoader__.load({
6720
6712
  return null;
6721
6713
  }
6722
6714
  }
6723
- function browserName(agent) {
6724
- const browser = /Edg\//.test(agent) ? "Edge" : /Firefox\//.test(agent) ? "Firefox" : /Chrome\//.test(agent) ? "Chrome" : /Safari/.test(agent) ? "Safari" : "Browser";
6725
- const device = /iPhone|iPad/.test(agent) ? "iOS" : /Android/.test(agent) ? "Android" : /Macintosh/.test(agent) ? "macOS" : /Windows/.test(agent) ? "Windows" : "";
6726
- return device ? `${browser} · ${device}` : browser;
6727
- }
6728
6715
  function RemoteSettings({ t }) {
6729
6716
  const [status, setStatus] = React.useState(null);
6730
6717
  const [error, setError] = React.useState("");
@@ -6745,11 +6732,7 @@ window.__ModuleLoader__.load({
6745
6732
  const fail = (caught) => {
6746
6733
  const key = caught instanceof Error ? caught.message : "";
6747
6734
  if (key === "remote.unauthorized") setStatus(null);
6748
- setError([
6749
- "remote.unauthorized",
6750
- "remote.copyFailed",
6751
- "remote.pairingClosed"
6752
- ].includes(key) ? key : "remote.requestFailed");
6735
+ setError(["remote.unauthorized", "remote.copyFailed"].includes(key) ? key : "remote.requestFailed");
6753
6736
  };
6754
6737
  React.useEffect(() => {
6755
6738
  const abort = new globalThis.AbortController();
@@ -6767,7 +6750,7 @@ window.__ModuleLoader__.load({
6767
6750
  controller.current = null;
6768
6751
  };
6769
6752
  }, []);
6770
- const confirm = (key, source) => {
6753
+ const askConfirm = (key, source) => {
6771
6754
  try {
6772
6755
  return globalThis.confirm(t(key));
6773
6756
  } catch {
@@ -6796,14 +6779,21 @@ window.__ModuleLoader__.load({
6796
6779
  if (body.enabled && "reconnectUrl" in data) setEntry(reconnectUrl(data.reconnectUrl, body.port));
6797
6780
  return;
6798
6781
  }
6799
- if (body.action === "copyPairLink") {
6800
- const url = pairingUrl(data);
6782
+ if (body.action === "addDevice" || body.action === "copyDeviceLink" || body.action === "reissue") {
6783
+ const url = deviceUrl(data);
6801
6784
  try {
6802
6785
  await copyToClipboard(url, abort.signal);
6803
6786
  } catch {
6804
6787
  throw new Error("remote.copyFailed");
6805
6788
  }
6806
- if (!abort.signal.aborted) setNote("remote.copied");
6789
+ if (abort.signal.aborted) return;
6790
+ if (body.action === "reissue" && body.id === status?.currentDeviceId) {
6791
+ setStatus(null);
6792
+ setNote("remote.reissued");
6793
+ return;
6794
+ }
6795
+ setNote(body.action === "reissue" ? "remote.reissued" : "remote.copied");
6796
+ if (body.action !== "copyDeviceLink") await refresh(abort.signal);
6807
6797
  return;
6808
6798
  }
6809
6799
  if (!data || typeof data !== "object" || !("ok" in data) || data.ok !== true) throw new Error("remote.requestFailed");
@@ -6815,21 +6805,7 @@ window.__ModuleLoader__.load({
6815
6805
  }
6816
6806
  await refresh(abort.signal);
6817
6807
  } catch (caught) {
6818
- if (!abort.signal.aborted) {
6819
- if (caught instanceof Error && caught.message === "remote.pairingClosed") {
6820
- setStatus((current) => current ? {
6821
- ...current,
6822
- pairing: false
6823
- } : current);
6824
- try {
6825
- await refresh(abort.signal);
6826
- } catch (refreshError) {
6827
- if (!abort.signal.aborted) fail(refreshError);
6828
- return;
6829
- }
6830
- }
6831
- if (!abort.signal.aborted) fail(caught);
6832
- }
6808
+ if (!abort.signal.aborted) fail(caught);
6833
6809
  } finally {
6834
6810
  if (!abort.signal.aborted) {
6835
6811
  inFlight.current = false;
@@ -6844,18 +6820,90 @@ window.__ModuleLoader__.load({
6844
6820
  setError("remote.invalidPort");
6845
6821
  return;
6846
6822
  }
6847
- if (enabled !== status.enabled && !confirm(enabled ? "remote.confirmEnable" : "remote.confirmDisable", source)) return;
6823
+ if (enabled !== status.enabled && !askConfirm(enabled ? "remote.confirmEnable" : "remote.confirmDisable", source)) return;
6848
6824
  run({
6849
6825
  action: "configure",
6850
6826
  enabled,
6851
6827
  port: nextPort
6852
6828
  });
6853
6829
  };
6854
- const pairing = (action, source) => {
6855
- if (!status?.running || inFlight.current || action !== "startPairing" && !status.pairing) return;
6856
- if (action === "resetPairing" && !confirm("remote.confirmRotate", source)) return;
6857
- if (action === "endPairing" && !confirm("remote.confirmEnd", source)) return;
6858
- run({ action });
6830
+ const device = (action, source, id) => {
6831
+ if (!status || inFlight.current) return;
6832
+ if (action === "revoke") {
6833
+ const row = id === void 0 ? void 0 : status.devices.find((item) => item.id === id);
6834
+ if (!row || row.revokedAt !== void 0) return;
6835
+ if (!askConfirm(row.id === status.currentDeviceId ? "remote.confirmRevokeSelf" : "remote.confirmRevoke", source)) return;
6836
+ run({
6837
+ action: "revoke",
6838
+ id: row.id
6839
+ });
6840
+ return;
6841
+ }
6842
+ if (!status.running) return;
6843
+ if (action === "addDevice") {
6844
+ run({ action: "addDevice" });
6845
+ return;
6846
+ }
6847
+ const row = id === void 0 ? void 0 : status.devices.find((item) => item.id === id);
6848
+ if (!row || row.revokedAt !== void 0) return;
6849
+ if (action === "copyDeviceLink") {
6850
+ run({
6851
+ action: "copyDeviceLink",
6852
+ id: row.id
6853
+ });
6854
+ return;
6855
+ }
6856
+ if (!askConfirm("remote.confirmReissue", source)) return;
6857
+ run({
6858
+ action: "reissue",
6859
+ id: row.id
6860
+ });
6861
+ };
6862
+ const deviceButton = (action, label, id, disabled, className) => h("button", {
6863
+ type: "button",
6864
+ ...className ? { className } : {},
6865
+ "data-remote-action": action,
6866
+ "data-remote-device": id,
6867
+ disabled: busy || disabled,
6868
+ onClick: (event) => device(action, event?.currentTarget, id)
6869
+ }, label);
6870
+ const running = status?.running === true;
6871
+ const deviceCard = (row) => {
6872
+ const title = row.name || t("remote.unnamedDevice");
6873
+ const platform = deviceLabel(row.userAgent) || t("remote.unnamedDevice");
6874
+ const meta = platform === title ? row.id.slice(-8) : `${platform} · ${row.id.slice(-8)}`;
6875
+ return h("article", {
6876
+ key: row.id,
6877
+ className: "de-remote-device",
6878
+ "data-revoked": row.revokedAt !== void 0
6879
+ }, h("div", { className: "de-remote-heading" }, h("svg", {
6880
+ className: "de-remote-device-icon",
6881
+ "aria-hidden": true,
6882
+ viewBox: "0 0 24 24",
6883
+ fill: "none",
6884
+ stroke: "currentColor",
6885
+ strokeWidth: 1.6
6886
+ }, /iPhone|iPad|Android|Mobile/.test(row.userAgent) ? [h("rect", {
6887
+ key: "body",
6888
+ x: 6.5,
6889
+ y: 2.5,
6890
+ width: 11,
6891
+ height: 19,
6892
+ rx: 2.5
6893
+ }), h("path", {
6894
+ key: "detail",
6895
+ d: "M10 18h4"
6896
+ })] : [h("rect", {
6897
+ key: "body",
6898
+ x: 3,
6899
+ y: 4,
6900
+ width: 18,
6901
+ height: 13,
6902
+ rx: 2
6903
+ }), h("path", {
6904
+ key: "detail",
6905
+ d: "M9 21h6m-3-4v4"
6906
+ })]), h("span", { className: "de-remote-badge" }, t(row.revokedAt !== void 0 ? "remote.revoked" : row.online ? "remote.online" : "remote.offline"))), h("strong", null, title), row.id === status?.currentDeviceId ? h("span", { className: "de-remote-badge" }, t("remote.currentDevice")) : null, h("p", null, meta), h("p", null, `${t("remote.createdAt")}${new Date(row.createdAt).toLocaleString()}`), h("div", { className: "de-remote-device-footer" }, h("span", null, t(row.revokedAt !== void 0 ? "remote.revoked" : "remote.permanentAuthorization")), h("div", { className: "de-remote-actions" }, row.revokedAt === void 0 ? deviceButton("copyDeviceLink", t("remote.copy"), row.id, !running) : null, row.revokedAt === void 0 ? deviceButton("reissue", t("remote.reissue"), row.id, !running) : null, deviceButton("revoke", t("remote.revoke"), row.id, row.revokedAt !== void 0, "de-remote-revoke"))));
6859
6907
  };
6860
6908
  return h("div", { "data-desktop-enhance-remote": "" }, h("section", { className: "de-remote-body" }, busy ? h("p", { role: "status" }, t("remote.loading")) : null, error ? h("p", { role: "alert" }, t(error)) : null, note ? h("p", { role: "status" }, t(note)) : null, entry ? h("a", {
6861
6909
  href: entry,
@@ -6884,74 +6932,20 @@ window.__ModuleLoader__.load({
6884
6932
  "data-remote-action": "savePort",
6885
6933
  disabled: busy || port === String(status.port) || status.enabled && !status.nativeLoopback,
6886
6934
  onClick: () => configure(status.enabled)
6887
- }, t("remote.savePort"))), status.management === "remote" && port !== String(status.port) ? h("p", { role: "note" }, t("remote.portSwitchWarning")) : null, !status.nativeLoopback ? h("p", { role: "alert" }, t("remote.nativeBlocked")) : null, status.error ? h("p", { role: "alert" }, t("remote.serviceError")) : null, h("div", { className: "de-remote-pairing" }, h("h4", null, t("remote.pairingTitle")), h("div", { className: "de-remote-actions" }, h("button", {
6888
- type: "button",
6889
- "data-remote-action": status.pairing ? "endPairing" : "startPairing",
6890
- disabled: busy || !status.running,
6891
- onClick: (event) => pairing(status.pairing ? "endPairing" : "startPairing", event?.currentTarget)
6892
- }, t(status.pairing ? "remote.endPairing" : "remote.startPairing")), status.pairing && status.running ? h("button", {
6935
+ }, t("remote.savePort"))), status.management === "remote" && port !== String(status.port) ? h("p", { role: "note" }, t("remote.portSwitchWarning")) : null, !status.nativeLoopback ? h("p", { role: "alert" }, t("remote.nativeBlocked")) : null, status.error ? h("p", { role: "alert" }, t("remote.serviceError")) : null, h("section", { className: "de-remote-devices" }, h("div", { className: "de-remote-heading" }, h("h3", null, t("remote.devicesTitle")), h("div", { className: "de-remote-actions" }, h("button", {
6893
6936
  type: "button",
6894
6937
  className: "de-remote-primary",
6895
- "data-remote-action": "copy",
6896
- disabled: busy,
6897
- onClick: () => pairing("copyPairLink")
6898
- }, t("remote.copy")) : null, status.pairing && status.running ? h("button", {
6899
- type: "button",
6900
- "data-remote-action": "resetPairing",
6901
- disabled: busy,
6902
- onClick: (event) => pairing("resetPairing", event.currentTarget)
6903
- }, t("remote.rotate")) : null), h("p", null, t(status.pairing ? "remote.pairingHint" : "remote.pairingInactive"))), h("section", { className: "de-remote-devices" }, h("div", { className: "de-remote-heading" }, h("h3", null, t("remote.devicesTitle")), h("button", {
6938
+ "data-remote-action": "addDevice",
6939
+ disabled: busy || !status.running,
6940
+ onClick: (event) => device("addDevice", event?.currentTarget)
6941
+ }, t("remote.addDevice")), h("button", {
6904
6942
  type: "button",
6905
6943
  "data-remote-action": "refresh",
6906
6944
  disabled: busy,
6907
6945
  onClick: () => {
6908
6946
  run();
6909
6947
  }
6910
- }, t("remote.refresh"))), h("p", null, t("remote.devicesHint")), h("div", { className: "de-remote-device-grid" }, ...status.devices.map((device) => h("article", {
6911
- key: device.id,
6912
- className: "de-remote-device",
6913
- "data-revoked": device.revokedAt !== void 0
6914
- }, h("div", { className: "de-remote-heading" }, h("svg", {
6915
- className: "de-remote-device-icon",
6916
- "aria-hidden": true,
6917
- viewBox: "0 0 24 24",
6918
- fill: "none",
6919
- stroke: "currentColor",
6920
- strokeWidth: 1.6
6921
- }, /iPhone|iPad|Android|Mobile/.test(device.userAgent) ? [h("rect", {
6922
- key: "body",
6923
- x: 6.5,
6924
- y: 2.5,
6925
- width: 11,
6926
- height: 19,
6927
- rx: 2.5
6928
- }), h("path", {
6929
- key: "detail",
6930
- d: "M10 18h4"
6931
- })] : [h("rect", {
6932
- key: "body",
6933
- x: 3,
6934
- y: 4,
6935
- width: 18,
6936
- height: 13,
6937
- rx: 2
6938
- }), h("path", {
6939
- key: "detail",
6940
- d: "M9 21h6m-3-4v4"
6941
- })]), h("span", { className: "de-remote-badge" }, t(device.revokedAt !== void 0 ? "remote.revoked" : device.online ? "remote.online" : "remote.offline"))), h("strong", null, device.name || t("remote.unnamedDevice")), device.id === status.currentDeviceId ? h("span", { className: "de-remote-badge" }, t("remote.currentDevice")) : null, h("p", null, `${browserName(device.userAgent)} · ${device.id.slice(-8)}`), h("p", null, `${t("remote.createdAt")}${new Date(device.createdAt).toLocaleString()}`), h("div", { className: "de-remote-device-footer" }, h("span", null, t(device.revokedAt !== void 0 ? "remote.revoked" : "remote.permanentAuthorization")), h("button", {
6942
- type: "button",
6943
- className: "de-remote-revoke",
6944
- "data-remote-action": "revoke",
6945
- "data-remote-device": device.id,
6946
- disabled: busy || device.revokedAt !== void 0,
6947
- onClick: (event) => {
6948
- if (device.revokedAt !== void 0 || inFlight.current || !confirm(device.id === status.currentDeviceId ? "remote.confirmRevokeSelf" : "remote.confirmRevoke", event.currentTarget)) return;
6949
- run({
6950
- action: "revoke",
6951
- id: device.id
6952
- });
6953
- }
6954
- }, t("remote.revoke"))))), status.devices.length === 0 ? h("p", { className: "de-remote-empty" }, t("remote.noDevices")) : null))) : null));
6948
+ }, t("remote.refresh")))), h("p", null, t("remote.devicesHint")), status.devices.length === 0 ? h("p", { className: "de-remote-empty" }, t("remote.noDevices")) : h("div", { className: "de-remote-device-grid" }, ...status.devices.map(deviceCard)))) : null));
6955
6949
  }
6956
6950
  //#endregion
6957
6951
  //#region src/client/mobile/settings.ts
@@ -7941,7 +7935,7 @@ window.__ModuleLoader__.load({
7941
7935
  }
7942
7936
  //#endregion
7943
7937
  //#region \0dsh-desktop-enhance-css:/Users/lijiechengbj/projects/AI-agents/dsh-desktop-enhance/src/client/remote/styles.css.mjs
7944
- var styles_css_default$2 = "\n[data-desktop-enhance-remote] { display:flex; flex-direction:column; gap:var(--dsh-de-space-section); min-width:0; padding:var(--dsh-de-space-lg); border:1px solid var(--dsh-de-border); border-radius:var(--dsh-de-radius-card); background:var(--dsh-de-surface); }\n[data-desktop-enhance-remote] .de-remote-body,\n[data-desktop-enhance-remote] .de-remote-content { display:flex; flex-direction:column; gap:var(--dsh-de-space-lg); min-width:0; }\n[data-desktop-enhance-remote] h3,\n[data-desktop-enhance-remote] h4,\n[data-desktop-enhance-remote] p { margin:0; }\n[data-desktop-enhance-remote] h3 { font-size:var(--dsh-de-font-heading); font-weight:600; }\n[data-desktop-enhance-remote] h4 { font-size:var(--dsh-de-font-body); font-weight:600; }\n[data-desktop-enhance-remote] p { color:var(--dsh-de-muted); font-size:var(--dsh-de-font-caption); line-height:1.5; overflow-wrap:anywhere; }\n[data-desktop-enhance-remote] [role=\"alert\"] { color:var(--dsh-de-danger); }\n[data-desktop-enhance-remote] .de-remote-heading { display:flex; align-items:center; justify-content:space-between; gap:var(--dsh-de-space-lg); }\n[data-desktop-enhance-remote] .de-remote-heading > div { display:grid; gap:4px; }\n[data-desktop-enhance-remote] .de-remote-port-row,\n[data-desktop-enhance-remote] .de-remote-field,\n[data-desktop-enhance-remote] .de-remote-actions { display:flex; align-items:center; gap:var(--dsh-de-space-md); flex-wrap:wrap; }\n[data-desktop-enhance-remote] .de-remote-field { font-size:var(--dsh-de-font-caption); color:var(--dsh-de-muted); }\n[data-desktop-enhance-remote] .de-remote-pairing,\n[data-desktop-enhance-remote] .de-remote-devices { border-top:1px solid var(--dsh-de-border); padding-top:var(--dsh-de-space-section); }\n[data-desktop-enhance-remote] .de-remote-pairing,\n[data-desktop-enhance-remote] .de-remote-devices { display:grid; gap:var(--dsh-de-space-md); }\n[data-desktop-enhance-remote] input { box-sizing:border-box; width:104px; min-width:0; max-width:100%; min-height:var(--dsh-de-control-height); padding:6px 8px; border:1px solid var(--dsh-de-border); border-radius:var(--dsh-de-radius-control); background:var(--dsh-de-surface); color:var(--dsh-de-text); font:inherit; }\n[data-desktop-enhance-settings] [data-desktop-enhance-remote] button.de-remote-primary { color:var(--dsw-alias-label-primary-bluish); background:var(--dsw-alias-state-business-tertiary); border-color:var(--dsh-de-accent); font-weight:600; }\n[data-desktop-enhance-settings] [data-desktop-enhance-remote] button.de-remote-primary:hover:not(:disabled) { background:var(--dsw-alias-state-business-tertiary); filter:brightness(.96); }\n[data-desktop-enhance-remote] .de-remote-device-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(min(210px,100%),1fr)); gap:var(--dsh-de-space-md); }\n[data-desktop-enhance-remote] .de-remote-device { min-width:0; display:flex; flex-direction:column; align-items:flex-start; gap:var(--dsh-de-space-sm); padding:var(--dsh-de-space-lg); border:1px solid var(--dsh-de-border); border-radius:var(--dsh-de-radius-card); background:var(--dsh-de-surface); }\n[data-desktop-enhance-remote] .de-remote-device > .de-remote-heading { align-self:stretch; margin-bottom:4px; }\n[data-desktop-enhance-remote] .de-remote-device strong { overflow-wrap:anywhere; }\n[data-desktop-enhance-remote] .de-remote-device-icon { width:28px; height:28px; color:var(--dsh-de-muted); }\n[data-desktop-enhance-remote] .de-remote-badge { border-radius:var(--dsh-de-radius-control); padding:3px 7px; background:var(--dsh-de-hover); font-size:var(--dsh-de-font-caption); color:var(--dsh-de-muted); }\n[data-desktop-enhance-remote] .de-remote-device[data-revoked=\"true\"] { opacity:.65; }\n[data-desktop-enhance-remote] .de-remote-device-footer { display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:var(--dsh-de-space-sm); align-self:stretch; margin-top:auto; padding-top:var(--dsh-de-space-md); border-top:1px solid var(--dsh-de-border); color:var(--dsh-de-muted); font-size:var(--dsh-de-font-caption); }\n[data-desktop-enhance-settings] [data-desktop-enhance-remote] button.de-remote-revoke { padding:4px 0; color:var(--dsh-de-danger); background:transparent; border-color:transparent; font-size:var(--dsh-de-font-caption); }\n[data-desktop-enhance-remote] .de-remote-empty { padding:var(--dsh-de-space-section); border:1px dashed var(--dsh-de-border); border-radius:var(--dsh-de-radius-card); }\n@media (max-width:600px) {\n [data-desktop-enhance-remote] .de-remote-device-grid { grid-template-columns:repeat(2,minmax(0,1fr)); gap:var(--dsh-de-space-sm); }\n [data-desktop-enhance-remote] .de-remote-device { padding:var(--dsh-de-space-md); }\n}\n@media (max-width:360px) { [data-desktop-enhance-remote] .de-remote-device-grid { grid-template-columns:1fr; } }\n";
7938
+ var styles_css_default$2 = "\n[data-desktop-enhance-remote] { display:flex; flex-direction:column; gap:var(--dsh-de-space-section); min-width:0; padding:var(--dsh-de-space-lg); border:1px solid var(--dsh-de-border); border-radius:var(--dsh-de-radius-card); background:var(--dsh-de-surface); }\n[data-desktop-enhance-remote] .de-remote-body,\n[data-desktop-enhance-remote] .de-remote-content { display:flex; flex-direction:column; gap:var(--dsh-de-space-lg); min-width:0; }\n[data-desktop-enhance-remote] h3,\n[data-desktop-enhance-remote] h4,\n[data-desktop-enhance-remote] p { margin:0; }\n[data-desktop-enhance-remote] h3 { font-size:var(--dsh-de-font-heading); font-weight:600; }\n[data-desktop-enhance-remote] h4 { font-size:var(--dsh-de-font-body); font-weight:600; }\n[data-desktop-enhance-remote] p { color:var(--dsh-de-muted); font-size:var(--dsh-de-font-caption); line-height:1.5; overflow-wrap:anywhere; }\n[data-desktop-enhance-remote] [role=\"alert\"] { color:var(--dsh-de-danger); }\n[data-desktop-enhance-remote] .de-remote-heading { display:flex; align-items:center; justify-content:space-between; gap:var(--dsh-de-space-lg); }\n[data-desktop-enhance-remote] .de-remote-heading > div { display:grid; gap:4px; }\n[data-desktop-enhance-remote] .de-remote-port-row,\n[data-desktop-enhance-remote] .de-remote-field,\n[data-desktop-enhance-remote] .de-remote-actions { display:flex; align-items:center; gap:var(--dsh-de-space-md); flex-wrap:wrap; }\n[data-desktop-enhance-remote] .de-remote-field { font-size:var(--dsh-de-font-caption); color:var(--dsh-de-muted); }\n[data-desktop-enhance-remote] .de-remote-devices { display:grid; gap:var(--dsh-de-space-md); border-top:1px solid var(--dsh-de-border); padding-top:var(--dsh-de-space-section); }\n[data-desktop-enhance-remote] input { box-sizing:border-box; width:104px; min-width:0; max-width:100%; min-height:var(--dsh-de-control-height); padding:6px 8px; border:1px solid var(--dsh-de-border); border-radius:var(--dsh-de-radius-control); background:var(--dsh-de-surface); color:var(--dsh-de-text); font:inherit; }\n[data-desktop-enhance-settings] [data-desktop-enhance-remote] button.de-remote-primary { color:var(--dsw-alias-label-primary-bluish); background:var(--dsw-alias-state-business-tertiary); border-color:var(--dsh-de-accent); font-weight:600; }\n[data-desktop-enhance-settings] [data-desktop-enhance-remote] button.de-remote-primary:hover:not(:disabled) { background:var(--dsw-alias-state-business-tertiary); filter:brightness(.96); }\n[data-desktop-enhance-remote] .de-remote-device-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(min(210px,100%),1fr)); gap:var(--dsh-de-space-md); }\n[data-desktop-enhance-remote] .de-remote-device { min-width:0; display:flex; flex-direction:column; align-items:flex-start; gap:var(--dsh-de-space-sm); padding:var(--dsh-de-space-lg); border:1px solid var(--dsh-de-border); border-radius:var(--dsh-de-radius-card); background:var(--dsh-de-surface); }\n[data-desktop-enhance-remote] .de-remote-device > .de-remote-heading { align-self:stretch; margin-bottom:4px; }\n[data-desktop-enhance-remote] .de-remote-device strong { overflow-wrap:anywhere; }\n[data-desktop-enhance-remote] .de-remote-device-icon { width:28px; height:28px; color:var(--dsh-de-muted); }\n[data-desktop-enhance-remote] .de-remote-badge { border-radius:var(--dsh-de-radius-control); padding:3px 7px; background:var(--dsh-de-hover); font-size:var(--dsh-de-font-caption); color:var(--dsh-de-muted); }\n[data-desktop-enhance-remote] .de-remote-device[data-revoked=\"true\"] { opacity:.65; }\n[data-desktop-enhance-remote] .de-remote-device-footer { display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:var(--dsh-de-space-sm); align-self:stretch; margin-top:auto; padding-top:var(--dsh-de-space-md); border-top:1px solid var(--dsh-de-border); color:var(--dsh-de-muted); font-size:var(--dsh-de-font-caption); }\n[data-desktop-enhance-settings] [data-desktop-enhance-remote] button.de-remote-revoke { padding:4px 0; color:var(--dsh-de-danger); background:transparent; border-color:transparent; font-size:var(--dsh-de-font-caption); }\n[data-desktop-enhance-remote] .de-remote-empty { padding:var(--dsh-de-space-section); border:1px dashed var(--dsh-de-border); border-radius:var(--dsh-de-radius-card); }\n@media (max-width:600px) {\n [data-desktop-enhance-remote] .de-remote-device-grid { grid-template-columns:repeat(2,minmax(0,1fr)); gap:var(--dsh-de-space-sm); }\n [data-desktop-enhance-remote] .de-remote-device { padding:var(--dsh-de-space-md); }\n}\n@media (max-width:360px) { [data-desktop-enhance-remote] .de-remote-device-grid { grid-template-columns:1fr; } }\n";
7945
7939
  //#endregion
7946
7940
  //#region src/shared/session-model.ts
7947
7941
  const SESSION_MODEL_PROJECTION = "desktop-enhance.session-model";