dsh-mobile-ios 0.2.1 → 0.2.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.
package/README.md CHANGED
@@ -4,12 +4,12 @@
4
4
 
5
5
  DSH Mobile iOS 是 DSH Moblie 项目的桌面端插件与 iOS移动伴侣 App 的组合:插件在电脑端提供移动网关(REST + WebSocket),iPhone App 通过局域网或隧道配对连接,实时查看任务进度、追加指令、审批待办、查看产物。桌面端侧栏左下角有「**iOS移动伴侣**」入口,点开即见连接状态与配对码。
6
6
 
7
- > 本插件与社区的 [dsh-mobile](https://github.com/saya-ch/dsh-mobile)(Android 伴侣)定位互补、互不冲突:它走**原生 iOS App** 路线,面向 iPhone 优化(SwiftUI 原生界面、钥匙串凭证、系统通知),而不是移动网页布局适配。
7
+ 面向 iPhone / iPad 采用 **SwiftUI 原生界面**:钥匙串凭证、系统通知、双栏自适应,而非移动网页布局适配。
8
8
 
9
9
  ## 安装
10
10
 
11
11
  在 DSH 桌面端:**插件 → 添加插件**,输入框填包名 `dsh-mobile-ios`,点安装即可。
12
- 输入框接受的就是 **npm 包名**(也可带版本,如 `dsh-mobile-ios@0.2.1`)、Git 仓库
12
+ 输入框接受的就是 **npm 包名**(也可带版本,如 `dsh-mobile-ios@0.2.2`)、Git 仓库
13
13
  地址或本地插件目录路径。安装源展开后可选:
14
14
 
15
15
  - **npm 官方源** `registry.npmjs.org`
@@ -21,8 +21,8 @@ DSH Mobile iOS 是 DSH Moblie 项目的桌面端插件与 iOS移动伴侣 App
21
21
  `cordis.patch.yml`,校验可过),再按所选源安装。装好后桌面侧栏左下角出现
22
22
  「📱 iOS移动伴侣」入口,点开即可生成配对码,iPhone App 扫码连接。
23
23
 
24
- > 尚未发布到 npm 时,用 Git 地址 `https://github.com/yelter666/dsh-mobile-ios`
25
- > 或本地目录路径安装;发布后直接用包名即可。
24
+ > 本包已发布至 npm:`https://www.npmjs.com/package/dsh-mobile-ios`。
25
+ > 也可粘贴仓库地址 `https://github.com/yelter666/dsh-mobile-ios` 或本地目录路径安装。
26
26
 
27
27
  ### 更新
28
28
 
@@ -30,8 +30,8 @@ DSH Mobile iOS 是 DSH Moblie 项目的桌面端插件与 iOS移动伴侣 App
30
30
 
31
31
  - npm 已发布且有新版:提示到插件页**卸载后重新安装**(或输 `dsh-mobile-ios@版本号`
32
32
  更新)——DSH 对非官方按需插件的升级方式是"删除已装包再按相同选择重装";
33
- - 尚未发布(registry 返回 404):如实提示当前为本地开发版,更新方式为
34
- `git pull` 后重启 DSH 桌面端,插件随源码热重载;
33
+ - 本地 link 安装的开发态(读不到 registry 版本):提示 `git pull` 后重启 DSH
34
+ 桌面端,插件随源码热重载;
35
35
  - 网络不可达:如实报不可达,不假装已是最新。
36
36
 
37
37
  ### Windows 注意
@@ -58,8 +58,10 @@ macOS 用 `brew install cloudflared`。未安装时插件如实隐藏远程入
58
58
 
59
59
  ### 1. 安装插件(DSH Desktop)
60
60
 
61
+ 普通用户直接用上文「安装」里的包名方式即可。开发态想从源码加载:
62
+
61
63
  ```bash
62
- # 在桌面端 profile 注册本 bundle(安装后重启 DSH 生效)
64
+ # 在桌面端 profile 注册本地 bundle(改源码后重启 DSH 生效)
63
65
  dsh plugin --profile desktop add /path/to/dsh-mobile-ios
64
66
  ```
65
67
 
@@ -160,7 +162,7 @@ gateway/ # 包名 dsh-mobile-ios(插件标识)
160
162
  └── mux-table.mjs X2 方法表验收(32 断言)
161
163
  ```
162
164
 
163
- ## 2. 六条命令
165
+ ## 2. 开发命令
164
166
 
165
167
  ```bash
166
168
  # ① 起服务(mock 宿主,附带开箱可用的配对码)
@@ -168,7 +170,7 @@ node entries/sidecar.mjs --host=mock --dev
168
170
  # REST http://127.0.0.1:3081/mobile/v1/health
169
171
  # WS ws://127.0.0.1:3081/ws/mobile
170
172
 
171
- # ② 全量契约测试(11 套件 505 断言)
173
+ # ② 全量契约测试(11 套件 532 断言)
172
174
  npm test
173
175
 
174
176
  # ③ Spike-0 六项验收(本机)
@@ -220,12 +222,12 @@ bash spike0/run-demo.sh # 自动起服务 → 造 3 帧 → 跑客户
220
222
 
221
223
  | 项 | 结果 |
222
224
  |---|---|
223
- | `npm test`(11 套件) | **505 通过 / 0 失败**(自检 58 + 运维 41 + 韧性 29 + 借鉴 39 + mux 方法表 53 + 隧道 148 + 帧/产物/附件/增强/会话动作等) |
225
+ | `npm test`(11 套件) | **532 通过 / 0 失败**(自检 67 + 运维 44 + 韧性 29 + 借鉴 54 + mux 方法表 53 + 隧道 148 + 帧/产物/附件/增强/会话动作等) |
224
226
  | `node spike0/probe.mjs`(mock) | **PASS**,6 项阻塞全过;真宿主与 mux 两项目标为 WARN/SKIP(不假装通过) |
225
227
  | `node spike0/probe.mjs --host=mux`(不可达) | **FAIL**,如实报「宿主降级」与 `status=0`,不是假绿 |
226
228
  | X1 宿主挂载 | **已验证**(2026-11-16):desktop profile bundle 加载,127.0.0.1:3081 服务,/health + 配对码 + 4001 鉴权 |
227
229
  | X2 方法表 | **已落地**:`cordis-host.mjs` 进程内适配器 + 32 断言;真宿主对照 diag 待验 |
228
- | iOS 端到端(`ios/DSHMobileKit`) | **439 / 439** 全绿(Kit spike)+ 模拟器真跑截图链路 |
230
+ | iOS 端到端(`ios/DSHMobileKit`) | **634 / 634** 全绿(Kit spike)+ 模拟器真跑截图链路 |
229
231
 
230
232
  韧性验收覆盖的关键行为:异常断链后按游标续传(1..7 零丢失零重复)、缺口时 `gap=true` 且 `resumeFrom` 指向真实下界、宿主重启后旧 gen 握手被要求全量重建(`gap=true/resumed=0`)而新 gen 不误报、重启后 seq 从 1 重开、幂等窗口不随重启失效(`duplicate=true`)。
231
233
 
@@ -276,6 +278,7 @@ bash spike0/run-demo.sh # 自动起服务 → 造 3 帧 → 跑客户
276
278
  ## 10. 下一步
277
279
 
278
280
  1. **X2 真宿主实跑**:desktop profile 的 `cordis.patch.yml` 打开 `host: mux` 重启,对照 diag 服务可见性。
279
- 2. 真机装 `brew install cloudflared` 后,把 `--tunnel-bin` 指向真实可执行文件复跑 `test/ops.mjs`,
280
- 确认解析逻辑与真实输出格式一致(当前用假脚本验证的是格式契约,不是真实二进制)。
281
+ 2. 真机安装 cloudflared 后(macOS `brew install cloudflared`;Windows 下载 `cloudflared.exe`
282
+ 加入 PATH),把 `--tunnel-bin` 指向真实可执行文件复跑 `test/ops.mjs`,确认解析逻辑与真实
283
+ 输出格式一致(当前用假脚本验证的是格式契约,不是真实二进制)。
281
284
  3. iOS 界面层持续完善(连接指引页 / 附件契约升级 / 模型选择宿主映射)。
Binary file
@@ -14,9 +14,10 @@ import { createMockHost } from '../src/adapter/mock-host.mjs';
14
14
  import { createMuxHost } from '../src/adapter/mux-host.mjs';
15
15
  import { createCordisHost } from '../src/adapter/cordis-host.mjs';
16
16
  import { createProvisioner } from '../src/cloudflare.mjs';
17
+ import { PLUGIN_VERSION } from '../src/version.mjs';
17
18
 
18
19
  export const name = 'dsh-mobile-ios';
19
- export const version = '0.2.1';
20
+ export const version = PLUGIN_VERSION;
20
21
 
21
22
  /**
22
23
  * 本机 cloudflared 发现链:config.tunnelBin → env CLOUDFLARED_BIN(tunnel.mjs 处理)
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "dsh-mobile-ios",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "type": "module",
5
5
  "description": "DSH iOS移动伴侣:iPhone/iPad 扫码连接 DSH 桌面端,局域网直连 + Cloudflare Tunnel 固定域名远程两种通道",
6
6
  "main": "entries/plugin.mjs",
7
+ "icon": "assets/brand/plugin-icon.png",
7
8
  "engines": {
8
9
  "node": ">=20",
9
10
  "dsh": ">=0.2.1-alpha.4"
@@ -17,6 +18,7 @@
17
18
  ],
18
19
  "license": "MIT",
19
20
  "files": [
21
+ "assets/",
20
22
  "entries/",
21
23
  "lib/",
22
24
  "src/",
@@ -28,7 +30,7 @@
28
30
  "start": "node entries/sidecar.mjs --host=mock --dev",
29
31
  "start:lan": "node entries/sidecar.mjs --host=mock --dev --lan=true",
30
32
  "probe": "node spike0/probe.mjs",
31
- "test": "node test/selftest.mjs && node test/ops.mjs && node test/resilience.mjs && node test/borrowed.mjs && node test/mux-table.mjs && node test/live-frames.mjs && node test/artifacts.mjs && node test/attachments.mjs && node test/session-actions.mjs && node test/enhance.mjs && node test/tunnel-named.mjs"
33
+ "test": "node test/selftest.mjs && node test/version.mjs && node test/ops.mjs && node test/resilience.mjs && node test/borrowed.mjs && node test/mux-table.mjs && node test/live-frames.mjs && node test/artifacts.mjs && node test/attachments.mjs && node test/session-actions.mjs && node test/enhance.mjs && node test/tunnel-named.mjs"
32
34
  },
33
35
  "dsh": {
34
36
  "bundle": {
package/src/rest.mjs CHANGED
@@ -4,6 +4,7 @@
4
4
  import { fail, ERRORS, newId } from './protocol.mjs';
5
5
  import { translateRecords } from './adapter/session-history.mjs';
6
6
  import { createRequire } from 'node:module';
7
+ import { PLUGIN_VERSION } from './version.mjs';
7
8
 
8
9
  // QR 编码(vendor:qrcode-generator 1.4.4,MIT,零依赖;见 lib/vendor/,
9
10
  // .cjs 后缀:包为 type:module,require 需显式 CommonJS)
@@ -97,7 +98,8 @@ const DESKTOP_CORS_PATHS = [
97
98
  /^\/mobile\/v1\/tunnel\/provision$/,
98
99
  ];
99
100
 
100
- const GATEWAY_VERSION = '0.2.1';
101
+ // 面板「插件版本」与更新检查的「当前版本」都取这里;必须与 npm 包版本同源。
102
+ const GATEWAY_VERSION = PLUGIN_VERSION;
101
103
 
102
104
  function readJson(req) {
103
105
  return new Promise((resolve, reject) => {
@@ -0,0 +1,24 @@
1
+ // src/version.mjs — 插件版本号的唯一真相源(single source of truth)
2
+ //
3
+ // 事故背景:面板「插件版本」走 summary.version(rest.mjs 的 GATEWAY_VERSION),
4
+ // 插件详情走 npm 包元数据 package.json,更新检查拿前者比对 npm latest。
5
+ // 发版时 npm version 只改了 package.json,两处硬编码仍停在 0.2.1,
6
+ // 于是详情显示 v0.2.2、面板显示 v0.2.1、更新检查误报「发现新版」。
7
+ //
8
+ // 修复:所有展示与比对统一从 package.json 读取,杜绝多处硬编码漂移。
9
+ // npm 始终会把 package.json 打进 tarball(无论 files 字段),故运行时可读。
10
+
11
+ import { createRequire } from 'node:module';
12
+
13
+ const require = createRequire(import.meta.url);
14
+
15
+ let loaded;
16
+ try {
17
+ loaded = require('../package.json').version;
18
+ } catch (err) {
19
+ // 读不到版本号是打包异常,必须显式失败,绝不能回退到某个写死的版本号
20
+ // ——那正是本次事故的根因。
21
+ throw new Error(`[dsh-mobile-ios] 无法从 package.json 读取版本号:${err.message}`);
22
+ }
23
+
24
+ export const PLUGIN_VERSION = String(loaded);