dsh-plugin 1.6.11 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +1 -1
- package/README.md +1 -1
- package/client/client.js +705 -803
- package/client/client.js.map +1 -1
- package/lib/http/catalog.js +2 -3
- package/lib/http/diagnostics.js +6 -7
- package/lib/http/install.js +47 -213
- package/lib/http/logs.js +1 -2
- package/lib/http/npm-release-age.js +42 -0
- package/lib/http/routes.js +8 -7
- package/lib/http/settings.js +2 -2
- package/lib/http/shared.js +2 -2
- package/lib/http/task.js +1 -2
- package/lib/index.js +5 -6
- package/lib/services/install/install-types.js +4 -4
- package/lib/services/install/install.js +1 -1
- package/lib/services/install/npm-check.js +3 -2
- package/lib/services/install/npm-resolve.js +9 -96
- package/lib/services/install/package-entry.js +6 -11
- package/lib/services/install/registry-check.js +5 -16
- package/lib/services/install/release-target.js +8 -9
- package/lib/services/install/task-queue.js +74 -57
- package/lib/services/npm-release-age.js +119 -0
- package/lib/services/probe.js +4 -4
- package/lib/services/profile/installed-versions.js +15 -21
- package/lib/services/profile/profile.js +16 -44
- package/lib/services/profile/progress.js +8 -11
- package/lib/services/settings.js +2 -5
- package/lib/types/http/catalog.d.ts +1 -1
- package/lib/types/http/install.d.ts +2 -2
- package/lib/types/http/npm-release-age.d.ts +2 -0
- package/lib/types/http/routes.d.ts +10 -12
- package/lib/types/http/shared.d.ts +5 -6
- package/lib/types/index.d.ts +7 -8
- package/lib/types/services/install/install-types.d.ts +12 -13
- package/lib/types/services/install/install.d.ts +1 -1
- package/lib/types/services/install/npm-resolve.d.ts +4 -16
- package/lib/types/services/install/package-entry.d.ts +6 -11
- package/lib/types/services/install/release-target.d.ts +7 -8
- package/lib/types/services/install/task-queue.d.ts +32 -31
- package/lib/types/services/npm-release-age.d.ts +15 -0
- package/lib/types/services/probe.d.ts +4 -4
- package/lib/types/services/profile/installed-versions.d.ts +5 -7
- package/lib/types/services/profile/profile.d.ts +14 -18
- package/lib/types/services/profile/progress.d.ts +7 -10
- package/lib/types/services/settings.d.ts +0 -4
- package/package.json +1 -1
- package/src/client/components/PluginHubSection.tsx +23 -27
- package/src/client/components/catalog/CatalogList.tsx +2 -4
- package/src/client/components/catalog/PluginCard.tsx +2 -3
- package/src/client/components/layout/CatalogControls.tsx +5 -6
- package/src/client/components/layout/CatalogHeader.tsx +1 -2
- package/src/client/components/layout/CategoryTabs.tsx +2 -3
- package/src/client/components/layout/SectionTabs.tsx +3 -5
- package/src/client/components/modals/ConfirmDialog.tsx +4 -6
- package/src/client/components/modals/InstalledDetailModal.tsx +3 -6
- package/src/client/components/modals/LogsModal.tsx +7 -12
- package/src/client/components/modals/NotificationsModal.tsx +52 -24
- package/src/client/components/modals/ProgressView.tsx +3 -4
- package/src/client/components/modals/modals.tsx +58 -30
- package/src/client/components/ui/Dropdown.tsx +4 -6
- package/src/client/components/ui/Toggle.tsx +2 -3
- package/src/client/components/ui/icons.tsx +1 -2
- package/src/client/components/views/CustomInstallView.tsx +20 -178
- package/src/client/components/views/DiagnosticsView.tsx +3 -6
- package/src/client/components/views/InstalledView.tsx +6 -11
- package/src/client/components/views/MarketView.tsx +2 -4
- package/src/client/components/views/SettingsView.tsx +9 -32
- package/src/client/css-modules.d.ts +1 -1
- package/src/client/data/catalog.ts +2 -3
- package/src/client/data/host.ts +26 -3
- package/src/client/data/hub.ts +2 -3
- package/src/client/hooks/useCatalog.ts +79 -24
- package/src/client/hooks/useIncrementalList.ts +3 -5
- package/src/client/hooks/useLanguage.ts +4 -6
- package/src/client/hooks/useSettings.ts +4 -11
- package/src/client/hooks/useTaskQueue.ts +36 -42
- package/src/client/index.tsx +2 -3
- package/src/client/locales.ts +96 -123
- package/src/client/logic/constants.ts +1 -2
- package/src/client/logic/ensure-plugin-css.ts +8 -12
- package/src/client/logic/failures.ts +41 -28
- package/src/client/logic/format.ts +1 -1
- package/src/client/logic/install-command.ts +14 -35
- package/src/client/logic/installed.ts +15 -10
- package/src/client/logic/normalize.ts +3 -3
- package/src/client/logic/release-age.ts +19 -0
- package/src/client/logic/urls.ts +55 -50
- package/src/client/styles/CustomInstallView.module.css +3 -30
- package/src/client/styles/DiagnosticsView.module.css +3 -5
- package/src/client/styles/Dropdown.module.css +2 -4
- package/src/client/styles/Header.module.css +6 -7
- package/src/client/styles/InstalledView.module.css +4 -7
- package/src/client/styles/List.module.css +4 -5
- package/src/client/styles/LogsView.module.css +2 -3
- package/src/client/styles/Modal.module.css +4 -5
- package/src/client/styles/SectionTabs.module.css +2 -4
- package/src/client/styles/SettingsView.module.css +3 -5
- package/src/client/styles/Toggle.module.css +2 -4
- package/src/client/styles/tokens.module.css +14 -18
- package/src/client/types.ts +11 -11
- package/src/server/http/catalog.ts +2 -3
- package/src/server/http/diagnostics.ts +6 -7
- package/src/server/http/install.ts +47 -208
- package/src/server/http/logs.ts +1 -2
- package/src/server/http/npm-release-age.ts +42 -0
- package/src/server/http/routes.ts +12 -12
- package/src/server/http/settings.ts +2 -2
- package/src/server/http/shared.ts +5 -6
- package/src/server/http/task.ts +1 -2
- package/src/server/index.ts +7 -8
- package/src/server/services/install/install-types.ts +12 -13
- package/src/server/services/install/install.ts +0 -1
- package/src/server/services/install/npm-check.ts +3 -2
- package/src/server/services/install/npm-resolve.ts +9 -99
- package/src/server/services/install/package-entry.ts +6 -11
- package/src/server/services/install/registry-check.ts +5 -16
- package/src/server/services/install/release-target.ts +8 -9
- package/src/server/services/install/task-queue.ts +79 -63
- package/src/server/services/npm-release-age.ts +107 -0
- package/src/server/services/probe.ts +4 -4
- package/src/server/services/profile/installed-versions.ts +16 -22
- package/src/server/services/profile/profile.ts +16 -42
- package/src/server/services/profile/progress.ts +8 -11
- package/src/server/services/settings.ts +2 -9
- package/lib/services/install/preflight.js +0 -178
- package/lib/types/services/install/preflight.d.ts +0 -23
- package/src/server/services/install/preflight.ts +0 -184
|
@@ -3,23 +3,19 @@
|
|
|
3
3
|
* Website: https://dsh-plugin.org
|
|
4
4
|
* GitHub: https://github.com/dshplugin/dsh-plugin-hub
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
6
|
+
* 安装/卸载路由:校验目标后 spawn 官方 dsh CLI(见 services/install/install.ts),
|
|
7
|
+
* 并回传捕获的结果。自定义安装只接受 npm 包名。
|
|
8
8
|
*/
|
|
9
|
-
import {
|
|
10
|
-
import { githubReleaseTarget } from '../services/install/release-target.ts'
|
|
9
|
+
import { githubRepoOf, globalNpmPackagesOf, hasQueuedTarget, installTargetOf, startPluginMutation, validPackageName, type LoaderHandle } from '../services/install/install.ts'
|
|
11
10
|
import { recordResolvedNpmPackage } from '../services/profile/installed-versions.ts'
|
|
12
|
-
import { isDshNpmPackageForRepo
|
|
13
|
-
import {
|
|
14
|
-
import { gitLsRemote, probeUrl, systemProxy } from '../services/probe.ts'
|
|
11
|
+
import { isDshNpmPackageForRepo } from '../services/install/npm-resolve.ts'
|
|
12
|
+
import { probeUrl, systemProxy } from '../services/probe.ts'
|
|
15
13
|
import { loadSettings, type HubSettings } from '../services/settings.ts'
|
|
16
|
-
import {
|
|
14
|
+
import { readInstalled } from './catalog.ts'
|
|
17
15
|
import { COMMAND_TIMEOUT_MS, readJsonBody, requireTrustedPost, sendJson, type WebRoute, type WebServerService } from './shared.ts'
|
|
18
16
|
|
|
19
|
-
/** 安装/卸载 CLI
|
|
20
|
-
*
|
|
21
|
-
* 代理优先级:设置里的代理 → 系统代理(macOS scutil / Windows 注册表)→ 宿主 env 原有值。
|
|
22
|
-
* 使安装通道与诊断使用相同的代理来源。 */
|
|
17
|
+
/** 安装/卸载 CLI 的子进程环境:透传宿主环境并注入 HTTP(S) 代理,
|
|
18
|
+
* 代理来源与诊断一致(设置代理 → 系统代理 → 宿主 env);不注入 npm registry,沿用用户本机 npm 配置。 */
|
|
23
19
|
function mutationEnv(settings: HubSettings): NodeJS.ProcessEnv {
|
|
24
20
|
const env: NodeJS.ProcessEnv = { ...process.env, CI: 'true' }
|
|
25
21
|
const proxy = settings.proxy !== '' ? settings.proxy : (systemProxy() ?? '')
|
|
@@ -32,17 +28,6 @@ function mutationEnv(settings: HubSettings): NodeJS.ProcessEnv {
|
|
|
32
28
|
return env
|
|
33
29
|
}
|
|
34
30
|
|
|
35
|
-
/** Match a GitHub install target against the installed table; returns the package name when already installed. */
|
|
36
|
-
function installedByRepo(installed: Record<string, string>, target: string): string | null {
|
|
37
|
-
const repo = githubRepoOf(target)
|
|
38
|
-
if (repo === null) return null
|
|
39
|
-
const needle = repo.toLowerCase()
|
|
40
|
-
for (const [name, spec] of Object.entries(installed)) {
|
|
41
|
-
if (githubRepoOf(spec)?.toLowerCase() === needle) return name
|
|
42
|
-
}
|
|
43
|
-
return null
|
|
44
|
-
}
|
|
45
|
-
|
|
46
31
|
export function registerInstallRoutes(webServer: WebServerService, profile: string, loader: LoaderHandle | undefined): WebRoute[] {
|
|
47
32
|
return [
|
|
48
33
|
{
|
|
@@ -54,43 +39,37 @@ export function registerInstallRoutes(webServer: WebServerService, profile: stri
|
|
|
54
39
|
try {
|
|
55
40
|
const body = await readJsonBody(request)
|
|
56
41
|
// mode: 'update' = 已安装目标的覆盖更新(放行 add,pnpm 对已存在依赖原位覆盖重装)。
|
|
57
|
-
// 后续「同仓库残留」检测可能把 install 就地升级为 update(见包名冲突检测),故用 let。
|
|
58
42
|
let mode = body !== null && typeof body === 'object' && (body as { mode?: unknown }).mode === 'update'
|
|
59
43
|
? 'update'
|
|
60
44
|
: 'install'
|
|
61
|
-
// installTargetOf
|
|
62
|
-
// 兼容用户直接粘贴命令行(防输错),真正语法判定交给下面 githubRepoOf / validPackageName。
|
|
45
|
+
// installTargetOf 把完整 DSH 命令剥成裸目标;自定义目标只接受 npm 包名,语法判定交给 validPackageName。
|
|
63
46
|
const rawRepo = typeof body === 'object' && body !== null && typeof (body as { repo?: unknown }).repo === 'string'
|
|
64
47
|
? installTargetOf((body as { repo: string }).repo)
|
|
65
48
|
: ''
|
|
66
|
-
//
|
|
67
|
-
// 待重启行 / 任务恢复时展示仓库名,保证用户无感知(安装通道变化不改变所见目标)
|
|
49
|
+
// 展示用仓库名(owner/repo):npm 安装时 body.repo 是包名,display 供待重启行 / 任务恢复展示仓库名。
|
|
68
50
|
const displayRepo = typeof body === 'object' && body !== null && typeof (body as { display?: unknown }).display === 'string'
|
|
69
51
|
? (body as { display: string }).display.trim()
|
|
70
52
|
: rawRepo
|
|
71
|
-
// 请求来源:目录插件安装(catalog)走目录白名单;命令行安装(custom
|
|
53
|
+
// 请求来源:目录插件安装(catalog)走目录白名单;命令行安装(custom)受安全开关控制
|
|
72
54
|
const source = typeof body === 'object' && body !== null && typeof (body as { source?: unknown }).source === 'string'
|
|
73
55
|
? (body as { source: string }).source
|
|
74
56
|
: ''
|
|
75
|
-
//
|
|
76
|
-
// 客户端显式上报,服务端日志/报错据此精准溯源「从哪个入口发起」;目录插件安装不传。
|
|
57
|
+
// 自定义安装入口渠道(仅 NPM 包):日志/报错据此溯源发起入口。
|
|
77
58
|
const installChannel = (() => {
|
|
78
59
|
const raw = body !== null && typeof body === 'object' ? (body as { installChannel?: unknown }).installChannel : undefined
|
|
79
|
-
return raw === '
|
|
60
|
+
return raw === 'npm' ? 'npm' : undefined
|
|
80
61
|
})()
|
|
81
62
|
const settings = loadSettings(profile)
|
|
82
63
|
// 界面语言(客户端随请求携带):错误消息按用户当前语言提示(中文界面给中文,英文界面给英文)
|
|
83
64
|
const lang = typeof body === 'object' && body !== null && (body as { lang?: unknown }).lang === 'en'
|
|
84
65
|
? 'en'
|
|
85
66
|
: 'zh'
|
|
86
|
-
// 全局 npm
|
|
87
|
-
//
|
|
88
|
-
// 包列表优先取 body.globalNpm(客户端命令框解析后显式携带);兜底再从 rawRepo 解析,
|
|
89
|
-
// 保证直接调 API 传完整命令也能识别。
|
|
67
|
+
// 全局 npm 安装(`npm install -g <pkgs>`):不进任何 profile、无需宿主重启。
|
|
68
|
+
// 包列表优先取 body.globalNpm,兜底从 rawRepo 解析,保证直接调 API 传完整命令也能识别。
|
|
90
69
|
const bodyGlobalNpm = Array.isArray((body as { globalNpm?: unknown }).globalNpm)
|
|
91
70
|
? (body as { globalNpm: unknown[] }).globalNpm.filter((x): x is string => typeof x === 'string' && x !== '')
|
|
92
71
|
: []
|
|
93
|
-
|
|
72
|
+
const globalNpm: string[] = bodyGlobalNpm.length > 0 ? bodyGlobalNpm : (globalNpmPackagesOf(rawRepo) ?? [])
|
|
94
73
|
if (globalNpm.length > 0) {
|
|
95
74
|
// 包名逐个按 npm 包名语法校验 + 拒绝以 - 开头的 token(npm 会把 --xxx 当参数而非包名),数量封顶防滥用
|
|
96
75
|
if (globalNpm.length > 20 || globalNpm.some((p) => !validPackageName(p) || p.startsWith('-'))) {
|
|
@@ -122,216 +101,76 @@ export function registerInstallRoutes(webServer: WebServerService, profile: stri
|
|
|
122
101
|
sendJson(response, 200, { ok: true, task: task.id })
|
|
123
102
|
return
|
|
124
103
|
}
|
|
125
|
-
//
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
// githubRepoOf 先把各种 GitHub 地址归一成 owner/repo,让「输入地址即装」兼容粘贴完整链接。
|
|
129
|
-
const gitRepo = githubRepoOf(rawRepo)
|
|
130
|
-
const release = githubReleaseTarget(rawRepo)
|
|
131
|
-
// 显式 pin 的 Git ref(`#tag` / `#commit`)是用户意图:保留它,且不让 npm 反查
|
|
132
|
-
// 把这个精确修订换成 registry 上的默认版本。
|
|
133
|
-
const pinnedRef = githubRefOf(rawRepo)
|
|
134
|
-
const repoTarget = gitRepo !== null && release === null ? githubTarget(gitRepo, pinnedRef) : null
|
|
135
|
-
let target: string | null = release?.target ?? repoTarget ?? (validPackageName(rawRepo) ? rawRepo : null)
|
|
136
|
-
if (target === null) {
|
|
137
|
-
sendJson(response, 400, { error: 'unsupported install target' })
|
|
104
|
+
// 自定义安装目标只接受 npm 包名(@scope/name 或 name)。
|
|
105
|
+
if (!validPackageName(rawRepo)) {
|
|
106
|
+
sendJson(response, 400, { error: 'unsupported install target: expected an npm package name' })
|
|
138
107
|
return
|
|
139
108
|
}
|
|
109
|
+
const target = rawRepo
|
|
110
|
+
// 已尝试的安装方式(供失败提 Issue 预填):保持为空
|
|
140
111
|
const attempts: string[] = []
|
|
141
112
|
// 代理口径与诊断/安装通道一致:设置里的代理 → 系统代理 → 环境变量 → 直连。
|
|
142
|
-
// 供 npm 反查时跟随 GitHub 改名跳转用(Node https 读不到系统代理,交给 curl)。
|
|
143
113
|
const effectiveProxy = settings.proxy !== ''
|
|
144
114
|
? settings.proxy
|
|
145
115
|
: (systemProxy() ?? process.env.HTTPS_PROXY ?? process.env.https_proxy ?? '')
|
|
146
|
-
//
|
|
147
|
-
//
|
|
148
|
-
// registry metadata confirms it is a DSH package for this repo. Otherwise inspect the
|
|
149
|
-
// repository root package.json and use its package name only when that exact registry
|
|
150
|
-
// package also points back to the repo and identifies as a DSH plugin. This avoids
|
|
151
|
-
// relying on npm search ranking, which is not a repository index and can omit the
|
|
152
|
-
// correct package even with a large result window.
|
|
116
|
+
// 目录插件安装:目录数据可能滞后于打包拆分,确认目录下发的 npm 目标确为该仓库的 DSH 包,
|
|
117
|
+
// 命中则记录 repo → 包名映射,客户端据此把依赖 key 匹配回仓库、列表立即显示「已安装」。
|
|
153
118
|
const catalogRepo = source === 'catalog' ? githubRepoOf(displayRepo) : null
|
|
154
|
-
if (catalogRepo !== null
|
|
119
|
+
if (catalogRepo !== null) {
|
|
155
120
|
const catalogTargetIsDsh = await isDshNpmPackageForRepo(rawRepo, catalogRepo, settings.npmRegistry, effectiveProxy)
|
|
156
|
-
if (catalogTargetIsDsh)
|
|
157
|
-
recordResolvedNpmPackage(profile, catalogRepo, rawRepo)
|
|
158
|
-
} else {
|
|
159
|
-
const catalogGitTarget = githubTarget(catalogRepo)
|
|
160
|
-
if (catalogGitTarget !== null) {
|
|
161
|
-
const root = await preflightTarget(catalogGitTarget)
|
|
162
|
-
const rootName = root.ok && root.name !== null && validPackageName(root.name) ? root.name : null
|
|
163
|
-
if (rootName !== null && rootName !== rawRepo
|
|
164
|
-
&& await isDshNpmPackageForRepo(rootName, catalogRepo, settings.npmRegistry, effectiveProxy)) {
|
|
165
|
-
attempts.push(`catalog npm target: \`${target}\` → repository root DSH package \`${rootName}\``)
|
|
166
|
-
target = rootName
|
|
167
|
-
recordResolvedNpmPackage(profile, catalogRepo, rootName)
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
// npm 优先:git 目标先反查该仓库的官方 npm 包,命中则改走 npm 通道。
|
|
173
|
-
// git 分发常缺构建产物/子模块,npm 包是作者发布的完整产物;未命中或
|
|
174
|
-
// 查询失败保留 github 直装(不阻塞安装,预检仍会拦截缺入口文件的情况)。
|
|
175
|
-
// 通用机制,不针对具体插件。
|
|
176
|
-
// 反查本身计入「已尝试的安装方式」:组织 scope 与 GitHub 用户名不一致时仅凭
|
|
177
|
-
// 仓库名猜不到包名,失败提 Issue 时作者看到我们查过的命令就能直接指认正确包名。
|
|
178
|
-
// 显式 pin 了 Git ref 时跳过 npm 反查:用户要的就是那个精确修订,
|
|
179
|
-
// 不能用 registry 上的默认版本覆盖它。
|
|
180
|
-
if (repoTarget !== null && pinnedRef === null) {
|
|
181
|
-
// 反查/记录统一用归一化后的 owner/repo(gitRepo),保证「输入完整链接」也走同一套 npm 反查
|
|
182
|
-
const repoIdentity = gitRepo ?? rawRepo
|
|
183
|
-
const npmName = await resolveNpmPackage(repoIdentity, settings.npmRegistry, effectiveProxy)
|
|
184
|
-
if (npmName !== null) {
|
|
185
|
-
target = npmName
|
|
186
|
-
attempts.push(`npm registry search: \`npm search repository:${repoIdentity}\` → found \`${npmName}\``)
|
|
187
|
-
// 持久化 repo → npm 包名映射:目录数据未下发 npmPackage(组织 scope 与 GitHub
|
|
188
|
-
// 用户名不一致)时,客户端仍能通过 /installed 的 versions 把依赖 key 匹配回仓库,
|
|
189
|
-
// 列表立即显示「已安装」,避免安装成功后仍显示可安装
|
|
190
|
-
recordResolvedNpmPackage(profile, repoIdentity, npmName)
|
|
191
|
-
} else {
|
|
192
|
-
attempts.push(`npm registry search: \`npm search repository:${repoIdentity}\` → no matching package found (falling back to git install)`)
|
|
193
|
-
}
|
|
121
|
+
if (catalogTargetIsDsh) recordResolvedNpmPackage(profile, catalogRepo, rawRepo)
|
|
194
122
|
}
|
|
195
|
-
//
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
const isGitChannel = release !== null || (repoTarget !== null && target === repoTarget)
|
|
200
|
-
if (isGitChannel && !settings.enableGitInstall) {
|
|
201
|
-
sendJson(response, 403, { error: 'git installs are disabled by the security settings' })
|
|
202
|
-
return
|
|
203
|
-
}
|
|
204
|
-
if (!isGitChannel && !settings.enableNpmInstall) {
|
|
205
|
-
sendJson(response, 403, { error: 'npm installs are disabled by the security settings' })
|
|
206
|
-
return
|
|
207
|
-
}
|
|
123
|
+
// 命令行安装(目录外)受「启用 NPM 安装」开关控制;目录插件安装走目录白名单,不受开关影响。
|
|
124
|
+
if (source !== 'catalog' && !settings.enableNpmInstall) {
|
|
125
|
+
sendJson(response, 403, { error: 'npm installs are disabled by the security settings' })
|
|
126
|
+
return
|
|
208
127
|
}
|
|
209
|
-
//
|
|
210
|
-
//
|
|
211
|
-
// 「安装」会撞上重复安装守卫,直接覆盖重装比让用户看到一句看不懂的 already installed
|
|
212
|
-
// 报错友好,最终状态也一致(都是已安装)。命中判定双通道:npm 包名按 dependencies
|
|
213
|
-
// 键直接命中,GitHub 目标按仓库身份匹配。
|
|
128
|
+
// 命中已安装目标时按「更新」执行(pnpm add 对已存在依赖即原位覆盖重装):
|
|
129
|
+
// 客户端已装列表可能与服务端不同步,覆盖重装比报错更友好且终态一致。
|
|
214
130
|
const installed = readInstalled(profile)
|
|
215
|
-
const already =
|
|
131
|
+
const already = installed[target] !== undefined ? target : null
|
|
216
132
|
if (already !== null) mode = 'update'
|
|
217
133
|
// 队列级去重:同一目标已在排队/执行中时拒绝,避免客户端防重竞态导致重复入队
|
|
218
134
|
if (hasQueuedTarget(target)) {
|
|
219
135
|
sendJson(response, 409, { error: `already queued: ${target}` })
|
|
220
136
|
return
|
|
221
137
|
}
|
|
222
|
-
//
|
|
223
|
-
//
|
|
224
|
-
// 页 —— 404 表示「目标不存在」而非网络不通,不该被当成网络故障拦截。
|
|
225
|
-
// 仅新安装预检(更新是已信任目标的覆盖重装,跳过);不通直接 400 拦下并打
|
|
226
|
-
// [network] 标记,客户端据此提示「你的网络不通」,而不是把网络失败当成
|
|
227
|
-
// 插件侧问题引导去作者仓库提 Issue。
|
|
228
|
-
// 代理口径与诊断一致:设置里的代理 → 系统代理 → 环境变量 → 直连。
|
|
138
|
+
// 安装前网络探测:探 registry 根而非具体包(404 是「包不存在」而非网络不通);仅新安装执行,更新跳过。
|
|
139
|
+
// 不通则 400 拦下并打 [network] 标记,客户端据此提示网络问题,而非插件问题。
|
|
229
140
|
if (already === null) {
|
|
230
|
-
const
|
|
231
|
-
|
|
232
|
-
// npm 通道探 registry 根。两者都是通道的稳定入口,不探具体包/仓库(404 会被误判成网络故障)。
|
|
233
|
-
const httpProbeTarget = release !== null
|
|
234
|
-
? 'https://github.com/'
|
|
235
|
-
: `${(settings.npmRegistry.replace(/\/+$/, '') || 'https://registry.npmjs.org')}/`
|
|
236
|
-
// git 通道的探针换成克隆握手本身:git ls-remote 走的就是 pnpm 克隆前的同一套
|
|
237
|
-
// https 传输。curl 打 github.com 主页会被按协议/端口区分的防火墙与 TLS 复检
|
|
238
|
-
// 拦截(能 git 克隆、打不开网页),把可装的仓库误判成 [network] 而中止。
|
|
239
|
-
// 握手失败时再用 curl 复核一次主页连通性:只有两者都不通
|
|
240
|
-
// 才判「网络不通」;仅握手失败(仓库不存在、私有仓库、需要凭据)放行,
|
|
241
|
-
// 交给后续预检与真实安装给出准确原因。
|
|
242
|
-
// 探针只握手仓库本身(去掉 git+ 前缀与 #ref 片段):ls-remote 认的是仓库地址,
|
|
243
|
-
// 带 ref 片段会干扰 URL 解析
|
|
244
|
-
const gitProbeTarget = repoTarget === null ? null : repoTarget.replace(/^git\+/, '').replace(/#.*$/, '')
|
|
245
|
-
let net: Awaited<ReturnType<typeof probeUrl>>
|
|
246
|
-
if (gitProbeTarget !== null) {
|
|
247
|
-
net = await gitLsRemote(gitProbeTarget, effectiveProxy, 6000)
|
|
248
|
-
if (!net.ok) {
|
|
249
|
-
const reachable = await probeUrl('https://github.com/', effectiveProxy, 6000)
|
|
250
|
-
if (reachable.ok) net = reachable
|
|
251
|
-
}
|
|
252
|
-
} else {
|
|
253
|
-
net = await probeUrl(httpProbeTarget, effectiveProxy, 6000)
|
|
254
|
-
}
|
|
255
|
-
const probeTarget = gitProbeTarget ?? httpProbeTarget
|
|
141
|
+
const probeTarget = `${(settings.npmRegistry.replace(/\/+$/, '') || 'https://registry.npmjs.org')}/`
|
|
142
|
+
const net = await probeUrl(probeTarget, effectiveProxy, 6000)
|
|
256
143
|
if (!net.ok) {
|
|
257
|
-
//
|
|
258
|
-
// 让用户一眼看懂是网络问题而非插件问题
|
|
259
|
-
const channelName = isGitChannel
|
|
260
|
-
? (lang === 'zh' ? 'GitHub' : 'github.com')
|
|
261
|
-
: (lang === 'zh' ? 'npm 源' : 'the npm registry')
|
|
144
|
+
// 错误消息按界面语言输出,让用户看清是网络问题而非插件问题
|
|
262
145
|
const error = lang === 'zh'
|
|
263
|
-
? `[network] 安装已中止:安装前无法连接到
|
|
264
|
-
: `[network] install aborted: cannot reach
|
|
146
|
+
? `[network] 安装已中止:安装前无法连接到 npm 源(${probeTarget})—— 您的网络似乎不通或被拦截(断网 / DNS 解析失败 / 防火墙 / 代理配置问题)。这不是插件本身的问题,请检查网络连接或代理设置,运行「系统诊断」检测各通道连通性后重试。`
|
|
147
|
+
: `[network] install aborted: cannot reach the npm registry (${probeTarget}) before install — your network connection appears to be down or blocked (DNS / proxy / firewall). This is not a problem with the plugin itself. Check your connection or proxy settings, run the connectivity diagnostic, then retry.`
|
|
265
148
|
sendJson(response, 400, { error, attempts })
|
|
266
149
|
return
|
|
267
150
|
}
|
|
268
151
|
}
|
|
269
|
-
//
|
|
270
|
-
//
|
|
271
|
-
// npm 包信任 registry 直接放行;github 源拦截时标记 [packaging] 前缀,
|
|
272
|
-
// 供客户端归类为「插件分发不完整」并引导去仓库提 Issue
|
|
273
|
-
if (already === null) {
|
|
274
|
-
const preflight = await preflightTarget(target)
|
|
275
|
-
if (!preflight.ok) {
|
|
276
|
-
// 预检拦截(git 分发缺作者声明的文件):同步 400 返回,附上已尝试的安装方式,
|
|
277
|
-
// 客户端失败弹窗提 Issue 时一并贴给作者
|
|
278
|
-
sendJson(response, 400, {
|
|
279
|
-
error: `[packaging] ${target}: plugin distribution is incomplete — the file ${preflight.missing ?? '?'} the package needs (its declared entry, an entry a bundled patch mounts, or the patch itself) is not present in the git distribution (build output not committed). Report to the author.`,
|
|
280
|
-
attempts,
|
|
281
|
-
})
|
|
282
|
-
return
|
|
283
|
-
}
|
|
284
|
-
// 包名冲突检测(仅 git 通道):git 目标包内声明的 name 若与 profile 已装依赖同名,
|
|
285
|
-
// pnpm 会以该 name 做依赖键撞车,抛出的 CLI 报错晦涩难懂 —— 且该包名在 registry 上
|
|
286
|
-
// 可能被别的仓库占用,npm 反查搜不到,git 直装就会撞上已装的同名依赖。
|
|
287
|
-
// 到这里已装依赖要么来源不同仓库、要么 spec 是版本号解析不出仓库身份。
|
|
288
|
-
// 读 node_modules 里已装包的真实 repository 区分两种情况:
|
|
289
|
-
// - 指向同一仓库 → 是「同仓库残留」(spec 丢了仓库身份),就地转 update 覆盖重装(幂等);
|
|
290
|
-
// - 指向别的仓库 / 读不到 → 跨仓库包名冲突,入队前转成明确 409,指导用户先卸载或改装。
|
|
291
|
-
if (preflight.name !== null && repoTarget !== null && target === repoTarget) {
|
|
292
|
-
const declared = preflight.name
|
|
293
|
-
if (installed[declared] !== undefined) {
|
|
294
|
-
const installedRepo = installedRepoOf(profile, declared)
|
|
295
|
-
if (installedRepo !== null && gitRepo !== null && installedRepo.toLowerCase() === gitRepo.toLowerCase()) {
|
|
296
|
-
// 同名且同源:已装 spec 丢了仓库身份导致的残留,直接按 update 覆盖重装,不打扰用户
|
|
297
|
-
attempts.push(`same-repo residual: \`${declared}\` resolves to \`${installedRepo}\` → reinstall as update`)
|
|
298
|
-
mode = 'update'
|
|
299
|
-
} else {
|
|
300
|
-
attempts.push(`package name conflict: \`${gitRepo}\` declares npm name \`${declared}\`, which is already present in the profile and cannot be matched to this repo (that npm name is likely registered by another repository)`)
|
|
301
|
-
const error = lang === 'zh'
|
|
302
|
-
? `already installed: ${declared} —— ${gitRepo} 声明的 npm 包名「${declared}」已存在于当前 profile,且无法匹配到本仓库(该包名在 npm 上可能被其他仓库占用)。请先移除现有的 ${declared}(dsh plugin remove ${declared}),再重新安装;或改装该包名对应的官方 npm 包。`
|
|
303
|
-
: `already installed: ${declared} — ${gitRepo} declares the npm package name "${declared}", which is already present in the profile and cannot be matched to this repo (that npm name is likely registered by another repository). Remove the existing ${declared} dependency (dsh plugin remove ${declared}) first, then retry; or install the official npm package under that name.`
|
|
304
|
-
sendJson(response, 409, { error, attempts })
|
|
305
|
-
return
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
// 入队前复检(与上方检查同语义,但必须在同步块内):preflight 的 await 期间并发请求
|
|
311
|
-
// 可能已通过上方检查、任务却尚未入队——此处检查与 startPluginMutation 之间无 await,
|
|
312
|
-
// JS 单线程保证同一目标至多一个任务,杜绝双击/并发产生双任务
|
|
152
|
+
// 入队前复检:网络探测的 await 期间并发请求可能已通过上方检查,而此处到 startPluginMutation
|
|
153
|
+
// 之间无 await,JS 单线程保证同一目标至多一个任务,杜绝双击/并发双任务。
|
|
313
154
|
if (hasQueuedTarget(target)) {
|
|
314
155
|
sendJson(response, 409, { error: `already queued: ${target}` })
|
|
315
156
|
return
|
|
316
157
|
}
|
|
317
|
-
//
|
|
158
|
+
// 后台启动 CLI;客户端轮询 /status 获取进度
|
|
318
159
|
const task = startPluginMutation({
|
|
319
160
|
// mode=update(已安装目标的覆盖更新)以 update 动作入队:
|
|
320
161
|
// 日志按 update 类别落盘(update.start/done/fail),实际 CLI 执行仍是 add <target>@latest
|
|
321
162
|
action: mode === 'update' ? 'update' : 'add',
|
|
322
163
|
profile,
|
|
323
164
|
target,
|
|
324
|
-
// npm 安装时 target 是包名:displayTarget
|
|
165
|
+
// npm 安装时 target 是包名:displayTarget 固定展示仓库名,待重启行/前端恢复不因安装目标形态而变
|
|
325
166
|
displayTarget: githubRepoOf(displayRepo) ?? undefined,
|
|
326
|
-
//
|
|
327
|
-
attempts,
|
|
328
|
-
timeoutMs: COMMAND_TIMEOUT_MS,
|
|
329
|
-
env: mutationEnv(settings),
|
|
330
|
-
// 覆盖更新:npm 通道命令显式 @latest(pnpm add 无版本对已存在依赖是幂等的,不加版本不会真更新)
|
|
167
|
+
// 覆盖更新:npm 命令显式 @latest(pnpm add 无版本对已存在依赖是幂等的,不加版本不会真更新)
|
|
331
168
|
updateNpm: mode === 'update',
|
|
332
169
|
// 运行中 loader:安装成功后把新插件热挂进 loader,非桌面端 + 纯服务端插件无需重启即生效
|
|
333
170
|
loader,
|
|
334
|
-
|
|
171
|
+
timeoutMs: COMMAND_TIMEOUT_MS,
|
|
172
|
+
env: mutationEnv(settings),
|
|
173
|
+
// 自定义安装入口渠道:日志/报错据此溯源
|
|
335
174
|
installChannel,
|
|
336
175
|
})
|
|
337
176
|
sendJson(response, 200, { ok: true, task: task.id })
|
package/src/server/http/logs.ts
CHANGED
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
* Website: https://dsh-plugin.org
|
|
4
4
|
* GitHub: https://github.com/dshplugin/dsh-plugin-hub
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
* native folder picker for choosing a log directory.
|
|
6
|
+
* 日志路由:分页日志查看器、清空、在文件管理器中定位,以及选择日志目录的原生文件夹选择器。
|
|
8
7
|
*/
|
|
9
8
|
import { spawn } from 'node:child_process'
|
|
10
9
|
import { dirname } from 'node:path'
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DSH Plugin Hub — the community plugin marketplace for DeepSeek Harness.
|
|
3
|
+
* Website: https://dsh-plugin.org
|
|
4
|
+
* GitHub: https://github.com/dshplugin/dsh-plugin-hub
|
|
5
|
+
*
|
|
6
|
+
* npm 包发布时间查询路由:按已安装插件的 npm 包名按需查询最新版本的发布时间,
|
|
7
|
+
* 供客户端判定 pnpm 24h 供应链门禁(发布未满门槛的版本不提示更新)。
|
|
8
|
+
*/
|
|
9
|
+
import { systemProxy } from '../services/probe.ts'
|
|
10
|
+
import { lookupReleaseAge, parseReleaseAgeRequest } from '../services/npm-release-age.ts'
|
|
11
|
+
import { loadSettings } from '../services/settings.ts'
|
|
12
|
+
import { readJsonBody, requireTrustedPost, sendJson, type WebRoute, type WebServerService } from './shared.ts'
|
|
13
|
+
|
|
14
|
+
export function registerNpmReleaseAgeRoutes(webServer: WebServerService, profile: string): WebRoute[] {
|
|
15
|
+
return [
|
|
16
|
+
{
|
|
17
|
+
kind: 'exact',
|
|
18
|
+
path: '/dsh-plugin-hub/npm-release-age',
|
|
19
|
+
handler: async (request, response) => {
|
|
20
|
+
if (!requireTrustedPost(request, response)) return
|
|
21
|
+
try {
|
|
22
|
+
const packages = parseReleaseAgeRequest(await readJsonBody(request))
|
|
23
|
+
if (packages === null) {
|
|
24
|
+
sendJson(response, 400, { error: 'invalid package list' })
|
|
25
|
+
return
|
|
26
|
+
}
|
|
27
|
+
const settings = loadSettings(profile)
|
|
28
|
+
// 代理口径与安装/目录一致:设置里的代理 → 系统代理 → 环境变量 → 直连
|
|
29
|
+
const proxy = settings.proxy !== ''
|
|
30
|
+
? settings.proxy
|
|
31
|
+
: (systemProxy() ?? process.env.HTTPS_PROXY ?? process.env.https_proxy ?? '')
|
|
32
|
+
// 并发查询:单包各自带超时且失败即 null,整体不因任一包失败而失败
|
|
33
|
+
const results = await Promise.all(packages.map(async (name) =>
|
|
34
|
+
[name, await lookupReleaseAge(name, settings.npmRegistry, proxy)] as const))
|
|
35
|
+
sendJson(response, 200, { packages: Object.fromEntries(results) })
|
|
36
|
+
} catch (error) {
|
|
37
|
+
sendJson(response, 500, { error: error instanceof Error ? error.message : String(error) })
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
]
|
|
42
|
+
}
|
|
@@ -3,10 +3,9 @@
|
|
|
3
3
|
* Website: https://dsh-plugin.org
|
|
4
4
|
* GitHub: https://github.com/dshplugin/dsh-plugin-hub
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* install
|
|
9
|
-
* (see services/install/install.ts) and reports the captured result back.
|
|
6
|
+
* 本地 HTTP 路由:把真实安装能力暴露给应用内的插件中心 UI。客户端请求同源
|
|
7
|
+
* `/dsh-plugin-hub/*` 端点;安装处理校验目标后 spawn 官方 dsh CLI(见
|
|
8
|
+
* services/install/install.ts)并回传捕获的结果。
|
|
10
9
|
*/
|
|
11
10
|
import { type LoaderHandle } from '../services/install/install.ts'
|
|
12
11
|
import { appendLog } from '../services/log.ts'
|
|
@@ -17,13 +16,13 @@ import { registerSettingsRoutes } from './settings.ts'
|
|
|
17
16
|
import { registerLogsRoutes } from './logs.ts'
|
|
18
17
|
import { registerDiagnosticsRoutes } from './diagnostics.ts'
|
|
19
18
|
import { registerTaskRoutes } from './task.ts'
|
|
19
|
+
import { registerNpmReleaseAgeRoutes } from './npm-release-age.ts'
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
|
-
*
|
|
23
|
-
* @param webServer - DSH web server
|
|
24
|
-
* @param profile - profile
|
|
25
|
-
* @param loader -
|
|
26
|
-
* immediately so the page survives a refresh without a host restart.
|
|
22
|
+
* 在宿主 web server 上注册插件中心 API 并返回 dispose 函数。
|
|
23
|
+
* @param webServer - DSH web server 服务。
|
|
24
|
+
* @param profile - 拥有插件变更权限的 profile。
|
|
25
|
+
* @param loader - 运行中 loader(可选):让卸载立即移除条目,页面刷新即生效、无需重启宿主。
|
|
27
26
|
*/
|
|
28
27
|
export function mountPluginHubRoutes(webServer: WebServerService, profile: string, loader?: LoaderHandle): () => void {
|
|
29
28
|
if (!PROFILE_RE.test(profile)) throw new Error(`invalid profile name: ${profile}`)
|
|
@@ -43,6 +42,7 @@ export function mountPluginHubRoutes(webServer: WebServerService, profile: strin
|
|
|
43
42
|
...registerLogsRoutes(webServer, profile),
|
|
44
43
|
...registerDiagnosticsRoutes(webServer, profile),
|
|
45
44
|
...registerTaskRoutes(webServer, profile, loader),
|
|
45
|
+
...registerNpmReleaseAgeRoutes(webServer, profile),
|
|
46
46
|
]
|
|
47
47
|
const disposers = routes.map((route) => webServer.register(route))
|
|
48
48
|
return () => {
|
|
@@ -50,9 +50,9 @@ export function mountPluginHubRoutes(webServer: WebServerService, profile: strin
|
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
/**
|
|
53
|
+
/** 与客户端路由文档共用的 profile 解析。 */
|
|
54
54
|
export { readProfileArg } from '../services/install/install.ts'
|
|
55
|
-
/**
|
|
55
|
+
/** 转出以便宿主入口(index.ts)继续从本模块引入。 */
|
|
56
56
|
export type { WebServerService } from './shared.ts'
|
|
57
|
-
/**
|
|
57
|
+
/** 转出以便 tests/routes.test.ts 继续从本模块引入。 */
|
|
58
58
|
export { isDesktopHost, isSameOrigin } from './shared.ts'
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Website: https://dsh-plugin.org
|
|
4
4
|
* GitHub: https://github.com/dshplugin/dsh-plugin-hub
|
|
5
5
|
*
|
|
6
|
-
*
|
|
6
|
+
* 设置路由:读写插件中心设置,以及恢复默认。
|
|
7
7
|
*/
|
|
8
8
|
import { mkdirSync } from 'node:fs'
|
|
9
9
|
import { dirname } from 'node:path'
|
|
@@ -28,7 +28,7 @@ export function registerSettingsRoutes(webServer: WebServerService, profile: str
|
|
|
28
28
|
// 白名单字段:只接受已知设置项,防客户端把任意键写进文件
|
|
29
29
|
const patch: Record<string, unknown> = {}
|
|
30
30
|
const source = typeof body === 'object' && body !== null ? body as Record<string, unknown> : {}
|
|
31
|
-
for (const key of ['checkUpdatesOnStart', 'enableNpmInstall', '
|
|
31
|
+
for (const key of ['checkUpdatesOnStart', 'enableNpmInstall', 'npmRegistry', 'proxy', 'logPath'] as const) {
|
|
32
32
|
if (source[key] !== undefined) patch[key] = source[key]
|
|
33
33
|
}
|
|
34
34
|
// 日志位置:非空时预建目录验证可写,失败直接 400 拦截(默认位置永远合法,空串 = 回默认)
|
|
@@ -3,9 +3,8 @@
|
|
|
3
3
|
* Website: https://dsh-plugin.org
|
|
4
4
|
* GitHub: https://github.com/dshplugin/dsh-plugin-hub
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* route modules in this directory.
|
|
6
|
+
* 共享 HTTP 工具:路由/服务类型、请求校验助手,以及守卫每个 POST 变更的同源校验。
|
|
7
|
+
* 由本目录其它路由模块引入。
|
|
9
8
|
*/
|
|
10
9
|
import type { IncomingMessage, ServerResponse } from 'node:http'
|
|
11
10
|
|
|
@@ -97,7 +96,7 @@ export interface WebRoute {
|
|
|
97
96
|
handler: (request: IncomingMessage, response: ServerResponse) => void | Promise<void>
|
|
98
97
|
}
|
|
99
98
|
|
|
100
|
-
/**
|
|
99
|
+
/** 本插件用到的宿主 web-server 服务子集。 */
|
|
101
100
|
export interface WebServerService {
|
|
102
101
|
register(route: WebRoute): () => void
|
|
103
102
|
}
|
|
@@ -135,8 +134,8 @@ function loopbackAuthority(authority: string): string | null {
|
|
|
135
134
|
}
|
|
136
135
|
}
|
|
137
136
|
|
|
138
|
-
/** POST
|
|
139
|
-
*
|
|
137
|
+
/** POST 变更只接受来自本地 web server 来源或桌面宿主页面。转出供测试(tests/routes.test.ts)使用 ——
|
|
138
|
+
* 来源校验就是全部的 CSRF 防御。 */
|
|
140
139
|
export function isSameOrigin(request: IncomingMessage): boolean {
|
|
141
140
|
// 服务只绑定本机回环地址:Host 不是回环(局域网 IP、被改写的域名)一律拒绝,
|
|
142
141
|
// 顺带挡掉 DNS rebinding(Host 是攻击者域名,即便解析到 127.0.0.1)。
|
package/src/server/http/task.ts
CHANGED
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
* Website: https://dsh-plugin.org
|
|
4
4
|
* GitHub: https://github.com/dshplugin/dsh-plugin-hub
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
* the installed-plugin inventory the client uses to reconcile its list.
|
|
6
|
+
* 任务/杂项路由:任务轮询、宿主重启、loader 条目调试,以及客户端用于对账列表的已装插件清单。
|
|
8
7
|
*/
|
|
9
8
|
import { spawn } from 'node:child_process'
|
|
10
9
|
import { join } from 'node:path'
|
package/src/server/index.ts
CHANGED
|
@@ -3,9 +3,8 @@
|
|
|
3
3
|
* Website: https://dsh-plugin.org
|
|
4
4
|
* GitHub: https://github.com/dshplugin/dsh-plugin-hub
|
|
5
5
|
*
|
|
6
|
-
* dsh-plugin
|
|
7
|
-
*
|
|
8
|
-
* these same-origin routes to perform real installs from inside the app.
|
|
6
|
+
* dsh-plugin 宿主入口:宿主 webServer 服务就绪后挂载插件中心的 HTTP 路由。
|
|
7
|
+
* 浏览器 bundle(src/client)通过这些同源路由在应用内执行真正的安装。
|
|
9
8
|
*/
|
|
10
9
|
import { readProfileArg, type LoaderHandle } from './services/install/install.ts'
|
|
11
10
|
import { mountPluginHubRoutes, type WebServerService } from './http/routes.ts'
|
|
@@ -13,11 +12,11 @@ import { mountPluginHubRoutes, type WebServerService } from './http/routes.ts'
|
|
|
13
12
|
export const name = 'dsh-plugin'
|
|
14
13
|
|
|
15
14
|
export interface Config {
|
|
16
|
-
/** DSH profile
|
|
15
|
+
/** 拥有插件变更权限的 DSH profile,缺省用启动时的 profile。 */
|
|
17
16
|
profile?: string
|
|
18
17
|
}
|
|
19
18
|
|
|
20
|
-
/**
|
|
19
|
+
/** 本插件用到的 cordis 宿主上下文子集。 */
|
|
21
20
|
interface HostContext {
|
|
22
21
|
webServer: WebServerService
|
|
23
22
|
/** 运行中 loader:卸载成功后主动移除条目、立即生效(宿主未提供时卸载仍需重启) */
|
|
@@ -27,9 +26,9 @@ interface HostContext {
|
|
|
27
26
|
}
|
|
28
27
|
|
|
29
28
|
/**
|
|
30
|
-
*
|
|
31
|
-
* @param ctx - cordis
|
|
32
|
-
* @param config -
|
|
29
|
+
* webServer 服务就绪后挂载插件中心路由。
|
|
30
|
+
* @param ctx - cordis 宿主上下文。
|
|
31
|
+
* @param config - 可选的 profile 覆盖。
|
|
33
32
|
*/
|
|
34
33
|
export function apply(ctx: HostContext, config: Config = {}): void {
|
|
35
34
|
const profile = config.profile ?? readProfileArg('web')
|