dsh-ui-controller 0.2.2 → 0.2.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/CHANGELOG.md +12 -0
- package/README.md +5 -2
- package/client.js +102 -19
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
Notable changes to `dsh-ui-controller`.
|
|
4
4
|
|
|
5
|
+
## 0.2.3 — 2026-11-15
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
|
|
9
|
+
- **The number after More is the sidebar's own truth.** It used to come from
|
|
10
|
+
our fold record, while the rows actually off screen are decided by the host's
|
|
11
|
+
pin state — so a record naming two panels could sit next to five hidden rows
|
|
12
|
+
and paint `更多 (2)`. `foldedRowCount` now counts "panels we know about minus
|
|
13
|
+
rows still on screen", reading `display:none` on the row and on any wrapper
|
|
14
|
+
the fold pass hid. When the sidebar cannot be read (collapsed, not mounted) the
|
|
15
|
+
launcher keeps its bare label instead of guessing a zero.
|
|
16
|
+
|
|
5
17
|
## 0.2.2 — 2026-11-15
|
|
6
18
|
|
|
7
19
|
### Fixed
|
package/README.md
CHANGED
|
@@ -186,7 +186,7 @@ Two sentences that belong in any answer about ordering:
|
|
|
186
186
|
node --check client.js
|
|
187
187
|
node --check index.js
|
|
188
188
|
node --check test/classify.test.mjs
|
|
189
|
-
node test/classify.test.mjs # expect: PASS —
|
|
189
|
+
node test/classify.test.mjs # expect: PASS — 41 groups
|
|
190
190
|
node ..\..\cangku\tmp\261114_gate_ui_controller.mjs # static gate, separate script
|
|
191
191
|
```
|
|
192
192
|
|
|
@@ -201,7 +201,10 @@ its own groups: entries group under their slot with empty seats in their own zon
|
|
|
201
201
|
the three filters count what they keep, folding starts closed and survives a
|
|
202
202
|
re-render, and the static fallback still draws slot heads when no live snapshot is
|
|
203
203
|
available. The sidebar-more behaviour has groups of its own: replay folds only
|
|
204
|
-
what the record and `foldAll` ask for; the
|
|
204
|
+
what the record and `foldAll` ask for; the launcher number is counted from the
|
|
205
|
+
DOM (panels minus the rows still on screen, including rows hidden behind a
|
|
206
|
+
wrapper) so it can never drift from what the sidebar actually hides, and it
|
|
207
|
+
agrees with the rows the menu lists; the count label repaints through the
|
|
205
208
|
`nav.panelList` ancestor and only when its text changes; folding hides the live
|
|
206
209
|
rows and restores them on the way out, leaving rows it cannot identify alone; and
|
|
207
210
|
the menu borrows a live host item's class list and computed size instead of any
|
package/client.js
CHANGED
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
* slots sort by `priority → order`, everything else by `priority` alone.
|
|
28
28
|
*/
|
|
29
29
|
|
|
30
|
-
const VERSION = '0.2.
|
|
30
|
+
const VERSION = '0.2.3';
|
|
31
31
|
|
|
32
32
|
const NS = 'uiController';
|
|
33
33
|
const SECTION_ID = 'ui-controller';
|
|
@@ -1865,18 +1865,57 @@ function glyphCloneOf(row) {
|
|
|
1865
1865
|
clone = null;
|
|
1866
1866
|
}
|
|
1867
1867
|
if (clone === null) return null;
|
|
1868
|
-
/* A cloned
|
|
1869
|
-
|
|
1870
|
-
|
|
1868
|
+
/* A cloned wrapper must never name a host slot twice. Ids are different: an
|
|
1869
|
+
icon drawn by the host is usually an <svg> whose <use href="#name"> points
|
|
1870
|
+
at a symbol, and stripping that symbol's id turns the icon into an empty
|
|
1871
|
+
box - the broken glyphs seen in the More menu. Keep every id the drawing
|
|
1872
|
+
itself refers to and drop only the decorative ones. */
|
|
1871
1873
|
try {
|
|
1872
|
-
clone.removeAttribute?.('id');
|
|
1873
1874
|
clone.removeAttribute?.('data-slot');
|
|
1874
1875
|
} catch {
|
|
1875
|
-
/*
|
|
1876
|
+
/* best effort */
|
|
1876
1877
|
}
|
|
1878
|
+
const referenced = new Set();
|
|
1879
|
+
const rememberRefs = (element) => {
|
|
1880
|
+
if (element === null || element === undefined) return;
|
|
1881
|
+
const names = [];
|
|
1882
|
+
for (const key of ['href', 'xlink:href']) {
|
|
1883
|
+
const value = element.getAttribute?.(key);
|
|
1884
|
+
if (typeof value === 'string') names.push(value);
|
|
1885
|
+
}
|
|
1886
|
+
const style = element.getAttribute?.('style');
|
|
1887
|
+
if (typeof style === 'string') names.push(style);
|
|
1888
|
+
for (const value of element.getAttributeNames?.() ?? []) {
|
|
1889
|
+
if (value === 'href' || value === 'xlink:href' || value === 'style') continue;
|
|
1890
|
+
const raw = element.getAttribute?.(value);
|
|
1891
|
+
if (typeof raw === 'string') names.push(raw);
|
|
1892
|
+
}
|
|
1893
|
+
for (const raw of names) {
|
|
1894
|
+
for (const match of raw.matchAll(/(?:#|url\()["']?([A-Za-z_][\w.:-]*)/g)) referenced.add(match[1]);
|
|
1895
|
+
}
|
|
1896
|
+
};
|
|
1897
|
+
rememberRefs(clone);
|
|
1898
|
+
if (typeof clone.querySelectorAll === 'function') {
|
|
1899
|
+
try {
|
|
1900
|
+
for (const tagged of Array.from(clone.querySelectorAll('*'))) rememberRefs(tagged);
|
|
1901
|
+
} catch {
|
|
1902
|
+
/* best effort */
|
|
1903
|
+
}
|
|
1904
|
+
}
|
|
1905
|
+
const dropId = (element) => {
|
|
1906
|
+
const name = element?.getAttribute?.('id');
|
|
1907
|
+
if (typeof name !== 'string' || name === '') return;
|
|
1908
|
+
if (referenced.has(name)) return;
|
|
1909
|
+
try {
|
|
1910
|
+
element.removeAttribute('id');
|
|
1911
|
+
} catch {
|
|
1912
|
+
/* best effort */
|
|
1913
|
+
}
|
|
1914
|
+
};
|
|
1915
|
+
dropId(clone);
|
|
1877
1916
|
if (typeof clone.querySelectorAll === 'function') {
|
|
1878
1917
|
try {
|
|
1879
|
-
for (const tagged of Array.from(clone.querySelectorAll('[id]'))) tagged
|
|
1918
|
+
for (const tagged of Array.from(clone.querySelectorAll('[id]'))) dropId(tagged);
|
|
1880
1919
|
} catch {
|
|
1881
1920
|
/* best effort */
|
|
1882
1921
|
}
|
|
@@ -2066,10 +2105,54 @@ function sidebarMoreReplay(entries, settings, storage) {
|
|
|
2066
2105
|
return entries.filter((entry) => entry.pinned === true && wanted.has(entry.id)).map((entry) => entry.id);
|
|
2067
2106
|
}
|
|
2068
2107
|
|
|
2069
|
-
/**
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2108
|
+
/**
|
|
2109
|
+
* How many panels are really behind the More button, counted from the sidebar
|
|
2110
|
+
* instead of from our own intent record. Two things can hide a panel: the host
|
|
2111
|
+
* drops the row of a pinned panel, and our fold pass sets display:none on the
|
|
2112
|
+
* rest — so "panels we know about minus rows still on screen" is the only number
|
|
2113
|
+
* that cannot drift from what the user sees. Returns null when the sidebar is not
|
|
2114
|
+
* readable (collapsed, not mounted yet): the caller keeps the bare label rather
|
|
2115
|
+
* than inventing a number.
|
|
2116
|
+
*/
|
|
2117
|
+
function foldedRowCount(doc, panels) {
|
|
2118
|
+
if (doc === null || doc === undefined || typeof doc.querySelectorAll !== 'function') return null;
|
|
2119
|
+
const total = panels.filter((panel) => panel.id !== 'plugins').length;
|
|
2120
|
+
if (total === 0) return 0;
|
|
2121
|
+
let rows = [];
|
|
2122
|
+
try {
|
|
2123
|
+
rows = Array.from(doc.querySelectorAll('nav[class*="panelList"] button[class*="panelRow"]'));
|
|
2124
|
+
} catch {
|
|
2125
|
+
rows = [];
|
|
2126
|
+
}
|
|
2127
|
+
if (rows.length === 0) return null;
|
|
2128
|
+
/* Identify a row by the panel it draws: the aria-label is the rendered title,
|
|
2129
|
+
which is what the host also uses for the row it removes. */
|
|
2130
|
+
const byName = new Map();
|
|
2131
|
+
for (const panel of panels) {
|
|
2132
|
+
if (panel.label !== undefined && panel.label !== '') byName.set(String(panel.label), panel.id);
|
|
2133
|
+
byName.set(String(panel.id), panel.id);
|
|
2134
|
+
}
|
|
2135
|
+
const hiddenInTree = (row) => {
|
|
2136
|
+
let node = row;
|
|
2137
|
+
for (let depth = 0; node !== null && node !== undefined && depth < 8; depth += 1) {
|
|
2138
|
+
if (node.hidden === true) return true;
|
|
2139
|
+
if (node.style?.display === 'none') return true;
|
|
2140
|
+
node = node.parentElement ?? null;
|
|
2141
|
+
}
|
|
2142
|
+
return false;
|
|
2143
|
+
};
|
|
2144
|
+
let shown = 0;
|
|
2145
|
+
for (const row of rows) {
|
|
2146
|
+
const aria = row.getAttribute?.('aria-label') ?? '';
|
|
2147
|
+
/* The launcher is a panel row too; it is never a panel behind itself. */
|
|
2148
|
+
if (MORE_TITLES.has(aria)) continue;
|
|
2149
|
+
const id = byName.get(aria) ?? null;
|
|
2150
|
+
/* Rows we cannot name are not ours to count, and plugins never folds. */
|
|
2151
|
+
if (id === null || id === 'plugins') continue;
|
|
2152
|
+
if (hiddenInTree(row) === true) continue;
|
|
2153
|
+
shown += 1;
|
|
2154
|
+
}
|
|
2155
|
+
return Math.max(0, total - shown);
|
|
2073
2156
|
}
|
|
2074
2157
|
|
|
2075
2158
|
/** Write one panel's pin through the host callback and keep the record honest. */
|
|
@@ -2207,7 +2290,7 @@ function SidebarMoreMenu(props) {
|
|
|
2207
2290
|
* untouched (screen readers keep "更多"); a missing button is skipped
|
|
2208
2291
|
* silently.
|
|
2209
2292
|
*/
|
|
2210
|
-
function paintMoreCount(doc, panels,
|
|
2293
|
+
function paintMoreCount(doc, panels, titleInfo) {
|
|
2211
2294
|
if (doc === null || typeof doc.querySelectorAll !== 'function') return;
|
|
2212
2295
|
let candidates = [];
|
|
2213
2296
|
try {
|
|
@@ -2241,10 +2324,10 @@ function paintMoreCount(doc, panels, settings, storageRef, titleInfo) {
|
|
|
2241
2324
|
titleInfo.title = title;
|
|
2242
2325
|
titleInfo.original = title.textContent ?? '';
|
|
2243
2326
|
}
|
|
2244
|
-
const count =
|
|
2327
|
+
const count = foldedRowCount(doc, panels);
|
|
2245
2328
|
/** The aria-label is the stable base; the title may already carry a painted count. */
|
|
2246
2329
|
const base = launcher.getAttribute('aria-label') ?? '';
|
|
2247
|
-
const wanted = moreLabel(base, count);
|
|
2330
|
+
const wanted = count === null ? base : moreLabel(base, count);
|
|
2248
2331
|
if (title.textContent !== wanted) title.textContent = wanted;
|
|
2249
2332
|
}
|
|
2250
2333
|
|
|
@@ -2263,7 +2346,7 @@ function apply(ctx) {
|
|
|
2263
2346
|
entriesOf('sidebar.panellist')
|
|
2264
2347
|
.map((entry) => ({ id: String(entry?.options?.id ?? ''), label: entryLabelOf(entry) }))
|
|
2265
2348
|
.filter((panel) => panel.id !== '');
|
|
2266
|
-
const paintCount = () => paintMoreCount(doc, sidebarPanelsOf(),
|
|
2349
|
+
const paintCount = () => paintMoreCount(doc, sidebarPanelsOf(), moreTitle);
|
|
2267
2350
|
const applyFold = () => applyFoldState(doc, sidebarPanelsOf(), readSettings(), storage(), moreTouched);
|
|
2268
2351
|
ctx.effect(() => () => clearMoreGlyphs(), 'ui-controller: forget sampled glyphs');
|
|
2269
2352
|
|
|
@@ -2306,14 +2389,14 @@ function apply(ctx) {
|
|
|
2306
2389
|
let moreObserver = null;
|
|
2307
2390
|
if (doc !== null && typeof doc.body?.addEventListener === 'function' && typeof MutationObserver === 'function') {
|
|
2308
2391
|
try {
|
|
2309
|
-
moreObserver = new MutationObserver(() => {
|
|
2392
|
+
moreObserver = new MutationObserver(() => { applyFold(); paintCount(); });
|
|
2310
2393
|
moreObserver.observe(doc.body, { childList: true, subtree: true });
|
|
2311
2394
|
} catch {
|
|
2312
2395
|
moreObserver = null;
|
|
2313
2396
|
}
|
|
2314
2397
|
}
|
|
2315
|
-
paintCount();
|
|
2316
2398
|
applyFold();
|
|
2399
|
+
paintCount();
|
|
2317
2400
|
|
|
2318
2401
|
let pickHandler = null;
|
|
2319
2402
|
|
|
@@ -2385,8 +2468,8 @@ function apply(ctx) {
|
|
|
2385
2468
|
const current = readSettings();
|
|
2386
2469
|
applyHidden();
|
|
2387
2470
|
applyVisualOrder(doc, current, ordered);
|
|
2388
|
-
paintCount();
|
|
2389
2471
|
applyFold();
|
|
2472
|
+
paintCount();
|
|
2390
2473
|
};
|
|
2391
2474
|
|
|
2392
2475
|
applyAll();
|
|
@@ -2509,7 +2592,7 @@ window.__ModuleLoader__.load({
|
|
|
2509
2592
|
computeFold,
|
|
2510
2593
|
moreLabel,
|
|
2511
2594
|
sidebarMoreReplay,
|
|
2512
|
-
|
|
2595
|
+
foldedRowCount,
|
|
2513
2596
|
desiredFoldIds,
|
|
2514
2597
|
foldedIdsOf,
|
|
2515
2598
|
entryLabelOf,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-ui-controller",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
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": {
|