dsh-cyrene-theme-change 0.11.0 → 0.11.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 (2) hide show
  1. package/lib/client.js +18 -92
  2. package/package.json +1 -1
package/lib/client.js CHANGED
@@ -164,7 +164,7 @@ body[data-dsh-cyrene][data-cyrene-skin="on"]{
164
164
  --dsw-alias-label-primary-inverted:#fff8fc;
165
165
  --dsw-alias-label-secondary:#87627a;
166
166
  --dsw-alias-label-tertiary:#826477;
167
- --dsw-alias-markdown-code-block:rgba(255,255,255,.62);
167
+ --dsw-alias-markdown-code-block:rgba(255,255,255,var(--cyre-glass-a,.62));
168
168
  --dsw-alias-menu-group-header-fill:rgba(255,236,246,.85);
169
169
  --dsw-alias-scrollbar-bg-l2:rgba(239,107,168,.18);
170
170
  --dsw-alias-scrollbar-hover-l2:rgba(239,107,168,.36);
@@ -177,11 +177,11 @@ body[data-dsh-cyrene][data-cyrene-skin="on"]{
177
177
  --dsw-alias-state-warn-label:#9a5f27;
178
178
  --dsw-alias-state-warn-tertiary:#fdeee0;
179
179
  --dsw-alias-tooltip-bg:rgba(74,43,63,.94);
180
- --dsw-specific-bubble:rgba(255,255,255,.55);
181
- --dsw-specific-input-major:rgba(255,255,255,.72);
180
+ --dsw-specific-bubble:rgba(255,255,255,var(--cyre-glass-a,.55));
181
+ --dsw-specific-input-major:rgba(255,255,255,var(--cyre-glass-a,.72));
182
182
  --dsw-specific-menu:rgba(255,250,253,.95);
183
183
  --dsw-specific-selector:rgba(255,255,255,.8);
184
- --dsw-specific-sidebar-fill:rgba(255,241,248,.55);
184
+ --dsw-specific-sidebar-fill:rgba(255,241,248,var(--cyre-glass-a,.55));
185
185
  --dsw-specific-sidebar-nav-item-active-accent:rgba(239,107,168,.16);
186
186
  --dsw-static-neutral-bluish-00:#fdf6fa;
187
187
  --dsw-shadow-lv2:0 18px 48px rgba(214,96,160,.16), 0 2px 8px rgba(214,96,160,.1);
@@ -224,7 +224,7 @@ body[data-dsh-cyrene][data-cyrene-skin="on"][data-ds-dark-theme]{
224
224
  --dsw-alias-label-primary-inverted:#2a1622;
225
225
  --dsw-alias-label-secondary:#cfa8bd;
226
226
  --dsw-alias-label-tertiary:#b08fa2;
227
- --dsw-alias-markdown-code-block:rgba(30,20,28,.6);
227
+ --dsw-alias-markdown-code-block:rgba(30,20,28,var(--cyre-glass-a,.6));
228
228
  --dsw-alias-menu-group-header-fill:rgba(60,36,54,.9);
229
229
  --dsw-alias-scrollbar-bg-l2:rgba(247,166,205,.18);
230
230
  --dsw-alias-scrollbar-hover-l2:rgba(247,166,205,.38);
@@ -241,11 +241,11 @@ body[data-dsh-cyrene][data-cyrene-skin="on"][data-ds-dark-theme]{
241
241
  所以这两种"小浮层"在深色下改成浅底:字仍然是那个深色,对比度约 13:1。 */
242
242
  --dsw-alias-tooltip-bg:rgba(255,246,251,.97);
243
243
  --dsw-alias-toast-bg:rgba(255,246,251,.97);
244
- --dsw-specific-bubble:rgba(58,36,52,.5);
245
- --dsw-specific-input-major:rgba(54,34,50,.75);
244
+ --dsw-specific-bubble:rgba(58,36,52,var(--cyre-glass-a,.5));
245
+ --dsw-specific-input-major:rgba(54,34,50,var(--cyre-glass-a,.75));
246
246
  --dsw-specific-menu:rgba(40,26,38,.96);
247
247
  --dsw-specific-selector:rgba(52,32,48,.85);
248
- --dsw-specific-sidebar-fill:rgba(46,28,44,.58);
248
+ --dsw-specific-sidebar-fill:rgba(46,28,44,var(--cyre-glass-a,.58));
249
249
  --dsw-specific-sidebar-nav-item-active-accent:rgba(247,166,205,.18);
250
250
  --dsw-static-neutral-bluish-00:#2a1a26;
251
251
  --dsw-shadow-lv2:0 20px 52px rgba(0,0,0,.45), 0 2px 10px rgba(0,0,0,.35);
@@ -359,10 +359,10 @@ body[data-dsh-cyrene][data-cyrene-skin="on"][data-ds-dark-theme] .cyre-bg-veil{
359
359
  气泡 position:fixed 的 Tooltip)是这一层的后代,一旦它成为 fixed 后代的
360
360
  包含块,鼠标停在发送键上时界面就会闪。 */
361
361
  body[data-dsh-cyrene][data-cyrene-skin="on"][data-cyre-bg="on"]{
362
- --dsw-specific-bubble:rgba(255,255,255,.78);
362
+ --dsw-specific-bubble:rgba(255,255,255,var(--cyre-glass-a,.78));
363
363
  }
364
364
  body[data-dsh-cyrene][data-cyrene-skin="on"][data-cyre-bg="on"][data-ds-dark-theme]{
365
- --dsw-specific-bubble:rgba(66,44,62,.76);
365
+ --dsw-specific-bubble:rgba(66,44,62,var(--cyre-glass-a,.76));
366
366
  }
367
367
  body[data-dsh-cyrene][data-cyrene-skin="on"][data-cyre-bg="on"] [data-conversation-scroll] :is(p,li,h1,h2,h3,h4,h5,h6,blockquote,td,th){
368
368
  text-shadow:0 1px 2px rgba(255,255,255,.9), 0 0 10px rgba(255,250,253,.72);
@@ -870,7 +870,7 @@ body[data-dsh-cyrene][data-ds-dark-theme]{
870
870
  参考 dsh-liquid-glass 的实测结论:backdrop-filter 会创建 containing block,
871
871
  把设置弹窗和浮层搞坏(他们踩过,我们之前给 shell.overlay 加模糊也糊过整窗)。
872
872
  所以这里的"玻璃"靠两件事:
873
- 1. 把 DSH 的面色 token 换成半透明(JS 里用 ctx.theme.overrideTokens);
873
+ 1. 把 DSH 的面色 token 换成半透明——本文件里那组 --dsw-* 覆盖,
874
874
  2. 结构层只加内高光和细白边,让边缘有"玻璃厚度",不加任何模糊。 */
875
875
  body[data-dsh-cyrene][data-cyrene-skin="on"] [data-chat-flow] [class*="bubble"]{
876
876
  box-shadow:
@@ -1404,86 +1404,10 @@ body[data-dsh-cyrene] [data-composer-input][data-placeholder^="Describe what you
1404
1404
  }
1405
1405
 
1406
1406
  /** 主题开关落到 body 属性上;样式表只认 on。贴图大小与色纱浓度落到 CSS 变量上。 */
1407
- // ── 液态玻璃:走宿主自己的 token 覆盖服务 ────────────────────────
1408
- // 参考 dsh-liquid-glass 的做法:用 ctx.theme.overrideTokens(source, tokens)
1409
- // 把「面」的 token 换成半透明,而不是自己写一堆 --dsw-* 变量去和主题打架。
1410
- // token 必须给 { light, dark } 成对,否则切深色时会变得没法看。
1411
- // 宿主没有这个服务(老版本)时静默跳过——CSS 那边还有一层兜底的高光。
1412
- const GLASS_SOURCE = PACKAGE_ID + ": glass"
1413
- const GLASS_TOKENS = [
1414
- "--dsw-alias-bg-base",
1415
- "--dsw-alias-bg-layer-1",
1416
- "--dsw-alias-bg-layer-2",
1417
- "--dsw-alias-bg-layer-3",
1418
- "--dsw-alias-bg-overlay",
1419
- "--dsw-specific-sidebar-fill",
1420
- "--dsw-specific-bubble",
1421
- "--dsw-specific-input-major",
1422
- "--dsw-alias-markdown-code-block",
1423
- "--dsw-alias-markdown-inline-code",
1424
- ]
1425
- /**
1426
- * 真·液态玻璃的滤镜定义:feTurbulence 造噪声 → 高斯柔化 → feDisplacementMap
1427
- * 按噪声把「背后」的像素推开,于是边缘出现折射起伏。
1428
- * 关键点:滤镜必须挂在 ::before 上(它只承载 backdrop-filter),不能挂在
1429
- * 元素本身——否则文字会一起被扭(这是所有 liquid-glass 实现的共同注意点)。
1430
- */
1431
- const LIQUID_ID = PACKAGE_ID + "-liquid"
1432
- function ensureLiquidFilter() {
1433
- if (typeof document.getElementById === "function" && document.getElementById(LIQUID_ID) !== null) return
1434
- if (typeof document.createElement !== "function") return
1435
- const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg")
1436
- svg.setAttribute("id", LIQUID_ID + "-holder")
1437
- svg.setAttribute("width", "0")
1438
- svg.setAttribute("height", "0")
1439
- svg.setAttribute("aria-hidden", "true")
1440
- svg.style.position = "absolute"
1441
- svg.innerHTML = '<filter id="' + LIQUID_ID + '" x="0" y="0" width="100%" height="100%">'
1442
- + '<feTurbulence type="fractalNoise" baseFrequency="0.009 0.009" numOctaves="2" seed="7" result="noise"></feTurbulence>'
1443
- + '<feGaussianBlur in="noise" stdDeviation="1.6" result="soft"></feGaussianBlur>'
1444
- + '<feDisplacementMap in="SourceGraphic" in2="soft" scale="24"'
1445
- + ' xChannelSelector="R" yChannelSelector="G"></feDisplacementMap>'
1446
- + "</filter>"
1447
- document.body.appendChild(svg)
1448
- }
1449
-
1450
- const GLASS_LIGHT = "#ffffff"
1451
- const GLASS_DARK = "#151517"
1452
- let disposeGlass = null
1453
-
1454
- function rgbaOf(hex, alpha) {
1455
- const value = String(hex).replace("#", "")
1456
- const n = Number.parseInt(value.length === 3
1457
- ? value.split("").map((c) => c + c).join("")
1458
- : value, 16)
1459
- const r = (n >> 16) & 255
1460
- const g = (n >> 8) & 255
1461
- const b = n & 255
1462
- return "rgba(" + r + "," + g + "," + b + "," + alpha + ")"
1463
- }
1464
-
1465
- function applyGlass() {
1466
- if (disposeGlass !== null) {
1467
- try { disposeGlass() } catch { /* 已随 fiber 回收 */ }
1468
- disposeGlass = null
1469
- }
1470
- const theme = hostCtx === null ? null : hostCtx.theme
1471
- if (theme === null || theme === undefined || typeof theme.overrideTokens !== "function") return
1472
- if (state.theme !== true) return
1473
- // 代码块要比其他面更实一点,否则深色代码看不清。
1474
- const alpha = Number.isFinite(state.glassAlpha) ? Math.min(0.95, Math.max(0.25, state.glassAlpha)) : 0.55
1475
- const tokens = {}
1476
- for (const key of GLASS_TOKENS) {
1477
- const a = key.indexOf("markdown") >= 0 ? Math.max(alpha, 0.7) : alpha
1478
- tokens[key] = { light: rgbaOf(GLASS_LIGHT, a), dark: rgbaOf(GLASS_DARK, a) }
1479
- }
1480
- try {
1481
- disposeGlass = theme.overrideTokens(GLASS_SOURCE, tokens)
1482
- } catch (error) {
1483
- log("warn", "液态玻璃 token 覆盖失败(宿主不认这组 key,已跳过)", error)
1484
- }
1485
- }
1486
-
1407
+ // ⚠️ 曾经试过用 ctx.theme.overrideTokens 做玻璃(dsh-liquid-glass 的路子),
1408
+ // 但本插件早有一套写死在本文件里的 --dsw-* 覆盖,选择器在 body[...] 上,
1409
+ // 优先级高于主题服务在 :root 写的值——结果服务覆写根本没生效。
1410
+ // 现在统一成本文件里的 CSS 变量 + --cyre-glass-a 滑块,只保留一条路。
1487
1411
  function applySkin() {
1488
1412
  if (!document.body) return;
1489
1413
  document.body.setAttribute(SKIN_ATTR, state.theme ? "on" : "off");
@@ -1491,8 +1415,10 @@ body[data-dsh-cyrene] [data-composer-input][data-placeholder^="Describe what you
1491
1415
  if (state.theme === true && state.glassHeavy === true) ensureLiquidFilter();
1492
1416
  const size = Number.isFinite(state.stickerSize) ? Math.round(state.stickerSize) : 96;
1493
1417
  document.body.style.setProperty("--cyre-sticker-size", size + "px");
1418
+ // 液态玻璃的不透明度:0.25(很透)→ 0.95(几乎不透明)
1419
+ const alpha = Number.isFinite(state.glassAlpha) ? Math.min(0.95, Math.max(0.25, state.glassAlpha)) : 0.55;
1420
+ document.body.style.setProperty("--cyre-glass-a", String(alpha));
1494
1421
  applyBackground();
1495
- applyGlass();
1496
1422
  }
1497
1423
 
1498
1424
  /** 把设置页里点选的文件读成 data URL(FileReader 在渲染进程里是同步可用的)。 */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-cyrene-theme-change",
3
- "version": "0.11.0",
3
+ "version": "0.11.1",
4
4
  "description": "昔涟(Cyrene)主题:粉白渐变毛玻璃 UI + 侧边栏可编辑的人格设定 + 表情包 / 背景图 / 世界书 + 认知记忆(L0/L1/L2 分层、成色衰减、语义召回、账本与健康行、压缩反思)与关系情绪 | A Cyrene (Honkai: Star Rail) theme for DeepSeek Harness",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",