@corti/dictation-web 0.4.0-rc.2 → 0.5.0-rc

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 (189) hide show
  1. package/README.md +53 -3
  2. package/dist/bundle.js +795 -152
  3. package/dist/components/corti-dictation.d.ts +15 -1
  4. package/dist/components/corti-dictation.js +35 -0
  5. package/dist/components/corti-dictation.js.map +1 -1
  6. package/dist/components/device-selector.d.ts +1 -1
  7. package/dist/components/keybinding-selector.d.ts +14 -0
  8. package/dist/components/keybinding-selector.js +82 -0
  9. package/dist/components/keybinding-selector.js.map +1 -0
  10. package/dist/components/language-selector.d.ts +1 -1
  11. package/dist/components/mode-selector.d.ts +14 -0
  12. package/dist/components/mode-selector.js +73 -0
  13. package/dist/components/mode-selector.js.map +1 -0
  14. package/dist/components/recording-button.d.ts +5 -2
  15. package/dist/components/recording-button.js +83 -17
  16. package/dist/components/recording-button.js.map +1 -1
  17. package/dist/components/settings-menu.d.ts +2 -0
  18. package/dist/components/settings-menu.js +20 -0
  19. package/dist/components/settings-menu.js.map +1 -1
  20. package/dist/contexts/dictation-context.d.ts +9 -1
  21. package/dist/contexts/dictation-context.js +35 -2
  22. package/dist/contexts/dictation-context.js.map +1 -1
  23. package/dist/controllers/dictation-controller.d.ts +2 -1
  24. package/dist/controllers/dictation-controller.js +53 -19
  25. package/dist/controllers/dictation-controller.js.map +1 -1
  26. package/dist/controllers/keybinding-controller.d.ts +18 -0
  27. package/dist/controllers/keybinding-controller.js +86 -0
  28. package/dist/controllers/keybinding-controller.js.map +1 -0
  29. package/dist/index.d.ts +4 -2
  30. package/dist/index.js +10 -0
  31. package/dist/index.js.map +1 -1
  32. package/dist/package.json +87 -7
  33. package/dist/styles/component-styles.d.ts +1 -0
  34. package/dist/styles/component-styles.js +10 -0
  35. package/dist/styles/component-styles.js.map +1 -1
  36. package/dist/styles/keybinding-selector.d.ts +2 -0
  37. package/dist/styles/keybinding-selector.js +72 -0
  38. package/dist/styles/keybinding-selector.js.map +1 -0
  39. package/dist/styles/mode-selector.d.ts +2 -0
  40. package/dist/styles/mode-selector.js +56 -0
  41. package/dist/styles/mode-selector.js.map +1 -0
  42. package/dist/styles/select.d.ts +1 -1
  43. package/dist/styles/select.js +6 -10
  44. package/dist/styles/select.js.map +1 -1
  45. package/dist/styles/settings-menu.js +9 -1
  46. package/dist/styles/settings-menu.js.map +1 -1
  47. package/dist/tsconfig.tsbuildinfo +1 -0
  48. package/dist/types.d.ts +3 -1
  49. package/dist/types.js.map +1 -1
  50. package/dist/utils/events.d.ts +14 -1
  51. package/dist/utils/events.js +22 -0
  52. package/dist/utils/events.js.map +1 -1
  53. package/dist/utils/keybinding.d.ts +36 -0
  54. package/dist/utils/keybinding.js +125 -0
  55. package/dist/utils/keybinding.js.map +1 -0
  56. package/package.json +2 -2
  57. package/dist/CortiDictation.d.ts +0 -55
  58. package/dist/CortiDictation.js +0 -303
  59. package/dist/CortiDictation.js.map +0 -1
  60. package/dist/DictationService.d.ts +0 -16
  61. package/dist/DictationService.js +0 -88
  62. package/dist/DictationService.js.map +0 -1
  63. package/dist/RecorderManager.d.ts +0 -25
  64. package/dist/RecorderManager.js +0 -145
  65. package/dist/RecorderManager.js.map +0 -1
  66. package/dist/audioService.d.ts +0 -6
  67. package/dist/audioService.js +0 -21
  68. package/dist/audioService.js.map +0 -1
  69. package/dist/controllers/DictationController.d.ts +0 -35
  70. package/dist/controllers/DictationController.js +0 -130
  71. package/dist/controllers/DictationController.js.map +0 -1
  72. package/dist/controllers/MediaController.d.ts +0 -31
  73. package/dist/controllers/MediaController.js +0 -99
  74. package/dist/controllers/MediaController.js.map +0 -1
  75. package/dist/src/components/audio-visualiser.d.ts +0 -14
  76. package/dist/src/components/audio-visualiser.js +0 -57
  77. package/dist/src/components/audio-visualiser.js.map +0 -1
  78. package/dist/src/components/corti-dictation.d.ts +0 -123
  79. package/dist/src/components/corti-dictation.js +0 -224
  80. package/dist/src/components/corti-dictation.js.map +0 -1
  81. package/dist/src/components/device-selector.d.ts +0 -24
  82. package/dist/src/components/device-selector.js +0 -106
  83. package/dist/src/components/device-selector.js.map +0 -1
  84. package/dist/src/components/language-selector.d.ts +0 -24
  85. package/dist/src/components/language-selector.js +0 -100
  86. package/dist/src/components/language-selector.js.map +0 -1
  87. package/dist/src/components/recording-button.d.ts +0 -37
  88. package/dist/src/components/recording-button.js +0 -203
  89. package/dist/src/components/recording-button.js.map +0 -1
  90. package/dist/src/components/settings-menu.d.ts +0 -16
  91. package/dist/src/components/settings-menu.js +0 -80
  92. package/dist/src/components/settings-menu.js.map +0 -1
  93. package/dist/src/constants.d.ts +0 -4
  94. package/dist/src/constants.js +0 -37
  95. package/dist/src/constants.js.map +0 -1
  96. package/dist/src/contexts/dictation-context.d.ts +0 -97
  97. package/dist/src/contexts/dictation-context.js +0 -208
  98. package/dist/src/contexts/dictation-context.js.map +0 -1
  99. package/dist/src/controllers/DictationController.d.ts +0 -35
  100. package/dist/src/controllers/DictationController.js +0 -130
  101. package/dist/src/controllers/DictationController.js.map +0 -1
  102. package/dist/src/controllers/MediaController.d.ts +0 -31
  103. package/dist/src/controllers/MediaController.js +0 -99
  104. package/dist/src/controllers/MediaController.js.map +0 -1
  105. package/dist/src/icons/icons.d.ts +0 -17
  106. package/dist/src/icons/icons.js +0 -158
  107. package/dist/src/icons/icons.js.map +0 -1
  108. package/dist/src/styles/ComponentStyles.d.ts +0 -2
  109. package/dist/src/styles/ComponentStyles.js +0 -18
  110. package/dist/src/styles/ComponentStyles.js.map +0 -1
  111. package/dist/src/styles/audio-visualiser.d.ts +0 -2
  112. package/dist/src/styles/audio-visualiser.js +0 -33
  113. package/dist/src/styles/audio-visualiser.js.map +0 -1
  114. package/dist/src/styles/buttons.d.ts +0 -2
  115. package/dist/src/styles/buttons.js +0 -52
  116. package/dist/src/styles/buttons.js.map +0 -1
  117. package/dist/src/styles/callout.d.ts +0 -2
  118. package/dist/src/styles/callout.js +0 -23
  119. package/dist/src/styles/callout.js.map +0 -1
  120. package/dist/src/styles/default-theme.d.ts +0 -2
  121. package/dist/src/styles/default-theme.js +0 -50
  122. package/dist/src/styles/default-theme.js.map +0 -1
  123. package/dist/src/styles/recording-button.d.ts +0 -2
  124. package/dist/src/styles/recording-button.js +0 -8
  125. package/dist/src/styles/recording-button.js.map +0 -1
  126. package/dist/src/styles/select.d.ts +0 -2
  127. package/dist/src/styles/select.js +0 -36
  128. package/dist/src/styles/select.js.map +0 -1
  129. package/dist/src/styles/settings-menu.d.ts +0 -2
  130. package/dist/src/styles/settings-menu.js +0 -34
  131. package/dist/src/styles/settings-menu.js.map +0 -1
  132. package/dist/src/types.d.ts +0 -7
  133. package/dist/src/types.js +0 -2
  134. package/dist/src/types.js.map +0 -1
  135. package/dist/src/utils/auth.d.ts +0 -9
  136. package/dist/src/utils/auth.js +0 -21
  137. package/dist/src/utils/auth.js.map +0 -1
  138. package/dist/src/utils/converters.d.ts +0 -4
  139. package/dist/src/utils/converters.js +0 -8
  140. package/dist/src/utils/converters.js.map +0 -1
  141. package/dist/src/utils/devices.d.ts +0 -26
  142. package/dist/src/utils/devices.js +0 -53
  143. package/dist/src/utils/devices.js.map +0 -1
  144. package/dist/src/utils/events.d.ts +0 -44
  145. package/dist/src/utils/events.js +0 -88
  146. package/dist/src/utils/events.js.map +0 -1
  147. package/dist/src/utils/languages.d.ts +0 -7
  148. package/dist/src/utils/languages.js +0 -29
  149. package/dist/src/utils/languages.js.map +0 -1
  150. package/dist/src/utils/media.d.ts +0 -6
  151. package/dist/src/utils/media.js +0 -39
  152. package/dist/src/utils/media.js.map +0 -1
  153. package/dist/src/utils/token.d.ts +0 -13
  154. package/dist/src/utils/token.js +0 -60
  155. package/dist/src/utils/token.js.map +0 -1
  156. package/dist/src/utils/validation.d.ts +0 -1
  157. package/dist/src/utils/validation.js +0 -7
  158. package/dist/src/utils/validation.js.map +0 -1
  159. package/dist/stories/audio-visualiser.stories.d.ts +0 -39
  160. package/dist/stories/audio-visualiser.stories.js +0 -71
  161. package/dist/stories/audio-visualiser.stories.js.map +0 -1
  162. package/dist/stories/corti-dictation.stories.d.ts +0 -27
  163. package/dist/stories/corti-dictation.stories.js +0 -129
  164. package/dist/stories/corti-dictation.stories.js.map +0 -1
  165. package/dist/stories/device-selector.stories.d.ts +0 -18
  166. package/dist/stories/device-selector.stories.js +0 -84
  167. package/dist/stories/device-selector.stories.js.map +0 -1
  168. package/dist/stories/language-selector.stories.d.ts +0 -18
  169. package/dist/stories/language-selector.stories.js +0 -53
  170. package/dist/stories/language-selector.stories.js.map +0 -1
  171. package/dist/stories/recording-button.stories.d.ts +0 -27
  172. package/dist/stories/recording-button.stories.js +0 -90
  173. package/dist/stories/recording-button.stories.js.map +0 -1
  174. package/dist/stories/settings-menu.stories.d.ts +0 -23
  175. package/dist/stories/settings-menu.stories.js +0 -156
  176. package/dist/stories/settings-menu.stories.js.map +0 -1
  177. package/dist/styles/ComponentStyles.d.ts +0 -2
  178. package/dist/styles/ComponentStyles.js +0 -18
  179. package/dist/styles/ComponentStyles.js.map +0 -1
  180. package/dist/styles/default-theme.d.ts +0 -2
  181. package/dist/styles/default-theme.js +0 -14
  182. package/dist/styles/default-theme.js.map +0 -1
  183. package/dist/styles/theme.d.ts +0 -2
  184. package/dist/styles/theme.js +0 -56
  185. package/dist/styles/theme.js.map +0 -1
  186. package/dist/tsconfig.stories.tsbuildinfo +0 -1
  187. package/dist/utils.d.ts +0 -59
  188. package/dist/utils.js +0 -179
  189. package/dist/utils.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  import type { Corti } from "@corti/sdk";
2
2
  import { LitElement } from "lit";
3
- import type { ConfigurableSettings, ProxyOptions, RecordingState } from "../types.js";
3
+ import type { ConfigurableSettings, DictationMode, ProxyOptions, RecordingState } from "../types.js";
4
4
  import "../contexts/dictation-context.js";
5
5
  import "./recording-button.js";
6
6
  import "./settings-menu.js";
@@ -69,6 +69,20 @@ export declare class CortiDictation extends LitElement {
69
69
  * Current state of recording (stopped, recording, initializing and stopping, ).
70
70
  */
71
71
  get recordingState(): RecordingState;
72
+ /**
73
+ * Dictation mode: "toggle-to-talk" or "push-to-talk"
74
+ */
75
+ set mode(value: DictationMode);
76
+ get mode(): DictationMode;
77
+ _mode?: DictationMode;
78
+ /**
79
+ * Keybinding for keyboard shortcut. Single key only (e.g., "`", "k", "meta", "ctrl").
80
+ * Combinations with "+" are not supported.
81
+ * Defaults to "`" if keybinding is in settingsEnabled, otherwise undefined
82
+ */
83
+ set keybinding(value: string | null | undefined);
84
+ get keybinding(): string | null | undefined;
85
+ _keybinding?: string | null;
72
86
  /**
73
87
  * Set the latest access token.
74
88
  * @returns ServerConfig with environment, tenant, and accessToken
@@ -45,6 +45,7 @@ let CortiDictation = class CortiDictation extends LitElement {
45
45
  */
46
46
  this.debug_displayAudio = false;
47
47
  this._dictationConfig = DEFAULT_DICTATION_CONFIG;
48
+ this._mode = "toggle-to-talk";
48
49
  }
49
50
  /**
50
51
  * List of all language codes available for use with the Web Component.
@@ -91,6 +92,26 @@ let CortiDictation = class CortiDictation extends LitElement {
91
92
  get recordingState() {
92
93
  return __classPrivateFieldGet(this, _CortiDictation_contextProviderRef, "f").value?.recordingState || "stopped";
93
94
  }
95
+ /**
96
+ * Dictation mode: "toggle-to-talk" or "push-to-talk"
97
+ */
98
+ set mode(value) {
99
+ this._mode = value;
100
+ }
101
+ get mode() {
102
+ return (__classPrivateFieldGet(this, _CortiDictation_contextProviderRef, "f").value?.mode || this._mode || "toggle-to-talk");
103
+ }
104
+ /**
105
+ * Keybinding for keyboard shortcut. Single key only (e.g., "`", "k", "meta", "ctrl").
106
+ * Combinations with "+" are not supported.
107
+ * Defaults to "`" if keybinding is in settingsEnabled, otherwise undefined
108
+ */
109
+ set keybinding(value) {
110
+ this._keybinding = value;
111
+ }
112
+ get keybinding() {
113
+ return __classPrivateFieldGet(this, _CortiDictation_contextProviderRef, "f").value?.keybinding || this._keybinding;
114
+ }
94
115
  // ─────────────────────────────────────────────────────────────────────────────
95
116
  // Public methods
96
117
  // ─────────────────────────────────────────────────────────────────────────────
@@ -159,6 +180,8 @@ let CortiDictation = class CortiDictation extends LitElement {
159
180
  .devices=${this._devices}
160
181
  .selectedDevice=${this._selectedDevice}
161
182
  .debug_displayAudio=${this.debug_displayAudio}
183
+ .mode=${this._mode}
184
+ .keybinding=${this._keybinding}
162
185
  >
163
186
  <dictation-recording-button
164
187
  ${ref(__classPrivateFieldGet(this, _CortiDictation_recordingButtonRef, "f"))}
@@ -231,6 +254,18 @@ __decorate([
231
254
  __decorate([
232
255
  state()
233
256
  ], CortiDictation.prototype, "_selectedDevice", void 0);
257
+ __decorate([
258
+ property({ type: String })
259
+ ], CortiDictation.prototype, "mode", null);
260
+ __decorate([
261
+ state()
262
+ ], CortiDictation.prototype, "_mode", void 0);
263
+ __decorate([
264
+ property({ type: String })
265
+ ], CortiDictation.prototype, "keybinding", null);
266
+ __decorate([
267
+ state()
268
+ ], CortiDictation.prototype, "_keybinding", void 0);
234
269
  CortiDictation = __decorate([
235
270
  customElement("corti-dictation")
236
271
  ], CortiDictation);
@@ -1 +1 @@
1
- {"version":3,"file":"corti-dictation.js","sourceRoot":"","sources":["../../src/components/corti-dictation.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,SAAS,EAAY,GAAG,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAO3D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAGjE,OAAO,kCAAkC,CAAC;AAC1C,OAAO,uBAAuB,CAAC;AAC/B,OAAO,oBAAoB,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QAClC,IAAI,EAAE,KAAK;KACZ,CAAC;uDAC+D;AAQjE;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;wDACM;AAOlC;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,qBAAqB,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;0DAC1B;AAMpC;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;qDAG5C;AASD;IADC,KAAK,EAAE;wDAC4D;AAMpE;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;6CAG3C;AAOD;IADC,KAAK,EAAE;gDACqB;AAM7B;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;oDAG5C;AASD;IADC,KAAK,EAAE;uDAC0B;AA3IvB,cAAc;IAD1B,aAAa,CAAC,iBAAiB,CAAC;GACpB,cAAc,CAsP1B","sourcesContent":["import type { Corti } from \"@corti/sdk\";\nimport { css, html, LitElement, nothing } from \"lit\";\nimport { customElement, property, state } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport { createRef, type Ref, ref } from \"lit/directives/ref.js\";\nimport { DEFAULT_DICTATION_CONFIG } from \"../constants.js\";\nimport type { DictationRoot } from \"../contexts/dictation-context.js\";\nimport type {\n ConfigurableSettings,\n ProxyOptions,\n RecordingState,\n} from \"../types.js\";\nimport { commaSeparatedConverter } from \"../utils/converters.js\";\nimport type { DictationRecordingButton } from \"./recording-button.js\";\n\nimport \"../contexts/dictation-context.js\";\nimport \"./recording-button.js\";\nimport \"./settings-menu.js\";\n\n@customElement(\"corti-dictation\")\nexport class CortiDictation extends LitElement {\n static styles = css`\n .hidden {\n display: none;\n }\n `;\n // ─────────────────────────────────────────────────────────────────────────────\n // Private refs\n // ─────────────────────────────────────────────────────────────────────────────\n\n #recordingButtonRef: Ref<DictationRecordingButton> = createRef();\n #contextProviderRef: Ref<DictationRoot> = createRef();\n\n // ─────────────────────────────────────────────────────────────────────────────\n // Properties\n // ─────────────────────────────────────────────────────────────────────────────\n\n /**\n * Latest access token\n */\n @property({ type: String })\n accessToken?: string;\n\n /**\n * Authentication configuration with optional refresh mechanism.\n */\n @property({ attribute: false, type: Object })\n authConfig?: Corti.BearerOptions;\n\n /**\n * WebSocket URL for proxy connection. When provided, uses CortiWebSocketProxyClient instead of CortiClient.\n */\n @property({ type: String })\n socketUrl?: string;\n\n /**\n * Socket proxy configuration object. When provided, uses CortiWebSocketProxyClient instead of CortiClient.\n */\n @property({ attribute: false, type: Object })\n socketProxy?: ProxyOptions;\n\n /**\n * List of all language codes available for use with the Web Component.\n * Default list depends on the accessToken\n */\n @property({\n converter: commaSeparatedConverter,\n type: Array,\n })\n set languagesSupported(value:\n | Corti.TranscribeSupportedLanguage[]\n | undefined) {\n this._languagesSupported = value;\n }\n\n get languagesSupported(): Corti.TranscribeSupportedLanguage[] {\n return (\n this.#contextProviderRef.value?.languages ||\n this._languagesSupported ||\n []\n );\n }\n\n @state()\n _languagesSupported?: Corti.TranscribeSupportedLanguage[];\n\n /**\n * Which settings should be available in the UI.\n * If an empty array is passed, the settings will be disabled entirely.\n * Options are language and devices\n */\n @property({\n converter: commaSeparatedConverter,\n type: Array,\n })\n settingsEnabled: ConfigurableSettings[] = [\"device\", \"language\"];\n\n /**\n * When false (default), allows the start/stop button from taking focus when clicked,\n * disabling textareas or other input elements to maintain focus.\n * Set to \"true\" to allow the button to receive focus on click.\n */\n @property({ type: Boolean })\n allowButtonFocus: boolean = false;\n\n /**\n * Overrides any device selection and instead uses getDisplayMedia to stream system audio.\n * Should only be used for debugging.\n */\n @property({ attribute: \"debug-display-audio\", type: Boolean })\n debug_displayAudio: boolean = false;\n\n /**\n * Configuration settings for dictation\n */\n @property({ attribute: false, type: Object })\n set dictationConfig(value: Corti.TranscribeConfig) {\n this._dictationConfig = value;\n }\n\n get dictationConfig(): Corti.TranscribeConfig {\n return (\n this.#contextProviderRef.value?.dictationConfig || this._dictationConfig\n );\n }\n\n @state()\n _dictationConfig: Corti.TranscribeConfig = DEFAULT_DICTATION_CONFIG;\n\n /**\n * List of available recording devices\n */\n @property({ attribute: false, type: Array })\n set devices(value: MediaDeviceInfo[] | undefined) {\n this._devices = value;\n }\n\n get devices(): MediaDeviceInfo[] {\n return this.#contextProviderRef.value?.devices || this._devices || [];\n }\n\n @state()\n _devices?: MediaDeviceInfo[];\n\n /**\n * The selected device used for recording (MediaDeviceInfo).\n */\n @property({ attribute: false, type: Object })\n set selectedDevice(value: MediaDeviceInfo | undefined) {\n this._selectedDevice = value;\n }\n\n get selectedDevice(): MediaDeviceInfo | undefined {\n return (\n this.#contextProviderRef.value?.selectedDevice || this._selectedDevice\n );\n }\n\n @state()\n _selectedDevice?: MediaDeviceInfo;\n\n /**\n * Current state of recording (stopped, recording, initializing and stopping, ).\n */\n get recordingState(): RecordingState {\n return this.#contextProviderRef.value?.recordingState || \"stopped\";\n }\n\n // ─────────────────────────────────────────────────────────────────────────────\n // Public methods\n // ─────────────────────────────────────────────────────────────────────────────\n\n /**\n * Set the latest access token.\n * @returns ServerConfig with environment, tenant, and accessToken\n * @deprecated Use 'accessToken' property instead.\n */\n public setAccessToken(token: string) {\n this.accessToken = token;\n\n return (\n this.#contextProviderRef.value?.setAccessToken(token) ?? {\n accessToken: token,\n environment: undefined,\n tenant: undefined,\n }\n );\n }\n\n /**\n * Set the auth configuration for OAuth flows.\n * @returns Promise with ServerConfig containing environment, tenant, and accessToken\n * @deprecated Use 'authConfig' property instead.\n */\n public async setAuthConfig(config: Corti.BearerOptions) {\n this.authConfig = config;\n\n return (\n this.#contextProviderRef.value?.setAuthConfig(config) ?? {\n accessToken: undefined,\n environment: undefined,\n tenant: undefined,\n }\n );\n }\n\n /**\n * Starts a recording.\n */\n public startRecording(): void {\n this.#recordingButtonRef.value?.startRecording();\n }\n\n /**\n * Stops a recording.\n */\n public stopRecording(): void {\n this.#recordingButtonRef.value?.stopRecording();\n }\n\n /**\n * Starts or stops recording. Convenience layer on top of the start/stop methods.\n */\n public toggleRecording(): void {\n this.#recordingButtonRef.value?.toggleRecording();\n }\n\n // ─────────────────────────────────────────────────────────────────────────────\n // Render\n // ─────────────────────────────────────────────────────────────────────────────\n\n render() {\n const isHidden =\n !this.accessToken &&\n !this.authConfig &&\n !this.socketUrl &&\n !this.socketProxy;\n\n return html`\n <dictation-root\n ${ref(this.#contextProviderRef)}\n class=${classMap({ hidden: isHidden })}\n .accessToken=${this.accessToken}\n .authConfig=${this.authConfig}\n .socketUrl=${this.socketUrl}\n .socketProxy=${this.socketProxy}\n .dictationConfig=${this._dictationConfig}\n .languages=${this._languagesSupported}\n .devices=${this._devices}\n .selectedDevice=${this._selectedDevice}\n .debug_displayAudio=${this.debug_displayAudio}\n >\n <dictation-recording-button\n ${ref(this.#recordingButtonRef)}\n ?allowButtonFocus=${this.allowButtonFocus}\n ></dictation-recording-button>\n ${\n this.settingsEnabled?.length > 0\n ? html`<dictation-settings-menu\n .settingsEnabled=${this.settingsEnabled}\n ></dictation-settings-menu>`\n : nothing\n }\n </dictation-root>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"corti-dictation\": CortiDictation;\n }\n}\n"]}
1
+ {"version":3,"file":"corti-dictation.js","sourceRoot":"","sources":["../../src/components/corti-dictation.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,SAAS,EAAY,GAAG,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAA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oDAG5C;AASD;IADC,KAAK,EAAE;uDAC0B;AAalC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;0CAG1B;AASD;IADC,KAAK,EAAE;6CACiC;AAQzC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gDAG1B;AAOD;IADC,KAAK,EAAE;mDACoB;AApLjB,cAAc;IAD1B,aAAa,CAAC,iBAAiB,CAAC;GACpB,cAAc,CA0R1B","sourcesContent":["import type { Corti } from \"@corti/sdk\";\nimport { css, html, LitElement, nothing } from \"lit\";\nimport { customElement, property, state } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport { createRef, type Ref, ref } from \"lit/directives/ref.js\";\nimport { DEFAULT_DICTATION_CONFIG } from \"../constants.js\";\nimport type { DictationRoot } from \"../contexts/dictation-context.js\";\nimport type {\n ConfigurableSettings,\n DictationMode,\n ProxyOptions,\n RecordingState,\n} from \"../types.js\";\nimport { commaSeparatedConverter } from \"../utils/converters.js\";\nimport type { DictationRecordingButton } from \"./recording-button.js\";\n\nimport \"../contexts/dictation-context.js\";\nimport \"./recording-button.js\";\nimport \"./settings-menu.js\";\n\n@customElement(\"corti-dictation\")\nexport class CortiDictation extends LitElement {\n static styles = css`\n .hidden {\n display: none;\n }\n `;\n // ─────────────────────────────────────────────────────────────────────────────\n // Private refs\n // ─────────────────────────────────────────────────────────────────────────────\n\n #recordingButtonRef: Ref<DictationRecordingButton> = createRef();\n #contextProviderRef: Ref<DictationRoot> = createRef();\n\n // ─────────────────────────────────────────────────────────────────────────────\n // Properties\n // ─────────────────────────────────────────────────────────────────────────────\n\n /**\n * Latest access token\n */\n @property({ type: String })\n accessToken?: string;\n\n /**\n * Authentication configuration with optional refresh mechanism.\n */\n @property({ attribute: false, type: Object })\n authConfig?: Corti.BearerOptions;\n\n /**\n * WebSocket URL for proxy connection. When provided, uses CortiWebSocketProxyClient instead of CortiClient.\n */\n @property({ type: String })\n socketUrl?: string;\n\n /**\n * Socket proxy configuration object. When provided, uses CortiWebSocketProxyClient instead of CortiClient.\n */\n @property({ attribute: false, type: Object })\n socketProxy?: ProxyOptions;\n\n /**\n * List of all language codes available for use with the Web Component.\n * Default list depends on the accessToken\n */\n @property({\n converter: commaSeparatedConverter,\n type: Array,\n })\n set languagesSupported(value:\n | Corti.TranscribeSupportedLanguage[]\n | undefined) {\n this._languagesSupported = value;\n }\n\n get languagesSupported(): Corti.TranscribeSupportedLanguage[] {\n return (\n this.#contextProviderRef.value?.languages ||\n this._languagesSupported ||\n []\n );\n }\n\n @state()\n _languagesSupported?: Corti.TranscribeSupportedLanguage[];\n\n /**\n * Which settings should be available in the UI.\n * If an empty array is passed, the settings will be disabled entirely.\n * Options are language and devices\n */\n @property({\n converter: commaSeparatedConverter,\n type: Array,\n })\n settingsEnabled: ConfigurableSettings[] = [\"device\", \"language\"];\n\n /**\n * When false (default), allows the start/stop button from taking focus when clicked,\n * disabling textareas or other input elements to maintain focus.\n * Set to \"true\" to allow the button to receive focus on click.\n */\n @property({ type: Boolean })\n allowButtonFocus: boolean = false;\n\n /**\n * Overrides any device selection and instead uses getDisplayMedia to stream system audio.\n * Should only be used for debugging.\n */\n @property({ attribute: \"debug-display-audio\", type: Boolean })\n debug_displayAudio: boolean = false;\n\n /**\n * Configuration settings for dictation\n */\n @property({ attribute: false, type: Object })\n set dictationConfig(value: Corti.TranscribeConfig) {\n this._dictationConfig = value;\n }\n\n get dictationConfig(): Corti.TranscribeConfig {\n return (\n this.#contextProviderRef.value?.dictationConfig || this._dictationConfig\n );\n }\n\n @state()\n _dictationConfig: Corti.TranscribeConfig = DEFAULT_DICTATION_CONFIG;\n\n /**\n * List of available recording devices\n */\n @property({ attribute: false, type: Array })\n set devices(value: MediaDeviceInfo[] | undefined) {\n this._devices = value;\n }\n\n get devices(): MediaDeviceInfo[] {\n return this.#contextProviderRef.value?.devices || this._devices || [];\n }\n\n @state()\n _devices?: MediaDeviceInfo[];\n\n /**\n * The selected device used for recording (MediaDeviceInfo).\n */\n @property({ attribute: false, type: Object })\n set selectedDevice(value: MediaDeviceInfo | undefined) {\n this._selectedDevice = value;\n }\n\n get selectedDevice(): MediaDeviceInfo | undefined {\n return (\n this.#contextProviderRef.value?.selectedDevice || this._selectedDevice\n );\n }\n\n @state()\n _selectedDevice?: MediaDeviceInfo;\n\n /**\n * Current state of recording (stopped, recording, initializing and stopping, ).\n */\n get recordingState(): RecordingState {\n return this.#contextProviderRef.value?.recordingState || \"stopped\";\n }\n\n /**\n * Dictation mode: \"toggle-to-talk\" or \"push-to-talk\"\n */\n @property({ type: String })\n set mode(value: DictationMode) {\n this._mode = value;\n }\n\n get mode(): DictationMode {\n return (\n this.#contextProviderRef.value?.mode || this._mode || \"toggle-to-talk\"\n );\n }\n\n @state()\n _mode?: DictationMode = \"toggle-to-talk\";\n\n /**\n * Keybinding for keyboard shortcut. Single key only (e.g., \"`\", \"k\", \"meta\", \"ctrl\").\n * Combinations with \"+\" are not supported.\n * Defaults to \"`\" if keybinding is in settingsEnabled, otherwise undefined\n */\n @property({ type: String })\n set keybinding(value: string | null | undefined) {\n this._keybinding = value;\n }\n\n get keybinding(): string | null | undefined {\n return this.#contextProviderRef.value?.keybinding || this._keybinding;\n }\n\n @state()\n _keybinding?: string | null;\n\n // ─────────────────────────────────────────────────────────────────────────────\n // Public methods\n // ─────────────────────────────────────────────────────────────────────────────\n\n /**\n * Set the latest access token.\n * @returns ServerConfig with environment, tenant, and accessToken\n * @deprecated Use 'accessToken' property instead.\n */\n public setAccessToken(token: string) {\n this.accessToken = token;\n\n return (\n this.#contextProviderRef.value?.setAccessToken(token) ?? {\n accessToken: token,\n environment: undefined,\n tenant: undefined,\n }\n );\n }\n\n /**\n * Set the auth configuration for OAuth flows.\n * @returns Promise with ServerConfig containing environment, tenant, and accessToken\n * @deprecated Use 'authConfig' property instead.\n */\n public async setAuthConfig(config: Corti.BearerOptions) {\n this.authConfig = config;\n\n return (\n this.#contextProviderRef.value?.setAuthConfig(config) ?? {\n accessToken: undefined,\n environment: undefined,\n tenant: undefined,\n }\n );\n }\n\n /**\n * Starts a recording.\n */\n public startRecording(): void {\n this.#recordingButtonRef.value?.startRecording();\n }\n\n /**\n * Stops a recording.\n */\n public stopRecording(): void {\n this.#recordingButtonRef.value?.stopRecording();\n }\n\n /**\n * Starts or stops recording. Convenience layer on top of the start/stop methods.\n */\n public toggleRecording(): void {\n this.#recordingButtonRef.value?.toggleRecording();\n }\n\n // ─────────────────────────────────────────────────────────────────────────────\n // Render\n // ─────────────────────────────────────────────────────────────────────────────\n\n render() {\n const isHidden =\n !this.accessToken &&\n !this.authConfig &&\n !this.socketUrl &&\n !this.socketProxy;\n\n return html`\n <dictation-root\n ${ref(this.#contextProviderRef)}\n class=${classMap({ hidden: isHidden })}\n .accessToken=${this.accessToken}\n .authConfig=${this.authConfig}\n .socketUrl=${this.socketUrl}\n .socketProxy=${this.socketProxy}\n .dictationConfig=${this._dictationConfig}\n .languages=${this._languagesSupported}\n .devices=${this._devices}\n .selectedDevice=${this._selectedDevice}\n .debug_displayAudio=${this.debug_displayAudio}\n .mode=${this._mode}\n .keybinding=${this._keybinding}\n >\n <dictation-recording-button\n ${ref(this.#recordingButtonRef)}\n ?allowButtonFocus=${this.allowButtonFocus}\n ></dictation-recording-button>\n ${\n this.settingsEnabled?.length > 0\n ? html`<dictation-settings-menu\n .settingsEnabled=${this.settingsEnabled}\n ></dictation-settings-menu>`\n : nothing\n }\n </dictation-root>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"corti-dictation\": CortiDictation;\n }\n}\n"]}
@@ -4,7 +4,7 @@ export declare class DictationDeviceSelector extends LitElement {
4
4
  _devices?: MediaDeviceInfo[];
5
5
  _selectedDevice?: MediaDeviceInfo;
6
6
  disabled: boolean;
7
- static styles: import("lit").CSSResult;
7
+ static styles: import("lit").CSSResult[];
8
8
  render(): import("lit-html").TemplateResult<1>;
9
9
  }
10
10
  declare global {
@@ -0,0 +1,14 @@
1
+ import { LitElement } from "lit";
2
+ export declare class DictationKeybindingSelector extends LitElement {
3
+ #private;
4
+ _keybinding?: string | null;
5
+ disabled: boolean;
6
+ _isCapturingKeybinding: boolean;
7
+ static styles: import("lit").CSSResult[];
8
+ render(): import("lit-html").TemplateResult<1>;
9
+ }
10
+ declare global {
11
+ interface HTMLElementTagNameMap {
12
+ "dictation-keybinding-selector": DictationKeybindingSelector;
13
+ }
14
+ }
@@ -0,0 +1,82 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
+ };
12
+ var _DictationKeybindingSelector_instances, _DictationKeybindingSelector_handleKeybindingInputFocus, _DictationKeybindingSelector_handleKeybindingInputBlur, _DictationKeybindingSelector_handleKeybindingKeyDown;
13
+ import { consume } from "@lit/context";
14
+ import { html, LitElement } from "lit";
15
+ import { customElement, property, state } from "lit/decorators.js";
16
+ import { keybindingContext } from "../contexts/dictation-context.js";
17
+ import KeybindingSelectorStyles from "../styles/keybinding-selector.js";
18
+ import { keybindingChangedEvent } from "../utils/events.js";
19
+ let DictationKeybindingSelector = class DictationKeybindingSelector extends LitElement {
20
+ constructor() {
21
+ super(...arguments);
22
+ _DictationKeybindingSelector_instances.add(this);
23
+ this.disabled = false;
24
+ this._isCapturingKeybinding = false;
25
+ }
26
+ render() {
27
+ return html `
28
+ <div>
29
+ <label>Keybinding</label>
30
+ <div class="keybinding-selector-wrapper">
31
+ ${this._keybinding && html `<div class="keybinding-key">${this._keybinding}</div>`}
32
+ <input
33
+ type="text"
34
+ class="keybinding-selector-input"
35
+ .value=""
36
+ placeholder="Click and press a key..."
37
+ readonly
38
+ @focusin=${__classPrivateFieldGet(this, _DictationKeybindingSelector_instances, "m", _DictationKeybindingSelector_handleKeybindingInputFocus)}
39
+ @focusout=${__classPrivateFieldGet(this, _DictationKeybindingSelector_instances, "m", _DictationKeybindingSelector_handleKeybindingInputBlur)}
40
+ @keydown=${__classPrivateFieldGet(this, _DictationKeybindingSelector_instances, "m", _DictationKeybindingSelector_handleKeybindingKeyDown)}
41
+ ?disabled=${this.disabled}
42
+ />
43
+ </div>
44
+ ${this._keybinding &&
45
+ html `<p class="keybinding-help">
46
+ Press ${this._keybinding} to start/stop recording
47
+ </p>`}
48
+ </div>
49
+ `;
50
+ }
51
+ };
52
+ _DictationKeybindingSelector_instances = new WeakSet();
53
+ _DictationKeybindingSelector_handleKeybindingInputFocus = function _DictationKeybindingSelector_handleKeybindingInputFocus() {
54
+ this._isCapturingKeybinding = true;
55
+ };
56
+ _DictationKeybindingSelector_handleKeybindingInputBlur = function _DictationKeybindingSelector_handleKeybindingInputBlur() {
57
+ this._isCapturingKeybinding = false;
58
+ };
59
+ _DictationKeybindingSelector_handleKeybindingKeyDown = function _DictationKeybindingSelector_handleKeybindingKeyDown(event) {
60
+ if (!this._isCapturingKeybinding) {
61
+ return;
62
+ }
63
+ event.preventDefault();
64
+ event.stopPropagation();
65
+ this.dispatchEvent(keybindingChangedEvent(event.key, event.code));
66
+ };
67
+ DictationKeybindingSelector.styles = KeybindingSelectorStyles;
68
+ __decorate([
69
+ consume({ context: keybindingContext, subscribe: true }),
70
+ state()
71
+ ], DictationKeybindingSelector.prototype, "_keybinding", void 0);
72
+ __decorate([
73
+ property({ type: Boolean })
74
+ ], DictationKeybindingSelector.prototype, "disabled", void 0);
75
+ __decorate([
76
+ state()
77
+ ], DictationKeybindingSelector.prototype, "_isCapturingKeybinding", void 0);
78
+ DictationKeybindingSelector = __decorate([
79
+ customElement("dictation-keybinding-selector")
80
+ ], DictationKeybindingSelector);
81
+ export { DictationKeybindingSelector };
82
+ //# sourceMappingURL=keybinding-selector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keybinding-selector.js","sourceRoot":"","sources":["../../src/components/keybinding-selector.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,wBAAwB,MAAM,kCAAkC,CAAC;AACxE,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAGrD,IAAM,2BAA2B,GAAjC,MAAM,2BAA4B,SAAQ,UAAU;IAApD;;;QAML,aAAQ,GAAY,KAAK,CAAC;QAG1B,2BAAsB,GAAY,KAAK,CAAC;IAkD1C,CAAC;IA3BC,MAAM;QACJ,OAAO,IAAI,CAAA;;;;YAIH,IAAI,CAAC,WAAW,IAAI,IAAI,CAAA,+BAA+B,IAAI,CAAC,WAAW,QAAQ;;;;;;;uBAOpE,uBAAA,IAAI,uGAA4B;wBAC/B,uBAAA,IAAI,sGAA2B;uBAChC,uBAAA,IAAI,oGAAyB;wBAC5B,IAAI,CAAC,QAAQ;;;UAI3B,IAAI,CAAC,WAAW;YAChB,IAAI,CAAA;oBACM,IAAI,CAAC,WAAW;eAE5B;;KAEH,CAAC;IACJ,CAAC;;;;IA5CC,IAAI,CAAC,sBAAsB,GAAG,IAAI,CAAC;AACrC,CAAC;;IAGC,IAAI,CAAC,sBAAsB,GAAG,KAAK,CAAC;AACtC,CAAC;qHAEwB,KAAoB;IAC3C,IAAI,CAAC,IAAI,CAAC,sBAAsB,EAAE,CAAC;QACjC,OAAO;IACT,CAAC;IAED,KAAK,CAAC,cAAc,EAAE,CAAC;IACvB,KAAK,CAAC,eAAe,EAAE,CAAC;IAExB,IAAI,CAAC,aAAa,CAAC,sBAAsB,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;AACpE,CAAC;AAnBM,kCAAM,GAAG,wBAAwB,AAA3B,CAA4B;AARzC;IAFC,OAAO,CAAC,EAAE,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IACxD,KAAK,EAAE;gEACoB;AAG5B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;6DACF;AAG1B;IADC,KAAK,EAAE;2EACgC;AAT7B,2BAA2B;IADvC,aAAa,CAAC,+BAA+B,CAAC;GAClC,2BAA2B,CA2DvC","sourcesContent":["import { consume } from \"@lit/context\";\nimport { html, LitElement } from \"lit\";\nimport { customElement, property, state } from \"lit/decorators.js\";\nimport { keybindingContext } from \"../contexts/dictation-context.js\";\nimport KeybindingSelectorStyles from \"../styles/keybinding-selector.js\";\nimport { keybindingChangedEvent } from \"../utils/events.js\";\n\n@customElement(\"dictation-keybinding-selector\")\nexport class DictationKeybindingSelector extends LitElement {\n @consume({ context: keybindingContext, subscribe: true })\n @state()\n _keybinding?: string | null;\n\n @property({ type: Boolean })\n disabled: boolean = false;\n\n @state()\n _isCapturingKeybinding: boolean = false;\n\n static styles = KeybindingSelectorStyles;\n\n #handleKeybindingInputFocus(): void {\n this._isCapturingKeybinding = true;\n }\n\n #handleKeybindingInputBlur(): void {\n this._isCapturingKeybinding = false;\n }\n\n #handleKeybindingKeyDown(event: KeyboardEvent): void {\n if (!this._isCapturingKeybinding) {\n return;\n }\n\n event.preventDefault();\n event.stopPropagation();\n\n this.dispatchEvent(keybindingChangedEvent(event.key, event.code));\n }\n\n render() {\n return html`\n <div>\n <label>Keybinding</label>\n <div class=\"keybinding-selector-wrapper\">\n ${this._keybinding && html`<div class=\"keybinding-key\">${this._keybinding}</div>`}\n <input\n type=\"text\"\n class=\"keybinding-selector-input\"\n .value=\"\"\n placeholder=\"Click and press a key...\"\n readonly\n @focusin=${this.#handleKeybindingInputFocus}\n @focusout=${this.#handleKeybindingInputBlur}\n @keydown=${this.#handleKeybindingKeyDown}\n ?disabled=${this.disabled}\n />\n </div>\n ${\n this._keybinding &&\n html`<p class=\"keybinding-help\">\n Press ${this._keybinding} to start/stop recording\n </p>`\n }\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"dictation-keybinding-selector\": DictationKeybindingSelector;\n }\n}\n"]}
@@ -5,7 +5,7 @@ export declare class DictationLanguageSelector extends LitElement {
5
5
  _languages?: Corti.TranscribeSupportedLanguage[];
6
6
  _dictationConfig?: Corti.TranscribeConfig;
7
7
  disabled: boolean;
8
- static styles: import("lit").CSSResult;
8
+ static styles: import("lit").CSSResult[];
9
9
  render(): import("lit-html").TemplateResult<1>;
10
10
  }
11
11
  declare global {
@@ -0,0 +1,14 @@
1
+ import { LitElement } from "lit";
2
+ import type { DictationMode } from "../types.js";
3
+ export declare class DictationModeSelector extends LitElement {
4
+ #private;
5
+ _mode: DictationMode;
6
+ disabled: boolean;
7
+ static styles: import("lit").CSSResult[];
8
+ render(): import("lit-html").TemplateResult<1>;
9
+ }
10
+ declare global {
11
+ interface HTMLElementTagNameMap {
12
+ "dictation-mode-selector": DictationModeSelector;
13
+ }
14
+ }
@@ -0,0 +1,73 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
+ };
12
+ var _DictationModeSelector_instances, _DictationModeSelector_handleModeChange;
13
+ import { consume } from "@lit/context";
14
+ import { html, LitElement } from "lit";
15
+ import { customElement, property, state } from "lit/decorators.js";
16
+ import { classMap } from "lit/directives/class-map.js";
17
+ import { modeContext } from "../contexts/dictation-context.js";
18
+ import ModeSelectorStyles from "../styles/mode-selector.js";
19
+ import { modeChangedEvent } from "../utils/events.js";
20
+ let DictationModeSelector = class DictationModeSelector extends LitElement {
21
+ constructor() {
22
+ super(...arguments);
23
+ _DictationModeSelector_instances.add(this);
24
+ this._mode = "toggle-to-talk";
25
+ this.disabled = false;
26
+ }
27
+ render() {
28
+ return html `
29
+ <div>
30
+ <label>Dictation Mode</label>
31
+ <div class="mode-selector-tabs">
32
+ <button
33
+ class=${classMap({
34
+ active: this._mode === "toggle-to-talk",
35
+ "mode-selector-tab": true,
36
+ })}
37
+ @click=${() => __classPrivateFieldGet(this, _DictationModeSelector_instances, "m", _DictationModeSelector_handleModeChange).call(this, "toggle-to-talk")}
38
+ ?disabled=${this.disabled}
39
+ >
40
+ Toggle-to-Talk
41
+ </button>
42
+ <button
43
+ class=${classMap({
44
+ active: this._mode === "push-to-talk",
45
+ "mode-selector-tab": true,
46
+ })}
47
+ @click=${() => __classPrivateFieldGet(this, _DictationModeSelector_instances, "m", _DictationModeSelector_handleModeChange).call(this, "push-to-talk")}
48
+ ?disabled=${this.disabled}
49
+ >
50
+ Push-to-Talk
51
+ </button>
52
+ </div>
53
+ </div>
54
+ `;
55
+ }
56
+ };
57
+ _DictationModeSelector_instances = new WeakSet();
58
+ _DictationModeSelector_handleModeChange = function _DictationModeSelector_handleModeChange(mode) {
59
+ this.dispatchEvent(modeChangedEvent(mode));
60
+ };
61
+ DictationModeSelector.styles = ModeSelectorStyles;
62
+ __decorate([
63
+ consume({ context: modeContext, subscribe: true }),
64
+ state()
65
+ ], DictationModeSelector.prototype, "_mode", void 0);
66
+ __decorate([
67
+ property({ type: Boolean })
68
+ ], DictationModeSelector.prototype, "disabled", void 0);
69
+ DictationModeSelector = __decorate([
70
+ customElement("dictation-mode-selector")
71
+ ], DictationModeSelector);
72
+ export { DictationModeSelector };
73
+ //# sourceMappingURL=mode-selector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mode-selector.js","sourceRoot":"","sources":["../../src/components/mode-selector.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAC/D,OAAO,kBAAkB,MAAM,4BAA4B,CAAC;AAE5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAG/C,IAAM,qBAAqB,GAA3B,MAAM,qBAAsB,SAAQ,UAAU;IAA9C;;;QAGL,UAAK,GAAkB,gBAAgB,CAAC;QAGxC,aAAQ,GAAY,KAAK,CAAC;IAqC5B,CAAC;IA7BC,MAAM;QACJ,OAAO,IAAI,CAAA;;;;;oBAKK,QAAQ,CAAC;YACf,MAAM,EAAE,IAAI,CAAC,KAAK,KAAK,gBAAgB;YACvC,mBAAmB,EAAE,IAAI;SAC1B,CAAC;qBACO,GAAG,EAAE,CAAC,uBAAA,IAAI,iFAAkB,MAAtB,IAAI,EAAmB,gBAAgB,CAAC;wBAC3C,IAAI,CAAC,QAAQ;;;;;oBAKjB,QAAQ,CAAC;YACf,MAAM,EAAE,IAAI,CAAC,KAAK,KAAK,cAAc;YACrC,mBAAmB,EAAE,IAAI;SAC1B,CAAC;qBACO,GAAG,EAAE,CAAC,uBAAA,IAAI,iFAAkB,MAAtB,IAAI,EAAmB,cAAc,CAAC;wBACzC,IAAI,CAAC,QAAQ;;;;;;KAMhC,CAAC;IACJ,CAAC;;;2FAhCiB,IAAmB;IACnC,IAAI,CAAC,aAAa,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC;AAC7C,CAAC;AAJM,4BAAM,GAAG,kBAAkB,AAArB,CAAsB;AALnC;IAFC,OAAO,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IAClD,KAAK,EAAE;oDACgC;AAGxC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;uDACF;AANf,qBAAqB;IADjC,aAAa,CAAC,yBAAyB,CAAC;GAC5B,qBAAqB,CA2CjC","sourcesContent":["import { consume } from \"@lit/context\";\nimport { html, LitElement } from \"lit\";\nimport { customElement, property, state } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport { modeContext } from \"../contexts/dictation-context.js\";\nimport ModeSelectorStyles from \"../styles/mode-selector.js\";\nimport type { DictationMode } from \"../types.js\";\nimport { modeChangedEvent } from \"../utils/events.js\";\n\n@customElement(\"dictation-mode-selector\")\nexport class DictationModeSelector extends LitElement {\n @consume({ context: modeContext, subscribe: true })\n @state()\n _mode: DictationMode = \"toggle-to-talk\";\n\n @property({ type: Boolean })\n disabled: boolean = false;\n\n static styles = ModeSelectorStyles;\n\n #handleModeChange(mode: DictationMode): void {\n this.dispatchEvent(modeChangedEvent(mode));\n }\n\n render() {\n return html`\n <div>\n <label>Dictation Mode</label>\n <div class=\"mode-selector-tabs\">\n <button\n class=${classMap({\n active: this._mode === \"toggle-to-talk\",\n \"mode-selector-tab\": true,\n })}\n @click=${() => this.#handleModeChange(\"toggle-to-talk\")}\n ?disabled=${this.disabled}\n >\n Toggle-to-Talk\n </button>\n <button\n class=${classMap({\n active: this._mode === \"push-to-talk\",\n \"mode-selector-tab\": true,\n })}\n @click=${() => this.#handleModeChange(\"push-to-talk\")}\n ?disabled=${this.disabled}\n >\n Push-to-Talk\n </button>\n </div>\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"dictation-mode-selector\": DictationModeSelector;\n }\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import type { Corti } from "@corti/sdk";
2
- import { type CSSResultGroup, LitElement } from "lit";
3
- import type { ProxyOptions, RecordingState } from "../types.js";
2
+ import { type CSSResultGroup, LitElement, type PropertyValues } from "lit";
3
+ import type { DictationMode, ProxyOptions, RecordingState } from "../types.js";
4
4
  import "./audio-visualiser.js";
5
5
  import "../icons/icons.js";
6
6
  export declare class DictationRecordingButton extends LitElement {
@@ -15,8 +15,11 @@ export declare class DictationRecordingButton extends LitElement {
15
15
  _socketUrl?: string;
16
16
  _socketProxy?: ProxyOptions;
17
17
  _debug_displayAudio?: boolean;
18
+ _keybinding?: string | null;
19
+ _mode?: DictationMode;
18
20
  allowButtonFocus: boolean;
19
21
  static styles: CSSResultGroup;
22
+ protected update(changedProperties: PropertyValues): void;
20
23
  startRecording(): void;
21
24
  stopRecording(): void;
22
25
  toggleRecording(): void;
@@ -9,13 +9,20 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
9
9
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
10
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
11
  };
12
- var _DictationRecordingButton_instances, _DictationRecordingButton_mediaController, _DictationRecordingButton_dictationController, _DictationRecordingButton_handleMouseDown, _DictationRecordingButton_handleWebSocketMessage, _DictationRecordingButton_handleWebSocketError, _DictationRecordingButton_handleWebSocketClose, _DictationRecordingButton_handleStart, _DictationRecordingButton_handleStop, _DictationRecordingButton_handleClick;
12
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
13
+ if (kind === "m") throw new TypeError("Private method is not writable");
14
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
15
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
16
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
17
+ };
18
+ var _DictationRecordingButton_instances, _DictationRecordingButton_mediaController, _DictationRecordingButton_dictationController, _DictationRecordingButton_keybindingController, _DictationRecordingButton_closeConnectionOnInit, _DictationRecordingButton_handlePointerDown, _DictationRecordingButton_handlePointerUp, _DictationRecordingButton_handlePointerLeave, _DictationRecordingButton_handleWebSocketMessage, _DictationRecordingButton_handleWebSocketError, _DictationRecordingButton_handleWebSocketClose, _DictationRecordingButton_handleStart, _DictationRecordingButton_handleStop;
13
19
  import { consume } from "@lit/context";
14
- import { html, LitElement } from "lit";
20
+ import { html, LitElement, } from "lit";
15
21
  import { customElement, property, state } from "lit/decorators.js";
16
22
  import { AUDIO_CHUNK_INTERVAL_MS } from "../constants.js";
17
- import { accessTokenContext, authConfigContext, debugDisplayAudioContext, dictationConfigContext, recordingStateContext, regionContext, selectedDeviceContext, socketProxyContext, socketUrlContext, tenantNameContext, } from "../contexts/dictation-context.js";
23
+ import { accessTokenContext, authConfigContext, debugDisplayAudioContext, dictationConfigContext, keybindingContext, modeContext, recordingStateContext, regionContext, selectedDeviceContext, socketProxyContext, socketUrlContext, tenantNameContext, } from "../contexts/dictation-context.js";
18
24
  import { DictationController, } from "../controllers/dictation-controller.js";
25
+ import { KeybindingController } from "../controllers/keybinding-controller.js";
19
26
  import { MediaController } from "../controllers/media-controller.js";
20
27
  import ButtonStyles from "../styles/buttons.js";
21
28
  import RecordingButtonStyles from "../styles/recording-button.js";
@@ -30,6 +37,8 @@ let DictationRecordingButton = class DictationRecordingButton extends LitElement
30
37
  this.allowButtonFocus = false;
31
38
  _DictationRecordingButton_mediaController.set(this, new MediaController(this));
32
39
  _DictationRecordingButton_dictationController.set(this, new DictationController(this));
40
+ _DictationRecordingButton_keybindingController.set(this, new KeybindingController(this));
41
+ _DictationRecordingButton_closeConnectionOnInit.set(this, false);
33
42
  _DictationRecordingButton_handleWebSocketMessage.set(this, (message) => {
34
43
  switch (message.type) {
35
44
  case "CONFIG_ACCEPTED":
@@ -70,6 +79,15 @@ let DictationRecordingButton = class DictationRecordingButton extends LitElement
70
79
  this.dispatchEvent(streamClosedEvent(event));
71
80
  });
72
81
  }
82
+ update(changedProperties) {
83
+ if (changedProperties.has("_recordingState") &&
84
+ this._recordingState === "recording" &&
85
+ __classPrivateFieldGet(this, _DictationRecordingButton_closeConnectionOnInit, "f")) {
86
+ __classPrivateFieldSet(this, _DictationRecordingButton_closeConnectionOnInit, false, "f");
87
+ __classPrivateFieldGet(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_handleStop).call(this);
88
+ }
89
+ super.update(changedProperties);
90
+ }
73
91
  startRecording() {
74
92
  if (this._recordingState !== "stopped") {
75
93
  return;
@@ -77,13 +95,23 @@ let DictationRecordingButton = class DictationRecordingButton extends LitElement
77
95
  __classPrivateFieldGet(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_handleStart).call(this);
78
96
  }
79
97
  stopRecording() {
80
- if (this._recordingState !== "recording") {
98
+ if (this._recordingState === "stopped" ||
99
+ this._recordingState === "stopping") {
100
+ return;
101
+ }
102
+ if (this._recordingState === "initializing") {
103
+ __classPrivateFieldSet(this, _DictationRecordingButton_closeConnectionOnInit, true, "f");
81
104
  return;
82
105
  }
83
106
  __classPrivateFieldGet(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_handleStop).call(this);
84
107
  }
85
108
  toggleRecording() {
86
- __classPrivateFieldGet(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_handleClick).call(this);
109
+ if (this._recordingState === "stopped") {
110
+ this.startRecording();
111
+ }
112
+ else if (this._recordingState === "recording") {
113
+ this.stopRecording();
114
+ }
87
115
  }
88
116
  render() {
89
117
  const isLoading = this._recordingState === "initializing" ||
@@ -91,8 +119,10 @@ let DictationRecordingButton = class DictationRecordingButton extends LitElement
91
119
  const isRecording = this._recordingState === "recording";
92
120
  return html `
93
121
  <button
94
- @mousedown=${__classPrivateFieldGet(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_handleMouseDown)}
95
- @click=${__classPrivateFieldGet(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_handleClick)}
122
+ @pointerdown=${__classPrivateFieldGet(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_handlePointerDown)}
123
+ @pointerup=${__classPrivateFieldGet(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_handlePointerUp)}
124
+ @pointerleave=${__classPrivateFieldGet(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_handlePointerLeave)}
125
+ @pointercancel=${__classPrivateFieldGet(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_handlePointerLeave)}
96
126
  ?disabled=${isLoading}
97
127
  class=${isRecording ? "red" : "accent"}
98
128
  aria-label=${isRecording ? "Stop recording" : "Start recording"}
@@ -113,14 +143,42 @@ let DictationRecordingButton = class DictationRecordingButton extends LitElement
113
143
  };
114
144
  _DictationRecordingButton_mediaController = new WeakMap();
115
145
  _DictationRecordingButton_dictationController = new WeakMap();
146
+ _DictationRecordingButton_keybindingController = new WeakMap();
147
+ _DictationRecordingButton_closeConnectionOnInit = new WeakMap();
116
148
  _DictationRecordingButton_handleWebSocketMessage = new WeakMap();
117
149
  _DictationRecordingButton_handleWebSocketError = new WeakMap();
118
150
  _DictationRecordingButton_handleWebSocketClose = new WeakMap();
119
151
  _DictationRecordingButton_instances = new WeakSet();
120
- _DictationRecordingButton_handleMouseDown = function _DictationRecordingButton_handleMouseDown(event) {
152
+ _DictationRecordingButton_handlePointerDown = function _DictationRecordingButton_handlePointerDown(event) {
121
153
  if (!this.allowButtonFocus) {
122
154
  event.preventDefault();
123
155
  }
156
+ if (this._mode === "push-to-talk") {
157
+ this.startRecording();
158
+ event.currentTarget.setPointerCapture(event.pointerId);
159
+ }
160
+ };
161
+ _DictationRecordingButton_handlePointerUp = function _DictationRecordingButton_handlePointerUp(event) {
162
+ if (this._mode === "push-to-talk") {
163
+ this.stopRecording();
164
+ const button = event.currentTarget;
165
+ if (button.hasPointerCapture(event.pointerId)) {
166
+ button.releasePointerCapture(event.pointerId);
167
+ }
168
+ return;
169
+ }
170
+ if (this._mode === "toggle-to-talk") {
171
+ this.toggleRecording();
172
+ }
173
+ };
174
+ _DictationRecordingButton_handlePointerLeave = function _DictationRecordingButton_handlePointerLeave(event) {
175
+ if (this._mode === "push-to-talk") {
176
+ this.stopRecording();
177
+ const button = event.currentTarget;
178
+ if (button.hasPointerCapture(event.pointerId)) {
179
+ button.releasePointerCapture(event.pointerId);
180
+ }
181
+ }
124
182
  };
125
183
  _DictationRecordingButton_handleStart = async function _DictationRecordingButton_handleStart() {
126
184
  this.dispatchEvent(recordingStateChangedEvent("initializing"));
@@ -131,7 +189,7 @@ _DictationRecordingButton_handleStart = async function _DictationRecordingButton
131
189
  __classPrivateFieldGet(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_handleStop).call(this);
132
190
  }
133
191
  });
134
- await __classPrivateFieldGet(this, _DictationRecordingButton_dictationController, "f").connect(__classPrivateFieldGet(this, _DictationRecordingButton_mediaController, "f").mediaRecorder, this._dictationConfig, {
192
+ const isNewConnection = await __classPrivateFieldGet(this, _DictationRecordingButton_dictationController, "f").connect(__classPrivateFieldGet(this, _DictationRecordingButton_mediaController, "f").mediaRecorder, this._dictationConfig, {
135
193
  onClose: __classPrivateFieldGet(this, _DictationRecordingButton_handleWebSocketClose, "f"),
136
194
  onError: __classPrivateFieldGet(this, _DictationRecordingButton_handleWebSocketError, "f"),
137
195
  onMessage: __classPrivateFieldGet(this, _DictationRecordingButton_handleWebSocketMessage, "f"),
@@ -139,6 +197,14 @@ _DictationRecordingButton_handleStart = async function _DictationRecordingButton
139
197
  this.dispatchEvent(networkActivityEvent(direction, data));
140
198
  },
141
199
  });
200
+ // configuration has been accepted before
201
+ if (!isNewConnection) {
202
+ __classPrivateFieldGet(this, _DictationRecordingButton_mediaController, "f").mediaRecorder?.start(AUDIO_CHUNK_INTERVAL_MS);
203
+ __classPrivateFieldGet(this, _DictationRecordingButton_mediaController, "f").startAudioLevelMonitoring((level) => {
204
+ this.dispatchEvent(audioLevelChangedEvent(level));
205
+ });
206
+ this.dispatchEvent(recordingStateChangedEvent("recording"));
207
+ }
142
208
  }
143
209
  catch (error) {
144
210
  this.dispatchEvent(errorEvent(error));
@@ -158,14 +224,6 @@ _DictationRecordingButton_handleStop = async function _DictationRecordingButton_
158
224
  }
159
225
  this.dispatchEvent(recordingStateChangedEvent("stopped"));
160
226
  };
161
- _DictationRecordingButton_handleClick = function _DictationRecordingButton_handleClick() {
162
- if (this._recordingState === "stopped") {
163
- __classPrivateFieldGet(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_handleStart).call(this);
164
- }
165
- else if (this._recordingState === "recording") {
166
- __classPrivateFieldGet(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_handleStop).call(this);
167
- }
168
- };
169
227
  DictationRecordingButton.styles = [RecordingButtonStyles, ButtonStyles];
170
228
  __decorate([
171
229
  consume({ context: recordingStateContext, subscribe: true }),
@@ -207,6 +265,14 @@ __decorate([
207
265
  consume({ context: debugDisplayAudioContext, subscribe: true }),
208
266
  state()
209
267
  ], DictationRecordingButton.prototype, "_debug_displayAudio", void 0);
268
+ __decorate([
269
+ consume({ context: keybindingContext, subscribe: true }),
270
+ state()
271
+ ], DictationRecordingButton.prototype, "_keybinding", void 0);
272
+ __decorate([
273
+ consume({ context: modeContext, subscribe: true }),
274
+ state()
275
+ ], DictationRecordingButton.prototype, "_mode", void 0);
210
276
  __decorate([
211
277
  property({ type: Boolean })
212
278
  ], DictationRecordingButton.prototype, "allowButtonFocus", void 0);