dsh-ui-controller 0.1.0 → 0.1.1
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 +38 -7
- package/client.js +268 -4
- 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.1.1 — 2026-11-14
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- **Three-state settings rail.** The left column of the settings dialog is now
|
|
10
|
+
`full` (188px), an `icon rail` (56px — labels hidden, each button keeps its
|
|
11
|
+
name as a tooltip) or `collapsed` (0px). It defaults to **following the host
|
|
12
|
+
sidebar**, using the same two readings the shipped code uses (an explicit
|
|
13
|
+
`data-sidebar-collapsed` marker, or a sidebar measured 1–64px wide); turn
|
|
14
|
+
following off to pick a state yourself. New settings field `nav`, stored with
|
|
15
|
+
the rest, with no settings-version bump.
|
|
16
|
+
|
|
5
17
|
## 0.1.0 — 2026-11-14
|
|
6
18
|
|
|
7
19
|
First release with the inventory page.
|
package/README.md
CHANGED
|
@@ -65,6 +65,19 @@ is missing, this is the plugin that answers that.
|
|
|
65
65
|
5. **Presets.** Hide-marks and visual order can be captured as named presets, applied,
|
|
66
66
|
and deleted; storage follows the same rules as `better-notice` (unknown keys are
|
|
67
67
|
preserved, user changes are marked, upgrades do not overwrite).
|
|
68
|
+
6. **Settings rail width.** The left column of the settings dialog has three states:
|
|
69
|
+
**full** (188px, the default), an **icon rail** (56px — labels hidden, each button
|
|
70
|
+
keeps its name as a `title` tooltip) and **collapsed** (0px). By default it
|
|
71
|
+
**follows the host sidebar**: when the host's own session list is a rail, this one
|
|
72
|
+
is too, and the stored three-way choice is not read at all. Turn *Follow the host
|
|
73
|
+
sidebar* off to pick one of the three yourself. Only the first grid track and a
|
|
74
|
+
few `title` attributes are touched — no slot is registered, and `settings.header`
|
|
75
|
+
is never involved, so the shipped title is never shadowed.
|
|
76
|
+
|
|
77
|
+
The follow switch reads the same two signals the shipped behaviour does: an
|
|
78
|
+
explicit `data-sidebar-collapsed` marker in the document, or a sidebar element
|
|
79
|
+
measured between 1px and 64px wide. A different threshold would make the two
|
|
80
|
+
disagree the moment the host changes its width.
|
|
68
81
|
|
|
69
82
|
## What it deliberately does **not** do
|
|
70
83
|
|
|
@@ -123,7 +136,7 @@ on it.
|
|
|
123
136
|
```js
|
|
124
137
|
const api = window.__UI_CONTROLLER__;
|
|
125
138
|
|
|
126
|
-
api.version // '0.1.
|
|
139
|
+
api.version // '0.1.1'
|
|
127
140
|
api.catalog() // → [{ key, kind, scope, risk, purpose, registrantStatic, injectStatic }]
|
|
128
141
|
api.catalogSummary() // → { total: 109, kinds: {...} }
|
|
129
142
|
api.inventory() // → { rows, empty, totalSlots, occupiedSlots, hiddenCount,
|
|
@@ -164,7 +177,7 @@ Two sentences that belong in any answer about ordering:
|
|
|
164
177
|
node --check client.js
|
|
165
178
|
node --check index.js
|
|
166
179
|
node --check test/classify.test.mjs
|
|
167
|
-
node test/classify.test.mjs # expect: PASS —
|
|
180
|
+
node test/classify.test.mjs # expect: PASS — 35 groups
|
|
168
181
|
node ..\..\cangku\tmp\261114_gate_ui_controller.mjs # static gate, separate script
|
|
169
182
|
```
|
|
170
183
|
|
|
@@ -178,7 +191,12 @@ with the old `order` alias, and the zh/en dictionary parity. The grouped page ha
|
|
|
178
191
|
its own groups: entries group under their slot with empty seats in their own zone,
|
|
179
192
|
the three filters count what they keep, folding starts closed and survives a
|
|
180
193
|
re-render, and the static fallback still draws slot heads when no live snapshot is
|
|
181
|
-
available.
|
|
194
|
+
available. The settings rail has four groups of its own: each state owns its grid
|
|
195
|
+
track (56px / 0px, and `full` claims none so a wider host rail is inherited
|
|
196
|
+
instead of pinned), following the host sidebar ignores the stored three-way
|
|
197
|
+
choice (and reads the same 64px threshold the host does), the attribute plus
|
|
198
|
+
tooltips are painted on the panel and taken back off, and picking a state stops
|
|
199
|
+
following while the follow switch writes it straight back.
|
|
182
200
|
|
|
183
201
|
## Known limits
|
|
184
202
|
|
|
@@ -191,16 +209,29 @@ available.
|
|
|
191
209
|
the reason instead of a control that does nothing.
|
|
192
210
|
3. **Hiding is not unloading.** A hidden entry still runs. If it is expensive, this
|
|
193
211
|
plugin is not the tool — talk to the plugin's author.
|
|
194
|
-
|
|
212
|
+
4. **Visual order is CSS only.** It applies inside one flex/grid parent; a child of
|
|
195
213
|
a `display: contents` or block parent is skipped, and nothing outside our bound
|
|
196
214
|
elements is touched.
|
|
197
|
-
|
|
215
|
+
5. **Hash class names change every build.** Nothing here keys off them; only
|
|
198
216
|
`data-*`, `role`, `aria-label`, `name` and `id` are used to build selectors.
|
|
199
|
-
|
|
200
|
-
|
|
217
|
+
6. **`root` is off limits.** Listing it is fine; registering into it is not.
|
|
218
|
+
7. **`registrant` is an inference.** The live value (`entry.registrant`) is only
|
|
201
219
|
readable at runtime for entries present in the registry; the column shows the
|
|
202
220
|
static proxy scanned out of the shipped bundles, so an entry registered by code
|
|
203
221
|
that ships no literal key can read as "—".
|
|
222
|
+
8. **The rail only collapses above 768px.** Below that breakpoint the host turns the
|
|
223
|
+
settings nav into a horizontal tab strip, where hiding the labels would leave an
|
|
224
|
+
unlabelled bar; the three states are inert there. Collapsing changes width and
|
|
225
|
+
paint order only — the keyboard order and the DOM order stay exactly as shipped.
|
|
226
|
+
9. **Following is read at paint time, not subscribed to.** The rail re-reads the host
|
|
227
|
+
sidebar on the same two-second pass that applies visibility and order, so a manual
|
|
228
|
+
host collapse is reflected within that window rather than instantly.
|
|
229
|
+
10. **Collapsed hides the section list.** With `Collapsed` the settings nav is 0px
|
|
230
|
+
wide, so while it is collapsed you cannot switch to another settings section.
|
|
231
|
+
Turn it back on from this page, or run
|
|
232
|
+
`__UI_CONTROLLER__.settings.set({ nav: { follow: false, state: 'rail' } })` in
|
|
233
|
+
the console. `Follow the host sidebar` (the default) never lands you there on
|
|
234
|
+
its own — only an explicit choice does.
|
|
204
235
|
|
|
205
236
|
## License
|
|
206
237
|
|
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.1.
|
|
30
|
+
const VERSION = '0.1.1';
|
|
31
31
|
|
|
32
32
|
const NS = 'uiController';
|
|
33
33
|
const SECTION_ID = 'ui-controller';
|
|
@@ -76,6 +76,9 @@ const PAGE_CSS = [
|
|
|
76
76
|
'.uic-filterGroup{display:inline-flex;gap:2px}',
|
|
77
77
|
'.uic-filter{height:26px;padding:0 8px;border-radius:6px;font-size:11px;cursor:pointer;border:1px solid var(--dsw-alias-border-l4);background:transparent;color:var(--dsw-alias-label-secondary)}',
|
|
78
78
|
'.uic-filter[data-on="true"]{border-color:var(--dsw-alias-state-business-primary);color:var(--dsw-alias-state-business-primary)}',
|
|
79
|
+
'.uic-navSection{display:flex;flex-direction:column;gap:6px;margin-top:12px;padding-top:10px;border-top:1px solid var(--dsw-alias-border-l2)}',
|
|
80
|
+
'.uic-navFollow{display:inline-flex;align-items:center;gap:6px;font-size:12px;cursor:pointer}',
|
|
81
|
+
'.uic-navStates{display:flex;gap:6px;flex-wrap:wrap}',
|
|
79
82
|
'.uic-zone{border-top:.5px solid var(--dsw-alias-border-l2);padding:2px 0}',
|
|
80
83
|
'.uic-zoneHead{display:flex;align-items:center;gap:6px;width:100%;height:32px;padding:0 2px;border:0;background:transparent;color:var(--dsw-alias-label-primary);cursor:pointer;text-align:left;font-size:12px;font-weight:600}',
|
|
81
84
|
'.uic-zoneName{flex:none}',
|
|
@@ -100,6 +103,100 @@ const PAGE_CSS = [
|
|
|
100
103
|
'@container (max-width:620px){.uic-slotHead{grid-template-columns:14px 12px minmax(0,1fr) 46px minmax(0,1fr);height:auto;min-height:44px}.uic-slotHead .uic-kind{display:none}.uic-entry{grid-template-columns:minmax(0,1fr) auto auto;min-height:44px}.uic-entry .uic-entryLive,.uic-entry .uic-num{display:none}}',
|
|
101
104
|
].join('\n');
|
|
102
105
|
|
|
106
|
+
/* ------------------------------------------------- settings page left rail */
|
|
107
|
+
|
|
108
|
+
const NAV_ATTR = 'data-uic-nav';
|
|
109
|
+
const PANEL_SELECTOR = 'div[data-shortcut-modal="settings"]';
|
|
110
|
+
const PANEL_NAV_STATES = ['expanded', 'rail', 'hidden'];
|
|
111
|
+
const NAV_WIDTHS = { expanded: 188, rail: 56, hidden: 0 };
|
|
112
|
+
const HOST_SIDEBAR_RAIL_MAX = 64;
|
|
113
|
+
|
|
114
|
+
/** Width of the settings rail, in px, for one of the three states. */
|
|
115
|
+
function navWidthOf(state) {
|
|
116
|
+
return hasOwn(NAV_WIDTHS, state) ? NAV_WIDTHS[state] : NAV_WIDTHS.expanded;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* First grid track of the settings modal.
|
|
121
|
+
*
|
|
122
|
+
* Longhand on purpose: the host's shorthand also carries grid area names that
|
|
123
|
+
* are hashed per build, so copying the whole declaration would break on the
|
|
124
|
+
* next release. Only the first track belongs to us.
|
|
125
|
+
*/
|
|
126
|
+
function navColumnsOf(state) {
|
|
127
|
+
return navWidthOf(state) + 'px minmax(0, 1fr)';
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/*
|
|
131
|
+
* Collapsing only means something while the host draws the rail as a vertical
|
|
132
|
+
* column; below 768px it becomes a horizontal tab strip, where hiding the
|
|
133
|
+
* labels would leave an unlabelled bar. Same breakpoint the host uses.
|
|
134
|
+
*
|
|
135
|
+
* Only the two collapsed states claim a track. Leaving `expanded` untouched
|
|
136
|
+
* means the host keeps ownership of its own width: if a later build widens the
|
|
137
|
+
* rail, we inherit it instead of pinning an old number.
|
|
138
|
+
*/
|
|
139
|
+
const NAV_CSS = [
|
|
140
|
+
'@media (min-width:768px){',
|
|
141
|
+
...PANEL_NAV_STATES.filter((state) => state !== 'expanded').map(
|
|
142
|
+
(state) =>
|
|
143
|
+
PANEL_SELECTOR + '[' + NAV_ATTR + '="' + state + '"]{grid-template-columns:' + navColumnsOf(state) + ' !important}',
|
|
144
|
+
),
|
|
145
|
+
PANEL_SELECTOR + '[' + NAV_ATTR + '="rail"] > nav{padding:10px 6px 0;overflow:hidden}',
|
|
146
|
+
PANEL_SELECTOR + '[' + NAV_ATTR + '="rail"] > nav button{justify-content:center;padding:8px 0;gap:0}',
|
|
147
|
+
PANEL_SELECTOR +
|
|
148
|
+
'[' +
|
|
149
|
+
NAV_ATTR +
|
|
150
|
+
'="rail"] > nav button > span:nth-child(2){position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0}',
|
|
151
|
+
PANEL_SELECTOR + '[' + NAV_ATTR + '="hidden"]{overflow:hidden}',
|
|
152
|
+
PANEL_SELECTOR + '[' + NAV_ATTR + '="hidden"] > nav{display:none}',
|
|
153
|
+
'}',
|
|
154
|
+
].join('\n');
|
|
155
|
+
|
|
156
|
+
/** Only the three stored states are meaningful; anything else is "expanded". */
|
|
157
|
+
function stateOr(value) {
|
|
158
|
+
return PANEL_NAV_STATES.includes(value) ? value : 'expanded';
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Whether the host's own session sidebar is currently a rail.
|
|
163
|
+
*
|
|
164
|
+
* Two readings, both taken from the shipped behaviour rather than invented
|
|
165
|
+
* here: an explicit `data-sidebar-collapsed` marker anywhere in the document,
|
|
166
|
+
* or a sidebar element measured between 1px and 64px. The three sidebar
|
|
167
|
+
* selectors are the ones the shipped code probes, in the same order; a
|
|
168
|
+
* different threshold would make the two disagree the moment the host changes
|
|
169
|
+
* its width.
|
|
170
|
+
*/
|
|
171
|
+
function hostSidebarCollapsed(doc) {
|
|
172
|
+
if (doc === null || doc === undefined || typeof doc.querySelector !== 'function') return false;
|
|
173
|
+
try {
|
|
174
|
+
if (doc.querySelector('[data-sidebar-collapsed]') !== null) return true;
|
|
175
|
+
const sidebar =
|
|
176
|
+
doc.querySelector('[data-slot="sidebar"]') ??
|
|
177
|
+
doc.querySelector('div[class*="sidebarCol"]') ??
|
|
178
|
+
doc.querySelector('div[class*="hHd-Xa_root"]');
|
|
179
|
+
if (sidebar === null || sidebar === undefined || typeof sidebar.getBoundingClientRect !== 'function') return false;
|
|
180
|
+
const measured = sidebar.getBoundingClientRect().width;
|
|
181
|
+
return Number.isFinite(measured) && measured > 0 && measured <= HOST_SIDEBAR_RAIL_MAX;
|
|
182
|
+
} catch {
|
|
183
|
+
return false;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Which of the three states applies right now.
|
|
189
|
+
*
|
|
190
|
+
* `follow` on (the default) means the rail mirrors the host sidebar, and the
|
|
191
|
+
* stored three-way choice is deliberately not read at all — that is the whole
|
|
192
|
+
* point of following.
|
|
193
|
+
*/
|
|
194
|
+
function resolveNavState(settings, doc) {
|
|
195
|
+
const nav = isPlainObject(settings) && isPlainObject(settings.nav) ? settings.nav : {};
|
|
196
|
+
if (nav.follow !== false) return stateOr(hostSidebarCollapsed(doc) ? 'rail' : 'expanded');
|
|
197
|
+
return stateOr(nav.state);
|
|
198
|
+
}
|
|
199
|
+
|
|
103
200
|
const PRESET_NAME_MAX = 40;
|
|
104
201
|
const SELECTOR_MAX = 240;
|
|
105
202
|
const LOCATOR_LIMIT = 400;
|
|
@@ -256,6 +353,7 @@ function defaultSettings() {
|
|
|
256
353
|
visualOrder: {},
|
|
257
354
|
presets: {},
|
|
258
355
|
activePreset: null,
|
|
356
|
+
nav: { follow: true, state: 'expanded' },
|
|
259
357
|
};
|
|
260
358
|
}
|
|
261
359
|
|
|
@@ -343,6 +441,15 @@ function sanitizePresets(raw) {
|
|
|
343
441
|
return next;
|
|
344
442
|
}
|
|
345
443
|
|
|
444
|
+
/** `follow` defaults to on; the three-way choice only matters when it is off. */
|
|
445
|
+
function sanitizeNav(raw) {
|
|
446
|
+
const next = { follow: true, state: 'expanded' };
|
|
447
|
+
if (isPlainObject(raw) === false) return next;
|
|
448
|
+
if (raw.follow === false) next.follow = false;
|
|
449
|
+
if (PANEL_NAV_STATES.includes(raw.state)) next.state = raw.state;
|
|
450
|
+
return next;
|
|
451
|
+
}
|
|
452
|
+
|
|
346
453
|
function sanitizeSettings(raw) {
|
|
347
454
|
const base = defaultSettings();
|
|
348
455
|
if (isPlainObject(raw) === false) return base;
|
|
@@ -352,6 +459,7 @@ function sanitizeSettings(raw) {
|
|
|
352
459
|
next.visualOrder = sanitizeVisualOrder(raw.visualOrder ?? raw.order);
|
|
353
460
|
next.presets = sanitizePresets(raw.presets);
|
|
354
461
|
next.activePreset = typeof raw.activePreset === 'string' && hasOwn(next.presets, raw.activePreset) ? raw.activePreset : null;
|
|
462
|
+
next.nav = sanitizeNav(raw.nav);
|
|
355
463
|
return next;
|
|
356
464
|
}
|
|
357
465
|
|
|
@@ -439,6 +547,7 @@ function patchSettings(patch) {
|
|
|
439
547
|
visualOrder,
|
|
440
548
|
presets: isPlainObject(patch.presets) ? patch.presets : base.presets,
|
|
441
549
|
activePreset: hasOwn(patch, 'activePreset') ? patch.activePreset : base.activePreset,
|
|
550
|
+
nav: { ...(isPlainObject(base.nav) ? base.nav : {}), ...(isPlainObject(patch.nav) ? patch.nav : {}) },
|
|
442
551
|
});
|
|
443
552
|
}
|
|
444
553
|
|
|
@@ -974,6 +1083,14 @@ const ZH = {
|
|
|
974
1083
|
'settings.filter.unbound': '未绑定',
|
|
975
1084
|
'settings.filterCount': '{slots} 槽 · {entries} entry',
|
|
976
1085
|
'settings.noMatch': '没有匹配的座位。',
|
|
1086
|
+
'settings.nav.title': '设置页左栏',
|
|
1087
|
+
'settings.nav.hint': '只改设置页左侧分类栏的宽度:展开、56px 图标栏,或收起。键盘顺序与 DOM 顺序都不变。',
|
|
1088
|
+
'settings.nav.follow': '跟随宿主侧栏',
|
|
1089
|
+
'settings.nav.followOn': '跟随宿主侧栏时这三档不生效,先关掉跟随。',
|
|
1090
|
+
'settings.nav.state.expanded': '展开',
|
|
1091
|
+
'settings.nav.state.rail': '图标栏',
|
|
1092
|
+
'settings.nav.state.hidden': '收起',
|
|
1093
|
+
'settings.nav.now': '当前选择:{width}px。',
|
|
977
1094
|
};
|
|
978
1095
|
|
|
979
1096
|
const EN = {
|
|
@@ -1028,6 +1145,14 @@ const EN = {
|
|
|
1028
1145
|
'settings.filter.unbound': 'Unbound',
|
|
1029
1146
|
'settings.filterCount': '{slots} slots · {entries} entries',
|
|
1030
1147
|
'settings.noMatch': 'No slot matches.',
|
|
1148
|
+
'settings.nav.title': 'Settings rail',
|
|
1149
|
+
'settings.nav.hint': 'Only the width of the settings rail changes: full, a 56px icon rail, or collapsed. Keyboard and DOM order never change.',
|
|
1150
|
+
'settings.nav.follow': 'Follow the host sidebar',
|
|
1151
|
+
'settings.nav.followOn': 'While following, these three do not apply — turn following off first.',
|
|
1152
|
+
'settings.nav.state.expanded': 'Full',
|
|
1153
|
+
'settings.nav.state.rail': 'Icon rail',
|
|
1154
|
+
'settings.nav.state.hidden': 'Collapsed',
|
|
1155
|
+
'settings.nav.now': 'Selected: {width}px.',
|
|
1031
1156
|
};
|
|
1032
1157
|
|
|
1033
1158
|
const DICTS = { zh: ZH, en: EN };
|
|
@@ -1061,12 +1186,18 @@ function node(tagName, props, children) {
|
|
|
1061
1186
|
|
|
1062
1187
|
function injectStyle(doc) {
|
|
1063
1188
|
if (doc === null || doc === undefined) return;
|
|
1189
|
+
const css = HIDE_CSS + '\n' + PAGE_CSS + '\n' + NAV_CSS;
|
|
1064
1190
|
const existing = typeof doc.getElementById === 'function' ? doc.getElementById(STYLE_ID) : null;
|
|
1065
|
-
|
|
1191
|
+
/* A reloaded plugin can find the stylesheet its previous instance left behind.
|
|
1192
|
+
Rewriting it keeps the three rule groups from drifting apart. */
|
|
1193
|
+
if (existing !== null && existing !== undefined) {
|
|
1194
|
+
if (existing.textContent !== css) existing.textContent = css;
|
|
1195
|
+
return;
|
|
1196
|
+
}
|
|
1066
1197
|
const style = doc.createElement('style');
|
|
1067
1198
|
style.id = STYLE_ID;
|
|
1068
1199
|
style.setAttribute('data-uic', 'style');
|
|
1069
|
-
style.textContent =
|
|
1200
|
+
style.textContent = css;
|
|
1070
1201
|
const head = doc.head ?? doc.documentElement;
|
|
1071
1202
|
if (head !== null && head !== undefined) head.appendChild(style);
|
|
1072
1203
|
}
|
|
@@ -1077,6 +1208,75 @@ function removeStyle(doc) {
|
|
|
1077
1208
|
if (existing !== null && existing !== undefined && typeof existing.remove === 'function') existing.remove();
|
|
1078
1209
|
}
|
|
1079
1210
|
|
|
1211
|
+
/* ------------------------------------------------------------- nav DOM */
|
|
1212
|
+
|
|
1213
|
+
/** Buttons we put a `title` on, so leaving rail state can undo exactly those. */
|
|
1214
|
+
const navTitled = [];
|
|
1215
|
+
|
|
1216
|
+
/**
|
|
1217
|
+
* Put captured `title` attributes back, then forget them.
|
|
1218
|
+
*
|
|
1219
|
+
* `keep` is the set of buttons that should stay titled: the two-second paint
|
|
1220
|
+
* pass calls this with the buttons it just found, so a host re-render that
|
|
1221
|
+
* replaces the nav nodes drops the stale entries and nothing is written twice.
|
|
1222
|
+
*/
|
|
1223
|
+
function releaseNavTitles(keep) {
|
|
1224
|
+
for (let index = navTitled.length - 1; index >= 0; index -= 1) {
|
|
1225
|
+
const item = navTitled[index];
|
|
1226
|
+
if (keep !== undefined && keep.has(item.element) === true) continue;
|
|
1227
|
+
if (item.previous === null) item.element.removeAttribute('title');
|
|
1228
|
+
else item.element.setAttribute('title', item.previous);
|
|
1229
|
+
navTitled.splice(index, 1);
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
|
|
1233
|
+
/**
|
|
1234
|
+
* Paint one of the three states onto the settings modal.
|
|
1235
|
+
*
|
|
1236
|
+
* Only the panel attribute and a handful of `title` attributes are written:
|
|
1237
|
+
* the nav markup belongs to the host and is never moved, re-registered or
|
|
1238
|
+
* re-rendered by us. Rail state hides the labels with CSS, so nothing has to
|
|
1239
|
+
* be remembered across a host re-render beyond the attribute itself. Called
|
|
1240
|
+
* every two seconds, so every write is guarded — an unchanged attribute or
|
|
1241
|
+
* tooltip is left alone instead of being re-set in a loop.
|
|
1242
|
+
*/
|
|
1243
|
+
function applyNavStateTo(doc, settings) {
|
|
1244
|
+
const state = resolveNavState(settings, doc);
|
|
1245
|
+
if (doc === null || doc === undefined || typeof doc.querySelector !== 'function') return state;
|
|
1246
|
+
const panel = doc.querySelector(PANEL_SELECTOR);
|
|
1247
|
+
if (panel === null || panel === undefined) {
|
|
1248
|
+
releaseNavTitles();
|
|
1249
|
+
return state;
|
|
1250
|
+
}
|
|
1251
|
+
if (panel.getAttribute(NAV_ATTR) !== state) panel.setAttribute(NAV_ATTR, state);
|
|
1252
|
+
const nav = state === 'rail' && typeof panel.querySelector === 'function' ? panel.querySelector('nav') : null;
|
|
1253
|
+
if (nav === null || nav === undefined || typeof nav.querySelectorAll !== 'function') {
|
|
1254
|
+
releaseNavTitles();
|
|
1255
|
+
return state;
|
|
1256
|
+
}
|
|
1257
|
+
const wanted = new Set();
|
|
1258
|
+
for (const button of Array.from(nav.querySelectorAll('button'))) {
|
|
1259
|
+
const spans = typeof button.querySelectorAll === 'function' ? Array.from(button.querySelectorAll('span')) : [];
|
|
1260
|
+
const label = elementText(spans.length > 1 ? spans[1] : button);
|
|
1261
|
+
if (label === '') continue;
|
|
1262
|
+
wanted.add(button);
|
|
1263
|
+
if (button.getAttribute('title') === label) continue;
|
|
1264
|
+
if (navTitled.some((item) => item.element === button) === false) {
|
|
1265
|
+
navTitled.push({ element: button, previous: button.getAttribute('title') });
|
|
1266
|
+
}
|
|
1267
|
+
button.setAttribute('title', label);
|
|
1268
|
+
}
|
|
1269
|
+
releaseNavTitles(wanted);
|
|
1270
|
+
return state;
|
|
1271
|
+
}
|
|
1272
|
+
|
|
1273
|
+
/** Take the attribute and every `title` back off, e.g. when the plugin unloads. */
|
|
1274
|
+
function clearNavState(doc) {
|
|
1275
|
+
releaseNavTitles();
|
|
1276
|
+
if (doc === null || doc === undefined || typeof doc.querySelectorAll !== 'function') return;
|
|
1277
|
+
for (const panel of Array.from(doc.querySelectorAll(PANEL_SELECTOR))) panel.removeAttribute(NAV_ATTR);
|
|
1278
|
+
}
|
|
1279
|
+
|
|
1080
1280
|
/* ---------------------------------------------------------------- grouping */
|
|
1081
1281
|
|
|
1082
1282
|
const RISK_RISKY = 'shadows-shipped-ui';
|
|
@@ -1527,6 +1727,54 @@ function settingsPage(props) {
|
|
|
1527
1727
|
|
|
1528
1728
|
const presetNames = Object.keys(state.presets).sort();
|
|
1529
1729
|
|
|
1730
|
+
const navStored = isPlainObject(state.nav) ? state.nav : {};
|
|
1731
|
+
const followOn = navStored.follow !== false;
|
|
1732
|
+
const navChoice = PANEL_NAV_STATES.includes(navStored.state) ? navStored.state : 'expanded';
|
|
1733
|
+
/* While following, the three buttons are inert, so the selected mark and the
|
|
1734
|
+
width line show what the rail is actually doing right now. */
|
|
1735
|
+
const navNow = followOn ? resolveNavState({ nav: navStored }, typeof document === 'undefined' ? null : document) : navChoice;
|
|
1736
|
+
const navEdit = (change) => commit({ ...state, nav: { ...navStored, ...change } });
|
|
1737
|
+
|
|
1738
|
+
const navBlock = node('div', { key: 'nav', className: 'uic-navSection', 'data-uic-nav-section': '1' }, [
|
|
1739
|
+
node('h3', { key: 'h', className: 'uic-h3' }, t('settings.nav.title')),
|
|
1740
|
+
node('p', { key: 'hint', className: 'uic-dim' }, t('settings.nav.hint')),
|
|
1741
|
+
node('label', { key: 'follow', className: 'uic-navFollow' }, [
|
|
1742
|
+
node('input', {
|
|
1743
|
+
key: 'box',
|
|
1744
|
+
type: 'checkbox',
|
|
1745
|
+
'data-uic-nav-follow': followOn ? 'true' : 'false',
|
|
1746
|
+
checked: followOn,
|
|
1747
|
+
onChange: (event) => navEdit({ follow: event.target.checked === true }),
|
|
1748
|
+
}),
|
|
1749
|
+
node('span', { key: 'text' }, t('settings.nav.follow')),
|
|
1750
|
+
]),
|
|
1751
|
+
node(
|
|
1752
|
+
'div',
|
|
1753
|
+
{ key: 'states', className: 'uic-navStates' },
|
|
1754
|
+
PANEL_NAV_STATES.map((option) =>
|
|
1755
|
+
node(
|
|
1756
|
+
'button',
|
|
1757
|
+
{
|
|
1758
|
+
key: option,
|
|
1759
|
+
className: 'uic-filter' + (navChoice === option ? ' uic-filter-on' : ''),
|
|
1760
|
+
type: 'button',
|
|
1761
|
+
'data-uic-nav-pick': option,
|
|
1762
|
+
'data-on': navNow === option ? 'true' : 'false',
|
|
1763
|
+
disabled: followOn,
|
|
1764
|
+
title: followOn ? t('settings.nav.followOn') : undefined,
|
|
1765
|
+
onClick: () => navEdit({ follow: false, state: option }),
|
|
1766
|
+
},
|
|
1767
|
+
t('settings.nav.state.' + option),
|
|
1768
|
+
),
|
|
1769
|
+
),
|
|
1770
|
+
),
|
|
1771
|
+
node(
|
|
1772
|
+
'p',
|
|
1773
|
+
{ key: 'now', className: 'uic-dim', 'data-uic-nav-now': navNow },
|
|
1774
|
+
t('settings.nav.now', { width: navWidthOf(navNow) }),
|
|
1775
|
+
),
|
|
1776
|
+
]);
|
|
1777
|
+
|
|
1530
1778
|
return node('div', { className: 'uic-page', 'data-uic-page': '1' }, [
|
|
1531
1779
|
node('h2', { key: 'title', className: 'uic-title' }, t('settings.title')),
|
|
1532
1780
|
node('p', { key: 'lead', className: 'uic-lead' }, t('settings.lead')),
|
|
@@ -1610,6 +1858,7 @@ function settingsPage(props) {
|
|
|
1610
1858
|
)),
|
|
1611
1859
|
node('p', { key: 'order-hint', className: 'uic-dim' }, t('settings.orderHint')),
|
|
1612
1860
|
node('p', { key: 'order-hint-2', className: 'uic-dim' }, t('settings.orderHint2')),
|
|
1861
|
+
navBlock,
|
|
1613
1862
|
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')),
|
|
1614
1863
|
]);
|
|
1615
1864
|
}
|
|
@@ -1671,6 +1920,7 @@ function apply(ctx) {
|
|
|
1671
1920
|
injectStyle(doc);
|
|
1672
1921
|
ctx.effect(() => () => {
|
|
1673
1922
|
stopPicking();
|
|
1923
|
+
clearNavState(doc);
|
|
1674
1924
|
removeStyle(doc);
|
|
1675
1925
|
if (doc !== null) {
|
|
1676
1926
|
for (const element of Array.from(doc.querySelectorAll('[' + HIDDEN_ATTR + ']'))) element.removeAttribute(HIDDEN_ATTR);
|
|
@@ -1681,8 +1931,10 @@ function apply(ctx) {
|
|
|
1681
1931
|
const ordered = [];
|
|
1682
1932
|
|
|
1683
1933
|
const applyAll = () => {
|
|
1934
|
+
const current = readSettings();
|
|
1684
1935
|
applyHidden();
|
|
1685
|
-
applyVisualOrder(doc,
|
|
1936
|
+
applyVisualOrder(doc, current, ordered);
|
|
1937
|
+
applyNavStateTo(doc, current);
|
|
1686
1938
|
};
|
|
1687
1939
|
|
|
1688
1940
|
applyAll();
|
|
@@ -1795,6 +2047,18 @@ window.__ModuleLoader__.load({
|
|
|
1795
2047
|
isOpen,
|
|
1796
2048
|
toggleOpen,
|
|
1797
2049
|
resetOpen,
|
|
2050
|
+
NAV_ATTR,
|
|
2051
|
+
PANEL_SELECTOR,
|
|
2052
|
+
PANEL_NAV_STATES,
|
|
2053
|
+
NAV_WIDTHS,
|
|
2054
|
+
NAV_CSS,
|
|
2055
|
+
navWidthOf,
|
|
2056
|
+
navColumnsOf,
|
|
2057
|
+
hostSidebarCollapsed,
|
|
2058
|
+
resolveNavState,
|
|
2059
|
+
sanitizeNav,
|
|
2060
|
+
applyNavStateTo,
|
|
2061
|
+
clearNavState,
|
|
1798
2062
|
DICTS,
|
|
1799
2063
|
};
|
|
1800
2064
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-ui-controller",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Placeholder release: inspect and control the UI that other plugins register into DeepSeek Harness slots (visibility, order, mirrored entries). The real implementation ships in a later version.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|