@moonsand/dsh-ui-optimize 0.12.3 → 0.12.4
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 +1 -1
- package/README.zh.md +1 -1
- package/client.js +23 -1
- package/desktop-restart.host.js +89 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -43,7 +43,7 @@ The plugin page gets an **Updates** tab. It reads what is installed from the hos
|
|
|
43
43
|
|
|
44
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
|
-
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.
|
|
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. Releases that are already loaded cannot be swapped in a running host, so that batch is staged instead: on the Linux host DSH stops once, the batch is installed with pnpm, and DSH starts again; in the desktop app the same batch is installed while the app restarts itself. Reload the page afterwards: the new client half only loads on a fresh page.
|
|
47
47
|
|
|
48
48
|
If the host's plugin manager is unavailable, the tab says so instead of pretending to check.
|
|
49
49
|
|
package/README.zh.md
CHANGED
|
@@ -58,7 +58,7 @@ dsh plugin 或 GUI 插件管理:安装 @moonsand/dsh-ui-optimize
|
|
|
58
58
|
|
|
59
59
|
只装**发布满 24 小时**的版本;更年轻的会列出剩余时间并跳过——刚发几小时的版本还可能被撤回或补丁。读不到发布时间的同样跳过:规则无法确认,就不假装确认过。宿主判定**与当前 DSH 版本不兼容**的版本(`engines.dsh` 或某个 DSH peer 包不满足)单列一区,写明它要求的版本,并且永远不被「一键更新」带上——刚升级完 DSH 时,页签告诉你是哪些插件还没跟上,而不是等你点下去才失败。
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
更新走宿主插件管理服务,和你手点单个插件的更新是同一条路径;进度与失败码由它回报。已经被宿主加载的插件不能就地替换,所以这批会先排进队列:Linux 宿主上 DSH 停一次、整批用 pnpm 装完、再启动;桌面版则在应用自身重启的过程中把这一批装好。更新完刷新页面:新的客户端代码只在重新加载时生效。
|
|
62
62
|
|
|
63
63
|
宿主的插件管理服务拿不到时,页签直接说明查不了,不会假装在检查。
|
|
64
64
|
|
package/client.js
CHANGED
|
@@ -137,6 +137,8 @@ window.__ModuleLoader__.load({
|
|
|
137
137
|
'updates.section.blocked': 'Not loadable on this DSH',
|
|
138
138
|
'updates.section.blockedHint': 'The running DSH version cannot load these releases. Upgrade DSH first, or wait for the plugin to publish a compatible one.',
|
|
139
139
|
'updates.compatTag': 'Needs {version}',
|
|
140
|
+
'updates.pendingUnsupported':
|
|
141
|
+
'This host is not Linux ({platform}), so DSH cannot be stopped from here. While DSH is stopped, run: {command}',
|
|
140
142
|
'updates.applyStarted': '{n} loaded plugin(s) are queued: DSH stops once, installs the whole batch, then starts once — not one restart per plugin. The page reconnects on its own.',
|
|
141
143
|
'updates.applyFailed': 'Could not start the background install. Try again in a moment.',
|
|
142
144
|
'updates.waitingRestart': 'waiting for restart',
|
|
@@ -254,6 +256,8 @@ window.__ModuleLoader__.load({
|
|
|
254
256
|
'updates.section.blocked': '与当前 DSH 不兼容',
|
|
255
257
|
'updates.section.blockedHint': '当前运行的 DSH 版本加载不了这些版本。先升级 DSH,或等插件发布兼容版本。',
|
|
256
258
|
'updates.compatTag': '需要 {version}',
|
|
259
|
+
'updates.pendingUnsupported':
|
|
260
|
+
'这个宿主不是 Linux({platform}),没法从这里停机安装。请在 DSH 停止时手动执行:{command}',
|
|
257
261
|
'updates.applyStarted': '{n} 个插件正在运行的,会一起停机安装:DSH 先退出、这批一次装完、再启动一次(不是每个插件重启一遍)。装完页面会自动重连。',
|
|
258
262
|
'updates.applyFailed': '后台安装没能启动,稍后再试一次。',
|
|
259
263
|
'updates.waitingRestart': '等待重启',
|
|
@@ -3093,6 +3097,14 @@ button.muik-shelf-row:focus-visible{outline:2px solid var(--dsw-alias-brand-prim
|
|
|
3093
3097
|
continue
|
|
3094
3098
|
}
|
|
3095
3099
|
if (!response.ok || payload.ok !== true) {
|
|
3100
|
+
/* A non-Linux host cannot run the staged helper at all; carry the
|
|
3101
|
+
* reason up so the panel can print the manual command instead of a
|
|
3102
|
+
* bare HTTP code the user can do nothing with. */
|
|
3103
|
+
if (payload.reason === 'unsupported-platform') {
|
|
3104
|
+
const error = new Error('unsupported-platform')
|
|
3105
|
+
error.unsupportedPlatform = String(payload.platform || '')
|
|
3106
|
+
throw error
|
|
3107
|
+
}
|
|
3096
3108
|
lastError = new Error('HTTP ' + response.status + ' ' + String(payload.reason || ''))
|
|
3097
3109
|
continue
|
|
3098
3110
|
}
|
|
@@ -3193,7 +3205,17 @@ button.muik-shelf-row:focus-visible{outline:2px solid var(--dsw-alias-brand-prim
|
|
|
3193
3205
|
})
|
|
3194
3206
|
} catch (err) {
|
|
3195
3207
|
applyFailed = true
|
|
3196
|
-
|
|
3208
|
+
if (err && err.unsupportedPlatform !== undefined) {
|
|
3209
|
+
const command = 'pnpm add ' + pendingRows.map(function (row) {
|
|
3210
|
+
const target = targetOf(row)
|
|
3211
|
+
return row.name + '@' + String((target && target.version) || row.latest)
|
|
3212
|
+
}).join(' ')
|
|
3213
|
+
applyError = translate('updates.pendingUnsupported')
|
|
3214
|
+
.replace('{platform}', String(err.unsupportedPlatform || 'unknown'))
|
|
3215
|
+
.replace('{command}', command)
|
|
3216
|
+
} else {
|
|
3217
|
+
applyError = err && err.message ? String(err.message) : String(err)
|
|
3218
|
+
}
|
|
3197
3219
|
}
|
|
3198
3220
|
}
|
|
3199
3221
|
setBusy(false)
|
package/desktop-restart.host.js
CHANGED
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
* @module @moonsand/dsh-desktop-restart
|
|
30
30
|
*/
|
|
31
31
|
import { spawn } from 'node:child_process'
|
|
32
|
-
import { existsSync, mkdirSync, readFileSync, rmSync, statSync, writeFileSync } from 'node:fs'
|
|
32
|
+
import { appendFileSync, existsSync, mkdirSync, readFileSync, rmSync, statSync, writeFileSync } from 'node:fs'
|
|
33
33
|
import { tmpdir } from 'node:os'
|
|
34
34
|
import { join } from 'node:path'
|
|
35
35
|
|
|
@@ -761,6 +761,69 @@ function writeApplyScript(specs) {
|
|
|
761
761
|
return script
|
|
762
762
|
}
|
|
763
763
|
|
|
764
|
+
/**
|
|
765
|
+
* Windows (the desktop app) has no POSIX shell, so the staged helper is written as a
|
|
766
|
+
* plain Node script instead and started with this very executable. Same contract:
|
|
767
|
+
* back up the manifests, `pnpm add` the batch, roll back on failure, restart only on
|
|
768
|
+
* success — the difference is that the restart goes through our own HTTP route, since
|
|
769
|
+
* the fnOS gateway socket does not exist here.
|
|
770
|
+
*/
|
|
771
|
+
function writeApplyNodeScript(specs, port) {
|
|
772
|
+
mkdirSync(APPLY_DIR, { recursive: true })
|
|
773
|
+
const profile = join(process.env.DSH_HOME || '', 'profiles', 'web')
|
|
774
|
+
const script = join(APPLY_DIR, 'apply.mjs')
|
|
775
|
+
const log = join(APPLY_DIR, 'apply.log')
|
|
776
|
+
const stamp = new Date().toISOString().replace(/[-:T]/g, '').slice(0, 14)
|
|
777
|
+
const body = `import { spawnSync } from 'node:child_process'
|
|
778
|
+
import { appendFileSync, copyFileSync, existsSync } from 'node:fs'
|
|
779
|
+
import { join } from 'node:path'
|
|
780
|
+
|
|
781
|
+
const log = ${JSON.stringify(log)}
|
|
782
|
+
const profile = ${JSON.stringify(profile)}
|
|
783
|
+
const specs = ${JSON.stringify(specs)}
|
|
784
|
+
const stamp = ${JSON.stringify(stamp)}
|
|
785
|
+
const port = ${JSON.stringify(String(port))}
|
|
786
|
+
const say = (line) => appendFileSync(log, line + '\\n')
|
|
787
|
+
|
|
788
|
+
say('== ' + new Date().toISOString() + ' apply start (node) ==')
|
|
789
|
+
const pkg = join(profile, 'package.json')
|
|
790
|
+
const lock = join(profile, 'pnpm-lock.yaml')
|
|
791
|
+
copyFileSync(pkg, pkg + '.bak-' + stamp)
|
|
792
|
+
if (existsSync(lock)) copyFileSync(lock, lock + '.bak-' + stamp)
|
|
793
|
+
|
|
794
|
+
const useShell = process.platform === 'win32'
|
|
795
|
+
const bin = useShell ? 'pnpm.cmd' : 'pnpm'
|
|
796
|
+
const result = spawnSync(bin, ['add', ...specs, '--registry=' + ${JSON.stringify('https://registry.npmjs.org/')}], {
|
|
797
|
+
cwd: profile,
|
|
798
|
+
shell: useShell,
|
|
799
|
+
encoding: 'utf8',
|
|
800
|
+
})
|
|
801
|
+
|
|
802
|
+
say((result.stdout || '') + (result.stderr || ''))
|
|
803
|
+
if (result.status !== 0) {
|
|
804
|
+
say('pnpm failed rc=' + String(result.status) + ' — rolling back')
|
|
805
|
+
copyFileSync(pkg + '.bak-' + stamp, pkg)
|
|
806
|
+
if (existsSync(lock + '.bak-' + stamp)) copyFileSync(lock + '.bak-' + stamp, lock)
|
|
807
|
+
say('== ' + new Date().toISOString() + ' apply done (rolled back) ==')
|
|
808
|
+
process.exit(1)
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
say('pnpm ok — asking DSH to restart')
|
|
812
|
+
try {
|
|
813
|
+
const response = await fetch('http://127.0.0.1:' + port + '/ui-optimize/desktop/restart', {
|
|
814
|
+
method: 'POST',
|
|
815
|
+
headers: { 'x-ui-optimize-apply': '1' },
|
|
816
|
+
})
|
|
817
|
+
say('restart response ' + response.status)
|
|
818
|
+
} catch (error) {
|
|
819
|
+
say('restart request failed: ' + String(error && error.message ? error.message : error))
|
|
820
|
+
}
|
|
821
|
+
say('== ' + new Date().toISOString() + ' apply done ==')
|
|
822
|
+
`
|
|
823
|
+
writeFileSync(script, body, { mode: 0o700 })
|
|
824
|
+
return script
|
|
825
|
+
}
|
|
826
|
+
|
|
764
827
|
async function handleRequest(ctx, request, response) {
|
|
765
828
|
const reply = (status, body) => {
|
|
766
829
|
response.writeHead(status, {
|
|
@@ -827,8 +890,31 @@ async function handleRequest(ctx, request, response) {
|
|
|
827
890
|
})
|
|
828
891
|
}
|
|
829
892
|
try {
|
|
830
|
-
|
|
831
|
-
|
|
893
|
+
// Two shapes, one contract: Linux stages a bash script and asks the fnOS gateway
|
|
894
|
+
// socket to restart; Windows (the desktop app) stages a Node script and restarts
|
|
895
|
+
// through our own HTTP route. Anything else refuses instead of guessing.
|
|
896
|
+
const windows = process.platform === 'win32'
|
|
897
|
+
const script = windows
|
|
898
|
+
? writeApplyNodeScript(specs, process.env.DSH_UPSTREAM_PORT || '3080')
|
|
899
|
+
: writeApplyScript(specs)
|
|
900
|
+
const child = windows
|
|
901
|
+
? spawn(process.execPath, [script], {
|
|
902
|
+
detached: true,
|
|
903
|
+
stdio: 'ignore',
|
|
904
|
+
env: { ...process.env, ELECTRON_RUN_AS_NODE: '1' },
|
|
905
|
+
})
|
|
906
|
+
: spawn('/bin/bash', [script], { detached: true, stdio: 'ignore' })
|
|
907
|
+
// Never let a failed exec kill the host: without this listener Node rethrows.
|
|
908
|
+
child.on('error', function (error) {
|
|
909
|
+
try {
|
|
910
|
+
appendFileSync(
|
|
911
|
+
join(APPLY_DIR, 'apply.log'),
|
|
912
|
+
'== ' + new Date().toISOString() + ' spawn failed: ' + (error && error.message ? error.message : String(error)) + ' ==\n',
|
|
913
|
+
)
|
|
914
|
+
} catch {
|
|
915
|
+
/* logging must never be the thing that breaks the request */
|
|
916
|
+
}
|
|
917
|
+
})
|
|
832
918
|
child.unref()
|
|
833
919
|
return reply(202, { ok: true, specs: specs.length, logPath: join(APPLY_DIR, 'apply.log') })
|
|
834
920
|
} catch (error) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moonsand/dsh-ui-optimize",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.4",
|
|
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",
|