@marktrue/dsh-mobile-remote 3.2.4-alpha.2-app → 3.2.4-alpha.2
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/CHANGELOG.md +1427 -0
- package/CONTRIBUTING.md +59 -0
- package/FAQ.md +111 -0
- package/README.md +254 -6
- package/cordis.patch.yml +14 -0
- package/docs/00-/345/274/200/345/217/221/346/200/273/347/272/262.md +125 -0
- package/docs/01-PRD.md +148 -0
- package/docs/02-architecture.md +249 -0
- package/docs/03-api.md +1154 -0
- package/docs/04-security.md +100 -0
- package/docs/05-test-cases.md +405 -0
- package/docs/06-install-run.md +372 -0
- package/docs/07-user-manual.md +70 -0
- package/docs/08-/346/211/251/345/261/225/345/274/200/345/217/221/346/214/207/345/215/227.md +86 -0
- package/docs/09-compatibility.md +227 -0
- package/docs/10-release.md +1067 -0
- 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 +145 -0
- package/lib/app-alignment.js +112 -0
- package/lib/app-carrier-store.js +1972 -0
- package/lib/app-carrier.js +609 -0
- package/lib/client.js +1174 -0
- package/lib/desktop-form.js +738 -0
- package/lib/endpoint-registry.js +167 -0
- package/lib/git-read-bundled-provider.js +450 -0
- package/lib/git-read-service.js +601 -0
- package/lib/index.js +9622 -0
- package/lib/npm-update-source.js +226 -0
- package/lib/plugin-content-digest.js +80 -0
- package/lib/plugin-self-update.js +997 -0
- package/lib/plugin-update-controller.js +274 -0
- package/lib/plugin-update-log.js +164 -0
- package/lib/plugin-update-transaction.js +322 -0
- package/lib/plugin-update.js +309 -0
- package/lib/runtime-dependency-snapshot.js +345 -0
- package/lib/session-title-cache.js +123 -0
- package/lib/session-title-refresh.js +261 -0
- package/lib/tool-process.js +20 -0
- package/lib/update-fetch.js +24 -0
- package/lib/update-lock-arbiter.js +170 -0
- package/lib/update-supervisor.js +346 -0
- package/node_modules/ansi-regex/index.d.ts +37 -0
- package/node_modules/ansi-regex/index.js +10 -0
- package/node_modules/ansi-regex/license +9 -0
- package/node_modules/ansi-regex/package.json +55 -0
- package/node_modules/ansi-regex/readme.md +78 -0
- package/node_modules/ansi-styles/index.d.ts +345 -0
- package/node_modules/ansi-styles/index.js +163 -0
- package/node_modules/ansi-styles/license +9 -0
- package/node_modules/ansi-styles/package.json +56 -0
- package/node_modules/ansi-styles/readme.md +152 -0
- package/node_modules/camelcase/index.d.ts +63 -0
- package/node_modules/camelcase/index.js +76 -0
- package/node_modules/camelcase/license +9 -0
- package/node_modules/camelcase/package.json +43 -0
- package/node_modules/camelcase/readme.md +99 -0
- package/node_modules/cliui/CHANGELOG.md +76 -0
- package/node_modules/cliui/LICENSE.txt +14 -0
- package/node_modules/cliui/README.md +115 -0
- package/node_modules/cliui/index.js +354 -0
- package/node_modules/cliui/package.json +65 -0
- package/node_modules/color-convert/CHANGELOG.md +54 -0
- package/node_modules/color-convert/LICENSE +21 -0
- package/node_modules/color-convert/README.md +68 -0
- package/node_modules/color-convert/conversions.js +839 -0
- package/node_modules/color-convert/index.js +81 -0
- package/node_modules/color-convert/package.json +48 -0
- package/node_modules/color-convert/route.js +97 -0
- package/node_modules/color-name/LICENSE +8 -0
- package/node_modules/color-name/README.md +11 -0
- package/node_modules/color-name/index.js +152 -0
- package/node_modules/color-name/package.json +28 -0
- package/node_modules/decamelize/index.js +13 -0
- package/node_modules/decamelize/license +21 -0
- package/node_modules/decamelize/package.json +38 -0
- package/node_modules/decamelize/readme.md +48 -0
- package/node_modules/dijkstrajs/.travis.yml +4 -0
- package/node_modules/dijkstrajs/CONTRIBUTING.md +8 -0
- package/node_modules/dijkstrajs/LICENSE.md +19 -0
- package/node_modules/dijkstrajs/README.md +18 -0
- package/node_modules/dijkstrajs/dijkstra.js +165 -0
- package/node_modules/dijkstrajs/package.json +60 -0
- package/node_modules/dijkstrajs/test/dijkstra.test.js +96 -0
- package/node_modules/emoji-regex/LICENSE-MIT.txt +20 -0
- package/node_modules/emoji-regex/README.md +73 -0
- package/node_modules/emoji-regex/es2015/index.js +6 -0
- package/node_modules/emoji-regex/es2015/text.js +6 -0
- package/node_modules/emoji-regex/index.d.ts +23 -0
- package/node_modules/emoji-regex/index.js +6 -0
- package/node_modules/emoji-regex/package.json +50 -0
- package/node_modules/emoji-regex/text.js +6 -0
- package/node_modules/find-up/index.d.ts +137 -0
- package/node_modules/find-up/index.js +89 -0
- package/node_modules/find-up/license +9 -0
- package/node_modules/find-up/package.json +53 -0
- package/node_modules/find-up/readme.md +156 -0
- package/node_modules/get-caller-file/LICENSE.md +6 -0
- package/node_modules/get-caller-file/README.md +41 -0
- package/node_modules/get-caller-file/index.d.ts +2 -0
- package/node_modules/get-caller-file/index.js +22 -0
- package/node_modules/get-caller-file/index.js.map +1 -0
- package/node_modules/get-caller-file/package.json +42 -0
- package/node_modules/is-fullwidth-code-point/index.d.ts +17 -0
- package/node_modules/is-fullwidth-code-point/index.js +50 -0
- package/node_modules/is-fullwidth-code-point/license +9 -0
- package/node_modules/is-fullwidth-code-point/package.json +42 -0
- package/node_modules/is-fullwidth-code-point/readme.md +39 -0
- package/node_modules/locate-path/index.d.ts +83 -0
- package/node_modules/locate-path/index.js +65 -0
- package/node_modules/locate-path/license +9 -0
- package/node_modules/locate-path/package.json +45 -0
- package/node_modules/locate-path/readme.md +122 -0
- package/node_modules/p-limit/index.d.ts +38 -0
- package/node_modules/p-limit/index.js +57 -0
- package/node_modules/p-limit/license +9 -0
- package/node_modules/p-limit/package.json +52 -0
- package/node_modules/p-limit/readme.md +101 -0
- package/node_modules/p-locate/index.d.ts +64 -0
- package/node_modules/p-locate/index.js +52 -0
- package/node_modules/p-locate/license +9 -0
- package/node_modules/p-locate/package.json +53 -0
- package/node_modules/p-locate/readme.md +90 -0
- package/node_modules/p-try/index.d.ts +39 -0
- package/node_modules/p-try/index.js +9 -0
- package/node_modules/p-try/license +9 -0
- package/node_modules/p-try/package.json +42 -0
- package/node_modules/p-try/readme.md +58 -0
- package/node_modules/path-exists/index.d.ts +28 -0
- package/node_modules/path-exists/index.js +23 -0
- package/node_modules/path-exists/license +9 -0
- package/node_modules/path-exists/package.json +39 -0
- package/node_modules/path-exists/readme.md +52 -0
- package/node_modules/pngjs/.eslintignore +2 -0
- package/node_modules/pngjs/.eslintrc.json +19 -0
- package/node_modules/pngjs/.prettierignore +3 -0
- package/node_modules/pngjs/LICENSE +20 -0
- package/node_modules/pngjs/README.md +429 -0
- package/node_modules/pngjs/browser.js +16096 -0
- package/node_modules/pngjs/coverage/lcov-report/base.css +354 -0
- package/node_modules/pngjs/coverage/lcov-report/bitmapper.js.html +881 -0
- package/node_modules/pngjs/coverage/lcov-report/bitpacker.js.html +554 -0
- package/node_modules/pngjs/coverage/lcov-report/block-navigation.js +77 -0
- package/node_modules/pngjs/coverage/lcov-report/chunkstream.js.html +647 -0
- package/node_modules/pngjs/coverage/lcov-report/constants.js.html +176 -0
- package/node_modules/pngjs/coverage/lcov-report/crc.js.html +200 -0
- package/node_modules/pngjs/coverage/lcov-report/favicon.png +0 -0
- package/node_modules/pngjs/coverage/lcov-report/filter-pack.js.html +593 -0
- package/node_modules/pngjs/coverage/lcov-report/filter-parse-async.js.html +152 -0
- package/node_modules/pngjs/coverage/lcov-report/filter-parse-sync.js.html +143 -0
- package/node_modules/pngjs/coverage/lcov-report/filter-parse.js.html +611 -0
- package/node_modules/pngjs/coverage/lcov-report/format-normaliser.js.html +359 -0
- package/node_modules/pngjs/coverage/lcov-report/index.html +426 -0
- package/node_modules/pngjs/coverage/lcov-report/interlace.js.html +365 -0
- package/node_modules/pngjs/coverage/lcov-report/packer-async.js.html +230 -0
- package/node_modules/pngjs/coverage/lcov-report/packer-sync.js.html +248 -0
- package/node_modules/pngjs/coverage/lcov-report/packer.js.html +467 -0
- package/node_modules/pngjs/coverage/lcov-report/paeth-predictor.js.html +128 -0
- package/node_modules/pngjs/coverage/lcov-report/parser-async.js.html +575 -0
- package/node_modules/pngjs/coverage/lcov-report/parser-sync.js.html +404 -0
- package/node_modules/pngjs/coverage/lcov-report/parser.js.html +950 -0
- package/node_modules/pngjs/coverage/lcov-report/png-sync.js.html +116 -0
- package/node_modules/pngjs/coverage/lcov-report/png.js.html +662 -0
- package/node_modules/pngjs/coverage/lcov-report/prettify.css +101 -0
- package/node_modules/pngjs/coverage/lcov-report/prettify.js +1007 -0
- package/node_modules/pngjs/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/node_modules/pngjs/coverage/lcov-report/sorter.js +169 -0
- package/node_modules/pngjs/coverage/lcov-report/sync-inflate.js.html +584 -0
- package/node_modules/pngjs/coverage/lcov-report/sync-reader.js.html +215 -0
- package/node_modules/pngjs/coverage/lcov.info +2177 -0
- package/node_modules/pngjs/lib/bitmapper.js +267 -0
- package/node_modules/pngjs/lib/bitpacker.js +158 -0
- package/node_modules/pngjs/lib/chunkstream.js +189 -0
- package/node_modules/pngjs/lib/constants.js +32 -0
- package/node_modules/pngjs/lib/crc.js +40 -0
- package/node_modules/pngjs/lib/filter-pack.js +171 -0
- package/node_modules/pngjs/lib/filter-parse-async.js +24 -0
- package/node_modules/pngjs/lib/filter-parse-sync.js +21 -0
- package/node_modules/pngjs/lib/filter-parse.js +177 -0
- package/node_modules/pngjs/lib/format-normaliser.js +93 -0
- package/node_modules/pngjs/lib/interlace.js +95 -0
- package/node_modules/pngjs/lib/packer-async.js +50 -0
- package/node_modules/pngjs/lib/packer-sync.js +56 -0
- package/node_modules/pngjs/lib/packer.js +129 -0
- package/node_modules/pngjs/lib/paeth-predictor.js +16 -0
- package/node_modules/pngjs/lib/parser-async.js +165 -0
- package/node_modules/pngjs/lib/parser-sync.js +108 -0
- package/node_modules/pngjs/lib/parser.js +290 -0
- package/node_modules/pngjs/lib/png-sync.js +12 -0
- package/node_modules/pngjs/lib/png.js +194 -0
- package/node_modules/pngjs/lib/sync-inflate.js +168 -0
- package/node_modules/pngjs/lib/sync-reader.js +45 -0
- package/node_modules/pngjs/package.json +73 -0
- package/node_modules/qrcode/README.md +770 -0
- package/node_modules/qrcode/bin/qrcode +159 -0
- package/node_modules/qrcode/helper/to-sjis-browser.js +2 -0
- package/node_modules/qrcode/helper/to-sjis.js +105 -0
- package/node_modules/qrcode/lib/browser.js +76 -0
- package/node_modules/qrcode/lib/can-promise.js +7 -0
- package/node_modules/qrcode/lib/core/alignment-pattern.js +83 -0
- package/node_modules/qrcode/lib/core/alphanumeric-data.js +59 -0
- package/node_modules/qrcode/lib/core/bit-buffer.js +37 -0
- package/node_modules/qrcode/lib/core/bit-matrix.js +65 -0
- package/node_modules/qrcode/lib/core/byte-data.js +30 -0
- package/node_modules/qrcode/lib/core/error-correction-code.js +135 -0
- package/node_modules/qrcode/lib/core/error-correction-level.js +50 -0
- package/node_modules/qrcode/lib/core/finder-pattern.js +22 -0
- package/node_modules/qrcode/lib/core/format-info.js +29 -0
- package/node_modules/qrcode/lib/core/galois-field.js +69 -0
- package/node_modules/qrcode/lib/core/kanji-data.js +54 -0
- package/node_modules/qrcode/lib/core/mask-pattern.js +234 -0
- package/node_modules/qrcode/lib/core/mode.js +167 -0
- package/node_modules/qrcode/lib/core/numeric-data.js +43 -0
- package/node_modules/qrcode/lib/core/polynomial.js +62 -0
- package/node_modules/qrcode/lib/core/qrcode.js +495 -0
- package/node_modules/qrcode/lib/core/reed-solomon-encoder.js +56 -0
- package/node_modules/qrcode/lib/core/regex.js +31 -0
- package/node_modules/qrcode/lib/core/segments.js +330 -0
- package/node_modules/qrcode/lib/core/utils.js +63 -0
- package/node_modules/qrcode/lib/core/version-check.js +9 -0
- package/node_modules/qrcode/lib/core/version.js +163 -0
- package/node_modules/qrcode/lib/index.js +12 -0
- package/node_modules/qrcode/lib/renderer/canvas.js +63 -0
- package/node_modules/qrcode/lib/renderer/png.js +78 -0
- package/node_modules/qrcode/lib/renderer/svg-tag.js +81 -0
- package/node_modules/qrcode/lib/renderer/svg.js +19 -0
- package/node_modules/qrcode/lib/renderer/terminal/terminal-small.js +85 -0
- package/node_modules/qrcode/lib/renderer/terminal/terminal.js +49 -0
- package/node_modules/qrcode/lib/renderer/terminal.js +9 -0
- package/node_modules/qrcode/lib/renderer/utf8.js +71 -0
- package/node_modules/qrcode/lib/renderer/utils.js +99 -0
- package/node_modules/qrcode/lib/server.js +138 -0
- package/node_modules/qrcode/license +10 -0
- package/node_modules/qrcode/package.json +77 -0
- package/node_modules/require-directory/.jshintrc +67 -0
- package/node_modules/require-directory/.npmignore +1 -0
- package/node_modules/require-directory/.travis.yml +3 -0
- package/node_modules/require-directory/LICENSE +22 -0
- package/node_modules/require-directory/README.markdown +184 -0
- package/node_modules/require-directory/index.js +86 -0
- package/node_modules/require-directory/package.json +40 -0
- package/node_modules/require-main-filename/CHANGELOG.md +26 -0
- package/node_modules/require-main-filename/LICENSE.txt +14 -0
- package/node_modules/require-main-filename/README.md +26 -0
- package/node_modules/require-main-filename/index.js +18 -0
- package/node_modules/require-main-filename/package.json +35 -0
- package/node_modules/set-blocking/CHANGELOG.md +26 -0
- package/node_modules/set-blocking/LICENSE.txt +14 -0
- package/node_modules/set-blocking/README.md +31 -0
- package/node_modules/set-blocking/index.js +7 -0
- package/node_modules/set-blocking/package.json +42 -0
- package/node_modules/string-width/index.d.ts +29 -0
- package/node_modules/string-width/index.js +47 -0
- package/node_modules/string-width/license +9 -0
- package/node_modules/string-width/package.json +56 -0
- package/node_modules/string-width/readme.md +50 -0
- package/node_modules/strip-ansi/index.d.ts +17 -0
- package/node_modules/strip-ansi/index.js +4 -0
- package/node_modules/strip-ansi/license +9 -0
- package/node_modules/strip-ansi/package.json +54 -0
- package/node_modules/strip-ansi/readme.md +46 -0
- package/node_modules/which-module/LICENSE +13 -0
- package/node_modules/which-module/README.md +58 -0
- package/node_modules/which-module/index.js +9 -0
- package/node_modules/which-module/package.json +41 -0
- package/node_modules/wrap-ansi/index.js +186 -0
- package/node_modules/wrap-ansi/license +9 -0
- package/node_modules/wrap-ansi/package.json +61 -0
- package/node_modules/wrap-ansi/readme.md +97 -0
- package/node_modules/y18n/CHANGELOG.md +35 -0
- package/node_modules/y18n/LICENSE +13 -0
- package/node_modules/y18n/README.md +109 -0
- package/node_modules/y18n/index.js +188 -0
- package/node_modules/y18n/package.json +39 -0
- package/node_modules/yargs/CHANGELOG.md +420 -0
- package/node_modules/yargs/LICENSE +21 -0
- package/node_modules/yargs/README.md +140 -0
- package/node_modules/yargs/build/lib/apply-extends.d.ts +2 -0
- package/node_modules/yargs/build/lib/apply-extends.js +65 -0
- package/node_modules/yargs/build/lib/argsert.d.ts +2 -0
- package/node_modules/yargs/build/lib/argsert.js +65 -0
- package/node_modules/yargs/build/lib/command.d.ts +64 -0
- package/node_modules/yargs/build/lib/command.js +416 -0
- package/node_modules/yargs/build/lib/common-types.d.ts +36 -0
- package/node_modules/yargs/build/lib/common-types.js +25 -0
- package/node_modules/yargs/build/lib/completion-templates.d.ts +2 -0
- package/node_modules/yargs/build/lib/completion-templates.js +50 -0
- package/node_modules/yargs/build/lib/completion.d.ts +21 -0
- package/node_modules/yargs/build/lib/completion.js +135 -0
- package/node_modules/yargs/build/lib/is-promise.d.ts +1 -0
- package/node_modules/yargs/build/lib/is-promise.js +9 -0
- package/node_modules/yargs/build/lib/levenshtein.d.ts +1 -0
- package/node_modules/yargs/build/lib/levenshtein.js +58 -0
- package/node_modules/yargs/build/lib/middleware.d.ts +10 -0
- package/node_modules/yargs/build/lib/middleware.js +57 -0
- package/node_modules/yargs/build/lib/obj-filter.d.ts +1 -0
- package/node_modules/yargs/build/lib/obj-filter.js +14 -0
- package/node_modules/yargs/build/lib/parse-command.d.ts +11 -0
- package/node_modules/yargs/build/lib/parse-command.js +36 -0
- package/node_modules/yargs/build/lib/process-argv.d.ts +2 -0
- package/node_modules/yargs/build/lib/process-argv.js +31 -0
- package/node_modules/yargs/build/lib/usage.d.ts +49 -0
- package/node_modules/yargs/build/lib/usage.js +540 -0
- package/node_modules/yargs/build/lib/validation.d.ts +34 -0
- package/node_modules/yargs/build/lib/validation.js +330 -0
- package/node_modules/yargs/build/lib/yargs.d.ts +274 -0
- package/node_modules/yargs/build/lib/yargs.js +1190 -0
- package/node_modules/yargs/build/lib/yerror.d.ts +4 -0
- package/node_modules/yargs/build/lib/yerror.js +11 -0
- package/node_modules/yargs/index.js +40 -0
- package/node_modules/yargs/locales/be.json +46 -0
- package/node_modules/yargs/locales/de.json +46 -0
- package/node_modules/yargs/locales/en.json +51 -0
- package/node_modules/yargs/locales/es.json +46 -0
- package/node_modules/yargs/locales/fi.json +49 -0
- package/node_modules/yargs/locales/fr.json +53 -0
- package/node_modules/yargs/locales/hi.json +49 -0
- package/node_modules/yargs/locales/hu.json +46 -0
- package/node_modules/yargs/locales/id.json +50 -0
- package/node_modules/yargs/locales/it.json +46 -0
- package/node_modules/yargs/locales/ja.json +51 -0
- package/node_modules/yargs/locales/ko.json +49 -0
- package/node_modules/yargs/locales/nb.json +44 -0
- package/node_modules/yargs/locales/nl.json +49 -0
- package/node_modules/yargs/locales/nn.json +44 -0
- package/node_modules/yargs/locales/pirate.json +13 -0
- package/node_modules/yargs/locales/pl.json +49 -0
- package/node_modules/yargs/locales/pt.json +45 -0
- package/node_modules/yargs/locales/pt_BR.json +48 -0
- package/node_modules/yargs/locales/ru.json +46 -0
- package/node_modules/yargs/locales/th.json +46 -0
- package/node_modules/yargs/locales/tr.json +48 -0
- package/node_modules/yargs/locales/zh_CN.json +48 -0
- package/node_modules/yargs/locales/zh_TW.json +47 -0
- package/node_modules/yargs/package.json +92 -0
- package/node_modules/yargs/yargs.js +14 -0
- package/node_modules/yargs-parser/CHANGELOG.md +601 -0
- package/node_modules/yargs-parser/LICENSE.txt +14 -0
- package/node_modules/yargs-parser/README.md +449 -0
- package/node_modules/yargs-parser/index.js +1032 -0
- package/node_modules/yargs-parser/lib/tokenize-arg-string.js +40 -0
- package/node_modules/yargs-parser/package.json +46 -0
- package/package.json +65 -12
- package/DSH-Remote-v3.2.4.apk +0 -4
- package/manifest.json +0 -21
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
import { appCarrierAlias, appCarrierVersion } from "./app-carrier.js";
|
|
3
|
+
import { parseVersion } from "./plugin-update.js";
|
|
4
|
+
import { shellOptions } from "./tool-process.js";
|
|
5
|
+
|
|
6
|
+
const SRI_PATTERN = /^sha(?:256|384|512)-[A-Za-z0-9+/]+={0,2}$/;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Stable package follows latest; 预发布跟随其自身的通道(alpha / rc)。
|
|
10
|
+
* 例:3.2.2-alpha.15 查 alpha,3.2.2-rc.1 查 rc;绝不把预发布塞给 latest。
|
|
11
|
+
*/
|
|
12
|
+
export function npmUpdateChannel(localVersion) {
|
|
13
|
+
const parsed = parseVersion(localVersion);
|
|
14
|
+
if (!parsed) return { ok: false, reason: "npm-local-version-invalid" };
|
|
15
|
+
if (parsed.prerelease.length === 0) return { ok: true, channel: "latest" };
|
|
16
|
+
const channel = parsed.prerelease[0];
|
|
17
|
+
if (channel === "alpha" || channel === "rc") return { ok: true, channel };
|
|
18
|
+
return { ok: false, reason: "npm-prerelease-channel-unsupported" };
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function packageIntegrity(pkg) {
|
|
22
|
+
const value = pkg?.dist?.integrity;
|
|
23
|
+
return typeof value === "string" && SRI_PATTERN.test(value) ? value : "";
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* `npm view <pkg> dist-tags --json` prints the tag map itself
|
|
28
|
+
* (`{"latest":"...","alpha":"..."}`), while some adapters/tests hand back the
|
|
29
|
+
* whole packument field (`{"dist-tags":{...}}`). Accept both so the check never
|
|
30
|
+
* fails merely because of the projection shape.
|
|
31
|
+
*/
|
|
32
|
+
function distTagMap(tags) {
|
|
33
|
+
if (!tags || typeof tags !== "object" || Array.isArray(tags)) return null;
|
|
34
|
+
const nested = tags["dist-tags"];
|
|
35
|
+
if (nested && typeof nested === "object" && !Array.isArray(nested)) return nested;
|
|
36
|
+
return tags;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** 检查日志只放包名/版本/稳定原因码;绝不写 registry URL、凭据或 npm stderr。 */
|
|
40
|
+
export const NPM_CHECK_LOG_LIMIT = 40;
|
|
41
|
+
const CHECK_LOG_LINE_LIMIT = 240;
|
|
42
|
+
|
|
43
|
+
function checkRecorder(log) {
|
|
44
|
+
if (!Array.isArray(log)) return () => {};
|
|
45
|
+
return (line) => {
|
|
46
|
+
const text = String(line ?? "").trim();
|
|
47
|
+
if (text === "") return;
|
|
48
|
+
log.push(text.length > CHECK_LOG_LINE_LIMIT ? `${text.slice(0, CHECK_LOG_LINE_LIMIT)}…` : text);
|
|
49
|
+
if (log.length > NPM_CHECK_LOG_LIMIT) log.splice(0, log.length - NPM_CHECK_LOG_LIMIT);
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Resolve an immutable plugin/carrier pair from NPM metadata only.
|
|
55
|
+
* `packageView(spec)` is the host NPM adapter; tests inject a deterministic registry.
|
|
56
|
+
* This function never downloads a tarball and never returns registry URLs or raw metadata.
|
|
57
|
+
* `log` (optional array) receives sanitized, bounded diagnostic lines for the settings UI.
|
|
58
|
+
*/
|
|
59
|
+
export async function resolveNpmUpdateCandidate({ packageName, localVersion, packageView, log } = {}) {
|
|
60
|
+
const record = checkRecorder(log);
|
|
61
|
+
if (typeof packageName !== "string" || packageName.trim() === "") {
|
|
62
|
+
record(`包名无效:${String(packageName ?? "")}`);
|
|
63
|
+
return { ok: false, reason: "npm-package-name-invalid" };
|
|
64
|
+
}
|
|
65
|
+
if (typeof packageView !== "function") {
|
|
66
|
+
record(`找不到 npm 元数据适配器(${packageName})`);
|
|
67
|
+
return { ok: false, reason: "npm-client-unavailable" };
|
|
68
|
+
}
|
|
69
|
+
const channel = npmUpdateChannel(localVersion);
|
|
70
|
+
if (!channel.ok) {
|
|
71
|
+
record(`# 本机版本 ${String(localVersion || "未知")} 无法确定 NPM 通道:${channel.reason}`);
|
|
72
|
+
return channel;
|
|
73
|
+
}
|
|
74
|
+
record(`# 本机版本 ${String(localVersion || "未知")} · NPM 通道 ${channel.channel}`);
|
|
75
|
+
|
|
76
|
+
let tags;
|
|
77
|
+
record(`$ npm view ${packageName} dist-tags --json`);
|
|
78
|
+
try {
|
|
79
|
+
tags = await packageView(packageName);
|
|
80
|
+
} catch (error) {
|
|
81
|
+
const reason = viewFailureReason(error);
|
|
82
|
+
record(`→ 失败:${reason}`);
|
|
83
|
+
return { ok: false, reason };
|
|
84
|
+
}
|
|
85
|
+
const candidateVersion = distTagMap(tags)?.[channel.channel];
|
|
86
|
+
if (typeof candidateVersion !== "string" || !parseVersion(candidateVersion)) {
|
|
87
|
+
record(`→ 缺少 ${channel.channel} 标签`);
|
|
88
|
+
return { ok: false, reason: "npm-channel-version-missing", channel: channel.channel };
|
|
89
|
+
}
|
|
90
|
+
record(`→ ${channel.channel}=${candidateVersion}`);
|
|
91
|
+
|
|
92
|
+
let plugin;
|
|
93
|
+
record(`$ npm view ${packageName}@${candidateVersion} --json`);
|
|
94
|
+
try {
|
|
95
|
+
plugin = await packageView(`${packageName}@${candidateVersion}`);
|
|
96
|
+
} catch (error) {
|
|
97
|
+
record(`→ 失败:${viewFailureReason(error)}`);
|
|
98
|
+
return { ok: false, reason: "npm-plugin-metadata-unavailable" };
|
|
99
|
+
}
|
|
100
|
+
if (!plugin || plugin.version !== candidateVersion) {
|
|
101
|
+
record(`→ 版本不符:${String(plugin?.version ?? "缺失")} ≠ ${candidateVersion}`);
|
|
102
|
+
return { ok: false, reason: "npm-plugin-version-mismatch" };
|
|
103
|
+
}
|
|
104
|
+
const pluginIntegrity = packageIntegrity(plugin);
|
|
105
|
+
if (!pluginIntegrity) {
|
|
106
|
+
record(`→ 元数据缺少 dist.integrity`);
|
|
107
|
+
return { ok: false, reason: "npm-plugin-integrity-missing" };
|
|
108
|
+
}
|
|
109
|
+
record(`→ 插件 v${candidateVersion}`);
|
|
110
|
+
|
|
111
|
+
const carrierVersion = appCarrierVersion(candidateVersion);
|
|
112
|
+
const alias = appCarrierAlias(packageName);
|
|
113
|
+
const expectedAliasSpec = `npm:${packageName}@${carrierVersion}`;
|
|
114
|
+
if (plugin.optionalDependencies?.[alias] !== expectedAliasSpec) {
|
|
115
|
+
record(`→ 载体别名不匹配:${String(plugin.optionalDependencies?.[alias] ?? "缺失")}(期望 ${expectedAliasSpec})`);
|
|
116
|
+
return { ok: false, reason: "npm-carrier-alias-mismatch" };
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
let carrier;
|
|
120
|
+
record(`$ npm view ${packageName}@${carrierVersion} --json`);
|
|
121
|
+
try {
|
|
122
|
+
carrier = await packageView(`${packageName}@${carrierVersion}`);
|
|
123
|
+
} catch (error) {
|
|
124
|
+
record(`→ 失败:${viewFailureReason(error)}`);
|
|
125
|
+
return { ok: false, reason: "npm-carrier-metadata-unavailable" };
|
|
126
|
+
}
|
|
127
|
+
if (!carrier || carrier.version !== carrierVersion) {
|
|
128
|
+
record(`→ 版本不符:${String(carrier?.version ?? "缺失")} ≠ ${carrierVersion}`);
|
|
129
|
+
return { ok: false, reason: "npm-carrier-version-mismatch" };
|
|
130
|
+
}
|
|
131
|
+
const carrierIntegrity = packageIntegrity(carrier);
|
|
132
|
+
if (!carrierIntegrity) {
|
|
133
|
+
record(`→ 元数据缺少 dist.integrity`);
|
|
134
|
+
return { ok: false, reason: "npm-carrier-integrity-missing" };
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const appVersion = typeof carrier.appVersion === "string" ? carrier.appVersion : null;
|
|
138
|
+
if (appVersion !== null) {
|
|
139
|
+
const parsedApp = parseVersion(appVersion);
|
|
140
|
+
const parsedPlugin = parseVersion(candidateVersion);
|
|
141
|
+
if (!parsedApp || parsedApp.build === null) {
|
|
142
|
+
record(`→ App 版本格式无效:${appVersion}`);
|
|
143
|
+
return { ok: false, reason: "npm-app-version-invalid" };
|
|
144
|
+
}
|
|
145
|
+
if (parsedApp.version !== parsedPlugin.version) {
|
|
146
|
+
record(`→ App 版本配对不符:${appVersion} ↔ 插件 ${candidateVersion}`);
|
|
147
|
+
return { ok: false, reason: "npm-app-version-pairing-mismatch" };
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
const contentSha256 = typeof carrier.pluginContentSha256 === "string" ? carrier.pluginContentSha256.toLowerCase() : "";
|
|
151
|
+
if (contentSha256 !== "" && !/^[0-9a-f]{64}$/.test(contentSha256)) {
|
|
152
|
+
record(`→ 插件内容标识格式无效(${carrierVersion})`);
|
|
153
|
+
return { ok: false, reason: "npm-plugin-content-sha256-invalid" };
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
record(`→ 载体 v${carrierVersion} · App build ${appVersion ?? "缺失(需预检)"}`);
|
|
157
|
+
|
|
158
|
+
return {
|
|
159
|
+
ok: true,
|
|
160
|
+
channel: channel.channel,
|
|
161
|
+
plugin: {
|
|
162
|
+
name: packageName,
|
|
163
|
+
version: candidateVersion,
|
|
164
|
+
integrity: pluginIntegrity,
|
|
165
|
+
contentSha256,
|
|
166
|
+
},
|
|
167
|
+
carrier: {
|
|
168
|
+
name: packageName,
|
|
169
|
+
version: carrierVersion,
|
|
170
|
+
integrity: carrierIntegrity,
|
|
171
|
+
appVersion,
|
|
172
|
+
pluginContentSha256: contentSha256,
|
|
173
|
+
legacyMetadataMissing: appVersion === null,
|
|
174
|
+
},
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export function runNpmView(args, { cwd = process.cwd(), timeoutMs = 20_000, execFileImpl = execFile, platform = process.platform } = {}) {
|
|
179
|
+
return new Promise((resolve) => {
|
|
180
|
+
execFileImpl("npm", args, {
|
|
181
|
+
cwd,
|
|
182
|
+
env: process.env,
|
|
183
|
+
timeout: timeoutMs,
|
|
184
|
+
maxBuffer: 1024 * 1024,
|
|
185
|
+
windowsHide: true,
|
|
186
|
+
// Windows 上 npm 是 npm.cmd,必须经 shell 解析;POSIX 直接 spawn。
|
|
187
|
+
...shellOptions(platform),
|
|
188
|
+
}, (error, stdout, stderr) => {
|
|
189
|
+
if (error) {
|
|
190
|
+
// npm stderr may contain private registry URLs; expose only a stable source error.
|
|
191
|
+
// 区分「找不到 npm 客户端」与「registry 不可用」,便于界面给出可执行提示:
|
|
192
|
+
// Windows shell 找不到 .cmd 时 cmd 会报「不是内部或外部命令」而不是 ENOENT。
|
|
193
|
+
const stderrText = String(stderr ?? "");
|
|
194
|
+
const clientMissing = error?.code === "ENOENT" || /not recognized|不是内部或外部命令|command not found/i.test(stderrText);
|
|
195
|
+
resolve({ ok: false, error: clientMissing ? "npm-client-unavailable" : "npm-view-failed" });
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
resolve({ ok: true, stdout: String(stdout ?? "") });
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/** 检查失败原因:npm 客户端缺失是环境问题,不应伪装成 registry 故障。 */
|
|
204
|
+
function viewFailureReason(error) {
|
|
205
|
+
return error?.message === "npm-client-unavailable" ? "npm-client-unavailable" : "npm-registry-unavailable";
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Host-side npm view adapter. It deliberately supplies no --registry argument so npm
|
|
210
|
+
* applies the DSH process's project/user config, including scoped registry and credentials.
|
|
211
|
+
*/
|
|
212
|
+
export function createNpmPackageView({ packageName, cwd, run = runNpmView, platform = process.platform } = {}) {
|
|
213
|
+
return async (spec) => {
|
|
214
|
+
if (typeof spec !== "string" || spec === "") throw new Error("npm-package-spec-invalid");
|
|
215
|
+
const args = spec === packageName
|
|
216
|
+
? ["view", packageName, "dist-tags", "--json"]
|
|
217
|
+
: ["view", spec, "--json"];
|
|
218
|
+
const result = await run(args, { cwd, platform });
|
|
219
|
+
if (!result?.ok) throw new Error(result?.error ?? "npm-view-failed");
|
|
220
|
+
try {
|
|
221
|
+
return JSON.parse(result.stdout);
|
|
222
|
+
} catch {
|
|
223
|
+
throw new Error("npm-view-json-invalid");
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// 插件内容标识(CONTEXT「内容标识」):对插件自身的 `package.json` + `lib/**` 做规范化哈希。
|
|
3
|
+
//
|
|
4
|
+
// 为什么要它:manifest 的 `sha256` 是 **tgz 压缩包的字节哈希**,运行中的插件无法从已解开的
|
|
5
|
+
// 目录里复算;而「同一个版本号、不同内容」是真实存在的形态(上游 v3.2.0 与本仓库 develop
|
|
6
|
+
// 的插件版本号都是 3.2.0)。所以另给一个**内容哈希**,让发布侧(打包前)、产物侧
|
|
7
|
+
// (tgz 解包)与运行侧(已安装副本)三处都能算出同一个值。
|
|
8
|
+
//
|
|
9
|
+
// 规范(改动即需升 CONTENT_DIGEST_VERSION,否则同一算法下新旧值不可比):
|
|
10
|
+
// 1. 参与文件:顶层 `package.json` + 递归 `lib/**`;
|
|
11
|
+
// 排除 `node_modules` 与以 `.` 开头的条目;
|
|
12
|
+
// 2. 路径一律用 `/` 分隔、按字节序升序排列,保证与文件系统枚举顺序无关;
|
|
13
|
+
// 3. 每个文件先把 CRLF 归一为 LF 再哈希(Windows 检出与 Linux 打包必须得到同一个值),
|
|
14
|
+
// 按字节(latin1 往返)处理,避免 UTF-8 解码改变内容;
|
|
15
|
+
// 4. 文本形式为 `plugin-content-digest/v1\n` + 每行 `<相对路径> <文件哈希>\n`,
|
|
16
|
+
// 再取整段的 sha256 作为内容标识。
|
|
17
|
+
import { createHash } from "node:crypto";
|
|
18
|
+
import { readFileSync, readdirSync, statSync } from "node:fs";
|
|
19
|
+
import { join } from "node:path";
|
|
20
|
+
|
|
21
|
+
/** 内容标识算法的版本;算法本身变化时必须递增。 */
|
|
22
|
+
export const CONTENT_DIGEST_VERSION = 1;
|
|
23
|
+
/** 参与哈希的顶层文件。 */
|
|
24
|
+
const TOP_FILES = ["package.json"];
|
|
25
|
+
/** 参与哈希的目录(递归)。 */
|
|
26
|
+
const TOP_DIRS = ["lib"];
|
|
27
|
+
|
|
28
|
+
/** CRLF → LF 的字节级归一(不经 UTF-8 解码,二进制内容也能安全往返)。 */
|
|
29
|
+
export function normalizeLineEndings(buf) {
|
|
30
|
+
return Buffer.from(buf.toString("binary").replace(/\r\n/g, "\n"), "binary");
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** 收集参与哈希的相对路径,按字节序升序。 */
|
|
34
|
+
function collectRelPaths(root) {
|
|
35
|
+
const found = [];
|
|
36
|
+
for (const f of TOP_FILES) {
|
|
37
|
+
try {
|
|
38
|
+
if (statSync(join(root, f)).isFile()) found.push(f);
|
|
39
|
+
} catch {
|
|
40
|
+
// 缺失即不参与(发布侧会在别处报"必需文件缺失")
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
const walk = (rel) => {
|
|
44
|
+
let entries;
|
|
45
|
+
try {
|
|
46
|
+
entries = readdirSync(join(root, rel), { withFileTypes: true });
|
|
47
|
+
} catch {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
for (const e of entries) {
|
|
51
|
+
if (e.name === "node_modules" || e.name.startsWith(".")) continue;
|
|
52
|
+
const child = `${rel}/${e.name}`;
|
|
53
|
+
if (e.isDirectory()) walk(child);
|
|
54
|
+
else if (e.isFile()) found.push(child);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
for (const d of TOP_DIRS) walk(d);
|
|
58
|
+
return found.sort();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* 计算插件内容标识。
|
|
63
|
+
* @param {string} root 插件根目录(含 `package.json` 与 `lib/`)
|
|
64
|
+
* @returns {string} 64 位小写 hex
|
|
65
|
+
*/
|
|
66
|
+
export function pluginContentDigest(root) {
|
|
67
|
+
const h = createHash("sha256");
|
|
68
|
+
h.update(`plugin-content-digest/v${CONTENT_DIGEST_VERSION}\n`);
|
|
69
|
+
for (const rel of collectRelPaths(root)) {
|
|
70
|
+
const bytes = normalizeLineEndings(readFileSync(join(root, rel)));
|
|
71
|
+
const fileHash = createHash("sha256").update(bytes).digest("hex");
|
|
72
|
+
h.update(`${rel} ${fileHash}\n`);
|
|
73
|
+
}
|
|
74
|
+
return h.digest("hex");
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** 参与哈希的相对路径清单(诊断与测试用;与 pluginContentDigest 的输入完全一致)。 */
|
|
78
|
+
export function pluginContentFiles(root) {
|
|
79
|
+
return collectRelPaths(root);
|
|
80
|
+
}
|