@corti/dictation-web 0.0.0-test.571.1 → 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 (142) hide show
  1. package/dist/bundle.js +22 -9
  2. package/dist/components/recording-button.d.ts +2 -1
  3. package/dist/components/recording-button.js +22 -12
  4. package/dist/components/recording-button.js.map +1 -1
  5. package/dist/controllers/keybinding-controller.js +3 -0
  6. package/dist/controllers/keybinding-controller.js.map +1 -1
  7. package/dist/package.json +87 -7
  8. package/dist/tsconfig.tsbuildinfo +1 -0
  9. package/package.json +1 -1
  10. package/dist/CortiDictation.d.ts +0 -55
  11. package/dist/CortiDictation.js +0 -303
  12. package/dist/CortiDictation.js.map +0 -1
  13. package/dist/DictationService.d.ts +0 -16
  14. package/dist/DictationService.js +0 -88
  15. package/dist/DictationService.js.map +0 -1
  16. package/dist/RecorderManager.d.ts +0 -25
  17. package/dist/RecorderManager.js +0 -145
  18. package/dist/RecorderManager.js.map +0 -1
  19. package/dist/audioService.d.ts +0 -6
  20. package/dist/audioService.js +0 -21
  21. package/dist/audioService.js.map +0 -1
  22. package/dist/controllers/DictationController.d.ts +0 -35
  23. package/dist/controllers/DictationController.js +0 -130
  24. package/dist/controllers/DictationController.js.map +0 -1
  25. package/dist/controllers/MediaController.d.ts +0 -31
  26. package/dist/controllers/MediaController.js +0 -99
  27. package/dist/controllers/MediaController.js.map +0 -1
  28. package/dist/src/components/audio-visualiser.d.ts +0 -14
  29. package/dist/src/components/audio-visualiser.js +0 -57
  30. package/dist/src/components/audio-visualiser.js.map +0 -1
  31. package/dist/src/components/corti-dictation.d.ts +0 -123
  32. package/dist/src/components/corti-dictation.js +0 -224
  33. package/dist/src/components/corti-dictation.js.map +0 -1
  34. package/dist/src/components/device-selector.d.ts +0 -24
  35. package/dist/src/components/device-selector.js +0 -106
  36. package/dist/src/components/device-selector.js.map +0 -1
  37. package/dist/src/components/language-selector.d.ts +0 -24
  38. package/dist/src/components/language-selector.js +0 -100
  39. package/dist/src/components/language-selector.js.map +0 -1
  40. package/dist/src/components/recording-button.d.ts +0 -37
  41. package/dist/src/components/recording-button.js +0 -203
  42. package/dist/src/components/recording-button.js.map +0 -1
  43. package/dist/src/components/settings-menu.d.ts +0 -16
  44. package/dist/src/components/settings-menu.js +0 -80
  45. package/dist/src/components/settings-menu.js.map +0 -1
  46. package/dist/src/constants.d.ts +0 -4
  47. package/dist/src/constants.js +0 -37
  48. package/dist/src/constants.js.map +0 -1
  49. package/dist/src/contexts/dictation-context.d.ts +0 -97
  50. package/dist/src/contexts/dictation-context.js +0 -208
  51. package/dist/src/contexts/dictation-context.js.map +0 -1
  52. package/dist/src/controllers/DictationController.d.ts +0 -35
  53. package/dist/src/controllers/DictationController.js +0 -130
  54. package/dist/src/controllers/DictationController.js.map +0 -1
  55. package/dist/src/controllers/MediaController.d.ts +0 -31
  56. package/dist/src/controllers/MediaController.js +0 -99
  57. package/dist/src/controllers/MediaController.js.map +0 -1
  58. package/dist/src/icons/icons.d.ts +0 -17
  59. package/dist/src/icons/icons.js +0 -158
  60. package/dist/src/icons/icons.js.map +0 -1
  61. package/dist/src/styles/ComponentStyles.d.ts +0 -2
  62. package/dist/src/styles/ComponentStyles.js +0 -18
  63. package/dist/src/styles/ComponentStyles.js.map +0 -1
  64. package/dist/src/styles/audio-visualiser.d.ts +0 -2
  65. package/dist/src/styles/audio-visualiser.js +0 -33
  66. package/dist/src/styles/audio-visualiser.js.map +0 -1
  67. package/dist/src/styles/buttons.d.ts +0 -2
  68. package/dist/src/styles/buttons.js +0 -52
  69. package/dist/src/styles/buttons.js.map +0 -1
  70. package/dist/src/styles/callout.d.ts +0 -2
  71. package/dist/src/styles/callout.js +0 -23
  72. package/dist/src/styles/callout.js.map +0 -1
  73. package/dist/src/styles/default-theme.d.ts +0 -2
  74. package/dist/src/styles/default-theme.js +0 -50
  75. package/dist/src/styles/default-theme.js.map +0 -1
  76. package/dist/src/styles/recording-button.d.ts +0 -2
  77. package/dist/src/styles/recording-button.js +0 -8
  78. package/dist/src/styles/recording-button.js.map +0 -1
  79. package/dist/src/styles/select.d.ts +0 -2
  80. package/dist/src/styles/select.js +0 -36
  81. package/dist/src/styles/select.js.map +0 -1
  82. package/dist/src/styles/settings-menu.d.ts +0 -2
  83. package/dist/src/styles/settings-menu.js +0 -34
  84. package/dist/src/styles/settings-menu.js.map +0 -1
  85. package/dist/src/types.d.ts +0 -7
  86. package/dist/src/types.js +0 -2
  87. package/dist/src/types.js.map +0 -1
  88. package/dist/src/utils/auth.d.ts +0 -9
  89. package/dist/src/utils/auth.js +0 -21
  90. package/dist/src/utils/auth.js.map +0 -1
  91. package/dist/src/utils/converters.d.ts +0 -4
  92. package/dist/src/utils/converters.js +0 -8
  93. package/dist/src/utils/converters.js.map +0 -1
  94. package/dist/src/utils/devices.d.ts +0 -26
  95. package/dist/src/utils/devices.js +0 -53
  96. package/dist/src/utils/devices.js.map +0 -1
  97. package/dist/src/utils/events.d.ts +0 -44
  98. package/dist/src/utils/events.js +0 -88
  99. package/dist/src/utils/events.js.map +0 -1
  100. package/dist/src/utils/languages.d.ts +0 -7
  101. package/dist/src/utils/languages.js +0 -29
  102. package/dist/src/utils/languages.js.map +0 -1
  103. package/dist/src/utils/media.d.ts +0 -6
  104. package/dist/src/utils/media.js +0 -39
  105. package/dist/src/utils/media.js.map +0 -1
  106. package/dist/src/utils/token.d.ts +0 -13
  107. package/dist/src/utils/token.js +0 -60
  108. package/dist/src/utils/token.js.map +0 -1
  109. package/dist/src/utils/validation.d.ts +0 -1
  110. package/dist/src/utils/validation.js +0 -7
  111. package/dist/src/utils/validation.js.map +0 -1
  112. package/dist/stories/audio-visualiser.stories.d.ts +0 -39
  113. package/dist/stories/audio-visualiser.stories.js +0 -71
  114. package/dist/stories/audio-visualiser.stories.js.map +0 -1
  115. package/dist/stories/corti-dictation.stories.d.ts +0 -27
  116. package/dist/stories/corti-dictation.stories.js +0 -129
  117. package/dist/stories/corti-dictation.stories.js.map +0 -1
  118. package/dist/stories/device-selector.stories.d.ts +0 -18
  119. package/dist/stories/device-selector.stories.js +0 -84
  120. package/dist/stories/device-selector.stories.js.map +0 -1
  121. package/dist/stories/language-selector.stories.d.ts +0 -18
  122. package/dist/stories/language-selector.stories.js +0 -53
  123. package/dist/stories/language-selector.stories.js.map +0 -1
  124. package/dist/stories/recording-button.stories.d.ts +0 -27
  125. package/dist/stories/recording-button.stories.js +0 -90
  126. package/dist/stories/recording-button.stories.js.map +0 -1
  127. package/dist/stories/settings-menu.stories.d.ts +0 -23
  128. package/dist/stories/settings-menu.stories.js +0 -156
  129. package/dist/stories/settings-menu.stories.js.map +0 -1
  130. package/dist/styles/ComponentStyles.d.ts +0 -2
  131. package/dist/styles/ComponentStyles.js +0 -18
  132. package/dist/styles/ComponentStyles.js.map +0 -1
  133. package/dist/styles/default-theme.d.ts +0 -2
  134. package/dist/styles/default-theme.js +0 -14
  135. package/dist/styles/default-theme.js.map +0 -1
  136. package/dist/styles/theme.d.ts +0 -2
  137. package/dist/styles/theme.js +0 -56
  138. package/dist/styles/theme.js.map +0 -1
  139. package/dist/tsconfig.stories.tsbuildinfo +0 -1
  140. package/dist/utils.d.ts +0 -59
  141. package/dist/utils.js +0 -179
  142. package/dist/utils.js.map +0 -1
package/dist/bundle.js CHANGED
@@ -11499,6 +11499,9 @@ _KeybindingController_keydownHandler = /* @__PURE__ */ new WeakMap(), _Keybindin
11499
11499
  return;
11500
11500
  }
11501
11501
  if (this.host._mode === "push-to-talk" && matchesKeybinding(event, this.host._keybinding)) {
11502
+ if (!this.host.dispatchEvent(keybindingActivatedEvent(event))) {
11503
+ return;
11504
+ }
11502
11505
  this.host.stopRecording();
11503
11506
  }
11504
11507
  }, "f");
@@ -12012,10 +12015,17 @@ var __classPrivateFieldGet7 = function(receiver, state, kind, f5) {
12012
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");
12013
12016
  return kind === "m" ? f5 : kind === "a" ? f5.call(receiver) : f5 ? f5.value : state.get(receiver);
12014
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
+ };
12015
12024
  var _DictationRecordingButton_instances;
12016
12025
  var _DictationRecordingButton_mediaController;
12017
12026
  var _DictationRecordingButton_dictationController;
12018
12027
  var _DictationRecordingButton_keybindingController;
12028
+ var _DictationRecordingButton_closeConnectionOnInit;
12019
12029
  var _DictationRecordingButton_handleMouseDown;
12020
12030
  var _DictationRecordingButton_handleMouseUp;
12021
12031
  var _DictationRecordingButton_handleMouseLeave;
@@ -12033,6 +12043,7 @@ var DictationRecordingButton = class DictationRecordingButton2 extends i4 {
12033
12043
  _DictationRecordingButton_mediaController.set(this, new MediaController(this));
12034
12044
  _DictationRecordingButton_dictationController.set(this, new DictationController(this));
12035
12045
  _DictationRecordingButton_keybindingController.set(this, new KeybindingController(this));
12046
+ _DictationRecordingButton_closeConnectionOnInit.set(this, false);
12036
12047
  _DictationRecordingButton_handleWebSocketMessage.set(this, (message) => {
12037
12048
  switch (message.type) {
12038
12049
  case "CONFIG_ACCEPTED":
@@ -12073,6 +12084,13 @@ var DictationRecordingButton = class DictationRecordingButton2 extends i4 {
12073
12084
  this.dispatchEvent(streamClosedEvent(event));
12074
12085
  });
12075
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
+ }
12076
12094
  startRecording() {
12077
12095
  if (this._recordingState !== "stopped") {
12078
12096
  return;
@@ -12084,22 +12102,16 @@ var DictationRecordingButton = class DictationRecordingButton2 extends i4 {
12084
12102
  return;
12085
12103
  }
12086
12104
  if (this._recordingState === "initializing") {
12087
- this.addEventListener("recording-state-changed", (event) => {
12088
- if (event.detail.state === "recording") {
12089
- __classPrivateFieldGet7(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_handleStop).call(this);
12090
- }
12091
- }, {
12092
- once: true
12093
- });
12105
+ __classPrivateFieldSet6(this, _DictationRecordingButton_closeConnectionOnInit, true, "f");
12094
12106
  return;
12095
12107
  }
12096
12108
  __classPrivateFieldGet7(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_handleStop).call(this);
12097
12109
  }
12098
12110
  toggleRecording() {
12099
12111
  if (this._recordingState === "stopped") {
12100
- __classPrivateFieldGet7(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_handleStart).call(this);
12112
+ this.startRecording();
12101
12113
  } else if (this._recordingState === "recording") {
12102
- __classPrivateFieldGet7(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_handleStop).call(this);
12114
+ this.stopRecording();
12103
12115
  }
12104
12116
  }
12105
12117
  render() {
@@ -12127,6 +12139,7 @@ var DictationRecordingButton = class DictationRecordingButton2 extends i4 {
12127
12139
  _DictationRecordingButton_mediaController = /* @__PURE__ */ new WeakMap();
12128
12140
  _DictationRecordingButton_dictationController = /* @__PURE__ */ new WeakMap();
12129
12141
  _DictationRecordingButton_keybindingController = /* @__PURE__ */ new WeakMap();
12142
+ _DictationRecordingButton_closeConnectionOnInit = /* @__PURE__ */ new WeakMap();
12130
12143
  _DictationRecordingButton_handleWebSocketMessage = /* @__PURE__ */ new WeakMap();
12131
12144
  _DictationRecordingButton_handleWebSocketError = /* @__PURE__ */ new WeakMap();
12132
12145
  _DictationRecordingButton_handleWebSocketClose = /* @__PURE__ */ new WeakMap();
@@ -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;
@@ -84,24 +100,17 @@ let DictationRecordingButton = class DictationRecordingButton extends LitElement
84
100
  return;
85
101
  }
86
102
  if (this._recordingState === "initializing") {
87
- this.addEventListener("recording-state-changed", (event) => {
88
- if (event.detail
89
- .state === "recording") {
90
- __classPrivateFieldGet(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_handleStop).call(this);
91
- }
92
- }, {
93
- once: true,
94
- });
103
+ __classPrivateFieldSet(this, _DictationRecordingButton_closeConnectionOnInit, true, "f");
95
104
  return;
96
105
  }
97
106
  __classPrivateFieldGet(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_handleStop).call(this);
98
107
  }
99
108
  toggleRecording() {
100
109
  if (this._recordingState === "stopped") {
101
- __classPrivateFieldGet(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_handleStart).call(this);
110
+ this.startRecording();
102
111
  }
103
112
  else if (this._recordingState === "recording") {
104
- __classPrivateFieldGet(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_handleStop).call(this);
113
+ this.stopRecording();
105
114
  }
106
115
  }
107
116
  render() {
@@ -134,6 +143,7 @@ let DictationRecordingButton = class DictationRecordingButton extends LitElement
134
143
  _DictationRecordingButton_mediaController = new WeakMap();
135
144
  _DictationRecordingButton_dictationController = new WeakMap();
136
145
  _DictationRecordingButton_keybindingController = new WeakMap();
146
+ _DictationRecordingButton_closeConnectionOnInit = new WeakMap();
137
147
  _DictationRecordingButton_handleWebSocketMessage = new WeakMap();
138
148
  _DictationRecordingButton_handleWebSocketError = new WeakMap();
139
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,EA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AE,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,CAkQpC","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 (\n this._recordingState === \"stopped\" ||\n this._recordingState === \"stopping\"\n ) {\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,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,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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AAkB,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"]}
@@ -55,6 +55,9 @@ _KeybindingController_keydownHandler = new WeakMap(), _KeybindingController_keyu
55
55
  }
56
56
  if (this.host._mode === "push-to-talk" &&
57
57
  matchesKeybinding(event, this.host._keybinding)) {
58
+ if (!this.host.dispatchEvent(keybindingActivatedEvent(event))) {
59
+ return;
60
+ }
58
61
  this.host.stopRecording();
59
62
  }
60
63
  }, "f");
@@ -1 +1 @@
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;CAqEF;;IAlEG,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,CAAC;YACnD,OAA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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 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,CA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\"../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/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
  }