dsh-settings-launcher 0.0.0-stage → 0.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 DDDMUC
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,98 @@
1
- # Temporary Holding Version
1
+ # dsh-settings-launcher
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ 给 DeepSeek Harness 侧栏底部那个账号入口(`settings.launcher` 座位)加**两个独立开关**,在插件页勾选,可任意组合:
4
+
5
+ | 悬浮展开菜单 | 点击进设置 | 实际行为 |
6
+ |---|---|---|
7
+ | ✗ | ✗ | 官方原样:点一下弹菜单 |
8
+ | ✓ | ✗ | 指针移入即展开原版菜单,移出收起;点击可固定 |
9
+ | ✗ | ✓ | 点击直达设置面板;菜单点不开,意见反馈与登录/退出登录移进「账号与余额」页 |
10
+ | ✓ | ✓ | 移入展开菜单;点击先收起菜单再进设置(设置始终可达)。「账号与余额」页同样有那两张卡,与菜单内容重复,这是接受的取舍 |
11
+
12
+ 勾选立即生效,不用重启。
13
+
14
+ ## 安装
15
+
16
+ ```sh
17
+ npm i -g dsh-settings-launcher # 或作为 profile 依赖安装
18
+ ```
19
+
20
+ 作为 bundle 装进某个 profile:
21
+
22
+ ```sh
23
+ dsh plugin --profile <name> install dsh-settings-launcher
24
+ ```
25
+
26
+ 或者直接给 `plugin_manager install_bundle` 传 npm tgz 的 https URL。
27
+
28
+ 插件页里搜「设置入口」即可找到;两个开关都在它自己的配置卡里。
29
+
30
+ ## 做法:什么都不替换
31
+
32
+ 座位 `settings.launcher` 始终由官方的 `AccountMenu` 占着。所以下面这些全部保持原样,一行都不用重建:
33
+
34
+ - 菜单的 DOM、图标、`⌥⌘,` 快捷键行、菜单宽度与行高
35
+ - 登录弹窗(含桌面端 deviceInfo 回跳)、退出前查运行任务的三种确认文案
36
+ - 「模型需登录」「会话已过期」两个 Toast
37
+ - `settings.launcher.notifications` 上的账号公告栈
38
+ - 全部菜单文案的 i18n
39
+
40
+ 插件只往官方那个按钮上挂两样东西:
41
+
42
+ **悬浮** — 指针事件驱动官方按钮自己的 toggle:
43
+
44
+ ```
45
+ pointerenter → 160ms 后 click() 一次(防手滑误开)
46
+ pointerleave → 260ms 后若仍展开再 click() 一次(留出移进菜单的时间)
47
+ 用户自己点过 → 固定,移出不再关;点外部或按 Esc 才释放
48
+ ```
49
+
50
+ 菜单是 portal,所以菜单体自己接管指针进入/离开,不会被「从按钮移进菜单」误关。我们自己发的合成点击有标记,不会被当成用户点击而误固定。
51
+
52
+ **点击进设置** — 一个 capture 阶段监听:
53
+
54
+ ```
55
+ 点击 → preventDefault + stopPropagation(外加 stopImmediatePropagation)
56
+ → 菜单若开着先 click() 收起它
57
+ → 跑 settings.open 命令打开设置
58
+ ```
59
+
60
+ 用 capture + `stopPropagation` 是为了让 React 挂在根节点的委托 onClick 根本收不到这个事件;`stopImmediatePropagation` 是用来压住本插件自己挂在同一个按钮上的冒泡期 `onClick`(`stopPropagation` 不会阻止同节点的其它监听器)。
61
+
62
+ 「先收起再进设置」不是多余动作:悬浮开着时,指针移入就已经把菜单拉起来了,点击几乎总是发生在「菜单已开」的状态。若此时交回官方 toggle,就只是把菜单关掉,设置永远点不开 —— 这就是两个都勾选时最初没能实现的原因。
63
+
64
+ ## 为什么走 `settings.open` 命令
65
+
66
+ 座位 owner props 里的 `openSettings` 只发给座位占位者,旁观者拿不到;而官方自己就是用 `ctx.shortcuts.register({ id: 'settings.open', ... })` 打开面板的。服务的公开面只有 `register` / `edit` / `describeBinding`,没有执行入口,但 `registry` 是它自己的字段,`registry.invoke(id, context)` 就是菜单行执行命令的方式。代码里对这个形状逐项检查:`registry` 是对象、`invoke` 是函数,不成立就不装监听、打一条警告、账号入口保持官方行为。
67
+
68
+ `commands` 里有没有 `settings.open` 是**点击时**才检查的,不是安装时:那条命令由设置 shell 在 `remoteAccess.whenAccess('settings/describe', …)` 里注册,是激活之后异步解析的。安装当时查必然"不存在",会把好构建误判成不可用(这正是两个都勾选时最初没生效的直接原因)。命令还没就绪时,这次点击原样放行给官方 toggle,不吞事件、不假装成功。
69
+
70
+ ## 无障碍
71
+
72
+ 只有「点击进设置」勾了、而「悬浮」没勾时,菜单才真的点不开。那种组合下把 `aria-haspopup` 从 `menu` 改成 `dialog`,免得读屏软件承诺一个永远不出现的菜单;其余三种组合保留官方值。禁用或卸载时改回 `menu`。
73
+
74
+ ## 「账号与余额」页的卡片什么时候出现
75
+
76
+ 只要勾了「点击进设置」就注入,不论「悬浮」是否也勾着。两个都勾时页面上会出现和菜单重复的两项(意见反馈、退出登录),但页面长相因此在四种组合里保持一致 —— 这是明确的取舍,不是遗漏。
77
+
78
+ ## 依赖的官方契约
79
+
80
+ - `button[data-signed-out]` — 官方的 `AccountMenu` 用它标记登录态,是侧栏里唯一带这个属性的按钮(`aria-haspopup` 会被本插件改写,所以不能拿它当锚点)
81
+ - `[role="menu"]` — 官方菜单的 portal 容器
82
+ - `aria-expanded` — 官方按钮的展开态
83
+ - `settings.open` 命令 + `shortcuts.registry.invoke`
84
+ - 「账号与余额」页:设置弹窗 `[data-shortcut-modal="settings"]` 里的 `[class*="_options"]` 列、当前分区用 `aria-current` 或 `_active` 类标记(两种构建都认)
85
+
86
+ 官方改这些地方,对应的开关会失效:改按钮属性则悬浮/点击都不触发(点击仍能弹菜单),改命令则「点击进设置」不生效并打警告。
87
+
88
+ ## 还原
89
+
90
+ 插件页禁用或卸载本 bundle,侧栏立刻恢复成原来的账号菜单;本插件改过的 `aria-haspopup` 也会被改回 `menu`。
91
+
92
+ ## 存储
93
+
94
+ `localStorage` 的 `dsh-settings-launcher:flags`(`{"hover":bool,"direct":bool}`)。改名前的 `dsh-settings-direct:flags` 与更早的单字符串 `dsh-settings-direct:mode`(`'hover'` / `'direct'`)都会被自动迁移一次,写进新键后清掉旧键 —— 改包名不会重置已经勾过的组合。
95
+
96
+ ## License
97
+
98
+ MIT
@@ -0,0 +1,3 @@
1
+ - insert:
2
+ - id: settings-launcher
3
+ name: dsh-settings-launcher
package/icon.svg ADDED
@@ -0,0 +1,6 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" fill="none">
2
+ <rect x="4" y="4" width="56" height="56" rx="14" fill="#EEF4FD"/>
3
+ <circle cx="32" cy="32" r="8.5" stroke="#2C7BE5" stroke-width="4"/>
4
+ <path d="M32 12v6M32 46v6M12 32h6M46 32h6M18 18l4.5 4.5M41.5 41.5 46 46M46 18l-4.5 4.5M22.5 41.5 18 46" stroke="#2C7BE5" stroke-width="4" stroke-linecap="round"/>
5
+ <path d="M44 44l8 8" stroke="#9FC0E6" stroke-width="4" stroke-linecap="round"/>
6
+ </svg>
package/locale/en.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "Settings entry",
4
+ "description": "Two independent switches for the sidebar account row: hover opens the shipped menu, and a click opens Settings directly. Either, both, or neither; neither leaves the shipped behaviour."
5
+ }
6
+ }
package/locale/zh.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "设置入口",
4
+ "description": "侧栏账号入口的两个独立开关:「悬浮展开菜单」指针移入即展开原版菜单;「点击进设置」点击直接打开设置面板。可单选也可全开,都不勾选就是官方原样。"
5
+ }
6
+ }
package/package.json CHANGED
@@ -1,6 +1,52 @@
1
1
  {
2
2
  "name": "dsh-settings-launcher",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.0.1",
4
+ "description": "侧栏账号入口的两个独立开关:悬浮自动展开原版菜单、点击直达设置;可单选也可全开,全关即官方原样。",
5
+ "type": "module",
6
+ "main": "src/index.js",
7
+ "exports": {
8
+ ".": "./src/index.js",
9
+ "./client": "./src/client.js",
10
+ "./locale/*.json": "./locale/*.json",
11
+ "./icon": "./icon.svg",
12
+ "./package.json": "./package.json"
13
+ },
14
+ "files": [
15
+ "src",
16
+ "cordis.patch.yml",
17
+ "locale/*.json",
18
+ "icon.svg"
19
+ ],
20
+ "keywords": [
21
+ "deepseek-harness",
22
+ "dsh",
23
+ "dsh-plugin",
24
+ "settings",
25
+ "sidebar",
26
+ "account-menu"
27
+ ],
28
+ "author": "DDDMUC",
29
+ "license": "MIT",
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "git+https://github.com/DDDMUC/dsh-settings-launcher.git"
33
+ },
34
+ "homepage": "https://github.com/DDDMUC/dsh-settings-launcher#readme",
35
+ "bugs": {
36
+ "url": "https://github.com/DDDMUC/dsh-settings-launcher/issues"
37
+ },
38
+ "dsh": {
39
+ "bundle": {
40
+ "patch": "./cordis.patch.yml"
41
+ },
42
+ "client": {
43
+ "platform": "web",
44
+ "immediately": true,
45
+ "inject": [
46
+ "@deepseek-ai/dsh-client-ui-settings",
47
+ "@deepseek-ai/dsh-client-ui-settings-general",
48
+ "@deepseek-ai/dsh-client-ui-settings-account"
49
+ ]
50
+ }
51
+ }
52
+ }
package/src/client.js ADDED
@@ -0,0 +1,904 @@
1
+ // dsh-settings-launcher — client half.
2
+ //
3
+ // Two independent switches for the sidebar-foot account entry, set on the
4
+ // plugin page:
5
+ //
6
+ // hover the shipped menu opens when the pointer enters the row
7
+ // direct a click opens the Settings panel instead of the menu
8
+ //
9
+ // Neither switch replaces anything. The seat `settings.launcher` keeps the
10
+ // shipped AccountMenu occupant, so its markup, icons, shortcut row, sign-in
11
+ // dialog, sign-out confirmation, "model sign-in required" toasts, the account
12
+ // notice stack on `settings.launcher.notifications` and its locale copy all
13
+ // stay exactly as shipped. Only two things are attached to the shipped button:
14
+ // pointer timers for `hover`, and one capturing click listener for `direct`
15
+ // that runs the shipped `settings.open` shortcut command before React's own
16
+ // onClick can toggle the menu.
17
+ //
18
+ // When `direct` is on and `hover` is off, the menu becomes unreachable by mouse
19
+ // — so 意见反馈 / 登录·退出登录 are injected into the shipped 账号与余额 page to
20
+ // keep them available. With `hover` also on the menu stays reachable and no
21
+ // card is injected.
22
+ window.__ModuleLoader__.load({
23
+ id: 'dsh-settings-launcher',
24
+ factory: (require) => {
25
+ const React = require('react')
26
+ const h = React.createElement
27
+
28
+ /** Effect labels; Cordis names the fiber after these. */
29
+ const NS = 'dsh-settings-launcher'
30
+ /** The questionnaire the shipped account menu opens (its only feedback target). */
31
+ const FEEDBACK_URL =
32
+ 'https://trtgsjkv6r.feishu.cn/share/base/form/shrcnlCoGElW7MQznGy9r3YYXcg?hide_uid=1&hide_device_info=1&hide_harness_version=1'
33
+
34
+ /**
35
+ * Both switches live in localStorage rather than the Loader Config: the
36
+ * client half switches at runtime, and a Config edit restarts the row
37
+ * instead of reaching the browser. One store, read by the switch card and
38
+ * the installer, so a change lands everywhere at once.
39
+ */
40
+ const STORE_KEY = 'dsh-settings-launcher:flags'
41
+ /**
42
+ * Keys written under the package's previous name. Read once, then removed
43
+ * after the first successful write, so a rename does not silently reset
44
+ * the switches a user already chose.
45
+ */
46
+ const LEGACY_STORE_KEYS = ['dsh-settings-direct:flags']
47
+ /** The single-string key written by the version before `:flags`. */
48
+ const LEGACY_STORE_KEY = 'dsh-settings-direct:mode'
49
+ const FLAG_HOVER = 'hover'
50
+ const FLAG_DIRECT = 'direct'
51
+ const DEFAULT_FLAGS = { hover: true, direct: false }
52
+ /** Row-config key: `<bundle package>#<row id from the bundle patch>`. */
53
+ const ROW_CONFIG_KEY = 'dsh-settings-launcher#settings-launcher'
54
+
55
+ /**
56
+ * Two different attribute names on purpose. The stylesheet tag and the
57
+ * injected card block used to share one, and the card cleanup sweeps every
58
+ * node carrying that attribute — so reinstalling deleted the stylesheet
59
+ * together with the cards, leaving the plugin page's form unstyled.
60
+ */
61
+ const STYLE_ATTR = 'data-dsd-style'
62
+ const INJECT_ATTR = 'data-dsd-cards'
63
+
64
+ /**
65
+ * The shipped account trigger is the only button in the sidebar carrying
66
+ * `data-signed-out` (`AccountMenu` sets it from the sign-in state). Its
67
+ * class prefix is a CSS-module hash that changes every build, and its
68
+ * `aria-haspopup` is rewritten below when the click opens a dialog — so the
69
+ * selector anchors on that flag alone.
70
+ */
71
+ const TRIGGER_SELECTOR = 'button[data-signed-out]'
72
+ /** Any open menu list; the shipped menu is portal-rendered under the body. */
73
+ const MENU_SELECTOR = '[role="menu"]'
74
+ const OPEN_DELAY = 160
75
+ const CLOSE_DELAY = 260
76
+ /** Shipped shortcut command that opens the Settings panel. */
77
+ const SETTINGS_COMMAND = 'settings.open'
78
+
79
+ const flagSubscribers = new Set()
80
+
81
+ /** Parse one `{hover,direct}` document; `null` when it is not one. */
82
+ function parseFlags(raw) {
83
+ if (raw === null) return null
84
+ try {
85
+ const parsed = JSON.parse(raw)
86
+ if (parsed === null || typeof parsed !== 'object') return null
87
+ return { hover: parsed.hover === true, direct: parsed.direct === true }
88
+ } catch {
89
+ return null
90
+ }
91
+ }
92
+
93
+ function readFlags() {
94
+ try {
95
+ const own = parseFlags(localStorage.getItem(STORE_KEY))
96
+ if (own !== null) return own
97
+ // Keys written under the package's previous name keep the user's
98
+ // choice across the rename.
99
+ for (const key of LEGACY_STORE_KEYS) {
100
+ const previous = parseFlags(localStorage.getItem(key))
101
+ if (previous !== null) return previous
102
+ }
103
+ // The single-string value from before `:flags`: 'direct' meant "click
104
+ // opens Settings instead of the menu", 'hover' meant "menu opens on
105
+ // hover".
106
+ const legacy = localStorage.getItem(LEGACY_STORE_KEY)
107
+ if (legacy === 'direct') return { hover: false, direct: true }
108
+ if (legacy === 'hover') return { hover: true, direct: false }
109
+ } catch {
110
+ // Storage may be unavailable; the defaults still apply.
111
+ }
112
+ return { ...DEFAULT_FLAGS }
113
+ }
114
+
115
+ function writeFlags(next) {
116
+ const value = { hover: next.hover === true, direct: next.direct === true }
117
+ try {
118
+ localStorage.setItem(STORE_KEY, JSON.stringify(value))
119
+ localStorage.removeItem(LEGACY_STORE_KEY)
120
+ // Drop the previous-name copies only after the new key is written.
121
+ for (const key of LEGACY_STORE_KEYS) localStorage.removeItem(key)
122
+ } catch {
123
+ // A failed write leaves the previous flags in effect; report nothing.
124
+ }
125
+ for (const fn of flagSubscribers) {
126
+ try {
127
+ fn(value)
128
+ } catch {
129
+ // A broken subscriber must not stop the others.
130
+ }
131
+ }
132
+ }
133
+
134
+ function subscribeFlags(fn) {
135
+ flagSubscribers.add(fn)
136
+ return () => {
137
+ flagSubscribers.delete(fn)
138
+ }
139
+ }
140
+
141
+ /** One line for the plugin row and for any log message. */
142
+ function flagsSummary(flags) {
143
+ if (flags.hover && flags.direct) return '当前:悬浮展开菜单 + 点击进设置'
144
+ if (flags.hover) return '当前:悬浮展开菜单'
145
+ if (flags.direct) return '当前:点击进设置'
146
+ return '当前:官方原样(点一下弹菜单)'
147
+ }
148
+
149
+ const CSS = [
150
+ '.dsd-inject{display:flex;flex-direction:column;gap:12px;margin-top:12px}',
151
+ '.dsd-card{border:1px solid var(--dsw-alias-border-secondary,rgba(128,128,128,.18));',
152
+ 'border-radius:16px;padding:16px 20px;display:flex;flex-direction:column;gap:4px;',
153
+ 'background:var(--dsw-alias-bg-primary,transparent);box-sizing:border-box}',
154
+ '.dsd-title{font-size:14px;color:var(--dsw-alias-label-primary)}',
155
+ '.dsd-sub{font-size:12px;line-height:1.5;color:var(--dsw-alias-label-tertiary)}',
156
+ '.dsd-actions{display:flex;flex-wrap:wrap;gap:8px;margin-top:6px}',
157
+ '.dsd-btn{font:inherit;font-size:13px;line-height:20px;padding:6px 14px;cursor:pointer;',
158
+ 'border-radius:var(--dsw-radius-md,8px);border:1px solid var(--dsw-alias-border-secondary,rgba(128,128,128,.3));',
159
+ 'background:transparent;color:var(--dsw-alias-label-primary)}',
160
+ '.dsd-btn:hover{background:var(--dsw-alias-interactive-bg-hover)}',
161
+ '.dsd-btn:disabled{opacity:.5;cursor:default}',
162
+ '.dsd-btn[data-tone=danger]{color:var(--dsw-alias-state-error-primary,#e5484d);',
163
+ 'border-color:var(--dsw-alias-state-error-primary,#e5484d)}',
164
+ '.dsd-note{font-size:12px;line-height:1.5;color:var(--dsw-alias-label-tertiary)}',
165
+ // The plugin page's form: two independent rows, each its own checkbox.
166
+ '.dsd-form{display:flex;flex-direction:column;gap:8px}',
167
+ '.dsd-choice{display:flex;flex-direction:column;gap:10px}',
168
+ '.dsd-option{display:flex;align-items:flex-start;gap:10px;cursor:pointer;',
169
+ 'border:1px solid var(--dsw-alias-border-secondary,rgba(128,128,128,.18));',
170
+ 'border-radius:var(--dsw-radius-md,8px);padding:10px 12px;background:transparent}',
171
+ '.dsd-option[data-selected=true]{border-color:var(--dsw-alias-state-business-primary,#4a6cf7);',
172
+ 'background:var(--dsw-alias-interactive-bg-hover)}',
173
+ '.dsd-option input{margin:2px 0 0;flex:none}',
174
+ '.dsd-optionText{display:flex;flex-direction:column;gap:2px;min-width:0}',
175
+ '.dsd-optionTitle{font-size:13px;color:var(--dsw-alias-label-primary)}',
176
+ '.dsd-optionHint{font-size:12px;line-height:1.5;color:var(--dsw-alias-label-tertiary)}',
177
+ ].join('')
178
+
179
+ function ensureStyle() {
180
+ if (typeof document === 'undefined') return null
181
+ const existing = document.querySelector('style[' + STYLE_ATTR + ']')
182
+ if (existing !== null) {
183
+ if (existing.textContent !== CSS) existing.textContent = CSS
184
+ return existing
185
+ }
186
+ const tag = document.createElement('style')
187
+ tag.setAttribute(STYLE_ATTR, '1')
188
+ tag.textContent = CSS
189
+ document.head.appendChild(tag)
190
+ return tag
191
+ }
192
+
193
+ /**
194
+ * The switch on the plugin page. The host hands a keyed
195
+ * `plugins.row.config` occupant either `view: 'summary'` (the one-liner
196
+ * under the row) or `view: 'page'` (this form). There is no save button: a
197
+ * checkbox change is the whole edit, so the choice lands immediately and
198
+ * the installer below re-runs.
199
+ */
200
+ function SwitchCard(props) {
201
+ const [, forceRender] = React.useReducer((count) => count + 1, 0)
202
+ const [flags, setFlags] = React.useState(readFlags)
203
+ React.useEffect(() => subscribeFlags((next) => { setFlags(next); forceRender() }), [])
204
+
205
+ if (props?.view === 'summary') {
206
+ return h('span', { className: 'dsd-note' }, flagsSummary(flags))
207
+ }
208
+
209
+ const row = (key, title, hint) =>
210
+ h(
211
+ 'label',
212
+ { key, className: 'dsd-option', 'data-selected': flags[key] === true ? 'true' : undefined },
213
+ h('input', {
214
+ type: 'checkbox',
215
+ checked: flags[key] === true,
216
+ onChange: (event) => writeFlags({ ...flags, [key]: event.target.checked === true }),
217
+ }),
218
+ h(
219
+ 'span',
220
+ { className: 'dsd-optionText' },
221
+ h('span', { className: 'dsd-optionTitle' }, title),
222
+ h('span', { className: 'dsd-optionHint' }, hint),
223
+ ),
224
+ )
225
+
226
+ return h(
227
+ 'div',
228
+ { className: 'dsd-form' },
229
+ h(
230
+ 'fieldset',
231
+ { className: 'dsd-choice', 'aria-label': '侧栏账号入口的交互' },
232
+ row(
233
+ FLAG_HOVER,
234
+ '悬浮展开菜单',
235
+ '指针移入即展开原版菜单(设置 / 意见反馈 / 退出登录),移出收起;点击可固定。',
236
+ ),
237
+ row(
238
+ FLAG_DIRECT,
239
+ '点击进设置',
240
+ '点击直达设置面板;「账号与余额」页同时追加意见反馈与登录/退出登录两张卡片(与菜单内容重复,属预期)。',
241
+ ),
242
+ h('span', { className: 'dsd-note' }, flagsSummary(flags)),
243
+ ),
244
+ )
245
+ }
246
+
247
+ /**
248
+ * Resolve the account Remote surface. `remote.account` is the same service
249
+ * path the account plugin injects; the nested form is the fallback for a
250
+ * deployment that only publishes the namespace root.
251
+ */
252
+ function accountService(ctx) {
253
+ for (const key of ['remote.account', 'remote']) {
254
+ try {
255
+ const service = ctx?.get(key)
256
+ if (key === 'remote') {
257
+ if (service?.account !== undefined) return service.account
258
+ } else if (service !== undefined && service !== null) {
259
+ return service
260
+ }
261
+ } catch {
262
+ // A missing service is a fallback, not a failure.
263
+ }
264
+ }
265
+ return null
266
+ }
267
+
268
+ /** Metadata the account Remote methods carry. */
269
+ function clientMeta(ctx) {
270
+ const locale = (() => {
271
+ try {
272
+ return ctx.get('locale')?.getSnapshot()?.active ?? 'zh'
273
+ } catch {
274
+ return 'zh'
275
+ }
276
+ })()
277
+ return {
278
+ version: '0.3.0',
279
+ locale,
280
+ timezoneOffsetSeconds: -new Date().getTimezoneOffset() * 60,
281
+ }
282
+ }
283
+
284
+ /**
285
+ * The actions the menu holds, appended to the shipped "账号与余额" page for
286
+ * the click-only combination.
287
+ *
288
+ * That page is owned by ui-settings-account and declares no extension slot,
289
+ * so the only way in is the DOM: when the settings dialog is open and the
290
+ * account row is the active section, a card block is appended to the section
291
+ * column and removed again on any other section. Everything here is written
292
+ * in plain DOM — React never owns these nodes, so the observer re-adds them
293
+ * whenever the shell re-renders the column.
294
+ */
295
+ /** Active-section text that means "the account page". */
296
+ const ACCOUNT_LABELS = ['账号与余额', 'Account & balance', 'Account']
297
+
298
+ function buildInjectedCards(ctx) {
299
+ const root = document.createElement('div')
300
+ root.setAttribute(INJECT_ATTR, '1')
301
+ root.className = 'dsd-inject'
302
+
303
+ const accountCard = document.createElement('section')
304
+ accountCard.className = 'dsd-card'
305
+ const accountTitle = document.createElement('div')
306
+ accountTitle.className = 'dsd-title'
307
+ accountTitle.textContent = '账号'
308
+ const accountSub = document.createElement('div')
309
+ accountSub.className = 'dsd-sub'
310
+ accountSub.textContent = '正在读取账号状态…'
311
+ const accountActions = document.createElement('div')
312
+ accountActions.className = 'dsd-actions'
313
+ accountCard.append(accountTitle, accountSub, accountActions)
314
+
315
+ const feedbackCard = document.createElement('section')
316
+ feedbackCard.className = 'dsd-card'
317
+ const feedbackTitle = document.createElement('div')
318
+ feedbackTitle.className = 'dsd-title'
319
+ feedbackTitle.textContent = '意见反馈'
320
+ const feedbackSub = document.createElement('div')
321
+ feedbackSub.className = 'dsd-sub'
322
+ feedbackSub.textContent = '在浏览器中打开问卷,提交问题或建议。'
323
+ const feedbackActions = document.createElement('div')
324
+ feedbackActions.className = 'dsd-actions'
325
+ const feedbackButton = document.createElement('button')
326
+ feedbackButton.type = 'button'
327
+ feedbackButton.className = 'dsd-btn'
328
+ feedbackButton.textContent = '打开问卷'
329
+ feedbackButton.addEventListener('click', () => {
330
+ window.open(FEEDBACK_URL, '_blank', 'noopener')
331
+ })
332
+ feedbackActions.append(feedbackButton)
333
+ feedbackCard.append(feedbackTitle, feedbackSub, feedbackActions)
334
+
335
+ root.append(accountCard, feedbackCard)
336
+
337
+ const service = accountService(ctx)
338
+
339
+ /**
340
+ * One action button whose listeners are rebuilt whenever the account state
341
+ * changes. Replacing the node keeps the old listeners from stacking up;
342
+ * `actionButton` always points at the node currently in the DOM.
343
+ */
344
+ let actionButton = null
345
+ let busy = false
346
+
347
+ const setBusy = (value, text) => {
348
+ busy = value
349
+ if (actionButton === null) return
350
+ actionButton.disabled = value
351
+ if (value) actionButton.textContent = text
352
+ }
353
+
354
+ async function onSignOut() {
355
+ if (service === null || busy || actionButton === null) return
356
+ const node = actionButton
357
+ if (node.dataset.confirm !== '1') {
358
+ node.dataset.confirm = '1'
359
+ node.textContent = '确认退出'
360
+ accountSub.textContent = '再点一次「确认退出」完成退出。'
361
+ setTimeout(() => {
362
+ if (node.dataset.confirm === '1') {
363
+ node.dataset.confirm = ''
364
+ paint('signed-in')
365
+ }
366
+ }, 5000)
367
+ return
368
+ }
369
+ node.dataset.confirm = ''
370
+ setBusy(true, '正在退出…')
371
+ try {
372
+ const result = await service.signOut(clientMeta(ctx))
373
+ if (!result?.ok) throw new Error('sign out failed')
374
+ paint('signed-out')
375
+ } catch {
376
+ accountSub.textContent = '退出登录失败,请稍后再试。'
377
+ paint('signed-in')
378
+ }
379
+ }
380
+
381
+ async function onSignIn() {
382
+ if (service === null || busy || actionButton === null) return
383
+ setBusy(true, '正在登录…')
384
+ try {
385
+ const result = await service.startSignIn(clientMeta(ctx))
386
+ if (!result?.ok) throw new Error('sign in failed')
387
+ const url = result.value?.attempt?.authorizeUrl
388
+ if (typeof url === 'string' && url !== '') window.open(url, '_blank', 'noopener')
389
+ accountSub.textContent = '已在浏览器中打开登录页,完成后回到这里即可。'
390
+ paint('signed-out')
391
+ } catch {
392
+ accountSub.textContent = '无法开始登录,请稍后再试。'
393
+ paint('signed-out')
394
+ }
395
+ }
396
+
397
+ /** `status` is 'signed-in', 'signed-out', 'unavailable' or 'unknown'. */
398
+ const paint = (status) => {
399
+ busy = false
400
+ if (status === 'signed-in') accountSub.textContent = '退出后不影响任何本地数据,可随时重新登录。'
401
+ else if (status === 'signed-out') accountSub.textContent = '未登录。'
402
+ else accountSub.textContent = '当前环境无法读取账号服务。'
403
+
404
+ const replacement = document.createElement('button')
405
+ replacement.type = 'button'
406
+ replacement.className = 'dsd-btn'
407
+ if (status === 'signed-in') {
408
+ replacement.textContent = '退出登录'
409
+ replacement.addEventListener('click', () => { void onSignOut() })
410
+ } else {
411
+ replacement.textContent = '登录'
412
+ if (status === 'signed-out') {
413
+ replacement.addEventListener('click', () => { void onSignIn() })
414
+ } else {
415
+ replacement.disabled = true
416
+ }
417
+ }
418
+ if (actionButton === null) {
419
+ actionButton = replacement
420
+ accountActions.append(actionButton)
421
+ return
422
+ }
423
+ actionButton.replaceWith(replacement)
424
+ actionButton = replacement
425
+ }
426
+
427
+ paint('unknown')
428
+ if (service !== null) {
429
+ Promise.resolve()
430
+ .then(() => service.getState())
431
+ .then((result) => {
432
+ if (!result?.ok) return paint('unknown')
433
+ paint(result.value?.status === 'credential-stored' ? 'signed-in' : 'signed-out')
434
+ })
435
+ .catch(() => paint('unknown'))
436
+ } else {
437
+ paint('unavailable')
438
+ }
439
+
440
+ return root
441
+ }
442
+
443
+ /**
444
+ * Keep the injected block in step with the open dialog: the shell swaps the
445
+ * section column on every navigation, so the block is re-added on the account
446
+ * row and dropped everywhere else.
447
+ */
448
+ function installAccountCardInjector(ctx) {
449
+ if (typeof document === 'undefined') return () => {}
450
+ let dialog = null
451
+ let dialogObserver = null
452
+ let scheduled = false
453
+
454
+ const findDialog = () =>
455
+ document.querySelector('[role="dialog"][data-shortcut-modal="settings"]')
456
+
457
+ /**
458
+ * The selected row's label. The shell marks it with `aria-current` in some
459
+ * builds and with a CSS-module `_active` class in others (the local class
460
+ * suffix is stable across builds; the hashed prefix is not), so both are
461
+ * accepted rather than assuming one.
462
+ */
463
+ const currentLabel = (node) => {
464
+ const active =
465
+ node.querySelector('nav button[aria-current="true"]') ??
466
+ node.querySelector('nav button[class*="_active"]')
467
+ return active === null ? null : (active.textContent ?? '').trim()
468
+ }
469
+
470
+ const sync = () => {
471
+ scheduled = false
472
+ const next = findDialog()
473
+ if (next === null) {
474
+ if (dialogObserver !== null) {
475
+ dialogObserver.disconnect()
476
+ dialogObserver = null
477
+ }
478
+ dialog = null
479
+ return
480
+ }
481
+ if (next !== dialog) {
482
+ if (dialogObserver !== null) dialogObserver.disconnect()
483
+ dialog = next
484
+ dialogObserver = new MutationObserver(schedule)
485
+ dialogObserver.observe(next, {
486
+ childList: true,
487
+ subtree: true,
488
+ attributes: true,
489
+ // The active row is marked by `aria-current` in some builds and by a
490
+ // class swap in others, so both attribute changes must re-run `sync`.
491
+ attributeFilter: ['aria-current', 'class'],
492
+ })
493
+ }
494
+ const column = dialog.querySelector('[class*="_options"]')
495
+ if (column === null) return
496
+ const label = currentLabel(dialog)
497
+ const wanted = label !== null && ACCOUNT_LABELS.some((one) => label.includes(one))
498
+ const existing = column.querySelector('[' + INJECT_ATTR + ']')
499
+ if (!wanted) {
500
+ if (existing !== null) existing.remove()
501
+ return
502
+ }
503
+ if (existing !== null) return
504
+ column.append(buildInjectedCards(ctx))
505
+ }
506
+
507
+ function schedule() {
508
+ if (scheduled) return
509
+ scheduled = true
510
+ if (typeof requestAnimationFrame === 'function') requestAnimationFrame(sync)
511
+ else setTimeout(sync, 16)
512
+ }
513
+
514
+ const bodyObserver = new MutationObserver((records) => {
515
+ for (const record of records) {
516
+ if (record.addedNodes.length > 0 || record.removedNodes.length > 0) {
517
+ schedule()
518
+ return
519
+ }
520
+ }
521
+ })
522
+ bodyObserver.observe(document.body, { childList: true })
523
+ schedule()
524
+
525
+ return () => {
526
+ bodyObserver.disconnect()
527
+ if (dialogObserver !== null) dialogObserver.disconnect()
528
+ for (const node of document.querySelectorAll('[' + INJECT_ATTR + ']')) node.remove()
529
+ }
530
+ }
531
+
532
+ /**
533
+ * Build a caller for the shipped `settings.open` command.
534
+ *
535
+ * Nothing in the launcher seat hands out `openSettings` to a bystander, so
536
+ * the panel is opened through the same command its own shortcut uses. The
537
+ * service exposes `register` / `edit` / `describeBinding` but not a runner;
538
+ * `registry` is its own plain field and `registry.invoke(id, context)` is
539
+ * how a menu row runs a command. That shape is checked here rather than
540
+ * assumed, and a deployment without it leaves the shipped click alone.
541
+ */
542
+ function settingsInvoker(ctx) {
543
+ let service = null
544
+ try {
545
+ service = ctx?.get('shortcuts') ?? null
546
+ } catch {
547
+ service = null
548
+ }
549
+ if (service === null) return null
550
+ const registry = service.registry
551
+ if (registry === null || typeof registry !== 'object') return null
552
+ if (typeof registry.invoke !== 'function') return null
553
+ return () => {
554
+ // `settings.open` is not registered by the package itself: the settings
555
+ // shell registers it inside `remoteAccess.whenAccess('settings/describe',
556
+ // ...)`, which resolves asynchronously after activation. Checking
557
+ // `commands.has()` at install time therefore reports "missing" on a
558
+ // perfectly good build, so the check belongs here, per click.
559
+ const commands = registry.commands
560
+ if (typeof commands?.has === 'function' && commands.has(SETTINGS_COMMAND) === false) {
561
+ return false
562
+ }
563
+ // `modal: null` means "no modal is covering the page"; the command
564
+ // opens the panel. Passing `settings` there would close it instead.
565
+ registry.invoke(SETTINGS_COMMAND, { region: 'page', modal: null })
566
+ return true
567
+ }
568
+ }
569
+
570
+ /**
571
+ * Attach the two behaviours to the shipped account trigger.
572
+ *
573
+ * Nothing is rendered and no slot is taken, so the menu keeps every bit of
574
+ * its shipped appearance, keyboard behaviour, toasts, dialogs and its
575
+ * `settings.launcher.notifications` stack.
576
+ *
577
+ * hover pointer enters the row -> click it once, if it is not open yet
578
+ * pointer leaves the row -> click it again after a delay, unless
579
+ * the pointer moved into the open menu
580
+ * a real click -> that menu is pinned
581
+ * direct a click lowers the menu if hover had raised it, then opens the
582
+ * Settings panel
583
+ */
584
+ function installInteraction(ctx, flags) {
585
+ if (typeof document === 'undefined') return () => {}
586
+
587
+ const timers = { open: null, close: null }
588
+ let trigger = null
589
+ let menu = null
590
+ /** True while our own synthetic click is running, so it is not "a click". */
591
+ let synthetic = false
592
+ /** A menu the user opened by clicking stays open until dismissed. */
593
+ let pinned = false
594
+ const openSettings = flags.direct ? settingsInvoker(ctx) : null
595
+
596
+ if (flags.direct && openSettings === null) {
597
+ console.warn(
598
+ '[dsh-settings-launcher] 拿不到 shortcuts 服务的 registry.invoke,' +
599
+ '「点击进设置」这次不生效,账号入口保持官方行为。',
600
+ )
601
+ }
602
+
603
+ const clear = (name) => {
604
+ if (timers[name] !== null) {
605
+ clearTimeout(timers[name])
606
+ timers[name] = null
607
+ }
608
+ }
609
+
610
+ const isOpen = () => trigger !== null && trigger.getAttribute('aria-expanded') === 'true'
611
+
612
+ const openMenu = () => {
613
+ if (trigger === null || isOpen()) return
614
+ synthetic = true
615
+ try {
616
+ trigger.click()
617
+ } finally {
618
+ synthetic = false
619
+ }
620
+ }
621
+
622
+ const closeMenu = () => {
623
+ if (trigger === null || !isOpen()) return
624
+ synthetic = true
625
+ try {
626
+ trigger.click()
627
+ } finally {
628
+ synthetic = false
629
+ }
630
+ }
631
+
632
+ /** The portal the trigger raises, so hovering it counts as "inside". */
633
+ const adoptMenu = (before) => {
634
+ const candidates = Array.from(document.querySelectorAll(MENU_SELECTOR))
635
+ const next = candidates.find((node) => !before.has(node)) ?? null
636
+ if (next === menu) return
637
+ releaseMenu()
638
+ menu = next
639
+ if (menu !== null) {
640
+ menu.addEventListener('pointerenter', onMenuEnter)
641
+ menu.addEventListener('pointerleave', onMenuLeave)
642
+ }
643
+ }
644
+
645
+ function releaseMenu() {
646
+ if (menu === null) return
647
+ menu.removeEventListener('pointerenter', onMenuEnter)
648
+ menu.removeEventListener('pointerleave', onMenuLeave)
649
+ menu = null
650
+ }
651
+
652
+ const pointerInsideMenu = () => {
653
+ if (menu === null || !menu.isConnected) return false
654
+ return menu.matches(':hover') || menu.contains(document.activeElement)
655
+ }
656
+
657
+ const scheduleOpen = () => {
658
+ clear('close')
659
+ if (isOpen()) return
660
+ clear('open')
661
+ timers.open = setTimeout(() => {
662
+ timers.open = null
663
+ if (pinned) return
664
+ const before = new Set(document.querySelectorAll(MENU_SELECTOR))
665
+ openMenu()
666
+ // The menu mounts after the click; adopt it once React has committed.
667
+ setTimeout(() => adoptMenu(before), 0)
668
+ }, OPEN_DELAY)
669
+ }
670
+
671
+ const scheduleClose = () => {
672
+ clear('open')
673
+ clear('close')
674
+ if (pinned) return
675
+ timers.close = setTimeout(() => {
676
+ timers.close = null
677
+ if (pointerInsideMenu()) return
678
+ closeMenu()
679
+ releaseMenu()
680
+ }, CLOSE_DELAY)
681
+ }
682
+
683
+ function onMenuEnter() {
684
+ clear('close')
685
+ }
686
+
687
+ function onMenuLeave() {
688
+ scheduleClose()
689
+ }
690
+
691
+ function onEnter() {
692
+ scheduleOpen()
693
+ }
694
+
695
+ function onLeave() {
696
+ scheduleClose()
697
+ }
698
+
699
+ /**
700
+ * A real click is the shipped toggle. Pin only when that click *opened*
701
+ * the menu, and read the result after React has committed the new
702
+ * `aria-expanded` rather than guessing it here.
703
+ */
704
+ function onClick() {
705
+ if (synthetic) return
706
+ clear('open')
707
+ clear('close')
708
+ const before = isOpen()
709
+ setTimeout(() => {
710
+ if (isOpen() && !before) {
711
+ pinned = true
712
+ return
713
+ }
714
+ pinned = false
715
+ releaseMenu()
716
+ }, 0)
717
+ }
718
+
719
+ /**
720
+ * `direct`: run the settings command instead of React's menu toggle.
721
+ *
722
+ * Capturing on the trigger and stopping propagation keeps React's
723
+ * delegated onClick (attached at the root, bubble phase) from ever seeing
724
+ * the event. Our own bubble-phase `onClick` sits on this same node, so it
725
+ * needs `stopImmediatePropagation` too. Because `hover` raises the menu on
726
+ * pointer-enter, a click normally arrives with the menu already open; that
727
+ * click lowers the menu and then opens Settings, so both switches can be
728
+ * on at once. `pinned` therefore only applies to the hover-only mode.
729
+ */
730
+ function onClickCapture(event) {
731
+ if (openSettings === null || synthetic) return
732
+ // The command may not be registered yet; when it is not, leave the
733
+ // event alone so the shipped toggle still runs instead of swallowing it.
734
+ if (openSettings() === false) return
735
+
736
+ event.preventDefault()
737
+ event.stopPropagation()
738
+ // Our own bubble-phase listener sits on this same node and would still
739
+ // run after stopPropagation, so stop it as well.
740
+ if (typeof event.stopImmediatePropagation === 'function') event.stopImmediatePropagation()
741
+ clear('open')
742
+ clear('close')
743
+ pinned = false
744
+ // With `hover` on, the pointer entering the row already raised the menu,
745
+ // so a click usually arrives while it is open. Lower it first, then open
746
+ // Settings — otherwise the two switches together would only be able to
747
+ // close the menu and Settings would stay unreachable by mouse.
748
+ if (isOpen()) {
749
+ closeMenu()
750
+ releaseMenu()
751
+ }
752
+ }
753
+
754
+ /** Pin release: outside pointerdown, Escape, or the menu closing itself. */
755
+ function onDocumentPointerDown(event) {
756
+ if (!pinned) return
757
+ if (trigger !== null && trigger.contains(event.target)) return
758
+ if (menu !== null && menu.contains(event.target)) return
759
+ pinned = false
760
+ }
761
+
762
+ function onDocumentKeyDown(event) {
763
+ if (event.key === 'Escape' && pinned) pinned = false
764
+ }
765
+
766
+ /**
767
+ * Announce the real behaviour. With `direct` alone the menu cannot be
768
+ * opened at all, so keeping `aria-haspopup="menu"` would promise a menu
769
+ * that never appears; with `hover` on as well the menu is still reachable
770
+ * and the shipped value stays right.
771
+ */
772
+ const applyAria = (node) => {
773
+ if (node === null) return
774
+ if (flags.direct && !flags.hover) node.setAttribute('aria-haspopup', 'dialog')
775
+ }
776
+
777
+ const restoreAria = (node) => {
778
+ if (node === null) return
779
+ if (flags.direct && !flags.hover) node.setAttribute('aria-haspopup', 'menu')
780
+ }
781
+
782
+ const bind = () => {
783
+ const next = document.querySelector(TRIGGER_SELECTOR)
784
+ if (next === trigger) return
785
+ if (trigger !== null) {
786
+ trigger.removeEventListener('pointerenter', onEnter)
787
+ trigger.removeEventListener('pointerleave', onLeave)
788
+ trigger.removeEventListener('click', onClick)
789
+ trigger.removeEventListener('click', onClickCapture, true)
790
+ restoreAria(trigger)
791
+ }
792
+ trigger = next
793
+ pinned = false
794
+ releaseMenu()
795
+ if (trigger === null) return
796
+ if (flags.hover) {
797
+ trigger.addEventListener('pointerenter', onEnter)
798
+ trigger.addEventListener('pointerleave', onLeave)
799
+ trigger.addEventListener('click', onClick)
800
+ }
801
+ if (openSettings !== null) trigger.addEventListener('click', onClickCapture, true)
802
+ applyAria(trigger)
803
+ }
804
+
805
+ const observer = new MutationObserver(() => {
806
+ bind()
807
+ // The menu unmounts on close; drop the reference so a reopen re-adopts.
808
+ if (menu !== null && !isOpen()) releaseMenu()
809
+ })
810
+ observer.observe(document.body, { childList: true, subtree: true })
811
+ bind()
812
+
813
+ document.addEventListener('pointerdown', onDocumentPointerDown, true)
814
+ document.addEventListener('keydown', onDocumentKeyDown, true)
815
+
816
+ return () => {
817
+ clear('open')
818
+ clear('close')
819
+ observer.disconnect()
820
+ document.removeEventListener('pointerdown', onDocumentPointerDown, true)
821
+ document.removeEventListener('keydown', onDocumentKeyDown, true)
822
+ if (trigger !== null) {
823
+ trigger.removeEventListener('pointerenter', onEnter)
824
+ trigger.removeEventListener('pointerleave', onLeave)
825
+ trigger.removeEventListener('click', onClick)
826
+ trigger.removeEventListener('click', onClickCapture, true)
827
+ restoreAria(trigger)
828
+ }
829
+ releaseMenu()
830
+ }
831
+ }
832
+
833
+ return {
834
+ inject: ['slots', 'remote.account'],
835
+ apply(ctx) {
836
+ // ctx.effect 要的是一个 cleanup 函数;ensureStyle() 返回的是 <style>
837
+ // 元素,直接返回会让 Cordis 在激活时拿到非函数值而把 fiber 判为 failed。
838
+ ctx.effect(() => {
839
+ const tag = ensureStyle()
840
+ return () => {
841
+ if (tag !== null) tag.remove()
842
+ }
843
+ }, NS + ': stylesheet')
844
+
845
+ // Both switches are read on every install, so a checkbox change tears
846
+ // the running behaviour down and builds the next one without a reload.
847
+ ctx.effect(() => {
848
+ let dispose = null
849
+ const install = () => {
850
+ if (dispose !== null) {
851
+ try {
852
+ dispose()
853
+ } catch {
854
+ // Rebuilding anyway; a failed teardown is not fatal.
855
+ }
856
+ dispose = null
857
+ }
858
+ const flags = readFlags()
859
+ const releases = [installInteraction(ctx, flags)]
860
+ // With `direct` the card is always injected, including when the
861
+ // menu is also reachable through hover. That repeats 意见反馈 and
862
+ // 退出登录 on the account page, which is the intended trade: the
863
+ // page looks the same however the menu was opened.
864
+ if (flags.direct) releases.push(installAccountCardInjector(ctx))
865
+ dispose = () => {
866
+ for (const release of releases) {
867
+ try {
868
+ release()
869
+ } catch {
870
+ // One failed cleanup must not skip the others.
871
+ }
872
+ }
873
+ }
874
+ }
875
+ install()
876
+ const off = subscribeFlags(install)
877
+ return () => {
878
+ off()
879
+ if (dispose !== null) {
880
+ try {
881
+ dispose()
882
+ } catch {
883
+ // Nothing left to report on teardown failure.
884
+ }
885
+ dispose = null
886
+ }
887
+ }
888
+ }, NS + ': behaviours')
889
+
890
+ // The plugin page's switches; independent of what is running.
891
+ ctx.effect(() => {
892
+ try {
893
+ return ctx.slots.inject('plugins.row.config', () =>
894
+ ctx.slots.register({ name: 'plugins.row.config', key: ROW_CONFIG_KEY }, SwitchCard),
895
+ )
896
+ } catch (error) {
897
+ console.warn('[dsh-settings-launcher] 无法挂载插件页开关:', error)
898
+ return undefined
899
+ }
900
+ }, NS + ': row config')
901
+ },
902
+ }
903
+ },
904
+ })
package/src/index.js ADDED
@@ -0,0 +1,2 @@
1
+ /** Host half of the bundle; the Client module owns the UI. */
2
+ export function apply() {}