@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.
@@ -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").ShallowRef<boolean, boolean>;
15
+ requesting: import("vue").ComputedRef<boolean>;
16
16
  statusText: import("vue").ComputedRef<string>;
17
17
  trigger: (breakRecording?: boolean) => Promise<void>;
18
18
  };
@@ -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
- var _socket$value, _config$value$onRecor, _config$value;
170
- if (!internalRecording.value) return;
171
- yield flushWorklet();
172
- const endedAt = performance.now();
173
- internalRecording.value = false;
174
- 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({
175
- type: "end",
176
- reason
177
- }));
178
- yield releaseResources();
179
- 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);
180
- options.onEnd({
181
- source: "capture",
182
- reason,
183
- startedAt: startedAt.value,
184
- endedAt,
185
- duration: endedAt - startedAt.value,
186
- chunks: chunks.value
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
  };
@@ -2,7 +2,7 @@
2
2
  "$schema": "https://raw.githubusercontent.com/JetBrains/web-types/master/schema/web-types.json",
3
3
  "framework": "vue",
4
4
  "name": "@sdata/web-vue",
5
- "version": "3.22.0",
5
+ "version": "3.22.1",
6
6
  "contributions": {
7
7
  "html": {
8
8
  "types-syntax": "typescript",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sdata/web-vue",
3
- "version": "3.22.1",
3
+ "version": "3.22.2",
4
4
  "description": "SD Design Vue: A Vue.js 3 UI Library",
5
5
  "keywords": [
6
6
  "sd",