dsh-mobile-plugin 0.5.127 → 0.5.129
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/lib/client.js +21 -2
- package/lib/impl.js +14 -13
- package/lib/mirror/pusher.cjs +24 -14
- package/lib/mobile/feedback.js +43 -0
- package/lib/panel/index.html +10 -10
- package/lib/relay/ingress-guard.cjs +25 -0
- package/lib/relay/lan-proxy.js +20 -6
- package/lib/relay/pairing-payload.cjs +4 -1
- package/lib/relay/status.js +2 -0
- package/lib/remote/runtime.cjs +6 -1
- package/lib/remote/store.cjs +64 -1
- package/lib/routes/control-plane.js +71 -30
- package/package.json +13 -14
package/lib/client.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// 2026-11-24:两种诊断页都把「完整重启 DSH」摆第一条;打开失败的那一屏补上版本/来源/激活时间/shellChanged。
|
|
3
3
|
// 2026-11-24:就地反馈附件补 plugin_source / activated_at / shell_changed,便于判断装完没重启。
|
|
4
4
|
// 2026-11-25:会话状态在 DSH 0.2.3 拆成独立服务,绿点同步改为同时兼容独立服务与普通属性两种宿主。
|
|
5
|
+
// 2026-11-27:保活的那扇弹窗收起时摘掉 role / aria-modal,免得官方快捷键一直以为有模态框挡着。
|
|
5
6
|
/**
|
|
6
7
|
* 移动端插件提供电脑插件页面目录;标准页面保留宿主上下文并支持直接导航。
|
|
7
8
|
* 聊天嵌入服务合并顶部栏显示声明,随提供方与消费方生命周期释放。
|
|
@@ -934,6 +935,20 @@ window.__ModuleLoader__.load({
|
|
|
934
935
|
}
|
|
935
936
|
try { if (prev.focus && typeof prev.focus.focus === 'function') prev.focus.focus(); } catch { /* ignore */ }
|
|
936
937
|
};
|
|
938
|
+
/**
|
|
939
|
+
* 挂上/摘掉「这是一扇模态框」的两样身份。官方快捷键系统只按这两个属性找弹窗
|
|
940
|
+
* (**不看它可不可见**),藏起来的那一窗要是留着它们,就会被当成一直挡在前面。
|
|
941
|
+
*/
|
|
942
|
+
const markModal = (on) => {
|
|
943
|
+
if (!overlay) return;
|
|
944
|
+
if (on) {
|
|
945
|
+
overlay.setAttribute('role', 'dialog');
|
|
946
|
+
overlay.setAttribute('aria-modal', 'true');
|
|
947
|
+
} else if (typeof overlay.removeAttribute === 'function') {
|
|
948
|
+
overlay.removeAttribute('role');
|
|
949
|
+
overlay.removeAttribute('aria-modal');
|
|
950
|
+
}
|
|
951
|
+
};
|
|
937
952
|
const hide = () => {
|
|
938
953
|
releaseChrome();
|
|
939
954
|
// 只有已确认就绪的页面保活;加载中或失败的页面,下次打开必须重新请求。
|
|
@@ -945,6 +960,8 @@ window.__ModuleLoader__.load({
|
|
|
945
960
|
// 让它自己把轮询停掉 —— 否则「关掉窗口就恢复正常」这条就不成立了。
|
|
946
961
|
if (overlay && overlay.__dshmKeep) {
|
|
947
962
|
if (typeof overlay.style === 'object') overlay.style.display = 'none';
|
|
963
|
+
// 收起来的窗要摘掉身份:它不是「在场的模态框」,只是留在 DOM 里等下次复用。
|
|
964
|
+
markModal(false);
|
|
948
965
|
tellFrame(overlay, false);
|
|
949
966
|
// 说明那一行**不清**:下次复用这一窗时还要往上写一句「已复制」之类。
|
|
950
967
|
} else if (overlay) {
|
|
@@ -974,6 +991,7 @@ window.__ModuleLoader__.load({
|
|
|
974
991
|
if (overlay && overlay.__dshmKeep && overlay.__dshmSrc === frameSrc
|
|
975
992
|
&& overlay.__dshmFrameState === 'ready') {
|
|
976
993
|
if (typeof overlay.style === 'object') overlay.style.display = '';
|
|
994
|
+
markModal(true);
|
|
977
995
|
if (spec.title) overlay.setAttribute('aria-label', spec.title);
|
|
978
996
|
tellFrame(overlay, true);
|
|
979
997
|
// 底下那句说明仍然按这一轮重置(`noteEl` 是上一轮那个节点,还挂着)。
|
|
@@ -990,8 +1008,7 @@ window.__ModuleLoader__.load({
|
|
|
990
1008
|
if (!overlay) {
|
|
991
1009
|
overlay = make('div', 'dshm_overlay');
|
|
992
1010
|
overlay.setAttribute(DIAG_MARK, '');
|
|
993
|
-
|
|
994
|
-
overlay.setAttribute('aria-modal', 'true');
|
|
1011
|
+
markModal(true);
|
|
995
1012
|
// 点遮罩收起;卡片内部的点击不冒到遮罩上(免得点按钮被当成「点外面」)。
|
|
996
1013
|
overlay.addEventListener('click', (event) => {
|
|
997
1014
|
if (event && event.target === overlay) hide();
|
|
@@ -1007,6 +1024,8 @@ window.__ModuleLoader__.load({
|
|
|
1007
1024
|
// 复用一个**已收起**(keep 且被 `hide` 设成 display:none)的窗时,必须显式把 display 复位。
|
|
1008
1025
|
// 否则从控制台窗切到诊断窗会落进同一个 overlay、整窗仍是隐藏的 —— 点了没反应。
|
|
1009
1026
|
if (typeof overlay.style === 'object') overlay.style.display = '';
|
|
1027
|
+
// 身份在收起时摘掉了(见 `hide`),亮出来之前挂回去。
|
|
1028
|
+
markModal(true);
|
|
1010
1029
|
if (spec.title) overlay.setAttribute('aria-label', spec.title);
|
|
1011
1030
|
// 「这一窗收起时不销毁」的记号(见 `hide`)。只有带整页 iframe 的那一窗需要它:
|
|
1012
1031
|
// 那一页重建一次要重新解析一整份产物,而诊断窗那几行读数是现拼的,重建几乎不要钱。
|
package/lib/impl.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// 2026-11-27:线路级问题码搬进 relay/ingress-guard.cjs,装配层只交现状、不再写判断。
|
|
1
2
|
// 2026-11-26:零讯旧隧道落点端口失效时接线层清掉地址,通知 Cloudflare 兜底重新判定顶上。
|
|
2
3
|
// 2026-11-25:三条线路的本地端口接上回环入口判据;自检结论记入 ingress-guard,状态带出绕开与兜底原因。
|
|
3
4
|
// 热重载跨代:隧道助手/点对点的父地址取值器改为挂载时缓存,回滚或半装载后不再现读失效 ctx.webServer。
|
|
@@ -529,21 +530,21 @@ function apply(ctx) {
|
|
|
529
530
|
// 总控上报当前状态(地址、令牌、连没连上):手机据此知道该不该、能不能去总控查。
|
|
530
531
|
getControl: () => control.snapshot(),
|
|
531
532
|
getLanPortLock: portLock,
|
|
532
|
-
// 面板 /
|
|
533
|
+
// 面板 / 手机读到的入口全景:实绑入口、是否被绕开、冲突类型、兜底原因码与线路级问题。
|
|
534
|
+
// routeIssue 与 fallbackReason 分开:后者说「兜底也顶不上、要用户接着处理」,前者只说
|
|
535
|
+
// 「这条线路自己落点不对」——兜底已经顶上时也要让用户看见旧隧道该去哪改。判据在 ingress-guard。
|
|
533
536
|
getIngressView: () => {
|
|
534
537
|
const signals = ingressSignals()
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
}),
|
|
546
|
-
}
|
|
538
|
+
const ingressPort = ingressGuard.ingressPortOf(state)
|
|
539
|
+
const { fallbackReason, routeIssue } = ingressGuard.routeIssueOf({
|
|
540
|
+
signals, ingressPort, hasUsableRoute: hasUsableRoute(),
|
|
541
|
+
cloudflareAvailable: cloudflare.status().available === true,
|
|
542
|
+
portLocked: Boolean(portLock()), externalTarget: portLock() === 'forwarding',
|
|
543
|
+
provider: state.zeroNewsUrl ? 'zeronews' : '', hasLegacyTunnel: Boolean(state.zeroNewsUrl),
|
|
544
|
+
legacyTunnelPort: tunnelPortFor('zeronews'),
|
|
545
|
+
})
|
|
546
|
+
return { ingressPort, bypassing: signals.needsBypass, conflict: signals.conflict,
|
|
547
|
+
fallbackReason, routeIssue }
|
|
547
548
|
},
|
|
548
549
|
})
|
|
549
550
|
function applyServices() {
|
package/lib/mirror/pusher.cjs
CHANGED
|
@@ -110,6 +110,8 @@ const BG_LIST_REBUILD_FALLBACK_MS = 5000;
|
|
|
110
110
|
const MIRROR_FULL_PUSH_MIN_INTERVAL_MS = 30_000;
|
|
111
111
|
const MAX_CONCURRENT_SESSION_BUILDS = 2;
|
|
112
112
|
const MAX_CONSECUTIVE_EVENT_BUILDS = 3;
|
|
113
|
+
/** 隧道没连时短路记账的那句话。只有它可以被「隧道已恢复」清掉,别的错误是真故障。 */
|
|
114
|
+
const TUNNEL_OFFLINE_ERROR = '隧道未连接,镜像未推送';
|
|
113
115
|
|
|
114
116
|
function createMirrorPusher(deps) {
|
|
115
117
|
const { ctx, tunnelConnected, getSidecar, listSignal = sharedListSignal, sessionSignal = sharedSessionSignal } = deps;
|
|
@@ -582,7 +584,7 @@ function createMirrorPusher(deps) {
|
|
|
582
584
|
// 每一次推上去的清单都顺手记一下规模(含短路那两条路径:手机侧栏看的就是这份清单)。
|
|
583
585
|
noteMirrorList(payload && payload.sessions);
|
|
584
586
|
if (!tunnelConnected()) {
|
|
585
|
-
recordMirrorPush(false,
|
|
587
|
+
recordMirrorPush(false, TUNNEL_OFFLINE_ERROR);
|
|
586
588
|
// 没推成镜像,但「正文长到哪儿了」这件事仍然要说给手机听(见 announceSessionActivity)。
|
|
587
589
|
announceSessionActivity(payload.messages);
|
|
588
590
|
return false
|
|
@@ -1254,25 +1256,33 @@ function createMirrorPusher(deps) {
|
|
|
1254
1256
|
};
|
|
1255
1257
|
};
|
|
1256
1258
|
|
|
1259
|
+
/**
|
|
1260
|
+
* 把「上次推送的记账」投影成面板该显示的当前状态。
|
|
1261
|
+
*
|
|
1262
|
+
* 「隧道未连接」是断线那一刻记下的结果,它不会自动撤销:隧道恢复后 onTunnelUp 的补推
|
|
1263
|
+
* 可能被 30 秒全量间隔挡掉,面板于是挂着一句已经不成立的故障,还让人一键反馈假问题。
|
|
1264
|
+
* 只清这一条、只在隧道确实已连时清——别的错误是真故障,必须原样保留。
|
|
1265
|
+
* 内部记账(pushedAt / ok / error)不动:它仍是「上次尝试」的忠实记录。
|
|
1266
|
+
*/
|
|
1267
|
+
const mirrorPushView = () => {
|
|
1268
|
+
const stale = tunnelConnected() && mirrorPushError === TUNNEL_OFFLINE_ERROR
|
|
1269
|
+
return {
|
|
1270
|
+
pushedAt: mirrorPushAt, ok: stale ? null : mirrorPushOk, error: stale ? null : mirrorPushError,
|
|
1271
|
+
skippedBodies: mirrorBodySkipCount, skipReason: mirrorBodySkipReason,
|
|
1272
|
+
listSessions: mirrorListSessions,
|
|
1273
|
+
listActiveSessions: mirrorListActiveSessions,
|
|
1274
|
+
listSubagents: mirrorListSubagents,
|
|
1275
|
+
listAt: mirrorListAt,
|
|
1276
|
+
}
|
|
1277
|
+
};
|
|
1278
|
+
|
|
1257
1279
|
return {
|
|
1258
1280
|
start,
|
|
1259
1281
|
pushMirror,
|
|
1260
1282
|
pushSessionImmediately,
|
|
1261
1283
|
/** 会话名(取不到就空串):装配层拿它当系统通知的标题。 */
|
|
1262
1284
|
sessionTitleOf,
|
|
1263
|
-
getMirrorPush:
|
|
1264
|
-
pushedAt: mirrorPushAt, ok: mirrorPushOk, error: mirrorPushError,
|
|
1265
|
-
// 正文缺失而清单照推的次数与最近原因:与 ok/pushedAt 分开,避免再把
|
|
1266
|
-
// 「某会话正文读不到」误读成「镜像死了」(见 recordMirrorPushSkipped)。
|
|
1267
|
-
skippedBodies: mirrorBodySkipCount, skipReason: mirrorBodySkipReason,
|
|
1268
|
-
// 清单规模(自检台账读它):会话总数 / 其中活跃 / 其中子会话 / 这份读数的时间。
|
|
1269
|
-
// 这是「手机侧栏那份清单有多大」,**不是**「宿主内存里挂着多少会话、正文占多少」——
|
|
1270
|
-
// 后者插件看不到(见 lib/mobile/self-check.cjs 的口径段)。
|
|
1271
|
-
listSessions: mirrorListSessions,
|
|
1272
|
-
listActiveSessions: mirrorListActiveSessions,
|
|
1273
|
-
listSubagents: mirrorListSubagents,
|
|
1274
|
-
listAt: mirrorListAt,
|
|
1275
|
-
}),
|
|
1285
|
+
getMirrorPush: mirrorPushView,
|
|
1276
1286
|
/** 失败会话的定向重试账(诊断 + 守卫用):失败几次、下次什么时候补推。 */
|
|
1277
1287
|
getPushFailures: () => [...sessionPushFailures.entries()].map(([sessionId, entry]) => ({
|
|
1278
1288
|
sessionId, attempts: entry.attempts, dueAt: entry.dueAt, error: entry.lastError,
|
package/lib/mobile/feedback.js
CHANGED
|
@@ -408,6 +408,48 @@ function renderSummary(value) {
|
|
|
408
408
|
}
|
|
409
409
|
}
|
|
410
410
|
|
|
411
|
+
/**
|
|
412
|
+
* 面板「发送问题」的入口:表单在这里(Node 侧)拼、在这里发,面板只走同源本地接口。
|
|
413
|
+
*
|
|
414
|
+
* 面板在浏览器里直连平台时,来源是 `http://127.0.0.1:<端口>`,平台只对自己的站点回
|
|
415
|
+
* `access-control-allow-origin`,浏览器读不到响应就抛 `Failed to fetch` —— 请求其实已经
|
|
416
|
+
* 到平台了,用户却看到发送失败、还会重发。字段必须与面板原先逐字一致(尤其不带
|
|
417
|
+
* submit_kind,保持「插件自报」的归类),所以这里复用同一套 buildFeedbackForm。
|
|
418
|
+
*/
|
|
419
|
+
async function submitPanelFeedback({ summary, detail, context, version, deviceId, submissionId }) {
|
|
420
|
+
const form = buildFeedbackForm(null, String(summary || ''), '', {
|
|
421
|
+
localDeviceId: String(deviceId || ''),
|
|
422
|
+
submissionId,
|
|
423
|
+
componentVersion: version,
|
|
424
|
+
diagnosis: String(detail || ''),
|
|
425
|
+
context: context && typeof context === 'object' ? context : {},
|
|
426
|
+
});
|
|
427
|
+
const data = await postMultipart(form);
|
|
428
|
+
const key = data && typeof data.thread_key === 'string' ? data.thread_key : '';
|
|
429
|
+
if (!key) throw new Error('反馈接口没有返回线程编号');
|
|
430
|
+
return { threadKey: key, submissionId };
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
/**
|
|
434
|
+
* 面板「发送问题」的本机转发路由:只在本机来源上收面板草稿,Node 侧发出去。
|
|
435
|
+
*/
|
|
436
|
+
async function handlePanelFeedback({ req, res, readJson, sendJson }) {
|
|
437
|
+
try {
|
|
438
|
+
const body = await readJson(req);
|
|
439
|
+
const submitted = await submitPanelFeedback({
|
|
440
|
+
summary: body.summary,
|
|
441
|
+
detail: body.detail,
|
|
442
|
+
context: body.context,
|
|
443
|
+
version: body.version,
|
|
444
|
+
deviceId: body.deviceId,
|
|
445
|
+
submissionId: body.submissionId,
|
|
446
|
+
});
|
|
447
|
+
return sendJson(res, 200, submitted);
|
|
448
|
+
} catch (error) {
|
|
449
|
+
return sendJson(res, error.status || 502, { ok: false, error: { code: 'feedback_failed', message: String(error?.message || error) } });
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
|
|
411
453
|
/** 装配层入口:挂 `dsh_feedback` 工具;宿主没有 tools 服务时只少这个工具。 */
|
|
412
454
|
function installFeedback(ctx, deps) {
|
|
413
455
|
return registerFeedbackTool(ctx, deps);
|
|
@@ -425,6 +467,7 @@ module.exports = {
|
|
|
425
467
|
SOURCE,
|
|
426
468
|
buildFeedbackForm,
|
|
427
469
|
diagnosisTextOf,
|
|
470
|
+
handlePanelFeedback,
|
|
428
471
|
feedbackChannels,
|
|
429
472
|
installFeedback,
|
|
430
473
|
localDeviceId,
|