dsh-xiaomi-tts 0.1.0 → 1.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/README.en.md CHANGED
@@ -1,10 +1,10 @@
1
1
  # dsh-xiaomi-tts
2
2
 
3
- [中文说明](README.md)
3
+ <p><a href="README.md"><strong>中文说明 →</strong></a></p>
4
4
 
5
5
  Xiaomi MiMo text-to-speech controls for finalized assistant messages in DeepSeek Harness Web.
6
6
 
7
- ## Screenshots
7
+ ## Preview
8
8
 
9
9
  ![Xiaomi MiMo settings menu](assets/menu.png)
10
10
 
@@ -14,12 +14,12 @@ Xiaomi MiMo text-to-speech controls for finalized assistant messages in DeepSeek
14
14
 
15
15
  ## Features
16
16
 
17
- - Adds a read-aloud button to the assistant message action strip.
17
+ - Adds an optional read-aloud button to the assistant message action strip; it is enabled by default.
18
18
  - Uses Xiaomi MiMo's official `mimo-v2.5-tts` Chat Completions-compatible API.
19
- - Configures the API key, autoplay, built-in voice, MP3/WAV format, and reading instruction under **Settings → Plugins → Plugin configuration**.
19
+ - Configures whether to show the read-aloud button, the API key, autoplay, built-in voice, MP3/WAV format, and reading instruction under **Settings → Plugins → Plugin configuration**.
20
20
  - Keeps the API key on the DSH Host. The browser sends only the response text to a same-origin plugin route.
21
21
  - Supports pause, resume, regeneration, request errors, and browser autoplay rejection.
22
- - The settings card is collapsed by default and expands on click.
22
+ - Cleans speech text before sending it to TTS: URLs, file paths, code blocks, emoji, icons, and control characters are removed, and common Chinese punctuation is converted to ASCII punctuation.
23
23
 
24
24
  Official Xiaomi MiMo TTS reference: <https://mimo.mi.com/static/docs/api/audio/tts.md>
25
25
 
@@ -31,6 +31,14 @@ dsh plugin --profile web add dsh-xiaomi-tts
31
31
 
32
32
  Restart `dsh web`, then open **Settings → Plugins → Plugin configuration** and save a Xiaomi MiMo API key.
33
33
 
34
+ The settings include the API key, read-aloud button, automatic read-aloud, voice, audio format, and reading instruction. Both switches are enabled by default; disabling the read-aloud button also disables automatic read-aloud, while enabling automatic read-aloud enables the button.
35
+
36
+ Browsers may block autoplay. If that happens, click the read-aloud button below a response.
37
+
38
+ ### Speech text preprocessing
39
+
40
+ Read-aloud uses cleaned text and does not modify the assistant reply shown in the chat. Markdown links keep their readable labels while their targets are removed; URLs, file paths, complete code blocks, emoji, icons, zero-width characters, and control characters are not sent to Xiaomi MiMo. Inline code keeps its text without backticks, consecutive whitespace is collapsed, and common Chinese punctuation is converted to ASCII punctuation.
41
+
34
42
  ## Development
35
43
 
36
44
  ```bash
@@ -40,7 +48,11 @@ pnpm test
40
48
  pnpm pack:check
41
49
  ```
42
50
 
43
- The response text is sent to Xiaomi MiMo when speech is generated. Review Xiaomi's privacy and data-handling terms before using the plugin with sensitive content.
51
+ ## Privacy
52
+
53
+ - The API key stays on the DSH Host and is never sent to the browser.
54
+ - Response text is sent to Xiaomi MiMo when speech is generated.
55
+ - Audio is played through a temporary Blob URL and is not persisted to disk.
44
56
 
45
57
  ## License
46
58
 
package/README.md CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  为 DeepSeek Harness Web 的助手回复添加 Xiaomi MiMo TTS 语音朗读。
4
4
 
5
- ## 界面预览
5
+ <p><a href="README.en.md"><strong>English README →</strong></a></p>
6
6
 
7
- 设置菜单中的插件配置默认收起,点击标题即可展开;助手回复操作栏会显示朗读、暂停和继续按钮。
7
+ ## 预览
8
8
 
9
9
  ![Xiaomi MiMo 设置菜单](assets/menu.png)
10
10
 
@@ -14,14 +14,12 @@
14
14
 
15
15
  ## 功能
16
16
 
17
- - 在每条已完成助手回复正文下方的操作栏中添加“朗读”按钮。
17
+ - 在每条已完成助手回复正文下方的操作栏中按需显示“朗读”按钮(默认开启)。
18
18
  - 调用 Xiaomi MiMo 官方 `mimo-v2.5-tts` 接口,把回复正文转成 MP3 或 WAV 并播放。
19
- - 在 **设置 → 插件 → 插件配置** 中配置 API Key、自动播报、音色、格式和朗读指令。
19
+ - 在 **设置 → 插件 → 插件配置** 中配置是否显示朗读按钮、API Key、自动播报、音色、格式和朗读指令。
20
20
  - API Key 仅由 DSH Host 读取,浏览器只向同源 Host 路由提交回复正文。
21
21
  - 支持暂停、继续、重新生成,以及浏览器自动播放被拦截时的提示。
22
- - 设置卡片默认折叠,减少插件配置占用的页面空间。
23
-
24
- > 当前版本聚焦官方内置音色模型 `mimo-v2.5-tts`,暂不提供 Voice Design 与 Voice Clone 配置。
22
+ - 发送给 TTS 前会积极清理朗读文本:移除网址、文件路径、代码块、表情符号、图标和控制字符,并将常规中文标点转换为英文标点。
25
23
 
26
24
  ## 环境要求
27
25
 
@@ -62,31 +60,19 @@ dsh plugin --profile web add github:ppy-web/dsh-plugin-xiaomi-mimo-tts
62
60
  - 英文女声:`Mia`、`Chloe`
63
61
  - 英文男声:`Milo`、`Dean`
64
62
 
65
- 设置卡片默认收起。点击“Xiaomi MiMo 语音朗读”标题后,可配置:
66
-
67
- - API Key
68
- - 是否自动播报新回复
69
- - 内置音色
70
- - MP3/WAV 输出格式
71
- - 朗读风格指令
72
-
73
- 默认配置位于 `cordis.patch.yml`,用户设置会覆盖 composition 默认值。
74
-
75
- ## 自动播报说明
63
+ 配置项包括 API Key、朗读按钮、自动播报、音色、音频格式和朗读风格指令。两个开关默认开启;关闭朗读按钮会同步关闭自动播报,开启自动播报会自动开启朗读按钮。
76
64
 
77
- 浏览器通常要求页面先发生一次用户交互,才允许带声音的自动播放。如果浏览器拒绝 `audio.play()`,插件不会绕过浏览器策略,点击回复下方的朗读按钮即可播放。
65
+ 浏览器可能阻止自动播放;遇到这种情况,请点击回复下方的朗读按钮。
78
66
 
79
- 为避免刚启用插件或打开历史会话时批量朗读旧消息,自动播报只处理插件加载后短时间内新挂载的回复操作项。
67
+ ### 朗读文本处理
80
68
 
81
- ## 安全设计
69
+ 朗读只使用清理后的正文,不会修改聊天记录中显示的助手回复。Markdown 链接会保留可读标题并删除链接地址;网址、文件路径、完整代码块、表情符号、图标、零宽字符和控制字符不会发送给 Xiaomi MiMo。行内代码保留文字内容但去除反引号,连续空白会合并,常规中文标点会转换为 ASCII 英文标点。
82
70
 
83
- - `apiKey` 的 Schemastery schema 标记为 `role('secret')`。
84
- - 设置描述通过 DSH wire 传到浏览器时会脱敏。
85
- - Host 使用 API Key 请求 `https://api.xiaomimimo.com/v1/chat/completions`。
86
- - 音频响应不会持久化到磁盘,浏览器使用临时 Blob URL 播放并在切换时释放。
87
- - Host 路由限制请求体大小、正文长度和请求超时。
71
+ ## 隐私
88
72
 
89
- 请注意:回复正文会发送给 Xiaomi MiMo 服务,请在使用前确认内容符合你的隐私与合规要求。
73
+ - API Key 仅保存在 DSH Host,不会发送给浏览器。
74
+ - 生成语音时,回复正文会发送给 Xiaomi MiMo 服务。
75
+ - 音频只通过临时 Blob URL 播放,不会持久化到磁盘。
90
76
 
91
77
  ## 开发
92
78
 
package/assets/menu.png CHANGED
Binary file
package/cordis.patch.yml CHANGED
@@ -4,12 +4,13 @@
4
4
  - id: xiaomi-mimo-tts
5
5
  name: 'dsh-xiaomi-tts'
6
6
  config:
7
+ enabled: true
7
8
  apiKey: ''
8
9
  baseURL: 'https://api.xiaomimimo.com/v1'
9
10
  model: 'mimo-v2.5-tts'
10
11
  voice: '冰糖'
11
12
  format: 'mp3'
12
- autoPlay: false
13
+ autoPlay: true
13
14
  instruction: '请用自然、清晰、语速适中的语气朗读。'
14
15
  maxTextLength: 12000
15
16
  requestTimeoutMs: 120000
@@ -1,4 +1,5 @@
1
1
  import type { ClientContext } from '@deepseek-ai/dsh-client-runtime/client';
2
+ /** Client services required by this plugin. */
2
3
  export declare const inject: string[];
3
4
  declare const zh: {
4
5
  readonly 'action.play': "朗读回复";
@@ -9,19 +10,27 @@ declare const zh: {
9
10
  readonly 'error.noText': "这条回复没有可朗读的正文。";
10
11
  readonly 'error.request': "语音生成失败。";
11
12
  readonly 'error.play': "浏览器阻止了自动播放,请点击朗读按钮。";
12
- readonly 'settings.title': "Xiaomi MiMo 语音朗读";
13
+ readonly 'settings.title': "语音朗读 (Xiaomi MiMo)";
13
14
  readonly 'settings.description': "在助手回复操作栏中使用 Xiaomi MiMo TTS 生成并播放语音。";
15
+ readonly 'settings.enabled': "显示朗读按钮";
16
+ readonly 'settings.enabledHint': "关闭后不会在助手回复操作栏显示朗读按钮,也不会自动播报。";
14
17
  readonly 'settings.apiKey': "API Key";
15
18
  readonly 'settings.apiKeyHint': "密钥保存在 DSH 设置文件中,传到浏览器前会被脱敏。";
16
19
  readonly 'settings.apiKeyStatus': "只有输入新值并保存时才会替换现有密钥。";
17
- readonly 'settings.autoPlay': "自动播报新回复";
18
- readonly 'settings.autoPlayHint': "浏览器可能因为自动播放策略而拒绝;拒绝后可手动点击朗读。";
20
+ readonly 'settings.apiKeyConfigured': "已配置";
21
+ readonly 'settings.getApiKey': "获取 API Key";
22
+ readonly 'settings.autoPlay': "开启自动播报";
23
+ readonly 'settings.autoPlayHint': "开启时会同步显示朗读按钮;浏览器也可能拒绝自动播放。";
19
24
  readonly 'settings.voice': "内置音色";
20
25
  readonly 'settings.format': "音频格式";
21
26
  readonly 'settings.instruction': "朗读风格指令";
22
27
  readonly 'settings.save': "保存";
23
28
  readonly 'settings.saving': "保存中…";
24
29
  readonly 'settings.saved': "已保存";
30
+ readonly 'settings.unsaved': "未保存";
31
+ readonly 'settings.overridden': "已覆盖";
32
+ readonly 'settings.reset': "恢复默认";
33
+ readonly 'settings.discard': "放弃修改";
25
34
  readonly 'settings.failed': "保存失败,请重试。";
26
35
  readonly 'settings.readOnly': "当前 DSH 设置为只读。";
27
36
  readonly 'settings.secretPlaceholder': "输入新的 Xiaomi MiMo API Key";
@@ -34,6 +43,7 @@ declare module '@deepseek-ai/dsh-client-ui-slots' {
34
43
  'xiaomi-mimo-tts': LocaleKey;
35
44
  }
36
45
  }
46
+ /** Register the Web action, settings card, locale dictionaries, and styles. */
37
47
  export declare function apply(ctx: ClientContext): void;
38
48
  export {};
39
49
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,aAAa,EAAuC,MAAM,wCAAwC,CAAA;AAMhH,eAAO,MAAM,MAAM,UAMlB,CAAA;AA+BD,QAAA,MAAM,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BE,CAAA;AA+BV,KAAK,SAAS,GAAG,MAAM,OAAO,EAAE,CAAA;AAIhC,OAAO,QAAQ,kCAAkC,CAAC;IAChD,UAAU,kBAAkB;QAC1B,iBAAiB,EAAE,SAAS,CAAA;KAC7B;CACF;AAkXD,wBAAgB,KAAK,CAAC,GAAG,EAAE,aAAa,GAAG,IAAI,CAgD9C"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,aAAa,EAAuC,MAAM,wCAAwC,CAAA;AAchH,+CAA+C;AAC/C,eAAO,MAAM,MAAM,UAMlB,CAAA;AAgBD,QAAA,MAAM,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmCE,CAAA;AAuCV,KAAK,SAAS,GAAG,MAAM,OAAO,EAAE,CAAA;AAIhC,OAAO,QAAQ,kCAAkC,CAAC;IAChD,UAAU,kBAAkB;QAC1B,iBAAiB,EAAE,SAAS,CAAA;KAC7B;CACF;AA8hBD,+EAA+E;AAC/E,wBAAgB,KAAK,CAAC,GAAG,EAAE,aAAa,GAAG,IAAI,CA6C9C"}
@@ -1,6 +1,8 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useEffect, useRef, useState, useSyncExternalStore } from 'react';
3
3
  import { IconLoadingOutline16, IconPauseOutline16, IconPlayOutline16, IconChevronDownOutline14, Tooltip, extractMarkdownPlainText, } from '@deepseek-ai/dsh-client-ui-primitives';
4
+ import { TTS_ROUTE, TTS_SETTINGS_NAMESPACE, TTS_VOICES, prepareTtsText, resolveTtsSettings, } from '../shared.js';
5
+ /** Client services required by this plugin. */
4
6
  export const inject = [
5
7
  'slots',
6
8
  'locale',
@@ -9,8 +11,6 @@ export const inject = [
9
11
  'settingsScope',
10
12
  ];
11
13
  const NS = 'xiaomi-mimo-tts';
12
- const SETTINGS_NAMESPACE = 'xiaomi-mimo-tts';
13
- const TTS_ROUTE = '/plugins/xiaomi-mimo-tts/synthesize';
14
14
  const zh = {
15
15
  'action.play': '朗读回复',
16
16
  'action.pause': '暂停朗读',
@@ -20,19 +20,27 @@ const zh = {
20
20
  'error.noText': '这条回复没有可朗读的正文。',
21
21
  'error.request': '语音生成失败。',
22
22
  'error.play': '浏览器阻止了自动播放,请点击朗读按钮。',
23
- 'settings.title': 'Xiaomi MiMo 语音朗读',
23
+ 'settings.title': '语音朗读 (Xiaomi MiMo)',
24
24
  'settings.description': '在助手回复操作栏中使用 Xiaomi MiMo TTS 生成并播放语音。',
25
+ 'settings.enabled': '显示朗读按钮',
26
+ 'settings.enabledHint': '关闭后不会在助手回复操作栏显示朗读按钮,也不会自动播报。',
25
27
  'settings.apiKey': 'API Key',
26
28
  'settings.apiKeyHint': '密钥保存在 DSH 设置文件中,传到浏览器前会被脱敏。',
27
29
  'settings.apiKeyStatus': '只有输入新值并保存时才会替换现有密钥。',
28
- 'settings.autoPlay': '自动播报新回复',
29
- 'settings.autoPlayHint': '浏览器可能因为自动播放策略而拒绝;拒绝后可手动点击朗读。',
30
+ 'settings.apiKeyConfigured': '已配置',
31
+ 'settings.getApiKey': '获取 API Key',
32
+ 'settings.autoPlay': '开启自动播报',
33
+ 'settings.autoPlayHint': '开启时会同步显示朗读按钮;浏览器也可能拒绝自动播放。',
30
34
  'settings.voice': '内置音色',
31
35
  'settings.format': '音频格式',
32
36
  'settings.instruction': '朗读风格指令',
33
37
  'settings.save': '保存',
34
38
  'settings.saving': '保存中…',
35
39
  'settings.saved': '已保存',
40
+ 'settings.unsaved': '未保存',
41
+ 'settings.overridden': '已覆盖',
42
+ 'settings.reset': '恢复默认',
43
+ 'settings.discard': '放弃修改',
36
44
  'settings.failed': '保存失败,请重试。',
37
45
  'settings.readOnly': '当前 DSH 设置为只读。',
38
46
  'settings.secretPlaceholder': '输入新的 Xiaomi MiMo API Key',
@@ -48,19 +56,27 @@ const en = {
48
56
  'error.noText': 'This response has no readable body text.',
49
57
  'error.request': 'Speech generation failed.',
50
58
  'error.play': 'The browser blocked autoplay. Click Read aloud to play it.',
51
- 'settings.title': 'Xiaomi MiMo text to speech',
59
+ 'settings.title': 'Text To Speech (Xiaomi MiMo)',
52
60
  'settings.description': 'Generate and play Xiaomi MiMo TTS audio from assistant message actions.',
61
+ 'settings.enabled': 'Show read-aloud button',
62
+ 'settings.enabledHint': 'When disabled, the read-aloud button and automatic speech are both turned off.',
53
63
  'settings.apiKey': 'API Key',
54
64
  'settings.apiKeyHint': 'Stored in DSH settings and redacted before settings are sent to the browser.',
55
65
  'settings.apiKeyStatus': 'An existing key changes only when you save a new value.',
56
- 'settings.autoPlay': 'Automatically read new responses',
57
- 'settings.autoPlayHint': 'The browser may reject autoplay; use the message action if it does.',
66
+ 'settings.apiKeyConfigured': 'Configured',
67
+ 'settings.getApiKey': 'Get API Key',
68
+ 'settings.autoPlay': 'Enable automatic read-aloud',
69
+ 'settings.autoPlayHint': 'Enabling it also shows the read-aloud button; the browser may reject autoplay.',
58
70
  'settings.voice': 'Built-in voice',
59
71
  'settings.format': 'Audio format',
60
72
  'settings.instruction': 'Reading style instruction',
61
73
  'settings.save': 'Save',
62
74
  'settings.saving': 'Saving…',
63
75
  'settings.saved': 'Saved',
76
+ 'settings.unsaved': 'Unsaved',
77
+ 'settings.overridden': 'Overridden',
78
+ 'settings.reset': 'Restore default',
79
+ 'settings.discard': 'Discard changes',
64
80
  'settings.failed': 'Save failed. Try again.',
65
81
  'settings.readOnly': 'DSH settings are read-only.',
66
82
  'settings.secretPlaceholder': 'Enter a new Xiaomi MiMo API key',
@@ -74,6 +90,8 @@ function decodeSettings(value) {
74
90
  if (!isRecord(value))
75
91
  return undefined;
76
92
  const decoded = {};
93
+ if (typeof value.enabled === 'boolean')
94
+ decoded.enabled = value.enabled;
77
95
  if (typeof value.apiKey === 'string')
78
96
  decoded.apiKey = value.apiKey;
79
97
  if (typeof value.baseURL === 'string')
@@ -100,21 +118,24 @@ function useSettingsSnapshot(scope) {
100
118
  function formatStartupError(error) {
101
119
  return error instanceof Error ? error.message : String(error);
102
120
  }
103
- function safeSlotInject(ctx, name, register) {
104
- try {
105
- ctx.slots.inject(name, () => {
106
- try {
107
- return register();
108
- }
109
- catch (error) {
110
- ctx.logger.error(`dsh-xiaomi-tts: ${name} contribution disabled: ${formatStartupError(error)}`);
111
- return () => { };
112
- }
113
- });
114
- }
115
- catch (error) {
116
- ctx.logger.error(`dsh-xiaomi-tts: ${name} injection disabled: ${formatStartupError(error)}`);
117
- }
121
+ function registerSlotContribution(ctx, name, register) {
122
+ ctx.effect(() => {
123
+ try {
124
+ ctx.slots.inject(name, () => {
125
+ try {
126
+ return register();
127
+ }
128
+ catch (error) {
129
+ ctx.logger.error(`dsh-xiaomi-tts: ${name} contribution disabled: ${formatStartupError(error)}`);
130
+ return () => { };
131
+ }
132
+ });
133
+ }
134
+ catch (error) {
135
+ ctx.logger.error(`dsh-xiaomi-tts: ${name} injection disabled: ${formatStartupError(error)}`);
136
+ }
137
+ return () => { };
138
+ }, `xiaomi-mimo-tts: ${name}`);
118
139
  }
119
140
  function messageText(snapshot, messageId) {
120
141
  for (const node of snapshot.nodes) {
@@ -124,7 +145,7 @@ function messageText(snapshot, messageId) {
124
145
  .filter((block) => block.kind === 'text')
125
146
  .map((block) => block.text)
126
147
  .join('\n\n');
127
- return extractMarkdownPlainText(markdown).trim();
148
+ return extractMarkdownPlainText(prepareTtsText(markdown)).trim();
128
149
  }
129
150
  return '';
130
151
  }
@@ -192,7 +213,9 @@ class PlaybackController {
192
213
  else if (typeof body.error === 'string')
193
214
  message = body.error;
194
215
  }
195
- catch { }
216
+ catch {
217
+ // Non-JSON error bodies leave the HTTP status as the fallback message.
218
+ }
196
219
  throw new Error(message);
197
220
  }
198
221
  const blob = await response.blob();
@@ -260,7 +283,7 @@ function ReadAloudAction({ messageId, useSession, playback, settings, t }) {
260
283
  const view = useSyncExternalStore(playback.subscribe, playback.getSnapshot, playback.getSnapshot);
261
284
  const autoPlayed = useRef(false);
262
285
  useEffect(() => {
263
- if (autoPlayed.current || settingsSnapshot.value?.autoPlay !== true || message.time === null || message.time < playback.autoPlayArmedAt)
286
+ if (autoPlayed.current || text.length === 0 || settingsSnapshot.value?.enabled !== true || settingsSnapshot.value?.autoPlay !== true || message.time === null || message.time < playback.autoPlayArmedAt)
264
287
  return;
265
288
  autoPlayed.current = true;
266
289
  const cancel = window.setTimeout(() => {
@@ -268,7 +291,9 @@ function ReadAloudAction({ messageId, useSession, playback, settings, t }) {
268
291
  void playback.toggle(messageId, text, true);
269
292
  }, 0);
270
293
  return () => window.clearTimeout(cancel);
271
- }, [message.time, messageId, playback, settingsSnapshot.value?.autoPlay, text]);
294
+ }, [message.time, messageId, playback, settingsSnapshot.value?.autoPlay, settingsSnapshot.value?.enabled, text]);
295
+ if (settingsSnapshot.value?.enabled !== true || text.length === 0)
296
+ return null;
272
297
  const mine = view.messageId === messageId;
273
298
  const status = mine ? view.status : 'idle';
274
299
  const label = status === 'loading'
@@ -294,50 +319,158 @@ function ReadAloudAction({ messageId, useSession, playback, settings, t }) {
294
319
  ? _jsx(IconPauseOutline16, {})
295
320
  : _jsx(IconPlayOutline16, {}) }) }), errorText === null ? null : _jsx("span", { className: "xmimo-tts-inline-error", role: "status", children: errorText })] }));
296
321
  }
322
+ const EDITABLE_SETTING_FIELDS = ['enabled', 'autoPlay', 'voice', 'format', 'instruction'];
323
+ function layerSettings(value) {
324
+ return isRecord(value) ? value : undefined;
325
+ }
326
+ function hasLayerField(value, field) {
327
+ return isRecord(value) && Object.hasOwn(value, field);
328
+ }
329
+ function SettingFieldHeading({ label, suffix, overriddenLabel, resetLabel, overridden, resettable, disabled, onReset }) {
330
+ return (_jsxs("span", { className: "xmimo-tts-field-heading", children: [_jsxs("span", { className: "xmimo-tts-field-label", children: [_jsx("span", { children: label }), suffix] }), overridden ? _jsxs("span", { className: "xmimo-tts-field-badges", children: [_jsx("small", { className: "xmimo-tts-overridden", children: overriddenLabel }), resettable && onReset !== undefined && resetLabel !== undefined ? _jsx("button", { type: "button", className: "xmimo-tts-reset", disabled: disabled, onClick: (event) => { event.preventDefault(); event.stopPropagation(); onReset(); }, children: resetLabel }) : null] }) : null] }));
331
+ }
297
332
  function SettingsCard({ scope, t }) {
298
333
  const snapshot = useSettingsSnapshot(scope);
299
334
  const value = snapshot.value;
335
+ const initial = resolveTtsSettings(value);
300
336
  const [apiKey, setApiKey] = useState('');
301
- const [autoPlay, setAutoPlay] = useState(value?.autoPlay ?? false);
302
- const [voice, setVoice] = useState(value?.voice ?? '冰糖');
303
- const [format, setFormat] = useState(value?.format ?? 'mp3');
304
- const [instruction, setInstruction] = useState(value?.instruction ?? '');
337
+ const [enabled, setEnabled] = useState(initial.enabled);
338
+ const [autoPlay, setAutoPlay] = useState(initial.autoPlay);
339
+ const [voice, setVoice] = useState(initial.voice);
340
+ const [format, setFormat] = useState(initial.format);
341
+ const [instruction, setInstruction] = useState(initial.instruction);
342
+ const [changes, setChanges] = useState({});
305
343
  const [state, setState] = useState('idle');
306
344
  const [open, setOpen] = useState(false);
345
+ const accepted = resolveTtsSettings(value);
346
+ const base = resolveTtsSettings(layerSettings(snapshot.base));
347
+ const draft = { enabled, autoPlay: enabled && autoPlay, voice, format, instruction };
348
+ const acceptedValue = (field) => {
349
+ const raw = value?.[field];
350
+ return (raw === undefined ? accepted[field] : raw);
351
+ };
352
+ const hasOverride = (field) => hasLayerField(snapshot.user, field);
353
+ const fieldOverridden = (field) => {
354
+ const change = changes[field];
355
+ if (change?.kind === 'clear')
356
+ return false;
357
+ if (change?.kind === 'set')
358
+ return field === 'apiKey' ? apiKey.trim().length > 0 : true;
359
+ return hasOverride(field);
360
+ };
361
+ const fieldDirty = (field) => {
362
+ const change = changes[field];
363
+ if (change === undefined)
364
+ return false;
365
+ if (change.kind === 'clear')
366
+ return hasOverride(field);
367
+ return !Object.is(draft[field], acceptedValue(field));
368
+ };
369
+ const apiKeyDirty = changes.apiKey?.kind === 'clear'
370
+ ? hasOverride('apiKey')
371
+ : changes.apiKey?.kind === 'set' && apiKey.trim().length > 0;
372
+ const dirty = EDITABLE_SETTING_FIELDS.some(fieldDirty) || apiKeyDirty === true;
307
373
  useEffect(() => {
308
- if (value === undefined)
374
+ if (dirty)
309
375
  return;
310
- setAutoPlay(value.autoPlay ?? false);
311
- setVoice(value.voice ?? '冰糖');
312
- setFormat(value.format ?? 'mp3');
313
- setInstruction(value.instruction ?? '');
314
- }, [value]);
376
+ const next = resolveTtsSettings(value);
377
+ setEnabled(next.enabled);
378
+ setAutoPlay(next.autoPlay);
379
+ setVoice(next.voice);
380
+ setFormat(next.format);
381
+ setInstruction(next.instruction);
382
+ setChanges({});
383
+ }, [dirty, value]);
315
384
  if (snapshot.status === 'unavailable')
316
385
  return null;
386
+ const markChange = (field, kind = 'set') => {
387
+ setChanges((current) => ({ ...current, [field]: { kind } }));
388
+ setState('idle');
389
+ };
390
+ const resetField = (field) => {
391
+ markChange(field, 'clear');
392
+ if (field === 'enabled')
393
+ setEnabled(base.enabled);
394
+ if (field === 'autoPlay')
395
+ setAutoPlay(base.autoPlay);
396
+ if (field === 'voice')
397
+ setVoice(base.voice);
398
+ if (field === 'format')
399
+ setFormat(base.format);
400
+ if (field === 'instruction')
401
+ setInstruction(base.instruction);
402
+ };
403
+ const discard = () => {
404
+ const next = resolveTtsSettings(scope.getSnapshot().value);
405
+ setEnabled(next.enabled);
406
+ setAutoPlay(next.autoPlay);
407
+ setVoice(next.voice);
408
+ setFormat(next.format);
409
+ setInstruction(next.instruction);
410
+ setApiKey('');
411
+ setChanges({});
412
+ setState('idle');
413
+ };
317
414
  const save = async () => {
318
415
  setState('saving');
319
416
  try {
320
- await scope.set('autoPlay', autoPlay);
321
- await scope.set('voice', voice);
322
- await scope.set('format', format);
323
- await scope.set('instruction', instruction);
324
- if (apiKey.trim().length > 0)
417
+ for (const field of EDITABLE_SETTING_FIELDS) {
418
+ const change = changes[field];
419
+ if (change === undefined)
420
+ continue;
421
+ if (change.kind === 'clear') {
422
+ if (hasOverride(field))
423
+ await scope.unset(field);
424
+ }
425
+ else if (!Object.is(draft[field], acceptedValue(field))) {
426
+ await scope.set(field, draft[field]);
427
+ }
428
+ }
429
+ const apiKeyChange = changes.apiKey;
430
+ if (apiKeyChange?.kind === 'clear') {
431
+ if (hasOverride('apiKey'))
432
+ await scope.unset('apiKey');
433
+ }
434
+ else if (apiKeyChange?.kind === 'set' && apiKey.trim().length > 0) {
325
435
  await scope.set('apiKey', apiKey.trim());
436
+ }
326
437
  setApiKey('');
438
+ setChanges({});
327
439
  setState('saved');
328
440
  }
329
441
  catch {
330
442
  setState('failed');
331
443
  }
332
444
  };
333
- return (_jsxs("li", { className: open ? 'xmimo-tts-card xmimo-tts-card-open' : 'xmimo-tts-card', children: [_jsxs("button", { type: "button", className: "xmimo-tts-card-header", "aria-expanded": open, "aria-label": `${t(open ? 'settings.collapse' : 'settings.expand')}: ${t('settings.title')}`, onClick: () => { setOpen((current) => !current); }, children: [_jsxs("span", { className: "xmimo-tts-card-head-text", children: [_jsx("span", { className: "xmimo-tts-card-title", children: t('settings.title') }), _jsx("span", { className: "xmimo-tts-card-description", children: t('settings.description') })] }), _jsx(IconChevronDownOutline14, { className: open ? 'xmimo-tts-chevron xmimo-tts-chevron-open' : 'xmimo-tts-chevron' })] }), open ? _jsxs("div", { className: "xmimo-tts-card-body", children: [_jsxs("div", { className: "xmimo-tts-grid", children: [_jsxs("label", { children: [_jsx("span", { children: t('settings.apiKey') }), _jsx("input", { type: "password", value: apiKey, autoComplete: "off", placeholder: t('settings.secretPlaceholder'), disabled: !snapshot.writable, onChange: (event) => { setApiKey(event.target.value); setState('idle'); } }), _jsx("small", { children: t('settings.apiKeyStatus') }), _jsx("small", { children: t('settings.apiKeyHint') })] }), _jsxs("label", { className: "xmimo-tts-checkbox-row", children: [_jsx("input", { type: "checkbox", checked: autoPlay, disabled: !snapshot.writable, onChange: (event) => { setAutoPlay(event.target.checked); setState('idle'); } }), _jsxs("span", { children: [_jsx("strong", { children: t('settings.autoPlay') }), _jsx("small", { children: t('settings.autoPlayHint') })] })] }), _jsxs("label", { children: [_jsx("span", { children: t('settings.voice') }), _jsx("select", { value: voice, disabled: !snapshot.writable, onChange: (event) => { setVoice(event.target.value); setState('idle'); }, children: ['冰糖', '茉莉', '苏打', '白桦', 'Mia', 'Chloe', 'Milo', 'Dean'].map((item) => _jsx("option", { value: item, children: item }, item)) })] }), _jsxs("label", { children: [_jsx("span", { children: t('settings.format') }), _jsxs("select", { value: format, disabled: !snapshot.writable, onChange: (event) => { setFormat(event.target.value); setState('idle'); }, children: [_jsx("option", { value: "mp3", children: "MP3" }), _jsx("option", { value: "wav", children: "WAV" })] })] }), _jsxs("label", { className: "xmimo-tts-wide", children: [_jsx("span", { children: t('settings.instruction') }), _jsx("textarea", { value: instruction, rows: 3, disabled: !snapshot.writable, onChange: (event) => { setInstruction(event.target.value); setState('idle'); } })] })] }), _jsxs("div", { className: "xmimo-tts-card-actions", children: [!snapshot.writable ? _jsx("span", { children: t('settings.readOnly') }) : null, state === 'saved' ? _jsx("span", { children: t('settings.saved') }) : null, state === 'failed' ? _jsx("span", { className: "xmimo-tts-failed", children: t('settings.failed') }) : null, _jsx("button", { type: "button", disabled: !snapshot.writable || state === 'saving', onClick: () => { void save(); }, children: state === 'saving' ? t('settings.saving') : t('settings.save') })] })] }) : null] }));
445
+ return (_jsxs("li", { className: open ? 'xmimo-tts-card xmimo-tts-card-open' : 'xmimo-tts-card', children: [_jsxs("button", { type: "button", className: "xmimo-tts-card-header", "aria-expanded": open, "aria-label": `${t(open ? 'settings.collapse' : 'settings.expand')}: ${t('settings.title')}`, onClick: () => { setOpen((current) => !current); }, children: [_jsxs("span", { className: "xmimo-tts-card-head-text", children: [_jsx("span", { className: "xmimo-tts-card-title", children: t('settings.title') }), _jsx("span", { className: "xmimo-tts-card-description", children: t('settings.description') })] }), dirty ? _jsx("span", { className: "xmimo-tts-pending", role: "status", children: t('settings.unsaved') }) : null, _jsx(IconChevronDownOutline14, { className: open ? 'xmimo-tts-chevron xmimo-tts-chevron-open' : 'xmimo-tts-chevron' })] }), open ? _jsxs("div", { className: "xmimo-tts-card-body", children: [_jsxs("div", { className: "xmimo-tts-grid", children: [_jsxs("div", { className: "xmimo-tts-api-key xmimo-tts-wide", children: [_jsx(SettingFieldHeading, { label: t('settings.apiKey'), suffix: _jsx("a", { className: "xmimo-tts-api-key-link", href: "https://platform.xiaomimimo.com/console/api-keys", target: "_blank", rel: "noopener noreferrer", children: t('settings.getApiKey') }), overriddenLabel: t('settings.apiKeyConfigured'), overridden: fieldOverridden('apiKey'), resettable: false, disabled: !snapshot.writable }), _jsx("input", { type: "password", value: apiKey, name: "xmimo-tts-api-key", autoComplete: "new-password", autoCorrect: "off", spellCheck: false, "aria-autocomplete": "none", "data-1p-ignore": "true", "data-bwignore": "true", "data-lpignore": "true", placeholder: t('settings.secretPlaceholder'), disabled: !snapshot.writable, onChange: (event) => { setApiKey(event.target.value); markChange('apiKey'); } }), _jsxs("span", { className: "xmimo-tts-api-key-hints", children: [_jsx("small", { children: t('settings.apiKeyStatus') }), _jsx("small", { children: t('settings.apiKeyHint') })] })] }), _jsxs("div", { className: "xmimo-tts-switch-row xmimo-tts-wide", children: [_jsxs("label", { className: "xmimo-tts-checkbox-row", children: [_jsx("input", { type: "checkbox", checked: enabled, disabled: !snapshot.writable, onChange: (event) => {
446
+ const next = event.target.checked;
447
+ setEnabled(next);
448
+ if (!next) {
449
+ setAutoPlay(false);
450
+ setChanges((current) => ({ ...current, enabled: { kind: 'set' }, autoPlay: { kind: 'set' } }));
451
+ }
452
+ else
453
+ markChange('enabled');
454
+ setState('idle');
455
+ } }), _jsxs("span", { children: [_jsx(SettingFieldHeading, { label: t('settings.enabled'), overriddenLabel: t('settings.overridden'), resetLabel: t('settings.reset'), overridden: false, resettable: false, disabled: !snapshot.writable, onReset: () => { resetField('enabled'); } }), _jsx("small", { children: t('settings.enabledHint') })] })] }), _jsxs("label", { className: "xmimo-tts-checkbox-row", children: [_jsx("input", { type: "checkbox", checked: enabled && autoPlay, disabled: !snapshot.writable, onChange: (event) => {
456
+ const next = event.target.checked;
457
+ setAutoPlay(next);
458
+ if (next) {
459
+ setEnabled(true);
460
+ setChanges((current) => ({ ...current, autoPlay: { kind: 'set' }, enabled: { kind: 'set' } }));
461
+ }
462
+ else
463
+ markChange('autoPlay');
464
+ setState('idle');
465
+ } }), _jsxs("span", { children: [_jsx(SettingFieldHeading, { label: t('settings.autoPlay'), overriddenLabel: t('settings.overridden'), resetLabel: t('settings.reset'), overridden: false, resettable: false, disabled: !snapshot.writable, onReset: () => { resetField('autoPlay'); } }), _jsx("small", { children: t('settings.autoPlayHint') })] })] })] }), _jsxs("div", { className: "xmimo-tts-instruction", children: [_jsx(SettingFieldHeading, { label: t('settings.instruction'), overriddenLabel: t('settings.overridden'), resetLabel: t('settings.reset'), overridden: fieldOverridden('instruction'), resettable: true, disabled: !snapshot.writable, onReset: () => { resetField('instruction'); } }), _jsx("textarea", { value: instruction, rows: 6, disabled: !snapshot.writable, onChange: (event) => { setInstruction(event.target.value); markChange('instruction'); } })] }), _jsxs("div", { className: "xmimo-tts-select-column", children: [_jsxs("div", { children: [_jsx(SettingFieldHeading, { label: t('settings.voice'), overriddenLabel: t('settings.overridden'), resetLabel: t('settings.reset'), overridden: false, resettable: false, disabled: !snapshot.writable, onReset: () => { resetField('voice'); } }), _jsx("select", { value: voice, disabled: !snapshot.writable, onChange: (event) => { setVoice(event.target.value); markChange('voice'); }, children: TTS_VOICES.map((item) => _jsx("option", { value: item, children: item }, item)) })] }), _jsxs("div", { children: [_jsx(SettingFieldHeading, { label: t('settings.format'), overriddenLabel: t('settings.overridden'), resetLabel: t('settings.reset'), overridden: false, resettable: false, disabled: !snapshot.writable, onReset: () => { resetField('format'); } }), _jsxs("select", { value: format, disabled: !snapshot.writable, onChange: (event) => { setFormat(event.target.value); markChange('format'); }, children: [_jsx("option", { value: "mp3", children: "MP3" }), _jsx("option", { value: "wav", children: "WAV" })] })] })] })] }), _jsxs("div", { className: "xmimo-tts-card-actions", children: [!snapshot.writable ? _jsx("span", { children: t('settings.readOnly') }) : null, state === 'saved' && !dirty ? _jsx("span", { role: "status", children: t('settings.saved') }) : null, state === 'failed' ? _jsx("span", { className: "xmimo-tts-failed", role: "status", children: t('settings.failed') }) : null, _jsx("button", { type: "button", className: "xmimo-tts-discard", disabled: !snapshot.writable || !dirty || state === 'saving', onClick: discard, children: t('settings.discard') }), _jsx("button", { type: "button", disabled: !snapshot.writable || !dirty || state === 'saving', onClick: () => { void save(); }, children: state === 'saving' ? t('settings.saving') : t('settings.save') })] })] }) : null] }));
334
466
  }
467
+ /** Register the Web action, settings card, locale dictionaries, and styles. */
335
468
  export function apply(ctx) {
336
469
  const locale = ctx.locale;
337
470
  const t = locale.bind(NS);
338
471
  ctx.effect(() => locale.register(NS, { zh, en }), 'xiaomi-mimo-tts: dictionaries');
339
472
  const scope = ctx.settingsScope.bind({
340
- namespace: SETTINGS_NAMESPACE,
473
+ namespace: TTS_SETTINGS_NAMESPACE,
341
474
  decode: decodeSettings,
342
475
  });
343
476
  const playback = new PlaybackController();
@@ -346,29 +479,26 @@ export function apply(ctx) {
346
479
  const style = document.createElement('style');
347
480
  style.dataset.plugin = NS;
348
481
  style.textContent = `
349
- .xmimo-tts-action{display:inline-flex;flex:0 0 28px;align-items:center;justify-content:center;width:28px;height:28px;box-sizing:border-box;padding:0;border:0;border-radius:6px;color:var(--dsw-alias-label-tertiary);background:transparent;cursor:pointer}
350
- .xmimo-tts-action:hover,.xmimo-tts-action[aria-pressed=true]{color:var(--dsw-alias-label-primary);background:var(--dsw-alias-fill-l2)}
351
- .xmimo-tts-action:disabled{cursor:wait;opacity:.65}.xmimo-tts-spin{animation:xmimo-spin 1s linear infinite}@keyframes xmimo-spin{to{transform:rotate(360deg)}}
352
- .xmimo-tts-inline-error{max-width:220px;color:var(--dsw-alias-state-danger-primary);font-size:12px}
353
- .xmimo-tts-card{list-style:none;border:1px solid var(--dsw-alias-border-l2);border-radius:12px;color:var(--dsw-alias-label-primary);background:var(--dsw-alias-bg-l1);overflow:hidden}.xmimo-tts-card-header{display:flex;width:100%;align-items:center;justify-content:space-between;gap:12px;padding:14px 16px;border:0;color:inherit;text-align:left;background:transparent;font:inherit;cursor:pointer}.xmimo-tts-card-header:hover{background:var(--dsw-alias-interactive-bg-hover)}.xmimo-tts-card-head-text{display:flex;min-width:0;flex-direction:column;gap:4px}.xmimo-tts-card-title{font-size:15px;font-weight:600}.xmimo-tts-card-description{color:var(--dsw-alias-label-tertiary);font-size:13px;line-height:18px}.xmimo-tts-chevron{flex:none;color:var(--dsw-alias-label-tertiary);transition:transform 160ms ease}.xmimo-tts-chevron-open{transform:rotate(180deg)}.xmimo-tts-card-body{padding:0 16px 16px}
354
- .xmimo-tts-grid{display:grid;grid-template-columns:1fr 1fr;gap:14px;margin-top:16px}.xmimo-tts-grid label{display:flex;min-width:0;flex-direction:column;gap:6px;font-size:13px}.xmimo-tts-grid input,.xmimo-tts-grid select,.xmimo-tts-grid textarea{box-sizing:border-box;width:100%;border:1px solid var(--dsw-alias-border-l2);border-radius:8px;padding:8px 10px;color:var(--dsw-alias-label-primary);background:var(--dsw-alias-bg-l2);font:inherit}.xmimo-tts-grid small{color:var(--dsw-alias-label-tertiary)}
355
- .xmimo-tts-wide{grid-column:1/-1}.xmimo-tts-checkbox-row{flex-direction:row!important;align-items:flex-start!important}.xmimo-tts-checkbox-row input{width:auto!important;margin-top:3px}.xmimo-tts-checkbox-row span{display:flex;flex-direction:column;gap:4px}
356
- .xmimo-tts-card-actions{display:flex;align-items:center;justify-content:flex-end;gap:10px;margin-top:16px;font-size:12px;color:var(--dsw-alias-label-tertiary)}.xmimo-tts-card-actions button{border:0;border-radius:8px;padding:8px 14px;color:var(--dsw-alias-label-on-color);background:var(--dsw-alias-state-business-primary);cursor:pointer}.xmimo-tts-card-actions button:disabled{cursor:not-allowed;opacity:.55}.xmimo-tts-failed{color:var(--dsw-alias-state-danger-primary)}
357
- @media(max-width:720px){.xmimo-tts-grid{grid-template-columns:1fr}.xmimo-tts-wide{grid-column:auto}}
482
+ .xmimo-tts-action{width:28px;height:28px;color:var(--dsw-alias-label-tertiary);cursor:pointer;background:transparent;border:none;border-radius:28px;justify-content:center;align-items:center;padding:6px;display:inline-flex}.xmimo-tts-action:hover{background:var(--dsw-alias-interactive-bg-hover,#f3f4f6);color:var(--dsw-alias-label-secondary,#5f6875)}.xmimo-tts-action[aria-pressed=true]{background:var(--dsw-alias-interactive-bg-hover,#f3f4f6);color:var(--dsw-alias-label-secondary,#5f6875)}.xmimo-tts-action:disabled{cursor:default;opacity:.45}.xmimo-tts-spin{animation:xmimo-spin 1s linear infinite}@keyframes xmimo-spin{to{transform:rotate(360deg)}}
483
+ .xmimo-tts-inline-error{max-width:220px;color:var(--dsw-alias-state-error-primary,#dc2626);font-size:12px}
484
+ .xmimo-tts-card{list-style:none;border:1px solid var(--dsw-alias-border-l2,#e5e7eb);border-radius:12px;color:var(--dsw-alias-label-primary,#1f2328);background:var(--dsw-alias-bg-layer-3,#fff);overflow:hidden;transition:border-color 160ms ease,background 160ms ease}.xmimo-tts-card:hover{border-color:var(--dsw-alias-label-dimmed,#c8ccd4)}.xmimo-tts-card-open{background:var(--dsw-alias-bg-layer-2,#f7f8fa);border-color:var(--dsw-alias-label-dimmed,#c8ccd4)}.xmimo-tts-card-header{appearance:none;display:flex;width:100%;align-items:center;justify-content:space-between;gap:12px;padding:14px 16px;border:0;border-radius:12px;color:inherit;text-align:left;background:transparent;font:inherit;cursor:pointer}.xmimo-tts-card-header:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#4f6ef7);outline-offset:-2px}.xmimo-tts-card-head-text{display:flex;min-width:0;flex:1;flex-direction:column;gap:4px}.xmimo-tts-card-title{font-size:15px;font-weight:600}.xmimo-tts-card-description{color:var(--dsw-alias-label-tertiary,#8b93a1);font-size:13px;line-height:18px}.xmimo-tts-chevron{flex:none;color:var(--dsw-alias-label-tertiary,#8b93a1);transition:transform 160ms ease}.xmimo-tts-chevron-open{transform:rotate(180deg)}.xmimo-tts-pending{flex:none;border-radius:999px;padding:1px 8px;color:var(--dsw-alias-label-secondary,#5f6875);background:var(--dsw-alias-bg-module-platform,#eef0f3);font-size:11px;font-weight:500;line-height:17px}.xmimo-tts-card-body{border-top:1px solid var(--dsw-alias-border-l2,#e5e7eb);margin:0 16px;padding:0 0 16px}
485
+ .xmimo-tts-grid{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:16px 14px;margin-top:16px;align-items:start}.xmimo-tts-grid label,.xmimo-tts-api-key,.xmimo-tts-instruction,.xmimo-tts-select-column>div{display:flex;min-width:0;flex-direction:column;gap:6px;font-size:13px}.xmimo-tts-grid input,.xmimo-tts-grid select,.xmimo-tts-grid textarea{box-sizing:border-box;width:100%;border:1px solid var(--dsw-alias-border-l2,#e5e7eb);border-radius:8px;padding:8px 10px;color:var(--dsw-alias-label-primary,#1f2328);background:var(--dsw-alias-bg-layer-2,#f3f4f6);font:inherit}.xmimo-tts-grid select{color-scheme:light dark}.xmimo-tts-grid select option{color:var(--dsw-alias-label-primary,#1f2328);background:var(--dsw-alias-bg-layer-1,#fff)}.xmimo-tts-grid select:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#4f6ef7);outline-offset:1px}.xmimo-tts-grid small{color:var(--dsw-alias-label-tertiary,#8b93a1);line-height:17px}.xmimo-tts-field-heading{display:flex;min-width:0;min-height:20px;flex-direction:row!important;align-items:center;justify-content:space-between;gap:8px}.xmimo-tts-field-label{display:inline-flex;min-width:0;align-items:center;gap:8px}.xmimo-tts-api-key-link{color:var(--dsw-alias-brand-primary,#4f6ef7);font-size:12px;text-decoration:none}.xmimo-tts-api-key-link:hover{text-decoration:underline}.xmimo-tts-field-badges{display:flex!important;flex:none;flex-direction:row!important;align-items:center;gap:8px}.xmimo-tts-overridden{border-radius:999px;padding:1px 7px;color:var(--dsw-alias-label-secondary,#5f6875);background:var(--dsw-alias-bg-module-platform,#eef0f3);font-size:11px;line-height:17px}.xmimo-tts-reset{padding:0;border:0;color:var(--dsw-alias-label-secondary,#5f6875);background:transparent;font:inherit;font-size:12px;cursor:pointer}.xmimo-tts-reset:hover:not(:disabled){color:var(--dsw-alias-label-primary,#1f2328)}.xmimo-tts-reset:disabled{cursor:not-allowed;opacity:.45}.xmimo-tts-api-key-hints{display:flex;min-width:0;gap:8px;align-items:center}.xmimo-tts-api-key-hints small{min-width:0;white-space:nowrap}.xmimo-tts-wide{grid-column:1/-1}.xmimo-tts-switch-row{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:14px}.xmimo-tts-checkbox-row{flex-direction:row!important;align-items:flex-start!important}.xmimo-tts-checkbox-row input{width:auto!important;flex:none;margin-top:3px}.xmimo-tts-checkbox-row span{display:flex;min-width:0;flex-direction:column;gap:4px}.xmimo-tts-select-column{display:flex;min-width:0;flex-direction:column;gap:16px}
486
+ .xmimo-tts-card-actions{display:flex;align-items:center;justify-content:flex-end;gap:10px;margin-top:16px;padding-top:12px;border-top:1px solid var(--dsw-alias-border-l2,#e5e7eb);font-size:12px;color:var(--dsw-alias-label-tertiary,#8b93a1)}.xmimo-tts-card-actions button{border:1px solid var(--dsw-alias-brand-primary,#4f6ef7);border-radius:8px;padding:5px 14px;color:var(--dsw-alias-bg-layer-1,#fff);background:var(--dsw-alias-brand-primary,#4f6ef7);cursor:pointer;font:inherit}.xmimo-tts-card-actions button:hover:not(:disabled){filter:brightness(1.08)}.xmimo-tts-card-actions button:disabled{cursor:not-allowed;color:var(--dsw-alias-label-dimmed,#9ca3af);background:var(--dsw-alias-bg-layer-2,#f3f4f6);border-color:var(--dsw-alias-border-l2,#e5e7eb);opacity:1}.xmimo-tts-card-actions .xmimo-tts-discard{border-color:var(--dsw-alias-border-l2,#e5e7eb);color:var(--dsw-alias-label-secondary,#5f6875);background:transparent}.xmimo-tts-card-actions .xmimo-tts-discard:hover:not(:disabled){color:var(--dsw-alias-label-primary,#1f2328);border-color:var(--dsw-alias-label-dimmed,#c8ccd4)}.xmimo-tts-failed{color:var(--dsw-alias-state-error-primary,#dc2626)}
487
+ @media(max-width:720px){.xmimo-tts-grid{grid-template-columns:1fr}.xmimo-tts-wide{grid-column:auto}.xmimo-tts-switch-row{grid-template-columns:1fr}.xmimo-tts-instruction,.xmimo-tts-select-column{grid-column:auto}.xmimo-tts-api-key-hints{flex-wrap:wrap}.xmimo-tts-api-key-hints small{white-space:normal}}
358
488
  `;
359
489
  document.head.appendChild(style);
360
490
  return () => style.remove();
361
491
  }, 'xiaomi-mimo-tts: styles');
362
- safeSlotInject(ctx, 'conversation.chat.assistant-actions', () => ctx.slots.register({
492
+ registerSlotContribution(ctx, 'conversation.chat.assistant-actions', () => ctx.slots.register({
363
493
  name: 'conversation.chat.assistant-actions',
364
494
  id: 'xiaomi-mimo-tts',
365
495
  order: 20,
366
496
  locale: NS,
367
497
  inject: () => ({ playback, settings: scope, t }),
368
498
  }, ReadAloudAction));
369
- safeSlotInject(ctx, 'settings.plugin.item', () => ctx.slots.register({
499
+ registerSlotContribution(ctx, 'settings.plugin.item', () => ctx.slots.register({
370
500
  name: 'settings.plugin.item',
371
- key: SETTINGS_NAMESPACE,
501
+ key: TTS_SETTINGS_NAMESPACE,
372
502
  locale: NS,
373
503
  inject: () => ({ scope, t }),
374
504
  }, SettingsCard));