@corti/dictation-web 0.0.0-test.571 → 0.0.0-test.571.2

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 (153) hide show
  1. package/dist/bundle.js +37 -12
  2. package/dist/components/recording-button.d.ts +2 -1
  3. package/dist/components/recording-button.js +24 -13
  4. package/dist/components/recording-button.js.map +1 -1
  5. package/dist/controllers/keybinding-controller.d.ts +1 -0
  6. package/dist/controllers/keybinding-controller.js +7 -1
  7. package/dist/controllers/keybinding-controller.js.map +1 -1
  8. package/dist/index.d.ts +1 -1
  9. package/dist/index.js.map +1 -1
  10. package/dist/package.json +87 -7
  11. package/dist/styles/mode-selector.js +3 -1
  12. package/dist/styles/mode-selector.js.map +1 -1
  13. package/dist/tsconfig.tsbuildinfo +1 -0
  14. package/dist/utils/events.d.ts +4 -0
  15. package/dist/utils/events.js +8 -0
  16. package/dist/utils/events.js.map +1 -1
  17. package/dist/utils/keybinding.d.ts +0 -13
  18. package/dist/utils/keybinding.js +0 -15
  19. package/dist/utils/keybinding.js.map +1 -1
  20. package/package.json +1 -1
  21. package/dist/CortiDictation.d.ts +0 -55
  22. package/dist/CortiDictation.js +0 -303
  23. package/dist/CortiDictation.js.map +0 -1
  24. package/dist/DictationService.d.ts +0 -16
  25. package/dist/DictationService.js +0 -88
  26. package/dist/DictationService.js.map +0 -1
  27. package/dist/RecorderManager.d.ts +0 -25
  28. package/dist/RecorderManager.js +0 -145
  29. package/dist/RecorderManager.js.map +0 -1
  30. package/dist/audioService.d.ts +0 -6
  31. package/dist/audioService.js +0 -21
  32. package/dist/audioService.js.map +0 -1
  33. package/dist/controllers/DictationController.d.ts +0 -35
  34. package/dist/controllers/DictationController.js +0 -130
  35. package/dist/controllers/DictationController.js.map +0 -1
  36. package/dist/controllers/MediaController.d.ts +0 -31
  37. package/dist/controllers/MediaController.js +0 -99
  38. package/dist/controllers/MediaController.js.map +0 -1
  39. package/dist/src/components/audio-visualiser.d.ts +0 -14
  40. package/dist/src/components/audio-visualiser.js +0 -57
  41. package/dist/src/components/audio-visualiser.js.map +0 -1
  42. package/dist/src/components/corti-dictation.d.ts +0 -123
  43. package/dist/src/components/corti-dictation.js +0 -224
  44. package/dist/src/components/corti-dictation.js.map +0 -1
  45. package/dist/src/components/device-selector.d.ts +0 -24
  46. package/dist/src/components/device-selector.js +0 -106
  47. package/dist/src/components/device-selector.js.map +0 -1
  48. package/dist/src/components/language-selector.d.ts +0 -24
  49. package/dist/src/components/language-selector.js +0 -100
  50. package/dist/src/components/language-selector.js.map +0 -1
  51. package/dist/src/components/recording-button.d.ts +0 -37
  52. package/dist/src/components/recording-button.js +0 -203
  53. package/dist/src/components/recording-button.js.map +0 -1
  54. package/dist/src/components/settings-menu.d.ts +0 -16
  55. package/dist/src/components/settings-menu.js +0 -80
  56. package/dist/src/components/settings-menu.js.map +0 -1
  57. package/dist/src/constants.d.ts +0 -4
  58. package/dist/src/constants.js +0 -37
  59. package/dist/src/constants.js.map +0 -1
  60. package/dist/src/contexts/dictation-context.d.ts +0 -97
  61. package/dist/src/contexts/dictation-context.js +0 -208
  62. package/dist/src/contexts/dictation-context.js.map +0 -1
  63. package/dist/src/controllers/DictationController.d.ts +0 -35
  64. package/dist/src/controllers/DictationController.js +0 -130
  65. package/dist/src/controllers/DictationController.js.map +0 -1
  66. package/dist/src/controllers/MediaController.d.ts +0 -31
  67. package/dist/src/controllers/MediaController.js +0 -99
  68. package/dist/src/controllers/MediaController.js.map +0 -1
  69. package/dist/src/icons/icons.d.ts +0 -17
  70. package/dist/src/icons/icons.js +0 -158
  71. package/dist/src/icons/icons.js.map +0 -1
  72. package/dist/src/styles/ComponentStyles.d.ts +0 -2
  73. package/dist/src/styles/ComponentStyles.js +0 -18
  74. package/dist/src/styles/ComponentStyles.js.map +0 -1
  75. package/dist/src/styles/audio-visualiser.d.ts +0 -2
  76. package/dist/src/styles/audio-visualiser.js +0 -33
  77. package/dist/src/styles/audio-visualiser.js.map +0 -1
  78. package/dist/src/styles/buttons.d.ts +0 -2
  79. package/dist/src/styles/buttons.js +0 -52
  80. package/dist/src/styles/buttons.js.map +0 -1
  81. package/dist/src/styles/callout.d.ts +0 -2
  82. package/dist/src/styles/callout.js +0 -23
  83. package/dist/src/styles/callout.js.map +0 -1
  84. package/dist/src/styles/default-theme.d.ts +0 -2
  85. package/dist/src/styles/default-theme.js +0 -50
  86. package/dist/src/styles/default-theme.js.map +0 -1
  87. package/dist/src/styles/recording-button.d.ts +0 -2
  88. package/dist/src/styles/recording-button.js +0 -8
  89. package/dist/src/styles/recording-button.js.map +0 -1
  90. package/dist/src/styles/select.d.ts +0 -2
  91. package/dist/src/styles/select.js +0 -36
  92. package/dist/src/styles/select.js.map +0 -1
  93. package/dist/src/styles/settings-menu.d.ts +0 -2
  94. package/dist/src/styles/settings-menu.js +0 -34
  95. package/dist/src/styles/settings-menu.js.map +0 -1
  96. package/dist/src/types.d.ts +0 -7
  97. package/dist/src/types.js +0 -2
  98. package/dist/src/types.js.map +0 -1
  99. package/dist/src/utils/auth.d.ts +0 -9
  100. package/dist/src/utils/auth.js +0 -21
  101. package/dist/src/utils/auth.js.map +0 -1
  102. package/dist/src/utils/converters.d.ts +0 -4
  103. package/dist/src/utils/converters.js +0 -8
  104. package/dist/src/utils/converters.js.map +0 -1
  105. package/dist/src/utils/devices.d.ts +0 -26
  106. package/dist/src/utils/devices.js +0 -53
  107. package/dist/src/utils/devices.js.map +0 -1
  108. package/dist/src/utils/events.d.ts +0 -44
  109. package/dist/src/utils/events.js +0 -88
  110. package/dist/src/utils/events.js.map +0 -1
  111. package/dist/src/utils/languages.d.ts +0 -7
  112. package/dist/src/utils/languages.js +0 -29
  113. package/dist/src/utils/languages.js.map +0 -1
  114. package/dist/src/utils/media.d.ts +0 -6
  115. package/dist/src/utils/media.js +0 -39
  116. package/dist/src/utils/media.js.map +0 -1
  117. package/dist/src/utils/token.d.ts +0 -13
  118. package/dist/src/utils/token.js +0 -60
  119. package/dist/src/utils/token.js.map +0 -1
  120. package/dist/src/utils/validation.d.ts +0 -1
  121. package/dist/src/utils/validation.js +0 -7
  122. package/dist/src/utils/validation.js.map +0 -1
  123. package/dist/stories/audio-visualiser.stories.d.ts +0 -39
  124. package/dist/stories/audio-visualiser.stories.js +0 -71
  125. package/dist/stories/audio-visualiser.stories.js.map +0 -1
  126. package/dist/stories/corti-dictation.stories.d.ts +0 -27
  127. package/dist/stories/corti-dictation.stories.js +0 -129
  128. package/dist/stories/corti-dictation.stories.js.map +0 -1
  129. package/dist/stories/device-selector.stories.d.ts +0 -18
  130. package/dist/stories/device-selector.stories.js +0 -84
  131. package/dist/stories/device-selector.stories.js.map +0 -1
  132. package/dist/stories/language-selector.stories.d.ts +0 -18
  133. package/dist/stories/language-selector.stories.js +0 -53
  134. package/dist/stories/language-selector.stories.js.map +0 -1
  135. package/dist/stories/recording-button.stories.d.ts +0 -27
  136. package/dist/stories/recording-button.stories.js +0 -90
  137. package/dist/stories/recording-button.stories.js.map +0 -1
  138. package/dist/stories/settings-menu.stories.d.ts +0 -23
  139. package/dist/stories/settings-menu.stories.js +0 -156
  140. package/dist/stories/settings-menu.stories.js.map +0 -1
  141. package/dist/styles/ComponentStyles.d.ts +0 -2
  142. package/dist/styles/ComponentStyles.js +0 -18
  143. package/dist/styles/ComponentStyles.js.map +0 -1
  144. package/dist/styles/default-theme.d.ts +0 -2
  145. package/dist/styles/default-theme.js +0 -14
  146. package/dist/styles/default-theme.js.map +0 -1
  147. package/dist/styles/theme.d.ts +0 -2
  148. package/dist/styles/theme.js +0 -56
  149. package/dist/styles/theme.js.map +0 -1
  150. package/dist/tsconfig.stories.tsbuildinfo +0 -1
  151. package/dist/utils.d.ts +0 -59
  152. package/dist/utils.js +0 -179
  153. package/dist/utils.js.map +0 -1
package/dist/bundle.js CHANGED
@@ -1093,6 +1093,14 @@ function keybindingChangedEvent(key, code) {
1093
1093
  detail: { code, key }
1094
1094
  });
1095
1095
  }
1096
+ function keybindingActivatedEvent(keyboardEvent) {
1097
+ return new CustomEvent("keybinding-activated", {
1098
+ bubbles: true,
1099
+ cancelable: true,
1100
+ composed: true,
1101
+ detail: { keyboardEvent }
1102
+ });
1103
+ }
1096
1104
 
1097
1105
  // dist/controllers/devices-controller.js
1098
1106
  var __classPrivateFieldSet = function(receiver, state, value, kind, f5) {
@@ -11475,7 +11483,9 @@ _KeybindingController_keydownHandler = /* @__PURE__ */ new WeakMap(), _Keybindin
11475
11483
  return;
11476
11484
  }
11477
11485
  if (matchesKeybinding(event, this.host._keybinding)) {
11478
- event.preventDefault();
11486
+ if (!this.host.dispatchEvent(keybindingActivatedEvent(event))) {
11487
+ return;
11488
+ }
11479
11489
  if (this.host._mode === "push-to-talk") {
11480
11490
  this.host.startRecording();
11481
11491
  }
@@ -11489,6 +11499,9 @@ _KeybindingController_keydownHandler = /* @__PURE__ */ new WeakMap(), _Keybindin
11489
11499
  return;
11490
11500
  }
11491
11501
  if (this.host._mode === "push-to-talk" && matchesKeybinding(event, this.host._keybinding)) {
11502
+ if (!this.host.dispatchEvent(keybindingActivatedEvent(event))) {
11503
+ return;
11504
+ }
11492
11505
  this.host.stopRecording();
11493
11506
  }
11494
11507
  }, "f");
@@ -12002,10 +12015,17 @@ var __classPrivateFieldGet7 = function(receiver, state, kind, f5) {
12002
12015
  if (typeof state === "function" ? receiver !== state || !f5 : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
12003
12016
  return kind === "m" ? f5 : kind === "a" ? f5.call(receiver) : f5 ? f5.value : state.get(receiver);
12004
12017
  };
12018
+ var __classPrivateFieldSet6 = function(receiver, state, value, kind, f5) {
12019
+ if (kind === "m") throw new TypeError("Private method is not writable");
12020
+ if (kind === "a" && !f5) throw new TypeError("Private accessor was defined without a setter");
12021
+ if (typeof state === "function" ? receiver !== state || !f5 : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
12022
+ return kind === "a" ? f5.call(receiver, value) : f5 ? f5.value = value : state.set(receiver, value), value;
12023
+ };
12005
12024
  var _DictationRecordingButton_instances;
12006
12025
  var _DictationRecordingButton_mediaController;
12007
12026
  var _DictationRecordingButton_dictationController;
12008
12027
  var _DictationRecordingButton_keybindingController;
12028
+ var _DictationRecordingButton_closeConnectionOnInit;
12009
12029
  var _DictationRecordingButton_handleMouseDown;
12010
12030
  var _DictationRecordingButton_handleMouseUp;
12011
12031
  var _DictationRecordingButton_handleMouseLeave;
@@ -12023,6 +12043,7 @@ var DictationRecordingButton = class DictationRecordingButton2 extends i4 {
12023
12043
  _DictationRecordingButton_mediaController.set(this, new MediaController(this));
12024
12044
  _DictationRecordingButton_dictationController.set(this, new DictationController(this));
12025
12045
  _DictationRecordingButton_keybindingController.set(this, new KeybindingController(this));
12046
+ _DictationRecordingButton_closeConnectionOnInit.set(this, false);
12026
12047
  _DictationRecordingButton_handleWebSocketMessage.set(this, (message) => {
12027
12048
  switch (message.type) {
12028
12049
  case "CONFIG_ACCEPTED":
@@ -12063,6 +12084,13 @@ var DictationRecordingButton = class DictationRecordingButton2 extends i4 {
12063
12084
  this.dispatchEvent(streamClosedEvent(event));
12064
12085
  });
12065
12086
  }
12087
+ update(changedProperties) {
12088
+ if (changedProperties.has("_recordingState") && this._recordingState === "recording" && __classPrivateFieldGet7(this, _DictationRecordingButton_closeConnectionOnInit, "f")) {
12089
+ __classPrivateFieldSet6(this, _DictationRecordingButton_closeConnectionOnInit, false, "f");
12090
+ __classPrivateFieldGet7(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_handleStop).call(this);
12091
+ }
12092
+ super.update(changedProperties);
12093
+ }
12066
12094
  startRecording() {
12067
12095
  if (this._recordingState !== "stopped") {
12068
12096
  return;
@@ -12070,26 +12098,20 @@ var DictationRecordingButton = class DictationRecordingButton2 extends i4 {
12070
12098
  __classPrivateFieldGet7(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_handleStart).call(this);
12071
12099
  }
12072
12100
  stopRecording() {
12073
- if (this._recordingState === "stopped") {
12101
+ if (this._recordingState === "stopped" || this._recordingState === "stopping") {
12074
12102
  return;
12075
12103
  }
12076
12104
  if (this._recordingState === "initializing") {
12077
- this.addEventListener("recording-state-changed", (event) => {
12078
- if (event.detail.state === "recording") {
12079
- __classPrivateFieldGet7(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_handleStop).call(this);
12080
- }
12081
- }, {
12082
- once: true
12083
- });
12105
+ __classPrivateFieldSet6(this, _DictationRecordingButton_closeConnectionOnInit, true, "f");
12084
12106
  return;
12085
12107
  }
12086
12108
  __classPrivateFieldGet7(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_handleStop).call(this);
12087
12109
  }
12088
12110
  toggleRecording() {
12089
12111
  if (this._recordingState === "stopped") {
12090
- __classPrivateFieldGet7(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_handleStart).call(this);
12112
+ this.startRecording();
12091
12113
  } else if (this._recordingState === "recording") {
12092
- __classPrivateFieldGet7(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_handleStop).call(this);
12114
+ this.stopRecording();
12093
12115
  }
12094
12116
  }
12095
12117
  render() {
@@ -12117,6 +12139,7 @@ var DictationRecordingButton = class DictationRecordingButton2 extends i4 {
12117
12139
  _DictationRecordingButton_mediaController = /* @__PURE__ */ new WeakMap();
12118
12140
  _DictationRecordingButton_dictationController = /* @__PURE__ */ new WeakMap();
12119
12141
  _DictationRecordingButton_keybindingController = /* @__PURE__ */ new WeakMap();
12142
+ _DictationRecordingButton_closeConnectionOnInit = /* @__PURE__ */ new WeakMap();
12120
12143
  _DictationRecordingButton_handleWebSocketMessage = /* @__PURE__ */ new WeakMap();
12121
12144
  _DictationRecordingButton_handleWebSocketError = /* @__PURE__ */ new WeakMap();
12122
12145
  _DictationRecordingButton_handleWebSocketClose = /* @__PURE__ */ new WeakMap();
@@ -12650,6 +12673,7 @@ var ModeSelectorStyles = [
12650
12673
  font-weight: 500;
12651
12674
  line-height: 24px;
12652
12675
  color: var(--component-text-color, light-dark(#333, #eee));
12676
+ opacity: 0.6;
12653
12677
  cursor: pointer;
12654
12678
  transition: all 0.2s;
12655
12679
  height: 32px;
@@ -12660,12 +12684,13 @@ var ModeSelectorStyles = [
12660
12684
  margin: -1px;
12661
12685
  }
12662
12686
  .mode-selector-tab:hover:not(:disabled) {
12663
- background: var(--action-plain-background-hover, light-dark(#ddd, #444));
12687
+ opacity: 1;
12664
12688
  }
12665
12689
  .mode-selector-tab.active {
12666
12690
  background: var(--card-background, light-dark(#fff, #333));
12667
12691
  border-color: var(--card-border-color, light-dark(#ddd, #555));
12668
12692
  box-shadow: var(--card-box-shadow, 0 2px 5px rgba(0, 0, 0, 0.1));
12693
+ opacity: 1;
12669
12694
  }
12670
12695
  .mode-selector-tab:disabled {
12671
12696
  opacity: 0.5;
@@ -1,5 +1,5 @@
1
1
  import type { Corti } from "@corti/sdk";
2
- import { type CSSResultGroup, LitElement } from "lit";
2
+ import { type CSSResultGroup, LitElement, type PropertyValues } from "lit";
3
3
  import type { DictationMode, ProxyOptions, RecordingState } from "../types.js";
4
4
  import "./audio-visualiser.js";
5
5
  import "../icons/icons.js";
@@ -19,6 +19,7 @@ export declare class DictationRecordingButton extends LitElement {
19
19
  _mode?: DictationMode;
20
20
  allowButtonFocus: boolean;
21
21
  static styles: CSSResultGroup;
22
+ protected update(changedProperties: PropertyValues): void;
22
23
  startRecording(): void;
23
24
  stopRecording(): void;
24
25
  toggleRecording(): void;
@@ -9,9 +9,15 @@ 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_keybindingController, _DictationRecordingButton_handleMouseDown, _DictationRecordingButton_handleMouseUp, _DictationRecordingButton_handleMouseLeave, _DictationRecordingButton_handleWebSocketMessage, _DictationRecordingButton_handleWebSocketError, _DictationRecordingButton_handleWebSocketClose, _DictationRecordingButton_handleStart, _DictationRecordingButton_handleStop;
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_handleMouseDown, _DictationRecordingButton_handleMouseUp, _DictationRecordingButton_handleMouseLeave, _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
23
  import { accessTokenContext, authConfigContext, debugDisplayAudioContext, dictationConfigContext, keybindingContext, modeContext, recordingStateContext, regionContext, selectedDeviceContext, socketProxyContext, socketUrlContext, tenantNameContext, } from "../contexts/dictation-context.js";
@@ -32,6 +38,7 @@ let DictationRecordingButton = class DictationRecordingButton extends LitElement
32
38
  _DictationRecordingButton_mediaController.set(this, new MediaController(this));
33
39
  _DictationRecordingButton_dictationController.set(this, new DictationController(this));
34
40
  _DictationRecordingButton_keybindingController.set(this, new KeybindingController(this));
41
+ _DictationRecordingButton_closeConnectionOnInit.set(this, false);
35
42
  _DictationRecordingButton_handleWebSocketMessage.set(this, (message) => {
36
43
  switch (message.type) {
37
44
  case "CONFIG_ACCEPTED":
@@ -72,6 +79,15 @@ let DictationRecordingButton = class DictationRecordingButton extends LitElement
72
79
  this.dispatchEvent(streamClosedEvent(event));
73
80
  });
74
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
+ }
75
91
  startRecording() {
76
92
  if (this._recordingState !== "stopped") {
77
93
  return;
@@ -79,28 +95,22 @@ let DictationRecordingButton = class DictationRecordingButton extends LitElement
79
95
  __classPrivateFieldGet(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_handleStart).call(this);
80
96
  }
81
97
  stopRecording() {
82
- if (this._recordingState === "stopped") {
98
+ if (this._recordingState === "stopped" ||
99
+ this._recordingState === "stopping") {
83
100
  return;
84
101
  }
85
102
  if (this._recordingState === "initializing") {
86
- this.addEventListener("recording-state-changed", (event) => {
87
- if (event.detail
88
- .state === "recording") {
89
- __classPrivateFieldGet(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_handleStop).call(this);
90
- }
91
- }, {
92
- once: true,
93
- });
103
+ __classPrivateFieldSet(this, _DictationRecordingButton_closeConnectionOnInit, true, "f");
94
104
  return;
95
105
  }
96
106
  __classPrivateFieldGet(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_handleStop).call(this);
97
107
  }
98
108
  toggleRecording() {
99
109
  if (this._recordingState === "stopped") {
100
- __classPrivateFieldGet(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_handleStart).call(this);
110
+ this.startRecording();
101
111
  }
102
112
  else if (this._recordingState === "recording") {
103
- __classPrivateFieldGet(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_handleStop).call(this);
113
+ this.stopRecording();
104
114
  }
105
115
  }
106
116
  render() {
@@ -133,6 +143,7 @@ let DictationRecordingButton = class DictationRecordingButton extends LitElement
133
143
  _DictationRecordingButton_mediaController = new WeakMap();
134
144
  _DictationRecordingButton_dictationController = new WeakMap();
135
145
  _DictationRecordingButton_keybindingController = new WeakMap();
146
+ _DictationRecordingButton_closeConnectionOnInit = new WeakMap();
136
147
  _DictationRecordingButton_handleWebSocketMessage = new WeakMap();
137
148
  _DictationRecordingButton_handleWebSocketError = new WeakMap();
138
149
  _DictationRecordingButton_handleWebSocketClose = new WeakMap();
@@ -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,EAAuB,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5D,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,iBAAiB,EACjB,WAAW,EACX,qBAAqB,EACrB,aAAa,EACb,qBAAqB,EACrB,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,GAClB,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,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S,EAAE,IAAI,EAAE,CAAC;IACxD,KAAK,EAAE;6DACoB;AAI5B;IAFC,OAAO,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IAClD,KAAK,EAAE;uDACc;AAGtB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;kEACM;AAlDvB,wBAAwB;IADpC,aAAa,CAAC,4BAA4B,CAAC;GAC/B,wBAAwB,CA+PpC","sourcesContent":["import type { Corti } from \"@corti/sdk\";\nimport { consume } from \"@lit/context\";\nimport { type CSSResultGroup, html, LitElement } 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 keybindingContext,\n modeContext,\n recordingStateContext,\n regionContext,\n selectedDeviceContext,\n socketProxyContext,\n socketUrlContext,\n tenantNameContext,\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 { DictationMode, 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: keybindingContext, subscribe: true })\n @state()\n _keybinding?: string | null;\n\n @consume({ context: modeContext, subscribe: true })\n @state()\n _mode?: DictationMode;\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\n static styles: CSSResultGroup = [RecordingButtonStyles, ButtonStyles];\n\n #handleMouseDown(event: MouseEvent): void {\n if (!this.allowButtonFocus) {\n event.preventDefault();\n }\n\n if (this._mode === \"push-to-talk\") {\n this.startRecording();\n }\n }\n\n #handleMouseUp(): void {\n if (this._mode === \"push-to-talk\") {\n this.stopRecording();\n return;\n }\n\n if (this._mode === \"toggle-to-talk\") {\n this.toggleRecording();\n }\n }\n\n #handleMouseLeave(): void {\n if (this._mode === \"push-to-talk\") {\n this.stopRecording();\n }\n }\n\n #handleWebSocketMessage = (message: TranscribeMessage): void => {\n switch (message.type) {\n case \"CONFIG_ACCEPTED\":\n this.#mediaController.mediaRecorder?.start(AUDIO_CHUNK_INTERVAL_MS);\n this.#mediaController.startAudioLevelMonitoring((level) => {\n this.dispatchEvent(audioLevelChangedEvent(level));\n });\n this.dispatchEvent(recordingStateChangedEvent(\"recording\"));\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 }\n };\n\n #handleWebSocketError = (error: Error): void => {\n this.dispatchEvent(errorEvent(\"Socket error: \" + error.message));\n this.#handleStop();\n };\n\n #handleWebSocketClose = (event: unknown): void => {\n this.dispatchEvent(streamClosedEvent(event));\n };\n\n async #handleStart(): Promise<void> {\n this.dispatchEvent(recordingStateChangedEvent(\"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\n const isNewConnection = await this.#dictationController.connect(\n this.#mediaController.mediaRecorder,\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 // configuration has been accepted before\n if (!isNewConnection) {\n this.#mediaController.mediaRecorder?.start(AUDIO_CHUNK_INTERVAL_MS);\n this.#mediaController.startAudioLevelMonitoring((level) => {\n this.dispatchEvent(audioLevelChangedEvent(level));\n });\n this.dispatchEvent(recordingStateChangedEvent(\"recording\"));\n }\n } catch (error) {\n this.dispatchEvent(errorEvent(error));\n await this.#handleStop();\n }\n }\n\n async #handleStop(): Promise<void> {\n this.dispatchEvent(recordingStateChangedEvent(\"stopping\"));\n\n try {\n this.#mediaController.stopAudioLevelMonitoring();\n await this.#mediaController.stopRecording();\n\n await this.#dictationController.disconnect(this.#handleWebSocketClose);\n await this.#mediaController.cleanup();\n } catch (error) {\n this.dispatchEvent(errorEvent(error));\n }\n\n this.dispatchEvent(recordingStateChangedEvent(\"stopped\"));\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 (this._recordingState === \"stopped\") {\n return;\n }\n\n if (this._recordingState === \"initializing\") {\n this.addEventListener(\n \"recording-state-changed\",\n (event) => {\n if (\n (event as CustomEvent<RecordingStateChangedEventDetail>).detail\n .state === \"recording\"\n ) {\n this.#handleStop();\n }\n },\n {\n once: true,\n },\n );\n return;\n }\n\n this.#handleStop();\n }\n\n public toggleRecording(): void {\n if (this._recordingState === \"stopped\") {\n this.#handleStart();\n } else if (this._recordingState === \"recording\") {\n this.#handleStop();\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 @mousedown=${this.#handleMouseDown}\n @mouseup=${this.#handleMouseUp}\n @mouseleave=${this.#handleMouseLeave}\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,C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ACxD,KAAK,EAAE;6DAC0B;AAIlC;IAFC,OAAO,CAAC,EAAE,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IACpD,KAAK,EAAE;yDACS;AAIjB;IAFC,OAAO,CAAC,EAAE,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IACxD,KAAK,EAAE;6DACa;AAIrB;IAFC,OAAO,CAAC,EAAE,OAAO,EAAE,sBAAsB,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IAC7D,KAAK,EAAE;kEACkC;AAI1C;IAFC,OAAO,CAAC,EAAE,OAAO,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,iBAAiB,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IACxD,KAAK,EAAE;6DACoB;AAI5B;IAFC,OAAO,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IAClD,KAAK,EAAE;uDACc;AAGtB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;kEACM;AAlDvB,wBAAwB;IADpC,aAAa,CAAC,4BAA4B,CAAC;GAC/B,wBAAwB,CAmQpC","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 keybindingContext,\n modeContext,\n recordingStateContext,\n regionContext,\n selectedDeviceContext,\n socketProxyContext,\n socketUrlContext,\n tenantNameContext,\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 { DictationMode, ProxyOptions, RecordingState } from \"../types.js\";\nimport {\n audioLevelChangedEvent,\n commandEvent,\n errorEvent,\n networkActivityEvent,\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: keybindingContext, subscribe: true })\n @state()\n _keybinding?: string | null;\n\n @consume({ context: modeContext, subscribe: true })\n @state()\n _mode?: DictationMode;\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\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 #handleMouseDown(event: MouseEvent): void {\n if (!this.allowButtonFocus) {\n event.preventDefault();\n }\n\n if (this._mode === \"push-to-talk\") {\n this.startRecording();\n }\n }\n\n #handleMouseUp(): void {\n if (this._mode === \"push-to-talk\") {\n this.stopRecording();\n return;\n }\n\n if (this._mode === \"toggle-to-talk\") {\n this.toggleRecording();\n }\n }\n\n #handleMouseLeave(): void {\n if (this._mode === \"push-to-talk\") {\n this.stopRecording();\n }\n }\n\n #handleWebSocketMessage = (message: TranscribeMessage): void => {\n switch (message.type) {\n case \"CONFIG_ACCEPTED\":\n this.#mediaController.mediaRecorder?.start(AUDIO_CHUNK_INTERVAL_MS);\n this.#mediaController.startAudioLevelMonitoring((level) => {\n this.dispatchEvent(audioLevelChangedEvent(level));\n });\n this.dispatchEvent(recordingStateChangedEvent(\"recording\"));\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 }\n };\n\n #handleWebSocketError = (error: Error): void => {\n this.dispatchEvent(errorEvent(\"Socket error: \" + error.message));\n this.#handleStop();\n };\n\n #handleWebSocketClose = (event: unknown): void => {\n this.dispatchEvent(streamClosedEvent(event));\n };\n\n async #handleStart(): Promise<void> {\n this.dispatchEvent(recordingStateChangedEvent(\"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\n const isNewConnection = await this.#dictationController.connect(\n this.#mediaController.mediaRecorder,\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 // configuration has been accepted before\n if (!isNewConnection) {\n this.#mediaController.mediaRecorder?.start(AUDIO_CHUNK_INTERVAL_MS);\n this.#mediaController.startAudioLevelMonitoring((level) => {\n this.dispatchEvent(audioLevelChangedEvent(level));\n });\n this.dispatchEvent(recordingStateChangedEvent(\"recording\"));\n }\n } catch (error) {\n this.dispatchEvent(errorEvent(error));\n await this.#handleStop();\n }\n }\n\n async #handleStop(): Promise<void> {\n this.dispatchEvent(recordingStateChangedEvent(\"stopping\"));\n\n try {\n this.#mediaController.stopAudioLevelMonitoring();\n await this.#mediaController.stopRecording();\n\n await this.#dictationController.disconnect(this.#handleWebSocketClose);\n await this.#mediaController.cleanup();\n } catch (error) {\n this.dispatchEvent(errorEvent(error));\n }\n\n this.dispatchEvent(recordingStateChangedEvent(\"stopped\"));\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 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 @mousedown=${this.#handleMouseDown}\n @mouseup=${this.#handleMouseUp}\n @mouseleave=${this.#handleMouseLeave}\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"]}
@@ -6,6 +6,7 @@ interface KeybindingControllerHost extends ReactiveControllerHost {
6
6
  startRecording(): void;
7
7
  stopRecording(): void;
8
8
  toggleRecording(): void;
9
+ dispatchEvent(event: Event): boolean;
9
10
  }
10
11
  export declare class KeybindingController implements ReactiveController {
11
12
  #private;
@@ -10,6 +10,7 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
10
10
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
11
11
  };
12
12
  var _KeybindingController_instances, _KeybindingController_keydownHandler, _KeybindingController_keyupHandler, _KeybindingController_blurHandler, _KeybindingController_setupListeners, _KeybindingController_removeListeners;
13
+ import { keybindingActivatedEvent } from "../utils/events.js";
13
14
  import { matchesKeybinding, shouldIgnoreKeybinding, } from "../utils/keybinding.js";
14
15
  export class KeybindingController {
15
16
  constructor(host) {
@@ -37,7 +38,9 @@ _KeybindingController_keydownHandler = new WeakMap(), _KeybindingController_keyu
37
38
  return;
38
39
  }
39
40
  if (matchesKeybinding(event, this.host._keybinding)) {
40
- event.preventDefault();
41
+ if (!this.host.dispatchEvent(keybindingActivatedEvent(event))) {
42
+ return;
43
+ }
41
44
  if (this.host._mode === "push-to-talk") {
42
45
  this.host.startRecording();
43
46
  }
@@ -52,6 +55,9 @@ _KeybindingController_keydownHandler = new WeakMap(), _KeybindingController_keyu
52
55
  }
53
56
  if (this.host._mode === "push-to-talk" &&
54
57
  matchesKeybinding(event, this.host._keybinding)) {
58
+ if (!this.host.dispatchEvent(keybindingActivatedEvent(event))) {
59
+ return;
60
+ }
55
61
  this.host.stopRecording();
56
62
  }
57
63
  }, "f");
@@ -1 +1 @@
1
- {"version":3,"file":"keybinding-controller.js","sourceRoot":"","sources":["../../src/controllers/keybinding-controller.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,OAAO,EACL,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,wBAAwB,CAAC;AAUhC,MAAM,OAAO,oBAAoB;IAO/B,YAAY,IAA8B;;QAJ1C,uDAAiD;QACjD,qDAA+C;QAC/C,oDAA0B;QAGxB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC;IAED,aAAa;QACX,uBAAA,IAAI,6EAAgB,MAApB,IAAI,CAAkB,CAAC;IACzB,CAAC;IAED,gBAAgB;QACd,uBAAA,IAAI,8EAAiB,MAArB,IAAI,CAAmB,CAAC;IAC1B,CAAC;CAmEF;;IAhEG,uBAAA,IAAI,8EAAiB,MAArB,IAAI,CAAmB,CAAC;IAExB,uBAAA,IAAI,wCAAmB,CAAC,KAAoB,EAAE,EAAE;QAC9C,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;YAC3B,OAAO;QACT,CAAC;QAED,IAAI,sBAAsB,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE,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;IAGC,IAAI,uBAAA,IAAI,4CAAgB,EAAE,CAAC;QACzB,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,uBAAA,IAAI,4CAAgB,CAAC,CAAC;QAC5D,uBAAA,IAAI,wCAAmB,SAAS,MAAA,CAAC;IACnC,CAAC;IAED,IAAI,uBAAA,IAAI,0CAAc,EAAE,CAAC;QACvB,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,uBAAA,IAAI,0CAAc,CAAC,CAAC;QACxD,uBAAA,IAAI,sCAAiB,SAAS,MAAA,CAAC;IACjC,CAAC;IAED,IAAI,uBAAA,IAAI,yCAAa,EAAE,CAAC;QACtB,MAAM,CAAC,mBAAmB,CAAC,MAAM,EAAE,uBAAA,IAAI,yCAAa,CAAC,CAAC;QACtD,uBAAA,IAAI,qCAAgB,SAAS,MAAA,CAAC;IAChC,CAAC;AACH,CAAC","sourcesContent":["import type { ReactiveController, ReactiveControllerHost } from \"lit\";\nimport type { DictationMode } from \"../types.js\";\nimport {\n matchesKeybinding,\n shouldIgnoreKeybinding,\n} from \"../utils/keybinding.js\";\n\ninterface KeybindingControllerHost extends ReactiveControllerHost {\n _keybinding?: string | null;\n _mode?: DictationMode;\n startRecording(): void;\n stopRecording(): void;\n toggleRecording(): void;\n}\n\nexport class KeybindingController implements ReactiveController {\n host: KeybindingControllerHost;\n\n #keydownHandler?: (event: KeyboardEvent) => void;\n #keyupHandler?: (event: KeyboardEvent) => void;\n #blurHandler?: () => void;\n\n constructor(host: KeybindingControllerHost) {\n this.host = host;\n host.addController(this);\n }\n\n hostConnected(): void {\n this.#setupListeners();\n }\n\n hostDisconnected(): void {\n this.#removeListeners();\n }\n\n #setupListeners(): void {\n this.#removeListeners();\n\n this.#keydownHandler = (event: KeyboardEvent) => {\n if (!this.host._keybinding) {\n return;\n }\n\n if (shouldIgnoreKeybinding(document.activeElement)) {\n return;\n }\n\n if (matchesKeybinding(event, this.host._keybinding)) {\n event.preventDefault();\n\n if (this.host._mode === \"push-to-talk\") {\n this.host.startRecording();\n }\n\n if (this.host._mode === \"toggle-to-talk\") {\n this.host.toggleRecording();\n }\n }\n };\n\n this.#keyupHandler = (event: KeyboardEvent) => {\n if (!this.host._keybinding) {\n return;\n }\n\n if (\n this.host._mode === \"push-to-talk\" &&\n matchesKeybinding(event, this.host._keybinding)\n ) {\n this.host.stopRecording();\n }\n };\n\n this.#blurHandler = () => {\n if (this.host._mode === \"push-to-talk\") {\n this.host.stopRecording();\n }\n };\n\n window.addEventListener(\"keydown\", this.#keydownHandler);\n window.addEventListener(\"keyup\", this.#keyupHandler);\n window.addEventListener(\"blur\", this.#blurHandler);\n }\n\n #removeListeners(): void {\n if (this.#keydownHandler) {\n window.removeEventListener(\"keydown\", this.#keydownHandler);\n this.#keydownHandler = undefined;\n }\n\n if (this.#keyupHandler) {\n window.removeEventListener(\"keyup\", this.#keyupHandler);\n this.#keyupHandler = undefined;\n }\n\n if (this.#blurHandler) {\n window.removeEventListener(\"blur\", this.#blurHandler);\n this.#blurHandler = undefined;\n }\n }\n}\n"]}
1
+ {"version":3,"file":"keybinding-controller.js","sourceRoot":"","sources":["../../src/controllers/keybinding-controller.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EACL,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,wBAAwB,CAAC;AAWhC,MAAM,OAAO,oBAAoB;IAO/B,YAAY,IAA8B;;QAJ1C,uDAAiD;QACjD,qDAA+C;QAC/C,oDAA0B;QAGxB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC;IAED,aAAa;QACX,uBAAA,IAAI,6EAAgB,MAApB,IAAI,CAAkB,CAAC;IACzB,CAAC;IAED,gBAAgB;QACd,uBAAA,IAAI,8EAAiB,MAArB,IAAI,CAAmB,CAAC;IAC1B,CAAC;CAyEF;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C;IACH,CAAC,MAAA,CAAC;IAEF,uBAAA,IAAI,qCAAgB,GAAG,EAAE;QACvB,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,cAAc,EAAE,CAAC;YACvC,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;QAC5B,CAAC;IACH,CAAC,MAAA,CAAC;IAEF,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,uBAAA,IAAI,4CAAgB,CAAC,CAAC;IACzD,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,uBAAA,IAAI,0CAAc,CAAC,CAAC;IACrD,MAAM,CAAC,gBAAgB,CAAC,MAAM,EAAE,uBAAA,IAAI,yCAAa,CAAC,CAAC;AACrD,CAAC;IAGC,IAAI,uBAAA,IAAI,4CAAgB,EAAE,CAAC;QACzB,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,uBAAA,IAAI,4CAAgB,CAAC,CAAC;QAC5D,uBAAA,IAAI,wCAAmB,SAAS,MAAA,CAAC;IACnC,CAAC;IAED,IAAI,uBAAA,IAAI,0CAAc,EAAE,CAAC;QACvB,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,uBAAA,IAAI,0CAAc,CAAC,CAAC;QACxD,uBAAA,IAAI,sCAAiB,SAAS,MAAA,CAAC;IACjC,CAAC;IAED,IAAI,uBAAA,IAAI,yCAAa,EAAE,CAAC;QACtB,MAAM,CAAC,mBAAmB,CAAC,MAAM,EAAE,uBAAA,IAAI,yCAAa,CAAC,CAAC;QACtD,uBAAA,IAAI,qCAAgB,SAAS,MAAA,CAAC;IAChC,CAAC;AACH,CAAC","sourcesContent":["import type { ReactiveController, ReactiveControllerHost } from \"lit\";\nimport type { DictationMode } from \"../types.js\";\nimport { keybindingActivatedEvent } from \"../utils/events.js\";\nimport {\n matchesKeybinding,\n shouldIgnoreKeybinding,\n} from \"../utils/keybinding.js\";\n\ninterface KeybindingControllerHost extends ReactiveControllerHost {\n _keybinding?: string | null;\n _mode?: DictationMode;\n startRecording(): void;\n stopRecording(): void;\n toggleRecording(): void;\n dispatchEvent(event: Event): boolean;\n}\n\nexport class KeybindingController implements ReactiveController {\n host: KeybindingControllerHost;\n\n #keydownHandler?: (event: KeyboardEvent) => void;\n #keyupHandler?: (event: KeyboardEvent) => void;\n #blurHandler?: () => void;\n\n constructor(host: KeybindingControllerHost) {\n this.host = host;\n host.addController(this);\n }\n\n hostConnected(): void {\n this.#setupListeners();\n }\n\n hostDisconnected(): void {\n this.#removeListeners();\n }\n\n #setupListeners(): void {\n this.#removeListeners();\n\n this.#keydownHandler = (event: KeyboardEvent) => {\n if (!this.host._keybinding) {\n return;\n }\n\n if (shouldIgnoreKeybinding(document.activeElement)) {\n return;\n }\n\n if (matchesKeybinding(event, this.host._keybinding)) {\n if (!this.host.dispatchEvent(keybindingActivatedEvent(event))) {\n return;\n }\n\n if (this.host._mode === \"push-to-talk\") {\n this.host.startRecording();\n }\n\n if (this.host._mode === \"toggle-to-talk\") {\n this.host.toggleRecording();\n }\n }\n };\n\n this.#keyupHandler = (event: KeyboardEvent) => {\n if (!this.host._keybinding) {\n return;\n }\n\n if (\n this.host._mode === \"push-to-talk\" &&\n matchesKeybinding(event, this.host._keybinding)\n ) {\n if (!this.host.dispatchEvent(keybindingActivatedEvent(event))) {\n return;\n }\n\n this.host.stopRecording();\n }\n };\n\n this.#blurHandler = () => {\n if (this.host._mode === \"push-to-talk\") {\n this.host.stopRecording();\n }\n };\n\n window.addEventListener(\"keydown\", this.#keydownHandler);\n window.addEventListener(\"keyup\", this.#keyupHandler);\n window.addEventListener(\"blur\", this.#blurHandler);\n }\n\n #removeListeners(): void {\n if (this.#keydownHandler) {\n window.removeEventListener(\"keydown\", this.#keydownHandler);\n this.#keydownHandler = undefined;\n }\n\n if (this.#keyupHandler) {\n window.removeEventListener(\"keyup\", this.#keyupHandler);\n this.#keyupHandler = undefined;\n }\n\n if (this.#blurHandler) {\n window.removeEventListener(\"blur\", this.#blurHandler);\n this.#blurHandler = undefined;\n }\n }\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -8,5 +8,5 @@ export { DictationRecordingButton } from "./components/recording-button.js";
8
8
  export { DictationSettingsMenu } from "./components/settings-menu.js";
9
9
  export { DictationRoot } from "./contexts/dictation-context.js";
10
10
  export type { ConfigurableSettings, DictationMode, Keybinding, RecordingState, } from "./types.js";
11
- export type { AudioLevelChangedEventDetail, CommandEventDetail, ErrorEventDetail, KeybindingChangedEventDetail, LanguageChangedEventDetail, LanguagesChangedEventDetail, ModeChangedEventDetail, NetworkActivityEventDetail, RecordingDevicesChangedEventDetail, RecordingStateChangedEventDetail, TranscriptEventDetail, UsageEventDetail, } from "./utils/events.js";
11
+ export type { AudioLevelChangedEventDetail, CommandEventDetail, ErrorEventDetail, KeybindingActivatedEventDetail, KeybindingChangedEventDetail, LanguageChangedEventDetail, LanguagesChangedEventDetail, ModeChangedEventDetail, NetworkActivityEventDetail, RecordingDevicesChangedEventDetail, RecordingStateChangedEventDetail, TranscriptEventDetail, UsageEventDetail, } from "./utils/events.js";
12
12
  export default CortiDictation;
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AAClF,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAC9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAEhE,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,i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AO,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AAClF,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAC9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAuBhE,eAAe,cAAc,CAAC","sourcesContent":["import { CortiDictation } from \"./components/corti-dictation.js\";\nimport { DictationDeviceSelector } from \"./components/device-selector.js\";\nimport { DictationKeybindingSelector } from \"./components/keybinding-selector.js\";\nimport { DictationLanguageSelector } from \"./components/language-selector.js\";\nimport { DictationModeSelector } from \"./components/mode-selector.js\";\nimport { DictationRecordingButton } from \"./components/recording-button.js\";\nimport { DictationSettingsMenu } from \"./components/settings-menu.js\";\nimport { DictationRoot } from \"./contexts/dictation-context.js\";\n\nif (!customElements.get(\"corti-dictation\")) {\n customElements.define(\"corti-dictation\", CortiDictation);\n}\n\nif (!customElements.get(\"dictation-recording-button\")) {\n customElements.define(\"dictation-recording-button\", DictationRecordingButton);\n}\n\nif (!customElements.get(\"dictation-device-selector\")) {\n customElements.define(\"dictation-device-selector\", DictationDeviceSelector);\n}\n\nif (!customElements.get(\"dictation-language-selector\")) {\n customElements.define(\n \"dictation-language-selector\",\n DictationLanguageSelector,\n );\n}\n\nif (!customElements.get(\"dictation-mode-selector\")) {\n customElements.define(\"dictation-mode-selector\", DictationModeSelector);\n}\n\nif (!customElements.get(\"dictation-keybinding-selector\")) {\n customElements.define(\n \"dictation-keybinding-selector\",\n DictationKeybindingSelector,\n );\n}\n\nif (!customElements.get(\"dictation-settings-menu\")) {\n customElements.define(\"dictation-settings-menu\", DictationSettingsMenu);\n}\n\nif (!customElements.get(\"dictation-root\")) {\n customElements.define(\"dictation-root\", DictationRoot);\n}\n\nexport { CortiDictation } from \"./components/corti-dictation.js\";\nexport { DictationDeviceSelector } from \"./components/device-selector.js\";\nexport { DictationKeybindingSelector } from \"./components/keybinding-selector.js\";\nexport { DictationLanguageSelector } from \"./components/language-selector.js\";\nexport { DictationModeSelector } from \"./components/mode-selector.js\";\nexport { DictationRecordingButton } from \"./components/recording-button.js\";\nexport { DictationSettingsMenu } from \"./components/settings-menu.js\";\nexport { DictationRoot } from \"./contexts/dictation-context.js\";\n\nexport type {\n ConfigurableSettings,\n DictationMode,\n Keybinding,\n RecordingState,\n} from \"./types.js\";\nexport type {\n AudioLevelChangedEventDetail,\n CommandEventDetail,\n ErrorEventDetail,\n KeybindingChangedEventDetail,\n LanguageChangedEventDetail,\n LanguagesChangedEventDetail,\n ModeChangedEventDetail,\n NetworkActivityEventDetail,\n RecordingDevicesChangedEventDetail,\n RecordingStateChangedEventDetail,\n TranscriptEventDetail,\n UsageEventDetail,\n} from \"./utils/events.js\";\n\nexport default CortiDictation;\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AAClF,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAC9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAEhE,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,iBAAiB,CAAC,EAAE,CAAC;IAC3C,cAAc,CAAC,MAAM,CAAC,iBAAiB,EAAE,cAAc,CAAC,CAAC;AAC3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AC;AAC9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAwBhE,eAAe,cAAc,CAAC","sourcesContent":["import { CortiDictation } from \"./components/corti-dictation.js\";\nimport { DictationDeviceSelector } from \"./components/device-selector.js\";\nimport { DictationKeybindingSelector } from \"./components/keybinding-selector.js\";\nimport { DictationLanguageSelector } from \"./components/language-selector.js\";\nimport { DictationModeSelector } from \"./components/mode-selector.js\";\nimport { DictationRecordingButton } from \"./components/recording-button.js\";\nimport { DictationSettingsMenu } from \"./components/settings-menu.js\";\nimport { DictationRoot } from \"./contexts/dictation-context.js\";\n\nif (!customElements.get(\"corti-dictation\")) {\n customElements.define(\"corti-dictation\", CortiDictation);\n}\n\nif (!customElements.get(\"dictation-recording-button\")) {\n customElements.define(\"dictation-recording-button\", DictationRecordingButton);\n}\n\nif (!customElements.get(\"dictation-device-selector\")) {\n customElements.define(\"dictation-device-selector\", DictationDeviceSelector);\n}\n\nif (!customElements.get(\"dictation-language-selector\")) {\n customElements.define(\n \"dictation-language-selector\",\n DictationLanguageSelector,\n );\n}\n\nif (!customElements.get(\"dictation-mode-selector\")) {\n customElements.define(\"dictation-mode-selector\", DictationModeSelector);\n}\n\nif (!customElements.get(\"dictation-keybinding-selector\")) {\n customElements.define(\n \"dictation-keybinding-selector\",\n DictationKeybindingSelector,\n );\n}\n\nif (!customElements.get(\"dictation-settings-menu\")) {\n customElements.define(\"dictation-settings-menu\", DictationSettingsMenu);\n}\n\nif (!customElements.get(\"dictation-root\")) {\n customElements.define(\"dictation-root\", DictationRoot);\n}\n\nexport { CortiDictation } from \"./components/corti-dictation.js\";\nexport { DictationDeviceSelector } from \"./components/device-selector.js\";\nexport { DictationKeybindingSelector } from \"./components/keybinding-selector.js\";\nexport { DictationLanguageSelector } from \"./components/language-selector.js\";\nexport { DictationModeSelector } from \"./components/mode-selector.js\";\nexport { DictationRecordingButton } from \"./components/recording-button.js\";\nexport { DictationSettingsMenu } from \"./components/settings-menu.js\";\nexport { DictationRoot } from \"./contexts/dictation-context.js\";\n\nexport type {\n ConfigurableSettings,\n DictationMode,\n Keybinding,\n RecordingState,\n} from \"./types.js\";\nexport type {\n AudioLevelChangedEventDetail,\n CommandEventDetail,\n ErrorEventDetail,\n KeybindingActivatedEventDetail,\n KeybindingChangedEventDetail,\n LanguageChangedEventDetail,\n LanguagesChangedEventDetail,\n ModeChangedEventDetail,\n NetworkActivityEventDetail,\n RecordingDevicesChangedEventDetail,\n RecordingStateChangedEventDetail,\n TranscriptEventDetail,\n UsageEventDetail,\n} from \"./utils/events.js\";\n\nexport default CortiDictation;\n"]}
package/dist/package.json CHANGED
@@ -1,14 +1,94 @@
1
1
  {
2
2
  "name": "@corti/dictation-web",
3
- "version": "0.0.0-local",
3
+ "description": "Web component for Corti Dictation",
4
+ "author": "Corti ApS",
5
+ "version": "0.0.0-test.571.1",
6
+ "license": "MIT",
4
7
  "type": "module",
5
- "main": "./index.js",
6
- "module": "./index.js",
8
+ "main": "dist/index.js",
9
+ "module": "dist/index.js",
10
+ "types": "dist/index.d.ts",
7
11
  "exports": {
8
12
  ".": {
9
- "import": "./index.js",
10
- "types": "./index.d.ts"
11
- },
12
- "./*": "./*"
13
+ "types": "./dist/index.d.ts",
14
+ "import": "./dist/index.js",
15
+ "browser": "./dist/bundle.js",
16
+ "default": "./dist/bundle.js"
17
+ }
18
+ },
19
+ "jsdelivr": "./dist/bundle.js",
20
+ "browser": "./dist/bundle.js",
21
+ "files": [
22
+ "dist"
23
+ ],
24
+ "bugs": {
25
+ "url": "https://docs.corti.ai",
26
+ "email": "help@corti.ai"
27
+ },
28
+ "repository": "github:corticph/dictation-web",
29
+ "homepage": "https://docs.corti.ai/stt/dictation-web",
30
+ "keywords": [
31
+ "corti",
32
+ "dictation",
33
+ "web",
34
+ "sdk",
35
+ "speech",
36
+ "recognition",
37
+ "transcription",
38
+ "audio",
39
+ "medical",
40
+ "healthcare"
41
+ ],
42
+ "scripts": {
43
+ "analyze": "cem analyze --litelement",
44
+ "build": "tsc && npm run analyze -- --exclude dist",
45
+ "build:bundle": "esbuild dist/index.js --bundle --outfile=dist/bundle.js --format=esm --platform=browser",
46
+ "release": "npm run build && npm run build:bundle && npm publish --access public",
47
+ "start": "npm run build && npm run build:bundle && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"web-dev-server\"",
48
+ "prepublish": "tsc && npm run analyze -- --exclude dist",
49
+ "lint": "biome check .",
50
+ "format": "biome format --write .",
51
+ "biome:check": "biome check .",
52
+ "biome:format": "biome format --write .",
53
+ "biome:fix": "biome check --write .",
54
+ "prepare": "husky && husky install",
55
+ "test": "tsc && wtr --coverage",
56
+ "test:watch": "tsc && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"wtr --watch\"",
57
+ "storybook": "npm run analyze -- --exclude dist && storybook dev -p 8080",
58
+ "storybook:build": "tsc && tsc -p tsconfig.stories.json && npm run analyze -- --exclude dist && storybook build"
59
+ },
60
+ "dependencies": {
61
+ "@corti/sdk": "^0.8.0",
62
+ "@lit/context": "^1.1.6",
63
+ "lit": "^3.3.1"
64
+ },
65
+ "devDependencies": {
66
+ "@biomejs/biome": "^2.3.6",
67
+ "@custom-elements-manifest/analyzer": "^0.10.3",
68
+ "@open-wc/testing": "^4.0.0",
69
+ "@storybook/addon-a11y": "10.1.5",
70
+ "@storybook/addon-docs": "^10.1.5",
71
+ "@storybook/addon-links": "10.1.5",
72
+ "@storybook/web-components": "10.1.5",
73
+ "@storybook/web-components-vite": "^10.1.5",
74
+ "@types/mocha": "^10.0.7",
75
+ "@web/dev-server": "^0.4.6",
76
+ "@web/storybook-builder": "^0.1.16",
77
+ "@web/storybook-framework-web-components": "^0.1.2",
78
+ "@web/test-runner": "^0.18.2",
79
+ "concurrently": "^8.2.2",
80
+ "esbuild": "^0.25.0",
81
+ "husky": "^8.0.0",
82
+ "lint-staged": "^15.2.7",
83
+ "sinon": "^19.0.2",
84
+ "storybook": "10.1.5",
85
+ "tslib": "^2.6.3",
86
+ "typescript": "^5.5.3"
87
+ },
88
+ "customElements": "custom-elements.json",
89
+ "lint-staged": {
90
+ "*.ts": [
91
+ "biome check --write"
92
+ ]
13
93
  }
14
94
  }
@@ -27,6 +27,7 @@ const ModeSelectorStyles = [
27
27
  font-weight: 500;
28
28
  line-height: 24px;
29
29
  color: var(--component-text-color, light-dark(#333, #eee));
30
+ opacity: 0.6;
30
31
  cursor: pointer;
31
32
  transition: all 0.2s;
32
33
  height: 32px;
@@ -37,12 +38,13 @@ const ModeSelectorStyles = [
37
38
  margin: -1px;
38
39
  }
39
40
  .mode-selector-tab:hover:not(:disabled) {
40
- background: var(--action-plain-background-hover, light-dark(#ddd, #444));
41
+ opacity: 1;
41
42
  }
42
43
  .mode-selector-tab.active {
43
44
  background: var(--card-background, light-dark(#fff, #333));
44
45
  border-color: var(--card-border-color, light-dark(#ddd, #555));
45
46
  box-shadow: var(--card-box-shadow, 0 2px 5px rgba(0, 0, 0, 0.1));
47
+ opacity: 1;
46
48
  }
47
49
  .mode-selector-tab:disabled {
48
50
  opacity: 0.5;
@@ -1 +1 @@
1
- {"version":3,"file":"mode-selector.js","sourceRoot":"","sources":["../../src/styles/mode-selector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC1B,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpD,MAAM,kBAAkB,GAAG;IACzB,WAAW;IACX,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8CJ;CACA,CAAC;AAEF,eAAe,kBAAkB,CAAC","sourcesContent":["import { css } from \"lit\";\nimport { LabelStyles } from \"./component-styles.js\";\n\nconst ModeSelectorStyles = [\n LabelStyles,\n css`\n :host {\n display: block;\n }\n .mode-selector-tabs {\n display: flex;\n background: var(--muted-background, light-dark(#fafafa, #2a2a2a));\n border: 1px solid var(--card-border-color, light-dark(#ddd, #555));\n border-radius: var(--card-inner-border-radius, 6px);\n padding: 0;\n overflow: hidden;\n align-items: center;\n justify-content: center;\n text-wrap: nowrap;\n gap: 2px;\n }\n .mode-selector-tab {\n flex: 1;\n padding: 4px 8px;\n border: 1px solid transparent;\n background: transparent;\n font-size: 14px;\n font-weight: 500;\n line-height: 24px;\n color: var(--component-text-color, light-dark(#333, #eee));\n cursor: pointer;\n transition: all 0.2s;\n height: 32px;\n display: flex;\n align-items: center;\n justify-content: center;\n border-radius: var(--card-inner-border-radius, 6px);\n margin: -1px;\n }\n .mode-selector-tab:hover:not(:disabled) {\n background: var(--action-plain-background-hover, light-dark(#ddd, #444));\n }\n .mode-selector-tab.active {\n background: var(--card-background, light-dark(#fff, #333));\n border-color: var(--card-border-color, light-dark(#ddd, #555));\n box-shadow: var(--card-box-shadow, 0 2px 5px rgba(0, 0, 0, 0.1));\n }\n .mode-selector-tab:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n }\n`,\n];\n\nexport default ModeSelectorStyles;\n"]}
1
+ {"version":3,"file":"mode-selector.js","sourceRoot":"","sources":["../../src/styles/mode-selector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC1B,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpD,MAAM,kBAAkB,GAAG;IACzB,WAAW;IACX,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgDJ;CACA,CAAC;AAEF,eAAe,kBAAkB,CAAC","sourcesContent":["import { css } from \"lit\";\nimport { LabelStyles } from \"./component-styles.js\";\n\nconst ModeSelectorStyles = [\n LabelStyles,\n css`\n :host {\n display: block;\n }\n .mode-selector-tabs {\n display: flex;\n background: var(--muted-background, light-dark(#fafafa, #2a2a2a));\n border: 1px solid var(--card-border-color, light-dark(#ddd, #555));\n border-radius: var(--card-inner-border-radius, 6px);\n padding: 0;\n overflow: hidden;\n align-items: center;\n justify-content: center;\n text-wrap: nowrap;\n gap: 2px;\n }\n .mode-selector-tab {\n flex: 1;\n padding: 4px 8px;\n border: 1px solid transparent;\n background: transparent;\n font-size: 14px;\n font-weight: 500;\n line-height: 24px;\n color: var(--component-text-color, light-dark(#333, #eee));\n opacity: 0.6;\n cursor: pointer;\n transition: all 0.2s;\n height: 32px;\n display: flex;\n align-items: center;\n justify-content: center;\n border-radius: var(--card-inner-border-radius, 6px);\n margin: -1px;\n }\n .mode-selector-tab:hover:not(:disabled) {\n opacity: 1;\n }\n .mode-selector-tab.active {\n background: var(--card-background, light-dark(#fff, #333));\n border-color: var(--card-border-color, light-dark(#ddd, #555));\n box-shadow: var(--card-box-shadow, 0 2px 5px rgba(0, 0, 0, 0.1));\n opacity: 1;\n }\n .mode-selector-tab:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n }\n`,\n];\n\nexport default ModeSelectorStyles;\n"]}