dsh-sidebar-fold 0.1.6 → 0.1.13

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/src/index.js CHANGED
@@ -1,88 +1,99 @@
1
- /**
2
- * Host half of `dsh-sidebar-fold`.
3
- *
4
- * The plugin's behaviour lives entirely in the browser half (`lib/client.js`,
5
- * served through `exports["./client"]`): it folds the sidebar's add-on panel
6
- * rows under the shipped "More" row. This half therefore installs nothing and
7
- * owns no state — it exists so the profile row has an entry point, and it
8
- * declares the Config schema the settings form is projected from.
9
- *
10
- * Plain JS on purpose (the `dsh-session-guard` arrangement): the host half needs
11
- * no build step, so `dsh.plugin.json` points straight at `./src/index.js` and a
12
- * stale `lib/` can never shadow the served schema.
13
- *
14
- * Namespace discipline (verified against the shipped rc.3 browser half):
15
- * `ConfigForms.get(entryId)` keys forms by the *host plugin entry id*, and the
16
- * Plugin Manager page only opens a form whose namespace appears in the served
17
- * `settings.describe` mirror (`dsh-client-ui-plugin-manager/lib/client.js:3835`).
18
- * The entry id is the bundle row's id, which `cordis.patch.yml` inserts as this
19
- * package's name — so the client half reads its form under `name` below, and this
20
- * schema is what the host serves for it.
21
- */
22
- import z from '@deepseek-ai/schemastery'
23
-
24
- /** Profile row / settings namespace / module-loader id: one string, never drifted. */
25
- export const name = 'dsh-sidebar-fold'
26
-
27
- /** State a fresh window starts in when it has no local record yet. */
28
- export const DEFAULT_FOLDED = false
29
-
30
- /**
31
- * Rows kept visible while the group folds (zh first, because the sidebar renders
32
- * zh by default; en rides along so an English host behaves the same).
33
- *
34
- * Only the `插件` / `Plugins` entry is here on purpose: every other add-on row
35
- * (schedules, agent teams, markets, …) folds by default, and the user adjusts the
36
- * list from the settings card's per-row switches, which read the live sidebar.
37
- */
38
- export const DEFAULT_KEEP_LABELS = ['插件', 'Plugins']
39
-
40
- /**
41
- * Row-content alignment for the managed area: `start` | `center` | `end`.
42
- *
43
- * A plain string, not a closed union: schemastery's union builder is not the same
44
- * on every line this plugin supports, and the browser half already rejects an
45
- * unknown value through `normalizeAlign` (falling back to `start`, the shipped
46
- * layout). Keeping the schema primitive is what lets one Config serve
47
- * 0.1.0-rc.8 through 0.2.1-rc.3.
48
- */
49
- export const DEFAULT_ALIGN = 'start'
50
-
51
- /**
52
- * Whether THIS schemastery build knows `.volatile()`.
53
- *
54
- * 0.1.7+ projects a settings form out of the plugin's own Config, and only a
55
- * field marked volatile becomes editable there; dsh 0.1.5 ships schemastery
56
- * 3.18.2, which has no such method at all. Calling it unconditionally would
57
- * throw while this module LOADS — taking the whole plugin down on the older
58
- * line. Probe, never assume (the discipline dsh-paste-dock documents at
59
- * `src/index.ts:188-203`).
60
- */
61
- const schemaVolatileCapable =
62
- typeof /** @type {{ volatile?: unknown }} */ (z.boolean()).volatile === 'function'
63
-
64
- /** A live-editable field where the running line supports it, an ordinary one where not. */
65
- function live(schema) {
66
- const box = /** @type {{ volatile?: () => typeof schema }} */ (schema)
67
- return typeof box.volatile === 'function' ? box.volatile() : schema
68
- }
69
-
70
- /**
71
- * The plugin's own Config — and, on dsh 0.1.7+, its settings surface.
72
- *
73
- * Both fields are volatile on purpose: the browser half re-reads the served
74
- * document through `configForms` and applies changes without a restart.
75
- */
76
- export const Config = z.object({
77
- defaultFolded: live(z.boolean().default(DEFAULT_FOLDED)),
78
- // Rows kept visible while folding. Edited through the card's per-row switches,
79
- // which enumerate the live sidebar rather than asking the user to type labels.
80
- keepLabels: live(z.array(z.string()).default(DEFAULT_KEEP_LABELS)),
81
- // Icon + label alignment inside each managed row (`start` | `center` | `end`).
82
- align: live(z.string().default(DEFAULT_ALIGN)),
83
- })
84
-
85
- /**
86
- * Node-face apply. Intentionally empty: the fold lives in the browser.
87
- */
88
- export function apply() {}
1
+ /**
2
+ * Host half of `dsh-sidebar-fold`.
3
+ *
4
+ * The plugin's behaviour lives entirely in the browser half (`lib/client.js`,
5
+ * served through `exports["./client"]`): it folds the sidebar's add-on panel
6
+ * rows under the shipped "More" row. This half therefore installs nothing and
7
+ * owns no state — it exists so the profile row has an entry point, and it
8
+ * declares the Config schema the settings form is projected from.
9
+ *
10
+ * Plain JS on purpose (the `dsh-session-guard` arrangement): the host half needs
11
+ * no build step, so `dsh.plugin.json` points straight at `./src/index.js` and a
12
+ * stale `lib/` can never shadow the served schema.
13
+ *
14
+ * Namespace discipline (verified against the shipped rc.3 browser half):
15
+ * `ConfigForms.get(entryId)` keys forms by the *host plugin entry id*, and the
16
+ * Plugin Manager page only opens a form whose namespace appears in the served
17
+ * `settings.describe` mirror (`dsh-client-ui-plugin-manager/lib/client.js:3835`).
18
+ * The entry id is the bundle row's id, which `cordis.patch.yml` inserts as this
19
+ * package's name — so the client half reads its form under `name` below, and this
20
+ * schema is what the host serves for it.
21
+ */
22
+ import z from '@deepseek-ai/schemastery'
23
+
24
+ /** Profile row / settings namespace / module-loader id: one string, never drifted. */
25
+ export const name = 'dsh-sidebar-fold'
26
+
27
+ /** State a fresh window starts in when it has no local record yet. */
28
+ export const DEFAULT_FOLDED = false
29
+
30
+ /**
31
+ * Rows kept visible while the group folds (zh first, because the sidebar renders
32
+ * zh by default; en rides along so an English host behaves the same).
33
+ *
34
+ * Only the `插件` / `Plugins` entry is here on purpose: every other add-on row
35
+ * (schedules, agent teams, markets, …) folds by default, and the user adjusts the
36
+ * list from the settings card's per-row switches, which read the live sidebar.
37
+ */
38
+ export const DEFAULT_KEEP_LABELS = ['插件', 'Plugins']
39
+
40
+ /**
41
+ * Rows handed to the host's own "More" list (empty by default).
42
+ *
43
+ * The third state, from the 0.2.2 sidebar on: an entry can leave the column and
44
+ * live in the "More" menu. Our half only records the choice — the host owns the
45
+ * list, and its pin controls are what actually move a row.
46
+ */
47
+ export const DEFAULT_HIDE_LABELS = []
48
+
49
+ /**
50
+ * Row-content alignment for the managed area: `start` | `center` | `end`.
51
+ *
52
+ * A plain string, not a closed union: schemastery's union builder is not the same
53
+ * on every line this plugin supports, and the browser half already rejects an
54
+ * unknown value through `normalizeAlign` (falling back to `start`, the shipped
55
+ * layout). Keeping the schema primitive is what lets one Config serve
56
+ * 0.1.0-rc.8 through 0.2.1-rc.3.
57
+ */
58
+ export const DEFAULT_ALIGN = 'start'
59
+
60
+ /**
61
+ * Whether THIS schemastery build knows `.volatile()`.
62
+ *
63
+ * 0.1.7+ projects a settings form out of the plugin's own Config, and only a
64
+ * field marked volatile becomes editable there; dsh 0.1.5 ships schemastery
65
+ * 3.18.2, which has no such method at all. Calling it unconditionally would
66
+ * throw while this module LOADS — taking the whole plugin down on the older
67
+ * line. Probe, never assume (the discipline dsh-paste-dock documents at
68
+ * `src/index.ts:188-203`).
69
+ */
70
+ const schemaVolatileCapable =
71
+ typeof /** @type {{ volatile?: unknown }} */ (z.boolean()).volatile === 'function'
72
+
73
+ /** A live-editable field where the running line supports it, an ordinary one where not. */
74
+ function live(schema) {
75
+ const box = /** @type {{ volatile?: () => typeof schema }} */ (schema)
76
+ return typeof box.volatile === 'function' ? box.volatile() : schema
77
+ }
78
+
79
+ /**
80
+ * The plugin's own Config — and, on dsh 0.1.7+, its settings surface.
81
+ *
82
+ * Both fields are volatile on purpose: the browser half re-reads the served
83
+ * document through `configForms` and applies changes without a restart.
84
+ */
85
+ export const Config = z.object({
86
+ defaultFolded: live(z.boolean().default(DEFAULT_FOLDED)),
87
+ // Rows kept visible while folding. Edited through the card's per-row controls,
88
+ // which enumerate the live sidebar rather than asking the user to type labels.
89
+ keepLabels: live(z.array(z.string()).default(DEFAULT_KEEP_LABELS)),
90
+ // Rows the host owns in its "More" list (the card's third state).
91
+ hideLabels: live(z.array(z.string()).default(DEFAULT_HIDE_LABELS)),
92
+ // Icon + label alignment inside each managed row (`start` | `center` | `end`).
93
+ align: live(z.string().default(DEFAULT_ALIGN)),
94
+ })
95
+
96
+ /**
97
+ * Node-face apply. Intentionally empty: the fold lives in the browser.
98
+ */
99
+ export function apply() {}