dsh-theme-palette 1.3.1 → 1.3.2

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 CHANGED
@@ -538,12 +538,49 @@ alpha **浅色与内置一致、深色压到 0.6 倍**(见下):
538
538
 
539
539
  ## 安装
540
540
 
541
+ 从 npm(推荐):
542
+
543
+ ```bash
544
+ # 方式 A:装进 DSH profile
545
+ cd ~/.dsh/profiles/desktop
546
+ pnpm add dsh-theme-palette
547
+
548
+ # 方式 B:用 DSH 的插件命令
549
+ dsh plugin --profile desktop add dsh-theme-palette
550
+ ```
551
+
552
+ 从 GitHub Release 的 tarball(npm 不可达时):
553
+
554
+ ```bash
555
+ pnpm add "https://github.com/zuoyunlai/dsh-theme-palette/releases/download/v1.3.1/dsh-theme-palette-1.3.1.tgz"
556
+ ```
557
+
558
+ 从源码(开发调试):
559
+
560
+ ```bash
561
+ git clone https://github.com/zuoyunlai/dsh-theme-palette.git
562
+ dsh plugin --profile desktop add "$PWD/dsh-theme-palette"
541
563
  ```
542
- dsh plugin --profile desktop add "E:\Documents\deepseek-harness\default-workspace\dsh-theme-palette"
564
+
565
+ 装完**必须重启 GUI**(运行中的进程仍持旧模块)。
566
+
567
+ > 开发时注意:`node_modules/dsh-theme-palette` 是**副本**,改源码后要
568
+ > `rm -rf node_modules/dsh-theme-palette && pnpm install` —— `pnpm add` 对已存在的
569
+ > `file:` 目录不会刷新内容。
570
+
571
+ 安装后:左下角头像 → 设置 → 左侧「**主题色**」。
572
+
573
+ ## 发版
574
+
575
+ ```bash
576
+ node tools/release.mjs --dry # 本地检查:语法 / 工作区 / 打包内容 / 版本是否已存在
577
+ node tools/release.mjs # 真发布(npm 已登录)+ 等 registry 放出 + 校验 latest
578
+ node tools/release.mjs --tag # 发布后再打 tag 并推 main + tag
543
579
  ```
544
580
 
545
- 装完**必须重启 GUI**。`node_modules/dsh-theme-palette` 是**副本**,改源码后要删掉副本再 `pnpm install`
546
- (`pnpm add` 对已存在的 `file:` 目录不会刷新内容)。
581
+ 脚本要处理三件容易出错的事:本机 npm 默认源是 npmmirror(**必须显式指官方源**);
582
+ 新包名的首次发布会进**暂存审核**(CLI 照打印 `+ pkg@ver`,但 registry 要过几分钟才 200);
583
+ `latest` 不保证自动前移。2026-10-21 实测:提交到放出约 **8 分钟**。
547
584
 
548
585
  ## 结构
549
586
 
@@ -612,6 +649,10 @@ dsh plugin --profile desktop add "E:\Documents\deepseek-harness\default-workspac
612
649
  - 苔绿强调 `155°→165°` —— 与底色(h≈152)从 2° 拉开到 13°,链接不再只靠明度识别
613
650
  - 深色对比度:正文 14.40–14.98、三级 4.79 起、链接 4.65 起(0 处低于下限)
614
651
 
652
+ **1.3.2**
653
+ - README 安装说明改为 npm / Release tarball / 源码三条路径,去掉本机绝对路径
654
+ - 新增 `tools/release.mjs`:一键发版(检查 → 发布 → 等 registry → 校验 latest → 可选打 tag)
655
+
615
656
  **1.3.1**
616
657
  - 自愈:override 层被宿主丢掉时(插件 fiber 重载等)自动重放,设置页显示恢复次数
617
658
  - 触发点:visibilitychange / focus / pageshow / theme/change / 4s 定时;健康时零写入
package/client.js CHANGED
@@ -27,7 +27,7 @@ window.__ModuleLoader__.load({
27
27
  const React = require('react')
28
28
  const h = React.createElement
29
29
 
30
- const PLUGIN_VERSION = '1.3.1'
30
+ const PLUGIN_VERSION = '1.3.2'
31
31
  const STORE_KEY = 'dsh-theme-palette.v1'
32
32
  const OVERRIDE_SOURCE = 'dsh-theme-palette'
33
33
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-theme-palette",
3
- "version": "1.3.1",
3
+ "version": "1.3.2",
4
4
  "description": "DSH 主题配色:4 套配色 × 明暗两模式,OKLCH 色域安全重建 + 真实承载面对比度求解,可调强度与面板表面。",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -22,7 +22,8 @@
22
22
  "tools/shoot-html.mjs",
23
23
  "tools/preview-settings.mjs",
24
24
  "tools/shoot-desktop.mjs",
25
- "tools/compare.mjs"
25
+ "tools/compare.mjs",
26
+ "tools/release.mjs"
26
27
  ],
27
28
  "peerDependencies": {
28
29
  "@deepseek-ai/cordis": "^4.0.0"
@@ -0,0 +1,117 @@
1
+ /**
2
+ * 一键发版:npm publish + 等 registry 出现该版本 + 校验 dist-tag + 可选打 tag 推 Git。
3
+ *
4
+ * 用法:
5
+ * node tools/release.mjs --dry # 只做本地检查(语法、打包内容、版本可用性)
6
+ * node tools/release.mjs # 真发布(需要 npm 登录态)
7
+ * node tools/release.mjs --tag # 发布后再打 tag 并推 main + tag
8
+ * node tools/release.mjs --skip-publish # 只打 tag(版本已经在 registry 上了)
9
+ *
10
+ * 为什么需要它:本机 npm 默认源是 npmmirror,publish 必须显式指官方源;而 npm 对新包名
11
+ * 会走「暂存审核」,CLI 照样打印 `+ pkg@ver`,必须回查 registry 才知道有没有真的放出来。
12
+ * 另外 latest 不保证自动前移,得验一次。
13
+ */
14
+ import { execFileSync } from 'node:child_process'
15
+ import { readFileSync } from 'node:fs'
16
+ import path from 'node:path'
17
+ import { fileURLToPath } from 'node:url'
18
+
19
+ const here = path.dirname(fileURLToPath(import.meta.url))
20
+ const root = path.resolve(here, '..')
21
+ const args = process.argv.slice(2)
22
+ const has = (f) => args.includes('--' + f)
23
+
24
+ const REGISTRY = 'https://registry.npmjs.org'
25
+ // Windows 上 `npm` 实际是 npm.cmd,execFileSync 不做 PATHEXT 解析,必须写全名。
26
+ const NPM = process.platform === 'win32' ? 'npm.cmd' : 'npm'
27
+ const CURL = process.platform === 'win32' ? 'curl.exe' : 'curl'
28
+ const pkg = JSON.parse(readFileSync(path.join(root, 'package.json'), 'utf8'))
29
+ const { name, version } = pkg
30
+ const tag = 'v' + version
31
+
32
+ const run = (cmd, cmdArgs, opts = {}) => {
33
+ const out = execFileSync(cmd, cmdArgs, { cwd: root, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], ...opts })
34
+ return typeof out === 'string' ? out.trim() : ''
35
+ }
36
+ const sh = (cmd) => run(process.platform === 'win32' ? 'cmd' : 'sh', process.platform === 'win32' ? ['/c', cmd] : ['-c', cmd])
37
+ const ok = (m) => console.log(' ✓ ' + m)
38
+ const die = (m) => { console.error(' ✗ ' + m); process.exit(1) }
39
+
40
+ console.log(`\n发版 ${name}@${version}${has('dry') ? '(dry run)' : ''}\n`)
41
+
42
+ // 1. 本地检查
43
+ try { run(process.execPath, ['--check', 'client.js']); ok('client.js 语法') } catch { die('client.js 语法错误') }
44
+ const dirty = sh('git status --porcelain')
45
+ if (dirty) die('工作区不干净,先提交:\n' + dirty)
46
+ ok('工作区干净')
47
+
48
+ const packed = run(process.platform === 'win32' ? 'cmd' : 'sh',
49
+ process.platform === 'win32' ? ['/c', 'npm pack --dry-run --json'] : ['-c', 'npm pack --dry-run --json'])
50
+ try {
51
+ const info = JSON.parse(packed.slice(packed.indexOf('[')))[0]
52
+ ok(`打包 ${info.entryCount} 个文件 / ${(info.size / 1024).toFixed(1)} KB`)
53
+ } catch { die('读不出 npm pack --dry-run 的结果') }
54
+
55
+ // 2. 版本是否已在 registry
56
+ let remote = null
57
+ try { remote = JSON.parse(sh(`${NPM} view ${name} versions --json --registry=${REGISTRY}`)) } catch { remote = null }
58
+ const remoteList = Array.isArray(remote) ? remote : remote ? [remote] : []
59
+ if (remoteList.includes(version)) {
60
+ ok(`registry 上已有 ${version}`)
61
+ if (!has('skip-publish')) die('该版本已发布,先改 package.json 的 version')
62
+ } else {
63
+ ok(`registry 上没有 ${version}(当前 ${remoteList.length} 个版本)`)
64
+ }
65
+
66
+ if (has('dry')) { console.log('\n干跑结束,没有发布。\n'); process.exit(0) }
67
+
68
+ // 3. 发布
69
+ if (!has('skip-publish')) {
70
+ console.log('\n发布中…')
71
+ try {
72
+ // Node 20+ 在 Windows 上不允许直接 spawn .cmd(CVE-2024-27980 的缓解),
73
+ // 必须走 shell;所以统一用 sh(),而不是 execFileSync。
74
+ const out = sh(`${NPM} publish --registry=${REGISTRY}`)
75
+ if (out) console.log(out)
76
+ } catch (err) {
77
+ die('npm publish 失败:' + (err.stderr || err.message))
78
+ }
79
+ }
80
+
81
+ // 4. 回查 registry(新包会进暂存审核,CLI 打印成功不代表已放出)
82
+ console.log('\n等 registry 出现该版本(最多 10 分钟,暂存审核通过前会一直 404)…')
83
+ const started = Date.now()
84
+ let live = false
85
+ while (Date.now() - started < 10 * 60 * 1000) {
86
+ try {
87
+ const code = sh(`${CURL} -s -o ${process.platform === 'win32' ? 'NUL' : '/dev/null'} -w "%{http_code}" ${REGISTRY}/${name}/${version}`)
88
+ if (code.trim() === '200') { live = true; break }
89
+ } catch { /* 网络抖动继续等 */ }
90
+ await new Promise((r) => setTimeout(r, 15000))
91
+ }
92
+ if (!live) die('10 分钟内没出现在 registry —— 可能仍在审核,稍后手动跑 npm view ' + name + ' versions')
93
+ ok(`registry 上已可下载 ${version}`)
94
+
95
+ // 5. dist-tag
96
+ const latest = sh(`${NPM} view ${name} dist-tags.latest --registry=${REGISTRY}`).trim()
97
+ if (latest === version) ok(`latest = ${version}`)
98
+ else {
99
+ console.log(` ! latest 指向 ${latest},手工前移:npm dist-tag add ${name}@${version} latest --registry=${REGISTRY}`)
100
+ try {
101
+ sh(`${NPM} dist-tag add ${name}@${version} latest --registry=${REGISTRY}`)
102
+ ok(`已前移 latest → ${version}`)
103
+ } catch { console.log(' ! 前移失败,需要人工处理') }
104
+ }
105
+
106
+ // 6. Git tag(可选)
107
+ if (has('tag')) {
108
+ try {
109
+ sh(`git tag -a ${tag} -m "${name} ${version}"`)
110
+ sh(`git push origin main ${tag}`)
111
+ ok(`已打 tag 并推送 ${tag}`)
112
+ } catch (err) {
113
+ console.log(' ! tag/推送失败:' + (err.stderr || err.message))
114
+ }
115
+ }
116
+
117
+ console.log(`\n完成:https://www.npmjs.com/package/${name}/v/${version}\n`)