dsh-theme-paper-warm 0.0.0-stage → 0.1.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 zhongfu
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,75 @@
1
- # Temporary Holding Version
1
+ # dsh-theme-paper-warm · 护眼暖纸主题
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Eye-care warm paper theme for the DeepSeek Harness (DSH) Web GUI: canvas `#F2F0E5`, ink `#100F0F`, sidebar painted the same warm paper, font stack led by `Segoe UI`. It registers as a third-party theme (`paper-warm`) and adds its own toggle row to **Settings → General**; the choice persists across reloads and restarts. Search keywords: eye-care, eye-friendly, warm paper, 护眼, 暖纸.
4
+
5
+ 给 DeepSeek Harness Web GUI 的护眼暖纸主题:画布 `#F2F0E5`,正文 `#100F0F`,侧栏与画布同色,字体栈以 `Segoe UI` 打头。以「第三方主题」形式注册(id `paper-warm`),并在「设置 → 通用」里自带一行开关;选择跨刷新、跨重启保留。搜索关键词:护眼、暖纸、暖色、纸张配色。
6
+
7
+ ![icon](icon.svg)
8
+
9
+ ## 安装 / Install
10
+
11
+ - **插件市场**:本插件已投稿 [awesome-dsh-plugin](https://github.com/awesome-dsh-plugin/awesome-dsh-plugin) 精选列表;合并后即可在 DSH 的 **插件 → 插件市场**([dshmarket](https://github.com/dsh-market/dsh-market))搜索 `paper-warm` 一键安装。收录合并前请用下面两种方式。
12
+ - **命令行**:`dsh plugin --profile <profile> add dsh-theme-paper-warm`,刷新页面即可。
13
+ - **本仓库源码**:`dsh plugin --profile <profile> add github:factyy163/dsh-theme-paper-warm`。
14
+
15
+ 卸载即恢复原生外观;主题选择存在浏览器 `localStorage`,卸载后重新安装会自动恢复上次的选择。
16
+
17
+ ## 它做什么
18
+
19
+ - 通过 `ctx.theme.register()` 注册主题 `paper-warm`(`colorScheme: light`),token 覆盖整套暖色阶:画布、侧栏(`--dsw-specific-sidebar-fill`,与画布同为 `#F2F0E5`)、卡片/侧栏层、弹层、正文与次级文字、描边、悬停态、代码块、滚动条。
20
+ - 另叠一层 `theme.overrideTokens()` 的 `{ light, dark }` 配对覆盖层,深色基础配色下同样成立(画布 `#100F0F`、正文 `#F2F0E5`)。
21
+ - 覆盖 `--dsw-font-family` 为 `"Segoe UI", -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif`。DSH 默认栈本身就含 Segoe UI,但排在 `-apple-system` / `BlinkMacSystemFont` 之后,本主题把它提到首位;CJK 字体保留,中文不会掉到兜底字形。
22
+ - 在「设置 → 通用」增加一行 `暖纸 / 原生` 的开关。
23
+ - 选择存在浏览器 `localStorage`(键 `dsh.theme.paper-warm`),下次打开页面自动恢复,并顶住宿主设置的下发与重连重读(见下节);只有本行的「原生」会结束这个选择。
24
+ - 附带侧栏恢复层:侧栏折叠后左上角始终有一个重新展开的按钮(Windows 下折叠会留下零宽轨道、原生重开控件全部藏在其中),并把第三方侧栏(`--dcu-*`)的冷色调色板映射到同一套暖色。
25
+
26
+ ## 三个必须知道的机制约束
27
+
28
+ 1. **第三方主题 id 跨不过内置设置 schema。** `ui-theme` 的 `preference` 字段是封闭枚举 `light | dark | system`,`ThemeRuntime.setTheme()` 对非内置 id 不写 Host 设置。所以本插件不写 `ui-theme`,而是自己持久化选择。
29
+ 2. **本行才是持久开关,原生「外观」是当次会话的覆盖。** 在原生「外观」里点浅色/深色/跟随系统,暖色即时下线、本行回到「原生」,但已存选择不动,所以重载或重启后仍回到「暖纸」;要长期回到原生,点本行的「原生」。
30
+ 3. **宿主设置的下发永远顶不掉已存选择。** `ThemeRuntime` 先以 schema 默认值(`system`)对外提供快照,之后在设置文档到达浏览器时采纳其中的持久 `preference`——启动时一次,此后每次设置失效重读/重连再来一次;每次都发 `theme/change`。这些下发没有可用于区分「用户选择」的标记,所以本插件反过来做:**只要已存选择还在,凡是内置值的变化一律重新断言它;只有紧跟在一次「外观开关按压」之后的那个变化才算用户的选择**(原生三个方块与本行按钮都是 `aria-pressed` 按钮,插件在 capture 阶段记录按压时刻,窗口 750ms)。任何一次误判都不会把主题永久弄丢。
31
+
32
+ ## 覆盖的 token
33
+
34
+ | 类别 | token |
35
+ |---|---|
36
+ | 字体 | `--dsw-font-family` |
37
+ | 画布 / 侧栏 | `--dsw-alias-bg-base`、`--dsw-specific-sidebar-fill` |
38
+ | 表面层级 | `bg-layer-1..3`、`bg-overlay`、`bg-module-platform`、`bg-multi-select`、`bg-document-preview`、`bg-skeleton` |
39
+ | 文字 | `label-primary`、`label-secondary`、`label-tertiary`、`label-caption`、`menu-icon` |
40
+ | 描边 / 交互 | `border-l1..l4`、`interactive-bg-hover`、`interactive-bg-active`、`interactive-bg-hover-solid` |
41
+ | 控件 | `button-floating-fill` / `-hover`、`button-elevated-fill`、`button-ghost-active-fill` / `-hover` |
42
+ | 代码 / 滚动条 | `markdown-code-block`、`markdown-code-block-banner`、`scrollbar-bg-l1`、`scrollbar-bg-l2` |
43
+
44
+ 深色基础配色下的对应值:画布与侧栏 `#100F0F`,正文 `#F2F0E5`,层级与描边按同一暖色调推导。
45
+
46
+ ## 改色
47
+
48
+ 改 `lib/client.js` 顶部的 `PALETTE`(`light` / `dark` 两组,两边 token 名必须一一对应,`PALETTE_OVERRIDE` 会自动转置),改完刷新页面即可。字体改 `PALETTE` 上方的 `FONT_STACK`。
49
+
50
+ ## 结构
51
+
52
+ | 文件 | 作用 |
53
+ |---|---|
54
+ | `lib/index.mjs` | 宿主半边,空实现;存在的意义是让 loader 有一条声明了 `dsh.client` 的条目,客户端模块系统据此把浏览器 bundle 提供给页面 |
55
+ | `lib/client.js` | 浏览器半边(预构建 bundle):注册主题、覆盖层、设置行、侧栏恢复层 |
56
+ | `cordis.patch.yml` | bundle 补丁:插入 loader 条目 `theme-paper-warm` |
57
+ | `locale/*.json` | 插件管理器显示的标题与描述(en / zh) |
58
+ | `test/boot-race.test.mjs` | 回归测试:锁住「宿主设置下发 vs 已存选择」的启动竞态 |
59
+
60
+ ## 回归测试
61
+
62
+ ```sh
63
+ node test/boot-race.test.mjs
64
+ ```
65
+
66
+ 在不启动 GUI 的情况下复现并按真实顺序驱动客户端半边(插件 `apply` 先恢复已存选择 → 宿主设置稍后下发),断言最终仍是暖纸,同时覆盖原生「外观」选择、本行开关、以及取不到设置服务时的降级行为。
67
+
68
+ ## 更新日志 / Changelog
69
+
70
+ - **0.1.1**(2026-11-16):备注与描述改为「护眼暖纸主题 / eye-care warm paper」便于插件市场搜索索引;声明 `engines.dsh`(`>=0.2.1-rc.2 <0.2.2-0 || >=0.2.2-rc.1 <0.3.0-0`,适配 0.2.2-rc 系列新版本 Harness);按升级指南 `v0.2.2-rc.1/window-drag-regions` 为侧栏重开按钮声明 `data-window-drag-exclude`,保证 macOS Desktop 上浮层按钮可交互。
71
+ - **0.1.0**(2026-11-13):首次发布(npm + GitHub + awesome-dsh-plugin 收录)。
72
+
73
+ ## License
74
+
75
+ MIT
@@ -0,0 +1,3 @@
1
+ - insert:
2
+ - id: theme-paper-warm
3
+ name: dsh-theme-paper-warm
package/icon.svg ADDED
@@ -0,0 +1,8 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
2
+ <rect x="2" y="2" width="60" height="60" rx="14" fill="#E3B366"/>
3
+ <path d="M16 12h22l10 10v30a2 2 0 0 1-2 2H16a2 2 0 0 1-2-2V14a2 2 0 0 1 2-2z" fill="#F2F0E5"/>
4
+ <path d="M38 12l10 10h-8a2 2 0 0 1-2-2z" fill="#DDD9C9"/>
5
+ <rect x="20" y="30" width="24" height="3" rx="1.5" fill="#100F0F"/>
6
+ <rect x="20" y="37" width="24" height="3" rx="1.5" fill="#55524A"/>
7
+ <rect x="20" y="44" width="16" height="3" rx="1.5" fill="#8E887C"/>
8
+ </svg>
package/lib/client.js ADDED
@@ -0,0 +1,650 @@
1
+ window.__ModuleLoader__.load({
2
+ id: "dsh-theme-paper-warm",
3
+ factory: (require) => {
4
+ var module = { exports: {} };
5
+ var exports = module.exports;
6
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
7
+ let react = require("react");
8
+ let react_jsx_runtime = require("react/jsx-runtime");
9
+
10
+ //#region lib/client/theme.js
11
+ /**
12
+ * Registered theme id. Registered themes are process-local extensions: the
13
+ * built-in `ui-theme` settings schema only accepts `light`, `dark` and
14
+ * `system`, so this id can never be persisted as the durable Appearance
15
+ * preference. This package therefore keeps its own selection in
16
+ * localStorage and drives `ctx.theme.setTheme()` from its own row.
17
+ */
18
+ const THEME_ID = "paper-warm";
19
+ /** Storage key holding this plugin's own selection. */
20
+ const STORAGE_KEY = "dsh.theme.paper-warm";
21
+ /** Preference restored when the user leaves the paper theme. */
22
+ const FALLBACK_KEY = "dsh.theme.paper-warm.previous";
23
+ /** Built-in preferences this plugin may restore. */
24
+ const BUILTIN_PREFERENCES = ["light", "dark", "system"];
25
+ /**
26
+ * How long after a press on an appearance toggle a built-in preference still
27
+ * counts as the user's choice rather than a Host settings push. A press
28
+ * reaches its handler within milliseconds, so this only has to absorb a
29
+ * stalled event loop.
30
+ */
31
+ const PRESS_WINDOW_MS = 750;
32
+
33
+ /**
34
+ * Font stack. Segoe UI first, so Windows renders it instead of the shell's
35
+ * leading `-apple-system`/`BlinkMacSystemFont`; the CJK faces and the
36
+ * remaining fallbacks are kept so Chinese text and every other script still
37
+ * resolve to a real face. Applied as a token override, so it reaches the
38
+ * whole shell through `var(--dsw-font-family)` plus body inheritance.
39
+ */
40
+ const FONT_STACK =
41
+ '"Segoe UI", -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif';
42
+
43
+ /**
44
+ * Warm paper palette. `light` carries the two colors the user asked for:
45
+ * canvas #F2F0E5 and ink #100F0F. Every other entry is derived so raised
46
+ * surfaces, borders and the secondary text ladder stay legible on the warm
47
+ * canvas instead of re-using the cool neutral-bluish scale.
48
+ */
49
+ const PALETTE = {
50
+ light: {
51
+ "--dsw-font-family": FONT_STACK,
52
+ "--dsw-alias-bg-base": "#F2F0E5",
53
+ "--dsw-specific-sidebar-fill": "#F2F0E5",
54
+ /* The composer input reads this token (third-party sidebar maps it to
55
+ --dcu-composer-bg), so warm-white here replaces the white input card. */
56
+ "--dsw-specific-input-major": "#FAF8F0",
57
+ "--dsw-alias-bg-layer-1": "#FAF8F0",
58
+ "--dsw-alias-bg-layer-2": "#FDFCF6",
59
+ "--dsw-alias-bg-layer-3": "#FFFFFF",
60
+ "--dsw-alias-bg-overlay": "#F7F5EC",
61
+ "--dsw-alias-bg-module-platform": "#ECE9DC",
62
+ "--dsw-alias-bg-multi-select": "#ECE9DC",
63
+ "--dsw-alias-bg-document-preview": "#ECE9DC",
64
+ "--dsw-alias-label-primary": "#100F0F",
65
+ "--dsw-alias-label-secondary": "#55524A",
66
+ "--dsw-alias-label-tertiary": "#7A756A",
67
+ "--dsw-alias-label-caption": "#8E887C",
68
+ "--dsw-alias-border-l1": "#100f0f14",
69
+ "--dsw-alias-border-l2": "#100f0f1f",
70
+ "--dsw-alias-border-l3": "#100f0f29",
71
+ "--dsw-alias-border-l4": "#100f0f33",
72
+ "--dsw-alias-interactive-bg-hover": "#100f0f0f",
73
+ "--dsw-alias-interactive-bg-active": "#100f0f1a",
74
+ "--dsw-alias-interactive-bg-hover-solid": "#E7E4D6",
75
+ "--dsw-alias-button-floating-fill": "#FAF8F0",
76
+ "--dsw-alias-button-floating-hover": "#F1EEE2",
77
+ "--dsw-alias-button-elevated-fill": "#FAF8F0",
78
+ "--dsw-alias-button-ghost-active-fill": "#ECE9DC",
79
+ "--dsw-alias-button-ghost-active-hover": "#E7E4D6",
80
+ "--dsw-alias-menu-icon": "#3A3833",
81
+ "--dsw-alias-markdown-code-block": "#EAE7DA",
82
+ "--dsw-alias-markdown-code-block-banner": "#EAE7DA",
83
+ "--dsw-alias-scrollbar-bg-l1": "#DDD9C9",
84
+ "--dsw-alias-scrollbar-bg-l2": "#DDD9C9",
85
+ "--dsw-alias-bg-skeleton": "#100f0f0f"
86
+ },
87
+ dark: {
88
+ "--dsw-font-family": FONT_STACK,
89
+ "--dsw-alias-bg-base": "#100F0F",
90
+ "--dsw-specific-sidebar-fill": "#100F0F",
91
+ "--dsw-specific-input-major": "#222120",
92
+ "--dsw-alias-bg-layer-1": "#1A1918",
93
+ "--dsw-alias-bg-layer-2": "#222120",
94
+ "--dsw-alias-bg-layer-3": "#2B2A28",
95
+ "--dsw-alias-bg-overlay": "#2B2A28",
96
+ "--dsw-alias-bg-module-platform": "#1E1D1C",
97
+ "--dsw-alias-bg-multi-select": "#1E1D1C",
98
+ "--dsw-alias-bg-document-preview": "#1E1D1C",
99
+ "--dsw-alias-label-primary": "#F2F0E5",
100
+ "--dsw-alias-label-secondary": "#C4BFB1",
101
+ "--dsw-alias-label-tertiary": "#9C978A",
102
+ "--dsw-alias-label-caption": "#837E72",
103
+ "--dsw-alias-border-l1": "#f2f0e51a",
104
+ "--dsw-alias-border-l2": "#f2f0e524",
105
+ "--dsw-alias-border-l3": "#f2f0e52e",
106
+ "--dsw-alias-border-l4": "#f2f0e538",
107
+ "--dsw-alias-interactive-bg-hover": "#f2f0e514",
108
+ "--dsw-alias-interactive-bg-active": "#f2f0e521",
109
+ "--dsw-alias-interactive-bg-hover-solid": "#2B2A28",
110
+ "--dsw-alias-button-floating-fill": "#222120",
111
+ "--dsw-alias-button-floating-hover": "#2B2A28",
112
+ "--dsw-alias-button-elevated-fill": "#222120",
113
+ "--dsw-alias-button-ghost-active-fill": "#2B2A28",
114
+ "--dsw-alias-button-ghost-active-hover": "#343230",
115
+ "--dsw-alias-menu-icon": "#D8D3C4",
116
+ "--dsw-alias-markdown-code-block": "#1A1918",
117
+ "--dsw-alias-markdown-code-block-banner": "#1A1918",
118
+ "--dsw-alias-scrollbar-bg-l1": "#3A3835",
119
+ "--dsw-alias-scrollbar-bg-l2": "#3A3835",
120
+ "--dsw-alias-bg-skeleton": "#f2f0e50f"
121
+ }
122
+ };
123
+
124
+ /**
125
+ * The same palette in the shape `theme.overrideTokens()` requires: one
126
+ * `{ light, dark }` pair per token name (a bare string throws at runtime, so
127
+ * the palette above is transposed here at module scope).
128
+ */
129
+ const PALETTE_OVERRIDE = Object.fromEntries(
130
+ Object.keys(PALETTE.light).map((name) => [name, { light: PALETTE.light[name], dark: PALETTE.dark[name] }])
131
+ );
132
+
133
+ /**
134
+ * Read the stored selection without throwing when storage is unavailable.
135
+ * @returns whether the paper theme was selected.
136
+ */
137
+ function storedActive() {
138
+ try {
139
+ return globalThis.localStorage?.getItem(STORAGE_KEY) === "1";
140
+ } catch {
141
+ return false;
142
+ }
143
+ }
144
+
145
+ /** Persist the selection; storage failures only cost durability. */
146
+ function storeActive(active) {
147
+ try {
148
+ globalThis.localStorage?.setItem(STORAGE_KEY, active ? "1" : "0");
149
+ } catch {
150
+ /* ignored */
151
+ }
152
+ }
153
+
154
+ /**
155
+ * Remember the built-in preference to restore when paper is switched off.
156
+ * @param preference - the preference in effect before the switch.
157
+ */
158
+ function storeFallback(preference) {
159
+ if (!BUILTIN_PREFERENCES.includes(preference)) return;
160
+ try {
161
+ globalThis.localStorage?.setItem(FALLBACK_KEY, preference);
162
+ } catch {
163
+ /* ignored */
164
+ }
165
+ }
166
+
167
+ /** @returns the remembered built-in preference, defaulting to `system`. */
168
+ function storedFallback() {
169
+ try {
170
+ const value = globalThis.localStorage?.getItem(FALLBACK_KEY);
171
+ return BUILTIN_PREFERENCES.includes(value) ? value : "system";
172
+ } catch {
173
+ return "system";
174
+ }
175
+ }
176
+ //#endregion
177
+
178
+ //#region lib/client/PaperRow.js
179
+ /** Row copy; the locale registration below overrides these through `t`. */
180
+ const FALLBACK_COPY = {
181
+ title: "暖纸主题",
182
+ description: "背景 #F2F0E5、前景 #100F0F 的暖色纸张配色",
183
+ on: "暖纸",
184
+ off: "原生"
185
+ };
186
+
187
+ /**
188
+ * Appearance-section row for the paper theme. Reads its state from the theme
189
+ * service snapshot (reacting to `theme/change`) and writes through the
190
+ * plugin's own selection helpers, so it never depends on the built-in
191
+ * `preference` field accepting a third-party id.
192
+ * @param props - composed slot props (`t` from the locale share, plus `read`,
193
+ * `write` and `useTheme` from this package's inject share).
194
+ * @returns the row element tree.
195
+ */
196
+ function PaperRow({ t, read, write, useTheme }) {
197
+ const theme = useTheme();
198
+ const active = theme.preference === THEME_ID;
199
+ const translate = (key) => (typeof t === "function" ? t(key) : FALLBACK_COPY[key]) ?? FALLBACK_COPY[key];
200
+
201
+ const option = (id, label) =>
202
+ react.createElement(
203
+ "button",
204
+ {
205
+ type: "button",
206
+ key: id,
207
+ onClick: () => write(id === THEME_ID),
208
+ "aria-pressed": id === THEME_ID ? active : !active,
209
+ style: {
210
+ font: "inherit",
211
+ lineHeight: "22px",
212
+ padding: "0 14px",
213
+ height: 32,
214
+ border: "1px solid #100f0f1f",
215
+ borderRadius: 8,
216
+ cursor: "pointer",
217
+ background: (id === THEME_ID) === active ? "#100f0f" : "#f2f0e5",
218
+ color: (id === THEME_ID) === active ? "#f2f0e5" : "#100f0f",
219
+ transition: "background 120ms ease, color 120ms ease"
220
+ }
221
+ },
222
+ label
223
+ );
224
+
225
+ return react_jsx_runtime.jsxs("div", {
226
+ style: {
227
+ display: "flex",
228
+ alignItems: "center",
229
+ gap: 16,
230
+ borderBottom: "0.5px solid var(--dsw-alias-border-l2, #100f0f1f)",
231
+ padding: "16px 0"
232
+ },
233
+ children: [
234
+ react_jsx_runtime.jsxs("div", {
235
+ style: { display: "flex", flexDirection: "column", gap: 4, flex: 1, minWidth: 0, paddingRight: 48 },
236
+ children: [
237
+ react_jsx_runtime.jsx("div", {
238
+ style: { color: "var(--dsw-alias-label-primary, #100f0f)", fontSize: 14, lineHeight: "22px" },
239
+ children: translate("title")
240
+ }),
241
+ react_jsx_runtime.jsx("div", {
242
+ style: { color: "var(--dsw-alias-label-tertiary, #7a756a)", fontSize: 12, lineHeight: "18px" },
243
+ children: translate("description")
244
+ })
245
+ ]
246
+ }),
247
+ react_jsx_runtime.jsx("div", {
248
+ style: { display: "inline-flex", gap: 6, alignItems: "center" },
249
+ children: [option("builtin", translate("off")), option(THEME_ID, translate("on"))]
250
+ })
251
+ ]
252
+ });
253
+ }
254
+ //#endregion
255
+
256
+ //#region lib/client/locales.js
257
+ const SETTINGS_NS = "settings.paper-warm";
258
+ const zh = {
259
+ title: "暖纸主题",
260
+ description: "背景 #F2F0E5、前景 #100F0F 的暖色纸张配色",
261
+ on: "暖纸",
262
+ off: "原生"
263
+ };
264
+ const en = {
265
+ title: "Paper warm",
266
+ description: "Warm paper palette: background #F2F0E5, foreground #100F0F",
267
+ on: "Paper",
268
+ off: "Native"
269
+ };
270
+ //#endregion
271
+
272
+ //#region lib/client/index.js
273
+ /** Services this plugin needs; `theme` is provided by `@deepseek-ai/dsh-client-ui-theme`. */
274
+ const inject = ["theme", "slots", "locale"];
275
+
276
+ /**
277
+ * Sidebar layer: warm palette for the third-party sidebar plus a guaranteed
278
+ * reopen affordance. Collapsing the left sidebar on Windows leaves a zero-width
279
+ * grid track while every reopen control lives inside that track, so the plugin
280
+ * renders its own button, shown only while the body carries
281
+ * `data-dsh-sidebar-collapsed`.
282
+ *
283
+ * Why the `--dcu-*` overrides: `@michengai/dsh-codex-ui` replaces the official
284
+ * sidebar and paints it from its own palette variables declared on `.dcu-root`
285
+ * (light `#eef7f5`, a cool teal). Overriding the first-party
286
+ * `--dsw-specific-sidebar-fill` therefore leaves that sidebar cool; the sheet
287
+ * maps its variables onto the same warm scale the theme uses.
288
+ */
289
+ const SIDEBAR_CSS = `
290
+ /* --- third-party sidebar palette: cool teal default -> warm paper --- */
291
+ :root,
292
+ :root body[data-ds-dark-theme] {
293
+ --dcu-sidebar-background: #F2F0E5 !important;
294
+ --dcu-sidebar-primary: #100F0F !important;
295
+ --dcu-sidebar-secondary: #55524A !important;
296
+ --dcu-sidebar-tertiary: #7A756A !important;
297
+ --dcu-sidebar-navigation: #3A3833 !important;
298
+ --dcu-sidebar-icon: #3A3833 !important;
299
+ --dcu-sidebar-hover: #E7E4D6 !important;
300
+ --dcu-sidebar-border: #100f0f1f !important;
301
+ --dcu-tip-bg: #FAF8F0 !important;
302
+ --dcu-tip-shadow: 0 10px 32px #100f0f29 !important;
303
+ }
304
+
305
+ /* --- its settings page reads a separate --sp-* palette --- */
306
+ :root .dcu-settings-page,
307
+ :root body[data-ds-dark-theme] .dcu-settings-page {
308
+ --sp-bg: #F2F0E5 !important;
309
+ --sp-nav: #F2F0E5 !important;
310
+ --sp-card: #FAF8F0 !important;
311
+ --sp-border: #100f0f1f !important;
312
+ --sp-text: #100F0F !important;
313
+ --sp-muted: #55524A !important;
314
+ --sp-hover: #E7E4D6 !important;
315
+ --sp-active: #DFDBCB !important;
316
+ }
317
+
318
+ /* --- the theme's own dark palette (resolved through data-ds-dark-theme) --- */
319
+ :root body[data-ds-dark-theme] {
320
+ --dcu-sidebar-background: #100F0F !important;
321
+ --dcu-sidebar-primary: #F2F0E5 !important;
322
+ --dcu-sidebar-secondary: #C4BFB1 !important;
323
+ --dcu-sidebar-tertiary: #9C978A !important;
324
+ --dcu-sidebar-navigation: #D8D3C4 !important;
325
+ --dcu-sidebar-icon: #D8D3C4 !important;
326
+ --dcu-sidebar-hover: #2B2A28 !important;
327
+ --dcu-sidebar-border: #f2f0e524 !important;
328
+ --dcu-tip-bg: #222120 !important;
329
+ --dcu-tip-shadow: 0 10px 32px #00000073 !important;
330
+ }
331
+
332
+ /*
333
+ * The sidebar also ships a "glass" variant that hard-codes its own fill
334
+ * (body[data-we-sidebar-glass] .dcu-root { background: #eef7f5 }), which no
335
+ * variable override can reach. Paint the sidebar root from the theme token
336
+ * directly; when that attribute is absent this re-asserts the same colour.
337
+ */
338
+ body .dcu-root,
339
+ body[data-we-sidebar-glass] .dcu-root {
340
+ background: var(--dsw-specific-sidebar-fill, #F2F0E5) !important;
341
+ }
342
+
343
+ body[data-ds-dark-theme] .dcu-root,
344
+ body[data-ds-dark-theme][data-we-sidebar-glass] .dcu-root {
345
+ background: #100F0F !important;
346
+ }
347
+
348
+ /*
349
+ * A third-party "glass sidebar" effect lifts the sidebar toward white with
350
+ * color-mix + a white sheen gradient on the .dcu-root::before overlay, which washes
351
+ * the warm canvas out. Neutralise it *for the warm palette only*: clearing the mix
352
+ * colour and dropping the sheen keeps the effect configured (blur/saturation still
353
+ * apply) while letting #F2F0E5 show through. Dark mode keeps the effect untouched.
354
+ */
355
+ body[data-we-sidebar-glass]:not([data-ds-dark-theme]) .dcu-root {
356
+ --we-sidebar-color: transparent !important;
357
+ --we-sidebar-sheen: 0 !important;
358
+ }
359
+
360
+ :root body[data-ds-dark-theme] .dcu-settings-page {
361
+ --sp-bg: #100F0F !important;
362
+ --sp-nav: #100F0F !important;
363
+ --sp-card: #1A1918 !important;
364
+ --sp-border: #f2f0e524 !important;
365
+ --sp-text: #F2F0E5 !important;
366
+ --sp-muted: #C4BFB1 !important;
367
+ --sp-hover: #2B2A28 !important;
368
+ --sp-active: #343230 !important;
369
+ }
370
+
371
+ /* --- reopen affordance, visible only while the sidebar is collapsed --- */
372
+ [data-paper-warm-expand] {
373
+ display: none;
374
+ position: fixed;
375
+ top: max(6px, env(safe-area-inset-top));
376
+ left: 12px;
377
+ z-index: 60;
378
+ align-items: center;
379
+ justify-content: center;
380
+ width: 28px;
381
+ height: 28px;
382
+ padding: 0;
383
+ border: 1px solid var(--dsw-alias-border-l2, #100f0f1f);
384
+ border-radius: 50%;
385
+ background: var(--dsw-alias-bg-layer-1, #faf8f0);
386
+ color: var(--dsw-alias-label-primary, #100f0f);
387
+ cursor: pointer;
388
+ box-shadow: 0 1px 3px #100f0f1f;
389
+ }
390
+ body[data-dsh-sidebar-collapsed] [data-paper-warm-expand] { display: inline-flex; }
391
+ [data-paper-warm-expand]:hover { background: var(--dsw-alias-interactive-bg-hover-solid, #e7e4d6); }
392
+ [data-paper-warm-expand]:focus-visible {
393
+ outline: var(--dsw-focus-ring-width, 2px) solid var(--dsw-alias-state-business-primary, #4176e6);
394
+ outline-offset: -2px;
395
+ }
396
+ html[data-windows-titlebar] body[data-dsh-sidebar-collapsed] button[aria-label="打开侧边栏"],
397
+ html[data-windows-titlebar] body[data-dsh-sidebar-collapsed] button[aria-label="Open sidebar"] {
398
+ position: fixed;
399
+ top: max(6px, calc((var(--dsh-windows-titlebar-height, 32px) - 28px) / 2));
400
+ left: 48px;
401
+ z-index: 60;
402
+ display: inline-flex;
403
+ align-items: center;
404
+ justify-content: center;
405
+ width: 28px;
406
+ height: 28px;
407
+ border-radius: 50%;
408
+ }
409
+ body[data-dsh-sidebar-collapsed] [data-dsh-toggle-cluster] { z-index: 60; pointer-events: auto; }
410
+ body[data-dsh-sidebar-collapsed] [data-dsh-toggle-cluster] button { pointer-events: auto; cursor: pointer; }
411
+ `;
412
+
413
+ /** Install the recovery sheet once per document. */
414
+ function installSidebarCss() {
415
+ const tagId = "dsh-theme-paper-warm/sidebar-recovery.css";
416
+ if (document.querySelector(`style[data-plugin-css="${tagId}"]`) !== null) return;
417
+ const tag = document.createElement("style");
418
+ tag.dataset.plugin = "dsh-theme-paper-warm";
419
+ tag.dataset.pluginCss = tagId;
420
+ tag.textContent = SIDEBAR_CSS;
421
+ document.head.append(tag);
422
+ }
423
+
424
+ /**
425
+ * Build the reopen button and wire its click to the most specific available
426
+ * toggle path.
427
+ * @param toggle - layout service toggle, or `undefined` when absent.
428
+ * @returns the button element.
429
+ */
430
+ function createExpandButton(toggle) {
431
+ const button = document.createElement("button");
432
+ button.type = "button";
433
+ button.dataset.paperWarmExpand = "";
434
+ /* macOS Desktop 0.2.2-rc.1+ only auto-excludes interactive controls
435
+ inside marked rows; a fixed overlay button that covers the window
436
+ drag region must declare its own no-drag rectangle, or it sits
437
+ inert over the draggable header there (upgrade guide
438
+ v0.2.2-rc.1/window-drag-regions). Inert on Windows and Web. */
439
+ button.setAttribute("data-window-drag-exclude", "");
440
+ button.setAttribute("aria-label", "打开侧边栏");
441
+ button.title = "打开侧边栏";
442
+ button.style.margin = "0";
443
+ button.innerHTML =
444
+ '<svg width="16" height="16" viewBox="0 0 16 16" aria-hidden="true" focusable="false"><rect x="1.5" y="2.5" width="13" height="11" rx="1.6" fill="none" stroke="currentColor" stroke-width="1.3"/><line x1="6" y1="2.5" x2="6" y2="13.5" stroke="currentColor" stroke-width="1.3"/></svg>';
445
+ button.addEventListener("click", (event) => {
446
+ event.preventDefault();
447
+ event.stopPropagation();
448
+ if (toggle !== undefined && typeof toggle.toggleSidebar === "function") {
449
+ toggle.toggleSidebar();
450
+ return;
451
+ }
452
+ const cluster = document.querySelector("[data-dsh-toggle-cluster] button");
453
+ if (cluster instanceof HTMLElement) {
454
+ cluster.click();
455
+ return;
456
+ }
457
+ const native = document.querySelector(
458
+ 'button[aria-label="打开侧边栏"], button[aria-label="Open sidebar"]'
459
+ );
460
+ if (native instanceof HTMLElement) native.click();
461
+ });
462
+ return button;
463
+ }
464
+
465
+ /**
466
+ * Client plugin body: register the third-party theme, restore a previous
467
+ * selection, add the row that switches it, and install the sidebar recovery
468
+ * layer.
469
+ * @param ctx - client cordis context.
470
+ */
471
+ function apply(ctx) {
472
+ const theme = ctx.theme;
473
+ if (theme === undefined) return;
474
+
475
+ /**
476
+ * Whether the stored selection is wanted. Only this package's own row
477
+ * changes it: a page load and every preference the Host settings push are
478
+ * answered by re-asserting the stored selection, never by dropping it.
479
+ */
480
+ let desired = storedActive();
481
+
482
+ /**
483
+ * Session-only override, set when the platform Appearance row is pressed
484
+ * (see the press listener below). The built-in preference the user just
485
+ * picked stays in force until the next page load; the stored selection is
486
+ * left alone, so no misread press can ever lose the theme.
487
+ */
488
+ let overridden = false;
489
+
490
+ /** Timestamp of the last press on an appearance toggle. */
491
+ let pressedAt = 0;
492
+
493
+ /** Re-assert the stored selection; a rejected restore only costs the theme. */
494
+ function assertStored() {
495
+ try {
496
+ theme.setTheme(THEME_ID);
497
+ } catch (error) {
498
+ console.warn("paper-warm: restoring the stored selection failed", error);
499
+ }
500
+ }
501
+
502
+ ctx.effect(() => {
503
+ const disposer = theme.register({ id: THEME_ID, colorScheme: "light", tokens: PALETTE.light });
504
+ if (desired) assertStored();
505
+ return () => {
506
+ if (typeof disposer === "function") disposer();
507
+ };
508
+ }, "paper-warm: theme registration");
509
+
510
+ /**
511
+ * `ThemeRuntime` provides itself on the schema default and adopts the
512
+ * durable `ui-theme` preference whenever the settings document reaches the
513
+ * browser — at boot, and again on every invalidation or reconnect. Each
514
+ * adoption publishes `theme/change` with a built-in preference and would
515
+ * otherwise silently outvote the stored selection (the theme "is gone"
516
+ * after a restart). Those pushes carry no signature worth guessing at, so
517
+ * the rule is the other way round: keep the stored selection in force, and
518
+ * let a real press on an appearance toggle end it for this session.
519
+ */
520
+ ctx.effect(
521
+ () =>
522
+ ctx.on("theme/change", (snapshot) => {
523
+ if (!desired || overridden || snapshot.preference === THEME_ID) return;
524
+ /* Both the platform Appearance cubes and this package's own row
525
+ are `aria-pressed` buttons; a press right before the change is
526
+ what makes it a choice rather than a settings push. */
527
+ if (Date.now() - pressedAt < PRESS_WINDOW_MS) {
528
+ overridden = true;
529
+ return;
530
+ }
531
+ storeFallback(snapshot.preference);
532
+ assertStored();
533
+ }),
534
+ "paper-warm: stored selection reconciliation"
535
+ );
536
+
537
+ /** Remember an appearance press, so the next change can be read as one. */
538
+ ctx.effect(() => {
539
+ const notePress = (event) => {
540
+ if (event.target?.closest?.("button[aria-pressed]") != null) pressedAt = Date.now();
541
+ };
542
+ document.addEventListener("pointerdown", notePress, true);
543
+ return () => document.removeEventListener("pointerdown", notePress, true);
544
+ }, "paper-warm: appearance presses");
545
+
546
+ /**
547
+ * Stack the palette as a token override layer while — and only while —
548
+ * the paper theme is the active preference. The registered definition
549
+ * carries one color scheme, so this layer is what keeps the warm palette
550
+ * correct when the user later switches the built-in Appearance option to
551
+ * another scheme: overrides carry a `{ light, dark }` pair and the active
552
+ * scheme picks. Without an active layer the built-in palette shows
553
+ * through, so "native" stays genuinely native.
554
+ */
555
+ ctx.effect(() => {
556
+ let remove;
557
+ const sync = (preference) => {
558
+ const active = preference === THEME_ID;
559
+ if (active && remove === undefined) remove = theme.overrideTokens("dsh-theme-paper-warm", PALETTE_OVERRIDE);
560
+ else if (!active && remove !== undefined) {
561
+ remove();
562
+ remove = undefined;
563
+ }
564
+ };
565
+ sync(theme.getTheme().preference);
566
+ const off = ctx.on("theme/change", (snapshot) => sync(snapshot.preference));
567
+ return () => {
568
+ off();
569
+ remove?.();
570
+ remove = undefined;
571
+ };
572
+ }, "paper-warm: palette override layer");
573
+
574
+ ctx.effect(
575
+ () =>
576
+ ctx.locale.register(SETTINGS_NS, {
577
+ zh,
578
+ en
579
+ }),
580
+ "paper-warm: row dictionaries"
581
+ );
582
+
583
+ /**
584
+ * Read the live theme snapshot. Called during render, so it subscribes the
585
+ * component to `theme/change` through the client runtime's hook.
586
+ * @returns the current theme snapshot.
587
+ */
588
+ const useTheme = () => {
589
+ const [snapshot, setSnapshot] = react.useState(() => theme.getTheme());
590
+ react.useEffect(() => ctx.on("theme/change", (next) => setSnapshot(next)), []);
591
+ return snapshot;
592
+ };
593
+
594
+ /** @returns whether the paper theme is the current preference. */
595
+ const read = () => theme.getTheme().preference === THEME_ID;
596
+
597
+ /**
598
+ * Switch the paper theme on or off — the package's own durable selection.
599
+ * The host settings schema cannot store a third-party id, so this package
600
+ * persists the selection itself and only falls back to a built-in
601
+ * preference when switching off.
602
+ * @param active - desired state.
603
+ */
604
+ const write = (active) => {
605
+ desired = active;
606
+ overridden = false;
607
+ if (active) {
608
+ storeFallback(theme.getTheme().preference);
609
+ storeActive(true);
610
+ theme.setTheme(THEME_ID);
611
+ return;
612
+ }
613
+ storeActive(false);
614
+ theme.setTheme(storedFallback());
615
+ };
616
+
617
+ ctx.slots.inject("settings.general.item", () =>
618
+ ctx.slots.register(
619
+ {
620
+ name: "settings.general.item",
621
+ id: "paper-warm",
622
+ order: 12,
623
+ locale: SETTINGS_NS,
624
+ inject: () => ({ read, write, useTheme })
625
+ },
626
+ PaperRow
627
+ )
628
+ );
629
+
630
+ /*
631
+ * Sidebar recovery. The sheet is document-global (it does not depend on
632
+ * the theme being selected), and the button is mounted on every page the
633
+ * plugin runs on, so a closed sidebar always has a visible way back.
634
+ */
635
+ installSidebarCss();
636
+ ctx.inject(["layout"], (layoutCtx) => {
637
+ const button = createExpandButton(layoutCtx.layout);
638
+ document.body.append(button);
639
+ layoutCtx.effect(() => () => button.remove(), "paper-warm: sidebar expand button");
640
+ });
641
+ }
642
+ //#endregion
643
+
644
+ exports.SETTINGS_NS = SETTINGS_NS;
645
+ exports.THEME_ID = THEME_ID;
646
+ exports.apply = apply;
647
+ exports.inject = inject;
648
+ return module.exports;
649
+ }
650
+ });
package/lib/index.mjs ADDED
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Host half of `dsh-theme-paper-warm`.
3
+ *
4
+ * All behaviour lives in the client half (`./client`), which registers the
5
+ * `paper-warm` theme through `ctx.theme` and adds its row to the Appearance
6
+ * section. This half only exists so the package is a resolvable Loader entry:
7
+ * the client module system discovers a browser bundle from a loaded entry that
8
+ * declares `dsh.client`, so an entry with no host behaviour is still required.
9
+ *
10
+ * @module dsh-theme-paper-warm
11
+ */
12
+
13
+ /** No host-side services are required. */
14
+ export const inject = [];
15
+
16
+ /** Host body: intentionally empty. */
17
+ export function apply() {}
18
+
19
+ export default { inject, apply };
package/locale/en.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "Paper warm theme",
4
+ "description": "Eye-care warm paper palette (canvas #F2F0E5, ink #100F0F) with a toggle row in Settings → General."
5
+ }
6
+ }
package/locale/zh.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "护眼暖纸主题",
4
+ "description": "护眼暖纸主题:背景 #F2F0E5、正文 #100F0F 的暖色纸张配色,在「设置 → 通用」提供开关行。"
5
+ }
6
+ }
package/package.json CHANGED
@@ -1,6 +1,70 @@
1
1
  {
2
2
  "name": "dsh-theme-paper-warm",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.1",
4
+ "description": "Eye-care warm paper theme (护眼暖纸主题) for the DeepSeek Harness Web GUI: canvas #F2F0E5, ink #100F0F, registered as a selectable third-party theme with a Settings → General toggle row.",
5
+ "type": "module",
6
+ "main": "lib/index.mjs",
7
+ "exports": {
8
+ ".": {
9
+ "default": "./lib/index.mjs"
10
+ },
11
+ "./client": {
12
+ "default": "./lib/client.js"
13
+ },
14
+ "./locale/*.json": "./locale/*.json",
15
+ "./icon": "./icon.svg",
16
+ "./package.json": "./package.json"
17
+ },
18
+ "files": [
19
+ "lib",
20
+ "locale",
21
+ "cordis.patch.yml",
22
+ "icon.svg",
23
+ "README.md",
24
+ "LICENSE"
25
+ ],
26
+ "icon": "icon.svg",
27
+ "keywords": [
28
+ "deepseek",
29
+ "deepseek-harness",
30
+ "dsh",
31
+ "dsh-plugin",
32
+ "theme",
33
+ "skin",
34
+ "warm",
35
+ "paper",
36
+ "eye-care",
37
+ "eye-friendly",
38
+ "护眼",
39
+ "暖纸",
40
+ "cordis"
41
+ ],
42
+ "license": "MIT",
43
+ "engines": {
44
+ "dsh": ">=0.2.1-rc.2 <0.2.2-0 || >=0.2.2-rc.1 <0.3.0-0"
45
+ },
46
+ "repository": {
47
+ "type": "git",
48
+ "url": "git+https://github.com/factyy163/dsh-theme-paper-warm.git"
49
+ },
50
+ "homepage": "https://github.com/factyy163/dsh-theme-paper-warm#readme",
51
+ "bugs": {
52
+ "url": "https://github.com/factyy163/dsh-theme-paper-warm/issues"
53
+ },
54
+ "dsh": {
55
+ "bundle": {
56
+ "patch": "./cordis.patch.yml"
57
+ },
58
+ "client": {
59
+ "inject": [
60
+ "@deepseek-ai/dsh-client-runtime",
61
+ "@deepseek-ai/dsh-client-ui-layout",
62
+ "@deepseek-ai/dsh-client-ui-theme",
63
+ "@deepseek-ai/dsh-client-ui-slots",
64
+ "@deepseek-ai/dsh-client-ui-settings",
65
+ "@deepseek-ai/dsh-client-locale"
66
+ ],
67
+ "platform": "web"
68
+ }
69
+ }
6
70
  }