@speechly/react-client
Advanced tools
Comparing version 0.0.7 to 0.0.8
@@ -88,2 +88,3 @@ import React from 'react'; | ||
toggleIsOn: boolean; | ||
startedContextPromise?: Promise<string>; | ||
segment?: SpeechSegment; | ||
@@ -90,0 +91,0 @@ tentativeTranscript?: TentativeSpeechTranscript; |
@@ -103,3 +103,3 @@ "use strict"; | ||
_this.startContext = function () { return __awaiter(_this, void 0, void 0, function () { | ||
var _a, client, clientState, _b; | ||
var _a, client, clientState, startedContextPromise, _b; | ||
return __generator(this, function (_c) { | ||
@@ -112,17 +112,24 @@ switch (_c.label) { | ||
case browser_client_1.ClientState.Disconnected: return [3 /*break*/, 1]; | ||
case browser_client_1.ClientState.Connected: return [3 /*break*/, 4]; | ||
case browser_client_1.ClientState.Connected: return [3 /*break*/, 3]; | ||
} | ||
return [3 /*break*/, 6]; | ||
return [3 /*break*/, 4]; | ||
case 1: return [4 /*yield*/, client.initialize()]; | ||
case 2: | ||
_c.sent(); | ||
return [4 /*yield*/, client.startContext()]; | ||
startedContextPromise = client.startContext(); | ||
return [3 /*break*/, 5]; | ||
case 3: | ||
_c.sent(); | ||
return [2 /*return*/]; | ||
case 4: return [4 /*yield*/, client.startContext()]; | ||
startedContextPromise = client.startContext(); | ||
return [3 /*break*/, 5]; | ||
case 4: | ||
console.warn('Cannot start context - client is not connected'); | ||
_c.label = 5; | ||
case 5: | ||
this.setState({ startedContextPromise: startedContextPromise }); | ||
if (!(startedContextPromise !== undefined)) return [3 /*break*/, 7]; | ||
return [4 /*yield*/, startedContextPromise]; | ||
case 6: | ||
_c.sent(); | ||
return [2 /*return*/]; | ||
case 6: throw Error('Cannot start context - client is not connected'); | ||
_c.label = 7; | ||
case 7: return [2 /*return*/]; | ||
} | ||
@@ -132,18 +139,18 @@ }); | ||
_this.stopContext = function () { return __awaiter(_this, void 0, void 0, function () { | ||
var _a, client, clientState, _b; | ||
var _a, client, clientState, startedContextPromise, _b; | ||
return __generator(this, function (_c) { | ||
switch (_c.label) { | ||
case 0: | ||
_a = this.state, client = _a.client, clientState = _a.clientState; | ||
_a = this.state, client = _a.client, clientState = _a.clientState, startedContextPromise = _a.startedContextPromise; | ||
if (!(startedContextPromise !== undefined)) return [3 /*break*/, 2]; | ||
return [4 /*yield*/, startedContextPromise]; | ||
case 1: | ||
_c.sent(); | ||
_c.label = 2; | ||
case 2: | ||
_b = clientState; | ||
switch (_b) { | ||
case browser_client_1.ClientState.Starting: return [3 /*break*/, 1]; | ||
case browser_client_1.ClientState.Connected: return [3 /*break*/, 3]; | ||
case browser_client_1.ClientState.Recording: return [3 /*break*/, 5]; | ||
case browser_client_1.ClientState.Recording: return [3 /*break*/, 3]; | ||
} | ||
return [3 /*break*/, 7]; | ||
case 1: return [4 /*yield*/, client.stopContext()]; | ||
case 2: | ||
_c.sent(); | ||
return [2 /*return*/]; | ||
return [3 /*break*/, 5]; | ||
case 3: return [4 /*yield*/, client.stopContext()]; | ||
@@ -153,7 +160,3 @@ case 4: | ||
return [2 /*return*/]; | ||
case 5: return [4 /*yield*/, client.stopContext()]; | ||
case 6: | ||
_c.sent(); | ||
return [2 /*return*/]; | ||
case 7: return [2 /*return*/, Promise.resolve()]; | ||
case 5: return [2 /*return*/, Promise.resolve()]; | ||
} | ||
@@ -267,2 +270,3 @@ }); | ||
toggleIsOn: false, | ||
startedContextPromise: undefined, | ||
}; | ||
@@ -269,0 +273,0 @@ return _this; |
@@ -150,2 +150,3 @@ import { Client } from '@speechly/browser-client'; | ||
toggleIsOn: boolean; | ||
startedContextPromise?: Promise<string>; | ||
segment?: SpeechSegment; | ||
@@ -152,0 +153,0 @@ tentativeTranscript?: TentativeSpeechTranscript; |
{ | ||
"name": "@speechly/react-client", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"description": "React client for Speechly SLU API", | ||
@@ -5,0 +5,0 @@ "private": false, |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
50879
929