@corti/dictation-web 0.6.0-rc → 0.6.0

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 (37) hide show
  1. package/README.md +1 -1
  2. package/dist/bundle.js +6875 -5532
  3. package/dist/components/corti-dictation.d.ts +3 -3
  4. package/dist/components/corti-dictation.js.map +1 -1
  5. package/dist/components/recording-button.d.ts +2 -2
  6. package/dist/components/recording-button.js +16 -17
  7. package/dist/components/recording-button.js.map +1 -1
  8. package/dist/contexts/dictation-context.d.ts +6 -6
  9. package/dist/contexts/dictation-context.js.map +1 -1
  10. package/dist/controllers/dictation-controller.d.ts +7 -4
  11. package/dist/controllers/dictation-controller.js +140 -34
  12. package/dist/controllers/dictation-controller.js.map +1 -1
  13. package/dist/controllers/media-controller.d.ts +1 -3
  14. package/dist/controllers/media-controller.js +4 -22
  15. package/dist/controllers/media-controller.js.map +1 -1
  16. package/dist/icons/icons.d.ts +1 -1
  17. package/dist/icons/icons.js +7 -7
  18. package/dist/icons/icons.js.map +1 -1
  19. package/dist/index.d.ts +1 -1
  20. package/dist/index.js.map +1 -1
  21. package/dist/styles/audio-visualiser.js.map +1 -1
  22. package/dist/styles/callout.js +1 -1
  23. package/dist/styles/callout.js.map +1 -1
  24. package/dist/tsconfig.tsbuildinfo +1 -1
  25. package/dist/utils/auth.d.ts +2 -2
  26. package/dist/utils/auth.js.map +1 -1
  27. package/dist/utils/events.d.ts +2 -0
  28. package/dist/utils/events.js +22 -1
  29. package/dist/utils/events.js.map +1 -1
  30. package/package.json +3 -5
  31. package/dist/components/mode-selector.d.ts +0 -14
  32. package/dist/components/mode-selector.js +0 -73
  33. package/dist/components/mode-selector.js.map +0 -1
  34. package/dist/package.json +0 -94
  35. package/dist/styles/mode-selector.d.ts +0 -2
  36. package/dist/styles/mode-selector.js +0 -56
  37. package/dist/styles/mode-selector.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import type { Corti } from "@corti/sdk";
1
+ import type { Corti, CortiAuth } from "@corti/sdk";
2
2
  import { LitElement } from "lit";
3
3
  import type { ConfigurableSettings, ProxyOptions, RecordingState } from "../types.js";
4
4
  import "../contexts/dictation-context.js";
@@ -14,7 +14,7 @@ export declare class CortiDictation extends LitElement {
14
14
  /**
15
15
  * Authentication configuration with optional refresh mechanism.
16
16
  */
17
- authConfig?: Corti.BearerOptions;
17
+ authConfig?: CortiAuth.AuthTokenDerivable;
18
18
  /**
19
19
  * WebSocket URL for proxy connection. When provided, uses CortiWebSocketProxyClient instead of CortiClient.
20
20
  */
@@ -106,7 +106,7 @@ export declare class CortiDictation extends LitElement {
106
106
  * @returns Promise with ServerConfig containing environment, tenant, and accessToken
107
107
  * @deprecated Use 'authConfig' property instead.
108
108
  */
109
- setAuthConfig(config: Corti.BearerOptions): Promise<{
109
+ setAuthConfig(config: CortiAuth.AuthTokenDerivable): Promise<{
110
110
  accessToken: string | undefined;
111
111
  environment: undefined;
112
112
  tenant: undefined;
@@ -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,CAAC;AAGrB,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,UAAU;IAAvC;;QA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AAE,MAAM,EAAE,CAAC;oDAG5C;AASD;IADC,KAAK,EAAE;uDAC0B;AAgBlC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;0DAG1B;AAUD;IADC,KAAK,EAAE;6DAC8B;AAStC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4DAG1B;AAUD;IADC,KAAK,EAAE;+DACgC;AA5L7B,cAAc;IAD1B,aAAa,CAAC,iBAAiB,CAAC;GACpB,cAAc,CAkT1B","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 * Push-to-talk keybinding for keyboard shortcut. Single key only (e.g., \"Space\", \"k\", \"meta\", \"ctrl\").\n * Combinations with \"+\" are not supported.\n * Keydown starts recording, keyup stops recording.\n * Defaults to \"Space\" if keybinding is in settingsEnabled, otherwise undefined\n */\n @property({ type: String })\n set pushToTalkKeybinding(value: string | null | undefined) {\n this._pushToTalkKeybinding = value;\n }\n\n get pushToTalkKeybinding(): string | null | undefined {\n return (\n this.#contextProviderRef.value?.pushToTalkKeybinding ||\n this._pushToTalkKeybinding\n );\n }\n\n @state()\n _pushToTalkKeybinding?: string | null;\n\n /**\n * Toggle-to-talk keybinding for keyboard shortcut. Single key only (e.g., \"`\", \"k\", \"meta\", \"ctrl\").\n * Combinations with \"+\" are not supported.\n * Pressing the key toggles recording on/off.\n * Defaults to \"`\" if keybinding is in settingsEnabled, otherwise undefined\n */\n @property({ type: String })\n set toggleToTalkKeybinding(value: string | null | undefined) {\n this._toggleToTalkKeybinding = value;\n }\n\n get toggleToTalkKeybinding(): string | null | undefined {\n return (\n this.#contextProviderRef.value?.toggleToTalkKeybinding ||\n this._toggleToTalkKeybinding\n );\n }\n\n @state()\n _toggleToTalkKeybinding?: 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 * Opens the WebSocket connection without starting recording.\n * Use this to pre-establish the connection before recording starts.\n */\n public async openConnection(): Promise<void> {\n await this.#recordingButtonRef.value?.openConnection();\n }\n\n /**\n * Closes the WebSocket connection by sending \"end\" and waiting for \"ended\".\n * Call this to receive \"usage\" statistics or when done with the connection.\n */\n public async closeConnection(): Promise<void> {\n await this.#recordingButtonRef.value?.closeConnection();\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 .pushToTalkKeybinding=${this._pushToTalkKeybinding}\n .toggleToTalkKeybinding=${this._toggleToTalkKeybinding}\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,iBAAiB,CAAC;AAO3D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAGjE,OAAO,kCAAkC,CAAC;AAC1C,OAAO,uBAAuB,CAAC;AAC/B,OAAO,oBAAoB,CAAC;AAGrB,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,UAAU;IAAvC;;QAML,gFAAgF;QAChF,eAAe;QACf,gFAAgF;QAEhF,6CAAqD,SAAS,EAAE,EAAC;QACjE,6CAA0C,SAAS,EAAE,EAAC;QAuDtD;;;;WAIG;QAKH,oBAAe,GAA2B,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;QAEjE;;;;WAIG;QAEH,qBAAgB,GAAY,KAAK,CAAC;QAElC;;;WAGG;QAEH,uBAAkB,GAAY,KAAK,CAAC;QAiBp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1B,aAAa,CAAC,iBAAiB,CAAC;GACpB,cAAc,CAkT1B","sourcesContent":["import type { Corti, CortiAuth } 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?: CortiAuth.AuthTokenDerivable;\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 * Push-to-talk keybinding for keyboard shortcut. Single key only (e.g., \"Space\", \"k\", \"meta\", \"ctrl\").\n * Combinations with \"+\" are not supported.\n * Keydown starts recording, keyup stops recording.\n * Defaults to \"Space\" if keybinding is in settingsEnabled, otherwise undefined\n */\n @property({ type: String })\n set pushToTalkKeybinding(value: string | null | undefined) {\n this._pushToTalkKeybinding = value;\n }\n\n get pushToTalkKeybinding(): string | null | undefined {\n return (\n this.#contextProviderRef.value?.pushToTalkKeybinding ||\n this._pushToTalkKeybinding\n );\n }\n\n @state()\n _pushToTalkKeybinding?: string | null;\n\n /**\n * Toggle-to-talk keybinding for keyboard shortcut. Single key only (e.g., \"`\", \"k\", \"meta\", \"ctrl\").\n * Combinations with \"+\" are not supported.\n * Pressing the key toggles recording on/off.\n * Defaults to \"`\" if keybinding is in settingsEnabled, otherwise undefined\n */\n @property({ type: String })\n set toggleToTalkKeybinding(value: string | null | undefined) {\n this._toggleToTalkKeybinding = value;\n }\n\n get toggleToTalkKeybinding(): string | null | undefined {\n return (\n this.#contextProviderRef.value?.toggleToTalkKeybinding ||\n this._toggleToTalkKeybinding\n );\n }\n\n @state()\n _toggleToTalkKeybinding?: 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: CortiAuth.AuthTokenDerivable) {\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 * Opens the WebSocket connection without starting recording.\n * Use this to pre-establish the connection before recording starts.\n */\n public async openConnection(): Promise<void> {\n await this.#recordingButtonRef.value?.openConnection();\n }\n\n /**\n * Closes the WebSocket connection by sending \"end\" and waiting for \"ended\".\n * Call this to receive \"usage\" statistics or when done with the connection.\n */\n public async closeConnection(): Promise<void> {\n await this.#recordingButtonRef.value?.closeConnection();\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 .pushToTalkKeybinding=${this._pushToTalkKeybinding}\n .toggleToTalkKeybinding=${this._toggleToTalkKeybinding}\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,4 +1,4 @@
1
- import type { Corti } from "@corti/sdk";
1
+ import type { Corti, CortiAuth } from "@corti/sdk";
2
2
  import { type CSSResultGroup, LitElement, type PropertyValues } from "lit";
3
3
  import type { ProxyOptions, RecordingState } from "../types.js";
4
4
  import "./audio-visualiser.js";
@@ -8,7 +8,7 @@ export declare class DictationRecordingButton extends LitElement {
8
8
  _recordingState: RecordingState;
9
9
  _selectedDevice?: MediaDeviceInfo;
10
10
  _accessToken?: string;
11
- _authConfig?: Corti.BearerOptions;
11
+ _authConfig?: CortiAuth.AuthTokenDerivable;
12
12
  _region?: string;
13
13
  _tenantName?: string;
14
14
  _dictationConfig?: Corti.TranscribeConfig;
@@ -26,7 +26,7 @@ import { KeybindingController } from "../controllers/keybinding-controller.js";
26
26
  import { MediaController } from "../controllers/media-controller.js";
27
27
  import ButtonStyles from "../styles/buttons.js";
28
28
  import RecordingButtonStyles from "../styles/recording-button.js";
29
- import { audioLevelChangedEvent, commandEvent, errorEvent, networkActivityEvent, recordingStateChangedEvent, streamClosedEvent, transcriptEvent, usageEvent, } from "../utils/events.js";
29
+ import { audioLevelChangedEvent, commandEvent, deltaUsageEvent, errorEvent, networkActivityEvent, recordingStateChangedEvent, streamClosedEvent, transcriptEvent, usageEvent, } from "../utils/events.js";
30
30
  import "./audio-visualiser.js";
31
31
  import "../icons/icons.js";
32
32
  let DictationRecordingButton = class DictationRecordingButton extends LitElement {
@@ -43,13 +43,6 @@ let DictationRecordingButton = class DictationRecordingButton extends LitElement
43
43
  _DictationRecordingButton_connection.set(this, "CLOSED");
44
44
  _DictationRecordingButton_handleWebSocketMessage.set(this, (message) => {
45
45
  switch (message.type) {
46
- case "CONFIG_ACCEPTED":
47
- __classPrivateFieldGet(this, _DictationRecordingButton_mediaController, "f").addDataHandler(__classPrivateFieldGet(this, _DictationRecordingButton_dictationController, "f").mediaRecorderHandler);
48
- if (this._recordingState === "initializing") {
49
- __classPrivateFieldSet(this, _DictationRecordingButton_processing, true, "f");
50
- __classPrivateFieldGet(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_dispatchRecordingStateChanged).call(this, "recording");
51
- }
52
- break;
53
46
  case "CONFIG_DENIED":
54
47
  this.dispatchEvent(errorEvent(`Config denied: ${message.reason ?? "Unknown reason"}`));
55
48
  __classPrivateFieldGet(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_handleStop).call(this);
@@ -67,6 +60,9 @@ let DictationRecordingButton = class DictationRecordingButton extends LitElement
67
60
  case "usage":
68
61
  this.dispatchEvent(usageEvent(message));
69
62
  break;
63
+ case "delta_usage":
64
+ this.dispatchEvent(deltaUsageEvent(message));
65
+ break;
70
66
  case "error":
71
67
  this.dispatchEvent(errorEvent(message.error));
72
68
  __classPrivateFieldGet(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_handleStop).call(this);
@@ -88,7 +84,8 @@ let DictationRecordingButton = class DictationRecordingButton extends LitElement
88
84
  });
89
85
  _DictationRecordingButton_handleWebSocketClose.set(this, (event) => {
90
86
  // When we already have new socket opened
91
- if (__classPrivateFieldGet(this, _DictationRecordingButton_dictationController, "f").isConnectionOpen()) {
87
+ if (__classPrivateFieldGet(this, _DictationRecordingButton_dictationController, "f").isConnectionOpen() ||
88
+ __classPrivateFieldGet(this, _DictationRecordingButton_dictationController, "f").isConnecting()) {
92
89
  return;
93
90
  }
94
91
  __classPrivateFieldSet(this, _DictationRecordingButton_processing, false, "f");
@@ -140,7 +137,7 @@ let DictationRecordingButton = class DictationRecordingButton extends LitElement
140
137
  }
141
138
  try {
142
139
  __classPrivateFieldSet(this, _DictationRecordingButton_connection, "CONNECTING", "f");
143
- __classPrivateFieldGet(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_dispatchRecordingStateChanged).call(this, "stopped");
140
+ __classPrivateFieldGet(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_dispatchRecordingStateChanged).call(this, this._recordingState);
144
141
  await __classPrivateFieldGet(this, _DictationRecordingButton_dictationController, "f").connect(this._dictationConfig, {
145
142
  onClose: __classPrivateFieldGet(this, _DictationRecordingButton_handleWebSocketClose, "f"),
146
143
  onError: __classPrivateFieldGet(this, _DictationRecordingButton_handleWebSocketError, "f"),
@@ -150,7 +147,7 @@ let DictationRecordingButton = class DictationRecordingButton extends LitElement
150
147
  },
151
148
  });
152
149
  __classPrivateFieldSet(this, _DictationRecordingButton_connection, "OPEN", "f");
153
- __classPrivateFieldGet(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_dispatchRecordingStateChanged).call(this, "stopped");
150
+ __classPrivateFieldGet(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_dispatchRecordingStateChanged).call(this, this._recordingState);
154
151
  }
155
152
  catch (error) {
156
153
  __classPrivateFieldSet(this, _DictationRecordingButton_connection, "CLOSED", "f");
@@ -161,6 +158,9 @@ let DictationRecordingButton = class DictationRecordingButton extends LitElement
161
158
  if (this._recordingState !== "stopped" || __classPrivateFieldGet(this, _DictationRecordingButton_processing, "f")) {
162
159
  return;
163
160
  }
161
+ if (__classPrivateFieldGet(this, _DictationRecordingButton_dictationController, "f").isConnecting()) {
162
+ await __classPrivateFieldGet(this, _DictationRecordingButton_dictationController, "f").waitForConnection();
163
+ }
164
164
  if (!__classPrivateFieldGet(this, _DictationRecordingButton_dictationController, "f").isConnectionOpen()) {
165
165
  __classPrivateFieldSet(this, _DictationRecordingButton_connection, "CLOSED", "f");
166
166
  __classPrivateFieldGet(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_dispatchRecordingStateChanged).call(this, "stopped");
@@ -230,11 +230,12 @@ _DictationRecordingButton_handleStart = async function _DictationRecordingButton
230
230
  this.dispatchEvent(errorEvent("Recording device access was lost."));
231
231
  __classPrivateFieldGet(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_handleStop).call(this);
232
232
  }
233
- });
233
+ }, __classPrivateFieldGet(this, _DictationRecordingButton_dictationController, "f").mediaRecorderHandler);
234
234
  __classPrivateFieldGet(this, _DictationRecordingButton_mediaController, "f").mediaRecorder?.start(AUDIO_CHUNK_INTERVAL_MS);
235
235
  __classPrivateFieldGet(this, _DictationRecordingButton_mediaController, "f").startAudioLevelMonitoring((level) => {
236
236
  this.dispatchEvent(audioLevelChangedEvent(level));
237
237
  });
238
+ __classPrivateFieldSet(this, _DictationRecordingButton_processing, true, "f");
238
239
  if (__classPrivateFieldGet(this, _DictationRecordingButton_connection, "f") !== "OPEN") {
239
240
  __classPrivateFieldSet(this, _DictationRecordingButton_connection, "CONNECTING", "f");
240
241
  }
@@ -247,12 +248,11 @@ _DictationRecordingButton_handleStart = async function _DictationRecordingButton
247
248
  this.dispatchEvent(networkActivityEvent(direction, data));
248
249
  },
249
250
  });
250
- if (!isNewConnection) {
251
- __classPrivateFieldGet(this, _DictationRecordingButton_mediaController, "f").addDataHandler(__classPrivateFieldGet(this, _DictationRecordingButton_dictationController, "f").mediaRecorderHandler);
252
- __classPrivateFieldSet(this, _DictationRecordingButton_processing, true, "f");
251
+ if (isNewConnection === "superseded") {
252
+ return;
253
253
  }
254
254
  __classPrivateFieldSet(this, _DictationRecordingButton_connection, "OPEN", "f");
255
- __classPrivateFieldGet(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_dispatchRecordingStateChanged).call(this, "recording");
255
+ __classPrivateFieldGet(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_dispatchRecordingStateChanged).call(this, this._recordingState);
256
256
  }
257
257
  catch (error) {
258
258
  this.dispatchEvent(errorEvent(error));
@@ -264,7 +264,6 @@ _DictationRecordingButton_handleStop = async function _DictationRecordingButton_
264
264
  try {
265
265
  __classPrivateFieldGet(this, _DictationRecordingButton_mediaController, "f").stopAudioLevelMonitoring();
266
266
  await __classPrivateFieldGet(this, _DictationRecordingButton_mediaController, "f").stopRecording();
267
- __classPrivateFieldGet(this, _DictationRecordingButton_mediaController, "f").removeDataHandler();
268
267
  __classPrivateFieldGet(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_dispatchRecordingStateChanged).call(this, "stopped");
269
268
  await __classPrivateFieldGet(this, _DictationRecordingButton_dictationController, "f").pause();
270
269
  await __classPrivateFieldGet(this, _DictationRecordingButton_mediaController, "f").cleanup();
@@ -1 +1 @@
1
- {"version":3,"file":"recording-button.js","sourceRoot":"","sources":["../../src/components/recording-button.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AACA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAEL,IAAI,EACJ,UAAU,GAEX,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,wBAAwB,EACxB,sBAAsB,EACtB,2BAA2B,EAC3B,qBAAqB,EACrB,aAAa,EACb,qBAAqB,EACrB,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,6BAA6B,GAC9B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACL,mBAAmB,GAEpB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,yCAAyC,CAAC;AAC/E,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,YAAY,MAAM,sBAAsB,CAAC;AAChD,OAAO,qBAAqB,MAAM,+BAA+B,CAAC;AAElE,OAAO,EACL,sBAAsB,EACtB,YAAY,EACZ,UAAU,EACV,oBAAoB,EAEpB,0BAA0B,EAC1B,iBAAiB,EACjB,eAAe,EACf,UAAU,GACX,MAAM,oBAAoB,CAAC;AAE5B,OAAO,uBAAuB,CAAC;AAC/B,OAAO,mBAAmB,CAAC;AAGpB,IAAM,wBAAwB,GAA9B,MAAM,wBAAyB,SAAQ,UAAU;IAA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yEACgC;AAGxC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;kEACM;AAlDvB,wBAAwB;IADpC,aAAa,CAAC,4BAA4B,CAAC;GAC/B,wBAAwB,CA+UpC","sourcesContent":["import type { Corti } from \"@corti/sdk\";\nimport { consume } from \"@lit/context\";\nimport {\n type CSSResultGroup,\n html,\n LitElement,\n type PropertyValues,\n} from \"lit\";\nimport { customElement, property, state } from \"lit/decorators.js\";\nimport { AUDIO_CHUNK_INTERVAL_MS } from \"../constants.js\";\nimport {\n accessTokenContext,\n authConfigContext,\n debugDisplayAudioContext,\n dictationConfigContext,\n pushToTalkKeybindingContext,\n recordingStateContext,\n regionContext,\n selectedDeviceContext,\n socketProxyContext,\n socketUrlContext,\n tenantNameContext,\n toggleToTalkKeybindingContext,\n} from \"../contexts/dictation-context.js\";\nimport {\n DictationController,\n type TranscribeMessage,\n} from \"../controllers/dictation-controller.js\";\nimport { KeybindingController } from \"../controllers/keybinding-controller.js\";\nimport { MediaController } from \"../controllers/media-controller.js\";\nimport ButtonStyles from \"../styles/buttons.js\";\nimport RecordingButtonStyles from \"../styles/recording-button.js\";\nimport type { ProxyOptions, RecordingState } from \"../types.js\";\nimport {\n audioLevelChangedEvent,\n commandEvent,\n errorEvent,\n networkActivityEvent,\n type RecordingStateChangedEventDetail,\n recordingStateChangedEvent,\n streamClosedEvent,\n transcriptEvent,\n usageEvent,\n} from \"../utils/events.js\";\n\nimport \"./audio-visualiser.js\";\nimport \"../icons/icons.js\";\n\n@customElement(\"dictation-recording-button\")\nexport class DictationRecordingButton extends LitElement {\n @consume({ context: recordingStateContext, subscribe: true })\n @state()\n _recordingState: RecordingState = \"stopped\";\n\n @consume({ context: selectedDeviceContext, subscribe: true })\n @state()\n _selectedDevice?: MediaDeviceInfo;\n\n @consume({ context: accessTokenContext, subscribe: true })\n @state()\n _accessToken?: string;\n\n @consume({ context: authConfigContext, subscribe: true })\n @state()\n _authConfig?: Corti.BearerOptions;\n\n @consume({ context: regionContext, subscribe: true })\n @state()\n _region?: string;\n\n @consume({ context: tenantNameContext, subscribe: true })\n @state()\n _tenantName?: string;\n\n @consume({ context: dictationConfigContext, subscribe: true })\n @state()\n _dictationConfig?: Corti.TranscribeConfig;\n\n @consume({ context: socketUrlContext, subscribe: true })\n @state()\n _socketUrl?: string;\n\n @consume({ context: socketProxyContext, subscribe: true })\n @state()\n _socketProxy?: ProxyOptions;\n\n @consume({ context: debugDisplayAudioContext, subscribe: true })\n @state()\n _debug_displayAudio?: boolean;\n\n @consume({ context: pushToTalkKeybindingContext, subscribe: true })\n @state()\n _pushToTalkKeybinding?: string | null;\n\n @consume({ context: toggleToTalkKeybindingContext, subscribe: true })\n @state()\n _toggleToTalkKeybinding?: string | null;\n\n @property({ type: Boolean })\n allowButtonFocus: boolean = false;\n\n #mediaController = new MediaController(this);\n #dictationController = new DictationController(this);\n #keybindingController = new KeybindingController(this);\n #closeConnectionOnInit = false;\n #processing = false;\n #connection: RecordingStateChangedEventDetail[\"connection\"] = \"CLOSED\";\n\n static styles: CSSResultGroup = [RecordingButtonStyles, ButtonStyles];\n\n protected update(changedProperties: PropertyValues) {\n if (\n changedProperties.has(\"_recordingState\") &&\n this._recordingState === \"recording\" &&\n this.#closeConnectionOnInit\n ) {\n this.#closeConnectionOnInit = false;\n this.#handleStop();\n }\n\n super.update(changedProperties);\n }\n\n #handleClick(event: MouseEvent): void {\n if (!this.allowButtonFocus) {\n event.preventDefault();\n }\n\n this.toggleRecording();\n }\n\n #handleWebSocketMessage = (message: TranscribeMessage): void => {\n switch (message.type) {\n case \"CONFIG_ACCEPTED\":\n this.#mediaController.addDataHandler(\n this.#dictationController.mediaRecorderHandler,\n );\n\n if (this._recordingState === \"initializing\") {\n this.#processing = true;\n this.#dispatchRecordingStateChanged(\"recording\");\n }\n break;\n case \"CONFIG_DENIED\":\n this.dispatchEvent(\n errorEvent(`Config denied: ${message.reason ?? \"Unknown reason\"}`),\n );\n this.#handleStop();\n break;\n case \"CONFIG_TIMEOUT\":\n this.dispatchEvent(errorEvent(\"Config timeout\"));\n this.#handleStop();\n break;\n case \"transcript\":\n this.dispatchEvent(transcriptEvent(message));\n break;\n case \"command\":\n this.dispatchEvent(commandEvent(message));\n break;\n case \"usage\":\n this.dispatchEvent(usageEvent(message));\n break;\n case \"error\":\n this.dispatchEvent(errorEvent(message.error));\n this.#handleStop();\n break;\n case \"flushed\":\n if (\n this._recordingState === \"stopped\" ||\n this._recordingState === \"stopping\"\n ) {\n this.#processing = false;\n this.#dispatchRecordingStateChanged(this._recordingState);\n }\n break;\n }\n };\n\n #handleWebSocketError = (error: Error): void => {\n this.dispatchEvent(errorEvent(\"Socket error: \" + error.message));\n this.#processing = false;\n this.#connection = \"CLOSED\";\n this.#handleStop();\n };\n\n #handleWebSocketClose = (event: unknown): void => {\n // When we already have new socket opened\n if (this.#dictationController.isConnectionOpen()) {\n return;\n }\n\n this.#processing = false;\n this.#connection = \"CLOSED\";\n this.dispatchEvent(streamClosedEvent(event));\n this.#dispatchRecordingStateChanged(this._recordingState);\n };\n\n #dispatchRecordingStateChanged(state: RecordingState): void {\n this.dispatchEvent(\n recordingStateChangedEvent(state, {\n connection: this.#connection,\n processing: this.#processing,\n }),\n );\n }\n\n async #handleStart(): Promise<void> {\n this.#dispatchRecordingStateChanged(\"initializing\");\n\n try {\n await this.#mediaController.initialize(() => {\n if (this._recordingState === \"recording\") {\n this.dispatchEvent(errorEvent(\"Recording device access was lost.\"));\n this.#handleStop();\n }\n });\n this.#mediaController.mediaRecorder?.start(AUDIO_CHUNK_INTERVAL_MS);\n this.#mediaController.startAudioLevelMonitoring((level) => {\n this.dispatchEvent(audioLevelChangedEvent(level));\n });\n\n if (this.#connection !== \"OPEN\") {\n this.#connection = \"CONNECTING\";\n }\n\n this.#dispatchRecordingStateChanged(\"recording\");\n\n const isNewConnection = await this.#dictationController.connect(\n this._dictationConfig,\n {\n onClose: this.#handleWebSocketClose,\n onError: this.#handleWebSocketError,\n onMessage: this.#handleWebSocketMessage,\n onNetworkActivity: (direction, data) => {\n this.dispatchEvent(networkActivityEvent(direction, data));\n },\n },\n );\n\n if (!isNewConnection) {\n this.#mediaController.addDataHandler(\n this.#dictationController.mediaRecorderHandler,\n );\n this.#processing = true;\n }\n\n this.#connection = \"OPEN\";\n\n this.#dispatchRecordingStateChanged(\"recording\");\n } catch (error) {\n this.dispatchEvent(errorEvent(error));\n await this.#handleStop();\n }\n }\n\n async #handleStop(): Promise<void> {\n this.#dispatchRecordingStateChanged(\"stopping\");\n\n try {\n this.#mediaController.stopAudioLevelMonitoring();\n await this.#mediaController.stopRecording();\n this.#mediaController.removeDataHandler();\n\n this.#dispatchRecordingStateChanged(\"stopped\");\n\n await this.#dictationController.pause();\n await this.#mediaController.cleanup();\n } catch (error) {\n this.dispatchEvent(errorEvent(error));\n }\n }\n\n public startRecording(): void {\n if (this._recordingState !== \"stopped\") {\n return;\n }\n\n this.#handleStart();\n }\n\n public stopRecording(): void {\n if (\n this._recordingState === \"stopped\" ||\n this._recordingState === \"stopping\"\n ) {\n return;\n }\n\n if (this._recordingState === \"initializing\") {\n this.#closeConnectionOnInit = true;\n return;\n }\n\n this.#handleStop();\n }\n\n public toggleRecording(): void {\n if (this._recordingState === \"stopped\") {\n this.startRecording();\n } else if (this._recordingState === \"recording\") {\n this.stopRecording();\n }\n }\n\n public async openConnection(): Promise<void> {\n if (this._recordingState !== \"stopped\" || this.#processing) {\n return;\n }\n\n if (this.#dictationController.isConnectionOpen()) {\n return;\n }\n\n try {\n this.#connection = \"CONNECTING\";\n this.#dispatchRecordingStateChanged(\"stopped\");\n\n await this.#dictationController.connect(this._dictationConfig, {\n onClose: this.#handleWebSocketClose,\n onError: this.#handleWebSocketError,\n onMessage: this.#handleWebSocketMessage,\n onNetworkActivity: (direction, data) => {\n this.dispatchEvent(networkActivityEvent(direction, data));\n },\n });\n\n this.#connection = \"OPEN\";\n this.#dispatchRecordingStateChanged(\"stopped\");\n } catch (error) {\n this.#connection = \"CLOSED\";\n this.dispatchEvent(errorEvent(error));\n }\n }\n\n public async closeConnection(): Promise<void> {\n if (this._recordingState !== \"stopped\" || this.#processing) {\n return;\n }\n\n if (!this.#dictationController.isConnectionOpen()) {\n this.#connection = \"CLOSED\";\n this.#dispatchRecordingStateChanged(\"stopped\");\n return;\n }\n\n try {\n this.#connection = \"CLOSING\";\n this.#dispatchRecordingStateChanged(\"stopped\");\n await this.#dictationController.closeConnection(\n this.#handleWebSocketClose,\n );\n } catch (error) {\n this.dispatchEvent(errorEvent(error));\n }\n }\n\n render() {\n const isLoading =\n this._recordingState === \"initializing\" ||\n this._recordingState === \"stopping\";\n const isRecording = this._recordingState === \"recording\";\n\n return html`\n <button\n @click=${this.#handleClick}\n ?disabled=${isLoading}\n class=${isRecording ? \"red\" : \"accent\"}\n aria-label=${isRecording ? \"Stop recording\" : \"Start recording\"}\n aria-pressed=${isRecording}\n >\n ${\n isLoading\n ? html`<icon-loading-spinner />`\n : isRecording\n ? html`<icon-recording />`\n : html`<icon-mic-on />`\n }\n <dictation-audio-visualiser\n .level=${this.#mediaController.audioLevel}\n ?active=${isRecording}\n />\n </button>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"dictation-recording-button\": DictationRecordingButton;\n }\n}\n"]}
1
+ {"version":3,"file":"recording-button.js","sourceRoot":"","sources":["../../src/components/recording-button.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AACA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAEL,IAAI,EACJ,UAAU,GAEX,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,wBAAwB,EACxB,sBAAsB,EACtB,2BAA2B,EAC3B,qBAAqB,EACrB,aAA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AAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IACvD,KAAK,EAAE;4DACY;AAIpB;IAFC,OAAO,CAAC,EAAE,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IACzD,KAAK,EAAE;8DACoB;AAI5B;IAFC,OAAO,CAAC,EAAE,OAAO,EAAE,wBAAwB,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IAC/D,KAAK,EAAE;qEACsB;AAI9B;IAFC,OAAO,CAAC,EAAE,OAAO,EAAE,2BAA2B,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IAClE,KAAK,EAAE;uEAC8B;AAItC;IAFC,OAAO,CAAC,EAAE,OAAO,EAAE,6BAA6B,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IACpE,KAAK,EAAE;yEACgC;AAGxC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;kEACM;AAlDvB,wBAAwB;IADpC,aAAa,CAAC,4BAA4B,CAAC;GAC/B,wBAAwB,CA6UpC","sourcesContent":["import type { Corti, CortiAuth } from \"@corti/sdk\";\nimport { consume } from \"@lit/context\";\nimport {\n type CSSResultGroup,\n html,\n LitElement,\n type PropertyValues,\n} from \"lit\";\nimport { customElement, property, state } from \"lit/decorators.js\";\nimport { AUDIO_CHUNK_INTERVAL_MS } from \"../constants.js\";\nimport {\n accessTokenContext,\n authConfigContext,\n debugDisplayAudioContext,\n dictationConfigContext,\n pushToTalkKeybindingContext,\n recordingStateContext,\n regionContext,\n selectedDeviceContext,\n socketProxyContext,\n socketUrlContext,\n tenantNameContext,\n toggleToTalkKeybindingContext,\n} from \"../contexts/dictation-context.js\";\nimport {\n DictationController,\n type TranscribeMessage,\n} from \"../controllers/dictation-controller.js\";\nimport { KeybindingController } from \"../controllers/keybinding-controller.js\";\nimport { MediaController } from \"../controllers/media-controller.js\";\nimport ButtonStyles from \"../styles/buttons.js\";\nimport RecordingButtonStyles from \"../styles/recording-button.js\";\nimport type { ProxyOptions, RecordingState } from \"../types.js\";\nimport {\n audioLevelChangedEvent,\n commandEvent,\n deltaUsageEvent,\n errorEvent,\n networkActivityEvent,\n type RecordingStateChangedEventDetail,\n recordingStateChangedEvent,\n streamClosedEvent,\n transcriptEvent,\n usageEvent,\n} from \"../utils/events.js\";\n\nimport \"./audio-visualiser.js\";\nimport \"../icons/icons.js\";\n\n@customElement(\"dictation-recording-button\")\nexport class DictationRecordingButton extends LitElement {\n @consume({ context: recordingStateContext, subscribe: true })\n @state()\n _recordingState: RecordingState = \"stopped\";\n\n @consume({ context: selectedDeviceContext, subscribe: true })\n @state()\n _selectedDevice?: MediaDeviceInfo;\n\n @consume({ context: accessTokenContext, subscribe: true })\n @state()\n _accessToken?: string;\n\n @consume({ context: authConfigContext, subscribe: true })\n @state()\n _authConfig?: CortiAuth.AuthTokenDerivable;\n\n @consume({ context: regionContext, subscribe: true })\n @state()\n _region?: string;\n\n @consume({ context: tenantNameContext, subscribe: true })\n @state()\n _tenantName?: string;\n\n @consume({ context: dictationConfigContext, subscribe: true })\n @state()\n _dictationConfig?: Corti.TranscribeConfig;\n\n @consume({ context: socketUrlContext, subscribe: true })\n @state()\n _socketUrl?: string;\n\n @consume({ context: socketProxyContext, subscribe: true })\n @state()\n _socketProxy?: ProxyOptions;\n\n @consume({ context: debugDisplayAudioContext, subscribe: true })\n @state()\n _debug_displayAudio?: boolean;\n\n @consume({ context: pushToTalkKeybindingContext, subscribe: true })\n @state()\n _pushToTalkKeybinding?: string | null;\n\n @consume({ context: toggleToTalkKeybindingContext, subscribe: true })\n @state()\n _toggleToTalkKeybinding?: string | null;\n\n @property({ type: Boolean })\n allowButtonFocus: boolean = false;\n\n #mediaController = new MediaController(this);\n #dictationController = new DictationController(this);\n #keybindingController = new KeybindingController(this);\n #closeConnectionOnInit = false;\n #processing = false;\n #connection: RecordingStateChangedEventDetail[\"connection\"] = \"CLOSED\";\n\n static styles: CSSResultGroup = [RecordingButtonStyles, ButtonStyles];\n\n protected update(changedProperties: PropertyValues) {\n if (\n changedProperties.has(\"_recordingState\") &&\n this._recordingState === \"recording\" &&\n this.#closeConnectionOnInit\n ) {\n this.#closeConnectionOnInit = false;\n this.#handleStop();\n }\n\n super.update(changedProperties);\n }\n\n #handleClick(event: MouseEvent): void {\n if (!this.allowButtonFocus) {\n event.preventDefault();\n }\n\n this.toggleRecording();\n }\n\n #handleWebSocketMessage = (message: TranscribeMessage): void => {\n switch (message.type) {\n case \"CONFIG_DENIED\":\n this.dispatchEvent(\n errorEvent(`Config denied: ${message.reason ?? \"Unknown reason\"}`),\n );\n this.#handleStop();\n break;\n case \"CONFIG_TIMEOUT\":\n this.dispatchEvent(errorEvent(\"Config timeout\"));\n this.#handleStop();\n break;\n case \"transcript\":\n this.dispatchEvent(transcriptEvent(message));\n break;\n case \"command\":\n this.dispatchEvent(commandEvent(message));\n break;\n case \"usage\":\n this.dispatchEvent(usageEvent(message));\n break;\n case \"delta_usage\":\n this.dispatchEvent(deltaUsageEvent(message));\n break;\n case \"error\":\n this.dispatchEvent(errorEvent(message.error));\n this.#handleStop();\n break;\n case \"flushed\":\n if (\n this._recordingState === \"stopped\" ||\n this._recordingState === \"stopping\"\n ) {\n this.#processing = false;\n this.#dispatchRecordingStateChanged(this._recordingState);\n }\n break;\n }\n };\n\n #handleWebSocketError = (error: Error): void => {\n this.dispatchEvent(errorEvent(\"Socket error: \" + error.message));\n this.#processing = false;\n this.#connection = \"CLOSED\";\n this.#handleStop();\n };\n\n #handleWebSocketClose = (event: unknown): void => {\n // When we already have new socket opened\n if (\n this.#dictationController.isConnectionOpen() ||\n this.#dictationController.isConnecting()\n ) {\n return;\n }\n\n this.#processing = false;\n this.#connection = \"CLOSED\";\n this.dispatchEvent(streamClosedEvent(event));\n this.#dispatchRecordingStateChanged(this._recordingState);\n };\n\n #dispatchRecordingStateChanged(state: RecordingState): void {\n this.dispatchEvent(\n recordingStateChangedEvent(state, {\n connection: this.#connection,\n processing: this.#processing,\n }),\n );\n }\n\n async #handleStart(): Promise<void> {\n this.#dispatchRecordingStateChanged(\"initializing\");\n\n try {\n await this.#mediaController.initialize(() => {\n if (this._recordingState === \"recording\") {\n this.dispatchEvent(errorEvent(\"Recording device access was lost.\"));\n this.#handleStop();\n }\n }, this.#dictationController.mediaRecorderHandler);\n this.#mediaController.mediaRecorder?.start(AUDIO_CHUNK_INTERVAL_MS);\n this.#mediaController.startAudioLevelMonitoring((level) => {\n this.dispatchEvent(audioLevelChangedEvent(level));\n });\n\n this.#processing = true;\n\n if (this.#connection !== \"OPEN\") {\n this.#connection = \"CONNECTING\";\n }\n\n this.#dispatchRecordingStateChanged(\"recording\");\n\n const isNewConnection = await this.#dictationController.connect(\n this._dictationConfig,\n {\n onClose: this.#handleWebSocketClose,\n onError: this.#handleWebSocketError,\n onMessage: this.#handleWebSocketMessage,\n onNetworkActivity: (direction, data) => {\n this.dispatchEvent(networkActivityEvent(direction, data));\n },\n },\n );\n\n if (isNewConnection === \"superseded\") {\n return;\n }\n\n this.#connection = \"OPEN\";\n\n this.#dispatchRecordingStateChanged(this._recordingState);\n } catch (error) {\n this.dispatchEvent(errorEvent(error));\n await this.#handleStop();\n }\n }\n\n async #handleStop(): Promise<void> {\n this.#dispatchRecordingStateChanged(\"stopping\");\n\n try {\n this.#mediaController.stopAudioLevelMonitoring();\n await this.#mediaController.stopRecording();\n\n this.#dispatchRecordingStateChanged(\"stopped\");\n\n await this.#dictationController.pause();\n await this.#mediaController.cleanup();\n } catch (error) {\n this.dispatchEvent(errorEvent(error));\n }\n }\n\n public startRecording(): void {\n if (this._recordingState !== \"stopped\") {\n return;\n }\n\n this.#handleStart();\n }\n\n public stopRecording(): void {\n if (\n this._recordingState === \"stopped\" ||\n this._recordingState === \"stopping\"\n ) {\n return;\n }\n\n if (this._recordingState === \"initializing\") {\n this.#closeConnectionOnInit = true;\n return;\n }\n\n this.#handleStop();\n }\n\n public toggleRecording(): void {\n if (this._recordingState === \"stopped\") {\n this.startRecording();\n } else if (this._recordingState === \"recording\") {\n this.stopRecording();\n }\n }\n\n public async openConnection(): Promise<void> {\n if (this._recordingState !== \"stopped\" || this.#processing) {\n return;\n }\n\n if (this.#dictationController.isConnectionOpen()) {\n return;\n }\n\n try {\n this.#connection = \"CONNECTING\";\n this.#dispatchRecordingStateChanged(this._recordingState);\n\n await this.#dictationController.connect(this._dictationConfig, {\n onClose: this.#handleWebSocketClose,\n onError: this.#handleWebSocketError,\n onMessage: this.#handleWebSocketMessage,\n onNetworkActivity: (direction, data) => {\n this.dispatchEvent(networkActivityEvent(direction, data));\n },\n });\n\n this.#connection = \"OPEN\";\n this.#dispatchRecordingStateChanged(this._recordingState);\n } catch (error) {\n this.#connection = \"CLOSED\";\n this.dispatchEvent(errorEvent(error));\n }\n }\n\n public async closeConnection(): Promise<void> {\n if (this._recordingState !== \"stopped\" || this.#processing) {\n return;\n }\n\n if (this.#dictationController.isConnecting()) {\n await this.#dictationController.waitForConnection();\n }\n\n if (!this.#dictationController.isConnectionOpen()) {\n this.#connection = \"CLOSED\";\n this.#dispatchRecordingStateChanged(\"stopped\");\n return;\n }\n\n try {\n this.#connection = \"CLOSING\";\n this.#dispatchRecordingStateChanged(\"stopped\");\n await this.#dictationController.closeConnection(\n this.#handleWebSocketClose,\n );\n } catch (error) {\n this.dispatchEvent(errorEvent(error));\n }\n }\n\n render() {\n const isLoading =\n this._recordingState === \"initializing\" ||\n this._recordingState === \"stopping\";\n const isRecording = this._recordingState === \"recording\";\n\n return html`\n <button\n @click=${this.#handleClick}\n ?disabled=${isLoading}\n class=${isRecording ? \"red\" : \"accent\"}\n aria-label=${isRecording ? \"Stop recording\" : \"Start recording\"}\n aria-pressed=${isRecording}\n >\n ${\n isLoading\n ? html`<icon-loading-spinner />`\n : isRecording\n ? html`<icon-recording />`\n : html`<icon-mic-on />`\n }\n <dictation-audio-visualiser\n .level=${this.#mediaController.audioLevel}\n ?active=${isRecording}\n />\n </button>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"dictation-recording-button\": DictationRecordingButton;\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { Corti } from "@corti/sdk";
1
+ import type { Corti, CortiAuth } from "@corti/sdk";
2
2
  import { type CSSResultGroup, LitElement } from "lit";
3
3
  import type { ProxyOptions, RecordingState } from "../types.js";
4
4
  export declare const regionContext: {
@@ -26,7 +26,7 @@ export declare const dictationConfigContext: {
26
26
  __context__: Corti.TranscribeConfig | undefined;
27
27
  };
28
28
  export declare const authConfigContext: {
29
- __context__: Corti.BearerOptions | undefined;
29
+ __context__: CortiAuth.AuthTokenDerivable | undefined;
30
30
  };
31
31
  export declare const socketUrlContext: {
32
32
  __context__: string | undefined;
@@ -51,9 +51,9 @@ export declare class DictationRoot extends LitElement {
51
51
  _accessToken?: string;
52
52
  set accessToken(token: string | undefined);
53
53
  get accessToken(): string | undefined;
54
- _authConfig?: Corti.BearerOptions;
55
- set authConfig(config: Corti.BearerOptions | undefined);
56
- get authConfig(): Corti.BearerOptions | undefined;
54
+ _authConfig?: CortiAuth.AuthTokenDerivable;
55
+ set authConfig(config: CortiAuth.AuthTokenDerivable | undefined);
56
+ get authConfig(): CortiAuth.AuthTokenDerivable | undefined;
57
57
  socketUrl?: string;
58
58
  socketProxy?: ProxyOptions;
59
59
  dictationConfig?: Corti.TranscribeConfig;
@@ -89,7 +89,7 @@ export declare class DictationRoot extends LitElement {
89
89
  * @returns Promise with ServerConfig containing environment, tenant, and accessToken
90
90
  * @deprecated Use 'authConfig' property instead.
91
91
  */
92
- setAuthConfig(config?: Corti.BearerOptions): Promise<{
92
+ setAuthConfig(config?: CortiAuth.AuthTokenDerivable): Promise<{
93
93
  accessToken: string | undefined;
94
94
  environment: undefined;
95
95
  tenant: undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"dictation-context.js","sourceRoot":"","sources":["../../src/contexts/dictation-context.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,OAAO,EAAqB,aAAa,EAAE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O,CAAC,EAAE,OAAO,EAAE,wBAAwB,EAAE,CAAC;IAC9C,QAAQ,CAAC,EAAE,SAAS,EAAE,qBAAqB,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;yDACjC;AAI7B;IAFC,OAAO,CAAC,EAAE,OAAO,EAAE,2BAA2B,EAAE,CAAC;IACjD,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2DACU;AAIrC;IAFC,OAAO,CAAC,EAAE,OAAO,EAAE,6BAA6B,EAAE,CAAC;IACnD,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6DACY;AAGvC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;gDACD;AAtHhB,aAAa;IADzB,aAAa,CAAC,gBAAgB,CAAC;GACnB,aAAa,CAoSzB","sourcesContent":["import type { Corti } from \"@corti/sdk\";\nimport { type ContextEvent, createContext, provide } from \"@lit/context\";\nimport { type CSSResultGroup, html, LitElement } from \"lit\";\nimport { customElement, property, state } from \"lit/decorators.js\";\nimport { DevicesController } from \"../controllers/devices-controller.js\";\nimport { LanguagesController } from \"../controllers/languages-controller.js\";\nimport ComponentStyles from \"../styles/component-styles.js\";\nimport type { ProxyOptions, RecordingState } from \"../types.js\";\nimport { getInitialToken } from \"../utils/auth.js\";\nimport { commaSeparatedConverter } from \"../utils/converters.js\";\nimport {\n errorEvent,\n type KeybindingChangedEventDetail,\n keybindingChangedEvent,\n} from \"../utils/events.js\";\nimport { decodeToken } from \"../utils/token.js\";\n\nexport const regionContext = createContext<string | undefined>(\n Symbol(\"region\"),\n);\nexport const tenantNameContext = createContext<string | undefined>(\n Symbol(\"tenantName\"),\n);\nexport const languagesContext = createContext<\n Corti.TranscribeSupportedLanguage[] | undefined\n>(Symbol(\"languages\"));\nexport const devicesContext = createContext<MediaDeviceInfo[] | undefined>(\n Symbol(\"devices\"),\n);\nexport const selectedDeviceContext = createContext<MediaDeviceInfo | undefined>(\n Symbol(\"selectedDevice\"),\n);\nexport const recordingStateContext = createContext<RecordingState>(\n Symbol(\"recordingState\"),\n);\nexport const accessTokenContext = createContext<string | undefined>(\n Symbol(\"accessToken\"),\n);\nexport const dictationConfigContext = createContext<\n Corti.TranscribeConfig | undefined\n>(Symbol(\"dictationConfig\"));\nexport const authConfigContext = createContext<Corti.BearerOptions | undefined>(\n Symbol(\"authConfig\"),\n);\nexport const socketUrlContext = createContext<string | undefined>(\n Symbol(\"socketUrl\"),\n);\nexport const socketProxyContext = createContext<ProxyOptions | undefined>(\n Symbol(\"socketProxy\"),\n);\nexport const debugDisplayAudioContext = createContext<boolean | undefined>(\n Symbol(\"debugDisplayAudio\"),\n);\nexport const pushToTalkKeybindingContext = createContext<\n string | null | undefined\n>(Symbol(\"pushToTalkKeybinding\"));\nexport const toggleToTalkKeybindingContext = createContext<\n string | null | undefined\n>(Symbol(\"toggleToTalkKeybinding\"));\n\n@customElement(\"dictation-root\")\nexport class DictationRoot extends LitElement {\n // ─────────────────────────────────────────────────────────────────────────────\n // Context state\n // ─────────────────────────────────────────────────────────────────────────────\n\n @provide({ context: regionContext })\n @state()\n region?: string;\n\n @provide({ context: tenantNameContext })\n @state()\n tenantName?: string;\n\n @provide({ context: recordingStateContext })\n @state()\n recordingState: RecordingState = \"stopped\";\n\n // ─────────────────────────────────────────────────────────────────────────────\n // Properties\n // ─────────────────────────────────────────────────────────────────────────────\n\n @provide({ context: accessTokenContext })\n @state()\n _accessToken?: string;\n\n @property({ type: String })\n set accessToken(token: string | undefined) {\n this.setAccessToken(token);\n }\n\n get accessToken(): string | undefined {\n return this._accessToken;\n }\n\n @provide({ context: authConfigContext })\n @state()\n _authConfig?: Corti.BearerOptions;\n\n @property({ attribute: false, type: Object })\n set authConfig(config: Corti.BearerOptions | undefined) {\n this.setAuthConfig(config);\n }\n\n get authConfig(): Corti.BearerOptions | undefined {\n return this._authConfig;\n }\n\n @provide({ context: socketUrlContext })\n @property({ type: String })\n socketUrl?: string;\n\n @provide({ context: socketProxyContext })\n @property({ attribute: false, type: Object })\n socketProxy?: ProxyOptions;\n\n @provide({ context: dictationConfigContext })\n @property({ attribute: false, type: Object })\n dictationConfig?: Corti.TranscribeConfig;\n\n #languagesController = new LanguagesController(this);\n #devicesController = new DevicesController(this);\n\n @provide({ context: languagesContext })\n @state()\n _languages?: Corti.TranscribeSupportedLanguage[];\n\n @property({\n converter: commaSeparatedConverter,\n type: Array,\n })\n set languages(value: Corti.TranscribeSupportedLanguage[] | undefined) {\n this._languages = value;\n\n // Clear auto-loaded flag when languages are set via property\n if (value !== undefined) {\n this.#languagesController.clearAutoLoadedFlag();\n }\n }\n\n get languages(): Corti.TranscribeSupportedLanguage[] | undefined {\n return this._languages;\n }\n\n @provide({ context: devicesContext })\n @state()\n _devices?: MediaDeviceInfo[];\n\n @property({ attribute: false, type: Array })\n set devices(value: MediaDeviceInfo[] | undefined) {\n this._devices = value;\n\n // Clear auto-loaded flag when devices are set via property\n if (value !== undefined) {\n this.#devicesController.clearAutoLoadedFlag();\n }\n }\n\n get devices(): MediaDeviceInfo[] | undefined {\n return this._devices;\n }\n\n @provide({ context: selectedDeviceContext })\n @property({ attribute: false, type: Object })\n selectedDevice?: MediaDeviceInfo;\n\n @provide({ context: debugDisplayAudioContext })\n @property({ attribute: \"debug-display-audio\", type: Boolean })\n debug_displayAudio?: boolean;\n\n @provide({ context: pushToTalkKeybindingContext })\n @property({ type: String })\n pushToTalkKeybinding?: string | null;\n\n @provide({ context: toggleToTalkKeybindingContext })\n @property({ type: String })\n toggleToTalkKeybinding?: string | null;\n\n @property({ type: Boolean })\n noWrapper: boolean = false;\n\n // ─────────────────────────────────────────────────────────────────────────────\n // Static\n // ─────────────────────────────────────────────────────────────────────────────\n\n static styles: CSSResultGroup = [ComponentStyles];\n\n // ─────────────────────────────────────────────────────────────────────────────\n // Lifecycle\n // ─────────────────────────────────────────────────────────────────────────────\n\n constructor() {\n super();\n this.addEventListener(\"languages-changed\", this.#handleLanguageChanged);\n this.addEventListener(\n \"recording-devices-changed\",\n this.#handleDeviceChanged,\n );\n this.addEventListener(\n \"recording-state-changed\",\n this.#handleRecordingStateChanged,\n );\n this.addEventListener(\"context-request\", this.#handleContextRequest);\n this.addEventListener(\"keybinding-changed\", this.#handleKeybindingChanged);\n }\n\n // ─────────────────────────────────────────────────────────────────────────────\n // Public methods\n // ─────────────────────────────────────────────────────────────────────────────\n\n /**\n * Sets the access token and parses region/tenant from it.\n * @returns ServerConfig with environment, tenant, and accessToken\n * @deprecated Use 'accessToken' property instead.\n */\n public setAccessToken(token: string | undefined) {\n this._accessToken = token;\n this.region = undefined;\n this.tenantName = undefined;\n\n if (!token) {\n return { accessToken: token, environment: undefined, tenant: undefined };\n }\n\n try {\n const decoded = decodeToken(token);\n\n this.region = decoded?.environment;\n this.tenantName = decoded?.tenant;\n\n return {\n accessToken: token,\n environment: decoded?.environment,\n tenant: decoded?.tenant,\n };\n } catch (error) {\n this.dispatchEvent(errorEvent(error));\n }\n\n return { accessToken: token, environment: undefined, tenant: undefined };\n }\n\n /**\n * Sets the auth config and parses region/tenant from the initial token.\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 if (!config) {\n return {\n accessToken: undefined,\n environment: undefined,\n tenant: undefined,\n };\n }\n\n try {\n const { accessToken } = await getInitialToken(config);\n\n return this.setAccessToken(accessToken);\n } catch (error) {\n this.dispatchEvent(errorEvent(error));\n }\n\n return {\n accessToken: undefined,\n environment: undefined,\n tenant: undefined,\n };\n }\n\n // ─────────────────────────────────────────────────────────────────────────────\n // Private event handlers\n // ─────────────────────────────────────────────────────────────────────────────\n\n #handleLanguageChanged = (e: Event) => {\n const event = e as CustomEvent;\n\n this.dictationConfig = {\n ...this.dictationConfig,\n primaryLanguage: event.detail.selectedLanguage,\n };\n };\n\n #handleDeviceChanged = (e: Event) => {\n const event = e as CustomEvent;\n\n this.selectedDevice = event.detail.selectedDevice;\n };\n\n #handleRecordingStateChanged = (e: Event) => {\n const event = e as CustomEvent;\n\n this.recordingState = event.detail.state;\n };\n\n #handleContextRequest = (e: ContextEvent<any>) => {\n if (e.context === languagesContext) {\n this.#languagesController.initialize();\n } else if (e.context === devicesContext) {\n this.#devicesController.initialize();\n } else if (\n e.contextTarget.tagName.toLowerCase() === \"dictation-keybinding-selector\"\n ) {\n if (\n e.context === pushToTalkKeybindingContext &&\n this.pushToTalkKeybinding === undefined\n ) {\n this.pushToTalkKeybinding = \"Space\";\n this.dispatchEvent(\n keybindingChangedEvent(\" \", \"Space\", \"Space\", \"push-to-talk\"),\n );\n }\n\n if (\n e.context === toggleToTalkKeybindingContext &&\n this.toggleToTalkKeybinding === undefined\n ) {\n this.toggleToTalkKeybinding = \"Enter\";\n this.dispatchEvent(\n keybindingChangedEvent(\"Enter\", \"Enter\", \"Enter\", \"toggle-to-talk\"),\n );\n }\n }\n };\n\n #handleKeybindingChanged = (e: Event) => {\n const event = e as CustomEvent<KeybindingChangedEventDetail>;\n\n const keybinding = event.detail.keybinding;\n\n if (event.detail.type === \"push-to-talk\") {\n this.pushToTalkKeybinding = keybinding;\n } else if (event.detail.type === \"toggle-to-talk\") {\n this.toggleToTalkKeybinding = keybinding;\n }\n };\n\n // ─────────────────────────────────────────────────────────────────────────────\n // Render\n // ─────────────────────────────────────────────────────────────────────────────\n\n render() {\n if (this.noWrapper) {\n return html`<slot></slot>`;\n }\n\n return html`<div class=\"wrapper\">\n <slot></slot>\n </div>`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"dictation-root\": DictationRoot;\n }\n}\n"]}
1
+ {"version":3,"file":"dictation-context.js","sourceRoot":"","sources":["../../src/contexts/dictation-context.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,OAAO,EAAqB,aAAa,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACzE,OAAO,EAAuB,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,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,qBAAqB,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;yDACjC;AAI7B;IAFC,OAAO,CAAC,EAAE,OAAO,EAAE,2BAA2B,EAAE,CAAC;IACjD,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2DACU;AAIrC;IAFC,OAAO,CAAC,EAAE,OAAO,EAAE,6BAA6B,EAAE,CAAC;IACnD,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6DACY;AAGvC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;gDACD;AAtHhB,aAAa;IADzB,aAAa,CAAC,gBAAgB,CAAC;GACnB,aAAa,CAoSzB","sourcesContent":["import type { Corti, CortiAuth } from \"@corti/sdk\";\nimport { type ContextEvent, createContext, provide } from \"@lit/context\";\nimport { type CSSResultGroup, html, LitElement } from \"lit\";\nimport { customElement, property, state } from \"lit/decorators.js\";\nimport { DevicesController } from \"../controllers/devices-controller.js\";\nimport { LanguagesController } from \"../controllers/languages-controller.js\";\nimport ComponentStyles from \"../styles/component-styles.js\";\nimport type { ProxyOptions, RecordingState } from \"../types.js\";\nimport { getInitialToken } from \"../utils/auth.js\";\nimport { commaSeparatedConverter } from \"../utils/converters.js\";\nimport {\n errorEvent,\n type KeybindingChangedEventDetail,\n keybindingChangedEvent,\n} from \"../utils/events.js\";\nimport { decodeToken } from \"../utils/token.js\";\n\nexport const regionContext = createContext<string | undefined>(\n Symbol(\"region\"),\n);\nexport const tenantNameContext = createContext<string | undefined>(\n Symbol(\"tenantName\"),\n);\nexport const languagesContext = createContext<\n Corti.TranscribeSupportedLanguage[] | undefined\n>(Symbol(\"languages\"));\nexport const devicesContext = createContext<MediaDeviceInfo[] | undefined>(\n Symbol(\"devices\"),\n);\nexport const selectedDeviceContext = createContext<MediaDeviceInfo | undefined>(\n Symbol(\"selectedDevice\"),\n);\nexport const recordingStateContext = createContext<RecordingState>(\n Symbol(\"recordingState\"),\n);\nexport const accessTokenContext = createContext<string | undefined>(\n Symbol(\"accessToken\"),\n);\nexport const dictationConfigContext = createContext<\n Corti.TranscribeConfig | undefined\n>(Symbol(\"dictationConfig\"));\nexport const authConfigContext = createContext<\n CortiAuth.AuthTokenDerivable | undefined\n>(Symbol(\"authConfig\"));\nexport const socketUrlContext = createContext<string | undefined>(\n Symbol(\"socketUrl\"),\n);\nexport const socketProxyContext = createContext<ProxyOptions | undefined>(\n Symbol(\"socketProxy\"),\n);\nexport const debugDisplayAudioContext = createContext<boolean | undefined>(\n Symbol(\"debugDisplayAudio\"),\n);\nexport const pushToTalkKeybindingContext = createContext<\n string | null | undefined\n>(Symbol(\"pushToTalkKeybinding\"));\nexport const toggleToTalkKeybindingContext = createContext<\n string | null | undefined\n>(Symbol(\"toggleToTalkKeybinding\"));\n\n@customElement(\"dictation-root\")\nexport class DictationRoot extends LitElement {\n // ─────────────────────────────────────────────────────────────────────────────\n // Context state\n // ─────────────────────────────────────────────────────────────────────────────\n\n @provide({ context: regionContext })\n @state()\n region?: string;\n\n @provide({ context: tenantNameContext })\n @state()\n tenantName?: string;\n\n @provide({ context: recordingStateContext })\n @state()\n recordingState: RecordingState = \"stopped\";\n\n // ─────────────────────────────────────────────────────────────────────────────\n // Properties\n // ─────────────────────────────────────────────────────────────────────────────\n\n @provide({ context: accessTokenContext })\n @state()\n _accessToken?: string;\n\n @property({ type: String })\n set accessToken(token: string | undefined) {\n this.setAccessToken(token);\n }\n\n get accessToken(): string | undefined {\n return this._accessToken;\n }\n\n @provide({ context: authConfigContext })\n @state()\n _authConfig?: CortiAuth.AuthTokenDerivable;\n\n @property({ attribute: false, type: Object })\n set authConfig(config: CortiAuth.AuthTokenDerivable | undefined) {\n this.setAuthConfig(config);\n }\n\n get authConfig(): CortiAuth.AuthTokenDerivable | undefined {\n return this._authConfig;\n }\n\n @provide({ context: socketUrlContext })\n @property({ type: String })\n socketUrl?: string;\n\n @provide({ context: socketProxyContext })\n @property({ attribute: false, type: Object })\n socketProxy?: ProxyOptions;\n\n @provide({ context: dictationConfigContext })\n @property({ attribute: false, type: Object })\n dictationConfig?: Corti.TranscribeConfig;\n\n #languagesController = new LanguagesController(this);\n #devicesController = new DevicesController(this);\n\n @provide({ context: languagesContext })\n @state()\n _languages?: Corti.TranscribeSupportedLanguage[];\n\n @property({\n converter: commaSeparatedConverter,\n type: Array,\n })\n set languages(value: Corti.TranscribeSupportedLanguage[] | undefined) {\n this._languages = value;\n\n // Clear auto-loaded flag when languages are set via property\n if (value !== undefined) {\n this.#languagesController.clearAutoLoadedFlag();\n }\n }\n\n get languages(): Corti.TranscribeSupportedLanguage[] | undefined {\n return this._languages;\n }\n\n @provide({ context: devicesContext })\n @state()\n _devices?: MediaDeviceInfo[];\n\n @property({ attribute: false, type: Array })\n set devices(value: MediaDeviceInfo[] | undefined) {\n this._devices = value;\n\n // Clear auto-loaded flag when devices are set via property\n if (value !== undefined) {\n this.#devicesController.clearAutoLoadedFlag();\n }\n }\n\n get devices(): MediaDeviceInfo[] | undefined {\n return this._devices;\n }\n\n @provide({ context: selectedDeviceContext })\n @property({ attribute: false, type: Object })\n selectedDevice?: MediaDeviceInfo;\n\n @provide({ context: debugDisplayAudioContext })\n @property({ attribute: \"debug-display-audio\", type: Boolean })\n debug_displayAudio?: boolean;\n\n @provide({ context: pushToTalkKeybindingContext })\n @property({ type: String })\n pushToTalkKeybinding?: string | null;\n\n @provide({ context: toggleToTalkKeybindingContext })\n @property({ type: String })\n toggleToTalkKeybinding?: string | null;\n\n @property({ type: Boolean })\n noWrapper: boolean = false;\n\n // ─────────────────────────────────────────────────────────────────────────────\n // Static\n // ─────────────────────────────────────────────────────────────────────────────\n\n static styles: CSSResultGroup = [ComponentStyles];\n\n // ─────────────────────────────────────────────────────────────────────────────\n // Lifecycle\n // ─────────────────────────────────────────────────────────────────────────────\n\n constructor() {\n super();\n this.addEventListener(\"languages-changed\", this.#handleLanguageChanged);\n this.addEventListener(\n \"recording-devices-changed\",\n this.#handleDeviceChanged,\n );\n this.addEventListener(\n \"recording-state-changed\",\n this.#handleRecordingStateChanged,\n );\n this.addEventListener(\"context-request\", this.#handleContextRequest);\n this.addEventListener(\"keybinding-changed\", this.#handleKeybindingChanged);\n }\n\n // ─────────────────────────────────────────────────────────────────────────────\n // Public methods\n // ─────────────────────────────────────────────────────────────────────────────\n\n /**\n * Sets the access token and parses region/tenant from it.\n * @returns ServerConfig with environment, tenant, and accessToken\n * @deprecated Use 'accessToken' property instead.\n */\n public setAccessToken(token: string | undefined) {\n this._accessToken = token;\n this.region = undefined;\n this.tenantName = undefined;\n\n if (!token) {\n return { accessToken: token, environment: undefined, tenant: undefined };\n }\n\n try {\n const decoded = decodeToken(token);\n\n this.region = decoded?.environment;\n this.tenantName = decoded?.tenant;\n\n return {\n accessToken: token,\n environment: decoded?.environment,\n tenant: decoded?.tenant,\n };\n } catch (error) {\n this.dispatchEvent(errorEvent(error));\n }\n\n return { accessToken: token, environment: undefined, tenant: undefined };\n }\n\n /**\n * Sets the auth config and parses region/tenant from the initial token.\n * @returns Promise with ServerConfig containing environment, tenant, and accessToken\n * @deprecated Use 'authConfig' property instead.\n */\n public async setAuthConfig(config?: CortiAuth.AuthTokenDerivable) {\n this._authConfig = config;\n\n if (!config) {\n return {\n accessToken: undefined,\n environment: undefined,\n tenant: undefined,\n };\n }\n\n try {\n const { accessToken } = await getInitialToken(config);\n\n return this.setAccessToken(accessToken);\n } catch (error) {\n this.dispatchEvent(errorEvent(error));\n }\n\n return {\n accessToken: undefined,\n environment: undefined,\n tenant: undefined,\n };\n }\n\n // ─────────────────────────────────────────────────────────────────────────────\n // Private event handlers\n // ─────────────────────────────────────────────────────────────────────────────\n\n #handleLanguageChanged = (e: Event) => {\n const event = e as CustomEvent;\n\n this.dictationConfig = {\n ...this.dictationConfig,\n primaryLanguage: event.detail.selectedLanguage,\n };\n };\n\n #handleDeviceChanged = (e: Event) => {\n const event = e as CustomEvent;\n\n this.selectedDevice = event.detail.selectedDevice;\n };\n\n #handleRecordingStateChanged = (e: Event) => {\n const event = e as CustomEvent;\n\n this.recordingState = event.detail.state;\n };\n\n #handleContextRequest = (e: ContextEvent<any>) => {\n if (e.context === languagesContext) {\n this.#languagesController.initialize();\n } else if (e.context === devicesContext) {\n this.#devicesController.initialize();\n } else if (\n e.contextTarget.tagName.toLowerCase() === \"dictation-keybinding-selector\"\n ) {\n if (\n e.context === pushToTalkKeybindingContext &&\n this.pushToTalkKeybinding === undefined\n ) {\n this.pushToTalkKeybinding = \"Space\";\n this.dispatchEvent(\n keybindingChangedEvent(\" \", \"Space\", \"Space\", \"push-to-talk\"),\n );\n }\n\n if (\n e.context === toggleToTalkKeybindingContext &&\n this.toggleToTalkKeybinding === undefined\n ) {\n this.toggleToTalkKeybinding = \"Enter\";\n this.dispatchEvent(\n keybindingChangedEvent(\"Enter\", \"Enter\", \"Enter\", \"toggle-to-talk\"),\n );\n }\n }\n };\n\n #handleKeybindingChanged = (e: Event) => {\n const event = e as CustomEvent<KeybindingChangedEventDetail>;\n\n const keybinding = event.detail.keybinding;\n\n if (event.detail.type === \"push-to-talk\") {\n this.pushToTalkKeybinding = keybinding;\n } else if (event.detail.type === \"toggle-to-talk\") {\n this.toggleToTalkKeybinding = keybinding;\n }\n };\n\n // ─────────────────────────────────────────────────────────────────────────────\n // Render\n // ─────────────────────────────────────────────────────────────────────────────\n\n render() {\n if (this.noWrapper) {\n return html`<slot></slot>`;\n }\n\n return html`<div class=\"wrapper\">\n <slot></slot>\n </div>`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"dictation-root\": DictationRoot;\n }\n}\n"]}
@@ -1,16 +1,17 @@
1
- import { type Corti } from "@corti/sdk";
1
+ import { type Corti, type CortiAuth } from "@corti/sdk";
2
2
  import type { ReactiveController, ReactiveControllerHost } from "lit";
3
3
  import type { ProxyOptions } from "../types.js";
4
4
  interface DictationControllerHost extends ReactiveControllerHost {
5
+ dispatchEvent: (event: Event) => void;
5
6
  _accessToken?: string;
6
- _authConfig?: Corti.BearerOptions;
7
+ _authConfig?: CortiAuth.AuthTokenDerivable;
7
8
  _region?: string;
8
9
  _tenantName?: string;
9
10
  _socketUrl?: string;
10
11
  _socketProxy?: ProxyOptions;
11
12
  _dictationConfig?: Corti.TranscribeConfig;
12
13
  }
13
- export type TranscribeMessage = Corti.TranscribeConfigStatusMessage | Corti.TranscribeUsageMessage | Corti.TranscribeEndedMessage | Corti.TranscribeErrorMessage | Corti.TranscribeTranscriptMessage | Corti.TranscribeCommandMessage | Corti.TranscribeFlushedMessage;
14
+ export type TranscribeMessage = Corti.TranscribeConfigStatusMessage | Corti.TranscribeUsageMessage | Corti.TranscribeDeltaUsageMessage | Corti.TranscribeEndedMessage | Corti.TranscribeErrorMessage | Corti.TranscribeTranscriptMessage | Corti.TranscribeCommandMessage | Corti.TranscribeFlushedMessage;
14
15
  interface WebSocketCallbacks {
15
16
  onMessage?: (message: TranscribeMessage) => void;
16
17
  onError?: (error: Error) => void;
@@ -22,10 +23,12 @@ export declare class DictationController implements ReactiveController {
22
23
  host: DictationControllerHost;
23
24
  constructor(host: DictationControllerHost);
24
25
  hostDisconnected(): void;
25
- connect(dictationConfig?: Corti.TranscribeConfig, callbacks?: WebSocketCallbacks): Promise<boolean>;
26
+ connect(dictationConfig?: Corti.TranscribeConfig, callbacks?: WebSocketCallbacks): Promise<boolean | "superseded">;
26
27
  mediaRecorderHandler: (data: Blob) => void;
27
28
  pause(): Promise<void>;
28
29
  isConnectionOpen(): boolean;
30
+ isConnecting(): boolean;
31
+ waitForConnection(): Promise<void>;
29
32
  closeConnection(onClose?: (event: unknown) => void): Promise<void>;
30
33
  cleanup(): void;
31
34
  }