dsh-protorig-panel 0.4.19 → 0.4.20

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
@@ -1,6 +1,6 @@
1
1
  # dsh-protorig-panel
2
2
 
3
- dsh-protorig-panel 将 PROTORIG ES 用作 480×480 副屏和遥控器。USB 由电脑渲染画面并接收手表触摸,BLE 由手表显示电脑指标和交互卡片。本仓库中的插件版本为 **0.4.19**。
3
+ dsh-protorig-panel 将 PROTORIG ES 用作 480×480 副屏和遥控器。USB 由电脑渲染画面并接收手表触摸,BLE 由手表显示电脑指标和交互卡片。本仓库中的插件版本为 **0.4.20**。
4
4
 
5
5
  设置页支持设备绑定、显示参数、审批与问答、图片表盘安装、默认表盘下半区换图,以及 Windows/macOS 烧录。
6
6
 
@@ -50,12 +50,12 @@ eFuse chip ID 算出。实现见固件 `services/svc_device_id.c`。
50
50
 
51
51
  ### 从 npm 安装(公网)
52
52
 
53
- 插件已发布到公网 npm(当前 0.4.19):
53
+ 插件已发布到公网 npm(当前 0.4.20):
54
54
 
55
55
  ```bash
56
- npm i -g dsh-protorig-panel@0.4.19
56
+ npm i -g dsh-protorig-panel@0.4.20
57
57
  # 或装进 DSH profile
58
- dsh plugin --profile <name> add dsh-protorig-panel@0.4.19 --allow-build=@serialport/bindings-cpp
58
+ dsh plugin --profile <name> add dsh-protorig-panel@0.4.20 --allow-build=@serialport/bindings-cpp
59
59
  ```
60
60
 
61
61
  ### macOS 上用 DSH 自带的 pnpm
@@ -66,7 +66,7 @@ dsh plugin --profile <name> add dsh-protorig-panel@0.4.19 --allow-build=@serialp
66
66
  cd plugin/dsh-protorig-panel
67
67
  ./tools/pnpm-dsh.sh install --frozen-lockfile # 首次 / 锁文件变更后
68
68
  ./tools/pnpm-dsh.sh test # 运行插件测试
69
- ./tools/pnpm-dsh.sh pack # → dsh-protorig-panel-0.4.19.tgz
69
+ ./tools/pnpm-dsh.sh pack # → dsh-protorig-panel-0.4.20.tgz
70
70
  ```
71
71
 
72
72
  - 构建脚本白名单在 `pnpm-workspace.yaml` 的 `allowBuilds`(pnpm 11 起不再读
@@ -83,7 +83,7 @@ cd plugin/dsh-protorig-panel
83
83
  cd plugin/dsh-protorig-panel
84
84
  npm ci # 或 npm install
85
85
  npm test
86
- npm pack # → dsh-protorig-panel-0.4.19.tgz
86
+ npm pack # → dsh-protorig-panel-0.4.20.tgz
87
87
  ```
88
88
 
89
89
  ### 装进 DSH profile / 插件管理器
@@ -97,7 +97,7 @@ npm pack # → dsh-protorig-panel-0.4.19.tgz
97
97
  > 非交互安装(CLI)时可以直接放行,等价于批准:
98
98
  >
99
99
  > ```bash
100
- > dsh plugin --profile <name> add ./dsh-protorig-panel-0.4.19.tgz \
100
+ > dsh plugin --profile <name> add ./dsh-protorig-panel-0.4.20.tgz \
101
101
  > --allow-build=@serialport/bindings-cpp
102
102
  > ```
103
103
 
@@ -112,7 +112,7 @@ npm_config_store_dir="<dsh-portable-dir>/store" \
112
112
  # 装完重启 DSH 宿主(插件在宿主进程内加载)
113
113
  ```
114
114
 
115
- 也可以用 DSH 的插件管理器装 tarball 路径(`plugin add ./dsh-protorig-panel-0.4.19.tgz`)。
115
+ 也可以用 DSH 的插件管理器装 tarball 路径(`plugin add ./dsh-protorig-panel-0.4.20.tgz`)。
116
116
  插件靠 `package.json` 的 `dsh.bundle.patch → cordis.patch.yml` 被加载;
117
117
  `plugin add` 会把 bundle 追加到 profile 的 `dsh.profile.bundles`。
118
118
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-protorig-panel",
3
- "version": "0.4.19",
3
+ "version": "0.4.20",
4
4
  "description": "PROTORIG ES 手表电脑模式插件:USB 像素副屏 + 脏块渲染 + 审批/问答 + 跨平台设备身份(admin_id);烧录(Windows/macOS)",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -250,6 +250,9 @@ export class BleBridge {
250
250
  const scanStale = this.scanning && Date.now() - this.scanStartedAt > 120000;
251
251
  /* connecting 期间绝不能再 startScanning:WinRT 会在 GATT 连接中途重置
252
252
  * watcher,表现为"有时连上、有时一直连不上"(2026-11-14 用户实测)。 */
253
+ /* 设置页关掉「蓝牙连接」:面板会显式 stop(),这里再兜一层 ——
254
+ * 重试定时器/旧 tick 残留都不该把扫描重新拉起来。 */
255
+ if (this.config?.ble?.enabled === false) return false;
253
256
  if (this.disabled || this.connected || this.connecting || this.timer || this.starting) return false;
254
257
  if (this.scanning && !scanStale) return false;
255
258
  if (scanStale) {
@@ -281,6 +284,7 @@ export class BleBridge {
281
284
 
282
285
  #onDiscover(peripheral) {
283
286
  if (this.probeOnly) return; // probeOnce() 自己收集广播,不自动连
287
+ if (this.config?.ble?.enabled === false) return; // 开关关掉:残留广播不再触发连接
284
288
  if (this.connected || this.connecting || this.stopping) return;
285
289
  const advertisement = peripheral?.advertisement ?? {};
286
290
  const localName = advertisement.localName ?? peripheral?.advertisement?.serviceLocalName ?? '';
@@ -468,7 +472,7 @@ export class BleBridge {
468
472
  this.timer = setTimeout(() => {
469
473
  this.timer = null;
470
474
  if (!this.stopping) {
471
- if (this.noble?.state === 'poweredOn' && !this.connected) {
475
+ if (this.config?.ble?.enabled !== false && this.noble?.state === 'poweredOn' && !this.connected) {
472
476
  try {
473
477
  this.noble.startScanning([], true);
474
478
  this.scanning = true;
package/src/client.js CHANGED
@@ -149,7 +149,9 @@ window.__ModuleLoader__.load({
149
149
 
150
150
  /* 连接 */
151
151
  connection: '连接',
152
- connectionHint: '关闭后不再主动连接;探测只登记编号,不改变当前连接。',
152
+ connectionHint: '关掉开关会立刻停掉该通道(连正在跑的扫描一起停)并禁止自动连接;「断开」只是临时暂停全部,点「重连」恢复。探测只登记编号,不改变当前连接。',
153
+ statusPaused: '已暂停(手动断开)',
154
+ statusBothOff: '两个通道都已关闭',
153
155
  usbSwitch: 'USB 连接',
154
156
  bleSwitch: '蓝牙连接',
155
157
  probeTitle: '设备探测',
@@ -350,7 +352,9 @@ window.__ModuleLoader__.load({
350
352
  balanceInterval: 'Refresh interval',
351
353
 
352
354
  connection: 'Connection',
353
- connectionHint: 'When off, the plugin stops connecting. Probing only registers IDs.',
355
+ connectionHint: 'Turning a channel off stops it immediately (including a running scan) and blocks auto-connect. Disconnect only pauses everything until you press Reconnect. Probe just registers IDs.',
356
+ statusPaused: 'Paused (manually disconnected)',
357
+ statusBothOff: 'Both channels are off',
354
358
  usbSwitch: 'USB connection',
355
359
  bleSwitch: 'BLE connection',
356
360
  probeTitle: 'Device probe',
@@ -1536,12 +1540,18 @@ window.__ModuleLoader__.load({
1536
1540
  }
1537
1541
 
1538
1542
  /** 概览:状态 + 身份 + 电量 + 快捷操作(73 §8 / §8.2)。 */
1539
- function OverviewGroup({ t, host, onAction, busy, message, open, onToggle }) {
1543
+ function OverviewGroup({ t, host, onAction, busy, message, open, onToggle, draft, change, onProbe, probeBusy, probeMessage }) {
1540
1544
  const runtime = host?.state ?? null;
1541
1545
  const connected = !!runtime?.connected;
1542
1546
  const ble = !!runtime?.ble;
1543
1547
  const device = runtime?.device ?? {};
1544
- const status = connected ? t('statusUsb') : ble ? t('statusBle') : t('statusOffline');
1548
+ const bothOff = draft.usb.enabled === false && draft.ble.enabled === false;
1549
+ const paused = runtime?.paused === true;
1550
+ const status = connected ? t('statusUsb')
1551
+ : ble ? t('statusBle')
1552
+ : bothOff ? t('statusBothOff')
1553
+ : paused ? t('statusPaused')
1554
+ : t('statusOffline');
1545
1555
  const where = connected && runtime?.port ? ` · ${runtime.port}` : '';
1546
1556
  const fw = runtime?.firmwareVersion
1547
1557
  || (Number.isFinite(runtime?.protocolVersion) ? `v${runtime.protocolVersion}` : '—');
@@ -1564,13 +1574,33 @@ window.__ModuleLoader__.load({
1564
1574
  h('span', { style: styles.statusDot(connected || ble, false) }),
1565
1575
  h('span', { style: styles.statusText }, `${status}${where}`),
1566
1576
  message ? h('span', { style: { ...styles.message, color: C.secondary } }, message) : null),
1577
+ /* 连接通道开关 + 探测(2026-11-22 从最底部「连接」分组搬上来):
1578
+ * 想关掉蓝牙扫描却要翻到最后,而且关掉当时并不会停掉已在跑的扫描 —— 状态只有放在
1579
+ * 概览这里、和「断开/重连」排在一起才说得清。 */
1580
+ h(Row, { label: t('usbSwitch') },
1581
+ h(Toggle, {
1582
+ checked: draft.usb.enabled, label: t('usbSwitch'),
1583
+ onChange: (value) => change(['usb', 'enabled'], value),
1584
+ })),
1585
+ h(Row, { label: t('bleSwitch') },
1586
+ h(Toggle, {
1587
+ checked: draft.ble.enabled, label: t('bleSwitch'),
1588
+ onChange: (value) => change(['ble', 'enabled'], value),
1589
+ })),
1590
+ h('p', { style: styles.note }, t('connectionHint')),
1591
+ h(Row, { label: t('probeTitle') },
1592
+ h(Button, { onClick: () => onProbe('usb'), disabled: probeBusy === 'usb' },
1593
+ probeBusy === 'usb' ? t('scanning') : t('probeUsb')),
1594
+ h(Button, { onClick: () => onProbe('ble'), disabled: probeBusy === 'ble' },
1595
+ probeBusy === 'ble' ? t('scanning') : t('probeBle'))),
1596
+ probeMessage ? h('p', { style: styles.note }, probeMessage) : null,
1567
1597
  h('p', { style: styles.metaLine }, meta),
1568
1598
  device.mismatch ? h('p', { style: styles.warn }, t('bindMismatch')) : null,
1569
1599
  h('div', { style: styles.actions },
1570
1600
  h(Button, { style: 'primary', onClick: () => onAction('reconnect'), disabled: busy }, t('actionReconnect')),
1571
- h(Button, { onClick: () => onAction('disconnect'), disabled: busy || !connected }, t('actionDisconnect')),
1601
+ h(Button, { onClick: () => onAction('disconnect'), disabled: busy || paused }, t('actionDisconnect')),
1572
1602
  h(Button, { onClick: () => onAction('identify'), disabled: busy || !(connected || ble) }, t('actionIdentify'))),
1573
- !connected && !ble ? h('p', { style: styles.note }, t('needWatch')) : null);
1603
+ !connected && !ble && !bothOff ? h('p', { style: styles.note }, t('needWatch')) : null);
1574
1604
  }
1575
1605
 
1576
1606
  /** 设备:候选列表 + 绑定/解绑 + 当前连接(P10)。 */
@@ -1678,7 +1708,6 @@ window.__ModuleLoader__.load({
1678
1708
  display: true,
1679
1709
  faces: true,
1680
1710
  interaction: false,
1681
- connection: false,
1682
1711
  devices: false,
1683
1712
  advanced: false,
1684
1713
  }));
@@ -1859,6 +1888,7 @@ window.__ModuleLoader__.load({
1859
1888
  t, host, busy: actionBusy, message: actionMessage,
1860
1889
  open: openGroups.overview, onToggle: () => toggle('overview'),
1861
1890
  onAction: runAction,
1891
+ draft, change, onProbe: probeDevices, probeBusy, probeMessage,
1862
1892
  }),
1863
1893
 
1864
1894
  /* 2 显示(USB/蓝牙同一组控件,用分段切换) */
@@ -1972,35 +2002,14 @@ window.__ModuleLoader__.load({
1972
2002
  },
1973
2003
  h(FacesGroup, { t, host, connected })),
1974
2004
 
1975
- /* 5 连接开关 + 探测注册 */
1976
- h(Group, {
1977
- title: t('connection'), hint: t('connectionHint'),
1978
- open: openGroups.connection, onToggle: () => toggle('connection'),
1979
- },
1980
- h(Row, { label: t('usbSwitch') },
1981
- h(Toggle, {
1982
- checked: draft.usb.enabled, label: t('usbSwitch'),
1983
- onChange: (value) => change(['usb', 'enabled'], value),
1984
- })),
1985
- h(Row, { label: t('bleSwitch') },
1986
- h(Toggle, {
1987
- checked: draft.ble.enabled, label: t('bleSwitch'),
1988
- onChange: (value) => change(['ble', 'enabled'], value),
1989
- })),
1990
- h(Divider),
1991
- h(Row, { label: t('probeTitle') },
1992
- h(Button, { onClick: () => probeDevices('usb'), disabled: probeBusy === 'usb' }, probeBusy === 'usb' ? t('scanning') : t('probeUsb')),
1993
- h(Button, { onClick: () => probeDevices('ble'), disabled: probeBusy === 'ble' }, probeBusy === 'ble' ? t('scanning') : t('probeBle'))),
1994
- probeMessage ? h('p', { style: styles.note }, probeMessage) : null),
1995
-
1996
- /* 6 设备 */
2005
+ /* 5 设备 */
1997
2006
  h(DeviceGroup, {
1998
2007
  t, host, open: devicesOpen,
1999
2008
  onToggle: () => setOpenGroups((current) => ({ ...current, devicesTouched: true, devices: !devicesOpen })),
2000
2009
  onBind: bindDevice, bindBusy, deviceMessage, onRefresh: scanDevices, scanning,
2001
2010
  }),
2002
2011
 
2003
- /* 7 高级(默认折叠;烧录仅 Windows/macOS 渲染) */
2012
+ /* 6 高级(默认折叠;烧录仅 Windows/macOS 渲染) */
2004
2013
  h(Group, {
2005
2014
  title: t('advanced'), hint: t('advancedHint'),
2006
2015
  open: openGroups.advanced, onToggle: () => toggle('advanced'),
@@ -211,6 +211,7 @@ export class PanelService {
211
211
  this.appliedDeviceId = this.config.deviceId;
212
212
  /** 已生效的 USB 连接开关(关掉时自动断开串口)。 */
213
213
  this.appliedUsbEnabled = this.config.usb.enabled !== false;
214
+ this.appliedBleEnabled = this.config.ble.enabled !== false;
214
215
  /** 最近一次枚举到的候选口(/state 与设置页「设备」分组直接读它,不重复枚举)。 */
215
216
  this.candidates = [];
216
217
  this.candidatesAt = 0;
@@ -2008,6 +2009,23 @@ export class PanelService {
2008
2009
  }
2009
2010
  }
2010
2011
 
2012
+ /* 设置页改了蓝牙连接开关:关掉必须**立刻 stop()**,不能只是"下一次不再 start"。
2013
+ * 残留的 startScanning 会继续收广播,`#onDiscover` 命中后还会自己连上(2026-11-22 实测),
2014
+ * 用户看着开关是关的,射频却一直在扫。 */
2015
+ const bleEnabled = this.config.ble.enabled !== false;
2016
+ if (bleEnabled !== this.appliedBleEnabled) {
2017
+ this.appliedBleEnabled = bleEnabled;
2018
+ this.logger.info(`蓝牙连接开关:${bleEnabled ? '开' : '关'}`);
2019
+ if (!bleEnabled) {
2020
+ // 先把新配置交给 bridge,再停:避免这 500 ms 内残留广播按旧配置连上
2021
+ this.ble.config = this.config;
2022
+ await this.ble.stop().catch(() => {});
2023
+ } else if (this.manualPaused) {
2024
+ // 用户重新打开通道 = 想连:清掉「断开」的暂停,让 tick 重新起桥
2025
+ this.manualPaused = false;
2026
+ }
2027
+ }
2028
+
2011
2029
  // 设置页改了设备绑定(P6/P7):按新绑定重新挑口;连着的正是绑定表就不折腾
2012
2030
  const bound = normalizeAdminId(this.config.deviceId);
2013
2031
  if (bound !== this.appliedDeviceId) {
@@ -2036,14 +2054,15 @@ export class PanelService {
2036
2054
  if (!this.link.state.connected) {
2037
2055
  if (this.manualPaused) {
2038
2056
  // 用户点了「断开」:不探测、不起 BLE,等「重连」或改设置
2039
- if (this.ble.connected || this.ble.child || this.ble.starting) this.ble.stop();
2057
+ // scanning 也算在内:否则"暂停"只是不再新起扫描,已经在跑的照旧收广播。
2058
+ if (this.ble.connected || this.ble.starting || this.ble.scanning) this.ble.stop();
2040
2059
  return;
2041
2060
  }
2042
2061
  // 断开期间:USB 开关开才探测;BLE 开关开才起桥(失败由 tick 重试)
2043
2062
  if (usbEnabled) this.#scheduleOpen();
2044
2063
  this.ble.config = this.config;
2045
2064
  if (!this.config.ble.enabled) {
2046
- if (this.ble.connected || this.ble.child || this.ble.starting) this.ble.stop();
2065
+ if (this.ble.connected || this.ble.starting || this.ble.scanning) this.ble.stop();
2047
2066
  } else if (now - this.startedAt > 1500 && now - (this.lastConnectedAt ?? 0) > 2500) {
2048
2067
  this.ble.start().catch((error) => this.logger.debug?.(`BLE 降级:${error.message}`));
2049
2068
  }
package/tools/pnpm-dsh.sh CHANGED
File without changes