@marktrue/dsh-mobile-remote 3.2.4-rc.3 → 3.2.4-rc.4-app
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/DSH-Remote-v3.2.4.apk +4 -0
- package/README.md +6 -256
- package/manifest.json +21 -0
- package/package.json +12 -68
- package/CHANGELOG.md +0 -2087
- package/CONTRIBUTING.md +0 -114
- package/FAQ.md +0 -111
- package/cordis.patch.yml +0 -14
- package/docs/00-/345/274/200/345/217/221/346/200/273/347/272/262.md +0 -125
- package/docs/01-PRD.md +0 -148
- package/docs/02-architecture.md +0 -249
- package/docs/03-api.md +0 -1456
- package/docs/04-security.md +0 -114
- package/docs/05-test-cases.md +0 -405
- package/docs/06-install-run.md +0 -342
- package/docs/07-user-manual.md +0 -70
- package/docs/08-/346/211/251/345/261/225/345/274/200/345/217/221/346/214/207/345/215/227.md +0 -86
- package/docs/09-compatibility.md +0 -255
- package/docs/10-release.md +0 -1032
- package/docs/11-notification-reliability.md +0 -45
- package/docs/12-implementation-status.md +0 -41
- package/docs/13-device-acceptance-2026-11-03.md +0 -37
- package/docs/16-next-window-handoff-2026-11-04.md +0 -44
- package/docs/17-remaining-work-review-2026-11-04.md +0 -53
- package/docs/18-device-reliability-acceptance-2026-11-04.md +0 -63
- package/docs/19-issue-followup-2026-11-04.md +0 -39
- package/docs/20-dsh-022-compatibility-2026-11-05.md +0 -32
- package/docs/screenshots/01-home.png +0 -0
- package/docs/screenshots/02-notifications.png +0 -0
- package/docs/screenshots/03-sessions.png +0 -0
- package/docs/screenshots/04-chat.png +0 -0
- package/docs/screenshots/05-settings.png +0 -0
- package/docs/screenshots/06-new-session.png +0 -0
- package/docs/screenshots/pgy-appstore.jpg +0 -0
- package/docs/screenshots/pgy-mobile-app.jpg +0 -0
- package/docs/screenshots/pgy-pc-client.jpg +0 -0
- package/lib/account-usage.js +0 -145
- package/lib/app-alignment.js +0 -112
- package/lib/app-carrier-store.js +0 -1972
- package/lib/app-carrier.js +0 -609
- package/lib/client.js +0 -1196
- package/lib/desktop-form.js +0 -738
- package/lib/endpoint-registry.js +0 -187
- package/lib/git-read-bundled-provider.js +0 -464
- package/lib/git-read-service.js +0 -872
- package/lib/host-manager-update.js +0 -222
- package/lib/host-update-capabilities.js +0 -209
- package/lib/index.js +0 -12503
- package/lib/npm-update-source.js +0 -226
- package/lib/plugin-content-digest.js +0 -80
- package/lib/plugin-self-update.js +0 -1112
- package/lib/plugin-update-check.js +0 -268
- package/lib/plugin-update-controller.js +0 -416
- package/lib/plugin-update-log.js +0 -164
- package/lib/plugin-update-transaction.js +0 -358
- package/lib/plugin-update.js +0 -309
- package/lib/runtime-dependency-snapshot.js +0 -345
- package/lib/session-title-cache.js +0 -123
- package/lib/session-title-refresh.js +0 -261
- package/lib/tool-process.js +0 -20
- package/lib/update-fetch.js +0 -24
- package/lib/update-lock-arbiter.js +0 -210
- package/lib/update-supervisor.js +0 -379
- package/node_modules/ansi-regex/index.d.ts +0 -37
- package/node_modules/ansi-regex/index.js +0 -10
- package/node_modules/ansi-regex/license +0 -9
- package/node_modules/ansi-regex/package.json +0 -55
- package/node_modules/ansi-regex/readme.md +0 -78
- package/node_modules/ansi-styles/index.d.ts +0 -345
- package/node_modules/ansi-styles/index.js +0 -163
- package/node_modules/ansi-styles/license +0 -9
- package/node_modules/ansi-styles/package.json +0 -56
- package/node_modules/ansi-styles/readme.md +0 -152
- package/node_modules/camelcase/index.d.ts +0 -63
- package/node_modules/camelcase/index.js +0 -76
- package/node_modules/camelcase/license +0 -9
- package/node_modules/camelcase/package.json +0 -43
- package/node_modules/camelcase/readme.md +0 -99
- package/node_modules/cliui/CHANGELOG.md +0 -76
- package/node_modules/cliui/LICENSE.txt +0 -14
- package/node_modules/cliui/README.md +0 -115
- package/node_modules/cliui/index.js +0 -354
- package/node_modules/cliui/package.json +0 -65
- package/node_modules/color-convert/CHANGELOG.md +0 -54
- package/node_modules/color-convert/LICENSE +0 -21
- package/node_modules/color-convert/README.md +0 -68
- package/node_modules/color-convert/conversions.js +0 -839
- package/node_modules/color-convert/index.js +0 -81
- package/node_modules/color-convert/package.json +0 -48
- package/node_modules/color-convert/route.js +0 -97
- package/node_modules/color-name/LICENSE +0 -8
- package/node_modules/color-name/README.md +0 -11
- package/node_modules/color-name/index.js +0 -152
- package/node_modules/color-name/package.json +0 -28
- package/node_modules/decamelize/index.js +0 -13
- package/node_modules/decamelize/license +0 -21
- package/node_modules/decamelize/package.json +0 -38
- package/node_modules/decamelize/readme.md +0 -48
- package/node_modules/dijkstrajs/.travis.yml +0 -4
- package/node_modules/dijkstrajs/CONTRIBUTING.md +0 -8
- package/node_modules/dijkstrajs/LICENSE.md +0 -19
- package/node_modules/dijkstrajs/README.md +0 -18
- package/node_modules/dijkstrajs/dijkstra.js +0 -165
- package/node_modules/dijkstrajs/package.json +0 -60
- package/node_modules/dijkstrajs/test/dijkstra.test.js +0 -96
- package/node_modules/emoji-regex/LICENSE-MIT.txt +0 -20
- package/node_modules/emoji-regex/README.md +0 -73
- package/node_modules/emoji-regex/es2015/index.js +0 -6
- package/node_modules/emoji-regex/es2015/text.js +0 -6
- package/node_modules/emoji-regex/index.d.ts +0 -23
- package/node_modules/emoji-regex/index.js +0 -6
- package/node_modules/emoji-regex/package.json +0 -50
- package/node_modules/emoji-regex/text.js +0 -6
- package/node_modules/find-up/index.d.ts +0 -137
- package/node_modules/find-up/index.js +0 -89
- package/node_modules/find-up/license +0 -9
- package/node_modules/find-up/package.json +0 -53
- package/node_modules/find-up/readme.md +0 -156
- package/node_modules/get-caller-file/LICENSE.md +0 -6
- package/node_modules/get-caller-file/README.md +0 -41
- package/node_modules/get-caller-file/index.d.ts +0 -2
- package/node_modules/get-caller-file/index.js +0 -22
- package/node_modules/get-caller-file/index.js.map +0 -1
- package/node_modules/get-caller-file/package.json +0 -42
- package/node_modules/is-fullwidth-code-point/index.d.ts +0 -17
- package/node_modules/is-fullwidth-code-point/index.js +0 -50
- package/node_modules/is-fullwidth-code-point/license +0 -9
- package/node_modules/is-fullwidth-code-point/package.json +0 -42
- package/node_modules/is-fullwidth-code-point/readme.md +0 -39
- package/node_modules/locate-path/index.d.ts +0 -83
- package/node_modules/locate-path/index.js +0 -65
- package/node_modules/locate-path/license +0 -9
- package/node_modules/locate-path/package.json +0 -45
- package/node_modules/locate-path/readme.md +0 -122
- package/node_modules/p-limit/index.d.ts +0 -38
- package/node_modules/p-limit/index.js +0 -57
- package/node_modules/p-limit/license +0 -9
- package/node_modules/p-limit/package.json +0 -52
- package/node_modules/p-limit/readme.md +0 -101
- package/node_modules/p-locate/index.d.ts +0 -64
- package/node_modules/p-locate/index.js +0 -52
- package/node_modules/p-locate/license +0 -9
- package/node_modules/p-locate/package.json +0 -53
- package/node_modules/p-locate/readme.md +0 -90
- package/node_modules/p-try/index.d.ts +0 -39
- package/node_modules/p-try/index.js +0 -9
- package/node_modules/p-try/license +0 -9
- package/node_modules/p-try/package.json +0 -42
- package/node_modules/p-try/readme.md +0 -58
- package/node_modules/path-exists/index.d.ts +0 -28
- package/node_modules/path-exists/index.js +0 -23
- package/node_modules/path-exists/license +0 -9
- package/node_modules/path-exists/package.json +0 -39
- package/node_modules/path-exists/readme.md +0 -52
- package/node_modules/pngjs/.eslintignore +0 -2
- package/node_modules/pngjs/.eslintrc.json +0 -19
- package/node_modules/pngjs/.prettierignore +0 -3
- package/node_modules/pngjs/LICENSE +0 -20
- package/node_modules/pngjs/README.md +0 -429
- package/node_modules/pngjs/browser.js +0 -16096
- package/node_modules/pngjs/coverage/lcov-report/base.css +0 -354
- package/node_modules/pngjs/coverage/lcov-report/bitmapper.js.html +0 -881
- package/node_modules/pngjs/coverage/lcov-report/bitpacker.js.html +0 -554
- package/node_modules/pngjs/coverage/lcov-report/block-navigation.js +0 -77
- package/node_modules/pngjs/coverage/lcov-report/chunkstream.js.html +0 -647
- package/node_modules/pngjs/coverage/lcov-report/constants.js.html +0 -176
- package/node_modules/pngjs/coverage/lcov-report/crc.js.html +0 -200
- package/node_modules/pngjs/coverage/lcov-report/favicon.png +0 -0
- package/node_modules/pngjs/coverage/lcov-report/filter-pack.js.html +0 -593
- package/node_modules/pngjs/coverage/lcov-report/filter-parse-async.js.html +0 -152
- package/node_modules/pngjs/coverage/lcov-report/filter-parse-sync.js.html +0 -143
- package/node_modules/pngjs/coverage/lcov-report/filter-parse.js.html +0 -611
- package/node_modules/pngjs/coverage/lcov-report/format-normaliser.js.html +0 -359
- package/node_modules/pngjs/coverage/lcov-report/index.html +0 -426
- package/node_modules/pngjs/coverage/lcov-report/interlace.js.html +0 -365
- package/node_modules/pngjs/coverage/lcov-report/packer-async.js.html +0 -230
- package/node_modules/pngjs/coverage/lcov-report/packer-sync.js.html +0 -248
- package/node_modules/pngjs/coverage/lcov-report/packer.js.html +0 -467
- package/node_modules/pngjs/coverage/lcov-report/paeth-predictor.js.html +0 -128
- package/node_modules/pngjs/coverage/lcov-report/parser-async.js.html +0 -575
- package/node_modules/pngjs/coverage/lcov-report/parser-sync.js.html +0 -404
- package/node_modules/pngjs/coverage/lcov-report/parser.js.html +0 -950
- package/node_modules/pngjs/coverage/lcov-report/png-sync.js.html +0 -116
- package/node_modules/pngjs/coverage/lcov-report/png.js.html +0 -662
- package/node_modules/pngjs/coverage/lcov-report/prettify.css +0 -101
- package/node_modules/pngjs/coverage/lcov-report/prettify.js +0 -1007
- package/node_modules/pngjs/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/node_modules/pngjs/coverage/lcov-report/sorter.js +0 -169
- package/node_modules/pngjs/coverage/lcov-report/sync-inflate.js.html +0 -584
- package/node_modules/pngjs/coverage/lcov-report/sync-reader.js.html +0 -215
- package/node_modules/pngjs/coverage/lcov.info +0 -2177
- package/node_modules/pngjs/lib/bitmapper.js +0 -267
- package/node_modules/pngjs/lib/bitpacker.js +0 -158
- package/node_modules/pngjs/lib/chunkstream.js +0 -189
- package/node_modules/pngjs/lib/constants.js +0 -32
- package/node_modules/pngjs/lib/crc.js +0 -40
- package/node_modules/pngjs/lib/filter-pack.js +0 -171
- package/node_modules/pngjs/lib/filter-parse-async.js +0 -24
- package/node_modules/pngjs/lib/filter-parse-sync.js +0 -21
- package/node_modules/pngjs/lib/filter-parse.js +0 -177
- package/node_modules/pngjs/lib/format-normaliser.js +0 -93
- package/node_modules/pngjs/lib/interlace.js +0 -95
- package/node_modules/pngjs/lib/packer-async.js +0 -50
- package/node_modules/pngjs/lib/packer-sync.js +0 -56
- package/node_modules/pngjs/lib/packer.js +0 -129
- package/node_modules/pngjs/lib/paeth-predictor.js +0 -16
- package/node_modules/pngjs/lib/parser-async.js +0 -165
- package/node_modules/pngjs/lib/parser-sync.js +0 -108
- package/node_modules/pngjs/lib/parser.js +0 -290
- package/node_modules/pngjs/lib/png-sync.js +0 -12
- package/node_modules/pngjs/lib/png.js +0 -194
- package/node_modules/pngjs/lib/sync-inflate.js +0 -168
- package/node_modules/pngjs/lib/sync-reader.js +0 -45
- package/node_modules/pngjs/package.json +0 -73
- package/node_modules/qrcode/README.md +0 -770
- package/node_modules/qrcode/bin/qrcode +0 -159
- package/node_modules/qrcode/helper/to-sjis-browser.js +0 -2
- package/node_modules/qrcode/helper/to-sjis.js +0 -105
- package/node_modules/qrcode/lib/browser.js +0 -76
- package/node_modules/qrcode/lib/can-promise.js +0 -7
- package/node_modules/qrcode/lib/core/alignment-pattern.js +0 -83
- package/node_modules/qrcode/lib/core/alphanumeric-data.js +0 -59
- package/node_modules/qrcode/lib/core/bit-buffer.js +0 -37
- package/node_modules/qrcode/lib/core/bit-matrix.js +0 -65
- package/node_modules/qrcode/lib/core/byte-data.js +0 -30
- package/node_modules/qrcode/lib/core/error-correction-code.js +0 -135
- package/node_modules/qrcode/lib/core/error-correction-level.js +0 -50
- package/node_modules/qrcode/lib/core/finder-pattern.js +0 -22
- package/node_modules/qrcode/lib/core/format-info.js +0 -29
- package/node_modules/qrcode/lib/core/galois-field.js +0 -69
- package/node_modules/qrcode/lib/core/kanji-data.js +0 -54
- package/node_modules/qrcode/lib/core/mask-pattern.js +0 -234
- package/node_modules/qrcode/lib/core/mode.js +0 -167
- package/node_modules/qrcode/lib/core/numeric-data.js +0 -43
- package/node_modules/qrcode/lib/core/polynomial.js +0 -62
- package/node_modules/qrcode/lib/core/qrcode.js +0 -495
- package/node_modules/qrcode/lib/core/reed-solomon-encoder.js +0 -56
- package/node_modules/qrcode/lib/core/regex.js +0 -31
- package/node_modules/qrcode/lib/core/segments.js +0 -330
- package/node_modules/qrcode/lib/core/utils.js +0 -63
- package/node_modules/qrcode/lib/core/version-check.js +0 -9
- package/node_modules/qrcode/lib/core/version.js +0 -163
- package/node_modules/qrcode/lib/index.js +0 -12
- package/node_modules/qrcode/lib/renderer/canvas.js +0 -63
- package/node_modules/qrcode/lib/renderer/png.js +0 -78
- package/node_modules/qrcode/lib/renderer/svg-tag.js +0 -81
- package/node_modules/qrcode/lib/renderer/svg.js +0 -19
- package/node_modules/qrcode/lib/renderer/terminal/terminal-small.js +0 -85
- package/node_modules/qrcode/lib/renderer/terminal/terminal.js +0 -49
- package/node_modules/qrcode/lib/renderer/terminal.js +0 -9
- package/node_modules/qrcode/lib/renderer/utf8.js +0 -71
- package/node_modules/qrcode/lib/renderer/utils.js +0 -99
- package/node_modules/qrcode/lib/server.js +0 -138
- package/node_modules/qrcode/license +0 -10
- package/node_modules/qrcode/package.json +0 -77
- package/node_modules/require-directory/.jshintrc +0 -67
- package/node_modules/require-directory/.npmignore +0 -1
- package/node_modules/require-directory/.travis.yml +0 -3
- package/node_modules/require-directory/LICENSE +0 -22
- package/node_modules/require-directory/README.markdown +0 -184
- package/node_modules/require-directory/index.js +0 -86
- package/node_modules/require-directory/package.json +0 -40
- package/node_modules/require-main-filename/CHANGELOG.md +0 -26
- package/node_modules/require-main-filename/LICENSE.txt +0 -14
- package/node_modules/require-main-filename/README.md +0 -26
- package/node_modules/require-main-filename/index.js +0 -18
- package/node_modules/require-main-filename/package.json +0 -35
- package/node_modules/set-blocking/CHANGELOG.md +0 -26
- package/node_modules/set-blocking/LICENSE.txt +0 -14
- package/node_modules/set-blocking/README.md +0 -31
- package/node_modules/set-blocking/index.js +0 -7
- package/node_modules/set-blocking/package.json +0 -42
- package/node_modules/string-width/index.d.ts +0 -29
- package/node_modules/string-width/index.js +0 -47
- package/node_modules/string-width/license +0 -9
- package/node_modules/string-width/package.json +0 -56
- package/node_modules/string-width/readme.md +0 -50
- package/node_modules/strip-ansi/index.d.ts +0 -17
- package/node_modules/strip-ansi/index.js +0 -4
- package/node_modules/strip-ansi/license +0 -9
- package/node_modules/strip-ansi/package.json +0 -54
- package/node_modules/strip-ansi/readme.md +0 -46
- package/node_modules/which-module/LICENSE +0 -13
- package/node_modules/which-module/README.md +0 -58
- package/node_modules/which-module/index.js +0 -9
- package/node_modules/which-module/package.json +0 -41
- package/node_modules/wrap-ansi/index.js +0 -186
- package/node_modules/wrap-ansi/license +0 -9
- package/node_modules/wrap-ansi/package.json +0 -61
- package/node_modules/wrap-ansi/readme.md +0 -97
- package/node_modules/y18n/CHANGELOG.md +0 -35
- package/node_modules/y18n/LICENSE +0 -13
- package/node_modules/y18n/README.md +0 -109
- package/node_modules/y18n/index.js +0 -188
- package/node_modules/y18n/package.json +0 -39
- package/node_modules/yargs/CHANGELOG.md +0 -420
- package/node_modules/yargs/LICENSE +0 -21
- package/node_modules/yargs/README.md +0 -140
- package/node_modules/yargs/build/lib/apply-extends.d.ts +0 -2
- package/node_modules/yargs/build/lib/apply-extends.js +0 -65
- package/node_modules/yargs/build/lib/argsert.d.ts +0 -2
- package/node_modules/yargs/build/lib/argsert.js +0 -65
- package/node_modules/yargs/build/lib/command.d.ts +0 -64
- package/node_modules/yargs/build/lib/command.js +0 -416
- package/node_modules/yargs/build/lib/common-types.d.ts +0 -36
- package/node_modules/yargs/build/lib/common-types.js +0 -25
- package/node_modules/yargs/build/lib/completion-templates.d.ts +0 -2
- package/node_modules/yargs/build/lib/completion-templates.js +0 -50
- package/node_modules/yargs/build/lib/completion.d.ts +0 -21
- package/node_modules/yargs/build/lib/completion.js +0 -135
- package/node_modules/yargs/build/lib/is-promise.d.ts +0 -1
- package/node_modules/yargs/build/lib/is-promise.js +0 -9
- package/node_modules/yargs/build/lib/levenshtein.d.ts +0 -1
- package/node_modules/yargs/build/lib/levenshtein.js +0 -58
- package/node_modules/yargs/build/lib/middleware.d.ts +0 -10
- package/node_modules/yargs/build/lib/middleware.js +0 -57
- package/node_modules/yargs/build/lib/obj-filter.d.ts +0 -1
- package/node_modules/yargs/build/lib/obj-filter.js +0 -14
- package/node_modules/yargs/build/lib/parse-command.d.ts +0 -11
- package/node_modules/yargs/build/lib/parse-command.js +0 -36
- package/node_modules/yargs/build/lib/process-argv.d.ts +0 -2
- package/node_modules/yargs/build/lib/process-argv.js +0 -31
- package/node_modules/yargs/build/lib/usage.d.ts +0 -49
- package/node_modules/yargs/build/lib/usage.js +0 -540
- package/node_modules/yargs/build/lib/validation.d.ts +0 -34
- package/node_modules/yargs/build/lib/validation.js +0 -330
- package/node_modules/yargs/build/lib/yargs.d.ts +0 -274
- package/node_modules/yargs/build/lib/yargs.js +0 -1190
- package/node_modules/yargs/build/lib/yerror.d.ts +0 -4
- package/node_modules/yargs/build/lib/yerror.js +0 -11
- package/node_modules/yargs/index.js +0 -40
- package/node_modules/yargs/locales/be.json +0 -46
- package/node_modules/yargs/locales/de.json +0 -46
- package/node_modules/yargs/locales/en.json +0 -51
- package/node_modules/yargs/locales/es.json +0 -46
- package/node_modules/yargs/locales/fi.json +0 -49
- package/node_modules/yargs/locales/fr.json +0 -53
- package/node_modules/yargs/locales/hi.json +0 -49
- package/node_modules/yargs/locales/hu.json +0 -46
- package/node_modules/yargs/locales/id.json +0 -50
- package/node_modules/yargs/locales/it.json +0 -46
- package/node_modules/yargs/locales/ja.json +0 -51
- package/node_modules/yargs/locales/ko.json +0 -49
- package/node_modules/yargs/locales/nb.json +0 -44
- package/node_modules/yargs/locales/nl.json +0 -49
- package/node_modules/yargs/locales/nn.json +0 -44
- package/node_modules/yargs/locales/pirate.json +0 -13
- package/node_modules/yargs/locales/pl.json +0 -49
- package/node_modules/yargs/locales/pt.json +0 -45
- package/node_modules/yargs/locales/pt_BR.json +0 -48
- package/node_modules/yargs/locales/ru.json +0 -46
- package/node_modules/yargs/locales/th.json +0 -46
- package/node_modules/yargs/locales/tr.json +0 -48
- package/node_modules/yargs/locales/zh_CN.json +0 -48
- package/node_modules/yargs/locales/zh_TW.json +0 -47
- package/node_modules/yargs/package.json +0 -92
- package/node_modules/yargs/yargs.js +0 -14
- package/node_modules/yargs-parser/CHANGELOG.md +0 -601
- package/node_modules/yargs-parser/LICENSE.txt +0 -14
- package/node_modules/yargs-parser/README.md +0 -449
- package/node_modules/yargs-parser/index.js +0 -1032
- package/node_modules/yargs-parser/lib/tokenize-arg-string.js +0 -40
- package/node_modules/yargs-parser/package.json +0 -46
|
@@ -1,222 +0,0 @@
|
|
|
1
|
-
// 通过宿主原生插件管理器执行更新(DSH 0.2.2+):不重启宿主。
|
|
2
|
-
//
|
|
3
|
-
// 与 `plugin-self-update.js` 那条「改依赖 → pnpm install → 重启 → 健康确认」的传统
|
|
4
|
-
// 通道并列;本模块只在宿主提供 `pluginManager.updateBundle()` 时使用。
|
|
5
|
-
//
|
|
6
|
-
// 为什么优先用它:
|
|
7
|
-
// 1. **不重启**:宿主在 HMR 可用时移除旧版本、装新版本并在进程内重新组合 profile,
|
|
8
|
-
// 插件被重新加载而宿主进程不变——手机与桌面都不掉连接。
|
|
9
|
-
// 2. **判定权交给宿主**:registry 选择、pnpm 配置、凭据、兼容性豁免、构建脚本批准
|
|
10
|
-
// 全部由宿主那一套既有实现决定,我们不重复实现、也不绕过它的安全检查。
|
|
11
|
-
// 3. **失败即回滚**:宿主在装新版本失败/取消时会把旧版本装回去,并把结果如实报出来。
|
|
12
|
-
//
|
|
13
|
-
// 本模块不做的事:不自己跑 pnpm、不改 profile 文件、不做健康判定(宿主的
|
|
14
|
-
// `application` 字段就是结论)。
|
|
15
|
-
import { compareVersion, parseVersion } from "./plugin-update.js";
|
|
16
|
-
import { HOST_MANAGER_REASON, UPDATE_CHANNEL } from "./host-update-capabilities.js";
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* 宿主拒绝后的**稳定动作枚举**(issue #116,对外契约;只有 5 个值)。
|
|
20
|
-
*
|
|
21
|
-
* 由宿主 `error.code` 白名单映射而来,App 据此给出可执行提示(例如“先重启 DSH”);
|
|
22
|
-
* 未知 code 保留原码并落到 `diagnose`,绝不因为不认识就丢弃。
|
|
23
|
-
*/
|
|
24
|
-
export const HOST_MANAGER_NEXT_ACTION = {
|
|
25
|
-
/** 另有插件变更待重启(`stop-profile` / `bundle-in-use`)——重启宿主后重试。 */
|
|
26
|
-
RESTART_HOST: "restart-host",
|
|
27
|
-
/** 目标版本与当前宿主不兼容。 */
|
|
28
|
-
VERSION_INCOMPATIBLE: "version-incompatible",
|
|
29
|
-
/** 目标不是可更新的 bundle / 版本非法。 */
|
|
30
|
-
INVALID_TARGET: "invalid-target",
|
|
31
|
-
/** 宿主执行失败,可重试或看诊断。 */
|
|
32
|
-
RETRY_OR_DIAGNOSE: "retry-or-diagnose",
|
|
33
|
-
/** 未知原因,只能给诊断信息(保留 `hostErrorCode` 原码)。 */
|
|
34
|
-
DIAGNOSE: "diagnose",
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
/** 宿主 `error.code` → `nextAction` 的**唯一映射点**(白名单;未知 code → diagnose)。 */
|
|
38
|
-
const HOST_ERROR_NEXT_ACTION = new Map([
|
|
39
|
-
["stop-profile", HOST_MANAGER_NEXT_ACTION.RESTART_HOST],
|
|
40
|
-
["bundle-in-use", HOST_MANAGER_NEXT_ACTION.RESTART_HOST],
|
|
41
|
-
["incompatible-version", HOST_MANAGER_NEXT_ACTION.VERSION_INCOMPATIBLE],
|
|
42
|
-
["not-bundle", HOST_MANAGER_NEXT_ACTION.INVALID_TARGET],
|
|
43
|
-
["invalid-spec", HOST_MANAGER_NEXT_ACTION.INVALID_TARGET],
|
|
44
|
-
["operation-error", HOST_MANAGER_NEXT_ACTION.RETRY_OR_DIAGNOSE],
|
|
45
|
-
]);
|
|
46
|
-
|
|
47
|
-
/** 把宿主错误码映射为稳定动作;空码返回空串(不是一次宿主拒绝),未知非空码 → diagnose。 */
|
|
48
|
-
export function nextActionForHostError(code) {
|
|
49
|
-
const value = typeof code === "string" ? code : "";
|
|
50
|
-
if (value === "") return "";
|
|
51
|
-
return HOST_ERROR_NEXT_ACTION.get(value) ?? HOST_MANAGER_NEXT_ACTION.DIAGNOSE;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/** 宿主更新失败的稳定原因码(对外只暴露这一类,不含宿主异常原文)。 */
|
|
55
|
-
export const HOST_MANAGER_ERROR = {
|
|
56
|
-
/** 探测阶段就不可用。 */
|
|
57
|
-
UNAVAILABLE: "host-manager-unavailable",
|
|
58
|
-
/** 目标版本不是合法 semver。 */
|
|
59
|
-
VERSION_INVALID: "host-manager-version-invalid",
|
|
60
|
-
/** 目标版本不高于已安装版本(宿主会拒绝,这里提前挡)。 */
|
|
61
|
-
VERSION_NOT_NEWER: "host-manager-version-not-newer",
|
|
62
|
-
/** 宿主拒绝(`ChangeResult.application === 'failed'`)。 */
|
|
63
|
-
REJECTED: "host-manager-rejected",
|
|
64
|
-
/** 用户/调用方取消。 */
|
|
65
|
-
CANCELLED: "host-manager-cancelled",
|
|
66
|
-
/** 装上了但需要重启才生效。 */
|
|
67
|
-
RESTART_REQUIRED: "host-manager-restart-required",
|
|
68
|
-
/** 调用 itself 抛错。 */
|
|
69
|
-
CALL_FAILED: "host-manager-call-failed",
|
|
70
|
-
/** 被替代/覆盖(同一插件条目上有更高优先级的覆盖)。 */
|
|
71
|
-
OVERRIDDEN: "host-manager-overridden",
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* 把宿主的 `ChangeResult`(以及 `updateBundle` 外层结果)压成我们自己的稳定结论。
|
|
76
|
-
*
|
|
77
|
-
* 宿主字段语义(见 dsh-plugin-manager 的 `ChangeResult` / `PluginUpdateResult`):
|
|
78
|
-
* - `application: 'applied'` → 已生效,无需重启;
|
|
79
|
-
* - `application: 'restart-required'` → 装了但下次启动才生效;
|
|
80
|
-
* - `application: 'failed' | 'cancelled'` → 未生效(`restore` 存在时表示旧版本已装回);
|
|
81
|
-
* - `application: 'overridden'` → 被其它条目覆盖。
|
|
82
|
-
*
|
|
83
|
-
* @param {object|undefined} outcome - `updateBundle()` 的返回值。
|
|
84
|
-
* @returns {{ok: boolean, reason: string, restored: boolean, from: string, to: string, step: string,
|
|
85
|
-
* detail: string, hostErrorCode: string, nextAction: string}}
|
|
86
|
-
*/
|
|
87
|
-
export function interpretHostManagerUpdate(outcome) {
|
|
88
|
-
const from = typeof outcome?.from === "string" ? outcome.from : "";
|
|
89
|
-
const to = typeof outcome?.to === "string" ? outcome.to : "";
|
|
90
|
-
const step = typeof outcome?.step === "string" ? outcome.step : "";
|
|
91
|
-
const base = { from, to, step, restored: Boolean(outcome?.restore) };
|
|
92
|
-
// `updateBundle` 在「检查阶段就拒绝」时也可能没有 result。
|
|
93
|
-
const result = outcome?.result;
|
|
94
|
-
if (!result || typeof result !== "object") {
|
|
95
|
-
const reason = typeof result === "string" ? result : "";
|
|
96
|
-
return { ...base, ok: false, reason: HOST_MANAGER_ERROR.REJECTED, detail: reason,
|
|
97
|
-
hostErrorCode: "", nextAction: "" };
|
|
98
|
-
}
|
|
99
|
-
switch (result.application) {
|
|
100
|
-
case "applied":
|
|
101
|
-
return { ...base, ok: true, reason: "", detail: "" };
|
|
102
|
-
case "restart-required":
|
|
103
|
-
return { ...base, ok: false, reason: HOST_MANAGER_ERROR.RESTART_REQUIRED, detail: String(result.restartReason ?? ""),
|
|
104
|
-
hostErrorCode: "", nextAction: "" };
|
|
105
|
-
case "cancelled":
|
|
106
|
-
return { ...base, ok: false, reason: HOST_MANAGER_ERROR.CANCELLED, detail: "",
|
|
107
|
-
hostErrorCode: "", nextAction: "" };
|
|
108
|
-
case "overridden":
|
|
109
|
-
return { ...base, ok: false, reason: HOST_MANAGER_ERROR.OVERRIDDEN, detail: "",
|
|
110
|
-
hostErrorCode: "", nextAction: "" };
|
|
111
|
-
case "failed":
|
|
112
|
-
default: {
|
|
113
|
-
// 宿主的 error 是结构化对象(code/diagnostic);只取 code,绝不透传 diagnostic 原文
|
|
114
|
-
// (可能含 registry URL、凭据或缺路径)。
|
|
115
|
-
const code = typeof result.error?.code === "string" ? result.error.code : "";
|
|
116
|
-
return { ...base, ok: false, reason: HOST_MANAGER_ERROR.REJECTED, detail: code,
|
|
117
|
-
hostErrorCode: code, nextAction: nextActionForHostError(code) };
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* 校验目标版本可以交给宿主更新。
|
|
124
|
-
*
|
|
125
|
-
* 宿主自己也会校验(`semver.gt`),这里提前挡是为了给出**我们自己的稳定原因码**,
|
|
126
|
-
* 而不是把宿主的英文 diagnostic 抛给手机。
|
|
127
|
-
*
|
|
128
|
-
* @param {object} input
|
|
129
|
-
* @param {string} input.targetVersion - 目标版本。
|
|
130
|
-
* @param {string} input.installedVersion - 当前已安装版本。
|
|
131
|
-
* @returns {{ok: boolean, reason: string}}
|
|
132
|
-
*/
|
|
133
|
-
export function validateHostManagerTarget({ targetVersion, installedVersion } = {}) {
|
|
134
|
-
if (!parseVersion(targetVersion)) return { ok: false, reason: HOST_MANAGER_ERROR.VERSION_INVALID };
|
|
135
|
-
if (installedVersion) {
|
|
136
|
-
const comparison = compareVersion(targetVersion, installedVersion);
|
|
137
|
-
// 比较不出来时放行给宿主判定:我们的比较器只认 `X.Y.Z[-pre][+N]`,
|
|
138
|
-
// 而宿主用的是完整 semver——不因为我们的解析面更窄就误拒。
|
|
139
|
-
if (comparison !== null && comparison <= 0) {
|
|
140
|
-
return { ok: false, reason: HOST_MANAGER_ERROR.VERSION_NOT_NEWER };
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
return { ok: true, reason: "" };
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* 通过宿主插件管理器更新本插件。
|
|
148
|
-
*
|
|
149
|
-
* 执行顺序刻意固定:
|
|
150
|
-
* 1. 探测结论必须可用(`probe.channel === host-manager`),否则直接拒绝;
|
|
151
|
-
* 2. 校验目标版本;
|
|
152
|
-
* 3. 调 `updateBundle(name, version, { registry?, requestId? })`;
|
|
153
|
-
* 4. 把结果压成稳定结论。
|
|
154
|
-
*
|
|
155
|
-
* 不在这里做重试:宿主的 `updateBundle` 内部已经处理了 registry 回退与失败回滚,
|
|
156
|
-
* 我们外加一层重试只会让「已经回滚过的事」再发生一次。
|
|
157
|
-
*
|
|
158
|
-
* @param {object} input
|
|
159
|
-
* @param {object} input.service - `pluginManager` 服务实例。
|
|
160
|
-
* @param {string} input.packageName - 本插件包名。
|
|
161
|
-
* @param {string} input.targetVersion - 目标版本。
|
|
162
|
-
* @param {string} [input.installedVersion] - 当前版本(用于提前挡降级)。
|
|
163
|
-
* @param {string} [input.registry] - 指定 registry;缺省由宿主按配置决定。
|
|
164
|
-
* @param {string} [input.requestId] - 宿主用它关联进度与日志。
|
|
165
|
-
* @param {(progress: object) => void} [input.onProgress] - 宿主 `update-state` 事件的转发。
|
|
166
|
-
* @param {object} [input.log] - 结构化日志(注入以便测试)。
|
|
167
|
-
* @returns {Promise<object>} 稳定结论。
|
|
168
|
-
*/
|
|
169
|
-
export async function runHostManagerUpdate({
|
|
170
|
-
service,
|
|
171
|
-
packageName,
|
|
172
|
-
targetVersion,
|
|
173
|
-
installedVersion = "",
|
|
174
|
-
registry,
|
|
175
|
-
requestId,
|
|
176
|
-
onProgress,
|
|
177
|
-
log = {},
|
|
178
|
-
} = {}) {
|
|
179
|
-
if (!service || typeof service.updateBundle !== "function") {
|
|
180
|
-
return { ok: false, channel: UPDATE_CHANNEL.HOST_MANAGER, reason: HOST_MANAGER_REASON.SERVICE_MISSING, from: "", to: String(targetVersion ?? ""), step: "", restored: false };
|
|
181
|
-
}
|
|
182
|
-
if (typeof packageName !== "string" || packageName === "") {
|
|
183
|
-
return { ok: false, channel: UPDATE_CHANNEL.HOST_MANAGER, reason: HOST_MANAGER_REASON.NOT_UPDATABLE, from: "", to: String(targetVersion ?? ""), step: "", restored: false };
|
|
184
|
-
}
|
|
185
|
-
const validated = validateHostManagerTarget({ targetVersion, installedVersion });
|
|
186
|
-
if (!validated.ok) {
|
|
187
|
-
return { ok: false, channel: UPDATE_CHANNEL.HOST_MANAGER, reason: validated.reason, from: String(installedVersion ?? ""), to: String(targetVersion ?? ""), step: "check", restored: false };
|
|
188
|
-
}
|
|
189
|
-
const options = {};
|
|
190
|
-
// 只在调用方明确给了 registry 时才传:缺省要比「传 undefined」更明确地走宿主配置。
|
|
191
|
-
if (typeof registry === "string" && registry !== "") options.registry = registry;
|
|
192
|
-
if (typeof requestId === "string" && requestId !== "") options.requestId = requestId;
|
|
193
|
-
let outcome;
|
|
194
|
-
try {
|
|
195
|
-
log.stage?.("host-manager", `Updating ${packageName} to ${targetVersion} through the host plugin manager`);
|
|
196
|
-
outcome = await service.updateBundle(packageName, targetVersion, Object.keys(options).length > 0 ? options : undefined);
|
|
197
|
-
} catch (error) {
|
|
198
|
-
// 宿主在锁超时/服务销毁时是 reject 而不是返回失败结果;这仍然是一次失败结论。
|
|
199
|
-
log.fail?.("host-manager", "Host plugin manager update call rejected");
|
|
200
|
-
return {
|
|
201
|
-
ok: false,
|
|
202
|
-
channel: UPDATE_CHANNEL.HOST_MANAGER,
|
|
203
|
-
reason: HOST_MANAGER_ERROR.CALL_FAILED,
|
|
204
|
-
from: String(installedVersion ?? ""),
|
|
205
|
-
to: String(targetVersion ?? ""),
|
|
206
|
-
step: "",
|
|
207
|
-
restored: false,
|
|
208
|
-
detail: typeof error?.code === "string" ? error.code : "",
|
|
209
|
-
hostErrorCode: typeof error?.code === "string" ? error.code : "",
|
|
210
|
-
nextAction: nextActionForHostError(typeof error?.code === "string" ? error.code : ""),
|
|
211
|
-
};
|
|
212
|
-
}
|
|
213
|
-
const interpreted = interpretHostManagerUpdate(outcome);
|
|
214
|
-
if (typeof onProgress === "function") {
|
|
215
|
-
try {
|
|
216
|
-
onProgress({ step: interpreted.step, from: interpreted.from, to: interpreted.to });
|
|
217
|
-
} catch {
|
|
218
|
-
// 进度回调不应影响更新结论
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
return { ...interpreted, channel: UPDATE_CHANNEL.HOST_MANAGER };
|
|
222
|
-
}
|
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
// 宿主「原生插件更新」能力探测(DSH 0.2.2+ 的 `pluginManager` 服务)。
|
|
2
|
-
//
|
|
3
|
-
// 背景:0.2.2 起 DSH 自带插件管理器(`@deepseek-ai/dsh-plugin-manager`),它把
|
|
4
|
-
// 「装/删/更新插件」做成了宿主内的服务方法,并且 **在 HMR 可用时不重启宿主**:
|
|
5
|
-
// `updateBundle()` 会先移除旧版本、再装新版本,由 `hmr.reconcileProfile()` 在进程内
|
|
6
|
-
// 重新组合 profile——插件被卸载并重新加载,宿主进程不变。
|
|
7
|
-
//
|
|
8
|
-
// 我们的自更新原先只会「改 profile 依赖 → pnpm install → 重启宿主」这一条路;当宿主
|
|
9
|
-
// 形态判断不出可重启方式(例如容器里没有 systemd、进程环境没有 DSH_PROFILE)时,
|
|
10
|
-
// 就整条降级成「请到电脑上运行 pnpm install」的手工指引。有了宿主原生能力后,
|
|
11
|
-
// 那种情形可以直接委托给宿主,彻底不需要重启,也不需要用户碰命令行。
|
|
12
|
-
//
|
|
13
|
-
// 本模块只做**探测**与**能力描述**,不执行更新(执行在 plugin-self-update.js)。
|
|
14
|
-
|
|
15
|
-
/** 更新执行通道。 */
|
|
16
|
-
export const UPDATE_CHANNEL = {
|
|
17
|
-
/** 委托宿主 `pluginManager.updateBundle()`:进程内热更新,不重启。 */
|
|
18
|
-
HOST_MANAGER: "host-manager",
|
|
19
|
-
/** 传统通道:改 profile 依赖 → pnpm install → 重启宿主并做健康确认。 */
|
|
20
|
-
RESTART: "restart",
|
|
21
|
-
/** 两者都不可用,只能给人工指引。 */
|
|
22
|
-
GUIDANCE: "guidance",
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
/** 宿主管理器不可用的稳定原因码(对外只暴露这几类,不含内部异常原文)。 */
|
|
26
|
-
export const HOST_MANAGER_REASON = {
|
|
27
|
-
/** 宿主没有 `pluginManager` 服务(0.2.2 之前,或该 bundle 未启用)。 */
|
|
28
|
-
SERVICE_MISSING: "host-manager-service-missing",
|
|
29
|
-
/** 服务存在但没有 `updateBundle` 方法(接口被裁剪/版本不符)。 */
|
|
30
|
-
METHOD_MISSING: "host-manager-method-missing",
|
|
31
|
-
/** 宿主没报告 HMR:更新仍可安装,但结果要重启才生效。 */
|
|
32
|
-
HMR_MISSING: "host-manager-hmr-missing",
|
|
33
|
-
/** 当前安装不是「以自身包名从 registry 装的 profile 依赖」,宿主会拒绝更新。 */
|
|
34
|
-
NOT_UPDATABLE: "host-manager-not-updatable",
|
|
35
|
-
/** 探测过程抛错。 */
|
|
36
|
-
PROBE_FAILED: "host-manager-probe-failed",
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
/** 探测结果的稳定状态。 */
|
|
40
|
-
export const HOST_MANAGER_STATE = {
|
|
41
|
-
/** 可用且能免重启生效。 */
|
|
42
|
-
READY: "ready",
|
|
43
|
-
/** 可用,但生效需要重启(无 HMR)。 */
|
|
44
|
-
RESTART_REQUIRED: "restart-required",
|
|
45
|
-
/** 不可用。 */
|
|
46
|
-
UNSUPPORTED: "unsupported",
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* 读 `pluginManager` 服务。
|
|
51
|
-
*
|
|
52
|
-
* 探测顺序刻意保守:先拿服务(`ctx.get('pluginManager')`),再确认 `updateBundle`
|
|
53
|
-
* 是可调用函数。**不看版本号**——版本号无法证明该服务真的挂在当前 profile 上
|
|
54
|
-
* (ADR 0017:能力看声明,不看版本号)。任何异常都收敛成 unsupported,不向上抛。
|
|
55
|
-
*
|
|
56
|
-
* @param {object} ctx - cordis 上下文。
|
|
57
|
-
* @returns {{available: boolean, reason: string, service: object|null}}
|
|
58
|
-
*/
|
|
59
|
-
export function probeHostPluginManager(ctx) {
|
|
60
|
-
let service;
|
|
61
|
-
try {
|
|
62
|
-
service = ctx?.get?.("pluginManager");
|
|
63
|
-
} catch {
|
|
64
|
-
return { available: false, reason: HOST_MANAGER_REASON.PROBE_FAILED, service: null };
|
|
65
|
-
}
|
|
66
|
-
if (!service || typeof service !== "object") {
|
|
67
|
-
return { available: false, reason: HOST_MANAGER_REASON.SERVICE_MISSING, service: null };
|
|
68
|
-
}
|
|
69
|
-
if (typeof service.updateBundle !== "function") {
|
|
70
|
-
return { available: false, reason: HOST_MANAGER_REASON.METHOD_MISSING, service };
|
|
71
|
-
}
|
|
72
|
-
return { available: true, reason: "", service };
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* 宿主是否报告 HMR(决定更新结果能否免重启生效)。
|
|
77
|
-
*
|
|
78
|
-
* `pluginManager.updateBundle` 在没有 HMR 时照样能装,只是返回
|
|
79
|
-
* `application: 'restart-required'`。这里单独探测,是为了在**开始更新之前**
|
|
80
|
-
* 就告诉用户「这次会重启」还是「这次不重启」,而不是等装完再报。
|
|
81
|
-
*
|
|
82
|
-
* @param {object} ctx - cordis 上下文。
|
|
83
|
-
* @returns {{available: boolean, reason: string}}
|
|
84
|
-
*/
|
|
85
|
-
export function probeHostHmr(ctx) {
|
|
86
|
-
let hmr;
|
|
87
|
-
try {
|
|
88
|
-
hmr = ctx?.get?.("hmr");
|
|
89
|
-
} catch {
|
|
90
|
-
return { available: false, reason: HOST_MANAGER_REASON.PROBE_FAILED };
|
|
91
|
-
}
|
|
92
|
-
if (!hmr || typeof hmr !== "object" || typeof hmr.reconcileProfile !== "function") {
|
|
93
|
-
return { available: false, reason: HOST_MANAGER_REASON.HMR_MISSING };
|
|
94
|
-
}
|
|
95
|
-
return { available: true, reason: "" };
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* 由 bundle 视图判断宿主会不会接受这次更新。
|
|
100
|
-
*
|
|
101
|
-
* `updateBundle` 的准入是(见 dsh-plugin-manager 的 `updateRefusal`):
|
|
102
|
-
* 必须是 profile 里的第三方依赖、从 registry 以**自身包名**安装、声明 semver 版本、
|
|
103
|
-
* 不带插件管理职责。`listBundles()` 已经把结论投影成 `updatable` 与
|
|
104
|
-
* `readOnlyReason`,这里直接采信,不重复实现那套判据。
|
|
105
|
-
*
|
|
106
|
-
* @param {object|undefined} bundle - `listBundles()` 里对应本插件的一行。
|
|
107
|
-
* @returns {{ok: boolean, reason: string}}
|
|
108
|
-
*/
|
|
109
|
-
export function hostManagerAcceptsBundle(bundle) {
|
|
110
|
-
if (!bundle || typeof bundle !== "object") {
|
|
111
|
-
return { ok: false, reason: HOST_MANAGER_REASON.NOT_UPDATABLE };
|
|
112
|
-
}
|
|
113
|
-
// DSH 0.2.2-rc.1:`updatable: boolean`;rc.2:`update?: 'registry' | 'git'`,
|
|
114
|
-
// 不再提供 updatable。两种行契约都接受,否则 rc.2 会静默降级到重启通道。
|
|
115
|
-
// 有 rc.2 的 update 字段时以它为准;只有旧行才看 updatable,避免两字段冲突时误放行。
|
|
116
|
-
const updatable = bundle.update !== undefined
|
|
117
|
-
? (bundle.update === "registry" || bundle.update === "git")
|
|
118
|
-
: bundle.updatable === true;
|
|
119
|
-
if (!updatable) {
|
|
120
|
-
return { ok: false, reason: HOST_MANAGER_REASON.NOT_UPDATABLE };
|
|
121
|
-
}
|
|
122
|
-
if (bundle.readOnlyReason !== undefined) {
|
|
123
|
-
return { ok: false, reason: HOST_MANAGER_REASON.NOT_UPDATABLE };
|
|
124
|
-
}
|
|
125
|
-
return { ok: true, reason: "" };
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* 汇总一次探测的结果:宿主管理器可用性 + HMR + 本插件是否可被它更新。
|
|
130
|
-
*
|
|
131
|
-
* 返回的 `channel` 是本进程**应该优先使用**的更新通道;调用方还要结合传统重启通道
|
|
132
|
-
* 是否可用再决定最终通道(见 {@link chooseUpdateChannel})。
|
|
133
|
-
*
|
|
134
|
-
* @param {object} input
|
|
135
|
-
* @param {object} input.ctx - cordis 上下文。
|
|
136
|
-
* @param {string} input.packageName - 本插件包名。
|
|
137
|
-
* @param {(name: string) => Promise<object[]>} [input.listBundles] - 宿主 `listBundles()`;缺省用服务自己的方法。
|
|
138
|
-
* @returns {Promise<object>} 探测结果(稳定字段,可直接进 bootstrap)。
|
|
139
|
-
*/
|
|
140
|
-
export async function detectHostUpdateCapabilities({ ctx, packageName, listBundles } = {}) {
|
|
141
|
-
const manager = probeHostPluginManager(ctx);
|
|
142
|
-
const hmr = probeHostHmr(ctx);
|
|
143
|
-
const base = {
|
|
144
|
-
packageName: typeof packageName === "string" ? packageName : "",
|
|
145
|
-
managerAvailable: manager.available,
|
|
146
|
-
managerReason: manager.reason,
|
|
147
|
-
hmrAvailable: hmr.available,
|
|
148
|
-
hmrReason: hmr.reason,
|
|
149
|
-
updatable: false,
|
|
150
|
-
state: HOST_MANAGER_STATE.UNSUPPORTED,
|
|
151
|
-
channel: UPDATE_CHANNEL.GUIDANCE,
|
|
152
|
-
};
|
|
153
|
-
if (!manager.available) return base;
|
|
154
|
-
const service = manager.service;
|
|
155
|
-
let bundle;
|
|
156
|
-
try {
|
|
157
|
-
const list = typeof listBundles === "function" ? listBundles : service.listBundles;
|
|
158
|
-
const bundles = await list.call(service);
|
|
159
|
-
bundle = Array.isArray(bundles) ? bundles.find((item) => item?.name === base.packageName) : undefined;
|
|
160
|
-
} catch {
|
|
161
|
-
return { ...base, managerReason: HOST_MANAGER_REASON.PROBE_FAILED };
|
|
162
|
-
}
|
|
163
|
-
const accepts = hostManagerAcceptsBundle(bundle);
|
|
164
|
-
if (!accepts.ok) {
|
|
165
|
-
return { ...base, managerReason: accepts.reason, installedVersion: bundle?.version ?? "" };
|
|
166
|
-
}
|
|
167
|
-
return {
|
|
168
|
-
...base,
|
|
169
|
-
updatable: true,
|
|
170
|
-
state: hmr.available ? HOST_MANAGER_STATE.READY : HOST_MANAGER_STATE.RESTART_REQUIRED,
|
|
171
|
-
channel: UPDATE_CHANNEL.HOST_MANAGER,
|
|
172
|
-
installedVersion: bundle?.version ?? "",
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
/**
|
|
177
|
-
* 在「宿主原生免重启更新」与「传统重启更新」之间选通道。
|
|
178
|
-
*
|
|
179
|
-
* 规则(顺序即优先级):
|
|
180
|
-
* 1. 宿主管理器可用 → 用它(免重启,且不依赖我们能重启宿主)。
|
|
181
|
-
* 2. 否则传统重启通道可用(systemd / 前台 web)→ 用重启。
|
|
182
|
-
* 3. 都不行 → 人工指引。
|
|
183
|
-
*
|
|
184
|
-
* 注意第 1 条**不看** `hmrAvailable`:没有 HMR 时宿主管理器仍会把包装好,
|
|
185
|
-
* 只是返回 `restart-required`。这种情形仍优先走管理器——它至少保证了
|
|
186
|
-
* 「依赖真的被装上了」,比我们自己 `pnpm install` 更可靠;重启由宿主报告为准。
|
|
187
|
-
*
|
|
188
|
-
* @param {object} input
|
|
189
|
-
* @param {boolean} input.hostManagerAvailable - 宿主管理器是否可用(且本插件可被它更新)。
|
|
190
|
-
* @param {boolean} input.canRestart - 传统重启通道是否可用。
|
|
191
|
-
* @returns {{channel: string, reason: string}}
|
|
192
|
-
*/
|
|
193
|
-
export function chooseUpdateChannel({ hostManagerAvailable = false, canRestart = false } = {}) {
|
|
194
|
-
if (hostManagerAvailable) return { channel: UPDATE_CHANNEL.HOST_MANAGER, reason: "" };
|
|
195
|
-
if (canRestart) return { channel: UPDATE_CHANNEL.RESTART, reason: "" };
|
|
196
|
-
return { channel: UPDATE_CHANNEL.GUIDANCE, reason: "no-update-channel" };
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
/** 通道 → 面向用户的一句话说明(手机与桌面共用,避免两端文案漂移)。 */
|
|
200
|
-
export function describeUpdateChannel(channel) {
|
|
201
|
-
switch (channel) {
|
|
202
|
-
case UPDATE_CHANNEL.HOST_MANAGER:
|
|
203
|
-
return "由 DSH 插件管理器在进程内更新,无需重启宿主";
|
|
204
|
-
case UPDATE_CHANNEL.RESTART:
|
|
205
|
-
return "安装新版本后重启宿主使插件生效";
|
|
206
|
-
default:
|
|
207
|
-
return "当前形态无法自动更新,需要人工处理";
|
|
208
|
-
}
|
|
209
|
-
}
|