dsh-mobile-plugin 0.5.107 → 0.5.109
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 +20 -4
- package/lib/index.js +9 -1
- package/lib/relay/pairing-payload.cjs +25 -13
- package/lib/shell/updater.js +52 -0
- package/package.json +13 -15
package/lib/client.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// 用途:桌面端入口与诊断反馈;打开配置页失败附带稳定原因码,不外发原始错误和访问凭据。
|
|
2
|
+
// 2026-11-24:两种诊断页都把「完整重启 DSH」摆第一条;打开失败的那一屏补上版本/来源/激活时间/shellChanged。
|
|
2
3
|
/**
|
|
3
4
|
* 移动端插件提供电脑插件页面目录;标准页面保留宿主上下文并支持直接导航。
|
|
4
5
|
* 聊天嵌入服务合并顶部栏显示声明,随提供方与消费方生命周期释放。
|
|
@@ -1966,7 +1967,8 @@ window.__ModuleLoader__.load({
|
|
|
1966
1967
|
* 把这一轮的现场摆成一屏**能自己动手**的自查。
|
|
1967
1968
|
*
|
|
1968
1969
|
* `kind` 两种:`'load'`(连状态都读不到,所以没有地址可去)、`'open'`(地址读到了但
|
|
1969
|
-
*
|
|
1970
|
+
* 页面没开成)。两者都把「装完没重启」摆第一条——市场装完没重启时实现换了、外壳还是
|
|
1971
|
+
* 旧的,两种失败都撞得上;open 再补一条重试。
|
|
1970
1972
|
*
|
|
1971
1973
|
* 这一屏的三个层次,顺序就是用户该想的顺序:
|
|
1972
1974
|
* 1. 谁说了什么(宿主返回的原文 + 外壳自检那份快照,含版本/来源/后台重试/要不要重启);
|
|
@@ -2048,8 +2050,12 @@ window.__ModuleLoader__.load({
|
|
|
2048
2050
|
};
|
|
2049
2051
|
|
|
2050
2052
|
const stepsOf = () => {
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
+
// 2026-11-24:「打开失败」也把重启放第一位——插件市场装完没重启时,实现换了、
|
|
2054
|
+
// 外壳还是旧的,表现就是状态读得到但面板打不开(HTTP 400)。原来这一档只让重试 /
|
|
2055
|
+
// 查反代,把最常见的「装完没重启」漏掉了。
|
|
2056
|
+
const steps = [t('diagStepRestart')];
|
|
2057
|
+
if (kind === 'open') steps.push(t('diagStepRetryOpen'));
|
|
2058
|
+
else steps.push(t('diagStepReinstall'));
|
|
2053
2059
|
if (half && half.retrying) steps.push(t('diagStepRetrying'));
|
|
2054
2060
|
steps.push(t('diagStepDuplicate'), t('diagStepProxy'));
|
|
2055
2061
|
return steps;
|
|
@@ -2421,7 +2427,17 @@ window.__ModuleLoader__.load({
|
|
|
2421
2427
|
}
|
|
2422
2428
|
rows.push({ key: 'panel_url', label: t('diagFactPanelUrl'), value: snapshot.url || '—' });
|
|
2423
2429
|
rows.push({ key: 'panel_scope', label: t('diagFactScope'), value: snapshot.scope });
|
|
2424
|
-
if (half && half.
|
|
2430
|
+
if (half && half.unavailable === true) {
|
|
2431
|
+
rows.push({ key: 'self_check', label: t('diagFactSelfcheck'), value: t('diagFactUnavailable') });
|
|
2432
|
+
} else if (half) {
|
|
2433
|
+
// 2026-11-24:补上版本 / 来源 / 激活时间 / shellChanged。市场装完没重启时,
|
|
2434
|
+
// 这一屏是用户唯一看得到的地方——没有这几格就看不出「实现换了、外壳没换」。
|
|
2435
|
+
if (half.version) rows.push({ key: 'plugin_version', label: t('diagFactPlugin'), value: String(half.version) });
|
|
2436
|
+
if (half.source) rows.push({ key: 'plugin_source', label: t('diagFactSource'), value: half.source });
|
|
2437
|
+
if (half.activatedAt) rows.push({ key: 'activated_at', label: t('diagFactActivated'), value: half.activatedAt });
|
|
2438
|
+
if (half.shellChanged) rows.push({ key: 'shell_changed', label: t('diagFactShell'), value: 'true' });
|
|
2439
|
+
if (half.lastError) rows.push({ key: 'host_last_error', label: t('diagFactReason'), value: half.lastError });
|
|
2440
|
+
}
|
|
2425
2441
|
return rows;
|
|
2426
2442
|
};
|
|
2427
2443
|
async function sendFeedback() {
|
package/lib/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 插件入口(**稳定外壳**)。
|
|
3
3
|
*
|
|
4
|
+
* 2026-11-24:查新版改为与装包同源(优先问 npm,市场兜底),修 106 卡住不放。
|
|
5
|
+
*
|
|
4
6
|
* 这个文件是整条自更新链路的锚点,所以它必须尽量不变。真正的实现在**代**里:随包发布的
|
|
5
7
|
* 那份是 `lib/impl.js`,市场装新版之后 profile 里那份是新一代(新 realpath)。
|
|
6
8
|
* 外壳负责挑一代、装上去,并在更新到位后换过去,见 `lib/shell/runtime.js`。
|
|
@@ -78,7 +80,13 @@ export function apply(ctx) {
|
|
|
78
80
|
updateState.checking = true
|
|
79
81
|
try {
|
|
80
82
|
await deviceOta.reconcileOfficial()
|
|
81
|
-
|
|
83
|
+
// 与真正装包同源:先问盘上那一代的 npm 查询模块;只有那一代没有查询模块(老版本 /
|
|
84
|
+
// 无头源码部署)才退回市场。市场没同步到新版就让自动更新停摆、而 App 走 npm 看得到
|
|
85
|
+
// 新版 —— 这正是 0.5.106 卡住不放的原因,两处判据必须走同一个源。
|
|
86
|
+
const fromNpm = await updater.checkFromGeneration({
|
|
87
|
+
packageManager: hostService('profileContext')?.packageManager ?? null,
|
|
88
|
+
})
|
|
89
|
+
updateState.result = fromNpm ?? await updater.checkUpdate(base())
|
|
82
90
|
updateState.lastError = null
|
|
83
91
|
} catch (error) {
|
|
84
92
|
updateState.result = null
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
// 2026-11-24
|
|
1
|
+
// 2026-11-24:服务商的 http(s) 地址同时进 lanUrls,让不认 routes 的老包也能扫码走服务商直连;
|
|
2
|
+
// 内置公用中转改成「码里真没有自己的线路时才塞」的兜底,不再无条件写进每张码。
|
|
2
3
|
// 2026-11-24:出码前的「有没有可用地址」收成 `pairingHasAddress`,服务商线路也算数——两个出码入口同用一处判据。
|
|
3
4
|
// 2026-11-23:第三方服务商线路随二维码一起下发(通用 `routes` 一栏):以后加服务商不用再改二维码。
|
|
4
5
|
// 配对二维码的 IPv6 候选为手填那条预留一席,避免被条数上限切掉。
|
|
@@ -18,7 +19,7 @@
|
|
|
18
19
|
|
|
19
20
|
const os = require('node:os');
|
|
20
21
|
// 中转地址两格的收敛:二维码里 `relayUrls[0]` 必须与 `relayUrl` 是同一个字符串。
|
|
21
|
-
const { relayAddressesOf, PUBLIC_RELAY_URLS } = require('./core.js');
|
|
22
|
+
const { relayAddressesOf, PUBLIC_RELAY_URLS, isPublicRelayUrl } = require('./core.js');
|
|
22
23
|
const { providerLinesOf } = require('./provider-lines.cjs');
|
|
23
24
|
const {
|
|
24
25
|
advertisedCandidates,
|
|
@@ -95,22 +96,33 @@ function pairingPayload(state, lanPort) {
|
|
|
95
96
|
if (tcpLanUrl && !urls.includes(tcpLanUrl)) urls.push(tcpLanUrl);
|
|
96
97
|
// 老手机只读 `relayUrl`(语义一个字没变),新手机优先读数组、没有就退化到单条。
|
|
97
98
|
// `relayUrls[0]` 恒等于 `relayUrl` 这条不变式,在发进码的这一份里由下面的 codeRelays 保证。
|
|
98
|
-
//
|
|
99
|
-
// 2026-11-24 用户要求:出码时把内置公用中转地址并进这两格。引导页现在按地区配服务商,
|
|
100
|
-
// 但 iOS 扫不上 routes 里的服务商地址,给一条公用地址它就能拨。只改发进二维码的这一份,
|
|
101
|
-
// 不写回 state、不动停用逻辑:宿主配了自建的仍排在前、公用做兜底;没配中转的(新装 /
|
|
102
|
-
// 只接服务商)码里就只有这一条公用地址,手机扫到即可连。
|
|
103
99
|
const relay = relayAddressesOf(state);
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
100
|
+
// 服务商线路:与心跳 / 总控同源,另补 Cloudflare;同址已进 lanUrls 的不重复写。
|
|
101
|
+
// 要在拼 codeRelays 之前算好——下面把 http 类补进 urls 后,hasHttpProviderLine 要用它。
|
|
102
|
+
const routes = pairingRoutes(state, new Set(urls));
|
|
103
|
+
// 老包不认 routes 那一栏,只认 lanUrls。把 http(s) 服务商线路按「直连」形状也写一份进
|
|
104
|
+
// lanUrls,老包扫码就能直接拨服务商、不再借公用中转完成配对。tcp 类的不塞——它在
|
|
105
|
+
// lanUrls 里会被当 http 拨不通(要靠原生裸 TCP),仍只走 routes 那条。
|
|
106
|
+
// 判「有没有自己的线路」用原始清单、不看去重后的 routes:服务商地址即使同时填进了手填
|
|
107
|
+
// 直连(同址已在 urls 里、被 pairingRoutes 跳过),用户也确实配了线路,不该再塞公用。
|
|
108
|
+
let hasHttpProviderLine = providerLinesOf(state).some((row) => row.transport === 'http')
|
|
109
|
+
|| Boolean(typeof state.cloudflareUrl === 'string' && state.cloudflareUrl.trim());
|
|
110
|
+
for (const row of routes) {
|
|
111
|
+
if (row.transport === 'http' && !urls.includes(row.url)) urls.push(row.url);
|
|
112
|
+
}
|
|
113
|
+
// 老包能自己拨的线路:自建中转(codeRelays)或 http 服务商线路。只有这两类都不存在时,
|
|
114
|
+
// 公用中转才是「新装机器首次配对」唯一的通道,才写进码里。一旦配了其中任一类,码里一条
|
|
115
|
+
// 公用都不留:配对落在自己的线路上,不再持续压公用中转。
|
|
116
|
+
const codeRelays = [...relay.relayUrls].filter((url) => !isPublicRelayUrl(url));
|
|
117
|
+
if (codeRelays.length === 0 && !hasHttpProviderLine) {
|
|
118
|
+
for (const url of PUBLIC_RELAY_URLS) {
|
|
119
|
+
if (!codeRelays.includes(url)) codeRelays.push(url);
|
|
120
|
+
}
|
|
107
121
|
}
|
|
108
122
|
const codeRelayUrl = codeRelays[0] || '';
|
|
109
123
|
// **只有一条时不写数组**:那个数组恒等于单值,写进去是同一串地址在码里出现两遍,
|
|
110
|
-
//
|
|
124
|
+
// 白占七八个模块。只在纯公用兜底时才是一条,省下来的这几格最划算。
|
|
111
125
|
const relayList = codeRelays.length > 1 ? codeRelays : undefined;
|
|
112
|
-
// 服务商线路:与心跳 / 总控同源,另补 Cloudflare;同址已进 lanUrls 的不重复写。
|
|
113
|
-
const routes = pairingRoutes(state, new Set(urls));
|
|
114
126
|
const payload = {
|
|
115
127
|
type: 'dsh-pair',
|
|
116
128
|
version: 1,
|
package/lib/shell/updater.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** 2026-11-24:判新版改为与装包同源(优先问 npm,市场兜底),修 106 卡住不放。 */
|
|
1
2
|
/** 更新账本保留安装恢复结果,外壳(含启动时加载的常驻模块)变化提示重新载入外壳。 */
|
|
2
3
|
/**
|
|
3
4
|
* 更新编排:查与装都归实现自己,装完就地换代(不重启 DSH)。
|
|
@@ -183,6 +184,57 @@ export async function checkUpdate(base, name = PACKAGE_NAME, { force = false } =
|
|
|
183
184
|
}
|
|
184
185
|
}
|
|
185
186
|
|
|
187
|
+
/**
|
|
188
|
+
* 外壳的进程启动时就把插件树定死了:盘上那一代换过之后,这里再 require 会拿到旧模块。
|
|
189
|
+
* 所以「判有没有新版」也跟装包一样,从盘上那一代**动态**取查询模块(带时间戳绕开缓存)。
|
|
190
|
+
*/
|
|
191
|
+
async function generationModule(dir, rel) {
|
|
192
|
+
const file = path.join(dir, 'lib', rel)
|
|
193
|
+
if (!fs.existsSync(file)) return null
|
|
194
|
+
try {
|
|
195
|
+
return await import(`${pathToFileURL(file).href}?v=${Date.now()}`)
|
|
196
|
+
} catch {
|
|
197
|
+
return null
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* 用盘上那一代自己的查询模块问 npm 注册表——与真正装包同一个源。
|
|
203
|
+
*
|
|
204
|
+
* 装包走 `update-install.cjs`(问 npm 注册表),而自动更新以前拿去判「有没有新版」的
|
|
205
|
+
* `check()` 问的是 DSH 市场:市场没装 / 太老 / 还没同步到新版本时,那一头说「没新版」,
|
|
206
|
+
* 自动更新就地停摆,可 App 和手动更新走 npm 却看得到新版。两处判据必须同源。
|
|
207
|
+
*
|
|
208
|
+
* 盘上那一代没有查询模块(老版本 / 无头源码部署)就拿到 null,调用方退回市场,不让
|
|
209
|
+
* 自动更新整个坏掉。拿不到注册表地址也照查——查询模块自己会退回官方源。
|
|
210
|
+
*/
|
|
211
|
+
export async function checkFromGeneration({ packageManager = null } = {}) {
|
|
212
|
+
const dir = installedPackageDirSafe()
|
|
213
|
+
if (!dir) return null
|
|
214
|
+
const reg = await generationModule(dir, 'update-registry.cjs')
|
|
215
|
+
const inst = await generationModule(dir, 'update-install.cjs')
|
|
216
|
+
const checkForUpdate = reg?.checkForUpdate ?? reg?.default?.checkForUpdate
|
|
217
|
+
const profileRegistry = inst?.profileRegistry ?? inst?.default?.profileRegistry
|
|
218
|
+
const declaredSource = inst?.declaredSource ?? inst?.default?.declaredSource
|
|
219
|
+
if (typeof checkForUpdate !== 'function' || typeof profileRegistry !== 'function') return null
|
|
220
|
+
try {
|
|
221
|
+
const base = await profileRegistry({ profileNodeModules: profileNodeModules(), packageManager })
|
|
222
|
+
const source = typeof declaredSource === 'function'
|
|
223
|
+
? declaredSource(path.dirname(profileNodeModules()))
|
|
224
|
+
: null
|
|
225
|
+
const update = await checkForUpdate({ installedVersion: installedVersion(), source, base: base ?? undefined })
|
|
226
|
+
return {
|
|
227
|
+
installedVersion: typeof update.installedVersion === 'string' ? update.installedVersion : null,
|
|
228
|
+
latestVersion: typeof update.latestVersion === 'string' ? update.latestVersion : null,
|
|
229
|
+
updateAvailable: update.updateAvailable === true,
|
|
230
|
+
source: typeof update.source === 'string' ? update.source : null,
|
|
231
|
+
channelSwitch: false,
|
|
232
|
+
}
|
|
233
|
+
} catch {
|
|
234
|
+
return null
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
186
238
|
/**
|
|
187
239
|
* 这条链能不能自动更新。
|
|
188
240
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-mobile-plugin",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.109",
|
|
4
4
|
"description": "Mobile API (/api/mobile/v1) and relay client for the DSH mobile app — desktop profile build (dsh 0.2.x, peers resolved by the host)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"icon": "./icon.png",
|
|
@@ -117,24 +117,22 @@
|
|
|
117
117
|
"yaml": "2.9.1"
|
|
118
118
|
},
|
|
119
119
|
"dshMobileReleaseNotes": {
|
|
120
|
-
"version": "0.5.
|
|
120
|
+
"version": "0.5.109",
|
|
121
121
|
"kinds": [
|
|
122
|
-
"feature",
|
|
123
|
-
"other",
|
|
124
122
|
"fix"
|
|
125
123
|
],
|
|
126
124
|
"notes": {
|
|
127
|
-
"zh-Hans": "-
|
|
128
|
-
"zh-Hant": "-
|
|
129
|
-
"en": "-
|
|
130
|
-
"ja": "-
|
|
131
|
-
"ko": "-
|
|
132
|
-
"de": "-
|
|
133
|
-
"es": "-
|
|
134
|
-
"fr": "-
|
|
135
|
-
"pt": "-
|
|
136
|
-
"ru": "-
|
|
137
|
-
"tr": "-
|
|
125
|
+
"zh-Hans": "- 配置页面打不开时,报错页现在会把「完整退出 DSH 再打开」放在第一条:插件更新后没重启是最常见的原因。页面同时展示插件版本、来源和更新时间,方便看清当前状态。",
|
|
126
|
+
"zh-Hant": "- 設定頁面打不開時,報錯頁現在會把「完整結束 DSH 再開啟」放在第一條:外掛更新後沒重啟是最常見的原因。頁面同時顯示外掛版本、來源與更新時間,方便看清目前狀態。",
|
|
127
|
+
"en": "- When the configuration page won't open, the error page now puts \"quit DSH completely and reopen it\" first — not restarting after an update is the most common cause. It also shows the plugin version, source and activation time so you can see the current state.",
|
|
128
|
+
"ja": "- 設定ページが開かない場合、エラーページに「DSH を完全に終了してから開き直す」を最初に表示するようになりました。更新後に再起動していないことが最も多い原因です。プラグインのバージョン、入手元、有効化時刻も表示され、現在の状態を確認できます。",
|
|
129
|
+
"ko": "- 설정 페이지가 열리지 않을 때, 오류 화면에 \"DSH를 완전히 종료했다가 다시 열기\"를 가장 먼저 표시합니다. 업데이트 후 재시작하지 않은 것이 가장 흔한 원인입니다. 플러그인 버전, 출처, 활성화 시각도 함께 표시되어 현재 상태를 확인할 수 있습니다.",
|
|
130
|
+
"de": "- Wenn die Konfigurationsseite nicht geöffnet wird, steht auf der Fehlerseite jetzt „DSH vollständig beenden und erneut öffnen“ an erster Stelle — ein vergessener Neustart nach einem Update ist die häufigste Ursache. Die Seite zeigt auch Plugin-Version, Quelle und Aktivierungszeit, damit du den aktuellen Zustand sehen kannst.",
|
|
131
|
+
"es": "- Cuando la página de configuración no se abre, la página de error ahora muestra primero «sal de DSH por completo y vuelve a abrirlo»: no reiniciar tras una actualización es la causa más común. También muestra la versión del plugin, su origen y la hora de activación para que veas el estado actual.",
|
|
132
|
+
"fr": "- Lorsque la page de configuration ne s'ouvre pas, la page d'erreur affiche désormais en premier « quittez complètement DSH et rouvrez-le » : ne pas redémarrer après une mise à jour est la cause la plus fréquente. Elle affiche aussi la version du plugin, sa source et l'heure d'activation pour voir l'état actuel.",
|
|
133
|
+
"pt": "- Quando a página de configuração não abre, a página de erro agora mostra primeiro «saia do DSH completamente e abra novamente»: não reiniciar após uma atualização é a causa mais comum. Ela também mostra a versão do plugin, a origem e o horário de ativação para você ver o estado atual.",
|
|
134
|
+
"ru": "- Если страница настроек не открывается, на странице ошибки теперь первым делом указано «полностью выйти из DSH и открыть снова» — чаще всего причина в том, что после обновления не выполнен перезапуск. Также показываются версия плагина, источник и время активации, чтобы было видно текущее состояние.",
|
|
135
|
+
"tr": "- Yapılandırma sayfası açılmadığında, hata sayfası artık \"DSH'yi tamamen kapatıp yeniden açın\" önerisini ilk sıraya koyuyor; güncelleme sonrası yeniden başlatmamak en yaygın nedendir. Sayfa ayrıca eklenti sürümünü, kaynağını ve etkinleştirme zamanını göstererek mevcut durumu görmenizi sağlar."
|
|
138
136
|
}
|
|
139
137
|
}
|
|
140
138
|
}
|