From 7e65825d3ebd5be3a934682c22f964af65018feb Mon Sep 17 00:00:00 2001 From: zhongluofeng Date: Mon, 28 Sep 2026 18:05:29 +0800 Subject: [PATCH] =?UTF-8?q?dsh=E6=A8=A1=E5=9D=97=E3=80=81=E5=BF=AB?= =?UTF-8?q?=E6=8D=B7=E9=94=AE=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 2045 ++++++++++++++++- package.json | 4 +- src-tauri/src/constants.rs | 11 + src-tauri/src/dsh/ai_sync.rs | 253 ++ src-tauri/src/dsh/commands.rs | 232 ++ src-tauri/src/dsh/install.rs | 397 ++++ src-tauri/src/dsh/mod.rs | 484 ++++ src-tauri/src/dsh/node.rs | 399 ++++ src-tauri/src/dsh/server.rs | 316 +++ src-tauri/src/dsh/types.rs | 239 ++ src-tauri/src/lib.rs | 42 +- src-tauri/src/music/audio/engine.rs | 4 + src-tauri/src/music/mod.rs | 4 +- src-tauri/src/setup.rs | 12 +- src-tauri/src/terminal/settings.rs | 24 +- src-tauri/src/translate/settings.rs | 17 +- src/components/ui/stepper/Stepper.vue | 27 + .../ui/stepper/StepperDescription.vue | 19 + .../ui/stepper/StepperIndicator.vue | 32 + src/components/ui/stepper/StepperItem.vue | 23 + .../ui/stepper/StepperSeparator.vue | 27 + src/components/ui/stepper/StepperTitle.vue | 19 + src/components/ui/stepper/StepperTrigger.vue | 22 + src/components/ui/stepper/index.ts | 7 + src/lib/bindings.ts | 213 +- src/lib/constants.ts | 20 + src/lib/terminalActions.ts | 11 +- src/main.ts | 6 + src/modules/dsh/DshModule.vue | 170 ++ src/modules/dsh/components/DshLogPanel.vue | 54 + .../dsh/components/DshSettingsPanel.vue | 363 +++ src/modules/dsh/components/SetupStepper.vue | 491 ++++ src/modules/dsh/index.ts | 72 + src/modules/icons.ts | 6 +- src/modules/index.ts | 4 +- src/modules/screenshot/ScreenshotEditor.vue | 10 + src/modules/screenshot/ScreenshotOverlay.vue | 10 + src/modules/screenshot/ScreenshotPin.vue | 9 + src/modules/terminal/FileWindow.vue | 2 +- src/modules/terminal/TerminalQuickLaunch.vue | 2 +- .../terminal/components/FileManager.vue | 9 +- src/modules/terminal/components/FilePane.vue | 193 +- .../terminal/components/HostManager.vue | 8 +- .../terminal/components/KeyManagerPanel.vue | 10 +- .../components/SnippetEditorDialog.vue | 15 +- src/modules/terminal/fileUtils.ts | 30 +- src/modules/terminal/index.ts | 4 +- src/modules/translate/TranslatePopup.vue | 2 +- .../components/TranslateSettings.vue | 2 +- src/stores/dshStore.ts | 545 +++++ src/stores/screenshotStore.ts | 127 +- src/style.css | 4 + src/types/dsh.ts | 138 ++ src/types/translate.ts | 2 +- 54 files changed, 7082 insertions(+), 109 deletions(-) create mode 100644 src-tauri/src/dsh/ai_sync.rs create mode 100644 src-tauri/src/dsh/commands.rs create mode 100644 src-tauri/src/dsh/install.rs create mode 100644 src-tauri/src/dsh/mod.rs create mode 100644 src-tauri/src/dsh/node.rs create mode 100644 src-tauri/src/dsh/server.rs create mode 100644 src-tauri/src/dsh/types.rs create mode 100644 src/components/ui/stepper/Stepper.vue create mode 100644 src/components/ui/stepper/StepperDescription.vue create mode 100644 src/components/ui/stepper/StepperIndicator.vue create mode 100644 src/components/ui/stepper/StepperItem.vue create mode 100644 src/components/ui/stepper/StepperSeparator.vue create mode 100644 src/components/ui/stepper/StepperTitle.vue create mode 100644 src/components/ui/stepper/StepperTrigger.vue create mode 100644 src/components/ui/stepper/index.ts create mode 100644 src/modules/dsh/DshModule.vue create mode 100644 src/modules/dsh/components/DshLogPanel.vue create mode 100644 src/modules/dsh/components/DshSettingsPanel.vue create mode 100644 src/modules/dsh/components/SetupStepper.vue create mode 100644 src/modules/dsh/index.ts create mode 100644 src/stores/dshStore.ts create mode 100644 src/types/dsh.ts diff --git a/package-lock.json b/package-lock.json index 3df8ae0..0dbd12a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,14 +1,14 @@ { "name": "thing", - "version": "26.9.3", + "version": "26.9.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "thing", - "version": "26.9.3", + "version": "26.9.4", "dependencies": { - "@lucide/vue": "^1.28.0", + "@lucide/vue": "^1.48.0", "@tailwindcss/vite": "^4.3.2", "@tauri-apps/api": "^2", "@tauri-apps/plugin-autostart": "~2", @@ -27,7 +27,8 @@ "clsx": "^2.1.1", "pinia": "^3.0.4", "pinyin-pro": "^3.28.2", - "reka-ui": "^2.10.1", + "qrcode": "^1.5.4", + "reka-ui": "^2.10.5", "tailwind-merge": "^3.6.0", "tailwindcss": "^4.3.2", "vue": "^3.5.13", @@ -37,7 +38,11 @@ "devDependencies": { "@tauri-apps/cli": "^2", "@types/node": "^26.1.1", + "@types/qrcode": "^1.5.6", "@vitejs/plugin-vue": "^5.2.1", + "@vue/eslint-config-typescript": "^14.9.0", + "eslint": "^10.11.0", + "eslint-plugin-vue": "^10.11.0", "tw-animate-css": "^1.4.0", "typescript": "~5.6.2", "vite": "^6.0.3", @@ -82,6 +87,30 @@ "node": ">=6.9.0" } }, + "node_modules/@cacheable/memory": { + "version": "2.2.0", + "resolved": "https://registry.npmmirror.com/@cacheable/memory/-/memory-2.2.0.tgz", + "integrity": "sha512-CTLKqLItRCEixEAewD3/j9DB3/o96gpTPD4eJ1v+DGOlxZRZncRQkGYqqnAGCscYd6RNeXfGeiuCphsPtqyIfQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@cacheable/utils": "^2.5.0", + "@keyv/bigmap": "^1.3.1", + "hookified": "^1.15.1", + "keyv": "^5.6.0" + } + }, + "node_modules/@cacheable/utils": { + "version": "2.5.0", + "resolved": "https://registry.npmmirror.com/@cacheable/utils/-/utils-2.5.0.tgz", + "integrity": "sha512-buipgOVDkkPXNR5+xBpDw7Zk2n1EvU7qBJCNUcL7rhQ//kfpOXPAvQ511Os0vpLYJ1pZnvudNytkQt2hst3wqA==", + "dev": true, + "license": "MIT", + "dependencies": { + "hashery": "^1.5.1", + "keyv": "^5.6.0" + } + }, "node_modules/@esbuild/aix-ppc64": { "version": "0.25.12", "resolved": "https://registry.npmmirror.com/@esbuild/aix-ppc64/-/aix-ppc64-0.25.12.tgz", @@ -496,6 +525,139 @@ "node": ">=18" } }, + "node_modules/@eslint-community/eslint-utils": { + "version": "4.10.1", + "resolved": "https://registry.npmmirror.com/@eslint-community/eslint-utils/-/eslint-utils-4.10.1.tgz", + "integrity": "sha512-cuadcxVFE8sDK6iWJbs8Sn0av2Nrh2QSGQhVlBW9AaAHqHwjWsZHT8LJ4hFGPh7ASBV2deFdM7H/DPjulmh8rg==", + "dev": true, + "license": "MIT", + "dependencies": { + "eslint-visitor-keys": "^3.4.3" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + }, + "peerDependencies": { + "eslint": "^6.0.0 || ^7.0.0 || >=8.0.0" + } + }, + "node_modules/@eslint-community/regexpp": { + "version": "4.12.2", + "resolved": "https://registry.npmmirror.com/@eslint-community/regexpp/-/regexpp-4.12.2.tgz", + "integrity": "sha512-EriSTlt5OC9/7SXkRSCAhfSxxoSUgBm33OH+IkwbdpgoqsSsUg7y3uh+IICI/Qg4BBWr3U2i39RpmycbxMq4ew==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^12.0.0 || ^14.0.0 || >=16.0.0" + } + }, + "node_modules/@eslint/config-array": { + "version": "0.23.5", + "resolved": "https://registry.npmmirror.com/@eslint/config-array/-/config-array-0.23.5.tgz", + "integrity": "sha512-Y3kKLvC1dvTOT+oGlqNQ1XLqK6D1HU2YXPc52NmAlJZbMMWDzGYXMiPRJ8TYD39muD/OTjlZmNJ4ib7dvSrMBA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@eslint/object-schema": "^3.0.5", + "debug": "^4.3.1", + "minimatch": "^10.2.4" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + } + }, + "node_modules/@eslint/config-array/node_modules/balanced-match": { + "version": "4.0.4", + "resolved": "https://registry.npmmirror.com/balanced-match/-/balanced-match-4.0.4.tgz", + "integrity": "sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==", + "dev": true, + "license": "MIT", + "engines": { + "node": "18 || 20 || >=22" + } + }, + "node_modules/@eslint/config-array/node_modules/brace-expansion": { + "version": "5.0.12", + "resolved": "https://registry.npmmirror.com/brace-expansion/-/brace-expansion-5.0.12.tgz", + "integrity": "sha512-YovQ3rzhaLMIrDjNDMkNS01tea93qhEhG5xy8f6+R0l+dw3Ki+5sCoIoI942iuLZTHWogWktgwVDhU09iNEimQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^4.0.2" + }, + "engines": { + "node": "20 || >=22" + } + }, + "node_modules/@eslint/config-array/node_modules/minimatch": { + "version": "10.2.6", + "resolved": "https://registry.npmmirror.com/minimatch/-/minimatch-10.2.6.tgz", + "integrity": "sha512-vpLQEs+VLCr1nU0BXS07maYoFwlDAH0gngQuuttxIwutDFEMHq2blX+8vpgxDdK3J1PwjCJiep77OitTZ4Ll1A==", + "dev": true, + "license": "BlueOak-1.0.0", + "dependencies": { + "brace-expansion": "^5.0.8" + }, + "engines": { + "node": "18 || 20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/@eslint/config-helpers": { + "version": "0.7.0", + "resolved": "https://registry.npmmirror.com/@eslint/config-helpers/-/config-helpers-0.7.0.tgz", + "integrity": "sha512-DObd/KKUsU+FaFv4PLxSRenpXfQWmPXXP3pPZ6/K1PCrMu2vQpMDMuQe/BqYeoLcz8ro0bVDF1RxOJgfVEdhUw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@eslint/core": "^1.2.1" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + } + }, + "node_modules/@eslint/core": { + "version": "1.2.1", + "resolved": "https://registry.npmmirror.com/@eslint/core/-/core-1.2.1.tgz", + "integrity": "sha512-MwcE1P+AZ4C6DWlpin/OmOA54mmIZ/+xZuJiQd4SyB29oAJjN30UW9wkKNptW2ctp4cEsvhlLY/CsQ1uoHDloQ==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@types/json-schema": "^7.0.15" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + } + }, + "node_modules/@eslint/object-schema": { + "version": "3.0.5", + "resolved": "https://registry.npmmirror.com/@eslint/object-schema/-/object-schema-3.0.5.tgz", + "integrity": "sha512-vqTaUEgxzm+YDSdElad6PiRoX4t8VGDjCtt05zn4nU810UIx/uNEV7/lZJ6KwFThKZOzOxzXy48da+No7HZaMw==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + } + }, + "node_modules/@eslint/plugin-kit": { + "version": "0.7.3", + "resolved": "https://registry.npmmirror.com/@eslint/plugin-kit/-/plugin-kit-0.7.3.tgz", + "integrity": "sha512-IkO+/KEUvwbVpiURZg+P7zF74z5Jxe0UgJxVni+RtoHQ6IZieXaO02kmadomap/q+l6bc/jdPGGqTjhuZnuz1Q==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@eslint/core": "^1.2.1", + "levn": "^0.4.1" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + } + }, "node_modules/@floating-ui/core": { "version": "1.8.0", "resolved": "https://registry.npmmirror.com/@floating-ui/core/-/core-1.8.0.tgz", @@ -558,6 +720,72 @@ } } }, + "node_modules/@humanfs/core": { + "version": "0.19.2", + "resolved": "https://registry.npmmirror.com/@humanfs/core/-/core-0.19.2.tgz", + "integrity": "sha512-UhXNm+CFMWcbChXywFwkmhqjs3PRCmcSa/hfBgLIb7oQ5HNb1wS0icWsGtSAUNgefHeI+eBrA8I1fxmbHsGdvA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@humanfs/types": "^0.15.0" + }, + "engines": { + "node": ">=18.18.0" + } + }, + "node_modules/@humanfs/node": { + "version": "0.16.8", + "resolved": "https://registry.npmmirror.com/@humanfs/node/-/node-0.16.8.tgz", + "integrity": "sha512-gE1eQNZ3R++kTzFUpdGlpmy8kDZD/MLyHqDwqjkVQI0JMdI1D51sy1H958PNXYkM2rAac7e5/CnIKZrHtPh3BQ==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@humanfs/core": "^0.19.2", + "@humanfs/types": "^0.15.0", + "@humanwhocodes/retry": "^0.4.0" + }, + "engines": { + "node": ">=18.18.0" + } + }, + "node_modules/@humanfs/types": { + "version": "0.15.0", + "resolved": "https://registry.npmmirror.com/@humanfs/types/-/types-0.15.0.tgz", + "integrity": "sha512-ZZ1w0aoQkwuUuC7Yf+7sdeaNfqQiiLcSRbfI08oAxqLtpXQr9AIVX7Ay7HLDuiLYAaFPu8oBYNq/QIi9URHJ3Q==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=18.18.0" + } + }, + "node_modules/@humanwhocodes/module-importer": { + "version": "1.0.1", + "resolved": "https://registry.npmmirror.com/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", + "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=12.22" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } + }, + "node_modules/@humanwhocodes/retry": { + "version": "0.4.3", + "resolved": "https://registry.npmmirror.com/@humanwhocodes/retry/-/retry-0.4.3.tgz", + "integrity": "sha512-bV0Tgo9K4hfPCek+aMAn81RppFKv2ySDQeMoSZuvTASywNTnVJCArCZE2FWqpvIatKu7VMRLWlR1EazvVhDyhQ==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=18.18" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } + }, "node_modules/@internationalized/date": { "version": "3.12.2", "resolved": "https://registry.npmmirror.com/@internationalized/date/-/date-3.12.2.tgz", @@ -611,15 +839,77 @@ "@jridgewell/sourcemap-codec": "^1.4.14" } }, + "node_modules/@keyv/bigmap": { + "version": "1.3.1", + "resolved": "https://registry.npmmirror.com/@keyv/bigmap/-/bigmap-1.3.1.tgz", + "integrity": "sha512-WbzE9sdmQtKy8vrNPa9BRnwZh5UF4s1KTmSK0KUVLo3eff5BlQNNWDnFOouNpKfPKDnms9xynJjsMYjMaT/aFQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "hashery": "^1.4.0", + "hookified": "^1.15.0" + }, + "engines": { + "node": ">= 18" + }, + "peerDependencies": { + "keyv": "^5.6.0" + } + }, + "node_modules/@keyv/serialize": { + "version": "1.1.1", + "resolved": "https://registry.npmmirror.com/@keyv/serialize/-/serialize-1.1.1.tgz", + "integrity": "sha512-dXn3FZhPv0US+7dtJsIi2R+c7qWYiReoEh5zUntWCf4oSpMNib8FDhSoed6m3QyZdx5hK7iLFkYk3rNxwt8vTA==", + "dev": true, + "license": "MIT" + }, "node_modules/@lucide/vue": { - "version": "1.28.0", - "resolved": "https://registry.npmmirror.com/@lucide/vue/-/vue-1.28.0.tgz", - "integrity": "sha512-cO89UyNM/0i2Srdi04nFWeEOQkqzDZlM2ehtWyBhcMpRTJDKpMZPCGAVlmVBgBgr5HaeL5L6FsU8RHsOdwXtKw==", + "version": "1.48.0", + "resolved": "https://registry.npmmirror.com/@lucide/vue/-/vue-1.48.0.tgz", + "integrity": "sha512-3/Nwx/RsqQ4ZrrSML1GNsSWCSDyLnBgoF/eEr1q9G6iZymn3+WKtzIj7Dbc/Nxrt9WOPuGrJ58S+CBiamK+36w==", "license": "ISC", "peerDependencies": { "vue": ">=3.0.1" } }, + "node_modules/@nodelib/fs.scandir": { + "version": "2.1.5", + "resolved": "https://registry.npmmirror.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", + "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@nodelib/fs.stat": "2.0.5", + "run-parallel": "^1.1.9" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.stat": { + "version": "2.0.5", + "resolved": "https://registry.npmmirror.com/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", + "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.walk": { + "version": "1.2.8", + "resolved": "https://registry.npmmirror.com/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", + "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@nodelib/fs.scandir": "2.1.5", + "fastq": "^1.6.0" + }, + "engines": { + "node": ">= 8" + } + }, "node_modules/@rollup/rollup-android-arm-eabi": { "version": "4.62.2", "resolved": "https://registry.npmmirror.com/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.62.2.tgz", @@ -1480,10 +1770,24 @@ "@tauri-apps/api": "^2.11.0" } }, + "node_modules/@types/esrecurse": { + "version": "4.3.1", + "resolved": "https://registry.npmmirror.com/@types/esrecurse/-/esrecurse-4.3.1.tgz", + "integrity": "sha512-xJBAbDifo5hpffDBuHl0Y8ywswbiAp/Wi7Y/GtAgSlZyIABppyurxVueOPE8LUQOxdlgi6Zqce7uoEpqNTeiUw==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/estree": { "version": "1.0.9", "license": "MIT" }, + "node_modules/@types/json-schema": { + "version": "7.0.15", + "resolved": "https://registry.npmmirror.com/@types/json-schema/-/json-schema-7.0.15.tgz", + "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/node": { "version": "26.1.1", "resolved": "https://registry.npmmirror.com/@types/node/-/node-26.1.1.tgz", @@ -1494,6 +1798,16 @@ "undici-types": "~8.3.0" } }, + "node_modules/@types/qrcode": { + "version": "1.5.6", + "resolved": "https://registry.npmmirror.com/@types/qrcode/-/qrcode-1.5.6.tgz", + "integrity": "sha512-te7NQcV2BOvdj2b1hCAHzAoMNuj65kNBMz0KBaxM6c3VGBOhU0dURQKOtH8CFNI/dsKkwlv32p26qYQTWoB5bw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, "node_modules/@types/sortablejs": { "version": "1.15.9", "resolved": "https://registry.npmmirror.com/@types/sortablejs/-/sortablejs-1.15.9.tgz", @@ -1506,6 +1820,288 @@ "integrity": "sha512-oIQLCGWtcFZy2JW77j9k8nHzAOpqMHLQejDA48XXMWH6tjCQHz5RCFz1bzsmROyL6PUm+LLnUiI4BCn221inxA==", "license": "MIT" }, + "node_modules/@typescript-eslint/eslint-plugin": { + "version": "8.70.1", + "resolved": "https://registry.npmmirror.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.70.1.tgz", + "integrity": "sha512-nDNrUQ/4ruSNYbu749TRY7cfrzPtoLHEXSNBI8aaNY32LlZCajixqRf3FqcKC4p5Cam4VOHYx/t+i5+nKXvrqA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@eslint-community/regexpp": "^4.12.2", + "@typescript-eslint/scope-manager": "8.70.1", + "@typescript-eslint/type-utils": "8.70.1", + "@typescript-eslint/utils": "8.70.1", + "@typescript-eslint/visitor-keys": "8.70.1", + "ignore": "^7.0.5", + "natural-compare": "^1.4.0", + "ts-api-utils": "^2.5.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "@typescript-eslint/parser": "^8.70.1", + "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0", + "typescript": ">=4.8.4 <6.1.0" + } + }, + "node_modules/@typescript-eslint/eslint-plugin/node_modules/ignore": { + "version": "7.0.10", + "resolved": "https://registry.npmmirror.com/ignore/-/ignore-7.0.10.tgz", + "integrity": "sha512-HpbUakT7xp5miBUywCHf36ZEuAJNklBJDDsGpUIjMzOSmM8ELSfA9Sa/QDPeNeqeoN31u+UTCkL4klCOVvRm4Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 4" + } + }, + "node_modules/@typescript-eslint/parser": { + "version": "8.70.1", + "resolved": "https://registry.npmmirror.com/@typescript-eslint/parser/-/parser-8.70.1.tgz", + "integrity": "sha512-nO974WLllwhSFWQXnMLj6nDGa8f0khKEz1JzpPJ1u7Vm/4X1X6ZHajpoknU4bb41vJyMB0HHVyS2GqdhWfIXZw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/scope-manager": "8.70.1", + "@typescript-eslint/types": "8.70.1", + "@typescript-eslint/typescript-estree": "8.70.1", + "@typescript-eslint/visitor-keys": "8.70.1", + "debug": "^4.4.3" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0", + "typescript": ">=4.8.4 <6.1.0" + } + }, + "node_modules/@typescript-eslint/project-service": { + "version": "8.70.1", + "resolved": "https://registry.npmmirror.com/@typescript-eslint/project-service/-/project-service-8.70.1.tgz", + "integrity": "sha512-62xOgboPfwc3/IgPSX/W6oQR3ZbF04194FPGUGH8HL8iLFHbt/456/8Ph1wLNUgVF+s94FlHoipBsz+v7+LMnA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/tsconfig-utils": "^8.70.1", + "@typescript-eslint/types": "^8.70.1", + "debug": "^4.4.3" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "typescript": ">=4.8.4 <6.1.0" + } + }, + "node_modules/@typescript-eslint/scope-manager": { + "version": "8.70.1", + "resolved": "https://registry.npmmirror.com/@typescript-eslint/scope-manager/-/scope-manager-8.70.1.tgz", + "integrity": "sha512-Pa0EeSeAusQc1WbjQMac+YfenewYTBu0KjgYvkUKwhXaHUKbFog23Dm/rp0DX/6tyYOQ3Xl1a+3EcFNZynGHCw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/types": "8.70.1", + "@typescript-eslint/visitor-keys": "8.70.1" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/tsconfig-utils": { + "version": "8.70.1", + "resolved": "https://registry.npmmirror.com/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.70.1.tgz", + "integrity": "sha512-jumze1fPI+sDOaM2TWGQdn39PDxTr7TZGeuyLkAbNyx2vtMT3uRnVKChN0hfht5V2TugphJzF6bYXvBcE09qqg==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "typescript": ">=4.8.4 <6.1.0" + } + }, + "node_modules/@typescript-eslint/type-utils": { + "version": "8.70.1", + "resolved": "https://registry.npmmirror.com/@typescript-eslint/type-utils/-/type-utils-8.70.1.tgz", + "integrity": "sha512-7zKTnyvaVWqzLZHPFQtX1hVHqgkMC+WebPWakNCSyrQVbIP1AM0L0TlBZtACldIRb6PptI8Odk+jyZ5kP3B1VA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/types": "8.70.1", + "@typescript-eslint/typescript-estree": "8.70.1", + "@typescript-eslint/utils": "8.70.1", + "debug": "^4.4.3", + "ts-api-utils": "^2.5.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0", + "typescript": ">=4.8.4 <6.1.0" + } + }, + "node_modules/@typescript-eslint/types": { + "version": "8.70.1", + "resolved": "https://registry.npmmirror.com/@typescript-eslint/types/-/types-8.70.1.tgz", + "integrity": "sha512-Dm1ypdhhrGCTyyehxElhgJ6kgk8MVCv5qXdoOVqPr1uqk42jX8KjrZqhROvdShczA8qrDoYiOWn1ykWlx2k81Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/typescript-estree": { + "version": "8.70.1", + "resolved": "https://registry.npmmirror.com/@typescript-eslint/typescript-estree/-/typescript-estree-8.70.1.tgz", + "integrity": "sha512-TU8PwyGN0PQJUcE96mw8eCQ44SmxGdQlJmlWakHaHQ15eIuuvye5yNtmh/i6oS88jzXVQB71xdNkbkB/fMwL0g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/project-service": "8.70.1", + "@typescript-eslint/tsconfig-utils": "8.70.1", + "@typescript-eslint/types": "8.70.1", + "@typescript-eslint/visitor-keys": "8.70.1", + "debug": "^4.4.3", + "minimatch": "^10.2.2", + "semver": "^7.7.3", + "tinyglobby": "^0.2.15", + "ts-api-utils": "^2.5.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "typescript": ">=4.8.4 <6.1.0" + } + }, + "node_modules/@typescript-eslint/typescript-estree/node_modules/balanced-match": { + "version": "4.0.4", + "resolved": "https://registry.npmmirror.com/balanced-match/-/balanced-match-4.0.4.tgz", + "integrity": "sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==", + "dev": true, + "license": "MIT", + "engines": { + "node": "18 || 20 || >=22" + } + }, + "node_modules/@typescript-eslint/typescript-estree/node_modules/brace-expansion": { + "version": "5.0.12", + "resolved": "https://registry.npmmirror.com/brace-expansion/-/brace-expansion-5.0.12.tgz", + "integrity": "sha512-YovQ3rzhaLMIrDjNDMkNS01tea93qhEhG5xy8f6+R0l+dw3Ki+5sCoIoI942iuLZTHWogWktgwVDhU09iNEimQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^4.0.2" + }, + "engines": { + "node": "20 || >=22" + } + }, + "node_modules/@typescript-eslint/typescript-estree/node_modules/minimatch": { + "version": "10.2.6", + "resolved": "https://registry.npmmirror.com/minimatch/-/minimatch-10.2.6.tgz", + "integrity": "sha512-vpLQEs+VLCr1nU0BXS07maYoFwlDAH0gngQuuttxIwutDFEMHq2blX+8vpgxDdK3J1PwjCJiep77OitTZ4Ll1A==", + "dev": true, + "license": "BlueOak-1.0.0", + "dependencies": { + "brace-expansion": "^5.0.8" + }, + "engines": { + "node": "18 || 20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/@typescript-eslint/utils": { + "version": "8.70.1", + "resolved": "https://registry.npmmirror.com/@typescript-eslint/utils/-/utils-8.70.1.tgz", + "integrity": "sha512-Esgul8MsnKnRLdYU2Eb2cRV9bS5HJYtKj1ByJnOzzG2M58DGdSUQ1jUuILxipqcpB2h9WLrbD5GijIWUjX/Tqw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@eslint-community/eslint-utils": "^4.9.1", + "@typescript-eslint/scope-manager": "8.70.1", + "@typescript-eslint/types": "8.70.1", + "@typescript-eslint/typescript-estree": "8.70.1" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0", + "typescript": ">=4.8.4 <6.1.0" + } + }, + "node_modules/@typescript-eslint/visitor-keys": { + "version": "8.70.1", + "resolved": "https://registry.npmmirror.com/@typescript-eslint/visitor-keys/-/visitor-keys-8.70.1.tgz", + "integrity": "sha512-Vwj9lUIW5Xq3wQ9w6gv3R86g1hMK8f2zNOdGTAgeXUMMXFK78G9ruCjjqutHMNJc0+CH7LYRnHeUB9IT8wFmcw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/types": "8.70.1", + "eslint-visitor-keys": "^5.0.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/visitor-keys/node_modules/eslint-visitor-keys": { + "version": "5.0.1", + "resolved": "https://registry.npmmirror.com/eslint-visitor-keys/-/eslint-visitor-keys-5.0.1.tgz", + "integrity": "sha512-tD40eHxA35h0PEIZNeIjkHoDR4YjjJp34biM0mDvplBe//mB+IHCqHDGV7pxF+7MklTvighcCPPZC7ynWyjdTA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, "node_modules/@vitejs/plugin-vue": { "version": "5.2.4", "dev": true, @@ -1625,6 +2221,35 @@ "rfdc": "^1.4.1" } }, + "node_modules/@vue/eslint-config-typescript": { + "version": "14.9.0", + "resolved": "https://registry.npmmirror.com/@vue/eslint-config-typescript/-/eslint-config-typescript-14.9.0.tgz", + "integrity": "sha512-E3j9hDlfVf10F30MRcLTPY2IIhWIx1nsvkVukk14kTcuA+oBVot9zsP1hzsO+PAMDxV3Fd9FimBJtUBNBL5KFA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/utils": "^8.60.0", + "fast-glob": "^3.3.3", + "typescript-eslint": "^8.60.0", + "vue-eslint-parser": "^10.4.0" + }, + "bin": { + "vue-eslint-config-typescript": "dist/bin.js" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "peerDependencies": { + "eslint": "^9.10.0 || ^10.0.0", + "eslint-plugin-vue": "^9.28.0 || ^10.0.0", + "typescript": ">=4.8.4" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, "node_modules/@vue/language-core": { "version": "2.2.12", "dev": true, @@ -1771,11 +2396,75 @@ "addons/*" ] }, + "node_modules/acorn": { + "version": "8.18.0", + "resolved": "https://registry.npmmirror.com/acorn/-/acorn-8.18.0.tgz", + "integrity": "sha512-lGq+9yr1/GuAWaVYIHRjvvySG5/4VfKIvC8EWxStPdcDh/Ka7FG3twP6v4d5BkravUilhIAsG4Qj83t02LWUPQ==", + "dev": true, + "license": "MIT", + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/acorn-jsx": { + "version": "5.3.2", + "resolved": "https://registry.npmmirror.com/acorn-jsx/-/acorn-jsx-5.3.2.tgz", + "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" + } + }, + "node_modules/ajv": { + "version": "6.15.0", + "resolved": "https://registry.npmmirror.com/ajv/-/ajv-6.15.0.tgz", + "integrity": "sha512-fgFx7Hfoq60ytK2c7DhnF8jIvzYgOMxfugjLOSMHjLIPgenqa7S7oaagATUq99mV6IYvN2tRmC0wnTYX6iPbMw==", + "dev": true, + "license": "MIT", + "dependencies": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, "node_modules/alien-signals": { "version": "1.0.13", "dev": true, "license": "MIT" }, + "node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmmirror.com/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmmirror.com/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "license": "MIT", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, "node_modules/aria-hidden": { "version": "1.2.6", "resolved": "https://registry.npmmirror.com/aria-hidden/-/aria-hidden-1.2.6.tgz", @@ -1802,6 +2491,13 @@ "url": "https://github.com/sponsors/antfu" } }, + "node_modules/boolbase": { + "version": "1.0.0", + "resolved": "https://registry.npmmirror.com/boolbase/-/boolbase-1.0.0.tgz", + "integrity": "sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww==", + "dev": true, + "license": "ISC" + }, "node_modules/brace-expansion": { "version": "2.1.2", "dev": true, @@ -1810,6 +2506,42 @@ "balanced-match": "^1.0.0" } }, + "node_modules/braces": { + "version": "3.0.3", + "resolved": "https://registry.npmmirror.com/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", + "dev": true, + "license": "MIT", + "dependencies": { + "fill-range": "^7.1.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/cacheable": { + "version": "2.5.0", + "resolved": "https://registry.npmmirror.com/cacheable/-/cacheable-2.5.0.tgz", + "integrity": "sha512-60cyAOytib/OzBw1JNSoSV/boK1AtHryDIjvVBk7XbN4ugfkM3+Sry7fEjNgPMGgOjuaZPAp8ruZ0Cxafwyq9g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@cacheable/memory": "^2.2.0", + "@cacheable/utils": "^2.5.0", + "hookified": "^1.15.0", + "keyv": "^5.6.0", + "qified": "^0.10.1" + } + }, + "node_modules/camelcase": { + "version": "5.3.1", + "resolved": "https://registry.npmmirror.com/camelcase/-/camelcase-5.3.1.tgz", + "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, "node_modules/class-variance-authority": { "version": "0.7.1", "resolved": "https://registry.npmmirror.com/class-variance-authority/-/class-variance-authority-0.7.1.tgz", @@ -1822,6 +2554,17 @@ "url": "https://polar.sh/cva" } }, + "node_modules/cliui": { + "version": "6.0.0", + "resolved": "https://registry.npmmirror.com/cliui/-/cliui-6.0.0.tgz", + "integrity": "sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==", + "license": "ISC", + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^6.2.0" + } + }, "node_modules/clsx": { "version": "2.1.1", "resolved": "https://registry.npmmirror.com/clsx/-/clsx-2.1.1.tgz", @@ -1831,6 +2574,24 @@ "node": ">=6" } }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmmirror.com/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "license": "MIT", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmmirror.com/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "license": "MIT" + }, "node_modules/copy-anything": { "version": "4.0.5", "resolved": "https://registry.npmmirror.com/copy-anything/-/copy-anything-4.0.5.tgz", @@ -1846,6 +2607,34 @@ "url": "https://github.com/sponsors/mesqueeb" } }, + "node_modules/cross-spawn": { + "version": "7.0.6", + "resolved": "https://registry.npmmirror.com/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", + "dev": true, + "license": "MIT", + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/cssesc": { + "version": "3.0.0", + "resolved": "https://registry.npmmirror.com/cssesc/-/cssesc-3.0.0.tgz", + "integrity": "sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg==", + "dev": true, + "license": "MIT", + "bin": { + "cssesc": "bin/cssesc" + }, + "engines": { + "node": ">=4" + } + }, "node_modules/csstype": { "version": "3.2.3", "license": "MIT" @@ -1855,6 +2644,40 @@ "dev": true, "license": "MIT" }, + "node_modules/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmmirror.com/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/decamelize": { + "version": "1.2.0", + "resolved": "https://registry.npmmirror.com/decamelize/-/decamelize-1.2.0.tgz", + "integrity": "sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/deep-is": { + "version": "0.1.4", + "resolved": "https://registry.npmmirror.com/deep-is/-/deep-is-0.1.4.tgz", + "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", + "dev": true, + "license": "MIT" + }, "node_modules/defu": { "version": "6.1.7", "resolved": "https://registry.npmmirror.com/defu/-/defu-6.1.7.tgz", @@ -1868,6 +2691,18 @@ "node": ">=8" } }, + "node_modules/dijkstrajs": { + "version": "1.0.3", + "resolved": "https://registry.npmmirror.com/dijkstrajs/-/dijkstrajs-1.0.3.tgz", + "integrity": "sha512-qiSlmBq9+BCdCA/L46dw8Uy93mloxsPSbwnm5yrKn2vMPiy8KyAskTF6zuV/j5BMsmOGZDPs7KjU+mjb670kfA==", + "license": "MIT" + }, + "node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmmirror.com/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "license": "MIT" + }, "node_modules/enhanced-resolve": { "version": "5.21.6", "license": "MIT", @@ -1928,10 +2763,336 @@ "@esbuild/win32-x64": "0.25.12" } }, + "node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmmirror.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/eslint": { + "version": "10.11.0", + "resolved": "https://registry.npmmirror.com/eslint/-/eslint-10.11.0.tgz", + "integrity": "sha512-P7a6UEEqb9G95MYAtqkmsTbVXIYyzIfl6NGOIJk162PaahFxFyeGcrlXYFSiagECg4sEm8IseJdZBKR3rx6MsQ==", + "dev": true, + "license": "MIT", + "workspaces": [ + "packages/*" + ], + "dependencies": { + "@eslint-community/eslint-utils": "^4.8.0", + "@eslint-community/regexpp": "^4.12.2", + "@eslint/config-array": "^0.23.5", + "@eslint/config-helpers": "^0.7.0", + "@eslint/core": "^1.2.1", + "@eslint/plugin-kit": "^0.7.3", + "@humanfs/node": "^0.16.6", + "@humanwhocodes/module-importer": "^1.0.1", + "@humanwhocodes/retry": "^0.4.2", + "@types/estree": "^1.0.6", + "ajv": "^6.14.0", + "cross-spawn": "^7.0.6", + "debug": "^4.3.2", + "escape-string-regexp": "^4.0.0", + "eslint-scope": "^9.1.2", + "eslint-visitor-keys": "^5.0.1", + "espree": "^11.2.0", + "esquery": "^1.7.0", + "esutils": "^2.0.2", + "fast-deep-equal": "^3.1.3", + "file-entry-cache": "11.1.5 || >11.1.6 <12", + "find-up": "^5.0.0", + "glob-parent": "^6.0.2", + "ignore": "^5.2.0", + "imurmurhash": "^0.1.4", + "is-glob": "^4.0.0", + "json-stable-stringify-without-jsonify": "^1.0.1", + "minimatch": "^10.2.5", + "natural-compare": "^1.4.0", + "optionator": "^0.9.3" + }, + "bin": { + "eslint": "bin/eslint.js" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + }, + "funding": { + "url": "https://eslint.org/donate" + }, + "peerDependencies": { + "jiti": "*" + }, + "peerDependenciesMeta": { + "jiti": { + "optional": true + } + } + }, + "node_modules/eslint-plugin-vue": { + "version": "10.11.1", + "resolved": "https://registry.npmmirror.com/eslint-plugin-vue/-/eslint-plugin-vue-10.11.1.tgz", + "integrity": "sha512-pasVXhl7wUmIvhujoqs/m0mJ9r59QW1IR9XXYKGR0FETzSM+Hhlf4qKIYgWiDDP+9YKv4YfbwskD7LqIdVcgQw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@eslint-community/eslint-utils": "^4.9.1", + "natural-compare": "^1.4.0", + "nth-check": "^2.1.1", + "postcss-selector-parser": "^7.1.4", + "semver": "^7.8.5", + "xml-name-validator": "^5.0.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "peerDependencies": { + "@stylistic/eslint-plugin": "^2.0.0 || ^3.0.0 || ^4.0.0 || ^5.0.0", + "@typescript-eslint/parser": "^7.0.0 || ^8.0.0", + "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0", + "vue-eslint-parser": "^10.3.0" + }, + "peerDependenciesMeta": { + "@stylistic/eslint-plugin": { + "optional": true + }, + "@typescript-eslint/parser": { + "optional": true + } + } + }, + "node_modules/eslint-scope": { + "version": "9.1.2", + "resolved": "https://registry.npmmirror.com/eslint-scope/-/eslint-scope-9.1.2.tgz", + "integrity": "sha512-xS90H51cKw0jltxmvmHy2Iai1LIqrfbw57b79w/J7MfvDfkIkFZ+kj6zC3BjtUwh150HsSSdxXZcsuv72miDFQ==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "@types/esrecurse": "^4.3.1", + "@types/estree": "^1.0.8", + "esrecurse": "^4.3.0", + "estraverse": "^5.2.0" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint-visitor-keys": { + "version": "3.4.3", + "resolved": "https://registry.npmmirror.com/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", + "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint/node_modules/balanced-match": { + "version": "4.0.4", + "resolved": "https://registry.npmmirror.com/balanced-match/-/balanced-match-4.0.4.tgz", + "integrity": "sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==", + "dev": true, + "license": "MIT", + "engines": { + "node": "18 || 20 || >=22" + } + }, + "node_modules/eslint/node_modules/brace-expansion": { + "version": "5.0.12", + "resolved": "https://registry.npmmirror.com/brace-expansion/-/brace-expansion-5.0.12.tgz", + "integrity": "sha512-YovQ3rzhaLMIrDjNDMkNS01tea93qhEhG5xy8f6+R0l+dw3Ki+5sCoIoI942iuLZTHWogWktgwVDhU09iNEimQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^4.0.2" + }, + "engines": { + "node": "20 || >=22" + } + }, + "node_modules/eslint/node_modules/eslint-visitor-keys": { + "version": "5.0.1", + "resolved": "https://registry.npmmirror.com/eslint-visitor-keys/-/eslint-visitor-keys-5.0.1.tgz", + "integrity": "sha512-tD40eHxA35h0PEIZNeIjkHoDR4YjjJp34biM0mDvplBe//mB+IHCqHDGV7pxF+7MklTvighcCPPZC7ynWyjdTA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint/node_modules/minimatch": { + "version": "10.2.6", + "resolved": "https://registry.npmmirror.com/minimatch/-/minimatch-10.2.6.tgz", + "integrity": "sha512-vpLQEs+VLCr1nU0BXS07maYoFwlDAH0gngQuuttxIwutDFEMHq2blX+8vpgxDdK3J1PwjCJiep77OitTZ4Ll1A==", + "dev": true, + "license": "BlueOak-1.0.0", + "dependencies": { + "brace-expansion": "^5.0.8" + }, + "engines": { + "node": "18 || 20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/espree": { + "version": "11.2.0", + "resolved": "https://registry.npmmirror.com/espree/-/espree-11.2.0.tgz", + "integrity": "sha512-7p3DrVEIopW1B1avAGLuCSh1jubc01H2JHc8B4qqGblmg5gI9yumBgACjWo4JlIc04ufug4xJ3SQI8HkS/Rgzw==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "acorn": "^8.16.0", + "acorn-jsx": "^5.3.2", + "eslint-visitor-keys": "^5.0.1" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/espree/node_modules/eslint-visitor-keys": { + "version": "5.0.1", + "resolved": "https://registry.npmmirror.com/eslint-visitor-keys/-/eslint-visitor-keys-5.0.1.tgz", + "integrity": "sha512-tD40eHxA35h0PEIZNeIjkHoDR4YjjJp34biM0mDvplBe//mB+IHCqHDGV7pxF+7MklTvighcCPPZC7ynWyjdTA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/esquery": { + "version": "1.7.0", + "resolved": "https://registry.npmmirror.com/esquery/-/esquery-1.7.0.tgz", + "integrity": "sha512-Ap6G0WQwcU/LHsvLwON1fAQX9Zp0A2Y6Y/cJBl9r/JbW90Zyg4/zbG6zzKa2OTALELarYHmKu0GhpM5EO+7T0g==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "estraverse": "^5.1.0" + }, + "engines": { + "node": ">=0.10" + } + }, + "node_modules/esrecurse": { + "version": "4.3.0", + "resolved": "https://registry.npmmirror.com/esrecurse/-/esrecurse-4.3.0.tgz", + "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "estraverse": "^5.2.0" + }, + "engines": { + "node": ">=4.0" + } + }, + "node_modules/estraverse": { + "version": "5.3.0", + "resolved": "https://registry.npmmirror.com/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=4.0" + } + }, "node_modules/estree-walker": { "version": "2.0.2", "license": "MIT" }, + "node_modules/esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmmirror.com/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmmirror.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true, + "license": "MIT" + }, + "node_modules/fast-glob": { + "version": "3.3.3", + "resolved": "https://registry.npmmirror.com/fast-glob/-/fast-glob-3.3.3.tgz", + "integrity": "sha512-7MptL8U0cqcFdzIzwOTHoilX9x5BrNqye7Z/LuC7kCMRio1EMSyqRK3BEAUD7sXRq4iT4AzTVuZdhgQ2TCvYLg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@nodelib/fs.stat": "^2.0.2", + "@nodelib/fs.walk": "^1.2.3", + "glob-parent": "^5.1.2", + "merge2": "^1.3.0", + "micromatch": "^4.0.8" + }, + "engines": { + "node": ">=8.6.0" + } + }, + "node_modules/fast-glob/node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmmirror.com/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "license": "ISC", + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/fast-json-stable-stringify": { + "version": "2.1.0", + "resolved": "https://registry.npmmirror.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", + "dev": true, + "license": "MIT" + }, + "node_modules/fast-levenshtein": { + "version": "2.0.6", + "resolved": "https://registry.npmmirror.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", + "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", + "dev": true, + "license": "MIT" + }, + "node_modules/fastq": { + "version": "1.20.3", + "resolved": "https://registry.npmmirror.com/fastq/-/fastq-1.20.3.tgz", + "integrity": "sha512-XKv5nnLs6nLF71NgiKJLIZFLkPyIEuOselLG7ujZnGrRfQK8HpvY+WqKhAJUAdLomwVHErVS4LfxFlPq0/FTAw==", + "dev": true, + "license": "ISC", + "dependencies": { + "reusify": "^1.0.4" + } + }, "node_modules/fdir": { "version": "6.5.0", "license": "MIT", @@ -1947,6 +3108,65 @@ } } }, + "node_modules/file-entry-cache": { + "version": "11.1.5", + "resolved": "https://registry.npmmirror.com/file-entry-cache/-/file-entry-cache-11.1.5.tgz", + "integrity": "sha512-+PFTHITI08JIGhnNpGNI8T8inUpgZfk3GNEqfT9R2zZV2iFXg3CvqzSl/uEhs7TSGujYRELEANyDvS8Fj7+S7Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "flat-cache": "^6.1.23" + } + }, + "node_modules/fill-range": { + "version": "7.1.1", + "resolved": "https://registry.npmmirror.com/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", + "dev": true, + "license": "MIT", + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/find-up": { + "version": "5.0.0", + "resolved": "https://registry.npmmirror.com/find-up/-/find-up-5.0.0.tgz", + "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", + "dev": true, + "license": "MIT", + "dependencies": { + "locate-path": "^6.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/flat-cache": { + "version": "6.1.23", + "resolved": "https://registry.npmmirror.com/flat-cache/-/flat-cache-6.1.23.tgz", + "integrity": "sha512-f++BY9pTk+983xK1FLzlLpmM0i0z+jHmx3QESGkURMXujQZz1k5wzwX6hjnQ8goaD0B+sYnDK1yZ6MTyZfUaqA==", + "dev": true, + "license": "MIT", + "dependencies": { + "cacheable": "^2.5.0", + "flatted": "^3.4.2", + "hookified": "^1.15.0" + } + }, + "node_modules/flatted": { + "version": "3.4.4", + "resolved": "https://registry.npmmirror.com/flatted/-/flatted-3.4.4.tgz", + "integrity": "sha512-5+ybhBZANEJxaH3X5evAFatUxLfEHSr7n6kYJ+1Qd0mUqr4eu9gIf6GDbWHf8RJijHrjjO8G+la14SlL2SeS1Q==", + "dev": true, + "license": "ISC" + }, "node_modules/fsevents": { "version": "2.3.3", "resolved": "https://registry.npmmirror.com/fsevents/-/fsevents-2.3.3.tgz", @@ -1961,10 +3181,45 @@ "node": "^8.16.0 || ^10.6.0 || >=11.0.0" } }, + "node_modules/get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmmirror.com/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "license": "ISC", + "engines": { + "node": "6.* || 8.* || >= 10.*" + } + }, + "node_modules/glob-parent": { + "version": "6.0.2", + "resolved": "https://registry.npmmirror.com/glob-parent/-/glob-parent-6.0.2.tgz", + "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", + "dev": true, + "license": "ISC", + "dependencies": { + "is-glob": "^4.0.3" + }, + "engines": { + "node": ">=10.13.0" + } + }, "node_modules/graceful-fs": { "version": "4.2.11", "license": "ISC" }, + "node_modules/hashery": { + "version": "1.5.1", + "resolved": "https://registry.npmmirror.com/hashery/-/hashery-1.5.1.tgz", + "integrity": "sha512-iZyKG96/JwPz1N55vj2Ie2vXbhu440zfUfJvSwEqEbeLluk7NnapfGqa7LH0mOsnDxTF85Mx8/dyR6HfqcbmbQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "hookified": "^1.15.0" + }, + "engines": { + "node": ">=20" + } + }, "node_modules/he": { "version": "1.2.0", "dev": true, @@ -1979,6 +3234,75 @@ "integrity": "sha512-Yc+BQe8SvoXH1643Qez1zqLRmbA5rCL+sSmk6TVos0LWVfNIB7PGncdlId77WzLGSIB5KaWgTaNTs2lNVEI6VQ==", "license": "MIT" }, + "node_modules/hookified": { + "version": "1.15.1", + "resolved": "https://registry.npmmirror.com/hookified/-/hookified-1.15.1.tgz", + "integrity": "sha512-MvG/clsADq1GPM2KGo2nyfaWVyn9naPiXrqIe4jYjXNZQt238kWyOGrsyc/DmRAQ+Re6yeo6yX/yoNCG5KAEVg==", + "dev": true, + "license": "MIT" + }, + "node_modules/ignore": { + "version": "5.3.2", + "resolved": "https://registry.npmmirror.com/ignore/-/ignore-5.3.2.tgz", + "integrity": "sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 4" + } + }, + "node_modules/imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmmirror.com/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.8.19" + } + }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmmirror.com/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmmirror.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmmirror.com/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmmirror.com/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.12.0" + } + }, "node_modules/is-what": { "version": "5.5.0", "resolved": "https://registry.npmmirror.com/is-what/-/is-what-5.5.0.tgz", @@ -1991,6 +3315,13 @@ "url": "https://github.com/sponsors/mesqueeb" } }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmmirror.com/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "dev": true, + "license": "ISC" + }, "node_modules/jiti": { "version": "2.7.0", "license": "MIT", @@ -1998,6 +3329,44 @@ "jiti": "lib/jiti-cli.mjs" } }, + "node_modules/json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmmirror.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true, + "license": "MIT" + }, + "node_modules/json-stable-stringify-without-jsonify": { + "version": "1.0.1", + "resolved": "https://registry.npmmirror.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", + "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", + "dev": true, + "license": "MIT" + }, + "node_modules/keyv": { + "version": "5.6.0", + "resolved": "https://registry.npmmirror.com/keyv/-/keyv-5.6.0.tgz", + "integrity": "sha512-CYDD3SOtsHtyXeEORYRx2qBtpDJFjRTGXUtmNEMGyzYOKj1TE3tycdlho7kA1Ufx9OYWZzg52QFBGALTirzDSw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@keyv/serialize": "^1.1.1" + } + }, + "node_modules/levn": { + "version": "0.4.1", + "resolved": "https://registry.npmmirror.com/levn/-/levn-0.4.1.tgz", + "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "prelude-ls": "^1.2.1", + "type-check": "~0.4.0" + }, + "engines": { + "node": ">= 0.8.0" + } + }, "node_modules/lightningcss": { "version": "1.32.0", "license": "MPL-2.0", @@ -2243,6 +3612,22 @@ "url": "https://opencollective.com/parcel" } }, + "node_modules/locate-path": { + "version": "6.0.0", + "resolved": "https://registry.npmmirror.com/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-locate": "^5.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/magic-string": { "version": "0.30.21", "license": "MIT", @@ -2250,6 +3635,43 @@ "@jridgewell/sourcemap-codec": "^1.5.5" } }, + "node_modules/merge2": { + "version": "1.4.1", + "resolved": "https://registry.npmmirror.com/merge2/-/merge2-1.4.1.tgz", + "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 8" + } + }, + "node_modules/micromatch": { + "version": "4.0.8", + "resolved": "https://registry.npmmirror.com/micromatch/-/micromatch-4.0.8.tgz", + "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", + "dev": true, + "license": "MIT", + "dependencies": { + "braces": "^3.0.3", + "picomatch": "^2.3.1" + }, + "engines": { + "node": ">=8.6" + } + }, + "node_modules/micromatch/node_modules/picomatch": { + "version": "2.3.2", + "resolved": "https://registry.npmmirror.com/picomatch/-/picomatch-2.3.2.tgz", + "integrity": "sha512-V7+vQEJ06Z+c5tSye8S+nHUfI51xoXIXjHQ99cQtKUkQqqO1kO/KCJUfZXuB47h/YBlDhah2H3hdUGXn8ie0oA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, "node_modules/minimatch": { "version": "9.0.9", "dev": true, @@ -2270,6 +3692,13 @@ "integrity": "sha512-vKivATfr97l2/QBCYAkXYDbrIWPM2IIKEl7YPhjCvKlG3kE2gm+uBo6nEXK3M5/Ffh/FLpKExzOQ3JJoJGFKBw==", "license": "MIT" }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmmirror.com/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true, + "license": "MIT" + }, "node_modules/muggle-string": { "version": "0.4.1", "dev": true, @@ -2291,17 +3720,115 @@ "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" } }, + "node_modules/natural-compare": { + "version": "1.4.0", + "resolved": "https://registry.npmmirror.com/natural-compare/-/natural-compare-1.4.0.tgz", + "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", + "dev": true, + "license": "MIT" + }, + "node_modules/nth-check": { + "version": "2.1.1", + "resolved": "https://registry.npmmirror.com/nth-check/-/nth-check-2.1.1.tgz", + "integrity": "sha512-lqjrjmaOoAnWfMmBPL+XNnynZh2+swxiX3WUE0s4yEHI6m+AwrK2UZOimIRl3X/4QctVqS8AiZjFqyOGrMXb/w==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "boolbase": "^1.0.0" + }, + "funding": { + "url": "https://github.com/fb55/nth-check?sponsor=1" + } + }, "node_modules/ohash": { "version": "2.0.11", "resolved": "https://registry.npmmirror.com/ohash/-/ohash-2.0.11.tgz", "integrity": "sha512-RdR9FQrFwNBNXAr4GixM8YaRZRJ5PUWbKYbE5eOsrwAjJW0q2REGcf79oYPsLyskQCZG1PLN+S/K1V00joZAoQ==", "license": "MIT" }, + "node_modules/optionator": { + "version": "0.9.4", + "resolved": "https://registry.npmmirror.com/optionator/-/optionator-0.9.4.tgz", + "integrity": "sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==", + "dev": true, + "license": "MIT", + "dependencies": { + "deep-is": "^0.1.3", + "fast-levenshtein": "^2.0.6", + "levn": "^0.4.1", + "prelude-ls": "^1.2.1", + "type-check": "^0.4.0", + "word-wrap": "^1.2.5" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmmirror.com/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "yocto-queue": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-locate": { + "version": "5.0.0", + "resolved": "https://registry.npmmirror.com/p-locate/-/p-locate-5.0.0.tgz", + "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-limit": "^3.0.2" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-try": { + "version": "2.2.0", + "resolved": "https://registry.npmmirror.com/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, "node_modules/path-browserify": { "version": "1.0.1", "dev": true, "license": "MIT" }, + "node_modules/path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmmirror.com/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmmirror.com/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, "node_modules/perfect-debounce": { "version": "1.0.0", "resolved": "https://registry.npmmirror.com/perfect-debounce/-/perfect-debounce-1.0.0.tgz", @@ -2349,6 +3876,15 @@ "integrity": "sha512-jV38yxXHLfidirMC4hrXasLDozLCSq/4DfX88GnHcSEJ2+GpSedG6I9VOiEXJu6iQ5dbJC/RjmzyMuS5h/wH5A==", "license": "MIT" }, + "node_modules/pngjs": { + "version": "5.0.0", + "resolved": "https://registry.npmmirror.com/pngjs/-/pngjs-5.0.0.tgz", + "integrity": "sha512-40QW5YalBNfQo5yRYmiw7Yz6TKKVr3h6970B2YE+3fQpsWcrbj1PzJgxeJ19DRQjhMbKPIuMY8rFaXc8moolVw==", + "license": "MIT", + "engines": { + "node": ">=10.13.0" + } + }, "node_modules/postcss": { "version": "8.5.19", "funding": [ @@ -2375,10 +3911,102 @@ "node": "^10 || ^12 || >=14" } }, + "node_modules/postcss-selector-parser": { + "version": "7.1.6", + "resolved": "https://registry.npmmirror.com/postcss-selector-parser/-/postcss-selector-parser-7.1.6.tgz", + "integrity": "sha512-7qASPzhKF2l2KLboRZux8CCTRMdGiV08vWmyKzPz22qZ7ZjQBOeY7rNzNoCLSUiftJ7HUq0GERHmxw/t0dCdMw==", + "dev": true, + "license": "MIT", + "dependencies": { + "cssesc": "^3.0.0", + "util-deprecate": "^1.0.2" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/prelude-ls": { + "version": "1.2.1", + "resolved": "https://registry.npmmirror.com/prelude-ls/-/prelude-ls-1.2.1.tgz", + "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/punycode": { + "version": "2.3.1", + "resolved": "https://registry.npmmirror.com/punycode/-/punycode-2.3.1.tgz", + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/qified": { + "version": "0.10.1", + "resolved": "https://registry.npmmirror.com/qified/-/qified-0.10.1.tgz", + "integrity": "sha512-+Owyggi9IxT1ePKGafcI87ubSmxol6smwJ+RAHDQlx9+9cPwFWDiKFFCPuWhr9ignlGpZ9vDQLw67N4dcTVFEA==", + "dev": true, + "license": "MIT", + "dependencies": { + "hookified": "^2.1.1" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/qified/node_modules/hookified": { + "version": "2.2.0", + "resolved": "https://registry.npmmirror.com/hookified/-/hookified-2.2.0.tgz", + "integrity": "sha512-p/LgFzRN5FeoD3DLS6bkUapeye6E4SI6yJs6KetENd18S+FBthqYq2amJUWpt5z0EQwwHemidjY5OqJGEKm5uA==", + "dev": true, + "license": "MIT" + }, + "node_modules/qrcode": { + "version": "1.5.4", + "resolved": "https://registry.npmmirror.com/qrcode/-/qrcode-1.5.4.tgz", + "integrity": "sha512-1ca71Zgiu6ORjHqFBDpnSMTR2ReToX4l1Au1VFLyVeBTFavzQnv5JxMFr3ukHVKpSrSA2MCk0lNJSykjUfz7Zg==", + "license": "MIT", + "dependencies": { + "dijkstrajs": "^1.0.1", + "pngjs": "^5.0.0", + "yargs": "^15.3.1" + }, + "bin": { + "qrcode": "bin/qrcode" + }, + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/queue-microtask": { + "version": "1.2.3", + "resolved": "https://registry.npmmirror.com/queue-microtask/-/queue-microtask-1.2.3.tgz", + "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, "node_modules/reka-ui": { - "version": "2.10.1", - "resolved": "https://registry.npmmirror.com/reka-ui/-/reka-ui-2.10.1.tgz", - "integrity": "sha512-drcOQ4rQtDYAcGCsyQBqQg8QQ+H3B+zDaMJU0h8KPEPMa7g9BHu3zcOi4OB39XJSWizceFoNO0Z9tctSGLOXqg==", + "version": "2.10.5", + "resolved": "https://registry.npmmirror.com/reka-ui/-/reka-ui-2.10.5.tgz", + "integrity": "sha512-/8o0y9BThE0hcHKFg+3770tWcJh3qKdOEFxLOPb9HIajXeFoH/J530cZH62jUJunbqwBgpSBL9v7nB8LJ5pDXA==", "license": "MIT", "dependencies": { "@floating-ui/dom": "^1.6.13", @@ -2400,6 +4028,32 @@ "vue": ">= 3.4.0" } }, + "node_modules/require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmmirror.com/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/require-main-filename": { + "version": "2.0.0", + "resolved": "https://registry.npmmirror.com/require-main-filename/-/require-main-filename-2.0.0.tgz", + "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==", + "license": "ISC" + }, + "node_modules/reusify": { + "version": "1.1.0", + "resolved": "https://registry.npmmirror.com/reusify/-/reusify-1.1.0.tgz", + "integrity": "sha512-g6QUff04oZpHs0eG5p83rFLhHeV00ug/Yf9nZM6fLeUrPguBTkTQOdpAWWspMh55TZfVQDPaN3NQJfbVRAxdIw==", + "dev": true, + "license": "MIT", + "engines": { + "iojs": ">=1.0.0", + "node": ">=0.10.0" + } + }, "node_modules/rfdc": { "version": "1.4.1", "resolved": "https://registry.npmmirror.com/rfdc/-/rfdc-1.4.1.tgz", @@ -2448,6 +4102,72 @@ "fsevents": "~2.3.2" } }, + "node_modules/run-parallel": { + "version": "1.2.0", + "resolved": "https://registry.npmmirror.com/run-parallel/-/run-parallel-1.2.0.tgz", + "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT", + "dependencies": { + "queue-microtask": "^1.2.2" + } + }, + "node_modules/semver": { + "version": "7.8.5", + "resolved": "https://registry.npmmirror.com/semver/-/semver-7.8.5.tgz", + "integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmmirror.com/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==", + "license": "ISC" + }, + "node_modules/shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmmirror.com/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "license": "MIT", + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmmirror.com/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, "node_modules/source-map-js": { "version": "1.2.1", "license": "BSD-3-Clause", @@ -2464,6 +4184,32 @@ "node": ">=0.10.0" } }, + "node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmmirror.com/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "license": "MIT", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmmirror.com/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "license": "MIT", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/superjson": { "version": "2.2.6", "resolved": "https://registry.npmmirror.com/superjson/-/superjson-2.2.6.tgz", @@ -2515,6 +4261,32 @@ "url": "https://github.com/sponsors/SuperchupuDev" } }, + "node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmmirror.com/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } + }, + "node_modules/ts-api-utils": { + "version": "2.5.0", + "resolved": "https://registry.npmmirror.com/ts-api-utils/-/ts-api-utils-2.5.0.tgz", + "integrity": "sha512-OJ/ibxhPlqrMM0UiNHJ/0CKQkoKF243/AEmplt3qpRgkW8VG7IfOS41h7V8TjITqdByHzrjcS/2si+y4lIh8NA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18.12" + }, + "peerDependencies": { + "typescript": ">=4.8.4" + } + }, "node_modules/tslib": { "version": "2.8.1", "resolved": "https://registry.npmmirror.com/tslib/-/tslib-2.8.1.tgz", @@ -2531,6 +4303,19 @@ "url": "https://github.com/sponsors/Wombosvideo" } }, + "node_modules/type-check": { + "version": "0.4.0", + "resolved": "https://registry.npmmirror.com/type-check/-/type-check-0.4.0.tgz", + "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", + "dev": true, + "license": "MIT", + "dependencies": { + "prelude-ls": "^1.2.1" + }, + "engines": { + "node": ">= 0.8.0" + } + }, "node_modules/typescript": { "version": "5.6.3", "devOptional": true, @@ -2543,6 +4328,30 @@ "node": ">=14.17" } }, + "node_modules/typescript-eslint": { + "version": "8.70.1", + "resolved": "https://registry.npmmirror.com/typescript-eslint/-/typescript-eslint-8.70.1.tgz", + "integrity": "sha512-AcWG7KDjZ2THNXsgwttMaGmzVi0VFRlFYfqFHYQRbDpF3owuYbuiL8c7UUrd2k8s3PoSfIQrWfrGXfcElrWLYA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/eslint-plugin": "8.70.1", + "@typescript-eslint/parser": "8.70.1", + "@typescript-eslint/typescript-estree": "8.70.1", + "@typescript-eslint/utils": "8.70.1" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0", + "typescript": ">=4.8.4 <6.1.0" + } + }, "node_modules/undici-types": { "version": "8.3.0", "resolved": "https://registry.npmmirror.com/undici-types/-/undici-types-8.3.0.tgz", @@ -2550,6 +4359,23 @@ "devOptional": true, "license": "MIT" }, + "node_modules/uri-js": { + "version": "4.4.1", + "resolved": "https://registry.npmmirror.com/uri-js/-/uri-js-4.4.1.tgz", + "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "punycode": "^2.1.0" + } + }, + "node_modules/util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmmirror.com/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", + "dev": true, + "license": "MIT" + }, "node_modules/vite": { "version": "6.4.3", "license": "MIT", @@ -2663,6 +4489,43 @@ } } }, + "node_modules/vue-eslint-parser": { + "version": "10.4.1", + "resolved": "https://registry.npmmirror.com/vue-eslint-parser/-/vue-eslint-parser-10.4.1.tgz", + "integrity": "sha512-Gk6gRDj0n/fkRa3C3l0bBheoBckUq/Rs0F/TvMWIS6nzzx67amAViMe9CkNgsP2tXyQONvGiHQESHwFtZ3aYDA==", + "dev": true, + "license": "MIT", + "dependencies": { + "debug": "^4.4.0", + "eslint-scope": "^8.2.0 || ^9.0.0", + "eslint-visitor-keys": "^4.2.0 || ^5.0.0", + "espree": "^10.3.0 || ^11.0.0", + "esquery": "^1.6.0", + "semver": "^7.6.3" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://github.com/sponsors/mysticatea" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0" + } + }, + "node_modules/vue-eslint-parser/node_modules/eslint-visitor-keys": { + "version": "5.0.1", + "resolved": "https://registry.npmmirror.com/eslint-visitor-keys/-/eslint-visitor-keys-5.0.1.tgz", + "integrity": "sha512-tD40eHxA35h0PEIZNeIjkHoDR4YjjJp34biM0mDvplBe//mB+IHCqHDGV7pxF+7MklTvighcCPPZC7ynWyjdTA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, "node_modules/vue-sonner": { "version": "2.0.9", "resolved": "https://registry.npmmirror.com/vue-sonner/-/vue-sonner-2.0.9.tgz", @@ -2699,6 +4562,168 @@ "peerDependencies": { "typescript": ">=5.0.0" } + }, + "node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmmirror.com/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "license": "ISC", + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/which-module": { + "version": "2.0.1", + "resolved": "https://registry.npmmirror.com/which-module/-/which-module-2.0.1.tgz", + "integrity": "sha512-iBdZ57RDvnOR9AGBhML2vFZf7h8vmBjhoaZqODJBFWHVtKkDmKuHai3cx5PgVMrX5YDNp27AofYbAwctSS+vhQ==", + "license": "ISC" + }, + "node_modules/word-wrap": { + "version": "1.2.5", + "resolved": "https://registry.npmmirror.com/word-wrap/-/word-wrap-1.2.5.tgz", + "integrity": "sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/wrap-ansi": { + "version": "6.2.0", + "resolved": "https://registry.npmmirror.com/wrap-ansi/-/wrap-ansi-6.2.0.tgz", + "integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==", + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/xml-name-validator": { + "version": "5.0.0", + "resolved": "https://registry.npmmirror.com/xml-name-validator/-/xml-name-validator-5.0.0.tgz", + "integrity": "sha512-EvGK8EJ3DhaHfbRlETOWAS5pO9MZITeauHKJyb8wyajUfQUenkIg2MvLDTZ4T/TgIcm3HU0TFBgWWboAZ30UHg==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=18" + } + }, + "node_modules/y18n": { + "version": "4.0.3", + "resolved": "https://registry.npmmirror.com/y18n/-/y18n-4.0.3.tgz", + "integrity": "sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==", + "license": "ISC" + }, + "node_modules/yargs": { + "version": "15.4.1", + "resolved": "https://registry.npmmirror.com/yargs/-/yargs-15.4.1.tgz", + "integrity": "sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==", + "license": "MIT", + "dependencies": { + "cliui": "^6.0.0", + "decamelize": "^1.2.0", + "find-up": "^4.1.0", + "get-caller-file": "^2.0.1", + "require-directory": "^2.1.1", + "require-main-filename": "^2.0.0", + "set-blocking": "^2.0.0", + "string-width": "^4.2.0", + "which-module": "^2.0.0", + "y18n": "^4.0.0", + "yargs-parser": "^18.1.2" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/yargs-parser": { + "version": "18.1.3", + "resolved": "https://registry.npmmirror.com/yargs-parser/-/yargs-parser-18.1.3.tgz", + "integrity": "sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==", + "license": "ISC", + "dependencies": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/yargs/node_modules/find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmmirror.com/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "license": "MIT", + "dependencies": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/yargs/node_modules/locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmmirror.com/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "license": "MIT", + "dependencies": { + "p-locate": "^4.1.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/yargs/node_modules/p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmmirror.com/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "license": "MIT", + "dependencies": { + "p-try": "^2.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/yargs/node_modules/p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmmirror.com/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "license": "MIT", + "dependencies": { + "p-limit": "^2.2.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/yocto-queue": { + "version": "0.1.0", + "resolved": "https://registry.npmmirror.com/yocto-queue/-/yocto-queue-0.1.0.tgz", + "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } } } } diff --git a/package.json b/package.json index 741a1b6..4ec8ad8 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "tauri": "tauri" }, "dependencies": { - "@lucide/vue": "^1.28.0", + "@lucide/vue": "^1.48.0", "@tailwindcss/vite": "^4.3.2", "@tauri-apps/api": "^2", "@tauri-apps/plugin-autostart": "~2", @@ -34,7 +34,7 @@ "pinia": "^3.0.4", "pinyin-pro": "^3.28.2", "qrcode": "^1.5.4", - "reka-ui": "^2.10.1", + "reka-ui": "^2.10.5", "tailwind-merge": "^3.6.0", "tailwindcss": "^4.3.2", "vue": "^3.5.13", diff --git a/src-tauri/src/constants.rs b/src-tauri/src/constants.rs index 359e12a..75911cc 100644 --- a/src-tauri/src/constants.rs +++ b/src-tauri/src/constants.rs @@ -22,6 +22,10 @@ pub mod windows { /// 文件管理器独立窗口。**单例**(label 固定,不含会话 id): /// 它不绑定会话,左右两栏各自选择连接,因此没有「每会话一个窗口」的语义。 pub const FILE_WINDOW: &str = "file-window"; + /// dsh 模块的 Web UI 独立窗口(内容是远端 `http://127.0.0.1:`, + /// 因此**不登记 capability**:远端页面不应获得任何 Tauri 权限)。 + #[allow(dead_code)] + pub const DSH_WEB: &str = "dsh-web"; } /// Tauri 事件名(与前端 constants::EVENTS 对应) @@ -123,4 +127,11 @@ pub mod events { pub const DOWNLOAD_REMOVED: &str = "download-removed"; /// 浏览器扩展通过 HTTP API 新增下载(负载 { id },前端据以为该任务创建专属下载窗口) pub const DOWNLOAD_EXTENSION_ADDED: &str = "download-extension-added"; + // dsh 模块:安装/下载进度(负载见 dsh::types::DshInstallProgress) + pub const DSH_INSTALL_PROGRESS: &str = "dsh-install-progress"; + // dsh 模块:服务进程状态(负载见 dsh::types::DshServerStatus) + pub const DSH_SERVER_STATE: &str = "dsh-server-state"; + /// dsh 模块:全局快捷键触发「打开独立窗口」(无负载)。 + /// 窗口由前端创建(它持有带令牌的地址与 label 判重),Rust 侧只负责注册快捷键。 + pub const DSH_OPEN_WINDOW: &str = "dsh-open-window"; } diff --git a/src-tauri/src/dsh/ai_sync.rs b/src-tauri/src/dsh/ai_sync.rs new file mode 100644 index 0000000..ffa56f7 --- /dev/null +++ b/src-tauri/src/dsh/ai_sync.rs @@ -0,0 +1,253 @@ +//! AI 装载:把主设置(AI 服务)里的供应商映射进 dsh 的 `$DSH_HOME/settings.yaml`, +//! 并在启动服务时以环境变量注入 API Key。 +//! +//! 安全姿态(对齐 `crate::ai` 与 `crate::secrets`):**密钥不落盘**。 +//! settings.yaml 里只写 `apiKeyEnv`(环境变量名),明文由 +//! [`crate::ai::provider_api_key`] 从系统凭据管理器读出后随子进程环境注入。 +//! +//! 合并规则:只替换 `llm-pi-ai.providers` 下本模块管理的 `thing-*` 键与 +//! `agent-default-model`,用户自己写的其它段落(profile patch / 第三方插件配置) +//! 原样保留;写盘前把旧文件备份为 `settings.yaml.bak`。 + +use serde_yaml::{Mapping, Value}; +use tauri::AppHandle; + +use super::types::{DshAiPreview, DshAiProvider}; +use super::DshManager; + +/// 本模块写入 settings.yaml 的供应商键前缀。 +const PROVIDER_PREFIX: &str = "thing-"; +/// `llm-pi-ai` 段名(dsh 的通用 OpenAI 兼容提供方插件)。 +const LLM_SECTION: &str = "llm-pi-ai"; +/// 默认模型段名。 +const DEFAULT_MODEL_SECTION: &str = "agent-default-model"; + +impl DshManager { + /// dsh 侧供应商键(`thing-`,只保留小写字母数字与短横线)。 + fn dsh_provider_id(id: &str) -> String { + let sanitized: String = id + .trim() + .to_lowercase() + .chars() + .map(|c| if c.is_ascii_alphanumeric() { c } else { '-' }) + .collect(); + format!("{PROVIDER_PREFIX}{sanitized}") + } + + /// 环境变量名(`THING_AI__KEY`)。 + fn env_name(id: &str) -> String { + let sanitized: String = id + .trim() + .to_uppercase() + .chars() + .map(|c| if c.is_ascii_alphanumeric() { c } else { '_' }) + .collect(); + format!("THING_AI_{sanitized}_KEY") + } + + /// settings.yaml 路径(`$DSH_HOME/settings.yaml`)。 + pub fn dsh_settings_path(&self) -> std::path::PathBuf { + self.home_dir().join("settings.yaml") + } + + /// 当前将被映射的供应商列表(enabled 且 baseUrl 非空)。 + pub fn ai_providers(&self) -> Vec { + let settings = crate::ai::AiManager::load_settings_sync(&self.data_dir); + settings + .providers + .iter() + .filter(|p| p.enabled && !p.base_url.trim().is_empty() && !p.model.trim().is_empty()) + .map(|p| DshAiProvider { + id: p.id.clone(), + name: p.name.clone(), + env_name: Self::env_name(&p.id), + base_url: p.base_url.clone(), + model: p.model.clone(), + has_key: !crate::ai::provider_api_key(&p.id).is_empty(), + }) + .collect() + } + + /// 构造本模块管理的配置片段(`llm-pi-ai.providers` + `agent-default-model`)。 + fn build_patch(&self) -> (Mapping, Value, Option, Option) { + let settings = crate::ai::AiManager::load_settings_sync(&self.data_dir); + let mut providers = Mapping::new(); + let mut default_pair: Option<(String, String)> = None; + let wanted = self.load_settings().provider_id; + + for p in settings.providers.iter() { + if !p.enabled || p.base_url.trim().is_empty() || p.model.trim().is_empty() { + continue; + } + let dsh_id = Self::dsh_provider_id(&p.id); + let mut entry = Mapping::new(); + entry.insert( + Value::String("displayName".into()), + Value::String(if p.name.trim().is_empty() { + p.id.clone() + } else { + p.name.clone() + }), + ); + entry.insert( + Value::String("api".into()), + Value::String("openai-completions".into()), + ); + entry.insert( + Value::String("baseURL".into()), + Value::String(p.base_url.trim().trim_end_matches('/').to_string()), + ); + entry.insert( + Value::String("apiKeyEnv".into()), + Value::String(Self::env_name(&p.id)), + ); + // 模型目录:当前模型 + 常见上下文窗口(字段名以 dsh 的 catalog 为准, + // 这里只写最稳定的 id/name,避免写错字段导致 dsh 拒绝配置) + let mut model = Mapping::new(); + model.insert(Value::String("id".into()), Value::String(p.model.clone())); + model.insert(Value::String("name".into()), Value::String(p.model.clone())); + entry.insert( + Value::String("models".into()), + Value::Sequence(vec![Value::Mapping(model)]), + ); + providers.insert(Value::String(dsh_id.clone()), Value::Mapping(entry)); + + let is_wanted = p.id == wanted || (wanted.is_empty() && default_pair.is_none()); + if is_wanted { + default_pair = Some((dsh_id, p.model.clone())); + } + } + + let default_value = match &default_pair { + Some((provider, model)) => { + let mut m = Mapping::new(); + m.insert(Value::String("provider".into()), Value::String(provider.clone())); + m.insert(Value::String("model".into()), Value::String(model.clone())); + Value::Mapping(m) + } + None => Value::Null, + }; + let default_provider = default_pair.as_ref().map(|(p, _)| p.clone()); + let default_model = default_pair.map(|(_, m)| m); + (providers, default_value, default_provider, default_model) + } + + /// 预览将要写入的 YAML(不含明文密钥)。 + pub fn ai_preview(&self) -> DshAiPreview { + let (providers, default_value, default_provider, default_model) = self.build_patch(); + let mut root = Mapping::new(); + if !default_value.is_null() { + root.insert(Value::String(DEFAULT_MODEL_SECTION.into()), default_value); + } + let mut llm = Mapping::new(); + llm.insert(Value::String("providers".into()), Value::Mapping(providers)); + root.insert(Value::String(LLM_SECTION.into()), Value::Mapping(llm)); + + let yaml = serde_yaml::to_string(&Value::Mapping(root)) + .unwrap_or_else(|e| format!("# 生成预览失败: {e}")); + DshAiPreview { + yaml, + providers: self.ai_providers(), + default_provider, + default_model, + settings_path: self.dsh_settings_path().to_string_lossy().to_string(), + } + } + + /// 生成/合并 `$DSH_HOME/settings.yaml`(写盘前备份旧文件)。 + pub fn ai_sync(&self, _app: &AppHandle) -> Result<(), String> { + let (providers, default_value, _, _) = self.build_patch(); + let path = self.dsh_settings_path(); + if let Some(parent) = path.parent() { + std::fs::create_dir_all(parent).map_err(|e| format!("创建 $DSH_HOME 失败: {e}"))?; + } + + // 读现有文档(缺失/非映射时用空映射起步) + let existing = std::fs::read_to_string(&path).ok(); + let mut doc = existing + .as_deref() + .and_then(|t| serde_yaml::from_str::(t).ok()) + .filter(|v| v.is_mapping()) + .unwrap_or_else(|| Value::Mapping(Mapping::new())); + let root = doc.as_mapping_mut().ok_or_else(|| "settings.yaml 结构非法".to_string())?; + + // 备份 + if existing.is_some() { + std::fs::write(path.with_extension("yaml.bak"), existing.as_deref().unwrap_or_default()) + .map_err(|e| format!("备份 settings.yaml 失败: {e}"))?; + } + + // llm-pi-ai.providers:只替换本模块管理的 thing-* 键 + let llm_key = Value::String(LLM_SECTION.into()); + let llm_entry = root + .entry(llm_key) + .or_insert_with(|| Value::Mapping(Mapping::new())); + if !llm_entry.is_mapping() { + *llm_entry = Value::Mapping(Mapping::new()); + } + let llm_map = llm_entry.as_mapping_mut().expect("已保证为映射"); + let providers_key = Value::String("providers".into()); + let providers_entry = llm_map + .entry(providers_key) + .or_insert_with(|| Value::Mapping(Mapping::new())); + if !providers_entry.is_mapping() { + *providers_entry = Value::Mapping(Mapping::new()); + } + let providers_map = providers_entry.as_mapping_mut().expect("已保证为映射"); + // 先清掉上一次由本模块写入的键(用户自建的其它键保留) + let stale: Vec = providers_map + .keys() + .filter(|k| { + k.as_str() + .map(|s| s.starts_with(PROVIDER_PREFIX)) + .unwrap_or(false) + }) + .cloned() + .collect(); + for key in stale { + providers_map.remove(&key); + } + for (key, value) in providers.iter() { + providers_map.insert(key.clone(), value.clone()); + } + + // agent-default-model + if default_value.is_null() { + root.remove(&Value::String(DEFAULT_MODEL_SECTION.into())); + } else { + root.insert(Value::String(DEFAULT_MODEL_SECTION.into()), default_value); + } + + let text = serde_yaml::to_string(&doc).map_err(|e| format!("序列化 settings.yaml 失败: {e}"))?; + std::fs::write(&path, text).map_err(|e| format!("写入 settings.yaml 失败: {e}"))?; + crate::logger::log_info( + "dsh", + &format!("已同步 AI 供应商到 {}", path.display()), + ); + Ok(()) + } + + /// 启动服务时注入的环境变量(供应商密钥 + DeepSeek 官方变量兜底)。 + pub fn ai_env_vars(&self) -> Vec<(String, String)> { + let settings = crate::ai::AiManager::load_settings_sync(&self.data_dir); + let mut vars: Vec<(String, String)> = Vec::new(); + for p in settings.providers.iter() { + if !p.enabled || p.base_url.trim().is_empty() || p.model.trim().is_empty() { + continue; + } + let key = crate::ai::provider_api_key(&p.id); + if key.is_empty() { + continue; + } + vars.push((Self::env_name(&p.id), key.clone())); + // DeepSeek 官方通道:dsh 内置 provider 直接读 DEEPSEEK_API_KEY + let is_deepseek = p.id.eq_ignore_ascii_case("deepseek") + || p.preset.eq_ignore_ascii_case("deepseek") + || p.base_url.contains("api.deepseek.com"); + if is_deepseek { + vars.push(("DEEPSEEK_API_KEY".into(), key)); + } + } + vars + } +} \ No newline at end of file diff --git a/src-tauri/src/dsh/commands.rs b/src-tauri/src/dsh/commands.rs new file mode 100644 index 0000000..b52e82f --- /dev/null +++ b/src-tauri/src/dsh/commands.rs @@ -0,0 +1,232 @@ +//! dsh 模块的 Tauri 命令层。 +//! +//! 前端统一经 `@/lib/bindings` 的 `commands.dsh*` 调用。 +//! 进度事件 `dsh-install-progress`、状态事件 `dsh-server-state` 见 +//! `crate::constants::events`(与 `src/lib/constants.ts` 的 `EVENTS` 对应)。 + +use tauri::Manager; +use tauri::{AppHandle, State}; +use tauri_plugin_opener::OpenerExt; + +use super::types::{ + DshAiPreview, DshEnvStatus, DshInstallStatus, DshNpmRegistryInfo, DshServerStatus, DshSettings, + DshUpdateInfo, NodeStatus, +}; +use super::DshManager; + +/// 环境总览:Node / dsh / 服务状态 + 模块设置(模块首屏一次拿全)。 +/// +/// 声明为 `async`:Tauri 的**同步**命令在主线程执行,而本命令要跑 +/// `node --version` 子进程探测,放主线程会造成界面卡顿。 +/// (async 命令带 `State<'_>` 引用参数时必须返回 `Result`,故这里包一层 Ok。) +#[tauri::command] +#[specta::specta] +pub async fn dsh_env_status(state: State<'_, DshManager>) -> Result { + Ok(DshEnvStatus { + node: state.node_status(), + dsh: state.install_status(), + server: state.server_status(), + settings: state.load_settings(), + }) +} + +/// 重新探测 Node(系统 PATH + 托管目录)。同样因执行 `node --version` 而用 async。 +#[tauri::command] +#[specta::specta] +pub async fn dsh_node_detect(state: State<'_, DshManager>) -> Result { + Ok(state.node_status()) +} + +/// 下载并安装便携 Node(`version` 为空 = 自动取满足要求的最新版)。 +#[tauri::command] +#[specta::specta] +pub async fn dsh_node_install( + app: AppHandle, + state: State<'_, DshManager>, + version: Option, +) -> Result { + state.node_install(&app, version).await +} + +/// 安装 dsh(`version` 为空 = latest)。 +#[tauri::command] +#[specta::specta] +pub async fn dsh_install( + app: AppHandle, + state: State<'_, DshManager>, + version: Option, +) -> Result { + state.install(&app, version).await +} + +/// 更新 dsh 到 latest(更新前停止服务,避免文件被占用)。 +#[tauri::command] +#[specta::specta] +pub async fn dsh_update( + app: AppHandle, + state: State<'_, DshManager>, +) -> Result { + state.stop_server(&app); + state.install(&app, None).await +} + +/// 卸载 dsh(停止服务并删除包目录;保留设置与 $DSH_HOME)。 +#[tauri::command] +#[specta::specta] +pub fn dsh_uninstall(app: AppHandle, state: State<'_, DshManager>) -> Result<(), String> { + state.uninstall(&app) +} + +/// 取消进行中的下载 / 安装。 +#[tauri::command] +#[specta::specta] +pub fn dsh_cancel_install(state: State<'_, DshManager>) { + state.request_cancel(); +} + +/// 查询 npm 上的可用版本。 +#[tauri::command] +#[specta::specta] +pub async fn dsh_check_update(state: State<'_, DshManager>) -> Result { + state.check_update().await +} + +/// 读取「本次安装实际使用的 npm 源」及其来源。 +/// +/// 设置为空时 npm 会用自己配置链里的源(含系统 Node 的 `~/.npmrc`), +/// 这里把解析结果回给前端展示,让用户能看出「到底走的是哪个源」。 +/// async:内部要跑 `node config get registry` 子进程。 +#[tauri::command] +#[specta::specta] +pub async fn dsh_npm_registry_info( + state: State<'_, DshManager>, +) -> Result { + Ok(state.npm_registry_info()) +} + +#[tauri::command] +#[specta::specta] +pub fn dsh_get_settings(state: State<'_, DshManager>) -> DshSettings { + state.load_settings() +} + +/// 保存设置(即时生效;端口等改动在下次启动服务时生效)。 +#[tauri::command] +#[specta::specta] +pub fn dsh_save_settings( + state: State<'_, DshManager>, + settings: DshSettings, +) -> Result { + state.save_settings(settings) +} + +/// 启动 dsh Web 服务。async:内部要 spawn 子进程 + 读凭据 + 写 settings.yaml, +/// 同步命令会在主线程执行从而卡住界面。 +#[tauri::command] +#[specta::specta] +pub async fn dsh_start(app: AppHandle, state: State<'_, DshManager>) -> Result { + state.start_server(&app) +} + +/// 停止 dsh Web 服务。 +#[tauri::command] +#[specta::specta] +pub async fn dsh_stop(app: AppHandle, state: State<'_, DshManager>) -> Result { + state.stop_server(&app); + Ok(state.server_status()) +} + +/// 重启 dsh Web 服务。 +#[tauri::command] +#[specta::specta] +pub async fn dsh_restart(app: AppHandle, state: State<'_, DshManager>) -> Result { + state.stop_server(&app); + // Windows 上端口释放有延迟,稍等再起,避免 bind 预检误判占用 + // (用异步 sleep:同步命令在主线程执行,阻塞 500ms 会冻界面) + tokio::time::sleep(std::time::Duration::from_millis(500)).await; + state.start_server(&app) +} + +/// 预览将写入 `$DSH_HOME/settings.yaml` 的内容(不含明文密钥)。 +#[tauri::command] +#[specta::specta] +pub fn dsh_ai_preview(state: State<'_, DshManager>) -> DshAiPreview { + state.ai_preview() +} + +/// 执行 AI 配置同步(合并写入 settings.yaml,写前备份)。 +#[tauri::command] +#[specta::specta] +pub fn dsh_ai_sync(app: AppHandle, state: State<'_, DshManager>) -> Result { + state.ai_sync(&app)?; + Ok(state.ai_preview()) +} + +/// 读取服务日志尾部。 +#[tauri::command] +#[specta::specta] +pub fn dsh_log_tail(state: State<'_, DshManager>, lines: u32) -> String { + state.log_tail(lines as usize) +} + +/// 读取 dsh 安装输出(npm 的 stdout/stderr 尾部)。 +/// +/// 只存在内存里(每次安装开始时清空),供「安装引导 → dsh 本体」页临时展示, +/// **不写应用日志、不落盘**。前端在安装进行中轮询这个命令。 +#[tauri::command] +#[specta::specta] +pub fn dsh_install_log(state: State<'_, DshManager>) -> String { + state.install_log() +} + +#[tauri::command] +#[specta::specta] +pub fn dsh_log_clear(state: State<'_, DshManager>) { + state.clear_log(); +} + +/// 在资源管理器中打开 dsh 模块目录。 +#[tauri::command] +#[specta::specta] +pub fn dsh_open_dir(app: AppHandle, state: State<'_, DshManager>) -> Result<(), String> { + app.opener() + .open_path(state.root().to_string_lossy().to_string(), None::<&str>) + .map_err(|e| format!("打开目录失败: {e}")) +} + +/// 注册(或切换)「打开 dsh 独立窗口」全局快捷键;传空字符串则注销。 +/// +/// 按下时只 emit `dsh-open-window` 事件,**窗口由前端创建**:前端才持有带令牌的 +/// 启动地址,也能用 label 判重复用已开窗口(与截图模块「快捷键 → 事件 → 前端开窗」同构)。 +#[tauri::command] +#[specta::specta] +pub async fn dsh_register_shortcut(app: AppHandle, shortcut: String) -> Result<(), String> { + crate::shortcut::register_shortcut(&app, "dsh", &shortcut, |a| { + use tauri::Emitter; + let _ = a.emit(crate::constants::events::DSH_OPEN_WINDOW, ()); + }) +} + +/// 注销「打开 dsh 独立窗口」全局快捷键。 +#[tauri::command] +#[specta::specta] +pub async fn dsh_unregister_shortcut(app: AppHandle) -> Result<(), String> { + crate::shortcut::unregister_shortcut(&app, "dsh"); + Ok(()) +} + +/// 供 `setup.rs` 在应用启动时按设置自启服务。 +pub fn autostart_if_enabled(app: &AppHandle) { + let manager = app.state::(); + let settings = manager.load_settings(); + if !settings.auto_start { + return; + } + if !manager.install_status().installed { + crate::logger::log_warn("dsh", "设置了自动启动,但 dsh 尚未安装,跳过"); + return; + } + if let Err(e) = manager.start_server(app) { + crate::logger::log_warn("dsh", &format!("自动启动 dsh 服务失败: {e}")); + } +} \ No newline at end of file diff --git a/src-tauri/src/dsh/install.rs b/src-tauri/src/dsh/install.rs new file mode 100644 index 0000000..a79bf6b --- /dev/null +++ b/src-tauri/src/dsh/install.rs @@ -0,0 +1,397 @@ +//! dsh 本体的安装 / 更新 / 卸载与版本查询。 +//! +//! 安装方式:用当前解析出的 Node 自带的 npm,把 `@deepseek-ai/dsh` 装进模块目录 +//! (`npm install --prefix {app_data}/dsh`)。好处是版本可锁、可配镜像源、可复用 +//! 已下载的依赖,且启动时直接 `node `,不依赖 PATH 上的全局 shim。 +//! +//! npm 调用形态:`node install ...`(不走 npm.cmd,理由见 `node.rs`)。 + +use std::io::{BufRead, BufReader}; +use std::path::PathBuf; +use std::sync::atomic::Ordering; +use std::sync::Arc; + +use tauri::{AppHandle, Emitter}; + +use super::node::NODE_CANCELLED; +use super::types::{DshInstallProgress, DshInstallStatus, DshNpmRegistryInfo, DshUpdateInfo, DSH_PACKAGE}; +use super::DshManager; + +impl DshManager { + /// dsh 包目录 + fn package_dir(&self) -> PathBuf { + self.install_root() + .join("node_modules") + .join("@deepseek-ai") + .join("dsh") + } + + /// 已安装版本(读 package.json,不起进程) + pub fn installed_version(&self) -> Option { + let text = std::fs::read_to_string(self.package_dir().join("package.json")).ok()?; + let value: serde_json::Value = serde_json::from_str(&text).ok()?; + value + .get("version") + .and_then(|v| v.as_str()) + .map(|s| s.to_string()) + } + + /// dsh bin 入口(`package.json` 的 `bin.dsh`),启动服务时直接 `node <入口>`。 + pub fn bin_entry(&self) -> Option { + let dir = self.package_dir(); + let text = std::fs::read_to_string(dir.join("package.json")).ok()?; + let value: serde_json::Value = serde_json::from_str(&text).ok()?; + let rel = match value.get("bin") { + Some(serde_json::Value::String(s)) => s.clone(), + Some(serde_json::Value::Object(map)) => map.get("dsh")?.as_str()?.to_string(), + _ => return None, + }; + let entry = dir.join(rel); + entry.exists().then_some(entry) + } + + /// 安装状态 + pub fn install_status(&self) -> DshInstallStatus { + let version = self.installed_version(); + let entry = self.bin_entry(); + DshInstallStatus { + installed: version.is_some() && entry.is_some(), + version, + entry: entry.map(|p| p.to_string_lossy().to_string()), + dir: self.install_root().to_string_lossy().to_string(), + } + } + + /// 模块设置里**显式**填写的 npm 源(空 = 未指定,交给 npm 自己解析)。 + /// + /// 与 [`Self::npm_registry_info`] 的区别:这里只认模块设置。安装时只在 + /// 显式填写的情况下才传 `--registry`,其余情况让 npm 走自己的配置链 + /// (环境变量 > 安装目录 `.npmrc` > 用户 `~/.npmrc` > 内置), + /// 这样「系统 node 以前配过的镜像」会被自动沿用。 + fn registry_setting(&self) -> String { + self.load_settings() + .npm_registry + .trim() + .trim_end_matches('/') + .to_string() + } + + /// npm 自身解析出的源(`node config get registry`)。 + /// + /// 未检测到 Node/npm、或 npm 执行失败时为 None。cwd 取安装目录—— + /// npm 的「项目级配置」来自 cwd 下的 `.npmrc`,要与真实安装保持一致。 + pub fn npm_config_registry(&self) -> Option { + let env = self.resolve_node_env()?; + let npm = env.npm?; + let mut cmd = std::process::Command::new(&env.node_exe); + cmd.arg(&npm).args(["config", "get", "registry"]); + // 安装目录可能还没创建(首次安装):退回模块目录,保证能起来 + let install_root = self.install_root(); + cmd.current_dir(if install_root.exists() { + install_root + } else { + self.root.clone() + }); + cmd.stdout(std::process::Stdio::piped()) + .stderr(std::process::Stdio::null()) + .stdin(std::process::Stdio::null()); + crate::process_manager::setup_creation_flags(&mut cmd); + let out = cmd.output().ok()?; + if !out.status.success() { + return None; + } + let text = String::from_utf8_lossy(&out.stdout); + text.lines() + .map(|l| l.trim()) + .find(|l| !l.is_empty()) + .map(|l| l.trim_end_matches('/').to_string()) + } + + /// 本次安装/查询实际使用的源 + 来源(供 UI 展示与快捷切换)。 + pub fn npm_registry_info(&self) -> DshNpmRegistryInfo { + let setting = self.registry_setting(); + let npm_registry = self.npm_config_registry(); + let (effective, source) = if !setting.is_empty() { + (setting.clone(), "setting") + } else if let Some(npm) = npm_registry.as_ref() { + (npm.clone(), "npm") + } else { + ("https://registry.npmjs.org".to_string(), "fallback") + }; + DshNpmRegistryInfo { + effective, + source: source.to_string(), + npm_registry, + setting, + } + } + + /// 版本查询(reqwest)用的源:与安装保持一致(设置 → npm 配置 → 官方源)。 + /// + /// 之前这里在设置为空时硬编码官方源,导致「安装走国内镜像、检查更新却直连 + /// npmjs.org」的不一致。 + fn registry_for_query(&self) -> String { + self.npm_registry_info().effective + } + + /// 查询 npm 上的可用版本(`dist-tags.latest` + 版本列表)。 + pub async fn check_update(&self) -> Result { + let url = format!("{}/{DSH_PACKAGE}", self.registry_for_query()); + let resp = self + .http_client(30) + .get(&url) + .send() + .await + .map_err(|e| format!("查询 npm 版本失败: {e}"))?; + if !resp.status().is_success() { + return Err(format!("查询 npm 版本失败: HTTP {}", resp.status().as_u16())); + } + let value: serde_json::Value = resp + .json() + .await + .map_err(|e| format!("解析 npm 响应失败: {e}"))?; + + let latest = value + .get("dist-tags") + .and_then(|t| t.get("latest")) + .and_then(|v| v.as_str()) + .ok_or_else(|| "npm 响应缺少 dist-tags.latest".to_string())? + .to_string(); + + let mut versions: Vec = value + .get("versions") + .and_then(|v| v.as_object()) + .map(|m| m.keys().cloned().collect()) + .unwrap_or_default(); + // 取尾部若干(近似按发布顺序),再反转成最新在前 + if versions.len() > 20 { + versions = versions.split_off(versions.len() - 20); + } + versions.reverse(); + + let current = self.installed_version(); + Ok(DshUpdateInfo { + has_update: current.as_deref() != Some(latest.as_str()), + current, + latest, + versions, + }) + } + + /// 安装 / 更新 dsh(`version` 为空 = 装 latest)。 + pub async fn install(&self, app: &AppHandle, version: Option) -> Result { + self.cancel.store(false, Ordering::SeqCst); + // 每次安装开始清空上一次的输出缓冲 + self.clear_install_log(); + let result = self.install_inner(app, version).await; + self.cancel.store(false, Ordering::SeqCst); + if let Err(ref e) = result { + if e != NODE_CANCELLED { + self.push_install_log(&format!("[错误] {e}")); + self.emit_progress(app, "error", 0, 0, None, e); + } + } + result + } + + async fn install_inner(&self, app: &AppHandle, version: Option) -> Result { + let env = self + .resolve_node_env() + .ok_or_else(|| "未找到可用的 Node,请先完成第 1 步".to_string())?; + if !super::satisfies_node_requirement(&env.version) { + return Err(format!( + "当前 Node {} 不满足 dsh 要求({}),请先安装合规的 Node", + env.version, + super::NODE_REQUIRED + )); + } + let npm = env + .npm + .clone() + .ok_or_else(|| "未找到 npm(Node 分发中缺少 npm-cli.js)".to_string())?; + + let spec = version + .as_deref() + .map(|v| v.trim()) + .filter(|v| !v.is_empty()) + .map(|v| format!("{DSH_PACKAGE}@{v}")) + .unwrap_or_else(|| DSH_PACKAGE.to_string()); + + let install_dir = self.install_root(); + // npm 的 prefix 目录不存在时由 npm 自己创建;这里先建一次,避免 + // 自定义到新盘符目录时 npm 因父级缺失报 ENOENT + std::fs::create_dir_all(&install_dir) + .map_err(|e| format!("创建安装目录失败({}): {e}", install_dir.display()))?; + let mut args: Vec = vec![ + npm.to_string_lossy().to_string(), + "install".into(), + "--prefix".into(), + install_dir.to_string_lossy().to_string(), + spec.clone(), + "--no-fund".into(), + "--no-audit".into(), + "--loglevel".into(), + "info".into(), + ]; + let registry = self.registry_setting(); + if !registry.is_empty() { + // 只在显式指定时才覆盖 npm 自己的配置链 + args.push("--registry".into()); + args.push(registry); + } + + self.emit_progress( + app, + "installing", + 0, + 0, + None, + &format!("正在安装 {spec}(依赖较多,请稍候)..."), + ); + + // npm 不输出百分比:percent 恒为 0(前端按不确定进度展示), + // message 跟随 npm 自身的汇总行(`added N packages` 等)更新。 + // + // 逐行输出**只进内存缓冲**(安装引导页临时展示),不写应用日志: + // npm 的 72 个依赖会刷出上千行,进应用日志只会淹没真正的运行日志。 + let progress_app = app.clone(); + let install_ring = self.install_ring_handle(); + let on_line = Arc::new(move |line: &str| { + super::push_bounded(&install_ring, super::INSTALL_RING_CAPACITY, line); + let trimmed = line.trim(); + if trimmed.starts_with("added ") + || trimmed.starts_with("changed ") + || trimmed.starts_with("removed ") + || trimmed.starts_with("up to date") + { + let _ = progress_app.emit( + crate::constants::events::DSH_INSTALL_PROGRESS, + DshInstallProgress { + stage: "installing".into(), + percent: 0, + downloaded_bytes: 0, + total_bytes: None, + message: trimmed.to_string(), + }, + ); + } + }); + + let node_exe = env.node_exe.clone(); + let pid_ref = self.install_pid.clone(); + let result = tauri::async_runtime::spawn_blocking(move || { + run_npm(node_exe, args, install_dir, pid_ref, on_line) + }) + .await + .map_err(|e| format!("安装任务执行失败: {e}"))?; + self.install_pid.store(0, Ordering::SeqCst); + + if self.cancel.load(Ordering::SeqCst) { + return Err(NODE_CANCELLED.into()); + } + result?; + + let status = self.install_status(); + if !status.installed { + return Err("npm 安装结束,但未找到 dsh 入口(请查看日志)".into()); + } + self.emit_progress( + app, + "done", + 100, + 0, + None, + &format!( + "dsh {} 安装完成", + status.version.as_deref().unwrap_or("unknown") + ), + ); + crate::logger::log_info( + "dsh", + &format!( + "dsh 安装完成: {}", + status.version.as_deref().unwrap_or("unknown") + ), + ); + Ok(status) + } + + /// 卸载 dsh:停止服务并删除包目录(保留设置与 $DSH_HOME)。 + pub fn uninstall(&self, app: &AppHandle) -> Result<(), String> { + self.stop_server(app); + let dir = self.package_dir(); + if dir.exists() { + std::fs::remove_dir_all(&dir).map_err(|e| format!("删除 dsh 目录失败: {e}"))?; + } + Ok(()) + } +} + +/// 同步执行 npm(阻塞线程内),逐行读输出交给 `on_line`;pid 记录供取消时 taskkill。 +fn run_npm( + node_exe: PathBuf, + args: Vec, + cwd: PathBuf, + pid_ref: Arc, + on_line: Arc, +) -> Result<(), String> { + let mut cmd = std::process::Command::new(&node_exe); + cmd.args(&args); + cmd.current_dir(&cwd); + cmd.stdout(std::process::Stdio::piped()) + .stderr(std::process::Stdio::piped()) + .stdin(std::process::Stdio::null()); + crate::process_manager::setup_creation_flags(&mut cmd); + + let mut child = cmd + .spawn() + .map_err(|e| format!("启动 npm 失败({}): {e}", node_exe.display()))?; + let pid = child.id(); + pid_ref.store(pid as u64, Ordering::SeqCst); + + let stdout = child.stdout.take(); + let stderr = child.stderr.take(); + + // 末 40 行留作失败时的错误摘要 + let tail = Arc::new(std::sync::Mutex::new(Vec::::new())); + let mut handles = Vec::new(); + let pipes: [Option>; 2] = [ + stdout.map(|p| Box::new(p) as Box), + stderr.map(|p| Box::new(p) as Box), + ]; + for pipe in pipes.into_iter().flatten() { + let on_line = on_line.clone(); + let tail = tail.clone(); + handles.push(std::thread::spawn(move || { + let reader = BufReader::new(pipe); + for line in reader.lines().map_while(Result::ok) { + on_line(&line); + if let Ok(mut t) = tail.lock() { + if t.len() >= 40 { + t.remove(0); + } + t.push(line); + } + } + })); + } + + let status = child.wait(); + for h in handles { + let _ = h.join(); + } + pid_ref.store(0, Ordering::SeqCst); + + let status = status.map_err(|e| format!("等待 npm 结束失败: {e}"))?; + if status.success() { + return Ok(()); + } + let text = tail.lock().map(|t| t.join("\n")).unwrap_or_default(); + let chars: Vec = text.chars().collect(); + let skip = chars.len().saturating_sub(800); + Err(format!( + "npm 退出码 {}: {}", + status.code().unwrap_or(-1), + chars[skip..].iter().collect::() + )) +} \ No newline at end of file diff --git a/src-tauri/src/dsh/mod.rs b/src-tauri/src/dsh/mod.rs new file mode 100644 index 0000000..87a7c5c --- /dev/null +++ b/src-tauri/src/dsh/mod.rs @@ -0,0 +1,484 @@ +//! dsh 模块(DeepSeek Harness 外壳)。 +//! +//! 模块定位:为 DeepSeek Harness(npm 包 `@deepseek-ai/dsh`)做安装、更新与 +//! 生命周期管理,并把主设置里的 AI 供应商(含 DeepSeek API Key)装载给 dsh。 +//! 模块页不内嵌浏览器,dsh 的 Web UI 通过独立窗口 / 系统浏览器打开。 +//! +//! 目录布局(`{app_data_dir}/dsh`): +//! ```text +//! settings.json 模块自身设置(版本号 + 自愈) +//! node/ 便携 Node(仅系统 Node 不可用时) +//! node_modules/ @deepseek-ai/dsh 本地安装(npm --prefix) +//! home/ $DSH_HOME(settings.yaml / profiles / 会话) +//! workspace/ 默认工作区(dsh 进程的启动目录) +//! logs/web.log dsh 服务输出 +//! ``` +//! +//! 安全姿态:模块设置不含任何密钥;API Key 只在 spawn 子进程时以环境变量注入 +//! (明文来自系统凭据管理器,见 [`crate::secrets`]),不写 dsh 的 +//! `.credentials.yaml`、不落日志、不过前端。 + +mod ai_sync; +mod commands; +mod install; +mod node; +mod server; +mod types; + +pub use commands::{ + dsh_ai_preview, dsh_ai_sync, dsh_cancel_install, dsh_check_update, dsh_env_status, + dsh_get_settings, dsh_install, dsh_install_log, dsh_log_clear, dsh_log_tail, + dsh_node_detect, dsh_node_install, dsh_npm_registry_info, dsh_open_dir, + dsh_register_shortcut, dsh_restart, dsh_save_settings, dsh_start, dsh_stop, + dsh_uninstall, dsh_unregister_shortcut, dsh_update, +}; +pub use commands::autostart_if_enabled; +// 仅重导出模块自身与子模块会经 `super::` 用到的类型(其余由各子模块直接从 types 取) +pub use types::{DshInstallProgress, DshSettings, NODE_REQUIRED}; + +use std::collections::VecDeque; +use std::path::PathBuf; +use std::process::Child; +use std::sync::atomic::{AtomicBool, AtomicU64}; +use std::sync::{Arc, Mutex}; +use std::time::{Duration, Instant}; + +use tauri::AppHandle; + +/// 设置内存缓存有效期(与其他模块的 500ms 一致)。 +const SETTINGS_CACHE_TTL: Duration = Duration::from_millis(500); +/// 日志环形缓冲保留的最大行数(供「日志」页签快速读取)。 +const LOG_RING_CAPACITY: usize = 500; +/// 安装输出缓冲保留的最大行数(npm 输出较啰嗦,只留最近一段)。 +const INSTALL_RING_CAPACITY: usize = 200; + +/// 服务进程条目(自管 stdio,不走 ProcessManager)。 +pub(crate) struct ServerEntry { + pub child: Child, + pub pid: u32, + pub port: u16, + /// 启动时间(unix 秒) + pub started_at: i64, +} + +struct SettingsCacheEntry { + read_at: Instant, + settings: DshSettings, +} + +/// 解析出的 Node 运行环境。 +pub(crate) struct NodeEnv { + /// system | managed + pub source: &'static str, + pub node_exe: PathBuf, + /// npm 入口(`node_modules/npm/bin/npm-cli.js`,用 `node <此路径>` 调用) + pub npm: Option, + pub version: String, +} + +/// dsh 模块管理器(Tauri State)。 +pub struct DshManager { + /// 应用数据目录(`{app_data_dir}`) + data_dir: PathBuf, + /// 模块根目录(`{app_data_dir}/dsh`) + root: PathBuf, + settings_cache: Mutex>, + /// 安装/下载取消标志 + cancel: Arc, + /// 安装子进程 pid(取消时 taskkill /T) + install_pid: Arc, + /// 服务进程 + server: Mutex>, + /// 启动串行化锁(防并发双开) + start_lock: Mutex<()>, + /// HTTP 就绪标志 + ready: Arc, + /// 本次进程的「带 token 启动地址」(从 dsh stdout 抓取)。 + /// dsh web 的浏览器鉴权靠它首次访问换取 cookie,没它就只会拿到 401。 + launch_url: Arc>>, + /// 最近一次启动错误(端口占用 / 进程立即退出) + server_error: Mutex>, + /// 日志环形缓冲 + log_ring: Arc>>, + /// 安装(npm)输出缓冲:只在模块页临时展示,**不落应用日志、不落盘** + install_ring: Arc>>, +} + +impl DshManager { + pub fn new(app_data_dir: PathBuf) -> Self { + let root = app_data_dir.join("dsh"); + for d in ["node", "logs", "home", "workspace"] { + std::fs::create_dir_all(root.join(d)).ok(); + } + Self { + data_dir: app_data_dir, + root, + settings_cache: Mutex::new(None), + cancel: Arc::new(AtomicBool::new(false)), + install_pid: Arc::new(AtomicU64::new(0)), + server: Mutex::new(None), + start_lock: Mutex::new(()), + ready: Arc::new(AtomicBool::new(false)), + launch_url: Arc::new(Mutex::new(None)), + server_error: Mutex::new(None), + log_ring: Arc::new(Mutex::new(VecDeque::with_capacity(LOG_RING_CAPACITY))), + install_ring: Arc::new(Mutex::new(VecDeque::with_capacity(INSTALL_RING_CAPACITY))), + } + } + + /// 模块根目录(「在文件夹中打开」用) + pub fn root(&self) -> &PathBuf { + &self.root + } + + /// 便携 Node 目录 + pub fn node_dir(&self) -> PathBuf { + self.root.join("node") + } + + /// dsh 本体的安装根目录(npm `--prefix` 目标)。 + /// + /// 设置留空 = 模块目录。自定义时**只有 dsh 本体与它的 node_modules 跟随**, + /// 便携 Node / `$DSH_HOME` / 日志 / 模块设置仍留在应用数据目录——自定义路径 + /// 若被移动或卸载,至少配置与日志还读得到,排障不会失联。 + pub fn install_root(&self) -> PathBuf { + let raw = self.load_settings().install_dir; + let raw = raw.trim(); + if raw.is_empty() { + self.root.clone() + } else { + PathBuf::from(raw) + } + } + + /// `$DSH_HOME` + pub fn home_dir(&self) -> PathBuf { + let settings = self.load_settings(); + if settings.dsh_home_mode == "user" { + dirs::home_dir() + .map(|h| h.join(".dsh")) + .unwrap_or_else(|| self.root.join("home")) + } else { + self.root.join("home") + } + } + + /// dsh 进程的启动目录(工作区) + pub fn workspace_dir(&self) -> PathBuf { + let settings = self.load_settings(); + let raw = settings.workspace.trim(); + let dir = if raw.is_empty() { + self.root.join("workspace") + } else { + PathBuf::from(raw) + }; + std::fs::create_dir_all(&dir).ok(); + dir + } + + pub fn log_path(&self) -> PathBuf { + self.root.join("logs").join("web.log") + } + + pub fn settings_path(&self) -> PathBuf { + self.root.join("settings.json") + } + + // ---------- 设置 ---------- + + pub fn load_settings(&self) -> DshSettings { + if let Ok(cache) = self.settings_cache.lock() { + if let Some(entry) = cache.as_ref() { + if entry.read_at.elapsed() < SETTINGS_CACHE_TTL { + return entry.settings.clone(); + } + } + } + let mut settings = std::fs::read_to_string(self.settings_path()) + .ok() + .and_then(|t| serde_json::from_str::(&t).ok()) + .unwrap_or_default(); + let changed = settings.heal(); + if changed { + self.write_settings(&settings).ok(); + } + if let Ok(mut cache) = self.settings_cache.lock() { + *cache = Some(SettingsCacheEntry { + read_at: Instant::now(), + settings: settings.clone(), + }); + } + settings + } + + pub fn save_settings(&self, mut settings: DshSettings) -> Result { + // 自定义安装目录必须是绝对路径:npm 的 --prefix 用相对路径会落到 + // 进程当前目录(开发期即仓库根目录),这种"看起来生效其实装错地方"最难排查 + let custom = settings.install_dir.trim(); + if !custom.is_empty() && !std::path::Path::new(custom).is_absolute() { + return Err("dsh 安装目录必须是绝对路径(如 D:/Thing/dsh)".to_string()); + } + settings.heal(); + self.write_settings(&settings)?; + if let Ok(mut cache) = self.settings_cache.lock() { + *cache = Some(SettingsCacheEntry { + read_at: Instant::now(), + settings: settings.clone(), + }); + } + Ok(settings) + } + + fn write_settings(&self, settings: &DshSettings) -> Result<(), String> { + let json = serde_json::to_string_pretty(settings) + .map_err(|e| format!("序列化 dsh 设置失败: {e}"))?; + std::fs::write(self.settings_path(), json).map_err(|e| format!("写入 dsh 设置失败: {e}")) + } + + // ---------- 日志 ---------- + + /// 追加一行到环形缓冲 + 落盘(服务输出走这里)。 + pub(crate) fn push_log(&self, line: &str) { + push_log_shared(&self.log_ring, &self.log_path(), line); + } + + /// 读取日志:优先环形缓冲;为空时回落到文件尾部。 + pub fn log_tail(&self, lines: usize) -> String { + let lines = lines.clamp(1, LOG_RING_CAPACITY); + if let Ok(ring) = self.log_ring.lock() { + if !ring.is_empty() { + let skip = ring.len().saturating_sub(lines); + return ring + .iter() + .skip(skip) + .cloned() + .collect::>() + .join("\n"); + } + } + let text = std::fs::read_to_string(self.log_path()).unwrap_or_default(); + let all: Vec<&str> = text.lines().collect(); + let skip = all.len().saturating_sub(lines); + all[skip..].join("\n") + } + + pub fn clear_log(&self) { + if let Ok(mut ring) = self.log_ring.lock() { + ring.clear(); + } + std::fs::write(self.log_path(), b"").ok(); + } + + // ---------- 安装输出(仅内存,供安装引导页临时展示) ---------- + + /// 追加一行安装输出(已过滤疑似密钥)。 + pub(crate) fn push_install_log(&self, line: &str) { + push_bounded(&self.install_ring, INSTALL_RING_CAPACITY, line); + } + + /// 读取当前安装输出(每次安装开始时清空)。 + pub fn install_log(&self) -> String { + self.install_ring + .lock() + .map(|r| r.iter().cloned().collect::>().join("\n")) + .unwrap_or_default() + } + + pub(crate) fn clear_install_log(&self) { + if let Ok(mut ring) = self.install_ring.lock() { + ring.clear(); + } + } + + /// 安装输出缓冲句柄(阻塞线程内的 on_line 闭包持有;'static 需要)。 + pub(crate) fn install_ring_handle( + &self, + ) -> Arc>> { + self.install_ring.clone() + } + + // ---------- 代理 ---------- + + /// 按设置解析代理地址(mihomo mixed 端口)。返回 None 表示直连。 + /// + /// 只读代理模块设置文件里的 mixedPort,并用一次 300ms TCP 探测确认内核在线; + /// 内核没起来时静默直连(与 download_engine / translate 的降级姿态一致)。 + pub(crate) fn proxy_url(&self) -> Option { + if !self.load_settings().use_proxy { + return None; + } + let text = std::fs::read_to_string(self.data_dir.join("proxy").join("settings.json")).ok()?; + let value: serde_json::Value = serde_json::from_str(&text).ok()?; + let port = value.get("mixedPort").and_then(|v| v.as_u64())?; + if port == 0 || port > u16::MAX as u64 { + return None; + } + let port = port as u16; + let addr = std::net::SocketAddr::from(([127, 0, 0, 1], port)); + if std::net::TcpStream::connect_timeout(&addr, Duration::from_millis(300)).is_err() { + return None; + } + Some(format!("http://127.0.0.1:{port}")) + } + + // ---------- 事件 ---------- + + /// 推送安装/下载进度(stage: download | extracting | installing | done | error)。 + pub(crate) fn emit_progress( + &self, + app: &AppHandle, + stage: &str, + percent: u8, + downloaded_bytes: u64, + total_bytes: Option, + message: &str, + ) { + use tauri::Emitter; + let _ = app.emit( + crate::constants::events::DSH_INSTALL_PROGRESS, + DshInstallProgress { + stage: stage.into(), + percent, + downloaded_bytes, + total_bytes, + message: message.into(), + }, + ); + } + + /// 推送服务状态(启动/停止/就绪变化时)。 + pub(crate) fn emit_server_state(&self, app: &AppHandle) { + use tauri::Emitter; + let status = self.server_status(); + let _ = app.emit(crate::constants::events::DSH_SERVER_STATE, status); + } + + /// 构造 reqwest 客户端:按代理设置决定是否走 mihomo。 + pub(crate) fn http_client(&self, timeout_secs: u64) -> reqwest::Client { + let mut builder = reqwest::Client::builder() + .user_agent("thing-app") + .timeout(Duration::from_secs(timeout_secs)); + if let Some(proxy) = self.proxy_url() { + if let Ok(p) = reqwest::Proxy::all(&proxy) { + builder = builder.proxy(p); + } + } + builder.build().unwrap_or_else(|_| reqwest::Client::new()) + } +} + +/// 过滤日志行里的疑似密钥(`sk-` 形态)与 URL 里的会话令牌。 +pub(crate) fn sanitize_log_line(line: &str) -> String { + let line = mask_token_in_url(line); + let mut out = String::with_capacity(line.len()); + for token in line.split_inclusive(char::is_whitespace) { + let trimmed = token.trim_end(); + if trimmed.starts_with("sk-") && trimmed.len() > 12 { + out.push_str("sk-***"); + out.push_str(&token[trimmed.len()..]); + } else { + out.push_str(token); + } + } + out +} + +/// 掩码 URL 里的 `token=` 取值(`?token=xxx` → `?token=***`)。 +/// +/// dsh web 的浏览器会话令牌等同于「对该 loopback 服务(能执行代码)的完全访问权」, +/// 不该落进应用日志与 logs/web.log;真正的带令牌地址经 IPC 单独给前端使用。 +fn mask_token_in_url(line: &str) -> String { + const NEEDLE: &str = "token="; + let mut out = String::with_capacity(line.len()); + let mut cursor = 0usize; + while let Some(rel) = line[cursor..].find(NEEDLE) { + let start = cursor + rel + NEEDLE.len(); + out.push_str(&line[cursor..start]); + let after = &line[start..]; + let end = after + .find(|c: char| c.is_whitespace() || matches!(c, ')' | ',' | '"' | '\'' | '&')) + .unwrap_or(after.len()); + out.push_str("***"); + cursor = start + end; + } + out.push_str(&line[cursor..]); + out +} + +/// 从 dsh 输出行里解析「带 token 的启动地址」。 +/// +/// `dsh web` 就绪后会打印(见 dsh-web-app 的 announceReady): +/// `dsh web: http://127.0.0.1:3080/?token=<随机令牌> (LAN: http://:3080/?token=<...>)` +/// +/// 浏览器鉴权靠这个地址首次访问换取签名 cookie(dsh-client-connection 的 BrowserAuth); +/// 令牌是**每次进程随机生成**的,无法推导,只能从输出里取。 +/// 取第一个(loopback)地址,忽略随后的 LAN 地址。 +pub(crate) fn parse_launch_url(line: &str) -> Option { + let start = line.find("http://").or_else(|| line.find("https://"))?; + let rest = &line[start..]; + let end = rest.find(char::is_whitespace).unwrap_or(rest.len()); + let url = rest[..end].trim_end_matches(|c: char| c == ')' || c == ','); + url.contains("token=").then(|| url.to_string()) +} + +/// 共享的日志写入(服务 stdout/stderr reader 线程与探测线程用)。 +/// +/// reader 线程拿不到 `&DshManager`(需要 'static),因此把环形缓冲与日志路径 +/// 单独传进来。 +pub(crate) fn push_log_shared( + ring: &Arc>>, + log_path: &PathBuf, + line: &str, +) { + let line = push_bounded(ring, LOG_RING_CAPACITY, line); + if let Ok(mut f) = std::fs::OpenOptions::new() + .create(true) + .append(true) + .open(log_path) + { + use std::io::Write; + let _ = writeln!(f, "{line}"); + } +} + +/// 有界环形缓冲追加(**不落盘**),返回写入后的文本。 +/// +/// 安装输出走这里:只要内存,不写应用日志、不写文件——用户明确要求安装日志 +/// 仅在安装引导页临时展示(npm 输出啰嗦,进应用日志只会淹没真正的运行日志)。 +pub(crate) fn push_bounded( + ring: &Arc>>, + capacity: usize, + line: &str, +) -> String { + let line = sanitize_log_line(line); + if let Ok(mut r) = ring.lock() { + if r.len() >= capacity { + r.pop_front(); + } + r.push_back(line.clone()); + } + line +} + +/// 解析 "v24.9.0" / "24.9.0" → (24, 9, 0) +pub(crate) fn parse_version(raw: &str) -> Option<(u32, u32, u32)> { + let cleaned = raw.trim().trim_start_matches('v'); + let core = cleaned.split('-').next().unwrap_or(cleaned); + let mut it = core.split('.'); + let major = it.next()?.parse::().ok()?; + let minor = it.next().unwrap_or("0").parse::().ok()?; + let patch = it.next().unwrap_or("0").parse::().ok()?; + Some((major, minor, patch)) +} + +/// 是否满足 dsh 的要求:`^22.19.0 || >=24.0.0` +pub(crate) fn satisfies_node_requirement(raw: &str) -> bool { + let Some((major, minor, patch)) = parse_version(raw) else { + return false; + }; + match major { + 22 => (minor, patch) >= (19, 0), + 24.. => true, + _ => false, + } +} \ No newline at end of file diff --git a/src-tauri/src/dsh/node.rs b/src-tauri/src/dsh/node.rs new file mode 100644 index 0000000..2aba637 --- /dev/null +++ b/src-tauri/src/dsh/node.rs @@ -0,0 +1,399 @@ +//! Node 运行环境:探测系统 Node / 下载并解压便携 Node。 +//! +//! dsh 要求 Node `^22.19.0 || >=24.0.0`。策略(用户已确认): +//! 优先复用 PATH 上的系统 Node,版本不满足或缺失时才下载官方便携版到 +//! `{app_data}/dsh/node`(官方 zip 内含 npm/npx,因此托管 Node 自带 npm)。 + +use std::fs; +use std::io::{Read, Write}; +use std::path::{Path, PathBuf}; +use std::sync::atomic::Ordering; + +use futures_util::StreamExt; +use tauri::AppHandle; + +use super::types::{NodeStatus, NODE_REQUIRED}; +use super::{satisfies_node_requirement, DshManager, NodeEnv}; + +/// 用户取消时返回的错误信息(前端静默处理,不弹错误 toast)。 +pub(crate) const NODE_CANCELLED: &str = "已取消"; + +impl DshManager { + /// 系统 PATH 上的 node.exe + pub fn system_node(&self) -> Option { + which_node() + } + + /// 托管便携 Node 的 node.exe + pub fn managed_node(&self) -> Option { + let exe = self.node_dir().join(if cfg!(windows) { "node.exe" } else { "bin/node" }); + exe.exists().then_some(exe) + } + + /// 解析实际使用的 Node 环境(按 nodeSource 设置)。 + pub fn resolve_node_env(&self) -> Option { + let settings = self.load_settings(); + let system = self.system_node(); + let managed = self.managed_node(); + + let system_ok = system + .as_ref() + .and_then(|p| node_version(p)) + .map(|v| satisfies_node_requirement(&v)) + .unwrap_or(false); + + // 选定 (是否托管, 可执行文件) + let chosen: Option<(bool, PathBuf)> = match settings.node_source.as_str() { + "system" => system.map(|p| (false, p)), + "managed" => managed.map(|p| (true, p)), + // auto:系统满足即复用,否则回落托管;两者都没有时退回系统 Node 仅用于展示版本 + _ => { + if system_ok { + system.map(|p| (false, p)) + } else { + managed + .map(|p| (true, p)) + .or_else(|| system.map(|p| (false, p))) + } + } + }; + let (is_managed, exe) = chosen?; + + let version = node_version(&exe).unwrap_or_default(); + let npm = npm_cli_js(&exe); + Some(NodeEnv { + source: if is_managed { "managed" } else { "system" }, + node_exe: exe, + npm, + version, + }) + } + + /// 当前 Node 状态(供 UI 首屏展示)。 + pub fn node_status(&self) -> NodeStatus { + match self.resolve_node_env() { + Some(env) => { + let satisfies = satisfies_node_requirement(&env.version); + NodeStatus { + source: if env.source == "managed" { "managed".into() } else { "system".into() }, + path: Some(env.node_exe.to_string_lossy().to_string()), + version: Some(env.version), + satisfies, + required: NODE_REQUIRED.into(), + } + } + None => NodeStatus { + source: "none".into(), + path: None, + version: None, + satisfies: false, + required: NODE_REQUIRED.into(), + }, + } + } + + /// 下载并安装便携 Node(进度经 `dsh-install-progress` 推送)。 + /// + /// `version` 为空时自动解析满足要求的最新版本(优先 LTS)。 + pub async fn node_install(&self, app: &AppHandle, version: Option) -> Result { + if !cfg!(windows) { + return Err("便携 Node 安装仅支持 Windows,请改用系统 Node(nodeSource = system)".into()); + } + self.cancel.store(false, Ordering::SeqCst); + let result = self.node_install_inner(app, version).await; + self.cancel.store(false, Ordering::SeqCst); + if let Err(ref e) = result { + if e != NODE_CANCELLED { + self.emit_progress(app, "error", 0, 0, None, e); + } + } + result + } + + async fn node_install_inner(&self, app: &AppHandle, version: Option) -> Result { + let base = self.node_mirror_base(); + let version = match version.filter(|v| !v.trim().is_empty()) { + Some(v) => normalize_version(&v), + None => { + self.emit_progress(app, "download", 0, 0, None, "正在解析 Node 版本..."); + let requested = self.load_settings().managed_node_version; + if requested.trim().is_empty() { + self.resolve_latest_node_version(&base).await? + } else { + normalize_version(&requested) + } + } + }; + + let arch = platform_arch(); + let url = format!("{base}/{version}/node-{version}-{arch}.zip"); + let zip_path = self.node_dir().join("node-download.zip"); + self.emit_progress( + app, + "download", + 1, + 0, + None, + &format!("正在下载 Node {version}..."), + ); + self.download_to_file(app, &url, &zip_path, "正在下载 Node").await?; + + if self.cancel.load(Ordering::SeqCst) { + let _ = fs::remove_file(&zip_path); + return Err(NODE_CANCELLED.into()); + } + + // 解压:官方 zip 顶层是 node-vX-win-x64/,剥掉这一层直接落到 node/ + self.emit_progress(app, "extracting", 92, 0, None, "正在解压..."); + let dest = self.node_dir(); + if dest.exists() { + fs::remove_dir_all(&dest).map_err(|e| format!("清理旧 Node 目录失败: {e}"))?; + } + fs::create_dir_all(&dest).map_err(|e| format!("创建 Node 目录失败: {e}"))?; + if let Err(e) = extract_zip_strip_top(&zip_path, &dest) { + let _ = fs::remove_file(&zip_path); + return Err(format!("解压 Node 失败: {e}")); + } + let _ = fs::remove_file(&zip_path); + + let exe = dest.join("node.exe"); + if !exe.exists() { + return Err("解压后未找到 node.exe".into()); + } + let actual = node_version(&exe).unwrap_or(version.clone()); + self.emit_progress(app, "done", 100, 0, None, &format!("Node {actual} 安装完成")); + crate::logger::log_info("dsh", &format!("便携 Node 安装完成: {actual} ({})", exe.display())); + Ok(self.node_status()) + } + + /// 托管 Node 的镜像基址(`{base}/{version}/node-{version}-win-x64.zip`)。 + fn node_mirror_base(&self) -> String { + let mirror = self.load_settings().node_mirror; + let mirror = mirror.trim().trim_end_matches('/'); + if mirror.is_empty() { + "https://nodejs.org/dist".to_string() + } else { + mirror.to_string() + } + } + + /// 解析满足要求的最新 Node 版本(优先 LTS)。 + async fn resolve_latest_node_version(&self, base: &str) -> Result { + let url = format!("{base}/index.json"); + let resp = self + .http_client(30) + .get(&url) + .send() + .await + .map_err(|e| format!("获取 Node 版本列表失败: {e}"))?; + if !resp.status().is_success() { + return Err(format!("获取 Node 版本列表失败: HTTP {}", resp.status().as_u16())); + } + let list: Vec = resp + .json() + .await + .map_err(|e| format!("解析 Node 版本列表失败: {e}"))?; + + let mut latest_lts: Option<(u32, u32, u32, String)> = None; + let mut latest_any: Option<(u32, u32, u32, String)> = None; + for item in list { + let Some(version) = item.get("version").and_then(|v| v.as_str()) else { + continue; + }; + if !satisfies_node_requirement(version) { + continue; + } + let Some(parsed) = super::parse_version(version) else { + continue; + }; + let is_lts = item.get("lts").map(|l| !l.is_null() && l != false).unwrap_or(false); + if latest_any.as_ref().map(|(maj, min, pat, _)| (parsed.0, parsed.1, parsed.2) > (*maj, *min, *pat)).unwrap_or(true) { + latest_any = Some((parsed.0, parsed.1, parsed.2, version.to_string())); + } + if is_lts + && latest_lts + .as_ref() + .map(|(maj, min, pat, _)| (parsed.0, parsed.1, parsed.2) > (*maj, *min, *pat)) + .unwrap_or(true) + { + latest_lts = Some((parsed.0, parsed.1, parsed.2, version.to_string())); + } + } + latest_lts + .or(latest_any) + .map(|(_, _, _, v)| v) + .ok_or_else(|| "未找到满足 dsh 要求的 Node 版本".to_string()) + } + + /// 流式下载到文件(带取消 + 进度事件,percent 0-90)。 + pub(crate) async fn download_to_file( + &self, + app: &AppHandle, + url: &str, + dest: &Path, + label: &str, + ) -> Result<(), String> { + let resp = self + .http_client(1800) + .get(url) + .send() + .await + .map_err(|e| format!("请求下载失败({url}): {e}"))?; + let status = resp.status(); + if !status.is_success() { + return Err(format!("下载返回 HTTP {}", status.as_u16())); + } + let total = resp.content_length(); + let mut file = fs::File::create(dest).map_err(|e| format!("创建文件失败: {e}"))?; + let mut stream = resp.bytes_stream(); + let mut downloaded: u64 = 0; + let mut last_percent: u8 = 0; + while let Some(chunk) = stream.next().await { + if self.cancel.load(Ordering::SeqCst) { + drop(file); + fs::remove_file(dest).ok(); + return Err(NODE_CANCELLED.into()); + } + let chunk = chunk.map_err(|e| format!("下载中断: {e}"))?; + file.write_all(&chunk).map_err(|e| format!("写入文件失败: {e}"))?; + downloaded += chunk.len() as u64; + let percent = total + .filter(|t| *t > 0) + .map(|t| ((downloaded as f64 / t as f64) * 90.0) as u8) + .unwrap_or(0) + .min(90); + if percent >= last_percent + 1 { + last_percent = percent; + self.emit_progress( + app, + "download", + percent, + downloaded, + total, + &format!("{label} {:.1} MB", downloaded as f64 / 1048576.0), + ); + } + } + file.flush().ok(); + self.emit_progress(app, "download", 90, downloaded, total, "下载完成"); + Ok(()) + } + + /// 请求取消(下载 / 安装 / 解压均轮询此标志)。 + pub(crate) fn request_cancel(&self) { + self.cancel.store(true, Ordering::SeqCst); + let pid = self.install_pid.load(Ordering::SeqCst); + if pid > 0 { + taskkill_tree(pid); + } + } +} + +/// 官方分发包的平台标识(Windows x64 / arm64)。 +fn platform_arch() -> &'static str { + match std::env::consts::ARCH { + "aarch64" => "win-arm64", + _ => "win-x64", + } +} + +/// PATH 上查找 node 可执行文件。 +fn which_node() -> Option { + let name = if cfg!(windows) { "node.exe" } else { "node" }; + let path_var = std::env::var_os("PATH")?; + for dir in std::env::split_paths(&path_var) { + let candidate = dir.join(name); + if candidate.is_file() { + return Some(candidate); + } + } + None +} + +/// 取 node 目录下的 npm 入口(`node_modules/npm/bin/npm-cli.js`)。 +/// +/// 直接 `node npm-cli.js` 而不是 `npm.cmd`:`.cmd` 在 Windows 上无法被 +/// CreateProcess 直接执行(需经 `cmd /C`,而 cmd 的引号规则易踩坑), +/// 且批处理 shim 会多出一层进程影响取消时的进程树清理。 +fn npm_cli_js(node_exe: &Path) -> Option { + let dir = node_exe.parent()?; + let candidates = [ + dir.join("node_modules").join("npm").join("bin").join("npm-cli.js"), + dir.join("lib").join("node_modules").join("npm").join("bin").join("npm-cli.js"), + ]; + candidates.into_iter().find(|p| p.is_file()) +} + +/// 执行 `node --version` 取版本号。 +fn node_version(node_exe: &Path) -> Option { + let mut cmd = std::process::Command::new(node_exe); + cmd.arg("--version"); + cmd.stdout(std::process::Stdio::piped()) + .stderr(std::process::Stdio::null()) + .stdin(std::process::Stdio::null()); + crate::process_manager::setup_creation_flags(&mut cmd); + let out = cmd.output().ok()?; + if !out.status.success() { + return None; + } + let text = String::from_utf8_lossy(&out.stdout).trim().to_string(); + (!text.is_empty()).then_some(text) +} + +/// 规范化版本号:补上 `v` 前缀。 +fn normalize_version(raw: &str) -> String { + let t = raw.trim(); + if t.starts_with('v') { + t.to_string() + } else { + format!("v{t}") + } +} + +/// 解压 zip 并剥掉顶层目录(Node 官方分发包顶层是 `node-vX-win-x64/`)。 +pub(crate) fn extract_zip_strip_top(zip_path: &Path, dest: &Path) -> Result<(), String> { + let file = fs::File::open(zip_path).map_err(|e| format!("打开 zip 失败: {e}"))?; + let mut archive = zip::ZipArchive::new(file).map_err(|e| format!("读取 zip 失败: {e}"))?; + for i in 0..archive.len() { + let mut entry = archive.by_index(i).map_err(|e| format!("读取条目失败: {e}"))?; + let Some(name) = entry.enclosed_name() else { + continue; + }; + // 剥掉第一层目录;顶层目录条目本身(只有一个组件)跳过 + let mut comps = name.components(); + comps.next(); + let rel: PathBuf = comps.map(|c| c.as_os_str()).collect(); + if rel.as_os_str().is_empty() { + continue; + } + let outpath = dest.join(&rel); + if entry.is_dir() { + fs::create_dir_all(&outpath).map_err(|e| e.to_string())?; + } else { + if let Some(parent) = outpath.parent() { + fs::create_dir_all(parent).map_err(|e| e.to_string())?; + } + let mut outfile = fs::File::create(&outpath).map_err(|e| e.to_string())?; + let mut buf = [0u8; 8192]; + loop { + let n = entry.read(&mut buf).map_err(|e| e.to_string())?; + if n == 0 { + break; + } + outfile.write_all(&buf[..n]).map_err(|e| e.to_string())?; + } + } + } + Ok(()) +} + +/// 强杀进程树(安装子进程取消用)。 +pub(crate) fn taskkill_tree(pid: u64) { + let mut cmd = std::process::Command::new("taskkill"); + cmd.args(["/F", "/T", "/PID", &pid.to_string()]) + .stdout(std::process::Stdio::null()) + .stderr(std::process::Stdio::null()) + .stdin(std::process::Stdio::null()); + crate::process_manager::setup_creation_flags(&mut cmd); + let _ = cmd.status(); +} \ No newline at end of file diff --git a/src-tauri/src/dsh/server.rs b/src-tauri/src/dsh/server.rs new file mode 100644 index 0000000..f0ec307 --- /dev/null +++ b/src-tauri/src/dsh/server.rs @@ -0,0 +1,316 @@ +//! dsh 服务进程生命周期:spawn(自管 stdio)→ 就绪探测 → 日志落盘 → 停止。 +//! +//! 进程形态参照 `music/bridge.rs` 的长驻子进程:stdout/stderr 各起一个 reader 线程, +//! 逐行写入日志环形缓冲与 `logs/web.log`;子进程加入 Job Object,应用退出时由 +//! 系统自动回收。启动命令为 `node web --port <端口> --no-open`: +//! `--no-open` 让 dsh 不要自己弹出系统浏览器(由本模块的按钮决定何时打开)。 + +use std::io::{BufRead, BufReader, Read, Write}; +use std::net::{SocketAddr, TcpListener, TcpStream}; +use std::process::{Command, Stdio}; +use std::sync::atomic::Ordering; +use std::time::{Duration, Instant}; + +use tauri::AppHandle; + +use super::types::DshServerStatus; +use super::{DshManager, ServerEntry}; + +/// 就绪探测总时长上限。 +const READY_TIMEOUT: Duration = Duration::from_secs(60); + +impl DshManager { + /// 进程是否存活。 + fn server_running(&self) -> bool { + let mut guard = match self.server.lock() { + Ok(g) => g, + Err(_) => return false, + }; + match guard.as_mut() { + Some(entry) => entry + .child + .try_wait() + .ok() + .map(|w| w.is_none()) + .unwrap_or(false), + None => false, + } + } + + /// 当前服务状态。 + pub fn server_status(&self) -> DshServerStatus { + let running = self.server_running(); + // 运行中一律用**进程实际使用的端口**(设置可能在启动后被改过, + // 此时 UI 展示的地址必须仍是真正监听的那个) + let entry = self + .server + .lock() + .ok() + .and_then(|g| g.as_ref().map(|e| (e.pid, e.port, e.started_at))); + let (pid, port, started_at) = match (running, entry) { + (true, Some((pid, port, started_at))) => (Some(pid), port, Some(started_at)), + _ => (None, self.load_settings().port, None), + }; + DshServerStatus { + running, + ready: running && self.ready.load(Ordering::SeqCst), + pid, + port, + url: format!("http://127.0.0.1:{port}"), + launch_url: if running { + self.launch_url.lock().ok().and_then(|g| g.clone()) + } else { + None + }, + started_at, + error: self.server_error.lock().ok().and_then(|g| g.clone()), + } + } + + /// 启动 dsh Web 服务(幂等:已在运行直接返回当前状态)。 + pub fn start_server(&self, app: &AppHandle) -> Result { + if self.server_running() { + return Ok(self.server_status()); + } + let _guard = self.start_lock.lock().map_err(|e| e.to_string())?; + if self.server_running() { + return Ok(self.server_status()); + } + // 清理可能残留的旧条目 + if let Ok(mut g) = self.server.lock() { + g.take(); + } + self.ready.store(false, Ordering::SeqCst); + if let Ok(mut g) = self.server_error.lock() { + *g = None; + } + // 上一进程的令牌必须清掉:沿用旧令牌会让新进程的首次访问仍然 401 + if let Ok(mut g) = self.launch_url.lock() { + *g = None; + } + + let settings = self.load_settings(); + let port = settings.port; + let env = self + .resolve_node_env() + .ok_or_else(|| "未找到可用的 Node,请先完成环境安装".to_string())?; + if !super::satisfies_node_requirement(&env.version) { + return Err(format!( + "当前 Node {} 不满足 dsh 要求({})", + env.version, + super::NODE_REQUIRED + )); + } + let entry = self + .bin_entry() + .ok_or_else(|| "未安装 dsh,请先完成安装".to_string())?; + + // 端口预检:dsh 自身在端口占用时的报错不够直观,这里提前给出可读错误 + if let Err(e) = TcpListener::bind(SocketAddr::from(([127, 0, 0, 1], port))) { + let msg = format!("端口 {port} 不可用({e}),请在配置中更换端口"); + self.set_server_error(&msg); + return Err(msg); + } + + // 同步 AI 供应商配置(写 settings.yaml + 收集环境变量) + if settings.ai_sync { + if let Err(e) = self.ai_sync(app) { + // 同步失败不阻塞启动,只记日志(用户可在 dsh 内手动配置) + crate::logger::log_warn("dsh", &format!("AI 配置同步失败(继续启动): {e}")); + } + } + let env_vars = self.ai_env_vars(); + + let mut cmd = Command::new(&env.node_exe); + cmd.arg(&entry) + .arg("web") + .arg("--port") + .arg(port.to_string()) + .arg("--no-open"); + cmd.current_dir(self.workspace_dir()); + cmd.env("DSH_HOME", self.home_dir()); + for (key, value) in env_vars { + cmd.env(key, value); + } + cmd.stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .stdin(Stdio::null()); + crate::process_manager::setup_creation_flags(&mut cmd); + + let mut child = cmd.spawn().map_err(|e| { + let msg = format!("启动 dsh 失败({}): {e}", env.node_exe.display()); + self.set_server_error(&msg); + msg + })?; + let pid = child.id(); + crate::process_manager::assign_to_job(&child); + + let stdout = child.stdout.take(); + let stderr = child.stderr.take(); + if let Ok(mut g) = self.server.lock() { + *g = Some(ServerEntry { + child, + pid, + port, + started_at: chrono::Utc::now().timestamp(), + }); + } + + // 输出 → 日志。stdout 额外承担「抓取带令牌启动地址」的职责: + // dsh 就绪后打印 `dsh web: http://127.0.0.1:/?token=<令牌>`, + // 浏览器鉴权靠这个地址换 cookie(我们传了 --no-open,没别人替它换)。 + let ring = self.log_ring_handle(); + let log_path = self.log_path(); + if let Some(out) = stdout { + spawn_stdout_reader(out, ring.clone(), log_path.clone(), self.launch_url.clone(), app.clone()); + } + if let Some(err) = stderr { + spawn_log_reader(err, ring, log_path); + } + + crate::logger::log_info( + "dsh", + &format!("dsh 服务已启动 (pid: {pid}, 端口: {port})"), + ); + self.emit_server_state(app); + + // 就绪探测(后台线程,不阻塞启动返回) + self.spawn_ready_probe(app.clone(), port); + Ok(self.server_status()) + } + + /// 停止 dsh 服务(kill 快速返回,wait 移到后台线程)。 + pub fn stop_server(&self, app: &AppHandle) { + let entry = self.server.lock().ok().and_then(|mut g| g.take()); + self.ready.store(false, Ordering::SeqCst); + if let Ok(mut g) = self.launch_url.lock() { + *g = None; + } + if let Some(mut entry) = entry { + // 先杀进程树(dsh 可能派生子进程),再关本进程句柄 + super::node::taskkill_tree(entry.pid as u64); + let _ = entry.child.kill(); + std::thread::spawn(move || { + let _ = entry.child.wait(); + }); + crate::logger::log_info("dsh", &format!("dsh 服务已停止 (pid: {})", entry.pid)); + } + self.emit_server_state(app); + } + + fn set_server_error(&self, message: &str) { + if let Ok(mut g) = self.server_error.lock() { + *g = Some(message.to_string()); + } + } + + /// 就绪探测:轮询 HTTP,成功置 ready;进程提前退出则记录错误原因。 + fn spawn_ready_probe(&self, app: AppHandle, port: u16) { + std::thread::spawn(move || { + use tauri::Manager; + let deadline = Instant::now() + READY_TIMEOUT; + loop { + { + let manager = app.state::(); + if http_probe(port) { + manager.ready.store(true, Ordering::SeqCst); + manager.emit_server_state(&app); + return; + } + if !manager.server_running() { + // 进程已退出:不必等到超时 + let line = "dsh 服务进程已退出,未能就绪(详见日志)".to_string(); + manager.push_log(&line); + manager.set_server_error(&line); + crate::logger::log_warn("dsh", &line); + manager.emit_server_state(&app); + return; + } + } + if Instant::now() >= deadline { + break; + } + std::thread::sleep(Duration::from_millis(500)); + } + let manager = app.state::(); + manager.emit_server_state(&app); + }); + } + + /// 日志环形缓冲句柄(reader/探测线程持有)。 + pub(crate) fn log_ring_handle(&self) -> std::sync::Arc>> { + self.log_ring.clone() + } +} + +/// 起一个 reader 线程把子进程输出逐行写进日志(stdout 与 stderr 类型不同,故泛型化)。 +fn spawn_log_reader( + pipe: R, + ring: std::sync::Arc>>, + log_path: std::path::PathBuf, +) { + std::thread::spawn(move || { + let reader = BufReader::new(pipe); + for line in reader.lines().map_while(Result::ok) { + super::push_log_shared(&ring, &log_path, &line); + } + }); +} + +/// stdout reader:写日志之外,还从 `dsh web: ...?token=<令牌>` 行里抓取启动地址。 +/// +/// 抓到后置入 `launch_url` 并推送状态事件,前端据此启用「独立窗口 / 浏览器打开」。 +/// 注意锁的粒度:先算好是否需要通知再释放锁——`emit_server_state` 会读 +/// `launch_url`,持锁调用会自锁。 +fn spawn_stdout_reader( + pipe: R, + ring: std::sync::Arc>>, + log_path: std::path::PathBuf, + launch_url: std::sync::Arc>>, + app: tauri::AppHandle, +) { + std::thread::spawn(move || { + let reader = BufReader::new(pipe); + for line in reader.lines().map_while(Result::ok) { + // 先解析原文(落日志时 token 会被掩码) + let parsed = super::parse_launch_url(&line); + if let Some(url) = parsed { + let changed = match launch_url.lock() { + Ok(mut slot) => { + let changed = slot.as_deref() != Some(url.as_str()); + if changed { + *slot = Some(url); + } + changed + } + Err(_) => false, + }; + if changed { + use tauri::Manager; + if let Some(manager) = app.try_state::() { + manager.emit_server_state(&app); + } + } + } + super::push_log_shared(&ring, &log_path, &line); + } + }); +} + +/// 极简 HTTP 探测:TCP 连上并收到以 `HTTP/` 开头的响应即视为就绪。 +fn http_probe(port: u16) -> bool { + let addr = SocketAddr::from(([127, 0, 0, 1], port)); + let Ok(mut stream) = TcpStream::connect_timeout(&addr, Duration::from_millis(500)) else { + return false; + }; + let _ = stream.set_read_timeout(Some(Duration::from_millis(800))); + let req = format!("GET / HTTP/1.1\r\nHost: 127.0.0.1:{port}\r\nConnection: close\r\n\r\n"); + if stream.write_all(req.as_bytes()).is_err() { + return false; + } + let mut buf = [0u8; 16]; + match stream.read(&mut buf) { + Ok(n) if n >= 5 => &buf[..5] == b"HTTP/", + _ => false, + } +} \ No newline at end of file diff --git a/src-tauri/src/dsh/types.rs b/src-tauri/src/dsh/types.rs new file mode 100644 index 0000000..b4563ff --- /dev/null +++ b/src-tauri/src/dsh/types.rs @@ -0,0 +1,239 @@ +//! dsh 模块(DeepSeek Harness 外壳)的数据类型。 +//! +//! 全部走 specta 导出到 `src/lib/bindings.ts`,字段 camelCase。 + +use serde::{Deserialize, Serialize}; +use specta::Type; + +/// dsh 对 Node 的版本要求(`^22.19.0 || >=24.0.0`)。 +pub const NODE_REQUIRED: &str = "^22.19.0 || >=24.0.0"; +/// dsh npm 包名。 +pub const DSH_PACKAGE: &str = "@deepseek-ai/dsh"; +/// 默认 Web UI 端口。 +pub const DEFAULT_PORT: u16 = 3080; +/// 默认「打开独立窗口」全局快捷键(与 quickpanel/截图等同为全局快捷键,格式见 +/// `keyboard-types` 的 `Modifiers+Code`:修饰键名大小写不敏感,数字键名即 `5`)。 +pub const DEFAULT_SHORTCUT: &str = "Alt+D"; + +/// 模块设置(`{app_data}/dsh/settings.json`)。 +/// +/// 独立文件,**不写** `thing_app_settings`(appStore 的 SETTINGS_VERSION 迁移会清空用户设置)。 +#[derive(Debug, Clone, Serialize, Deserialize, Type)] +#[serde(rename_all = "camelCase", default)] +pub struct DshSettings { + /// 结构版本号;变更时按版本校正字段 + pub version: u32, + /// Node 来源偏好:auto(系统优先,缺失回落托管)| system | managed + pub node_source: String, + /// 指定下载的 Node 版本(空 = 自动取满足要求的最新版) + pub managed_node_version: String, + /// Node 分发包镜像前缀(空 = 官方 nodejs.org;国内可用 npmmirror) + pub node_mirror: String, + /// npm registry(空 = 官方源) + pub npm_registry: String, + /// 下载 Node / npm 安装是否走代理模块(mihomo mixed 端口) + pub use_proxy: bool, + /// Web UI 端口(dsh 的 `--port` 参数) + pub port: u16, + /// 应用启动时自动拉起 dsh 服务 + pub auto_start: bool, + /// 全局快捷键:打开 dsh Web 独立窗口(空 = 未启用) + pub shortcut: String, + /// $DSH_HOME 模式:managed({app_data}/dsh/home)| user(~/.dsh) + pub dsh_home_mode: String, + /// 工作区目录(空 = {app_data}/dsh/workspace),即 dsh 进程的启动目录 + pub workspace: String, + /// dsh 本体的安装目录(npm `--prefix` 目标,即 node_modules 所在位置)。 + /// 空 = {app_data}/dsh。 + /// 只有 dsh 本体与它的 node_modules 跟随此设置;便携 Node、$DSH_HOME、 + /// 日志与模块设置仍固定在应用数据目录,避免自定义路径失效时连配置都读不到。 + pub install_dir: String, + /// 映射为 dsh 默认模型的 Thing AI 供应商 id + pub provider_id: String, + /// 启动前自动同步 settings.yaml + pub ai_sync: bool, +} + +impl Default for DshSettings { + fn default() -> Self { + Self { + version: 1, + node_source: "auto".into(), + managed_node_version: String::new(), + node_mirror: String::new(), + npm_registry: String::new(), + use_proxy: true, + port: DEFAULT_PORT, + auto_start: false, + shortcut: DEFAULT_SHORTCUT.into(), + dsh_home_mode: "managed".into(), + workspace: String::new(), + install_dir: String::new(), + provider_id: "deepseek".into(), + ai_sync: true, + } + } +} + +impl DshSettings { + /// 自愈:非法/越界字段夹回默认;版本推进。返回是否发生变更。 + pub fn heal(&mut self) -> bool { + let mut changed = false; + if !matches!(self.node_source.as_str(), "auto" | "system" | "managed") { + self.node_source = "auto".into(); + changed = true; + } + if !matches!(self.dsh_home_mode.as_str(), "managed" | "user") { + self.dsh_home_mode = "managed".into(); + changed = true; + } + if self.port == 0 { + self.port = DEFAULT_PORT; + changed = true; + } + if self.version < 1 { + self.version = 1; + changed = true; + } + // v1 → v2:默认「打开独立窗口」快捷键从 Ctrl+5 改为 Alt+D。 + // 仍等于旧默认值 = 用户没改过,直接迁移;改过(或清空禁用)的原样保留 —— + // 版本号已推进,之后即使再改回旧键位也不会被改写(同 translate 的 heal 约定)。 + if self.version < 2 { + if self.shortcut.trim().eq_ignore_ascii_case("ctrl+5") { + self.shortcut = DEFAULT_SHORTCUT.to_string(); + } + self.version = 2; + changed = true; + } + changed + } +} + +/// Node 运行环境状态。 +#[derive(Debug, Clone, Serialize, Type)] +#[serde(rename_all = "camelCase")] +pub struct NodeStatus { + /// system | managed | none + pub source: String, + /// node.exe 路径 + pub path: Option, + /// 版本号(如 v24.9.0) + pub version: Option, + /// 是否满足 dsh 的版本要求 + pub satisfies: bool, + /// 版本要求文案(供 UI 展示) + pub required: String, +} + +/// dsh 本体安装状态。 +#[derive(Debug, Clone, Serialize, Type)] +#[serde(rename_all = "camelCase")] +pub struct DshInstallStatus { + pub installed: bool, + pub version: Option, + /// bin 入口(dist/bin.js 绝对路径) + pub entry: Option, + /// 安装目录 + pub dir: String, +} + +/// dsh 服务进程状态。 +#[derive(Debug, Clone, Serialize, Type)] +#[serde(rename_all = "camelCase")] +pub struct DshServerStatus { + /// 进程存活 + pub running: bool, + /// HTTP 端口已可访问 + pub ready: bool, + pub pid: Option, + pub port: u16, + /// 规范地址(不含令牌,用于界面展示) + pub url: String, + /// 带令牌的启动地址(**用于打开界面**)。 + /// + /// dsh web 的浏览器鉴权是「进程级随机令牌 → 首次访问换 cookie」: + /// 直接访问 [`Self::url`] 只会拿到 401。令牌每次启动都不同,只能从 + /// dsh 的输出里抓取,因此进程刚起来时这里可能为 None(等它打印)。 + pub launch_url: Option, + /// 启动时间(unix 秒) + pub started_at: Option, + /// 启动失败原因(端口占用 / 进程立即退出等) + pub error: Option, +} + +/// 模块首屏环境总览。 +#[derive(Debug, Clone, Serialize, Type)] +#[serde(rename_all = "camelCase")] +pub struct DshEnvStatus { + pub node: NodeStatus, + pub dsh: DshInstallStatus, + pub server: DshServerStatus, + pub settings: DshSettings, +} + +/// 安装/下载进度事件载荷(与 kernel/music 同构)。 +/// stage: download | extracting | installing | done | error +#[derive(Debug, Clone, Serialize, Type)] +#[serde(rename_all = "camelCase")] +pub struct DshInstallProgress { + pub stage: String, + pub percent: u8, + #[specta(type = f64)] + pub downloaded_bytes: u64, + #[specta(type = Option)] + pub total_bytes: Option, + pub message: String, +} + +/// dsh 版本更新信息。 +#[derive(Debug, Clone, Serialize, Type)] +#[serde(rename_all = "camelCase")] +pub struct DshUpdateInfo { + pub current: Option, + pub latest: String, + pub has_update: bool, + /// 可选版本(倒序,最多 20 个) + pub versions: Vec, +} + +/// npm 源信息(安装引导页展示「本次实际用哪个源」并提供快捷切换)。 +#[derive(Debug, Clone, Serialize, Type)] +#[serde(rename_all = "camelCase")] +pub struct DshNpmRegistryInfo { + /// 本次安装/查询实际会使用的源(已去掉末尾 `/`) + pub effective: String, + /// effective 的来源:setting(模块设置显式指定)| npm(npm 自身配置链)| fallback(默认官方源) + pub source: String, + /// npm 自身解析出的源(环境变量 > 安装目录 .npmrc > 用户 ~/.npmrc > 内置), + /// 未检测到 Node/npm 时为 None + pub npm_registry: Option, + /// 模块设置里显式填写的值(空 = 未指定,交给 npm 解析) + pub setting: String, +} + +/// AI 供应商映射结果(预览用,不含明文密钥)。 +#[derive(Debug, Clone, Serialize, Type)] +#[serde(rename_all = "camelCase")] +pub struct DshAiProvider { + /// Thing 侧供应商 id + pub id: String, + pub name: String, + /// 写入 settings.yaml 的 apiKeyEnv 变量名 + pub env_name: String, + pub base_url: String, + pub model: String, + /// 凭据管理器中是否已配置密钥 + pub has_key: bool, +} + +/// settings.yaml 同步预览。 +#[derive(Debug, Clone, Serialize, Type)] +#[serde(rename_all = "camelCase")] +pub struct DshAiPreview { + /// 将被写入的 YAML 文本(密钥位置只有环境变量名) + pub yaml: String, + pub providers: Vec, + pub default_provider: Option, + pub default_model: Option, + pub settings_path: String, +} \ No newline at end of file diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 741b7e9..24fcae8 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -4,6 +4,7 @@ mod ai; mod clipboard; mod constants; mod download_engine; +mod dsh; mod logger; mod mihomo_manager; mod monitor_kernel; @@ -73,6 +74,13 @@ use music::{ AudioEngine, MusicManager, RemoteManager, SmtcController, SmtcMetaCache, }; use network_monitor::network_status; +use dsh::{ + dsh_ai_preview, dsh_ai_sync, dsh_cancel_install, dsh_check_update, dsh_env_status, + dsh_get_settings, dsh_install, dsh_install_log, dsh_log_clear, dsh_log_tail, + dsh_node_detect, dsh_node_install, dsh_npm_registry_info, dsh_open_dir, + dsh_register_shortcut, dsh_restart, dsh_save_settings, dsh_start, dsh_stop, + dsh_uninstall, dsh_unregister_shortcut, dsh_update, +}; use osd_window::{ osd_apply_overlay_style, osd_begin_drag, osd_set_bounds, osd_set_click_through, osd_set_topmost, osd_start_drag_watch, osd_start_game_watch, osd_start_topmost_watch, @@ -309,6 +317,13 @@ fn export_bindings() { terminal_history_clear, terminal_history_run, // AI 命令助手(P2)——与 `run()` 里那份保持一致,否则 bindings.ts 缺类型 terminal_ai_engines, terminal_ai_suggest, + // dsh(22)——与 `run()` 里那份保持一致,否则 bindings.ts 缺类型 + dsh_env_status, dsh_node_detect, dsh_node_install, dsh_install, dsh_update, + dsh_uninstall, dsh_cancel_install, dsh_check_update, dsh_npm_registry_info, + dsh_get_settings, dsh_save_settings, dsh_register_shortcut, + dsh_unregister_shortcut, dsh_start, dsh_stop, dsh_restart, + dsh_ai_preview, dsh_ai_sync, dsh_log_tail, dsh_install_log, dsh_log_clear, + dsh_open_dir, ]) .export(Typescript::default(), "../src/lib/bindings.ts") .expect("failed to export bindings"); @@ -332,7 +347,7 @@ pub fn run() { .plugin(tauri_plugin_opener::init()) .plugin(tauri_plugin_dialog::init()) // 截图快捷键改由 screenshot::shortcut::register_shortcut(on_shortcut)按需注册, - // 支持自定义;默认 Ctrl+Alt+A 由前端 store 启动时注册 + // 支持自定义;默认 F3 由前端 store 启动时注册 .plugin(tauri_plugin_global_shortcut::Builder::new().build()) .plugin(tauri_plugin_notification::init()) .plugin( @@ -724,7 +739,30 @@ pub fn run() { terminal_save_template, // AI 命令助手(P2) terminal_ai_engines, - terminal_ai_suggest + terminal_ai_suggest, + // dsh(22) + dsh_env_status, + dsh_node_detect, + dsh_node_install, + dsh_install, + dsh_update, + dsh_uninstall, + dsh_cancel_install, + dsh_check_update, + dsh_npm_registry_info, + dsh_get_settings, + dsh_save_settings, + dsh_register_shortcut, + dsh_unregister_shortcut, + dsh_start, + dsh_stop, + dsh_restart, + dsh_ai_preview, + dsh_ai_sync, + dsh_log_tail, + dsh_install_log, + dsh_log_clear, + dsh_open_dir ]) .setup(setup::init) .on_window_event(|window, event| { diff --git a/src-tauri/src/music/audio/engine.rs b/src-tauri/src/music/audio/engine.rs index 6750052..271b882 100644 --- a/src-tauri/src/music/audio/engine.rs +++ b/src-tauri/src/music/audio/engine.rs @@ -117,6 +117,10 @@ enum Control { struct Session { shared: Arc, ctrl: Sender, + /// 播放线程句柄:**故意不 join**(见 `stop_current` 的说明),唯一作用是与会话 + /// 同生共死 —— 会话 Arc 释放时它一起被丢弃,丢弃即 detach,线程收到 Stop 后 + /// 自行收尾并释放输出流。因为从不解绑/join,此字段除「持有」外没有任何读取。 + #[allow(dead_code)] handle: JoinHandle<()>, } diff --git a/src-tauri/src/music/mod.rs b/src-tauri/src/music/mod.rs index 69d2d3a..aba70f6 100644 --- a/src-tauri/src/music/mod.rs +++ b/src-tauri/src/music/mod.rs @@ -523,7 +523,7 @@ impl MusicManager { /// 解析桥接要用的 Python 运行时。 /// 便携版优先:musicdl 只装入便携运行时,系统 Python 无法保证装有 musicdl; /// 无便携版时退回系统 Python(此时 search 会报 musicdl 未安装,引导用户装便携版)。 - pub fn resolve_python(&self) -> Result { + pub(crate) fn resolve_python(&self) -> Result { if let Some(env) = self.detect_bundled_python() { return Ok(env); } @@ -534,7 +534,7 @@ impl MusicManager { } /// 便携 Python 是否可用(exe 存在且能跑 --version) - pub fn detect_bundled_python(&self) -> Option { + pub(crate) fn detect_bundled_python(&self) -> Option { detect_bundled_python_at(&self.bundled_python_exe()) } diff --git a/src-tauri/src/setup.rs b/src-tauri/src/setup.rs index 8f0ca3f..6e48e41 100644 --- a/src-tauri/src/setup.rs +++ b/src-tauri/src/setup.rs @@ -77,6 +77,12 @@ pub fn init(app: &mut App) -> Result<(), Box> { let _ = ai.load_settings(); app.manage(ai); + // ===== dsh 模块:DshManager(DeepSeek Harness 外壳) ===== + // 仅注册状态:Node/dsh 的安装、服务进程与 settings.yaml 同步都在命令调用时按需触发 + // (启动阶段只有 autoStart 开启时才拉起服务,见 init 末尾)。 + let dsh = crate::dsh::DshManager::new(app_data_dir.clone()); + app.manage(dsh); + // ===== 翻译模块:TranslateManager ===== // 仅注册状态:设置与密钥都在命令调用时按需读取,启动阶段不发任何网络请求 // (模型可用性校验因此改为懒校验:首次翻译失败时解释原因 + 设置页手动拉取模型列表)。 @@ -181,8 +187,12 @@ pub fn init(app: &mut App) -> Result<(), Box> { monitor.auto_start_on_launch(app.handle()); } + // dsh:开启"自动启动"且已安装时拉起 Web 服务(后台线程执行就绪探测,不阻塞启动)。 + // 「打开独立窗口」快捷键由前端 dshStore 启动时注册(同截图模块约定)。 + crate::dsh::autostart_if_enabled(app.handle()); + // 截图快捷键由前端 screenshotStore 启动时调用 screenshot_register_shortcut 注册 - // (支持自定义,默认 Ctrl+Alt+A),此处不再硬编码注册 + // (支持自定义,默认 F3),此处不再硬编码注册 Ok(()) } diff --git a/src-tauri/src/terminal/settings.rs b/src-tauri/src/terminal/settings.rs index 5d51b4a..8d4a881 100644 --- a/src-tauri/src/terminal/settings.rs +++ b/src-tauri/src/terminal/settings.rs @@ -662,9 +662,10 @@ impl Default for TemplateEntry { /// - 新建/关闭标签用 `Ctrl+Shift+T/W`,与浏览器习惯一致。 /// - 跳转标签用 `Alt+1..9`:`Ctrl+数字` 已被翻译模块的 `Ctrl+2`(翻译面板)占用, /// 而 `Alt+数字` 在终端里通常不产生控制字符,冲突面最小。 -/// - `newDetachedWindow`(`Ctrl+3`)是这张表里唯一**全局**生效的一条:它由前端 +///- `newDetachedWindow`(`Alt+T`)是这张表里唯一**全局**生效的一条:它由前端 /// `TerminalQuickLaunch` 注册成系统级热键(任意应用前台可触发),放在这里只为 -/// 跟着终端设置一起存与改。`Ctrl+2` 已被翻译面板占用,`Ctrl+3` 是空闲的相邻键位。 +/// 跟着终端设置一起存与改。`Alt+T` 与翻译面板的 `Alt+F`、dsh 的 `Alt+D` +/// 同处 `Alt+字母` 段,互不冲突。 pub fn default_shortcuts() -> Vec { let pairs: &[(&str, &str)] = &[ ("copy", "Ctrl+Shift+C"), @@ -692,7 +693,7 @@ pub fn default_shortcuts() -> Vec { // action(未知 action 会被剔除),前端设置表里有而这里没有 = 用户改完下次启动就被清掉。 ("detachWindow", "Ctrl+Shift+N"), // 全局生效的一条(见上方说明):新建独立窗口 + 选择会话 - ("newDetachedWindow", "Ctrl+3"), + ("newDetachedWindow", "Alt+T"), ]; pairs .iter() @@ -832,6 +833,23 @@ impl TerminalSettings { changed = true; } + // v2 → v3:新建独立窗口的默认键位从 Ctrl+3 改为 Alt+T(Ctrl+数字 与 + // 翻译面板、终端「Alt+数字 跳标签」两处分段冲突,统一收到 Alt+字母)。 + // 仍等于旧默认值 = 用户没改过,直接迁移;改过的原样保留。 + if self.version < 3 { + if let Some(binding) = self + .shortcuts + .iter_mut() + .find(|s| s.action == "newDetachedWindow") + { + if binding.keys.trim().eq_ignore_ascii_case("ctrl+3") { + binding.keys = "Alt+T".to_string(); + } + } + self.version = 3; + changed = true; + } + changed } } diff --git a/src-tauri/src/translate/settings.rs b/src-tauri/src/translate/settings.rs index b6f0662..d85f341 100644 --- a/src-tauri/src/translate/settings.rs +++ b/src-tauri/src/translate/settings.rs @@ -190,7 +190,7 @@ impl Default for TranslateEngineConfig { pub struct SelectionSettings { /// 总开关:打开翻译面板时是否尝试读取当前划词作为候选 pub enabled: bool, - /// 打开翻译面板的全局快捷键(默认 Ctrl+2) + /// 打开翻译面板的全局快捷键(默认 Alt+F) #[serde(default = "default_panel_shortcut")] pub panel_shortcut: String, /// 取词方式: @@ -209,7 +209,7 @@ pub struct SelectionSettings { } fn default_panel_shortcut() -> String { - "Ctrl+2".to_string() + "Alt+F".to_string() } impl Default for SelectionSettings { @@ -427,6 +427,19 @@ impl TranslateSettings { self.version = 2; changed = true; } + // v2 → v3:翻译面板默认快捷键从 Ctrl+2 改为 Alt+F(把 Ctrl+数字 让给终端)。 + // 仍等于旧默认值 = 用户没改过,直接迁移;改过或已清空的原样保留。 + if self.version < 3 { + if self.selection + .panel_shortcut + .trim() + .eq_ignore_ascii_case("ctrl+2") + { + self.selection.panel_shortcut = default_panel_shortcut(); + } + self.version = 3; + changed = true; + } changed } } diff --git a/src/components/ui/stepper/Stepper.vue b/src/components/ui/stepper/Stepper.vue new file mode 100644 index 0000000..91a7ce6 --- /dev/null +++ b/src/components/ui/stepper/Stepper.vue @@ -0,0 +1,27 @@ + + + diff --git a/src/components/ui/stepper/StepperDescription.vue b/src/components/ui/stepper/StepperDescription.vue new file mode 100644 index 0000000..49ce3ab --- /dev/null +++ b/src/components/ui/stepper/StepperDescription.vue @@ -0,0 +1,19 @@ + + + diff --git a/src/components/ui/stepper/StepperIndicator.vue b/src/components/ui/stepper/StepperIndicator.vue new file mode 100644 index 0000000..cb96e75 --- /dev/null +++ b/src/components/ui/stepper/StepperIndicator.vue @@ -0,0 +1,32 @@ + + + diff --git a/src/components/ui/stepper/StepperItem.vue b/src/components/ui/stepper/StepperItem.vue new file mode 100644 index 0000000..fda449b --- /dev/null +++ b/src/components/ui/stepper/StepperItem.vue @@ -0,0 +1,23 @@ + + + diff --git a/src/components/ui/stepper/StepperSeparator.vue b/src/components/ui/stepper/StepperSeparator.vue new file mode 100644 index 0000000..33b5a73 --- /dev/null +++ b/src/components/ui/stepper/StepperSeparator.vue @@ -0,0 +1,27 @@ + + + diff --git a/src/components/ui/stepper/StepperTitle.vue b/src/components/ui/stepper/StepperTitle.vue new file mode 100644 index 0000000..9004182 --- /dev/null +++ b/src/components/ui/stepper/StepperTitle.vue @@ -0,0 +1,19 @@ + + + diff --git a/src/components/ui/stepper/StepperTrigger.vue b/src/components/ui/stepper/StepperTrigger.vue new file mode 100644 index 0000000..0cbb539 --- /dev/null +++ b/src/components/ui/stepper/StepperTrigger.vue @@ -0,0 +1,22 @@ + + + diff --git a/src/components/ui/stepper/index.ts b/src/components/ui/stepper/index.ts new file mode 100644 index 0000000..a755492 --- /dev/null +++ b/src/components/ui/stepper/index.ts @@ -0,0 +1,7 @@ +export { default as Stepper } from "./Stepper.vue" +export { default as StepperDescription } from "./StepperDescription.vue" +export { default as StepperIndicator } from "./StepperIndicator.vue" +export { default as StepperItem } from "./StepperItem.vue" +export { default as StepperSeparator } from "./StepperSeparator.vue" +export { default as StepperTitle } from "./StepperTitle.vue" +export { default as StepperTrigger } from "./StepperTrigger.vue" diff --git a/src/lib/bindings.ts b/src/lib/bindings.ts index 1ab4756..30b27c8 100644 --- a/src/lib/bindings.ts +++ b/src/lib/bindings.ts @@ -853,6 +853,73 @@ export const commands = { * 帮助模型理解「接着上一步做什么」。 */ terminalAiSuggest: (engineId: string, intent: string, context: string) => __TAURI_INVOKE("terminal_ai_suggest", { engineId, intent, context }), + /** + * 环境总览:Node / dsh / 服务状态 + 模块设置(模块首屏一次拿全)。 + * + * 声明为 `async`:Tauri 的**同步**命令在主线程执行,而本命令要跑 + * `node --version` 子进程探测,放主线程会造成界面卡顿。 + * (async 命令带 `State<'_>` 引用参数时必须返回 `Result`,故这里包一层 Ok。) + */ + dshEnvStatus: () => __TAURI_INVOKE("dsh_env_status"), + /** 重新探测 Node(系统 PATH + 托管目录)。同样因执行 `node --version` 而用 async。 */ + dshNodeDetect: () => __TAURI_INVOKE("dsh_node_detect"), + /** 下载并安装便携 Node(`version` 为空 = 自动取满足要求的最新版)。 */ + dshNodeInstall: (version: string | null) => __TAURI_INVOKE("dsh_node_install", { version }), + /** 安装 dsh(`version` 为空 = latest)。 */ + dshInstall: (version: string | null) => __TAURI_INVOKE("dsh_install", { version }), + /** 更新 dsh 到 latest(更新前停止服务,避免文件被占用)。 */ + dshUpdate: () => __TAURI_INVOKE("dsh_update"), + /** 卸载 dsh(停止服务并删除包目录;保留设置与 $DSH_HOME)。 */ + dshUninstall: () => __TAURI_INVOKE("dsh_uninstall"), + /** 取消进行中的下载 / 安装。 */ + dshCancelInstall: () => __TAURI_INVOKE("dsh_cancel_install"), + /** 查询 npm 上的可用版本。 */ + dshCheckUpdate: () => __TAURI_INVOKE("dsh_check_update"), + /** + * 读取「本次安装实际使用的 npm 源」及其来源。 + * + * 设置为空时 npm 会用自己配置链里的源(含系统 Node 的 `~/.npmrc`), + * 这里把解析结果回给前端展示,让用户能看出「到底走的是哪个源」。 + * async:内部要跑 `node config get registry` 子进程。 + */ + dshNpmRegistryInfo: () => __TAURI_INVOKE("dsh_npm_registry_info"), + dshGetSettings: () => __TAURI_INVOKE("dsh_get_settings"), + /** 保存设置(即时生效;端口等改动在下次启动服务时生效)。 */ + dshSaveSettings: (settings: DshSettings) => __TAURI_INVOKE("dsh_save_settings", { settings }), + /** + * 注册(或切换)「打开 dsh 独立窗口」全局快捷键;传空字符串则注销。 + * + * 按下时只 emit `dsh-open-window` 事件,**窗口由前端创建**:前端才持有带令牌的 + * 启动地址,也能用 label 判重复用已开窗口(与截图模块「快捷键 → 事件 → 前端开窗」同构)。 + */ + dshRegisterShortcut: (shortcut: string) => __TAURI_INVOKE("dsh_register_shortcut", { shortcut }), + /** 注销「打开 dsh 独立窗口」全局快捷键。 */ + dshUnregisterShortcut: () => __TAURI_INVOKE("dsh_unregister_shortcut"), + /** + * 启动 dsh Web 服务。async:内部要 spawn 子进程 + 读凭据 + 写 settings.yaml, + * 同步命令会在主线程执行从而卡住界面。 + */ + dshStart: () => __TAURI_INVOKE("dsh_start"), + /** 停止 dsh Web 服务。 */ + dshStop: () => __TAURI_INVOKE("dsh_stop"), + /** 重启 dsh Web 服务。 */ + dshRestart: () => __TAURI_INVOKE("dsh_restart"), + /** 预览将写入 `$DSH_HOME/settings.yaml` 的内容(不含明文密钥)。 */ + dshAiPreview: () => __TAURI_INVOKE("dsh_ai_preview"), + /** 执行 AI 配置同步(合并写入 settings.yaml,写前备份)。 */ + dshAiSync: () => __TAURI_INVOKE("dsh_ai_sync"), + /** 读取服务日志尾部。 */ + dshLogTail: (lines: number) => __TAURI_INVOKE("dsh_log_tail", { lines }), + /** + * 读取 dsh 安装输出(npm 的 stdout/stderr 尾部)。 + * + * 只存在内存里(每次安装开始时清空),供「安装引导 → dsh 本体」页临时展示, + * **不写应用日志、不落盘**。前端在安装进行中轮询这个命令。 + */ + dshInstallLog: () => __TAURI_INVOKE("dsh_install_log"), + dshLogClear: () => __TAURI_INVOKE("dsh_log_clear"), + /** 在资源管理器中打开 dsh 模块目录。 */ + dshOpenDir: () => __TAURI_INVOKE("dsh_open_dir"), }; /* Types */ @@ -1365,6 +1432,136 @@ export type DownloaderSettings = { btUseProxy?: boolean, }; +/** settings.yaml 同步预览。 */ +export type DshAiPreview = { + /** 将被写入的 YAML 文本(密钥位置只有环境变量名) */ + yaml: string, + providers: DshAiProvider[], + defaultProvider: string | null, + defaultModel: string | null, + settingsPath: string, +}; + +/** AI 供应商映射结果(预览用,不含明文密钥)。 */ +export type DshAiProvider = { + /** Thing 侧供应商 id */ + id: string, + name: string, + /** 写入 settings.yaml 的 apiKeyEnv 变量名 */ + envName: string, + baseUrl: string, + model: string, + /** 凭据管理器中是否已配置密钥 */ + hasKey: boolean, +}; + +/** 模块首屏环境总览。 */ +export type DshEnvStatus = { + node: NodeStatus, + dsh: DshInstallStatus, + server: DshServerStatus, + settings: DshSettings, +}; + +/** dsh 本体安装状态。 */ +export type DshInstallStatus = { + installed: boolean, + version: string | null, + /** bin 入口(dist/bin.js 绝对路径) */ + entry: string | null, + /** 安装目录 */ + dir: string, +}; + +/** npm 源信息(安装引导页展示「本次实际用哪个源」并提供快捷切换)。 */ +export type DshNpmRegistryInfo = { + /** 本次安装/查询实际会使用的源(已去掉末尾 `/`) */ + effective: string, + /** effective 的来源:setting(模块设置显式指定)| npm(npm 自身配置链)| fallback(默认官方源) */ + source: string, + /** + * npm 自身解析出的源(环境变量 > 安装目录 .npmrc > 用户 ~/.npmrc > 内置), + * 未检测到 Node/npm 时为 None + */ + npmRegistry: string | null, + /** 模块设置里显式填写的值(空 = 未指定,交给 npm 解析) */ + setting: string, +}; + +/** dsh 服务进程状态。 */ +export type DshServerStatus = { + /** 进程存活 */ + running: boolean, + /** HTTP 端口已可访问 */ + ready: boolean, + pid: number | null, + port: number, + /** 规范地址(不含令牌,用于界面展示) */ + url: string, + /** + * 带令牌的启动地址(**用于打开界面**)。 + * + * dsh web 的浏览器鉴权是「进程级随机令牌 → 首次访问换 cookie」: + * 直接访问 [`Self::url`] 只会拿到 401。令牌每次启动都不同,只能从 + * dsh 的输出里抓取,因此进程刚起来时这里可能为 None(等它打印)。 + */ + launchUrl: string | null, + /** 启动时间(unix 秒) */ + startedAt: number | null, + /** 启动失败原因(端口占用 / 进程立即退出等) */ + error: string | null, +}; + +/** + * 模块设置(`{app_data}/dsh/settings.json`)。 + * + * 独立文件,**不写** `thing_app_settings`(appStore 的 SETTINGS_VERSION 迁移会清空用户设置)。 + */ +export type DshSettings = { + /** 结构版本号;变更时按版本校正字段 */ + version?: number, + /** Node 来源偏好:auto(系统优先,缺失回落托管)| system | managed */ + nodeSource?: string, + /** 指定下载的 Node 版本(空 = 自动取满足要求的最新版) */ + managedNodeVersion?: string, + /** Node 分发包镜像前缀(空 = 官方 nodejs.org;国内可用 npmmirror) */ + nodeMirror?: string, + /** npm registry(空 = 官方源) */ + npmRegistry?: string, + /** 下载 Node / npm 安装是否走代理模块(mihomo mixed 端口) */ + useProxy?: boolean, + /** Web UI 端口(dsh 的 `--port` 参数) */ + port?: number, + /** 应用启动时自动拉起 dsh 服务 */ + autoStart?: boolean, + /** 全局快捷键:打开 dsh Web 独立窗口(空 = 未启用) */ + shortcut?: string, + /** $DSH_HOME 模式:managed({app_data}/dsh/home)| user(~/.dsh) */ + dshHomeMode?: string, + /** 工作区目录(空 = {app_data}/dsh/workspace),即 dsh 进程的启动目录 */ + workspace?: string, + /** + * dsh 本体的安装目录(npm `--prefix` 目标,即 node_modules 所在位置)。 + * 空 = {app_data}/dsh。 + * 只有 dsh 本体与它的 node_modules 跟随此设置;便携 Node、$DSH_HOME、 + * 日志与模块设置仍固定在应用数据目录,避免自定义路径失效时连配置都读不到。 + */ + installDir?: string, + /** 映射为 dsh 默认模型的 Thing AI 供应商 id */ + providerId?: string, + /** 启动前自动同步 settings.yaml */ + aiSync?: boolean, +}; + +/** dsh 版本更新信息。 */ +export type DshUpdateInfo = { + current: string | null, + latest: string, + hasUpdate: boolean, + /** 可选版本(倒序,最多 20 个) */ + versions: string[], +}; + /** 重复类型 */ export type DuplicateKind = /** 无重复 */ @@ -1787,6 +1984,20 @@ export type MusicSettings = { remoteDevices?: RemoteDeviceMeta[], }; +/** Node 运行环境状态。 */ +export type NodeStatus = { + /** system | managed | none */ + source: string, + /** node.exe 路径 */ + path: string | null, + /** 版本号(如 v24.9.0) */ + version: string | null, + /** 是否满足 dsh 的版本要求 */ + satisfies: boolean, + /** 版本要求文案(供 UI 展示) */ + required: string, +}; + /** 划词结果悬浮窗外观(P1 生效)。 */ export type PopupSettings = { /** 正文字号(逻辑像素) */ @@ -2079,7 +2290,7 @@ export type Segment = { export type SelectionSettings = { /** 总开关:打开翻译面板时是否尝试读取当前划词作为候选 */ enabled?: boolean, - /** 打开翻译面板的全局快捷键(默认 Ctrl+2) */ + /** 打开翻译面板的全局快捷键(默认 Alt+F) */ panelShortcut?: string, /** * 取词方式: diff --git a/src/lib/constants.ts b/src/lib/constants.ts index bdfeb11..232be65 100644 --- a/src/lib/constants.ts +++ b/src/lib/constants.ts @@ -20,6 +20,13 @@ export const WINDOWS = { translatePopup: 'translate-popup', /** 单个终端独立窗口,实际 label = `terminal-window-` */ terminalWindow: 'terminal-window', + /** + * dsh 模块的 Web UI 独立窗口。 + * 内容为远端 `http://127.0.0.1:`,因此**不登记 capability**—— + * 远端页面不应获得任何 Tauri 权限(Windows 平台上 label 未命中任何 capability + * 时,webview 仍可正常加载与交互,只是拿不到 IPC)。 + */ + dshWeb: 'dsh-web', } as const /** Tauri 事件名(前端 emit / listen 与 Rust constants::events 对应) */ @@ -49,9 +56,13 @@ export const EVENTS = { // 截图 screenshotBegin: 'screenshot-begin', screenshotOverlayReady: 'screenshot-overlay-ready', + /** 覆盖层握手请求:主窗口每次发起截图前询问覆盖层是否已注册好 begin 监听(覆盖层以 screenshotOverlayReady 应答) */ + screenshotOverlayPing: 'screenshot-overlay-ping', screenshotShortcut: 'screenshot-shortcut', screenshotPinShortcut: 'screenshot-pin-shortcut', screenshotPinReady: 'screenshot-pin-ready', + /** 贴图窗口握手请求(同覆盖层):贴图窗口以 screenshotPinReady 应答 */ + screenshotPinPing: 'screenshot-pin-ping', screenshotPinShow: 'screenshot-pin-show', screenshotExported: 'screenshot-exported', /** 滚动截图会话:实时进度 { width, height, auto } */ @@ -64,6 +75,8 @@ export const EVENTS = { scrollToEditor: 'screenshot-scroll-to-editor', /** 常驻编辑器窗口挂载完成(store 等待后下发加载事件) */ screenshotEditorReady: 'screenshot-editor-ready', + /** 编辑器握手请求(同覆盖层):编辑器以 screenshotEditorReady 应答 */ + screenshotEditorPing: 'screenshot-editor-ping', /** 通知常驻编辑器窗口加载编辑器图片槽中的新图(raw IPC 取出) */ screenshotEditorLoad: 'screenshot-editor-load', // 内核安装进度 @@ -127,6 +140,13 @@ export const EVENTS = { downloadRemoved: 'download-removed', /** 浏览器扩展通过 HTTP API 新增下载(负载 { id },前端据以为该任务创建专属下载窗口) */ downloadExtensionAdded: 'download-extension-added', + // dsh 模块 + /** 安装/下载进度(负载见 src/types/dsh.ts 的 DshInstallProgress) */ + dshInstallProgress: 'dsh-install-progress', + /** 服务进程状态(负载见 src/types/dsh.ts 的 DshServerStatus) */ + dshServerState: 'dsh-server-state', + /** 全局快捷键按下:打开 dsh 独立窗口(无负载) */ + dshOpenWindow: 'dsh-open-window', } as const /** localStorage 存储键 */ diff --git a/src/lib/terminalActions.ts b/src/lib/terminalActions.ts index 5aa1784..8b8e690 100644 --- a/src/lib/terminalActions.ts +++ b/src/lib/terminalActions.ts @@ -17,9 +17,12 @@ * SIGINT(中断当前命令),这是不可协商的——把它映射成「复制」会让所有用户 * 失去中断能力。因此复制粘贴用 `Ctrl+Shift+C/V`(Windows Terminal 惯例)。 * - * 2. **避开项目已有的全局快捷键**。`Ctrl+2` 已被翻译模块占用(取词翻译面板), - * 所以标签跳转用 `Alt+1..9` —— 在终端里 `Alt+数字` 通常不产生控制字符, - * 冲突面最小,且符合「切标签」的直觉。 + * 2. **避开 `Ctrl+数字`**。项目里全局快捷键曾用过 `Ctrl+2`(翻译面板)与 + * `Ctrl+3`(新建独立窗口),现已统一收进 `Alt+字母` 段;标签跳转用 + * `Alt+1..9` —— 在终端里 `Alt+数字` 通常不产生控制字符,冲突面最小, + * 且符合「切标签」的直觉。 + * 全局那几条都落在 `Alt+字母`(翻译面板 `Alt+F`、dsh `Alt+D`、 + * 新建独立窗口 `Alt+T`),彼此不冲突,`Ctrl+数字` 整段留空。 * * # 唯一一条「全局」动作:`newDetachedWindow` * @@ -199,7 +202,7 @@ export const TERMINAL_ACTIONS: TerminalAction[] = [ label: '新建独立窗口', group: '会话', description: '全局生效(任意界面按下):打开独立终端窗口并选择要启动的会话', - defaultKeys: 'Ctrl+3' + defaultKeys: 'Alt+T' } ] diff --git a/src/main.ts b/src/main.ts index d46daf1..5797227 100644 --- a/src/main.ts +++ b/src/main.ts @@ -119,6 +119,12 @@ if (matched) { screenshotStore.initPinShortcutListener().catch(e => console.error('Screenshot pin shortcut listener init error:', e)) screenshotStore.initPinShortcutRegistration().catch(e => console.error('Screenshot pin shortcut registration init error:', e)) }) + + // dsh 模块:应用级初始化全局快捷键(注册 + 监听「打开独立窗口」事件)。 + // 放这里而不是模块挂载时:快捷键要在任意模块下都能用,模块卸载不能把它带走。 + void import('./stores/dshStore').then(({ useDshStore }) => { + useDshStore().initGlobalShortcut().catch(e => console.error('dsh shortcut init error:', e)) + }) }) } diff --git a/src/modules/dsh/DshModule.vue b/src/modules/dsh/DshModule.vue new file mode 100644 index 0000000..42e1873 --- /dev/null +++ b/src/modules/dsh/DshModule.vue @@ -0,0 +1,170 @@ + + + \ No newline at end of file diff --git a/src/modules/dsh/components/DshLogPanel.vue b/src/modules/dsh/components/DshLogPanel.vue new file mode 100644 index 0000000..1eea666 --- /dev/null +++ b/src/modules/dsh/components/DshLogPanel.vue @@ -0,0 +1,54 @@ + + + \ No newline at end of file diff --git a/src/modules/dsh/components/DshSettingsPanel.vue b/src/modules/dsh/components/DshSettingsPanel.vue new file mode 100644 index 0000000..e6c2c4f --- /dev/null +++ b/src/modules/dsh/components/DshSettingsPanel.vue @@ -0,0 +1,363 @@ + + + \ No newline at end of file diff --git a/src/modules/dsh/components/SetupStepper.vue b/src/modules/dsh/components/SetupStepper.vue new file mode 100644 index 0000000..c73273c --- /dev/null +++ b/src/modules/dsh/components/SetupStepper.vue @@ -0,0 +1,491 @@ + + + + + \ No newline at end of file diff --git a/src/modules/dsh/index.ts b/src/modules/dsh/index.ts new file mode 100644 index 0000000..4ae9cd7 --- /dev/null +++ b/src/modules/dsh/index.ts @@ -0,0 +1,72 @@ +import type { ModuleConfig } from '@/types/module' +import type { SearchIndexItem } from '@/stores/searchIndex' + +const searchItems: SearchIndexItem[] = [ + { + title: 'DeepSeek Harness', + description: '安装、更新与启动 dsh,管理 Node 运行环境与 AI 通道', + keywords: ['dsh', 'deepseek', 'harness', 'agent', '智能体', '外壳', '安装'], + tab: 'setup' + }, + { + title: '安装 dsh 环境', + description: '按步骤引导安装 Node 运行环境与 dsh 本体', + keywords: ['安装', 'install', 'node', '环境', '引导', 'stepper', '更新'], + tab: 'setup' + }, + { + title: 'dsh 设置', + description: '端口、工作区、Node 来源、镜像源与自动启动', + keywords: ['设置', 'setting', '端口', 'port', '工作区', 'workspace', '镜像'], + tab: 'settings' + }, + { + title: 'dsh AI 通道', + description: '把设置里的 AI 供应商(含 DeepSeek API Key)同步给 dsh', + keywords: ['ai', 'api key', 'deepseek', '供应商', 'provider', '模型', 'model'], + tab: 'settings' + }, + { + title: 'dsh 运行日志', + description: '查看 dsh 服务的输出日志', + keywords: ['日志', 'log', '输出', '排查', 'debug'], + tab: 'logs' + } +] + +export const moduleConfig: ModuleConfig = { + id: 'dsh', + name: 'DeepSeek Harness', + icon: 'dsh', + description: 'DeepSeek Harness(dsh)外壳:环境安装引导、版本更新与 Web 服务生命周期管理', + category: 'tool', + defaultEnabled: true, + loader: () => import('./DshModule.vue'), + searchItems, + lifecycle: { + // 模块启用:恢复全局快捷键(应用启动时由 main.ts 注册;这里覆盖「先禁用再启用」) + onEnable: async () => { + try { + const { useDshStore } = await import('@/stores/dshStore') + await useDshStore().registerShortcut() + } catch (e) { + console.error('[dsh] onEnable 注册快捷键失败:', e) + } + }, + // 模块禁用:停服务 + 注销快捷键(服务停了快捷键也没意义,且组合键不该被占着) + onDisable: async () => { + // 动态导入避免 index.ts 直接依赖 store(会形成循环依赖,参见 terminal / music 的处理) + try { + const { useDshStore } = await import('@/stores/dshStore') + const store = useDshStore() + if (store.running) await store.stop() + await store.unregisterShortcut() + store.stopListeners() + } catch (e) { + console.error('[dsh] onDisable 停止服务失败:', e) + } + } + }, + // 排在开发工具之后:音乐 / 代理 / 下载 / 终端 / 翻译 / 监控 / 截图 / 剪贴板 / 快捷面板 / 开发工具 / dsh + order: 110 +} \ No newline at end of file diff --git a/src/modules/icons.ts b/src/modules/icons.ts index 5a30f2d..7b64b2d 100644 --- a/src/modules/icons.ts +++ b/src/modules/icons.ts @@ -10,7 +10,8 @@ import { Wrench, Music, Languages, - SquareTerminal + SquareTerminal, + Bot } from '@lucide/vue' /** @@ -31,7 +32,8 @@ export const moduleIconMap: Record = { devtools: Wrench, music: Music, translate: Languages, - terminal: SquareTerminal + terminal: SquareTerminal, + dsh: Bot } /** 获取模块图标组件,未找到时回退到 Settings 图标 */ diff --git a/src/modules/index.ts b/src/modules/index.ts index 53353ad..ff1e693 100644 --- a/src/modules/index.ts +++ b/src/modules/index.ts @@ -13,6 +13,7 @@ import { moduleConfig as settings } from './settings' import { moduleConfig as music } from './music' import { moduleConfig as translate } from './translate' import { moduleConfig as terminal } from './terminal' +import { moduleConfig as dsh } from './dsh' const allModules: ModuleConfig[] = [ proxy, @@ -25,7 +26,8 @@ const allModules: ModuleConfig[] = [ settings, music, translate, - terminal + terminal, + dsh ] // 启动时注册所有模块 diff --git a/src/modules/screenshot/ScreenshotEditor.vue b/src/modules/screenshot/ScreenshotEditor.vue index 9ed3b6b..306549a 100644 --- a/src/modules/screenshot/ScreenshotEditor.vue +++ b/src/modules/screenshot/ScreenshotEditor.vue @@ -63,6 +63,8 @@ const win = getCurrentWindow() let objectUrl = '' /** 常驻窗口:加载事件监听(store 通知加载编辑器图片槽中的新图) */ let loadUnlisten: UnlistenFn | null = null +/** 握手请求监听(见 store 的 ensureEditorReady):主窗口每次打开编辑器前 ping,本窗口应答 ready */ +let pingUnlisten: UnlistenFn | null = null /** 马赛克结果缓存:标注参数不变时跳过重复像素化(长图上拖动其他标注不再卡顿) */ let mosaicCache: { key: string; canvas: HTMLCanvasElement } | null = null @@ -1108,6 +1110,12 @@ onMounted(async () => { loadUnlisten = await listen(EVENTS.screenshotEditorLoad, () => { void loadPendingImage() }) + // 握手应答:主窗口每次打开编辑器前 ping(store 的 ensureEditorReady)。本监听挂在 + // 加载监听**之后** —— 只有加载监听已就绪,应答才代表「可以接收新图」。这样主窗口 + // 重载后(编辑器窗口存活、不会再发首次 ready)也能重新确认就绪状态。 + pingUnlisten = await listen(EVENTS.screenshotEditorPing, () => { + void emit(EVENTS.screenshotEditorReady).catch(() => {}) + }) await emit(EVENTS.screenshotEditorReady) }) @@ -1118,6 +1126,8 @@ onUnmounted(() => { window.removeEventListener('storage', onStorageChange) loadUnlisten?.() loadUnlisten = null + pingUnlisten?.() + pingUnlisten = null if (objectUrl) { URL.revokeObjectURL(objectUrl) objectUrl = '' diff --git a/src/modules/screenshot/ScreenshotOverlay.vue b/src/modules/screenshot/ScreenshotOverlay.vue index bbdd9d4..1746c7e 100644 --- a/src/modules/screenshot/ScreenshotOverlay.vue +++ b/src/modules/screenshot/ScreenshotOverlay.vue @@ -167,6 +167,8 @@ let magGridCanvas: HTMLCanvasElement | null = null // 常驻窗口:'screenshot-begin' 事件监听(store 捕获并定位窗口后触发) let beginUnlisten: UnlistenFn | null = null +/** 握手请求监听(见 store 的 ensureOverlayReady):主窗口每次截图前 ping,本窗口应答 ready */ +let pingUnlisten: UnlistenFn | null = null const beginUnlistenCleanups: Array<() => void> = [] /** 界面内滚动会话事件监听(scrollProgress / scrollComplete / scrollCancelled) */ let scrollProgressUnlisten: UnlistenFn | null = null @@ -1904,6 +1906,12 @@ onMounted(async () => { beginUnlisten = await listen(EVENTS.screenshotBegin, (e) => { void beginCapture(e.payload) }) + // 握手应答:主窗口每次发起截图前 ping(store 的 ensureOverlayReady)。本监听挂在 + // begin 监听**之后** —— 只有 begin 监听已就绪,应答才真正代表「可以接收截图」。 + // 这样主窗口重载后(覆盖层窗口存活、不会再发首次 ready)也能重新确认就绪状态。 + pingUnlisten = await listen(EVENTS.screenshotOverlayPing, () => { + void emit(EVENTS.screenshotOverlayReady).catch(() => {}) + }) // 界面内滚动会话事件(仅滚动模式下有意义;会话由主窗口触发、覆盖层常驻监听) scrollProgressUnlisten = await listen<{ width: number; height: number }>(EVENTS.scrollProgress, (e) => { if (!scrollMode.value) return @@ -2029,6 +2037,8 @@ onUnmounted(() => { window.removeEventListener('storage', onStorageChange) beginUnlisten?.() beginUnlisten = null + pingUnlisten?.() + pingUnlisten = null scrollProgressUnlisten?.() scrollProgressUnlisten = null scrollCompleteUnlisten?.() diff --git a/src/modules/screenshot/ScreenshotPin.vue b/src/modules/screenshot/ScreenshotPin.vue index 64b32a2..1b813a7 100644 --- a/src/modules/screenshot/ScreenshotPin.vue +++ b/src/modules/screenshot/ScreenshotPin.vue @@ -27,6 +27,8 @@ const items = ref<{ filePath: string; width: number; height: number; posX?: numb const cur = ref(0) let showUnlisten: UnlistenFn | null = null +/** 握手请求监听(见 store 的 ensurePinReady):主窗口每次贴图前 ping,本窗口应答 ready */ +let pingUnlisten: UnlistenFn | null = null // ===== 贴图数据缓存(LRU,值为 Blob URL):命中时上一张/下一张切换零 IPC、零等待 ===== const imgCache = new Map() @@ -384,6 +386,11 @@ onMounted(async () => { showUnlisten = await listen(EVENTS.screenshotPinShow, () => { openPin() }) + // 握手应答:主窗口每次贴图前 ping(store 的 ensurePinReady)。挂在 show 监听**之后** + // —— 应答即代表 show 监听已就绪。主窗口重载后本窗口不会再发首次 ready,由应答补上。 + pingUnlisten = await listen(EVENTS.screenshotPinPing, () => { + void emit(EVENTS.screenshotPinReady).catch(() => {}) + }) await emit(EVENTS.screenshotPinReady) }) @@ -391,6 +398,8 @@ onUnmounted(() => { window.removeEventListener('keydown', onKeyDown) window.removeEventListener('blur', onBlur) showUnlisten?.() + pingUnlisten?.() + pingUnlisten = null }) diff --git a/src/modules/terminal/FileWindow.vue b/src/modules/terminal/FileWindow.vue index 31664dd..eddfa26 100644 --- a/src/modules/terminal/FileWindow.vue +++ b/src/modules/terminal/FileWindow.vue @@ -190,7 +190,7 @@ async function closeWindow() { - +
diff --git a/src/modules/terminal/TerminalQuickLaunch.vue b/src/modules/terminal/TerminalQuickLaunch.vue index b66af74..bf022a2 100644 --- a/src/modules/terminal/TerminalQuickLaunch.vue +++ b/src/modules/terminal/TerminalQuickLaunch.vue @@ -14,7 +14,7 @@ * * # 键位从设置里读 * - * 键位存在终端设置的快捷键表里(设置 → 快捷键 → 会话 → 新建独立窗口,默认 `Ctrl+3`), + * 键位存在终端设置的快捷键表里(设置 → 快捷键 → 会话 → 新建独立窗口,默认 `Alt+T`), * 因此这里是「读设置 → 注册」而不是硬编码:改键后 watch 到变化即重新注册。 * 关掉那一行右侧的开关 = 不注册。 * diff --git a/src/modules/terminal/components/FileManager.vue b/src/modules/terminal/components/FileManager.vue index 44820fc..d8eb9e5 100644 --- a/src/modules/terminal/components/FileManager.vue +++ b/src/modules/terminal/components/FileManager.vue @@ -281,10 +281,10 @@ watch( + + +
+ + +
\ No newline at end of file diff --git a/src/modules/terminal/components/HostManager.vue b/src/modules/terminal/components/HostManager.vue index c472d2a..79feef7 100644 --- a/src/modules/terminal/components/HostManager.vue +++ b/src/modules/terminal/components/HostManager.vue @@ -527,7 +527,13 @@ function moveHop(i: number, dir: -1 | 1) { (monitor / downloader)都用 ScrollArea + max-h 的写法。 --> -
+ +
diff --git a/src/modules/terminal/components/KeyManagerPanel.vue b/src/modules/terminal/components/KeyManagerPanel.vue index e5db715..376f4aa 100644 --- a/src/modules/terminal/components/KeyManagerPanel.vue +++ b/src/modules/terminal/components/KeyManagerPanel.vue @@ -543,9 +543,10 @@ function formatDate(rfc3339: string): string { - + -
+
@@ -628,9 +629,10 @@ function formatDate(rfc3339: string): string { - + -
+
diff --git a/src/modules/terminal/components/SnippetEditorDialog.vue b/src/modules/terminal/components/SnippetEditorDialog.vue index 07ddbc9..f49f2dc 100644 --- a/src/modules/terminal/components/SnippetEditorDialog.vue +++ b/src/modules/terminal/components/SnippetEditorDialog.vue @@ -118,9 +118,20 @@ async function submit() { - + -
+
diff --git a/src/stores/dshStore.ts b/src/stores/dshStore.ts new file mode 100644 index 0000000..7c6c610 --- /dev/null +++ b/src/stores/dshStore.ts @@ -0,0 +1,545 @@ +import { defineStore } from 'pinia' +import { computed, ref } from 'vue' +import { invoke } from '@tauri-apps/api/core' +import { listen, type UnlistenFn } from '@tauri-apps/api/event' +import { openUrl as openExternalUrl } from '@tauri-apps/plugin-opener' +import { toast } from 'vue-sonner' +import { createLogger } from '@/lib/logger' +import { EVENTS, WINDOWS } from '@/lib/constants' +import type { + DshAiPreview, + DshEnvStatus, + DshInstallProgress, + DshInstallStatus, + DshNodeStatus, + DshNpmRegistryInfo, + DshServerStatus, + DshSettings, + DshUpdateInfo +} from '@/types/dsh' + +const logger = createLogger('dsh') + +/** 用户主动取消的统一文案(与 Rust 侧 `node.rs::NODE_CANCELLED` 对应) */ +const CANCELLED = '已取消' + +/** + * dsh 模块(DeepSeek Harness 外壳)状态。 + * + * 调用方式说明:P0 阶段用原生 `invoke` 而不是 `@/lib/bindings` 的 `commands.*`—— + * specta 绑定只在 debug 构建启动时重新生成,新增命令在首次 `tauri dev` 之前不存在于 + * bindings.ts。把调用点全部收敛在此处,是为了将来替换成 `commands.dshXxx` 时 + * 只改这一个文件(与 translateStore 同约定)。 + */ +export const useDshStore = defineStore('dsh', () => { + const node = ref(null) + const install = ref(null) + const server = ref(null) + const settings = ref(null) + + const progress = ref(null) + const updateInfo = ref(null) + const preview = ref(null) + const logs = ref('') + /** + * dsh 安装输出(npm 尾部)。 + * + * 只存在 Rust 内存缓冲里、由 `dsh_install_log` 拉取:用户明确要求安装日志 + * **不进应用日志**,只在「安装引导 → dsh 本体」页临时展示。 + * 用轮询而不是事件,是为了避免"切走模块漏掉中间行"——每次都取完整缓冲。 + */ + const installLog = ref('') + /** 本次安装实际使用的 npm 源(含来源说明;见 `loadRegistryInfo`) */ + const registryInfo = ref(null) + + /** 是否已完成首次加载(避免初始空值导致状态闪烁) */ + const initialized = ref(false) + /** 安装/下载进行中 */ + const installing = ref(false) + const starting = ref(false) + const stopping = ref(false) + const checkingUpdate = ref(false) + const loadingLogs = ref(false) + + const nodeReady = computed(() => node.value?.satisfies ?? false) + const installed = computed(() => install.value?.installed ?? false) + const running = computed(() => server.value?.running ?? false) + const ready = computed(() => server.value?.ready ?? false) + /** 环境齐备(Node 合规 + dsh 已安装) */ + const envReady = computed(() => nodeReady.value && installed.value) + /** 规范地址(不含令牌),用于界面展示 */ + const displayUrl = computed( + () => server.value?.url ?? `http://127.0.0.1:${settings.value?.port ?? 3080}` + ) + /** + * 能否打开界面:必须在 dsh 打印出带令牌的启动地址之后。 + * + * dsh web 的浏览器鉴权是「进程级随机令牌 → 首次访问换 cookie」,直接打开 + * 规范地址只会拿到 `dsh web authentication required`。我们传了 `--no-open`, + * 没有浏览器替它完成这次换取,所以只能靠抓取的那行输出。 + */ + const canOpen = computed(() => !!server.value?.ready && !!server.value?.launchUrl) + /** 用于打开的地址(带令牌) */ + const openUrl = computed(() => server.value?.launchUrl ?? displayUrl.value) + /** 安装引导当前步(0=Node,1=dsh,2=AI,3=完成) */ + const setupStep = computed(() => { + if (!nodeReady.value) return 0 + if (!installed.value) return 1 + return 2 + }) + + let unlisteners: UnlistenFn[] = [] + /** + * 全局快捷键事件的监听器**单独持有**:它必须跨模块卸载存活 + * (快捷键在任意模块下都要能开窗,而 `stopListeners` 会在模块卸载时清理)。 + */ + let shortcutUnlisten: UnlistenFn | null = null + /** 安装期间的日志轮询定时器 */ + let installLogTimer: number | null = null + + const sleep = (ms: number) => new Promise(resolve => window.setTimeout(resolve, ms)) + + /** 拉取一次安装输出 */ + async function loadInstallLog() { + try { + installLog.value = await invoke('dsh_install_log') + } catch (e) { + logger.error('读取安装输出失败: ' + e) + } + } + + function startInstallLogPolling() { + if (installLogTimer !== null) return + installLogTimer = window.setInterval(() => void loadInstallLog(), 600) + } + + function stopInstallLogPolling() { + if (installLogTimer !== null) { + window.clearInterval(installLogTimer) + installLogTimer = null + } + } + + /** 读取本次安装实际使用的 npm 源 */ + async function loadRegistryInfo() { + try { + registryInfo.value = await invoke('dsh_npm_registry_info') + } catch (e) { + logger.error('读取 npm 源信息失败: ' + e) + } + } + + /** 统一错误处理:取消静默,其余 toast */ + function handleError(e: unknown, fallback: string) { + const msg = e instanceof Error ? e.message : String(e) + if (msg.includes(CANCELLED)) return + logger.error(`${fallback}: ${msg}`) + toast.error(msg || fallback) + } + + /** 读取环境总览(Node / dsh / 服务 / 设置) */ + async function refresh() { + try { + const env = await invoke('dsh_env_status') + node.value = env.node + install.value = env.dsh + server.value = env.server + settings.value = env.settings + initialized.value = true + } catch (e) { + logger.error('读取 dsh 环境状态失败: ' + e) + } + } + + /** 重新探测 Node */ + async function detectNode() { + try { + node.value = await invoke('dsh_node_detect') + } catch (e) { + handleError(e, '探测 Node 失败') + } + } + + /** 下载并安装便携 Node(version 为空 = 自动选版本) */ + async function installNode(version?: string) { + installing.value = true + try { + node.value = await invoke('dsh_node_install', { version: version ?? null }) + } catch (e) { + handleError(e, '安装 Node 失败') + } finally { + installing.value = false + progress.value = null + } + } + + /** 安装或更新 dsh(version 为空 = latest) */ + async function installDsh(version?: string) { + installing.value = true + installLog.value = '' + startInstallLogPolling() + try { + install.value = await invoke('dsh_install', { version: version ?? null }) + updateInfo.value = null + } catch (e) { + handleError(e, '安装 dsh 失败') + } finally { + installing.value = false + progress.value = null + stopInstallLogPolling() + // 收尾再取一次,确保拿到最后几行(含错误摘要) + await loadInstallLog() + await refresh() + } + } + + /** 更新到 latest(服务会先停止) */ + async function updateDsh() { + installing.value = true + installLog.value = '' + startInstallLogPolling() + try { + install.value = await invoke('dsh_update') + updateInfo.value = null + } catch (e) { + handleError(e, '更新 dsh 失败') + } finally { + installing.value = false + progress.value = null + stopInstallLogPolling() + await loadInstallLog() + await refresh() + } + } + + /** 取消进行中的下载/安装 */ + async function cancelInstall() { + try { + await invoke('dsh_cancel_install') + } catch (e) { + logger.error('取消失败: ' + e) + } + } + + /** 卸载 dsh(停止服务 + 删除包目录) */ + async function uninstallDsh() { + try { + await invoke('dsh_uninstall') + } catch (e) { + handleError(e, '卸载 dsh 失败') + } finally { + await refresh() + } + } + + /** 查询 npm 上的可用版本 */ + async function checkUpdate() { + checkingUpdate.value = true + try { + updateInfo.value = await invoke('dsh_check_update') + } catch (e) { + handleError(e, '检查更新失败') + } finally { + checkingUpdate.value = false + } + return updateInfo.value + } + + /** 保存设置(即时生效) */ + async function saveSettings(patch: Partial) { + if (!settings.value) return + try { + settings.value = await invoke('dsh_save_settings', { + settings: { ...settings.value, ...patch } + }) + // 安装目录改动会同时影响「已安装状态 / 实际安装位置 / 实际使用的源」, + // 只 reload 设置会让界面继续显示旧目录下的安装状态 + if ('installDir' in patch) await refresh() + if ('npmRegistry' in patch || 'installDir' in patch) await loadRegistryInfo() + // 快捷键改动立即重新注册(注册内部先注销旧的,幂等) + if ('shortcut' in patch) await registerShortcut() + } catch (e) { + handleError(e, '保存设置失败') + } + } + + async function start() { + starting.value = true + try { + server.value = await invoke('dsh_start') + } catch (e) { + handleError(e, '启动 dsh 失败') + // 端口占用 / 环境缺失等由 Rust 记入 server.error,刷新后状态卡会显示原因 + await refresh() + } finally { + starting.value = false + } + } + + async function stop() { + stopping.value = true + try { + server.value = await invoke('dsh_stop') + } catch (e) { + handleError(e, '停止 dsh 失败') + } finally { + stopping.value = false + } + } + + async function restart() { + starting.value = true + try { + server.value = await invoke('dsh_restart') + } catch (e) { + handleError(e, '重启 dsh 失败') + await refresh() + } finally { + starting.value = false + } + } + + /** 预览将写入 settings.yaml 的内容 */ + async function loadAiPreview() { + try { + preview.value = await invoke('dsh_ai_preview') + } catch (e) { + handleError(e, '生成 AI 配置预览失败') + } + return preview.value + } + + /** 执行 AI 配置同步 */ + async function syncAi() { + try { + preview.value = await invoke('dsh_ai_sync') + toast.success('AI 供应商已同步到 dsh') + } catch (e) { + handleError(e, '同步 AI 配置失败') + } + return preview.value + } + + async function loadLogs(lines = 300) { + loadingLogs.value = true + try { + logs.value = await invoke('dsh_log_tail', { lines }) + } catch (e) { + logger.error('读取日志失败: ' + e) + } finally { + loadingLogs.value = false + } + } + + async function clearLogs() { + try { + await invoke('dsh_log_clear') + logs.value = '' + } catch (e) { + logger.error('清空日志失败: ' + e) + } + } + + async function openDir() { + try { + await invoke('dsh_open_dir') + } catch (e) { + handleError(e, '打开目录失败') + } + } + + // ===== 打开 dsh 界面(独立窗口 / 系统浏览器) ===== + + /** + * 打开 dsh Web UI 的独立窗口(单例)。 + * + * 地址必须用**带令牌**的 `openUrl`:dsh 靠「首次访问带令牌的地址」种下会话 + * cookie,直接开规范地址只会拿到 401。 + * 窗口放在 store 而非组件里,是因为全局快捷键要跨模块开窗 + * (与 screenshotStore 建覆盖层窗口同一取舍)。 + */ + async function openWebWindow() { + const { WebviewWindow } = await import('@tauri-apps/api/webviewWindow') + const label = WINDOWS.dshWeb + try { + const existing = await WebviewWindow.getByLabel(label) + if (existing) { + await existing.setFocus() + return + } + // 远端页面拿不到 Tauri IPC(未登记 capability),因此保留系统装饰以便拖动与关闭 + new WebviewWindow(label, { + url: openUrl.value, + title: 'DeepSeek Harness', + width: 1280, + height: 860, + minWidth: 900, + minHeight: 600, + decorations: true, + resizable: true, + visible: true, + focus: true + }).once('tauri://error', e => { + toast.error(`打开独立窗口失败:${String(e.payload ?? '')}`) + }) + } catch (e) { + toast.error(`打开独立窗口失败:${e instanceof Error ? e.message : String(e)}`) + } + } + + /** 用系统默认浏览器打开 dsh Web UI(同样带令牌) */ + async function openInBrowser() { + try { + await openExternalUrl(openUrl.value) + } catch (e) { + toast.error(`打开浏览器失败:${e instanceof Error ? e.message : String(e)}`) + } + } + + /** + * 全局快捷键触发:服务已就绪直接开窗,否则给一次短暂等待。 + * + * `canOpen` 要求「已监听 + 已拿到令牌」——dsh 打印那行输出可能比开始监听晚几秒, + * 所以这里轮询等一会儿再放弃,而不是立刻报未就绪。 + */ + async function handleShortcutOpen() { + if (!server.value) await refresh() + if (!canOpen.value) { + if (!running.value) { + toast.warning('dsh 服务未启动:请先在 dsh 模块的「状态」页启动服务') + return + } + for (let i = 0; i < 40 && !canOpen.value; i++) await sleep(250) + if (!canOpen.value) { + toast.warning('dsh 尚未就绪(未拿到访问令牌),请查看 dsh 模块的日志') + return + } + } + await openWebWindow() + } + + // ===== 全局快捷键 ===== + + /** 按当前设置注册快捷键(失败只提示,不抛) */ + async function registerShortcut() { + const shortcut = settings.value?.shortcut ?? '' + try { + await invoke('dsh_register_shortcut', { shortcut }) + } catch (e) { + toast.error(e instanceof Error ? e.message : String(e)) + } + } + + async function unregisterShortcut() { + try { + await invoke('dsh_unregister_shortcut') + } catch (e) { + logger.error('注销快捷键失败: ' + e) + } + } + + /** + * 应用启动时调用(main.ts 应用级初始化)。 + * + * 与模块挂载无关:快捷键必须在任何模块下都能用,所以监听器与注册都不放进 + * `stopListeners`/`init` 的生命周期里。 + */ + async function initGlobalShortcut() { + await refresh() + if (!shortcutUnlisten) { + shortcutUnlisten = await listen(EVENTS.dshOpenWindow, () => { + void handleShortcutOpen() + }) + } + await registerShortcut() + } + + /** 注册事件监听(幂等) */ + async function startListeners() { + if (unlisteners.length > 0) return + unlisteners.push( + await listen(EVENTS.dshInstallProgress, e => { + progress.value = e.payload + }) + ) + unlisteners.push( + await listen(EVENTS.dshServerState, e => { + server.value = e.payload + }) + ) + } + + function stopListeners() { + stopInstallLogPolling() + for (const un of unlisteners) un() + unlisteners = [] + } + + /** 模块激活时调用 */ + async function init() { + await startListeners() + await refresh() + // 安装输出只在内存缓冲里:重新进入模块时补一次,安装中则恢复轮询 + await loadInstallLog() + // npm 源解析要跑子进程,放在最后且不 await 阻塞首屏 + void loadRegistryInfo() + if (installing.value) startInstallLogPolling() + } + + return { + // state + node, + install, + server, + settings, + progress, + updateInfo, + preview, + logs, + installLog, + registryInfo, + initialized, + installing, + starting, + stopping, + checkingUpdate, + loadingLogs, + // getters + nodeReady, + installed, + running, + ready, + envReady, + displayUrl, + canOpen, + openUrl, + setupStep, + // actions + refresh, + detectNode, + installNode, + installDsh, + updateDsh, + cancelInstall, + uninstallDsh, + checkUpdate, + saveSettings, + start, + stop, + restart, + loadAiPreview, + syncAi, + loadInstallLog, + loadRegistryInfo, + loadLogs, + clearLogs, + openDir, + openWebWindow, + openInBrowser, + registerShortcut, + unregisterShortcut, + initGlobalShortcut, + init, + stopListeners + } +}) \ No newline at end of file diff --git a/src/stores/screenshotStore.ts b/src/stores/screenshotStore.ts index ffc8bb7..b3af327 100644 --- a/src/stores/screenshotStore.ts +++ b/src/stores/screenshotStore.ts @@ -6,10 +6,18 @@ import { availableMonitors } from '@tauri-apps/api/window' import { emit, listen, type UnlistenFn } from '@tauri-apps/api/event' import { toast } from 'vue-sonner' import { EVENTS, STORAGE_KEYS, WINDOWS } from '@/lib/constants' +import { createLogger } from '@/lib/logger' // Rust 端通过 tauri-specta 生成的命令绑定(bindings.ts) import { commands } from '@/lib/bindings' import type { WindowInfo } from '@/modules/screenshot/types' +const logger = createLogger('截图') + +/** 各常驻子窗口就绪握手的等待上限:超时仍继续(与旧行为一致,只是不再每次都白等) */ +const OVERLAY_READY_TIMEOUT_MS = 3000 +const EDITOR_READY_TIMEOUT_MS = 5000 +const PIN_READY_TIMEOUT_MS = 3000 + export interface RecentCapture { id: string /** 缩略图 data URL(JPEG,~256px 宽,常驻内存的只有它,完整图已落盘缓存) */ @@ -39,18 +47,27 @@ export interface ScreenshotSettings { pinShortcut: string /** 截图延时(秒),0 表示立即截图 */ delay: number + /** + * 默认快捷键的一次性迁移标记(随设置落盘,见 loadSettings)。 + * 用它而**不是** SETTINGS_VERSION:后者会整体重置设置,为改两个快捷键 + * 丢掉保存目录/延迟不值得。 + */ + shortcutDefaultsVersion?: number } const SETTINGS_KEY = 'screenshot-settings' /** 设置版本:结构变更(默认值/字段增删)时递增,清除旧数据以应用新默认值 */ const SETTINGS_VERSION = 2 +/** 快捷键默认值迁移版本(v2:截图 ctrl+1→F3、贴图 alt+1→F4) */ +const SHORTCUT_DEFAULTS_VERSION = 2 const DEFAULT_SETTINGS: ScreenshotSettings = { autoSave: false, saveDir: '', historyLimit: 48, - shortcut: 'ctrl+1', - pinShortcut: 'alt+1', + shortcut: 'F3', + pinShortcut: 'F4', delay: 0, + shortcutDefaultsVersion: SHORTCUT_DEFAULTS_VERSION, } export const useScreenshotStore = defineStore('screenshot', () => { @@ -66,7 +83,6 @@ export const useScreenshotStore = defineStore('screenshot', () => { const OVERLAY_LABEL = WINDOWS.screenshotOverlay let overlayWin: WebviewWindow | null = null let overlayReadyResolve: (() => void) | null = null - let overlayReadyPromise: Promise | null = null let readyListenerInit = false /** 上次已应用的覆盖层布局矩形(虚拟屏未变化时跳过 setPosition/setSize,省 2 次 IPC 往返) */ let lastOverlayRectKey = '' @@ -79,7 +95,6 @@ export const useScreenshotStore = defineStore('screenshot', () => { let pinReadyUnlisten: UnlistenFn | null = null let pinReadyListenerInit = false let pinReadyResolve: (() => void) | null = null - let pinReadyPromise: Promise | null = null /** 贴图全局快捷键事件监听 */ let pinShortcutUnlisten: UnlistenFn | null = null @@ -99,6 +114,19 @@ export const useScreenshotStore = defineStore('screenshot', () => { saveSettings() } else { settings.value = { ...DEFAULT_SETTINGS, ...parsed } + // 默认快捷键一次性迁移:仍等于旧默认值 = 用户没改过,换成新默认值; + // 改过(或已清空禁用)的原样保留。标记落盘后不会再改写,用户之后 + // 就算主动绑回 ctrl+1 / alt+1 也不会被覆盖。 + if ((parsed.shortcutDefaultsVersion ?? 1) < SHORTCUT_DEFAULTS_VERSION) { + if (settings.value.shortcut.toLowerCase() === 'ctrl+1') { + settings.value.shortcut = DEFAULT_SETTINGS.shortcut + } + if (settings.value.pinShortcut.toLowerCase() === 'alt+1') { + settings.value.pinShortcut = DEFAULT_SETTINGS.pinShortcut + } + settings.value.shortcutDefaultsVersion = SHORTCUT_DEFAULTS_VERSION + saveSettings() + } } } } catch (e) { @@ -181,7 +209,7 @@ export const useScreenshotStore = defineStore('screenshot', () => { await overlayWin?.setSize(new PhysicalSize(rect.width, rect.height)) lastOverlayRectKey = rectKey } - await waitOverlayReady() + await ensureOverlayReady() // 携带捕获时刻光标 + 窗口列表:覆盖层显示前即可完成初始高亮,无"遮罩→高亮"闪烁 await emit(EVENTS.screenshotBegin, { cursorX: start.cursorX, @@ -197,18 +225,37 @@ export const useScreenshotStore = defineStore('screenshot', () => { } } - function resetOverlayReady() { - overlayReadyPromise = new Promise((resolve) => { + /** 重置就绪信号,并返回这一轮的 promise(调用方直接持有,避免读到被后续 reset 覆盖的引用) */ + function resetOverlayReady(): Promise { + return new Promise((resolve) => { overlayReadyResolve = resolve }) } - /** 等待覆盖层就绪(首次创建时等 onMounted 完成,之后立即返回) */ - async function waitOverlayReady() { - await Promise.race([ - overlayReadyPromise, - new Promise((r) => setTimeout(r, 3000)), + /** + * 等待覆盖层就绪(每次截图前握手)。 + * + * # 为什么不能只等「首次 ready 事件」 + * + * 覆盖层的 ready 只在它自己的 onMounted 里发一次,而主窗口的 JS 上下文会**独立** + * 重载(dev 下 Vite 整页刷新、改了前端代码后的 reload),此时覆盖层窗口是**存活**的 + * (它不会被销毁),重载后的主窗口却重新注册了一个永远等不到「首次」ready 的监听: + * `Promise.race` 每次都落到 3s 超时上白等 —— 表现为「按快捷键后要等几秒才出现」, + * 且没有任何报错可查。 + * + * 因此改为每次截图前主动握手:重置就绪信号 → ping 覆盖层 → 等它应答 ready。 + * 覆盖层尚未加载完时 ping 会丢,但它 onMounted 末尾的首次 ready 会兑现同一个信号 + *(两条路径调用同一个 resolve),所以「首轮创建」这一情形也不会被漏掉。 + */ + async function ensureOverlayReady() { + const ready = resetOverlayReady() + void emit(EVENTS.screenshotOverlayPing).catch(() => {}) + const answered = await Promise.race([ + ready.then(() => true), + new Promise((r) => setTimeout(() => r(false), OVERLAY_READY_TIMEOUT_MS)), ]) + // 超时说明 begin 监听可能尚未注册(覆盖层正在加载/已异常),本轮 begin 事件可能丢失 + if (!answered) logger.warn(`覆盖层未在 ${OVERLAY_READY_TIMEOUT_MS}ms 内应答就绪,本轮截图可能丢失`) } /** 创建常驻覆盖层窗口(隐藏、透明、置顶、无任务栏;启动时创建,复用直到应用退出) */ @@ -259,19 +306,29 @@ export const useScreenshotStore = defineStore('screenshot', () => { let editorReadyUnlisten: UnlistenFn | null = null let editorReadyListenerInit = false let editorReadyResolve: (() => void) | null = null - let editorReadyPromise: Promise | null = null - function resetEditorReady() { - editorReadyPromise = new Promise((resolve) => { + /** 重置就绪信号,并返回这一轮的 promise(调用方直接持有,避免读到被后续 reset 覆盖的引用) */ + function resetEditorReady(): Promise { + return new Promise((resolve) => { editorReadyResolve = resolve }) } - async function waitEditorReady() { - await Promise.race([ - editorReadyPromise, - new Promise((r) => setTimeout(r, 5000)), + /** + * 等待编辑器就绪(每次打开前握手)。 + * + * 与 `ensureOverlayReady` 同一取舍:编辑器窗口是**常驻复用**的,ready 只在它的 + * onMounted 里发一次;主窗口 JS 上下文重载后(dev 下常见)新注册的监听永远等不到 + * 那次 ready,于是每次「打开编辑器」都白等 5s。改为每次主动 ping + 等应答。 + */ + async function ensureEditorReady() { + const ready = resetEditorReady() + void emit(EVENTS.screenshotEditorPing).catch(() => {}) + const answered = await Promise.race([ + ready.then(() => true), + new Promise((r) => setTimeout(() => r(false), EDITOR_READY_TIMEOUT_MS)), ]) + if (!answered) logger.warn(`编辑器未在 ${EDITOR_READY_TIMEOUT_MS}ms 内应答就绪,本轮加载可能丢失`) } async function ensureEditorListener() { @@ -316,7 +373,7 @@ export const useScreenshotStore = defineStore('screenshot', () => { async function openEditor() { await ensureEditorListener() await ensureEditorWindow() - await waitEditorReady() + await ensureEditorReady() await emit(EVENTS.screenshotEditorLoad) } @@ -536,7 +593,7 @@ export const useScreenshotStore = defineStore('screenshot', () => { }) } - /** 应用启动时按已保存的快捷键注册全局热键(支持自定义,默认 Ctrl+Alt+A) */ + /** 应用启动时按已保存的快捷键注册全局热键(支持自定义,默认截图 F3 / 贴图 F4) */ async function initShortcutRegistration() { try { await commands.screenshotRegisterShortcut(settings.value.shortcut) @@ -559,18 +616,30 @@ export const useScreenshotStore = defineStore('screenshot', () => { } // ===== 贴图窗口 ===== - function resetPinReady() { - pinReadyPromise = new Promise((resolve) => { + /** + * 重置就绪信号,并返回这一轮的 promise(调用方直接持有,避免读到被后续 reset 覆盖的引用) + */ + function resetPinReady(): Promise { + return new Promise((resolve) => { pinReadyResolve = resolve }) } - /** 等待贴图窗口就绪(首次创建时等 onMounted 完成,之后立即返回) */ - async function waitPinReady() { - await Promise.race([ - pinReadyPromise, - new Promise((r) => setTimeout(r, 3000)), + /** + * 等待贴图窗口就绪(每次贴图前握手)。 + * + * 与 `ensureOverlayReady` 同一取舍。此前只有「创建窗口」那条路径会等待,复用已有 + * 窗口时直接 emit `screenshotPinShow` —— 主窗口重载后贴图窗口可能仍在加载, + * 事件就静默丢了(按了没反应);统一握手后两条路径都先确认接收方就绪。 + */ + async function ensurePinReady() { + const ready = resetPinReady() + void emit(EVENTS.screenshotPinPing).catch(() => {}) + const answered = await Promise.race([ + ready.then(() => true), + new Promise((r) => setTimeout(() => r(false), PIN_READY_TIMEOUT_MS)), ]) + if (!answered) logger.warn(`贴图窗口未在 ${PIN_READY_TIMEOUT_MS}ms 内应答就绪,本轮贴图可能丢失`) } /** 注册贴图窗口就绪监听(首次贴图前调用) */ @@ -612,7 +681,6 @@ export const useScreenshotStore = defineStore('screenshot', () => { focus: false, visible: false, }) - await waitPinReady() } /** @@ -640,6 +708,7 @@ export const useScreenshotStore = defineStore('screenshot', () => { const i = Math.max(0, Math.min(index ?? 0, recent.value.length - 1)) localStorage.setItem(PIN_INDEX_KEY, String(i)) await ensurePinWindow() + await ensurePinReady() await emit(EVENTS.screenshotPinShow) } diff --git a/src/style.css b/src/style.css index b9e7e0a..fd80659 100644 --- a/src/style.css +++ b/src/style.css @@ -1,3 +1,7 @@ + +@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap'); +/* ---break--- + */ /* 把 Tailwind 的自动内容检测根**收窄到 src/**,不要从项目根开始扫。 * * 原因:Tailwind v4 默认以项目根为扫描起点,只读**根目录**的 .gitignore。本仓库的 diff --git a/src/types/dsh.ts b/src/types/dsh.ts new file mode 100644 index 0000000..110760c --- /dev/null +++ b/src/types/dsh.ts @@ -0,0 +1,138 @@ +/** + * dsh 模块(DeepSeek Harness 外壳)的前端类型。 + * + * 与 Rust 侧 `src-tauri/src/dsh/types.rs` 一一对应(camelCase)。 + * + * 注意:这里手写类型是**过渡态**——specta 绑定只在 debug 构建启动时重新生成 + * (`lib.rs::export_bindings`),新增命令在首次 `bun run tauri dev` 之前不存在于 + * `src/lib/bindings.ts`。调用点全部收敛在 `@/stores/dshStore`,将来换成 + * `commands.dshXxx` 时只改那一个文件。 + */ + +/** 模块设置(与 Rust `DshSettings` 对应) */ +export interface DshSettings { + version: number + /** auto(系统优先,缺失回落托管)| system | managed */ + nodeSource: string + /** 指定下载的 Node 版本(空 = 自动取满足要求的最新版) */ + managedNodeVersion: string + /** Node 分发包镜像前缀(空 = 官方 nodejs.org) */ + nodeMirror: string + /** npm registry(空 = 官方源) */ + npmRegistry: string + /** 下载 Node / npm 安装是否走代理模块 */ + useProxy: boolean + port: number + autoStart: boolean + /** 全局快捷键:打开 dsh Web 独立窗口(空 = 未启用),默认 Alt+D */ + shortcut: string + /** managed(模块目录)| user(~/.dsh) */ + dshHomeMode: string + /** 工作区目录(空 = 模块目录下的 workspace) */ + workspace: string + /** + * dsh 本体的安装目录(npm `--prefix` 目标,即 node_modules 所在位置)。 + * 空 = 模块目录。只有 dsh 本体跟随此设置;便携 Node、$DSH_HOME、日志与 + * 模块设置仍在应用数据目录。 + */ + installDir: string + /** 映射为 dsh 默认模型的 Thing AI 供应商 id */ + providerId: string + aiSync: boolean +} + +/** Node 运行环境状态 */ +export interface DshNodeStatus { + /** system | managed | none */ + source: string + path: string | null + version: string | null + satisfies: boolean + required: string +} + +/** dsh 本体安装状态 */ +export interface DshInstallStatus { + installed: boolean + version: string | null + entry: string | null + dir: string +} + +/** 服务进程状态 */ +export interface DshServerStatus { + running: boolean + ready: boolean + pid: number | null + port: number + /** 规范地址(不含令牌,用于展示) */ + url: string + /** + * 带令牌的启动地址(**用于打开界面**)。 + * + * dsh web 的鉴权是「进程级随机令牌 → 首次访问换 cookie」:直接访问 `url` + * 只会拿到 401。令牌每次启动都不同,只能从 dsh 输出里抓取,因此进程刚起来时 + * 这里可能为 null(等它打印那一行)。 + */ + launchUrl: string | null + startedAt: number | null + error: string | null +} + +/** 环境总览 */ +export interface DshEnvStatus { + node: DshNodeStatus + dsh: DshInstallStatus + server: DshServerStatus + settings: DshSettings +} + +/** 安装/下载进度事件载荷 */ +export interface DshInstallProgress { + /** download | extracting | installing | done | error */ + stage: string + /** 0 表示「不确定进度」(npm 无百分比输出时前端显示动画条) */ + percent: number + downloadedBytes: number + totalBytes: number | null + message: string +} + +/** 版本更新信息 */ +export interface DshUpdateInfo { + current: string | null + latest: string + hasUpdate: boolean + versions: string[] +} + +/** npm 源信息:本次安装实际用哪个源、来自哪里 */ +export interface DshNpmRegistryInfo { + /** 本次安装/查询实际会使用的源(已去掉末尾 `/`) */ + effective: string + /** setting(模块设置指定)| npm(npm 自身配置链)| fallback(默认官方源) */ + source: string + /** npm 自身解析出的源(含系统 Node 的 ~/.npmrc),未检测到时为 null */ + npmRegistry: string | null + /** 模块设置里显式填写的值(空 = 未指定) */ + setting: string +} + +/** AI 供应商映射项(预览,不含明文密钥) */ +export interface DshAiProvider { + id: string + name: string + envName: string + baseUrl: string + model: string + hasKey: boolean +} + +/** settings.yaml 同步预览 */ +export interface DshAiPreview { + yaml: string + providers: DshAiProvider[] + defaultProvider: string | null + defaultModel: string | null + settingsPath: string +} \ No newline at end of file diff --git a/src/types/translate.ts b/src/types/translate.ts index 60988c6..06c221b 100644 --- a/src/types/translate.ts +++ b/src/types/translate.ts @@ -99,7 +99,7 @@ export const DEFAULT_TRANSLATE_AI_PARAMS: Omit export interface SelectionSettings { enabled: boolean - /** 打开翻译面板的全局快捷键(默认 Ctrl+2) */ + /** 打开翻译面板的全局快捷键(默认 Alt+F) */ panelShortcut: string mode: string restoreClipboard: boolean