@sonicloud/dsh-sonicloud-device 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/CHANGELOG.zh.md +28 -0
  3. package/README.md +24 -1
  4. package/README.zh.md +24 -1
  5. package/dist/build.json +1 -1
  6. package/dist/client.js +101 -2
  7. package/docs/contributing/development.md +31 -3
  8. package/docs/specs/smart-mouse-plugin.md +31 -1
  9. package/native/README.md +4 -0
  10. package/native/desktop/VOICE_SOURCE.json +16 -0
  11. package/native/desktop/VoicePanel.swift +27 -0
  12. package/native/desktop/darwin-arm64/Sonicloud Voice.app/Contents/MacOS/sonicloud-voice +0 -0
  13. package/native/desktop/darwin-arm64/Sonicloud Voice.app/Contents/_CodeSignature/CodeResources +115 -0
  14. package/native/screenshot/README.md +34 -0
  15. package/native/screenshot/SOURCE.json +218 -0
  16. package/native/screenshot/darwin-arm64/screentool-macos-1.2.2.zip +0 -0
  17. package/native/screenshot/patches/hide-cloud-actions.patch +202 -0
  18. package/native/screenshot/patches/mac-permissions.patch +545 -0
  19. package/native/screenshot/patches/upstream-files.json +22 -0
  20. package/native/screenshot/win32-x64/PixPinScrollCapture.dll +0 -0
  21. package/native/screenshot/win32-x64/Qt5Core.dll +0 -0
  22. package/native/screenshot/win32-x64/Qt5Gui.dll +0 -0
  23. package/native/screenshot/win32-x64/Qt5Network.dll +0 -0
  24. package/native/screenshot/win32-x64/Qt5Svg.dll +0 -0
  25. package/native/screenshot/win32-x64/Qt5Widgets.dll +0 -0
  26. package/native/screenshot/win32-x64/iconengines/qsvgicon.dll +0 -0
  27. package/native/screenshot/win32-x64/imageformats/qjpeg.dll +0 -0
  28. package/native/screenshot/win32-x64/imageformats/qsvg.dll +0 -0
  29. package/native/screenshot/win32-x64/libcrypto-1_1-x64.dll +0 -0
  30. package/native/screenshot/win32-x64/libssl-1_1-x64.dll +0 -0
  31. package/native/screenshot/win32-x64/msvcp140.dll +0 -0
  32. package/native/screenshot/win32-x64/platforms/qwindows.dll +0 -0
  33. package/native/screenshot/win32-x64/qwindowsvistastyle.dll +0 -0
  34. package/native/screenshot/win32-x64/screenhelper.exe +0 -0
  35. package/native/screenshot/win32-x64/screentool.dll +0 -0
  36. package/native/screenshot/win32-x64/vcruntime140.dll +0 -0
  37. package/native/screenshot/win32-x64/vcruntime140_1.dll +0 -0
  38. package/package.json +1 -1
  39. package/src/desktop/presentation.mjs +18 -4
  40. package/src/desktop/screenshot-worker.mjs +225 -0
  41. package/src/desktop/screenshot.mjs +185 -0
  42. package/src/devices/manager.mjs +37 -3
  43. package/src/host/index.mjs +5 -1
  44. package/src/shared/remote.mjs +5 -0
package/CHANGELOG.md CHANGED
@@ -4,6 +4,25 @@
4
4
 
5
5
  ### Added
6
6
 
7
+ - Check macOS typing and screenshot permissions on initial activation and reconnection, with separate Sonicloud Voice and screenhelper authorization and recheck guidance in Sonicloud Devices; system permission confirmation remains manual.
8
+ - Integrate standalone screenshot processes for Windows x64 and macOS ARM64, triggered by the mouse capture button or Start Screenshot in Sonicloud Devices, with region selection, annotation, copying, saving, pinning, and scrolling capture; report repeated triggers and startup failures, and close capture and pinned windows when the plugin is disabled.
9
+
10
+ ### Changed
11
+
12
+ - Sign macOS Sonicloud Voice with a Developer ID; existing Accessibility grants from older versions may need to be confirmed again as prompted by the system.
13
+ - Move the screenshot controls to the bottom of the Sonicloud Devices page.
14
+
15
+ ### Fixed
16
+
17
+ - Check macOS Screen Recording permission in both the host and native screenshot process before showing the overlay, preventing it from covering system permission prompts; missing Accessibility permission does not block regular screenshots or manual scrolling.
18
+ - Restore macOS voice helper execution permissions lost during cross-platform packaging so packages built on Windows can start Sonicloud Voice.
19
+ - Hide unsupported image translation and scrolling OCR/Word export actions in both Windows and macOS screenshot processes while keeping scrolling capture available; retain the original Developer ID identity for the macOS package.
20
+ - Parse Windows tar line endings correctly during package checks so complete packages are not reported as missing files.
21
+
22
+ ## 0.1.2 - 2026-11-12
23
+
24
+ ### Added
25
+
7
26
  - Add a Sonicloud Devices panel to the left navigation bar with the same device management UI as the settings page; shown by default, with a settings-page switch to hide or restore it without affecting the settings page.
8
27
  - Switch Windows voice typing and translation to the typer injection library: text is typed live into the focused window character by character while speaking, with automatic backspace corrections, and finalized on release; translation types only the final translated text. Character injection never reads from or writes to the clipboard; password fields, a missing library, or rejected injection (for example, elevated windows) keep the result available to copy.
9
28
  - Restore the Harness window for the AI button on Windows: activation now restores minimized windows directly, and for tray-hidden windows launches a second instance of the running app (stripping node-mode Electron environment overrides) handled by its single-instance handler; an activation failure alone no longer blocks filling the conversation draft.
@@ -11,6 +30,8 @@
11
30
 
12
31
  ### Changed
13
32
 
33
+ - Sign macOS Sonicloud Voice with a Developer ID; existing Accessibility grants from older versions may need to be confirmed again as prompted by the system.
34
+ - Move the screenshot controls to the bottom of the Sonicloud Devices page.
14
35
  - Provide an English-default user guide with a Chinese version, UI installation, update, and removal instructions, and screenshots.
15
36
  - Refactor device and speech handling and share retry logic, preserving functionality and UI.
16
37
  - Streamline specifications and development docs, consolidating CI/CD configuration and release verification records.
@@ -18,6 +39,13 @@
18
39
  - Relax release-notes rules: publishing falls back to the Unreleased section when the changelog has no section for the current version, so merging dev directly can ship.
19
40
  - Accept fully folded changelogs in release checks: an Unreleased section must stay at the top when present, and a fully folded changelog (version sections only) publishes from the current version section.
20
41
 
42
+ ### Fixed
43
+
44
+ - Check macOS Screen Recording permission in both the host and native screenshot process before showing the overlay, preventing it from covering system permission prompts; missing Accessibility permission does not block regular screenshots or manual scrolling.
45
+ - Restore macOS voice helper execution permissions lost during cross-platform packaging so packages built on Windows can start Sonicloud Voice.
46
+ - Hide unsupported image translation and scrolling OCR/Word export actions in both Windows and macOS screenshot processes while keeping scrolling capture available; retain the original Developer ID identity for the macOS package.
47
+ - Parse Windows tar line endings correctly during package checks so complete packages are not reported as missing files.
48
+
21
49
  ## 0.1.1 - 2026-11-09
22
50
 
23
51
  ### Added
package/CHANGELOG.zh.md CHANGED
@@ -4,6 +4,25 @@
4
4
 
5
5
  ### 新增
6
6
 
7
+ - macOS 首次启用或重新连接时检查打字和截图权限,在“声云设备”中分别引导 Sonicloud Voice 与 screenhelper 授权并重新检查;系统授权由用户手动确认。
8
+ - 集成 Windows x64 与 macOS ARM64 独立截图进程,支持鼠标截图键及“声云设备”的“开始截图”按钮,提供选区、标注、复制、保存、贴图和滚动截图;截图重复触发及启动失败会提示,禁用插件时关闭截图和贴图窗口。
9
+
10
+ ### 变更
11
+
12
+ - macOS Sonicloud Voice 改用 Developer ID 签名;旧版本的辅助功能授权可能需要按系统提示重新确认。
13
+ - 将“声云设备”页面的截图操作行移至最底部。
14
+
15
+ ### 修复
16
+
17
+ - macOS 截图在宿主和原生进程两层检查屏幕录制权限,缺权限时不显示蒙层,避免遮挡系统授权弹窗;辅助功能缺失不阻止普通截图和手动滚动。
18
+ - 恢复跨平台打包丢失的 macOS 语音组件执行权限,避免从 Windows 生成的安装包无法启动 Sonicloud Voice。
19
+ - Windows、macOS 截图进程统一隐藏未接入的图片翻译及滚动 OCR/Word 导出入口,保留滚动截图;macOS 包沿用原 Developer ID 签名。
20
+ - 修正 Windows 上安装包检查对 tar 换行的解析,避免完整安装包被误判缺少文件。
21
+
22
+ ## 0.1.2 - 2026-11-12
23
+
24
+ ### 新增
25
+
7
26
  - 左侧导航栏新增「声云设备」面板,与设置页提供同样的设备管理界面;默认显示,可在设置页开关手动隐藏或恢复,隐藏不影响设置页功能。
8
27
  - Windows 语音打字与语音翻译改用 typer 标准注入库:说话期间文字实时逐字填入当前焦点窗口并自动退格更正,松手完成收尾;翻译仅逐字打出最终译文。逐字注入不读取、不占用剪贴板;密码框、组件缺失或注入被拒(如提权窗口)时保留结果供复制。
9
28
  - AI 键支持唤回 Harness 窗口:Windows 直接还原最小化窗口,托盘隐藏时剥离 node 模式环境变量后二次启动运行中的程序、由单实例还原或重建窗口;唤起失败不再阻断对话草稿填充。
@@ -11,6 +30,8 @@
11
30
 
12
31
  ### 变更
13
32
 
33
+ - macOS Sonicloud Voice 改用 Developer ID 签名;旧版本的辅助功能授权可能需要按系统提示重新确认。
34
+ - 将“声云设备”页面的截图操作行移至最底部。
14
35
  - 提供默认英文、可切换中文的用户指南,补充界面安装、更新、卸载说明及截图。
15
36
  - 重构设备与语音处理、复用重连逻辑,保持功能和界面不变。
16
37
  - 精简规格与开发文档,汇总 CI/CD 配置及发布验证记录。
@@ -18,6 +39,13 @@
18
39
  - 放宽发布说明规则:更新日志缺少当前版本章节时正式发布自动回退采用未发布章节内容,dev 分支直接合并即可发布。
19
40
  - 发布校验兼容完全折叠的更新日志:未发布章节存在时仍须置顶,完全折叠(仅版本章节、无未发布章节)时正式发布直接采用当前版本章节。
20
41
 
42
+ ### 修复
43
+
44
+ - macOS 截图在宿主和原生进程两层检查屏幕录制权限,缺权限时不显示蒙层,避免遮挡系统授权弹窗;辅助功能缺失不阻止普通截图和手动滚动。
45
+ - 恢复跨平台打包丢失的 macOS 语音组件执行权限,避免从 Windows 生成的安装包无法启动 Sonicloud Voice。
46
+ - Windows、macOS 截图进程统一隐藏未接入的图片翻译及滚动 OCR/Word 导出入口,保留滚动截图;macOS 包沿用原 Developer ID 签名。
47
+ - 修正 Windows 上安装包检查对 tar 换行的解析,避免完整安装包被误判缺少文件。
48
+
21
49
  ## 0.1.1 - 2026-11-09
22
50
 
23
51
  ### 新增
package/README.md CHANGED
@@ -21,6 +21,8 @@ Supports Apple silicon Macs and Windows x64. The plugin identifies your mouse an
21
21
  3. Enter **@sonicloud/dsh-sonicloud-device** and click **Install (安装)**.
22
22
  4. Once installed, enable the plugin and open **Settings → Sonicloud Devices (设置 → 声云设备)** to view and configure your mouse.
23
23
 
24
+ On macOS, initial activation and reconnection check typing and screenshot permissions. Sonicloud Devices keeps the setup guidance available; see [first-time permissions](#first-time-permissions-on-macos).
25
+
24
26
  ![Add the plugin in Harness by entering @sonicloud/dsh-sonicloud-device and clicking Install](docs/images/plugin-install.png)
25
27
 
26
28
  ## Features
@@ -31,6 +33,7 @@ Supports Apple silicon Macs and Windows x64. The plugin identifies your mouse an
31
33
  | Voice translation | Choose source and target languages and assign Voice Translation to the voice or M button. Hold to speak, then release to insert the translation |
32
34
  | Voice search | Assign Voice Search to the M button and choose Baidu, Bing, or Google. Speak your query and release to search |
33
35
  | AI conversations | Hold the AI button to speak, then release to fill a Harness conversation. Auto-send is enabled by default and can be turned off in settings |
36
+ | Screenshots | Press the mouse capture button or click Start Screenshot in Sonicloud Devices, then select a region to annotate, copy, save, pin, or capture scrolling content |
34
37
  | Buttons and sensitivity | Assign Enter, Backspace, Open Link, or other actions to the M button, and adjust mouse DPI |
35
38
  | Multiple mice | View each mouse's connection, battery level, and serial number, and save its language, button, and sensitivity settings separately |
36
39
 
@@ -40,6 +43,20 @@ Manage these options in **Settings → Sonicloud Devices (设置 → 声云设
40
43
 
41
44
  ## Getting started
42
45
 
46
+ ### First-time permissions on macOS
47
+
48
+ After enabling the plugin, open **Sonicloud Devices (声云设备)** and grant the permissions you need:
49
+
50
+ | Component | Permission and purpose |
51
+ | --- | --- |
52
+ | Sonicloud Voice | Accessibility: insert recognized text into desktop apps; recognition and copying remain available without it |
53
+ | screenhelper | Screen Recording: required for screenshots; the capture overlay stays closed until permission is granted |
54
+ | screenhelper | Accessibility: optional for automatic scrolling; regular screenshots and manual scrolling remain available |
55
+
56
+ Click the corresponding **Authorize (授权)** button to let that component request permission. Confirm manually in the system prompt or **System Settings → Privacy & Security**, then click **Authorized, Check Again (已授权,重新检查)**. If a component is missing from the list, expand its location in the page and add it by that path. The plugin checks and guides setup; it never confirms system permissions for you.
57
+
58
+ Sonicloud Voice now uses a Developer ID signature. If an older version is already checked but the plugin still reports missing permission, follow the system prompts to authorize it again and restart Harness, then recheck.
59
+
43
60
  ### Voice typing and translation
44
61
 
45
62
  1. Turn on your mouse, select Bluetooth or 2.4 GHz mode, and connect it.
@@ -51,7 +68,7 @@ Audio comes from the mouse. Recognized text and processing status appear in a se
51
68
 
52
69
  Keep the target window, document, and input position unchanged during recording, and avoid typing, clicking, or scrolling. If the target changes or the app does not support automatic insertion, the overlay keeps the result available to copy. If translation fails, you can copy the recognized source text.
53
70
 
54
- On macOS, automatic insertion requires allowing **Sonicloud Voice** under **System Settings → Privacy & Security → Accessibility**. Recognition and copying still work without this permission. Insertion temporarily uses the clipboard, then restores its previous contents while preserving anything newly copied in the meantime.
71
+ For macOS insertion permissions, see [first-time permissions](#first-time-permissions-on-macos). Insertion temporarily uses the clipboard, then restores its previous contents while preserving anything newly copied in the meantime.
55
72
 
56
73
  On Windows, recognized text is typed live into the focused field character by character through the typer injection library, with automatic corrections while you speak; translation types only the final translated text. Character injection never touches the clipboard. Password fields and windows that reject simulated input (for example, elevated apps) keep the result available to copy instead.
57
74
 
@@ -65,6 +82,12 @@ With **Auto-send (自动发送)** enabled, the complete draft and attachments ar
65
82
 
66
83
  Voice search uses the current mouse's recognition language and selected search engine. For **Open Link (一键链接)**, enter a URL and click **Confirm (确认)**; you can omit `https://` or `http://`. Searching and opening links do not require a focused input field. Non-voice M button actions run when you release the button.
67
84
 
85
+ ### Screenshots
86
+
87
+ Press the mouse capture button or click **Start Screenshot (开始截图)** at the bottom of **Sonicloud Devices (声云设备)**, then select a region in the separate capture UI. The capture process is bundled. The UI button also works without a connected mouse. Repeated triggers while capturing report that a capture is already in progress. Press `Esc` to leave region selection. Disabling the plugin or quitting Harness closes the capture process and pinned image windows.
88
+
89
+ On macOS, complete [first-time permissions](#first-time-permissions-on-macos) before taking a screenshot. Cloud service integration for OCR, image translation, and Word export is outside this integration.
90
+
68
91
  ## Update or uninstall
69
92
 
70
93
  Find the Sonicloud smart mouse plugin under **Plugins → Installed (插件 → 已安装)** in Harness.
package/README.zh.md CHANGED
@@ -21,6 +21,8 @@
21
21
  3. 输入 **@sonicloud/dsh-sonicloud-device**,点击**安装**。
22
22
  4. 安装完成后启用插件,打开**设置 → 声云设备**,即可查看和配置鼠标。
23
23
 
24
+ macOS 首次启用或重新连接插件时会检查打字和截图权限,并在“声云设备”中保留授权引导;操作见[首次授权](#macos-首次授权)。
25
+
24
26
  ![在 Harness 插件页面点击“添加插件”,输入 @sonicloud/dsh-sonicloud-device 后安装](docs/images/plugin-install.png)
25
27
 
26
28
  ## 你可以做什么
@@ -31,6 +33,7 @@
31
33
  | 语音翻译 | 选择源语言和目标语言,将语音键或 M 键设为“语音翻译”,按住说话,松开后填入译文 |
32
34
  | 语音搜索 | 将 M 键设为“语音搜索”,选择百度、Bing 或 Google,说出关键词后松开即可搜索 |
33
35
  | AI 对话 | 按住 AI 键说话,松开后填入 Harness 对话;“自动发送”默认开启,可在设置中关闭 |
36
+ | 截图 | 按鼠标截图键,或在“声云设备”中点击“开始截图”,框选后标注、复制、保存、贴图或滚动截图 |
34
37
  | 自定义按键与灵敏度 | 为 M 键选择回车、后退或一键链接等动作,并调整鼠标 DPI |
35
38
  | 多设备管理 | 查看每台鼠标的连接方式、电量和序列号,分别保存语言、按键和灵敏度设置 |
36
39
 
@@ -40,6 +43,20 @@
40
43
 
41
44
  ## 开始使用
42
45
 
46
+ ### macOS 首次授权
47
+
48
+ 安装后启用插件,打开**声云设备**,按需要为以下组件授权:
49
+
50
+ | 组件 | 权限与用途 |
51
+ | --- | --- |
52
+ | Sonicloud Voice | 辅助功能:将识别文字自动填入桌面应用;未授权仍可识别并复制文字 |
53
+ | screenhelper | 屏幕录制:截图必需;未授权时不会显示截图蒙层 |
54
+ | screenhelper | 辅助功能:自动滚动可选,普通截图和手动滚动不受影响 |
55
+
56
+ 点击对应的**授权**按钮后,由该组件向系统申请权限;在系统弹窗或**系统设置 → 隐私与安全性**中手动确认,再点击**已授权,重新检查**。找不到组件时,可展开页面中的组件位置,按路径手动添加。插件只检查和引导,不会自动确认系统授权。
57
+
58
+ Sonicloud Voice 已改用 Developer ID 签名。若旧版本已勾选,但插件仍显示待授权,请按系统提示重新授权并重启 Harness,再重新检查。
59
+
43
60
  ### 语音输入与翻译
44
61
 
45
62
  1. 打开鼠标电源,选择蓝牙或 2.4G 模式并完成连接。
@@ -51,7 +68,7 @@
51
68
 
52
69
  录音期间请保持目标窗口、文档和输入位置,不进行键盘编辑、鼠标点击或滚动。目标发生变化或应用不支持自动填入时,浮层会保留结果供复制;翻译失败时可复制识别原文。
53
70
 
54
- macOS 自动填入需要在**系统设置 → 隐私与安全性 → 辅助功能**中允许 **Sonicloud Voice**。没有权限也可以识别并复制结果。macOS 填入文字时会临时使用剪贴板,随后恢复原内容,并保留期间新复制的内容。
71
+ macOS 自动填入所需权限见[首次授权](#macos-首次授权)。填入文字时会临时使用剪贴板,随后恢复原内容,并保留期间新复制的内容。
55
72
 
56
73
  Windows 通过 typer 标准注入库逐字打字:说话期间文字实时填入当前焦点输入框并自动更正,全程不占用剪贴板;翻译在译文就绪后逐字打出。目标为密码框或注入被拒(如管理员窗口)时保留结果供复制。
57
74
 
@@ -65,6 +82,12 @@ Windows 通过 typer 标准注入库逐字打字:说话期间文字实时填
65
82
 
66
83
  语音搜索使用当前鼠标的识别语言和所选搜索引擎。使用一键链接时,先填写网址并点击**确认**;可以省略 `https://` 或 `http://`。搜索和打开链接无需先选中输入框,非语音的 M 键动作在松键时执行。
67
84
 
85
+ ### 截图
86
+
87
+ 按鼠标截图键,或点击**声云设备**页面底部的**开始截图**,在独立截图界面中选择区域后操作。截图进程随插件提供,界面按钮无需连接鼠标。截图期间重复触发会提示正在进行,按 `Esc` 可退出选区。插件禁用或 Harness 退出时,截图进程和贴图窗口一并关闭。
88
+
89
+ macOS 请先完成[首次授权](#macos-首次授权),再开始截图。OCR、图片翻译和 Word 导出所需的云服务接入不包含在本次集成中。
90
+
68
91
  ## 更新与卸载
69
92
 
70
93
  在 Harness 的**插件 → 已安装**中找到声云智能鼠标插件。
package/dist/build.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "plugin": "dsh-sonicloud-device",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "harness": "0.2.1-rc.5"
5
5
  }
package/dist/client.js CHANGED
@@ -20016,6 +20016,17 @@ var REMOTE = {
20016
20016
  descriptors: [
20017
20017
  define("catalog", [], catalog),
20018
20018
  define("devices", [], devices),
20019
+ define("captureScreenshot", [], external_exports.boolean()),
20020
+ define(
20021
+ "screenshotPermissions",
20022
+ [["action", external_exports.enum(["check", "screen", "accessibility", "refresh"])]],
20023
+ external_exports.object({ supported: external_exports.boolean(), screenRecording: external_exports.boolean(), accessibility: external_exports.boolean(), helperApp: text }).strict()
20024
+ ),
20025
+ define(
20026
+ "typingPermissions",
20027
+ [["action", external_exports.enum(["check", "accessibility", "refresh"])]],
20028
+ external_exports.object({ supported: external_exports.boolean(), accessibility: external_exports.boolean(), helperApp: text }).strict()
20029
+ ),
20019
20030
  define(
20020
20031
  "saveDevice",
20021
20032
  [["sn", snSchema], ["revision", external_exports.number().int().nonnegative()], ["preferences", preferencesSchema]],
@@ -20195,12 +20206,82 @@ var DeviceController = class {
20195
20206
  dismissToast(id2) {
20196
20207
  if (this.state.toast?.id === id2) this.publish({ toast: void 0 });
20197
20208
  }
20209
+ refreshScreenshotPermissions(action = "check", options) {
20210
+ return this.refreshPermissionStatus("screenshot", action, options);
20211
+ }
20212
+ refreshTypingPermissions(action = "check", options) {
20213
+ return this.refreshPermissionStatus("typing", action, options);
20214
+ }
20215
+ async refreshPermissionStatus(kind, action, { automatic = false } = {}) {
20216
+ const method = `${kind}Permissions`, requestKey = `${kind}PermissionRequest`;
20217
+ const busyKey = `${kind}PermissionBusy`, errorKey = `${kind}PermissionError`, messageKey = `${kind}PermissionMessage`;
20218
+ const isTyping = kind === "typing";
20219
+ const helper = isTyping ? "Sonicloud Voice" : "screenhelper";
20220
+ const fallback = `${isTyping ? "\u6253\u5B57" : "\u622A\u56FE"}\u6743\u9650\u68C0\u67E5\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5`;
20221
+ if (this.lifetime.signal.aborted || typeof this.api[method] !== "function") return void 0;
20222
+ const epoch = this.permissionEpoch ?? 0;
20223
+ if (this[requestKey]?.epoch === epoch) return this[requestKey].promise;
20224
+ this.publish({ [busyKey]: true, [errorKey]: void 0 });
20225
+ const current = { epoch };
20226
+ current.promise = Promise.resolve().then(async () => {
20227
+ try {
20228
+ const result = await this.api[method](action);
20229
+ if (this.lifetime.signal.aborted || (this.permissionEpoch ?? 0) !== epoch) return void 0;
20230
+ const permissions = result?.value;
20231
+ const fields = isTyping ? ["supported", "accessibility"] : ["supported", "screenRecording", "accessibility"];
20232
+ if (!result?.ok || !permissions || fields.some((key) => typeof permissions[key] !== "boolean") || typeof permissions.helperApp !== "string") throw new Error(result?.error?.message || fallback);
20233
+ let message;
20234
+ const missing = !permissions.accessibility || !isTyping && !permissions.screenRecording;
20235
+ if (action === "screen" || action === "accessibility") message = `\u8BF7\u5728\u7CFB\u7EDF\u5F39\u7A97\u6216\u201C\u9690\u79C1\u4E0E\u5B89\u5168\u6027\u201D\u4E2D\u4E3A ${helper} \u5B8C\u6210\u6388\u6743\uFF0C\u518D\u70B9\u51FB\u201C\u5DF2\u6388\u6743\uFF0C\u91CD\u65B0\u68C0\u67E5\u201D\u3002\u5982\u7CFB\u7EDF\u8981\u6C42\u91CD\u542F\uFF0C\u8BF7\u6309\u63D0\u793A\u64CD\u4F5C\u3002`;
20236
+ else if (action === "refresh" && permissions.supported && (isTyping ? !permissions.accessibility : !permissions.screenRecording)) message = "\u5C1A\u672A\u83B7\u5F97\u6240\u9700\u6743\u9650\uFF1B\u5982\u521A\u5B8C\u6210\u6388\u6743\uFF0C\u8BF7\u6309\u7CFB\u7EDF\u63D0\u793A\u91CD\u542F\u540E\u518D\u68C0\u67E5\u3002";
20237
+ this.publish({ [method]: permissions, [messageKey]: message });
20238
+ if (automatic && permissions.supported && missing && !this.permissionPrompted) {
20239
+ this.permissionPrompted = true;
20240
+ this.notice("macOS \u9996\u6B21\u4F7F\u7528\u65F6\uFF0C\u8BF7\u5230\u201C\u58F0\u4E91\u8BBE\u5907\u201D\u67E5\u770B\u5E76\u5B8C\u6210\u6240\u9700\u7684\u7CFB\u7EDF\u6388\u6743\u3002", "info");
20241
+ }
20242
+ return permissions;
20243
+ } catch (error62) {
20244
+ if (!this.lifetime.signal.aborted && (this.permissionEpoch ?? 0) === epoch) {
20245
+ this.publish({ [method]: void 0, [errorKey]: error62?.message || fallback });
20246
+ if (!automatic) this.notice(error62?.message || fallback);
20247
+ }
20248
+ return void 0;
20249
+ } finally {
20250
+ if (this[requestKey] === current) this[requestKey] = void 0;
20251
+ if (!this.lifetime.signal.aborted && (this.permissionEpoch ?? 0) === epoch) this.publish({ [busyKey]: false });
20252
+ }
20253
+ });
20254
+ this[requestKey] = current;
20255
+ return current.promise;
20256
+ }
20257
+ async captureScreenshot() {
20258
+ if (this.lifetime.signal.aborted || this.state.screenshotBusy) return false;
20259
+ if (this.state.screenshotPermissionError || this.state.screenshotPermissions?.supported && !this.state.screenshotPermissions.screenRecording) {
20260
+ this.notice(this.state.screenshotPermissionError || "\u8BF7\u5148\u4E3A screenhelper \u6388\u4E88\u5C4F\u5E55\u5F55\u5236\u6743\u9650\uFF0C\u518D\u91CD\u65B0\u68C0\u67E5");
20261
+ return false;
20262
+ }
20263
+ this.publish({ screenshotBusy: true });
20264
+ try {
20265
+ const result = await this.api.captureScreenshot();
20266
+ if (!result.ok || !result.value) throw new Error(result.error?.message || "\u622A\u56FE\u542F\u52A8\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5");
20267
+ return true;
20268
+ } catch (error62) {
20269
+ if (!this.lifetime.signal.aborted) this.notice(error62.message || "\u622A\u56FE\u542F\u52A8\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5");
20270
+ return false;
20271
+ } finally {
20272
+ if (!this.lifetime.signal.aborted) this.publish({ screenshotBusy: false });
20273
+ }
20274
+ }
20198
20275
  connect() {
20199
20276
  return this.connecting ??= this.watchLoop();
20200
20277
  }
20201
20278
  async watchLoop() {
20202
20279
  const signal = this.lifetime.signal;
20203
20280
  while (!signal.aborted) {
20281
+ this.permissionEpoch = (this.permissionEpoch ?? 0) + 1;
20282
+ this.permissionPrompted = false;
20283
+ void this.refreshScreenshotPermissions("check", { automatic: true });
20284
+ void this.refreshTypingPermissions("check", { automatic: true });
20204
20285
  try {
20205
20286
  this.stream = this.api.watch(this.clientId, signal);
20206
20287
  for await (const event2 of this.stream) {
@@ -20213,7 +20294,21 @@ var DeviceController = class {
20213
20294
  this.stream = void 0;
20214
20295
  }
20215
20296
  if (signal.aborted) return;
20216
- this.publish({ status: "\u8BBE\u5907\u670D\u52A1\u8FDE\u63A5\u4E2D\u65AD\uFF0C\u6B63\u5728\u91CD\u65B0\u8FDE\u63A5\u2026", devices: [] });
20297
+ this.permissionEpoch++;
20298
+ this.publish({
20299
+ status: "\u8BBE\u5907\u670D\u52A1\u8FDE\u63A5\u4E2D\u65AD\uFF0C\u6B63\u5728\u91CD\u65B0\u8FDE\u63A5\u2026",
20300
+ devices: [],
20301
+ ...typeof this.api.screenshotPermissions === "function" ? {
20302
+ screenshotPermissions: void 0,
20303
+ screenshotPermissionBusy: false,
20304
+ screenshotPermissionError: "\u8BBE\u5907\u670D\u52A1\u8FDE\u63A5\u4E2D\u65AD\uFF0C\u8FDE\u63A5\u6062\u590D\u540E\u4F1A\u91CD\u65B0\u68C0\u67E5\u622A\u56FE\u6743\u9650"
20305
+ } : {},
20306
+ ...typeof this.api.typingPermissions === "function" ? {
20307
+ typingPermissions: void 0,
20308
+ typingPermissionBusy: false,
20309
+ typingPermissionError: "\u8BBE\u5907\u670D\u52A1\u8FDE\u63A5\u4E2D\u65AD\uFF0C\u8FDE\u63A5\u6062\u590D\u540E\u4F1A\u91CD\u65B0\u68C0\u67E5\u6253\u5B57\u6743\u9650"
20310
+ } : {}
20311
+ });
20217
20312
  await waitForRetry(signal, this.retryDelayMs);
20218
20313
  }
20219
20314
  }
@@ -20510,7 +20605,11 @@ function Devices({ controller, sidebar }) {
20510
20605
  const devices2 = state.devices, device2 = devices2.find((item) => item.id === selected) ?? devices2[0];
20511
20606
  const index = device2 ? devices2.indexOf(device2) : 0;
20512
20607
  const count = new Set(devices2.filter((item) => item.identityConfirmed).map((item) => item.sn)).size;
20513
- return /* @__PURE__ */ import_react2.default.createElement("section", { className: "dsh-mouse-settings", "aria-label": "\u58F0\u4E91\u8BBE\u5907" }, /* @__PURE__ */ import_react2.default.createElement("header", { className: "dsh-mouse-head" }, /* @__PURE__ */ import_react2.default.createElement("h2", null, "\u58F0\u4E91\u8BBE\u5907"), sidebar && /* @__PURE__ */ import_react2.default.createElement("span", { className: "dsh-mouse-switch" }, /* @__PURE__ */ import_react2.default.createElement("span", null, "\u4FA7\u8FB9\u680F"), /* @__PURE__ */ import_react2.default.createElement(import_dsh_client_ui_primitives.Switch, { label: "\u4FA7\u8FB9\u680F", checked: sidebarVisible, onChange: (value) => sidebar.setVisible(value) }))), /* @__PURE__ */ import_react2.default.createElement("p", { className: "dsh-asr-intro" }, count, " \u53F0\u8BBE\u5907\u5DF2\u8FDE\u63A5 \xB7 \u4E3A\u6BCF\u53F0\u8BBE\u5907\u8BBE\u7F6E\u4E13\u5C5E\u504F\u597D"), !device2 ? /* @__PURE__ */ import_react2.default.createElement("div", { className: "dsh-mouse-empty" }, /* @__PURE__ */ import_react2.default.createElement("span", { "aria-hidden": "true" }, "\u2301"), /* @__PURE__ */ import_react2.default.createElement("h3", null, "\u6682\u65E0\u8BBE\u5907\u8FDE\u63A5"), /* @__PURE__ */ import_react2.default.createElement("p", null, "\u8BF7\u8FDE\u63A5\u667A\u80FD\u9F20\u6807\u7684 USB \u63A5\u6536\u5668\uFF0C\u6216\u901A\u8FC7\u84DD\u7259\u8FDE\u63A5\u9F20\u6807\u3002"), /* @__PURE__ */ import_react2.default.createElement("p", { className: "dsh-asr-muted" }, state.status)) : /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null, /* @__PURE__ */ import_react2.default.createElement("div", { className: "dsh-mouse-carousel" }, devices2.length > 1 && /* @__PURE__ */ import_react2.default.createElement("button", { type: "button", "aria-label": "\u4E0A\u4E00\u53F0\u8BBE\u5907", onClick: () => setSelected(devices2[(index + devices2.length - 1) % devices2.length].id) }, "\u2039"), /* @__PURE__ */ import_react2.default.createElement("div", { className: "dsh-mouse-product" }, /* @__PURE__ */ import_react2.default.createElement("div", { className: "dsh-mouse-illustration", role: "img", "aria-label": "\u667A\u80FD\u9F20\u6807\u793A\u610F\u56FE" }, /* @__PURE__ */ import_react2.default.createElement("span", { className: "dsh-mouse-wheel" }), /* @__PURE__ */ import_react2.default.createElement("span", { className: "dsh-mouse-ai" }, "AI")), /* @__PURE__ */ import_react2.default.createElement("h3", null, device2.name)), devices2.length > 1 && /* @__PURE__ */ import_react2.default.createElement("button", { type: "button", "aria-label": "\u4E0B\u4E00\u53F0\u8BBE\u5907", onClick: () => setSelected(devices2[(index + 1) % devices2.length].id) }, "\u203A")), devices2.length > 1 && /* @__PURE__ */ import_react2.default.createElement("div", { className: "dsh-mouse-dots" }, devices2.map((item, i) => /* @__PURE__ */ import_react2.default.createElement("button", { type: "button", key: item.id, "aria-label": `\u5207\u6362\u5230\u8BBE\u5907 ${i + 1}`, "aria-current": item.id === device2.id ? "true" : void 0, onClick: () => setSelected(item.id) }))), /* @__PURE__ */ import_react2.default.createElement(Row, { label: "SN" }, /* @__PURE__ */ import_react2.default.createElement("span", { className: "dsh-mouse-value" }, device2.sn || "\u8BBE\u5907\u8EAB\u4EFD\u672A\u786E\u8BA4")), /* @__PURE__ */ import_react2.default.createElement(Row, { label: "\u8FDE\u63A5\u65B9\u5F0F" }, /* @__PURE__ */ import_react2.default.createElement("span", { className: "dsh-mouse-value" }, device2.connection === "usb" ? "USB \u63A5\u6536\u5668" : "\u84DD\u7259")), /* @__PURE__ */ import_react2.default.createElement(Row, { label: "\u8BBE\u5907\u7535\u91CF" }, /* @__PURE__ */ import_react2.default.createElement("span", { className: "dsh-mouse-value" }, device2.battery === null ? "\u672A\u77E5" : `${device2.battery}%`)), device2.type === "smart-mouse" ? /* @__PURE__ */ import_react2.default.createElement(DeviceForm, { key: device2.id, device: device2, controller, state }) : /* @__PURE__ */ import_react2.default.createElement("p", null, "\u6B64\u8BBE\u5907\u7C7B\u578B\u6682\u672A\u63D0\u4F9B\u4E13\u5C5E\u8BBE\u7F6E\u3002")));
20608
+ const permissions = state.screenshotPermissions;
20609
+ const screenMissing = permissions?.supported && !permissions.screenRecording;
20610
+ const permissionBusy = state.screenshotPermissionBusy;
20611
+ const typingPermissions = state.typingPermissions;
20612
+ return /* @__PURE__ */ import_react2.default.createElement("section", { className: "dsh-mouse-settings", "aria-label": "\u58F0\u4E91\u8BBE\u5907" }, /* @__PURE__ */ import_react2.default.createElement("header", { className: "dsh-mouse-head" }, /* @__PURE__ */ import_react2.default.createElement("h2", null, "\u58F0\u4E91\u8BBE\u5907"), sidebar && /* @__PURE__ */ import_react2.default.createElement("span", { className: "dsh-mouse-switch" }, /* @__PURE__ */ import_react2.default.createElement("span", null, "\u4FA7\u8FB9\u680F"), /* @__PURE__ */ import_react2.default.createElement(import_dsh_client_ui_primitives.Switch, { label: "\u4FA7\u8FB9\u680F", checked: sidebarVisible, onChange: (value) => sidebar.setVisible(value) }))), /* @__PURE__ */ import_react2.default.createElement("p", { className: "dsh-asr-intro" }, count, " \u53F0\u8BBE\u5907\u5DF2\u8FDE\u63A5 \xB7 \u4E3A\u6BCF\u53F0\u8BBE\u5907\u8BBE\u7F6E\u4E13\u5C5E\u504F\u597D"), !device2 ? /* @__PURE__ */ import_react2.default.createElement("div", { className: "dsh-mouse-empty" }, /* @__PURE__ */ import_react2.default.createElement("span", { "aria-hidden": "true" }, "\u2301"), /* @__PURE__ */ import_react2.default.createElement("h3", null, "\u6682\u65E0\u8BBE\u5907\u8FDE\u63A5"), /* @__PURE__ */ import_react2.default.createElement("p", null, "\u8BF7\u8FDE\u63A5\u667A\u80FD\u9F20\u6807\u7684 USB \u63A5\u6536\u5668\uFF0C\u6216\u901A\u8FC7\u84DD\u7259\u8FDE\u63A5\u9F20\u6807\u3002"), /* @__PURE__ */ import_react2.default.createElement("p", { className: "dsh-asr-muted" }, state.status)) : /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null, /* @__PURE__ */ import_react2.default.createElement("div", { className: "dsh-mouse-carousel" }, devices2.length > 1 && /* @__PURE__ */ import_react2.default.createElement("button", { type: "button", "aria-label": "\u4E0A\u4E00\u53F0\u8BBE\u5907", onClick: () => setSelected(devices2[(index + devices2.length - 1) % devices2.length].id) }, "\u2039"), /* @__PURE__ */ import_react2.default.createElement("div", { className: "dsh-mouse-product" }, /* @__PURE__ */ import_react2.default.createElement("div", { className: "dsh-mouse-illustration", role: "img", "aria-label": "\u667A\u80FD\u9F20\u6807\u793A\u610F\u56FE" }, /* @__PURE__ */ import_react2.default.createElement("span", { className: "dsh-mouse-wheel" }), /* @__PURE__ */ import_react2.default.createElement("span", { className: "dsh-mouse-ai" }, "AI")), /* @__PURE__ */ import_react2.default.createElement("h3", null, device2.name)), devices2.length > 1 && /* @__PURE__ */ import_react2.default.createElement("button", { type: "button", "aria-label": "\u4E0B\u4E00\u53F0\u8BBE\u5907", onClick: () => setSelected(devices2[(index + 1) % devices2.length].id) }, "\u203A")), devices2.length > 1 && /* @__PURE__ */ import_react2.default.createElement("div", { className: "dsh-mouse-dots" }, devices2.map((item, i) => /* @__PURE__ */ import_react2.default.createElement("button", { type: "button", key: item.id, "aria-label": `\u5207\u6362\u5230\u8BBE\u5907 ${i + 1}`, "aria-current": item.id === device2.id ? "true" : void 0, onClick: () => setSelected(item.id) }))), /* @__PURE__ */ import_react2.default.createElement(Row, { label: "SN" }, /* @__PURE__ */ import_react2.default.createElement("span", { className: "dsh-mouse-value" }, device2.sn || "\u8BBE\u5907\u8EAB\u4EFD\u672A\u786E\u8BA4")), /* @__PURE__ */ import_react2.default.createElement(Row, { label: "\u8FDE\u63A5\u65B9\u5F0F" }, /* @__PURE__ */ import_react2.default.createElement("span", { className: "dsh-mouse-value" }, device2.connection === "usb" ? "USB \u63A5\u6536\u5668" : "\u84DD\u7259")), /* @__PURE__ */ import_react2.default.createElement(Row, { label: "\u8BBE\u5907\u7535\u91CF" }, /* @__PURE__ */ import_react2.default.createElement("span", { className: "dsh-mouse-value" }, device2.battery === null ? "\u672A\u77E5" : `${device2.battery}%`)), device2.type === "smart-mouse" ? /* @__PURE__ */ import_react2.default.createElement(DeviceForm, { key: device2.id, device: device2, controller, state }) : /* @__PURE__ */ import_react2.default.createElement("p", null, "\u6B64\u8BBE\u5907\u7C7B\u578B\u6682\u672A\u63D0\u4F9B\u4E13\u5C5E\u8BBE\u7F6E\u3002")), typingPermissions?.supported && /* @__PURE__ */ import_react2.default.createElement("div", { "aria-label": "\u6253\u5B57\u4E0A\u5C4F\u6743\u9650", "aria-busy": state.typingPermissionBusy }, /* @__PURE__ */ import_react2.default.createElement("p", null, /* @__PURE__ */ import_react2.default.createElement("strong", null, "Sonicloud Voice"), " \u8F85\u52A9\u529F\u80FD\uFF1A", typingPermissions.accessibility ? "\u5DF2\u6388\u6743" : "\u5F85\u6388\u6743"), !typingPermissions.accessibility && /* @__PURE__ */ import_react2.default.createElement("p", null, "\u5C06\u8BC6\u522B\u6587\u5B57\u81EA\u52A8\u586B\u5165\u684C\u9762\u5E94\u7528\u9700\u8981\u6B64\u6743\u9650\uFF1B\u672A\u6388\u6743\u65F6\u4ECD\u53EF\u8BC6\u522B\u5E76\u590D\u5236\u6587\u5B57\u3002"), /* @__PURE__ */ import_react2.default.createElement("div", { className: "dsh-mouse-controls" }, !typingPermissions.accessibility && /* @__PURE__ */ import_react2.default.createElement(import_dsh_client_ui_primitives.Button, { "aria-label": "\u6388\u6743\u6253\u5B57\u8F85\u52A9\u529F\u80FD", disabled: state.typingPermissionBusy, onClick: () => controller.refreshTypingPermissions("accessibility") }, "\u6388\u6743\u6253\u5B57\u8F85\u52A9\u529F\u80FD"), /* @__PURE__ */ import_react2.default.createElement(import_dsh_client_ui_primitives.Button, { "aria-label": "\u91CD\u65B0\u68C0\u67E5\u6253\u5B57\u6743\u9650", disabled: state.typingPermissionBusy, onClick: () => controller.refreshTypingPermissions("refresh") }, state.typingPermissionBusy ? "\u6B63\u5728\u68C0\u67E5\u2026" : "\u5DF2\u6388\u6743\uFF0C\u91CD\u65B0\u68C0\u67E5")), state.typingPermissionMessage && /* @__PURE__ */ import_react2.default.createElement("p", { role: "status" }, state.typingPermissionMessage), !typingPermissions.accessibility && typingPermissions.helperApp && /* @__PURE__ */ import_react2.default.createElement("details", null, /* @__PURE__ */ import_react2.default.createElement("summary", null, "\u627E\u4E0D\u5230 Sonicloud Voice \u65F6\u67E5\u770B\u7EC4\u4EF6\u4F4D\u7F6E"), /* @__PURE__ */ import_react2.default.createElement("p", null, "\u5728\u8F85\u52A9\u529F\u80FD\u6743\u9650\u5217\u8868\u4E2D\u9700\u8981\u624B\u52A8\u6DFB\u52A0\u65F6\uFF0C\u4F7F\u7528\u4E0B\u65B9\u4F4D\u7F6E\uFF1A"), /* @__PURE__ */ import_react2.default.createElement("code", { style: { overflowWrap: "anywhere" } }, typingPermissions.helperApp))), state.typingPermissionError && /* @__PURE__ */ import_react2.default.createElement("div", { role: "alert" }, /* @__PURE__ */ import_react2.default.createElement("p", null, state.typingPermissionError), /* @__PURE__ */ import_react2.default.createElement(import_dsh_client_ui_primitives.Button, { "aria-label": "\u91CD\u65B0\u68C0\u67E5\u6253\u5B57\u6743\u9650", disabled: state.typingPermissionBusy, onClick: () => controller.refreshTypingPermissions("refresh") }, state.typingPermissionBusy ? "\u6B63\u5728\u68C0\u67E5\u2026" : "\u91CD\u65B0\u68C0\u67E5\u6253\u5B57\u6743\u9650")), /* @__PURE__ */ import_react2.default.createElement(Row, { label: "\u622A\u56FE", description: screenMissing ? "\u9996\u6B21\u622A\u56FE\u524D\u8BF7\u5148\u6388\u6743\u5C4F\u5E55\u5F55\u5236\uFF0C\u6388\u6743\u671F\u95F4\u4E0D\u4F1A\u663E\u793A\u622A\u56FE\u8499\u5C42" : "\u70B9\u51FB\u6309\u94AE\u6216\u6309\u9F20\u6807\u622A\u56FE\u952E\uFF0C\u6846\u9009\u540E\u53EF\u6807\u6CE8\u3001\u590D\u5236\u3001\u4FDD\u5B58\u6216\u8D34\u56FE" }, /* @__PURE__ */ import_react2.default.createElement(import_dsh_client_ui_primitives.Button, { "aria-label": "\u5F00\u59CB\u622A\u56FE", disabled: state.screenshotBusy || screenMissing || Boolean(state.screenshotPermissionError) || permissionBusy && !permissions, onClick: () => controller.captureScreenshot() }, state.screenshotBusy ? "\u6B63\u5728\u542F\u52A8\u2026" : "\u5F00\u59CB\u622A\u56FE")), permissions?.supported && /* @__PURE__ */ import_react2.default.createElement("div", { "aria-label": "\u622A\u56FE\u6743\u9650", "aria-busy": permissionBusy }, /* @__PURE__ */ import_react2.default.createElement("p", null, permissions.screenRecording && permissions.accessibility ? /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null, "\u622A\u56FE\u7EC4\u4EF6 ", /* @__PURE__ */ import_react2.default.createElement("strong", null, "screenhelper"), " \u6743\u9650\u5DF2\u5C31\u7EEA\u3002") : /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null, "\u8BF7\u4E3A\u622A\u56FE\u7EC4\u4EF6 ", /* @__PURE__ */ import_react2.default.createElement("strong", null, "screenhelper"), " \u6388\u6743\u3002")), /* @__PURE__ */ import_react2.default.createElement("p", { role: "status" }, "\u5C4F\u5E55\u5F55\u5236\uFF1A", permissions.screenRecording ? "\u5DF2\u6388\u6743" : "\u5F85\u6388\u6743", "\uFF08\u622A\u56FE\u5FC5\u9700\uFF09", /* @__PURE__ */ import_react2.default.createElement("br", null), "\u8F85\u52A9\u529F\u80FD\uFF1A", permissions.accessibility ? "\u5DF2\u6388\u6743" : "\u5F85\u6388\u6743", "\uFF08\u81EA\u52A8\u6EDA\u52A8\u53EF\u9009\uFF0C\u666E\u901A\u622A\u56FE\u548C\u624B\u52A8\u6EDA\u52A8\u4E0D\u53D7\u5F71\u54CD\uFF09"), /* @__PURE__ */ import_react2.default.createElement("div", { className: "dsh-mouse-controls" }, !permissions.screenRecording && /* @__PURE__ */ import_react2.default.createElement(import_dsh_client_ui_primitives.Button, { "aria-label": "\u6388\u6743\u5C4F\u5E55\u5F55\u5236", disabled: permissionBusy, onClick: () => controller.refreshScreenshotPermissions("screen") }, "\u6388\u6743\u5C4F\u5E55\u5F55\u5236"), !permissions.accessibility && /* @__PURE__ */ import_react2.default.createElement(import_dsh_client_ui_primitives.Button, { "aria-label": "\u6388\u6743\u8F85\u52A9\u529F\u80FD", disabled: permissionBusy, onClick: () => controller.refreshScreenshotPermissions("accessibility") }, "\u6388\u6743\u8F85\u52A9\u529F\u80FD"), /* @__PURE__ */ import_react2.default.createElement(import_dsh_client_ui_primitives.Button, { "aria-label": "\u91CD\u65B0\u68C0\u67E5\u622A\u56FE\u6743\u9650", disabled: permissionBusy, onClick: () => controller.refreshScreenshotPermissions("refresh") }, permissionBusy ? "\u6B63\u5728\u68C0\u67E5\u2026" : "\u5DF2\u6388\u6743\uFF0C\u91CD\u65B0\u68C0\u67E5")), state.screenshotPermissionMessage && /* @__PURE__ */ import_react2.default.createElement("p", { role: "status" }, state.screenshotPermissionMessage), (!permissions.screenRecording || !permissions.accessibility) && permissions.helperApp && /* @__PURE__ */ import_react2.default.createElement("details", null, /* @__PURE__ */ import_react2.default.createElement("summary", null, "\u627E\u4E0D\u5230 screenhelper \u65F6\u67E5\u770B\u7EC4\u4EF6\u4F4D\u7F6E"), /* @__PURE__ */ import_react2.default.createElement("p", null, "\u5728\u7CFB\u7EDF\u6743\u9650\u5217\u8868\u4E2D\u9700\u8981\u624B\u52A8\u6DFB\u52A0\u65F6\uFF0C\u4F7F\u7528\u4E0B\u65B9\u4F4D\u7F6E\uFF1A"), /* @__PURE__ */ import_react2.default.createElement("code", { style: { overflowWrap: "anywhere" } }, permissions.helperApp))), state.screenshotPermissionError && /* @__PURE__ */ import_react2.default.createElement("div", { role: "alert" }, /* @__PURE__ */ import_react2.default.createElement("p", null, state.screenshotPermissionError), /* @__PURE__ */ import_react2.default.createElement(import_dsh_client_ui_primitives.Button, { "aria-label": "\u91CD\u65B0\u68C0\u67E5\u622A\u56FE\u6743\u9650", disabled: permissionBusy, onClick: () => controller.refreshScreenshotPermissions("refresh") }, permissionBusy ? "\u6B63\u5728\u68C0\u67E5\u2026" : "\u91CD\u65B0\u68C0\u67E5\u622A\u56FE\u6743\u9650")));
20514
20613
  }
20515
20614
  function DevicesPanel(props) {
20516
20615
  return /* @__PURE__ */ import_react2.default.createElement("div", { className: "dsh-mouse-panel" }, /* @__PURE__ */ import_react2.default.createElement(Devices, { ...props }));
@@ -73,7 +73,7 @@ dsh plugin --profile desktop add /绝对路径/项目目录/artifacts/实际包
73
73
  | 路径 | 职责 |
74
74
  | --- | --- |
75
75
  | `src/client/` | React 设备设置、偏好编辑、AI 对话桥接与连接重试 |
76
- | `src/desktop/`、`native/desktop/` | 桌面浮层进程、私有标准流协议及系统输入框回填 |
76
+ | `src/desktop/`、`native/desktop/`、`native/screenshot/` | 桌面浮层、输入框回填及独立截图进程 |
77
77
  | `src/host/` | 宿主插件入口、Remote 注册与存储适配 |
78
78
  | `src/devices/` | SDK 独立进程、设备管理、偏好、语音会话与按键动作 |
79
79
  | `src/asr/` | 语音服务配置、鉴权与流式识别 |
@@ -92,6 +92,7 @@ dsh plugin --profile desktop add /绝对路径/项目目录/artifacts/实际包
92
92
  - `insert` 携带录音时的 `aiAutoSend`,通过 `requestDraftInitialization` 追加草稿,按开关调用目标组件的 `inputActions.submit()`。请求绑定同一前端连接;断开不重放填充,结束释放引用。原生浮层对 `ai_input` 只提供预览、取消和失败结果复制。
93
93
 
94
94
  - macOS:`native/desktop/VoicePanel.swift` 构建不激活的 NSPanel,默认采用兼容粘贴,核对进程、窗口、文档、焦点和输入活动计数;可读取内容与选区时同时检查,不再要求辅助功能写入接口。随包提供 ARM64 应用;修改源码后在 macOS 执行 `node scripts/native/build-desktop.mjs`,需要 Xcode Command Line Tools。普通用户无需 Swift 工具链。
95
+ - Sonicloud Voice 的 `permissions` 命令可在无录音时查询辅助功能状态,不显示浮层;只有用户点击授权才发起原生请求,活动语音期间不弹授权窗口。该组件与 screenhelper 分别授权,未授权不阻止识别和复制回退。启动前恢复 Mac 可执行文件的 `0755` 权限,以兼容 Windows 生成的 npm 包。
95
96
  - Windows:`windows.ps1` 在隐藏的 STA 进程中加载 `VoicePanel.cs`,使用系统 WinForms 与 UI Automation,无需额外下载运行时。不支持安全回填的控件显示结果供复制。验证范围见下文记录。
96
97
  - 浮层和 Host 通过私有 stdin/stdout 交换 JSON,文字不进入命令行、临时文件或日志;macOS 默认通过临时粘贴回填,随后恢复此前的全部剪贴板类型,若期间有新复制则保留新内容。其他剪贴板写入仅来自用户点击“复制结果”。辅助功能权限不足不阻止预览,但不能自动回填。
97
98
  - 开发代际复制 `native/desktop/` 并将浮层模块的资源路径固定到对应代际。修改开发构建脚本后须重启 `npm run dev`。
@@ -138,6 +139,8 @@ DPI 选项及保存值见[鼠标设置](../specs/mouse-settings.md#dpi-设置)
138
139
 
139
140
  ## 验证变更
140
141
 
142
+ 截图组件的来源、部署、原生补丁、平台限制和权限统一见[截图组件说明](../../native/screenshot/README.md)。截图使用独立 Node worker 加载客户端库;开发构建同时生成该 worker 并复制运行依赖。
143
+
141
144
  提交代码前执行:
142
145
 
143
146
  ```sh
@@ -153,6 +156,8 @@ npm test
153
156
  | 快速检查单个模块 | `node --test tests/devices.test.mjs`,文件名替换为目标测试;直接调用不会触发构建,依赖 `dist/` 时先运行 `npm run build` |
154
157
  | 界面与热重载 | 在 Harness 中保存源码,确认重载日志、界面更新、设置保存及重载后配置恢复 |
155
158
  | 设备与语音 | 用实际鼠标验证相关连接方式、按键、录音、取消、重连及多设备隔离;记录平台与设备信息 |
159
+ | 截图 | `node --test tests/screenshot*.test.mjs` 检查进程、销毁时序、缓存与资源;再在目标平台验证鼠标截图键、页面按钮、选区、复制/保存/贴图/滚动、取消、权限及禁用清理 |
160
+ | macOS 权限 | 自动化核对首次启用与重连检查、两个组件的请求/状态隔离、缺屏幕权限不启动蒙层及打字复制回退;真实系统弹窗、授权点击、重新授权与操作效果由用户人工验证 |
156
161
  | 包内容或安装入口 | `npm pack --dry-run` 检查文件列表;再打包安装,确认包含前端产物、宿主源码、patch、原生库及许可证,不包含 `work/` 等开发产物 |
157
162
  | ASR 服务连通性 | 按需运行 `npm run probe -- <设备SN>`;该命令访问真实 Token / WSS 服务,仅检查鉴权握手,不采集或发送音频 |
158
163
 
@@ -160,7 +165,7 @@ npm test
160
165
 
161
166
  ### 已有验证记录
162
167
 
163
- 以下汇总截至 2026-11-09 的历史记录,不代表每次提交均已通过。维护者已确认完成 0.1.0 的 README 实机验收;专项验证仍以表内范围为准,未记录的场景不推定通过。发布平台记录单独维护在 [CI/CD 规格](../specs/ci-cd.md#6-验收与平台状态)。
168
+ 以下表格为截至 2026-11-09 的历史记录,不代表每次提交均已通过;后续专项结果按日期列于表后。维护者已确认完成 0.1.0 的 README 实机验收;未记录的场景不推定通过。发布平台记录单独维护在 [CI/CD 规格](../specs/ci-cd.md#6-验收与平台状态)。
164
169
 
165
170
  | 范围 | 已验证 | 边界 |
166
171
  | --- | --- | --- |
@@ -171,7 +176,30 @@ npm test
171
176
  | 开发重载 | 隔离 profile 下同一 Host 进程替换后端、通知前端、重建 SDK;自动化覆盖失败保护、监听、恢复及退出清理 | 桌面实际重绘及 Windows 开发流程待验证 |
172
177
  | 语言与服务 | 语言范围曾核对官方文档;普通话、英语、日语、粤语、法语及普通话繁体通过合成音频抽样 | 其余语言、新鉴权与文本翻译实网链路待验证 |
173
178
 
174
- 专项待验证:BLE/2.4G 音频与尾音时序、DPI 固件映射、系统按键及辅助功能权限、Windows 原生浮层与真实鼠标链路。产品与硬件待确认事项见[插件规格第 8 节](../specs/smart-mouse-plugin.md#8-待确认与联调)。
179
+ 当时未完成的专项包括 BLE/2.4G 音频与尾音时序、DPI 固件映射、系统按键及辅助功能权限、Windows 原生浮层与真实鼠标链路;本次截图、授权和打字上屏的后续结果见下文。产品与硬件待确认事项见[插件规格第 8 节](../specs/smart-mouse-plugin.md#8-待确认与联调)。
180
+
181
+ #### 2026-11-20:截图集成与 macOS 授权
182
+
183
+ 本次改动:
184
+
185
+ - 接入 ScreenTool 1.2.2 的 Windows x64、macOS ARM64 独立截图进程,提供鼠标截图键和页面按钮;支持选区、标注、复制、保存、贴图及滚动截图,处理重复触发、失败和停用清理。
186
+ - 截图操作行移至页面底部。两端通过配置和原生补丁隐藏 OCR、图片翻译及滚动 OCR/Word 导出入口,保留滚动截图;未接入对应云服务。
187
+ - 仅 macOS 增加首次启用及重连时的权限检查与人工授权引导:screenhelper 申请屏幕录制及辅助功能,Sonicloud Voice 单独申请辅助功能。缺屏幕录制权限时不显示截图蒙层;缺辅助功能不阻止普通截图和手动滚动。Windows 不显示授权区域,原有截图和打字流程保持。
188
+ - macOS 两个组件完成 Developer ID 签名与严格验签,并修复跨平台打包丢失 Voice 执行位的问题。旧版 Voice 授权可能需要重新确认;本次未执行 Apple 公证。隐藏机制、构建及系统要求统一见[截图组件说明](../../native/screenshot/README.md)。
189
+
190
+ 验证结果:
191
+
192
+ | 范围 | 结果 | 依据与边界 |
193
+ | --- | --- | --- |
194
+ | Windows 本地 Harness | 截图、打字上屏人工验证通过 | 用户安装最新版后明确确认通过;安装检查确认 Voice 和鼠标 worker 已启动,授权接口返回 `supported: false`,宿主程序、原配置及其他插件依赖未改动 |
195
+ | macOS Harness | 授权引导及授权后使用人工确认可行 | 用户反馈“已经验证了,可行”;授权前检查另确认缺屏幕录制时拦截截图、不创建会话,Voice 执行位由 `0644` 恢复为 `0755`,两组件严格验签通过 |
196
+ | 两端安装 | 同一份 0.1.2 测试包安装成功 | 每端均校验 96 个包内文件;本地安装检查与用户人工验收分别记录 |
197
+ | JavaScript 自动化 | 164 通过、1 跳过、0 失败 | Windows 上运行 `npm test`;跳过项为需要 macOS Swift 工具链的平台测试 |
198
+ | 截图原生回归 | Windows 12 通过;macOS 20 通过,均无失败 | Windows 为入口显隐 4 项、配置 8 项;macOS 另含权限策略 8 项,计数包含 QtTest 初始化及清理 |
199
+
200
+ 交付包为 `sonicloud-dsh-sonicloud-device-0.1.2.tgz`,SHA-256:`840bc54eefa2d05bdf6d49b25c73cc42a53556efb669a4aae61f5b9ca9d040a6`。两端均已安装到 Harness 的 `desktop` profile;本次为本地测试交付,尚未正式发布。
201
+
202
+ 原始本地证据位于 `test-results/mac-permissions-2026-11-20/` 和 `test-results/windows-latest-install-2026-11-20/`,不入库。Mac 安装回执中的未授权状态是人工操作前的检查快照,不代表最终授权状态。用户反馈未逐项列出标注、保存、贴图、滚动截图、隐藏入口及各输入控件的独立用例,本记录不将其扩展为所有子场景逐项验收通过。
175
203
 
176
204
  ## 贡献流程
177
205
 
@@ -4,7 +4,7 @@
4
4
 
5
5
  目标宿主:DeepSeek Harness `0.2.1-rc.5`。包名:`@sonicloud/dsh-sonicloud-device`;插件 ID:`dsh-sonicloud-device`。当前版本以 `package.json` 为准。
6
6
 
7
- 接入通过 BLE 或 2.4G USB 接收器连接的智能鼠标,提供多设备设置、语音打字、翻译、搜索、DPI 与按键配置。设备模型预留其他类型的扩展能力。
7
+ 接入通过 BLE 或 2.4G USB 接收器连接的智能鼠标,提供多设备设置、语音打字、翻译、搜索、截图、DPI 与按键配置。设备模型预留其他类型的扩展能力。
8
8
 
9
9
  语音会话由插件后台管理,录音和识别不依赖 Harness 主界面、对话页或前端订阅。AI 键通过宿主前端创建对话和填充输入框,连接不可用时保留结果供复制。独立原生浮层显示中间结果;主窗口最小化或隐藏时仍可用,完全退出宿主后后台停止。不提供独立于宿主进程的安装程序。
10
10
 
@@ -36,6 +36,7 @@
36
36
  | 区域 | 要求 |
37
37
  | --- | --- |
38
38
  | 标题 | “声云设备”;说明为“N 台设备已连接 · 为每台设备设置专属偏好”,按已确认身份的在线设备去重计数。 |
39
+ | 截图 | 位于页面最底部,提供“开始截图”按钮,无设备时也可使用;按下后在启动响应前禁用按钮,失败使用统一提示。 |
39
40
  | 设备切换 | 显示图片、名称/颜色,使用左右箭头和位置指示点切换;单台时隐藏切换控件。 |
40
41
  | 基本信息 | 依次显示 SN、连接方式、电量;连接方式显示“蓝牙”或“USB 接收器”。 |
41
42
  | 无设备/离线 | 无设备时显示“暂无设备连接”及连接提示;当前设备离线后停止下发指令,允许切换其他在线设备。 |
@@ -99,6 +100,29 @@ Windows 回退:目标对话填充失败时,浮层保留完整识别文本并
99
100
 
100
101
  松开后完成识别并自动填充。“自动发送”开启时,通过目标输入组件的宿主发送接口提交追加语音后的完整草稿(含已有文字及附件),每次语音会话最多调用一次;关闭时保留草稿,不调用发送接口。开关默认值、存储与生效时机见[鼠标设置](mouse-settings.md#语音键与-ai-键)。空结果、取消、识别失败或填充失败均不发送;发送由宿主负责校验、排队和错误提示,插件不自动重试。
101
102
 
103
+ ### 3.5 截图
104
+
105
+ 鼠标截图键 `capture click/down` 和页面“开始截图”共用独立截图服务。一次物理按键只触发一次,忽略重复 `down`、`hold` 和随后的 `click/up`;截图不请求语音凭据、不启动或中断语音会话,也不依赖前端订阅。界面按钮无需设备在线。
106
+
107
+ 随包分发 Windows x64 和 macOS ARM64 的客户端库及独立 helper,按需启动;macOS 权限检查可提前连接 helper,但不显示截图界面。选区、标注、复制、保存、贴图和滚动截图由 helper 完成;插件不自动另存截图,也不接入 OCR、图片翻译和 Word 导出的云服务。截图忙碌、组件缺失、启动或连接失败通过统一提示反馈;禁用插件时关闭 helper 及贴图窗口。
108
+
109
+ Windows、macOS 使用同一原生补丁隐藏普通 OCR、图片翻译及滚动 OCR/Word 导出入口,保留滚动截图。配置、隐藏机制、构建与系统要求见[截图组件说明](../../native/screenshot/README.md)。
110
+
111
+ macOS 宿主与原生 helper 均在显示蒙层前检查屏幕录制权限;缺权限时回报状态并结束会话,不创建选区或抓屏。普通截图和手动滚动不因辅助功能未授权而被阻止。首次权限引导见第 3.6 节,真实系统弹窗和多屏滚动效果由用户人工验收。
112
+
113
+ ### 3.6 macOS 权限引导
114
+
115
+ 安装后首次启用和每次服务重连时,前端异步查询权限,不阻塞设备连接或自动申请系统授权;每次连接最多显示一次缺权提示。“声云设备”页面保留状态、对应授权按钮、重新检查及必要的组件位置,无鼠标时同样可用。
116
+
117
+ | 组件 | 权限边界 |
118
+ | --- | --- |
119
+ | Sonicloud Voice | 辅助功能用于桌面应用自动填入;未授权仍可识别并复制结果。 |
120
+ | screenhelper | 屏幕录制是截图必需权限;辅助功能仅用于可选的自动滚动。 |
121
+
122
+ 用户点击授权按钮后,由对应组件原生请求权限,并由用户在系统弹窗或设置中确认;请求受理不代表授权成功,不自动点击授权。查询失败保持未知状态并允许重试,重连或卸载后忽略迟到结果。截图权限重新检查仅在无活动截图、贴图时重启 helper;打字权限重新检查不强关活动语音。
123
+
124
+ Sonicloud Voice 已从旧版 ad-hoc 签名切换为 Developer ID。若系统列表已勾选而仍显示待授权,按系统提示重新授权并重启 Harness,再重新检查。具体操作统一见[用户指南](../../README.zh.md#macos-首次授权)。
125
+
102
126
  ## 4. 语音会话与输出
103
127
 
104
128
  ### 4.1 调度与流程
@@ -210,6 +234,8 @@ ASR 成功后请求一次,不翻译临时句。仅 HTTP 成功、`code=0` 且
210
234
  | AI 键 | 设置显示标题、规定说明及“自动发送”开关,无动作下拉框;默认开启,旧配置兼容、按设备保存及恢复默认正确;前台、后台、隐藏和最小化分别覆盖 AI 对话页与非对话页;对话页输入框有焦点、无焦点均填充当前对话且不新建;非对话页仅新建一个对话并填充;后台自动调至前台,不向其他应用或其他输入框写入;长按录音、松开收尾,重复事件不重复建对话、填充或发送;开启时填充后发送一次,关闭时仅保留草稿;空结果、取消及失败不误填充或发送。 |
211
235
  | 翻译 | 语言映射、成功译文、空译文、超长、同源/目标语言及失败;不误回填原文。 |
212
236
  | 按键与 DPI | 全部 M 键动作、AI 键、设备定向下发及失败提示;搜索覆盖三个引擎和中文、空格、`&`、`#`;无输入框可搜索/打开链接。 |
237
+ | 截图 | 无设备界面按钮、前台/后台截图键、重复 down/click/up、选区/标注/复制/保存/贴图/滚动、Esc 取消、缺依赖及权限失败、helper 重启、禁用关闭贴图;缺屏幕录制权限时不显示蒙层,不启动或中断语音会话。 |
238
+ | macOS 授权 | 首次启用提示、两类组件状态和授权入口、请求成功不伪报已授权、重新检查、失联/卸载迟到结果隔离;实际系统确认、旧签名重新授权及授权后截图/打字由用户人工验收。 |
213
239
  | Token | 按 SN 隔离、缓存/过期、并发刷新、无效响应、业务失败;首次失效无感恢复,刷新或重试失败仅在独立浮层提示一次。 |
214
240
  | 异常与迁移 | 断网、超时、掉线、通道中断及禁用释放资源;重试不丢音频、不重复输出;旧凭据清理且 Token 不落盘。 |
215
241
  | 平台 | 主窗口最小化/隐藏、前端断开后仍显示预览;多屏工作区定位、不抢焦点、取消及清理;跨应用安全回填与权限不足复制回退;SDK、蓝牙、USB 和多设备。 |
@@ -225,4 +251,8 @@ ASR 成功后请求一次,不翻译临时句。仅 HTTP 成功、`code=0` 且
225
251
 
226
252
  截至 2026-11-12,已实现设备设置与偏好持久化、SDK 接入、后台单语音会话、M/AI 键动作、DPI 同步、桌面浮层、系统输入框回填、侧边栏声云设备面板、Windows typer.dll 会话式逐字注入(实时更正、不动剪贴板)、AI 键唤回加固(还原最小化窗口、托盘隐藏时二次启动还原)及填充失败的“一键提交”回退。真机已验证 AI 键目标对话填充、自动发送与最小化/托盘唤回;Windows 逐字注入清单(实时出字、翻译终稿、取消、提权、剪贴板、密码框)批量验收待完成。
227
253
 
254
+ 2026-11-20 新增截图服务接入、鼠标截图键和页面按钮,截图行移至页面底部。两端 helper 均已重建,隐藏 OCR、图片翻译及 Word 导出入口,保留滚动截图;本次不接入对应云服务。macOS 增加截图与打字权限引导、截图双层权限前检,完成两组件 Developer ID 签名及执行位修复;授权引导仅在 macOS 显示,Windows 原有流程保持。
255
+
256
+ 两端已安装同一份 0.1.2 测试包。用户已确认 macOS 授权引导及授权后使用可行,Windows 截图与打字上屏人工验证通过;自动化、安装校验及人工反馈的具体范围统一记录于[开发说明](../contributing/development.md#已有验证记录),不将整体反馈视为所有子场景逐项通过。本次尚未正式发布。
257
+
228
258
  历史验证和具体边界统一见[开发说明](../contributing/development.md#已有验证记录),发布平台记录见[CI/CD 规格](ci-cd.md#6-验收与平台状态)。自动化通过不代表全部实机和实网场景已验收;第 7 节列出验收要求,第 8 节保留待确认事项。
package/native/README.md CHANGED
@@ -13,3 +13,7 @@
13
13
  ## 桌面语音组件
14
14
 
15
15
  `desktop/` 是本项目维护的原生浮层及输入框回填实现,不属于上游鼠标 SDK。macOS ARM64 可执行文件由同目录 Swift 源码构建;Windows 源码由系统 PowerShell 加载。构建、权限和验证范围见[开发说明](../docs/contributing/development.md#桌面语音浮层)。
16
+
17
+ ## 截图组件
18
+
19
+ `screenshot/` 随包提供 ScreenTool 1.2.2 客户端与独立截图进程,支持 Windows x64 和 macOS ARM64。来源、部署与权限见[截图组件说明](screenshot/README.md)。
@@ -0,0 +1,16 @@
1
+ {
2
+ "platform": "darwin-arm64",
3
+ "source": "VoicePanel.swift",
4
+ "sourceSha256": "973e8283174f65b08363d1df6081eaa30c63b9b2e3a4879ec69885ffb2210612",
5
+ "policy": "CompatibilityPolicy.swift",
6
+ "policySha256": "70a2427f52f61c061c2a41ed9f33030d25842cb7e65ee8d1cda3fa47527f3e5e",
7
+ "binary": "darwin-arm64/Sonicloud Voice.app/Contents/MacOS/sonicloud-voice",
8
+ "binarySha256": "c9584df2b7139bb80c741c4bae32ad977191ba756cd6cbeccd848e266b809329",
9
+ "bundleId": "com.sonicloud.voice-panel",
10
+ "teamId": "F3TYM6YPF7",
11
+ "codesignVerified": true,
12
+ "permissions": [
13
+ "accessibility"
14
+ ],
15
+ "previousSignature": "ad-hoc"
16
+ }
@@ -268,6 +268,33 @@ final class VoiceUI: NSObject {
268
268
  }
269
269
  func handle(_ command: [String: Any]) {
270
270
  let name = command["command"] as? String ?? ""
271
+ if name == "permissions" {
272
+ let action = command["action"] as? String ?? "check"
273
+ guard ["check", "refresh", "accessibility"].contains(action) else {
274
+ if let id = command["id"] { emit(["id": id, "ok": false, "message": "不支持此打字权限操作"]) }
275
+ return
276
+ }
277
+ if action == "accessibility" {
278
+ guard !active && !resultPending else {
279
+ if let id = command["id"] { emit(["id": id, "ok": false, "message": "请先结束语音输入,再设置打字权限"]) }
280
+ return
281
+ }
282
+ if !AXIsProcessTrusted() {
283
+ hide()
284
+ let options = [kAXTrustedCheckOptionPrompt.takeUnretainedValue() as String: true] as CFDictionary
285
+ _ = AXIsProcessTrustedWithOptions(options)
286
+ if let settings = URL(string: "x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility") {
287
+ NSWorkspace.shared.open(settings)
288
+ }
289
+ }
290
+ }
291
+ let helperApp = Bundle.main.bundlePath.hasSuffix(".app") ? Bundle.main.bundlePath
292
+ : URL(fileURLWithPath: CommandLine.arguments[0]).deletingLastPathComponent().deletingLastPathComponent().deletingLastPathComponent().path
293
+ if let id = command["id"] {
294
+ emit(["id": id, "ok": true, "value": ["supported": true, "accessibility": AXIsProcessTrusted(), "helperApp": helperApp]])
295
+ }
296
+ return
297
+ }
271
298
  let incoming = command["sessionId"] as? String ?? ""
272
299
  var success = true
273
300
  let inserted = false