@sdata/web-vue 3.22.1 → 3.22.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/sender/use-speech.d.ts +1 -1
- package/es/sender/use-speech.js +28 -21
- package/json/web-types.json +1 -1
- package/package.json +1 -1
|
@@ -12,7 +12,7 @@ interface UseSpeechOptions {
|
|
|
12
12
|
export declare function useSpeech(allowSpeech: MaybeRefOrGetter<SenderAllowSpeech | undefined>, options: UseSpeechOptions): {
|
|
13
13
|
available: import("vue").ComputedRef<boolean>;
|
|
14
14
|
recording: import("vue").ComputedRef<boolean>;
|
|
15
|
-
requesting: import("vue").
|
|
15
|
+
requesting: import("vue").ComputedRef<boolean>;
|
|
16
16
|
statusText: import("vue").ComputedRef<string>;
|
|
17
17
|
trigger: (breakRecording?: boolean) => Promise<void>;
|
|
18
18
|
};
|
package/es/sender/use-speech.js
CHANGED
|
@@ -55,6 +55,7 @@ function useSpeech(allowSpeech, options) {
|
|
|
55
55
|
const supported = shallowRef(false);
|
|
56
56
|
const internalRecording = shallowRef(false);
|
|
57
57
|
const requesting = shallowRef(false);
|
|
58
|
+
const stopping = shallowRef(false);
|
|
58
59
|
const captureError = shallowRef();
|
|
59
60
|
const stream = shallowRef();
|
|
60
61
|
const audioContext = shallowRef();
|
|
@@ -166,25 +167,30 @@ function useSpeech(allowSpeech, options) {
|
|
|
166
167
|
}();
|
|
167
168
|
const stopCapture = function() {
|
|
168
169
|
var _ref3 = _asyncToGenerator(function* (reason = "manual") {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
170
|
+
if (!internalRecording.value || stopping.value) return;
|
|
171
|
+
stopping.value = true;
|
|
172
|
+
try {
|
|
173
|
+
var _socket$value, _config$value$onRecor, _config$value;
|
|
174
|
+
yield flushWorklet();
|
|
175
|
+
const endedAt = performance.now();
|
|
176
|
+
internalRecording.value = false;
|
|
177
|
+
if (((_socket$value = socket.value) === null || _socket$value === void 0 ? void 0 : _socket$value.readyState) === WebSocket.OPEN && typeof config.value === "object" && config.value.sendMetadata !== false) socket.value.send(JSON.stringify({
|
|
178
|
+
type: "end",
|
|
179
|
+
reason
|
|
180
|
+
}));
|
|
181
|
+
yield releaseResources();
|
|
182
|
+
if (typeof config.value === "object") (_config$value$onRecor = (_config$value = config.value).onRecordingChange) === null || _config$value$onRecor === void 0 || _config$value$onRecor.call(_config$value, false);
|
|
183
|
+
options.onEnd({
|
|
184
|
+
source: "capture",
|
|
185
|
+
reason,
|
|
186
|
+
startedAt: startedAt.value,
|
|
187
|
+
endedAt,
|
|
188
|
+
duration: endedAt - startedAt.value,
|
|
189
|
+
chunks: chunks.value
|
|
190
|
+
});
|
|
191
|
+
} finally {
|
|
192
|
+
stopping.value = false;
|
|
193
|
+
}
|
|
188
194
|
});
|
|
189
195
|
return function stopCapture() {
|
|
190
196
|
return _ref3.apply(this, arguments);
|
|
@@ -192,7 +198,7 @@ function useSpeech(allowSpeech, options) {
|
|
|
192
198
|
}();
|
|
193
199
|
const startCapture = function() {
|
|
194
200
|
var _ref4 = _asyncToGenerator(function* () {
|
|
195
|
-
if (requesting.value || internalRecording.value || !available.value) return;
|
|
201
|
+
if (requesting.value || stopping.value || internalRecording.value || !available.value) return;
|
|
196
202
|
requesting.value = true;
|
|
197
203
|
captureError.value = void 0;
|
|
198
204
|
let phase = "permission";
|
|
@@ -300,6 +306,7 @@ function useSpeech(allowSpeech, options) {
|
|
|
300
306
|
}();
|
|
301
307
|
const trigger = function() {
|
|
302
308
|
var _ref5 = _asyncToGenerator(function* (breakRecording = false) {
|
|
309
|
+
if (requesting.value || stopping.value) return;
|
|
303
310
|
if (breakRecording && !recording.value) return;
|
|
304
311
|
if (controlled.value && typeof config.value === "object") {
|
|
305
312
|
var _config$value$onRecor2, _config$value2;
|
|
@@ -349,7 +356,7 @@ function useSpeech(allowSpeech, options) {
|
|
|
349
356
|
return {
|
|
350
357
|
available,
|
|
351
358
|
recording,
|
|
352
|
-
requesting,
|
|
359
|
+
requesting: computed(() => requesting.value || stopping.value),
|
|
353
360
|
statusText,
|
|
354
361
|
trigger
|
|
355
362
|
};
|
package/json/web-types.json
CHANGED