dsh-mobile-plugin 0.5.97 → 0.5.99

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.
@@ -138,7 +138,7 @@ async function workspaceListViaFollow(ctx, signal) {
138
138
  updatedAt: workspace.updatedAt,
139
139
  })),
140
140
  archivedSessionIds: [...registry.archivedSessionIds],
141
- pinnedSessionIds: [...registry.pinnedSessionIds],
141
+ pinnedSessionIds: Array.isArray(registry.pinnedSessionIds) ? [...registry.pinnedSessionIds] : [],
142
142
  });
143
143
  }
144
144
  const frames = await openStream(ctx, 'workspace', 'follow', {}, deadline(signal, SYNTHETIC_DEADLINE_MS));
@@ -11,11 +11,20 @@
11
11
  * 环境对不上时按 ERR_PNPM_*_DIFF / store 不一致各修一次再重试;装前先看有没有 agent 在跑(force 与 auto 跳过这道闸);失败要带出包管理器自己的报错正文;Windows 上是 .cmd,见 `cmdInvocation`。
12
12
  */
13
13
 
14
+ /**
15
+ * 依赖自检要绕开 Node 的模块解析缓存:`Module._pathCache` 存的是「请求 + 查找路径 → 绝对路径」,
16
+ * 只记路径、不再看盘。装前那次自检刚把旧布局(插件内嵌套的 node_modules)写进去,pnpm 升级后
17
+ * 把嵌套目录删掉、改成顶层 hoist,同一个 package.json 的查找路径没变,缓存仍返回已删的嵌套路径,
18
+ * `accessSync` 抛 ENOENT,一次正常升级就被判成安装不完整并回退。这是进程级缓存,不重启 DSH
19
+ * 会每轮更新复现,所以每次自检解析依赖前清空。
20
+ */
21
+
14
22
  const fs = require('node:fs');
15
23
  const os = require('node:os');
16
24
  const path = require('node:path');
17
25
  const { spawn } = require('node:child_process');
18
- const { createRequire } = require('node:module');
26
+ const Module = require('node:module');
27
+ const { createRequire } = Module;
19
28
 
20
29
  const { checkForUpdate } = require('./update-registry.cjs');
21
30
 
@@ -277,6 +286,8 @@ function installationProblem(profileNodeModules, name, version) {
277
286
  try {
278
287
  const pkg = JSON.parse(fs.readFileSync(file, 'utf8'));
279
288
  if (pkg.version !== version) return `预期 ${version},盘上是 ${pkg.version ?? '未知版本'}`;
289
+ // 见顶部:缓存的是绝对路径、不再看盘;上面那次自检刚把旧布局写进去,pnpm 一换目录就拿到已删路径。
290
+ Module._pathCache = Object.create(null);
280
291
  const fromPlugin = createRequire(fs.realpathSync(file));
281
292
  for (const dependency of Object.keys(pkg.dependencies || {})) {
282
293
  fs.accessSync(fromPlugin.resolve(dependency));
@@ -1,4 +1,5 @@
1
1
  // ZeroNews 线路挂载:把运行器接进装配层,隧道地址写回独立字段,随 effect 启停。
2
+ // 第一次接入的「打开登录页」按命令退出结果返回,不给面板留永远等不到的等待。
2
3
  'use strict';
3
4
 
4
5
  /**
@@ -28,15 +29,16 @@ const CONSOLE_URL = 'https://user.zeronews.cc/setup';
28
29
  * 进程,`open` / `start` / `xdg-open` 一定到得了。打不开就回 false,让面板把地址写出来给人
29
30
  * 手动点 —— 不假装开过。
30
31
  */
31
- function openInBrowser(url) {
32
+ function openInBrowser(url, exec = execFile) {
32
33
  const platform = process.platform;
33
34
  const command = platform === 'darwin' ? 'open' : platform === 'win32' ? 'cmd' : 'xdg-open';
34
35
  const args = platform === 'win32' ? ['/c', 'start', '', url] : [url];
35
36
  return new Promise((resolve) => {
36
37
  try {
37
- const child = execFile(command, args, { windowsHide: true }, () => {});
38
- if (child && typeof child.on === 'function') child.on('error', () => resolve(false));
39
- else resolve(false);
38
+ // 命令退出(含打不开的报错)就是结果;只等 error 会在浏览器正常打开时永远等不到。
39
+ const child = exec(command, args, { windowsHide: true }, (err) => resolve(!err));
40
+ if (!child || typeof child.on !== 'function') resolve(false);
41
+ else child.on('error', () => resolve(false));
40
42
  } catch { resolve(false); }
41
43
  });
42
44
  }
@@ -58,6 +60,7 @@ function mountZeroNews(options) {
58
60
  const { mount, settings, getState, control, warn, ctx, name } = options;
59
61
  const makeRunner = typeof options.runnerFactory === 'function' ? options.runnerFactory : createZeroNewsRunner;
60
62
  const provision = typeof options.ensure === 'function' ? options.ensure : ensureZeroNews;
63
+ const exec = typeof options.execFile === 'function' ? options.execFile : execFile;
61
64
  // 自愈:客户端意外退出 / 启动失败时,只要还「配置过」,就按退避自动重连,别让线路卡死在错误上。
62
65
  // 插件自动更新 / 就地重载后由新实例重新挂载,这条重连负责把上一轮断掉的客户端重新接上。
63
66
  const retryBaseMs = Number(options.retryBaseMs) > 0 ? Number(options.retryBaseMs) : 3000;
@@ -130,7 +133,7 @@ function mountZeroNews(options) {
130
133
  if (!got || !got.ok) {
131
134
  return { ok: false, error: got && got.code === 'unsupported-platform' ? '这台系统不支持自动安装 ZeroNews 客户端' : '下载 ZeroNews 客户端失败,请稍后重试' };
132
135
  }
133
- const opened = await (typeof options.openUrl === 'function' ? options.openUrl(CONSOLE_URL) : openInBrowser(CONSOLE_URL));
136
+ const opened = await (typeof options.openUrl === 'function' ? options.openUrl(CONSOLE_URL) : openInBrowser(CONSOLE_URL, exec));
134
137
  return { ok: true, downloaded: got.source === 'downloaded', opened: opened === true, url: CONSOLE_URL };
135
138
  };
136
139
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-mobile-plugin",
3
- "version": "0.5.97",
3
+ "version": "0.5.99",
4
4
  "description": "Mobile API (/api/mobile/v1) and relay client for the DSH mobile app — desktop profile build (dsh 0.2.x, peers resolved by the host)",
5
5
  "license": "MIT",
6
6
  "icon": "./icon.png",
@@ -78,11 +78,11 @@
78
78
  "ws": "8.23.0"
79
79
  },
80
80
  "optionalDependencies": {
81
- "dsh-mobile-shell-darwin-arm64": "0.1.2",
82
- "dsh-mobile-shell-darwin-x64": "0.1.2",
83
- "dsh-mobile-shell-linux-arm64": "0.1.2",
84
- "dsh-mobile-shell-linux-x64": "0.1.2",
85
- "dsh-mobile-shell-win32-x64": "0.1.2",
81
+ "dsh-mobile-shell-darwin-arm64": "0.1.3",
82
+ "dsh-mobile-shell-darwin-x64": "0.1.3",
83
+ "dsh-mobile-shell-linux-arm64": "0.1.3",
84
+ "dsh-mobile-shell-linux-x64": "0.1.3",
85
+ "dsh-mobile-shell-win32-x64": "0.1.3",
86
86
  "dsh-mobile-tailcat-darwin-arm64": "1.1.7",
87
87
  "dsh-mobile-tailcat-darwin-x64": "1.1.7",
88
88
  "dsh-mobile-tailcat-linux-arm64": "1.1.7",