dsh-mobile-plugin 0.5.107 → 0.5.108
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/index.js +9 -1
- package/lib/shell/updater.js +52 -0
- package/package.json +15 -16
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
|
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.108",
|
|
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,23 @@
|
|
|
117
117
|
"yaml": "2.9.1"
|
|
118
118
|
},
|
|
119
119
|
"dshMobileReleaseNotes": {
|
|
120
|
-
"version": "0.5.
|
|
120
|
+
"version": "0.5.108",
|
|
121
121
|
"kinds": [
|
|
122
|
-
"
|
|
123
|
-
"
|
|
124
|
-
"fix"
|
|
122
|
+
"fix",
|
|
123
|
+
"feature"
|
|
125
124
|
],
|
|
126
125
|
"notes": {
|
|
127
|
-
"zh-Hans": "-
|
|
128
|
-
"zh-Hant": "-
|
|
129
|
-
"en": "-
|
|
130
|
-
"ja": "-
|
|
131
|
-
"ko": "-
|
|
132
|
-
"de": "- Der
|
|
133
|
-
"es": "-
|
|
134
|
-
"fr": "-
|
|
135
|
-
"pt": "-
|
|
136
|
-
"ru": "-
|
|
137
|
-
"tr": "-
|
|
126
|
+
"zh-Hans": "- 修复插件卡在旧版不自动更新的问题:电脑判断有没有新版现在和真正安装走同一个来源,不会再出现「手机上有提示、电脑上却一直不动」。\n- App 现在每隔半小时检查一次插件新版,一直开着也能收到更新提示,不用再切到后台再回来。\n- 插件更新完成后会自动清掉页面上残留的「更新 / 稍后再说」;设备多的时候,更新页可以一次把所有设备一起更新。",
|
|
127
|
+
"zh-Hant": "- 修復外掛卡在舊版不自動更新的問題:電腦判斷有沒有新版現在和真正安裝走同一個來源,不會再出現「手機上有提示、電腦上卻一直不動」。\n- App 現在每隔半小時檢查一次外掛新版,一直開著也能收到更新提示,不用再切到背景再回來。\n- 外掛更新完成後會自動清掉頁面上殘留的「更新 / 稍後再說」;裝置多的時候,更新頁可以一次把所有裝置一起更新。",
|
|
128
|
+
"en": "- Fixed a bug where the plugin could get stuck on an old version and never auto-update: the computer now checks for new versions from the same source it installs from, so the phone can show an update while the computer stays put no longer happens.\n- The app now checks for plugin updates every 30 minutes, so you'll get the notification even if you leave it open — no need to send it to the background and come back.\n- After an update finishes, the leftover \"Update / Later\" buttons are cleared automatically; with many devices, the update page can update them all at once.",
|
|
129
|
+
"ja": "- プラグインが古いバージョンで固まって自動更新されない問題を修正しました。新しいバージョンがあるかの確認を、実際のインストールと同じ情報源から行うようになり、「スマホには通知が出るのにパソコンが動かない」という状態が起きなくなりました。\n- アプリが30分ごとにプラグインの更新を確認するようになり、開いたままでも通知が届きます。バックグラウンドにして戻る必要はありません。\n- 更新完了後にページに残る「更新 / 後で」ボタンが自動で消えます。デバイスが多い場合、更新ページですべてをまとめて更新できます。",
|
|
130
|
+
"ko": "- 플러그인이 오래된 버전에 멈춰 자동 업데이트되지 않던 문제를 수정했습니다. 새 버전이 있는지 확인할 때 실제 설치와 같은 출처를 사용하므로, \"휴대전화에는 알림이 뜨는데 컴퓨터는 그대로인\" 상황이 더 이상 발생하지 않습니다.\n- 앱이 30분마다 플러그인 업데이트를 확인하므로 계속 열어 두어도 알림을 받을 수 있습니다. 백그라운드로 보냈다가 돌아올 필요가 없습니다.\n- 업데이트가 끝나면 화면에 남아 있던 \"업데이트 / 나중에\" 버튼이 자동으로 사라집니다. 기기가 많으면 업데이트 페이지에서 모두 한 번에 업데이트할 수 있습니다.",
|
|
131
|
+
"de": "- Behoben: Das Plugin blieb manchmal auf einer alten Version hängen und aktualisierte sich nicht automatisch. Der Computer prüft jetzt auf dieselbe Weise auf neue Versionen, wie er auch installiert — „das Handy zeigt eine Update-Meldung, der Computer bleibt stehen“ passiert nicht mehr.\n- Die App prüft jetzt alle 30 Minuten auf Plugin-Updates, sodass du auch bei dauerhaft geöffneter App eine Benachrichtigung bekommst — ohne in den Hintergrund und zurück zu wechseln.\n- Nach Abschluss eines Updates verschwinden die übrig gebliebenen Buttons „Aktualisieren / Später“ automatisch; bei vielen Geräten kann die Update-Seite alle auf einmal aktualisieren.",
|
|
132
|
+
"es": "- Corregido: el plugin podía quedarse atascado en una versión antigua y no actualizarse solo. Ahora el ordenador comprueba si hay versiones nuevas desde la misma fuente que usa para instalar, así que ya no ocurre que «el móvil muestra un aviso pero el ordenador no se mueve».\n- La app ahora comprueba las actualizaciones del plugin cada 30 minutos, así que recibirás el aviso aunque la dejes abierta, sin necesidad de pasar a segundo plano y volver.\n- Al terminar una actualización, los botones sobrantes de «Actualizar / Más tarde» desaparecen automáticamente; con muchos dispositivos, la página de actualizaciones puede actualizarlos todos a la vez.",
|
|
133
|
+
"fr": "- Corrigé : le plugin pouvait rester bloqué sur une ancienne version et ne pas se mettre à jour automatiquement. L'ordinateur vérifie désormais l'existence de nouvelles versions depuis la même source que celle utilisée pour l'installation : le cas « le téléphone affiche une notification mais l'ordinateur ne bouge pas » ne se produit plus.\n- L'application vérifie maintenant les mises à jour du plugin toutes les 30 minutes : vous recevrez la notification même si elle reste ouverte, sans passer en arrière-plan et revenir.\n- Une fois la mise à jour terminée, les boutons restants « Mettre à jour / Plus tard » disparaissent automatiquement ; avec de nombreux appareils, la page de mise à jour peut tous les mettre à jour en une seule fois.",
|
|
134
|
+
"pt": "- Corrigido: o plugin podia ficar preso numa versão antiga e não atualizar sozinho. Agora o computador verifica se há versões novas na mesma fonte usada para instalar, então não acontece mais de «o celular mostrar um aviso e o computador ficar parado».\n- O app agora verifica atualizações do plugin a cada 30 minutos, então você recebe o aviso mesmo deixando-o aberto, sem precisar ir para o segundo plano e voltar.\n- Após a conclusão da atualização, os botões restantes de «Atualizar / Depois» desaparecem automaticamente; com muitos dispositivos, a página de atualizações pode atualizar todos de uma vez.",
|
|
135
|
+
"ru": "- Исправлено: плагин мог застрять на старой версии и не обновляться автоматически. Теперь компьютер проверяет наличие новых версий из того же источника, из которого выполняет установку, поэтому ситуация «телефон показывает уведомление, а компьютер не реагирует» больше не возникает.\n- Теперь приложение проверяет обновления плагина каждые 30 минут, поэтому уведомление придёт даже если оно всё время открыто — не нужно сворачивать его и возвращаться.\n- После завершения обновления оставшиеся кнопки «Обновить / Позже» исчезают автоматически; при большом количестве устройств страница обновлений может обновить их все сразу.",
|
|
136
|
+
"tr": "- Düzeltildi: eklenti eski bir sürüme takılıp kendiliğinden güncellenmeyebiliyordu. Artık bilgisayar yeni sürüm olup olmadığını, kurulumu yaptığı kaynaktan kontrol ediyor; böylece \"telefonda bildirim çıkıyor ama bilgisayar kıpırdamıyor\" durumu artık oluşmuyor.\n- Uygulama artık eklenti güncellemelerini 30 dakikada bir kontrol ediyor; açık bıraksanız da bildirim gelir, arka plana alıp geri dönmeniz gerekmez.\n- Bir güncelleme tamamlandığında geride kalan \"Güncelle / Daha sonra\" düğmeleri otomatik kaybolur; cihaz sayısı fazlaysa güncelleme sayfası tümünü aynı anda güncelleyebilir."
|
|
138
137
|
}
|
|
139
138
|
}
|
|
140
139
|
}
|