@vibedev-si/dsh-vibedev 0.3.10 → 0.5.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.md +141 -7
- package/THIRD-PARTY-NOTICES.txt +1 -1
- package/client/client.account-center.js +13151 -0
- package/client/client.js +3417 -878
- package/cordis.patch.yml +5 -0
- package/lib/account/center-business-contract.d.ts +22 -0
- package/lib/account/center-business.d.ts +6 -0
- package/lib/account/center-contract.d.ts +12 -0
- package/lib/account/center-monitor-contract.d.ts +10 -0
- package/lib/account/center-price-contract.d.ts +5 -0
- package/lib/account/center.d.ts +7 -0
- package/lib/account/index.d.ts +14 -0
- package/lib/{anthropic-messages-BgIfgjNt.js → anthropic-messages-QcnVMGaA.js} +11 -11
- package/lib/contract-v1.types.d.ts +134 -0
- package/lib/contracts.d.ts +34 -0
- package/lib/gateway/errors.d.ts +29 -1
- package/lib/gateway/http.d.ts +6 -0
- package/lib/host-locales.d.ts +4 -0
- package/lib/index.d.ts +14 -0
- package/lib/index.js +4619 -1976
- package/lib/{node-D58f7Ea6.js → node-CcLPV4RA.js} +4 -4
- package/lib/{node-Br-0fshF.js → node-vkDR3GtK.js} +2 -2
- package/lib/pricing.d.ts +21 -1
- package/lib/service.d.ts +51 -9
- package/lib/tasks/progress.d.ts +96 -0
- package/lib/tasks/remote.d.ts +15 -8
- package/lib/tasks/store.d.ts +59 -9
- package/lib/tasks/tracker.d.ts +51 -45
- package/lib/tools/image.d.ts +1 -0
- package/lib/tools/video.d.ts +3 -0
- package/lib/util/files.d.ts +2 -0
- package/locale/en.json +13 -0
- package/locale/zh.json +13 -0
- package/node_modules/@vibedev-si/dsh-ecosystem/LICENSE +22 -0
- package/node_modules/@vibedev-si/dsh-ecosystem/README.md +154 -0
- package/node_modules/@vibedev-si/dsh-ecosystem/catalog/catalog.json +167 -0
- package/node_modules/@vibedev-si/dsh-ecosystem/catalog-updates.js +326 -0
- package/node_modules/@vibedev-si/dsh-ecosystem/catalog-validator.js +263 -0
- package/node_modules/@vibedev-si/dsh-ecosystem/client.js +2816 -0
- package/node_modules/@vibedev-si/dsh-ecosystem/cordis.patch.yml +5 -0
- package/node_modules/@vibedev-si/dsh-ecosystem/icon.svg +5 -0
- package/node_modules/@vibedev-si/dsh-ecosystem/index.js +169 -0
- package/node_modules/@vibedev-si/dsh-ecosystem/locale/en.json +6 -0
- package/node_modules/@vibedev-si/dsh-ecosystem/locale/zh.json +6 -0
- package/node_modules/@vibedev-si/dsh-ecosystem/package.json +75 -0
- package/node_modules/@vibedev-si/dsh-ecosystem/remote-catalog.js +212 -0
- package/package.json +12 -1
|
@@ -0,0 +1,2816 @@
|
|
|
1
|
+
/*! @vibedev-si/dsh-ecosystem 0.2.0 client half. GENERATED by scripts/build.mjs, do not edit. */
|
|
2
|
+
window.__ModuleLoader__.load({
|
|
3
|
+
id: "@vibedev-si/dsh-ecosystem",
|
|
4
|
+
factory: (require) => {
|
|
5
|
+
var module = { exports: {} };
|
|
6
|
+
var exports = module.exports;
|
|
7
|
+
|
|
8
|
+
"use strict";
|
|
9
|
+
var React = require("react");
|
|
10
|
+
/**
|
|
11
|
+
* The catalog validator, shared by everything that trusts catalog/catalog.json.
|
|
12
|
+
*
|
|
13
|
+
* The catalog is the install ALLOW-LIST: the ecosystem installs nothing that is not an entry here,
|
|
14
|
+
* so every rule below protects users, not just formatting. It has two callers:
|
|
15
|
+
*
|
|
16
|
+
* - scripts/validate-catalog.mjs (the maintainer's offline/online check, same rules as before)
|
|
17
|
+
* - src/remote-catalog.js (the Host's ONLINE catalog reader: an entry that arrives over
|
|
18
|
+
* the network is validated with exactly these rules before a
|
|
19
|
+
* single package name from it is trusted)
|
|
20
|
+
*
|
|
21
|
+
* Pure and dependency-free: no file reads, no network, no globals. `validateCatalog` never throws.
|
|
22
|
+
*
|
|
23
|
+
* The catalog source is FIXED (the repository's own catalog/catalog.json on the default branch) and
|
|
24
|
+
* the names an entry may use are validated here — the reader does not accept a caller-supplied URL
|
|
25
|
+
* or an unbounded set of trusted package names. It is deliberately NOT a "these four plugins only"
|
|
26
|
+
* list: a new @vibedev-si/* plugin committed to the catalog is picked up without shipping a new
|
|
27
|
+
* client, which is the whole point of the online catalog.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
/** Hard bounds: a payload over these is refused whole rather than rendered. */
|
|
31
|
+
const CATALOG_LIMITS = {
|
|
32
|
+
plugins: 40,
|
|
33
|
+
suites: 20,
|
|
34
|
+
sizeKB: 1048576, // 1 GB: the catalog only DESCRIBES size, so a large legitimate plugin is not blocked
|
|
35
|
+
capabilities: 12,
|
|
36
|
+
doesLines: 8,
|
|
37
|
+
textLength: 600,
|
|
38
|
+
taglineLength: 200,
|
|
39
|
+
itemsPerSuite: 40,
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** The catalog format this build understands: `catalog.schema` must be one of these. */
|
|
43
|
+
const CATALOG_SCHEMA = 1
|
|
44
|
+
const CATALOG_SCHEMAS = [1]
|
|
45
|
+
|
|
46
|
+
/** Names the catalog may claim. Everything else is refused, so the trusted install surface is fixed. */
|
|
47
|
+
const CATALOG_KNOWN = {
|
|
48
|
+
/** VibeDev's own packages are scoped; dsh-film is grandfathered from before the scope existed. */
|
|
49
|
+
officialScopes: ['@vibedev-si/'],
|
|
50
|
+
officialGrandfathered: ['dsh-film'],
|
|
51
|
+
/** Community entries are the packages already shipped this way; the list does not grow by remote edit. */
|
|
52
|
+
community: ['dshmarket'],
|
|
53
|
+
/** Never VibeDev's own: a DSH-scoped name claiming "official" is impersonation. */
|
|
54
|
+
forbiddenScopes: ['@deepseek-ai/'],
|
|
55
|
+
officialRepo: /^https:\/\/github\.com\/VibeDev-Si\/[A-Za-z0-9._-]+$/,
|
|
56
|
+
npmPage: /^https:\/\/www\.npmjs\.com\/package\/[@a-z0-9._~/-]+$/i,
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** The ecosystem itself, which is never a catalog entry. */
|
|
60
|
+
const CATALOG_SELF = ['@vibedev-si/dsh-ecosystem']
|
|
61
|
+
|
|
62
|
+
const ORIGINS = new Set(['official', 'community'])
|
|
63
|
+
const ROLES = new Set(['official', 'dependency', 'companion', 'featured'])
|
|
64
|
+
const UPDATES = new Set(['center', 'self'])
|
|
65
|
+
const COMPAT = new Set(['verified', 'likely', 'unknown', 'incompatible'])
|
|
66
|
+
const TAGS = new Set(['official', 'community', 'needsAccount', 'paid', 'needsHost02', 'dependency', 'companion', 'tested'])
|
|
67
|
+
const CAPS = new Set(['network', 'writeFiles', 'readFiles', 'credentials', 'cost', 'agentTools', 'localRoute', 'pageScripts', 'community', 'fileAccess', 'writeConfig'])
|
|
68
|
+
/** A plain package name: no urls, no git specs, no paths, no versions, no dist-tags. */
|
|
69
|
+
const SPEC = /^(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/
|
|
70
|
+
/** An exact released version. No range, no tag, no prerelease suffix. */
|
|
71
|
+
const STABLE = /^\d+\.\d+\.\d+$/
|
|
72
|
+
const ISO_UTC = /^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(\.\d+)?Z$/
|
|
73
|
+
const EARLIEST = Date.parse('2020-01-01T00:00:00Z')
|
|
74
|
+
/** Two CSS hex colours, and nothing else: `url(...)`, `var(...)` or a named colour would let a remote
|
|
75
|
+
* payload make the page fetch something or read a theme value it should not touch. */
|
|
76
|
+
const HEX = /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/
|
|
77
|
+
const PROFILE = '[A-Za-z0-9._-]{1,64}'
|
|
78
|
+
/** The one shape a `cmd` may have. Nothing from a payload is ever executed or echoed as a shell line:
|
|
79
|
+
* the reader regenerates the command from the entry's own npm name and exact version. */
|
|
80
|
+
const canonicalCmd = (npm, version) => new RegExp(`^dsh plugin(?: --profile ${PROFILE})? add ${escapeRe(npm)}(?:@${escapeRe(version)})?$`)
|
|
81
|
+
|
|
82
|
+
/** Escape a package name or version so it can only match itself inside a pattern. */
|
|
83
|
+
function escapeRe(value) {
|
|
84
|
+
return String(value).replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* The canonical install command for an entry, built from fields this validator has already checked.
|
|
89
|
+
* @param npm - the entry's package name.
|
|
90
|
+
* @param version - the entry's exact version.
|
|
91
|
+
* @param profile - an optional dsh profile name.
|
|
92
|
+
* @returns the command the UI may show and the user may copy.
|
|
93
|
+
*/
|
|
94
|
+
function catalogCommand(npm, version, profile) {
|
|
95
|
+
return `dsh plugin${profile ? ` --profile ${profile}` : ''} add ${npm}@${version}`
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* A copy of the catalog whose commands are regenerated rather than trusted.
|
|
100
|
+
* @param catalog - a catalog that passed validateCatalog.
|
|
101
|
+
* @param options - { profile }: the dsh profile the Host installs into, when it knows one.
|
|
102
|
+
* @returns a new catalog object; the input is never modified.
|
|
103
|
+
*/
|
|
104
|
+
function normalizeCatalog(catalog, options = {}) {
|
|
105
|
+
const profile = options.profile
|
|
106
|
+
if (profile !== undefined && !new RegExp(`^${PROFILE}$`).test(String(profile))) throw new Error('invalid profile name')
|
|
107
|
+
const plugins = (catalog?.plugins ?? []).map((p) => ({ ...p, cmd: catalogCommand(p.npm, p.version, profile) }))
|
|
108
|
+
const suites = (catalog?.suites ?? []).map((s) => ({ ...s }))
|
|
109
|
+
return { ...catalog, plugins, suites }
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** https, and a plain path: no credentials in the authority, no query, no fragment. */
|
|
113
|
+
const plainHttps = (value) => typeof value === 'string' && /^https:\/\//.test(value)
|
|
114
|
+
&& !/^https:\/\/[^/]*@/.test(value) && !/[?#]/.test(value)
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Validate one catalog.
|
|
118
|
+
* @param catalog - the parsed catalog (or anything at all).
|
|
119
|
+
* @param options - { now, limits, known } overrides, for tests and for a stricter caller.
|
|
120
|
+
* @returns { ok, errors, counts }: the errors are messages, safe to log and to show.
|
|
121
|
+
*/
|
|
122
|
+
function validateCatalog(catalog, options = {}) {
|
|
123
|
+
const limits = { ...CATALOG_LIMITS, ...(options.limits ?? {}) }
|
|
124
|
+
const known = { ...CATALOG_KNOWN, ...(options.known ?? {}) }
|
|
125
|
+
const now = typeof options.now === 'function' ? options.now() : (options.now ?? Date.now())
|
|
126
|
+
const errors = []
|
|
127
|
+
const err = (m) => errors.push(m)
|
|
128
|
+
const entry = (v) => v !== null && typeof v === 'object'
|
|
129
|
+
const text = (v) => typeof v === 'string' && v.trim().length > 0
|
|
130
|
+
const bi = (v, where) => {
|
|
131
|
+
if (!entry(v) || !text(v.zh) || !text(v.en)) return err(`${where}: needs non-empty zh and en`)
|
|
132
|
+
if (v.zh.length > limits.textLength || v.en.length > limits.textLength) err(`${where}: text is longer than ${limits.textLength} characters`)
|
|
133
|
+
}
|
|
134
|
+
const biList = (v, where, min = 1, max = limits.doesLines) => {
|
|
135
|
+
if (!entry(v) || !Array.isArray(v.zh) || !Array.isArray(v.en) || v.zh.length === 0) return err(`${where}: needs zh[] and en[]`)
|
|
136
|
+
if (v.zh.length !== v.en.length) err(`${where}: zh and en must have the same number of lines (${v.zh.length} vs ${v.en.length})`)
|
|
137
|
+
if (v.zh.length > max) err(`${where}: more than ${max} lines`)
|
|
138
|
+
for (const line of [...v.zh, ...v.en]) if (!text(line)) err(`${where}: every line must be non-empty`)
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (!entry(catalog)) return { ok: false, errors: ['catalog: not an object'], counts: { plugins: 0, suites: 0 } }
|
|
142
|
+
const schemas = options.schemas ?? CATALOG_SCHEMAS
|
|
143
|
+
if (!schemas.includes(catalog.schema)) err(`schema must be one of ${schemas.join(', ')} (got ${JSON.stringify(catalog.schema)})`)
|
|
144
|
+
if (!Array.isArray(catalog.plugins) || catalog.plugins.length === 0) err('plugins[] is required')
|
|
145
|
+
const plugins = Array.isArray(catalog.plugins) ? catalog.plugins : []
|
|
146
|
+
const suites = Array.isArray(catalog.suites) ? catalog.suites : []
|
|
147
|
+
if (plugins.length > limits.plugins) err(`plugins[] has ${plugins.length} entries, more than the ${limits.plugins} this reader accepts`)
|
|
148
|
+
if (suites.length > limits.suites) err(`suites[] has ${suites.length} entries, more than the ${limits.suites} this reader accepts`)
|
|
149
|
+
|
|
150
|
+
const ids = new Set()
|
|
151
|
+
const npmNames = new Set()
|
|
152
|
+
for (const p of plugins) {
|
|
153
|
+
const w = `plugin ${entry(p) ? p.id ?? '?' : '?'}`
|
|
154
|
+
if (!entry(p)) { err(`${w}: not an object`); continue }
|
|
155
|
+
if (!text(p.id) || ids.has(p.id)) err(`${w}: id missing or duplicated`)
|
|
156
|
+
if (typeof p.id === 'string') ids.add(p.id)
|
|
157
|
+
if (p.id !== p.npm) err(`${w}: id must equal npm name`)
|
|
158
|
+
if (!text(p.npm) || !SPEC.test(p.npm)) err(`${w}: npm is not a plain package name (no urls, git specs, paths, versions or tags)`)
|
|
159
|
+
if (npmNames.has(p.npm)) err(`${w}: duplicate npm name`)
|
|
160
|
+
if (typeof p.npm === 'string') npmNames.add(p.npm)
|
|
161
|
+
if (!STABLE.test(p.version ?? '')) err(`${w}: version must be an exact released x.y.z (no range, tag or prerelease)`)
|
|
162
|
+
// When this exact version reached npm. The update screens use it to warn about pnpm's one-day cooldown honestly.
|
|
163
|
+
const published = typeof p.publishedAt === 'string' && ISO_UTC.test(p.publishedAt) ? Date.parse(p.publishedAt) : NaN
|
|
164
|
+
if (Number.isNaN(published)) err(`${w}: publishedAt must be an ISO UTC time such as 2026-10-05T14:40:00.000Z`)
|
|
165
|
+
else if (published < EARLIEST) err(`${w}: publishedAt is before 2020`)
|
|
166
|
+
else if (published > now + 24 * 3600 * 1000) err(`${w}: publishedAt is in the future`)
|
|
167
|
+
if (!ORIGINS.has(p.origin)) err(`${w}: origin`)
|
|
168
|
+
if (!ROLES.has(p.role)) err(`${w}: role`)
|
|
169
|
+
if (!UPDATES.has(p.updates)) err(`${w}: updates`)
|
|
170
|
+
// What a name may claim. A DSH-scoped package is never VibeDev's own, whatever the entry says.
|
|
171
|
+
const scope = typeof p.npm === 'string' ? p.npm.slice(0, p.npm.indexOf('/') + 1) : ''
|
|
172
|
+
// The center itself is listed as a manual row and updated from the Plugins page: it must never
|
|
173
|
+
// appear here, or a click could unload the very panel reading this catalog.
|
|
174
|
+
if ((options.self ?? CATALOG_SELF).includes(p.npm) || (options.self ?? CATALOG_SELF).includes(p.id)) {
|
|
175
|
+
err(`${w}: the ecosystem is not a catalog entry (it is updated from the Plugins page, never installed from here)`)
|
|
176
|
+
}
|
|
177
|
+
if (known.forbiddenScopes.includes(scope)) err(`${w}: ${scope} is not a VibeDev package name`)
|
|
178
|
+
if (p.origin === 'official' && !(known.officialScopes.some((s) => (p.npm ?? '').startsWith(s)) || known.officialGrandfathered.includes(p.npm))) {
|
|
179
|
+
err(`${w}: an "official" entry must be @vibedev-si/* or one of the grandfathered unscoped names`)
|
|
180
|
+
}
|
|
181
|
+
if (p.origin === 'community') {
|
|
182
|
+
if (p.role === 'official') err(`${w}: community entry cannot have role official`)
|
|
183
|
+
if (!p.author) err(`${w}: community entry needs author`)
|
|
184
|
+
if (!known.community.includes(p.npm)) err(`${w}: community entries are limited to the packages this catalog already ships`)
|
|
185
|
+
if (!(p.capabilities ?? []).some((c) => entry(c) && c.key === 'community')) err(`${w}: community entry must carry the "community" capability disclaimer`)
|
|
186
|
+
}
|
|
187
|
+
bi(p.name, `${w}.name`)
|
|
188
|
+
bi(p.tagline, `${w}.tagline`)
|
|
189
|
+
if (entry(p.tagline) && text(p.tagline.zh) && p.tagline.zh.length > limits.taglineLength) err(`${w}.tagline: longer than ${limits.taglineLength} characters`)
|
|
190
|
+
biList(p.does, `${w}.does`)
|
|
191
|
+
// Rendered when present (the card shows this instead of the computed size), so it must be a
|
|
192
|
+
// bilingual string pair like every other rendered field: a payload must not be able to put an
|
|
193
|
+
// object — or a line that disagrees with the real size — there.
|
|
194
|
+
if (p.sizeNote != null) bi(p.sizeNote, `${w}.sizeNote`)
|
|
195
|
+
for (const t of p.tags ?? []) if (!TAGS.has(t)) err(`${w}: unknown tag ${t}`)
|
|
196
|
+
const caps = Array.isArray(p.capabilities) ? p.capabilities : []
|
|
197
|
+
if (caps.length > limits.capabilities) err(`${w}: more than ${limits.capabilities} capabilities`)
|
|
198
|
+
for (const c of caps) {
|
|
199
|
+
if (!entry(c) || !CAPS.has(c.key)) err(`${w}: unknown capability ${entry(c) ? c.key : '?'}`)
|
|
200
|
+
bi(c?.text, `${w}.capabilities.${c?.key}`)
|
|
201
|
+
}
|
|
202
|
+
if (!caps.length) err(`${w}: capabilities must list at least one entry`)
|
|
203
|
+
if (!Number.isFinite(p.sizeKB) || p.sizeKB <= 0) err(`${w}: sizeKB`)
|
|
204
|
+
else if (p.sizeKB > limits.sizeKB) err(`${w}: sizeKB ${p.sizeKB} is larger than the ${limits.sizeKB} KB this reader accepts`)
|
|
205
|
+
if (!p.icon?.glyph?.zh || !p.icon?.glyph?.en || p.icon.grad?.length !== 2) err(`${w}: icon.glyph{zh,en} and icon.grad[2]`)
|
|
206
|
+
if (p.icon?.glyph?.en && /[^\x00-\x7f]/.test(p.icon.glyph.en)) err(`${w}: icon.glyph.en must be plain ASCII (it is shown in the English UI)`)
|
|
207
|
+
for (const c of p.icon?.grad ?? []) if (!HEX.test(String(c))) err(`${w}: icon.grad must be two CSS hex colours (got ${String(c).slice(0, 40)})`)
|
|
208
|
+
// The command is a fixed shape built from the name and version above: a payload cannot smuggle a
|
|
209
|
+
// shell line in, and the reader regenerates it anyway (see normalizeCatalog).
|
|
210
|
+
if (!canonicalCmd(p.npm ?? '', p.version ?? '').test(p.cmd ?? '')) {
|
|
211
|
+
err(`${w}: cmd must be "dsh plugin [--profile <name>] add ${p.npm ?? '?'}[@${p.version ?? '?'}]" and nothing else`)
|
|
212
|
+
}
|
|
213
|
+
// Links: https, no credentials, no query or fragment — and the shapes this catalog actually uses.
|
|
214
|
+
for (const k of ['repo', 'npm']) if (!plainHttps(p.links?.[k])) err(`${w}: links.${k} must be a plain https url`)
|
|
215
|
+
if (plainHttps(p.links?.repo) && p.origin === 'official' && !known.officialRepo.test(p.links.repo)) err(`${w}: links.repo must be a VibeDev repository (${p.links.repo})`)
|
|
216
|
+
if (plainHttps(p.links?.npm) && !known.npmPage.test(p.links.npm)) err(`${w}: links.npm must be the npm package page`)
|
|
217
|
+
if (p.compat != null) {
|
|
218
|
+
if (!COMPAT.has(p.compat.s)) err(`${w}: compat.s`)
|
|
219
|
+
bi(p.compat.why, `${w}.compat.why`)
|
|
220
|
+
}
|
|
221
|
+
if (p.reviewed != null && !(p.reviewed.date && Array.isArray(p.reviewed.tested) && p.reviewed.tested.length)) err(`${w}: reviewed needs date and tested[]`)
|
|
222
|
+
}
|
|
223
|
+
for (const p of plugins) {
|
|
224
|
+
if (!entry(p)) continue
|
|
225
|
+
for (const k of ['requires', 'partners']) {
|
|
226
|
+
if (p[k] !== undefined && !Array.isArray(p[k])) { err(`plugin ${p.id}: ${k} must be an array`); continue }
|
|
227
|
+
for (const d of p[k] ?? []) if (!ids.has(d)) err(`plugin ${p.id}: ${k} points at unknown id ${d}`)
|
|
228
|
+
}
|
|
229
|
+
if (p.legacyNames !== undefined && !Array.isArray(p.legacyNames)) err(`plugin ${p.id}: legacyNames must be an array`)
|
|
230
|
+
else {
|
|
231
|
+
// Legacy aliases are the plain package names this plugin used to be published under (dsh-media):
|
|
232
|
+
// useful for the migration banner, and never a url, a git spec or a path.
|
|
233
|
+
for (const name of p.legacyNames ?? []) {
|
|
234
|
+
if (typeof name !== 'string' || !SPEC.test(name)) err(`plugin ${p.id}: legacyNames must be plain package names (got ${String(name).slice(0, 40)})`)
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
if ((p.requires ?? []).includes(p.id)) err(`plugin ${p.id}: requires itself`)
|
|
238
|
+
}
|
|
239
|
+
// dependency cycles
|
|
240
|
+
const visit = (id, path) => {
|
|
241
|
+
if (path.includes(id)) return err(`dependency cycle: ${[...path, id].join(' -> ')}`)
|
|
242
|
+
const p = plugins.find((x) => entry(x) && x.id === id)
|
|
243
|
+
for (const d of p?.requires ?? []) visit(d, [...path, id])
|
|
244
|
+
}
|
|
245
|
+
for (const p of plugins) if (entry(p) && text(p.id)) visit(p.id, [])
|
|
246
|
+
const suiteIds = new Set()
|
|
247
|
+
for (const s of suites) {
|
|
248
|
+
if (!entry(s)) { err('suite: not an object'); continue }
|
|
249
|
+
if (!text(s.id)) err('suite: id is required')
|
|
250
|
+
else if (suiteIds.has(s.id)) err(`suite ${s.id}: id is duplicated`)
|
|
251
|
+
else suiteIds.add(s.id)
|
|
252
|
+
bi(s.name, `suite ${s.id}.name`)
|
|
253
|
+
bi(s.tagline, `suite ${s.id}.tagline`)
|
|
254
|
+
if (!Array.isArray(s.items)) err(`suite ${s.id}: items[] is required`)
|
|
255
|
+
else {
|
|
256
|
+
if (s.items.length > limits.itemsPerSuite) err(`suite ${s.id}: more than ${limits.itemsPerSuite} items`)
|
|
257
|
+
for (const i of s.items) if (!ids.has(i)) err(`suite ${s.id}: unknown item ${i}`)
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
return { ok: errors.length === 0, errors, counts: { plugins: plugins.length, suites: suites.length } }
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* The error list alone, for a caller that only wants to know why a catalog is refused.
|
|
266
|
+
* @param catalog - the parsed catalog.
|
|
267
|
+
* @param options - as validateCatalog.
|
|
268
|
+
* @returns the error messages, empty when the catalog is fine.
|
|
269
|
+
*/
|
|
270
|
+
function catalogErrors(catalog, options) {
|
|
271
|
+
return validateCatalog(catalog, options).errors
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Install engine: pure logic, no DOM, no React. It drives the host's `pluginManager`
|
|
276
|
+
* through an injected `pm` object, so the same code runs against the real service and
|
|
277
|
+
* against the fake one used in tests.
|
|
278
|
+
*
|
|
279
|
+
* Contract with the host (read from @deepseek-ai/dsh-plugin-manager's typert schema):
|
|
280
|
+
* pm.inspect(spec, {registry}) -> { ok, value | error } value: {status:'accepted'|'refused', ...}
|
|
281
|
+
* pm.installBundle(spec, {enabled, requestId, registry, approvedBuilds}) -> { ok, value | error }
|
|
282
|
+
* pm.setBundleEnabled(name, enabled) -> { ok, value | error }
|
|
283
|
+
* pm.removeBundle(name) -> { ok, value | error }
|
|
284
|
+
* pm.cancelInstall(requestId) -> { ok, value: {status: 'cancelled'|'too-late'|...} }
|
|
285
|
+
* pm.listBundles() -> { ok, value: BundleInfo[] }
|
|
286
|
+
* `value.application`: 'applied' | 'restart-required' | 'failed' | 'cancelled' | 'overridden'
|
|
287
|
+
*
|
|
288
|
+
* Safety rules enforced HERE (not in the UI, so a UI bug cannot bypass them):
|
|
289
|
+
* - only catalog entries can be installed, and only at the catalog's exact version;
|
|
290
|
+
* - the spec is always built as `name@exactVersion`, never taken from outside the catalog;
|
|
291
|
+
* - inspect() must answer with the same name and version we asked for.
|
|
292
|
+
*/
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
/** Plain, exact install spec for one catalog entry. */
|
|
296
|
+
function specOf(entry) {
|
|
297
|
+
return `${entry.npm}@${entry.version}`
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Expand the requested ids with their `requires`, dependencies first, without duplicates.
|
|
302
|
+
* Unknown ids and cycles throw: the catalog validator already forbids them, this is the belt to its braces.
|
|
303
|
+
*/
|
|
304
|
+
function resolvePlan(catalog, wantedIds) {
|
|
305
|
+
const byId = new Map(catalog.plugins.map((p) => [p.id, p]))
|
|
306
|
+
const out = []
|
|
307
|
+
const done = new Set()
|
|
308
|
+
const visiting = new Set()
|
|
309
|
+
const visit = (id) => {
|
|
310
|
+
const p = byId.get(id)
|
|
311
|
+
if (!p) throw new Error(`not in catalog: ${id}`)
|
|
312
|
+
if (done.has(id)) return
|
|
313
|
+
if (visiting.has(id)) throw new Error(`dependency cycle at ${id}`)
|
|
314
|
+
visiting.add(id)
|
|
315
|
+
for (const d of p.requires ?? []) visit(d)
|
|
316
|
+
visiting.delete(id)
|
|
317
|
+
done.add(id)
|
|
318
|
+
out.push(p)
|
|
319
|
+
}
|
|
320
|
+
for (const id of wantedIds) visit(id)
|
|
321
|
+
return out
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* Installation-provided packages have no profile-owned source and cannot be removed. A host that reports `application`
|
|
326
|
+
* (VibeDev Next from 0.2.1-alpha.2.20261011.3) also lets the app's own packages be updated in the profile.
|
|
327
|
+
*/
|
|
328
|
+
function providedByApp(bundle) {
|
|
329
|
+
return !!applicationCopy(bundle) || bundle?.readOnlyReason === 'application-owned' || bundle?.removable === false && !bundle.source
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* The two copies of an app-owned package, when the host can update it: `shipped` is the floor, a newer compatible
|
|
334
|
+
* `local` copy the profile installed is `selected` from the next start, and removing it returns to the shipped one.
|
|
335
|
+
* @returns {{shipped?: string, local?: string, selected: 'installation'|'profile', reason?: string} | undefined}
|
|
336
|
+
*/
|
|
337
|
+
function applicationCopy(bundle) {
|
|
338
|
+
const a = bundle?.application
|
|
339
|
+
return a && typeof a === 'object' && (a.selected === 'installation' || a.selected === 'profile') ? a : undefined
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
/** An app-owned package whose newer release this host installs into the profile (it takes over at the next start). */
|
|
343
|
+
function updatableBuiltIn(bundle) {
|
|
344
|
+
return !!applicationCopy(bundle)
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
/** The profile is running (or will run from the next start) an update of an app-owned package, not the shipped copy. */
|
|
348
|
+
function runsUpdatedCopy(bundle) {
|
|
349
|
+
return applicationCopy(bundle)?.selected === 'profile'
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/** Presence includes installation-provided bundles, not only profile dependencies. */
|
|
353
|
+
function bundlePresent(bundle) {
|
|
354
|
+
return !!bundle?.installed || providedByApp(bundle)
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
/** A shipped bundle can run through a default layer without being selected in the profile. */
|
|
358
|
+
async function readBundleInventory(pm) {
|
|
359
|
+
const result = await pm.listBundles()
|
|
360
|
+
if (!result?.ok || !result.value.some(providedByApp)) return result
|
|
361
|
+
let plugins
|
|
362
|
+
try {
|
|
363
|
+
const answer = await pm.listPlugins()
|
|
364
|
+
if (answer?.ok) plugins = answer.value
|
|
365
|
+
} catch { /* Still recognise the shipped package; never install a second copy to recover a failed read. */ }
|
|
366
|
+
return { ...result, value: result.value.map((b) => !providedByApp(b) ? b : {
|
|
367
|
+
...b,
|
|
368
|
+
enabled: !b.error && (!!b.enabled || !!plugins?.some((p) => p.enabled && (b.rows ?? []).some((row) =>
|
|
369
|
+
row.entryId === p.entryId && row.moduleName === p.moduleName))),
|
|
370
|
+
}) }
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
/** Whether a plan row needs work, including a legacy copy beside the new built-in package. */
|
|
374
|
+
function needsInstall(row, update = false) {
|
|
375
|
+
return update || !(row.installed && row.enabled) || !!(row.provided && row.legacy)
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* Which of the planned plugins are already present, by npm name. `provided` means the application owns the package.
|
|
380
|
+
* A row also names a profile-owned older package (`legacy`), so installing it switches over instead of running both.
|
|
381
|
+
*/
|
|
382
|
+
function markInstalled(plan, bundles) {
|
|
383
|
+
const have = new Map((bundles ?? []).filter(bundlePresent).map((b) => [b.name, b]))
|
|
384
|
+
return plan.map((p) => {
|
|
385
|
+
const b = have.get(p.npm)
|
|
386
|
+
const legacy = (p.legacyNames ?? []).find((name) => have.get(name)?.installed && !providedByApp(have.get(name)))
|
|
387
|
+
return {
|
|
388
|
+
entry: p, installed: !!b, enabled: !!b?.enabled, installedVersion: b?.version,
|
|
389
|
+
...(providedByApp(b) ? { provided: true } : {}),
|
|
390
|
+
...(updatableBuiltIn(b) ? { updatable: true } : {}),
|
|
391
|
+
...(legacy ? { legacy, legacyEnabled: !!have.get(legacy).enabled } : {}),
|
|
392
|
+
}
|
|
393
|
+
})
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* Turn whatever the host returned into ONE shape the UI can render.
|
|
398
|
+
* kinds: ok | restart | network | builds | incompat | notfound | exempt | halfRemoved | refused | failed
|
|
399
|
+
*/
|
|
400
|
+
function classifyFailure(result) {
|
|
401
|
+
const err = result?.error
|
|
402
|
+
const log = `${result?.packageResult?.output ?? ''}\n${err?.diagnostic ?? ''}`
|
|
403
|
+
const kind = result?.packageResult?.kind
|
|
404
|
+
if (result?.pendingBuilds?.length || kind === 'build-blocked') return { kind: 'builds', pendingBuilds: result.pendingBuilds ?? [] }
|
|
405
|
+
if (err?.code === 'incompatible-version') return { kind: 'incompat', incompatible: err.incompatible ?? result?.packageResult?.incompatible ?? [] }
|
|
406
|
+
// The pnpm release-age cooldown: it blocks EVERY install/uninstall until the version is a day old.
|
|
407
|
+
if (/ERR_PNPM_MINIMUM_RELEASE_AGE_VIOLATION|minimumReleaseAge/.test(log)) {
|
|
408
|
+
const m = /([@\w./-]+@[\w.-]+) was published at ([0-9T:.\-]+Z)/.exec(log)
|
|
409
|
+
return { kind: 'exempt', culprit: m?.[1], publishedAt: m?.[2] }
|
|
410
|
+
}
|
|
411
|
+
if (kind === 'network' || kind === 'timeout') return { kind: 'network', registries: result?.registries, diagnostic: err?.diagnostic ?? '' }
|
|
412
|
+
if (kind === 'not-found' || kind === 'no-matching-version') return { kind: 'notfound' }
|
|
413
|
+
if (err?.code === 'stop-profile' || err?.code === 'bundle-in-use') return { kind: 'busy', code: err.code }
|
|
414
|
+
return { kind: 'failed', code: err?.code, diagnostic: err?.diagnostic ?? result?.packageResult?.output ?? '' }
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
/** When the pnpm cooldown for a version ends: publishedAt + 24 h. */
|
|
418
|
+
function cooldownEnds(publishedAtIso) {
|
|
419
|
+
const t = Date.parse(publishedAtIso)
|
|
420
|
+
return Number.isFinite(t) ? new Date(t + 24 * 3600 * 1000) : undefined
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
let seq = 0
|
|
424
|
+
const newRequestId = () => `eco-${Date.now().toString(36)}-${(seq++).toString(36)}`
|
|
425
|
+
|
|
426
|
+
/* ── registry choice: the same rule as the official Plugins page ─────────────────────────────
|
|
427
|
+
* The host's registries() answers { registry, fallbackRegistries, resolved }. The page only considers the
|
|
428
|
+
* China mirror when pnpm's own default resolves to the OFFICIAL npm registry (a user whose default is already
|
|
429
|
+
* a mirror is left alone), and then only switches to it when the host's probe says the mirror is the fastest. */
|
|
430
|
+
const NPMJS = 'https://registry.npmjs.org/'
|
|
431
|
+
const NPMMIRROR = 'https://registry.npmmirror.com/'
|
|
432
|
+
const normReg = (u) => { try { const x = new URL(u); return `${x.protocol}//${x.host.toLowerCase()}${x.pathname.replace(/\/?$/, '/')}` } catch { return undefined } }
|
|
433
|
+
|
|
434
|
+
function eligibleMirror(regs) {
|
|
435
|
+
if (!regs || regs.registry !== null || regs.resolved == null) return undefined
|
|
436
|
+
if (normReg(regs.resolved) !== NPMJS) return undefined
|
|
437
|
+
return (regs.fallbackRegistries ?? []).find((r) => r === NPMMIRROR)
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
/** The registry to ask first, or null for "whatever pnpm is configured with". Never throws, never waits long. */
|
|
441
|
+
async function chooseRegistry(pm, probe, opts = {}) {
|
|
442
|
+
const ms = opts.timeoutMs ?? 8000
|
|
443
|
+
const capped = (p) => { let t; return Promise.race([Promise.resolve(p), new Promise((r) => { t = setTimeout(() => r(undefined), ms) })]).finally(() => clearTimeout(t)) }
|
|
444
|
+
try {
|
|
445
|
+
const regs = await capped(pm?.registries?.())
|
|
446
|
+
if (!regs?.ok) return null
|
|
447
|
+
const mirror = eligibleMirror(regs.value)
|
|
448
|
+
if (!mirror || typeof probe?.fastest !== 'function') return null
|
|
449
|
+
const f = await capped(probe.fastest())
|
|
450
|
+
return f?.ok && f.value === mirror ? mirror : null
|
|
451
|
+
} catch { return null }
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
/* ── "is there a newer version of the center itself?" ─────────────────────────────────────────────────────────
|
|
455
|
+
* The catalog is bundled in the package, so the center cannot learn about its own newer release from it. The host half
|
|
456
|
+
* reads npm once, only when the user asks (index.js /vdc/latest); this turns that answer into what the screen says.
|
|
457
|
+
* `answer` is the JSON of /vdc/latest, or undefined when the request itself failed.
|
|
458
|
+
* -> {kind:'newer'|'same'|'ahead'|'unavailable', latest?, publishedAt?, sources?} */
|
|
459
|
+
function judgeSelfUpdate(current, answer) {
|
|
460
|
+
// The host half already vets the version; this second check keeps a malformed one from ever reaching a link or the screen.
|
|
461
|
+
if (!answer || answer.ok !== true || typeof answer.latest !== 'string' || !/^\d+\.\d+\.\d+(-[0-9A-Za-z.-]+)?$/.test(answer.latest)) return { kind: 'unavailable', sources: answer?.sources ?? [] }
|
|
462
|
+
const c = compareSemver(current, answer.latest)
|
|
463
|
+
return { kind: c < 0 ? 'newer' : c === 0 ? 'same' : 'ahead', latest: answer.latest, publishedAt: answer.publishedAt, from: answer.from, sources: answer.sources ?? [] }
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
/** pnpm holds back a version younger than 24 h. {active, endsAt} for an ISO publish time; never throws. */
|
|
467
|
+
function cooldownState(publishedAtIso, now = Date.now()) {
|
|
468
|
+
const endsAt = cooldownEnds(publishedAtIso)
|
|
469
|
+
return endsAt === undefined ? { active: false, endsAt: undefined } : { active: now < endsAt.getTime(), endsAt }
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
/* ── plugins replaced underneath a running page (the cause of the desktop boot crash) ───────────────────────────────
|
|
473
|
+
* Verified on a real machine, twice: the desktop shell hands the page the plugin list (script URLs with a revision that is
|
|
474
|
+
* a hash of each bundle's mtime, ctime and size) that the Host produced WHEN VIBEDEV STARTED, and reuses it for every
|
|
475
|
+
* reload. The Host serves only the CURRENT revision, so a plugin whose files changed since then (uninstalled and
|
|
476
|
+
* installed again, or updated) is requested under its old revision, gets a 404, and the shell reports "N entries did not
|
|
477
|
+
* activate". Plugins that were merely installed for the first time while VibeDev was running are fine, and so is removal
|
|
478
|
+
* alone. So the dangerous events are: a plugin whose version changed, and a plugin that disappeared and came back.
|
|
479
|
+
* state = {prev: {name: version} | null, removed: [name], dirty: [name]}; pure, returns the next state. */
|
|
480
|
+
function trackLoadedChanges(state, bundles) {
|
|
481
|
+
const cur = {}
|
|
482
|
+
for (const b of bundles ?? []) if (b?.installed && typeof b.name === 'string') cur[b.name] = String(b.version ?? '')
|
|
483
|
+
const prev = state?.prev ?? null
|
|
484
|
+
if (prev === null) return { prev: cur, removed: [], dirty: [] } // the first look is the baseline, never an alarm
|
|
485
|
+
const removed = new Set(state.removed ?? [])
|
|
486
|
+
const dirty = new Set(state.dirty ?? [])
|
|
487
|
+
for (const name of Object.keys(prev)) if (!(name in cur)) removed.add(name)
|
|
488
|
+
for (const name of Object.keys(cur)) {
|
|
489
|
+
if (name in prev && prev[name] !== cur[name]) dirty.add(name) // updated or downgraded in place
|
|
490
|
+
else if (!(name in prev) && removed.has(name)) dirty.add(name) // came back after being removed
|
|
491
|
+
}
|
|
492
|
+
return { prev: cur, removed: [...removed], dirty: [...dirty] }
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
/* ── a courtesy pause between plugins and before saying "done" ───────────────────────────────────────────────────
|
|
496
|
+
* NOT the fix for the boot crash. That crash is not about timing at all: see trackLoadedChanges below (the desktop
|
|
497
|
+
* page boots from a plugin list taken when VibeDev STARTED, so reloading after a plugin was replaced fails whether it
|
|
498
|
+
* happens 5 seconds or 5 hours later). This only lets the host settle so the done screen is not shown while it is still
|
|
499
|
+
* busy. It waits until no change event has arrived for `quietMs` (never longer than `maxMs`). */
|
|
500
|
+
function waitQuiet(subscribe, opts = {}) {
|
|
501
|
+
const quietMs = opts.quietMs ?? 2000
|
|
502
|
+
const maxMs = opts.maxMs ?? 10000
|
|
503
|
+
return new Promise((resolve) => {
|
|
504
|
+
let quiet, cap, off
|
|
505
|
+
const done = () => { clearTimeout(quiet); clearTimeout(cap); try { if (typeof off === 'function') off() } catch { /* ignore */ } resolve() }
|
|
506
|
+
const arm = () => { clearTimeout(quiet); quiet = setTimeout(done, quietMs) }
|
|
507
|
+
try { off = typeof subscribe === 'function' ? subscribe(arm) : undefined } catch { off = undefined }
|
|
508
|
+
arm()
|
|
509
|
+
cap = setTimeout(done, maxMs)
|
|
510
|
+
})
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
/* ── readable text on the host's brand colour ─────────────────────────────────────────────────
|
|
514
|
+
* The host's brand colour is near-black in the light theme and (very likely) light in the dark one, so a fixed
|
|
515
|
+
* white label on primary buttons would vanish. Pick whichever of black/white has the higher WCAG contrast. */
|
|
516
|
+
function readableTextOn(bg) {
|
|
517
|
+
const m = /rgba?\(\s*(\d+)[\s,]+(\d+)[\s,]+(\d+)/.exec(String(bg ?? ''))
|
|
518
|
+
if (!m) return '#fff'
|
|
519
|
+
const [r, g, b] = [m[1], m[2], m[3]].map((v) => { const c = Number(v) / 255; return c <= 0.03928 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4) })
|
|
520
|
+
const L = 0.2126 * r + 0.7152 * g + 0.0722 * b
|
|
521
|
+
return 1.05 / (L + 0.05) >= (L + 0.05) / 0.05 ? '#fff' : '#000'
|
|
522
|
+
}
|
|
523
|
+
function contrastRatio(fg, bg) {
|
|
524
|
+
const lum = (s) => { const m = /rgba?\(\s*(\d+)[\s,]+(\d+)[\s,]+(\d+)/.exec(s); if (!m) return undefined; const [r, g, b] = [m[1], m[2], m[3]].map((v) => { const c = Number(v) / 255; return c <= 0.03928 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4) }); return 0.2126 * r + 0.7152 * g + 0.0722 * b }
|
|
525
|
+
const a = lum(fg), b = lum(bg)
|
|
526
|
+
if (a === undefined || b === undefined) return undefined
|
|
527
|
+
const [hi, lo] = a >= b ? [a, b] : [b, a]
|
|
528
|
+
return (hi + 0.05) / (lo + 0.05)
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
/**
|
|
532
|
+
* Install one entry: inspect -> install (not enabled) -> enable.
|
|
533
|
+
* Never throws; always resolves to {status, ...}. status:
|
|
534
|
+
* 'done' installed and enabled (applied)
|
|
535
|
+
* 'restart' installed, needs an app restart to take effect
|
|
536
|
+
* 'skipped' already installed (and enabled)
|
|
537
|
+
* 'enabledOnly' was installed but disabled; we enabled it
|
|
538
|
+
* 'failed' with .failure = classifyFailure(...) or {kind:'refused'|'mismatch', ...}
|
|
539
|
+
* 'cancelled'
|
|
540
|
+
* `hooks.onStep(step)` is told 'inspect' | 'install' | 'enable' so the UI can show progress.
|
|
541
|
+
*
|
|
542
|
+
* When an older name of the plugin is installed (`state.legacy`, from markInstalled), turning the new one on switches
|
|
543
|
+
* over exactly as migrate() does: the steps 'disable-old' and 'remove-old' surround 'enable', a failed enable turns the
|
|
544
|
+
* old one back on (`restoredOld`), and an old one that could not be removed is reported as `legacyLeft`.
|
|
545
|
+
*/
|
|
546
|
+
async function installOne(pm, entry, state, opts = {}) {
|
|
547
|
+
const hooks = opts.hooks ?? {}
|
|
548
|
+
const registry = opts.registry ?? null
|
|
549
|
+
const approved = opts.approvedBuilds
|
|
550
|
+
const update = opts.update === true
|
|
551
|
+
const step = (s, detail) => hooks.onStep?.(s, entry, detail)
|
|
552
|
+
const requestId = newRequestId()
|
|
553
|
+
hooks.onRequest?.(requestId, entry)
|
|
554
|
+
|
|
555
|
+
if (state?.provided) {
|
|
556
|
+
if (update && state.updatable) return updateBuiltIn(pm, entry.npm, entry.version, { ...opts, hooks, requestId })
|
|
557
|
+
if (update || !state.enabled) return { status: 'failed', failure: { kind: 'provided' } }
|
|
558
|
+
if (!state.legacy) return { status: 'skipped' }
|
|
559
|
+
const moved = await migrate(pm, entry, state.legacy, opts)
|
|
560
|
+
return moved.status === 'halfRemoved' ? { status: 'done', legacyLeft: state.legacy } : moved
|
|
561
|
+
}
|
|
562
|
+
if (!update && state?.installed && state?.enabled) return { status: 'skipped' }
|
|
563
|
+
if (!update && state?.installed && !state?.enabled) {
|
|
564
|
+
const on = await switchOn(pm, entry, state, step)
|
|
565
|
+
if (!on.ok) return { status: 'failed', ...on.failed }
|
|
566
|
+
return { status: on.value?.application === 'restart-required' ? 'restart' : 'enabledOnly', ...on.left }
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
step('inspect')
|
|
570
|
+
const ins = await pm.inspect(specOf(entry), { registry })
|
|
571
|
+
if (!ins?.ok) return { status: 'failed', failure: { kind: 'network', diagnostic: ins?.error?.message ?? 'inspect failed' } }
|
|
572
|
+
const v = ins.value
|
|
573
|
+
// The host's inspect refuses by NAME when the package is installed, whatever the version.
|
|
574
|
+
// For a fresh install that means "nothing to do"; for an UPDATE it is the expected answer and we go on.
|
|
575
|
+
const installedAlready = v.status === 'refused' && v.problem === 'already-installed'
|
|
576
|
+
if (v.status === 'refused' && !(update && installedAlready)) {
|
|
577
|
+
if (installedAlready) return { status: 'skipped' }
|
|
578
|
+
return { status: 'failed', failure: { kind: v.problem === 'network' ? 'network' : v.problem === 'not-found' ? 'notfound' : 'refused', problem: v.problem, diagnostic: v.reason, registries: v.registries } }
|
|
579
|
+
}
|
|
580
|
+
if (v.status === 'accepted' && (v.name !== entry.npm || (v.version && v.version !== entry.version) || v.bundle === false)) {
|
|
581
|
+
// The registry answered with something other than what the catalog promised. Do not install it.
|
|
582
|
+
return { status: 'failed', failure: { kind: 'mismatch', diagnostic: `expected ${specOf(entry)}, registry says ${v.name}@${v.version}${v.bundle === false ? ' (not a bundle)' : ''}` } }
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
step('install')
|
|
586
|
+
const inst = await pm.installBundle(specOf(entry), {
|
|
587
|
+
enabled: false,
|
|
588
|
+
requestId,
|
|
589
|
+
registry: (v.status === 'accepted' ? v.registry : null) ?? registry,
|
|
590
|
+
...(approved?.length ? { approvedBuilds: approved } : {}),
|
|
591
|
+
})
|
|
592
|
+
if (!inst?.ok) return { status: 'failed', failure: { kind: 'failed', diagnostic: inst?.error?.message ?? 'install call failed' }, requestId, uncertain: true }
|
|
593
|
+
const iv = inst.value
|
|
594
|
+
if (iv.application === 'cancelled') return { status: 'cancelled' }
|
|
595
|
+
// DSH from 0.2.1-alpha.3 with HMR refuses to install over a package the profile already has, changing nothing.
|
|
596
|
+
if (update && iv.application === 'failed' && iv.error?.code === 'already-installed') {
|
|
597
|
+
return replaceInstalled(pm, entry, { step, requestId, registry: (v.status === 'accepted' ? v.registry : null) ?? registry, approved })
|
|
598
|
+
}
|
|
599
|
+
if (iv.application === 'failed') return { status: 'failed', failure: classifyFailure(iv), requestId }
|
|
600
|
+
if (iv.application === 'overridden') return { status: 'failed', failure: { kind: 'failed', diagnostic: 'overridden by profile configuration' } }
|
|
601
|
+
|
|
602
|
+
// An update of something the user had switched off must stay off.
|
|
603
|
+
if (update && state?.enabled === false) return { status: iv.application === 'restart-required' ? 'restart' : 'done' }
|
|
604
|
+
|
|
605
|
+
const on = await switchOn(pm, entry, update ? undefined : state, step)
|
|
606
|
+
if (!on.ok) return { status: 'failed', ...on.failed, installedNotEnabled: true }
|
|
607
|
+
// Replacing an already-installed package only loads the new code after a restart; say so even if the host stayed quiet.
|
|
608
|
+
const restart = iv.application === 'restart-required' || on.value?.application === 'restart-required' || update
|
|
609
|
+
return { status: restart ? 'restart' : 'done', ...on.left }
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
const EXACT_VERSION = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/
|
|
613
|
+
|
|
614
|
+
/**
|
|
615
|
+
* Update an installed package on a host that will not install over it (DSH from 0.2.1-alpha.3 with HMR, where removing
|
|
616
|
+
* a bundle stops its plugins and the next version starts afresh): read the installed copy, remove it, install the
|
|
617
|
+
* catalog's exact version switched off, and switch it on only if the removed one was on. Nothing is removed unless the
|
|
618
|
+
* installed copy has an exact version to put back. When the new version does not install (failed, cancelled, or the
|
|
619
|
+
* connection dropped), the removed version is installed again at that exact version and switched on as it was
|
|
620
|
+
* (`restoredPrevious`); when that fails too, the answer names the exact spec to install by hand (`previousLost`,
|
|
621
|
+
* `previousSpec`). Never throws; resolves like installOne.
|
|
622
|
+
*/
|
|
623
|
+
async function replaceInstalled(pm, entry, { step, requestId, registry, approved }) {
|
|
624
|
+
const list = await pm.listBundles()
|
|
625
|
+
const current = list?.ok ? list.value.find((b) => b.name === entry.npm && b.installed) : undefined
|
|
626
|
+
if (!current || typeof current.version !== 'string' || !EXACT_VERSION.test(current.version)) {
|
|
627
|
+
return { status: 'failed', failure: { kind: 'failed', code: 'already-installed', diagnostic: `${entry.npm}: the installed version could not be read, so it was not replaced` } }
|
|
628
|
+
}
|
|
629
|
+
const wasEnabled = !!current.enabled
|
|
630
|
+
const previousSpec = `${entry.npm}@${current.version}`
|
|
631
|
+
step('remove-current', previousSpec)
|
|
632
|
+
const rm = await pm.removeBundle(entry.npm)
|
|
633
|
+
if (!rm?.ok || rm.value?.application === 'failed') {
|
|
634
|
+
// The host disables before it removes, so a failed removal can leave the old version installed but switched off.
|
|
635
|
+
if (wasEnabled) await pm.setBundleEnabled(entry.npm, true)
|
|
636
|
+
return rm?.ok
|
|
637
|
+
? { status: 'failed', failure: classifyFailure(rm.value) }
|
|
638
|
+
: { status: 'failed', failure: { kind: 'failed', diagnostic: rm?.error?.message ?? 'remove call failed' }, uncertain: true }
|
|
639
|
+
}
|
|
640
|
+
step('install', specOf(entry))
|
|
641
|
+
const inst = await pm.installBundle(specOf(entry), { enabled: false, requestId, registry, ...(approved?.length ? { approvedBuilds: approved } : {}) })
|
|
642
|
+
const iv = inst?.ok ? inst.value : undefined
|
|
643
|
+
if (!iv || iv.application === 'failed' || iv.application === 'cancelled' || iv.application === 'overridden') {
|
|
644
|
+
const failure = !iv ? { kind: 'failed', diagnostic: inst?.error?.message ?? 'install call failed' }
|
|
645
|
+
: iv.application === 'failed' ? classifyFailure(iv)
|
|
646
|
+
: iv.application === 'overridden' ? { kind: 'failed', diagnostic: 'overridden by profile configuration' } : undefined
|
|
647
|
+
const back = await restorePrevious(pm, entry.npm, previousSpec, wasEnabled, step, registry)
|
|
648
|
+
return { status: iv?.application === 'cancelled' ? 'cancelled' : 'failed', ...(failure ? { failure } : {}), requestId, ...back }
|
|
649
|
+
}
|
|
650
|
+
if (!wasEnabled) return { status: iv.application === 'restart-required' ? 'restart' : 'done', replaced: true }
|
|
651
|
+
const on = await switchOn(pm, entry, undefined, step)
|
|
652
|
+
if (!on.ok) return { status: 'failed', ...on.failed, installedNotEnabled: true }
|
|
653
|
+
// The page keeps the plugin list from the app start, so replaced code is only loaded reliably after a restart.
|
|
654
|
+
return { status: 'restart', replaced: true }
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
/**
|
|
658
|
+
* Install a removed version again at its exact spec and switch it on as it was. Never throws.
|
|
659
|
+
* -> {restoredPrevious, previousSpec, installedNotEnabled?} | {previousLost, previousSpec, uncertain?} | {uncertain}
|
|
660
|
+
*/
|
|
661
|
+
async function restorePrevious(pm, name, previousSpec, wasEnabled, step, registry) {
|
|
662
|
+
step('restore', previousSpec)
|
|
663
|
+
const back = await pm.installBundle(previousSpec, { enabled: false, requestId: newRequestId(), registry })
|
|
664
|
+
if (!back?.ok) return { previousLost: true, previousSpec, uncertain: true }
|
|
665
|
+
const bv = back.value
|
|
666
|
+
// Refused as already installed: the new version landed after all, so nothing was lost, but its state is not known here.
|
|
667
|
+
if (bv?.application === 'failed' && bv.error?.code === 'already-installed') return { uncertain: true }
|
|
668
|
+
if (!bv || bv.application === 'failed' || bv.application === 'cancelled' || bv.application === 'overridden') return { previousLost: true, previousSpec }
|
|
669
|
+
if (wasEnabled) {
|
|
670
|
+
const en = await pm.setBundleEnabled(name, true)
|
|
671
|
+
if (!en?.ok || en.value?.application === 'failed') return { restoredPrevious: true, previousSpec, installedNotEnabled: true }
|
|
672
|
+
}
|
|
673
|
+
return { restoredPrevious: true, previousSpec }
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
/**
|
|
677
|
+
* The unmet DSH requirements of one package a host refused as incompatible, as [key, range] pairs: `requirements` from
|
|
678
|
+
* DSH 0.2.1-alpha.4 (keyed `engines.dsh` or by DSH peer package name), else the `peers` of earlier hosts.
|
|
679
|
+
* @param item - one entry of `error.incompatible`.
|
|
680
|
+
* @returns the pairs with a text range, in the host's order; none for anything unreadable.
|
|
681
|
+
*/
|
|
682
|
+
function incompatibleRequirements(item) {
|
|
683
|
+
const reqs = item?.requirements ?? item?.peers
|
|
684
|
+
if (!reqs || typeof reqs !== 'object' || Array.isArray(reqs)) return []
|
|
685
|
+
return Object.entries(reqs).filter(([, range]) => typeof range === 'string')
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
/**
|
|
689
|
+
* Update an app-owned package (this center itself, or the account plugin): its exact newer version goes into the profile
|
|
690
|
+
* beside the shipped copy, unselected (the app's own layers keep running the package), and replaces the shipped copy
|
|
691
|
+
* when VibeDev Next next starts. Never throws; resolves like installOne, with status 'restart' on success.
|
|
692
|
+
* @param pm - the host's plugin manager.
|
|
693
|
+
* @param name - package name.
|
|
694
|
+
* @param version - the exact version to install (must be newer than the shipped one; the host refuses anything else).
|
|
695
|
+
* @param opts - { registry, hooks, requestId }.
|
|
696
|
+
*/
|
|
697
|
+
async function updateBuiltIn(pm, name, version, opts = {}) {
|
|
698
|
+
const hooks = opts.hooks ?? {}
|
|
699
|
+
const spec = `${name}@${version}`
|
|
700
|
+
const step = (s) => hooks.onStep?.(s, { npm: name, version })
|
|
701
|
+
const registry = opts.registry ?? null
|
|
702
|
+
step('inspect')
|
|
703
|
+
const ins = await pm.inspect(spec, { registry })
|
|
704
|
+
if (!ins?.ok) return { status: 'failed', failure: { kind: 'network', diagnostic: ins?.error?.message ?? 'inspect failed' } }
|
|
705
|
+
const v = ins.value
|
|
706
|
+
if (v.status === 'refused') {
|
|
707
|
+
// 'already-installed' here means the host will not take this version as an update (not newer than the shipped one).
|
|
708
|
+
return { status: 'failed', failure: { kind: v.problem === 'network' ? 'network' : v.problem === 'not-found' ? 'notfound' : 'refused', problem: v.problem, diagnostic: v.reason, registries: v.registries } }
|
|
709
|
+
}
|
|
710
|
+
if (v.name !== name || (v.version && v.version !== version) || v.bundle === false) {
|
|
711
|
+
return { status: 'failed', failure: { kind: 'mismatch', diagnostic: `expected ${spec}, registry says ${v.name}@${v.version}` } }
|
|
712
|
+
}
|
|
713
|
+
step('install')
|
|
714
|
+
const requestId = opts.requestId ?? newRequestId()
|
|
715
|
+
const inst = await pm.installBundle(spec, { enabled: false, saveExact: true, requestId, registry: v.registry ?? registry })
|
|
716
|
+
if (!inst?.ok) return { status: 'failed', failure: { kind: 'failed', diagnostic: inst?.error?.message ?? 'install call failed' }, requestId, uncertain: true }
|
|
717
|
+
const iv = inst.value
|
|
718
|
+
if (iv.application === 'cancelled') return { status: 'cancelled' }
|
|
719
|
+
if (iv.application === 'failed') return { status: 'failed', failure: classifyFailure(iv), requestId }
|
|
720
|
+
return { status: 'restart', builtIn: true }
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
/**
|
|
724
|
+
* Return an app-owned package to the copy shipped with the app: the profile's own copy is removed, and the shipped one
|
|
725
|
+
* runs again from the next start. Never throws.
|
|
726
|
+
*/
|
|
727
|
+
async function restoreBuiltIn(pm, name) {
|
|
728
|
+
const r = await pm.removeBundle(name)
|
|
729
|
+
if (!r?.ok) return { status: 'failed', failure: { kind: 'failed', diagnostic: r?.error?.message ?? 'remove failed' } }
|
|
730
|
+
if (r.value?.application === 'failed') return { status: 'failed', failure: classifyFailure(r.value) }
|
|
731
|
+
return { status: 'restart', builtIn: true }
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
/**
|
|
735
|
+
* Enable an installed entry; with an older name of it installed, switch over in migrate()'s order (see installOne).
|
|
736
|
+
* -> {ok: true, value, left} | {ok: false, failed}, where `left` and `failed` are spread into installOne's answer.
|
|
737
|
+
*/
|
|
738
|
+
async function switchOn(pm, entry, state, step) {
|
|
739
|
+
const legacy = state?.legacy
|
|
740
|
+
if (legacy) {
|
|
741
|
+
step('disable-old')
|
|
742
|
+
// Two packages registering the same tools and services crash the plugin tree: the old one goes off first.
|
|
743
|
+
const off = await pm.setBundleEnabled(legacy, false)
|
|
744
|
+
if (!off?.ok) return { ok: false, failed: { failure: { kind: 'failed', diagnostic: off?.error?.message ?? 'could not disable the old package' }, oldStillEnabled: true } }
|
|
745
|
+
if (off.value?.application === 'failed') return { ok: false, failed: { failure: classifyFailure(off.value), oldStillEnabled: true } }
|
|
746
|
+
}
|
|
747
|
+
step('enable')
|
|
748
|
+
const en = await pm.setBundleEnabled(entry.npm, true)
|
|
749
|
+
if (!en?.ok || en.value?.application === 'failed') {
|
|
750
|
+
const failure = en?.ok ? classifyFailure(en.value) : { kind: 'failed', diagnostic: en?.error?.message ?? 'enable failed' }
|
|
751
|
+
if (!legacy || state.legacyEnabled === false) return { ok: false, failed: { failure } }
|
|
752
|
+
// Put the old one back so the user is not left with neither.
|
|
753
|
+
await pm.setBundleEnabled(legacy, true)
|
|
754
|
+
return { ok: false, failed: { failure, restoredOld: true } }
|
|
755
|
+
}
|
|
756
|
+
if (!legacy) return { ok: true, value: en.value, left: {} }
|
|
757
|
+
step('remove-old')
|
|
758
|
+
const rm = await pm.removeBundle(legacy)
|
|
759
|
+
return { ok: true, value: en.value, left: !rm?.ok || rm.value?.application === 'failed' ? { legacyLeft: legacy } : {} }
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
/**
|
|
763
|
+
* Run a whole plan, in order, one plugin at a time, and STOP at the first failure
|
|
764
|
+
* (what is already installed stays; nothing after it is touched).
|
|
765
|
+
* `rows` = markInstalled(...). Returns {results:[{id,status,...}], stoppedAt?}
|
|
766
|
+
*/
|
|
767
|
+
async function installPlan(pm, rows, opts = {}) {
|
|
768
|
+
const results = []
|
|
769
|
+
let stoppedAt
|
|
770
|
+
for (const row of rows) {
|
|
771
|
+
if (opts.signal?.aborted) { stoppedAt = row.entry.id; results.push({ id: row.entry.id, status: 'cancelled' }); break }
|
|
772
|
+
opts.hooks?.onPluginStart?.(row.entry)
|
|
773
|
+
const r = await installOne(pm, row.entry, row, { ...opts, approvedBuilds: opts.approvedBuilds?.[row.entry.id] })
|
|
774
|
+
results.push({ id: row.entry.id, ...r })
|
|
775
|
+
opts.hooks?.onPluginEnd?.(row.entry, r)
|
|
776
|
+
if (r.status === 'failed' || r.status === 'cancelled') { stoppedAt = row.entry.id; break }
|
|
777
|
+
}
|
|
778
|
+
return { results, stoppedAt }
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
/**
|
|
782
|
+
* Migration from a legacy package name to the current one, in the only safe order:
|
|
783
|
+
* 1. install the new package WITHOUT enabling it
|
|
784
|
+
* 2. disable the old one (two packages registering the same routes/viewers crash the plugin tree)
|
|
785
|
+
* 3. enable the new one
|
|
786
|
+
* 4. only then remove the old one (and a failure here is reported, not hidden: the old one is already disabled)
|
|
787
|
+
*/
|
|
788
|
+
async function migrate(pm, entry, legacyName, opts = {}) {
|
|
789
|
+
const hooks = opts.hooks ?? {}
|
|
790
|
+
const say = (s) => hooks.onStep?.(s, entry)
|
|
791
|
+
const inventory = await readBundleInventory(pm)
|
|
792
|
+
if (!inventory?.ok) return { status: 'failed', phase: 'inspect', failure: { kind: 'network', diagnostic: 'could not read current bundles' } }
|
|
793
|
+
const supplied = inventory.value.find((b) => b.name === entry.npm && providedByApp(b))
|
|
794
|
+
const old = inventory.value.find((b) => b.name === legacyName)
|
|
795
|
+
if (providedByApp(old) || supplied && !supplied.enabled) return { status: 'failed', phase: 'inspect', failure: { kind: 'provided' } }
|
|
796
|
+
if (!supplied) {
|
|
797
|
+
say('inspect')
|
|
798
|
+
const ins = await pm.inspect(specOf(entry), { registry: opts.registry ?? null })
|
|
799
|
+
if (!ins?.ok || ins.value.status === 'refused' && ins.value.problem !== 'already-installed') {
|
|
800
|
+
return { status: 'failed', phase: 'inspect', failure: { kind: 'network', diagnostic: ins?.error?.message ?? ins?.value?.reason } }
|
|
801
|
+
}
|
|
802
|
+
if (!(ins.value.status === 'refused' && ins.value.problem === 'already-installed')) {
|
|
803
|
+
say('install')
|
|
804
|
+
const inst = await pm.installBundle(specOf(entry), { enabled: false, requestId: newRequestId(), registry: ins.value.registry ?? null })
|
|
805
|
+
if (!inst?.ok || inst.value.application === 'failed') return { status: 'failed', phase: 'install', failure: classifyFailure(inst?.value ?? {}) }
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
say('disable-old')
|
|
809
|
+
const off = await pm.setBundleEnabled(legacyName, false)
|
|
810
|
+
if (!off?.ok || off.value?.application === 'failed') return { status: 'failed', phase: 'disable-old', failure: { kind: 'failed', diagnostic: off?.error?.message ?? 'could not disable the old package' }, oldStillEnabled: true }
|
|
811
|
+
if (!supplied) {
|
|
812
|
+
say('enable')
|
|
813
|
+
const on = await pm.setBundleEnabled(entry.npm, true)
|
|
814
|
+
if (!on?.ok || on.value?.application === 'failed') {
|
|
815
|
+
// Put the old one back so the user is not left with neither.
|
|
816
|
+
await pm.setBundleEnabled(legacyName, true)
|
|
817
|
+
return { status: 'failed', phase: 'enable-new', failure: classifyFailure(on?.value ?? {}), restoredOld: true }
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
say('remove-old')
|
|
821
|
+
const rm = await pm.removeBundle(legacyName)
|
|
822
|
+
if (!rm?.ok || rm.value?.application === 'failed') {
|
|
823
|
+
return { status: 'halfRemoved', failure: classifyFailure(rm?.value ?? {}), note: 'old package is disabled but not removed' }
|
|
824
|
+
}
|
|
825
|
+
return { status: 'done' }
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
/**
|
|
829
|
+
* Uninstall. The host's uninstall is NOT atomic: it disables first, then removes, and a failure in
|
|
830
|
+
* the last step leaves the plugin disabled but still installed. We detect that and say so.
|
|
831
|
+
*/
|
|
832
|
+
async function uninstall(pm, entry) {
|
|
833
|
+
const inventory = await pm.listBundles()
|
|
834
|
+
if (!inventory?.ok) return { status: 'failed', failure: { kind: 'network', diagnostic: 'could not read current bundles' } }
|
|
835
|
+
if (providedByApp(inventory.value.find((b) => b.name === entry.npm))) return { status: 'failed', failure: { kind: 'provided' } }
|
|
836
|
+
const r = await pm.removeBundle(entry.npm)
|
|
837
|
+
if (!r?.ok) return { status: 'failed', failure: { kind: 'failed', diagnostic: r?.error?.message ?? 'remove failed' } }
|
|
838
|
+
if (r.value?.application === 'failed') {
|
|
839
|
+
const list = await pm.listBundles()
|
|
840
|
+
const left = list?.ok ? list.value.find((b) => b.name === entry.npm) : undefined
|
|
841
|
+
return { status: left && !left.enabled ? 'halfRemoved' : 'failed', failure: classifyFailure(r.value) }
|
|
842
|
+
}
|
|
843
|
+
return { status: r.value?.application === 'restart-required' ? 'restart' : 'done' }
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
/**
|
|
847
|
+
* Compare installed versions with the catalog. Only center-managed entries are offered for update. An app-owned package
|
|
848
|
+
* counts when the host can update it (`updatableBuiltIn`), compared at the copy the host selects; such a row is `builtIn`.
|
|
849
|
+
*/
|
|
850
|
+
function pendingUpdates(catalog, bundles) {
|
|
851
|
+
const have = new Map((bundles ?? []).filter((b) => b.installed && !providedByApp(b) || updatableBuiltIn(b)).map((b) => [b.name, b]))
|
|
852
|
+
const out = []
|
|
853
|
+
for (const p of catalog.plugins) {
|
|
854
|
+
if (p.updates !== 'center') continue
|
|
855
|
+
const b = have.get(p.npm)
|
|
856
|
+
const v = b?.version
|
|
857
|
+
if (v && compareSemver(v, p.version) < 0) out.push({ entry: p, from: v, to: p.version, ...(updatableBuiltIn(b) ? { builtIn: true } : {}) })
|
|
858
|
+
}
|
|
859
|
+
return out
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
/** Read a validated online listing without widening the allowed namespaces or silently installing it. */
|
|
863
|
+
function catalogWithReleases(catalog, answer) {
|
|
864
|
+
const listingAccepted = !!answer?.catalog && validateCatalog(answer.catalog).ok
|
|
865
|
+
const listing = listingAccepted ? answer.catalog : catalog
|
|
866
|
+
const bundled = new Map(catalog.plugins.map(p => [p.npm, p]))
|
|
867
|
+
const releases = new Map((Array.isArray(answer?.plugins) ? answer.plugins : [])
|
|
868
|
+
.filter((r) => r?.ok === true && typeof r.name === 'string' && /^\d+\.\d+\.\d+$/.test(r.version ?? '')
|
|
869
|
+
&& typeof r.publishedAt === 'string' && Number.isFinite(Date.parse(r.publishedAt))
|
|
870
|
+
&& ['https://registry.npmjs.org/', 'https://registry.npmmirror.com/'].includes(r.registry))
|
|
871
|
+
.map((r) => [r.name, r]))
|
|
872
|
+
return { ...listing, listingAccepted, plugins: listing.plugins.map((entry) => {
|
|
873
|
+
const p = bundled.has(entry.npm) ? entry : { ...entry, onlineOnly: true }
|
|
874
|
+
const r = releases.get(p.npm)
|
|
875
|
+
if (p.origin !== 'official' || p.updates !== 'center' || !r || compareSemver(r.version, p.version) < 0) return p
|
|
876
|
+
return { ...p, version: r.version, publishedAt: r.publishedAt, cmd: `dsh plugin add ${p.npm}@${r.version}`,
|
|
877
|
+
...(Number.isFinite(r.sizeKB) && r.sizeKB > 0 ? { sizeKB: r.sizeKB } : {}),
|
|
878
|
+
...(compareSemver(r.version, p.version) > 0 ? { reviewed: null } : {}),
|
|
879
|
+
registry: r.registry, releaseSource: r.registry,
|
|
880
|
+
usesLiveVersion: !bundled.has(p.npm) || compareSemver(r.version, bundled.get(p.npm).version) > 0 }
|
|
881
|
+
}) }
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
/**
|
|
885
|
+
* How many updates the center offers: the number on its Updates tab and on its sidebar entry, so the two
|
|
886
|
+
* never disagree. Installed plugins with a newer verified release (pendingUpdates), app-owned packages that
|
|
887
|
+
* a newer app release brings (appReleaseUpdates), and this center itself when it is behind.
|
|
888
|
+
* @param catalog - The shipped catalog; the answer's catalog and releases are applied as the page applies them.
|
|
889
|
+
* @param answer - A /vdc/updates answer, or null.
|
|
890
|
+
* @param bundles - The installed list; anything else (still loading, unavailable) counts nothing.
|
|
891
|
+
* @param selfVersion - The running version of this center.
|
|
892
|
+
* @returns The count.
|
|
893
|
+
*/
|
|
894
|
+
function updateCount(catalog, answer, bundles, selfVersion) {
|
|
895
|
+
if (!Array.isArray(bundles)) return 0
|
|
896
|
+
const live = catalogWithReleases(catalog, answer)
|
|
897
|
+
return pendingUpdates(live, bundles).length + appReleaseUpdates(live, bundles).length
|
|
898
|
+
+ (judgeSelfUpdate(selfVersion, answer?.self).kind === 'newer' ? 1 : 0)
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
/** How long an answer kept from an earlier visit may still be shown while the next check runs. */
|
|
902
|
+
const KEPT_ANSWER_MAX_AGE_MS = 30 * 24 * 60 * 60 * 1000
|
|
903
|
+
|
|
904
|
+
/**
|
|
905
|
+
* A /vdc/updates answer kept from an earlier visit, made fit to show the moment the center opens — so the page
|
|
906
|
+
* starts on the newest catalog it knows instead of the copy this client was built with, and does not change
|
|
907
|
+
* under the user a few seconds later. It must be a successful answer, at most 30 days old, whose catalog is not
|
|
908
|
+
* older than the shipped one (an app update since then wins) and passes the validator. It is relabelled as a
|
|
909
|
+
* cached listing: it never counts as checked just now, and everything in it still goes through
|
|
910
|
+
* catalogWithReleases, which re-checks the catalog and every release.
|
|
911
|
+
* @param stored - what was kept, parsed; anything else is refused.
|
|
912
|
+
* @param bundled - the catalog this client ships.
|
|
913
|
+
* @param now - the clock.
|
|
914
|
+
* @returns the answer to start from, or null.
|
|
915
|
+
*/
|
|
916
|
+
function restoredAnswer(stored, bundled, now = Date.now()) {
|
|
917
|
+
if (!stored || typeof stored !== 'object' || Array.isArray(stored) || stored.ok !== true) return null
|
|
918
|
+
if (!Array.isArray(stored.plugins) && !(stored.self && typeof stored.self === 'object')) return null
|
|
919
|
+
// Age from when this client kept it (its own clock), else from when the host checked.
|
|
920
|
+
const keptAt = Date.parse(stored.keptAt ?? stored.checkedAt)
|
|
921
|
+
if (!Number.isFinite(keptAt) || now - keptAt > KEPT_ANSWER_MAX_AGE_MS) return null
|
|
922
|
+
if (stored.catalog !== undefined) {
|
|
923
|
+
const updated = stored.catalog?.updated
|
|
924
|
+
if (typeof updated !== 'string' || updated < String(bundled?.updated ?? '')) return null
|
|
925
|
+
if (!validateCatalog(stored.catalog).ok) return null
|
|
926
|
+
}
|
|
927
|
+
const { catalogError: _error, catalogStale: _stale, cached: _cached, keptAt: _keptAt, ...kept } = stored
|
|
928
|
+
return { ...kept, catalogSource: 'cached', restored: true }
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
/** A completed check may claim current versions only when every fixed VibeDev package and self answered. */
|
|
932
|
+
function releasesComplete(catalog, answer) {
|
|
933
|
+
if (answer?.ok !== true || answer.self?.ok !== true || answer.self.registry !== 'https://registry.npmjs.org/'
|
|
934
|
+
|| answer.self.degraded || !/^\d+\.\d+\.\d+$/.test(answer.self.latest ?? '')) return false
|
|
935
|
+
const releases = new Map((Array.isArray(answer.plugins) ? answer.plugins : []).map((r) => [r?.name, r]))
|
|
936
|
+
return catalog.plugins.filter((p) => p.origin === 'official' && p.updates === 'center').every((p) => {
|
|
937
|
+
const r = releases.get(p.npm)
|
|
938
|
+
return r?.ok === true && /^\d+\.\d+\.\d+$/.test(r.version ?? '')
|
|
939
|
+
&& Number.isFinite(Date.parse(r.publishedAt))
|
|
940
|
+
&& compareSemver(r.version, p.version) >= 0
|
|
941
|
+
&& r.registry === 'https://registry.npmjs.org/' && !r.degraded
|
|
942
|
+
})
|
|
943
|
+
}
|
|
944
|
+
|
|
945
|
+
/**
|
|
946
|
+
* Keep app-supplied version differences visible, but never offer to install an external replacement: for a host that
|
|
947
|
+
* cannot update an app-owned package (one that updates it lists it in pendingUpdates instead).
|
|
948
|
+
*/
|
|
949
|
+
function appReleaseUpdates(catalog, bundles) {
|
|
950
|
+
const have = new Map((bundles ?? []).filter((b) => providedByApp(b) && !updatableBuiltIn(b)).map((b) => [b.name, b]))
|
|
951
|
+
return catalog.plugins.flatMap((p) => {
|
|
952
|
+
const b = have.get(p.npm)
|
|
953
|
+
return b?.version && compareSemver(b.version, p.version) < 0 ? [{ entry: p, from: b.version, to: p.version }] : []
|
|
954
|
+
})
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
function compareSemver(a, b) {
|
|
958
|
+
const pa = a.split('-')[0].split('.').map(Number)
|
|
959
|
+
const pb = b.split('-')[0].split('.').map(Number)
|
|
960
|
+
for (let i = 0; i < 3; i++) if ((pa[i] ?? 0) !== (pb[i] ?? 0)) return (pa[i] ?? 0) < (pb[i] ?? 0) ? -1 : 1
|
|
961
|
+
return 0
|
|
962
|
+
}
|
|
963
|
+
|
|
964
|
+
/** Which legacy packages are installed (so the migration banner should show). */
|
|
965
|
+
function legacyInstalled(catalog, bundles) {
|
|
966
|
+
const have = new Map((bundles ?? []).filter(bundlePresent).map((b) => [b.name, b]))
|
|
967
|
+
const out = []
|
|
968
|
+
for (const p of catalog.plugins) for (const l of p.legacyNames ?? []) if (have.get(l)?.installed && !providedByApp(have.get(l))) out.push({ entry: p, legacy: l, newInstalled: have.has(p.npm), ...(providedByApp(have.get(p.npm)) ? { provided: true } : {}) })
|
|
969
|
+
return out
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
/**
|
|
973
|
+
* How one plugin's declared relations stand on this Host: its `requires` first, then its
|
|
974
|
+
* `partners`, each with what the catalogue says it is (`role`) and what the Host actually has.
|
|
975
|
+
* A relation is never an install button here: what the Host has is opened for viewing and
|
|
976
|
+
* configuration, and what it lacks is opened as well, where that plugin's own page offers the
|
|
977
|
+
* install. Nothing is installed from here, so nothing can be installed twice.
|
|
978
|
+
* @param entry - one catalog entry.
|
|
979
|
+
* @param lookup - (id) => entry, for naming a relation.
|
|
980
|
+
* @param bundles - the Host's bundle inventory.
|
|
981
|
+
* @returns one row per relation, in declaration order.
|
|
982
|
+
*/
|
|
983
|
+
function relationsOf(entry, lookup, bundles) {
|
|
984
|
+
const have = new Map((bundles ?? []).filter(bundlePresent).map((b) => [b.name, b]))
|
|
985
|
+
const rows = []
|
|
986
|
+
const seen = new Set()
|
|
987
|
+
for (const [kind, ids] of [['requires', entry?.requires ?? []], ['partners', entry?.partners ?? []]]) {
|
|
988
|
+
for (const id of ids) {
|
|
989
|
+
const other = lookup?.(id)
|
|
990
|
+
if (!other || seen.has(id)) continue
|
|
991
|
+
seen.add(id)
|
|
992
|
+
const bundle = have.get(other.npm)
|
|
993
|
+
const provided = providedByApp(bundle)
|
|
994
|
+
rows.push({
|
|
995
|
+
kind, id, entry: other,
|
|
996
|
+
present: bundlePresent(bundle), provided, installed: !!bundle?.installed, enabled: !!bundle?.enabled,
|
|
997
|
+
})
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
return rows
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
/**
|
|
1004
|
+
* Whether an installed `dsh-film` is the old canvas: 0.1 predates the film workbench, and the
|
|
1005
|
+
* catalogue has a newer version to move to. The move is the centre's ordinary explicit update
|
|
1006
|
+
* (confirm, then install), never a silent replacement, and it keeps the project files.
|
|
1007
|
+
* @param entry - the catalog entry being viewed.
|
|
1008
|
+
* @param bundle - the Host's row for it, if any.
|
|
1009
|
+
* @returns whether the detail should offer the explicit upgrade.
|
|
1010
|
+
*/
|
|
1011
|
+
function oldCanvas(entry, bundle) {
|
|
1012
|
+
if (entry?.npm !== 'dsh-film' || !bundle?.installed || providedByApp(bundle)) return false
|
|
1013
|
+
if (typeof bundle.version !== 'string' || typeof entry.version !== 'string') return false
|
|
1014
|
+
return bundle.version.split('-')[0].startsWith('0.1.') && compareSemver(bundle.version, entry.version) < 0
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
const E = { specOf, resolvePlan, providedByApp, applicationCopy, updatableBuiltIn, runsUpdatedCopy, bundlePresent, readBundleInventory, needsInstall, markInstalled, classifyFailure, cooldownEnds, eligibleMirror, chooseRegistry, judgeSelfUpdate, cooldownState, trackLoadedChanges, waitQuiet, readableTextOn, contrastRatio, installOne, incompatibleRequirements, updateBuiltIn, restoreBuiltIn, installPlan, migrate, uninstall, pendingUpdates, catalogWithReleases, updateCount, KEPT_ANSWER_MAX_AGE_MS, restoredAnswer, releasesComplete, appReleaseUpdates, compareSemver, legacyInstalled, relationsOf, oldCanvas };
|
|
1018
|
+
/**
|
|
1019
|
+
* i18n for the center. Plain objects; the catalog carries its own zh/en text.
|
|
1020
|
+
* The host locale id looks like "zh" / "zh-CN" / "en" ...; anything starting with "zh" gets Chinese.
|
|
1021
|
+
*/
|
|
1022
|
+
const STR = {
|
|
1023
|
+
zh: {
|
|
1024
|
+
title: 'VibeDev 生态', preview: '预览', sectionPlugins: '插件',
|
|
1025
|
+
accountInstallTitle: 'VibeDev 账号与模型', accountInstallBody: '安装账号插件后,可在同一个 VibeDev 入口查看账号和插件。安装前请确认下面的说明。',
|
|
1026
|
+
installAccount: '安装 VibeDev 账号插件', signIn: '需要 VibeDev 账号 · 登录', signInFailed: '没能开始登录,请稍后重试。',
|
|
1027
|
+
tabAll: '全部', tabInstalled: '已安装', tabUpdates: '可更新', tabCommunity: '社区插件',
|
|
1028
|
+
about: '关于 VibeDev 生态',
|
|
1029
|
+
introTitle: 'VibeDev 团队出品的插件,集中在这里',
|
|
1030
|
+
introLead: '一个入口了解、安装和管理 VibeDev 出品的插件。',
|
|
1031
|
+
f1t: 'VibeDev 出品,说明写清楚', f1d: '每个插件由 VibeDev 维护;功能、费用、会读写什么、依赖什么,都写在卡片和详情里。',
|
|
1032
|
+
f2t: '一键安装,依赖自动处理', f2d: '点一次、确认一次,就自动完成「检查 → 安装 → 启用」;缺少的前置插件会一并装好。',
|
|
1033
|
+
f3t: '套装与迁移', f3d: '常用组合做成套装一键装齐;发现旧包名时,帮你按安全顺序切换到新包。',
|
|
1034
|
+
// Shown, with the footer link, only while the catalog lists a community market.
|
|
1035
|
+
introMarket: '这里只收录 VibeDev 出品的插件。社区插件可以在插件市场里找:',
|
|
1036
|
+
installMarket: '一键安装插件市场 →', openMarket: '打开插件市场 →',
|
|
1037
|
+
official: 'VibeDev 插件', officialSub: (n) => `${n} 个 · 由 VibeDev 维护`,
|
|
1038
|
+
deps: '依赖与搭档', depsSub: 'VibeDev 插件需要的、或值得搭配的社区插件;仅提供安装入口,本中心不审查其代码',
|
|
1039
|
+
install: '安装', installWithDeps: '安装(含依赖)', enabled: '已启用', disabled: '已停用', enable: '启用', manage: '管理 ▾',
|
|
1040
|
+
disable: '停用(保留数据)', uninstall: '卸载', details: '查看详情',
|
|
1041
|
+
updateTo: (v) => `更新到 ${v}`,
|
|
1042
|
+
provided: '应用内置', providedNote: '此插件随应用提供,无需重复安装;版本随应用更新。在设置的插件页查看运行状态。',
|
|
1043
|
+
providedBlockedT: '这个插件由应用提供', providedBlockedB: 'VibeDev 生态不会重装、更新或卸载内置插件。请在设置的插件页检查是否启用,并通过更新应用升级它。',
|
|
1044
|
+
providedMigration: '新包已经内置并启用:只停用、卸载旧外置包,保留内置的新包。',
|
|
1045
|
+
needs: (names) => `需要 ${names}`, satisfied: '(已满足)', willInstall: '(未安装,会一并安装)',
|
|
1046
|
+
view: '查看', viewConfigure: '查看与配置', notInstalled: '未安装',
|
|
1047
|
+
oldCanvasNote: '装的是 0.1 的旧画布。影视工作台(0.2 起)用同一套 film/film.json 项目:升级会保留工作区里的 film/ 作品,也不会动账号登录;要你在这里确认之后才会更新。',
|
|
1048
|
+
upgradeCanvas: '升级到影视工作台',
|
|
1049
|
+
suiteInstall: '一键安装套装', suiteDone: '套装已全部安装',
|
|
1050
|
+
suiteWill: (n, have, size) => `将安装 ${n} 个插件(已装 ${have} 个)· ${size}`,
|
|
1051
|
+
tagOfficial: 'VibeDev 插件', tagCommunity: '社区插件', tagNeedsAccount: '需要 VibeDev 账号', tagPaid: '按用量计费',
|
|
1052
|
+
tagNeedsHost02: '需要 VibeDev / DSH 0.2.x', tagDependency: '前置依赖', tagCompanion: '推荐搭档', tagTested: '已测试',
|
|
1053
|
+
does: '能做什么', needsH: '需要什么', prereq: '前置插件', partners: '搭档(可选)', size: '体积', none: '无',
|
|
1054
|
+
capsH: '权限与费用', sourceH: '来源与审查', source: '来源', review: '审查', compat: '兼容性',
|
|
1055
|
+
officialSrc: 'VibeDev 出品', communitySrc: (a) => `社区插件 · ${a}`,
|
|
1056
|
+
officialReview: '由 VibeDev 团队维护', notReviewed: '本中心未审查其代码',
|
|
1057
|
+
reviewedBy: (v, d) => `已在 VibeDev 测试 · 版本 ${v} · ${d}`,
|
|
1058
|
+
compatS: { verified: '已验证', likely: '可能兼容', unknown: '未知', incompatible: '不兼容' },
|
|
1059
|
+
manualH: '手动安装', manualNote: 'VibeDev 桌面版的命令是 vibedev-app plugin --profile desktop add <包名>;安装前请先完全退出应用。',
|
|
1060
|
+
linksH: '链接', repo: 'GitHub', npm: 'npm',
|
|
1061
|
+
footMore: '想找更多社区插件?', footFeedback: '反馈问题', footCatalog: (d, source, error) => `目录 ${d} · ${error ? '在线目录未能刷新,使用可用目录' : source === 'online' || source === 'cached' ? '在线收录目录' : '随包离线目录'}`,
|
|
1062
|
+
confirmInstall: (n, upd) => `确认并${upd ? '更新' : '安装'} ${n} 个插件`, cancel: '取消', back: '返回',
|
|
1063
|
+
willInstallN: (n, skip, size) => `将安装 ${n} 个插件${skip ? `,已安装的 ${skip} 个自动跳过` : ''} · ${size}`,
|
|
1064
|
+
willUpdateN: (n, size) => `将更新 ${n} 个插件 · ${size}`,
|
|
1065
|
+
alreadyInstalled: '已安装,跳过', afterUpdateRefresh: '更新后需要重启 VibeDev 才会生效',
|
|
1066
|
+
acctTitle: '需要 VibeDev 账号,按用量计费',
|
|
1067
|
+
acctBody: (names) => `${names}:在 VibeDev 里直接使用你已登录的账号;在 DSH 里到侧边栏底部「登录 VibeDev」或「设置 → VibeDev 账号」登录。安装本身不收费。`,
|
|
1068
|
+
coolUpdate: (names, end) => `${names} 发布还不满一天。更新时 pnpm 通常会在你的配置里再追加一条同名放行规则,而它只认同名的第一条,所以更新可能被拦住,并让所有插件的安装和卸载暂时失败,直到 ${end}。更稳妥的做法是 ${end} 之后再更新。更新不会改动你的工作区里的项目文件。`,
|
|
1069
|
+
updatesBannerT: (n) => `有 ${n} 个更新可用`, updatesBannerOpen: '查看更新', updatesBannerMore: ' 等', badgeTitle: (n) => `VibeDev 生态:${n} 个更新可用`,
|
|
1070
|
+
noRefreshT: '请不要刷新页面,请完全退出并重新打开 VibeDev',
|
|
1071
|
+
noRefreshB: (names) => `${names} 在 VibeDev 启动之后被更新,或被卸载后又装了回来。桌面版刷新页面时,用的是 VibeDev 启动那一刻的插件清单,而这些插件的文件已经变了,刷新会让启动失败并弹出崩溃窗口(你的数据不会丢)。直接重启就没有这个问题。`,
|
|
1072
|
+
updateKeeps: '更新不会改动你的工作区里的项目文件。', versionOf: (v) => `v${v}`, checkUpdate: '检查更新', checking: '正在检查…', dismiss: '关闭',
|
|
1073
|
+
selfOk: (v) => `VibeDev 生态已是最新版本(${v})。`,
|
|
1074
|
+
selfAhead: (cur, latest) => `你运行的是 ${cur},比 npm 上的最新版 ${latest} 还新(可能是本地开发版)。`,
|
|
1075
|
+
selfNewT: (latest, cur) => `VibeDev 生态有新版本 ${latest}(你现在是 ${cur})`,
|
|
1076
|
+
selfBuiltIn: 'VibeDev 生态随 VibeDev Next 内置,版本随应用更新:新版本会随下一个 VibeDev Next 版本带上,不需要在插件页重新安装。',
|
|
1077
|
+
// Built-in plugins this host can update in place (the app's copy stays as the fallback).
|
|
1078
|
+
selfUpdatable: 'VibeDev 生态随 VibeDev Next 内置,也可以直接更新:新版本装在你的配置里,重启 VibeDev Next 后生效;应用自带的版本一直保留,随时可以恢复。',
|
|
1079
|
+
providedUpdatable: '此插件随应用提供,无需重复安装。有新版本时可以在「可更新」里直接更新,重启 VibeDev Next 后生效;应用自带的版本一直保留。',
|
|
1080
|
+
builtInUpdated: (local, shipped) => `正在使用更新后的 ${local}(应用自带 ${shipped})。`,
|
|
1081
|
+
builtInPending: (local) => `已下载 ${local},重启 VibeDev Next 后生效。`,
|
|
1082
|
+
restoreBuiltIn: (shipped) => `恢复应用自带的 ${shipped}`,
|
|
1083
|
+
builtInRunUpdate: (v) => `正在更新到 ${v}…`, builtInRunRestore: '正在恢复应用自带的版本…',
|
|
1084
|
+
builtInDoneUpdateT: (v) => `已下载 ${v}`, builtInDoneRestoreT: (v) => `已恢复应用自带的 ${v}`,
|
|
1085
|
+
builtInDoneB: '重启 VibeDev Next 后生效。VibeDev 生态不会替你重启应用;请先保存手头的工作,再完全退出并重新打开。',
|
|
1086
|
+
officialSummary: '发现、安装和管理 VibeDev 出品的插件',
|
|
1087
|
+
officialPage: 'VibeDev 生态随 VibeDev Next 内置,在这里发现、安装和管理 VibeDev 出品的插件。',
|
|
1088
|
+
officialOpen: '打开 VibeDev 生态',
|
|
1089
|
+
selfNewB: 'VibeDev 生态不能给自己更新。请在 VibeDev 的「插件」页卸载「VibeDev 生态」,再点「添加插件」,输入下面的完整包名(必须带 @vibedev-si/ 前缀),最后完全退出并重新打开 VibeDev。',
|
|
1090
|
+
selfCool: (pub, end) => `这个版本发布于 ${pub}。pnpm 默认要等满一天才放行新版本,现在更新可能被拦住,并让其他插件的安装和卸载暂时失败。建议 ${end} 之后再更新。`,
|
|
1091
|
+
selfFailT: '没能读取最新版本', selfFailB: (list) => `${list ? `没有一个源回应:${list}。` : '检查请求没有得到回应。'}这不代表你是最新的,请稍后再试。`,
|
|
1092
|
+
copyPkg: '复制包名', copiedPkg: '已复制', viewVersion: '查看这个版本',
|
|
1093
|
+
stepsH: '将要执行的操作(点击展开)',
|
|
1094
|
+
stepsFoot: '通过 DSH 宿主的插件管理器完成。只会处理上面列出的插件,之后可随时停用或卸载。',
|
|
1095
|
+
consent: (upd) => `点击「确认并${upd ? '更新' : '安装'}」即同意处理以上插件`,
|
|
1096
|
+
installing: '正在安装', progress: (d, n) => `${d} / ${n} 完成 · 请保持页面打开`,
|
|
1097
|
+
stWait: '等待', stInspect: '检查中', stInstall: '下载与安装', stEnable: '启用', stDone: '已启用', stFail: '失败', stHold: '待你确认', stSkip: '已安装', stOldOff: '停用旧包', stOldRemove: '卸载旧包', stRemoveCurrent: '移除当前版本', stRestore: '恢复原版本',
|
|
1098
|
+
replacesOld: (old) => `替换旧包 ${old}`,
|
|
1099
|
+
switchNote: (olds) => `会替换旧包 ${olds}:新包装好后先停用旧包、再启用新包,新包启用成功后才卸载旧包;新包启用失败时会把旧包重新启用。`,
|
|
1100
|
+
logH: '安装日志', cancelInstall: '取消安装', cancelHintOk: '可以取消;已装好的插件会保留', cancelHintLate: '已进入应用阶段,无法取消',
|
|
1101
|
+
doneTitle: '安装完成', doneSub: (d, n) => `${d} / ${n} 个插件已装好`,
|
|
1102
|
+
doneHead: (d) => `已安装并启用 ${d} 个插件`, doneLoaded: '插件由 VibeDev 自己加载,通常几秒内就会出现,不需要刷新页面。如果过一会儿侧边栏仍没有变化,请完全退出并重新打开 VibeDev。',
|
|
1103
|
+
nextH: '接下来',
|
|
1104
|
+
nextFilm: '打开任意会话的右侧栏,在「开始」页点「剧本」「分镜画布」「导演台」。',
|
|
1105
|
+
nextVibedev: 'VibeDev 账号与模型:在侧边栏底部点「登录 VibeDev」(在 VibeDev 里直接用已登录的账号);之后模型选择器里会出现 VibeDev 的模型,也可以对 Agent 说「生成一张…」。',
|
|
1106
|
+
nextViewer: '在右侧栏的文件树里点开 mp4、wav 或 html 文件就能直接预览;「媒体画廊」在右侧栏开始页,文件树顶部也有入口。',
|
|
1107
|
+
nextMarket: '插件市场在这里的「社区插件」标签页里使用;它也会出现在设置里。',
|
|
1108
|
+
nextMarketHint: '想找社区里的更多插件?回到首页「依赖与搭档」,可以一键安装插件市场。',
|
|
1109
|
+
gotIt: '知道了', settling: '正在等 VibeDev 加载完这些插件,请先不要关闭或刷新页面…', waitingHost: '正在等 VibeDev 加载上一个插件…',
|
|
1110
|
+
restartTitle: '安装完成,需要重启', restartHead: '已安装,但需要重启 VibeDev 才能生效',
|
|
1111
|
+
restartBody: (n) => `${n} 个插件已写入配置。VibeDev 生态不会替你重启应用;请先保存手头的工作,再完全退出并重新打开。`,
|
|
1112
|
+
failTitle: '安装未完成',
|
|
1113
|
+
fNetworkT: '无法下载插件', fNetworkB: (n, d) => `${n > 1 ? `已依次尝试 ${n} 个源,都没有连上。` : '没能连上 npm 源。'}请检查网络或代理后重试。${d ? `(${String(d).slice(0, 140)})` : ''}`,
|
|
1114
|
+
fBuildsT: '这个插件的依赖需要执行构建脚本', fBuildsB: (names) => `待你决定的包:${names}。构建脚本会以你的用户权限运行命令,请只在信任来源时允许。`,
|
|
1115
|
+
fIncompatT: '当前 VibeDev 版本不满足要求', fIncompatB: (s) => `${s}已拦截安装,没有下载任何内容。`,
|
|
1116
|
+
fNotFoundT: '在 npm 上找不到这个版本', fNotFoundB: '目录里登记的版本可能已被撤回或还没同步到镜像。请稍后重试,或到 GitHub 反馈。',
|
|
1117
|
+
fMismatchT: '已拦截:npm 返回的内容和目录不一致', fMismatchB: (d) => `为了安全,没有安装。${d}`,
|
|
1118
|
+
fExemptT: '包管理器的「新版本冷却期」拦住了所有安装和卸载', fExemptB: (c, when) => `${c ? c + ' ' : ''}发布不足一天,pnpm 默认不放行。这会影响所有插件的安装和卸载,直到${when ? ' ' + when + ' ' : ''}冷却期结束。`,
|
|
1119
|
+
fBusyT: '现在无法操作', fBusyB: '有会话正在运行,或这个插件正被使用。请先结束相关会话再试。',
|
|
1120
|
+
fRefusedT: '插件管理器拒绝了这个请求', fFailedT: '安装没有成功', fFailedB: '插件管理器没有给出更多信息,详情见日志。',
|
|
1121
|
+
keptDone: (n) => `已完成的 ${n} 个插件会保留;`, noChangeFail: '失败的插件没有改动你的插件配置。', noChangeHold: '你确认之前没有改动插件配置。',
|
|
1122
|
+
installedNotEnabled: '插件已装好,但启用失败;可以在设置的插件页手动启用。',
|
|
1123
|
+
updRestored: (spec) => `新版本没能装好,已重新安装原来的 ${spec},并恢复了它原来的启用状态。`,
|
|
1124
|
+
updLostT: '原来的版本没能恢复', updLostB: (spec) => `新版本没能装好;原来的版本已被移除,重新安装也没有成功。请稍后在插件页添加 ${spec},或点「复制安装命令」。`,
|
|
1125
|
+
retry: '重试', approveRetry: '允许这些脚本并重试', skipThis: '跳过此插件', copyCmd: '复制安装命令', later: '稍后再试', seeCompat: '查看兼容说明',
|
|
1126
|
+
uncertainT: '没能确认结果', uncertainB: '和插件管理器的连接中断了,安装可能已经完成。点「重新检查」查看实际状态。', recheck: '重新检查',
|
|
1127
|
+
migrateTitle: (old) => `检测到旧版插件 ${old}`,
|
|
1128
|
+
migrateBody: (old, nw) => `它已改名为 ${nw}。两者不能同时启用,否则可能互相冲突。`,
|
|
1129
|
+
migrateOrder: '切换顺序:安装新包但先不启用 → 停用旧包 → 启用新包 → 确认可用后再卸载旧包。', migrateBtn: '一键切换',
|
|
1130
|
+
migrating: '正在切换', migDone: '已切换到新包,旧包已卸载。', migHalf: '已切换到新包;旧包已停用但没能卸载,可稍后在插件页手动卸载。',
|
|
1131
|
+
migRestored: '没能启用新包,已把旧包重新启用,你的功能不受影响。',
|
|
1132
|
+
oldStillOn: (old) => `没能停用旧包 ${old},所以新包装好后没有启用(两者不能同时启用)。可以稍后重试。`,
|
|
1133
|
+
halfRemovedT: '插件已被停用,但没有卸载干净', halfRemovedB: '它现在是「已停用、仍安装」的状态。可以重新启用,或解决问题后重试卸载。', reenable: '重新启用', retryUninstall: '重试卸载',
|
|
1134
|
+
communityEmptyT: '安装插件市场后,可以在这里浏览社区插件',
|
|
1135
|
+
communityEmptyB: (author) => `插件市场是第三方插件,由 ${author} 维护。装好后,可以在这个标签页里浏览、搜索和安装社区插件。`,
|
|
1136
|
+
communityNote: (size) => `约 ${size} · 第三方插件,VibeDev 生态不审查其代码`,
|
|
1137
|
+
communityViaMarket: (name) => `由${name}提供`, communityAbout: (name) => `关于${name}`,
|
|
1138
|
+
communityUnlisted: '当前目录未收录 DSH 社区市场。已安装的市场仍可从 DSH 的插件页打开或卸载。',
|
|
1139
|
+
discoverT: '社区插件在「插件」页的「发现」里',
|
|
1140
|
+
discoverB: '社区插件是第三方开发的代码。VibeDev 审查后才收录,并且只列出审查过的精确版本。请在「插件」→「发现」里浏览和安装。',
|
|
1141
|
+
discoverOpen: '打开「发现」',
|
|
1142
|
+
discoverFailed: '没能自动打开。请在侧边栏点「插件」,再选「发现」。',
|
|
1143
|
+
communityNoEmbed: '插件市场已安装,但没能在这里嵌入它的界面。请在设置里打开「插件市场」。',
|
|
1144
|
+
allUpToDate: '已核验,已安装的 VibeDev 插件暂无正式版更新', nothingInstalled: '还没有安装任何 VibeDev 插件',
|
|
1145
|
+
releaseChecking: '正在从官方 npm 核验 VibeDev 插件版本…',
|
|
1146
|
+
releaseChecked: '版本已通过官方 npm 核验;更新将使用对应的精确版本。',
|
|
1147
|
+
releaseUnavailable: '部分版本未能从官方 npm 核验。仍显示已确认的版本和随包目录,不代表已经是最新版。',
|
|
1148
|
+
releaseNoVerifiedUpdates: '暂未核验到可更新的版本,请稍后重试。',
|
|
1149
|
+
selfRowHelp: 'VibeDev 生态自身有新版本。请在 DSH 的插件页用下面的精确包名更新,再完全退出并重开应用。',
|
|
1150
|
+
appUpdateHelp: '此组件由应用内置。npm 已发布新版本,请通过升级应用获取;生态不会另外安装一份。',
|
|
1151
|
+
loadFail: '没能读取已安装的插件', loadFailB: '插件管理器暂时不可用。仍可使用下面的「复制安装命令」手动安装。',
|
|
1152
|
+
noManager: '这个环境没有提供插件管理器,无法一键安装。请用详情里的命令手动安装。',
|
|
1153
|
+
sizeSmall: '很小',
|
|
1154
|
+
},
|
|
1155
|
+
en: {
|
|
1156
|
+
title: 'VibeDev Ecosystem', preview: 'Preview', sectionPlugins: 'Plugins',
|
|
1157
|
+
accountInstallTitle: 'VibeDev Account & Models', accountInstallBody: 'Install the account plugin to see your account and plugins in one VibeDev entry. Review the details before installing.',
|
|
1158
|
+
installAccount: 'Install VibeDev account plugin', signIn: 'Needs a VibeDev account · Sign in', signInFailed: 'Could not start sign-in. Try again later.',
|
|
1159
|
+
tabAll: 'All', tabInstalled: 'Installed', tabUpdates: 'Updates', tabCommunity: 'Community',
|
|
1160
|
+
about: 'About',
|
|
1161
|
+
introTitle: 'Plugins from the VibeDev team, in one place',
|
|
1162
|
+
introLead: 'One place to learn about, install and manage the plugins VibeDev makes.',
|
|
1163
|
+
f1t: 'Official, and spelled out', f1d: 'Every plugin is maintained by VibeDev. What it does, what it costs, what it reads and writes, and what it needs are all on the card and in the details.',
|
|
1164
|
+
f2t: 'One click, dependencies handled', f2d: 'Click once, confirm once, and it runs "check → install → enable". Missing prerequisites are installed with it.',
|
|
1165
|
+
f3t: 'Suites and migration', f3d: 'Common combinations come as a suite you install in one go; if an old package name is found, we switch you to the new one in a safe order.',
|
|
1166
|
+
introMarket: 'Only VibeDev\u2019s own plugins are listed here. Community plugins are in the plugin market: ',
|
|
1167
|
+
installMarket: 'Install the plugin market →', openMarket: 'Open the plugin market →',
|
|
1168
|
+
official: 'VibeDev plugins', officialSub: (n) => `${n} · maintained by VibeDev`,
|
|
1169
|
+
deps: 'Prerequisites and companions', depsSub: 'Community plugins that VibeDev plugins need or pair well with; install link only, this center does not review their code',
|
|
1170
|
+
install: 'Install', installWithDeps: 'Install (with dependencies)', enabled: 'Enabled', disabled: 'Disabled', enable: 'Enable', manage: 'Manage ▾',
|
|
1171
|
+
disable: 'Disable (keep data)', uninstall: 'Uninstall', details: 'Details',
|
|
1172
|
+
updateTo: (v) => `Update to ${v}`,
|
|
1173
|
+
provided: 'Built into the app', providedNote: 'This plugin is supplied by the app; no separate installation is needed. Update the app to upgrade it, and check its status on the Plugins settings page.',
|
|
1174
|
+
providedBlockedT: 'This plugin is supplied by the app', providedBlockedB: 'The center does not reinstall, update or remove built-in plugins. Check their enablement on the Plugins settings page, and upgrade them by updating the app.',
|
|
1175
|
+
providedMigration: 'The new package is already built in and enabled: disable and remove only the old external package, leaving the built-in one in place.',
|
|
1176
|
+
needs: (names) => `Needs ${names}`, satisfied: ' (satisfied)', willInstall: ' (not installed, will be added)',
|
|
1177
|
+
view: 'View', viewConfigure: 'View and configure', notInstalled: 'Not installed',
|
|
1178
|
+
oldCanvasNote: 'This is the 0.1 canvas. The film workbench (0.2 and later) uses the same film/film.json projects: upgrading keeps the film/ work in your workspace and leaves your sign-in alone, and it only runs once you confirm here.',
|
|
1179
|
+
upgradeCanvas: 'Upgrade to the film workbench',
|
|
1180
|
+
suiteInstall: 'Install the suite', suiteDone: 'Suite fully installed',
|
|
1181
|
+
suiteWill: (n, have, size) => `Will install ${n} plugin(s) (${have} already installed) · ${size}`,
|
|
1182
|
+
tagOfficial: 'VibeDev plugin', tagCommunity: 'Community plugin', tagNeedsAccount: 'Needs a VibeDev account', tagPaid: 'Pay per use',
|
|
1183
|
+
tagNeedsHost02: 'Needs VibeDev / DSH 0.2.x', tagDependency: 'Prerequisite', tagCompanion: 'Companion', tagTested: 'Tested',
|
|
1184
|
+
does: 'What it does', needsH: 'What it needs', prereq: 'Prerequisites', partners: 'Pairs with (optional)', size: 'Size', none: 'None',
|
|
1185
|
+
capsH: 'Permissions and cost', sourceH: 'Source and review', source: 'Source', review: 'Review', compat: 'Compatibility',
|
|
1186
|
+
officialSrc: 'Made by VibeDev', communitySrc: (a) => `Community plugin · ${a}`,
|
|
1187
|
+
officialReview: 'Maintained by the VibeDev team', notReviewed: 'Its code is not reviewed by this center',
|
|
1188
|
+
reviewedBy: (v, d) => `Tested on VibeDev · version ${v} · ${d}`,
|
|
1189
|
+
compatS: { verified: 'Verified', likely: 'Likely compatible', unknown: 'Unknown', incompatible: 'Incompatible' },
|
|
1190
|
+
manualH: 'Install by hand', manualNote: 'On VibeDev desktop the command is vibedev-app plugin --profile desktop add <package>; quit the app completely first.',
|
|
1191
|
+
linksH: 'Links', repo: 'GitHub', npm: 'npm',
|
|
1192
|
+
footMore: 'Looking for more community plugins? ', footFeedback: 'Feedback', footCatalog: (d, source, error) => `Catalog ${d} · ${error ? 'could not refresh online; using an available catalog' : source === 'online' || source === 'cached' ? 'online listing' : 'bundled offline catalog'}`,
|
|
1193
|
+
confirmInstall: (n, upd) => `Confirm and ${upd ? 'update' : 'install'} ${n} plugin(s)`, cancel: 'Cancel', back: 'Back',
|
|
1194
|
+
willInstallN: (n, skip, size) => `Will install ${n} plugin(s)${skip ? `; ${skip} already installed are skipped` : ''} · ${size}`,
|
|
1195
|
+
willUpdateN: (n, size) => `Will update ${n} plugin(s) · ${size}`,
|
|
1196
|
+
alreadyInstalled: 'Already installed, skipped', afterUpdateRefresh: 'Takes effect after restarting VibeDev',
|
|
1197
|
+
acctTitle: 'Needs a VibeDev account, billed by use',
|
|
1198
|
+
acctBody: (names) => `${names}: inside VibeDev it uses the account you are already signed in with; in DSH, sign in with "Sign in to VibeDev" at the bottom of the sidebar or in Settings → VibeDev account. Installing itself is free.`,
|
|
1199
|
+
coolUpdate: (names, end) => `${names} was published less than a day ago. An update usually makes pnpm add another rule with the same package name to your configuration, and it only honours the first rule per name, so the update may be blocked and installs and removals of every plugin may fail until ${end}. The safer course is to update after ${end}. Updating does not touch the project files in your workspace.`,
|
|
1200
|
+
updatesBannerT: (n) => `${n} update${n === 1 ? '' : 's'} available`, updatesBannerOpen: 'View updates', updatesBannerMore: ', …', badgeTitle: (n) => `VibeDev Ecosystem: ${n} update${n === 1 ? '' : 's'} available`,
|
|
1201
|
+
noRefreshT: 'Do not reload the page; quit VibeDev completely and reopen it',
|
|
1202
|
+
noRefreshB: (names) => `${names} was updated, or removed and put back, after VibeDev started. When the desktop app reloads the page it uses the plugin list from the moment VibeDev started, and these plugins' files have changed since, so a reload makes startup fail and shows the crash window (your data is not lost). Restarting does not have this problem.`,
|
|
1203
|
+
updateKeeps: 'Updating does not touch the project files in your workspace.', versionOf: (v) => `v${v}`, checkUpdate: 'Check for updates', checking: 'Checking…', dismiss: 'Dismiss',
|
|
1204
|
+
selfOk: (v) => `The VibeDev Ecosystem is up to date (${v}).`,
|
|
1205
|
+
selfAhead: (cur, latest) => `You are running ${cur}, which is newer than ${latest} on npm (probably a local build).`,
|
|
1206
|
+
selfNewT: (latest, cur) => `A newer VibeDev Ecosystem is available: ${latest} (you have ${cur})`,
|
|
1207
|
+
selfBuiltIn: 'The VibeDev Ecosystem is built into VibeDev Next and updates with the app: the newer version comes with the next VibeDev Next release, with nothing to reinstall on the Plugins page.',
|
|
1208
|
+
selfUpdatable: 'The VibeDev Ecosystem is built into VibeDev Next and can also be updated directly: the new version goes into your configuration and takes effect after VibeDev Next restarts. The version shipped with the app stays, and you can return to it any time.',
|
|
1209
|
+
providedUpdatable: 'This plugin is supplied by the app; no separate installation is needed. When a newer version is out you can update it under "Updates"; it takes effect after VibeDev Next restarts, and the version shipped with the app stays.',
|
|
1210
|
+
builtInUpdated: (local, shipped) => `Running the update ${local} (shipped with the app: ${shipped}).`,
|
|
1211
|
+
builtInPending: (local) => `${local} is downloaded and takes effect after VibeDev Next restarts.`,
|
|
1212
|
+
restoreBuiltIn: (shipped) => `Return to ${shipped} shipped with the app`,
|
|
1213
|
+
builtInRunUpdate: (v) => `Updating to ${v}…`, builtInRunRestore: 'Returning to the version shipped with the app…',
|
|
1214
|
+
builtInDoneUpdateT: (v) => `${v} downloaded`, builtInDoneRestoreT: (v) => `Back to ${v} shipped with the app`,
|
|
1215
|
+
builtInDoneB: 'Takes effect after VibeDev Next restarts. The VibeDev Ecosystem will not restart the app for you; save your work, then quit completely and reopen.',
|
|
1216
|
+
officialSummary: 'Discover, install and manage plugins made by VibeDev',
|
|
1217
|
+
officialPage: 'The VibeDev Ecosystem is built into VibeDev Next. Discover, install and manage plugins made by VibeDev there.',
|
|
1218
|
+
officialOpen: 'Open the VibeDev Ecosystem',
|
|
1219
|
+
selfNewB: 'The VibeDev Ecosystem cannot update itself. On the Plugins page of VibeDev, remove "VibeDev Ecosystem", then click "Add plugin" and enter the full package name below (the @vibedev-si/ prefix is required), and finally quit VibeDev completely and reopen it.',
|
|
1220
|
+
selfCool: (pub, end) => `This version was published ${pub}. pnpm normally waits a full day before allowing a new version, so updating now may be blocked and installs and removals of other plugins may fail for a while. Updating after ${end} is safer.`,
|
|
1221
|
+
selfFailT: 'Could not read the latest version', selfFailB: (list) => `${list ? `No registry answered: ${list}. ` : 'The check got no answer. '}This does not mean you are up to date; try again later.`,
|
|
1222
|
+
copyPkg: 'Copy package name', copiedPkg: 'Copied', viewVersion: 'View this version',
|
|
1223
|
+
stepsH: 'What will run (click to expand)',
|
|
1224
|
+
stepsFoot: 'Done through the VibeDev plugin manager. Only the plugins listed above are touched, and you can disable or remove them any time.',
|
|
1225
|
+
consent: (upd) => `Clicking "Confirm and ${upd ? 'update' : 'install'}" means you agree to process the plugins above`,
|
|
1226
|
+
installing: 'Installing', progress: (d, n) => `${d} / ${n} done · keep this page open`,
|
|
1227
|
+
stWait: 'Waiting', stInspect: 'Checking', stInstall: 'Downloading', stEnable: 'Enabling', stDone: 'Enabled', stFail: 'Failed', stHold: 'Needs your OK', stSkip: 'Installed', stOldOff: 'Disabling the old package', stOldRemove: 'Removing the old package', stRemoveCurrent: 'Removing the current version', stRestore: 'Restoring the previous version',
|
|
1228
|
+
replacesOld: (old) => `replaces ${old}`,
|
|
1229
|
+
switchNote: (olds) => `Replaces the old package ${olds}: once the new one is installed, the old one is disabled and the new one enabled, and the old one is removed only after that worked; if the new one cannot be enabled, the old one is turned back on.`,
|
|
1230
|
+
logH: 'Install log', cancelInstall: 'Cancel install', cancelHintOk: 'You can cancel; plugins already installed are kept', cancelHintLate: 'Already applying, cannot cancel',
|
|
1231
|
+
doneTitle: 'Install complete', doneSub: (d, n) => `${d} / ${n} plugin(s) installed`,
|
|
1232
|
+
doneHead: (d) => `Installed and enabled ${d} plugin(s)`, doneLoaded: 'VibeDev loads them itself and they usually show up within seconds; there is no need to reload the page. If the sidebar still has not changed after a while, quit VibeDev completely and reopen it.',
|
|
1233
|
+
nextH: 'Next',
|
|
1234
|
+
nextFilm: 'Open the right sidebar in any session and use "Script", "Storyboard" or "Director" on the start page.',
|
|
1235
|
+
nextVibedev: 'VibeDev Account & Models: choose "Sign in to VibeDev" at the bottom of the sidebar (inside VibeDev your signed-in account is used); VibeDev models then appear in the model picker, and you can ask the agent to "generate an image of…".',
|
|
1236
|
+
nextViewer: 'Open an mp4, wav or html file from the file tree in the right sidebar to preview it; "Media gallery" is on the sidebar start page and at the top of the file tree.',
|
|
1237
|
+
nextMarket: 'The plugin market lives in the "Community" tab here; it also appears in Settings.',
|
|
1238
|
+
nextMarketHint: 'Want more community plugins? Back on the home page, "Prerequisites and companions" installs the plugin market in one click.',
|
|
1239
|
+
gotIt: 'Got it', settling: 'Waiting for VibeDev to finish loading these plugins; please do not close or reload the page yet…', waitingHost: 'Waiting for VibeDev to load the previous plugin…',
|
|
1240
|
+
restartTitle: 'Installed, restart needed', restartHead: 'Installed, but VibeDev must restart to take effect',
|
|
1241
|
+
restartBody: (n) => `${n} plugin(s) were written to your configuration. The VibeDev Ecosystem will not restart the app for you; save your work, then quit completely and reopen.`,
|
|
1242
|
+
failTitle: 'Install not finished',
|
|
1243
|
+
fNetworkT: 'Could not download the plugin', fNetworkB: (n, d) => `${n > 1 ? `${n} registries were tried and none answered.` : 'Could not reach the npm registry.'} Check your network or proxy and retry.${d ? ` (${String(d).slice(0, 140)})` : ''}`,
|
|
1244
|
+
fBuildsT: "This plugin's dependencies need to run build scripts", fBuildsB: (names) => `Packages waiting for your decision: ${names}. Build scripts run commands with your user's permissions; allow them only if you trust the source.`,
|
|
1245
|
+
fIncompatT: 'This VibeDev version does not meet the requirements', fIncompatB: (s) => `${s}Install was blocked and nothing was downloaded.`,
|
|
1246
|
+
fNotFoundT: 'That version was not found on npm', fNotFoundB: 'The version in the catalog may have been withdrawn or not yet mirrored. Retry later, or report it on GitHub.',
|
|
1247
|
+
fMismatchT: 'Blocked: what npm returned does not match the catalog', fMismatchB: (d) => `Nothing was installed, for safety. ${d}`,
|
|
1248
|
+
fExemptT: "The package manager's new-release cooldown is blocking all installs and uninstalls", fExemptB: (c, when) => `${c ? c + ' ' : ''}was published less than a day ago and pnpm does not allow it by default. This affects installing and removing every plugin until${when ? ' ' + when + ',' : ''} when the cooldown ends.`,
|
|
1249
|
+
fBusyT: 'Cannot do that right now', fBusyB: 'A session is running or the plugin is in use. End the related sessions and try again.',
|
|
1250
|
+
fRefusedT: 'The plugin manager refused this request', fFailedT: 'The install did not succeed', fFailedB: 'The plugin manager gave no further detail; see the log.',
|
|
1251
|
+
keptDone: (n) => `The ${n} plugin(s) already finished are kept; `, noChangeFail: 'the failed plugin did not change your plugin configuration.', noChangeHold: 'nothing in your plugin configuration changes until you confirm.',
|
|
1252
|
+
installedNotEnabled: 'The plugin is installed but enabling failed; you can enable it by hand on the Plugins page in Settings.',
|
|
1253
|
+
updRestored: (spec) => `The new version did not install, so ${spec} was installed again with its previous on/off state.`,
|
|
1254
|
+
updLostT: 'The previous version could not be restored', updLostB: (spec) => `The new version did not install; the previous version was removed and installing it again failed too. Add ${spec} on the Plugins page later, or use "Copy install command".`,
|
|
1255
|
+
retry: 'Retry', approveRetry: 'Allow these scripts and retry', skipThis: 'Skip this plugin', copyCmd: 'Copy install command', later: 'Try later', seeCompat: 'See compatibility notes',
|
|
1256
|
+
uncertainT: 'Could not confirm the result', uncertainB: 'The connection to the plugin manager dropped; the install may have finished. Click "Check again" to see the real state.', recheck: 'Check again',
|
|
1257
|
+
migrateTitle: (old) => `Old plugin ${old} detected`,
|
|
1258
|
+
migrateBody: (old, nw) => `It has been renamed to ${nw}. They cannot both be enabled or they may conflict.`,
|
|
1259
|
+
migrateOrder: 'Switch order: install the new one disabled → disable the old one → enable the new one → remove the old one once it works.', migrateBtn: 'Switch now',
|
|
1260
|
+
migrating: 'Switching', migDone: 'Switched to the new package and removed the old one.', migHalf: 'Switched to the new package; the old one is disabled but could not be removed, remove it later on the Plugins page.',
|
|
1261
|
+
migRestored: 'Could not enable the new package, so the old one was turned back on; nothing you use is affected.',
|
|
1262
|
+
oldStillOn: (old) => `Could not disable the old package ${old}, so the new one was installed but not enabled (they cannot both be on). Try again later.`,
|
|
1263
|
+
halfRemovedT: 'The plugin was disabled but not fully removed', halfRemovedB: 'It is now "disabled but still installed". You can enable it again, or fix the cause and retry removal.', reenable: 'Enable again', retryUninstall: 'Retry removal',
|
|
1264
|
+
communityEmptyT: 'Install the plugin market to browse community plugins here',
|
|
1265
|
+
communityEmptyB: (author) => `The plugin market is a third-party plugin maintained by ${author}. Once installed, you can browse, search and install community plugins in this tab.`,
|
|
1266
|
+
communityNote: (size) => `About ${size} · third-party plugin; the VibeDev Ecosystem does not review its code`,
|
|
1267
|
+
communityViaMarket: (name) => `Provided by ${name}`, communityAbout: (name) => `About ${name}`,
|
|
1268
|
+
communityUnlisted: 'The DSH community market is not in the current catalog. An installed market can still be opened or removed from the DSH Plugins page.',
|
|
1269
|
+
discoverT: 'Community plugins are in Discover on the Plugins page',
|
|
1270
|
+
discoverB: 'Community plugins are third-party code. VibeDev reviews each one before listing it, and lists only the exact versions it reviewed. Browse and install them in Plugins → Discover.',
|
|
1271
|
+
discoverOpen: 'Open Discover',
|
|
1272
|
+
discoverFailed: 'Could not open it. Choose "Plugins" in the sidebar, then "Discover".',
|
|
1273
|
+
communityNoEmbed: 'The plugin market is installed but its interface could not be embedded here. Open "Plugin Market" in Settings.',
|
|
1274
|
+
allUpToDate: 'Verified: no stable updates for the installed VibeDev plugins', nothingInstalled: 'No VibeDev plugin is installed yet',
|
|
1275
|
+
releaseChecking: 'Checking VibeDev releases on the official npm registry…',
|
|
1276
|
+
releaseChecked: 'Versions verified on the official npm registry. Updates use the corresponding exact version.',
|
|
1277
|
+
releaseUnavailable: 'Some versions could not be verified on the official npm registry. Confirmed releases and the bundled catalog remain available; this does not mean everything is current.',
|
|
1278
|
+
releaseNoVerifiedUpdates: 'No update has been verified yet. Try checking again later.',
|
|
1279
|
+
selfRowHelp: 'VibeDev Ecosystem itself has a newer version. Update it on the DSH Plugins page using the exact spec below, then quit and reopen the app.',
|
|
1280
|
+
appUpdateHelp: 'This component is built into the app. A newer npm version exists; update the app to obtain it. The ecosystem will not install an external duplicate.',
|
|
1281
|
+
loadFail: 'Could not read the installed plugins', loadFailB: 'The plugin manager is unavailable for now. You can still install by hand with "Copy install command".',
|
|
1282
|
+
noManager: 'This environment does not provide a plugin manager, so one-click install is unavailable. Use the command in the details instead.',
|
|
1283
|
+
sizeSmall: 'tiny',
|
|
1284
|
+
},
|
|
1285
|
+
}
|
|
1286
|
+
|
|
1287
|
+
const pick = (localeId) => (String(localeId ?? '').toLowerCase().startsWith('zh') ? 'zh' : 'en')
|
|
1288
|
+
const L = (obj, lang) => (obj && typeof obj === 'object' ? obj[lang] ?? obj.en ?? obj.zh : obj)
|
|
1289
|
+
|
|
1290
|
+
function fmtSize(kb) {
|
|
1291
|
+
if (kb >= 1024) return `${(kb / 1024).toFixed(kb >= 10240 ? 0 : 1)} MB`
|
|
1292
|
+
return `${kb < 100 ? Math.max(kb / 1024, 0.01).toFixed(2) : (kb / 1024).toFixed(1)} MB`
|
|
1293
|
+
}
|
|
1294
|
+
|
|
1295
|
+
/**
|
|
1296
|
+
* The Plugin Center screen. One React component tree, driven entirely by:
|
|
1297
|
+
* - the catalog (static data),
|
|
1298
|
+
* - `host` : { pm, locale, openUrl?, copy?, renderMarket?, pluginsTabs?, onChanged?, onLocale?, chooseRegistry?, settle? }
|
|
1299
|
+
* so the SAME code runs inside VibeDev and inside the Chrome test bench with a fake `pm`.
|
|
1300
|
+
*
|
|
1301
|
+
* Colours come only from the host's --dsw-alias-* variables (fallbacks are for the test bench).
|
|
1302
|
+
*/
|
|
1303
|
+
|
|
1304
|
+
|
|
1305
|
+
/** The white/black '#fff'/'#000' the engine picks, as an rgb() string its ratio helper accepts. */
|
|
1306
|
+
const rgbOfHex = (hex) => (hex === '#000' ? 'rgb(0,0,0)' : 'rgb(255,255,255)')
|
|
1307
|
+
|
|
1308
|
+
/** The alpha of a computed colour: 'rgb(...)' is opaque, 'rgba(...)' and 'transparent' are not. */
|
|
1309
|
+
function alphaOfColor(color) {
|
|
1310
|
+
const s = String(color ?? '').trim()
|
|
1311
|
+
if (s === 'transparent' || s === '') return 0
|
|
1312
|
+
const m = /rgba?\(([^)]+)\)/.exec(s)
|
|
1313
|
+
if (!m) return 0
|
|
1314
|
+
const parts = m[1].split(',').map((x) => x.trim())
|
|
1315
|
+
return parts.length < 4 ? 1 : Number(parts[3])
|
|
1316
|
+
}
|
|
1317
|
+
|
|
1318
|
+
/**
|
|
1319
|
+
* Which controls inside the embedded market cannot be read as they are, and what to paint them.
|
|
1320
|
+
* Pure: the caller passes what the browser computed for each candidate. Only an opaque filled
|
|
1321
|
+
* button with text, that is neither a toggle nor disabled and whose own colours fall short of
|
|
1322
|
+
* 4.5, is bridged — to whichever of black/white reads better on ITS OWN background. Nothing
|
|
1323
|
+
* transparent, textless, toggled or disabled is touched, and no background is changed.
|
|
1324
|
+
* @param rows - one row per candidate: { key, text, color, background, backgroundImage, toggle, disabled }.
|
|
1325
|
+
* @returns one fix per candidate that needs one, with the ratio it had and the ratio it gets.
|
|
1326
|
+
*/
|
|
1327
|
+
function marketTextFixes(rows) {
|
|
1328
|
+
const out = []
|
|
1329
|
+
for (const row of rows ?? []) {
|
|
1330
|
+
if (!row || !row.text || row.toggle || row.disabled) continue
|
|
1331
|
+
if (row.backgroundImage && row.backgroundImage !== 'none') continue
|
|
1332
|
+
if (!(alphaOfColor(row.background) >= 1)) continue
|
|
1333
|
+
const ratio = E.contrastRatio(row.color, row.background)
|
|
1334
|
+
if (ratio === undefined || ratio >= 4.5) continue
|
|
1335
|
+
const color = E.readableTextOn(row.background)
|
|
1336
|
+
const improved = E.contrastRatio(rgbOfHex(color), row.background)
|
|
1337
|
+
if (improved === undefined || improved <= ratio) continue
|
|
1338
|
+
out.push({ key: row.key, color, ratio, improved })
|
|
1339
|
+
}
|
|
1340
|
+
return out
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1343
|
+
/** The two colours the bridge may paint, as the attribute value that selects them in the CSS block. */
|
|
1344
|
+
const TEXT_ATTR = 'data-vdc-text'
|
|
1345
|
+
|
|
1346
|
+
function startMarketTextBridge(getRoot) {
|
|
1347
|
+
const marked = new Set()
|
|
1348
|
+
let queued = false
|
|
1349
|
+
let disposed = false
|
|
1350
|
+
const scan = () => {
|
|
1351
|
+
queued = false
|
|
1352
|
+
if (disposed) return
|
|
1353
|
+
const root = getRoot()
|
|
1354
|
+
if (!root) return
|
|
1355
|
+
const els = Array.from(root.querySelectorAll('button'))
|
|
1356
|
+
// Judge the market's own colours, never the ones this bridge painted last time: measuring our
|
|
1357
|
+
// own override would make the decision oscillate (mark -> readable -> unmark -> unreadable).
|
|
1358
|
+
for (const el of marked) el.removeAttribute(TEXT_ATTR)
|
|
1359
|
+
marked.clear()
|
|
1360
|
+
const rows = els.map((el, i) => {
|
|
1361
|
+
const cs = getComputedStyle(el)
|
|
1362
|
+
return {
|
|
1363
|
+
key: String(i), text: (el.textContent || '').trim().length > 0,
|
|
1364
|
+
color: cs.color, background: cs.backgroundColor, backgroundImage: cs.backgroundImage,
|
|
1365
|
+
toggle: el.hasAttribute('aria-pressed') || el.hasAttribute('aria-checked') || el.getAttribute('role') === 'switch' || el.getAttribute('role') === 'checkbox',
|
|
1366
|
+
disabled: el.disabled === true,
|
|
1367
|
+
}
|
|
1368
|
+
})
|
|
1369
|
+
for (const fix of marketTextFixes(rows)) {
|
|
1370
|
+
const el = els[Number(fix.key)]
|
|
1371
|
+
if (!el) continue
|
|
1372
|
+
el.setAttribute(TEXT_ATTR, fix.color === '#000' ? 'dark' : 'light')
|
|
1373
|
+
marked.add(el)
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
const schedule = () => { if (disposed || queued) return; queued = true; Promise.resolve().then(scan) }
|
|
1377
|
+
scan()
|
|
1378
|
+
const mo = typeof MutationObserver === 'function' ? new MutationObserver((records) => {
|
|
1379
|
+
// Writing the mark is what a scan does, so a record about it must never schedule another pass.
|
|
1380
|
+
if (records.length && records.every((r) => r.attributeName === TEXT_ATTR)) return
|
|
1381
|
+
schedule()
|
|
1382
|
+
}) : null
|
|
1383
|
+
if (mo) {
|
|
1384
|
+
mo.observe(document.documentElement, { attributes: true })
|
|
1385
|
+
if (document.body) mo.observe(document.body, { attributes: true })
|
|
1386
|
+
const root = getRoot()
|
|
1387
|
+
// The market mounts late and swaps what it shows, often without changing its box: watch its
|
|
1388
|
+
// own nodes and its controls' state, never our mark (filtered out, and guarded above).
|
|
1389
|
+
if (root) mo.observe(root, { childList: true, subtree: true, attributes: true, attributeFilter: ['class', 'style', 'disabled', 'aria-pressed', 'aria-checked'] })
|
|
1390
|
+
}
|
|
1391
|
+
// One deferred pass, for content already laid out when the observers attached.
|
|
1392
|
+
const raf = typeof requestAnimationFrame === 'function' ? requestAnimationFrame(schedule) : null
|
|
1393
|
+
// Only what happens inside the market matters: a document-wide pointer stream would scan the
|
|
1394
|
+
// whole subtree on every mouse move over the panel.
|
|
1395
|
+
const onPointer = (event) => {
|
|
1396
|
+
const root = getRoot()
|
|
1397
|
+
if (root && event.target instanceof Node && root.contains(event.target)) schedule()
|
|
1398
|
+
}
|
|
1399
|
+
const root0 = getRoot()
|
|
1400
|
+
if (root0) {
|
|
1401
|
+
root0.addEventListener('pointerover', onPointer, true)
|
|
1402
|
+
root0.addEventListener('pointerout', onPointer, true)
|
|
1403
|
+
root0.addEventListener('focusin', onPointer, true)
|
|
1404
|
+
root0.addEventListener('focusout', onPointer, true)
|
|
1405
|
+
}
|
|
1406
|
+
return () => {
|
|
1407
|
+
disposed = true
|
|
1408
|
+
if (mo) mo.disconnect()
|
|
1409
|
+
if (raf !== null) cancelAnimationFrame(raf)
|
|
1410
|
+
if (root0) {
|
|
1411
|
+
root0.removeEventListener('pointerover', onPointer, true)
|
|
1412
|
+
root0.removeEventListener('pointerout', onPointer, true)
|
|
1413
|
+
root0.removeEventListener('focusin', onPointer, true)
|
|
1414
|
+
root0.removeEventListener('focusout', onPointer, true)
|
|
1415
|
+
}
|
|
1416
|
+
for (const el of marked) el.removeAttribute(TEXT_ATTR)
|
|
1417
|
+
marked.clear()
|
|
1418
|
+
}
|
|
1419
|
+
}
|
|
1420
|
+
|
|
1421
|
+
function createCenter(React, catalog, host) {
|
|
1422
|
+
const h = React.createElement
|
|
1423
|
+
const { useState, useEffect, useRef, useCallback, useMemo, useSyncExternalStore } = React
|
|
1424
|
+
const NO_ACCOUNT = Object.freeze({ available: false, signedIn: false })
|
|
1425
|
+
const noSubscription = () => () => {}
|
|
1426
|
+
const readNoAccount = () => NO_ACCOUNT
|
|
1427
|
+
const FRAG = React.Fragment
|
|
1428
|
+
|
|
1429
|
+
const PLUGINS = catalog.plugins
|
|
1430
|
+
const byId = (id) => PLUGINS.find((p) => p.id === id)
|
|
1431
|
+
const MARKET = 'dshmarket'
|
|
1432
|
+
let LANG = 'zh' // set at the top of every render; icon glyphs are letters in English, characters in Chinese
|
|
1433
|
+
|
|
1434
|
+
/* ── what the page showed last ─────────────────────────────────────────────
|
|
1435
|
+
* Opening the center must show the newest thing it knows at once. Without this it drew the catalog this
|
|
1436
|
+
* client was built with, then swapped in the online one when /vdc/updates answered (2-4 s once the host's
|
|
1437
|
+
* one-minute cache has expired), and offered 安装 on every card until the installed list arrived: the flash.
|
|
1438
|
+
* The last successful answer is kept for the life of the page and in the host's memory (localStorage in the
|
|
1439
|
+
* app), and gated by E.restoredAnswer on the way back in; the installed list is kept for the life of the
|
|
1440
|
+
* page only, since an app restart is exactly when it changes. Both are replaced by the fresh reads that
|
|
1441
|
+
* every opening still makes, once each, as before. */
|
|
1442
|
+
const MEMORY_KEY = 'vibedev-ecosystem:last-updates:v1'
|
|
1443
|
+
let lastAnswer // undefined until read; null when nothing usable was kept
|
|
1444
|
+
let lastBundles = null
|
|
1445
|
+
const rememberedAnswer = () => {
|
|
1446
|
+
if (lastAnswer === undefined) {
|
|
1447
|
+
let stored = null
|
|
1448
|
+
try { const raw = host.memory?.read(MEMORY_KEY); stored = raw ? JSON.parse(raw) : null } catch { stored = null }
|
|
1449
|
+
lastAnswer = E.restoredAnswer(stored, catalog)
|
|
1450
|
+
}
|
|
1451
|
+
return lastAnswer
|
|
1452
|
+
}
|
|
1453
|
+
const rememberAnswer = (answer) => {
|
|
1454
|
+
if (answer?.ok !== true) return
|
|
1455
|
+
lastAnswer = answer
|
|
1456
|
+
try { host.memory?.write(MEMORY_KEY, JSON.stringify({ ...answer, keptAt: new Date().toISOString() })) } catch { /* the next opening reads it fresh */ }
|
|
1457
|
+
}
|
|
1458
|
+
|
|
1459
|
+
/* ── one check at app start, and the number on the sidebar entry ─────────────
|
|
1460
|
+
* The app loads this client half at boot. It checks once then (never on a timer), so the sidebar entry can show
|
|
1461
|
+
* that an update is waiting before the page is ever opened; the installed list is re-read, without going online,
|
|
1462
|
+
* whenever plugins change. The page reuses a check under a minute old and otherwise asks once per opening, as
|
|
1463
|
+
* before; an explicit check always asks. The startup check and the page share one request in flight. */
|
|
1464
|
+
const FRESH_MS = 60_000
|
|
1465
|
+
let inflight = null
|
|
1466
|
+
let lastChecked = null // { at, answer }: the most recent answer this page's life received, ok or not
|
|
1467
|
+
const badge = { count: 0, listeners: new Set() }
|
|
1468
|
+
const setBadge = (count) => {
|
|
1469
|
+
if (disposed || badge.count === count) return
|
|
1470
|
+
badge.count = count
|
|
1471
|
+
for (const listener of [...badge.listeners]) { try { listener() } catch { /* one subscriber must not stop the others */ } }
|
|
1472
|
+
}
|
|
1473
|
+
const requestUpdates = (signal) => {
|
|
1474
|
+
if (inflight) return inflight
|
|
1475
|
+
inflight = Promise.resolve().then(() => host.checkUpdates(signal)).catch(() => undefined).then((answer) => {
|
|
1476
|
+
rememberAnswer(answer)
|
|
1477
|
+
if (answer !== undefined) lastChecked = { at: Date.now(), answer }
|
|
1478
|
+
return answer
|
|
1479
|
+
}).finally(() => { inflight = null })
|
|
1480
|
+
return inflight
|
|
1481
|
+
}
|
|
1482
|
+
const recount = async () => {
|
|
1483
|
+
if (!host.pm) return
|
|
1484
|
+
const result = await E.readBundleInventory(host.pm)
|
|
1485
|
+
if (!result?.ok) return
|
|
1486
|
+
lastBundles = result.value
|
|
1487
|
+
// The newest successful answer (a failed check must not hide updates found before).
|
|
1488
|
+
setBadge(E.updateCount(catalog, rememberedAnswer(), result.value, host.version?.() ?? '0.0.0'))
|
|
1489
|
+
}
|
|
1490
|
+
let started = false
|
|
1491
|
+
let disposed = false
|
|
1492
|
+
let stopStartup = null
|
|
1493
|
+
const startupLifetime = new AbortController()
|
|
1494
|
+
const startup = () => {
|
|
1495
|
+
if (started || disposed) return
|
|
1496
|
+
started = true
|
|
1497
|
+
void (async () => {
|
|
1498
|
+
if (host.checkUpdates && !lastChecked) await requestUpdates(startupLifetime.signal)
|
|
1499
|
+
if (!disposed) await recount()
|
|
1500
|
+
})().catch(() => {})
|
|
1501
|
+
stopStartup = host.onChanged?.(() => { void recount().catch(() => {}) })
|
|
1502
|
+
}
|
|
1503
|
+
const dispose = () => {
|
|
1504
|
+
disposed = true
|
|
1505
|
+
startupLifetime.abort()
|
|
1506
|
+
stopStartup?.()
|
|
1507
|
+
badge.listeners.clear()
|
|
1508
|
+
}
|
|
1509
|
+
|
|
1510
|
+
/* ── style ─────────────────────────────────────────────────────────────── */
|
|
1511
|
+
const CSS = `.vdc{--bg:var(--dsw-alias-bg-base,#fff);--l1:var(--dsw-alias-bg-layer-1,#f6f7f9);--l2:var(--dsw-alias-bg-layer-2,#eceef3);--ov:var(--dsw-alias-bg-overlay,#fff);
|
|
1512
|
+
--b1:var(--dsw-alias-border-l1,rgba(20,24,40,.09));--b2:var(--dsw-alias-border-l2,rgba(20,24,40,.18));--brand:var(--dsw-alias-brand-primary,#4d6bfe);
|
|
1513
|
+
--t1:var(--dsw-alias-label-primary,#1b1d24);--t2:var(--dsw-alias-label-secondary,#6c7080);--ok:var(--dsw-alias-state-success-primary,#1f9d62);
|
|
1514
|
+
--warn:var(--dsw-alias-state-warn-primary,#c98a00);--err:var(--dsw-alias-state-error-primary,#d9363e);--idle:var(--dsw-alias-state-idle-primary,#9aa0ad);
|
|
1515
|
+
position:relative;display:flex;flex-direction:column;height:100%;min-height:0;background:var(--bg);color:var(--t1);font:14px/1.55 system-ui,-apple-system,"Segoe UI","Microsoft YaHei",sans-serif;overflow:hidden}
|
|
1516
|
+
.vdc :not(:where([data-vdc-market], [data-vdc-market] *)){box-sizing:border-box}
|
|
1517
|
+
.vdc button:not(:where([data-vdc-market], [data-vdc-market] *)){font:inherit;color:inherit;cursor:pointer}
|
|
1518
|
+
[data-vdc-market] button[data-vdc-text="light"]{color:#fff}
|
|
1519
|
+
[data-vdc-market] button[data-vdc-text="dark"]{color:#000}
|
|
1520
|
+
.vdc svg:not(:where([data-vdc-market], [data-vdc-market] *)){flex:none}
|
|
1521
|
+
.vdc .top:not(:where([data-vdc-market], [data-vdc-market] *)){display:flex;align-items:center;gap:18px;padding:12px 24px;border-bottom:1px solid var(--b1);background:var(--bg);flex:none;flex-wrap:wrap}
|
|
1522
|
+
.vdc .brand:not(:where([data-vdc-market], [data-vdc-market] *)){display:flex;align-items:center;gap:10px}
|
|
1523
|
+
.vdc .logo:not(:where([data-vdc-market], [data-vdc-market] *)){width:30px;height:30px;border-radius:9px;background:linear-gradient(135deg,#4d6bfe,#8f6bff);display:grid;place-items:center;color:#fff}
|
|
1524
|
+
.vdc h1:not(:where([data-vdc-market], [data-vdc-market] *)){font-size:16px;margin:0;font-weight:500}
|
|
1525
|
+
.vdc .pill:not(:where([data-vdc-market], [data-vdc-market] *)){font-size:11px;padding:1px 8px;border-radius:99px;border:1px solid var(--b2);color:var(--t2)}
|
|
1526
|
+
.vdc .tabs:not(:where([data-vdc-market], [data-vdc-market] *)){display:flex;gap:4px}
|
|
1527
|
+
.vdc .tab:not(:where([data-vdc-market], [data-vdc-market] *)){border:0;background:transparent;padding:6px 12px;border-radius:8px;color:var(--t2);font-weight:500}
|
|
1528
|
+
.vdc .tab:hover:not(:where([data-vdc-market], [data-vdc-market] *)){background:var(--l1)}
|
|
1529
|
+
.vdc .tab.on:not(:where([data-vdc-market], [data-vdc-market] *)){background:var(--l2);color:var(--t1)}
|
|
1530
|
+
.vdc .tab .n:not(:where([data-vdc-market], [data-vdc-market] *)){margin-left:5px;font-size:11px;padding:0 6px;border-radius:99px;background:var(--brand);color:var(--on-brand,#fff)}
|
|
1531
|
+
.vdc .sp:not(:where([data-vdc-market], [data-vdc-market] *)){flex:1}
|
|
1532
|
+
.vdc .ghost:not(:where([data-vdc-market], [data-vdc-market] *)){border:1px solid var(--b2);background:transparent;border-radius:8px;padding:6px 12px}
|
|
1533
|
+
.vdc .ghost:hover:not(:where([data-vdc-market], [data-vdc-market] *)){background:var(--l1)}
|
|
1534
|
+
.vdc .scroll:not(:where([data-vdc-market], [data-vdc-market] *)){flex:1;overflow:auto;min-height:0}
|
|
1535
|
+
.vdc .wrap:not(:where([data-vdc-market], [data-vdc-market] *)){max-width:1060px;margin:0 auto;padding:20px 24px 56px}
|
|
1536
|
+
.vdc .banner:not(:where([data-vdc-market], [data-vdc-market] *)){display:flex;gap:12px;align-items:flex-start;padding:12px 14px;border-radius:12px;border:1px solid color-mix(in srgb,var(--warn) 45%,var(--b1));background:color-mix(in srgb,var(--warn) 9%,var(--bg));margin-bottom:16px}
|
|
1537
|
+
.vdc .banner .grow:not(:where([data-vdc-market], [data-vdc-market] *)){flex:1}
|
|
1538
|
+
.vdc .banner.info:not(:where([data-vdc-market], [data-vdc-market] *)){align-items:center;margin-bottom:16px;border-color:color-mix(in srgb,var(--brand) 40%,var(--b1));background:color-mix(in srgb,var(--brand) 7%,var(--bg))}
|
|
1539
|
+
.vdc .banner.info > svg:not(:where([data-vdc-market], [data-vdc-market] *)){color:var(--brand);flex:none}
|
|
1540
|
+
.vdc .banner small:not(:where([data-vdc-market], [data-vdc-market] *)){display:block;color:var(--t2);margin-top:2px}
|
|
1541
|
+
.vdc .intro:not(:where([data-vdc-market], [data-vdc-market] *)){border:1px solid var(--b1);border-radius:16px;padding:18px 20px;background:linear-gradient(135deg,color-mix(in srgb,var(--brand) 8%,var(--bg)),var(--bg) 60%);margin-bottom:16px}
|
|
1542
|
+
.vdc .intro h2:not(:where([data-vdc-market], [data-vdc-market] *)){margin:0 0 4px;font-size:18px}
|
|
1543
|
+
.vdc .intro .lead:not(:where([data-vdc-market], [data-vdc-market] *)){margin:0 0 14px;color:var(--t2)}
|
|
1544
|
+
.vdc .three:not(:where([data-vdc-market], [data-vdc-market] *)){display:grid;grid-template-columns:repeat(auto-fit,minmax(230px,1fr));gap:12px}
|
|
1545
|
+
.vdc .fact:not(:where([data-vdc-market], [data-vdc-market] *)){background:var(--bg);border:1px solid var(--b1);border-radius:12px;padding:12px 14px}
|
|
1546
|
+
.vdc .fact b:not(:where([data-vdc-market], [data-vdc-market] *)){display:block;margin-bottom:2px}
|
|
1547
|
+
.vdc .fact span:not(:where([data-vdc-market], [data-vdc-market] *)){color:var(--t2);font-size:13px}
|
|
1548
|
+
.vdc .ic:not(:where([data-vdc-market], [data-vdc-market] *)){width:28px;height:28px;border-radius:8px;display:grid;place-items:center;background:color-mix(in srgb,var(--brand) 14%,transparent);color:var(--brand);margin-bottom:8px}
|
|
1549
|
+
.vdc .not:not(:where([data-vdc-market], [data-vdc-market] *)){margin-top:12px;font-size:13px;color:var(--t2)}
|
|
1550
|
+
.vdc .lnk:not(:where([data-vdc-market], [data-vdc-market] *)){color:var(--brand);font-weight:500;cursor:pointer;background:none;border:0;padding:0}
|
|
1551
|
+
.vdc .suite:not(:where([data-vdc-market], [data-vdc-market] *)){border:1px solid var(--b2);border-radius:16px;padding:16px 18px;margin-bottom:20px;background:var(--l1);display:grid;grid-template-columns:1fr auto;gap:12px 20px;align-items:center}
|
|
1552
|
+
.vdc .suite h3:not(:where([data-vdc-market], [data-vdc-market] *)){margin:0;font-size:16px;display:flex;align-items:center;gap:8px}
|
|
1553
|
+
.vdc .suite p:not(:where([data-vdc-market], [data-vdc-market] *)){margin:2px 0 0;color:var(--t2)}
|
|
1554
|
+
.vdc .suite .r:not(:where([data-vdc-market], [data-vdc-market] *)){text-align:right}
|
|
1555
|
+
.vdc .suite .r small:not(:where([data-vdc-market], [data-vdc-market] *)){display:block;color:var(--t2);margin-top:6px;font-size:12px}
|
|
1556
|
+
.vdc .chips:not(:where([data-vdc-market], [data-vdc-market] *)){grid-column:1/-1;display:flex;flex-wrap:wrap;gap:8px;align-items:center}
|
|
1557
|
+
.vdc .chip:not(:where([data-vdc-market], [data-vdc-market] *)){display:flex;align-items:center;gap:7px;padding:5px 10px 5px 6px;border-radius:99px;background:var(--bg);border:1px solid var(--b1);font-size:13px}
|
|
1558
|
+
.vdc .chip .st:not(:where([data-vdc-market], [data-vdc-market] *)){width:7px;height:7px;border-radius:50%;background:var(--idle)}
|
|
1559
|
+
.vdc .chip.done .st:not(:where([data-vdc-market], [data-vdc-market] *)){background:var(--ok)}
|
|
1560
|
+
.vdc .arrow:not(:where([data-vdc-market], [data-vdc-market] *)){color:var(--idle)}
|
|
1561
|
+
.vdc .btn:not(:where([data-vdc-market], [data-vdc-market] *)){border:1px solid var(--b2);background:var(--bg);padding:7px 14px;border-radius:9px;font-weight:500;display:inline-flex;align-items:center;gap:6px;white-space:nowrap}
|
|
1562
|
+
.vdc .btn:hover:not(:where([data-vdc-market], [data-vdc-market] *)){background:var(--l1)}
|
|
1563
|
+
.vdc .btn.primary:not(:where([data-vdc-market], [data-vdc-market] *)){background:var(--brand);border-color:var(--brand);color:var(--on-brand,#fff)}
|
|
1564
|
+
.vdc .btn.primary:hover:not(:where([data-vdc-market], [data-vdc-market] *)){filter:brightness(1.08)}
|
|
1565
|
+
.vdc .btn.big:not(:where([data-vdc-market], [data-vdc-market] *)){padding:10px 20px}
|
|
1566
|
+
.vdc .btn.sm:not(:where([data-vdc-market], [data-vdc-market] *)){padding:5px 9px}
|
|
1567
|
+
.vdc .btn[disabled]:not(:where([data-vdc-market], [data-vdc-market] *)){opacity:.5;cursor:default}
|
|
1568
|
+
.vdc .btn.ok:not(:where([data-vdc-market], [data-vdc-market] *)){color:var(--ok);border-color:color-mix(in srgb,var(--ok) 40%,var(--b1));background:color-mix(in srgb,var(--ok) 8%,var(--bg));pointer-events:none}
|
|
1569
|
+
.vdc .btn.warn:not(:where([data-vdc-market], [data-vdc-market] *)){background:color-mix(in srgb,var(--warn) 14%,var(--bg));border-color:color-mix(in srgb,var(--warn) 50%,var(--b1));color:var(--warn)}
|
|
1570
|
+
.vdc .btn.idle:not(:where([data-vdc-market], [data-vdc-market] *)){color:var(--t2)}
|
|
1571
|
+
.vdc .btn.ph:not(:where([data-vdc-market], [data-vdc-market] *)){width:76px;justify-content:center;border-color:transparent;background:var(--l2);pointer-events:none;animation:vdcph 1.2s ease-in-out infinite}
|
|
1572
|
+
.vdc .btn.big.ph:not(:where([data-vdc-market], [data-vdc-market] *)){width:132px}
|
|
1573
|
+
@keyframes vdcph{50%{opacity:.55}}
|
|
1574
|
+
@media (prefers-reduced-motion:reduce){.vdc .btn.ph{animation:none}}
|
|
1575
|
+
.vdc .sec:not(:where([data-vdc-market], [data-vdc-market] *)){display:flex;align-items:baseline;gap:10px;margin:6px 0 12px;flex-wrap:wrap}
|
|
1576
|
+
.vdc .sec h3:not(:where([data-vdc-market], [data-vdc-market] *)){margin:0;font-size:15px}
|
|
1577
|
+
.vdc .sec span:not(:where([data-vdc-market], [data-vdc-market] *)){color:var(--t2);font-size:13px}
|
|
1578
|
+
.vdc .grid:not(:where([data-vdc-market], [data-vdc-market] *)){display:grid;grid-template-columns:repeat(auto-fill,minmax(300px,1fr));gap:14px;margin-bottom:22px}
|
|
1579
|
+
.vdc .card:not(:where([data-vdc-market], [data-vdc-market] *)){border:1px solid var(--b1);border-radius:14px;padding:16px;background:var(--bg);display:flex;flex-direction:column;gap:10px;cursor:pointer;transition:border-color .15s,box-shadow .15s}
|
|
1580
|
+
.vdc .card:hover:not(:where([data-vdc-market], [data-vdc-market] *)){border-color:var(--b2);box-shadow:0 4px 18px rgba(0,0,0,.06)}
|
|
1581
|
+
.vdc .card .hd:not(:where([data-vdc-market], [data-vdc-market] *)){display:flex;gap:12px;align-items:center}
|
|
1582
|
+
.vdc .gl:not(:where([data-vdc-market], [data-vdc-market] *)){width:42px;height:42px;border-radius:12px;display:grid;place-items:center;color:#fff;font-weight:500;font-size:18px;flex:none}
|
|
1583
|
+
.vdc .nm:not(:where([data-vdc-market], [data-vdc-market] *)){font-weight:500;font-size:15px}
|
|
1584
|
+
.vdc .sub:not(:where([data-vdc-market], [data-vdc-market] *)){color:var(--t2);font-size:12px;word-break:break-all}
|
|
1585
|
+
.vdc .tg:not(:where([data-vdc-market], [data-vdc-market] *)){flex:1;font-size:13px}
|
|
1586
|
+
.vdc .tags:not(:where([data-vdc-market], [data-vdc-market] *)){display:flex;flex-wrap:wrap;gap:6px}
|
|
1587
|
+
.vdc .tag:not(:where([data-vdc-market], [data-vdc-market] *)){font-size:11px;padding:1px 8px;border-radius:99px;background:var(--l2);color:var(--t2);white-space:nowrap}
|
|
1588
|
+
.vdc .tag.off:not(:where([data-vdc-market], [data-vdc-market] *)){background:color-mix(in srgb,var(--brand) 14%,transparent);color:var(--brand);font-weight:500}
|
|
1589
|
+
.vdc .tag.acct:not(:where([data-vdc-market], [data-vdc-market] *)){background:color-mix(in srgb,var(--warn) 16%,transparent);color:var(--warn)}
|
|
1590
|
+
.vdc .tag.role:not(:where([data-vdc-market], [data-vdc-market] *)){background:color-mix(in srgb,var(--ok) 14%,transparent);color:var(--ok);font-weight:500}
|
|
1591
|
+
.vdc .rels:not(:where([data-vdc-market], [data-vdc-market] *)){display:flex;flex-direction:column;gap:6px}
|
|
1592
|
+
.vdc .rel:not(:where([data-vdc-market], [data-vdc-market] *)){display:flex;align-items:center;gap:8px;flex-wrap:wrap}
|
|
1593
|
+
.vdc .rel .rn:not(:where([data-vdc-market], [data-vdc-market] *)){font-weight:500}
|
|
1594
|
+
.vdc .rel .rs:not(:where([data-vdc-market], [data-vdc-market] *)){color:var(--t2);font-size:13px}
|
|
1595
|
+
.vdc .rel .lnk:not(:where([data-vdc-market], [data-vdc-market] *)){margin-left:auto}
|
|
1596
|
+
.vdc .ft:not(:where([data-vdc-market], [data-vdc-market] *)){display:flex;align-items:center;gap:10px;position:relative}
|
|
1597
|
+
.vdc .ft .meta:not(:where([data-vdc-market], [data-vdc-market] *)){flex:1;color:var(--t2);font-size:12px}
|
|
1598
|
+
.vdc .acts:not(:where([data-vdc-market], [data-vdc-market] *)){display:flex;gap:6px;align-items:center;position:relative}
|
|
1599
|
+
.vdc .dep:not(:where([data-vdc-market], [data-vdc-market] *)){font-size:12px;color:var(--t2);display:flex;gap:6px;align-items:center}
|
|
1600
|
+
.vdc .dep.miss:not(:where([data-vdc-market], [data-vdc-market] *)){color:var(--warn)}
|
|
1601
|
+
.vdc .menu:not(:where([data-vdc-market], [data-vdc-market] *)){position:absolute;right:0;bottom:calc(100% + 6px);min-width:150px;background:var(--ov);border:1px solid var(--b2);border-radius:10px;box-shadow:0 10px 30px rgba(0,0,0,.18);padding:4px;z-index:6}
|
|
1602
|
+
.vdc .menu button:not(:where([data-vdc-market], [data-vdc-market] *)){display:block;width:100%;text-align:left;border:0;background:transparent;padding:7px 10px;border-radius:7px;font-size:13px}
|
|
1603
|
+
.vdc .menu button:hover:not(:where([data-vdc-market], [data-vdc-market] *)){background:var(--l1)}
|
|
1604
|
+
.vdc .menu .danger:not(:where([data-vdc-market], [data-vdc-market] *)){color:var(--err)}
|
|
1605
|
+
.vdc .mask:not(:where([data-vdc-market], [data-vdc-market] *)){position:absolute;inset:0;background:rgba(0,0,0,.35);z-index:20}
|
|
1606
|
+
.vdc .drawer:not(:where([data-vdc-market], [data-vdc-market] *)){position:absolute;top:0;right:0;bottom:0;width:440px;max-width:94%;background:var(--ov);border-left:1px solid var(--b2);z-index:21;display:flex;flex-direction:column}
|
|
1607
|
+
.vdc .dh:not(:where([data-vdc-market], [data-vdc-market] *)){padding:18px 20px 12px;border-bottom:1px solid var(--b1)}
|
|
1608
|
+
.vdc .dh .row:not(:where([data-vdc-market], [data-vdc-market] *)){display:flex;gap:12px;align-items:center}
|
|
1609
|
+
.vdc .dh h2:not(:where([data-vdc-market], [data-vdc-market] *)){margin:0;font-size:17px}
|
|
1610
|
+
.vdc .x:not(:where([data-vdc-market], [data-vdc-market] *)){margin-left:auto;border:0;background:transparent;font-size:20px;color:var(--t2);width:30px;height:30px;border-radius:8px}
|
|
1611
|
+
.vdc .x:hover:not(:where([data-vdc-market], [data-vdc-market] *)){background:var(--l1)}
|
|
1612
|
+
.vdc .db:not(:where([data-vdc-market], [data-vdc-market] *)){flex:1;overflow:auto;padding:14px 20px 24px}
|
|
1613
|
+
.vdc .db h4:not(:where([data-vdc-market], [data-vdc-market] *)){margin:18px 0 6px;font-size:12px;letter-spacing:.5px;color:var(--t2);text-transform:uppercase}
|
|
1614
|
+
.vdc .db ul:not(:where([data-vdc-market], [data-vdc-market] *)){margin:0;padding-left:18px}
|
|
1615
|
+
.vdc .db li:not(:where([data-vdc-market], [data-vdc-market] *)){margin:3px 0}
|
|
1616
|
+
.vdc .kv:not(:where([data-vdc-market], [data-vdc-market] *)){display:grid;grid-template-columns:auto 1fr;gap:6px 12px;font-size:13px}
|
|
1617
|
+
.vdc .kv dt:not(:where([data-vdc-market], [data-vdc-market] *)){color:var(--t2)}
|
|
1618
|
+
.vdc .kv dd:not(:where([data-vdc-market], [data-vdc-market] *)){margin:0}
|
|
1619
|
+
.vdc .cap:not(:where([data-vdc-market], [data-vdc-market] *)){display:flex;gap:10px;padding:8px 10px;border:1px solid var(--b1);border-radius:10px;margin-bottom:6px;font-size:13px}
|
|
1620
|
+
.vdc .cap b:not(:where([data-vdc-market], [data-vdc-market] *)){min-width:78px;white-space:nowrap}
|
|
1621
|
+
.vdc .cap span:not(:where([data-vdc-market], [data-vdc-market] *)){color:var(--t2)}
|
|
1622
|
+
.vdc pre.cmd:not(:where([data-vdc-market], [data-vdc-market] *)){margin:6px 0;padding:8px 10px;border-radius:8px;background:var(--l1);border:1px solid var(--b1);font:12px/1.5 ui-monospace,Consolas,monospace;white-space:pre-wrap;word-break:break-all}
|
|
1623
|
+
.vdc .links button:not(:where([data-vdc-market], [data-vdc-market] *)){color:var(--brand);margin-right:14px;font-size:13px;background:none;border:0;padding:0}
|
|
1624
|
+
.vdc .dfoot:not(:where([data-vdc-market], [data-vdc-market] *)){padding:12px 20px;border-top:1px solid var(--b1);display:flex;gap:10px;align-items:center}
|
|
1625
|
+
.vdc .dfoot .grow:not(:where([data-vdc-market], [data-vdc-market] *)){flex:1;color:var(--t2);font-size:12px}
|
|
1626
|
+
.vdc .mask2:not(:where([data-vdc-market], [data-vdc-market] *)){z-index:30}
|
|
1627
|
+
.vdc .modal:not(:where([data-vdc-market], [data-vdc-market] *)){position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);width:600px;max-width:94%;max-height:92%;background:var(--ov);border:1px solid var(--b2);border-radius:16px;box-shadow:0 24px 70px rgba(0,0,0,.28);z-index:31;display:flex;flex-direction:column}
|
|
1628
|
+
.vdc .mh:not(:where([data-vdc-market], [data-vdc-market] *)){padding:18px 22px 6px}
|
|
1629
|
+
.vdc .mh h2:not(:where([data-vdc-market], [data-vdc-market] *)){margin:0;font-size:17px}
|
|
1630
|
+
.vdc .mh p:not(:where([data-vdc-market], [data-vdc-market] *)){margin:2px 0 0;color:var(--t2);font-size:13px}
|
|
1631
|
+
.vdc .mb:not(:where([data-vdc-market], [data-vdc-market] *)){padding:10px 22px;overflow:auto}
|
|
1632
|
+
.vdc .mf:not(:where([data-vdc-market], [data-vdc-market] *)){padding:14px 22px 18px;display:flex;gap:10px;justify-content:flex-end;align-items:center;flex-wrap:wrap}
|
|
1633
|
+
.vdc .mf .grow:not(:where([data-vdc-market], [data-vdc-market] *)){flex:1;color:var(--t2);font-size:12px}
|
|
1634
|
+
.vdc .row3:not(:where([data-vdc-market], [data-vdc-market] *)){display:flex;gap:12px;align-items:center;padding:10px 12px;border:1px solid var(--b1);border-radius:12px;margin-bottom:8px}
|
|
1635
|
+
.vdc .row3 .gl:not(:where([data-vdc-market], [data-vdc-market] *)){width:32px;height:32px;font-size:14px;border-radius:9px}
|
|
1636
|
+
.vdc .row3 .m:not(:where([data-vdc-market], [data-vdc-market] *)){flex:1;min-width:0}
|
|
1637
|
+
.vdc .row3 .m div:not(:where([data-vdc-market], [data-vdc-market] *)){font-size:12px;color:var(--t2)}
|
|
1638
|
+
.vdc .row3.skip:not(:where([data-vdc-market], [data-vdc-market] *)){opacity:.6}
|
|
1639
|
+
.vdc .stat:not(:where([data-vdc-market], [data-vdc-market] *)){font-size:12px;color:var(--t2);display:flex;align-items:center;gap:6px;white-space:nowrap}
|
|
1640
|
+
.vdc .spin:not(:where([data-vdc-market], [data-vdc-market] *)){width:14px;height:14px;border-radius:50%;border:2px solid var(--b2);border-top-color:var(--brand);animation:vdcsp .8s linear infinite}
|
|
1641
|
+
@keyframes vdcsp{to{transform:rotate(360deg)}
|
|
1642
|
+
}
|
|
1643
|
+
.vdc .dotc:not(:where([data-vdc-market], [data-vdc-market] *)){width:14px;height:14px;border-radius:50%;display:grid;place-items:center;color:#fff;font-size:10px}
|
|
1644
|
+
.vdc .dotc.ok:not(:where([data-vdc-market], [data-vdc-market] *)){background:var(--ok)}
|
|
1645
|
+
.vdc .dotc.err:not(:where([data-vdc-market], [data-vdc-market] *)){background:var(--err)}
|
|
1646
|
+
.vdc .dotc.wait:not(:where([data-vdc-market], [data-vdc-market] *)){background:var(--idle);opacity:.5}
|
|
1647
|
+
.vdc .dotc.hold:not(:where([data-vdc-market], [data-vdc-market] *)){background:var(--warn)}
|
|
1648
|
+
.vdc .bar:not(:where([data-vdc-market], [data-vdc-market] *)){height:6px;border-radius:99px;background:var(--l2);overflow:hidden;margin:6px 0 12px}
|
|
1649
|
+
.vdc .bar i:not(:where([data-vdc-market], [data-vdc-market] *)){display:block;height:100%;background:var(--brand);border-radius:99px;transition:width .3s}
|
|
1650
|
+
.vdc .note:not(:where([data-vdc-market], [data-vdc-market] *)){font-size:12px;color:var(--t2);margin:8px 0}
|
|
1651
|
+
.vdc .res:not(:where([data-vdc-market], [data-vdc-market] *)){display:flex;gap:12px;align-items:flex-start;padding:12px 14px;border-radius:12px;margin:6px 0 10px}
|
|
1652
|
+
.vdc .res.ok:not(:where([data-vdc-market], [data-vdc-market] *)){background:color-mix(in srgb,var(--ok) 10%,var(--bg));border:1px solid color-mix(in srgb,var(--ok) 35%,var(--b1))}
|
|
1653
|
+
.vdc .res.err:not(:where([data-vdc-market], [data-vdc-market] *)){background:color-mix(in srgb,var(--err) 9%,var(--bg));border:1px solid color-mix(in srgb,var(--err) 35%,var(--b1))}
|
|
1654
|
+
.vdc .res.warn:not(:where([data-vdc-market], [data-vdc-market] *)){background:color-mix(in srgb,var(--warn) 10%,var(--bg));border:1px solid color-mix(in srgb,var(--warn) 40%,var(--b1))}
|
|
1655
|
+
.vdc .res b:not(:where([data-vdc-market], [data-vdc-market] *)){display:block}
|
|
1656
|
+
.vdc .res span:not(:where([data-vdc-market], [data-vdc-market] *)){color:var(--t2);font-size:13px}
|
|
1657
|
+
.vdc details:not(:where([data-vdc-market], [data-vdc-market] *)){margin:6px 0;font-size:13px}
|
|
1658
|
+
.vdc summary:not(:where([data-vdc-market], [data-vdc-market] *)){cursor:pointer;color:var(--t2)}
|
|
1659
|
+
.vdc .log:not(:where([data-vdc-market], [data-vdc-market] *)){margin-top:6px;padding:8px 10px;border-radius:8px;background:var(--l1);border:1px solid var(--b1);font:11.5px/1.55 ui-monospace,Consolas,monospace;color:var(--t2);max-height:120px;overflow:auto;white-space:pre-wrap}
|
|
1660
|
+
.vdc .next:not(:where([data-vdc-market], [data-vdc-market] *)){margin-top:8px;padding:10px 12px;border-radius:10px;background:var(--l1);font-size:13px}
|
|
1661
|
+
.vdc .next li:not(:where([data-vdc-market], [data-vdc-market] *)){margin:2px 0}
|
|
1662
|
+
.vdc .foot:not(:where([data-vdc-market], [data-vdc-market] *)){margin-top:6px;padding-top:16px;border-top:1px solid var(--b1);display:flex;gap:18px;color:var(--t2);font-size:13px;flex-wrap:wrap}
|
|
1663
|
+
.vdc .empty:not(:where([data-vdc-market], [data-vdc-market] *)){max-width:560px;margin:56px auto;text-align:center;display:flex;flex-direction:column;align-items:center;gap:10px}
|
|
1664
|
+
.vdc .empty .gl:not(:where([data-vdc-market], [data-vdc-market] *)){width:56px;height:56px;border-radius:16px;font-size:24px}
|
|
1665
|
+
.vdc .empty h2:not(:where([data-vdc-market], [data-vdc-market] *)){margin:6px 0 0;font-size:20px}
|
|
1666
|
+
.vdc .empty p:not(:where([data-vdc-market], [data-vdc-market] *)){margin:0 0 6px;color:var(--t2)}
|
|
1667
|
+
.vdc .embed:not(:where([data-vdc-market], [data-vdc-market] *)){border:1px solid var(--b1);border-radius:16px;overflow:hidden}
|
|
1668
|
+
.vdc .embed-h:not(:where([data-vdc-market], [data-vdc-market] *)){display:flex;align-items:center;gap:10px;padding:12px 16px;border-bottom:1px solid var(--b1);background:var(--l1)}
|
|
1669
|
+
.vdc code:not(:where([data-vdc-market], [data-vdc-market] *)){font:12px ui-monospace,Consolas,monospace;background:var(--l2);padding:0 5px;border-radius:5px}
|
|
1670
|
+
.vdc{min-width:0}.vdc :is(b,strong,h1,h2,h3,h4):not(:where([data-vdc-market], [data-vdc-market] *)){font-weight:500}.vdc button.tag:not(:where([data-vdc-market], [data-vdc-market] *)){border:0}.vdc button:focus-visible:not(:where([data-vdc-market], [data-vdc-market] *)){outline:2px solid var(--brand);outline-offset:2px}
|
|
1671
|
+
.vdc :is(.hd>div,.grow,.r):not(:where([data-vdc-market], [data-vdc-market] *)){min-width:0}.vdc .grid:not(:where([data-vdc-market], [data-vdc-market] *)){grid-template-columns:repeat(auto-fill,minmax(min(300px,100%),1fr))}.vdc :is(.ft,.acts):not(:where([data-vdc-market], [data-vdc-market] *)){flex-wrap:wrap}
|
|
1672
|
+
.vdc[data-embedded="true"] .top:not(:where([data-vdc-market], [data-vdc-market] *)){padding:12px 24px;gap:8px}.vdc[data-embedded="true"] .wrap:not(:where([data-vdc-market], [data-vdc-market] *)){max-width:1160px}.vdc .banner.info:not(:where([data-vdc-market], [data-vdc-market] *)){flex-wrap:wrap}.vdc .banner.info>.grow:not(:where([data-vdc-market], [data-vdc-market] *)){flex:1 1 220px}
|
|
1673
|
+
@media(max-width:620px){.vdc .top:not(:where([data-vdc-market], [data-vdc-market] *)),.vdc[data-embedded="true"] .top:not(:where([data-vdc-market], [data-vdc-market] *)){padding:12px 14px;gap:8px}.vdc .tabs:not(:where([data-vdc-market], [data-vdc-market] *)){width:100%;justify-content:space-between}.vdc .tab:not(:where([data-vdc-market], [data-vdc-market] *)){padding:6px 9px}.vdc .wrap:not(:where([data-vdc-market], [data-vdc-market] *)){padding:16px 14px 40px}.vdc .suite:not(:where([data-vdc-market], [data-vdc-market] *)){grid-template-columns:minmax(0,1fr);padding:14px}.vdc .suite .r:not(:where([data-vdc-market], [data-vdc-market] *)){text-align:left}.vdc .chips:not(:where([data-vdc-market], [data-vdc-market] *)){gap:6px}.vdc .card:not(:where([data-vdc-market], [data-vdc-market] *)){padding:14px}.vdc .drawer:not(:where([data-vdc-market], [data-vdc-market] *)){width:100%;max-width:100%}.vdc .banner.info>.grow:not(:where([data-vdc-market], [data-vdc-market] *)){flex-basis:100%}.vdc .modal:not(:where([data-vdc-market], [data-vdc-market] *)){max-width:calc(100% - 20px)}.vdc .mf:not(:where([data-vdc-market], [data-vdc-market] *)){padding:12px;gap:8px}}
|
|
1674
|
+
`
|
|
1675
|
+
|
|
1676
|
+
/* ── icons ─────────────────────────────────────────────────────────────── */
|
|
1677
|
+
const svg = (w, kids, extra) => h('svg', Object.assign({ width: w, height: w, viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor', strokeWidth: 2, strokeLinecap: 'round', strokeLinejoin: 'round' }, extra || {}), kids)
|
|
1678
|
+
const path = (d, k) => h('path', { d, key: k || d })
|
|
1679
|
+
const I = {
|
|
1680
|
+
logo: () => svg(18, [path('M10 3H5a2 2 0 0 0-2 2v5a2 2 0 0 0 2 2h1a2 2 0 1 1 0 4H5a2 2 0 0 0-2 2v1a2 2 0 0 0 2 2h5v-2a2 2 0 1 1 4 0v2h5a2 2 0 0 0 2-2v-5h-2a2 2 0 1 1 0-4h2V5a2 2 0 0 0-2-2h-5v1a2 2 0 1 1-4 0z')]),
|
|
1681
|
+
down: () => svg(15, [path('M12 4v12m0 0l-5-5m5 5l5-5M5 20h14')], { strokeWidth: 2.2 }),
|
|
1682
|
+
check: (w) => svg(w || 12, [path('M5 12l5 5L20 7')], { strokeWidth: 3.5 }),
|
|
1683
|
+
shield: () => svg(16, [path('M12 3l8 3v6c0 5-3.5 8-8 9-4.5-1-8-4-8-9V6z', 'a'), path('M9 12l2 2 4-4', 'b')]),
|
|
1684
|
+
bolt: () => svg(16, [path('M13 2L4 14h7l-1 8 9-12h-7z')]),
|
|
1685
|
+
star: (w) => svg(w || 16, [path('M12 3l2.7 5.6 6.1.9-4.4 4.3 1 6.1L12 17l-5.4 2.9 1-6.1L3.2 9.5l6.1-.9z')]),
|
|
1686
|
+
warn: (w) => svg(w || 18, [path('M12 3l10 18H2z', 'a'), path('M12 10v5M12 18v.5', 'b')], { stroke: 'var(--warn)' }),
|
|
1687
|
+
ok: () => svg(20, [h('circle', { cx: 12, cy: 12, r: 9, key: 'c' }), path('M8 12.5l3 3 5-6', 'p')], { stroke: 'var(--ok)', strokeWidth: 2.2 }),
|
|
1688
|
+
err: () => svg(20, [h('circle', { cx: 12, cy: 12, r: 9, key: 'c' }), path('M9 9l6 6M15 9l-6 6', 'p')], { stroke: 'var(--err)', strokeWidth: 2.2 }),
|
|
1689
|
+
arrow: () => svg(14, [path('M5 12h14m-5-5l5 5-5 5')]),
|
|
1690
|
+
}
|
|
1691
|
+
const Glyph = (p, cls) => h('div', { className: cls || 'gl', style: { background: `linear-gradient(135deg,${p.icon.grad[0]},${p.icon.grad[1]})` } }, L(p.icon.glyph, LANG))
|
|
1692
|
+
|
|
1693
|
+
/* ── pure helpers ──────────────────────────────────────────────────────── */
|
|
1694
|
+
const tagInfo = (t, S) => ({
|
|
1695
|
+
official: [S.tagOfficial, 'off'], community: [S.tagCommunity, ''], needsAccount: [S.tagNeedsAccount, 'acct'], paid: [S.tagPaid, ''],
|
|
1696
|
+
needsHost02: [S.tagNeedsHost02, ''], dependency: [S.tagDependency, 'role'], companion: [S.tagCompanion, 'role'], tested: [S.tagTested, 'role'],
|
|
1697
|
+
}[t])
|
|
1698
|
+
const sizeOf = (list) => {
|
|
1699
|
+
const kb = list.reduce((a, p) => a + p.sizeKB, 0)
|
|
1700
|
+
return kb < 1024 ? '< 1 MB' : fmtSize(kb)
|
|
1701
|
+
}
|
|
1702
|
+
|
|
1703
|
+
/* ── component ─────────────────────────────────────────────────────────── */
|
|
1704
|
+
function Center(props = {}) {
|
|
1705
|
+
const embedded = props.embedded === true
|
|
1706
|
+
const accountState = useSyncExternalStore(host.center?.subscribe ?? noSubscription, host.center?.getSnapshot ?? readNoAccount, readNoAccount)
|
|
1707
|
+
const [accountError, setAccountError] = useState(false)
|
|
1708
|
+
const [releaseState, setReleaseState] = useState(() => ({ kind: 'idle', answer: rememberedAnswer() }))
|
|
1709
|
+
const releaseRequest = useRef(null)
|
|
1710
|
+
const releaseLifetime = useRef(null)
|
|
1711
|
+
const liveCatalog = useMemo(() => E.catalogWithReleases(catalog, releaseState.answer), [releaseState.answer])
|
|
1712
|
+
const PLUGINS = liveCatalog.plugins
|
|
1713
|
+
const byId = (id) => PLUGINS.find((p) => p.id === id)
|
|
1714
|
+
const loadReleases = useCallback(async (manual = false) => {
|
|
1715
|
+
if (releaseRequest.current) return releaseRequest.current
|
|
1716
|
+
if (!host.checkUpdates) { setReleaseState({ kind: 'unavailable', answer: null }); return undefined }
|
|
1717
|
+
// The startup check (or another opening) answered under a minute ago: that is this opening's answer.
|
|
1718
|
+
if (!manual && !inflight && lastChecked && Date.now() - lastChecked.at < FRESH_MS) {
|
|
1719
|
+
const answer = lastChecked.answer
|
|
1720
|
+
setReleaseState((previous) => ({ kind: answer?.ok ? 'ready' : 'unavailable',
|
|
1721
|
+
answer: answer && (Array.isArray(answer.plugins) || answer.self) ? answer : previous.answer }))
|
|
1722
|
+
return answer
|
|
1723
|
+
}
|
|
1724
|
+
setReleaseState((previous) => ({ ...previous, kind: 'checking' }))
|
|
1725
|
+
const signal = releaseLifetime.current?.signal
|
|
1726
|
+
const task = requestUpdates(signal)
|
|
1727
|
+
.then((answer) => {
|
|
1728
|
+
if (!signal?.aborted) setReleaseState((previous) => ({ kind: answer?.ok ? 'ready' : 'unavailable',
|
|
1729
|
+
answer: answer && (Array.isArray(answer.plugins) || answer.self) ? answer : previous.answer }))
|
|
1730
|
+
return answer
|
|
1731
|
+
}).finally(() => { releaseRequest.current = null })
|
|
1732
|
+
releaseRequest.current = task
|
|
1733
|
+
return task
|
|
1734
|
+
}, [])
|
|
1735
|
+
useEffect(() => {
|
|
1736
|
+
const lifetime = new AbortController()
|
|
1737
|
+
releaseLifetime.current = lifetime
|
|
1738
|
+
void loadReleases()
|
|
1739
|
+
return () => { lifetime.abort(); releaseLifetime.current = null }
|
|
1740
|
+
}, [loadReleases])
|
|
1741
|
+
const lang = pick(host.locale?.())
|
|
1742
|
+
LANG = lang
|
|
1743
|
+
const S = STR[lang]
|
|
1744
|
+
const [, bumpLocale] = useState(0)
|
|
1745
|
+
useEffect(() => (host.onLocale ? host.onLocale(() => bumpLocale((n) => n + 1)) : undefined), [])
|
|
1746
|
+
// Label colour on primary buttons: black or white, whichever reads on the host's CURRENT brand colour.
|
|
1747
|
+
const rootRef = useRef(null)
|
|
1748
|
+
useEffect(() => {
|
|
1749
|
+
const el = rootRef.current
|
|
1750
|
+
if (!el) return undefined
|
|
1751
|
+
const apply = () => {
|
|
1752
|
+
try {
|
|
1753
|
+
const probe = document.createElement('span')
|
|
1754
|
+
probe.style.cssText = 'position:absolute;width:0;height:0;background:var(--brand)'
|
|
1755
|
+
el.appendChild(probe); const bg = getComputedStyle(probe).backgroundColor; el.removeChild(probe)
|
|
1756
|
+
el.style.setProperty('--on-brand', E.readableTextOn(bg))
|
|
1757
|
+
} catch { /* keep the CSS fallback */ }
|
|
1758
|
+
}
|
|
1759
|
+
apply()
|
|
1760
|
+
const mo = typeof MutationObserver === 'function' ? new MutationObserver(apply) : null
|
|
1761
|
+
if (mo) { mo.observe(document.documentElement, { attributes: true }); mo.observe(document.body, { attributes: true }) }
|
|
1762
|
+
const timer = setInterval(apply, 1500) // themes that swap a stylesheet change no attribute
|
|
1763
|
+
return () => { mo && mo.disconnect(); clearInterval(timer) }
|
|
1764
|
+
}, [])
|
|
1765
|
+
// The market's own filled buttons can be unreadable on a light brand (white on #6f87ff, or on
|
|
1766
|
+
// anything near white): bridge only those, and put every colour back when the view or theme changes.
|
|
1767
|
+
const marketRef = useRef(null)
|
|
1768
|
+
const [bundles, setBundles] = useState(() => lastBundles) // null = loading, false = unavailable
|
|
1769
|
+
const [view, setView] = useState(() => ['all', 'installed', 'updates', 'community'].includes(props.view) ? props.view : 'all')
|
|
1770
|
+
useEffect(() => { if (['all', 'installed', 'updates', 'community'].includes(props.view)) setView(props.view) }, [props.view])
|
|
1771
|
+
const selectView = (next) => {
|
|
1772
|
+
setView(next)
|
|
1773
|
+
if (embedded && accountState.available) host.openCenter?.(next)
|
|
1774
|
+
}
|
|
1775
|
+
useEffect(() => {
|
|
1776
|
+
if (view !== 'community') return undefined
|
|
1777
|
+
return startMarketTextBridge(() => marketRef.current)
|
|
1778
|
+
}, [view, bundles])
|
|
1779
|
+
|
|
1780
|
+
const [intro, setIntro] = useState(false)
|
|
1781
|
+
const [discoverFailed, setDiscoverFailed] = useState(false)
|
|
1782
|
+
const [drawer, setDrawer] = useState(null)
|
|
1783
|
+
const [menu, setMenu] = useState(null)
|
|
1784
|
+
const [modal, setModal] = useState(null) // {mode:'confirm'|'run'|'result'|'migrate'|'uninstall', ...}
|
|
1785
|
+
const aborter = useRef(null)
|
|
1786
|
+
const copyTimer = useRef(null)
|
|
1787
|
+
useEffect(() => () => { aborter.current?.abort(); if (copyTimer.current) clearTimeout(copyTimer.current) }, [])
|
|
1788
|
+
const [selfUpd, setSelfUpd] = useState(null) // null | {kind:'checking'} | judgeSelfUpdate(...)
|
|
1789
|
+
const [copied, setCopied] = useState(false)
|
|
1790
|
+
// Plugins replaced underneath this page (updated, or removed and put back). See engine.trackLoadedChanges.
|
|
1791
|
+
const tracker = useRef({ prev: null, removed: [], dirty: [] })
|
|
1792
|
+
const [replaced, setReplaced] = useState([])
|
|
1793
|
+
|
|
1794
|
+
const refresh = useCallback(async () => {
|
|
1795
|
+
if (!host.pm) { setBundles(false); return }
|
|
1796
|
+
try {
|
|
1797
|
+
const r = await E.readBundleInventory(host.pm)
|
|
1798
|
+
setBundles(r?.ok ? r.value : false)
|
|
1799
|
+
if (r?.ok) {
|
|
1800
|
+
lastBundles = r.value
|
|
1801
|
+
tracker.current = E.trackLoadedChanges(tracker.current, r.value)
|
|
1802
|
+
setReplaced((old) => (old.length === tracker.current.dirty.length ? old : tracker.current.dirty))
|
|
1803
|
+
}
|
|
1804
|
+
} catch { setBundles(false) }
|
|
1805
|
+
}, [])
|
|
1806
|
+
useEffect(() => { refresh(); return host.onChanged?.(refresh) }, [refresh])
|
|
1807
|
+
|
|
1808
|
+
const have = useMemo(() => new Map((bundles || []).filter(E.bundlePresent).map((b) => [b.name, b])), [bundles])
|
|
1809
|
+
const isIn = (p) => !!p && have.has(p.npm)
|
|
1810
|
+
const isOn = (p) => !!p && !!have.get(p.npm)?.enabled
|
|
1811
|
+
const isProvided = (p) => !!p && E.providedByApp(have.get(p.npm))
|
|
1812
|
+
const shownVersion = (p) => isProvided(p) ? have.get(p.npm)?.version ?? p.version : p.version
|
|
1813
|
+
const missingDeps = (p) => (p.requires || []).filter((d) => !isIn(byId(d)) || isProvided(byId(d)) && !isOn(byId(d)))
|
|
1814
|
+
const updates = useMemo(() => (bundles ? E.pendingUpdates(liveCatalog, bundles) : []), [bundles, liveCatalog])
|
|
1815
|
+
const appUpdates = useMemo(() => (bundles ? E.appReleaseUpdates(liveCatalog, bundles) : []), [bundles, liveCatalog])
|
|
1816
|
+
const selfRelease = E.judgeSelfUpdate(host.version?.() ?? '0.0.0', releaseState.answer?.self)
|
|
1817
|
+
// This center itself ships with the app (VibeDev Next marks it official; any app shows it as not removable).
|
|
1818
|
+
const selfBuiltIn = host.official?.() === true || E.providedByApp(have.get('@vibedev-si/dsh-ecosystem'))
|
|
1819
|
+
// A host that can update app-owned packages reports both copies of this center (see E.applicationCopy).
|
|
1820
|
+
const selfCopy = E.applicationCopy(have.get('@vibedev-si/dsh-ecosystem'))
|
|
1821
|
+
const selfRunning = host.version?.() ?? '0.0.0'
|
|
1822
|
+
/** An update of this center already installed, waiting for VibeDev Next to restart. */
|
|
1823
|
+
const selfPending = selfCopy?.selected === 'profile' && !!selfCopy.local && E.compareSemver(selfCopy.local, selfRunning) > 0 ? selfCopy.local : null
|
|
1824
|
+
const fullyChecked = releaseState.kind === 'ready' && E.releasesComplete(liveCatalog, releaseState.answer)
|
|
1825
|
+
const legacy = useMemo(() => (bundles ? E.legacyInstalled(liveCatalog, bundles) : []), [bundles, liveCatalog])
|
|
1826
|
+
|
|
1827
|
+
const official = PLUGINS.filter((p) => p.origin === 'official')
|
|
1828
|
+
const companions = PLUGINS.filter((p) => p.role === 'dependency' || p.role === 'companion')
|
|
1829
|
+
// The ways to the community market (intro sentence, footer link) exist only while the catalog lists it;
|
|
1830
|
+
// an unlisted market gets no link at all, not a disabled one.
|
|
1831
|
+
const market = byId(MARKET)
|
|
1832
|
+
const marketIn = isIn(market)
|
|
1833
|
+
const toMarket = () => (marketIn ? setView('community') : openInstall([MARKET], `${S.install} ${L(market.name, lang)}`))
|
|
1834
|
+
|
|
1835
|
+
const tagEls = (p) => {
|
|
1836
|
+
const tg = (p.tags || []).slice()
|
|
1837
|
+
if (p.reviewed) tg.push('tested')
|
|
1838
|
+
return tg.map((t) => {
|
|
1839
|
+
if (t === 'needsAccount') {
|
|
1840
|
+
if (accountState.signedIn) return null
|
|
1841
|
+
return h('button', { key: t, type: 'button', className: 'tag acct', 'data-account-action': '', onClick: (event) => {
|
|
1842
|
+
event.stopPropagation()
|
|
1843
|
+
if (!accountState.available) {
|
|
1844
|
+
if (isIn(byId('@vibedev-si/dsh-vibedev')) && host.openLegacyAccount?.()) return
|
|
1845
|
+
openInstall(['@vibedev-si/dsh-vibedev'], S.installAccount)
|
|
1846
|
+
return
|
|
1847
|
+
}
|
|
1848
|
+
setAccountError(false)
|
|
1849
|
+
host.center.signIn().catch(() => setAccountError(true))
|
|
1850
|
+
} }, S.signIn)
|
|
1851
|
+
}
|
|
1852
|
+
const i = tagInfo(t, S)
|
|
1853
|
+
return i ? h('span', { key: t, className: 'tag ' + i[1] }, i[0]) : null
|
|
1854
|
+
})
|
|
1855
|
+
}
|
|
1856
|
+
const roleEl = (role) => { const i = tagInfo(role, S); return i ? h('span', { className: 'tag ' + i[1] }, i[0]) : null }
|
|
1857
|
+
const relationState = (r) => r.provided ? S.provided : r.installed ? (r.enabled ? S.enabled : S.disabled) : S.notInstalled
|
|
1858
|
+
/** One declared relation: what it is, what this Host has, and the way to it. Never an install button. */
|
|
1859
|
+
const relationEls = (ids, kind) => h('div', { className: 'rels', 'data-testid': 'rel-' + kind }, ids
|
|
1860
|
+
.map((id) => (byId(id) === undefined ? null : E.relationsOf({ [kind]: [id] }, byId, bundles || [])[0]))
|
|
1861
|
+
.filter(Boolean)
|
|
1862
|
+
.map((r) => h('div', { className: 'rel', key: kind + ':' + r.id, 'data-rel': r.id },
|
|
1863
|
+
h('span', { className: 'rn' }, L(r.entry.name, lang)),
|
|
1864
|
+
roleEl(r.entry.role),
|
|
1865
|
+
h('span', { className: 'rs' }, relationState(r)),
|
|
1866
|
+
h('button', { className: 'lnk', onClick: () => setDrawer(r.id) }, r.present ? S.viewConfigure : S.view))))
|
|
1867
|
+
/** A plugin needed as well as paired with is listed once, under what it is needed for. */
|
|
1868
|
+
const partnerIds = (p) => { const required = new Set(p.requires || []); return (p.partners || []).filter((id) => !required.has(id)) }
|
|
1869
|
+
|
|
1870
|
+
/* ── install flow ────────────────────────────────────────────────────── */
|
|
1871
|
+
const openInstall = (ids, title, opts = {}) => {
|
|
1872
|
+
setDrawer(null); setMenu(null)
|
|
1873
|
+
const rows = opts.update
|
|
1874
|
+
? E.markInstalled(ids.map(byId), bundles || []).map((row) => ({ ...row, update: updates.find((u) => u.entry.id === row.entry.id) }))
|
|
1875
|
+
: E.markInstalled(E.resolvePlan(liveCatalog, ids), bundles || [])
|
|
1876
|
+
setModal({ mode: 'confirm', rows, title, update: !!opts.update })
|
|
1877
|
+
}
|
|
1878
|
+
const start = async (rows, title, update, approved) => {
|
|
1879
|
+
const run = { rows: rows.map((r) => ({ ...r, st: E.needsInstall(r, update) ? 'wait' : 'skip', sub: '' })), log: [], title, update, cur: null, approved: approved || {} }
|
|
1880
|
+
aborter.current = new AbortController()
|
|
1881
|
+
setModal({ mode: 'run', run: { ...run } })
|
|
1882
|
+
const upd = () => setModal({ mode: 'run', run: { ...run, rows: run.rows.map((r) => ({ ...r })) } })
|
|
1883
|
+
const todo = run.rows.filter((r) => r.st !== 'skip')
|
|
1884
|
+
// Like the official Plugins page: ask the host which registry answers fastest (it matters on mainland-China networks).
|
|
1885
|
+
const registry = (await host.chooseRegistry?.()) ?? null
|
|
1886
|
+
run.log.push(`start: ${todo.length}`, `registry: ${registry || 'default'}`)
|
|
1887
|
+
const results = []
|
|
1888
|
+
// Let the host finish applying one plugin before the next change (see engine.waitQuiet for why).
|
|
1889
|
+
const T = (host.settle && host.settle()) || {}
|
|
1890
|
+
const between = T.between || { quietMs: 1200, maxMs: 6000 }
|
|
1891
|
+
const closing = T.final || { quietMs: 2500, maxMs: 12000 }
|
|
1892
|
+
let first = true
|
|
1893
|
+
for (const row of run.rows) {
|
|
1894
|
+
if (row.st === 'skip') continue
|
|
1895
|
+
if (aborter.current.signal.aborted) { row.st = 'wait'; results.push({ id: row.entry.id, status: 'cancelled' }); break }
|
|
1896
|
+
if (!first) { run.waiting = true; upd(); await E.waitQuiet(host.onChanged, between); run.waiting = false }
|
|
1897
|
+
first = false
|
|
1898
|
+
run.cur = row; row.st = 'run'; row.sub = S.stInspect; upd()
|
|
1899
|
+
const state = update ? { installed: true, enabled: row.enabled, provided: row.provided, updatable: row.updatable } : row
|
|
1900
|
+
const r = await E.installOne(host.pm, row.entry, state, {
|
|
1901
|
+
update,
|
|
1902
|
+
registry: update || row.entry.usesLiveVersion ? row.entry.registry ?? registry : registry,
|
|
1903
|
+
approvedBuilds: run.approved[row.entry.id],
|
|
1904
|
+
hooks: {
|
|
1905
|
+
onStep: (s, _entry, detail) => {
|
|
1906
|
+
row.sub = s === 'inspect' ? S.stInspect : s === 'install' ? S.stInstall : s === 'disable-old' ? S.stOldOff : s === 'remove-old' ? S.stOldRemove
|
|
1907
|
+
: s === 'remove-current' ? S.stRemoveCurrent : s === 'restore' ? S.stRestore : S.stEnable
|
|
1908
|
+
row.late = s !== 'inspect' && s !== 'install' // past the install nothing can be cancelled, the switch steps included
|
|
1909
|
+
run.log.push(`${s} ${detail ?? (s.endsWith('-old') ? row.legacy : E.specOf(row.entry))}`); upd()
|
|
1910
|
+
},
|
|
1911
|
+
onRequest: (id) => { row.requestId = id },
|
|
1912
|
+
},
|
|
1913
|
+
})
|
|
1914
|
+
results.push({ id: row.entry.id, ...r })
|
|
1915
|
+
if (r.status === 'failed' || r.status === 'cancelled') {
|
|
1916
|
+
row.st = r.failure?.kind === 'builds' ? 'hold' : 'err'
|
|
1917
|
+
row.failure = r.failure; run.log.push(`! ${r.failure?.kind || r.status}: ${r.failure?.diagnostic || ''}`)
|
|
1918
|
+
break
|
|
1919
|
+
}
|
|
1920
|
+
row.st = 'ok'; row.outcome = r.status; run.cur = null; run.log.push(`ok ${row.entry.id} (${r.status})`); upd()
|
|
1921
|
+
}
|
|
1922
|
+
const failed = results.find((x) => x.status === 'failed' || x.status === 'cancelled')
|
|
1923
|
+
const restart = results.some((x) => x.status === 'restart')
|
|
1924
|
+
// Only wait when something was actually changed: a failed or cancelled run has nothing left to apply.
|
|
1925
|
+
if (!failed && results.some((x) => x.status === 'done' || x.status === 'enabledOnly' || x.status === 'restart')) { run.settling = true; run.cur = null; upd(); await E.waitQuiet(host.onChanged, closing); run.settling = false }
|
|
1926
|
+
await refresh()
|
|
1927
|
+
setModal({ mode: 'result', run: { ...run, rows: run.rows.map((r) => ({ ...r })) }, results, failed, restart, update, title })
|
|
1928
|
+
}
|
|
1929
|
+
const cancelRun = async () => {
|
|
1930
|
+
aborter.current?.abort()
|
|
1931
|
+
const cur = modal?.run?.cur
|
|
1932
|
+
if (cur?.requestId && host.pm?.cancelInstall) { try { await host.pm.cancelInstall(cur.requestId) } catch { /* best effort */ } }
|
|
1933
|
+
}
|
|
1934
|
+
|
|
1935
|
+
const doMigrate = async (x) => {
|
|
1936
|
+
setModal({ mode: 'migrate', x, phase: 'run', step: 'inspect' })
|
|
1937
|
+
const registry = (await host.chooseRegistry?.()) ?? null
|
|
1938
|
+
const r = await E.migrate(host.pm, x.entry, x.legacy, { registry, hooks: { onStep: (s) => setModal((m) => (m && m.mode === 'migrate' ? { ...m, step: s } : m)) } })
|
|
1939
|
+
await refresh()
|
|
1940
|
+
setModal({ mode: 'migrate', x, phase: 'done', result: r })
|
|
1941
|
+
}
|
|
1942
|
+
const doUninstall = async (p) => {
|
|
1943
|
+
setMenu(null)
|
|
1944
|
+
const r = await E.uninstall(host.pm, p)
|
|
1945
|
+
await refresh()
|
|
1946
|
+
if (r.status === 'done' || r.status === 'restart') return
|
|
1947
|
+
setModal({ mode: 'uninstall', p, result: r })
|
|
1948
|
+
}
|
|
1949
|
+
const toggle = async (p, on) => { setMenu(null); const r = await host.pm.setBundleEnabled(p.npm, on); await refresh(); return r }
|
|
1950
|
+
/** Update an app-owned package in place, or return it to the copy shipped with the app; both apply at the next start. */
|
|
1951
|
+
const doBuiltIn = async (action, name, version, registry = null) => {
|
|
1952
|
+
setDrawer(null); setMenu(null)
|
|
1953
|
+
setModal({ mode: 'builtin', action, name, version, phase: 'run' })
|
|
1954
|
+
const chosen = action === 'update' ? registry ?? (await host.chooseRegistry?.()) ?? null : null
|
|
1955
|
+
const r = action === 'update' ? await E.updateBuiltIn(host.pm, name, version, { registry: chosen }) : await E.restoreBuiltIn(host.pm, name)
|
|
1956
|
+
await refresh()
|
|
1957
|
+
setModal({ mode: 'builtin', action, name, version, phase: 'done', result: r })
|
|
1958
|
+
}
|
|
1959
|
+
|
|
1960
|
+
/* ── pieces ──────────────────────────────────────────────────────────── */
|
|
1961
|
+
// "Is there a newer center?": one read of npm, made by the host half, only when the user clicks.
|
|
1962
|
+
const checkSelf = async () => {
|
|
1963
|
+
setSelfUpd({ kind: 'checking' })
|
|
1964
|
+
const answer = host.checkUpdates ? (await loadReleases(true))?.self
|
|
1965
|
+
: await (host.checkLatest ? host.checkLatest() : Promise.resolve(undefined))
|
|
1966
|
+
setSelfUpd(E.judgeSelfUpdate(host.version?.() ?? '0.0.0', answer))
|
|
1967
|
+
}
|
|
1968
|
+
const SELF_PKG = '@vibedev-si/dsh-ecosystem'
|
|
1969
|
+
const copyPkg = () => { host.copy?.(SELF_PKG); setCopied(true); if (copyTimer.current) clearTimeout(copyTimer.current); copyTimer.current = setTimeout(() => setCopied(false), 2000) }
|
|
1970
|
+
const stateBtn = (p) => {
|
|
1971
|
+
// Not known yet whether it is installed: a neutral placeholder, never a 安装 that turns into 已启用.
|
|
1972
|
+
if (bundles === null) return h('span', { className: 'btn ph', 'data-testid': 'state-pending', 'aria-hidden': 'true' }, '\u00a0')
|
|
1973
|
+
if (isProvided(p)) {
|
|
1974
|
+
const badge = h('span', { className: 'btn ' + (isOn(p) ? 'ok' : ''), 'data-testid': 'provided', title: E.updatableBuiltIn(have.get(p.npm)) ? S.providedUpdatable : S.providedNote }, S.provided, ' · ', isOn(p) ? S.enabled : S.disabled)
|
|
1975
|
+
const up = updates.find((u) => u.entry.id === p.id && u.builtIn)
|
|
1976
|
+
if (!up) return badge
|
|
1977
|
+
return h('span', { className: 'acts' },
|
|
1978
|
+
h('button', { className: 'btn warn', 'data-testid': 'update-built-in', onClick: (e) => { e.stopPropagation(); openInstall([p.id], `${S.updateTo(up.to)}`, { update: true }) } }, I.down(), ' ', S.updateTo(up.to)), badge)
|
|
1979
|
+
}
|
|
1980
|
+
if (isIn(p)) {
|
|
1981
|
+
const on = isOn(p)
|
|
1982
|
+
const up = updates.find((u) => u.entry.id === p.id)
|
|
1983
|
+
const main = up
|
|
1984
|
+
? h('button', { className: 'btn warn', onClick: (e) => { e.stopPropagation(); openInstall([p.id], `${S.updateTo(up.to)}`, { update: true }) } }, I.down(), ' ', S.updateTo(up.to))
|
|
1985
|
+
: !on ? h('button', { className: 'btn', onClick: (e) => { e.stopPropagation(); toggle(p, true) } }, S.enable)
|
|
1986
|
+
: h('span', { className: 'btn ok' }, I.check(), ' ', S.enabled)
|
|
1987
|
+
return h('span', { className: 'acts' }, main,
|
|
1988
|
+
h('button', { className: 'btn sm idle', onClick: (e) => { e.stopPropagation(); setMenu(menu === p.id ? null : p.id) } }, S.manage),
|
|
1989
|
+
menu === p.id && h('div', { className: 'menu', onClick: (e) => e.stopPropagation() },
|
|
1990
|
+
h('button', { onClick: () => { setMenu(null); setDrawer(p.id) } }, S.details),
|
|
1991
|
+
h('button', { onClick: () => toggle(p, !on) }, on ? S.disable : S.enable),
|
|
1992
|
+
h('button', { className: 'danger', onClick: () => doUninstall(p) }, S.uninstall)))
|
|
1993
|
+
}
|
|
1994
|
+
const m = missingDeps(p)
|
|
1995
|
+
return h('button', { className: 'btn primary', disabled: !host.pm || bundles === false, onClick: (e) => { e.stopPropagation(); openInstall([p.id], `${S.install} ${L(p.name, lang)}${m.length ? '' : ''}`) } }, I.down(), ' ', m.length ? S.installWithDeps : S.install)
|
|
1996
|
+
}
|
|
1997
|
+
const Card = (p) => {
|
|
1998
|
+
const m = missingDeps(p)
|
|
1999
|
+
const dep = (p.requires || []).length
|
|
2000
|
+
? h('div', { className: 'dep ' + (m.length ? 'miss' : '') }, m.length ? I.warn(14) : h('span', { className: 'dotc ok' }, I.check(9)),
|
|
2001
|
+
S.needs((p.requires || []).map((d) => L(byId(d).name, lang)).join(', ')), m.length ? S.willInstall : S.satisfied)
|
|
2002
|
+
: null
|
|
2003
|
+
return h('div', { className: 'card', key: p.id, 'data-id': p.id, onClick: () => setDrawer(p.id) },
|
|
2004
|
+
h('div', { className: 'hd' }, Glyph(p), h('div', null, h('div', { className: 'nm' }, L(p.name, lang)), h('div', { className: 'sub' }, `${p.npm} · ${shownVersion(p)}`))),
|
|
2005
|
+
h('div', { className: 'tg' }, L(p.tagline, lang)),
|
|
2006
|
+
h('div', { className: 'tags' }, tagEls(p)),
|
|
2007
|
+
dep,
|
|
2008
|
+
h('div', { className: 'ft' }, h('div', { className: 'meta' }, p.sizeNote ? L(p.sizeNote, lang) : fmtSize(p.sizeKB)), stateBtn(p)))
|
|
2009
|
+
}
|
|
2010
|
+
|
|
2011
|
+
const Suite = () => {
|
|
2012
|
+
const s = (liveCatalog.suites ?? [])[0]
|
|
2013
|
+
if (!s) return null
|
|
2014
|
+
const items = (s.items ?? []).map(byId).filter(Boolean)
|
|
2015
|
+
const todo = items.filter((p) => !isIn(p) || !isOn(p) || isProvided(p) && legacy.some((x) => x.entry.id === p.id))
|
|
2016
|
+
// What the plugins still to install weigh in the catalog (it used to say a fixed ~12 MB).
|
|
2017
|
+
const todoKB = todo.reduce((sum, p) => sum + (Number.isFinite(p.sizeKB) ? p.sizeKB : 0), 0)
|
|
2018
|
+
const chips = []
|
|
2019
|
+
items.forEach((p, i) => {
|
|
2020
|
+
if (i) chips.push(h('span', { className: 'arrow', key: 'a' + i }, I.arrow()))
|
|
2021
|
+
chips.push(h('div', { className: 'chip ' + (isIn(p) ? 'done' : ''), key: p.id }, Glyph(p, 'gl'), L(p.name, lang), h('span', { className: 'st' })))
|
|
2022
|
+
})
|
|
2023
|
+
chips.forEach((c) => c)
|
|
2024
|
+
return h('div', { className: 'suite' },
|
|
2025
|
+
h('div', null, h('h3', null, I.star(18), ' ', L(s.name, lang)), h('p', null, L(s.tagline, lang))),
|
|
2026
|
+
// Every state keeps the line under the button (blank when there is nothing to say), so the box keeps its
|
|
2027
|
+
// height when the installed list arrives and nothing below it moves.
|
|
2028
|
+
h('div', { className: 'r' }, bundles === null
|
|
2029
|
+
? [h('span', { key: 'b', className: 'btn big ph', 'data-testid': 'state-pending', 'aria-hidden': 'true' }, '\u00a0'),
|
|
2030
|
+
h('small', { key: 's', 'aria-hidden': 'true' }, '\u00a0')]
|
|
2031
|
+
: todo.length
|
|
2032
|
+
? [h('button', { key: 'b', className: 'btn primary big', disabled: !host.pm || bundles === false, onClick: () => openInstall(s.items, `${S.install} ${L(s.name, lang)}`) }, I.down(), ' ', S.suiteInstall),
|
|
2033
|
+
h('small', { key: 's' }, S.suiteWill(todo.length, items.length - todo.length, todoKB < 1024 ? S.sizeSmall : fmtSize(todoKB)))]
|
|
2034
|
+
: [h('span', { key: 'b', className: 'btn ok big' }, I.check(), ' ', S.suiteDone),
|
|
2035
|
+
h('small', { key: 's', 'aria-hidden': 'true' }, '\u00a0')]),
|
|
2036
|
+
h('div', { className: 'chips' }, chips))
|
|
2037
|
+
}
|
|
2038
|
+
|
|
2039
|
+
// Shown for as long as this page lives: a restart makes a new page and the notice goes away by itself.
|
|
2040
|
+
const NoRefresh = () => {
|
|
2041
|
+
if (!replaced.length) return null
|
|
2042
|
+
const names = replaced.map((n) => { const p = PLUGINS.find((x) => x.npm === n); return p ? L(p.name, lang) : n }).join(lang === 'zh' ? '\u3001' : ', ')
|
|
2043
|
+
return h('div', { className: 'banner', 'data-testid': 'no-refresh', role: 'alert' }, I.warn(),
|
|
2044
|
+
h('div', { className: 'grow' }, h('b', null, S.noRefreshT), h('small', null, S.noRefreshB(names))))
|
|
2045
|
+
}
|
|
2046
|
+
|
|
2047
|
+
const SelfUpdate = () => {
|
|
2048
|
+
if (!selfUpd) return null
|
|
2049
|
+
const cur = host.version?.() ?? ''
|
|
2050
|
+
const close = h('button', { className: 'x', key: 'x', title: S.dismiss, onClick: () => setSelfUpd(null) }, '\u00d7')
|
|
2051
|
+
const at = (d) => d.toLocaleString()
|
|
2052
|
+
if (selfUpd.kind === 'checking') return h('div', { className: 'note', 'data-testid': 'self-update', 'data-kind': 'checking', style: { display: 'flex', gap: 8, alignItems: 'center', marginBottom: 12 } }, h('span', { className: 'spin' }), S.checking)
|
|
2053
|
+
if (selfUpd.kind === 'same' || selfUpd.kind === 'ahead') return h('div', { className: 'res ok', 'data-testid': 'self-update', 'data-kind': selfUpd.kind }, I.ok(), h('div', { style: { flex: 1 } }, h('span', null, selfUpd.kind === 'same' ? S.selfOk(cur) : S.selfAhead(cur, selfUpd.latest)),
|
|
2054
|
+
// Running an update of this center: the copy shipped with the app is one click away.
|
|
2055
|
+
selfCopy?.selected === 'profile' && selfCopy.shipped && h('div', { style: { display: 'flex', gap: 8, marginTop: 8, flexWrap: 'wrap', alignItems: 'center' } },
|
|
2056
|
+
h('span', null, S.builtInUpdated(selfCopy.local, selfCopy.shipped)),
|
|
2057
|
+
h('button', { className: 'btn sm', 'data-testid': 'restore-self', disabled: !host.pm, onClick: () => doBuiltIn('restore', SELF_PKG, selfCopy.shipped) }, S.restoreBuiltIn(selfCopy.shipped)))), close)
|
|
2058
|
+
if (selfUpd.kind === 'unavailable') {
|
|
2059
|
+
const list = (selfUpd.sources || []).map((s) => { let host0 = s.registry; try { host0 = new URL(s.registry).host } catch { /* keep as is */ } return `${host0} (${s.error})` }).join(', ')
|
|
2060
|
+
return h('div', { className: 'res warn', 'data-testid': 'self-update', 'data-kind': 'unavailable' }, I.warn(), h('div', { style: { flex: 1 } }, h('b', null, S.selfFailT), h('span', null, S.selfFailB(list))), close)
|
|
2061
|
+
}
|
|
2062
|
+
// Built into an app that can update it in place: one click, effective after a restart.
|
|
2063
|
+
if (selfBuiltIn && selfCopy) return h('div', { className: 'res ok', 'data-testid': 'self-update', 'data-kind': 'newer-updatable' }, I.ok(), h('div', { style: { flex: 1 } },
|
|
2064
|
+
h('b', null, S.selfNewT(selfUpd.latest, cur)), h('span', null, selfPending ? S.builtInPending(selfPending) : S.selfUpdatable),
|
|
2065
|
+
!selfPending && h('div', { style: { display: 'flex', gap: 8, marginTop: 8, flexWrap: 'wrap' } },
|
|
2066
|
+
h('button', { className: 'btn primary sm', 'data-testid': 'update-self', disabled: !host.pm, onClick: () => doBuiltIn('update', SELF_PKG, selfUpd.latest) }, S.updateTo(selfUpd.latest)))), close)
|
|
2067
|
+
// Built into the app: a newer center comes with the next app release; there is nothing to reinstall.
|
|
2068
|
+
if (selfBuiltIn) return h('div', { className: 'res ok', 'data-testid': 'self-update', 'data-kind': 'newer-built-in' }, I.ok(), h('div', { style: { flex: 1 } },
|
|
2069
|
+
h('b', null, S.selfNewT(selfUpd.latest, cur)), h('span', null, S.selfBuiltIn)), close)
|
|
2070
|
+
const cd = E.cooldownState(selfUpd.publishedAt)
|
|
2071
|
+
return h('div', { className: 'res warn', 'data-testid': 'self-update', 'data-kind': 'newer' }, I.warn(), h('div', { style: { flex: 1 } },
|
|
2072
|
+
h('b', null, S.selfNewT(selfUpd.latest, cur)), h('span', null, S.selfNewB),
|
|
2073
|
+
h('pre', { className: 'cmd', 'data-testid': 'self-pkg' }, SELF_PKG),
|
|
2074
|
+
cd.active && h('div', { className: 'note', 'data-testid': 'self-cooldown' }, S.selfCool(at(new Date(selfUpd.publishedAt)), at(cd.endsAt))),
|
|
2075
|
+
h('div', { style: { display: 'flex', gap: 8, marginTop: 8, flexWrap: 'wrap' } },
|
|
2076
|
+
h('button', { className: 'btn primary sm', 'data-testid': 'copy-self', onClick: copyPkg }, copied ? S.copiedPkg : S.copyPkg),
|
|
2077
|
+
h('button', { className: 'btn sm', 'data-testid': 'view-self', onClick: () => host.openUrl?.(`https://github.com/VibeDev-Si/dsh-ecosystem/tree/v${selfUpd.latest}`) }, S.viewVersion))), close)
|
|
2078
|
+
}
|
|
2079
|
+
|
|
2080
|
+
const AccountInstall = () => {
|
|
2081
|
+
if (!Array.isArray(bundles) || accountState.available || !byId('@vibedev-si/dsh-vibedev') || isIn(byId('@vibedev-si/dsh-vibedev'))) return null
|
|
2082
|
+
return h('div', { className: 'banner info', 'data-testid': 'account-install' },
|
|
2083
|
+
h('div', { className: 'grow' }, h('b', null, S.accountInstallTitle), h('small', null, S.accountInstallBody)),
|
|
2084
|
+
h('button', { type: 'button', className: 'btn', disabled: !host.pm || !Array.isArray(bundles),
|
|
2085
|
+
onClick: () => openInstall(['@vibedev-si/dsh-vibedev'], S.installAccount) }, S.installAccount))
|
|
2086
|
+
}
|
|
2087
|
+
const Intro = () => h('div', { className: 'intro' },
|
|
2088
|
+
h('h2', null, S.introTitle), h('p', { className: 'lead' }, S.introLead),
|
|
2089
|
+
h('div', { className: 'three' },
|
|
2090
|
+
h('div', { className: 'fact' }, h('div', { className: 'ic' }, I.shield()), h('b', null, S.f1t), h('span', null, S.f1d)),
|
|
2091
|
+
h('div', { className: 'fact' }, h('div', { className: 'ic' }, I.bolt()), h('b', null, S.f2t), h('span', null, S.f2d)),
|
|
2092
|
+
h('div', { className: 'fact' }, h('div', { className: 'ic' }, I.star()), h('b', null, S.f3t), h('span', null, S.f3d))),
|
|
2093
|
+
market && h('div', { className: 'not', 'data-testid': 'intro-market' }, I.arrow(), ' ', S.introMarket,
|
|
2094
|
+
h('button', { className: 'lnk', onClick: toMarket }, marketIn ? S.openMarket : S.installMarket)))
|
|
2095
|
+
|
|
2096
|
+
const Banner = () => legacy.map((x) => h('div', { className: 'banner', key: x.legacy, 'data-testid': 'migrate-banner' }, I.warn(),
|
|
2097
|
+
h('div', { className: 'grow' }, h('b', null, S.migrateTitle(x.legacy)), ' ', S.migrateBody(x.legacy, x.entry.npm), h('small', null, x.provided ? S.providedMigration : S.migrateOrder)),
|
|
2098
|
+
h('button', { className: 'btn primary', onClick: () => doMigrate(x) }, S.migrateBtn)))
|
|
2099
|
+
|
|
2100
|
+
const Community = () => {
|
|
2101
|
+
const p = market
|
|
2102
|
+
if (!p) {
|
|
2103
|
+
// Apps whose Plugins page has a "Discover" tab list VibeDev's reviewed community plugins there. The center only
|
|
2104
|
+
// points to that tab and never reads the list itself; other apps keep the neutral note.
|
|
2105
|
+
let tabs = null
|
|
2106
|
+
try { tabs = host.pluginsTabs?.() ?? null } catch { tabs = null }
|
|
2107
|
+
if (!tabs) return h('div', { className: 'note', 'data-testid': 'market-unlisted' }, S.communityUnlisted)
|
|
2108
|
+
return h('div', { className: 'empty', 'data-testid': 'community-discover' }, h('div', { className: 'ic' }, I.shield()),
|
|
2109
|
+
h('h2', null, S.discoverT), h('p', null, S.discoverB),
|
|
2110
|
+
h('button', { className: 'btn primary big', 'data-testid': 'open-discover', onClick: () => setDiscoverFailed(!tabs.open('discover')) }, S.discoverOpen, ' ', I.arrow()),
|
|
2111
|
+
discoverFailed && h('div', { className: 'note', 'data-testid': 'discover-failed' }, S.discoverFailed))
|
|
2112
|
+
}
|
|
2113
|
+
if (!marketIn) return h('div', { className: 'empty' }, Glyph(p), h('h2', null, S.communityEmptyT), h('p', null, S.communityEmptyB(p.author)),
|
|
2114
|
+
h('button', { className: 'btn primary big', disabled: !host.pm, onClick: () => openInstall([MARKET], `${S.install} ${L(p.name, lang)}`) }, I.down(), ' ', S.installMarket), h('div', { className: 'note' }, S.communityNote(fmtSize(p.sizeKB))))
|
|
2115
|
+
const embedded = host.renderMarket?.()
|
|
2116
|
+
return h('div', { className: 'embed' },
|
|
2117
|
+
h('div', { className: 'embed-h' }, h('b', null, S.tabCommunity), h('span', { className: 'pill' }, S.communityViaMarket(L(p.name, lang))), h('span', { className: 'sp' }), h('button', { className: 'btn sm', onClick: () => setDrawer(MARKET) }, S.communityAbout(L(p.name, lang)))),
|
|
2118
|
+
h('div', { 'data-vdc-market': '', ref: marketRef, style: { padding: 16 } }, embedded || h('div', { className: 'note', 'data-testid': 'no-embed' }, S.communityNoEmbed)))
|
|
2119
|
+
}
|
|
2120
|
+
|
|
2121
|
+
const ReleaseRows = () => [
|
|
2122
|
+
selfRelease.kind === 'newer' && selfBuiltIn && selfCopy && h('article', { className: 'card', key: 'self', 'data-testid': 'self-update-row', 'data-built-in': '', 'data-updatable': '' },
|
|
2123
|
+
h('h3', null, S.title), h('div', { className: 'sub' }, `${SELF_PKG} · ${host.version?.() ?? ''} → ${selfRelease.latest}`),
|
|
2124
|
+
h('p', null, selfPending ? S.builtInPending(selfPending) : S.selfUpdatable),
|
|
2125
|
+
h('div', { className: 'cfoot' }, h('span', { className: 'tag' }, S.provided),
|
|
2126
|
+
!selfPending && h('button', { className: 'btn warn', 'data-testid': 'update-self-row', disabled: !host.pm,
|
|
2127
|
+
onClick: () => doBuiltIn('update', SELF_PKG, selfRelease.latest, releaseState.answer?.self?.registry ?? null) }, I.down(), ' ', S.updateTo(selfRelease.latest)))),
|
|
2128
|
+
selfRelease.kind === 'newer' && selfBuiltIn && !selfCopy && h('article', { className: 'card', key: 'self', 'data-testid': 'self-update-row', 'data-built-in': '' },
|
|
2129
|
+
h('h3', null, S.title), h('div', { className: 'sub' }, `${SELF_PKG} · ${host.version?.() ?? ''} → ${selfRelease.latest}`),
|
|
2130
|
+
h('p', null, S.selfBuiltIn), h('span', { className: 'tag' }, S.provided)),
|
|
2131
|
+
selfRelease.kind === 'newer' && !selfBuiltIn && h('article', { className: 'card', key: 'self', 'data-testid': 'self-update-row' },
|
|
2132
|
+
h('h3', null, S.title), h('div', { className: 'sub' }, `${SELF_PKG} · ${host.version?.() ?? ''} → ${selfRelease.latest}`),
|
|
2133
|
+
h('p', null, S.selfRowHelp), h('code', { 'data-testid': 'self-update-spec' }, `${SELF_PKG}@${selfRelease.latest}`),
|
|
2134
|
+
h('div', { className: 'cfoot' }, h('button', { className: 'btn', 'data-testid': 'copy-self-update',
|
|
2135
|
+
onClick: () => host.copy?.(`${SELF_PKG}@${selfRelease.latest}`) }, S.copyPkg))),
|
|
2136
|
+
...appUpdates.map((u) => h('article', { className: 'card', key: 'app-' + u.entry.id, 'data-testid': 'app-update-row', 'data-app': u.entry.id },
|
|
2137
|
+
h('h3', null, L(u.entry.name, lang)), h('div', { className: 'sub' }, `${u.from} → ${u.to}`),
|
|
2138
|
+
h('p', null, S.appUpdateHelp), h('span', { className: 'tag' }, S.provided))),
|
|
2139
|
+
].filter(Boolean)
|
|
2140
|
+
/** On the first page: what can be updated, and the way to it (built-in plugins included; nothing installs by itself). */
|
|
2141
|
+
const UpdatesBanner = () => {
|
|
2142
|
+
if (!Array.isArray(bundles) || counts.upd === 0) return null
|
|
2143
|
+
const names = [
|
|
2144
|
+
...updates.map((u) => `${L(u.entry.name, lang)} ${u.to}`),
|
|
2145
|
+
...appUpdates.map((u) => `${L(u.entry.name, lang)} ${u.to}`),
|
|
2146
|
+
...selfRelease.kind === 'newer' ? [`${S.title} ${selfRelease.latest}`] : [],
|
|
2147
|
+
]
|
|
2148
|
+
const shown = names.slice(0, 3).join(lang === 'zh' ? '、' : ', ') + (names.length > 3 ? S.updatesBannerMore : '')
|
|
2149
|
+
return h('div', { className: 'banner info', key: 'updates', 'data-testid': 'updates-banner' }, I.down(),
|
|
2150
|
+
h('div', { className: 'grow' }, h('b', null, S.updatesBannerT(counts.upd)), h('small', null, shown)),
|
|
2151
|
+
h('button', { className: 'btn primary', 'data-testid': 'updates-banner-open', onClick: () => { if (accountState.available) host.openCenter?.('updates'); setView('updates') } }, S.updatesBannerOpen))
|
|
2152
|
+
}
|
|
2153
|
+
const Main = () => {
|
|
2154
|
+
if (view === 'community') return Community()
|
|
2155
|
+
let list = official
|
|
2156
|
+
if (view === 'installed') list = official.filter(isIn)
|
|
2157
|
+
if (view === 'updates') list = updates.map((u) => u.entry)
|
|
2158
|
+
const extra = view === 'updates' ? ReleaseRows() : []
|
|
2159
|
+
const checked = fullyChecked && Array.isArray(bundles)
|
|
2160
|
+
const status = releaseState.kind === 'checking' || releaseState.kind === 'idle' ? S.releaseChecking
|
|
2161
|
+
: checked ? S.releaseChecked : S.releaseUnavailable
|
|
2162
|
+
return [
|
|
2163
|
+
view === 'all' && UpdatesBanner(),
|
|
2164
|
+
view === 'all' && intro && h(Intro, { key: 'i' }),
|
|
2165
|
+
view === 'all' && h(Suite, { key: 's' }),
|
|
2166
|
+
h('div', { className: 'sec', key: 'h' }, h('h3', null, S.official), h('span', null, S.officialSub(official.length))),
|
|
2167
|
+
view === 'updates' && h('div', { className: 'note', key: 'status', 'data-testid': 'release-status',
|
|
2168
|
+
'data-state': releaseState.kind === 'checking' || releaseState.kind === 'idle' ? 'checking' : checked ? 'verified' : 'unavailable' },
|
|
2169
|
+
status, ' ', h('button', { className: 'lnk', disabled: releaseState.kind === 'checking', onClick: checkSelf }, S.checkUpdate)),
|
|
2170
|
+
list.length || extra.length ? h('div', { className: 'grid', key: 'g' }, [...list.map(Card), ...extra])
|
|
2171
|
+
: h('div', { className: 'note', key: 'n', style: { padding: '30px 0', textAlign: 'center' } },
|
|
2172
|
+
view === 'updates' ? (checked ? S.allUpToDate : S.releaseNoVerifiedUpdates) : S.nothingInstalled),
|
|
2173
|
+
// A catalog that lists no prerequisite or companion (none since the community market left it) shows no such section.
|
|
2174
|
+
view === 'all' && companions.length > 0 && [
|
|
2175
|
+
h('div', { className: 'sec', key: 'dh' }, h('h3', null, S.deps), h('span', null, S.depsSub)),
|
|
2176
|
+
h('div', { className: 'grid', key: 'dg' }, companions.map(Card)),
|
|
2177
|
+
],
|
|
2178
|
+
]
|
|
2179
|
+
}
|
|
2180
|
+
|
|
2181
|
+
const Drawer = () => {
|
|
2182
|
+
const p = drawer && byId(drawer)
|
|
2183
|
+
if (!p) return null
|
|
2184
|
+
const m = missingDeps(p)
|
|
2185
|
+
const caps = (p.capabilities || [])
|
|
2186
|
+
return [
|
|
2187
|
+
h('div', { className: 'mask', key: 'm', onClick: () => setDrawer(null) }),
|
|
2188
|
+
h('aside', { className: 'drawer', key: 'd', 'data-testid': 'drawer' },
|
|
2189
|
+
h('div', { className: 'dh' }, h('div', { className: 'row' }, Glyph(p), h('div', null, h('h2', null, L(p.name, lang)), h('div', { className: 'sub' }, `${p.npm} · ${shownVersion(p)} · ${p.origin === 'official' ? S.officialSrc : S.communitySrc(p.author)}`)),
|
|
2190
|
+
h('button', { className: 'x', onClick: () => setDrawer(null) }, '×')), h('div', { className: 'tags', style: { marginTop: 10 } }, tagEls(p))),
|
|
2191
|
+
h('div', { className: 'db' },
|
|
2192
|
+
h('div', null, L(p.tagline, lang)),
|
|
2193
|
+
h('h4', null, S.does), h('ul', null, (p.does[lang] || p.does.en).map((d, i) => h('li', { key: i }, d))),
|
|
2194
|
+
h('h4', null, S.needsH),
|
|
2195
|
+
h('dl', { className: 'kv' },
|
|
2196
|
+
h('dt', null, S.prereq), h('dd', null, (p.requires || []).length ? relationEls(p.requires, 'requires') : S.none),
|
|
2197
|
+
h('dt', null, S.partners), h('dd', null, partnerIds(p).length ? relationEls(partnerIds(p), 'partners') : S.none),
|
|
2198
|
+
h('dt', null, S.size), h('dd', null, fmtSize(p.sizeKB))),
|
|
2199
|
+
E.oldCanvas(p, have.get(p.npm)) ? h('div', { className: 'note', 'data-testid': 'old-canvas' }, S.oldCanvasNote,
|
|
2200
|
+
h('button', { className: 'btn', 'data-testid': 'old-canvas-upgrade', onClick: () => openInstall([p.id], S.updateTo(shownVersion(p)), { update: true }) }, S.upgradeCanvas)) : null,
|
|
2201
|
+
h('h4', null, S.capsH), caps.map((c) => h('div', { className: 'cap', key: c.key }, h('b', null, capLabel(c.key, lang)), h('span', null, L(c.text, lang)))),
|
|
2202
|
+
h('h4', null, S.sourceH),
|
|
2203
|
+
h('dl', { className: 'kv' },
|
|
2204
|
+
h('dt', null, S.source), h('dd', null, p.origin === 'official' ? S.officialSrc : S.communitySrc(p.author)),
|
|
2205
|
+
h('dt', null, S.review), h('dd', null, p.origin === 'official' ? S.officialReview : p.reviewed ? S.reviewedBy(p.reviewed.tested.join(', '), p.reviewed.date) : S.notReviewed),
|
|
2206
|
+
p.compat ? [h('dt', { key: 'a' }, S.compat), h('dd', { key: 'b' }, `${S.compatS[p.compat.s]}: ${L(p.compat.why, lang)}`)] : null),
|
|
2207
|
+
h('h4', null, isProvided(p) ? S.provided : S.manualH), isProvided(p) ? BuiltInNote(p) : [h('pre', { className: 'cmd', key: 'cmd' }, p.cmd), h('div', { className: 'note', key: 'note' }, S.manualNote)],
|
|
2208
|
+
h('div', { className: 'links' }, h('button', { onClick: () => host.openUrl?.(p.links.repo) }, S.repo), h('button', { onClick: () => host.openUrl?.(p.links.npm) }, S.npm), !isProvided(p) && h('button', { onClick: () => host.copy?.(p.cmd) }, S.copyCmd))),
|
|
2209
|
+
h('div', { className: 'dfoot' }, h('div', { className: 'grow' }, isProvided(p) ? S.provided : isIn(p) ? (isOn(p) ? S.enabled : S.disabled) : m.length ? S.willInstall : ''), isIn(p) ? h('button', { className: 'btn', disabled: true }, isProvided(p) ? S.provided : isOn(p) ? S.enabled : S.disabled)
|
|
2210
|
+
: h('button', { className: 'btn primary big', disabled: !host.pm, onClick: () => openInstall([p.id], `${S.install} ${L(p.name, lang)}`) }, I.down(), ' ', m.length ? S.installWithDeps : S.install))),
|
|
2211
|
+
]
|
|
2212
|
+
}
|
|
2213
|
+
/** What the detail says about an app-owned plugin: how it updates, and the way back to the shipped copy. */
|
|
2214
|
+
const BuiltInNote = (p) => {
|
|
2215
|
+
const b = have.get(p.npm)
|
|
2216
|
+
const copy = E.applicationCopy(b)
|
|
2217
|
+
if (!copy) return h('div', { className: 'note', 'data-testid': 'provided-note' }, S.providedNote)
|
|
2218
|
+
const updated = copy.selected === 'profile' && copy.local && copy.shipped
|
|
2219
|
+
return h('div', { className: 'note', 'data-testid': 'provided-note', 'data-updatable': '' }, S.providedUpdatable,
|
|
2220
|
+
updated && h('div', { style: { display: 'flex', gap: 8, marginTop: 8, flexWrap: 'wrap', alignItems: 'center' } },
|
|
2221
|
+
h('span', { 'data-testid': 'built-in-updated' }, S.builtInUpdated(copy.local, copy.shipped)),
|
|
2222
|
+
h('button', { className: 'btn sm', 'data-testid': 'restore-built-in', disabled: !host.pm, onClick: () => doBuiltIn('restore', p.npm, copy.shipped) }, S.restoreBuiltIn(copy.shipped))))
|
|
2223
|
+
}
|
|
2224
|
+
const capLabel = (k, lg) => ({
|
|
2225
|
+
network: lg === 'zh' ? '联网' : 'Network', writeFiles: lg === 'zh' ? '写入文件' : 'Writes files', readFiles: lg === 'zh' ? '读取文件' : 'Reads files', credentials: lg === 'zh' ? '凭据' : 'Credentials',
|
|
2226
|
+
cost: lg === 'zh' ? '费用' : 'Cost', agentTools: lg === 'zh' ? 'Agent 工具' : 'Agent tools', localRoute: lg === 'zh' ? '本机路由' : 'Local route', pageScripts: lg === 'zh' ? '页面脚本' : 'Page scripts',
|
|
2227
|
+
community: lg === 'zh' ? '社区插件' : 'Community', fileAccess: lg === 'zh' ? '文件访问' : 'File access', writeConfig: lg === 'zh' ? '写入配置' : 'Writes config',
|
|
2228
|
+
}[k] || k)
|
|
2229
|
+
|
|
2230
|
+
/* ── modals ──────────────────────────────────────────────────────────── */
|
|
2231
|
+
const stIcon = (r) => {
|
|
2232
|
+
if (r.st === 'skip') return h('span', { className: 'stat' }, S.stSkip)
|
|
2233
|
+
if (r.st === 'wait') return h('span', { className: 'stat' }, h('span', { className: 'dotc wait' }), S.stWait)
|
|
2234
|
+
if (r.st === 'ok') return h('span', { className: 'stat', style: { color: 'var(--ok)' } }, h('span', { className: 'dotc ok' }, I.check(9)), S.stDone)
|
|
2235
|
+
if (r.st === 'hold') return h('span', { className: 'stat', style: { color: 'var(--warn)' } }, h('span', { className: 'dotc hold' }, '!'), S.stHold)
|
|
2236
|
+
if (r.st === 'err') return h('span', { className: 'stat', style: { color: 'var(--err)' } }, h('span', { className: 'dotc err' }, '!'), S.stFail)
|
|
2237
|
+
return h('span', { className: 'stat' }, h('span', { className: 'spin' }), r.sub)
|
|
2238
|
+
}
|
|
2239
|
+
const Row = (r) => h('div', { className: 'row3 ' + (r.st === 'skip' ? 'skip' : ''), key: r.entry.id }, Glyph(r.entry, 'gl'),
|
|
2240
|
+
h('div', { className: 'm' }, h('b', null, L(r.entry.name, lang)), ' ', h('span', { style: { color: 'var(--t2)', fontWeight: 400 } }, r.update ? `${r.update.from} → ${r.update.to}` : r.entry.version),
|
|
2241
|
+
h('div', null, r.st === 'skip' ? (r.provided ? S.provided + ' · ' + S.alreadyInstalled : S.alreadyInstalled) : r.update ? S.afterUpdateRefresh : r.legacy ? `${r.entry.npm} · ${S.replacesOld(r.legacy)}` : r.entry.npm)), stIcon(r))
|
|
2242
|
+
|
|
2243
|
+
const Confirm = () => {
|
|
2244
|
+
const { rows, title, update } = modal
|
|
2245
|
+
const todo = rows.filter((r) => E.needsInstall(r, update))
|
|
2246
|
+
const accts = update || accountState.signedIn ? [] : todo.filter((r) => (r.entry.tags || []).includes('needsAccount'))
|
|
2247
|
+
const switching = update ? [] : todo.filter((r) => r.legacy)
|
|
2248
|
+
return [
|
|
2249
|
+
h('div', { className: 'mh', key: 'h' }, h('h2', null, title), h('p', null, update ? S.willUpdateN(todo.length, sizeOf(todo.map((r) => r.entry))) : S.willInstallN(todo.length, rows.length - todo.length, sizeOf(todo.map((r) => r.entry))))),
|
|
2250
|
+
h('div', { className: 'mb', key: 'b' },
|
|
2251
|
+
rows.map((r) => Row({ ...r, st: E.needsInstall(r, update) ? 'wait-confirm' : 'skip', sub: '' })).map((el, i) => React.cloneElement(el, { key: i })),
|
|
2252
|
+
(() => {
|
|
2253
|
+
if (!update) return null
|
|
2254
|
+
const fresh = todo.filter((r) => E.cooldownState(r.entry.publishedAt).active)
|
|
2255
|
+
if (!fresh.length) return h('div', { className: 'note' }, S.updateKeeps)
|
|
2256
|
+
const end = new Date(Math.max(...fresh.map((r) => E.cooldownState(r.entry.publishedAt).endsAt.getTime())))
|
|
2257
|
+
return h('div', { className: 'res warn', 'data-testid': 'cooldown-note' }, I.warn(), h('div', null, h('span', null, S.coolUpdate(fresh.map((r) => `${L(r.entry.name, lang)} ${r.entry.version}`).join(lang === 'zh' ? '\u3001' : ', '), end.toLocaleString()))))
|
|
2258
|
+
})(),
|
|
2259
|
+
accts.length ? h('div', { className: 'res warn', 'data-testid': 'account-warning' }, I.warn(), h('div', null, h('b', null, S.acctTitle), h('span', null, S.acctBody(accts.map((r) => L(r.entry.name, lang)).join(', '))))) : null,
|
|
2260
|
+
switching.length ? h('div', { className: 'note', 'data-testid': 'switch-note' }, S.switchNote(switching.map((r) => r.legacy).join(', '))) : null,
|
|
2261
|
+
h('details', null, h('summary', null, S.stepsH), h('div', { className: 'log' }, todo.map((r) => r.legacy && !update
|
|
2262
|
+
? `1 inspect ${E.specOf(r.entry)}\n2 install enabled:false\n3 disable ${r.legacy}\n4 enable -> applied\n5 remove ${r.legacy}`
|
|
2263
|
+
: `1 inspect ${E.specOf(r.entry)}\n2 ${update ? 'update ' : 'install'} enabled:false\n3 enable -> applied`).join('\n\n') + '\n\n' + S.stepsFoot))),
|
|
2264
|
+
h('div', { className: 'mf', key: 'f' }, h('div', { className: 'grow' }, S.consent(update)), h('button', { className: 'btn', onClick: () => setModal(null) }, S.cancel),
|
|
2265
|
+
h('button', { className: 'btn primary big', 'data-testid': 'confirm', onClick: () => start(rows, title, update) }, S.confirmInstall(todo.length, update))),
|
|
2266
|
+
]
|
|
2267
|
+
}
|
|
2268
|
+
const Run = () => {
|
|
2269
|
+
const { run } = modal
|
|
2270
|
+
const todo = run.rows.filter((r) => r.st !== 'skip')
|
|
2271
|
+
const done = todo.filter((r) => r.st === 'ok').length
|
|
2272
|
+
const pct = todo.length ? Math.round(((done + (run.cur ? 0.5 : 0)) / todo.length) * 100) : 100
|
|
2273
|
+
return [
|
|
2274
|
+
h('div', { className: 'mh', key: 'h' }, h('h2', null, `${S.installing}: ${run.title.replace(/^[^ ]+ /, '')}`), h('p', { 'data-testid': 'progress' }, run.settling ? S.settling : run.waiting ? S.waitingHost : S.progress(done, todo.length))),
|
|
2275
|
+
h('div', { className: 'mb', key: 'b' }, h('div', { className: 'bar' }, h('i', { style: { width: Math.min(pct, 100) + '%' } })), run.rows.map(Row),
|
|
2276
|
+
h('details', { open: true }, h('summary', null, S.logH), h('div', { className: 'log' }, run.log.join('\n')))),
|
|
2277
|
+
h('div', { className: 'mf', key: 'f' }, h('div', { className: 'grow' }, run.cur && run.cur.late ? S.cancelHintLate : S.cancelHintOk), h('button', { className: 'btn', 'data-testid': 'cancel', disabled: !!(run.cur && run.cur.late), onClick: cancelRun }, S.cancelInstall)),
|
|
2278
|
+
]
|
|
2279
|
+
}
|
|
2280
|
+
const failText = (f) => {
|
|
2281
|
+
switch (f.kind) {
|
|
2282
|
+
case 'network': return [S.fNetworkT, S.fNetworkB(f.registries ? f.registries.length : 0, f.diagnostic), 'err']
|
|
2283
|
+
case 'builds': return [S.fBuildsT, S.fBuildsB(f.pendingBuilds.join(', ')), 'warn']
|
|
2284
|
+
case 'incompat': return [S.fIncompatT, S.fIncompatB((f.incompatible || []).map((x) => `${x.name}@${x.version}: ${x.runtimeVersion} (${E.incompatibleRequirements(x).map(([a, b]) => `${a} ${b}`).join(', ')}). `).join('')), 'err']
|
|
2285
|
+
case 'notfound': return [S.fNotFoundT, S.fNotFoundB, 'err']
|
|
2286
|
+
case 'mismatch': return [S.fMismatchT, S.fMismatchB(f.diagnostic || ''), 'err']
|
|
2287
|
+
case 'exempt': return [S.fExemptT, S.fExemptB(f.culprit, E.cooldownEnds(f.publishedAt)?.toLocaleString()), 'err']
|
|
2288
|
+
case 'busy': return [S.fBusyT, S.fBusyB, 'err']
|
|
2289
|
+
case 'provided': return [S.providedBlockedT, S.providedBlockedB, 'warn']
|
|
2290
|
+
case 'refused': return [S.fRefusedT, f.diagnostic || '', 'err']
|
|
2291
|
+
default: return [S.fFailedT, f.diagnostic ? f.diagnostic.slice(0, 400) : S.fFailedB, 'err']
|
|
2292
|
+
}
|
|
2293
|
+
}
|
|
2294
|
+
const Result = () => {
|
|
2295
|
+
const { run, results, failed, restart, update } = modal
|
|
2296
|
+
const todo = run.rows.filter((r) => r.st !== 'skip')
|
|
2297
|
+
const done = todo.filter((r) => r.st === 'ok')
|
|
2298
|
+
const failedRow = run.rows.find((r) => r.st === 'err' || r.st === 'hold')
|
|
2299
|
+
// An old package name that was switched off but could not be removed (the migrate banner offers to finish it).
|
|
2300
|
+
const leftOld = (results || []).some((x) => x.legacyLeft) && h('div', { className: 'res warn', key: 'old', 'data-testid': 'legacy-left' }, I.warn(), h('div', null, h('span', null, S.migHalf)))
|
|
2301
|
+
let head, extra, acts, title
|
|
2302
|
+
if (!failed && !restart) {
|
|
2303
|
+
title = S.doneTitle
|
|
2304
|
+
head = h('div', { className: 'res ok' }, I.ok(), h('div', null, h('b', null, S.doneHead(done.length)), h('span', null, S.doneLoaded)))
|
|
2305
|
+
const ids = done.map((r) => r.entry.id)
|
|
2306
|
+
extra = [leftOld, h('div', { className: 'next', key: 'next' }, h('b', null, S.nextH), h('ul', null,
|
|
2307
|
+
ids.includes('dsh-film') && h('li', { key: 1 }, S.nextFilm), ids.includes('@vibedev-si/dsh-vibedev') && h('li', { key: 2 }, S.nextVibedev),
|
|
2308
|
+
ids.includes('@vibedev-si/dsh-media-viewer') && h('li', { key: 3 }, S.nextViewer), ids.includes(MARKET) && h('li', { key: 4 }, S.nextMarket),
|
|
2309
|
+
!!market && !marketIn && !ids.includes(MARKET) && h('li', { key: 5 }, S.nextMarketHint)))]
|
|
2310
|
+
// No "reload the page" button, on purpose: the official Plugins page never reloads either (the host loads an
|
|
2311
|
+
// enabled plugin itself), and a reload pressed while the host was still applying the last change crashed a real user's boot.
|
|
2312
|
+
acts = h('button', { className: 'btn primary big', 'data-testid': 'done', onClick: () => setModal(null) }, S.gotIt)
|
|
2313
|
+
} else if (!failed && restart) {
|
|
2314
|
+
title = S.restartTitle
|
|
2315
|
+
head = h('div', { className: 'res warn' }, I.warn(), h('div', null, h('b', null, S.restartHead), h('span', null, S.restartBody(done.length))))
|
|
2316
|
+
extra = leftOld
|
|
2317
|
+
acts = h('button', { className: 'btn primary big', onClick: () => setModal(null) }, S.gotIt)
|
|
2318
|
+
} else {
|
|
2319
|
+
title = S.failTitle
|
|
2320
|
+
const f = failedRow?.failure || { kind: 'failed' }
|
|
2321
|
+
const [t, b, tone] = failed?.status === 'cancelled' ? [S.cancelInstall, '', 'warn'] : failText(f)
|
|
2322
|
+
head = h('div', { className: 'res ' + tone, 'data-testid': 'fail', 'data-kind': f.kind }, tone === 'warn' ? I.warn() : I.err(), h('div', null, h('b', null, t), h('span', null, b)))
|
|
2323
|
+
extra = [
|
|
2324
|
+
// After a failed switch, turning the new one on by hand would run both: say what happened to the old one instead.
|
|
2325
|
+
failed?.restoredOld ? h('div', { className: 'note', key: 1, 'data-testid': 'restored-old' }, S.migRestored)
|
|
2326
|
+
: failed?.oldStillEnabled ? h('div', { className: 'note', key: 1, 'data-testid': 'old-still-on' }, S.oldStillOn(failedRow?.legacy ?? ''))
|
|
2327
|
+
: failed?.installedNotEnabled && h('div', { className: 'note', key: 1 }, S.installedNotEnabled),
|
|
2328
|
+
// An update that replaced the installed copy says what became of it instead of "nothing was changed".
|
|
2329
|
+
failed?.restoredPrevious ? h('div', { className: 'note', key: 2, 'data-testid': 'restored-previous' }, (done.length ? S.keptDone(done.length) : '') + S.updRestored(failed.previousSpec))
|
|
2330
|
+
: failed?.previousLost ? h('div', { className: 'res warn', key: 2, 'data-testid': 'previous-lost' }, I.warn(), h('div', null, h('b', null, S.updLostT), h('span', null, S.updLostB(failed.previousSpec))))
|
|
2331
|
+
: h('div', { className: 'note', key: 2 }, (done.length ? S.keptDone(done.length) : '') + (f.kind === 'builds' ? S.noChangeHold : S.noChangeFail)),
|
|
2332
|
+
failed?.uncertain && h('div', { className: 'res warn', key: 3 }, I.warn(), h('div', null, h('b', null, S.uncertainT), h('span', null, S.uncertainB))),
|
|
2333
|
+
]
|
|
2334
|
+
const retryNow = () => start(run.rows.map((r) => ({ ...r, installed: r.st === 'ok' || r.installed && r.enabled, enabled: r.st === 'ok' || r.enabled })), run.title, update)
|
|
2335
|
+
acts = f.kind === 'provided' ? h('button', { className: 'btn', onClick: () => setModal(null) }, S.gotIt) : f.kind === 'builds'
|
|
2336
|
+
? [h('button', { className: 'btn', key: 's', onClick: () => setModal(null) }, S.skipThis), h('button', { className: 'btn primary big', key: 'r', 'data-testid': 'approve', onClick: () => start(run.rows.map((r) => ({ ...r, installed: r.st === 'ok' || (r.installed && r.enabled), enabled: r.st === 'ok' || r.enabled })), run.title, update, { [failedRow.entry.id]: f.pendingBuilds }) }, S.approveRetry)]
|
|
2337
|
+
: [h('button', { className: 'btn', key: 'c', onClick: () => { host.copy?.(failed?.previousLost ? `dsh plugin add ${failed.previousSpec}` : failedRow ? failedRow.entry.cmd : ''); } }, S.copyCmd), h('button', { className: 'btn', key: 'x', onClick: () => setModal(null) }, S.later),
|
|
2338
|
+
f.kind !== 'incompat' && f.kind !== 'mismatch' && h('button', { className: 'btn primary big', key: 'r', 'data-testid': 'retry', onClick: failed?.uncertain ? async () => { await refresh(); setModal(null) } : retryNow }, failed?.uncertain ? S.recheck : S.retry)]
|
|
2339
|
+
}
|
|
2340
|
+
return [
|
|
2341
|
+
h('div', { className: 'mh', key: 'h' }, h('h2', null, title), h('p', null, S.doneSub(done.length, todo.length))),
|
|
2342
|
+
h('div', { className: 'mb', key: 'b' }, head, run.rows.map(Row), extra),
|
|
2343
|
+
h('div', { className: 'mf', key: 'f' }, acts),
|
|
2344
|
+
]
|
|
2345
|
+
}
|
|
2346
|
+
const Migrate = () => {
|
|
2347
|
+
const { x, phase, step, result } = modal
|
|
2348
|
+
const steps = x.provided ? ['disable-old', 'remove-old'] : ['inspect', 'install', 'disable-old', 'enable', 'remove-old']
|
|
2349
|
+
if (phase === 'run') return [h('div', { className: 'mh', key: 'h' }, h('h2', null, S.migrating), h('p', null, x.provided ? S.providedMigration : S.migrateOrder)),
|
|
2350
|
+
h('div', { className: 'mb', key: 'b' }, steps.map((s, i) => h('div', { className: 'row3', key: s }, h('div', { className: 'm' }, h('b', null, `${i + 1}. ${s}`)), steps.indexOf(step) === i ? h('span', { className: 'stat' }, h('span', { className: 'spin' })) : steps.indexOf(step) > i ? h('span', { className: 'dotc ok' }, I.check(9)) : null)))]
|
|
2351
|
+
const ok = result.status === 'done', half = result.status === 'halfRemoved'
|
|
2352
|
+
return [h('div', { className: 'mh', key: 'h' }, h('h2', null, ok || half ? S.doneTitle : S.failTitle)),
|
|
2353
|
+
h('div', { className: 'mb', key: 'b' }, h('div', { className: 'res ' + (ok ? 'ok' : half ? 'warn' : 'err'), 'data-testid': 'mig-result', 'data-status': result.status }, ok ? I.ok() : half ? I.warn() : I.err(), h('div', null, h('b', null, ok ? S.migDone : half ? S.migHalf : result.restoredOld ? S.migRestored : result.failure?.kind === 'provided' ? S.providedBlockedT : S.fFailedT), h('span', null, !ok && !half && !result.restoredOld ? (result.failure?.kind === 'provided' ? S.providedBlockedB : result.failure?.diagnostic || '').slice(0, 300) : '')))),
|
|
2354
|
+
h('div', { className: 'mf', key: 'f' }, h('button', { className: 'btn primary big', onClick: () => setModal(null) }, S.gotIt))]
|
|
2355
|
+
}
|
|
2356
|
+
const UninstallResult = () => {
|
|
2357
|
+
const { p, result } = modal
|
|
2358
|
+
const f = result.failure || { kind: 'failed' }
|
|
2359
|
+
const [t, b] = failText(f)
|
|
2360
|
+
return [h('div', { className: 'mh', key: 'h' }, h('h2', null, result.status === 'halfRemoved' ? S.halfRemovedT : S.fFailedT)),
|
|
2361
|
+
h('div', { className: 'mb', key: 'b' }, h('div', { className: 'res warn', 'data-testid': 'half' }, I.warn(), h('div', null, h('b', null, result.status === 'halfRemoved' ? S.halfRemovedT : t), h('span', null, result.status === 'halfRemoved' ? S.halfRemovedB : b))),
|
|
2362
|
+
result.status === 'halfRemoved' && h('div', { className: 'res err' }, I.err(), h('div', null, h('b', null, t), h('span', null, b))), Row({ entry: p, st: 'err', sub: '' })),
|
|
2363
|
+
h('div', { className: 'mf', key: 'f' }, h('button', { className: 'btn', onClick: () => setModal(null) }, S.later),
|
|
2364
|
+
result.status === 'halfRemoved' && h('button', { className: 'btn', onClick: async () => { await toggle(p, true); setModal(null) } }, S.reenable),
|
|
2365
|
+
h('button', { className: 'btn primary big', onClick: async () => { setModal(null); await doUninstall(p) } }, S.retryUninstall))]
|
|
2366
|
+
}
|
|
2367
|
+
|
|
2368
|
+
/** Updating an app-owned package in place, or returning it to the shipped copy. */
|
|
2369
|
+
const BuiltIn = () => {
|
|
2370
|
+
const { action, version, phase, result } = modal
|
|
2371
|
+
const update = action === 'update'
|
|
2372
|
+
if (phase === 'run') return [h('div', { className: 'mh', key: 'h' }, h('h2', null, update ? S.builtInRunUpdate(version) : S.builtInRunRestore)),
|
|
2373
|
+
h('div', { className: 'mb', key: 'b' }, h('div', { className: 'note', style: { display: 'flex', gap: 8, alignItems: 'center' } }, h('span', { className: 'spin' }), update ? S.updateKeeps : S.builtInRunRestore))]
|
|
2374
|
+
const ok = result.status === 'restart'
|
|
2375
|
+
const [t, b, tone] = ok ? [update ? S.builtInDoneUpdateT(version) : S.builtInDoneRestoreT(version), S.builtInDoneB, 'warn']
|
|
2376
|
+
: result.status === 'cancelled' ? [S.cancelInstall, '', 'warn'] : failText(result.failure || { kind: 'failed' })
|
|
2377
|
+
return [h('div', { className: 'mh', key: 'h' }, h('h2', null, ok ? S.restartTitle : S.failTitle)),
|
|
2378
|
+
h('div', { className: 'mb', key: 'b' }, h('div', { className: 'res ' + tone, 'data-testid': 'built-in-result', 'data-status': result.status, 'data-kind': result.failure?.kind ?? '' },
|
|
2379
|
+
tone === 'err' ? I.err() : I.warn(), h('div', null, h('b', null, t), h('span', null, b)))),
|
|
2380
|
+
h('div', { className: 'mf', key: 'f' }, h('button', { className: 'btn primary big', 'data-testid': 'built-in-done', onClick: () => setModal(null) }, S.gotIt))]
|
|
2381
|
+
}
|
|
2382
|
+
|
|
2383
|
+
const modalBody = !modal ? null : modal.mode === 'confirm' ? Confirm() : modal.mode === 'run' ? Run() : modal.mode === 'result' ? Result() : modal.mode === 'migrate' ? Migrate() : modal.mode === 'builtin' ? BuiltIn() : UninstallResult()
|
|
2384
|
+
|
|
2385
|
+
const counts = { inst: official.filter(isIn).length, upd: updates.length + appUpdates.length + (selfRelease.kind === 'newer' ? 1 : 0) }
|
|
2386
|
+
// The sidebar entry shows the same number as the Updates tab (see E.updateCount), once the installed list is known.
|
|
2387
|
+
useEffect(() => { if (Array.isArray(bundles)) setBadge(counts.upd) }, [bundles, counts.upd])
|
|
2388
|
+
return h('div', { className: 'vdc', ref: rootRef, 'data-testid': 'center', 'data-embedded': embedded ? 'true' : 'false', onClick: () => menu && setMenu(null) },
|
|
2389
|
+
h('style', null, CSS),
|
|
2390
|
+
h('header', { className: 'top' },
|
|
2391
|
+
!embedded && h('div', { className: 'brand' }, h('div', { className: 'logo' }, I.logo()), h('h1', null, S.title), h('span', { className: 'pill' }, S.preview), host.version ? h('span', { className: 'pill', 'data-testid': 'version', title: S.title }, S.versionOf(host.version())) : null),
|
|
2392
|
+
h('nav', { className: 'tabs' }, [['all', S.tabAll, 0], ['installed', S.tabInstalled, counts.inst], ['updates', S.tabUpdates, counts.upd], ['community', S.tabCommunity, 0]].map(([k, t, c]) => h('button', { key: k, 'data-tab': k, className: 'tab ' + (view === k ? 'on' : ''), onClick: () => selectView(k) }, t, c ? h('span', { className: 'n' }, c) : null))),
|
|
2393
|
+
h('span', { className: 'sp' }), host.checkLatest ? h('button', { className: 'ghost', 'data-testid': 'check-update', disabled: selfUpd?.kind === 'checking', onClick: checkSelf }, S.checkUpdate) : null, h('button', { className: 'ghost', onClick: () => setIntro(!intro) }, S.about)),
|
|
2394
|
+
h('div', { className: 'scroll' }, h('div', { className: 'wrap' },
|
|
2395
|
+
bundles === false && h('div', { className: 'banner', 'data-testid': 'no-manager' }, I.warn(), h('div', { className: 'grow' }, h('b', null, S.loadFail), h('small', null, host.pm ? S.loadFailB : S.noManager))),
|
|
2396
|
+
accountError && h('div', { className: 'note', role: 'status' }, S.signInFailed),
|
|
2397
|
+
AccountInstall(), NoRefresh(), Banner(), SelfUpdate(), Main(),
|
|
2398
|
+
h('div', { className: 'foot' }, market && h('span', { 'data-testid': 'foot-market' }, S.footMore, h('button', { className: 'lnk', onClick: toMarket }, marketIn ? S.openMarket.replace(' →', '') : S.installMarket.replace(' →', ''))),
|
|
2399
|
+
h('span', null, S.footFeedback, ' ', h('button', { className: 'lnk', onClick: () => host.openUrl?.('https://github.com/VibeDev-Si/dsh-ecosystem/issues') }, 'VibeDev-Si · GitHub')), h('span', null, S.footCatalog(liveCatalog.updated,
|
|
2400
|
+
releaseState.answer?.catalog && !liveCatalog.listingAccepted ? 'bundled' : releaseState.answer?.catalogSource,
|
|
2401
|
+
releaseState.answer?.catalog && !liveCatalog.listingAccepted ? 'catalog refused' : releaseState.answer?.catalogError))))),
|
|
2402
|
+
Drawer(),
|
|
2403
|
+
modal && [h('div', { className: 'mask mask2', key: 'mk' }), h('section', { className: 'modal', key: 'md', 'data-mode': modal.mode }, modalBody)])
|
|
2404
|
+
}
|
|
2405
|
+
Center.startup = startup
|
|
2406
|
+
Center.dispose = dispose
|
|
2407
|
+
Center.updates = { count: () => badge.count, subscribe: (listener) => { badge.listeners.add(listener); return () => badge.listeners.delete(listener) } }
|
|
2408
|
+
return Center
|
|
2409
|
+
}
|
|
2410
|
+
|
|
2411
|
+
/**
|
|
2412
|
+
* Opt-in self-check. OFF unless the host says so: the host only answers {selfcheck:true} when the file
|
|
2413
|
+
* <profile>/.vdc/enable-selfcheck exists, which only a developer creates by hand.
|
|
2414
|
+
*
|
|
2415
|
+
* It makes READ-ONLY calls (listBundles, inspect) and never installs, enables, disables or removes anything.
|
|
2416
|
+
* It briefly opens the center's panel to prove it mounts inside the real shell, then puts the previous panel back.
|
|
2417
|
+
* Its report is POSTed to this machine's own /vdc/selfcheck route and written under the profile. Nothing leaves the machine.
|
|
2418
|
+
*/
|
|
2419
|
+
const sleep = (ms, signal) => {
|
|
2420
|
+
if (signal?.aborted) return Promise.resolve(false)
|
|
2421
|
+
return new Promise((resolve) => {
|
|
2422
|
+
const finish = (value) => { clearTimeout(timer); signal?.removeEventListener('abort', cancel); resolve(value) }
|
|
2423
|
+
const cancel = () => finish(false)
|
|
2424
|
+
const timer = setTimeout(() => finish(true), ms)
|
|
2425
|
+
signal?.addEventListener('abort', cancel, { once: true })
|
|
2426
|
+
})
|
|
2427
|
+
}
|
|
2428
|
+
|
|
2429
|
+
function watchErrors() {
|
|
2430
|
+
const errs = []
|
|
2431
|
+
if (typeof window !== 'undefined') {
|
|
2432
|
+
const onError = (e) => { if (errs.length < 20) errs.push(String(e.message)) }
|
|
2433
|
+
const onRejection = (e) => { if (errs.length < 20) errs.push('unhandledrejection: ' + String(e.reason && e.reason.message || e.reason)) }
|
|
2434
|
+
window.addEventListener('error', onError)
|
|
2435
|
+
window.addEventListener('unhandledrejection', onRejection)
|
|
2436
|
+
errs.dispose = () => { window.removeEventListener('error', onError); window.removeEventListener('unhandledrejection', onRejection) }
|
|
2437
|
+
}
|
|
2438
|
+
return errs
|
|
2439
|
+
}
|
|
2440
|
+
|
|
2441
|
+
/** Runs an opted-in local check; aborting the owning plugin stops later reads, navigation and reporting. */
|
|
2442
|
+
async function runSelfCheck(ctx, panelId, catalog, errs, version, probeHolder, choose, E, signal) {
|
|
2443
|
+
const active = () => !signal?.aborted
|
|
2444
|
+
if (!active()) return
|
|
2445
|
+
let cfg
|
|
2446
|
+
try {
|
|
2447
|
+
const r = await fetch('/vdc/config', { cache: 'no-store', signal })
|
|
2448
|
+
if (!active() || !r.ok) return
|
|
2449
|
+
cfg = await r.json()
|
|
2450
|
+
} catch { return }
|
|
2451
|
+
if (!active() || !cfg || cfg.selfcheck !== true) return
|
|
2452
|
+
|
|
2453
|
+
const report = { plugin: '@vibedev-si/dsh-ecosystem', version, checks: {} }
|
|
2454
|
+
const add = (k, v) => { report.checks[k] = v }
|
|
2455
|
+
const read = async (fn) => { if (!active()) return undefined; const value = await fn(); return active() ? value : undefined }
|
|
2456
|
+
const safe = async (k, fn) => {
|
|
2457
|
+
if (!active()) return false
|
|
2458
|
+
try { const value = await fn(); if (!active()) return false; add(k, value) }
|
|
2459
|
+
catch (e) { if (!active()) return false; add(k, { threw: String(e && e.message || e) }) }
|
|
2460
|
+
return true
|
|
2461
|
+
}
|
|
2462
|
+
|
|
2463
|
+
const pm = ctx.remote && ctx.remote.pluginManager
|
|
2464
|
+
add('pluginManager.present', !!pm)
|
|
2465
|
+
add('pluginManager.methods', pm ? ['listBundles', 'inspect', 'installBundle', 'setBundleEnabled', 'removeBundle', 'cancelInstall', 'waitForInstall'].map((m) => [m, typeof pm[m]]) : null)
|
|
2466
|
+
add('remote.$on', typeof (ctx.remote && ctx.remote.$on))
|
|
2467
|
+
add('layout.selectPanel', typeof (ctx.layout && ctx.layout.selectPanel))
|
|
2468
|
+
add('market.render', typeof (ctx.reflect && ctx.reflect.get && ctx.reflect.get('market') && ctx.reflect.get('market').render))
|
|
2469
|
+
if (!await safe('pluginNavigation.openTab', () => { const nav = ctx.reflect && ctx.reflect.get && ctx.reflect.get('pluginNavigation'); return typeof (nav && nav.openTab) })) return
|
|
2470
|
+
try { add('locale', ctx.locale.getLocale()) } catch (e) { add('locale', { threw: String(e) }) }
|
|
2471
|
+
|
|
2472
|
+
if (pm) {
|
|
2473
|
+
if (!await safe('registries()', async () => { const r = await pm.registries(); return r && r.ok ? r.value : { ok: false, error: r && r.error } })) return
|
|
2474
|
+
let fastest = null
|
|
2475
|
+
if (!await safe('registryProbe', async () => {
|
|
2476
|
+
const pr = probeHolder && probeHolder.probe
|
|
2477
|
+
if (!pr || typeof pr.fastest !== 'function') return { present: false, injected: !!(probeHolder && 'probe' in probeHolder) }
|
|
2478
|
+
const t0 = Date.now()
|
|
2479
|
+
const r = await pr.fastest()
|
|
2480
|
+
return { present: true, ms: Date.now() - t0, raw: r }
|
|
2481
|
+
})) return
|
|
2482
|
+
if (!await safe('chooseRegistry', async () => {
|
|
2483
|
+
const t0 = Date.now()
|
|
2484
|
+
const pr = probeHolder && probeHolder.probe
|
|
2485
|
+
// Guard nested reads as well: registry selection can await before asking the probe.
|
|
2486
|
+
fastest = await choose({ registries: () => read(() => pm.registries()) },
|
|
2487
|
+
pr && typeof pr.fastest === 'function' ? { fastest: () => read(() => pr.fastest()) } : undefined)
|
|
2488
|
+
return { chosen: fastest, ms: Date.now() - t0 }
|
|
2489
|
+
})) return
|
|
2490
|
+
if (!await safe('listBundles', async () => {
|
|
2491
|
+
const r = await pm.listBundles()
|
|
2492
|
+
if (!r || !r.ok) return { ok: false, error: r && r.error }
|
|
2493
|
+
const names = new Set(r.value.filter((b) => b.installed).map((b) => b.name))
|
|
2494
|
+
return {
|
|
2495
|
+
ok: true,
|
|
2496
|
+
count: r.value.length,
|
|
2497
|
+
fieldsOfFirst: Object.keys(r.value[0] || {}),
|
|
2498
|
+
catalogState: catalog.plugins.map((p) => [p.npm, names.has(p.npm) ? 'installed' : 'absent']),
|
|
2499
|
+
legacyPresent: catalog.plugins.flatMap((p) => p.legacyNames || []).filter((n) => names.has(n)),
|
|
2500
|
+
}
|
|
2501
|
+
})) return
|
|
2502
|
+
const timed = async (spec, registry) => {
|
|
2503
|
+
const t0 = Date.now()
|
|
2504
|
+
const r = await read(() => pm.inspect(spec, { registry }))
|
|
2505
|
+
return { ms: Date.now() - t0, ...(r && r.ok ? { ok: true, value: r.value } : { ok: false, error: r && r.error }) }
|
|
2506
|
+
}
|
|
2507
|
+
if (!await safe('inspect.notInstalled.defaultRegistry', () => timed('@vibedev-si/dsh-media-viewer@0.1.0', null))) return
|
|
2508
|
+
if (!await safe('inspect.notInstalled.probedRegistry', () => timed('@vibedev-si/dsh-media-viewer@0.1.0', fastest))) return
|
|
2509
|
+
if (!await safe('inspect.installedName', () => {
|
|
2510
|
+
const probe = catalog.plugins.find((p) => p.origin === 'community')
|
|
2511
|
+
return probe ? timed(probe.npm + '@' + probe.version, null) : 'skipped: no community entry in the catalog'
|
|
2512
|
+
})) return
|
|
2513
|
+
}
|
|
2514
|
+
|
|
2515
|
+
// Switching the visible panel flashes the user's screen, and the host hot-reloads linked installs on every file change,
|
|
2516
|
+
// so doing it by default made it fire at random (it did, to a real user). It is therefore a SECOND, separate opt-in:
|
|
2517
|
+
// <profile>/.vdc/enable-selfcheck-mount. Without it the check stays entirely invisible.
|
|
2518
|
+
if (cfg.mount !== true) {
|
|
2519
|
+
add('panel.mounted', 'skipped: the visible mount check is off (create .vdc/enable-selfcheck-mount to run it)')
|
|
2520
|
+
} else {
|
|
2521
|
+
// Prove the panel mounts inside the real shell.
|
|
2522
|
+
let previous
|
|
2523
|
+
try { previous = ctx.layout.panelInfo && ctx.layout.panelInfo.getSnapshot().activePanelId } catch { /* optional */ }
|
|
2524
|
+
add('previousPanel', previous === undefined ? null : previous)
|
|
2525
|
+
try {
|
|
2526
|
+
ctx.layout.selectPanel(panelId)
|
|
2527
|
+
let el = null
|
|
2528
|
+
for (let i = 0; i < 20 && !el; i++) {
|
|
2529
|
+
if (!await sleep(150, signal)) return
|
|
2530
|
+
el = document.querySelector('[data-testid=center]')
|
|
2531
|
+
}
|
|
2532
|
+
add('panel.mounted', !!el)
|
|
2533
|
+
if (el) {
|
|
2534
|
+
const box = el.getBoundingClientRect()
|
|
2535
|
+
const cs = getComputedStyle(el)
|
|
2536
|
+
const vars = ['--dsw-alias-bg-base', '--dsw-alias-bg-layer-1', '--dsw-alias-brand-primary', '--dsw-alias-label-primary', '--dsw-alias-border-l1']
|
|
2537
|
+
const read = (node) => vars.map((v) => [v, getComputedStyle(node).getPropertyValue(v).trim() || null])
|
|
2538
|
+
add('panel.size', [Math.round(box.width), Math.round(box.height)])
|
|
2539
|
+
add('panel.cards', el.querySelectorAll('.card').length)
|
|
2540
|
+
add('panel.text', el.innerText.slice(0, 120))
|
|
2541
|
+
// Read FROM THE PANEL (variables inherit), and from its ancestors, to learn where the shell defines them.
|
|
2542
|
+
add('theme.onPanel', read(el))
|
|
2543
|
+
add('theme.onBody', read(document.body))
|
|
2544
|
+
add('theme.onHtml', read(document.documentElement))
|
|
2545
|
+
add('theme.resolved', { '--bg': cs.getPropertyValue('--bg').trim(), '--brand': cs.getPropertyValue('--brand').trim(), '--on-brand': el.style.getPropertyValue('--on-brand'), panelBackground: cs.backgroundColor, panelColor: cs.color, bodyBackground: getComputedStyle(document.body).backgroundColor })
|
|
2546
|
+
// The number that matters in a dark theme: can the label on a primary button actually be read?
|
|
2547
|
+
const btn = el.querySelector('.btn.primary')
|
|
2548
|
+
if (btn) { const bs = getComputedStyle(btn); add('theme.primaryButton', { color: bs.color, background: bs.backgroundColor, contrast: E && E.contrastRatio ? E.contrastRatio(bs.color, bs.backgroundColor) : null }) }
|
|
2549
|
+
const label = (() => { try { return Array.from(document.querySelectorAll('aside *, nav *')).filter((n) => n.children.length === 0 && /VibeDev/.test(n.textContent || '')).map((n) => n.textContent.trim()).slice(0, 6) } catch { return null } })()
|
|
2550
|
+
add('sidebar.labelsMentioningVibeDev', label)
|
|
2551
|
+
add('theme.hooks', {
|
|
2552
|
+
htmlClass: document.documentElement.className, htmlData: Object.assign({}, document.documentElement.dataset),
|
|
2553
|
+
bodyClass: document.body.className, bodyData: Object.assign({}, document.body.dataset),
|
|
2554
|
+
prefersDark: typeof matchMedia === 'function' ? matchMedia('(prefers-color-scheme: dark)').matches : null,
|
|
2555
|
+
})
|
|
2556
|
+
try { add('theme.snapshot', JSON.stringify(ctx.theme.getTheme()).slice(0, 600)) } catch (e) { add('theme.snapshot', 'unavailable: ' + String(e && e.message || e)) }
|
|
2557
|
+
add('panel.scrollable', (() => { const s = el.querySelector('.scroll'); return s ? s.scrollHeight > s.clientHeight || s.clientHeight > 0 : null })())
|
|
2558
|
+
}
|
|
2559
|
+
} catch (e) { if (!active()) return; add('panel.error', String(e && e.message || e)) }
|
|
2560
|
+
if (!active()) return
|
|
2561
|
+
try { ctx.layout.selectPanel(previous === undefined ? null : previous) } catch { /* best effort */ }
|
|
2562
|
+
}
|
|
2563
|
+
|
|
2564
|
+
if (!active()) return
|
|
2565
|
+
add('errors', errs.slice())
|
|
2566
|
+
try {
|
|
2567
|
+
await fetch('/vdc/selfcheck', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(report), signal })
|
|
2568
|
+
} catch { /* nothing to do */ }
|
|
2569
|
+
}
|
|
2570
|
+
|
|
2571
|
+
/** A stable, credential-free view of the optional account center Client service. */
|
|
2572
|
+
function createCenterConnection() {
|
|
2573
|
+
const listeners = new Set()
|
|
2574
|
+
let service = null
|
|
2575
|
+
let stopAccount = null
|
|
2576
|
+
let snapshot = Object.freeze({ available: false, signedIn: false })
|
|
2577
|
+
const publish = () => {
|
|
2578
|
+
const available = service !== null
|
|
2579
|
+
const signedIn = available && service.account.getSnapshot().signedIn === true
|
|
2580
|
+
if (snapshot.available === available && snapshot.signedIn === signedIn) return
|
|
2581
|
+
snapshot = Object.freeze({ available, signedIn })
|
|
2582
|
+
for (const listener of [...listeners]) listener()
|
|
2583
|
+
}
|
|
2584
|
+
const disconnect = () => {
|
|
2585
|
+
stopAccount?.()
|
|
2586
|
+
stopAccount = null
|
|
2587
|
+
service = null
|
|
2588
|
+
publish()
|
|
2589
|
+
}
|
|
2590
|
+
return {
|
|
2591
|
+
getSnapshot: () => snapshot,
|
|
2592
|
+
subscribe(listener) { listeners.add(listener); return () => listeners.delete(listener) },
|
|
2593
|
+
attach(next) {
|
|
2594
|
+
disconnect()
|
|
2595
|
+
service = next
|
|
2596
|
+
stopAccount = next.account.subscribe(publish)
|
|
2597
|
+
publish()
|
|
2598
|
+
return () => { if (service === next) disconnect() }
|
|
2599
|
+
},
|
|
2600
|
+
open(view = 'all') {
|
|
2601
|
+
if (!service) return false
|
|
2602
|
+
service.open({ section: 'plugins', view })
|
|
2603
|
+
return true
|
|
2604
|
+
},
|
|
2605
|
+
signIn() { return service ? service.signIn() : Promise.resolve(false) },
|
|
2606
|
+
dispose() { disconnect(); listeners.clear() },
|
|
2607
|
+
}
|
|
2608
|
+
}
|
|
2609
|
+
|
|
2610
|
+
|
|
2611
|
+
var CATALOG = {"schema":1,"updated":"2026-10-19","suites":[{"id":"creator","name":{"zh":"AI 创作套装","en":"AI Creator Suite"},"tagline":{"zh":"写剧本 → 排分镜 → 生成素材 → 预览成片素材,一套装齐","en":"Script → storyboard → generate assets → preview them, installed in one go"},"items":["@vibedev-si/dsh-vibedev","dsh-film","@vibedev-si/dsh-media-viewer"]}],"plugins":[{"id":"@vibedev-si/dsh-vibedev","npm":"@vibedev-si/dsh-vibedev","version":"0.3.3","publishedAt":"2026-10-12T17:41:34.308Z","origin":"official","role":"official","updates":"center","name":{"zh":"VibeDev 账号与模型","en":"VibeDev Account & Models"},"tagline":{"zh":"登录 VibeDev 账号,和 DeepSeek 账号并存:用网关的 Claude、GPT 等模型,并让 Agent 生成图片、视频、音乐、播客和语音","en":"Sign in to VibeDev next to your DeepSeek account: use the gateway's Claude, GPT and other models, and let the agent generate images, video, music, podcasts and speech"},"does":{"zh":["在侧边栏底部或「设置 → VibeDev 账号」登录,查看余额、充值;和 DeepSeek 账号互不影响","余额实时更新:对话、生成、转写扣费后几秒内就能看到","登录后模型选择器里多出「VibeDev」一组(Claude、GPT 等),未登录时不显示","生成图片;带参考图时可改图、换风格","生成视频(后台运行,一般 1–10 分钟)","生成音乐(可自带歌词)、播客和语音(可用参考音色);音频模型按网关声明的能力识别;把语音转成文字","原名 dsh-media:已安装的会在这里一键切换,登录和进行中的任务都保留"],"en":["Sign in at the bottom of the sidebar or in Settings → VibeDev account, see the balance and top up; the DeepSeek account is not affected","Live balance: a charge from a chat, a generation or a transcription shows within seconds","Once signed in, the model picker gains a \"VibeDev\" group (Claude, GPT and more); nothing is listed while signed out","Generate images; edit or restyle with reference images","Generate video (runs in the background, usually 1-10 minutes)","Generate music (with your own lyrics), podcasts and speech (with reference voices); audio models are recognized from what the gateway declares; transcribe speech","Formerly dsh-media: an installed copy is switched over here in one click, keeping the sign-in and running tasks"]},"tags":["official","needsAccount","paid"],"requires":[],"partners":["dsh-film","@vibedev-si/dsh-media-viewer"],"legacyNames":["dsh-media"],"sizeKB":1664,"capabilities":[{"key":"network","text":{"zh":"发给 VibeDev 模型的对话、提示词和参考素材会发送到 VibeDev 网关,再转交模型服务商","en":"Conversations with VibeDev models, prompts and reference media are sent to the VibeDev gateway, which forwards them to the model provider"}},{"key":"credentials","text":{"zh":"在系统浏览器里登录 VibeDev,插件拿不到密码;登录凭据存在 DeepSeek Harness 的凭据存储里。在 VibeDev 应用里直接用已登录的账号","en":"You sign in to VibeDev in your system browser and the plugin never sees the password; the sign-in is kept in DeepSeek Harness's credential store. Inside the VibeDev app the app's account is used"}},{"key":"writeFiles","text":{"zh":"生成结果保存在工作区的 media/ 目录","en":"Results are saved under media/ in the workspace"}},{"key":"agentTools","text":{"zh":"为 Agent 增加 7 个媒体工具和简短说明","en":"Adds 7 media tools and a short guide for the agent"}},{"key":"cost","text":{"zh":"VibeDev 模型按用量计费;图片按张、视频按实际计费单位、音乐和播客按次、语音按原始秒、转写按分钟计费,没有价格的显示「未定价」;实际费用、预留和退款以网关回执为准,停止等待不代表已取消任务","en":"VibeDev models are billed by usage; images per image, video by its declared billing unit, music and podcasts per request, speech per second of original audio, transcription per minute, \"not priced\" when no price is stated. Charges, reservations and refunds follow the gateway receipt; stopping the wait does not cancel a task"}}],"links":{"repo":"https://github.com/VibeDev-Si/dsh-vibedev","npm":"https://www.npmjs.com/package/@vibedev-si/dsh-vibedev"},"cmd":"dsh plugin add @vibedev-si/dsh-vibedev","icon":{"glyph":{"zh":"账","en":"VD"},"grad":["#ff8a5b","#ff4f7a"]},"reviewed":null,"compat":null},{"id":"dsh-film","npm":"dsh-film","version":"0.5.3","publishedAt":"2026-10-11T12:15:34.253Z","origin":"official","role":"official","updates":"center","name":{"zh":"VibeDev 影视工作台","en":"VibeDev Film"},"tagline":{"zh":"在右侧栏打开画布式影视工作台:小说拆解、剧本、分镜画布、图片/视频/音频生成、剪辑成片","en":"A canvas film workbench in the right sidebar: novel breakdown, script, storyboard canvas, image / video / audio generation and editing"},"does":{"zh":["画布式工作台:小说拆解、剧本、分镜、导演台、剪辑成片,在会话右侧栏打开","图片、视频、音频生成节点都走 VibeDev 账号;发送键旁显示预计费用","音频节点支持音乐、播客和语音,只显示所选模型支持的参数;刷新页面不会重复生成","Agent 可以用影视工具搭建画布、调用节点,另带影视技能","从旧版影视工作台升级:配置条目不变,旧项目文件保留","只支持 Windows x64(Bun 运行时随插件安装,不用另装)"],"en":["Canvas workbench: novel breakdown, script, storyboard, director desk and editing, opened in the session's right sidebar","Image, video and audio generation nodes all go through the VibeDev account, with the expected cost beside the send button","The audio node does music, podcasts and speech, showing only the options the chosen model supports; a reload never generates twice","The agent can build the canvas and drive nodes with film tools, plus film skills","Upgrading from the earlier film workbench keeps the profile entry and the old project files","Windows x64 only (the Bun runtime is installed with it; nothing else to install)"]},"tags":["official","needsHost02"],"requires":["@vibedev-si/dsh-vibedev"],"partners":["@vibedev-si/dsh-vibedev","@vibedev-si/dsh-media-viewer"],"legacyNames":["dsh-film-studio"],"sizeKB":47030,"capabilities":[{"key":"writeFiles","text":{"zh":"项目保存在工作区的「VibeDev Film」文件夹,生成结果在项目的 assets/ 下;升级和卸载插件不会改动它们","en":"Projects are kept in the workspace's \"VibeDev Film\" folder and results under the project's assets/; upgrading or removing the plugin does not touch them"}},{"key":"localRoute","text":{"zh":"在本机回环地址上运行工作台服务,只接受本插件签发的会话","en":"Runs the workbench server on a loopback address, accepting only sessions this plugin issues"}},{"key":"agentTools","text":{"zh":"为 Agent 增加影视工具(打开工作台、列出与调用画布操作)和影视技能","en":"Adds film tools (open the workbench, list and call canvas operations) and film skills for the agent"}},{"key":"cost","text":{"zh":"生成节点发送前显示预计费用;实际计费来源、扣费和退款以网关回执为准","en":"Generation nodes show estimated cost before submission; actual billing sources, charges and refunds follow the gateway receipt"}}],"links":{"repo":"https://github.com/VibeDev-Si/dsh-film","npm":"https://www.npmjs.com/package/dsh-film"},"cmd":"dsh plugin add dsh-film","icon":{"glyph":{"zh":"影","en":"F"},"grad":["#6f7bff","#a24dff"]},"reviewed":null,"compat":{"s":"likely","why":{"zh":"只支持 Windows x64;音频生成需要 VibeDev 账号与模型 0.3.1 及以上","en":"Windows x64 only; audio generation needs VibeDev Account & Models 0.3.1 or later"}}},{"id":"@vibedev-si/dsh-media-viewer","npm":"@vibedev-si/dsh-media-viewer","version":"0.2.0","publishedAt":"2026-10-10T16:48:05.236Z","origin":"official","role":"official","updates":"center","name":{"zh":"媒体预览与画廊","en":"Media Viewer"},"tagline":{"zh":"在右侧栏直接预览视频、音频和 HTML,按文件夹浏览媒体画廊,多选加入影视画布","en":"Preview video, audio and HTML right in the sidebar, browse a folder as a media gallery, and add picks to the film canvas"},"does":{"zh":["视频:可拖进度条、倍速、循环,不限文件大小","音频:实时频谱、倍速、循环","HTML:默认允许脚本,在隔离沙箱里运行;可看源码、切换手机/平板/桌面宽度","媒体画廊:缩略图、按类型筛选、搜索、灯箱浏览;多选后加入影视工作台画布","直接用 DSH 自带的右侧栏,不需要其他插件"],"en":["Video: seekable, speed control, loop, no file-size cap","Audio: live spectrum, speed control, loop","HTML: scripts allowed by default, inside an isolated sandbox; view source, switch phone/tablet/desktop width","Media gallery: thumbnails, type filters, search, lightbox; multi-select and add to the Film Studio canvas","Uses DSH's own right sidebar; no other plugin needed"]},"tags":["official"],"requires":[],"partners":["dsh-film","@vibedev-si/dsh-vibedev"],"legacyNames":["dsh-media-viewer"],"sizeKB":86,"capabilities":[{"key":"readFiles","text":{"zh":"只读取当前会话工作目录内的文件","en":"Reads only files inside the current session's working directory"}},{"key":"localRoute","text":{"zh":"在本机服务上增加 /mp 路由,仅回环地址可访问","en":"Adds /mp routes to the local server, reachable from loopback only"}},{"key":"pageScripts","text":{"zh":"HTML 预览默认允许脚本,运行在无法访问界面的隔离沙箱中","en":"HTML preview allows scripts by default, inside a sandbox that cannot reach the UI"}}],"links":{"repo":"https://github.com/VibeDev-Si/dsh-media-viewer","npm":"https://www.npmjs.com/package/@vibedev-si/dsh-media-viewer"},"cmd":"dsh plugin add @vibedev-si/dsh-media-viewer","icon":{"glyph":{"zh":"览","en":"V"},"grad":["#27c3d6","#3b82f6"]},"reviewed":null,"compat":null}]};
|
|
2612
|
+
var VERSION = "0.2.0";
|
|
2613
|
+
|
|
2614
|
+
var PANEL_ID = "vibedev-center";
|
|
2615
|
+
var inject = ["slots", "locale", "remote", "remote.pluginManager", "layout"];
|
|
2616
|
+
var primitives; try { primitives = require("@deepseek-ai/dsh-client-ui-primitives"); } catch (e) { primitives = null; }
|
|
2617
|
+
|
|
2618
|
+
function PanelIcon(size) {
|
|
2619
|
+
var h = React.createElement;
|
|
2620
|
+
return h("svg", { width: size, height: size, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 1.8, strokeLinecap: "round", strokeLinejoin: "round" },
|
|
2621
|
+
h("path", { d: "M10 3H5a2 2 0 0 0-2 2v5a2 2 0 0 0 2 2h1a2 2 0 1 1 0 4H5a2 2 0 0 0-2 2v1a2 2 0 0 0 2 2h5v-2a2 2 0 1 1 4 0v2h5a2 2 0 0 0 2-2v-5h-2a2 2 0 1 1 0-4h2V5a2 2 0 0 0-2-2h-5v1a2 2 0 1 1-4 0z" }));
|
|
2622
|
+
}
|
|
2623
|
+
|
|
2624
|
+
/**
|
|
2625
|
+
* The sidebar entry: the panel icon, with a dot while updates are available (the Updates tab's number,
|
|
2626
|
+
* in the tooltip). It follows the count the center keeps, so it changes without the page being open.
|
|
2627
|
+
*/
|
|
2628
|
+
function createPanelEntry(Center, locale) {
|
|
2629
|
+
return function PanelEntry(p) {
|
|
2630
|
+
var h = React.createElement;
|
|
2631
|
+
var size = (p && p.size) || 18;
|
|
2632
|
+
var count = React.useSyncExternalStore(Center.updates.subscribe, Center.updates.count, Center.updates.count);
|
|
2633
|
+
var icon = PanelIcon(size);
|
|
2634
|
+
if (!count) return icon;
|
|
2635
|
+
var title = STR[pick(locale())].badgeTitle(count);
|
|
2636
|
+
return h("span", { "data-vdc-update-badge": String(count), title: title, style: { position: "relative", display: "inline-flex" } }, icon,
|
|
2637
|
+
h("span", { "aria-hidden": "true", style: { position: "absolute", top: -2, right: -3, width: 8, height: 8, borderRadius: 4,
|
|
2638
|
+
background: "var(--dsw-alias-state-error-primary, #e5484d)", boxShadow: "0 0 0 1.5px var(--dsw-alias-bg-base, #fff)" } }));
|
|
2639
|
+
};
|
|
2640
|
+
}
|
|
2641
|
+
|
|
2642
|
+
function currentLocale(ctx) {
|
|
2643
|
+
try { var l = ctx.locale.getLocale(); return (l && (l.active || l.id)) || "zh"; } catch (e) { return "zh"; } }
|
|
2644
|
+
|
|
2645
|
+
// Set by the host half (index.js) only when the app ships this center built in and says so in the row config.
|
|
2646
|
+
function readOfficial() { try { var g = globalThis.__VDC_OFFICIAL__; return !!(g && g.official === true); } catch (e) { return false; } }
|
|
2647
|
+
|
|
2648
|
+
/**
|
|
2649
|
+
* The Official-group card. `summary`: the card's one line. `page`: opening the card opens the center (the Plugins page
|
|
2650
|
+
* returns to its list once another panel is shown), with a button in case the switch did not happen.
|
|
2651
|
+
*/
|
|
2652
|
+
function OfficialCard(p, ctx, open) {
|
|
2653
|
+
var h = React.createElement;
|
|
2654
|
+
var S = STR[pick(currentLocale(ctx))];
|
|
2655
|
+
if (!p || p.view !== "page") return S.officialSummary;
|
|
2656
|
+
return h(OfficialPage, { open: open, S: S });
|
|
2657
|
+
}
|
|
2658
|
+
function OfficialPage(props) {
|
|
2659
|
+
var h = React.createElement;
|
|
2660
|
+
React.useEffect(function () { props.open(); }, []);
|
|
2661
|
+
return h("div", { "data-vdc-official": "", style: { display: "flex", flexDirection: "column", gap: 12, alignItems: "flex-start" } },
|
|
2662
|
+
h("p", { style: { margin: 0 } }, props.S.officialPage),
|
|
2663
|
+
h("button", { type: "button", className: "dsw-button", onClick: props.open }, props.S.officialOpen));
|
|
2664
|
+
}
|
|
2665
|
+
|
|
2666
|
+
function apply(ctx) {
|
|
2667
|
+
var OFFICIAL = readOfficial();
|
|
2668
|
+
var connection = createCenterConnection();
|
|
2669
|
+
var lifetime = new AbortController();
|
|
2670
|
+
var LOAD_ERRORS = watchErrors();
|
|
2671
|
+
var stopped = false;
|
|
2672
|
+
var sidebarStop = null;
|
|
2673
|
+
function openCenter(view) {
|
|
2674
|
+
if (connection.open(view || 'all')) return;
|
|
2675
|
+
ctx.layout.selectPanel(PANEL_ID);
|
|
2676
|
+
}
|
|
2677
|
+
// The registry probe is optional: the center works without it, so a missing service must not stop the plugin loading.
|
|
2678
|
+
// (Reading it without declaring it throws "cannot get property ... without inject", seen in a live self-check.)
|
|
2679
|
+
var probeHolder = { probe: undefined };
|
|
2680
|
+
try { ctx.inject(["remote.pluginRegistryProbe"], function (scoped) { try { probeHolder.probe = scoped.remote.pluginRegistryProbe; } catch (e) {} }); } catch (e) {}
|
|
2681
|
+
|
|
2682
|
+
var Center = createCenter(React, CATALOG, {
|
|
2683
|
+
center: connection,
|
|
2684
|
+
openCenter: openCenter,
|
|
2685
|
+
openLegacyAccount: function () {
|
|
2686
|
+
var entries = ctx.slots.entries('main');
|
|
2687
|
+
if (!entries.some(function (entry) { return entry.options.key === 'vibedev-account-center'; })) return false;
|
|
2688
|
+
ctx.layout.selectPanel('vibedev-account-center');
|
|
2689
|
+
return true;
|
|
2690
|
+
},
|
|
2691
|
+
get pm() { try { return ctx.remote.pluginManager; } catch (e) { return undefined; } },
|
|
2692
|
+
// The real getLocale() returns { active: "zh", locales: [...], revision } (read from a live self-check), not { id }.
|
|
2693
|
+
locale: function () { return currentLocale(ctx); },
|
|
2694
|
+
onLocale: function (fn) { try { return ctx.locale.subscribe(fn); } catch (e) { return function () {}; } },
|
|
2695
|
+
// Same rule as the official Plugins page: only consider the China mirror when pnpm defaults to the official registry.
|
|
2696
|
+
chooseRegistry: function () { return E.chooseRegistry(ctx.remote.pluginManager, probeHolder.probe); },
|
|
2697
|
+
onChanged: function (fn) { try { return ctx.remote.$on("plugin-manager/changed", fn); } catch (e) { return function () {}; } },
|
|
2698
|
+
openUrl: function (u) { window.open(u, "_blank", "noopener"); },
|
|
2699
|
+
copy: function (t) { try { navigator.clipboard && navigator.clipboard.writeText(t); } catch (e) {} },
|
|
2700
|
+
// Test hook only: the real host never sets ctx.__vdcSettle, so production always uses the built-in timings.
|
|
2701
|
+
settle: function () { return ctx.__vdcSettle || null; },
|
|
2702
|
+
// The version of THIS center, shown in the header and compared with npm's latest when the user clicks "check for updates".
|
|
2703
|
+
version: function () { return VERSION; },
|
|
2704
|
+
// Built into the app: a newer center arrives with the app, so it is not reinstalled from the Plugins page.
|
|
2705
|
+
official: function () { return OFFICIAL; },
|
|
2706
|
+
// One user-initiated read of npm's latest version, made by the host half (index.js /vdc/latest). Resolves to undefined on any failure.
|
|
2707
|
+
checkLatest: function () {
|
|
2708
|
+
var ctl = typeof AbortController === "function" ? new AbortController() : null;
|
|
2709
|
+
var abort = function () { if (ctl) ctl.abort(); };
|
|
2710
|
+
lifetime.signal.addEventListener('abort', abort, { once: true });
|
|
2711
|
+
var timer = ctl ? setTimeout(abort, 20000) : null;
|
|
2712
|
+
return fetch("/vdc/latest", { cache: "no-store", signal: ctl ? ctl.signal : lifetime.signal })
|
|
2713
|
+
.then(function (r) { return r.ok ? r.json() : undefined; })
|
|
2714
|
+
.catch(function () { return undefined; })
|
|
2715
|
+
.finally(function () { if (timer) clearTimeout(timer); lifetime.signal.removeEventListener('abort', abort); });
|
|
2716
|
+
},
|
|
2717
|
+
// The last verified catalog, kept so the next opening shows it at once (ui.js "what the page showed last").
|
|
2718
|
+
memory: {
|
|
2719
|
+
read: function (key) { try { return window.localStorage.getItem(key); } catch (e) { return null; } },
|
|
2720
|
+
write: function (key, value) { try { window.localStorage.setItem(key, value); } catch (e) {} },
|
|
2721
|
+
},
|
|
2722
|
+
// Read the four fixed VibeDev releases when this panel opens or the user checks again. The host caches successes.
|
|
2723
|
+
checkUpdates: function (signal) {
|
|
2724
|
+
var ctl = new AbortController();
|
|
2725
|
+
var abort = function () { ctl.abort(); };
|
|
2726
|
+
if (signal && signal.aborted || lifetime.signal.aborted) return Promise.resolve(undefined);
|
|
2727
|
+
if (signal) signal.addEventListener('abort', abort, { once: true });
|
|
2728
|
+
lifetime.signal.addEventListener('abort', abort, { once: true });
|
|
2729
|
+
var timer = setTimeout(abort, 35000);
|
|
2730
|
+
return fetch('/vdc/updates', { cache: 'no-store', signal: ctl.signal })
|
|
2731
|
+
.then(function (r) { return r.ok ? r.json() : undefined; })
|
|
2732
|
+
.catch(function () { return undefined; })
|
|
2733
|
+
.finally(function () { clearTimeout(timer); if (signal) signal.removeEventListener('abort', abort); lifetime.signal.removeEventListener('abort', abort); });
|
|
2734
|
+
},
|
|
2735
|
+
renderMarket: function () { try { var m = ctx.reflect && ctx.reflect.get && ctx.reflect.get("market"); return m && m.render ? m.render() : null; } catch (e) { return null; } },
|
|
2736
|
+
// The Plugins page's own tabs, on apps whose pluginNavigation can open one (VibeDev desktop with "Discover"):
|
|
2737
|
+
// { open(tab) -> false when the app could not }; null on apps without openTab. Read when used, never cached.
|
|
2738
|
+
pluginsTabs: function () {
|
|
2739
|
+
if (!pluginsTabOpener()) return null;
|
|
2740
|
+
return { open: function (tab) { var openTab = pluginsTabOpener(); if (!openTab) return false; try { openTab(tab); return true; } catch (e) { return false; } } };
|
|
2741
|
+
}
|
|
2742
|
+
});
|
|
2743
|
+
|
|
2744
|
+
function pluginsTabOpener() {
|
|
2745
|
+
try {
|
|
2746
|
+
var nav = ctx.reflect && ctx.reflect.get && ctx.reflect.get("pluginNavigation");
|
|
2747
|
+
return nav && typeof nav.openTab === "function" ? function (tab) { nav.openTab(tab); } : null;
|
|
2748
|
+
} catch (e) { return null; }
|
|
2749
|
+
}
|
|
2750
|
+
var PanelEntry = createPanelEntry(Center, function () { return currentLocale(ctx); });
|
|
2751
|
+
function ForwardPanel() {
|
|
2752
|
+
React.useEffect(function () { openCenter('all'); }, []);
|
|
2753
|
+
return null;
|
|
2754
|
+
}
|
|
2755
|
+
function Panel() {
|
|
2756
|
+
var state = React.useSyncExternalStore(connection.subscribe, connection.getSnapshot, connection.getSnapshot);
|
|
2757
|
+
return React.createElement(state.available ? ForwardPanel : Center);
|
|
2758
|
+
}
|
|
2759
|
+
function EmbeddedPanel(props) { return React.createElement(Center, Object.assign({}, props, { embedded: true })); }
|
|
2760
|
+
|
|
2761
|
+
ctx.effect(function () { return ctx.locale.register("vibedevCenter", { zh: {}, en: {} }); }, "vibedev-center: dictionaries");
|
|
2762
|
+
ctx.slots.inject("main", function* () {
|
|
2763
|
+
yield ctx.slots.register({ name: "main", key: PANEL_ID, locale: "vibedevCenter", inject: function () { return {}; } }, Panel);
|
|
2764
|
+
});
|
|
2765
|
+
function showStandalone() {
|
|
2766
|
+
if (stopped || sidebarStop) return;
|
|
2767
|
+
sidebarStop = ctx.slots.inject("sidebar.panellist", function () {
|
|
2768
|
+
return ctx.slots.register({
|
|
2769
|
+
name: "sidebar.panellist", id: PANEL_ID, order: 5,
|
|
2770
|
+
label: function () { return STR[pick(currentLocale(ctx))].title; }, locale: "vibedevCenter"
|
|
2771
|
+
}, PanelEntry);
|
|
2772
|
+
});
|
|
2773
|
+
}
|
|
2774
|
+
function hideStandalone() { if (sidebarStop) { sidebarStop(); sidebarStop = null; } }
|
|
2775
|
+
showStandalone();
|
|
2776
|
+
ctx.inject(['vibedevCenter'], function (scoped) {
|
|
2777
|
+
scoped.effect(function () {
|
|
2778
|
+
var detach = connection.attach(scoped.vibedevCenter);
|
|
2779
|
+
hideStandalone();
|
|
2780
|
+
return function () { detach(); showStandalone(); };
|
|
2781
|
+
}, 'vibedev-center: optional account center');
|
|
2782
|
+
scoped.slots.inject('vibedev.center.section', function* () {
|
|
2783
|
+
yield scoped.slots.register({ name: 'vibedev.center.section', id: 'plugins', locale: 'vibedevCenter', inject: function () { return {}; } }, EmbeddedPanel);
|
|
2784
|
+
yield scoped.vibedevCenter.registerSection({
|
|
2785
|
+
id: 'plugins', label: function () { return STR[pick(currentLocale(ctx))].sectionPlugins; }, order: 10,
|
|
2786
|
+
updates: { getSnapshot: Center.updates.count, subscribe: Center.updates.subscribe }
|
|
2787
|
+
});
|
|
2788
|
+
});
|
|
2789
|
+
});
|
|
2790
|
+
var startupTimer = setTimeout(function () { Center.startup(); }, 1500);
|
|
2791
|
+
// Built into the app (VibeDev Next): one card in the Plugins page's Official group. Its page opens the center itself.
|
|
2792
|
+
// A user's own install never sets the global, so DeepSeek Harness keeps the plain sidebar entry and nothing else.
|
|
2793
|
+
if (OFFICIAL) {
|
|
2794
|
+
ctx.slots.inject("plugins.item", function () {
|
|
2795
|
+
return ctx.slots.register({
|
|
2796
|
+
name: "plugins.item", id: "vibedev-ecosystem", order: 5,
|
|
2797
|
+
label: function () { return STR[pick(currentLocale(ctx))].title; }, locale: "vibedevCenter",
|
|
2798
|
+
inject: function () { return {}; }
|
|
2799
|
+
}, function (p) { return OfficialCard(p, ctx, function () { openCenter('all'); }); });
|
|
2800
|
+
});
|
|
2801
|
+
}
|
|
2802
|
+
var checkTimer = setTimeout(function () { runSelfCheck(ctx, PANEL_ID, CATALOG, LOAD_ERRORS, VERSION, probeHolder, E.chooseRegistry, E, lifetime.signal).catch(function () {}); }, 2500);
|
|
2803
|
+
ctx.effect(function () { return function () {
|
|
2804
|
+
stopped = true;
|
|
2805
|
+
clearTimeout(startupTimer); clearTimeout(checkTimer);
|
|
2806
|
+
lifetime.abort(); hideStandalone();
|
|
2807
|
+
Center.dispose(); connection.dispose();
|
|
2808
|
+
if (LOAD_ERRORS.dispose) LOAD_ERRORS.dispose();
|
|
2809
|
+
}; }, 'vibedev-center: resources');
|
|
2810
|
+
}
|
|
2811
|
+
|
|
2812
|
+
module.exports = { inject: inject, apply: apply, name: "@vibedev-si/dsh-ecosystem" };
|
|
2813
|
+
|
|
2814
|
+
return module.exports;
|
|
2815
|
+
}
|
|
2816
|
+
});
|