jbc-dssi 1.1.142 → 1.1.144

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.
Files changed (36) hide show
  1. package/lib/app-release-watch.js +5 -36
  2. package/lib/client.js +3 -66
  3. package/lib/device-auth.js +37 -368
  4. package/lib/e2e.js +8 -153
  5. package/lib/groups-event-buffer.js +5 -44
  6. package/lib/plugin-features.js +5 -13
  7. package/lib/proc-commands.js +14 -103
  8. package/lib/protocol.js +56 -349
  9. package/lib/qr.js +13 -114
  10. package/lib/relay-link.js +13 -197
  11. package/lib/restart-autocheck.js +9 -139
  12. package/lib/schedules.js +6 -55
  13. package/lib/slim.js +13 -177
  14. package/lib/ui-config-push.js +4 -23
  15. package/lib/ui-tuning.js +4 -51
  16. package/lib/workspace-bytes.js +2 -29
  17. package/package.json +1 -1
  18. package/vendor/bots/bridge/index.js +1 -7
  19. package/vendor/bots/bridge/meta.js +3 -13
  20. package/vendor/bots/bridge/view.js +5 -37
  21. package/vendor/dssAgent/bridge/distill.js +1 -15
  22. package/vendor/dssAgent/bridge/index.js +89 -772
  23. package/vendor/groups/bridge/engine/delivery.js +29 -178
  24. package/vendor/groups/bridge/engine/draft.js +9 -60
  25. package/vendor/groups/bridge/engine/rotate.js +8 -95
  26. package/vendor/groups/bridge/engine/session.js +2 -16
  27. package/vendor/groups/bridge/engine/settle.js +8 -56
  28. package/vendor/groups/bridge/engine/timing.js +4 -32
  29. package/vendor/groups/bridge/engine/turncard.js +3 -53
  30. package/vendor/groups/bridge/engine/turns.js +14 -69
  31. package/vendor/groups/bridge/engine.js +25 -134
  32. package/vendor/groups/bridge/index.js +22 -114
  33. package/vendor/groups/bridge/mentions.js +1 -16
  34. package/vendor/groups/bridge/pending.js +6 -28
  35. package/vendor/groups/bridge/prompt.js +7 -71
  36. package/vendor/groups/bridge/state.js +7 -32
@@ -1,22 +1,7 @@
1
- /**
2
- * 发版监听(2026-11-15 老谢定:"发版后主动推一次,别等轮询")。
3
- *
4
- * 为什么放电脑侧:发版脚本就在这台电脑上跑(`release-fast.sh` 最后写 `version.json`),
5
- * 文件一变,插件几秒内就能通过**已有桥接通道**把新版本推给正在连着的手机;
6
- * 不依赖轮询、不依赖改服务端 / relay。
7
- *
8
- * 设计要点:
9
- * · 只认 **versionCode 增大**(回滚 / 同版本重写不推,避免手机被回滚提示);
10
- * · 监听的是**目录**不是单个文件 —— 发版是"写临时文件再 rename",盯文件会在 rename 后丢 watch;
11
- * · fs.watch 不可用(部分平台)时退回 5 秒轮询,功能不受影响;
12
- * · 去抖 1 秒:发版一次可能连着写好几次,只推最后一版;
13
- * · 手机连上/重连时由调用方用 [createAppReleaseWatch.current] 补一条快照 ——
14
- * 覆盖"发版时手机没在线、之后才连上"的场景(连上立刻弹,不用等下一次发版)。
15
- */
1
+
16
2
  import { promises as fs, watch as fsWatchImpl } from 'node:fs';
17
3
  import { join } from 'node:path';
18
4
 
19
- /** 解析 version.json 文本;坏 JSON / 缺版本号返回 null(绝不因坏文件影响推送主流程)。 */
20
5
  export function parseReleaseJson(text) {
21
6
  let json;
22
7
  try {
@@ -38,21 +23,10 @@ export function parseReleaseJson(text) {
38
23
  };
39
24
  }
40
25
 
41
- /** 该不该推:新的 versionCode 必须比上次推过的更大(回滚/重写不推)。 */
42
26
  export function shouldAnnounce(prevVersionCode, nextVersionCode) {
43
27
  return Number.isFinite(nextVersionCode) && nextVersionCode > (Number(prevVersionCode) || 0);
44
28
  }
45
29
 
46
- /**
47
- * 建一个发版监听器。
48
- *
49
- * @param {object} opts
50
- * @param {string} opts.repoRoot 产品仓库根(version.json 所在目录)
51
- * @param {Function} opts.onRelease 回调:参数为解析后的版本信息
52
- * @param {Function} [opts.log]
53
- * @param {number} [opts.debounceMs=1000] 去抖时长
54
- * @param {number} [opts.pollMs=5000] fs.watch 不可用时的兜底轮询间隔
55
- */
56
30
  export function createAppReleaseWatch({ repoRoot, onRelease, log, debounceMs = 1000, pollMs = 5000 }) {
57
31
  const dir = String(repoRoot ?? '').trim();
58
32
  const file = join(dir, 'version.json');
@@ -69,7 +43,7 @@ export function createAppReleaseWatch({ repoRoot, onRelease, log, debounceMs = 1
69
43
  try {
70
44
  text = await fs.readFile(file, 'utf8');
71
45
  } catch {
72
- return; // 文件不存在(没发过版)就静默
46
+ return;
73
47
  }
74
48
  const info = parseReleaseJson(text);
75
49
  if (info === null) return;
@@ -82,7 +56,7 @@ export function createAppReleaseWatch({ repoRoot, onRelease, log, debounceMs = 1
82
56
  log?.(`[release] 推送回调失败:${err?.message ?? err}`);
83
57
  }
84
58
  } else if (info.versionCode > lastAnnounced) {
85
- // 启动时的首读只记水位,不推(手机连上时会单独补快照)
59
+
86
60
  lastAnnounced = info.versionCode;
87
61
  }
88
62
  }
@@ -98,7 +72,7 @@ export function createAppReleaseWatch({ repoRoot, onRelease, log, debounceMs = 1
98
72
  }
99
73
 
100
74
  function start() {
101
- // 先读一次定水位(不推:老版本信息不该在插件刚启动时炸弹窗)
75
+
102
76
  void readOnce({ announce: false });
103
77
  try {
104
78
  watcher = fsWatch(dir, () => schedule(true));
@@ -117,14 +91,13 @@ export function createAppReleaseWatch({ repoRoot, onRelease, log, debounceMs = 1
117
91
  try {
118
92
  watcher?.close?.();
119
93
  } catch {
120
- /* 忽略 */
94
+
121
95
  }
122
96
  watcher = null;
123
97
  if (poller !== null) clearInterval(poller);
124
98
  poller = null;
125
99
  }
126
100
 
127
- /** 当前已知的最新版本(手机连上时补一条)。可能为 null(还没读到过版本文件)。 */
128
101
  function getCurrent() {
129
102
  return current;
130
103
  }
@@ -132,10 +105,6 @@ export function createAppReleaseWatch({ repoRoot, onRelease, log, debounceMs = 1
132
105
  return { start, stop, current: getCurrent };
133
106
  }
134
107
 
135
- /*
136
- * 目录 watch 包一层:只关心 version.json(部分平台 filename 可能为 null,此时照样触发去抖)。
137
- * watch 本身抛错由 start() 捕获后退回轮询 —— 行为可预期。
138
- */
139
108
  function fsWatch(dir, listener) {
140
109
  return fsWatchImpl(dir, (event, filename) => {
141
110
  if (filename === null || filename === undefined || String(filename) === 'version.json') {
package/lib/client.js CHANGED
@@ -1,30 +1,4 @@
1
- /**
2
- * jbc-dssi 的**浏览器半边**(DSH Web 客户端插件)。
3
- *
4
- * 【它只做两件事】
5
- * 1. 在左侧栏「全局面板」区加一行:📱 手机配对;
6
- * 2. 点开之后中栏整块显示配对面板:二维码 + 手工码 + 当前设备。
7
- *
8
- * 【为什么是这种"手写 bundle"而不是 TS + 构建】
9
- * DSH 的客户端插件是一段由外壳 `/plugins` 提供的浏览器 bundle,
10
- * 格式固定:`window.__ModuleLoader__.load({ id, factory })`,
11
- * factory 拿到一个 `require`,从外壳的共享模块表里取 react 之类的基座模块。
12
- * 见本机 `dshmarket` 的 client 产物(同一套格式)。
13
- * 我们这个面板只用 react + ctx.slots,不需要任何第三方 UI 库 ——
14
- * 手写一份可读的 bundle,比为一个小组件引入整套构建链更符合本插件
15
- * "零依赖、可审查"的调性。
16
- *
17
- * 【数据从哪来】
18
- * 面板不碰文件、不推导配对信息,只 GET 宿主开的一条只读接口
19
- * `/jbc/pairing`(见宿主侧 pairing/web-api.js)。宿主是唯一真相,
20
- * 这样"显示出来的码"和"实际连上的码"不可能不一致。
21
- *
22
- * 【样式约定】
23
- * - 跟随 DSH 主题 token(深色/浅色都自适应);
24
- * - 但二维码卡片**固定白底黑码**:深色主题下的白码黑底部分扫描器认不出,
25
- * 这里以"能扫"优先(与 pairing.html 同一条理由)。
26
- * - 类名统一 `jbcP` 前缀,避免和宿主/其它插件的样式撞车。
27
- */
1
+
28
2
  window.__ModuleLoader__.load({
29
3
  id: 'jbc-dssi',
30
4
  factory: (require) => {
@@ -40,8 +14,6 @@ window.__ModuleLoader__.load({
40
14
  const API_PATH = '/jbc/pairing';
41
15
  const PANEL_LABEL = '手机配对';
42
16
 
43
- // ---------------------------------------------------------------- 样式
44
-
45
17
  const CSS = `
46
18
  .jbcP-page { box-sizing: border-box; width: 100%; height: 100%; min-height: 0; overflow: auto;
47
19
  color: var(--dsw-alias-label-primary); background: var(--dsw-alias-bg-base);
@@ -108,14 +80,6 @@ window.__ModuleLoader__.load({
108
80
  color: var(--dsw-alias-label-tertiary); font-size: 12px; line-height: 20px; }
109
81
  `;
110
82
 
111
- // ---------------------------------------------------------------- 图标
112
-
113
- /**
114
- * 左侧栏那行的手机图标。
115
- *
116
- * 侧栏会在展开/收起两种尺寸下渲染同一个占位者(wide ? 16 : 18),
117
- * 颜色由行本身控制(currentColor),选中态也一样 —— 所以这里不写死颜色。
118
- */
119
83
  function PairingGlyph(props) {
120
84
  const size = typeof props?.size === 'number' ? props.size : 16;
121
85
  return h(
@@ -147,9 +111,6 @@ window.__ModuleLoader__.load({
147
111
  );
148
112
  }
149
113
 
150
- // ---------------------------------------------------------------- 工具
151
-
152
- /** 读宿主只读接口。`ok:false` 是正常业务态(中继没开/还在准备),不抛。 */
153
114
  async function fetchPairing() {
154
115
  const response = await fetch(API_PATH, {
155
116
  method: 'GET',
@@ -161,7 +122,7 @@ window.__ModuleLoader__.load({
161
122
  try {
162
123
  body = await response.json();
163
124
  } catch {
164
- /* 非 JSON(例如 404 的 SPA HTML)按失败处理 */
125
+
165
126
  }
166
127
  if (!response.ok || body === null) {
167
128
  throw new Error(body && body.message ? body.message : `HTTP ${response.status}`);
@@ -169,7 +130,6 @@ window.__ModuleLoader__.load({
169
130
  return body;
170
131
  }
171
132
 
172
- /** 复制到剪贴板:优先 clipboard API,不可用时退回老办法(file:// / 非安全上下文)。 */
173
133
  async function copyToClipboard(text) {
174
134
  try {
175
135
  if (navigator.clipboard && window.isSecureContext) {
@@ -177,7 +137,7 @@ window.__ModuleLoader__.load({
177
137
  return true;
178
138
  }
179
139
  } catch {
180
- /* 落到下面的人工兜底 */
140
+
181
141
  }
182
142
  try {
183
143
  const area = document.createElement('textarea');
@@ -203,9 +163,6 @@ window.__ModuleLoader__.load({
203
163
  return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}`;
204
164
  }
205
165
 
206
- // ---------------------------------------------------------------- 小组件
207
-
208
- /** 一键复制按钮:复制成功后两秒内显示「已复制」。 */
209
166
  function CopyButton({ text, label = '复制' }) {
210
167
  const [copied, setCopied] = useState(false);
211
168
  useEffect(() => {
@@ -228,7 +185,6 @@ window.__ModuleLoader__.load({
228
185
  );
229
186
  }
230
187
 
231
- /** 一段等宽代码 + 复制按钮(手工配对码、换手机命令共用)。 */
232
188
  function CodeBox({ code, copyLabel }) {
233
189
  return h(
234
190
  'div',
@@ -238,15 +194,6 @@ window.__ModuleLoader__.load({
238
194
  );
239
195
  }
240
196
 
241
- // ---------------------------------------------------------------- 面板
242
-
243
- /**
244
- * 中栏面板。
245
- *
246
- * 三态:loading / error / ready(ready 里又分 ok 与 not-ready)。
247
- * 每次打开面板都重新取一遍 —— 换过手机、刚重启插件之后,
248
- * 这一下就能看到最新状态,不需要用户去刷新整个页面。
249
- */
250
197
  function PairingPanel() {
251
198
  const [state, setState] = useState({ phase: 'loading' });
252
199
  const [nonce, setNonce] = useState(0);
@@ -456,9 +403,6 @@ window.__ModuleLoader__.load({
456
403
  );
457
404
  }
458
405
 
459
- // ---------------------------------------------------------------- 插件
460
-
461
- /** 把面板样式挂到文档上一次;插件卸载时随之移除。 */
462
406
  function mountStyles(ctx) {
463
407
  ctx.effect(() => {
464
408
  const style = document.createElement('style');
@@ -472,12 +416,6 @@ window.__ModuleLoader__.load({
472
416
  function apply(ctx) {
473
417
  mountStyles(ctx);
474
418
 
475
- /*
476
- * 左侧栏「全局面板」一行。
477
- * id 同时是布局里 `main` keyed slot 的键 —— 点这一行就选同名主面板,
478
- * 所以两处必须用同一个 PANEL_ID(这是框架的契约,不是我们的约定)。
479
- * order=20:排在随附的「插件」(0)、「定时任务」(10) 之后,追加到末尾。
480
- */
481
419
  ctx.slots.inject('sidebar.panellist', () =>
482
420
  ctx.slots.register(
483
421
  {
@@ -490,7 +428,6 @@ window.__ModuleLoader__.load({
490
428
  ),
491
429
  );
492
430
 
493
- /** 中栏主面板:点左侧栏那一行时整块切换到这里。 */
494
431
  ctx.slots.inject('main', () =>
495
432
  ctx.slots.register(
496
433
  {