dsh-cyrene-theme-change 0.11.1 → 0.11.3

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/NOTICE CHANGED
@@ -26,6 +26,19 @@ SPDX-License-Identifier: MIT
26
26
  backdrop-filter 会创建 containing block、破坏弹窗浮层,因此不做全局面模糊。
27
27
  本项目未复制其代码,仅采用其公开的结论与 API 用法。
28
28
 
29
+ dsh-plugin-liquid-glass(神猫君,MIT)
30
+ https://github.com/smj-1680/dsh-plugin-liquid-glass
31
+ 参考点:backdrop-filter:url(#svg) 的真折射用法、feTurbulence/feDisplacementMap
32
+ 的实测参数(baseFrequency 0.006/0.010、numOctaves 2、scale 26、滤镜区域 124%)、
33
+ 以及噪声缓慢漂移让折射"活着"的做法。本项目未复制其代码。
34
+
35
+ dsh-liquid-glass(Ultronen)与 dsh-plugin-liquid-glass(神猫君)是两个不同项目,
36
+ 前者只做透明度,后者做折射;本项目两种结论都采用了。
37
+ https://github.com/Ultronen/dsh-liquid-glass
38
+ 参考点:用 ctx.theme.overrideTokens 做半透明而不是自写 --dsw-* 变量;
39
+ backdrop-filter 会创建 containing block、破坏弹窗浮层,因此不做全局面模糊。
40
+ 本项目未复制其代码,仅采用其公开的结论与 API 用法。
41
+
29
42
  本项目以 MIT 许可证发布,完整条款见同目录的 LICENSE 文件。
30
43
  使用、修改、再分发与商用均被允许,只需保留本 NOTICE 与 LICENSE 中的版权声明。
31
44
  注意:第三方素材(见三、四节)不因本许可证而改变归属。
package/README.md CHANGED
@@ -45,8 +45,14 @@
45
45
 
46
46
  折射档的操作开销来自 `feDisplacementMap` 的逐像素采样,手机上明显吃 GPU,所以默认关闭。
47
47
 
48
- 感谢 [`dsh-liquid-glass`](https://github.com/Ultronen/dsh-liquid-glass)(MIT)验证了
49
- 「只做透明度、不做 backdrop-filter」这条路线,以及 `overrideTokens` 的正确用法。
48
+ 感谢两个不同的参考项目(它们不是同一个东西):
49
+
50
+ | 项目 | 做法 | 我们借了什么 |
51
+ |---|---|---|
52
+ | [`dsh-liquid-glass`](https://github.com/Ultronen/dsh-liquid-glass)(Ultronen,MIT) | 只做透明度,**不用** `backdrop-filter`;用 `ctx.theme.overrideTokens` 换 token;设置存 localStorage | 「全局面不要用 backdrop-filter」这条结论 |
53
+ | [`dsh-plugin-liquid-glass`](https://github.com/smj-1680/dsh-plugin-liquid-glass)(神猫君,MIT) | 真折射:`backdrop-filter: url(#svg)` + `feTurbulence`/`feDisplacementMap`,噪声缓慢漂移 | 滤镜参数(频率 0.006/0.010、scale 26、区域 124%)与「滤镜放进 backdrop-filter、不要给元素加 filter」的用法 |
54
+
55
+ 两者走了相反的路线,这正好说明:**透明度是便宜的,折射是贵的**,所以我们把它做成开关。
50
56
 
51
57
  ## 与上游的差异
52
58
 
package/lib/client.js CHANGED
@@ -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),
@@ -1408,6 +1409,54 @@ body[data-dsh-cyrene] [data-composer-input][data-placeholder^="Describe what you
1408
1409
  // 但本插件早有一套写死在本文件里的 --dsw-* 覆盖,选择器在 body[...] 上,
1409
1410
  // 优先级高于主题服务在 :root 写的值——结果服务覆写根本没生效。
1410
1411
  // 现在统一成本文件里的 CSS 变量 + --cyre-glass-a 滑块,只保留一条路。
1412
+ /**
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:会晕的人不该被强制看动效。
1425
+ */
1426
+ const LIQUID_ID = PACKAGE_ID + "-liquid"
1427
+ let liquidDrift = null
1428
+ function ensureLiquidFilter() {
1429
+ if (typeof document.getElementById === "function" && document.getElementById(LIQUID_ID) !== null) return
1430
+ if (typeof document.createElementNS !== "function") return
1431
+ const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg")
1432
+ svg.setAttribute("id", LIQUID_ID + "-holder")
1433
+ svg.setAttribute("width", "0")
1434
+ svg.setAttribute("height", "0")
1435
+ svg.setAttribute("aria-hidden", "true")
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"'
1441
+ + ' xChannelSelector="R" yChannelSelector="G"></feDisplacementMap>'
1442
+ + "</filter>"
1443
+ document.body.appendChild(svg)
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)
1458
+ }
1459
+
1411
1460
  function applySkin() {
1412
1461
  if (!document.body) return;
1413
1462
  document.body.setAttribute(SKIN_ATTR, state.theme ? "on" : "off");
package/lib/index.js CHANGED
@@ -548,6 +548,10 @@ function publicState() {
548
548
  pet: state.pet,
549
549
  /** 聊天里贴图的最大边长(px)。 */
550
550
  stickerSize: state.stickerSize,
551
+ /** 液态玻璃:不透明度(0.25 很透 → 0.95 几乎不透明)。 */
552
+ glassAlpha: state.glassAlpha,
553
+ /** 液态玻璃:真折射(SVG 位移滤镜),开销大,默认关。 */
554
+ glassHeavy: state.glassHeavy,
551
555
  /** 自添加的表情包(条目在状态文件、文件在 stickers-custom/)。 */
552
556
  customStickers: state.customStickers.map((entry) => ({ ...entry })),
553
557
  /** 整页背景图的设定;可用素材清单走 /cyrene/backgrounds。 */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-cyrene-theme-change",
3
- "version": "0.11.1",
3
+ "version": "0.11.3",
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",