@moonsand/dsh-ui-optimize 0.11.1 → 0.11.8
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 +4 -2
- package/README.zh.md +4 -2
- package/client.js +187 -55
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -41,9 +41,11 @@ The launcher follows the pattern of the community plugin [dsh-sidebar-shelf](htt
|
|
|
41
41
|
|
|
42
42
|
The plugin page gets an **Updates** tab. It reads what is installed from the host's own plugin manager and each package's newest release and publish time from the npm registry — no marketplace plugin involved — then updates the whole eligible set with one click through that same host service.
|
|
43
43
|
|
|
44
|
-
Only releases **published at least 24 hours ago** are installed. Anything younger is listed and skipped: a release published hours ago can still be withdrawn or patched
|
|
44
|
+
Only releases **published at least 24 hours ago** are installed. Anything younger is listed with the time left and skipped: a release published hours ago can still be withdrawn or patched. A release whose publish time cannot be read is skipped too — the rule cannot be confirmed, so it is not claimed. Releases the host marks **incompatible with the running DSH version** (its `engines.dsh` or a DSH peer package is not satisfied) get their own section, state the version they need, and are never picked by *Update all* — so right after a DSH upgrade the tab tells you what is waiting on the plugins instead of failing mid-update.
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
Updates run through the host plugin manager, i.e. the same path the plugin page uses when you update one entry by hand; progress and failure codes come back from it. Reload the page afterwards: the new client half only loads on a fresh page.
|
|
47
|
+
|
|
48
|
+
If the host's plugin manager is unavailable, the tab says so instead of pretending to check.
|
|
47
49
|
|
|
48
50
|
## Known limitations
|
|
49
51
|
|
package/README.zh.md
CHANGED
|
@@ -56,9 +56,11 @@ dsh plugin 或 GUI 插件管理:安装 @moonsand/dsh-ui-optimize
|
|
|
56
56
|
|
|
57
57
|
插件页多一个「更新」页签。已装清单取自宿主自带的插件管理服务,最新版与发布时间直接从 npm registry 读——不依赖任何插件市场——再通过同一个宿主服务一键更新整批够格的版本。
|
|
58
58
|
|
|
59
|
-
只装**发布满 24
|
|
59
|
+
只装**发布满 24 小时**的版本;更年轻的会列出剩余时间并跳过——刚发几小时的版本还可能被撤回或补丁。读不到发布时间的同样跳过:规则无法确认,就不假装确认过。宿主判定**与当前 DSH 版本不兼容**的版本(`engines.dsh` 或某个 DSH peer 包不满足)单列一区,写明它要求的版本,并且永远不被「一键更新」带上——刚升级完 DSH 时,页签告诉你是哪些插件还没跟上,而不是等你点下去才失败。
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
更新走宿主插件管理服务,和你手点单个插件的更新是同一条路径;进度与失败码由它回报。更新完刷新页面:新的客户端代码只在重新加载时生效。
|
|
62
|
+
|
|
63
|
+
宿主的插件管理服务拿不到时,页签直接说明查不了,不会假装在检查。
|
|
62
64
|
|
|
63
65
|
## 已知限制
|
|
64
66
|
|
package/client.js
CHANGED
|
@@ -111,6 +111,8 @@ window.__ModuleLoader__.load({
|
|
|
111
111
|
'updates.notesNoZhVersion': 'No Chinese notes for this version.',
|
|
112
112
|
'updates.notesSpan': 'Changes since {from}',
|
|
113
113
|
'updates.updateAll': 'Update all',
|
|
114
|
+
'updates.needRestartHint': '{n} of them only take effect after DSH restarts — the new code is on disk, the running process still has the old one. Restarting also reloads the page, so one restart covers both. Restart when convenient.',
|
|
115
|
+
'updates.needRefreshHint': 'Done. Reload the page to load the new client code.',
|
|
114
116
|
'updates.updating': 'Updating…',
|
|
115
117
|
'updates.none': 'Nothing to update.',
|
|
116
118
|
'updates.upToDate': '{n} already up to date',
|
|
@@ -119,9 +121,9 @@ window.__ModuleLoader__.load({
|
|
|
119
121
|
'updates.idle': 'Not checked yet.',
|
|
120
122
|
'updates.unsupported': 'This host exposes no plugin manager, so updates cannot be checked here. Installed plugins still work.',
|
|
121
123
|
'updates.registryDown': 'The npm registry did not answer, so the release dates are unknown. Public plugins stay listed as unchecked.',
|
|
122
|
-
'updates.pmTimeout': 'The host plugin manager
|
|
123
|
-
'updates.pmWaiting': 'Waiting for the host plugin manager…
|
|
124
|
-
'updates.pmStalled': '
|
|
124
|
+
'updates.pmTimeout': 'The host plugin manager is still busy after {ms}s. Try again in a moment.',
|
|
125
|
+
'updates.pmWaiting': 'Waiting for the host plugin manager…',
|
|
126
|
+
'updates.pmStalled': 'The host plugin manager did not answer. Try again in a moment.',
|
|
125
127
|
'updates.loadFailed': 'The check failed',
|
|
126
128
|
'updates.waiting': 'Published under a day ago — skipped until it is 24 hours old',
|
|
127
129
|
'updates.unknownAge': 'Publish time could not be read — skipped, since the 24-hour rule cannot be confirmed',
|
|
@@ -216,6 +218,8 @@ window.__ModuleLoader__.load({
|
|
|
216
218
|
'updates.notesNoZhVersion': '该版本没有中文说明。',
|
|
217
219
|
'updates.notesSpan': '自 {from} 以来的改动',
|
|
218
220
|
'updates.updateAll': '一键更新',
|
|
221
|
+
'updates.needRestartHint': '{n} 个插件要重启 DSH 才真正生效——新代码已经在磁盘上,跑着的进程还是旧的。重启会连页面一起刷新,所以重启一次就都齐了,不急着马上重。',
|
|
222
|
+
'updates.needRefreshHint': '都更新完了,刷新页面即可加载新的客户端代码。',
|
|
219
223
|
'updates.updating': '更新中…',
|
|
220
224
|
'updates.none': '没有可更新的插件。',
|
|
221
225
|
'updates.upToDate': '其余 {n} 个已是最新版',
|
|
@@ -224,9 +228,9 @@ window.__ModuleLoader__.load({
|
|
|
224
228
|
'updates.idle': '还没检查。',
|
|
225
229
|
'updates.unsupported': '这台宿主没有可用的插件管理服务,所以这里查不了更新(已装插件不受影响)。',
|
|
226
230
|
'updates.registryDown': 'npm registry 没有回应,读不到发布时间。公开插件暂时按「未检查」处理。',
|
|
227
|
-
'updates.pmTimeout': '宿主的插件管理服务 {ms}
|
|
228
|
-
'updates.pmWaiting': '
|
|
229
|
-
'updates.pmStalled': '
|
|
231
|
+
'updates.pmTimeout': '宿主的插件管理服务 {ms} 秒还没应答,过一会儿再试。',
|
|
232
|
+
'updates.pmWaiting': '正在等宿主插件管理服务应答…',
|
|
233
|
+
'updates.pmStalled': '宿主的插件管理服务没有应答,过一会儿再试。',
|
|
230
234
|
'updates.loadFailed': '检查失败',
|
|
231
235
|
'updates.waiting': '发布不足 24 小时 —— 等满一天再更新',
|
|
232
236
|
'updates.unknownAge': '读不到发布时间 —— 无法确认是否满 24 小时,先跳过',
|
|
@@ -2171,20 +2175,6 @@ button.muik-shelf-row:focus-visible{outline:2px solid var(--dsw-alias-brand-prim
|
|
|
2171
2175
|
return pm && typeof pm.listBundles === 'function' ? pm : null
|
|
2172
2176
|
}
|
|
2173
2177
|
|
|
2174
|
-
/* Which remote namespaces the page actually got. Printed in the failure
|
|
2175
|
-
* text so a missing or renamed namespace is visible without DevTools. */
|
|
2176
|
-
function remoteNamespaces() {
|
|
2177
|
-
try {
|
|
2178
|
-
const remote = ctx.remote || (typeof ctx.get === 'function' ? ctx.get('remote') : null)
|
|
2179
|
-
if (!remote) return 'none'
|
|
2180
|
-
const keys = Object.keys(remote)
|
|
2181
|
-
if (keys.length === 0) return 'empty'
|
|
2182
|
-
return keys.slice(0, 10).join('|')
|
|
2183
|
-
} catch (err) {
|
|
2184
|
-
return 'error'
|
|
2185
|
-
}
|
|
2186
|
-
}
|
|
2187
|
-
|
|
2188
2178
|
function withTimeout(promise, ms) {
|
|
2189
2179
|
return new Promise(function (resolve) {
|
|
2190
2180
|
const timer = setTimeout(function () {
|
|
@@ -2231,9 +2221,20 @@ button.muik-shelf-row:focus-visible{outline:2px solid var(--dsw-alias-brand-prim
|
|
|
2231
2221
|
}
|
|
2232
2222
|
|
|
2233
2223
|
const REGISTRY_TIMEOUT_MS = 8000
|
|
2234
|
-
const REGISTRY_CONCURRENCY =
|
|
2224
|
+
const REGISTRY_CONCURRENCY = 6
|
|
2225
|
+
|
|
2226
|
+
/* Every packument is a few hundred KB. The badge scan, a tab switch and a
|
|
2227
|
+
* page reload all used to re-download all of them, which is why the first
|
|
2228
|
+
* look at this tab felt like it hung. One cache, one network round trip. */
|
|
2229
|
+
const REGISTRY_CACHE_MS = 10 * 60 * 1000
|
|
2230
|
+
const SCAN_CACHE_MS = 2 * 60 * 1000
|
|
2231
|
+
const registryCache = new Map()
|
|
2232
|
+
const compatCache = new Map()
|
|
2233
|
+
let scanCache = { at: 0, value: null }
|
|
2235
2234
|
|
|
2236
2235
|
async function readRegistry(name) {
|
|
2236
|
+
const cached = registryCache.get(name)
|
|
2237
|
+
if (cached && Date.now() - cached.at < REGISTRY_CACHE_MS) return cached.doc
|
|
2237
2238
|
const controller = typeof AbortController === 'function' ? new AbortController() : null
|
|
2238
2239
|
const timer = controller
|
|
2239
2240
|
? setTimeout(function () {
|
|
@@ -2252,11 +2253,13 @@ button.muik-shelf-row:focus-visible{outline:2px solid var(--dsw-alias-brand-prim
|
|
|
2252
2253
|
const doc = await res.json()
|
|
2253
2254
|
const time = (doc && doc.time) || {}
|
|
2254
2255
|
const tags = (doc && doc['dist-tags']) || {}
|
|
2255
|
-
|
|
2256
|
+
const parsed = {
|
|
2256
2257
|
latest: typeof tags.latest === 'string' ? tags.latest : '',
|
|
2257
2258
|
time: time,
|
|
2258
2259
|
repo: readRepo(doc),
|
|
2259
2260
|
}
|
|
2261
|
+
registryCache.set(name, { at: Date.now(), doc: parsed })
|
|
2262
|
+
return parsed
|
|
2260
2263
|
} catch (err) {
|
|
2261
2264
|
return null
|
|
2262
2265
|
} finally {
|
|
@@ -2269,6 +2272,9 @@ button.muik-shelf-row:focus-visible{outline:2px solid var(--dsw-alias-brand-prim
|
|
|
2269
2272
|
* when its `engines.dsh` (or a DSH peer) rejects the running build, and
|
|
2270
2273
|
* it already honours `compatibility.json` exemptions. */
|
|
2271
2274
|
async function readCompat(pm, name, version) {
|
|
2275
|
+
const key = name + '@' + version
|
|
2276
|
+
const cachedCompat = compatCache.get(key)
|
|
2277
|
+
if (cachedCompat !== undefined && Date.now() - cachedCompat.at < REGISTRY_CACHE_MS) return cachedCompat.doc
|
|
2272
2278
|
try {
|
|
2273
2279
|
const answer = await withTimeout(pm.listVersions(name), 8000)
|
|
2274
2280
|
if (!answer || answer.timedOut || answer.error !== undefined) return null
|
|
@@ -2284,10 +2290,12 @@ button.muik-shelf-row:focus-visible{outline:2px solid var(--dsw-alias-brand-prim
|
|
|
2284
2290
|
const listed = Object.keys(requirements).map(function (key) {
|
|
2285
2291
|
return key + ' ' + requirements[key]
|
|
2286
2292
|
})
|
|
2287
|
-
|
|
2293
|
+
const verdict = {
|
|
2288
2294
|
runtime: hit.incompatible.runtimeVersion || '',
|
|
2289
2295
|
required: requirements['engines.dsh'] || listed.join(', '),
|
|
2290
2296
|
}
|
|
2297
|
+
compatCache.set(key, { at: Date.now(), doc: verdict })
|
|
2298
|
+
return verdict
|
|
2291
2299
|
} catch (err) {
|
|
2292
2300
|
return null
|
|
2293
2301
|
}
|
|
@@ -2297,12 +2305,26 @@ button.muik-shelf-row:focus-visible{outline:2px solid var(--dsw-alias-brand-prim
|
|
|
2297
2305
|
* old that release is, and what the fallback would be. The list, the
|
|
2298
2306
|
* section split, the count and the badge all derive from this. */
|
|
2299
2307
|
async function collectUpdates(onRow) {
|
|
2308
|
+
if (scanCache.value && Date.now() - scanCache.at < SCAN_CACHE_MS) return scanCache.value
|
|
2300
2309
|
const pm = pluginManager()
|
|
2301
2310
|
if (!pm) return { supported: false, checked: 0, rows: [] }
|
|
2302
2311
|
let listed = null
|
|
2303
|
-
|
|
2312
|
+
/* A remote proxy can throw on the call itself (dead channel), not only
|
|
2313
|
+
* reject the promise — that used to escape load() and leave the panel
|
|
2314
|
+
* in "loading" with the watchdog as the only thing still talking. */
|
|
2315
|
+
let answer
|
|
2316
|
+
try {
|
|
2317
|
+
answer = await withTimeout(pm.listBundles(), 8000)
|
|
2318
|
+
} catch (err) {
|
|
2319
|
+
return {
|
|
2320
|
+
supported: false,
|
|
2321
|
+
checked: 0,
|
|
2322
|
+
rows: [],
|
|
2323
|
+
stalled: 'listBundles',
|
|
2324
|
+
}
|
|
2325
|
+
}
|
|
2304
2326
|
if (answer.timedOut) {
|
|
2305
|
-
return { supported: false, checked: 0, rows: [], stalled: 'listBundles'
|
|
2327
|
+
return { supported: false, checked: 0, rows: [], stalled: 'listBundles' }
|
|
2306
2328
|
}
|
|
2307
2329
|
if (answer.error !== undefined) return { supported: false, checked: 0, rows: [] }
|
|
2308
2330
|
listed = answer.value
|
|
@@ -2319,8 +2341,8 @@ button.muik-shelf-row:focus-visible{outline:2px solid var(--dsw-alias-brand-prim
|
|
|
2319
2341
|
const found = []
|
|
2320
2342
|
const stats = { tried: 0, failed: 0 }
|
|
2321
2343
|
let cursor = 0
|
|
2322
|
-
/*
|
|
2323
|
-
* one
|
|
2344
|
+
/* Six at a time: the public registry throttles a burst of thirty, and a
|
|
2345
|
+
* big packument on one lane must not hold the others in "loading". */
|
|
2324
2346
|
async function worker() {
|
|
2325
2347
|
while (cursor < candidates.length) {
|
|
2326
2348
|
const item = candidates[cursor]
|
|
@@ -2336,9 +2358,11 @@ button.muik-shelf-row:focus-visible{outline:2px solid var(--dsw-alias-brand-prim
|
|
|
2336
2358
|
const stamp = published === undefined ? NaN : Date.parse(published)
|
|
2337
2359
|
const age = Number.isFinite(stamp) ? Date.now() - stamp : null
|
|
2338
2360
|
const fallback = previousMatureVersion(doc.time, doc.latest)
|
|
2339
|
-
|
|
2361
|
+
/* Draw the row first: `listVersions` is a Host round trip of its own,
|
|
2362
|
+
* and waiting for it before painting made an already-slow list feel
|
|
2363
|
+
* frozen. The compatibility verdict lands on the row a moment later. */
|
|
2340
2364
|
const row = {
|
|
2341
|
-
compat:
|
|
2365
|
+
compat: null,
|
|
2342
2366
|
name: item.name,
|
|
2343
2367
|
installed: item.version,
|
|
2344
2368
|
latest: doc.latest,
|
|
@@ -2352,6 +2376,11 @@ button.muik-shelf-row:focus-visible{outline:2px solid var(--dsw-alias-brand-prim
|
|
|
2352
2376
|
}
|
|
2353
2377
|
found.push(row)
|
|
2354
2378
|
if (typeof onRow === 'function') onRow(row)
|
|
2379
|
+
readCompat(pm, item.name, doc.latest).then(function (compat) {
|
|
2380
|
+
if (!compat) return
|
|
2381
|
+
row.compat = compat
|
|
2382
|
+
if (typeof onRow === 'function') onRow(Object.assign({}, row))
|
|
2383
|
+
})
|
|
2355
2384
|
}
|
|
2356
2385
|
}
|
|
2357
2386
|
const lanes = []
|
|
@@ -2360,7 +2389,11 @@ button.muik-shelf-row:focus-visible{outline:2px solid var(--dsw-alias-brand-prim
|
|
|
2360
2389
|
found.sort(function (a, b) {
|
|
2361
2390
|
return a.name.localeCompare(b.name)
|
|
2362
2391
|
})
|
|
2363
|
-
|
|
2392
|
+
const result = { supported: true, checked: installed.length, rows: found, stats: stats }
|
|
2393
|
+
/* The badge scan runs at start-up, so by the time the tab is opened the
|
|
2394
|
+
* answer is normally already here: keep it for a couple of minutes. */
|
|
2395
|
+
scanCache = { at: Date.now(), value: result }
|
|
2396
|
+
return result
|
|
2364
2397
|
}
|
|
2365
2398
|
|
|
2366
2399
|
/* The packument's repository field is the only place that knows where the
|
|
@@ -2657,19 +2690,48 @@ button.muik-shelf-row:focus-visible{outline:2px solid var(--dsw-alias-brand-prim
|
|
|
2657
2690
|
return h('span', { className: 'dsuik-up-badge' }, String(count))
|
|
2658
2691
|
}
|
|
2659
2692
|
|
|
2693
|
+
/* Progress lives outside the component: switching tabs unmounts it,
|
|
2694
|
+
* and an install that is still running must not vanish with the view. */
|
|
2695
|
+
const updateRun = {
|
|
2696
|
+
rows: [],
|
|
2697
|
+
checked: 0,
|
|
2698
|
+
busy: false,
|
|
2699
|
+
listeners: new Set(),
|
|
2700
|
+
snapshot: function () {
|
|
2701
|
+
return { rows: updateRun.rows, checked: updateRun.checked, busy: updateRun.busy }
|
|
2702
|
+
},
|
|
2703
|
+
set: function (changes) {
|
|
2704
|
+
if (changes.rows !== undefined) updateRun.rows = changes.rows
|
|
2705
|
+
if (changes.checked !== undefined) updateRun.checked = changes.checked
|
|
2706
|
+
if (changes.busy !== undefined) updateRun.busy = changes.busy
|
|
2707
|
+
const snap = updateRun.snapshot()
|
|
2708
|
+
updateRun.listeners.forEach(function (fn) { fn(snap) })
|
|
2709
|
+
},
|
|
2710
|
+
subscribe: function (fn) {
|
|
2711
|
+
updateRun.listeners.add(fn)
|
|
2712
|
+
return function () { updateRun.listeners.delete(fn) }
|
|
2713
|
+
}
|
|
2714
|
+
}
|
|
2715
|
+
|
|
2660
2716
|
function UpdatesTab() {
|
|
2661
|
-
const [phase, setPhase] = React.useState('loading')
|
|
2717
|
+
const [phase, setPhase] = React.useState(updateRun.busy ? 'ready' : 'loading')
|
|
2662
2718
|
/* Mirror of `phase` for timers: reading a ref avoids calling one
|
|
2663
2719
|
* setState from inside another setState's updater, which throws. */
|
|
2664
|
-
const phaseRef = React.useRef('loading')
|
|
2720
|
+
const phaseRef = React.useRef(updateRun.busy ? 'ready' : 'loading')
|
|
2665
2721
|
function setPhaseSafe(next) {
|
|
2666
2722
|
phaseRef.current = next
|
|
2667
2723
|
setPhase(next)
|
|
2668
2724
|
}
|
|
2669
|
-
const [
|
|
2670
|
-
const
|
|
2725
|
+
const [run, setRun] = React.useState(updateRun.snapshot())
|
|
2726
|
+
const rows = run.rows
|
|
2727
|
+
const checked = run.checked
|
|
2728
|
+
const busy = run.busy
|
|
2729
|
+
function setRows(next) {
|
|
2730
|
+
updateRun.set({ rows: typeof next === 'function' ? next(updateRun.rows) : next })
|
|
2731
|
+
}
|
|
2732
|
+
function setChecked(next) { updateRun.set({ checked: next }) }
|
|
2733
|
+
function setBusy(next) { updateRun.set({ busy: next }) }
|
|
2671
2734
|
const [message, setMessage] = React.useState('')
|
|
2672
|
-
const [busy, setBusy] = React.useState(false)
|
|
2673
2735
|
const [open, setOpen] = React.useState({})
|
|
2674
2736
|
const [notes, setNotes] = React.useState({})
|
|
2675
2737
|
const [settings, setSettings] = React.useState(store.state)
|
|
@@ -2683,6 +2745,10 @@ button.muik-shelf-row:focus-visible{outline:2px solid var(--dsw-alias-brand-prim
|
|
|
2683
2745
|
})
|
|
2684
2746
|
}, [])
|
|
2685
2747
|
|
|
2748
|
+
React.useEffect(function () {
|
|
2749
|
+
return updateRun.subscribe(setRun)
|
|
2750
|
+
}, [])
|
|
2751
|
+
|
|
2686
2752
|
React.useEffect(function () {
|
|
2687
2753
|
alive.current = true
|
|
2688
2754
|
/* Ticks once a second so a frozen main thread is visible on screen:
|
|
@@ -2694,7 +2760,8 @@ button.muik-shelf-row:focus-visible{outline:2px solid var(--dsw-alias-brand-prim
|
|
|
2694
2760
|
load().catch(function (err) {
|
|
2695
2761
|
if (!alive.current) return
|
|
2696
2762
|
phaseRef.current = 'error'
|
|
2697
|
-
|
|
2763
|
+
console.warn('[dsh-ui-optimize] update scan failed', err)
|
|
2764
|
+
setMessage(translate('updates.loadFailed'))
|
|
2698
2765
|
setPhaseSafe('error')
|
|
2699
2766
|
})
|
|
2700
2767
|
return function () {
|
|
@@ -2704,7 +2771,6 @@ button.muik-shelf-row:focus-visible{outline:2px solid var(--dsw-alias-brand-prim
|
|
|
2704
2771
|
}, [])
|
|
2705
2772
|
|
|
2706
2773
|
function patch(name, changes) {
|
|
2707
|
-
if (!alive.current) return
|
|
2708
2774
|
setRows(function (previous) {
|
|
2709
2775
|
return previous.map(function (row) {
|
|
2710
2776
|
return row.name === name ? Object.assign({}, row, changes) : row
|
|
@@ -2712,15 +2778,50 @@ button.muik-shelf-row:focus-visible{outline:2px solid var(--dsw-alias-brand-prim
|
|
|
2712
2778
|
})
|
|
2713
2779
|
}
|
|
2714
2780
|
|
|
2715
|
-
async function load() {
|
|
2781
|
+
async function load(force) {
|
|
2782
|
+
/* "Check again" has to mean it: the cached scan would answer
|
|
2783
|
+
* instantly and the button would look broken. */
|
|
2784
|
+
if (force === true) {
|
|
2785
|
+
scanCache = { at: 0, value: null }
|
|
2786
|
+
registryCache.clear()
|
|
2787
|
+
}
|
|
2716
2788
|
if (store.state.updates === false) {
|
|
2717
2789
|
setPhaseSafe('off')
|
|
2718
2790
|
return
|
|
2719
2791
|
}
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2792
|
+
/* A batch started from an earlier mount is still running: keep its
|
|
2793
|
+
* rows and progress instead of rescanning over the top of it. */
|
|
2794
|
+
if (updateRun.busy) {
|
|
2795
|
+
setPhaseSafe('ready')
|
|
2796
|
+
return
|
|
2797
|
+
}
|
|
2798
|
+
/* A warm scan is shown at once and then revalidated in the background:
|
|
2799
|
+
* opening the tab always re-checks, but never blanks the list or makes
|
|
2800
|
+
* the user press "Check again" to see current numbers. */
|
|
2801
|
+
const warm = scanCache.value && Date.now() - scanCache.at < SCAN_CACHE_MS ? scanCache.value : null
|
|
2802
|
+
const carried = updateRun.rows.filter(function (row) { return row.state === 'succeeded' })
|
|
2803
|
+
if (warm) {
|
|
2804
|
+
const merged = carried.slice()
|
|
2805
|
+
warm.rows.forEach(function (row) {
|
|
2806
|
+
if (carried.some(function (item) { return item.name === row.name })) return
|
|
2807
|
+
merged.push(row)
|
|
2808
|
+
})
|
|
2809
|
+
merged.sort(function (a, b) { return a.name.localeCompare(b.name) })
|
|
2810
|
+
setRows(merged)
|
|
2811
|
+
setChecked(warm.checked)
|
|
2812
|
+
phaseRef.current = 'ready'
|
|
2813
|
+
setPhaseSafe('ready')
|
|
2814
|
+
setMessage('')
|
|
2815
|
+
scanCache = { at: 0, value: null }
|
|
2816
|
+
} else {
|
|
2817
|
+
phaseRef.current = 'loading'
|
|
2818
|
+
setPhaseSafe('loading')
|
|
2819
|
+
setMessage('')
|
|
2820
|
+
/* Keep what this session already installed on screen: a rescan would
|
|
2821
|
+
* otherwise drop those rows the moment the batch finishes, taking
|
|
2822
|
+
* the only confirmation the user gets with them. */
|
|
2823
|
+
setRows(carried)
|
|
2824
|
+
}
|
|
2724
2825
|
/* Rows appear as their registry answers arrive, so a slow package
|
|
2725
2826
|
* never leaves the panel empty. */
|
|
2726
2827
|
const scan = await collectUpdates(function (row) {
|
|
@@ -2743,16 +2844,28 @@ button.muik-shelf-row:focus-visible{outline:2px solid var(--dsw-alias-brand-prim
|
|
|
2743
2844
|
if (scan.stalled === 'listBundles') {
|
|
2744
2845
|
phaseRef.current = 'error'
|
|
2745
2846
|
setPhaseSafe('error')
|
|
2746
|
-
setMessage(
|
|
2747
|
-
translate('updates.pmStalled')
|
|
2748
|
-
.replace('{names}', String(scan.names || 'none'))
|
|
2749
|
-
)
|
|
2847
|
+
setMessage(translate('updates.pmStalled'))
|
|
2750
2848
|
return
|
|
2751
2849
|
}
|
|
2752
|
-
setPhaseSafe('
|
|
2850
|
+
setPhaseSafe('error')
|
|
2851
|
+
setMessage(translate('updates.pmStalled'))
|
|
2753
2852
|
return
|
|
2754
2853
|
}
|
|
2755
2854
|
setChecked(scan.checked)
|
|
2855
|
+
/* Reconcile with the fresh scan: a warm list can hold rows that have
|
|
2856
|
+
* since been installed (here or elsewhere) and must not linger. */
|
|
2857
|
+
setRows(function (previous) {
|
|
2858
|
+
const kept = previous.filter(function (row) {
|
|
2859
|
+
return row.state === 'succeeded' || row.state === 'running'
|
|
2860
|
+
})
|
|
2861
|
+
const merged = kept.slice()
|
|
2862
|
+
scan.rows.forEach(function (row) {
|
|
2863
|
+
if (merged.some(function (item) { return item.name === row.name })) return
|
|
2864
|
+
merged.push(row)
|
|
2865
|
+
})
|
|
2866
|
+
merged.sort(function (a, b) { return a.name.localeCompare(b.name) })
|
|
2867
|
+
return merged
|
|
2868
|
+
})
|
|
2756
2869
|
setMessage('')
|
|
2757
2870
|
phaseRef.current = 'ready'
|
|
2758
2871
|
if (scan.rows.length === 0 && scan.stats && scan.stats.tried > 0 && scan.stats.failed === scan.stats.tried) {
|
|
@@ -2805,6 +2918,8 @@ button.muik-shelf-row:focus-visible{outline:2px solid var(--dsw-alias-brand-prim
|
|
|
2805
2918
|
if (targets.length === 0) return
|
|
2806
2919
|
setBusy(true)
|
|
2807
2920
|
setMessage('')
|
|
2921
|
+
let restarts = 0
|
|
2922
|
+
let refreshes = 0
|
|
2808
2923
|
for (let index = 0; index < targets.length; index += 1) {
|
|
2809
2924
|
const name = targets[index].name
|
|
2810
2925
|
patch(name, { state: 'running', percent: null, detail: '' })
|
|
@@ -2817,8 +2932,15 @@ button.muik-shelf-row:focus-visible{outline:2px solid var(--dsw-alias-brand-prim
|
|
|
2817
2932
|
})
|
|
2818
2933
|
})
|
|
2819
2934
|
const ok = operation && operation.state === 'succeeded'
|
|
2935
|
+
/* How the update lands decides what the user has to do next:
|
|
2936
|
+
* a host-side change only applies at the next start, while a
|
|
2937
|
+
* client bundle is enough to reload the page for. */
|
|
2938
|
+
const needs = !ok ? '' : operation && operation.restartRequired ? 'restart' : 'refresh'
|
|
2939
|
+
if (needs === 'restart') restarts += 1
|
|
2940
|
+
else if (needs === 'refresh') refreshes += 1
|
|
2820
2941
|
patch(name, {
|
|
2821
2942
|
state: ok ? 'succeeded' : 'failed',
|
|
2943
|
+
needs: needs,
|
|
2822
2944
|
percent: 100,
|
|
2823
2945
|
done: ok
|
|
2824
2946
|
? { from: targets[index].from, to: (operation && operation.installedVersion) || targets[index].target.version }
|
|
@@ -2833,9 +2955,18 @@ button.muik-shelf-row:focus-visible{outline:2px solid var(--dsw-alias-brand-prim
|
|
|
2833
2955
|
patch(name, { state: 'failed', percent: 100, detail: err.message })
|
|
2834
2956
|
}
|
|
2835
2957
|
}
|
|
2958
|
+
/* The batch may outlive this mount: write the result to the shared
|
|
2959
|
+
* run state unconditionally, or a remount would come back with the
|
|
2960
|
+
* button stuck on "busy" forever. */
|
|
2961
|
+
setBusy(false)
|
|
2836
2962
|
if (alive.current) {
|
|
2837
|
-
|
|
2838
|
-
|
|
2963
|
+
setMessage(
|
|
2964
|
+
restarts > 0
|
|
2965
|
+
? translate('updates.needRestartHint').replace('{n}', String(restarts))
|
|
2966
|
+
: refreshes > 0
|
|
2967
|
+
? translate('updates.needRefreshHint')
|
|
2968
|
+
: translate('updates.reloadHint'),
|
|
2969
|
+
)
|
|
2839
2970
|
}
|
|
2840
2971
|
refreshUpdateBadge()
|
|
2841
2972
|
}
|
|
@@ -2852,7 +2983,7 @@ button.muik-shelf-row:focus-visible{outline:2px solid var(--dsw-alias-brand-prim
|
|
|
2852
2983
|
type: 'button',
|
|
2853
2984
|
className: 'dsuik-up-btn',
|
|
2854
2985
|
disabled: busy || phase === 'loading',
|
|
2855
|
-
onClick: load,
|
|
2986
|
+
onClick: function () { load(true) },
|
|
2856
2987
|
}, phase === 'loading'
|
|
2857
2988
|
? h('span', { className: 'dsuik-up-btnlabel' },
|
|
2858
2989
|
spinIcon(),
|
|
@@ -3074,11 +3205,9 @@ button.muik-shelf-row:focus-visible{outline:2px solid var(--dsw-alias-brand-prim
|
|
|
3074
3205
|
h('span', null,
|
|
3075
3206
|
message ||
|
|
3076
3207
|
(clock >= 13
|
|
3077
|
-
? translate('updates.pmTimeout')
|
|
3078
|
-
.replace('{remote}', pluginManager() ? 'yes' : 'no')
|
|
3079
|
-
.replace('{ms}', String(clock))
|
|
3208
|
+
? translate('updates.pmTimeout').replace('{ms}', String(clock))
|
|
3080
3209
|
: clock >= 4
|
|
3081
|
-
? translate('updates.pmWaiting')
|
|
3210
|
+
? translate('updates.pmWaiting')
|
|
3082
3211
|
: translate('updates.loadingDetail'))))
|
|
3083
3212
|
: null,
|
|
3084
3213
|
phase === 'ready'
|
|
@@ -3089,6 +3218,9 @@ button.muik-shelf-row:focus-visible{outline:2px solid var(--dsw-alias-brand-prim
|
|
|
3089
3218
|
/* The ready area stays on screen even when it is empty, so the page
|
|
3090
3219
|
* always answers "is there anything for me?" instead of going blank. */
|
|
3091
3220
|
phase === 'ready' ? sectionArea('updates.section.ready', groups.ready, false, null, true) : null,
|
|
3221
|
+
/* The closing hint belongs to the batch it talks about: right under the
|
|
3222
|
+
* rows you just updated, not after two unrelated sections. */
|
|
3223
|
+
phase === 'ready' && message ? h('p', { className: 'dsuik-up-note is-after-ready' }, message) : null,
|
|
3092
3224
|
phase === 'ready' ? sectionArea('updates.section.waiting', groups.waiting, true, 'updates.section.waitingHint', false) : null,
|
|
3093
3225
|
phase === 'ready'
|
|
3094
3226
|
? sectionArea(
|
|
@@ -3102,7 +3234,6 @@ button.muik-shelf-row:focus-visible{outline:2px solid var(--dsw-alias-brand-prim
|
|
|
3102
3234
|
false,
|
|
3103
3235
|
)
|
|
3104
3236
|
: null,
|
|
3105
|
-
message && phase !== 'error' ? h('p', { className: 'dsuik-up-note' }, message) : null,
|
|
3106
3237
|
)
|
|
3107
3238
|
}
|
|
3108
3239
|
|
|
@@ -3130,6 +3261,7 @@ button.muik-shelf-row:focus-visible{outline:2px solid var(--dsw-alias-brand-prim
|
|
|
3130
3261
|
.dsuik-up-section+.dsuik-up-section{margin-top:4px;padding-top:18px;border-top:1px solid var(--dsw-alias-border-l1);}
|
|
3131
3262
|
.dsuik-up-section-title{margin:0;font-size:12.5px;font-weight:600;letter-spacing:.01em;color:var(--dsw-alias-label-primary);}
|
|
3132
3263
|
.dsuik-up-section.is-muted .dsuik-up-row{opacity:.7;background:transparent;}
|
|
3264
|
+
.dsuik-up-note.is-after-ready{margin-top:-4px;}
|
|
3133
3265
|
.dsuik-up-note.is-empty{padding:10px 12px;border:1px dashed var(--dsw-alias-border-l1);border-radius:10px;}
|
|
3134
3266
|
.dsuik-up-loading{display:flex;align-items:center;justify-content:center;gap:8px;padding:34px 0 30px;font-size:13px;color:var(--dsw-alias-label-secondary);animation:dsuik-up-in .2s ease-out both;}
|
|
3135
3267
|
@media (prefers-reduced-motion: reduce){.dsuik-up-section,.dsuik-up-row,.dsuik-up-loading{animation:none;}}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moonsand/dsh-ui-optimize",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Switches that tune how DeepSeek Harness looks and behaves across the whole interface, not just a few screens — each works on its own and more arrive as the shell grows: an eight-theme minimalist gallery, sidebar panel folding, and reload/restart buttons at the sidebar foot. · 调 DeepSeek Harness 整体观感与操作的开关集合,管的是整套界面而不只是某几块;每个开关独立生效,随宿主能力增长继续增加:8 套极简主题画廊、侧栏面板收纳,以及侧栏底部的刷新界面与重启应用按钮。",
|
|
6
6
|
"license": "MIT",
|