@corti/dictation-web 0.0.0-test.571.2 → 0.0.0-test.7
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.
- package/README.md +25 -39
- package/dist/bundle.js +1120 -535
- package/dist/components/corti-dictation.d.ts +23 -9
- package/dist/components/corti-dictation.js +36 -17
- package/dist/components/corti-dictation.js.map +1 -1
- package/dist/components/keybinding-input.d.ts +16 -0
- package/dist/components/keybinding-input.js +94 -0
- package/dist/components/keybinding-input.js.map +1 -0
- package/dist/components/keybinding-selector.d.ts +3 -3
- package/dist/components/keybinding-selector.js +21 -49
- package/dist/components/keybinding-selector.js.map +1 -1
- package/dist/components/recording-button.d.ts +5 -3
- package/dist/components/recording-button.js +100 -45
- package/dist/components/recording-button.js.map +1 -1
- package/dist/components/settings-menu.d.ts +0 -1
- package/dist/components/settings-menu.js +4 -17
- package/dist/components/settings-menu.js.map +1 -1
- package/dist/contexts/dictation-context.d.ts +6 -6
- package/dist/contexts/dictation-context.js +24 -23
- package/dist/contexts/dictation-context.js.map +1 -1
- package/dist/controllers/dictation-controller.d.ts +8 -2
- package/dist/controllers/dictation-controller.js +151 -45
- package/dist/controllers/dictation-controller.js.map +1 -1
- package/dist/controllers/keybinding-controller.d.ts +2 -3
- package/dist/controllers/keybinding-controller.js +20 -17
- package/dist/controllers/keybinding-controller.js.map +1 -1
- package/dist/controllers/media-controller.d.ts +2 -1
- package/dist/controllers/media-controller.js +14 -3
- package/dist/controllers/media-controller.js.map +1 -1
- package/dist/index.d.ts +2 -3
- package/dist/index.js +0 -5
- package/dist/index.js.map +1 -1
- package/dist/styles/keybinding-selector.js +10 -4
- package/dist/styles/keybinding-selector.js.map +1 -1
- package/dist/styles/settings-menu.js +0 -8
- package/dist/styles/settings-menu.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.d.ts +1 -2
- package/dist/types.js.map +1 -1
- package/dist/utils/events.d.ts +13 -7
- package/dist/utils/events.js +26 -12
- package/dist/utils/events.js.map +1 -1
- package/package.json +2 -4
- package/dist/components/mode-selector.d.ts +0 -14
- package/dist/components/mode-selector.js +0 -73
- package/dist/components/mode-selector.js.map +0 -1
- package/dist/package.json +0 -94
- package/dist/styles/mode-selector.d.ts +0 -2
- package/dist/styles/mode-selector.js +0 -56
- package/dist/styles/mode-selector.js.map +0 -1
|
@@ -15,12 +15,12 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
|
|
|
15
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
16
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
17
17
|
};
|
|
18
|
-
var _DictationRecordingButton_instances, _DictationRecordingButton_mediaController, _DictationRecordingButton_dictationController, _DictationRecordingButton_keybindingController, _DictationRecordingButton_closeConnectionOnInit,
|
|
18
|
+
var _DictationRecordingButton_instances, _DictationRecordingButton_mediaController, _DictationRecordingButton_dictationController, _DictationRecordingButton_keybindingController, _DictationRecordingButton_closeConnectionOnInit, _DictationRecordingButton_processing, _DictationRecordingButton_connection, _DictationRecordingButton_handleClick, _DictationRecordingButton_handleWebSocketMessage, _DictationRecordingButton_handleWebSocketError, _DictationRecordingButton_handleWebSocketClose, _DictationRecordingButton_dispatchRecordingStateChanged, _DictationRecordingButton_handleStart, _DictationRecordingButton_handleStop;
|
|
19
19
|
import { consume } from "@lit/context";
|
|
20
20
|
import { html, LitElement, } from "lit";
|
|
21
21
|
import { customElement, property, state } from "lit/decorators.js";
|
|
22
22
|
import { AUDIO_CHUNK_INTERVAL_MS } from "../constants.js";
|
|
23
|
-
import { accessTokenContext, authConfigContext, debugDisplayAudioContext, dictationConfigContext,
|
|
23
|
+
import { accessTokenContext, authConfigContext, debugDisplayAudioContext, dictationConfigContext, pushToTalkKeybindingContext, recordingStateContext, regionContext, selectedDeviceContext, socketProxyContext, socketUrlContext, tenantNameContext, toggleToTalkKeybindingContext, } from "../contexts/dictation-context.js";
|
|
24
24
|
import { DictationController, } from "../controllers/dictation-controller.js";
|
|
25
25
|
import { KeybindingController } from "../controllers/keybinding-controller.js";
|
|
26
26
|
import { MediaController } from "../controllers/media-controller.js";
|
|
@@ -39,15 +39,10 @@ let DictationRecordingButton = class DictationRecordingButton extends LitElement
|
|
|
39
39
|
_DictationRecordingButton_dictationController.set(this, new DictationController(this));
|
|
40
40
|
_DictationRecordingButton_keybindingController.set(this, new KeybindingController(this));
|
|
41
41
|
_DictationRecordingButton_closeConnectionOnInit.set(this, false);
|
|
42
|
+
_DictationRecordingButton_processing.set(this, false);
|
|
43
|
+
_DictationRecordingButton_connection.set(this, "CLOSED");
|
|
42
44
|
_DictationRecordingButton_handleWebSocketMessage.set(this, (message) => {
|
|
43
45
|
switch (message.type) {
|
|
44
|
-
case "CONFIG_ACCEPTED":
|
|
45
|
-
__classPrivateFieldGet(this, _DictationRecordingButton_mediaController, "f").mediaRecorder?.start(AUDIO_CHUNK_INTERVAL_MS);
|
|
46
|
-
__classPrivateFieldGet(this, _DictationRecordingButton_mediaController, "f").startAudioLevelMonitoring((level) => {
|
|
47
|
-
this.dispatchEvent(audioLevelChangedEvent(level));
|
|
48
|
-
});
|
|
49
|
-
this.dispatchEvent(recordingStateChangedEvent("recording"));
|
|
50
|
-
break;
|
|
51
46
|
case "CONFIG_DENIED":
|
|
52
47
|
this.dispatchEvent(errorEvent(`Config denied: ${message.reason ?? "Unknown reason"}`));
|
|
53
48
|
__classPrivateFieldGet(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_handleStop).call(this);
|
|
@@ -69,14 +64,31 @@ let DictationRecordingButton = class DictationRecordingButton extends LitElement
|
|
|
69
64
|
this.dispatchEvent(errorEvent(message.error));
|
|
70
65
|
__classPrivateFieldGet(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_handleStop).call(this);
|
|
71
66
|
break;
|
|
67
|
+
case "flushed":
|
|
68
|
+
if (this._recordingState === "stopped" ||
|
|
69
|
+
this._recordingState === "stopping") {
|
|
70
|
+
__classPrivateFieldSet(this, _DictationRecordingButton_processing, false, "f");
|
|
71
|
+
__classPrivateFieldGet(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_dispatchRecordingStateChanged).call(this, this._recordingState);
|
|
72
|
+
}
|
|
73
|
+
break;
|
|
72
74
|
}
|
|
73
75
|
});
|
|
74
76
|
_DictationRecordingButton_handleWebSocketError.set(this, (error) => {
|
|
75
77
|
this.dispatchEvent(errorEvent("Socket error: " + error.message));
|
|
78
|
+
__classPrivateFieldSet(this, _DictationRecordingButton_processing, false, "f");
|
|
79
|
+
__classPrivateFieldSet(this, _DictationRecordingButton_connection, "CLOSED", "f");
|
|
76
80
|
__classPrivateFieldGet(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_handleStop).call(this);
|
|
77
81
|
});
|
|
78
82
|
_DictationRecordingButton_handleWebSocketClose.set(this, (event) => {
|
|
83
|
+
// When we already have new socket opened
|
|
84
|
+
if (__classPrivateFieldGet(this, _DictationRecordingButton_dictationController, "f").isConnectionOpen() ||
|
|
85
|
+
__classPrivateFieldGet(this, _DictationRecordingButton_dictationController, "f").isConnecting()) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
__classPrivateFieldSet(this, _DictationRecordingButton_processing, false, "f");
|
|
89
|
+
__classPrivateFieldSet(this, _DictationRecordingButton_connection, "CLOSED", "f");
|
|
79
90
|
this.dispatchEvent(streamClosedEvent(event));
|
|
91
|
+
__classPrivateFieldGet(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_dispatchRecordingStateChanged).call(this, this._recordingState);
|
|
80
92
|
});
|
|
81
93
|
}
|
|
82
94
|
update(changedProperties) {
|
|
@@ -113,15 +125,60 @@ let DictationRecordingButton = class DictationRecordingButton extends LitElement
|
|
|
113
125
|
this.stopRecording();
|
|
114
126
|
}
|
|
115
127
|
}
|
|
128
|
+
async openConnection() {
|
|
129
|
+
if (this._recordingState !== "stopped" || __classPrivateFieldGet(this, _DictationRecordingButton_processing, "f")) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
if (__classPrivateFieldGet(this, _DictationRecordingButton_dictationController, "f").isConnectionOpen()) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
try {
|
|
136
|
+
__classPrivateFieldSet(this, _DictationRecordingButton_connection, "CONNECTING", "f");
|
|
137
|
+
__classPrivateFieldGet(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_dispatchRecordingStateChanged).call(this, this._recordingState);
|
|
138
|
+
await __classPrivateFieldGet(this, _DictationRecordingButton_dictationController, "f").connect(this._dictationConfig, {
|
|
139
|
+
onClose: __classPrivateFieldGet(this, _DictationRecordingButton_handleWebSocketClose, "f"),
|
|
140
|
+
onError: __classPrivateFieldGet(this, _DictationRecordingButton_handleWebSocketError, "f"),
|
|
141
|
+
onMessage: __classPrivateFieldGet(this, _DictationRecordingButton_handleWebSocketMessage, "f"),
|
|
142
|
+
onNetworkActivity: (direction, data) => {
|
|
143
|
+
this.dispatchEvent(networkActivityEvent(direction, data));
|
|
144
|
+
},
|
|
145
|
+
});
|
|
146
|
+
__classPrivateFieldSet(this, _DictationRecordingButton_connection, "OPEN", "f");
|
|
147
|
+
__classPrivateFieldGet(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_dispatchRecordingStateChanged).call(this, this._recordingState);
|
|
148
|
+
}
|
|
149
|
+
catch (error) {
|
|
150
|
+
__classPrivateFieldSet(this, _DictationRecordingButton_connection, "CLOSED", "f");
|
|
151
|
+
this.dispatchEvent(errorEvent(error));
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
async closeConnection() {
|
|
155
|
+
if (this._recordingState !== "stopped" || __classPrivateFieldGet(this, _DictationRecordingButton_processing, "f")) {
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
if (__classPrivateFieldGet(this, _DictationRecordingButton_dictationController, "f").isConnecting()) {
|
|
159
|
+
await __classPrivateFieldGet(this, _DictationRecordingButton_dictationController, "f").waitForConnection();
|
|
160
|
+
}
|
|
161
|
+
if (!__classPrivateFieldGet(this, _DictationRecordingButton_dictationController, "f").isConnectionOpen()) {
|
|
162
|
+
__classPrivateFieldSet(this, _DictationRecordingButton_connection, "CLOSED", "f");
|
|
163
|
+
__classPrivateFieldGet(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_dispatchRecordingStateChanged).call(this, "stopped");
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
try {
|
|
167
|
+
__classPrivateFieldSet(this, _DictationRecordingButton_connection, "CLOSING", "f");
|
|
168
|
+
__classPrivateFieldGet(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_dispatchRecordingStateChanged).call(this, "stopped");
|
|
169
|
+
await __classPrivateFieldGet(this, _DictationRecordingButton_dictationController, "f").closeConnection(__classPrivateFieldGet(this, _DictationRecordingButton_handleWebSocketClose, "f"));
|
|
170
|
+
}
|
|
171
|
+
catch (error) {
|
|
172
|
+
this.dispatchEvent(errorEvent(error));
|
|
173
|
+
}
|
|
174
|
+
}
|
|
116
175
|
render() {
|
|
117
176
|
const isLoading = this._recordingState === "initializing" ||
|
|
118
177
|
this._recordingState === "stopping";
|
|
119
178
|
const isRecording = this._recordingState === "recording";
|
|
120
179
|
return html `
|
|
121
180
|
<button
|
|
122
|
-
@
|
|
123
|
-
@mouseup=${__classPrivateFieldGet(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_handleMouseUp)}
|
|
124
|
-
@mouseleave=${__classPrivateFieldGet(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_handleMouseLeave)}
|
|
181
|
+
@click=${__classPrivateFieldGet(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_handleClick)}
|
|
125
182
|
?disabled=${isLoading}
|
|
126
183
|
class=${isRecording ? "red" : "accent"}
|
|
127
184
|
aria-label=${isRecording ? "Stop recording" : "Start recording"}
|
|
@@ -144,42 +201,43 @@ _DictationRecordingButton_mediaController = new WeakMap();
|
|
|
144
201
|
_DictationRecordingButton_dictationController = new WeakMap();
|
|
145
202
|
_DictationRecordingButton_keybindingController = new WeakMap();
|
|
146
203
|
_DictationRecordingButton_closeConnectionOnInit = new WeakMap();
|
|
204
|
+
_DictationRecordingButton_processing = new WeakMap();
|
|
205
|
+
_DictationRecordingButton_connection = new WeakMap();
|
|
147
206
|
_DictationRecordingButton_handleWebSocketMessage = new WeakMap();
|
|
148
207
|
_DictationRecordingButton_handleWebSocketError = new WeakMap();
|
|
149
208
|
_DictationRecordingButton_handleWebSocketClose = new WeakMap();
|
|
150
209
|
_DictationRecordingButton_instances = new WeakSet();
|
|
151
|
-
|
|
210
|
+
_DictationRecordingButton_handleClick = function _DictationRecordingButton_handleClick(event) {
|
|
152
211
|
if (!this.allowButtonFocus) {
|
|
153
212
|
event.preventDefault();
|
|
154
213
|
}
|
|
155
|
-
|
|
156
|
-
this.startRecording();
|
|
157
|
-
}
|
|
214
|
+
this.toggleRecording();
|
|
158
215
|
};
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
this
|
|
162
|
-
|
|
163
|
-
}
|
|
164
|
-
if (this._mode === "toggle-to-talk") {
|
|
165
|
-
this.toggleRecording();
|
|
166
|
-
}
|
|
167
|
-
};
|
|
168
|
-
_DictationRecordingButton_handleMouseLeave = function _DictationRecordingButton_handleMouseLeave() {
|
|
169
|
-
if (this._mode === "push-to-talk") {
|
|
170
|
-
this.stopRecording();
|
|
171
|
-
}
|
|
216
|
+
_DictationRecordingButton_dispatchRecordingStateChanged = function _DictationRecordingButton_dispatchRecordingStateChanged(state) {
|
|
217
|
+
this.dispatchEvent(recordingStateChangedEvent(state, {
|
|
218
|
+
connection: __classPrivateFieldGet(this, _DictationRecordingButton_connection, "f"),
|
|
219
|
+
processing: __classPrivateFieldGet(this, _DictationRecordingButton_processing, "f"),
|
|
220
|
+
}));
|
|
172
221
|
};
|
|
173
222
|
_DictationRecordingButton_handleStart = async function _DictationRecordingButton_handleStart() {
|
|
174
|
-
this.
|
|
223
|
+
__classPrivateFieldGet(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_dispatchRecordingStateChanged).call(this, "initializing");
|
|
175
224
|
try {
|
|
176
225
|
await __classPrivateFieldGet(this, _DictationRecordingButton_mediaController, "f").initialize(() => {
|
|
177
226
|
if (this._recordingState === "recording") {
|
|
178
227
|
this.dispatchEvent(errorEvent("Recording device access was lost."));
|
|
179
228
|
__classPrivateFieldGet(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_handleStop).call(this);
|
|
180
229
|
}
|
|
230
|
+
}, __classPrivateFieldGet(this, _DictationRecordingButton_dictationController, "f").mediaRecorderHandler);
|
|
231
|
+
__classPrivateFieldGet(this, _DictationRecordingButton_mediaController, "f").mediaRecorder?.start(AUDIO_CHUNK_INTERVAL_MS);
|
|
232
|
+
__classPrivateFieldGet(this, _DictationRecordingButton_mediaController, "f").startAudioLevelMonitoring((level) => {
|
|
233
|
+
this.dispatchEvent(audioLevelChangedEvent(level));
|
|
181
234
|
});
|
|
182
|
-
|
|
235
|
+
__classPrivateFieldSet(this, _DictationRecordingButton_processing, true, "f");
|
|
236
|
+
if (__classPrivateFieldGet(this, _DictationRecordingButton_connection, "f") !== "OPEN") {
|
|
237
|
+
__classPrivateFieldSet(this, _DictationRecordingButton_connection, "CONNECTING", "f");
|
|
238
|
+
}
|
|
239
|
+
__classPrivateFieldGet(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_dispatchRecordingStateChanged).call(this, "recording");
|
|
240
|
+
const isNewConnection = await __classPrivateFieldGet(this, _DictationRecordingButton_dictationController, "f").connect(this._dictationConfig, {
|
|
183
241
|
onClose: __classPrivateFieldGet(this, _DictationRecordingButton_handleWebSocketClose, "f"),
|
|
184
242
|
onError: __classPrivateFieldGet(this, _DictationRecordingButton_handleWebSocketError, "f"),
|
|
185
243
|
onMessage: __classPrivateFieldGet(this, _DictationRecordingButton_handleWebSocketMessage, "f"),
|
|
@@ -187,14 +245,11 @@ _DictationRecordingButton_handleStart = async function _DictationRecordingButton
|
|
|
187
245
|
this.dispatchEvent(networkActivityEvent(direction, data));
|
|
188
246
|
},
|
|
189
247
|
});
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
__classPrivateFieldGet(this, _DictationRecordingButton_mediaController, "f").mediaRecorder?.start(AUDIO_CHUNK_INTERVAL_MS);
|
|
193
|
-
__classPrivateFieldGet(this, _DictationRecordingButton_mediaController, "f").startAudioLevelMonitoring((level) => {
|
|
194
|
-
this.dispatchEvent(audioLevelChangedEvent(level));
|
|
195
|
-
});
|
|
196
|
-
this.dispatchEvent(recordingStateChangedEvent("recording"));
|
|
248
|
+
if (isNewConnection === "superseded") {
|
|
249
|
+
return;
|
|
197
250
|
}
|
|
251
|
+
__classPrivateFieldSet(this, _DictationRecordingButton_connection, "OPEN", "f");
|
|
252
|
+
__classPrivateFieldGet(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_dispatchRecordingStateChanged).call(this, this._recordingState);
|
|
198
253
|
}
|
|
199
254
|
catch (error) {
|
|
200
255
|
this.dispatchEvent(errorEvent(error));
|
|
@@ -202,17 +257,17 @@ _DictationRecordingButton_handleStart = async function _DictationRecordingButton
|
|
|
202
257
|
}
|
|
203
258
|
};
|
|
204
259
|
_DictationRecordingButton_handleStop = async function _DictationRecordingButton_handleStop() {
|
|
205
|
-
this.
|
|
260
|
+
__classPrivateFieldGet(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_dispatchRecordingStateChanged).call(this, "stopping");
|
|
206
261
|
try {
|
|
207
262
|
__classPrivateFieldGet(this, _DictationRecordingButton_mediaController, "f").stopAudioLevelMonitoring();
|
|
208
263
|
await __classPrivateFieldGet(this, _DictationRecordingButton_mediaController, "f").stopRecording();
|
|
209
|
-
|
|
264
|
+
__classPrivateFieldGet(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_dispatchRecordingStateChanged).call(this, "stopped");
|
|
265
|
+
await __classPrivateFieldGet(this, _DictationRecordingButton_dictationController, "f").pause();
|
|
210
266
|
await __classPrivateFieldGet(this, _DictationRecordingButton_mediaController, "f").cleanup();
|
|
211
267
|
}
|
|
212
268
|
catch (error) {
|
|
213
269
|
this.dispatchEvent(errorEvent(error));
|
|
214
270
|
}
|
|
215
|
-
this.dispatchEvent(recordingStateChangedEvent("stopped"));
|
|
216
271
|
};
|
|
217
272
|
DictationRecordingButton.styles = [RecordingButtonStyles, ButtonStyles];
|
|
218
273
|
__decorate([
|
|
@@ -256,13 +311,13 @@ __decorate([
|
|
|
256
311
|
state()
|
|
257
312
|
], DictationRecordingButton.prototype, "_debug_displayAudio", void 0);
|
|
258
313
|
__decorate([
|
|
259
|
-
consume({ context:
|
|
314
|
+
consume({ context: pushToTalkKeybindingContext, subscribe: true }),
|
|
260
315
|
state()
|
|
261
|
-
], DictationRecordingButton.prototype, "
|
|
316
|
+
], DictationRecordingButton.prototype, "_pushToTalkKeybinding", void 0);
|
|
262
317
|
__decorate([
|
|
263
|
-
consume({ context:
|
|
318
|
+
consume({ context: toggleToTalkKeybindingContext, subscribe: true }),
|
|
264
319
|
state()
|
|
265
|
-
], DictationRecordingButton.prototype, "
|
|
320
|
+
], DictationRecordingButton.prototype, "_toggleToTalkKeybinding", void 0);
|
|
266
321
|
__decorate([
|
|
267
322
|
property({ type: Boolean })
|
|
268
323
|
], DictationRecordingButton.prototype, "allowButtonFocus", void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recording-button.js","sourceRoot":"","sources":["../../src/components/recording-button.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AACA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAEL,IAAI,EACJ,UAAU,GAEX,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAC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OAAO,CAAC,EAAE,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IACxD,KAAK,EAAE;6DACa;AAIrB;IAFC,OAAO,CAAC,EAAE,OAAO,EAAE,sBAAsB,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IAC7D,KAAK,EAAE;kEACkC;AAI1C;IAFC,OAAO,CAAC,EAAE,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IACvD,KAAK,EAAE;4DACY;AAIpB;IAFC,OAAO,CAAC,EAAE,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IACzD,KAAK,EAAE;8DACoB;AAI5B;IAFC,OAAO,CAAC,EAAE,OAAO,EAAE,wBAAwB,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IAC/D,KAAK,EAAE;qEACsB;AAI9B;IAFC,OAAO,CAAC,EAAE,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IACxD,KAAK,EAAE;6DACoB;AAI5B;IAFC,OAAO,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IAClD,KAAK,EAAE;uDACc;AAGtB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;kEACM;AAlDvB,wBAAwB;IADpC,aAAa,CAAC,4BAA4B,CAAC;GAC/B,wBAAwB,CAmQpC","sourcesContent":["import type { Corti } from \"@corti/sdk\";\nimport { consume } from \"@lit/context\";\nimport {\n type CSSResultGroup,\n html,\n LitElement,\n type PropertyValues,\n} from \"lit\";\nimport { customElement, property, state } from \"lit/decorators.js\";\nimport { AUDIO_CHUNK_INTERVAL_MS } from \"../constants.js\";\nimport {\n accessTokenContext,\n authConfigContext,\n debugDisplayAudioContext,\n dictationConfigContext,\n keybindingContext,\n modeContext,\n recordingStateContext,\n regionContext,\n selectedDeviceContext,\n socketProxyContext,\n socketUrlContext,\n tenantNameContext,\n} from \"../contexts/dictation-context.js\";\nimport {\n DictationController,\n type TranscribeMessage,\n} from \"../controllers/dictation-controller.js\";\nimport { KeybindingController } from \"../controllers/keybinding-controller.js\";\nimport { MediaController } from \"../controllers/media-controller.js\";\nimport ButtonStyles from \"../styles/buttons.js\";\nimport RecordingButtonStyles from \"../styles/recording-button.js\";\nimport type { DictationMode, ProxyOptions, RecordingState } from \"../types.js\";\nimport {\n audioLevelChangedEvent,\n commandEvent,\n errorEvent,\n networkActivityEvent,\n recordingStateChangedEvent,\n streamClosedEvent,\n transcriptEvent,\n usageEvent,\n} from \"../utils/events.js\";\n\nimport \"./audio-visualiser.js\";\nimport \"../icons/icons.js\";\n\n@customElement(\"dictation-recording-button\")\nexport class DictationRecordingButton extends LitElement {\n @consume({ context: recordingStateContext, subscribe: true })\n @state()\n _recordingState: RecordingState = \"stopped\";\n\n @consume({ context: selectedDeviceContext, subscribe: true })\n @state()\n _selectedDevice?: MediaDeviceInfo;\n\n @consume({ context: accessTokenContext, subscribe: true })\n @state()\n _accessToken?: string;\n\n @consume({ context: authConfigContext, subscribe: true })\n @state()\n _authConfig?: Corti.BearerOptions;\n\n @consume({ context: regionContext, subscribe: true })\n @state()\n _region?: string;\n\n @consume({ context: tenantNameContext, subscribe: true })\n @state()\n _tenantName?: string;\n\n @consume({ context: dictationConfigContext, subscribe: true })\n @state()\n _dictationConfig?: Corti.TranscribeConfig;\n\n @consume({ context: socketUrlContext, subscribe: true })\n @state()\n _socketUrl?: string;\n\n @consume({ context: socketProxyContext, subscribe: true })\n @state()\n _socketProxy?: ProxyOptions;\n\n @consume({ context: debugDisplayAudioContext, subscribe: true })\n @state()\n _debug_displayAudio?: boolean;\n\n @consume({ context: keybindingContext, subscribe: true })\n @state()\n _keybinding?: string | null;\n\n @consume({ context: modeContext, subscribe: true })\n @state()\n _mode?: DictationMode;\n\n @property({ type: Boolean })\n allowButtonFocus: boolean = false;\n\n #mediaController = new MediaController(this);\n #dictationController = new DictationController(this);\n #keybindingController = new KeybindingController(this);\n #closeConnectionOnInit = false;\n\n static styles: CSSResultGroup = [RecordingButtonStyles, ButtonStyles];\n\n protected update(changedProperties: PropertyValues) {\n if (\n changedProperties.has(\"_recordingState\") &&\n this._recordingState === \"recording\" &&\n this.#closeConnectionOnInit\n ) {\n this.#closeConnectionOnInit = false;\n this.#handleStop();\n }\n\n super.update(changedProperties);\n }\n\n #handleMouseDown(event: MouseEvent): void {\n if (!this.allowButtonFocus) {\n event.preventDefault();\n }\n\n if (this._mode === \"push-to-talk\") {\n this.startRecording();\n }\n }\n\n #handleMouseUp(): void {\n if (this._mode === \"push-to-talk\") {\n this.stopRecording();\n return;\n }\n\n if (this._mode === \"toggle-to-talk\") {\n this.toggleRecording();\n }\n }\n\n #handleMouseLeave(): void {\n if (this._mode === \"push-to-talk\") {\n this.stopRecording();\n }\n }\n\n #handleWebSocketMessage = (message: TranscribeMessage): void => {\n switch (message.type) {\n case \"CONFIG_ACCEPTED\":\n this.#mediaController.mediaRecorder?.start(AUDIO_CHUNK_INTERVAL_MS);\n this.#mediaController.startAudioLevelMonitoring((level) => {\n this.dispatchEvent(audioLevelChangedEvent(level));\n });\n this.dispatchEvent(recordingStateChangedEvent(\"recording\"));\n break;\n case \"CONFIG_DENIED\":\n this.dispatchEvent(\n errorEvent(`Config denied: ${message.reason ?? \"Unknown reason\"}`),\n );\n this.#handleStop();\n break;\n case \"CONFIG_TIMEOUT\":\n this.dispatchEvent(errorEvent(\"Config timeout\"));\n this.#handleStop();\n break;\n case \"transcript\":\n this.dispatchEvent(transcriptEvent(message));\n break;\n case \"command\":\n this.dispatchEvent(commandEvent(message));\n break;\n case \"usage\":\n this.dispatchEvent(usageEvent(message));\n break;\n case \"error\":\n this.dispatchEvent(errorEvent(message.error));\n this.#handleStop();\n break;\n }\n };\n\n #handleWebSocketError = (error: Error): void => {\n this.dispatchEvent(errorEvent(\"Socket error: \" + error.message));\n this.#handleStop();\n };\n\n #handleWebSocketClose = (event: unknown): void => {\n this.dispatchEvent(streamClosedEvent(event));\n };\n\n async #handleStart(): Promise<void> {\n this.dispatchEvent(recordingStateChangedEvent(\"initializing\"));\n\n try {\n await this.#mediaController.initialize(() => {\n if (this._recordingState === \"recording\") {\n this.dispatchEvent(errorEvent(\"Recording device access was lost.\"));\n this.#handleStop();\n }\n });\n\n const isNewConnection = await this.#dictationController.connect(\n this.#mediaController.mediaRecorder,\n this._dictationConfig,\n {\n onClose: this.#handleWebSocketClose,\n onError: this.#handleWebSocketError,\n onMessage: this.#handleWebSocketMessage,\n onNetworkActivity: (direction, data) => {\n this.dispatchEvent(networkActivityEvent(direction, data));\n },\n },\n );\n\n // configuration has been accepted before\n if (!isNewConnection) {\n this.#mediaController.mediaRecorder?.start(AUDIO_CHUNK_INTERVAL_MS);\n this.#mediaController.startAudioLevelMonitoring((level) => {\n this.dispatchEvent(audioLevelChangedEvent(level));\n });\n this.dispatchEvent(recordingStateChangedEvent(\"recording\"));\n }\n } catch (error) {\n this.dispatchEvent(errorEvent(error));\n await this.#handleStop();\n }\n }\n\n async #handleStop(): Promise<void> {\n this.dispatchEvent(recordingStateChangedEvent(\"stopping\"));\n\n try {\n this.#mediaController.stopAudioLevelMonitoring();\n await this.#mediaController.stopRecording();\n\n await this.#dictationController.disconnect(this.#handleWebSocketClose);\n await this.#mediaController.cleanup();\n } catch (error) {\n this.dispatchEvent(errorEvent(error));\n }\n\n this.dispatchEvent(recordingStateChangedEvent(\"stopped\"));\n }\n\n public startRecording(): void {\n if (this._recordingState !== \"stopped\") {\n return;\n }\n\n this.#handleStart();\n }\n\n public stopRecording(): void {\n if (\n this._recordingState === \"stopped\" ||\n this._recordingState === \"stopping\"\n ) {\n return;\n }\n\n if (this._recordingState === \"initializing\") {\n this.#closeConnectionOnInit = true;\n return;\n }\n\n this.#handleStop();\n }\n\n public toggleRecording(): void {\n if (this._recordingState === \"stopped\") {\n this.startRecording();\n } else if (this._recordingState === \"recording\") {\n this.stopRecording();\n }\n }\n\n render() {\n const isLoading =\n this._recordingState === \"initializing\" ||\n this._recordingState === \"stopping\";\n const isRecording = this._recordingState === \"recording\";\n\n return html`\n <button\n @mousedown=${this.#handleMouseDown}\n @mouseup=${this.#handleMouseUp}\n @mouseleave=${this.#handleMouseLeave}\n ?disabled=${isLoading}\n class=${isRecording ? \"red\" : \"accent\"}\n aria-label=${isRecording ? \"Stop recording\" : \"Start recording\"}\n aria-pressed=${isRecording}\n >\n ${\n isLoading\n ? html`<icon-loading-spinner />`\n : isRecording\n ? html`<icon-recording />`\n : html`<icon-mic-on />`\n }\n <dictation-audio-visualiser\n .level=${this.#mediaController.audioLevel}\n ?active=${isRecording}\n />\n </button>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"dictation-recording-button\": DictationRecordingButton;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"recording-button.js","sourceRoot":"","sources":["../../src/components/recording-button.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AACA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAEL,IAAI,EACJ,UAAU,GAEX,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,wBAAwB,EACxB,sBAAsB,EACtB,2BAA2B,EAC3B,qBAAqB,EACrB,aAAa,EACb,qBAAqB,EACrB,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,6BAA6B,GAC9B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACL,mBAAmB,GAEpB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,yCAAyC,CAAC;AAC/E,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,YA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AAE,CAAC;IAClE,KAAK,EAAE;uEAC8B;AAItC;IAFC,OAAO,CAAC,EAAE,OAAO,EAAE,6BAA6B,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IACpE,KAAK,EAAE;yEACgC;AAGxC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;kEACM;AAlDvB,wBAAwB;IADpC,aAAa,CAAC,4BAA4B,CAAC;GAC/B,wBAAwB,CA0UpC","sourcesContent":["import type { Corti } from \"@corti/sdk\";\nimport { consume } from \"@lit/context\";\nimport {\n type CSSResultGroup,\n html,\n LitElement,\n type PropertyValues,\n} from \"lit\";\nimport { customElement, property, state } from \"lit/decorators.js\";\nimport { AUDIO_CHUNK_INTERVAL_MS } from \"../constants.js\";\nimport {\n accessTokenContext,\n authConfigContext,\n debugDisplayAudioContext,\n dictationConfigContext,\n pushToTalkKeybindingContext,\n recordingStateContext,\n regionContext,\n selectedDeviceContext,\n socketProxyContext,\n socketUrlContext,\n tenantNameContext,\n toggleToTalkKeybindingContext,\n} from \"../contexts/dictation-context.js\";\nimport {\n DictationController,\n type TranscribeMessage,\n} from \"../controllers/dictation-controller.js\";\nimport { KeybindingController } from \"../controllers/keybinding-controller.js\";\nimport { MediaController } from \"../controllers/media-controller.js\";\nimport ButtonStyles from \"../styles/buttons.js\";\nimport RecordingButtonStyles from \"../styles/recording-button.js\";\nimport type { ProxyOptions, RecordingState } from \"../types.js\";\nimport {\n audioLevelChangedEvent,\n commandEvent,\n errorEvent,\n networkActivityEvent,\n type RecordingStateChangedEventDetail,\n recordingStateChangedEvent,\n streamClosedEvent,\n transcriptEvent,\n usageEvent,\n} from \"../utils/events.js\";\n\nimport \"./audio-visualiser.js\";\nimport \"../icons/icons.js\";\n\n@customElement(\"dictation-recording-button\")\nexport class DictationRecordingButton extends LitElement {\n @consume({ context: recordingStateContext, subscribe: true })\n @state()\n _recordingState: RecordingState = \"stopped\";\n\n @consume({ context: selectedDeviceContext, subscribe: true })\n @state()\n _selectedDevice?: MediaDeviceInfo;\n\n @consume({ context: accessTokenContext, subscribe: true })\n @state()\n _accessToken?: string;\n\n @consume({ context: authConfigContext, subscribe: true })\n @state()\n _authConfig?: Corti.BearerOptions;\n\n @consume({ context: regionContext, subscribe: true })\n @state()\n _region?: string;\n\n @consume({ context: tenantNameContext, subscribe: true })\n @state()\n _tenantName?: string;\n\n @consume({ context: dictationConfigContext, subscribe: true })\n @state()\n _dictationConfig?: Corti.TranscribeConfig;\n\n @consume({ context: socketUrlContext, subscribe: true })\n @state()\n _socketUrl?: string;\n\n @consume({ context: socketProxyContext, subscribe: true })\n @state()\n _socketProxy?: ProxyOptions;\n\n @consume({ context: debugDisplayAudioContext, subscribe: true })\n @state()\n _debug_displayAudio?: boolean;\n\n @consume({ context: pushToTalkKeybindingContext, subscribe: true })\n @state()\n _pushToTalkKeybinding?: string | null;\n\n @consume({ context: toggleToTalkKeybindingContext, subscribe: true })\n @state()\n _toggleToTalkKeybinding?: string | null;\n\n @property({ type: Boolean })\n allowButtonFocus: boolean = false;\n\n #mediaController = new MediaController(this);\n #dictationController = new DictationController(this);\n #keybindingController = new KeybindingController(this);\n #closeConnectionOnInit = false;\n #processing = false;\n #connection: RecordingStateChangedEventDetail[\"connection\"] = \"CLOSED\";\n\n static styles: CSSResultGroup = [RecordingButtonStyles, ButtonStyles];\n\n protected update(changedProperties: PropertyValues) {\n if (\n changedProperties.has(\"_recordingState\") &&\n this._recordingState === \"recording\" &&\n this.#closeConnectionOnInit\n ) {\n this.#closeConnectionOnInit = false;\n this.#handleStop();\n }\n\n super.update(changedProperties);\n }\n\n #handleClick(event: MouseEvent): void {\n if (!this.allowButtonFocus) {\n event.preventDefault();\n }\n\n this.toggleRecording();\n }\n\n #handleWebSocketMessage = (message: TranscribeMessage): void => {\n switch (message.type) {\n case \"CONFIG_DENIED\":\n this.dispatchEvent(\n errorEvent(`Config denied: ${message.reason ?? \"Unknown reason\"}`),\n );\n this.#handleStop();\n break;\n case \"CONFIG_TIMEOUT\":\n this.dispatchEvent(errorEvent(\"Config timeout\"));\n this.#handleStop();\n break;\n case \"transcript\":\n this.dispatchEvent(transcriptEvent(message));\n break;\n case \"command\":\n this.dispatchEvent(commandEvent(message));\n break;\n case \"usage\":\n this.dispatchEvent(usageEvent(message));\n break;\n case \"error\":\n this.dispatchEvent(errorEvent(message.error));\n this.#handleStop();\n break;\n case \"flushed\":\n if (\n this._recordingState === \"stopped\" ||\n this._recordingState === \"stopping\"\n ) {\n this.#processing = false;\n this.#dispatchRecordingStateChanged(this._recordingState);\n }\n break;\n }\n };\n\n #handleWebSocketError = (error: Error): void => {\n this.dispatchEvent(errorEvent(\"Socket error: \" + error.message));\n this.#processing = false;\n this.#connection = \"CLOSED\";\n this.#handleStop();\n };\n\n #handleWebSocketClose = (event: unknown): void => {\n // When we already have new socket opened\n if (\n this.#dictationController.isConnectionOpen() ||\n this.#dictationController.isConnecting()\n ) {\n return;\n }\n\n this.#processing = false;\n this.#connection = \"CLOSED\";\n this.dispatchEvent(streamClosedEvent(event));\n this.#dispatchRecordingStateChanged(this._recordingState);\n };\n\n #dispatchRecordingStateChanged(state: RecordingState): void {\n this.dispatchEvent(\n recordingStateChangedEvent(state, {\n connection: this.#connection,\n processing: this.#processing,\n }),\n );\n }\n\n async #handleStart(): Promise<void> {\n this.#dispatchRecordingStateChanged(\"initializing\");\n\n try {\n await this.#mediaController.initialize(() => {\n if (this._recordingState === \"recording\") {\n this.dispatchEvent(errorEvent(\"Recording device access was lost.\"));\n this.#handleStop();\n }\n }, this.#dictationController.mediaRecorderHandler);\n this.#mediaController.mediaRecorder?.start(AUDIO_CHUNK_INTERVAL_MS);\n this.#mediaController.startAudioLevelMonitoring((level) => {\n this.dispatchEvent(audioLevelChangedEvent(level));\n });\n\n this.#processing = true;\n\n if (this.#connection !== \"OPEN\") {\n this.#connection = \"CONNECTING\";\n }\n\n this.#dispatchRecordingStateChanged(\"recording\");\n\n const isNewConnection = await this.#dictationController.connect(\n this._dictationConfig,\n {\n onClose: this.#handleWebSocketClose,\n onError: this.#handleWebSocketError,\n onMessage: this.#handleWebSocketMessage,\n onNetworkActivity: (direction, data) => {\n this.dispatchEvent(networkActivityEvent(direction, data));\n },\n },\n );\n\n if (isNewConnection === \"superseded\") {\n return;\n }\n\n this.#connection = \"OPEN\";\n\n this.#dispatchRecordingStateChanged(this._recordingState);\n } catch (error) {\n this.dispatchEvent(errorEvent(error));\n await this.#handleStop();\n }\n }\n\n async #handleStop(): Promise<void> {\n this.#dispatchRecordingStateChanged(\"stopping\");\n\n try {\n this.#mediaController.stopAudioLevelMonitoring();\n await this.#mediaController.stopRecording();\n\n this.#dispatchRecordingStateChanged(\"stopped\");\n\n await this.#dictationController.pause();\n await this.#mediaController.cleanup();\n } catch (error) {\n this.dispatchEvent(errorEvent(error));\n }\n }\n\n public startRecording(): void {\n if (this._recordingState !== \"stopped\") {\n return;\n }\n\n this.#handleStart();\n }\n\n public stopRecording(): void {\n if (\n this._recordingState === \"stopped\" ||\n this._recordingState === \"stopping\"\n ) {\n return;\n }\n\n if (this._recordingState === \"initializing\") {\n this.#closeConnectionOnInit = true;\n return;\n }\n\n this.#handleStop();\n }\n\n public toggleRecording(): void {\n if (this._recordingState === \"stopped\") {\n this.startRecording();\n } else if (this._recordingState === \"recording\") {\n this.stopRecording();\n }\n }\n\n public async openConnection(): Promise<void> {\n if (this._recordingState !== \"stopped\" || this.#processing) {\n return;\n }\n\n if (this.#dictationController.isConnectionOpen()) {\n return;\n }\n\n try {\n this.#connection = \"CONNECTING\";\n this.#dispatchRecordingStateChanged(this._recordingState);\n\n await this.#dictationController.connect(this._dictationConfig, {\n onClose: this.#handleWebSocketClose,\n onError: this.#handleWebSocketError,\n onMessage: this.#handleWebSocketMessage,\n onNetworkActivity: (direction, data) => {\n this.dispatchEvent(networkActivityEvent(direction, data));\n },\n });\n\n this.#connection = \"OPEN\";\n this.#dispatchRecordingStateChanged(this._recordingState);\n } catch (error) {\n this.#connection = \"CLOSED\";\n this.dispatchEvent(errorEvent(error));\n }\n }\n\n public async closeConnection(): Promise<void> {\n if (this._recordingState !== \"stopped\" || this.#processing) {\n return;\n }\n\n if (this.#dictationController.isConnecting()) {\n await this.#dictationController.waitForConnection();\n }\n\n if (!this.#dictationController.isConnectionOpen()) {\n this.#connection = \"CLOSED\";\n this.#dispatchRecordingStateChanged(\"stopped\");\n return;\n }\n\n try {\n this.#connection = \"CLOSING\";\n this.#dispatchRecordingStateChanged(\"stopped\");\n await this.#dictationController.closeConnection(\n this.#handleWebSocketClose,\n );\n } catch (error) {\n this.dispatchEvent(errorEvent(error));\n }\n }\n\n render() {\n const isLoading =\n this._recordingState === \"initializing\" ||\n this._recordingState === \"stopping\";\n const isRecording = this._recordingState === \"recording\";\n\n return html`\n <button\n @click=${this.#handleClick}\n ?disabled=${isLoading}\n class=${isRecording ? \"red\" : \"accent\"}\n aria-label=${isRecording ? \"Stop recording\" : \"Start recording\"}\n aria-pressed=${isRecording}\n >\n ${\n isLoading\n ? html`<icon-loading-spinner />`\n : isRecording\n ? html`<icon-recording />`\n : html`<icon-mic-on />`\n }\n <dictation-audio-visualiser\n .level=${this.#mediaController.audioLevel}\n ?active=${isRecording}\n />\n </button>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"dictation-recording-button\": DictationRecordingButton;\n }\n}\n"]}
|
|
@@ -3,7 +3,6 @@ import type { ConfigurableSettings, RecordingState } from "../types.js";
|
|
|
3
3
|
import "./device-selector.js";
|
|
4
4
|
import "./keybinding-selector.js";
|
|
5
5
|
import "./language-selector.js";
|
|
6
|
-
import "./mode-selector.js";
|
|
7
6
|
import "../icons/icons.js";
|
|
8
7
|
export declare class DictationSettingsMenu extends LitElement {
|
|
9
8
|
_recordingState: RecordingState;
|
|
@@ -15,7 +15,6 @@ import { commaSeparatedConverter } from "../utils/converters.js";
|
|
|
15
15
|
import "./device-selector.js";
|
|
16
16
|
import "./keybinding-selector.js";
|
|
17
17
|
import "./language-selector.js";
|
|
18
|
-
import "./mode-selector.js";
|
|
19
18
|
import "../icons/icons.js";
|
|
20
19
|
let DictationSettingsMenu = class DictationSettingsMenu extends LitElement {
|
|
21
20
|
constructor() {
|
|
@@ -30,7 +29,6 @@ let DictationSettingsMenu = class DictationSettingsMenu extends LitElement {
|
|
|
30
29
|
const isRecording = this._recordingState === "recording";
|
|
31
30
|
const showDeviceSelector = this.settingsEnabled.includes("device");
|
|
32
31
|
const showLanguageSelector = this.settingsEnabled.includes("language");
|
|
33
|
-
const showModeSelector = this.settingsEnabled.includes("mode");
|
|
34
32
|
const showKeybinding = this.settingsEnabled.includes("keybinding");
|
|
35
33
|
return html `
|
|
36
34
|
<div class="mic-selector">
|
|
@@ -56,21 +54,10 @@ let DictationSettingsMenu = class DictationSettingsMenu extends LitElement {
|
|
|
56
54
|
?disabled=${isRecording}
|
|
57
55
|
/>`
|
|
58
56
|
: nothing}
|
|
59
|
-
${
|
|
60
|
-
? html
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
? html `<dictation-mode-selector
|
|
64
|
-
?disabled=${isRecording}
|
|
65
|
-
/>`
|
|
66
|
-
: nothing}
|
|
67
|
-
${showKeybinding
|
|
68
|
-
? html `<dictation-keybinding-selector
|
|
69
|
-
?disabled=${isRecording}
|
|
70
|
-
/>`
|
|
71
|
-
: nothing}
|
|
72
|
-
</div>
|
|
73
|
-
`
|
|
57
|
+
${showKeybinding
|
|
58
|
+
? html `<dictation-keybinding-selector
|
|
59
|
+
?disabled=${isRecording}
|
|
60
|
+
/>`
|
|
74
61
|
: nothing}
|
|
75
62
|
</div>
|
|
76
63
|
</div>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings-menu.js","sourceRoot":"","sources":["../../src/components/settings-menu.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAuB,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;A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MAAM,KAAK,CAAC,EAAE,CAAC;YACvC,OAAO,OAAO,CAAC;QACjB,CAAC;QAED,MAAM,WAAW,GAAG,IAAI,CAAC,eAAe,KAAK,WAAW,CAAC;QACzD,MAAM,kBAAkB,GAAG,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACnE,MAAM,oBAAoB,GAAG,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;QACvE,MAAM,cAAc,GAAG,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;QAEnE,OAAO,IAAI,CAAA;;;;;;;cAQD,WAAW;YACT,CAAC,CAAC,IAAI,CAAA;;;;iBAIL;YACD,CAAC,CAAC,OACN;cAEE,kBAAkB;YAChB,CAAC,CAAC,IAAI,CAAA;8BACQ,WAAW;mBACtB;YACH,CAAC,CAAC,OACN;cAEE,oBAAoB;YAClB,CAAC,CAAC,IAAI,CAAA;8BACQ,WAAW;mBACtB;YACH,CAAC,CAAC,OACN;cAEE,cAAc;YACZ,CAAC,CAAC,IAAI,CAAA;gCACU,WAAW;qBACtB;YACL,CAAC,CAAC,OACN;;;;KAIP,CAAC;IACJ,CAAC;;AAzDM,4BAAM,GAAmB;IAC9B,kBAAkB;IAClB,YAAY;IACZ,aAAa;CACd,AAJY,CAIX;AAZF;IAFC,OAAO,CAAC,EAAE,OAAO,EAAE,qBAAqB,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IAC5D,KAAK,EAAE;8DACoC;AAM5C;IAJC,QAAQ,CAAC;QACR,SAAS,EAAE,uBAAuB;QAClC,IAAI,EAAE,KAAK;KACZ,CAAC;8DAC+D;AATtD,qBAAqB;IADjC,aAAa,CAAC,yBAAyB,CAAC;GAC5B,qBAAqB,CAqEjC","sourcesContent":["import { consume } from \"@lit/context\";\nimport { type CSSResultGroup, html, LitElement, nothing } from \"lit\";\nimport { customElement, property, state } from \"lit/decorators.js\";\nimport { recordingStateContext } from \"../contexts/dictation-context.js\";\nimport ButtonStyles from \"../styles/buttons.js\";\nimport CalloutStyles from \"../styles/callout.js\";\nimport SettingsMenuStyles from \"../styles/settings-menu.js\";\nimport type { ConfigurableSettings, RecordingState } from \"../types.js\";\nimport { commaSeparatedConverter } from \"../utils/converters.js\";\n\nimport \"./device-selector.js\";\nimport \"./keybinding-selector.js\";\nimport \"./language-selector.js\";\nimport \"../icons/icons.js\";\n\n@customElement(\"dictation-settings-menu\")\nexport class DictationSettingsMenu extends LitElement {\n @consume({ context: recordingStateContext, subscribe: true })\n @state()\n _recordingState: RecordingState = \"stopped\";\n\n @property({\n converter: commaSeparatedConverter,\n type: Array,\n })\n settingsEnabled: ConfigurableSettings[] = [\"device\", \"language\"];\n\n static styles: CSSResultGroup = [\n SettingsMenuStyles,\n ButtonStyles,\n CalloutStyles,\n ];\n\n render() {\n if (this.settingsEnabled?.length === 0) {\n return nothing;\n }\n\n const isRecording = this._recordingState === \"recording\";\n const showDeviceSelector = this.settingsEnabled.includes(\"device\");\n const showLanguageSelector = this.settingsEnabled.includes(\"language\");\n const showKeybinding = this.settingsEnabled.includes(\"keybinding\");\n\n return html`\n <div class=\"mic-selector\">\n <button id=\"settings-popover-button\" popovertarget=\"settings-popover\">\n <icon-settings />\n </button>\n <div id=\"settings-popover\" popover>\n <div class=\"settings-wrapper\">\n ${\n isRecording\n ? html`\n <div class=\"callout warn\">\n Recording is in progress. Stop recording to change settings.\n </div>\n `\n : nothing\n }\n ${\n showDeviceSelector\n ? html`<dictation-device-selector\n ?disabled=${isRecording}\n />`\n : nothing\n }\n ${\n showLanguageSelector\n ? html`<dictation-language-selector\n ?disabled=${isRecording}\n />`\n : nothing\n }\n ${\n showKeybinding\n ? html`<dictation-keybinding-selector\n ?disabled=${isRecording}\n />`\n : nothing\n }\n </div>\n </div>\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"dictation-settings-menu\": DictationSettingsMenu;\n }\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Corti } from "@corti/sdk";
|
|
2
2
|
import { type CSSResultGroup, LitElement } from "lit";
|
|
3
|
-
import type {
|
|
3
|
+
import type { ProxyOptions, RecordingState } from "../types.js";
|
|
4
4
|
export declare const regionContext: {
|
|
5
5
|
__context__: string | undefined;
|
|
6
6
|
};
|
|
@@ -37,10 +37,10 @@ export declare const socketProxyContext: {
|
|
|
37
37
|
export declare const debugDisplayAudioContext: {
|
|
38
38
|
__context__: boolean | undefined;
|
|
39
39
|
};
|
|
40
|
-
export declare const
|
|
41
|
-
__context__:
|
|
40
|
+
export declare const pushToTalkKeybindingContext: {
|
|
41
|
+
__context__: string | null | undefined;
|
|
42
42
|
};
|
|
43
|
-
export declare const
|
|
43
|
+
export declare const toggleToTalkKeybindingContext: {
|
|
44
44
|
__context__: string | null | undefined;
|
|
45
45
|
};
|
|
46
46
|
export declare class DictationRoot extends LitElement {
|
|
@@ -65,8 +65,8 @@ export declare class DictationRoot extends LitElement {
|
|
|
65
65
|
get devices(): MediaDeviceInfo[] | undefined;
|
|
66
66
|
selectedDevice?: MediaDeviceInfo;
|
|
67
67
|
debug_displayAudio?: boolean;
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
pushToTalkKeybinding?: string | null;
|
|
69
|
+
toggleToTalkKeybinding?: string | null;
|
|
70
70
|
noWrapper: boolean;
|
|
71
71
|
static styles: CSSResultGroup;
|
|
72
72
|
constructor();
|
|
@@ -9,7 +9,7 @@ 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 _DictationRoot_languagesController, _DictationRoot_devicesController, _DictationRoot_handleLanguageChanged, _DictationRoot_handleDeviceChanged, _DictationRoot_handleRecordingStateChanged, _DictationRoot_handleContextRequest,
|
|
12
|
+
var _DictationRoot_languagesController, _DictationRoot_devicesController, _DictationRoot_handleLanguageChanged, _DictationRoot_handleDeviceChanged, _DictationRoot_handleRecordingStateChanged, _DictationRoot_handleContextRequest, _DictationRoot_handleKeybindingChanged;
|
|
13
13
|
import { createContext, provide } from "@lit/context";
|
|
14
14
|
import { html, LitElement } from "lit";
|
|
15
15
|
import { customElement, property, state } from "lit/decorators.js";
|
|
@@ -19,7 +19,6 @@ import ComponentStyles from "../styles/component-styles.js";
|
|
|
19
19
|
import { getInitialToken } from "../utils/auth.js";
|
|
20
20
|
import { commaSeparatedConverter } from "../utils/converters.js";
|
|
21
21
|
import { errorEvent, keybindingChangedEvent, } from "../utils/events.js";
|
|
22
|
-
import { normalizeKeybinding } from "../utils/keybinding.js";
|
|
23
22
|
import { decodeToken } from "../utils/token.js";
|
|
24
23
|
export const regionContext = createContext(Symbol("region"));
|
|
25
24
|
export const tenantNameContext = createContext(Symbol("tenantName"));
|
|
@@ -33,8 +32,8 @@ export const authConfigContext = createContext(Symbol("authConfig"));
|
|
|
33
32
|
export const socketUrlContext = createContext(Symbol("socketUrl"));
|
|
34
33
|
export const socketProxyContext = createContext(Symbol("socketProxy"));
|
|
35
34
|
export const debugDisplayAudioContext = createContext(Symbol("debugDisplayAudio"));
|
|
36
|
-
export const
|
|
37
|
-
export const
|
|
35
|
+
export const pushToTalkKeybindingContext = createContext(Symbol("pushToTalkKeybinding"));
|
|
36
|
+
export const toggleToTalkKeybindingContext = createContext(Symbol("toggleToTalkKeybinding"));
|
|
38
37
|
let DictationRoot = class DictationRoot extends LitElement {
|
|
39
38
|
set accessToken(token) {
|
|
40
39
|
this.setAccessToken(token);
|
|
@@ -76,7 +75,6 @@ let DictationRoot = class DictationRoot extends LitElement {
|
|
|
76
75
|
this.recordingState = "stopped";
|
|
77
76
|
_DictationRoot_languagesController.set(this, new LanguagesController(this));
|
|
78
77
|
_DictationRoot_devicesController.set(this, new DevicesController(this));
|
|
79
|
-
this.mode = "toggle-to-talk";
|
|
80
78
|
this.noWrapper = false;
|
|
81
79
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
82
80
|
// Private event handlers
|
|
@@ -103,29 +101,33 @@ let DictationRoot = class DictationRoot extends LitElement {
|
|
|
103
101
|
else if (e.context === devicesContext) {
|
|
104
102
|
__classPrivateFieldGet(this, _DictationRoot_devicesController, "f").initialize();
|
|
105
103
|
}
|
|
106
|
-
else if (e.
|
|
107
|
-
e.
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
this.
|
|
111
|
-
|
|
104
|
+
else if (e.contextTarget.tagName.toLowerCase() === "dictation-keybinding-selector") {
|
|
105
|
+
if (e.context === pushToTalkKeybindingContext &&
|
|
106
|
+
this.pushToTalkKeybinding === undefined) {
|
|
107
|
+
this.pushToTalkKeybinding = "Space";
|
|
108
|
+
this.dispatchEvent(keybindingChangedEvent(" ", "Space", "Space", "push-to-talk"));
|
|
109
|
+
}
|
|
110
|
+
if (e.context === toggleToTalkKeybindingContext &&
|
|
111
|
+
this.toggleToTalkKeybinding === undefined) {
|
|
112
|
+
this.toggleToTalkKeybinding = "Enter";
|
|
113
|
+
this.dispatchEvent(keybindingChangedEvent("Enter", "Enter", "Enter", "toggle-to-talk"));
|
|
112
114
|
}
|
|
113
115
|
}
|
|
114
116
|
});
|
|
115
|
-
_DictationRoot_handleModeChanged.set(this, (e) => {
|
|
116
|
-
const event = e;
|
|
117
|
-
this.mode = event.detail.mode;
|
|
118
|
-
});
|
|
119
117
|
_DictationRoot_handleKeybindingChanged.set(this, (e) => {
|
|
120
118
|
const event = e;
|
|
121
|
-
const
|
|
122
|
-
|
|
119
|
+
const keybinding = event.detail.keybinding;
|
|
120
|
+
if (event.detail.type === "push-to-talk") {
|
|
121
|
+
this.pushToTalkKeybinding = keybinding;
|
|
122
|
+
}
|
|
123
|
+
else if (event.detail.type === "toggle-to-talk") {
|
|
124
|
+
this.toggleToTalkKeybinding = keybinding;
|
|
125
|
+
}
|
|
123
126
|
});
|
|
124
127
|
this.addEventListener("languages-changed", __classPrivateFieldGet(this, _DictationRoot_handleLanguageChanged, "f"));
|
|
125
128
|
this.addEventListener("recording-devices-changed", __classPrivateFieldGet(this, _DictationRoot_handleDeviceChanged, "f"));
|
|
126
129
|
this.addEventListener("recording-state-changed", __classPrivateFieldGet(this, _DictationRoot_handleRecordingStateChanged, "f"));
|
|
127
130
|
this.addEventListener("context-request", __classPrivateFieldGet(this, _DictationRoot_handleContextRequest, "f"));
|
|
128
|
-
this.addEventListener("mode-changed", __classPrivateFieldGet(this, _DictationRoot_handleModeChanged, "f"));
|
|
129
131
|
this.addEventListener("keybinding-changed", __classPrivateFieldGet(this, _DictationRoot_handleKeybindingChanged, "f"));
|
|
130
132
|
}
|
|
131
133
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
@@ -203,7 +205,6 @@ _DictationRoot_handleLanguageChanged = new WeakMap();
|
|
|
203
205
|
_DictationRoot_handleDeviceChanged = new WeakMap();
|
|
204
206
|
_DictationRoot_handleRecordingStateChanged = new WeakMap();
|
|
205
207
|
_DictationRoot_handleContextRequest = new WeakMap();
|
|
206
|
-
_DictationRoot_handleModeChanged = new WeakMap();
|
|
207
208
|
_DictationRoot_handleKeybindingChanged = new WeakMap();
|
|
208
209
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
209
210
|
// Static
|
|
@@ -273,13 +274,13 @@ __decorate([
|
|
|
273
274
|
property({ attribute: "debug-display-audio", type: Boolean })
|
|
274
275
|
], DictationRoot.prototype, "debug_displayAudio", void 0);
|
|
275
276
|
__decorate([
|
|
276
|
-
provide({ context:
|
|
277
|
+
provide({ context: pushToTalkKeybindingContext }),
|
|
277
278
|
property({ type: String })
|
|
278
|
-
], DictationRoot.prototype, "
|
|
279
|
+
], DictationRoot.prototype, "pushToTalkKeybinding", void 0);
|
|
279
280
|
__decorate([
|
|
280
|
-
provide({ context:
|
|
281
|
+
provide({ context: toggleToTalkKeybindingContext }),
|
|
281
282
|
property({ type: String })
|
|
282
|
-
], DictationRoot.prototype, "
|
|
283
|
+
], DictationRoot.prototype, "toggleToTalkKeybinding", void 0);
|
|
283
284
|
__decorate([
|
|
284
285
|
property({ type: Boolean })
|
|
285
286
|
], DictationRoot.prototype, "noWrapper", void 0);
|