dsh-ui-controller 0.2.5 → 0.2.7
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/CHANGELOG.md +19 -0
- package/README.md +16 -0
- package/client.js +361 -3
- package/icon.png +0 -0
- package/package.json +4 -4
- package/icon.svg +0 -8
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,25 @@
|
|
|
2
2
|
|
|
3
3
|
Notable changes to `dsh-ui-controller`.
|
|
4
4
|
|
|
5
|
+
## 0.2.7 — 2026-11-19
|
|
6
|
+
|
|
7
|
+
**Icon only: the plugin icon is now a PNG (meru family).**
|
|
8
|
+
|
|
9
|
+
## 0.2.6 — 2026-11-17
|
|
10
|
+
### Added
|
|
11
|
+
- **Chat scroll damping** (user m21832: 「uic里加个功能,给聊天页的滑动加个阻尼」).
|
|
12
|
+
A wheel over `[data-conversation-scroll]` is eased with an exponential step in
|
|
13
|
+
`requestAnimationFrame` instead of jumping; `deltaMode` 0/1/2 are normalised
|
|
14
|
+
(px / 16px per line / 90% of the viewport), and strength 1–5 maps to
|
|
15
|
+
`k = [0.10, 0.14, 0.18, 0.24, 0.32]`. New settings group 对话区滚动 / Chat
|
|
16
|
+
scrolling with two live controls: `chatScroll.damping` (default on) and a
|
|
17
|
+
strength stepper (default 3).
|
|
18
|
+
- The easing never fights the host: any `scroll` landing more than 2px from the
|
|
19
|
+
value we last wrote cancels it (autofollow during streaming wins), top/bottom
|
|
20
|
+
wheels are left to the page so native overscroll survives, and nested scrollers
|
|
21
|
+
(terminals, overflowing code blocks, inner lists) keep their own wheel.
|
|
22
|
+
`prefers-reduced-motion: reduce` installs no listener at all.
|
|
23
|
+
|
|
5
24
|
## 0.2.5 — 2026-11-17
|
|
6
25
|
### Changed
|
|
7
26
|
- The 127 module-level declarations now live inside the loader factory: the
|
package/README.md
CHANGED
|
@@ -87,6 +87,22 @@ is missing, this is the plugin that answers that.
|
|
|
87
87
|
teardown; a row we cannot identify is left alone. Nothing else is touched: no
|
|
88
88
|
custom panel rows, no icon replacement, and the settings dialog's own nav
|
|
89
89
|
width is left alone.
|
|
90
|
+
7. **Chat scrolling: wheel damping.** A wheel over the chat pane is eased instead of
|
|
91
|
+
jumping: each tick is normalised (`deltaMode` 0 px / 1 ×16 px per line / 2 ×90% of
|
|
92
|
+
the viewport), added to a target `scrollTop`, and stepped toward it in
|
|
93
|
+
`requestAnimationFrame` with an exponential factor. Strength 1–5 maps to
|
|
94
|
+
`k = [0.10, 0.14, 0.18, 0.24, 0.32]` (default 3), and `chatScroll.damping`
|
|
95
|
+
(default on) switches it off entirely; both apply live. The container is the
|
|
96
|
+
host's `[data-conversation-scroll]` — the class beside it is hashed and is never
|
|
97
|
+
used. Three rules keep it from fighting the page: **the host always wins** (a
|
|
98
|
+
`scroll` that lands more than 2px from the value we last wrote cancels the easing
|
|
99
|
+
and re-syncs — autofollow while streaming keeps working), **the page is never
|
|
100
|
+
trapped** (up at the top or down at the bottom leaves the event alone, so native
|
|
101
|
+
overscroll stays), and **nested scrollers keep their own wheel** (a terminal, an
|
|
102
|
+
overflowing code block or an inner list is not ours to slow down). Keys
|
|
103
|
+
(PageUp/PageDown/Home/End/arrows/space), pointerdown, touchstart and window blur
|
|
104
|
+
all cancel immediately; `prefers-reduced-motion: reduce` installs no listener at
|
|
105
|
+
all.
|
|
90
106
|
|
|
91
107
|
## What it deliberately does **not** do
|
|
92
108
|
|
package/client.js
CHANGED
|
@@ -30,7 +30,7 @@ window.__ModuleLoader__.load({
|
|
|
30
30
|
id: 'dsh-ui-controller',
|
|
31
31
|
factory(require) {
|
|
32
32
|
|
|
33
|
-
const VERSION = '0.2.
|
|
33
|
+
const VERSION = '0.2.7';
|
|
34
34
|
|
|
35
35
|
const NS = 'uiController';
|
|
36
36
|
const SECTION_ID = 'ui-controller';
|
|
@@ -46,6 +46,30 @@ window.__ModuleLoader__.load({
|
|
|
46
46
|
const STYLE_ID = 'ui-controller-style';
|
|
47
47
|
const ROW_ATTR = 'data-uic-row';
|
|
48
48
|
|
|
49
|
+
/* Chat scroll damping (0.2.6).
|
|
50
|
+
The chat scroller is the host's `[data-conversation-scroll]` box — the class
|
|
51
|
+
next to it is hashed, so the data attribute is the only stable handle.
|
|
52
|
+
`CHAT_SCROLL_K` is the whole strength→speed table: index = strength - 1. */
|
|
53
|
+
const CHAT_SCROLL_SELECTOR = '[data-conversation-scroll]';
|
|
54
|
+
const CHAT_SCROLL_K = [0.1, 0.14, 0.18, 0.24, 0.32];
|
|
55
|
+
const CHAT_SCROLL_DEFAULT_STRENGTH = 3;
|
|
56
|
+
const CHAT_SCROLL_LINE_PX = 16;
|
|
57
|
+
const CHAT_SCROLL_PAGE_RATIO = 0.9;
|
|
58
|
+
const CHAT_SCROLL_SETTLE_PX = 1;
|
|
59
|
+
const CHAT_SCROLL_HOST_DRIFT_PX = 2;
|
|
60
|
+
const CHAT_SCROLL_CANCEL_KEYS = new Set([
|
|
61
|
+
'PageUp',
|
|
62
|
+
'PageDown',
|
|
63
|
+
'Home',
|
|
64
|
+
'End',
|
|
65
|
+
'ArrowUp',
|
|
66
|
+
'ArrowDown',
|
|
67
|
+
'ArrowLeft',
|
|
68
|
+
'ArrowRight',
|
|
69
|
+
' ',
|
|
70
|
+
'Spacebar',
|
|
71
|
+
]);
|
|
72
|
+
|
|
49
73
|
const HIDE_CSS = [
|
|
50
74
|
'[' + HIDDEN_ATTR + '="1"]{display:none !important}',
|
|
51
75
|
'[' + HIDDEN_ATTR + '="1"]:is(li,tr){display:none !important}',
|
|
@@ -307,6 +331,48 @@ window.__ModuleLoader__.load({
|
|
|
307
331
|
return Math.min(max, Math.max(min, value));
|
|
308
332
|
}
|
|
309
333
|
|
|
334
|
+
/* ------------------------------------------------- chat scroll damping maths */
|
|
335
|
+
|
|
336
|
+
/** One wheel tick in pixels: lines and pages become px so the rest can stay dumb. */
|
|
337
|
+
function normalizeWheelDelta(delta, deltaMode, clientHeight) {
|
|
338
|
+
const value = Number.isFinite(delta) ? delta : 0;
|
|
339
|
+
if (deltaMode === 1) return value * CHAT_SCROLL_LINE_PX;
|
|
340
|
+
if (deltaMode === 2) return value * Math.max(0, Number(clientHeight) || 0) * CHAT_SCROLL_PAGE_RATIO;
|
|
341
|
+
return value;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/** One exponential easing step; `done` means "land on target exactly". */
|
|
345
|
+
function dampNext(cur, target, k) {
|
|
346
|
+
const from = Number.isFinite(cur) ? cur : 0;
|
|
347
|
+
const to = Number.isFinite(target) ? target : from;
|
|
348
|
+
const ratio = Number.isFinite(k) ? clamp(k, 0.01, 0.99) : CHAT_SCROLL_K[CHAT_SCROLL_DEFAULT_STRENGTH - 1];
|
|
349
|
+
const gap = to - from;
|
|
350
|
+
if (Math.abs(gap) < CHAT_SCROLL_SETTLE_PX) return { next: to, done: true };
|
|
351
|
+
return { next: from + gap * ratio, done: false };
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
function clampScrollTop(value, max) {
|
|
355
|
+
const top = Number.isFinite(value) ? value : 0;
|
|
356
|
+
const limit = Number.isFinite(max) ? Math.max(0, max) : 0;
|
|
357
|
+
return clamp(top, 0, limit);
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
/** Strength 1–5 → k. Anything else falls back to the shipped default. */
|
|
361
|
+
function strengthToK(strength) {
|
|
362
|
+
const index = Math.round(Number(strength));
|
|
363
|
+
if (Number.isFinite(index) === false) return CHAT_SCROLL_K[CHAT_SCROLL_DEFAULT_STRENGTH - 1];
|
|
364
|
+
return CHAT_SCROLL_K[clamp(index, 1, CHAT_SCROLL_K.length) - 1];
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
function sanitizeChatScroll(raw) {
|
|
368
|
+
const base = { damping: true, strength: CHAT_SCROLL_DEFAULT_STRENGTH };
|
|
369
|
+
if (isPlainObject(raw) === false) return base;
|
|
370
|
+
return {
|
|
371
|
+
damping: raw.damping !== false,
|
|
372
|
+
strength: clamp(Math.round(Number(raw.strength) || CHAT_SCROLL_DEFAULT_STRENGTH), 1, CHAT_SCROLL_K.length),
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
|
|
310
376
|
function catalogByKey() {
|
|
311
377
|
const map = new Map();
|
|
312
378
|
for (const slot of SLOT_CATALOG) map.set(slot.key, slot);
|
|
@@ -326,6 +392,7 @@ window.__ModuleLoader__.load({
|
|
|
326
392
|
presets: {},
|
|
327
393
|
activePreset: null,
|
|
328
394
|
sidebarMore: { foldAll: true },
|
|
395
|
+
chatScroll: { damping: true, strength: CHAT_SCROLL_DEFAULT_STRENGTH },
|
|
329
396
|
};
|
|
330
397
|
}
|
|
331
398
|
|
|
@@ -424,6 +491,7 @@ window.__ModuleLoader__.load({
|
|
|
424
491
|
next.presets = sanitizePresets(raw.presets);
|
|
425
492
|
next.activePreset = typeof raw.activePreset === 'string' && hasOwn(next.presets, raw.activePreset) ? raw.activePreset : null;
|
|
426
493
|
next.sidebarMore = isPlainObject(raw.sidebarMore) ? { foldAll: raw.sidebarMore.foldAll !== false } : { foldAll: true };
|
|
494
|
+
next.chatScroll = sanitizeChatScroll(raw.chatScroll);
|
|
427
495
|
return next;
|
|
428
496
|
}
|
|
429
497
|
|
|
@@ -512,6 +580,7 @@ window.__ModuleLoader__.load({
|
|
|
512
580
|
presets: isPlainObject(patch.presets) ? patch.presets : base.presets,
|
|
513
581
|
activePreset: hasOwn(patch, 'activePreset') ? patch.activePreset : base.activePreset,
|
|
514
582
|
sidebarMore: { ...(isPlainObject(base.sidebarMore) ? base.sidebarMore : {}), ...(isPlainObject(patch.sidebarMore) ? patch.sidebarMore : {}) },
|
|
583
|
+
chatScroll: { ...(isPlainObject(base.chatScroll) ? base.chatScroll : {}), ...(isPlainObject(patch.chatScroll) ? patch.chatScroll : {}) },
|
|
515
584
|
});
|
|
516
585
|
}
|
|
517
586
|
|
|
@@ -1054,6 +1123,11 @@ window.__ModuleLoader__.load({
|
|
|
1054
1123
|
'settings.sidebarMore.unfold': '放到外面',
|
|
1055
1124
|
'settings.sidebarMore.foldAllAction': '全部收进更多',
|
|
1056
1125
|
'settings.sidebarMore.unfoldAllAction': '全部放回外面',
|
|
1126
|
+
'settings.chatScroll.title': '对话区滚动',
|
|
1127
|
+
'settings.chatScroll.hint': '给聊天区滚轮加一点惯性;侧栏和弹层不受影响。滚到顶或到底时照旧交给页面,原生回弹还在。',
|
|
1128
|
+
'settings.chatScroll.damping': '滚轮阻尼',
|
|
1129
|
+
'settings.chatScroll.strength': '阻尼强度',
|
|
1130
|
+
'settings.chatScroll.strengthHint': '1 最接近原生,5 滑得最远。改完立即生效。',
|
|
1057
1131
|
};
|
|
1058
1132
|
|
|
1059
1133
|
const EN = {
|
|
@@ -1115,6 +1189,11 @@ window.__ModuleLoader__.load({
|
|
|
1115
1189
|
'settings.sidebarMore.unfold': 'Show outside',
|
|
1116
1190
|
'settings.sidebarMore.foldAllAction': 'Fold all into More',
|
|
1117
1191
|
'settings.sidebarMore.unfoldAllAction': 'Put all back outside',
|
|
1192
|
+
'settings.chatScroll.title': 'Chat scrolling',
|
|
1193
|
+
'settings.chatScroll.hint': 'Adds momentum to the wheel in the chat pane only — the sidebar and popouts are untouched. Top and bottom still belong to the page, so native overscroll stays.',
|
|
1194
|
+
'settings.chatScroll.damping': 'Wheel damping',
|
|
1195
|
+
'settings.chatScroll.strength': 'Strength',
|
|
1196
|
+
'settings.chatScroll.strengthHint': '1 is closest to native, 5 glides furthest. Applies immediately.',
|
|
1118
1197
|
};
|
|
1119
1198
|
|
|
1120
1199
|
const DICTS = { zh: ZH, en: EN };
|
|
@@ -1636,6 +1715,56 @@ window.__ModuleLoader__.load({
|
|
|
1636
1715
|
]),
|
|
1637
1716
|
]);
|
|
1638
1717
|
|
|
1718
|
+
const dampingOn = state.chatScroll?.damping !== false;
|
|
1719
|
+
const strength = clamp(Math.round(Number(state.chatScroll?.strength) || CHAT_SCROLL_DEFAULT_STRENGTH), 1, CHAT_SCROLL_K.length);
|
|
1720
|
+
const setStrength = (value) =>
|
|
1721
|
+
commit({ ...state, chatScroll: { ...(isPlainObject(state.chatScroll) ? state.chatScroll : {}), strength: clamp(value, 1, CHAT_SCROLL_K.length) } });
|
|
1722
|
+
const chatScrollBlock = node('div', { key: 'chatScroll', className: 'uic-sidebarMore', 'data-uic-chat-scroll': '1' }, [
|
|
1723
|
+
node('h3', { key: 'h', className: 'uic-h3' }, t('settings.chatScroll.title')),
|
|
1724
|
+
node('p', { key: 'hint', className: 'uic-dim' }, t('settings.chatScroll.hint')),
|
|
1725
|
+
node('label', { key: 'damping', className: 'uic-sidebarMoreRow' }, [
|
|
1726
|
+
node('input', {
|
|
1727
|
+
key: 'box',
|
|
1728
|
+
type: 'checkbox',
|
|
1729
|
+
'data-uic-chat-scroll-damping': dampingOn ? 'true' : 'false',
|
|
1730
|
+
checked: dampingOn,
|
|
1731
|
+
onChange: (event) => commit({ ...state, chatScroll: { ...(isPlainObject(state.chatScroll) ? state.chatScroll : {}), damping: event.target.checked === true } }),
|
|
1732
|
+
}),
|
|
1733
|
+
node('span', { key: 'text' }, t('settings.chatScroll.damping')),
|
|
1734
|
+
]),
|
|
1735
|
+
node('div', { key: 'strength', className: 'uic-sidebarMoreRow' }, [
|
|
1736
|
+
node('span', { key: 'label' }, t('settings.chatScroll.strength')),
|
|
1737
|
+
node('span', { key: 'ctl', className: 'uic-ctl' }, [
|
|
1738
|
+
node(
|
|
1739
|
+
'button',
|
|
1740
|
+
{
|
|
1741
|
+
key: 'minus',
|
|
1742
|
+
type: 'button',
|
|
1743
|
+
className: 'uic-btn',
|
|
1744
|
+
'data-uic-chat-scroll-slower': '1',
|
|
1745
|
+
disabled: dampingOn === false || strength <= 1,
|
|
1746
|
+
onClick: () => setStrength(strength - 1),
|
|
1747
|
+
},
|
|
1748
|
+
'-',
|
|
1749
|
+
),
|
|
1750
|
+
node('span', { key: 'value', className: 'uic-num', 'data-uic-chat-scroll-strength': String(strength) }, String(strength)),
|
|
1751
|
+
node(
|
|
1752
|
+
'button',
|
|
1753
|
+
{
|
|
1754
|
+
key: 'plus',
|
|
1755
|
+
type: 'button',
|
|
1756
|
+
className: 'uic-btn',
|
|
1757
|
+
'data-uic-chat-scroll-faster': '1',
|
|
1758
|
+
disabled: dampingOn === false || strength >= CHAT_SCROLL_K.length,
|
|
1759
|
+
onClick: () => setStrength(strength + 1),
|
|
1760
|
+
},
|
|
1761
|
+
'+',
|
|
1762
|
+
),
|
|
1763
|
+
]),
|
|
1764
|
+
]),
|
|
1765
|
+
node('p', { key: 'strengthHint', className: 'uic-dim' }, t('settings.chatScroll.strengthHint')),
|
|
1766
|
+
]);
|
|
1767
|
+
|
|
1639
1768
|
return node('div', { className: 'uic-page', 'data-uic-page': '1' }, [
|
|
1640
1769
|
node('h2', { key: 'title', className: 'uic-title' }, t('settings.title')),
|
|
1641
1770
|
node('p', { key: 'lead', className: 'uic-lead' }, t('settings.lead')),
|
|
@@ -1720,6 +1849,7 @@ window.__ModuleLoader__.load({
|
|
|
1720
1849
|
node('p', { key: 'order-hint', className: 'uic-dim' }, t('settings.orderHint')),
|
|
1721
1850
|
node('p', { key: 'order-hint-2', className: 'uic-dim' }, t('settings.orderHint2')),
|
|
1722
1851
|
sidebarMoreBlock,
|
|
1852
|
+
chatScrollBlock,
|
|
1723
1853
|
node('button', { key: 'reset', className: 'uic-btn uic-btn-quiet', type: 'button', 'data-uic-reset': '1', onClick: onReset }, armed ? t('settings.resetOnce') : t('settings.reset')),
|
|
1724
1854
|
]);
|
|
1725
1855
|
}
|
|
@@ -2275,6 +2405,215 @@ window.__ModuleLoader__.load({
|
|
|
2275
2405
|
if (title.textContent !== base) title.textContent = base;
|
|
2276
2406
|
}
|
|
2277
2407
|
|
|
2408
|
+
/**
|
|
2409
|
+
* Wheel damping for the chat scroller.
|
|
2410
|
+
*
|
|
2411
|
+
* Three rules decide every branch in here:
|
|
2412
|
+
* 1. the host always wins — a `scroll` that lands more than 2px away from the
|
|
2413
|
+
* value we last wrote means somebody else moved the box (autofollow while
|
|
2414
|
+
* streaming, jump-to-bottom), so we drop the easing and re-sync instead of
|
|
2415
|
+
* fighting it. Two writers on one scrollTop is exactly the jitter this is
|
|
2416
|
+
* supposed to avoid;
|
|
2417
|
+
* 2. the page is never trapped — a wheel the box cannot honour (up at the top,
|
|
2418
|
+
* down at the bottom) is left to the browser, `defaultPrevented` stays false;
|
|
2419
|
+
* 3. a nested scroller keeps its own wheel — terminals, overflowing code blocks
|
|
2420
|
+
* and inner lists scroll themselves and are not ours to slow down.
|
|
2421
|
+
*
|
|
2422
|
+
* `sync(settings)` is idempotent: the 2s pass and every settings write call it.
|
|
2423
|
+
*/
|
|
2424
|
+
function createChatDamping(options) {
|
|
2425
|
+
const doc = options.doc ?? null;
|
|
2426
|
+
const view = options.view ?? (doc === null ? null : doc.defaultView ?? null);
|
|
2427
|
+
const getSettings = options.getSettings;
|
|
2428
|
+
const log = typeof options.log === 'function' ? options.log : () => {};
|
|
2429
|
+
|
|
2430
|
+
let host = null;
|
|
2431
|
+
let frame = 0;
|
|
2432
|
+
let expected = null;
|
|
2433
|
+
let target = 0;
|
|
2434
|
+
let listening = false;
|
|
2435
|
+
const stats = { frames: 0, wheels: 0, cancels: 0, lastCancel: '' };
|
|
2436
|
+
|
|
2437
|
+
const nowMs = () => Date.now();
|
|
2438
|
+
|
|
2439
|
+
const requestFrame = (callback) => {
|
|
2440
|
+
if (view !== null && typeof view.requestAnimationFrame === 'function') return view.requestAnimationFrame(callback);
|
|
2441
|
+
return setTimeout(callback, 16);
|
|
2442
|
+
};
|
|
2443
|
+
|
|
2444
|
+
const cancelFrame = (id) => {
|
|
2445
|
+
if (view !== null && typeof view.cancelAnimationFrame === 'function') view.cancelAnimationFrame(id);
|
|
2446
|
+
else clearTimeout(id);
|
|
2447
|
+
};
|
|
2448
|
+
|
|
2449
|
+
const maxScrollTop = () => {
|
|
2450
|
+
if (host === null) return 0;
|
|
2451
|
+
const height = Number(host.scrollHeight) || 0;
|
|
2452
|
+
const seen = Number(host.clientHeight) || 0;
|
|
2453
|
+
return Math.max(0, height - seen);
|
|
2454
|
+
};
|
|
2455
|
+
|
|
2456
|
+
const reducedMotion = () => {
|
|
2457
|
+
if (view === null || typeof view.matchMedia !== 'function') return false;
|
|
2458
|
+
try {
|
|
2459
|
+
return view.matchMedia('(prefers-reduced-motion: reduce)').matches === true;
|
|
2460
|
+
} catch {
|
|
2461
|
+
return false;
|
|
2462
|
+
}
|
|
2463
|
+
};
|
|
2464
|
+
|
|
2465
|
+
const write = (value) => {
|
|
2466
|
+
if (host === null) return;
|
|
2467
|
+
expected = value;
|
|
2468
|
+
host.scrollTop = value;
|
|
2469
|
+
};
|
|
2470
|
+
|
|
2471
|
+
/** Stop driving. `reason` only lands in the stats so the console can say why. */
|
|
2472
|
+
const stop = (reason) => {
|
|
2473
|
+
const wasDriving = expected !== null;
|
|
2474
|
+
if (frame !== 0) {
|
|
2475
|
+
cancelFrame(frame);
|
|
2476
|
+
frame = 0;
|
|
2477
|
+
}
|
|
2478
|
+
expected = null;
|
|
2479
|
+
target = host === null ? 0 : Number(host.scrollTop) || 0;
|
|
2480
|
+
if (wasDriving === true) {
|
|
2481
|
+
stats.cancels += 1;
|
|
2482
|
+
stats.lastCancel = reason + ' @' + nowMs();
|
|
2483
|
+
}
|
|
2484
|
+
};
|
|
2485
|
+
|
|
2486
|
+
const step = () => {
|
|
2487
|
+
frame = 0;
|
|
2488
|
+
if (host === null) return;
|
|
2489
|
+
const settings = getSettings();
|
|
2490
|
+
const k = strengthToK(settings?.chatScroll?.strength);
|
|
2491
|
+
const result = dampNext(Number(host.scrollTop) || 0, target, k);
|
|
2492
|
+
write(result.next);
|
|
2493
|
+
stats.frames += 1;
|
|
2494
|
+
if (result.done === true) {
|
|
2495
|
+
expected = null;
|
|
2496
|
+
return;
|
|
2497
|
+
}
|
|
2498
|
+
frame = requestFrame(step);
|
|
2499
|
+
};
|
|
2500
|
+
|
|
2501
|
+
const start = () => {
|
|
2502
|
+
if (frame !== 0) return;
|
|
2503
|
+
frame = requestFrame(step);
|
|
2504
|
+
};
|
|
2505
|
+
|
|
2506
|
+
/** True when `node` sits inside a scroller of its own, between `event.target` and us. */
|
|
2507
|
+
const scrollsItself = (node) => {
|
|
2508
|
+
if (node === null || node === undefined || typeof node !== 'object') return false;
|
|
2509
|
+
if (typeof node.scrollHeight !== 'number' || typeof node.clientHeight !== 'number') return false;
|
|
2510
|
+
if (node.scrollHeight - node.clientHeight < 1) return false;
|
|
2511
|
+
const style = view !== null && typeof view.getComputedStyle === 'function' ? view.getComputedStyle(node) : null;
|
|
2512
|
+
const overflow = style === null ? '' : String(style.overflowY ?? '');
|
|
2513
|
+
return overflow === 'auto' || overflow === 'scroll' || overflow === 'overlay';
|
|
2514
|
+
};
|
|
2515
|
+
|
|
2516
|
+
const nestedScroller = (from, root) => {
|
|
2517
|
+
let node = from;
|
|
2518
|
+
for (let depth = 0; node !== null && node !== undefined && node !== root && depth < 64; depth += 1) {
|
|
2519
|
+
if (scrollsItself(node) === true) return true;
|
|
2520
|
+
node = node.parentElement ?? null;
|
|
2521
|
+
}
|
|
2522
|
+
return false;
|
|
2523
|
+
};
|
|
2524
|
+
|
|
2525
|
+
const onWheel = (event) => {
|
|
2526
|
+
if (host === null || event === null || event === undefined) return;
|
|
2527
|
+
/* Ctrl+wheel is zoom, not scroll. */
|
|
2528
|
+
if (event.ctrlKey === true) return;
|
|
2529
|
+
if (nestedScroller(event.target ?? null, host) === true) return;
|
|
2530
|
+
const delta = normalizeWheelDelta(event.deltaY, event.deltaMode, host.clientHeight);
|
|
2531
|
+
if (delta === 0) return;
|
|
2532
|
+
const from = frame !== 0 ? target : Number(host.scrollTop) || 0;
|
|
2533
|
+
const next = clampScrollTop(from + delta, maxScrollTop());
|
|
2534
|
+
/* Nothing to give in that direction: leave the page front and centre. */
|
|
2535
|
+
if (Math.abs(next - from) < 0.5) return;
|
|
2536
|
+
if (typeof event.preventDefault === 'function') event.preventDefault();
|
|
2537
|
+
stats.wheels += 1;
|
|
2538
|
+
target = next;
|
|
2539
|
+
if (frame === 0) {
|
|
2540
|
+
expected = Number(host.scrollTop) || 0;
|
|
2541
|
+
start();
|
|
2542
|
+
}
|
|
2543
|
+
};
|
|
2544
|
+
|
|
2545
|
+
const onScroll = () => {
|
|
2546
|
+
if (host === null || expected === null) return;
|
|
2547
|
+
const actual = Number(host.scrollTop) || 0;
|
|
2548
|
+
if (Math.abs(actual - expected) <= CHAT_SCROLL_HOST_DRIFT_PX) return;
|
|
2549
|
+
stop('host moved scrollTop by ' + (actual - expected).toFixed(1));
|
|
2550
|
+
};
|
|
2551
|
+
|
|
2552
|
+
const onKeyDown = (event) => {
|
|
2553
|
+
const key = event === null || event === undefined ? '' : String(event.key ?? '');
|
|
2554
|
+
if (CHAT_SCROLL_CANCEL_KEYS.has(key) === false) return;
|
|
2555
|
+
stop('key ' + key);
|
|
2556
|
+
};
|
|
2557
|
+
|
|
2558
|
+
const onPointerDown = () => stop('pointerdown');
|
|
2559
|
+
const onTouchStart = () => stop('touchstart');
|
|
2560
|
+
const onBlur = () => stop('blur');
|
|
2561
|
+
|
|
2562
|
+
const attach = () => {
|
|
2563
|
+
if (host === null || listening === true) return;
|
|
2564
|
+
host.addEventListener('wheel', onWheel, { passive: false });
|
|
2565
|
+
host.addEventListener('scroll', onScroll, { passive: true });
|
|
2566
|
+
if (doc !== null && typeof doc.addEventListener === 'function') {
|
|
2567
|
+
doc.addEventListener('keydown', onKeyDown, true);
|
|
2568
|
+
doc.addEventListener('pointerdown', onPointerDown, true);
|
|
2569
|
+
doc.addEventListener('touchstart', onTouchStart, { passive: true, capture: true });
|
|
2570
|
+
}
|
|
2571
|
+
if (view !== null && typeof view.addEventListener === 'function') view.addEventListener('blur', onBlur);
|
|
2572
|
+
listening = true;
|
|
2573
|
+
};
|
|
2574
|
+
|
|
2575
|
+
const detach = () => {
|
|
2576
|
+
stop('detach');
|
|
2577
|
+
if (host !== null) {
|
|
2578
|
+
host.removeEventListener('wheel', onWheel, { passive: false });
|
|
2579
|
+
host.removeEventListener('scroll', onScroll, { passive: true });
|
|
2580
|
+
}
|
|
2581
|
+
if (doc !== null && typeof doc.removeEventListener === 'function') {
|
|
2582
|
+
doc.removeEventListener('keydown', onKeyDown, true);
|
|
2583
|
+
doc.removeEventListener('pointerdown', onPointerDown, true);
|
|
2584
|
+
doc.removeEventListener('touchstart', onTouchStart, true);
|
|
2585
|
+
}
|
|
2586
|
+
if (view !== null && typeof view.removeEventListener === 'function') view.removeEventListener('blur', onBlur);
|
|
2587
|
+
listening = false;
|
|
2588
|
+
};
|
|
2589
|
+
|
|
2590
|
+
/** Mount, move or unmount the damper for the current settings — safe to call often. */
|
|
2591
|
+
const sync = (settings) => {
|
|
2592
|
+
const current = settings ?? (typeof getSettings === 'function' ? getSettings() : null);
|
|
2593
|
+
const wanted = current?.chatScroll?.damping !== false && reducedMotion() === false;
|
|
2594
|
+
const found = wanted === false || doc === null || typeof doc.querySelector !== 'function'
|
|
2595
|
+
? null
|
|
2596
|
+
: doc.querySelector(CHAT_SCROLL_SELECTOR);
|
|
2597
|
+
if (found === host && (wanted === false || listening === true)) return host;
|
|
2598
|
+
detach();
|
|
2599
|
+
host = found;
|
|
2600
|
+
if (wanted === false) {
|
|
2601
|
+
log('chat scroll damping:', reducedMotion() === true ? 'reduced motion' : 'off');
|
|
2602
|
+
return null;
|
|
2603
|
+
}
|
|
2604
|
+
if (host === null) return null;
|
|
2605
|
+
target = Number(host.scrollTop) || 0;
|
|
2606
|
+
attach();
|
|
2607
|
+
return host;
|
|
2608
|
+
};
|
|
2609
|
+
|
|
2610
|
+
return {
|
|
2611
|
+
sync,
|
|
2612
|
+
stop,
|
|
2613
|
+
stats: () => ({ ...stats, listening, damping: host !== null, frame }),
|
|
2614
|
+
};
|
|
2615
|
+
}
|
|
2616
|
+
|
|
2278
2617
|
function apply(ctx) {
|
|
2279
2618
|
const doc = typeof document === 'undefined' ? null : document;
|
|
2280
2619
|
const slots = ctx.get('slots');
|
|
@@ -2386,8 +2725,7 @@ window.__ModuleLoader__.load({
|
|
|
2386
2725
|
|
|
2387
2726
|
injectStyle(doc);
|
|
2388
2727
|
ctx.effect(() => () => {
|
|
2389
|
-
if (moreObserver !== null && typeof moreObserver.disconnect === 'function') moreObserver.disconnect();
|
|
2390
|
-
for (const [row, original] of moreTouched) {
|
|
2728
|
+
if (moreObserver !== null && typeof moreObserver.disconnect === 'function') moreObserver.disconnect(); for (const [row, original] of moreTouched) {
|
|
2391
2729
|
if (row.style !== undefined) row.style.display = original;
|
|
2392
2730
|
}
|
|
2393
2731
|
moreTouched.clear();
|
|
@@ -2395,6 +2733,7 @@ window.__ModuleLoader__.load({
|
|
|
2395
2733
|
sidebarPanels = [];
|
|
2396
2734
|
sidebarReplayQueued = false;
|
|
2397
2735
|
stopPicking();
|
|
2736
|
+
chatDamping.stop('teardown');
|
|
2398
2737
|
removeStyle(doc);
|
|
2399
2738
|
if (doc !== null) {
|
|
2400
2739
|
for (const element of Array.from(doc.querySelectorAll('[' + HIDDEN_ATTR + ']'))) element.removeAttribute(HIDDEN_ATTR);
|
|
@@ -2404,12 +2743,22 @@ window.__ModuleLoader__.load({
|
|
|
2404
2743
|
/** Elements we wrote `style.order` to; cleared before every pass and on teardown. */
|
|
2405
2744
|
const ordered = [];
|
|
2406
2745
|
|
|
2746
|
+
/* One damper for the whole session. It finds the chat scroller itself, so a
|
|
2747
|
+
container the host re-creates is picked up by the same 2s pass. */
|
|
2748
|
+
const chatDamping = createChatDamping({
|
|
2749
|
+
doc,
|
|
2750
|
+
view: doc === null ? null : (doc.defaultView ?? null),
|
|
2751
|
+
getSettings: () => readSettings(),
|
|
2752
|
+
log: (...args) => console.debug('[ui-controller]', ...args),
|
|
2753
|
+
});
|
|
2754
|
+
|
|
2407
2755
|
const applyAll = () => {
|
|
2408
2756
|
const current = readSettings();
|
|
2409
2757
|
applyHidden();
|
|
2410
2758
|
applyVisualOrder(doc, current, ordered);
|
|
2411
2759
|
applyFold();
|
|
2412
2760
|
normalizeTitle();
|
|
2761
|
+
chatDamping.sync(current);
|
|
2413
2762
|
}; applyAll();
|
|
2414
2763
|
const timer = setInterval(applyAll, 2000);
|
|
2415
2764
|
ctx.effect(() => () => clearInterval(timer), 'ui-controller: reapply timer');
|
|
@@ -2465,6 +2814,7 @@ window.__ModuleLoader__.load({
|
|
|
2465
2814
|
inventory: () => inventory(),
|
|
2466
2815
|
catalog: () => SLOT_CATALOG.map((slot) => ({ ...slot })),
|
|
2467
2816
|
catalogSummary: () => ({ total: SLOT_CATALOG.length, kinds: kindCounts() }),
|
|
2817
|
+
chatScroll: () => chatDamping.stats(),
|
|
2468
2818
|
apply: applyAll,
|
|
2469
2819
|
};
|
|
2470
2820
|
|
|
@@ -2545,6 +2895,14 @@ window.__ModuleLoader__.load({
|
|
|
2545
2895
|
sampleMoreItem,
|
|
2546
2896
|
SidebarMoreMenu,
|
|
2547
2897
|
DICTS,
|
|
2898
|
+
CHAT_SCROLL_SELECTOR,
|
|
2899
|
+
CHAT_SCROLL_K,
|
|
2900
|
+
normalizeWheelDelta,
|
|
2901
|
+
dampNext,
|
|
2902
|
+
clampScrollTop,
|
|
2903
|
+
strengthToK,
|
|
2904
|
+
sanitizeChatScroll,
|
|
2905
|
+
createChatDamping,
|
|
2548
2906
|
};
|
|
2549
2907
|
},
|
|
2550
2908
|
});
|
package/icon.png
ADDED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-ui-controller",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.7",
|
|
4
4
|
"description": "Inspect and control the UI other plugins register into DeepSeek Harness slots (visibility, order, mirrored entries), and fold the sidebar's panels behind a single \"More (N)\" row.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"./client": "./client.js",
|
|
23
23
|
"./package.json": "./package.json",
|
|
24
24
|
"./locale/*.json": "./locale/*.json",
|
|
25
|
-
"./icon": "./icon.
|
|
25
|
+
"./icon": "./icon.png"
|
|
26
26
|
},
|
|
27
27
|
"files": [
|
|
28
28
|
"index.js",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"README.md",
|
|
32
32
|
"LICENSE",
|
|
33
33
|
"locale",
|
|
34
|
-
"icon.
|
|
34
|
+
"icon.png",
|
|
35
35
|
"CHANGELOG.md"
|
|
36
36
|
],
|
|
37
37
|
"dsh": {
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"platform": "web"
|
|
43
43
|
}
|
|
44
44
|
},
|
|
45
|
-
"icon": "./icon.
|
|
45
|
+
"icon": "./icon.png"
|
|
46
46
|
}
|
package/icon.svg
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" fill="none">
|
|
2
|
-
<rect x="4.5" y="6" width="23" height="4.5" rx="2" fill="#7C8B9A"/>
|
|
3
|
-
<rect x="4.5" y="13.75" width="23" height="4.5" rx="2" fill="#5B6B7C"/>
|
|
4
|
-
<rect x="4.5" y="21.5" width="23" height="4.5" rx="2" fill="#C3CED8"/>
|
|
5
|
-
<circle cx="24.5" cy="8.25" r="1.4" fill="#fff"/>
|
|
6
|
-
<circle cx="24.5" cy="16" r="1.4" fill="#fff"/>
|
|
7
|
-
<circle cx="7.5" cy="23.75" r="1.4" fill="#fff"/>
|
|
8
|
-
</svg>
|