dsh-remote-web 0.7.6-beta.7 → 0.7.6-beta.9

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/lib/client.js CHANGED
@@ -98,7 +98,7 @@ window.__ModuleLoader__.load({
98
98
  // 绝不写 :root / body —— 否则会污染整个 GUI。JS 解析出主题后往根节点写
99
99
  // data-dru-theme="dark|light",下面按属性切换;末一条 `:not([data-dru-theme])`
100
100
  // 是 JS 尚未执行时的纯 CSS 兜底(一旦 JS 写过属性就不再参与,不会打架)。
101
- ".dru-settings-section,.dru-popup,.dru-nav-remote{",
101
+ ".dru-settings-section,.dru-popup,.dru-nav-remote,.dru-standalone-card{",
102
102
  " color-scheme:light;",
103
103
  " --dru-surface:#f6f8fa;", // 卡片底
104
104
  " --dru-surface-2:#ffffff;", // 抬升面(输入框/行/弹窗卡)
@@ -149,10 +149,11 @@ window.__ModuleLoader__.load({
149
149
  // 深色:JS 写的 data-dru-theme 优先;宿主属性作 JS 未执行时的兜底。
150
150
  // 取值跟着宿主的深色基色走(body 实测 #151517 / 层 1 #232324 / 层 2 #2c2c2e / 层 3 #353638),
151
151
  // 语义色**在深底上重新取值**,不是沿用亮色值(亮色的 #1a7f37 / #cf222e 在深底对比度不足)。
152
- ".dru-settings-section[data-dru-theme=\"dark\"],.dru-popup[data-dru-theme=\"dark\"],.dru-nav-remote[data-dru-theme=\"dark\"],",
152
+ ".dru-settings-section[data-dru-theme=\"dark\"],.dru-popup[data-dru-theme=\"dark\"],.dru-nav-remote[data-dru-theme=\"dark\"],.dru-standalone-card[data-dru-theme=\"dark\"],",
153
153
  "body[data-ds-dark-theme] .dru-settings-section:not([data-dru-theme]),",
154
154
  "body[data-ds-dark-theme] .dru-popup:not([data-dru-theme]),",
155
- "body[data-ds-dark-theme] .dru-nav-remote:not([data-dru-theme]){",
155
+ "body[data-ds-dark-theme] .dru-nav-remote:not([data-dru-theme]),",
156
+ "body[data-ds-dark-theme] .dru-standalone-card:not([data-dru-theme]){",
156
157
  " color-scheme:dark;",
157
158
  " --dru-surface:#232324;",
158
159
  " --dru-surface-2:#2c2c2e;",
@@ -202,6 +203,15 @@ window.__ModuleLoader__.load({
202
203
  "}",
203
204
  // 设置页栏目容器(nav 选中后渲染在 settings.section 内容区)
204
205
  ".dru-settings-section{max-width:720px;display:flex;flex-direction:column;gap:14px;padding-top:2px;color:var(--dru-fg)}",
206
+ // 📱 独立「远程访问」弹层(2026-10-25):入口点击不再去"猜"官方设置面板的 DOM,
207
+ // 直接弹我们自己的一份设置页 —— 宿主改版也影响不到它。
208
+ ".dru-standalone-overlay{position:fixed;inset:0;z-index:2147483000;display:flex;align-items:center;justify-content:center;padding:24px;background:var(--dru-overlay)}",
209
+ ".dru-standalone-card{width:min(760px,100%);max-height:88vh;overflow:auto;box-sizing:border-box;padding:18px 20px 22px;border:1px solid var(--dru-border);border-radius:14px;background:var(--dru-surface-2);color:var(--dru-fg);box-shadow:0 18px 60px var(--dru-shadow)}",
210
+ ".dru-standalone-head{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:8px}",
211
+ ".dru-standalone-title{font-size:16px;font-weight:700}",
212
+ ".dru-standalone-close{appearance:none;border:1px solid var(--dru-border-ctl);background:var(--dru-surface-2);color:var(--dru-fg-muted);width:30px;height:30px;border-radius:8px;font-size:18px;line-height:1;cursor:pointer}",
213
+ ".dru-standalone-close:hover{background:var(--dru-hover);color:var(--dru-fg)}",
214
+ "@media (max-width:640px){.dru-standalone-overlay{padding:8px}.dru-standalone-card{max-height:94vh;border-radius:12px;padding:14px 14px 18px}}",
205
215
  ".dru-settings-head{display:flex;align-items:center;gap:10px;padding:6px 2px 2px}",
206
216
  ".dru-settings-icon{font-size:24px;line-height:1;flex:none}",
207
217
  // 标题/副标题优先沿用宿主语义令牌(自带深浅两套),取不到再退回本插件令牌
@@ -1117,6 +1127,61 @@ window.__ModuleLoader__.load({
1117
1127
  0.2 实测该槽就在侧栏底部、且**当前是空的**)—— 位置、宽度、折叠态全由宿主负责。
1118
1128
  所以这里不再注入任何 DOM,直接注册进槽位。id 仍保留 `dru-nav-remote`:
1119
1129
  公告徽标 / 首次红点那套按 id 取节点的既有逻辑因此不用改。 */
1130
+ /* 📱 独立「远程访问」弹层(2026-10-25 用户拍板):
1131
+ 桌面端点击侧栏入口时,不再去"点官方设置/找栏目"(宿主一改版就点错或没反应,
1132
+ 实测会点到左上角「更多→浏览插件」),而是弹出我们自己的一份设置页。
1133
+ 「设置 → 远程访问」栏目保留,正常从官方设置页进入的用户仍走那条路。
1134
+ 实现上用 shell.overlay 槽(宿主最上层,不受侧栏容器裁剪),组件常驻、按事件开关。 */
1135
+ var standaloneOverlayMounted = false;
1136
+ function openRemoteStandalonePanel() {
1137
+ try { window.dispatchEvent(new CustomEvent("dsh-remote:open-standalone")); } catch (e) { /* 忽略 */ }
1138
+ }
1139
+ function RemoteStandaloneOverlay() {
1140
+ var st = useState(false);
1141
+ var open = st[0];
1142
+ var setOpen = st[1];
1143
+ useEffect(function () {
1144
+ standaloneOverlayMounted = true;
1145
+ function onOpen() { try { setOpen(true); } catch (e) { /* 忽略 */ } }
1146
+ function onKey(e) {
1147
+ if (!e) return;
1148
+ if (e.key === "Escape" || e.keyCode === 27) { try { setOpen(false); } catch (e2) { /* 忽略 */ } }
1149
+ }
1150
+ try {
1151
+ window.addEventListener("dsh-remote:open-standalone", onOpen);
1152
+ window.addEventListener("keydown", onKey);
1153
+ } catch (e3) { /* 忽略 */ }
1154
+ return function () {
1155
+ standaloneOverlayMounted = false;
1156
+ try {
1157
+ window.removeEventListener("dsh-remote:open-standalone", onOpen);
1158
+ window.removeEventListener("keydown", onKey);
1159
+ } catch (e4) { /* 忽略 */ }
1160
+ };
1161
+ }, []);
1162
+ if (!open) return null;
1163
+ var dark = false;
1164
+ try { dark = !!document.body && document.body.hasAttribute("data-ds-dark-theme"); } catch (e5) { /* 忽略 */ }
1165
+ return h("div", {
1166
+ className: "dru-standalone-overlay",
1167
+ role: "dialog",
1168
+ "aria-modal": "true",
1169
+ "aria-label": "远程访问",
1170
+ onClick: function (e) { if (e && e.target === e.currentTarget) setOpen(false); }
1171
+ },
1172
+ h("div", { className: "dru-standalone-card", "data-dru-theme": dark ? "dark" : "light" },
1173
+ h("div", { className: "dru-standalone-head" },
1174
+ h("b", { className: "dru-standalone-title" }, "📱 远程访问"),
1175
+ h("button", {
1176
+ type: "button",
1177
+ className: "dru-standalone-close",
1178
+ "aria-label": "关闭",
1179
+ onClick: function () { setOpen(false); }
1180
+ }, "×")),
1181
+ h(RemoteControlSection, { standalone: true })
1182
+ ));
1183
+ }
1184
+
1120
1185
  function RemoteNavEntry(props) {
1121
1186
  var wide = !(props && props.wide === false);
1122
1187
  var seenArr = useState(false);
@@ -1133,7 +1198,16 @@ window.__ModuleLoader__.load({
1133
1198
  try { e.preventDefault(); } catch (err) { /* 忽略 */ }
1134
1199
  setClicked(true);
1135
1200
  dotMarkSeen(); // 用过入口 = 已了解位置 → 收起首次红点
1136
- if (remoteNavOpen) remoteNavOpen();
1201
+ // 2026-10-25(用户拍板):优先弹**我们自己的独立设置页**(不再依赖官方设置面板 DOM);
1202
+ // 只有宿主没有 shell.overlay 槽(极老版本)时才退回旧的"打开官方设置栏目"链路。
1203
+ try {
1204
+ openRemoteStandalonePanel();
1205
+ setTimeout(function () {
1206
+ if (!standaloneOverlayMounted) {
1207
+ try { openRemoteSettings(); } catch (e2) { /* 忽略 */ }
1208
+ }
1209
+ }, 150);
1210
+ } catch (errOpen) { /* 绝不因打开失败抛到宿主 */ }
1137
1211
  }
1138
1212
  }, [
1139
1213
  h("span", { className: "ico", key: "ico" }, "📱"),
@@ -6130,6 +6204,13 @@ window.__ModuleLoader__.load({
6130
6204
  // 公告是锦上添花,**没有任何资格**把门关上 —— 任何异常都只是"这次没有弹窗"。
6131
6205
  }
6132
6206
 
6207
+ // 📱 独立「远程访问」弹层(入口点击用;见 RemoteStandaloneOverlay 注释)
6208
+ try {
6209
+ ctx.slots.inject("shell.overlay", function () {
6210
+ return ctx.slots.register({ name: "shell.overlay", id: "dsh-remote-standalone", order: 95 }, RemoteStandaloneOverlay);
6211
+ });
6212
+ } catch (eStand) { /* 老宿主没有 shell.overlay:入口会在 150ms 后回退到官方设置栏目链路 */ }
6213
+
6133
6214
  // 📣 公告:每次页面加载**只拉一次**(sessionStorage 一次性标记,见 annPullOnce)。
6134
6215
  // 放在 apply() 里是刻意的:apply 跑在 app mount **之前**,所以这里**绝不能碰产品 DOM**
6135
6216
  // (那时还没有),只做数据拉取;UI 全部交给上面那个槽位与面板卡片。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-remote-web",
3
- "version": "0.7.6-beta.7",
3
+ "version": "0.7.6-beta.9",
4
4
  "description": "公网远程控制 DeepSeek Harness(dsh web):安装即得专属加密地址,人在外面也能用手机访问电脑上的 dsh——无需同一局域网/WiFi、无需公网 IP 与内网穿透,全程加密;手机端 100% 还原电脑体验(对话/工具/审批/设置)。技术用户可选自建服务,流量走自己的服务器。Remote control DeepSeek Harness (dsh web) from anywhere over the public internet — install, get an encrypted URL, use it from your phone on any network (dual-half cordis plugin: Settings panel + same-origin /dsh-remote routes). (2026-09 由 dsh-remote-ui 更名 / renamed from dsh-remote-ui; dsh-remote 的 dsh web 插件半,不是纯 UI/皮肤插件)",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -1679,20 +1679,22 @@ function releaseSpawnLock() {
1679
1679
  }
1680
1680
 
1681
1681
  // ---------- run:前台跑 bridge(带配置 + 自启动 watcher) ----------
1682
- async function runBridge() {
1683
- // 🔴 2026-10-25:升级自旧版的机器,launchd plist 里可能还带着**安装时的旧端口**
1684
- // (DSH_BRIDGE_UPSTREAM)。dsh 换端口后它会让守护/桥永远连旧端口 → 设备掉线。
1685
- // 插件每次装载都会把当前端口写进 .dsh-upstream,这里以文件为准校正进程环境(仅当文件合法且不同)。
1682
+ /** 以插件写入的 .dsh-upstream 为准校正进程内的旧上游环境变量(dsh 换端口后不再连旧端口)。 */
1683
+ function reconcileUpstreamEnvFromFile() {
1686
1684
  try {
1687
1685
  const fileUp = String(fs.readFileSync(path.join(CONFIG_DIR, UPSTREAM_FILE), "utf8")).trim().replace(/\/+$/, "");
1688
1686
  const envUp = String(process.env.DSH_BRIDGE_UPSTREAM || "").trim().replace(/\/+$/, "");
1689
- // 只在「继承到了旧的显式 env」时校正;env 为空时保持原有发现逻辑(文件可能过期,须走探测)。
1690
1687
  if (envUp && /^https?:\/\/[^\s]+$/i.test(fileUp) && fileUp !== envUp) {
1691
- console.log(`[dsh-remote] 忽略旧的上游地址 ${envUp || "(空)"} → 使用插件写入的最新地址 ${fileUp}(防端口漂移掉线)`);
1688
+ console.log(`[dsh-remote] 忽略旧的上游地址 ${envUp} → 使用插件写入的最新地址 ${fileUp}(防端口漂移掉线)`);
1692
1689
  process.env.DSH_BRIDGE_UPSTREAM = fileUp;
1693
1690
  discoveredUpstream = fileUp;
1694
1691
  }
1695
- } catch { /* 没有端口文件:保持原行为 */ }
1692
+ } catch { /* 无文件:保持原行为 */ }
1693
+ }
1694
+
1695
+ async function runBridge() {
1696
+ // 启动/每次拉起前都按插件写入的端口校正继承来的旧 env(旧 plist 可能钉着安装时的端口)
1697
+ reconcileUpstreamEnvFromFile();
1696
1698
  // 去重(所有平台):自启动服务、登录任务、插件半的脱离进程兜底都可能拉起 watcher,
1697
1699
  // 两个 bridge 会抢同一个设备登记 → 以 pid 文件为准。
1698
1700
  //
@@ -1889,6 +1891,7 @@ async function runBridge() {
1889
1891
  }
1890
1892
  warnedDuplicateBridge = false;
1891
1893
 
1894
+ reconcileUpstreamEnvFromFile(); // dsh 可能刚重启并换了端口:拉起前再以最新端口文件为准
1892
1895
  const alive = await checkUpstream();
1893
1896
  if (alive && childStopped(bridgeProc)) {
1894
1897
  starting = true;
@@ -2073,9 +2076,11 @@ async function setup(argv) {
2073
2076
  if (!PINNED_UPSTREAM && pluginTargets.some((t) => t.name === "desktop")) {
2074
2077
  const p = desktopAppPort();
2075
2078
  if (p) {
2076
- PINNED_UPSTREAM = `http://127.0.0.1:${p}`;
2077
- try { fs.writeFileSync(path.join(CONFIG_DIR, UPSTREAM_FILE), PINNED_UPSTREAM + "\n"); } catch { /* 忽略 */ }
2078
- console.log(`ℹ 桌面端在 127.0.0.1:${p} 监听 → 桥的上游已钉到它(避免与 Web 版互抢)`);
2079
+ // 🔴 2026-10-25:这里只能写运行时端口文件;**不能**回填 PINNED_UPSTREAM ——
2080
+ // 它会被写进 launchd plist 变成永久显式指定,dsh 换端口后守护/桥永远连旧端口
2081
+ // (用户实测 upstream_unreachable)。
2082
+ try { fs.writeFileSync(path.join(CONFIG_DIR, UPSTREAM_FILE), `http://127.0.0.1:${p}` + "\n"); } catch { /* 忽略 */ }
2083
+ console.log(`ℹ 桌面端在 127.0.0.1:${p} 监听 → 已写入运行时上游端口(不再钉进自启动配置)`);
2079
2084
  }
2080
2085
  }
2081
2086
  } catch { /* 探测失败不阻断安装 */ }