dsh-plugin-weapp-gateway 0.8.50 → 0.8.51

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 (3) hide show
  1. package/README.md +7 -0
  2. package/lib/client.js +74 -12
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -6,6 +6,13 @@
6
6
 
7
7
  `dsh-plugin-weapp-gateway` · DeepSeek Harness 移动客户端连接插件
8
8
 
9
+ ### v0.8.51 · 配对面板细节打磨
10
+
11
+ - 小程序模块去掉「鲸尾公网 · 小程序 / 中继优先,局域网兜底」说明行(上方描述文案已含同样信息)。
12
+ - 「鲸尾公网服务 · 已注册」下的提示大卡片移除,精简为一行连接器状态(运行中 / 异常 / 恢复中,带颜色标识)。
13
+ - 「兼容 App(备用)」层新增上游样式的**连接方案摘要**:按所选入口显示「配对入口」与提示——局域网 / Cloudflare / Tailscale / 手动地址各自判定(公网必须 wss、内网可 ws,含回环地址与子网路由提示),与上游 `pairingConnectionPlan` 同一判定思路。
14
+ - 「兼容 App」右侧箭头改为与下拉一致的 SVG chevron(展开时旋转 180°,带过渡动画),替换原来的文字箭头。
15
+ - 全量测试通过。
9
16
  ### v0.8.50 · 小程序固定中继优先、局域网兜底;自动选择移到 App 层
10
17
 
11
18
  - 小程序模块不再提供「自动选择」,固定为**鲸尾公网 · 小程序**:二维码改为小程序专用 v2 载荷(`routes` 同时包含中继与局域网端点,不生成 `miniProgramRoute`),因此小程序**先连中继、连不上再回落局域网**(旧的 v3 中继专用码不会回落局域网)。
package/lib/client.js CHANGED
@@ -379,6 +379,65 @@ window.__ModuleLoader__.load({
379
379
  return /^fd7a:115c:a1e0:/i.test(host)
380
380
  }
381
381
 
382
+ // 与上游一致的连接方案摘要:按所选入口给出「配对入口 + 提示」。
383
+ function appConnectionPlan(route, status, rawUrl) {
384
+ const lanUrl = lanPairingUrl(status)
385
+ if (route === 'auto') {
386
+ return {
387
+ valid: !!lanUrl,
388
+ entry: '自动选择(公网优先,局域网兜底)',
389
+ note: lanUrl ? '手机会按实际连通情况在公网与局域网之间自动切换。' : '局域网入口不可用;自动选择需要一个手机可访问的局域网或公网入口。',
390
+ }
391
+ }
392
+ if (route === 'lan') {
393
+ return {
394
+ valid: !!lanUrl,
395
+ entry: '局域网直连',
396
+ note: lanUrl ? '同一局域网可直接访问;离开该网络就无法直连。' : '局域网入口不可用,请先开启基本设置中的局域网入口。',
397
+ }
398
+ }
399
+ if (route === 'cloudflare') {
400
+ const ready = !!(status?.cloudflare?.enabled && status.cloudflare.publicReady === true && status.cloudflare.publicUrl)
401
+ return {
402
+ valid: ready,
403
+ entry: 'Cloudflare Tunnel',
404
+ note: ready ? '公网入口已验证可达;手机在任何网络都可尝试。' : '公网入口尚未验证通过,请先完成下方配置和检测。',
405
+ }
406
+ }
407
+ if (route === 'tailscale') {
408
+ const valid = !!(status?.lan?.listening && isTailscaleInput(rawUrl))
409
+ return {
410
+ valid,
411
+ entry: 'Tailscale 私有网络',
412
+ note: valid ? '手机与主机需登录同一 tailnet,并允许访问网关端口。' : '请填写运行网关这台主机的 Tailscale IP(不是手机 IP),例如 100.x.x.x。',
413
+ }
414
+ }
415
+ // custom:按地址特征给提示(与上游 pairingConnectionPlan 同一判定思路)。
416
+ const raw = String(rawUrl || '').trim()
417
+ let endpoint
418
+ try { endpoint = new URL(raw) } catch {
419
+ return { valid: false, entry: '等待填写有效的配对地址', note: '请输入手机能够访问的 ws:// 或 wss:// 地址。' }
420
+ }
421
+ const scheme = endpoint.protocol === 'http:' ? 'ws:' : endpoint.protocol === 'https:' ? 'wss:' : endpoint.protocol
422
+ const host = endpoint.hostname.replace(/^\[|\]$/g, '').toLowerCase()
423
+ const parts = host.split('.').map(Number)
424
+ const ipv4 = parts.length === 4 && parts.every((n) => Number.isInteger(n) && n >= 0 && n <= 255)
425
+ const loopback = host === 'localhost' || host === '::1' || (ipv4 && parts[0] === 127)
426
+ const privateHost = loopback || host.endsWith('.local') ||
427
+ (ipv4 && (parts[0] === 10 || (parts[0] === 172 && parts[1] >= 16 && parts[1] <= 31) ||
428
+ (parts[0] === 192 && parts[1] === 168) || (parts[0] === 169 && parts[1] === 254))) ||
429
+ (host.includes(':') && /^(fc|fd|fe80:)/.test(host))
430
+ if (!['ws:', 'wss:'].includes(scheme) || endpoint.username || endpoint.password || endpoint.search || endpoint.hash ||
431
+ raw.length > 2048 || ['0.0.0.0', '::'].includes(host) || (scheme === 'ws:' && !privateHost)) {
432
+ return { valid: false, entry: '配对地址需要修改', note: '公网地址必须使用 wss://;地址不能包含账号、查询参数或片段。' }
433
+ }
434
+ const entry = loopback ? '本机回环地址' : privateHost ? '局域网或子网路由' : '加密 WebSocket 入口'
435
+ let note = '配对地址已填写,手机是否可达仍需实际连接确认。'
436
+ if (loopback) note = '回环地址仅适用于本机模拟器;真机请填写电脑的局域网、Tailscale 或公网地址。'
437
+ else if (privateHost) note = '同一局域网可直接访问;异地访问此地址需要手机已有可用的子网路由。'
438
+ return { valid: true, entry, note }
439
+ }
440
+
382
441
  // 手动输入的裸 IP 补成 ws://<ip>:<lanPort><wsPath>;已是 URL 的原样返回。
383
442
  function tailscaleEndpointOf(value, status) {
384
443
  const raw = String(value || '').trim()
@@ -1124,6 +1183,7 @@ window.__ModuleLoader__.load({
1124
1183
  (appRoute === 'auto' && !lanPairingUrl(status)) ||
1125
1184
  (appRoute === 'lan' && !lanPairingUrl(status)) ||
1126
1185
  (appRoute === 'tailscale' && !(status?.lan?.listening && isTailscaleInput(appUrl)))
1186
+ const appPlan = appConnectionPlan(appRoute, status, appUrl)
1127
1187
 
1128
1188
  const advice = connectionAdvice(status, publicSetup)
1129
1189
  const helpLine = (name, description) => React.createElement('div', { style: { marginTop: 7 } },
@@ -1351,23 +1411,18 @@ window.__ModuleLoader__.load({
1351
1411
  React.createElement('div', { style: { color: colors.muted, marginTop: 6 } }, '面板无法判断手机当前网络;请按手机所在位置选择,提示不会替你修改选择。')))
1352
1412
  : null),
1353
1413
  React.createElement('p', { style: styles.muted }, '小程序默认通过鲸尾公网中继连接,不需要公网域名;手机与网关在同一局域网时自动兜底直连。'),
1354
- React.createElement('div', { style: { display: 'flex', alignItems: 'center', flexWrap: 'wrap', gap: '8px 14px', maxWidth: '100%', marginBottom: 2 } },
1355
- React.createElement('strong', { style: { fontWeight: 600 } }, '鲸尾公网 · 小程序'),
1356
- React.createElement('span', { style: styles.muted }, '中继优先,局域网兜底'),
1357
- status?.relay ? null : React.createElement('span', { style: { ...styles.muted, color: colors.danger, fontWeight: 500 } }, '尚未注册中继')),
1414
+
1358
1415
  // 中继信息块属于小程序模块(自动选择 / 鲸尾公网中继)。
1359
1416
  (relayInfo || relayConnector?.running || relayConnector?.delegatedTo || relayConnector?.lastError)
1360
1417
  ? (relayInfo
1361
1418
  ? React.createElement('div', { style: { ...styles.muted, margin: '2px 0 0', fontWeight: 500 } },
1362
1419
  '鲸尾公网服务 · 已注册', ' · ',
1363
1420
  React.createElement('span', { style: { opacity: .8 } }, `设备 ID ${relayInfo.nodeId.slice(0, 8)}… · ${relayInfo.gatewayName}`),
1364
- React.createElement('div', { style: { marginTop: 6, padding: '9px 11px', borderRadius: 10, border: '1px solid color-mix(in srgb, var(--dsw-alias-state-warning-primary, #d98324) 26%, transparent)', background: 'color-mix(in srgb, var(--dsw-alias-state-warning-primary, #d98324) 9%, transparent)', fontWeight: 400 } },
1365
- React.createElement('div', null, '公网 WSS 就绪时,DSH App 和小程序都会获得公网与局域网候选地址;没有公网入口时,App 使用局域网,小程序优先使用已注册的鲸尾公网中继,否则使用局域网。也可单独选择「鲸尾公网 · 小程序」强制生成专用中继二维码。'),
1366
- React.createElement('div', { style: { marginTop: 5 } }, relayConnector?.running || relayConnector?.delegatedTo
1367
- ? '中继连接保持运行;切换配对方式不会断开已配对设备。'
1368
- : relayConnector?.lastError ? '中继连接器暂不可用,请检查网络或重新开启公网连接。'
1369
- : '中继身份已保存,连接器正在恢复…'),
1370
- React.createElement('div', { style: { marginTop: 5 } }, '设备配对与公网有效期独立;公网到期不影响局域网。已注册不代表手机端完整链路已通过验证。')))
1421
+ React.createElement('div', { style: { marginTop: 4, color: relayConnector?.lastError ? colors.danger : relayConnector?.running || relayConnector?.delegatedTo ? colors.success : 'var(--dsw-alias-link, #4176e6)' } },
1422
+ relayConnector?.running || relayConnector?.delegatedTo
1423
+ ? '中继连接保持运行'
1424
+ : relayConnector?.lastError ? `中继连接器异常:${relayConnector.lastError}`
1425
+ : '中继连接器正在恢复…'))
1371
1426
  : relayConnector && relayConnector.running
1372
1427
  ? React.createElement('div', { style: { ...styles.muted, margin: '2px 0 0', fontWeight: 500,
1373
1428
  color: 'var(--dsw-alias-link, #4176e6)' } }, '内置连接器已自动启动,正在连接中继并上报身份…')
@@ -1398,7 +1453,10 @@ window.__ModuleLoader__.load({
1398
1453
  React.createElement('strong', null, '兼容 App(备用)'),
1399
1454
  React.createElement('span', { style: { ...styles.muted, marginLeft: 8, fontWeight: 400 } },
1400
1455
  appLayerOpen ? '收起 App 兼容方式' : '需要连接 DSH App 时展开')),
1401
- React.createElement('span', { 'aria-hidden': true, style: styles.muted }, appLayerOpen ? '▾' : '▸')),
1456
+ React.createElement('svg', { width: 16, height: 16, viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor',
1457
+ strokeWidth: 1.8, strokeLinecap: 'round', strokeLinejoin: 'round', 'aria-hidden': true,
1458
+ style: { flexShrink: 0, color: colors.muted, transform: appLayerOpen ? 'rotate(180deg)' : 'none', transition: 'transform .18s ease' } },
1459
+ React.createElement('path', { d: 'M6 9l6 6 6-6' }))),
1402
1460
  appLayerOpen
1403
1461
  ? React.createElement(React.Fragment, null,
1404
1462
  React.createElement('p', { style: styles.muted }, '仅用于 DSH App(上游移动网关的直连方式),与上方鲸尾公网互不影响。'),
@@ -1413,6 +1471,10 @@ window.__ModuleLoader__.load({
1413
1471
  React.createElement('option', { value: 'tailscale', disabled: !(status && status.lan && status.lan.listening) },
1414
1472
  (status && status.lan && status.lan.listening) ? 'Tailscale 私有网络' : 'Tailscale 私有网络 · 请先开启局域网入口'),
1415
1473
  React.createElement('option', { value: 'custom' }, '公网或其他手动地址'))),
1474
+ // 与上游一致的连接方案摘要:配对入口 + 提示。
1475
+ React.createElement('div', { 'aria-label': '当前连接方案', style: { margin: '2px 0 10px', padding: '9px 11px', borderRadius: 10, border: `1px solid ${colors.border}`, background: colors.card, fontSize: 12, lineHeight: 1.7 } },
1476
+ React.createElement('div', null, React.createElement('strong', null, '配对入口'), ':', appPlan.entry),
1477
+ React.createElement('div', { style: { color: appPlan.valid ? colors.muted : colors.danger } }, appPlan.note)),
1416
1478
  React.createElement('label', { style: styles.label, htmlFor: 'mgw-pair-address' }, appRoute === 'tailscale'
1417
1479
  ? '主机 Tailscale 地址(运行网关的电脑,不是手机)'
1418
1480
  : '配对入口地址(手机需能访问)'),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-plugin-weapp-gateway",
3
- "version": "0.8.50",
3
+ "version": "0.8.51",
4
4
  "description": "鲸尾网关助手:DeepSeek Harness 移动客户端连接与会话同步,支持安全配对、远程访问、上下文、编队、额度和语音输入",
5
5
  "main": "lib/index.mjs",
6
6
  "files": [