dsh-enhance 0.3.10 → 0.3.12
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/README.md +12 -12
- package/lib/client.js +352 -137
- package/lib/index.js +10 -18
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
- **共用部分**:Markdown 主题、划词批注、侧栏提问、文件与网页右键菜单、md 与文件预览。两边的规则与配色完全一致,不出两套皮肤。
|
|
6
6
|
- **外壳分开**:DS Bot 有自己的一套 `ds-` 风格界面(标题栏、胶囊、弹层、侧栏),DSH 保持并增强原生外观。
|
|
7
|
-
- **状态分开**:Dock
|
|
7
|
+
- **状态分开**:DSH 的 Dock 角标由本插件维护;DS Bot 的 Dock 角标由 DS Bot 宿主维护。本插件的存储键也按应用分开。
|
|
8
8
|
|
|
9
9
|
安装是两端各自独立:装进哪个应用的 profile 就只影响哪个应用,各存一份自己的文件。只有本地开发用软链时,两个 profile 才指向本仓库的同一份 `lib/` 产物。
|
|
10
10
|
|
|
@@ -16,11 +16,11 @@
|
|
|
16
16
|
| 共用功能 | Markdown 主题、划词批注、侧栏提问、文件/网页右键菜单、md 与文件预览 | 同左,规则与配色一致 |
|
|
17
17
|
| 界面外壳 | 原生外观 + 本插件的侧栏与状态增强 | 独立的 `ds-` 风格外壳:标题栏胶囊、账号菜单、弹层圆角、侧栏布局等 |
|
|
18
18
|
| 侧栏最小宽度 | 214px(上游 264px) | 220px;详情面板 260px;宽度会记住 |
|
|
19
|
-
| Dock
|
|
20
|
-
|
|
|
19
|
+
| Dock 角标 | 本插件根据会话状态 `completionUnread` 计数,后台跑完另行补记 | DS Bot 宿主独立维护,本插件不写入或清零 |
|
|
20
|
+
| 角标绘制通道 | 插件自己的 Host 路由 `POST /dsh-enhance/badge` | DS Bot 宿主自行绘制 |
|
|
21
21
|
| 存储键 | `dsh-enhance.*` | `ds-bot-enhance.*`(与 DSH 不共享) |
|
|
22
22
|
|
|
23
|
-
下面的功能清单逐条标注了适用范围:**[共用]** 两个应用都启用且表现一致;**[DSH]** 仅 DSH 生效;**[DS Bot]** 仅 DS Bot 生效。
|
|
23
|
+
下面的功能清单逐条标注了适用范围:**[共用]** 两个应用都启用且表现一致;**[DSH]** 仅 DSH 生效;**[DS Bot]** 仅 DS Bot 生效。
|
|
24
24
|
|
|
25
25
|
## 共用功能
|
|
26
26
|
|
|
@@ -43,10 +43,9 @@
|
|
|
43
43
|
|
|
44
44
|
- **[共用]网页链接右键菜单** — 在对话消息里的普通 HTTP(S) 链接上右键,弹出「打开方式」菜单:新标签页、新窗口、默认浏览器、复制链接、链接另存为…。新标签页优先打开宿主内置浏览器页签(`ctx.sidebarRight.openTab('browser', { url })`,未启用该页签时回退到新窗口);新窗口用浏览器弹窗;默认浏览器交给系统;链接另存为通过 `fetch` 取数据后以 `download` 下载,受跨域限制时提示无法下载。两个菜单都只在会话正文内拦截右键,其它位置保留宿主原生菜单;点击别处、滚动、Esc、失焦、窗口缩放都会关闭它。
|
|
45
45
|
|
|
46
|
-
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
- 画角标走插件自己的 Host 路由:页面把数字 POST 给主进程,主进程用 `app.dock.setBadge` 画角标——Electron 渲染层不实现 Badging API,之前走 `navigator.setAppBadge` 是空操作;普通浏览器里仍保留 Badging API 作为备选。
|
|
46
|
+
- **[DSH]Dock 完成角标** — 根据宿主 `uiSession.sessionStatus.completionUnread` 统计未读完成的会话,跳过空白占位和子代理。窗口失焦时结束的会话另行补记,回到窗口后清除该补记。页面通过插件自己的 Host 路由绘制角标,支持 Badging API 的浏览器也会使用该 API。
|
|
47
|
+
|
|
48
|
+
DS Bot 的角标完全由宿主维护,本插件不再写入或清零。宿主按有未读完成或待处理事项的 Bot/群行数统计,可能包含隐藏的行,因此不一定等于侧栏可见圆点数。
|
|
50
49
|
|
|
51
50
|
## DSH 专属功能
|
|
52
51
|
|
|
@@ -154,6 +153,7 @@ DSH 大版本升级后,插件依赖的插槽与 DOM 契约可能变化,需
|
|
|
154
153
|
|
|
155
154
|
## 已知限制
|
|
156
155
|
|
|
156
|
+
- **DS Bot 的 Dock 角标交由宿主维护后尚待原生验证。** 宿主的未读和待处理计数不一定与侧栏可见圆点数相同;应用重载后需在原生窗口验证实际角标更新。
|
|
157
157
|
- **DSH 里表格竖线穿过输入框的问题尚未修复。** 现象:表格中的竖线会穿过下方的输入框;根因待确认,也暂未拿到可复现的会话。
|
|
158
158
|
- **侧栏空白拖窗仅有浏览器侧规则验证。** 原生 Electron 窗口是否真正跟手、拖动带背景上的滚轮行为未经实机核实(Playwright Chromium 的 `app-region` 不生效,证明不了移动本身)。图标栏(rail)态在本 macOS 构建的折叠按钮为 `display:none`,无法从界面触达,规则与状态无关但未实机跑到该态。
|
|
159
159
|
- **上滚自动加载更早消息的阅读位置保持,在浏览器渲染下实测通过。** 阅读位置由插件自己保住:记下读者正在读的那一行,旧页插入后按内容增长量一次性校正 `scrollTop`,加载窗口内临时关掉浏览器 `overflow-anchor` 以免重复补偿(宿主的分页锚点盯的是列表第一行,不是读者行,单靠它会让内容整体下移)。浏览器实测中,旧消息插入后,读者正在看的消息位置保持稳定。同一帧内若仍有滚轮输入,视口会随输入移动。加载指示在插入后消失,宿主按钮恢复可点。深色是浏览器 `prefers-color-scheme` 下实测,非应用内主题切换;原生 Electron 下宿主的插入时序若与浏览器不同,校正写入与宿主 `write()` 的先后需再核。
|
|
@@ -174,8 +174,8 @@ DSH 大版本升级后,插件依赖的插槽与 DOM 契约可能变化,需
|
|
|
174
174
|
|
|
175
175
|
| 文件 | 作用 |
|
|
176
176
|
|---|---|
|
|
177
|
-
| `src/index.ts` | Node
|
|
178
|
-
| `src/badge-route.ts` |
|
|
177
|
+
| `src/index.ts` | Node 侧入口:注册 DSH 的 Dock 角标路由 |
|
|
178
|
+
| `src/badge-route.ts` | DSH 的角标路由(`/dsh-enhance/badge`) |
|
|
179
179
|
| `src/client/index.tsx` | 客户端 `apply(ctx)`:按 surface 挂载各功能 |
|
|
180
180
|
| `src/client/surface.ts` | 判断当前是 DSH 还是 DS Bot,给出该 surface 的 `features` 开关与样式表集合 |
|
|
181
181
|
| `src/client/styles.ts` | 两套样式表清单:DSH 9 张,DS Bot 5 张共用 + 3 张专属 |
|
|
@@ -192,8 +192,8 @@ DSH 大版本升级后,插件依赖的插槽与 DOM 契约可能变化,需
|
|
|
192
192
|
| `src/client/sidebar-width.ts` | 记住侧栏宽度(DSH 与 DS Bot 各用一键) |
|
|
193
193
|
| `src/client/sidebar-top-row.ts` | 把插件的侧栏底部图标搬进顶部行(DSH) |
|
|
194
194
|
| `src/client/window-geometry.ts` | 窗口几何:首次铺满可用区域,之后恢复上次的窗口位置与大小(DSH) |
|
|
195
|
-
| `src/client/turn-badge.ts` | Dock
|
|
196
|
-
| `src/client/badge-policy.ts` |
|
|
195
|
+
| `src/client/turn-badge.ts` | DSH Dock 未读角标;DS Bot 不写入 |
|
|
196
|
+
| `src/client/badge-policy.ts` | 未读会话的计数规则 |
|
|
197
197
|
| `src/client/whale-bubbles.ts` | 鲸鱼身后的水泡(DSH) |
|
|
198
198
|
| `src/client/locales.ts` | 插件自己的文案(中英) |
|
|
199
199
|
| `src/client/styles/` | 各样式表(每个文件导出一个 `String.raw` 模板) |
|
package/lib/client.js
CHANGED
|
@@ -4,9 +4,10 @@ window.__ModuleLoader__.load({
|
|
|
4
4
|
var module = { exports: {} };
|
|
5
5
|
var exports = module.exports;
|
|
6
6
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
7
|
+
let react_dom_client = require("react-dom/client");
|
|
8
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
7
9
|
let react = require("react");
|
|
8
10
|
let react_dom = require("react-dom");
|
|
9
|
-
let react_jsx_runtime = require("react/jsx-runtime");
|
|
10
11
|
// src/client/styles/document-preview.ts
|
|
11
12
|
/** Global presentation owned by dsh-enhance (migrated from the installer's injected styles). */
|
|
12
13
|
const css$11 = String.raw`body[data-ds-dark-theme] [data-document-markdown] {
|
|
@@ -2386,19 +2387,25 @@ body[data-ds-dark-theme] {
|
|
|
2386
2387
|
--bt-user: color-mix(in srgb, var(--bt-ink) 12%, var(--bt-main)) !important;
|
|
2387
2388
|
}
|
|
2388
2389
|
|
|
2389
|
-
/*
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
5px so their centre (20px) lines up with the 14px traffic lights. */
|
|
2393
|
-
.bt-leftcol {
|
|
2390
|
+
/* Centre the expanded toolbar in the 40px caption band. The rail's top
|
|
2391
|
+
clearance is set with its width rule below. */
|
|
2392
|
+
.bt-leftcol:not([data-left="rail"]) {
|
|
2394
2393
|
padding-top: 5px !important;
|
|
2395
2394
|
}
|
|
2396
2395
|
.bt-leftcol .bt-side-top {
|
|
2396
|
+
justify-content: flex-end;
|
|
2397
|
+
flex-wrap: wrap;
|
|
2397
2398
|
padding-top: 0 !important;
|
|
2398
2399
|
padding-right: 0 !important;
|
|
2399
2400
|
gap: 3px !important;
|
|
2400
2401
|
-webkit-app-region: no-drag !important;
|
|
2401
2402
|
}
|
|
2403
|
+
/* Frameless shells may put native window controls at the left. Keep the
|
|
2404
|
+
toolbar out of their 88px area, including the sidebar's 12px left inset.
|
|
2405
|
+
Extra actions wrap within the remaining space at compact widths. */
|
|
2406
|
+
html[data-windows-titlebar] .bt-leftcol .bt-side-top {
|
|
2407
|
+
padding-left: max(76px, var(--bt-caption-start, 0px));
|
|
2408
|
+
}
|
|
2402
2409
|
.bt-leftcol .bt-side-top button {
|
|
2403
2410
|
-webkit-app-region: no-drag !important;
|
|
2404
2411
|
width: 30px !important;
|
|
@@ -2455,6 +2462,37 @@ html[data-windows-titlebar] [class*="_addTab_"] {
|
|
|
2455
2462
|
backdrop-filter: none !important;
|
|
2456
2463
|
}
|
|
2457
2464
|
|
|
2465
|
+
/* Computer handoff renders the card and actions as siblings. Give them one
|
|
2466
|
+
column so the host's flex row cannot place the actions beside the card. */
|
|
2467
|
+
:is(.bt-q-dock, .bt-q-inline):has(> .bt-handoff + .bt-q-foot) {
|
|
2468
|
+
display: grid;
|
|
2469
|
+
grid-template-areas: 'card' 'actions';
|
|
2470
|
+
grid-template-columns: minmax(0, min(550px, 86%));
|
|
2471
|
+
row-gap: 8px;
|
|
2472
|
+
}
|
|
2473
|
+
.bt-q-dock:has(> .bt-handoff + .bt-q-foot) {
|
|
2474
|
+
grid-template-columns: minmax(0, calc(min(var(--dsh-chat-content-width, 748px), 100%) - 32px));
|
|
2475
|
+
padding-bottom: 8px;
|
|
2476
|
+
}
|
|
2477
|
+
:is(.bt-q-dock, .bt-q-inline) > .bt-handoff:has(+ .bt-q-foot) {
|
|
2478
|
+
grid-area: card;
|
|
2479
|
+
width: 100%;
|
|
2480
|
+
max-width: none;
|
|
2481
|
+
margin: 0;
|
|
2482
|
+
}
|
|
2483
|
+
:is(.bt-q-dock, .bt-q-inline) > .bt-handoff + .bt-q-foot {
|
|
2484
|
+
grid-area: actions;
|
|
2485
|
+
flex-wrap: wrap;
|
|
2486
|
+
}
|
|
2487
|
+
@media (max-width: 640px) {
|
|
2488
|
+
.bt-q-inline:has(> .bt-handoff + .bt-q-foot) {
|
|
2489
|
+
grid-template-columns: minmax(0, 1fr);
|
|
2490
|
+
}
|
|
2491
|
+
:is(.bt-q-dock, .bt-q-inline) > .bt-handoff + .bt-q-foot > button {
|
|
2492
|
+
min-height: 44px;
|
|
2493
|
+
}
|
|
2494
|
+
}
|
|
2495
|
+
|
|
2458
2496
|
/* Keep the user's settled 12px top offset. Absolute positioning preserves
|
|
2459
2497
|
the host's horizontal centring as the sidebar and detail panel resize. */
|
|
2460
2498
|
${PILL_HEADER} {
|
|
@@ -2687,7 +2725,7 @@ html[data-windows-titlebar] .bt-panel:has(> .bt-panel-view > .bt-subhead) > .bt-
|
|
|
2687
2725
|
min-width: 0 !important;
|
|
2688
2726
|
/* With the toggle removed, keep the first avatar below native window controls.
|
|
2689
2727
|
The live inline width still owns both the rail and its resize boundary. */
|
|
2690
|
-
padding-top: max(20px, calc(var(--bt-lc-clear, 0px) + 8px)) !important;
|
|
2728
|
+
padding-top: max(20px, calc(max(var(--bt-lc-clear, 0px), var(--dsh-windows-titlebar-height, 0px)) + 8px)) !important;
|
|
2691
2729
|
}
|
|
2692
2730
|
|
|
2693
2731
|
/* ---- Window drag from the sidebar background (desktop only) ---- */
|
|
@@ -2698,28 +2736,39 @@ html[data-windows-titlebar] .bt-panel:has(> .bt-panel-view > .bt-subhead) > .bt-
|
|
|
2698
2736
|
data-window-drag-recall into its no-drag carve-out; here the whole left
|
|
2699
2737
|
column becomes that region, and every control inside it is carved back out.
|
|
2700
2738
|
A drag region is the union of the drag boxes minus the no-drag boxes, so the
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
event (clicks, hover, right-click, wheel). Scoped to data-windows-titlebar so
|
|
2705
|
-
a plain browser tab — which has no native window to move — is left alone.
|
|
2739
|
+
empty space outside the list can still drag the window. The whole scrollport
|
|
2740
|
+
receives pointer events, including gaps between rows. A single no-drag box
|
|
2741
|
+
replaces the moving no-drag rectangles for each list control.
|
|
2706
2742
|
The grip is carved out so panel-widths.ts keeps owning its resize gesture. */
|
|
2707
2743
|
html[data-windows-titlebar] .bt-leftcol {
|
|
2708
2744
|
-webkit-app-region: drag !important;
|
|
2709
2745
|
}
|
|
2710
|
-
html[data-windows-titlebar] .bt-leftcol
|
|
2711
|
-
html[data-windows-titlebar] .bt-leftcol a,
|
|
2712
|
-
|
|
2713
|
-
html[data-windows-titlebar] .bt-leftcol textarea,
|
|
2714
|
-
html[data-windows-titlebar] .bt-leftcol select,
|
|
2715
|
-
html[data-windows-titlebar] .bt-leftcol [contenteditable="true"],
|
|
2716
|
-
html[data-windows-titlebar] .bt-leftcol [role="menu"],
|
|
2717
|
-
html[data-windows-titlebar] .bt-leftcol [role="menuitem"],
|
|
2718
|
-
html[data-windows-titlebar] .bt-leftcol [role="menuitemcheckbox"],
|
|
2746
|
+
html[data-windows-titlebar] .bt-leftcol > .bt-side > .bt-list,
|
|
2747
|
+
html[data-windows-titlebar] .bt-leftcol :is(button, a, input, textarea, select,
|
|
2748
|
+
[contenteditable="true"], [role="menu"], [role="menuitem"], [role="menuitemcheckbox"]):not(.bt-list *),
|
|
2719
2749
|
html[data-windows-titlebar] .bt-leftcol-grip {
|
|
2720
2750
|
-webkit-app-region: no-drag !important;
|
|
2721
2751
|
}
|
|
2722
2752
|
|
|
2753
|
+
/* A sidebar popup (account menu, section/row context menu) is rendered as a
|
|
2754
|
+
body-level .bt-menu overlay, so the pointerdown that the host's outside-click
|
|
2755
|
+
handler needs to dismiss it lands on the sidebar background — which the rule
|
|
2756
|
+
above makes a window-drag handle. Electron's drag region swallows that
|
|
2757
|
+
pointerdown, so the outside click never reaches the handler and the menu looks
|
|
2758
|
+
stuck when the empty area is clicked. Hand the whole column back to pointer
|
|
2759
|
+
events while a sidebar .bt-menu is open; the :has() stops matching the moment
|
|
2760
|
+
the overlay is removed and dragging returns. A .bt-menu exists only while a
|
|
2761
|
+
popup is open (none is parked in the DOM), and any other popup also dismisses
|
|
2762
|
+
on the first background click, so widening the no-drag window for it is safe. */
|
|
2763
|
+
html[data-windows-titlebar] body:has(> .bt-menu) .bt-leftcol {
|
|
2764
|
+
-webkit-app-region: no-drag !important;
|
|
2765
|
+
}
|
|
2766
|
+
|
|
2767
|
+
/* Custom avatar images in the sidebar use the host crop without its inset ring. */
|
|
2768
|
+
.bt-leftcol :is(.bt-tile, .bt-row) > .bt-mark > .bt-mark[data-shape="image"] > .bt-mark-img {
|
|
2769
|
+
box-shadow: none;
|
|
2770
|
+
}
|
|
2771
|
+
|
|
2723
2772
|
/* ---- Bot shortcut tile: let the card hold its role label ---- */
|
|
2724
2773
|
|
|
2725
2774
|
/* The pinned bot card shrink-wraps to its 60px avatar, but the role chip
|
|
@@ -2748,6 +2797,36 @@ html[data-windows-titlebar] .bt-leftcol-grip {
|
|
|
2748
2797
|
height: auto !important;
|
|
2749
2798
|
}
|
|
2750
2799
|
|
|
2800
|
+
/* The footer's native .bt-account/.bt-you styles provide the button and disc. */
|
|
2801
|
+
.bt-leftcol-foot .ds-footer-panel-icon {
|
|
2802
|
+
display: inline-flex;
|
|
2803
|
+
line-height: 0;
|
|
2804
|
+
}
|
|
2805
|
+
.bt-leftcol-foot .ds-open-artifact-icon {
|
|
2806
|
+
position: relative;
|
|
2807
|
+
width: 16px;
|
|
2808
|
+
height: 16px;
|
|
2809
|
+
}
|
|
2810
|
+
.bt-leftcol-foot .ds-open-artifact-icon::before,
|
|
2811
|
+
.bt-leftcol-foot .ds-open-artifact-icon::after {
|
|
2812
|
+
content: '';
|
|
2813
|
+
position: absolute;
|
|
2814
|
+
box-sizing: border-box;
|
|
2815
|
+
width: 10px;
|
|
2816
|
+
height: 12px;
|
|
2817
|
+
border: 1.5px solid currentColor;
|
|
2818
|
+
border-radius: 2.5px;
|
|
2819
|
+
}
|
|
2820
|
+
.bt-leftcol-foot .ds-open-artifact-icon::before {
|
|
2821
|
+
top: 0;
|
|
2822
|
+
right: 0;
|
|
2823
|
+
clip-path: polygon(0 0, 100% 0, 100% 100%, 42% 100%, 42% 30%, 0 30%);
|
|
2824
|
+
}
|
|
2825
|
+
.bt-leftcol-foot .ds-open-artifact-icon::after {
|
|
2826
|
+
bottom: 0;
|
|
2827
|
+
left: 0;
|
|
2828
|
+
}
|
|
2829
|
+
|
|
2751
2830
|
/* ---- Sidebar section headers (DS Bot tree) ---- */
|
|
2752
2831
|
|
|
2753
2832
|
/* The disclosure chevron's glyph sits ~2.5px right of the hover guide line
|
|
@@ -2955,9 +3034,9 @@ ${fallback} li::marker {
|
|
|
2955
3034
|
*
|
|
2956
3035
|
* DS Bot draws its own sidebar, so the DSH chrome (width, icon row, section
|
|
2957
3036
|
* counts, whale, window geometry) stays off there. Annotations, side chat,
|
|
2958
|
-
* both context menus, markdown
|
|
2959
|
-
*
|
|
2960
|
-
*
|
|
3037
|
+
* both context menus, markdown and document preview stay on. DS Bot owns its
|
|
3038
|
+
* Dock badge; this plugin only paints the DSH badge. The running-marker and
|
|
3039
|
+
* send-button looks follow the DSH chrome sheets. Edge refraction belongs to the
|
|
2961
3040
|
* DS Bot pill only: DSH draws no such pill, so it stays off there.
|
|
2962
3041
|
* @param surface - the decided surface.
|
|
2963
3042
|
* @returns the switches `apply` reads.
|
|
@@ -2974,6 +3053,7 @@ ${fallback} li::marker {
|
|
|
2974
3053
|
};
|
|
2975
3054
|
if (surface === "ds-bot") return {
|
|
2976
3055
|
...shared,
|
|
3056
|
+
badge: false,
|
|
2977
3057
|
sidebarFloor: false,
|
|
2978
3058
|
sidebarTopRow: false,
|
|
2979
3059
|
sectionStats: false,
|
|
@@ -3393,9 +3473,10 @@ ${fallback} li::marker {
|
|
|
3393
3473
|
frame = win.requestAnimationFrame(tick);
|
|
3394
3474
|
};
|
|
3395
3475
|
/** The reader scrolled: their gesture is the only thing that may trigger a load. */
|
|
3396
|
-
const onScroll = () => {
|
|
3476
|
+
const onScroll = (event) => {
|
|
3477
|
+
if (!(event.target instanceof win.Element) || !event.target.matches(SCROLLER)) return;
|
|
3397
3478
|
const scrollerEl = scroller();
|
|
3398
|
-
if (
|
|
3479
|
+
if (scrollerEl !== event.target) return;
|
|
3399
3480
|
const top = scrollerEl.scrollTop;
|
|
3400
3481
|
if (syncSession()) {
|
|
3401
3482
|
reset();
|
|
@@ -3421,11 +3502,10 @@ ${fallback} li::marker {
|
|
|
3421
3502
|
* the reader would have to scroll down and back up to get their history.
|
|
3422
3503
|
*/
|
|
3423
3504
|
const onWheel = (event) => {
|
|
3424
|
-
const
|
|
3425
|
-
if (!
|
|
3426
|
-
const
|
|
3427
|
-
if (!
|
|
3428
|
-
if (!scrollerEl.contains(node)) return;
|
|
3505
|
+
const target = event.target;
|
|
3506
|
+
if (!(target instanceof win.Element)) return;
|
|
3507
|
+
const candidate = target.closest(SCROLLER);
|
|
3508
|
+
if (!candidate || candidate !== scroller()) return;
|
|
3429
3509
|
if (!(event.deltaY < 0)) return;
|
|
3430
3510
|
markGesture();
|
|
3431
3511
|
if (!mayTrigger()) return;
|
|
@@ -3433,11 +3513,10 @@ ${fallback} li::marker {
|
|
|
3433
3513
|
};
|
|
3434
3514
|
/** The reader grabbed the scrollbar: a drag is a gesture of its own. */
|
|
3435
3515
|
const onPointerDown = (event) => {
|
|
3436
|
-
const
|
|
3437
|
-
if (!
|
|
3438
|
-
const
|
|
3439
|
-
if (!
|
|
3440
|
-
if (!scrollerEl.contains(node)) return;
|
|
3516
|
+
const target = event.target;
|
|
3517
|
+
if (!(target instanceof win.Element)) return;
|
|
3518
|
+
const candidate = target.closest(SCROLLER);
|
|
3519
|
+
if (!candidate || candidate !== scroller()) return;
|
|
3441
3520
|
gestureSeq += 1;
|
|
3442
3521
|
gestureUntil = win.performance.now() + GESTURE_WINDOW_MS;
|
|
3443
3522
|
};
|
|
@@ -4330,6 +4409,122 @@ ${fallback} li::marker {
|
|
|
4330
4409
|
style.remove();
|
|
4331
4410
|
};
|
|
4332
4411
|
}
|
|
4412
|
+
// src/client/surfaces/ds-bot/sidebar-bounce.ts
|
|
4413
|
+
const LIST = ".bt-leftcol > .bt-side > .bt-list";
|
|
4414
|
+
const MOTION = "(prefers-reduced-motion: no-preference) and (any-pointer: fine)";
|
|
4415
|
+
const EDGE_GESTURE_GAP = 140;
|
|
4416
|
+
const SCROLL_CONFIRM_WINDOW = 300;
|
|
4417
|
+
const BOUNCE_DISTANCE = 9;
|
|
4418
|
+
const BOUNCE_DURATION = 150;
|
|
4419
|
+
const GROUP = ".bt-sec, .bt-sec-body, .bt-sec-body-in, .bt-sec-ungrouped";
|
|
4420
|
+
function visibleContent(list, direction, height, end) {
|
|
4421
|
+
const viewport = list.getBoundingClientRect();
|
|
4422
|
+
const towardTop = direction < 0;
|
|
4423
|
+
const targets = [];
|
|
4424
|
+
const collect = (parent) => {
|
|
4425
|
+
let child = towardTop ? parent.firstElementChild : parent.lastElementChild;
|
|
4426
|
+
while (child) {
|
|
4427
|
+
const bounds = child.getBoundingClientRect();
|
|
4428
|
+
if (towardTop ? bounds.top >= viewport.bottom : bounds.bottom <= viewport.top) break;
|
|
4429
|
+
if (bounds.height > 0 && bounds.bottom > viewport.top && bounds.top < viewport.bottom) {
|
|
4430
|
+
if (bounds.height > height && child.matches(GROUP)) collect(child);
|
|
4431
|
+
else {
|
|
4432
|
+
const space = viewport.top + height + end - bounds.bottom;
|
|
4433
|
+
const distance = towardTop ? Math.min(BOUNCE_DISTANCE, Math.floor(space)) : -9;
|
|
4434
|
+
if (!towardTop || distance > 0) targets.push({
|
|
4435
|
+
element: child,
|
|
4436
|
+
distance
|
|
4437
|
+
});
|
|
4438
|
+
}
|
|
4439
|
+
}
|
|
4440
|
+
child = towardTop ? child.nextElementSibling : child.previousElementSibling;
|
|
4441
|
+
}
|
|
4442
|
+
};
|
|
4443
|
+
collect(list);
|
|
4444
|
+
return targets;
|
|
4445
|
+
}
|
|
4446
|
+
/** Leave the list's scroll offset and hit regions to the browser. */
|
|
4447
|
+
function installSidebarBounce(root) {
|
|
4448
|
+
const win = root.defaultView;
|
|
4449
|
+
if (!win?.matchMedia || !/\bElectron\//.test(win.navigator.userAgent) || typeof win.Element.prototype.animate !== "function") return () => {};
|
|
4450
|
+
const motion = win.matchMedia(MOTION);
|
|
4451
|
+
const animations = /* @__PURE__ */ new Set();
|
|
4452
|
+
let gesture;
|
|
4453
|
+
let frame = 0;
|
|
4454
|
+
const inspectEdge = () => {
|
|
4455
|
+
frame = 0;
|
|
4456
|
+
if (!gesture || gesture.feedbackShown || !motion.matches) return;
|
|
4457
|
+
const { list, direction, lastWheel } = gesture;
|
|
4458
|
+
if (win.performance.now() - lastWheel > SCROLL_CONFIRM_WINDOW || !list.isConnected || list.closest(".bt-leftcol[data-leaving]") || root.documentElement.hasAttribute("data-ds-enhance-resizing")) return;
|
|
4459
|
+
const height = list.clientHeight;
|
|
4460
|
+
const end = list.scrollHeight - height;
|
|
4461
|
+
const offset = list.scrollTop;
|
|
4462
|
+
if (end <= 1 || (direction < 0 ? offset > 1 : offset < end - 1)) return;
|
|
4463
|
+
gesture.feedbackShown = true;
|
|
4464
|
+
if (animations.size) return;
|
|
4465
|
+
for (const { element, distance } of visibleContent(list, direction, height, end)) {
|
|
4466
|
+
const animation = element.animate([
|
|
4467
|
+
{
|
|
4468
|
+
translate: "0 0",
|
|
4469
|
+
easing: "ease-out"
|
|
4470
|
+
},
|
|
4471
|
+
{
|
|
4472
|
+
translate: `0 ${distance}px`,
|
|
4473
|
+
offset: .24,
|
|
4474
|
+
easing: "ease-out"
|
|
4475
|
+
},
|
|
4476
|
+
{ translate: "0 0" }
|
|
4477
|
+
], BOUNCE_DURATION);
|
|
4478
|
+
animations.add(animation);
|
|
4479
|
+
animation.onfinish = animation.oncancel = () => {
|
|
4480
|
+
animations.delete(animation);
|
|
4481
|
+
};
|
|
4482
|
+
}
|
|
4483
|
+
};
|
|
4484
|
+
const schedule = () => {
|
|
4485
|
+
if (!frame) frame = win.requestAnimationFrame(inspectEdge);
|
|
4486
|
+
};
|
|
4487
|
+
const reset = () => {
|
|
4488
|
+
if (frame) win.cancelAnimationFrame(frame);
|
|
4489
|
+
frame = 0;
|
|
4490
|
+
gesture = void 0;
|
|
4491
|
+
for (const animation of animations.values()) animation.cancel();
|
|
4492
|
+
animations.clear();
|
|
4493
|
+
};
|
|
4494
|
+
const onWheel = (event) => {
|
|
4495
|
+
if (!motion.matches || event.defaultPrevented || event.ctrlKey || event.shiftKey || event.buttons) return;
|
|
4496
|
+
if (!Number.isFinite(event.deltaY) || Math.abs(event.deltaY) <= Math.abs(event.deltaX)) return;
|
|
4497
|
+
const target = event.target;
|
|
4498
|
+
if (!(target instanceof win.Element)) return;
|
|
4499
|
+
const list = target.closest(LIST);
|
|
4500
|
+
if (!list) return;
|
|
4501
|
+
const direction = Math.sign(event.deltaY);
|
|
4502
|
+
const now = win.performance.now();
|
|
4503
|
+
if (!gesture || gesture.list !== list || gesture.direction !== direction || now - gesture.lastWheel >= EDGE_GESTURE_GAP) gesture = {
|
|
4504
|
+
list,
|
|
4505
|
+
direction,
|
|
4506
|
+
lastWheel: now,
|
|
4507
|
+
feedbackShown: false
|
|
4508
|
+
};
|
|
4509
|
+
else gesture.lastWheel = now;
|
|
4510
|
+
if (!gesture.feedbackShown) schedule();
|
|
4511
|
+
};
|
|
4512
|
+
const onScroll = (event) => {
|
|
4513
|
+
if (gesture && event.target === gesture.list && !gesture.feedbackShown && win.performance.now() - gesture.lastWheel <= SCROLL_CONFIRM_WINDOW) schedule();
|
|
4514
|
+
};
|
|
4515
|
+
root.addEventListener("wheel", onWheel, { passive: true });
|
|
4516
|
+
root.addEventListener("scroll", onScroll, {
|
|
4517
|
+
capture: true,
|
|
4518
|
+
passive: true
|
|
4519
|
+
});
|
|
4520
|
+
motion.addEventListener("change", reset);
|
|
4521
|
+
return () => {
|
|
4522
|
+
root.removeEventListener("wheel", onWheel);
|
|
4523
|
+
root.removeEventListener("scroll", onScroll, true);
|
|
4524
|
+
motion.removeEventListener("change", reset);
|
|
4525
|
+
reset();
|
|
4526
|
+
};
|
|
4527
|
+
}
|
|
4333
4528
|
// src/client/surfaces/ds-bot/liquid-glass.ts
|
|
4334
4529
|
/** Liquid-glass refraction for the DS Bot session pill.
|
|
4335
4530
|
*
|
|
@@ -4493,6 +4688,108 @@ ${fallback} li::marker {
|
|
|
4493
4688
|
root.documentElement.removeAttribute(MODE_ATTR);
|
|
4494
4689
|
};
|
|
4495
4690
|
}
|
|
4691
|
+
// src/client/surfaces/ds-bot/footer-panels.ts
|
|
4692
|
+
const FOOTER_SELECTOR = ".bt-leftcol > .bt-side > .bt-leftcol-foot";
|
|
4693
|
+
const PANELS = [{
|
|
4694
|
+
id: "open-artifact",
|
|
4695
|
+
fallbackLabel: "Open Artifact",
|
|
4696
|
+
useRegisteredIcon: false
|
|
4697
|
+
}, {
|
|
4698
|
+
id: "skills-manager",
|
|
4699
|
+
fallbackLabel: "Skills Manager",
|
|
4700
|
+
useRegisteredIcon: true
|
|
4701
|
+
}];
|
|
4702
|
+
/** Mount shortcuts to registered pages in DS Bot's custom sidebar footer. */
|
|
4703
|
+
function installFooterPanels(ctx, root, mountIcon) {
|
|
4704
|
+
const { slots, layout, locale } = ctx;
|
|
4705
|
+
const mainExists = (id) => slots.entriesOfSlot("main").some(({ options }) => options.key === id);
|
|
4706
|
+
const panels = PANELS.map((panel) => {
|
|
4707
|
+
const button = root.createElement("button");
|
|
4708
|
+
button.type = "button";
|
|
4709
|
+
button.className = "bt-account";
|
|
4710
|
+
button.setAttribute(`data-ds-bot-enhance-${panel.id}`, "");
|
|
4711
|
+
const disc = root.createElement("span");
|
|
4712
|
+
disc.className = "bt-you";
|
|
4713
|
+
disc.setAttribute("aria-hidden", "true");
|
|
4714
|
+
const icon = root.createElement("span");
|
|
4715
|
+
icon.className = panel.useRegisteredIcon ? "ds-footer-panel-icon" : "ds-open-artifact-icon";
|
|
4716
|
+
disc.append(icon);
|
|
4717
|
+
button.append(disc);
|
|
4718
|
+
const open = () => {
|
|
4719
|
+
if (mainExists(panel.id)) layout.selectPanel(panel.id);
|
|
4720
|
+
};
|
|
4721
|
+
button.addEventListener("click", open);
|
|
4722
|
+
return {
|
|
4723
|
+
...panel,
|
|
4724
|
+
button,
|
|
4725
|
+
icon,
|
|
4726
|
+
open,
|
|
4727
|
+
component: void 0,
|
|
4728
|
+
stopIcon: void 0
|
|
4729
|
+
};
|
|
4730
|
+
});
|
|
4731
|
+
const updateIcon = (panel, component) => {
|
|
4732
|
+
if (panel.component === component) return;
|
|
4733
|
+
panel.stopIcon?.();
|
|
4734
|
+
panel.stopIcon = component ? mountIcon(panel.icon, component) : void 0;
|
|
4735
|
+
panel.component = component;
|
|
4736
|
+
};
|
|
4737
|
+
let footer = null;
|
|
4738
|
+
const sync = () => {
|
|
4739
|
+
footer = root.querySelector(FOOTER_SELECTOR);
|
|
4740
|
+
const entries = slots.entriesOfSlot("sidebar.panellist");
|
|
4741
|
+
for (const panel of panels) {
|
|
4742
|
+
const { id, button, useRegisteredIcon, fallbackLabel } = panel;
|
|
4743
|
+
const entry = entries.find(({ options }) => options.id === id);
|
|
4744
|
+
if (!footer || !mainExists(id) || useRegisteredIcon && !entry) {
|
|
4745
|
+
button.remove();
|
|
4746
|
+
updateIcon(panel, void 0);
|
|
4747
|
+
continue;
|
|
4748
|
+
}
|
|
4749
|
+
const label = entry?.options.label;
|
|
4750
|
+
const name = (typeof label === "function" ? label() : label) || fallbackLabel;
|
|
4751
|
+
if (Array.from(footer.querySelectorAll("button")).some((candidate) => candidate !== button && candidate.getAttribute("aria-label") === name)) {
|
|
4752
|
+
button.remove();
|
|
4753
|
+
updateIcon(panel, void 0);
|
|
4754
|
+
continue;
|
|
4755
|
+
}
|
|
4756
|
+
button.title = name;
|
|
4757
|
+
button.setAttribute("aria-label", name);
|
|
4758
|
+
if (button.parentElement !== footer) footer.append(button);
|
|
4759
|
+
if (useRegisteredIcon) updateIcon(panel, entry?.component);
|
|
4760
|
+
}
|
|
4761
|
+
};
|
|
4762
|
+
const syncSelection = () => {
|
|
4763
|
+
const activeId = layout.panelInfo.getSnapshot().activePanelId;
|
|
4764
|
+
for (const { id, button } of panels) if (activeId === id) button.setAttribute("aria-current", "page");
|
|
4765
|
+
else button.removeAttribute("aria-current");
|
|
4766
|
+
};
|
|
4767
|
+
const observer = new MutationObserver((records) => {
|
|
4768
|
+
if (!footer?.isConnected || records.some((record) => footer?.contains(record.target))) sync();
|
|
4769
|
+
});
|
|
4770
|
+
observer.observe(root.documentElement, {
|
|
4771
|
+
childList: true,
|
|
4772
|
+
subtree: true
|
|
4773
|
+
});
|
|
4774
|
+
const stopMain = slots.subscribe("main", sync);
|
|
4775
|
+
const stopEntries = slots.subscribe("sidebar.panellist", sync);
|
|
4776
|
+
const stopLocale = locale.subscribe(sync);
|
|
4777
|
+
const stopSelection = layout.panelInfo.subscribe(syncSelection);
|
|
4778
|
+
sync();
|
|
4779
|
+
syncSelection();
|
|
4780
|
+
return () => {
|
|
4781
|
+
observer.disconnect();
|
|
4782
|
+
stopMain();
|
|
4783
|
+
stopEntries();
|
|
4784
|
+
stopLocale();
|
|
4785
|
+
stopSelection();
|
|
4786
|
+
for (const panel of panels) {
|
|
4787
|
+
updateIcon(panel, void 0);
|
|
4788
|
+
panel.button.removeEventListener("click", panel.open);
|
|
4789
|
+
panel.button.remove();
|
|
4790
|
+
}
|
|
4791
|
+
};
|
|
4792
|
+
}
|
|
4496
4793
|
// src/client/section-stats.ts
|
|
4497
4794
|
/** Marks the injected row, for the stylesheet and the disposer. */
|
|
4498
4795
|
const STATS_ATTRIBUTE = "data-dsh-enhance-stats";
|
|
@@ -5017,25 +5314,10 @@ ${fallback} li::marker {
|
|
|
5017
5314
|
}
|
|
5018
5315
|
}
|
|
5019
5316
|
// src/badge-route.ts
|
|
5020
|
-
/**
|
|
5021
|
-
|
|
5022
|
-
return surface === "ds-bot" ? "/ds-bot-enhance/badge" : "/dsh-enhance/badge";
|
|
5023
|
-
}
|
|
5317
|
+
/** DSH's plugin-owned Dock badge route; DS Bot uses its own host badge. */
|
|
5318
|
+
const BADGE_ROUTE = "/dsh-enhance/badge";
|
|
5024
5319
|
// src/client/badge-policy.ts
|
|
5025
|
-
/**
|
|
5026
|
-
const DS_BOT_UNREAD_DOT = ".bt-leftcol .bt-row .bt-unread";
|
|
5027
|
-
/** The row a dot belongs to; one row may carry several marks. */
|
|
5028
|
-
const DS_BOT_ROW = ".bt-row";
|
|
5029
|
-
/**
|
|
5030
|
-
* Visible rows whose completion is unread, plus the attention overlay.
|
|
5031
|
-
*
|
|
5032
|
-
* Blank placeholders and subagent children are skipped. Statuses whose row is
|
|
5033
|
-
* gone are skipped too.
|
|
5034
|
-
* @param byId - list rows by id.
|
|
5035
|
-
* @param status - session status by id.
|
|
5036
|
-
* @param attention - extra ids that finished in the background.
|
|
5037
|
-
* @returns the ids, in list order.
|
|
5038
|
-
*/
|
|
5320
|
+
/** Return unread completions and background finishes for existing DSH sessions. */
|
|
5039
5321
|
function completionUnreadIds(byId, status, attention) {
|
|
5040
5322
|
const unread = [];
|
|
5041
5323
|
for (const [id, row] of Object.entries(byId)) {
|
|
@@ -5044,85 +5326,6 @@ ${fallback} li::marker {
|
|
|
5044
5326
|
}
|
|
5045
5327
|
return unread;
|
|
5046
5328
|
}
|
|
5047
|
-
/**
|
|
5048
|
-
* The rows DS Bot renders with an unread dot.
|
|
5049
|
-
*
|
|
5050
|
-
* One row is one bot, so the number of rows is the number the sidebar shows.
|
|
5051
|
-
* Several marks on one row count once; a mark that is not laid out (a hidden
|
|
5052
|
-
* section, a collapsed group) is skipped.
|
|
5053
|
-
* @param root - the document, or a stand-in in tests. Defaults to `document`.
|
|
5054
|
-
* @returns one entry per unread row, capped at the Host's own badge ceiling.
|
|
5055
|
-
*/
|
|
5056
|
-
function unreadSidebarRows(root) {
|
|
5057
|
-
const scope = root ?? defaultRoot();
|
|
5058
|
-
if (scope === void 0 || scope === null) return [];
|
|
5059
|
-
const rows = /* @__PURE__ */ new Set();
|
|
5060
|
-
for (const dot of Array.from(scope.querySelectorAll(DS_BOT_UNREAD_DOT))) {
|
|
5061
|
-
if (!isLaidOut(dot)) continue;
|
|
5062
|
-
const row = dot.closest?.(DS_BOT_ROW) ?? dot;
|
|
5063
|
-
rows.add(row);
|
|
5064
|
-
if (rows.size >= 999) break;
|
|
5065
|
-
}
|
|
5066
|
-
return [...rows];
|
|
5067
|
-
}
|
|
5068
|
-
/**
|
|
5069
|
-
* Whether an element occupies space on the page.
|
|
5070
|
-
*
|
|
5071
|
-
* A stand-in without layout methods counts as shown, so a test can model only
|
|
5072
|
-
* the structure it cares about.
|
|
5073
|
-
* @param element - the candidate.
|
|
5074
|
-
* @returns false only when the element reports that it has no boxes.
|
|
5075
|
-
*/
|
|
5076
|
-
function isLaidOut(element) {
|
|
5077
|
-
if (typeof element.getClientRects !== "function") return true;
|
|
5078
|
-
try {
|
|
5079
|
-
return element.getClientRects().length > 0;
|
|
5080
|
-
} catch {
|
|
5081
|
-
return true;
|
|
5082
|
-
}
|
|
5083
|
-
}
|
|
5084
|
-
/**
|
|
5085
|
-
* The page's document, when there is one.
|
|
5086
|
-
* @returns the document as a counting root, or undefined outside a DOM.
|
|
5087
|
-
*/
|
|
5088
|
-
function defaultRoot() {
|
|
5089
|
-
if (typeof document === "undefined") return void 0;
|
|
5090
|
-
return document;
|
|
5091
|
-
}
|
|
5092
|
-
/**
|
|
5093
|
-
* A stable key for one row, so `select` can return ids rather than elements.
|
|
5094
|
-
* @param row - the row element.
|
|
5095
|
-
* @param index - its position, used when the row carries no id.
|
|
5096
|
-
* @returns the row's bot or room id, else its index.
|
|
5097
|
-
*/
|
|
5098
|
-
function rowKey(row, index) {
|
|
5099
|
-
const id = row.getAttribute?.("data-bot-id") ?? row.getAttribute?.("data-room-id");
|
|
5100
|
-
return id === null || id === void 0 || id === "" ? `row-${index}` : id;
|
|
5101
|
-
}
|
|
5102
|
-
/**
|
|
5103
|
-
* The counting rule for one surface.
|
|
5104
|
-
*
|
|
5105
|
-
* DS Bot counts the unread rows its own left column renders, which is exactly
|
|
5106
|
-
* the number of green dots the reader sees. An empty sidebar therefore clears
|
|
5107
|
-
* the tile, and an unrendered history session can never inflate it.
|
|
5108
|
-
* @param surface - the decided surface.
|
|
5109
|
-
* @param options - `root` overrides the document in tests.
|
|
5110
|
-
* @returns the policy `installTurnBadge` calls.
|
|
5111
|
-
*/
|
|
5112
|
-
function badgePolicyFor(surface, options = {}) {
|
|
5113
|
-
if (surface === "ds-bot") return {
|
|
5114
|
-
id: "ds-bot-sidebar-unread-rows",
|
|
5115
|
-
pending: false,
|
|
5116
|
-
note: "One count per unread row in the DS Bot left column: the same rows that carry a green dot.",
|
|
5117
|
-
select: () => unreadSidebarRows(options.root).map(rowKey)
|
|
5118
|
-
};
|
|
5119
|
-
return {
|
|
5120
|
-
id: "dsh-completion-unread",
|
|
5121
|
-
pending: false,
|
|
5122
|
-
note: "",
|
|
5123
|
-
select: completionUnreadIds
|
|
5124
|
-
};
|
|
5125
|
-
}
|
|
5126
5329
|
// src/client/turn-badge.ts
|
|
5127
5330
|
/** localStorage key of the pre-v2 accumulating badge; cleared once on mount. */
|
|
5128
5331
|
const LEGACY_STORAGE_KEY = "dsh-enhance.turn-badge.v1";
|
|
@@ -5139,7 +5342,7 @@ ${fallback} li::marker {
|
|
|
5139
5342
|
if (typeof base !== "string" || base === "") return;
|
|
5140
5343
|
let url;
|
|
5141
5344
|
try {
|
|
5142
|
-
url = new URL(
|
|
5345
|
+
url = new URL(BADGE_ROUTE, base).href;
|
|
5143
5346
|
} catch {
|
|
5144
5347
|
return;
|
|
5145
5348
|
}
|
|
@@ -5180,6 +5383,7 @@ ${fallback} li::marker {
|
|
|
5180
5383
|
* @returns disposer.
|
|
5181
5384
|
*/
|
|
5182
5385
|
function installTurnBadge(ctx, deps = {}) {
|
|
5386
|
+
if (currentSurface() === "ds-bot") return () => {};
|
|
5183
5387
|
const badgeNavigator = navigator;
|
|
5184
5388
|
const badge = deps.badge ?? (typeof badgeNavigator.setAppBadge === "function" ? {
|
|
5185
5389
|
set: (contents) => badgeNavigator.setAppBadge?.(contents) ?? Promise.resolve(),
|
|
@@ -5190,7 +5394,7 @@ ${fallback} li::marker {
|
|
|
5190
5394
|
const statusStore = deps.statusSource ?? ctx.uiSession?.sessionStatus;
|
|
5191
5395
|
if (statusStore === void 0) return () => {};
|
|
5192
5396
|
try {
|
|
5193
|
-
localStorage.removeItem(
|
|
5397
|
+
localStorage.removeItem(LEGACY_STORAGE_KEY);
|
|
5194
5398
|
} catch {}
|
|
5195
5399
|
let painted;
|
|
5196
5400
|
/** Sessions that finished while the window was in the background. */
|
|
@@ -5218,7 +5422,7 @@ ${fallback} li::marker {
|
|
|
5218
5422
|
const paint = () => {
|
|
5219
5423
|
const byId = ctx.sessions.list.getSnapshot().byId;
|
|
5220
5424
|
observeRunning(byId);
|
|
5221
|
-
const count =
|
|
5425
|
+
const count = completionUnreadIds(byId, statusStore.getSnapshot(), attention).length;
|
|
5222
5426
|
if (painted === count) return;
|
|
5223
5427
|
painted = count;
|
|
5224
5428
|
paintHost(count);
|
|
@@ -8178,12 +8382,23 @@ ${fallback} li::marker {
|
|
|
8178
8382
|
*/
|
|
8179
8383
|
function apply(ctx) {
|
|
8180
8384
|
const t = ctx.locale.bind(LOCALE_NS);
|
|
8181
|
-
const
|
|
8385
|
+
const surface = currentSurface();
|
|
8386
|
+
const features = featuresFor(surface);
|
|
8182
8387
|
ctx.effect(() => ctx.locale.register(LOCALE_NS, {
|
|
8183
8388
|
zh,
|
|
8184
8389
|
en
|
|
8185
8390
|
}), "dsh-enhance: dictionaries");
|
|
8186
8391
|
installStyles(ctx);
|
|
8392
|
+
if (surface === "ds-bot") {
|
|
8393
|
+
ctx.effect(() => installSidebarBounce(document), "dsh-enhance: DS Bot sidebar bounce");
|
|
8394
|
+
ctx.inject(["layout"], (scope) => {
|
|
8395
|
+
scope.effect(() => installFooterPanels(scope, document, (target, Icon) => {
|
|
8396
|
+
const root = (0, react_dom_client.createRoot)(target);
|
|
8397
|
+
root.render(/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Icon, { size: 16 }));
|
|
8398
|
+
return () => root.unmount();
|
|
8399
|
+
}), "dsh-enhance: DS Bot footer panels");
|
|
8400
|
+
});
|
|
8401
|
+
}
|
|
8187
8402
|
if (features.whale) ctx.effect(() => installWhaleBubbles(document), "dsh-enhance: whale bubbles");
|
|
8188
8403
|
if (features.fileMenu) ctx.effect(() => installFileMenu(ctx, t), "dsh-enhance: file context menu");
|
|
8189
8404
|
if (features.sidebarFloor) {
|
package/lib/index.js
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
// src/badge-route.ts
|
|
2
|
-
/**
|
|
3
|
-
|
|
4
|
-
return surface === "ds-bot" ? "/ds-bot-enhance/badge" : "/dsh-enhance/badge";
|
|
5
|
-
}
|
|
6
|
-
/** DSH route, kept for callers and tests that predate surfaces. */
|
|
7
|
-
const BADGE_ROUTE = badgeRouteFor("dsh");
|
|
2
|
+
/** DSH's plugin-owned Dock badge route; DS Bot uses its own host badge. */
|
|
3
|
+
const BADGE_ROUTE = "/dsh-enhance/badge";
|
|
8
4
|
// src/index.ts
|
|
9
5
|
/** Largest request body this route reads; the payload is one small number. */
|
|
10
6
|
const MAX_BODY = 2048;
|
|
@@ -52,10 +48,11 @@ async function paintDockBadge(count) {
|
|
|
52
48
|
}
|
|
53
49
|
}
|
|
54
50
|
/**
|
|
55
|
-
* Mount
|
|
51
|
+
* Mount the DSH badge route on the Host's web server.
|
|
56
52
|
* @param ctx - host context carrying `webServer` and `connection`.
|
|
57
53
|
*/
|
|
58
54
|
function apply(ctx) {
|
|
55
|
+
if (process.env.DS_BOT_APP === "1") return;
|
|
59
56
|
const scope = ctx;
|
|
60
57
|
/** Register the routes once the services they need are present. */
|
|
61
58
|
const install = (host) => {
|
|
@@ -88,17 +85,12 @@ function apply(ctx) {
|
|
|
88
85
|
painted
|
|
89
86
|
}));
|
|
90
87
|
};
|
|
91
|
-
/**
|
|
92
|
-
const register = () => {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}));
|
|
98
|
-
return () => {
|
|
99
|
-
for (const stop of stops) stop();
|
|
100
|
-
};
|
|
101
|
-
};
|
|
88
|
+
/** Only DSH has a plugin-owned badge route. */
|
|
89
|
+
const register = () => webServer.register({
|
|
90
|
+
kind: "exact",
|
|
91
|
+
path: BADGE_ROUTE,
|
|
92
|
+
handler
|
|
93
|
+
});
|
|
102
94
|
const effect = host.effect;
|
|
103
95
|
if (typeof effect === "function") {
|
|
104
96
|
effect(register, "dsh-enhance: dock badge routes");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-enhance",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.12",
|
|
4
4
|
"description": "DeepSeek Harness enhancements: Markdown theme for every renderer, select-text annotations with pins, a file right-click menu, a narrower sidebar, and startup defaults (maximized window, narrowest sidebar, colourful running marker). 中文:DSH 增强插件——Markdown 主题、划词批注、文件右键菜单、侧栏宽度、启动默认状态。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|