dsh-mobile-ios 0.2.2 → 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
@@ -9,7 +9,7 @@ DSH Mobile iOS 是 DSH Moblie 项目的桌面端插件与 iOS移动伴侣 App
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`
@@ -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,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-mobile-ios",
3
- "version": "0.2.2",
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",
@@ -30,7 +30,7 @@
30
30
  "start": "node entries/sidecar.mjs --host=mock --dev",
31
31
  "start:lan": "node entries/sidecar.mjs --host=mock --dev --lan=true",
32
32
  "probe": "node spike0/probe.mjs",
33
- "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"
34
34
  },
35
35
  "dsh": {
36
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);