dsh-cyrene-theme-change 0.11.0 → 0.11.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.
Files changed (2) hide show
  1. package/lib/client.js +55 -80
  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:
@@ -918,9 +918,10 @@ body[data-dsh-cyrene][data-cyrene-glass="heavy"] .cyre-page::before{
918
918
  border-radius:inherit;
919
919
  z-index:-1;
920
920
  background:linear-gradient(135deg,rgba(255,255,255,.34),rgba(255,255,255,.10) 52%,rgba(255,255,255,.28));
921
- backdrop-filter:blur(10px) saturate(175%);
922
- -webkit-backdrop-filter:blur(10px) saturate(175%);
923
- filter:url(#cyrene-theme-change-liquid);
921
+ /* 关键:SVG 滤镜放进 backdrop-filter,而不是给元素加 filter。
922
+ 给元素加 filter 会把文字一起扭曲;放进 backdrop-filter 只扭"背后"。 */
923
+ backdrop-filter:url(#cyrene-theme-change-liquid) blur(6px) saturate(150%);
924
+ -webkit-backdrop-filter:url(#cyrene-theme-change-liquid) blur(6px) saturate(150%);
924
925
  box-shadow:
925
926
  inset 0 1px 0 rgba(255,255,255,.85),
926
927
  inset 0 -1px 0 rgba(255,255,255,.30),
@@ -1404,84 +1405,56 @@ body[data-dsh-cyrene] [data-composer-input][data-placeholder^="Describe what you
1404
1405
  }
1405
1406
 
1406
1407
  /** 主题开关落到 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
- ]
1408
+ // ⚠️ 曾经试过用 ctx.theme.overrideTokens 做玻璃(dsh-liquid-glass 的路子),
1409
+ // 但本插件早有一套写死在本文件里的 --dsw-* 覆盖,选择器在 body[...] 上,
1410
+ // 优先级高于主题服务在 :root 写的值——结果服务覆写根本没生效。
1411
+ // 现在统一成本文件里的 CSS 变量 + --cyre-glass-a 滑块,只保留一条路。
1425
1412
  /**
1426
- * 真·液态玻璃的滤镜定义:feTurbulence 造噪声 → 高斯柔化 → feDisplacementMap
1427
- * 按噪声把「背后」的像素推开,于是边缘出现折射起伏。
1428
- * 关键点:滤镜必须挂在 ::before 上(它只承载 backdrop-filter),不能挂在
1429
- * 元素本身——否则文字会一起被扭(这是所有 liquid-glass 实现的共同注意点)。
1413
+ * 真·液态玻璃的折射滤镜。
1414
+ *
1415
+ * 技术点全部来自 dsh-plugin-liquid-glass(神猫君,MIT)的实测参数:
1416
+ * · feTurbulence baseFrequency 0.006 / 0.010、numOctaves 2 —— 频率再高就变成"水波抖";
1417
+ * · feDisplacementMap scale 26,R/G 通道取位移;
1418
+ * · 滤镜区域放到 124%,否则边缘会被裁掉一圈;
1419
+ * · 每 120ms 微微漂移一次噪声频率,让折射"活着",慢到不抢注意力。
1420
+ *
1421
+ * 用法上和它一致:SVG 滤镜塞进 `backdrop-filter: url(#id)`,**不是**给元素加 filter
1422
+ * (那样文字会一起扭)。只作用于本插件自己的 .cyre-* 面,不碰 shell 槽位。
1423
+ *
1424
+ * 尊重 prefers-reduced-motion:会晕的人不该被强制看动效。
1430
1425
  */
1431
1426
  const LIQUID_ID = PACKAGE_ID + "-liquid"
1427
+ let liquidDrift = null
1432
1428
  function ensureLiquidFilter() {
1433
1429
  if (typeof document.getElementById === "function" && document.getElementById(LIQUID_ID) !== null) return
1434
- if (typeof document.createElement !== "function") return
1430
+ if (typeof document.createElementNS !== "function") return
1435
1431
  const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg")
1436
1432
  svg.setAttribute("id", LIQUID_ID + "-holder")
1437
1433
  svg.setAttribute("width", "0")
1438
1434
  svg.setAttribute("height", "0")
1439
1435
  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"'
1436
+ svg.style.cssText = "position:absolute;width:0;height:0;overflow:hidden;pointer-events:none"
1437
+ svg.innerHTML = '<filter id="' + LIQUID_ID + '" x="-12%" y="-12%" width="124%" height="124%"'
1438
+ + ' color-interpolation-filters="sRGB">'
1439
+ + '<feTurbulence type="fractalNoise" baseFrequency="0.006 0.010" numOctaves="2" seed="7" result="noise"></feTurbulence>'
1440
+ + '<feDisplacementMap in="SourceGraphic" in2="noise" scale="26"'
1445
1441
  + ' xChannelSelector="R" yChannelSelector="G"></feDisplacementMap>'
1446
1442
  + "</filter>"
1447
1443
  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
- }
1444
+ let reduced = false
1445
+ try { reduced = window.matchMedia("(prefers-reduced-motion: reduce)").matches } catch { reduced = false }
1446
+ if (reduced || liquidDrift !== null) return
1447
+ const turb = typeof svg.querySelector === "function" ? svg.querySelector("feTurbulence") : null
1448
+ if (turb === null) return
1449
+ let phase = 0
1450
+ liquidDrift = setInterval(() => {
1451
+ phase += 0.006
1452
+ try {
1453
+ turb.setAttribute("baseFrequency",
1454
+ (0.006 + Math.sin(phase) * 0.0012).toFixed(5) + " "
1455
+ + (0.010 + Math.cos(phase * 0.8) * 0.0016).toFixed(5))
1456
+ } catch { /* 元素已被回收 */ }
1457
+ }, 120)
1485
1458
  }
1486
1459
 
1487
1460
  function applySkin() {
@@ -1491,8 +1464,10 @@ body[data-dsh-cyrene] [data-composer-input][data-placeholder^="Describe what you
1491
1464
  if (state.theme === true && state.glassHeavy === true) ensureLiquidFilter();
1492
1465
  const size = Number.isFinite(state.stickerSize) ? Math.round(state.stickerSize) : 96;
1493
1466
  document.body.style.setProperty("--cyre-sticker-size", size + "px");
1467
+ // 液态玻璃的不透明度:0.25(很透)→ 0.95(几乎不透明)
1468
+ const alpha = Number.isFinite(state.glassAlpha) ? Math.min(0.95, Math.max(0.25, state.glassAlpha)) : 0.55;
1469
+ document.body.style.setProperty("--cyre-glass-a", String(alpha));
1494
1470
  applyBackground();
1495
- applyGlass();
1496
1471
  }
1497
1472
 
1498
1473
  /** 把设置页里点选的文件读成 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.2",
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",