dsh-theme-palette 1.8.0 → 1.8.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.
Files changed (3) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/client.js +51 -12
  3. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -4,6 +4,19 @@
4
4
 
5
5
  ## 版本一览
6
6
 
7
+ ### 1.8.1
8
+ Markdown 配色丰富化(非加色相,而是加层级 + 修代码块底):
9
+
10
+ - **标题三档**:h1/h2 → h3/h4 → h5/h6 由强到弱(`--dshtp-md-h1/h2/h3`),不再六级同色;
11
+ 层级按**着色强度**区分,字号仍由宿主决定
12
+ - **引用 / 表格 / 分割线 / 列表**:引用淡底 + 左侧强调边、表头淡底、表格边框与分割线跟随语义 token、列表标记用三级文字色
13
+ - **修代码块双层底**:宿主 `<pre>` 背景来自 `--shiki-background → --dsw-alias-markdown-code-block`(bluish-50/900),
14
+ 此前只染 `.md-code-block` 外层,内层仍是宿主中性色;现在直接覆盖该 token(含 banner),两层同色
15
+ - **新增断言**:标题三档互异、正文/代码块底 ≥4.5、正文/引用底 ≥4.5、次级/表头底 ≥5.5、
16
+ `<pre>` 底色与代码块一致、`md=off` 时全部继承;契约测试补 `--dsw-alias-markdown-code-block`
17
+ - **未做**:语法高亮(`--shiki-token-*`)跟随配色。宿主构建里这 9 个变量只定义、无消费者,
18
+ 需先在 GUI 实测渲染器是吃变量还是内联色,再决定方案——不在未验证的情况下强改
19
+
7
20
  ### 1.8.0
8
21
  依据 [竞品调研](../../_audit-theme-palette-20261023/竞品调研-2026-10-23.md) 的差距反哺:把工程严谨变成可见、可分享、可验证的东西(不改求解器)。
9
22
 
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.8.0'
30
+ const PLUGIN_VERSION = '1.8.1'
31
31
  const STORE_KEY = 'dsh-theme-palette.v1'
32
32
  const OVERRIDE_SOURCE = 'dsh-theme-palette'
33
33
 
@@ -870,37 +870,67 @@ window.__ModuleLoader__.load({
870
870
  ? 'var(--dsw-alias-bg-base)'
871
871
  : 'var(--dsw-specific-sidebar-fill)'
872
872
  pairs['--dshtp-rightbar-fill'] = { light: rightbarFill, dark: rightbarFill }
873
- // Markdown 强调色:标题 = 正文色混 40% 强调色;加粗 = 混 20%(比标题弱一档)
873
+ // Markdown 强调色:标题分三档(h1/h2 → h3/h4 → h5/h6),加粗比标题再弱一档。
874
+ // 分档而不是给六级标题六种色:长文靠层级扫读,不靠色相数量。
874
875
  if (params.tinted) {
876
+ const tintText = (hex, accentHex, extraChroma, lift) => {
877
+ const [L, C] = toOklch(hex)
878
+ const acc = toOklch(accentHex)
879
+ return fromOklch(clamp(L + lift, 0.05, 0.97), C + acc[1] * extraChroma, acc[2])
880
+ }
875
881
  if (mdMode === 'off') {
876
882
  const inherit = { light: 'inherit', dark: 'inherit' }
877
- pairs['--dshtp-md-heading'] = inherit
878
- pairs['--dshtp-md-strong'] = inherit
883
+ for (const k of ['--dshtp-md-h1', '--dshtp-md-h2', '--dshtp-md-h3', '--dshtp-md-strong',
884
+ '--dshtp-md-quote-fill', '--dshtp-md-quote-border', '--dshtp-md-table-head']) pairs[k] = inherit
879
885
  } else {
880
886
  // 加粗:只加色度、不动明度 —— 混色会把正文调亮(浅色下反而比正文更弱)。
881
887
  // 标题:再往中间推一点明度(浅色提亮 / 深色压暗),配合更大的字号拉开层级。
882
- const tintText = (hex, accentHex, extraChroma, lift) => {
883
- const [L, C] = toOklch(hex)
884
- const acc = toOklch(accentHex)
885
- return fromOklch(clamp(L + lift, 0.05, 0.97), C + acc[1] * extraChroma, acc[2])
886
- }
887
- pairs['--dshtp-md-heading'] = {
888
+ pairs['--dshtp-md-h1'] = {
888
889
  light: tintText(ramps.bluish['1000'], ramps.deepseek['500'], 0.45, 0.065),
889
890
  dark: tintText(ramps.bluish['50'], ramps.deepseek['400'], 0.40, -0.030),
890
891
  }
892
+ pairs['--dshtp-md-h2'] = {
893
+ light: tintText(ramps.bluish['1000'], ramps.deepseek['500'], 0.38, 0.035),
894
+ dark: tintText(ramps.bluish['50'], ramps.deepseek['400'], 0.36, -0.018),
895
+ }
896
+ pairs['--dshtp-md-h3'] = {
897
+ light: tintText(ramps.bluish['1000'], ramps.deepseek['500'], 0.30, 0.015),
898
+ dark: tintText(ramps.bluish['50'], ramps.deepseek['400'], 0.28, -0.008),
899
+ }
891
900
  pairs['--dshtp-md-strong'] = {
892
901
  light: tintText(ramps.bluish['1000'], ramps.deepseek['500'], 0.32, 0.012),
893
902
  dark: tintText(ramps.bluish['50'], ramps.deepseek['400'], 0.32, -0.010),
894
903
  }
904
+ // 引用 / 表头:只掺 4–7% 强调色,主文字在这些面上仍要走"不降级"的对比度断言
905
+ pairs['--dshtp-md-quote-fill'] = {
906
+ light: mixHex(ramps.deepseek['500'], ramps.bluish['00'], 0.04),
907
+ dark: mixHex(ramps.deepseek['400'], ramps.bluish['950'], 0.06),
908
+ }
909
+ pairs['--dshtp-md-quote-border'] = {
910
+ light: mixHex(ramps.deepseek['500'], ramps.bluish['150'], 0.55),
911
+ dark: mixHex(ramps.deepseek['400'], ramps.bluish['800'], 0.55),
912
+ }
913
+ pairs['--dshtp-md-table-head'] = {
914
+ light: mixHex(ramps.deepseek['500'], ramps.bluish['60'], 0.05),
915
+ dark: mixHex(ramps.deepseek['400'], ramps.bluish['850'], 0.07),
916
+ }
895
917
  }
896
918
  }
897
919
  // 代码块底色:宿主用 bg-layer-1,浅色下与画布同色(都指 00)→ 看不出边界。
898
920
  // 这里给它一档独立的"内嵌面板"色:卡层色 + 少量强调色相,保证与画布有可辨差。
899
921
  // mixHex(a, b, w) = a*w + b*(1-w):a 是要掺进去的颜色,b 是底色。
900
- pairs['--dshtp-code-fill'] = {
922
+ const codeFill = {
901
923
  light: mixHex(ramps.deepseek['500'], ramps.bluish['60'], 0.08),
902
924
  dark: mixHex(ramps.deepseek['400'], ramps.bluish['875'], 0.10),
903
925
  }
926
+ pairs['--dshtp-code-fill'] = codeFill
927
+ // 宿主的 <pre> 背景来自 --shiki-background → --dsw-alias-markdown-code-block(bluish-50/900)。
928
+ // 不覆盖它就会出现"外层 div 染了、内层 pre 没染"的双层底;直接改这个 token 才是根治。
929
+ pairs['--dsw-alias-markdown-code-block'] = codeFill
930
+ pairs['--dsw-alias-markdown-code-block-banner'] = {
931
+ light: mixHex(ramps.deepseek['500'], ramps.bluish['50'], 0.06),
932
+ dark: mixHex(ramps.deepseek['400'], ramps.bluish['850'], 0.08),
933
+ }
904
934
  pairs['--dshtp-code-inline'] = {
905
935
  light: mixHex(ramps.deepseek['500'], ramps.bluish['50'], 0.05),
906
936
  dark: mixHex(ramps.deepseek['400'], ramps.bluish['900'], 0.07),
@@ -958,8 +988,17 @@ window.__ModuleLoader__.load({
958
988
  '[data-rightbar-fullscreen] [data-rightbar-col]{background:var(--dsw-alias-bg-base)}',
959
989
  // Markdown 标题/加粗:容器类是 CSS Modules 的 `_markdown_<hash>_<n>`,
960
990
  // 用「类名里含 _markdown_」做钩子(局部名稳定,比整串哈希耐版本)。
961
- '[class*="_markdown_"] :where(h1,h2,h3,h4,h5,h6){color:var(--dshtp-md-heading,inherit)}',
991
+ // 三级层次:h1/h2 最重、h3/h4 次之、h5/h6 最轻(不是六级六色)。
992
+ '[class*="_markdown_"] :where(h1,h2){color:var(--dshtp-md-h1,inherit)}',
993
+ '[class*="_markdown_"] :where(h3,h4){color:var(--dshtp-md-h2,inherit)}',
994
+ '[class*="_markdown_"] :where(h5,h6){color:var(--dshtp-md-h3,inherit)}',
962
995
  '[class*="_markdown_"] strong{color:var(--dshtp-md-strong,inherit)}',
996
+ // 引用 / 表格 / 分割线 / 列表:只动"结构性"颜色,不碰正文
997
+ '[class*="_markdown_"] blockquote{background:var(--dshtp-md-quote-fill,transparent);border-left:3px solid var(--dshtp-md-quote-border,currentColor)}',
998
+ '[class*="_markdown_"] table th{background:var(--dshtp-md-table-head,transparent)}',
999
+ '[class*="_markdown_"] :where(table th,table td){border-color:var(--dsw-alias-border-l2)}',
1000
+ '[class*="_markdown_"] hr{border:0;border-top:.5px solid var(--dsw-alias-border-l3)}',
1001
+ '[class*="_markdown_"] li::marker{color:var(--dsw-alias-label-tertiary)}',
963
1002
  // 代码块:宿主把底色写在 CSS Modules 的 .block 上(浅色与画布同为 00,看不出边界)。
964
1003
  // 这里以 `.md-code-block` 提高一级特异性覆盖,不需要 !important。
965
1004
  '[class*="_markdown_"] .md-code-block{background:var(--dshtp-code-fill,inherit)}',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-theme-palette",
3
- "version": "1.8.0",
3
+ "version": "1.8.1",
4
4
  "description": "DSH 主题配色:4 套配色 × 明暗两模式,OKLCH 色域安全重建 + 真实承载面对比度求解,可调强度与面板表面。",
5
5
  "type": "module",
6
6
  "main": "index.js",