@sonicloud/dsh-sonicloud-device 0.1.3 → 0.1.5

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 (74) hide show
  1. package/CHANGELOG.md +37 -1
  2. package/CHANGELOG.zh.md +37 -1
  3. package/README.md +18 -14
  4. package/README.zh.md +9 -5
  5. package/dist/build.json +1 -1
  6. package/dist/client.js +2112 -120
  7. package/docs/contributing/development.md +7 -5
  8. package/docs/specs/ci-cd.md +5 -4
  9. package/docs/specs/mouse-settings.md +1 -1
  10. package/docs/specs/multilingual.md +98 -0
  11. package/docs/specs/smart-mouse-plugin.md +6 -3
  12. package/locale/de.json +7 -0
  13. package/locale/en.json +7 -0
  14. package/locale/es.json +7 -0
  15. package/locale/fr.json +7 -0
  16. package/locale/ja.json +7 -0
  17. package/locale/pt.json +7 -0
  18. package/locale/ru.json +7 -0
  19. package/locale/zh.json +7 -0
  20. package/native/desktop/VOICE_SOURCE.json +2 -2
  21. package/native/desktop/VoicePanel.cs +70 -33
  22. package/native/desktop/VoicePanel.swift +58 -21
  23. package/native/desktop/darwin-arm64/Sonicloud Voice.app/Contents/MacOS/sonicloud-voice +0 -0
  24. package/native/screenshot/README.md +9 -4
  25. package/native/screenshot/SOURCE.json +48 -17
  26. package/native/screenshot/darwin-arm64/screentool-macos-1.2.2.zip +0 -0
  27. package/native/screenshot/helper-i18n/de.json +85 -0
  28. package/native/screenshot/helper-i18n/es.json +85 -0
  29. package/native/screenshot/helper-i18n/fr.json +85 -0
  30. package/native/screenshot/patches/{hide-cloud-actions.patch → macos/hide-cloud-actions.patch} +84 -76
  31. package/native/screenshot/patches/macos/mac-clang-compat.patch +14 -0
  32. package/native/screenshot/patches/macos/mac-color-panel.patch +40 -0
  33. package/native/screenshot/patches/macos/mac-permissions.patch +549 -0
  34. package/native/screenshot/patches/macos/mac-ui-focus.patch +658 -0
  35. package/native/screenshot/patches/macos/upstream-files.json +77 -0
  36. package/native/screenshot/patches/upstream-files.json +12 -8
  37. package/native/screenshot/win32-x64/i18n/de.json +85 -0
  38. package/native/screenshot/win32-x64/i18n/es.json +85 -0
  39. package/native/screenshot/win32-x64/i18n/fr.json +85 -0
  40. package/native/screenshot/win32-x64/screenhelper.exe +0 -0
  41. package/package.json +5 -3
  42. package/src/asr/auth.mjs +9 -8
  43. package/src/asr/config.mjs +1 -1
  44. package/src/asr/stream.mjs +25 -24
  45. package/src/desktop/presentation.mjs +18 -12
  46. package/src/desktop/screenshot-shortcut-worker.mjs +188 -0
  47. package/src/desktop/screenshot-shortcut.mjs +266 -0
  48. package/src/desktop/screenshot-worker.mjs +49 -32
  49. package/src/desktop/screenshot.mjs +46 -26
  50. package/src/devices/actions.mjs +7 -6
  51. package/src/devices/config.mjs +2 -1
  52. package/src/devices/diagnostics.mjs +4 -3
  53. package/src/devices/manager.mjs +77 -43
  54. package/src/devices/native-worker.mjs +4 -3
  55. package/src/devices/native.mjs +9 -8
  56. package/src/devices/queue.mjs +4 -3
  57. package/src/devices/recognition.mjs +5 -4
  58. package/src/devices/store.mjs +3 -2
  59. package/src/devices/translate.mjs +11 -10
  60. package/src/host/ai-conversation.mjs +8 -7
  61. package/src/host/index.mjs +13 -3
  62. package/src/host/locale.mjs +44 -0
  63. package/src/shared/devices.mjs +13 -12
  64. package/src/shared/i18n.mjs +47 -0
  65. package/src/shared/locales/de.json +181 -0
  66. package/src/shared/locales/en.json +181 -0
  67. package/src/shared/locales/es.json +181 -0
  68. package/src/shared/locales/fr.json +181 -0
  69. package/src/shared/locales/ja.json +181 -0
  70. package/src/shared/locales/pt.json +181 -0
  71. package/src/shared/locales/ru.json +181 -0
  72. package/src/shared/locales/zh.json +181 -0
  73. package/src/shared/remote.mjs +7 -1
  74. package/src/shared/screenshot-shortcut.mjs +50 -0
@@ -0,0 +1,50 @@
1
+ import { z } from 'zod';
2
+ import { message as msg } from './i18n.mjs';
3
+
4
+ const modifierOrder = ['Control', 'Alt', 'Shift', 'Meta'];
5
+ const namedKeys = ['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown', 'Home', 'End', 'PageUp', 'PageDown',
6
+ 'Insert', 'Delete', 'Backspace', 'Space', 'Tab', 'Enter', 'Escape'];
7
+ export const shortcutBindingSchema = z.object({
8
+ code: z.string().refine(code => /^(?:Key[A-Z]|Digit[0-9]|F(?:[1-9]|10|11))$/.test(code) || namedKeys.includes(code)),
9
+ modifiers: z.array(z.enum(modifierOrder)).min(1).max(4).refine(value => new Set(value).size === value.length),
10
+ }).strict();
11
+ export const shortcutStateSchema = z.object({
12
+ supported: z.boolean(), platform: z.enum(['win32', 'darwin', 'other']),
13
+ binding: shortcutBindingSchema.nullable(), registered: z.boolean(), error: z.string().max(4096),
14
+ }).strict();
15
+
16
+ export function normalizeShortcut(input, platform) {
17
+ if (input === null) return null;
18
+ const result = shortcutBindingSchema.safeParse(input);
19
+ if (!result.success || !['win32', 'darwin'].includes(platform)) throw new Error(msg('shortcut.invalid'));
20
+ const { code } = result.data;
21
+ const modifiers = modifierOrder.filter(modifier => result.data.modifiers.includes(modifier));
22
+ const has = modifier => modifiers.includes(modifier);
23
+ if (!has('Control') && !has('Alt') && !has('Meta')) throw new Error(msg('shortcut.invalid'));
24
+ if (platform === 'win32' && (has('Meta') || (has('Alt') && ['Tab', 'Escape', 'F4'].includes(code))
25
+ || (has('Control') && code === 'Escape') || (has('Control') && has('Alt') && code === 'Delete')))
26
+ throw new Error(msg('shortcut.invalid'));
27
+ if (platform === 'darwin' && has('Meta') && (['Tab', 'Space'].includes(code)
28
+ || (has('Alt') && code === 'Escape') || (!has('Alt') && ['KeyQ', 'KeyH'].includes(code))))
29
+ throw new Error(msg('shortcut.invalid'));
30
+ return { code, modifiers };
31
+ }
32
+
33
+ export function bindingFromEvent(event, platform) {
34
+ if (!event || event.isComposing || event.repeat || event.getModifierState?.('AltGraph'))
35
+ throw new Error(msg('shortcut.invalid'));
36
+ return normalizeShortcut({ code: event.code, modifiers: modifierOrder.filter(modifier => ({
37
+ Control: event.ctrlKey, Alt: event.altKey, Shift: event.shiftKey, Meta: event.metaKey,
38
+ })[modifier]) }, platform);
39
+ }
40
+
41
+ export function formatShortcut(binding, platform) {
42
+ if (!binding) return '';
43
+ const value = normalizeShortcut(binding, platform);
44
+ const labels = platform === 'darwin' ? { Control: '⌃', Alt: '⌥', Shift: '⇧', Meta: '⌘' }
45
+ : { Control: 'Ctrl', Alt: 'Alt', Shift: 'Shift', Meta: 'Win' };
46
+ const keys = { ArrowLeft: '←', ArrowRight: '→', ArrowUp: '↑', ArrowDown: '↓', Escape: 'Esc',
47
+ Backspace: 'Backspace', Space: 'Space', PageUp: 'PageUp', PageDown: 'PageDown' };
48
+ const key = /^(?:Key|Digit)/.test(value.code) ? value.code.replace(/^(?:Key|Digit)/, '') : keys[value.code] ?? value.code;
49
+ return [...value.modifiers.map(modifier => labels[modifier]), key].join(platform === 'darwin' ? ' ' : ' + ');
50
+ }