dsh-ui-controller 0.2.1 → 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 +27 -0
- package/README.md +10 -3
- package/client.js +320 -20
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,33 @@
|
|
|
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
|
+
|
|
17
|
+
## 0.2.2 — 2026-11-15
|
|
18
|
+
|
|
19
|
+
### Fixed
|
|
20
|
+
|
|
21
|
+
- **The More menu rows carry the panel's own icon.** The icon is cloned at
|
|
22
|
+
runtime from the live sidebar row — the first child of
|
|
23
|
+
`span[class*="panelGlyph"]` — into a reserved slot left of the name, so no
|
|
24
|
+
SVG is shipped here and no host class name is hardcoded. The slot is emptied
|
|
25
|
+
before each fill (a host remount cannot stack copies), ids are stripped from
|
|
26
|
+
the clone, and a panel without a readable glyph keeps an empty slot silently.
|
|
27
|
+
- **Folding takes the icon with the text.** `applyFoldState` now hides the
|
|
28
|
+
element that actually wraps both: the row button normally, or the wrapper when
|
|
29
|
+
the host draws the glyph beside the button. `nav` is never hidden, and
|
|
30
|
+
unfolding restores every element it touched.
|
|
31
|
+
|
|
5
32
|
## 0.2.1 — 2026-11-15
|
|
6
33
|
|
|
7
34
|
### 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,11 +201,18 @@ 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
|
|
208
|
-
hardcoded name
|
|
211
|
+
hardcoded name; each menu row copies the panel glyph from the live sidebar row
|
|
212
|
+
(runtime clone taken from the drawing inside the host's slot anchor, ids and
|
|
213
|
+
`data-slot` stripped, refilled on every mount, remembered per panel so a folded
|
|
214
|
+
panel keeps its icon after the host stops rendering its row) and folding hides
|
|
215
|
+
the wrapper that owns both the icon and the text, never `nav`.
|
|
209
216
|
|
|
210
217
|
## Known limits
|
|
211
218
|
|
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';
|
|
@@ -81,6 +81,9 @@ const PAGE_CSS = [
|
|
|
81
81
|
'.uic-moreRow{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:4px 2px;font-size:13px;line-height:20px}',
|
|
82
82
|
'.uic-moreRow + .uic-moreRow{border-top:1px solid var(--dsw-alias-border-l2)}',
|
|
83
83
|
'.uic-moreRowName{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}',
|
|
84
|
+
'.uic-moreRowMain{display:flex;align-items:center;gap:8px;min-width:0;flex:1 1 auto}',
|
|
85
|
+
'.uic-moreGlyph{display:inline-flex;align-items:center;justify-content:center;flex:none;width:16px;height:16px;overflow:hidden}',
|
|
86
|
+
'.uic-moreGlyph>svg,.uic-moreGlyph>img{width:16px;height:16px;display:block}',
|
|
84
87
|
'.uic-moreAction{flex:none;padding:2px 8px;font-size:12px;border:1px solid var(--dsw-alias-border-l4);border-radius:6px;cursor:pointer}',
|
|
85
88
|
'.uic-moreAction:hover{background:var(--dsw-alias-bg-layer-2)}',
|
|
86
89
|
'.uic-zone{border-top:.5px solid var(--dsw-alias-border-l2);padding:2px 0}',
|
|
@@ -1734,6 +1737,10 @@ let sidebarReplayQueued = false;
|
|
|
1734
1737
|
|
|
1735
1738
|
/** Elements this session hid and the launcher title it rewrote; both are restored on teardown. */
|
|
1736
1739
|
const moreTouched = new Map();
|
|
1740
|
+
/* Cloned panel glyphs, remembered per panel id: the host stops rendering a
|
|
1741
|
+
panel's row once it is pinned away, so the icon has to be kept from the last
|
|
1742
|
+
time that row was on screen. */
|
|
1743
|
+
const moreGlyphs = new Map();
|
|
1737
1744
|
const moreTitle = { title: null, original: null };
|
|
1738
1745
|
|
|
1739
1746
|
/** Resolve a panel entry's label the way the host does (thunk first, then string, then id). */
|
|
@@ -1761,6 +1768,223 @@ function foldedIdsOf(panels, settings, storageRef) {
|
|
|
1761
1768
|
).filter((id) => id !== 'plugins');
|
|
1762
1769
|
}
|
|
1763
1770
|
|
|
1771
|
+
/**
|
|
1772
|
+
* The host sidebar row for one panel: matched by its own aria-label first, then
|
|
1773
|
+
* by the rendered title. Returns null while the row is not on screen yet.
|
|
1774
|
+
*/
|
|
1775
|
+
function panelRowOf(doc, label) {
|
|
1776
|
+
if (doc === null || doc === undefined || typeof doc.querySelectorAll !== 'function') return null;
|
|
1777
|
+
let rows = [];
|
|
1778
|
+
try {
|
|
1779
|
+
rows = Array.from(doc.querySelectorAll('nav[class*="panelList"] button[class*="panelRow"]'));
|
|
1780
|
+
} catch {
|
|
1781
|
+
rows = [];
|
|
1782
|
+
}
|
|
1783
|
+
for (const row of rows) {
|
|
1784
|
+
const aria = row.getAttribute?.('aria-label') ?? '';
|
|
1785
|
+
if (aria !== '' && aria === label) return row;
|
|
1786
|
+
if (typeof row.querySelector !== 'function') continue;
|
|
1787
|
+
try {
|
|
1788
|
+
const title = row.querySelector('span[class*="panelTitle"]');
|
|
1789
|
+
if (title !== null && title !== undefined && (title.textContent ?? '') === label) return row;
|
|
1790
|
+
} catch {
|
|
1791
|
+
/* a row we cannot read is simply not a match */
|
|
1792
|
+
}
|
|
1793
|
+
}
|
|
1794
|
+
return null;
|
|
1795
|
+
}
|
|
1796
|
+
|
|
1797
|
+
/**
|
|
1798
|
+
* The element that has to disappear when a panel folds. Usually that is the row
|
|
1799
|
+
* button itself (the host draws the glyph inside it), but a panel whose icon is
|
|
1800
|
+
* rendered beside the button would leave the icon behind, so the wrapper that
|
|
1801
|
+
* holds both is hidden instead. `nav` is never a folding unit.
|
|
1802
|
+
*/
|
|
1803
|
+
function foldUnitOf(row) {
|
|
1804
|
+
if (row === null || row === undefined) return null;
|
|
1805
|
+
let glyph = null;
|
|
1806
|
+
try {
|
|
1807
|
+
glyph = typeof row.querySelector === 'function' ? row.querySelector('span[class*="panelGlyph"]') : null;
|
|
1808
|
+
} catch {
|
|
1809
|
+
glyph = null;
|
|
1810
|
+
}
|
|
1811
|
+
if (glyph !== null && glyph !== undefined) return row;
|
|
1812
|
+
const parent = row.parentElement ?? null;
|
|
1813
|
+
if (parent === null) return row;
|
|
1814
|
+
if (String(parent.tagName ?? '').toUpperCase() === 'NAV') return row;
|
|
1815
|
+
let parentGlyph = null;
|
|
1816
|
+
try {
|
|
1817
|
+
parentGlyph = typeof parent.querySelector === 'function' ? parent.querySelector('span[class*="panelGlyph"]') : null;
|
|
1818
|
+
} catch {
|
|
1819
|
+
parentGlyph = null;
|
|
1820
|
+
}
|
|
1821
|
+
return parentGlyph !== null && parentGlyph !== undefined ? parent : row;
|
|
1822
|
+
}
|
|
1823
|
+
|
|
1824
|
+
/**
|
|
1825
|
+
* The node that actually draws the icon inside a host glyph span. The host puts
|
|
1826
|
+
* its slot anchor (`div[data-slot]` with `display: contents`) in between, so
|
|
1827
|
+
* the first child is a 0x0 wrapper; cloning that would duplicate a slot marker.
|
|
1828
|
+
* Returns the first svg / img / canvas inside it, or the first child itself when
|
|
1829
|
+
* the icon is drawn some other way.
|
|
1830
|
+
*/
|
|
1831
|
+
function glyphIconNodeOf(glyph) {
|
|
1832
|
+
if (glyph === null || glyph === undefined) return null;
|
|
1833
|
+
const start = glyph.firstElementChild ?? null;
|
|
1834
|
+
if (start === null) return null;
|
|
1835
|
+
if (typeof start.querySelector === 'function') {
|
|
1836
|
+
try {
|
|
1837
|
+
const drawing = start.querySelector('svg, img, canvas');
|
|
1838
|
+
if (drawing !== null && drawing !== undefined) return drawing;
|
|
1839
|
+
} catch {
|
|
1840
|
+
return start;
|
|
1841
|
+
}
|
|
1842
|
+
}
|
|
1843
|
+
return start;
|
|
1844
|
+
}
|
|
1845
|
+
|
|
1846
|
+
/**
|
|
1847
|
+
* Deep-clone the glyph inside one live host row and strip ids (a second copy
|
|
1848
|
+
* would collide in the document). Returns null when the row draws no glyph.
|
|
1849
|
+
*/
|
|
1850
|
+
function glyphCloneOf(row) {
|
|
1851
|
+
if (row === null || row === undefined) return null;
|
|
1852
|
+
let glyph = null;
|
|
1853
|
+
try {
|
|
1854
|
+
glyph = typeof row.querySelector === 'function' ? row.querySelector('span[class*="panelGlyph"]') : null;
|
|
1855
|
+
} catch {
|
|
1856
|
+
glyph = null;
|
|
1857
|
+
}
|
|
1858
|
+
if (glyph === null || glyph === undefined) return null;
|
|
1859
|
+
const source = glyphIconNodeOf(glyph);
|
|
1860
|
+
if (source === null || source === undefined) return null;
|
|
1861
|
+
let clone = null;
|
|
1862
|
+
try {
|
|
1863
|
+
clone = typeof source.cloneNode === 'function' ? source.cloneNode(true) : null;
|
|
1864
|
+
} catch {
|
|
1865
|
+
clone = null;
|
|
1866
|
+
}
|
|
1867
|
+
if (clone === null) return null;
|
|
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. */
|
|
1873
|
+
try {
|
|
1874
|
+
clone.removeAttribute?.('data-slot');
|
|
1875
|
+
} catch {
|
|
1876
|
+
/* best effort */
|
|
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);
|
|
1916
|
+
if (typeof clone.querySelectorAll === 'function') {
|
|
1917
|
+
try {
|
|
1918
|
+
for (const tagged of Array.from(clone.querySelectorAll('[id]'))) dropId(tagged);
|
|
1919
|
+
} catch {
|
|
1920
|
+
/* best effort */
|
|
1921
|
+
}
|
|
1922
|
+
}
|
|
1923
|
+
return clone;
|
|
1924
|
+
}
|
|
1925
|
+
|
|
1926
|
+
/** Remember one panel's glyph while its row is still rendered. */
|
|
1927
|
+
function captureMoreGlyph(panelId, row) {
|
|
1928
|
+
const id = String(panelId ?? '');
|
|
1929
|
+
if (id === '') return null;
|
|
1930
|
+
const cached = moreGlyphs.get(id) ?? null;
|
|
1931
|
+
if (cached !== null) return cached;
|
|
1932
|
+
const clone = glyphCloneOf(row);
|
|
1933
|
+
if (clone === null) return null;
|
|
1934
|
+
moreGlyphs.set(id, clone);
|
|
1935
|
+
return clone;
|
|
1936
|
+
}
|
|
1937
|
+
|
|
1938
|
+
/** Drop every remembered glyph (teardown, and tests). */
|
|
1939
|
+
function clearMoreGlyphs() {
|
|
1940
|
+
moreGlyphs.clear();
|
|
1941
|
+
}
|
|
1942
|
+
|
|
1943
|
+
/**
|
|
1944
|
+
* Copy the host's own panel glyph into one of our menu rows. The icon is the
|
|
1945
|
+
* first child of `span[class*="panelGlyph"]` inside the panel row — cloned at
|
|
1946
|
+
* runtime, never shipped here, so a host redesign keeps working. The
|
|
1947
|
+
* placeholder is emptied first, which makes the host remounting the menu
|
|
1948
|
+
* idempotent; a missing glyph leaves it empty and returns false (silent).
|
|
1949
|
+
*/
|
|
1950
|
+
function mountMoreGlyph(placeholder, doc, label, panelId) {
|
|
1951
|
+
if (placeholder === null || placeholder === undefined) return false;
|
|
1952
|
+
try {
|
|
1953
|
+
while (placeholder.firstChild !== null && placeholder.firstChild !== undefined) {
|
|
1954
|
+
placeholder.removeChild(placeholder.firstChild);
|
|
1955
|
+
}
|
|
1956
|
+
} catch {
|
|
1957
|
+
/* a placeholder we cannot clear is left as it is */
|
|
1958
|
+
}
|
|
1959
|
+
const row = panelRowOf(doc, label);
|
|
1960
|
+
/* A live row is the freshest source and also refreshes the memory; once the
|
|
1961
|
+
host pins a panel away its row disappears, so the remembered clone is what
|
|
1962
|
+
keeps the icon in our menu. */
|
|
1963
|
+
let source = null;
|
|
1964
|
+
if (row !== null) {
|
|
1965
|
+
const fresh = glyphCloneOf(row);
|
|
1966
|
+
if (fresh !== null) {
|
|
1967
|
+
moreGlyphs.set(String(panelId ?? label), fresh);
|
|
1968
|
+
source = fresh;
|
|
1969
|
+
}
|
|
1970
|
+
}
|
|
1971
|
+
if (source === null) source = moreGlyphs.get(String(panelId ?? label)) ?? null;
|
|
1972
|
+
if (source === null) return false;
|
|
1973
|
+
let clone = null;
|
|
1974
|
+
try {
|
|
1975
|
+
clone = typeof source.cloneNode === 'function' ? source.cloneNode(true) : null;
|
|
1976
|
+
} catch {
|
|
1977
|
+
clone = null;
|
|
1978
|
+
}
|
|
1979
|
+
if (clone === null) return false;
|
|
1980
|
+
try {
|
|
1981
|
+
placeholder.appendChild(clone);
|
|
1982
|
+
} catch {
|
|
1983
|
+
return false;
|
|
1984
|
+
}
|
|
1985
|
+
return true;
|
|
1986
|
+
}
|
|
1987
|
+
|
|
1764
1988
|
/**
|
|
1765
1989
|
* Hide the panel rows that belong behind the More button. The host keeps its
|
|
1766
1990
|
* pins in memory only and re-renders rows on every store change, so this pass
|
|
@@ -1792,14 +2016,26 @@ function applyFoldState(doc, panels, settings, storageRef, touched) {
|
|
|
1792
2016
|
}
|
|
1793
2017
|
const id = byLabel.get(label) ?? byLabel.get(titleText) ?? null;
|
|
1794
2018
|
if (id === null) continue;
|
|
2019
|
+
/* Remember the icon before this row can disappear from the sidebar. */
|
|
2020
|
+
captureMoreGlyph(id, row);
|
|
1795
2021
|
const hide = folded.has(id);
|
|
1796
|
-
|
|
2022
|
+
/* Hide whatever actually wraps both the icon and the text; a bare row button
|
|
2023
|
+
is the normal case, a wrapper is used when the host draws the glyph beside
|
|
2024
|
+
the button. `nav` is never hidden. */
|
|
2025
|
+
const unit = foldUnitOf(row);
|
|
2026
|
+
if (unit === null) continue;
|
|
2027
|
+
const current = unit.style?.display ?? '';
|
|
1797
2028
|
if (hide === true && current !== 'none') {
|
|
1798
|
-
if (touched.has(
|
|
1799
|
-
|
|
1800
|
-
} else if (hide === false
|
|
1801
|
-
row.
|
|
1802
|
-
|
|
2029
|
+
if (touched.has(unit) === false) touched.set(unit, current);
|
|
2030
|
+
unit.style.display = 'none';
|
|
2031
|
+
} else if (hide === false) {
|
|
2032
|
+
for (const candidate of [unit, row, row.parentElement ?? null]) {
|
|
2033
|
+
if (candidate === null || candidate === undefined) continue;
|
|
2034
|
+
if (touched.has(candidate) === true) {
|
|
2035
|
+
candidate.style.display = touched.get(candidate);
|
|
2036
|
+
touched.delete(candidate);
|
|
2037
|
+
}
|
|
2038
|
+
}
|
|
1803
2039
|
}
|
|
1804
2040
|
}
|
|
1805
2041
|
}
|
|
@@ -1869,10 +2105,54 @@ function sidebarMoreReplay(entries, settings, storage) {
|
|
|
1869
2105
|
return entries.filter((entry) => entry.pinned === true && wanted.has(entry.id)).map((entry) => entry.id);
|
|
1870
2106
|
}
|
|
1871
2107
|
|
|
1872
|
-
/**
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
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);
|
|
1876
2156
|
}
|
|
1877
2157
|
|
|
1878
2158
|
/** Write one panel's pin through the host callback and keep the record honest. */
|
|
@@ -1966,7 +2246,21 @@ function SidebarMoreMenu(props) {
|
|
|
1966
2246
|
'data-uic-more-row': entry.id,
|
|
1967
2247
|
onClick: () => { onOpen(entry.id); onDismiss(); },
|
|
1968
2248
|
}, [
|
|
1969
|
-
node('span', { key: '
|
|
2249
|
+
node('span', { key: 'main', className: 'uic-moreRowMain' }, [
|
|
2250
|
+
node('span', {
|
|
2251
|
+
key: 'glyph',
|
|
2252
|
+
className: 'uic-moreGlyph',
|
|
2253
|
+
'data-uic-more-glyph': entry.id,
|
|
2254
|
+
/* The host owns the icon: copy it from the live sidebar row once this
|
|
2255
|
+
placeholder is in the document. Refilled on every mount, so a host
|
|
2256
|
+
remount cannot stack copies. */
|
|
2257
|
+
ref: (element) => {
|
|
2258
|
+
if (element === null || element === undefined) return;
|
|
2259
|
+
mountMoreGlyph(element, doc, entry.label, entry.id);
|
|
2260
|
+
},
|
|
2261
|
+
}, []),
|
|
2262
|
+
node('span', { key: 'name', className: 'uic-moreRowName' }, entry.label),
|
|
2263
|
+
]),
|
|
1970
2264
|
node('span', {
|
|
1971
2265
|
key: 'toggle',
|
|
1972
2266
|
className: 'uic-moreToggle',
|
|
@@ -1996,7 +2290,7 @@ function SidebarMoreMenu(props) {
|
|
|
1996
2290
|
* untouched (screen readers keep "更多"); a missing button is skipped
|
|
1997
2291
|
* silently.
|
|
1998
2292
|
*/
|
|
1999
|
-
function paintMoreCount(doc, panels,
|
|
2293
|
+
function paintMoreCount(doc, panels, titleInfo) {
|
|
2000
2294
|
if (doc === null || typeof doc.querySelectorAll !== 'function') return;
|
|
2001
2295
|
let candidates = [];
|
|
2002
2296
|
try {
|
|
@@ -2030,10 +2324,10 @@ function paintMoreCount(doc, panels, settings, storageRef, titleInfo) {
|
|
|
2030
2324
|
titleInfo.title = title;
|
|
2031
2325
|
titleInfo.original = title.textContent ?? '';
|
|
2032
2326
|
}
|
|
2033
|
-
const count =
|
|
2327
|
+
const count = foldedRowCount(doc, panels);
|
|
2034
2328
|
/** The aria-label is the stable base; the title may already carry a painted count. */
|
|
2035
2329
|
const base = launcher.getAttribute('aria-label') ?? '';
|
|
2036
|
-
const wanted = moreLabel(base, count);
|
|
2330
|
+
const wanted = count === null ? base : moreLabel(base, count);
|
|
2037
2331
|
if (title.textContent !== wanted) title.textContent = wanted;
|
|
2038
2332
|
}
|
|
2039
2333
|
|
|
@@ -2052,8 +2346,9 @@ function apply(ctx) {
|
|
|
2052
2346
|
entriesOf('sidebar.panellist')
|
|
2053
2347
|
.map((entry) => ({ id: String(entry?.options?.id ?? ''), label: entryLabelOf(entry) }))
|
|
2054
2348
|
.filter((panel) => panel.id !== '');
|
|
2055
|
-
const paintCount = () => paintMoreCount(doc, sidebarPanelsOf(),
|
|
2349
|
+
const paintCount = () => paintMoreCount(doc, sidebarPanelsOf(), moreTitle);
|
|
2056
2350
|
const applyFold = () => applyFoldState(doc, sidebarPanelsOf(), readSettings(), storage(), moreTouched);
|
|
2351
|
+
ctx.effect(() => () => clearMoreGlyphs(), 'ui-controller: forget sampled glyphs');
|
|
2057
2352
|
|
|
2058
2353
|
/* One slot only, and only after it is declared: the inject callback itself
|
|
2059
2354
|
only fires once the host declares the slot, so the guard is belt and
|
|
@@ -2094,14 +2389,14 @@ function apply(ctx) {
|
|
|
2094
2389
|
let moreObserver = null;
|
|
2095
2390
|
if (doc !== null && typeof doc.body?.addEventListener === 'function' && typeof MutationObserver === 'function') {
|
|
2096
2391
|
try {
|
|
2097
|
-
moreObserver = new MutationObserver(() => {
|
|
2392
|
+
moreObserver = new MutationObserver(() => { applyFold(); paintCount(); });
|
|
2098
2393
|
moreObserver.observe(doc.body, { childList: true, subtree: true });
|
|
2099
2394
|
} catch {
|
|
2100
2395
|
moreObserver = null;
|
|
2101
2396
|
}
|
|
2102
2397
|
}
|
|
2103
|
-
paintCount();
|
|
2104
2398
|
applyFold();
|
|
2399
|
+
paintCount();
|
|
2105
2400
|
|
|
2106
2401
|
let pickHandler = null;
|
|
2107
2402
|
|
|
@@ -2173,8 +2468,8 @@ function apply(ctx) {
|
|
|
2173
2468
|
const current = readSettings();
|
|
2174
2469
|
applyHidden();
|
|
2175
2470
|
applyVisualOrder(doc, current, ordered);
|
|
2176
|
-
paintCount();
|
|
2177
2471
|
applyFold();
|
|
2472
|
+
paintCount();
|
|
2178
2473
|
};
|
|
2179
2474
|
|
|
2180
2475
|
applyAll();
|
|
@@ -2297,11 +2592,16 @@ window.__ModuleLoader__.load({
|
|
|
2297
2592
|
computeFold,
|
|
2298
2593
|
moreLabel,
|
|
2299
2594
|
sidebarMoreReplay,
|
|
2300
|
-
|
|
2595
|
+
foldedRowCount,
|
|
2301
2596
|
desiredFoldIds,
|
|
2302
2597
|
foldedIdsOf,
|
|
2303
2598
|
entryLabelOf,
|
|
2304
2599
|
applyFoldState,
|
|
2600
|
+
clearMoreGlyphs,
|
|
2601
|
+
foldUnitOf,
|
|
2602
|
+
glyphIconNodeOf,
|
|
2603
|
+
mountMoreGlyph,
|
|
2604
|
+
panelRowOf,
|
|
2305
2605
|
sampleMoreItem,
|
|
2306
2606
|
paintMoreCount,
|
|
2307
2607
|
SidebarMoreMenu,
|
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": {
|