dsh-pocket 1.0.14 → 1.0.16
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.en.md +1 -1
- package/README.md +1 -1
- package/client/client.js +7 -1
- package/client/index.jsx +8 -1
- package/lib/index.js +12 -3
- package/lib/web-rpc.js +1 -1
- package/package.json +1 -1
package/README.en.md
CHANGED
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
|
|
9
9
|
<p align="center">
|
|
10
10
|
<a href="https://www.npmjs.com/package/dsh-pocket"><img alt="npm" src="https://img.shields.io/npm/v/dsh-pocket?color=4d6bfe&label=npm"></a>
|
|
11
|
-
<a href="https://www.npmjs.com/package/dsh-pocket"><img alt="downloads" src="https://img.shields.io/npm/dm/dsh-pocket?color=4d6bfe"></a>
|
|
12
11
|
<a href="https://github.com/shaobeichen/dsh-pocket/actions"><img alt="CI" src="https://github.com/shaobeichen/dsh-pocket/actions/workflows/npm-publish.yml/badge.svg"></a>
|
|
13
12
|
<a href="LICENSE"><img alt="License: MIT" src="https://img.shields.io/badge/license-GPL--2.0-red.svg"></a>
|
|
14
13
|
<a href="https://github.com/shaobeichen/dsh-pocket/stargazers"><img alt="GitHub stars" src="https://img.shields.io/github/stars/shaobeichen/dsh-pocket"></a>
|
|
14
|
+
<a href="https://awesome-dsh-plugin.com"><img alt="Awesome DSH Plugin" src="https://awesome-dsh-plugin.com/badge.svg"></a>
|
|
15
15
|
</p>
|
|
16
16
|
|
|
17
17
|
> Put **DeepSeek Harness in your pocket**: one package, one settings tab — scan a QR code and your phone shows exactly what's on your computer screen, live, from anywhere.
|
package/README.md
CHANGED
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
|
|
9
9
|
<p align="center">
|
|
10
10
|
<a href="https://www.npmjs.com/package/dsh-pocket"><img alt="npm" src="https://img.shields.io/npm/v/dsh-pocket?color=4d6bfe&label=npm"></a>
|
|
11
|
-
<a href="https://www.npmjs.com/package/dsh-pocket"><img alt="downloads" src="https://img.shields.io/npm/dm/dsh-pocket?color=4d6bfe"></a>
|
|
12
11
|
<a href="https://github.com/shaobeichen/dsh-pocket/actions"><img alt="CI" src="https://github.com/shaobeichen/dsh-pocket/actions/workflows/npm-publish.yml/badge.svg"></a>
|
|
13
12
|
<a href="LICENSE"><img alt="License: MIT" src="https://img.shields.io/badge/license-GPL--2.0-red.svg"></a>
|
|
14
13
|
<a href="https://github.com/shaobeichen/dsh-pocket/stargazers"><img alt="GitHub stars" src="https://img.shields.io/github/stars/shaobeichen/dsh-pocket"></a>
|
|
14
|
+
<a href="https://awesome-dsh-plugin.com/zh/"><img alt="Awesome DSH Plugin" src="https://awesome-dsh-plugin.com/badge.svg"></a>
|
|
15
15
|
</p>
|
|
16
16
|
|
|
17
17
|
> 把 **DeepSeek Harness 装进你的口袋**:一个包、一个设置页,手机扫二维码就实时看到电脑上的同一个界面——人在外面也能用。
|
package/client/client.js
CHANGED
|
@@ -1341,6 +1341,8 @@ function PocketSettingsTab({ rpcCall }) {
|
|
|
1341
1341
|
const latest = typeof meta?.version === "string" ? meta.version : null;
|
|
1342
1342
|
if (latest && v.current && compareVersions(latest, v.current) > 0) {
|
|
1343
1343
|
setUpdateInfo({ current: v.current, latest, updating: false, result: null });
|
|
1344
|
+
} else if (v.current && v.loaded && compareVersions(v.current, v.loaded) > 0) {
|
|
1345
|
+
setUpdateInfo({ current: v.current, latest: v.current, updating: false, result: "ok", updated: true });
|
|
1344
1346
|
}
|
|
1345
1347
|
} catch {
|
|
1346
1348
|
}
|
|
@@ -1449,7 +1451,11 @@ function PocketSettingsTab({ rpcCall }) {
|
|
|
1449
1451
|
(0, import_react2.createElement)(
|
|
1450
1452
|
"div",
|
|
1451
1453
|
{ style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 8 } },
|
|
1452
|
-
(0, import_react2.createElement)(
|
|
1454
|
+
(0, import_react2.createElement)(
|
|
1455
|
+
"div",
|
|
1456
|
+
{ style: { fontWeight: 600, fontSize: 13 } },
|
|
1457
|
+
updateInfo.updated ? `\u2705 \u5DF2\u66F4\u65B0 v${updateInfo.current}\uFF0C\u91CD\u542F\u751F\u6548 | Updated \u2014 restart to apply` : `\u{1F4E6} \u65B0\u7248\u672C v${updateInfo.latest} | Update available`
|
|
1458
|
+
),
|
|
1453
1459
|
updateInfo.result !== "ok" ? (0, import_react2.createElement)("button", { style: styles.primary, onClick: runUpdate, disabled: updateInfo.updating }, updateInfo.updating ? "\u66F4\u65B0\u4E2D\u2026" : `\u66F4\u65B0\u5230 v${updateInfo.latest} | Update`) : (0, import_react2.createElement)("button", { style: styles.primary, onClick: restartPocket, disabled: updateInfo.restarting }, updateInfo.restarting ? "\u91CD\u542F\u4E2D\u2026" : "\u{1F504} \u91CD\u542F dsh web \u751F\u6548 | Restart now")
|
|
1454
1460
|
),
|
|
1455
1461
|
(0, import_react2.createElement)(
|
package/client/index.jsx
CHANGED
|
@@ -91,6 +91,7 @@ function PocketSettingsTab({ rpcCall }) {
|
|
|
91
91
|
}, []);
|
|
92
92
|
|
|
93
93
|
// 版本检测:host 当前版本 vs npm registry latest(registry 带 CORS *)
|
|
94
|
+
// 两种情况显示横幅:① 有新版可更新;② 磁盘已更新但进程还是旧代码(重启生效)
|
|
94
95
|
useEffect(() => {
|
|
95
96
|
let alive = true;
|
|
96
97
|
(async () => {
|
|
@@ -101,6 +102,9 @@ function PocketSettingsTab({ rpcCall }) {
|
|
|
101
102
|
const latest = typeof meta?.version === 'string' ? meta.version : null;
|
|
102
103
|
if (latest && v.current && compareVersions(latest, v.current) > 0) {
|
|
103
104
|
setUpdateInfo({ current: v.current, latest, updating: false, result: null });
|
|
105
|
+
} else if (v.current && v.loaded && compareVersions(v.current, v.loaded) > 0) {
|
|
106
|
+
// 已更新未重启:显示「已更新,重启生效」+ 重启按钮
|
|
107
|
+
setUpdateInfo({ current: v.current, latest: v.current, updating: false, result: 'ok', updated: true });
|
|
104
108
|
}
|
|
105
109
|
} catch { /* 网络失败静默 */ }
|
|
106
110
|
})();
|
|
@@ -200,7 +204,10 @@ function PocketSettingsTab({ rpcCall }) {
|
|
|
200
204
|
// 更新提示
|
|
201
205
|
updateInfo ? h('div', { style: { ...styles.block, border: '1px solid var(--dsw-alias-state-warn-primary,#b45309)' }, borderRadius: 8, background: 'var(--dsw-alias-bg-layer-2,#f3f4f6)', padding: '10px 12px' },
|
|
202
206
|
h('div', { style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 8 } },
|
|
203
|
-
h('div', { style: { fontWeight: 600, fontSize: 13 } },
|
|
207
|
+
h('div', { style: { fontWeight: 600, fontSize: 13 } },
|
|
208
|
+
updateInfo.updated
|
|
209
|
+
? `✅ 已更新 v${updateInfo.current},重启生效 | Updated — restart to apply`
|
|
210
|
+
: `📦 新版本 v${updateInfo.latest} | Update available`),
|
|
204
211
|
updateInfo.result !== 'ok'
|
|
205
212
|
? h('button', { style: styles.primary, onClick: runUpdate, disabled: updateInfo.updating }, updateInfo.updating ? '更新中…' : `更新到 v${updateInfo.latest} | Update`)
|
|
206
213
|
: h('button', { style: styles.primary, onClick: restartPocket, disabled: updateInfo.restarting }, updateInfo.restarting ? '重启中…' : '🔄 重启 dsh web 生效 | Restart now'),
|
package/lib/index.js
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
import { fileURLToPath } from 'node:url';
|
|
11
11
|
import { spawn } from 'node:child_process';
|
|
12
12
|
import { createRequire } from 'node:module';
|
|
13
|
+
import { readFileSync } from 'node:fs';
|
|
13
14
|
import { writeFile, readFile, mkdir } from 'node:fs/promises';
|
|
14
15
|
import { join, dirname } from 'node:path';
|
|
15
16
|
import { homedir } from 'node:os';
|
|
@@ -23,15 +24,23 @@ const name = 'dsh-pocket';
|
|
|
23
24
|
const inject = ['connection', 'webServer'];
|
|
24
25
|
const require = createRequire(import.meta.url);
|
|
25
26
|
|
|
26
|
-
|
|
27
|
+
const pkgPath = fileURLToPath(new URL('../package.json', import.meta.url));
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* 本插件磁盘上的已安装版本。注意:**不能用 require 缓存**(进程内永远不变),
|
|
31
|
+
* 必须实时读文件——一键更新会改写 package.json,「已更新未重启」靠它识别。
|
|
32
|
+
*/
|
|
27
33
|
function currentVersion() {
|
|
28
34
|
try {
|
|
29
|
-
return
|
|
35
|
+
return JSON.parse(readFileSync(pkgPath, 'utf8')).version;
|
|
30
36
|
} catch {
|
|
31
37
|
return '0.0.0';
|
|
32
38
|
}
|
|
33
39
|
}
|
|
34
40
|
|
|
41
|
+
/** 进程启动时加载的版本(模块加载瞬间固化;用于识别「磁盘已更新但进程还是旧代码」)。 */
|
|
42
|
+
const loadedVersion = currentVersion();
|
|
43
|
+
|
|
35
44
|
const restartNoticeRel = join('dsh-pocket', 'restarted.json');
|
|
36
45
|
function restartNoticePath() {
|
|
37
46
|
return join(process.env.DSH_HOME ?? join(homedir(), '.dsh'), restartNoticeRel);
|
|
@@ -107,7 +116,7 @@ export function apply(ctx, config = {}, internals = {}) {
|
|
|
107
116
|
const disposeRpc = installPocketRpc(ctx, {
|
|
108
117
|
service,
|
|
109
118
|
push: internals.push ?? { vapidPublicKey: () => '', count: () => 0, subscribe: async () => false, unsubscribe: async () => false, isEnabled: () => true, setEnabled: async () => true },
|
|
110
|
-
runUpdate: internals.runUpdate ?? { currentVersion, perform: performUpdate },
|
|
119
|
+
runUpdate: internals.runUpdate ?? { currentVersion, perform: performUpdate, loadedVersion: () => loadedVersion },
|
|
111
120
|
restart: internals.restart ?? pocketRestart,
|
|
112
121
|
restartNotice: internals.restartNotice ?? readRestartNotice,
|
|
113
122
|
log: logger,
|
package/lib/web-rpc.js
CHANGED
|
@@ -63,7 +63,7 @@ export function installPocketRpc(ctx, { service, push, log = console, runUpdate
|
|
|
63
63
|
return ok({ enabled, count: push.count() });
|
|
64
64
|
}
|
|
65
65
|
if (endpoint === POCKET_ENDPOINTS.version) {
|
|
66
|
-
return ok({ current: runUpdate?.currentVersion?.() ?? null });
|
|
66
|
+
return ok({ current: runUpdate?.currentVersion?.() ?? null, loaded: runUpdate?.loadedVersion?.() ?? null });
|
|
67
67
|
}
|
|
68
68
|
if (endpoint === POCKET_ENDPOINTS.update) {
|
|
69
69
|
if (!runUpdate) return fail('bad-request', '更新不可用 | update unavailable');
|
package/package.json
CHANGED