dsh-background-by-model 0.3.1 → 0.3.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.
package/lib/client.js CHANGED
@@ -38,6 +38,8 @@ window.__ModuleLoader__.load({
38
38
  uiSop: "设置界面透明度",
39
39
  uiChatRegion: "对话文本框",
40
40
  uiTrajectory: "轨迹页",
41
+ uiPreview: "文件预览侧栏",
42
+ uiPreviewHint: "点开文件后出现在右侧的那一栏。透明度默认跟随「主背景」,拖动本卡片后单独生效;模糊会在主背景模糊之上再叠加一层",
41
43
  uiScopeHint: "界面页的设置是全局的,所有模型共用",
42
44
  statusTitle: "当前生效",
43
45
  statusModel: "当前模型",
@@ -142,6 +144,8 @@ window.__ModuleLoader__.load({
142
144
  uiSop: "Settings interface opacity",
143
145
  uiChatRegion: "Conversation text frame",
144
146
  uiTrajectory: "Trajectory view",
147
+ uiPreview: "File preview panel",
148
+ uiPreviewHint: "The column that slides in on the right when you open a file. Its opacity follows the Main background until you drag this card; its blur stacks on top of the Main background blur",
145
149
  uiScopeHint: "Interface settings are global — every model shares them",
146
150
  statusTitle: "Active now",
147
151
  statusModel: "Current model",
@@ -299,11 +303,13 @@ window.__ModuleLoader__.load({
299
303
  settings: 0,
300
304
  chat: 0,
301
305
  trajectory: 0,
306
+ rightbar: 0,
302
307
  input: 0
303
308
  },
304
309
  settingsOpacity: 1,
305
310
  chatTextOpacity: 0,
306
- trajectoryOpacity: 1
311
+ trajectoryOpacity: 1,
312
+ rightbarOpacity: null
307
313
  };
308
314
  function freshConfig() {
309
315
  return {
@@ -312,7 +318,8 @@ window.__ModuleLoader__.load({
312
318
  blurs: { ...DEFAULT_CONFIG.blurs },
313
319
  settingsOpacity: DEFAULT_CONFIG.settingsOpacity,
314
320
  chatTextOpacity: DEFAULT_CONFIG.chatTextOpacity,
315
- trajectoryOpacity: DEFAULT_CONFIG.trajectoryOpacity
321
+ trajectoryOpacity: DEFAULT_CONFIG.trajectoryOpacity,
322
+ rightbarOpacity: DEFAULT_CONFIG.rightbarOpacity
316
323
  };
317
324
  }
318
325
  let cfg = freshConfig();
@@ -462,6 +469,7 @@ window.__ModuleLoader__.load({
462
469
  "settings",
463
470
  "chat",
464
471
  "trajectory",
472
+ "rightbar",
465
473
  "input"
466
474
  ]) out[k] = clamp$1(b[k], 0, 60, DEFAULT_CONFIG.blurs[k]);
467
475
  return out;
@@ -475,6 +483,11 @@ window.__ModuleLoader__.load({
475
483
  function rTrajectoryOpacity() {
476
484
  return clamp01(cfg.trajectoryOpacity, DEFAULT_CONFIG.trajectoryOpacity);
477
485
  }
486
+ /** Own opacity of the file-preview panel; while unowned it IS the main background's. */
487
+ function rRightbarOpacity() {
488
+ const own = cfg.rightbarOpacity;
489
+ return typeof own === "number" && isFinite(own) ? clamp01(own, 1) : rOps().bg;
490
+ }
478
491
  function adoptBgState(s) {
479
492
  return {
480
493
  zoom: clamp$1(s.zoom, .1, 10, 1),
@@ -522,6 +535,7 @@ window.__ModuleLoader__.load({
522
535
  "settings",
523
536
  "chat",
524
537
  "trajectory",
538
+ "rightbar",
525
539
  "input"
526
540
  ]) blurs[k] = clamp$1(bl[k], 0, 60, DEFAULT_CONFIG.blurs[k]);
527
541
  cfg = {
@@ -535,7 +549,8 @@ window.__ModuleLoader__.load({
535
549
  blurs,
536
550
  settingsOpacity: clamp01(c.settingsOpacity, DEFAULT_CONFIG.settingsOpacity),
537
551
  chatTextOpacity: clamp01(c.chatTextOpacity, DEFAULT_CONFIG.chatTextOpacity),
538
- trajectoryOpacity: clamp01(c.trajectoryOpacity, DEFAULT_CONFIG.trajectoryOpacity)
552
+ trajectoryOpacity: clamp01(c.trajectoryOpacity, DEFAULT_CONFIG.trajectoryOpacity),
553
+ rightbarOpacity: typeof c.rightbarOpacity === "number" && isFinite(c.rightbarOpacity) ? clamp01(c.rightbarOpacity, 1) : null
539
554
  };
540
555
  if (activeRuleId !== null && !rules.some((r) => r.id === activeRuleId)) {
541
556
  activeRuleId = null;
@@ -1133,6 +1148,23 @@ window.__ModuleLoader__.load({
1133
1148
  if (layer2 !== void 0) document.documentElement.style.setProperty("--dsh-any-traj-layer-2", toRgba(layer2, op));
1134
1149
  if (layer3 !== void 0) document.documentElement.style.setProperty("--dsh-any-traj-layer-3", toRgba(layer3, op));
1135
1150
  }
1151
+ const RIGHTBAR_STYLE_RULE = "div[data-sidebar-right-panel]{background:var(--dsh-any-bg-rightbar,var(--dsw-alias-bg-base))!important;-webkit-backdrop-filter:var(--dsh-any-blur-rightbar,none);backdrop-filter:var(--dsh-any-blur-rightbar,none)}";
1152
+ /** Paint the file-preview panel's surface from its own slider. */
1153
+ function applyRightbarOverrides(op) {
1154
+ const root = document.documentElement;
1155
+ if (!rHasColor()) {
1156
+ root.style.removeProperty("--dsh-any-bg-rightbar");
1157
+ return;
1158
+ }
1159
+ const [h, s, l] = rColor();
1160
+ const base = genTokens(h, s, l).tokens["--dsw-alias-bg-base"];
1161
+ if (base !== void 0) root.style.setProperty("--dsh-any-bg-rightbar", toRgba(base, op));
1162
+ }
1163
+ /** Extra backdrop frost for the file-preview panel (0 = no frost of its own). */
1164
+ function applyRightbarBlur(px) {
1165
+ if (px > 0) document.documentElement.style.setProperty("--dsh-any-blur-rightbar", `blur(${px}px)`);
1166
+ else document.documentElement.style.removeProperty("--dsh-any-blur-rightbar");
1167
+ }
1136
1168
  let frameEl = null;
1137
1169
  let sidebarEl = null;
1138
1170
  let centerEl = null;
@@ -1221,6 +1253,7 @@ window.__ModuleLoader__.load({
1221
1253
  applyCardPanelsBlur(blurs.card);
1222
1254
  applySettingsBlur(blurs.settings);
1223
1255
  applyInputBlur(blurs.input);
1256
+ applyRightbarBlur(blurs.rightbar);
1224
1257
  applyViewCards();
1225
1258
  }
1226
1259
  /** Live per-part blur update during slider drag (no full re-apply). */
@@ -1237,6 +1270,10 @@ window.__ModuleLoader__.load({
1237
1270
  applyInputBlur(v);
1238
1271
  return;
1239
1272
  }
1273
+ if (part === "rightbar") {
1274
+ applyRightbarBlur(v);
1275
+ return;
1276
+ }
1240
1277
  if (part === "chat" || part === "trajectory") {
1241
1278
  applyViewCards();
1242
1279
  return;
@@ -1728,6 +1765,7 @@ window.__ModuleLoader__.load({
1728
1765
  baseTokenKey = "";
1729
1766
  lastBgKey = "";
1730
1767
  }
1768
+ applyRightbarOverrides(rRightbarOpacity());
1731
1769
  applyPartBlurs(rBlurs());
1732
1770
  }
1733
1771
  function teardownWp() {
@@ -1748,6 +1786,8 @@ window.__ModuleLoader__.load({
1748
1786
  document.documentElement.style.removeProperty("--dsh-any-blur-settings");
1749
1787
  document.documentElement.style.removeProperty("--dsh-any-blur-card-panels");
1750
1788
  document.documentElement.style.removeProperty("--dsh-any-input-blur");
1789
+ document.documentElement.style.removeProperty("--dsh-any-bg-rightbar");
1790
+ document.documentElement.style.removeProperty("--dsh-any-blur-rightbar");
1751
1791
  for (const v of Object.values(OPACITY_VARS)) document.documentElement.style.removeProperty(v);
1752
1792
  baseTokenKey = "";
1753
1793
  lastBgKey = "";
@@ -2413,6 +2453,22 @@ window.__ModuleLoader__.load({
2413
2453
  rx: "2"
2414
2454
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M6.6 2.2v11.6" })]
2415
2455
  });
2456
+ /** Mirror of SidebarIcon: the file-preview panel docked to the right edge. */
2457
+ const PreviewIcon = ({ size, className }) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Glyph, {
2458
+ size,
2459
+ className,
2460
+ children: [
2461
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("rect", {
2462
+ x: "2.2",
2463
+ y: "2.2",
2464
+ width: "11.6",
2465
+ height: "11.6",
2466
+ rx: "2"
2467
+ }),
2468
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M9.4 2.2v11.6" }),
2469
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M11 5.6h1.2M11 8h1.2" })
2470
+ ]
2471
+ });
2416
2472
  const ChatIcon = ({ size, className }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Glyph, {
2417
2473
  size,
2418
2474
  className,
@@ -2594,6 +2650,11 @@ window.__ModuleLoader__.load({
2594
2650
  labelKey: "uiOpacitySide",
2595
2651
  Icon: SidebarIcon
2596
2652
  },
2653
+ {
2654
+ isRightbar: true,
2655
+ labelKey: "uiPreview",
2656
+ Icon: PreviewIcon
2657
+ },
2597
2658
  {
2598
2659
  opKey: "card",
2599
2660
  labelKey: "uiOpacityCard",
@@ -2621,7 +2682,7 @@ window.__ModuleLoader__.load({
2621
2682
  }
2622
2683
  ];
2623
2684
  function InterfacePage({ p }) {
2624
- const { t, setOps, setBlurs, setSop } = p;
2685
+ const { t, setOps, setBlurs, setSop, setRightbarOpacity } = p;
2625
2686
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("header", {
2626
2687
  className: "dab-head dab-rise",
2627
2688
  style: { "--d": 0 },
@@ -2647,10 +2708,10 @@ window.__ModuleLoader__.load({
2647
2708
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2648
2709
  className: "dab-grid-parts",
2649
2710
  children: PARTS.map((part, i) => {
2650
- const { labelKey, Icon, isSettings, isChat, isTrajectory } = part;
2711
+ const { labelKey, Icon, isSettings, isChat, isTrajectory, isRightbar } = part;
2651
2712
  const opKey = part.opKey;
2652
- const blurKey = isChat ? "chat" : isTrajectory ? "trajectory" : isSettings ? "settings" : opKey;
2653
- const opacity = isChat ? rChatTextOpacity() : isTrajectory ? rTrajectoryOpacity() : isSettings ? rSop() : rOps()[opKey];
2713
+ const blurKey = isChat ? "chat" : isTrajectory ? "trajectory" : isRightbar ? "rightbar" : isSettings ? "settings" : opKey;
2714
+ const opacity = isChat ? rChatTextOpacity() : isTrajectory ? rTrajectoryOpacity() : isRightbar ? rRightbarOpacity() : isSettings ? rSop() : rOps()[opKey];
2654
2715
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
2655
2716
  className: "dab-card dab-card-hover dab-rise",
2656
2717
  style: { "--d": i + 1 },
@@ -2687,6 +2748,9 @@ window.__ModuleLoader__.load({
2687
2748
  } else if (isTrajectory) {
2688
2749
  cfg.trajectoryOpacity = op;
2689
2750
  applyTrajectoryOverrides(op);
2751
+ } else if (isRightbar) {
2752
+ cfg.rightbarOpacity = op;
2753
+ applyRightbarOverrides(op);
2690
2754
  } else if (isSettings) {
2691
2755
  cfg.settingsOpacity = op;
2692
2756
  applySettingsOverrides(op);
@@ -2708,7 +2772,8 @@ window.__ModuleLoader__.load({
2708
2772
  cfg.trajectoryOpacity = op;
2709
2773
  applyTrajectoryOverrides(op);
2710
2774
  saveConfig();
2711
- } else if (isSettings) setSop(op);
2775
+ } else if (isRightbar) setRightbarOpacity(op);
2776
+ else if (isSettings) setSop(op);
2712
2777
  else {
2713
2778
  const ops = { ...rOps() };
2714
2779
  ops[opKey] = op;
@@ -2735,7 +2800,12 @@ window.__ModuleLoader__.load({
2735
2800
  blurs[blurKey] = v;
2736
2801
  setBlurs(blurs);
2737
2802
  }
2738
- })
2803
+ }),
2804
+ isRightbar ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2805
+ className: "dab-hint",
2806
+ style: { marginTop: 9 },
2807
+ children: t("uiPreviewHint")
2808
+ }) : null
2739
2809
  ]
2740
2810
  }, blurKey);
2741
2811
  })
@@ -4295,7 +4365,7 @@ window.__ModuleLoader__.load({
4295
4365
  }, "dsh-background-by-model: skin dispose");
4296
4366
  const styleEl = document.createElement("style");
4297
4367
  styleEl.dataset.plugin = "dsh-background-by-model";
4298
- styleEl.textContent = `body[data-ds-dark-theme="dsh-background-by-model"]::before{content:'';position:fixed;inset:0;z-index:-1;pointer-events:none;background:radial-gradient(ellipse 80% 60% at 50% 0%,rgba(255,255,255,0.03) 0%,transparent 60%)}${SETTINGS_STYLE_RULE}${TRAJECTORY_STYLE_RULE}${INPUT_BLUR_RULE}[data-composer-card] textarea::placeholder,[data-composer-card] input::placeholder,[data-composer-card] [contenteditable]::placeholder,[data-cordis-panel] input::placeholder,[data-cordis-panel] textarea::placeholder,.dab-input::placeholder,.dab-input textarea::placeholder,.dab-input input::placeholder{color:var(--dsh-any-placeholder,var(--dsw-alias-label-caption,#8a8f98))!important;font-style:italic;opacity:.85}`;
4368
+ styleEl.textContent = `body[data-ds-dark-theme="dsh-background-by-model"]::before{content:'';position:fixed;inset:0;z-index:-1;pointer-events:none;background:radial-gradient(ellipse 80% 60% at 50% 0%,rgba(255,255,255,0.03) 0%,transparent 60%)}${SETTINGS_STYLE_RULE}${TRAJECTORY_STYLE_RULE}${RIGHTBAR_STYLE_RULE}${INPUT_BLUR_RULE}[data-composer-card] textarea::placeholder,[data-composer-card] input::placeholder,[data-composer-card] [contenteditable]::placeholder,[data-cordis-panel] input::placeholder,[data-cordis-panel] textarea::placeholder,.dab-input::placeholder,.dab-input textarea::placeholder,.dab-input input::placeholder{color:var(--dsh-any-placeholder,var(--dsw-alias-label-caption,#8a8f98))!important;font-style:italic;opacity:.85}`;
4299
4369
  document.head.appendChild(styleEl);
4300
4370
  ctx.effect(() => () => {
4301
4371
  styleEl?.parentNode?.removeChild(styleEl);
@@ -4528,6 +4598,11 @@ window.__ModuleLoader__.load({
4528
4598
  applySettingsOverrides(v);
4529
4599
  saveConfig();
4530
4600
  },
4601
+ setRightbarOpacity: (v) => {
4602
+ cfg.rightbarOpacity = v;
4603
+ applyRightbarOverrides(rRightbarOpacity());
4604
+ saveConfig();
4605
+ },
4531
4606
  exportTheme: () => {
4532
4607
  const images = {};
4533
4608
  for (const rule of cfg.rules) {