@corti/dictation-web 0.3.0 → 0.4.0-rc.1

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 (201) hide show
  1. package/README.md +9 -4
  2. package/dist/bundle.js +3100 -1630
  3. package/dist/components/audio-visualiser.d.ts +5 -3
  4. package/dist/components/audio-visualiser.js +38 -46
  5. package/dist/components/audio-visualiser.js.map +1 -1
  6. package/dist/components/corti-dictation.d.ts +122 -0
  7. package/dist/components/corti-dictation.js +238 -0
  8. package/dist/components/corti-dictation.js.map +1 -0
  9. package/dist/components/device-selector.d.ts +14 -0
  10. package/dist/components/device-selector.js +75 -0
  11. package/dist/components/device-selector.js.map +1 -0
  12. package/dist/components/language-selector.d.ts +15 -0
  13. package/dist/components/language-selector.js +74 -0
  14. package/dist/components/language-selector.js.map +1 -0
  15. package/dist/components/recording-button.d.ts +29 -0
  16. package/dist/components/recording-button.js +217 -0
  17. package/dist/components/recording-button.js.map +1 -0
  18. package/dist/components/settings-menu.d.ts +9 -15
  19. package/dist/components/settings-menu.js +48 -161
  20. package/dist/components/settings-menu.js.map +1 -1
  21. package/dist/constants.d.ts +8 -2
  22. package/dist/constants.js +38 -12
  23. package/dist/constants.js.map +1 -1
  24. package/dist/contexts/dictation-context.d.ts +99 -0
  25. package/dist/contexts/dictation-context.js +257 -0
  26. package/dist/contexts/dictation-context.js.map +1 -0
  27. package/dist/controllers/DictationController.d.ts +35 -0
  28. package/dist/controllers/DictationController.js +130 -0
  29. package/dist/controllers/DictationController.js.map +1 -0
  30. package/dist/controllers/MediaController.d.ts +31 -0
  31. package/dist/controllers/MediaController.js +99 -0
  32. package/dist/controllers/MediaController.js.map +1 -0
  33. package/dist/controllers/devices-controller.d.ts +26 -0
  34. package/dist/controllers/devices-controller.js +99 -0
  35. package/dist/controllers/devices-controller.js.map +1 -0
  36. package/dist/controllers/dictation-controller.d.ts +28 -0
  37. package/dist/controllers/dictation-controller.js +141 -0
  38. package/dist/controllers/dictation-controller.js.map +1 -0
  39. package/dist/controllers/languages-controller.d.ts +26 -0
  40. package/dist/controllers/languages-controller.js +83 -0
  41. package/dist/controllers/languages-controller.js.map +1 -0
  42. package/dist/controllers/media-controller.d.ts +24 -0
  43. package/dist/controllers/media-controller.js +115 -0
  44. package/dist/controllers/media-controller.js.map +1 -0
  45. package/dist/index.d.ts +9 -1
  46. package/dist/index.js +29 -3
  47. package/dist/index.js.map +1 -1
  48. package/dist/package.json +14 -0
  49. package/dist/src/components/audio-visualiser.d.ts +14 -0
  50. package/dist/src/components/audio-visualiser.js +57 -0
  51. package/dist/src/components/audio-visualiser.js.map +1 -0
  52. package/dist/src/components/corti-dictation.d.ts +123 -0
  53. package/dist/src/components/corti-dictation.js +224 -0
  54. package/dist/src/components/corti-dictation.js.map +1 -0
  55. package/dist/src/components/device-selector.d.ts +24 -0
  56. package/dist/src/components/device-selector.js +106 -0
  57. package/dist/src/components/device-selector.js.map +1 -0
  58. package/dist/src/components/language-selector.d.ts +24 -0
  59. package/dist/src/components/language-selector.js +100 -0
  60. package/dist/src/components/language-selector.js.map +1 -0
  61. package/dist/src/components/recording-button.d.ts +37 -0
  62. package/dist/src/components/recording-button.js +203 -0
  63. package/dist/src/components/recording-button.js.map +1 -0
  64. package/dist/src/components/settings-menu.d.ts +16 -0
  65. package/dist/src/components/settings-menu.js +80 -0
  66. package/dist/src/components/settings-menu.js.map +1 -0
  67. package/dist/src/constants.d.ts +4 -0
  68. package/dist/src/constants.js +37 -0
  69. package/dist/src/constants.js.map +1 -0
  70. package/dist/src/contexts/dictation-context.d.ts +97 -0
  71. package/dist/src/contexts/dictation-context.js +208 -0
  72. package/dist/src/contexts/dictation-context.js.map +1 -0
  73. package/dist/src/controllers/DictationController.d.ts +35 -0
  74. package/dist/src/controllers/DictationController.js +130 -0
  75. package/dist/src/controllers/DictationController.js.map +1 -0
  76. package/dist/src/controllers/MediaController.d.ts +31 -0
  77. package/dist/src/controllers/MediaController.js +99 -0
  78. package/dist/src/controllers/MediaController.js.map +1 -0
  79. package/dist/src/icons/icons.d.ts +17 -0
  80. package/dist/src/icons/icons.js +158 -0
  81. package/dist/src/icons/icons.js.map +1 -0
  82. package/dist/src/styles/ComponentStyles.d.ts +2 -0
  83. package/dist/src/styles/ComponentStyles.js +18 -0
  84. package/dist/src/styles/ComponentStyles.js.map +1 -0
  85. package/dist/src/styles/audio-visualiser.d.ts +2 -0
  86. package/dist/src/styles/audio-visualiser.js +33 -0
  87. package/dist/src/styles/audio-visualiser.js.map +1 -0
  88. package/dist/src/styles/buttons.d.ts +2 -0
  89. package/dist/src/styles/buttons.js +52 -0
  90. package/dist/src/styles/buttons.js.map +1 -0
  91. package/dist/src/styles/callout.d.ts +2 -0
  92. package/dist/src/styles/callout.js +23 -0
  93. package/dist/src/styles/callout.js.map +1 -0
  94. package/dist/src/styles/default-theme.d.ts +2 -0
  95. package/dist/src/styles/default-theme.js +50 -0
  96. package/dist/src/styles/default-theme.js.map +1 -0
  97. package/dist/src/styles/recording-button.d.ts +2 -0
  98. package/dist/src/styles/recording-button.js +8 -0
  99. package/dist/src/styles/recording-button.js.map +1 -0
  100. package/dist/src/styles/select.d.ts +2 -0
  101. package/dist/src/styles/select.js +36 -0
  102. package/dist/src/styles/select.js.map +1 -0
  103. package/dist/src/styles/settings-menu.d.ts +2 -0
  104. package/dist/src/styles/settings-menu.js +34 -0
  105. package/dist/src/styles/settings-menu.js.map +1 -0
  106. package/dist/src/types.d.ts +7 -0
  107. package/dist/src/types.js +2 -0
  108. package/dist/src/types.js.map +1 -0
  109. package/dist/src/utils/auth.d.ts +9 -0
  110. package/dist/src/utils/auth.js +21 -0
  111. package/dist/src/utils/auth.js.map +1 -0
  112. package/dist/src/utils/converters.d.ts +4 -0
  113. package/dist/src/utils/converters.js +8 -0
  114. package/dist/src/utils/converters.js.map +1 -0
  115. package/dist/src/utils/devices.d.ts +26 -0
  116. package/dist/src/utils/devices.js +53 -0
  117. package/dist/src/utils/devices.js.map +1 -0
  118. package/dist/src/utils/events.d.ts +44 -0
  119. package/dist/src/utils/events.js +88 -0
  120. package/dist/src/utils/events.js.map +1 -0
  121. package/dist/src/utils/languages.d.ts +7 -0
  122. package/dist/src/utils/languages.js +29 -0
  123. package/dist/src/utils/languages.js.map +1 -0
  124. package/dist/src/utils/media.d.ts +6 -0
  125. package/dist/src/utils/media.js +39 -0
  126. package/dist/src/utils/media.js.map +1 -0
  127. package/dist/src/utils/token.d.ts +13 -0
  128. package/dist/src/utils/token.js +60 -0
  129. package/dist/src/utils/token.js.map +1 -0
  130. package/dist/src/utils/validation.d.ts +1 -0
  131. package/dist/src/utils/validation.js +7 -0
  132. package/dist/src/utils/validation.js.map +1 -0
  133. package/dist/stories/audio-visualiser.stories.d.ts +39 -0
  134. package/dist/stories/audio-visualiser.stories.js +71 -0
  135. package/dist/stories/audio-visualiser.stories.js.map +1 -0
  136. package/dist/stories/corti-dictation.stories.d.ts +27 -0
  137. package/dist/stories/corti-dictation.stories.js +129 -0
  138. package/dist/stories/corti-dictation.stories.js.map +1 -0
  139. package/dist/stories/device-selector.stories.d.ts +18 -0
  140. package/dist/stories/device-selector.stories.js +84 -0
  141. package/dist/stories/device-selector.stories.js.map +1 -0
  142. package/dist/stories/language-selector.stories.d.ts +18 -0
  143. package/dist/stories/language-selector.stories.js +53 -0
  144. package/dist/stories/language-selector.stories.js.map +1 -0
  145. package/dist/stories/recording-button.stories.d.ts +27 -0
  146. package/dist/stories/recording-button.stories.js +90 -0
  147. package/dist/stories/recording-button.stories.js.map +1 -0
  148. package/dist/stories/settings-menu.stories.d.ts +23 -0
  149. package/dist/stories/settings-menu.stories.js +156 -0
  150. package/dist/stories/settings-menu.stories.js.map +1 -0
  151. package/dist/styles/ComponentStyles.js +5 -39
  152. package/dist/styles/ComponentStyles.js.map +1 -1
  153. package/dist/styles/audio-visualiser.d.ts +2 -0
  154. package/dist/styles/audio-visualiser.js +33 -0
  155. package/dist/styles/audio-visualiser.js.map +1 -0
  156. package/dist/styles/buttons.js +19 -26
  157. package/dist/styles/buttons.js.map +1 -1
  158. package/dist/styles/callout.js +7 -17
  159. package/dist/styles/callout.js.map +1 -1
  160. package/dist/styles/component-styles.d.ts +2 -0
  161. package/dist/styles/component-styles.js +22 -0
  162. package/dist/styles/component-styles.js.map +1 -0
  163. package/dist/styles/default-theme.d.ts +2 -0
  164. package/dist/styles/default-theme.js +14 -0
  165. package/dist/styles/default-theme.js.map +1 -0
  166. package/dist/styles/recording-button.d.ts +2 -0
  167. package/dist/styles/recording-button.js +8 -0
  168. package/dist/styles/recording-button.js.map +1 -0
  169. package/dist/styles/select.js +9 -9
  170. package/dist/styles/select.js.map +1 -1
  171. package/dist/styles/settings-menu.d.ts +2 -0
  172. package/dist/styles/settings-menu.js +34 -0
  173. package/dist/styles/settings-menu.js.map +1 -0
  174. package/dist/tsconfig.stories.tsbuildinfo +1 -0
  175. package/dist/types.d.ts +6 -8
  176. package/dist/types.js.map +1 -1
  177. package/dist/utils/auth.d.ts +9 -0
  178. package/dist/utils/auth.js +21 -0
  179. package/dist/utils/auth.js.map +1 -0
  180. package/dist/utils/converters.d.ts +4 -0
  181. package/dist/utils/converters.js +8 -0
  182. package/dist/utils/converters.js.map +1 -0
  183. package/dist/utils/devices.d.ts +26 -0
  184. package/dist/utils/devices.js +53 -0
  185. package/dist/utils/devices.js.map +1 -0
  186. package/dist/utils/events.d.ts +44 -0
  187. package/dist/utils/events.js +88 -0
  188. package/dist/utils/events.js.map +1 -0
  189. package/dist/utils/languages.d.ts +8 -0
  190. package/dist/utils/languages.js +29 -0
  191. package/dist/utils/languages.js.map +1 -0
  192. package/dist/utils/media.d.ts +6 -0
  193. package/dist/utils/media.js +39 -0
  194. package/dist/utils/media.js.map +1 -0
  195. package/dist/utils/token.d.ts +13 -0
  196. package/dist/utils/token.js +60 -0
  197. package/dist/utils/token.js.map +1 -0
  198. package/dist/utils/validation.d.ts +1 -0
  199. package/dist/utils/validation.js +7 -0
  200. package/dist/utils/validation.js.map +1 -0
  201. package/package.json +29 -55
@@ -1,12 +1,14 @@
1
- import { LitElement } from 'lit';
2
- export declare class AudioVisualiser extends LitElement {
1
+ import { LitElement, type PropertyValues } from "lit";
2
+ export declare class DictationAudioVisualiser extends LitElement {
3
3
  level: number;
4
4
  active: boolean;
5
+ segmentCount: number;
5
6
  static styles: import("lit").CSSResult;
7
+ willUpdate(changedProperties: PropertyValues<this>): void;
6
8
  render(): import("lit-html").TemplateResult<1>;
7
9
  }
8
10
  declare global {
9
11
  interface HTMLElementTagNameMap {
10
- 'audio-visualiser': AudioVisualiser;
12
+ "dictation-audio-visualiser": DictationAudioVisualiser;
11
13
  }
12
14
  }
@@ -4,62 +4,54 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
4
4
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
- import { LitElement, html, css } from 'lit';
8
- import { property, customElement } from 'lit/decorators.js';
9
- let AudioVisualiser = class AudioVisualiser extends LitElement {
7
+ import { html, LitElement } from "lit";
8
+ import { customElement, property } from "lit/decorators.js";
9
+ import { classMap } from "lit/directives/class-map.js";
10
+ import { map } from "lit/directives/map.js";
11
+ import { range } from "lit/directives/range.js";
12
+ import AudioVisualiserStyles from "../styles/audio-visualiser.js";
13
+ import { normalizeToRange } from "../utils/validation.js";
14
+ let DictationAudioVisualiser = class DictationAudioVisualiser extends LitElement {
10
15
  constructor() {
11
16
  super(...arguments);
12
- this.level = 0; // expects a value from 0 to 100
13
- this.active = true;
17
+ this.level = 0;
18
+ this.active = false;
19
+ this.segmentCount = 5;
14
20
  }
15
- render() {
16
- // Each segment represents 20%. Using Math.ceil to fill segments optimistically.
17
- const activeSegments = Math.round(this.level * 5);
18
- const segments = [];
19
- for (let i = 0; i < 5; i += 1) {
20
- segments.push(html `
21
- <div class="segment ${i < activeSegments ? 'active' : ''}"></div>
22
- `);
21
+ willUpdate(changedProperties) {
22
+ if (changedProperties.has("level")) {
23
+ this.level = normalizeToRange(this.level);
23
24
  }
25
+ }
26
+ render() {
27
+ // Each segment represents 20%. Using Math.round to fill segments.
28
+ const activeSegments = Math.round(this.level * this.segmentCount);
29
+ const segments = map(range(this.segmentCount), (i) => html `<div class=${classMap({
30
+ active: i < activeSegments,
31
+ segment: true,
32
+ })} />`);
24
33
  return html `
25
- <div class="container ${this.active ? 'active' : ''}">${segments}</div>
34
+ <div class=${classMap({
35
+ active: this.active,
36
+ container: true,
37
+ })}>
38
+ ${segments}
39
+ </div>
26
40
  `;
27
41
  }
28
42
  };
29
- AudioVisualiser.styles = css `
30
- :host {
31
- height: 100%;
32
- }
33
- .container {
34
- display: flex;
35
- width: 8px;
36
- flex-direction: column-reverse; /* Bottom-up stacking */
37
- height: 100%;
38
- gap: 1px;
39
- opacity: 0.5;
40
- &.active {
41
- opacity: 1;
42
- }
43
- }
44
- .segment {
45
- flex: 1;
46
- background-color: var(--action-accent-text-color);
47
- transition: background-color 0.25s;
48
- border-radius: 1px;
49
- opacity: 0.5;
50
- }
51
- .segment.active {
52
- opacity: 1;
53
- }
54
- `;
43
+ DictationAudioVisualiser.styles = AudioVisualiserStyles;
55
44
  __decorate([
56
45
  property({ type: Number })
57
- ], AudioVisualiser.prototype, "level", void 0);
46
+ ], DictationAudioVisualiser.prototype, "level", void 0);
58
47
  __decorate([
59
48
  property({ type: Boolean })
60
- ], AudioVisualiser.prototype, "active", void 0);
61
- AudioVisualiser = __decorate([
62
- customElement('audio-visualiser')
63
- ], AudioVisualiser);
64
- export { AudioVisualiser };
49
+ ], DictationAudioVisualiser.prototype, "active", void 0);
50
+ __decorate([
51
+ property({ type: Number })
52
+ ], DictationAudioVisualiser.prototype, "segmentCount", void 0);
53
+ DictationAudioVisualiser = __decorate([
54
+ customElement("dictation-audio-visualiser")
55
+ ], DictationAudioVisualiser);
56
+ export { DictationAudioVisualiser };
65
57
  //# sourceM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ourcesContent":["import { LitElement, html, css } from 'lit';\nimport { property, customElement } from 'lit/decorators.js';\n\n@customElement('audio-visualiser')\nexport class AudioVisualiser extends LitElement {\n @property({ type: Number }) level = 0; // expects a value from 0 to 100\n\n @property({ type: Boolean }) active = true;\n\n static styles = css`\n :host {\n height: 100%;\n }\n .container {\n display: flex;\n width: 8px;\n flex-direction: column-reverse; /* Bottom-up stacking */\n height: 100%;\n gap: 1px;\n opacity: 0.5;\n &.active {\n opacity: 1;\n }\n }\n .segment {\n flex: 1;\n background-color: var(--action-accent-text-color);\n transition: background-color 0.25s;\n border-radius: 1px;\n opacity: 0.5;\n }\n .segment.active {\n opacity: 1;\n }\n `;\n\n render() {\n // Each segment represents 20%. Using Math.ceil to fill segments optimistically.\n const activeSegments = Math.round(this.level * 5);\n const segments = [];\n for (let i = 0; i < 5; i += 1) {\n segments.push(html`\n <div class=\"segment ${i < activeSegments ? 'active' : ''}\"></div>\n `);\n }\n return html`\n <div class=\"container ${this.active ? 'active' : ''}\">${segments}</div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'audio-visualiser': AudioVisualiser;\n }\n}\n"]}
1
+ {"version":3,"file":"audio-visualiser.js","sourceRoot":"","sources":["../../src/components/audio-visualiser.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAuB,MAAM,KAAK,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,qBAAqB,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAGnD,IAAM,wBAAwB,GAA9B,MAAM,wBAAyB,SAAQ,UAAU;IAAjD;;QAEL,UAAK,GAAW,CAAC,CAAC;QAGlB,WAAM,GAAY,KAAK,CAAC;QAGxB,iBAAY,GAAW,CAAC,CAAC;IA+B3B,CAAC;IA3BC,UAAU,CAAC,iBAAuC;QAChD,IAAI,iBAAiB,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;YACnC,IAAI,CAAC,KAAK,GAAG,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC;IAED,MAAM;QACJ,kEAAkE;QAClE,MAAM,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC;QAClE,MAAM,QAAQ,GAAG,GAAG,CAClB,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,EACxB,CAAC,CAAC,EAAE,EAAE,CACJ,IAAI,CAAA,cAAc,QAAQ,CAAC;YACzB,MAAM,EAAE,CAAC,GAAG,cAAc;YAC1B,OAAO,EAAE,IAAI;SACd,CAAC,KAAK,CACV,CAAC;QAEF,OAAO,IAAI,CAAA;mBACI,QAAQ,CAAC;YACpB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,SAAS,EAAE,IAAI;SAChB,CAAC;UACE,QAAQ;;KAEb,CAAC;IACJ,CAAC;;AA5BM,+BAAM,GAAG,qBAAqB,AAAxB,CAAyB;AARtC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uDACT;AAGlB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;wDACJ;AAGxB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8DACF;AARd,wBAAwB;IADpC,aAAa,CAAC,4BAA4B,CAAC;GAC/B,wBAAwB,CAuCpC","sourcesContent":["import { html, LitElement, type PropertyValues } from \"lit\";\nimport { customElement, property } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport { map } from \"lit/directives/map.js\";\nimport { range } from \"lit/directives/range.js\";\nimport AudioVisualiserStyles from \"../styles/audio-visualiser.js\";\nimport { normalizeToRange } from \"../utils/validation.js\";\n\n@customElement(\"dictation-audio-visualiser\")\nexport class DictationAudioVisualiser extends LitElement {\n @property({ type: Number })\n level: number = 0;\n\n @property({ type: Boolean })\n active: boolean = false;\n\n @property({ type: Number })\n segmentCount: number = 5;\n\n static styles = AudioVisualiserStyles;\n\n willUpdate(changedProperties: PropertyValues<this>): void {\n if (changedProperties.has(\"level\")) {\n this.level = normalizeToRange(this.level);\n }\n }\n\n render() {\n // Each segment represents 20%. Using Math.round to fill segments.\n const activeSegments = Math.round(this.level * this.segmentCount);\n const segments = map(\n range(this.segmentCount),\n (i) =>\n html`<div class=${classMap({\n active: i < activeSegments,\n segment: true,\n })} />`,\n );\n\n return html`\n <div class=${classMap({\n active: this.active,\n container: true,\n })}>\n ${segments}\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"dictation-audio-visualiser\": DictationAudioVisualiser;\n }\n}\n"]}
@@ -0,0 +1,122 @@
1
+ import type { Corti } from "@corti/sdk";
2
+ import { LitElement } from "lit";
3
+ import type { ConfigurableSettings, ProxyOptions, RecordingState } from "../types.js";
4
+ import "../contexts/dictation-context.js";
5
+ import "./recording-button.js";
6
+ import "./settings-menu.js";
7
+ export declare class CortiDictation extends LitElement {
8
+ #private;
9
+ static styles: import("lit").CSSResult;
10
+ /**
11
+ * Latest access token
12
+ */
13
+ accessToken?: string;
14
+ /**
15
+ * Authentication configuration with optional refresh mechanism.
16
+ */
17
+ authConfig?: Corti.BearerOptions;
18
+ /**
19
+ * WebSocket URL for proxy connection. When provided, uses CortiWebSocketProxyClient instead of CortiClient.
20
+ */
21
+ socketUrl?: string;
22
+ /**
23
+ * Socket proxy configuration object. When provided, uses CortiWebSocketProxyClient instead of CortiClient.
24
+ */
25
+ socketProxy?: ProxyOptions;
26
+ /**
27
+ * List of all language codes available for use with the Web Component.
28
+ * Default list depends on the accessToken
29
+ */
30
+ set languagesSupported(value: Corti.TranscribeSupportedLanguage[] | undefined);
31
+ get languagesSupported(): Corti.TranscribeSupportedLanguage[];
32
+ _languagesSupported?: Corti.TranscribeSupportedLanguage[];
33
+ /**
34
+ * Which settings should be available in the UI.
35
+ * If an empty array is passed, the settings will be disabled entirely.
36
+ * Options are language and devices
37
+ */
38
+ settingsEnabled: ConfigurableSettings[];
39
+ /**
40
+ * When false (default), allows the start/stop button from taking focus when clicked,
41
+ * disabling textareas or other input elements to maintain focus.
42
+ * Set to "true" to allow the button to receive focus on click.
43
+ */
44
+ allowButtonFocus: boolean;
45
+ /**
46
+ * Overrides any device selection and instead uses getDisplayMedia to stream system audio.
47
+ * Should only be used for debugging.
48
+ */
49
+ debug_displayAudio: boolean;
50
+ /**
51
+ * Configuration settings for dictation
52
+ */
53
+ set dictationConfig(value: Corti.TranscribeConfig);
54
+ get dictationConfig(): Corti.TranscribeConfig;
55
+ _dictationConfig: Corti.TranscribeConfig;
56
+ /**
57
+ * List of available recording devices
58
+ */
59
+ set devices(value: MediaDeviceInfo[] | undefined);
60
+ get devices(): MediaDeviceInfo[];
61
+ _devices?: MediaDeviceInfo[];
62
+ /**
63
+ * The selected device used for recording (MediaDeviceInfo).
64
+ */
65
+ set selectedDevice(value: MediaDeviceInfo | undefined);
66
+ get selectedDevice(): MediaDeviceInfo | undefined;
67
+ _selectedDevice?: MediaDeviceInfo;
68
+ /**
69
+ * Current state of recording (stopped, recording, initializing and stopping, ).
70
+ */
71
+ get recordingState(): RecordingState;
72
+ /**
73
+ * Set the latest access token.
74
+ * @returns ServerConfig with environment, tenant, and accessToken
75
+ * @deprecated Use 'accessToken' property instead.
76
+ */
77
+ setAccessToken(token: string): {
78
+ accessToken: string | undefined;
79
+ environment: undefined;
80
+ tenant: undefined;
81
+ } | {
82
+ accessToken: string;
83
+ environment: string;
84
+ tenant: string;
85
+ };
86
+ /**
87
+ * Set the auth configuration for OAuth flows.
88
+ * @returns Promise with ServerConfig containing environment, tenant, and accessToken
89
+ * @deprecated Use 'authConfig' property instead.
90
+ */
91
+ setAuthConfig(config: Corti.BearerOptions): Promise<{
92
+ accessToken: string | undefined;
93
+ environment: undefined;
94
+ tenant: undefined;
95
+ } | {
96
+ accessToken: string;
97
+ environment: string;
98
+ tenant: string;
99
+ } | {
100
+ accessToken: undefined;
101
+ environment: undefined;
102
+ tenant: undefined;
103
+ }>;
104
+ /**
105
+ * Starts a recording.
106
+ */
107
+ startRecording(): void;
108
+ /**
109
+ * Stops a recording.
110
+ */
111
+ stopRecording(): void;
112
+ /**
113
+ * Starts or stops recording. Convenience layer on top of the start/stop methods.
114
+ */
115
+ toggleRecording(): void;
116
+ render(): import("lit-html").TemplateResult<1>;
117
+ }
118
+ declare global {
119
+ interface HTMLElementTagNameMap {
120
+ "corti-dictation": CortiDictation;
121
+ }
122
+ }
@@ -0,0 +1,238 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
+ };
12
+ var _CortiDictation_recordingButtonRef, _CortiDictation_contextProviderRef;
13
+ import { css, html, LitElement, nothing } from "lit";
14
+ import { customElement, property, state } from "lit/decorators.js";
15
+ import { classMap } from "lit/directives/class-map.js";
16
+ import { createRef, ref } from "lit/directives/ref.js";
17
+ import { DEFAULT_DICTATION_CONFIG } from "../constants.js";
18
+ import { commaSeparatedConverter } from "../utils/converters.js";
19
+ import "../contexts/dictation-context.js";
20
+ import "./recording-button.js";
21
+ import "./settings-menu.js";
22
+ let CortiDictation = class CortiDictation extends LitElement {
23
+ constructor() {
24
+ super(...arguments);
25
+ // ─────────────────────────────────────────────────────────────────────────────
26
+ // Private refs
27
+ // ─────────────────────────────────────────────────────────────────────────────
28
+ _CortiDictation_recordingButtonRef.set(this, createRef());
29
+ _CortiDictation_contextProviderRef.set(this, createRef());
30
+ /**
31
+ * Which settings should be available in the UI.
32
+ * If an empty array is passed, the settings will be disabled entirely.
33
+ * Options are language and devices
34
+ */
35
+ this.settingsEnabled = ["device", "language"];
36
+ /**
37
+ * When false (default), allows the start/stop button from taking focus when clicked,
38
+ * disabling textareas or other input elements to maintain focus.
39
+ * Set to "true" to allow the button to receive focus on click.
40
+ */
41
+ this.allowButtonFocus = false;
42
+ /**
43
+ * Overrides any device selection and instead uses getDisplayMedia to stream system audio.
44
+ * Should only be used for debugging.
45
+ */
46
+ this.debug_displayAudio = false;
47
+ this._dictationConfig = DEFAULT_DICTATION_CONFIG;
48
+ }
49
+ /**
50
+ * List of all language codes available for use with the Web Component.
51
+ * Default list depends on the accessToken
52
+ */
53
+ set languagesSupported(value) {
54
+ this._languagesSupported = value;
55
+ }
56
+ get languagesSupported() {
57
+ return (__classPrivateFieldGet(this, _CortiDictation_contextProviderRef, "f").value?.languages ||
58
+ this._languagesSupported ||
59
+ []);
60
+ }
61
+ /**
62
+ * Configuration settings for dictation
63
+ */
64
+ set dictationConfig(value) {
65
+ this._dictationConfig = value;
66
+ }
67
+ get dictationConfig() {
68
+ return (__classPrivateFieldGet(this, _CortiDictation_contextProviderRef, "f").value?.dictationConfig || this._dictationConfig);
69
+ }
70
+ /**
71
+ * List of available recording devices
72
+ */
73
+ set devices(value) {
74
+ this._devices = value;
75
+ }
76
+ get devices() {
77
+ return __classPrivateFieldGet(this, _CortiDictation_contextProviderRef, "f").value?.devices || this._devices || [];
78
+ }
79
+ /**
80
+ * The selected device used for recording (MediaDeviceInfo).
81
+ */
82
+ set selectedDevice(value) {
83
+ this._selectedDevice = value;
84
+ }
85
+ get selectedDevice() {
86
+ return (__classPrivateFieldGet(this, _CortiDictation_contextProviderRef, "f").value?.selectedDevice || this._selectedDevice);
87
+ }
88
+ /**
89
+ * Current state of recording (stopped, recording, initializing and stopping, ).
90
+ */
91
+ get recordingState() {
92
+ return __classPrivateFieldGet(this, _CortiDictation_contextProviderRef, "f").value?.recordingState || "stopped";
93
+ }
94
+ // ─────────────────────────────────────────────────────────────────────────────
95
+ // Public methods
96
+ // ─────────────────────────────────────────────────────────────────────────────
97
+ /**
98
+ * Set the latest access token.
99
+ * @returns ServerConfig with environment, tenant, and accessToken
100
+ * @deprecated Use 'accessToken' property instead.
101
+ */
102
+ setAccessToken(token) {
103
+ this.accessToken = token;
104
+ return (__classPrivateFieldGet(this, _CortiDictation_contextProviderRef, "f").value?.setAccessToken(token) ?? {
105
+ accessToken: token,
106
+ environment: undefined,
107
+ tenant: undefined,
108
+ });
109
+ }
110
+ /**
111
+ * Set the auth configuration for OAuth flows.
112
+ * @returns Promise with ServerConfig containing environment, tenant, and accessToken
113
+ * @deprecated Use 'authConfig' property instead.
114
+ */
115
+ async setAuthConfig(config) {
116
+ this.authConfig = config;
117
+ return (__classPrivateFieldGet(this, _CortiDictation_contextProviderRef, "f").value?.setAuthConfig(config) ?? {
118
+ accessToken: undefined,
119
+ environment: undefined,
120
+ tenant: undefined,
121
+ });
122
+ }
123
+ /**
124
+ * Starts a recording.
125
+ */
126
+ startRecording() {
127
+ __classPrivateFieldGet(this, _CortiDictation_recordingButtonRef, "f").value?.startRecording();
128
+ }
129
+ /**
130
+ * Stops a recording.
131
+ */
132
+ stopRecording() {
133
+ __classPrivateFieldGet(this, _CortiDictation_recordingButtonRef, "f").value?.stopRecording();
134
+ }
135
+ /**
136
+ * Starts or stops recording. Convenience layer on top of the start/stop methods.
137
+ */
138
+ toggleRecording() {
139
+ __classPrivateFieldGet(this, _CortiDictation_recordingButtonRef, "f").value?.toggleRecording();
140
+ }
141
+ // ─────────────────────────────────────────────────────────────────────────────
142
+ // Render
143
+ // ─────────────────────────────────────────────────────────────────────────────
144
+ render() {
145
+ const isHidden = !this.accessToken &&
146
+ !this.authConfig &&
147
+ !this.socketUrl &&
148
+ !this.socketProxy;
149
+ return html `
150
+ <dictation-root
151
+ ${ref(__classPrivateFieldGet(this, _CortiDictation_contextProviderRef, "f"))}
152
+ class=${classMap({ hidden: isHidden })}
153
+ .accessToken=${this.accessToken}
154
+ .authConfig=${this.authConfig}
155
+ .socketUrl=${this.socketUrl}
156
+ .socketProxy=${this.socketProxy}
157
+ .dictationConfig=${this._dictationConfig}
158
+ .languages=${this._languagesSupported}
159
+ .devices=${this._devices}
160
+ .selectedDevice=${this._selectedDevice}
161
+ .debug_displayAudio=${this.debug_displayAudio}
162
+ >
163
+ <dictation-recording-button
164
+ ${ref(__classPrivateFieldGet(this, _CortiDictation_recordingButtonRef, "f"))}
165
+ ?allowButtonFocus=${this.allowButtonFocus}
166
+ ></dictation-recording-button>
167
+ ${this.settingsEnabled?.length > 0
168
+ ? html `<dictation-settings-menu
169
+ .settingsEnabled=${this.settingsEnabled}
170
+ ></dictation-settings-menu>`
171
+ : nothing}
172
+ </dictation-root>
173
+ `;
174
+ }
175
+ };
176
+ _CortiDictation_recordingButtonRef = new WeakMap();
177
+ _CortiDictation_contextProviderRef = new WeakMap();
178
+ CortiDictation.styles = css `
179
+ .hidden {
180
+ display: none;
181
+ }
182
+ `;
183
+ __decorate([
184
+ property({ type: String })
185
+ ], CortiDictation.prototype, "accessToken", void 0);
186
+ __decorate([
187
+ property({ attribute: false, type: Object })
188
+ ], CortiDictation.prototype, "authConfig", void 0);
189
+ __decorate([
190
+ property({ type: String })
191
+ ], CortiDictation.prototype, "socketUrl", void 0);
192
+ __decorate([
193
+ property({ attribute: false, type: Object })
194
+ ], CortiDictation.prototype, "socketProxy", void 0);
195
+ __decorate([
196
+ property({
197
+ converter: commaSeparatedConverter,
198
+ type: Array,
199
+ })
200
+ ], CortiDictation.prototype, "languagesSupported", null);
201
+ __decorate([
202
+ state()
203
+ ], CortiDictation.prototype, "_languagesSupported", void 0);
204
+ __decorate([
205
+ property({
206
+ converter: commaSeparatedConverter,
207
+ type: Array,
208
+ })
209
+ ], CortiDictation.prototype, "settingsEnabled", void 0);
210
+ __decorate([
211
+ property({ type: Boolean })
212
+ ], CortiDictation.prototype, "allowButtonFocus", void 0);
213
+ __decorate([
214
+ property({ attribute: "debug-display-audio", type: Boolean })
215
+ ], CortiDictation.prototype, "debug_displayAudio", void 0);
216
+ __decorate([
217
+ property({ attribute: false, type: Object })
218
+ ], CortiDictation.prototype, "dictationConfig", null);
219
+ __decorate([
220
+ state()
221
+ ], CortiDictation.prototype, "_dictationConfig", void 0);
222
+ __decorate([
223
+ property({ attribute: false, type: Array })
224
+ ], CortiDictation.prototype, "devices", null);
225
+ __decorate([
226
+ state()
227
+ ], CortiDictation.prototype, "_devices", void 0);
228
+ __decorate([
229
+ property({ attribute: false, type: Object })
230
+ ], CortiDictation.prototype, "selectedDevice", null);
231
+ __decorate([
232
+ state()
233
+ ], CortiDictation.prototype, "_selectedDevice", void 0);
234
+ CortiDictation = __decorate([
235
+ customElement("corti-dictation")
236
+ ], CortiDictation);
237
+ export { CortiDictation };
238
+ //# sourceMappingURL=corti-dictation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"corti-dictation.js","sourceRoot":"","sources":["../../src/components/corti-dictation.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,QAAQ,EA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MjC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;iDACR;AAMnB;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;mDAClB;AAU3B;IAJC,QAAQ,CAAC;QACR,SAAS,EAAE,uBAAuB;QAClC,IAAI,EAAE,KAAK;KACZ,CAAC;wDAKD;AAWD;IADC,KAAK,EAAE;2DACkD;AAW1D;IAJC,QAAQ,CAAC;QACR,SAAS,EAAE,uBAAuB;QAClC,IAAI,EAAE,KAAK;KACZ,CAAC;uDAC+D;AAQjE;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;wDACM;AAOlC;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,qBAAqB,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;0DAC1B;AAMpC;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;qDAG5C;AASD;IADC,KAAK,EAAE;wDAC4D;AAMpE;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;6CAG3C;AAOD;IADC,KAAK,EAAE;gDACqB;AAM7B;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;oDAG5C;AASD;IADC,KAAK,EAAE;uDAC0B;AA3IvB,cAAc;IAD1B,aAAa,CAAC,iBAAiB,CAAC;GACpB,cAAc,CAsP1B","sourcesContent":["import type { Corti } from \"@corti/sdk\";\nimport { css, html, LitElement, nothing } from \"lit\";\nimport { customElement, property, state } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport { createRef, type Ref, ref } from \"lit/directives/ref.js\";\nimport { DEFAULT_DICTATION_CONFIG } from \"../constants.js\";\nimport type { DictationRoot } from \"../contexts/dictation-context.js\";\nimport type {\n ConfigurableSettings,\n ProxyOptions,\n RecordingState,\n} from \"../types.js\";\nimport { commaSeparatedConverter } from \"../utils/converters.js\";\nimport type { DictationRecordingButton } from \"./recording-button.js\";\n\nimport \"../contexts/dictation-context.js\";\nimport \"./recording-button.js\";\nimport \"./settings-menu.js\";\n\n@customElement(\"corti-dictation\")\nexport class CortiDictation extends LitElement {\n static styles = css`\n .hidden {\n display: none;\n }\n `;\n // ─────────────────────────────────────────────────────────────────────────────\n // Private refs\n // ─────────────────────────────────────────────────────────────────────────────\n\n #recordingButtonRef: Ref<DictationRecordingButton> = createRef();\n #contextProviderRef: Ref<DictationRoot> = createRef();\n\n // ─────────────────────────────────────────────────────────────────────────────\n // Properties\n // ─────────────────────────────────────────────────────────────────────────────\n\n /**\n * Latest access token\n */\n @property({ type: String })\n accessToken?: string;\n\n /**\n * Authentication configuration with optional refresh mechanism.\n */\n @property({ attribute: false, type: Object })\n authConfig?: Corti.BearerOptions;\n\n /**\n * WebSocket URL for proxy connection. When provided, uses CortiWebSocketProxyClient instead of CortiClient.\n */\n @property({ type: String })\n socketUrl?: string;\n\n /**\n * Socket proxy configuration object. When provided, uses CortiWebSocketProxyClient instead of CortiClient.\n */\n @property({ attribute: false, type: Object })\n socketProxy?: ProxyOptions;\n\n /**\n * List of all language codes available for use with the Web Component.\n * Default list depends on the accessToken\n */\n @property({\n converter: commaSeparatedConverter,\n type: Array,\n })\n set languagesSupported(value:\n | Corti.TranscribeSupportedLanguage[]\n | undefined) {\n this._languagesSupported = value;\n }\n\n get languagesSupported(): Corti.TranscribeSupportedLanguage[] {\n return (\n this.#contextProviderRef.value?.languages ||\n this._languagesSupported ||\n []\n );\n }\n\n @state()\n _languagesSupported?: Corti.TranscribeSupportedLanguage[];\n\n /**\n * Which settings should be available in the UI.\n * If an empty array is passed, the settings will be disabled entirely.\n * Options are language and devices\n */\n @property({\n converter: commaSeparatedConverter,\n type: Array,\n })\n settingsEnabled: ConfigurableSettings[] = [\"device\", \"language\"];\n\n /**\n * When false (default), allows the start/stop button from taking focus when clicked,\n * disabling textareas or other input elements to maintain focus.\n * Set to \"true\" to allow the button to receive focus on click.\n */\n @property({ type: Boolean })\n allowButtonFocus: boolean = false;\n\n /**\n * Overrides any device selection and instead uses getDisplayMedia to stream system audio.\n * Should only be used for debugging.\n */\n @property({ attribute: \"debug-display-audio\", type: Boolean })\n debug_displayAudio: boolean = false;\n\n /**\n * Configuration settings for dictation\n */\n @property({ attribute: false, type: Object })\n set dictationConfig(value: Corti.TranscribeConfig) {\n this._dictationConfig = value;\n }\n\n get dictationConfig(): Corti.TranscribeConfig {\n return (\n this.#contextProviderRef.value?.dictationConfig || this._dictationConfig\n );\n }\n\n @state()\n _dictationConfig: Corti.TranscribeConfig = DEFAULT_DICTATION_CONFIG;\n\n /**\n * List of available recording devices\n */\n @property({ attribute: false, type: Array })\n set devices(value: MediaDeviceInfo[] | undefined) {\n this._devices = value;\n }\n\n get devices(): MediaDeviceInfo[] {\n return this.#contextProviderRef.value?.devices || this._devices || [];\n }\n\n @state()\n _devices?: MediaDeviceInfo[];\n\n /**\n * The selected device used for recording (MediaDeviceInfo).\n */\n @property({ attribute: false, type: Object })\n set selectedDevice(value: MediaDeviceInfo | undefined) {\n this._selectedDevice = value;\n }\n\n get selectedDevice(): MediaDeviceInfo | undefined {\n return (\n this.#contextProviderRef.value?.selectedDevice || this._selectedDevice\n );\n }\n\n @state()\n _selectedDevice?: MediaDeviceInfo;\n\n /**\n * Current state of recording (stopped, recording, initializing and stopping, ).\n */\n get recordingState(): RecordingState {\n return this.#contextProviderRef.value?.recordingState || \"stopped\";\n }\n\n // ─────────────────────────────────────────────────────────────────────────────\n // Public methods\n // ─────────────────────────────────────────────────────────────────────────────\n\n /**\n * Set the latest access token.\n * @returns ServerConfig with environment, tenant, and accessToken\n * @deprecated Use 'accessToken' property instead.\n */\n public setAccessToken(token: string) {\n this.accessToken = token;\n\n return (\n this.#contextProviderRef.value?.setAccessToken(token) ?? {\n accessToken: token,\n environment: undefined,\n tenant: undefined,\n }\n );\n }\n\n /**\n * Set the auth configuration for OAuth flows.\n * @returns Promise with ServerConfig containing environment, tenant, and accessToken\n * @deprecated Use 'authConfig' property instead.\n */\n public async setAuthConfig(config: Corti.BearerOptions) {\n this.authConfig = config;\n\n return (\n this.#contextProviderRef.value?.setAuthConfig(config) ?? {\n accessToken: undefined,\n environment: undefined,\n tenant: undefined,\n }\n );\n }\n\n /**\n * Starts a recording.\n */\n public startRecording(): void {\n this.#recordingButtonRef.value?.startRecording();\n }\n\n /**\n * Stops a recording.\n */\n public stopRecording(): void {\n this.#recordingButtonRef.value?.stopRecording();\n }\n\n /**\n * Starts or stops recording. Convenience layer on top of the start/stop methods.\n */\n public toggleRecording(): void {\n this.#recordingButtonRef.value?.toggleRecording();\n }\n\n // ─────────────────────────────────────────────────────────────────────────────\n // Render\n // ─────────────────────────────────────────────────────────────────────────────\n\n render() {\n const isHidden =\n !this.accessToken &&\n !this.authConfig &&\n !this.socketUrl &&\n !this.socketProxy;\n\n return html`\n <dictation-root\n ${ref(this.#contextProviderRef)}\n class=${classMap({ hidden: isHidden })}\n .accessToken=${this.accessToken}\n .authConfig=${this.authConfig}\n .socketUrl=${this.socketUrl}\n .socketProxy=${this.socketProxy}\n .dictationConfig=${this._dictationConfig}\n .languages=${this._languagesSupported}\n .devices=${this._devices}\n .selectedDevice=${this._selectedDevice}\n .debug_displayAudio=${this.debug_displayAudio}\n >\n <dictation-recording-button\n ${ref(this.#recordingButtonRef)}\n ?allowButtonFocus=${this.allowButtonFocus}\n ></dictation-recording-button>\n ${\n this.settingsEnabled?.length > 0\n ? html`<dictation-settings-menu\n .settingsEnabled=${this.settingsEnabled}\n ></dictation-settings-menu>`\n : nothing\n }\n </dictation-root>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"corti-dictation\": CortiDictation;\n }\n}\n"]}
@@ -0,0 +1,14 @@
1
+ import { LitElement } from "lit";
2
+ export declare class DictationDeviceSelector extends LitElement {
3
+ #private;
4
+ _devices?: MediaDeviceInfo[];
5
+ _selectedDevice?: MediaDeviceInfo;
6
+ disabled: boolean;
7
+ static styles: import("lit").CSSResult;
8
+ render(): import("lit-html").TemplateResult<1>;
9
+ }
10
+ declare global {
11
+ interface HTMLElementTagNameMap {
12
+ "dictation-device-selector": DictationDeviceSelector;
13
+ }
14
+ }
@@ -0,0 +1,75 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
+ };
12
+ var _DictationDeviceSelector_instances, _DictationDeviceSelector_handleSelectDevice;
13
+ import { consume } from "@lit/context";
14
+ import { html, LitElement } from "lit";
15
+ import { customElement, property, state } from "lit/decorators.js";
16
+ import { devicesContext, selectedDeviceContext, } from "../contexts/dictation-context.js";
17
+ import SelectStyles from "../styles/select.js";
18
+ import { recordingDevicesChangedEvent } from "../utils/events.js";
19
+ let DictationDeviceSelector = class DictationDeviceSelector extends LitElement {
20
+ constructor() {
21
+ super(...arguments);
22
+ _DictationDeviceSelector_instances.add(this);
23
+ this.disabled = false;
24
+ }
25
+ render() {
26
+ return html `
27
+ <div>
28
+ <label id="device-select-label" for="device-select">
29
+ Recording Device
30
+ </label>
31
+ <select
32
+ id="device-select"
33
+ aria-labelledby="device-select-label"
34
+ @change=${__classPrivateFieldGet(this, _DictationDeviceSelector_instances, "m", _DictationDeviceSelector_handleSelectDevice)}
35
+ ?disabled=${this.disabled || !this._devices || this._devices.length === 0}
36
+ >
37
+ ${this._devices?.map((device) => html `
38
+ <option
39
+ value=${device.deviceId}
40
+ ?selected=${this._selectedDevice?.deviceId === device.deviceId}
41
+ >
42
+ ${device.label || "Unknown Device"}
43
+ </option>
44
+ `)}
45
+ </select>
46
+ </div>
47
+ `;
48
+ }
49
+ };
50
+ _DictationDeviceSelector_instances = new WeakSet();
51
+ _DictationDeviceSelector_handleSelectDevice = function _DictationDeviceSelector_handleSelectDevice(e) {
52
+ const deviceId = e.target.value;
53
+ const device = this._devices?.find((d) => d.deviceId === deviceId);
54
+ if (!device) {
55
+ return;
56
+ }
57
+ this.dispatchEvent(recordingDevicesChangedEvent(this._devices || [], device));
58
+ };
59
+ DictationDeviceSelector.styles = SelectStyles;
60
+ __decorate([
61
+ consume({ context: devicesContext, subscribe: true }),
62
+ state()
63
+ ], DictationDeviceSelector.prototype, "_devices", void 0);
64
+ __decorate([
65
+ consume({ context: selectedDeviceContext, subscribe: true }),
66
+ state()
67
+ ], DictationDeviceSelector.prototype, "_selectedDevice", void 0);
68
+ __decorate([
69
+ property({ type: Boolean })
70
+ ], DictationDeviceSelector.prototype, "disabled", void 0);
71
+ DictationDeviceSelector = __decorate([
72
+ customElement("dictation-device-selector")
73
+ ], DictationDeviceSelector);
74
+ export { DictationDeviceSelector };
75
+ //# sourceMappingURL=device-selector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"device-selector.js","sourceRoot":"","sources":["../../src/components/device-selector.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE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AE,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IACrD,KAAK,EAAE;yDACqB;AAI7B;IAFC,OAAO,CAAC,EAAE,OAAO,EAAE,qBAAqB,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IAC5D,KAAK,EAAE;gEAC0B;AAGlC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;yDACF;AAVf,uBAAuB;IADnC,aAAa,CAAC,2BAA2B,CAAC;GAC9B,uBAAuB,CAqDnC","sourcesContent":["import { consume } from \"@lit/context\";\nimport { html, LitElement } from \"lit\";\nimport { customElement, property, state } from \"lit/decorators.js\";\nimport {\n devicesContext,\n selectedDeviceContext,\n} from \"../contexts/dictation-context.js\";\nimport SelectStyles from \"../styles/select.js\";\nimport { recordingDevicesChangedEvent } from \"../utils/events.js\";\n\n@customElement(\"dictation-device-selector\")\nexport class DictationDeviceSelector extends LitElement {\n @consume({ context: devicesContext, subscribe: true })\n @state()\n _devices?: MediaDeviceInfo[];\n\n @consume({ context: selectedDeviceContext, subscribe: true })\n @state()\n _selectedDevice?: MediaDeviceInfo;\n\n @property({ type: Boolean })\n disabled: boolean = false;\n\n static styles = SelectStyles;\n\n #handleSelectDevice(e: Event): void {\n const deviceId = (e.target as HTMLSelectElement).value;\n const device = this._devices?.find((d) => d.deviceId === deviceId);\n\n if (!device) {\n return;\n }\n\n this.dispatchEvent(\n recordingDevicesChangedEvent(this._devices || [], device),\n );\n }\n\n render() {\n return html`\n <div>\n <label id=\"device-select-label\" for=\"device-select\">\n Recording Device\n </label>\n <select\n id=\"device-select\"\n aria-labelledby=\"device-select-label\"\n @change=${this.#handleSelectDevice}\n ?disabled=${this.disabled || !this._devices || this._devices.length === 0}\n >\n ${this._devices?.map(\n (device) => html`\n <option\n value=${device.deviceId}\n ?selected=${this._selectedDevice?.deviceId === device.deviceId}\n >\n ${device.label || \"Unknown Device\"}\n </option>\n `,\n )}\n </select>\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"dictation-device-selector\": DictationDeviceSelector;\n }\n}\n"]}
@@ -0,0 +1,15 @@
1
+ import type { Corti } from "@corti/sdk";
2
+ import { LitElement } from "lit";
3
+ export declare class DictationLanguageSelector extends LitElement {
4
+ #private;
5
+ _languages?: Corti.TranscribeSupportedLanguage[];
6
+ _dictationConfig?: Corti.TranscribeConfig;
7
+ disabled: boolean;
8
+ static styles: import("lit").CSSResult;
9
+ render(): import("lit-html").TemplateResult<1>;
10
+ }
11
+ declare global {
12
+ interface HTMLElementTagNameMap {
13
+ "dictation-language-selector": DictationLanguageSelector;
14
+ }
15
+ }