@speechly/react-client
Advanced tools
Comparing version 1.2.0 to 1.2.1
@@ -25,6 +25,15 @@ import React from 'react'; | ||
/** | ||
* Toggles recording on or off. Automatically initialises the API connection and audio stack. | ||
* @deprecated | ||
* Toggles listening on or off. Automatically initialises the API connection and audio stack. | ||
*/ | ||
toggleRecording: ContextFunc; | ||
/** | ||
* Turns listening on. Automatically initialises the API connection and audio stack. | ||
*/ | ||
startContext: ContextFunc; | ||
/** | ||
* Turns listening off. | ||
*/ | ||
stopContext: ContextFunc; | ||
/** | ||
* Switch appId in multi-app project. | ||
@@ -42,2 +51,9 @@ */ | ||
*/ | ||
clientState: ClientState; | ||
/** | ||
* @deprecated | ||
* Current state of the context, whether it's idle, recording or failed, etc. | ||
* It's advised to react to this to enable / disable voice functionality in your app | ||
* as well as inidicate to the user that recording is in progress or results are being fetched from the API. | ||
*/ | ||
speechState: SpeechState; | ||
@@ -44,0 +60,0 @@ /** |
@@ -84,4 +84,11 @@ "use strict"; | ||
}); }); }, | ||
startContext: function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) { | ||
return [2 /*return*/, Promise.resolve()]; | ||
}); }); }, | ||
stopContext: function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) { | ||
return [2 /*return*/, Promise.resolve()]; | ||
}); }); }, | ||
switchApp: function () { }, | ||
speechState: types_1.SpeechState.Idle, | ||
clientState: browser_client_1.ClientState.Disconnected, | ||
}); | ||
@@ -130,2 +137,3 @@ /** | ||
_a = this.state, client = _a.client, clientState = _a.clientState, appId = _a.appId; | ||
this.setState({ toggleIsOn: true }); | ||
_b = clientState; | ||
@@ -136,4 +144,5 @@ switch (_b) { | ||
case browser_client_1.ClientState.Stopping: return [3 /*break*/, 3]; | ||
case browser_client_1.ClientState.Starting: return [3 /*break*/, 4]; | ||
} | ||
return [3 /*break*/, 4]; | ||
return [3 /*break*/, 5]; | ||
case 1: return [4 /*yield*/, (client === null || client === void 0 ? void 0 : client.initialize()) | ||
@@ -152,14 +161,17 @@ // falls through | ||
} | ||
return [3 /*break*/, 5]; | ||
return [3 /*break*/, 6]; | ||
case 4: | ||
console.warn('Already starting'); | ||
return [3 /*break*/, 6]; | ||
case 5: | ||
console.warn('Cannot start context - client is not connected'); | ||
_c.label = 5; | ||
case 5: | ||
return [3 /*break*/, 6]; | ||
case 6: | ||
this.setState({ startedContextPromise: startedContextPromise }); | ||
if (!(startedContextPromise !== undefined)) return [3 /*break*/, 7]; | ||
if (!(startedContextPromise !== undefined)) return [3 /*break*/, 8]; | ||
return [4 /*yield*/, startedContextPromise]; | ||
case 6: | ||
case 7: | ||
_c.sent(); | ||
_c.label = 7; | ||
case 7: return [2 /*return*/]; | ||
_c.label = 8; | ||
case 8: return [2 /*return*/]; | ||
} | ||
@@ -174,2 +186,3 @@ }); | ||
_a = this.state, client = _a.client, startedContextPromise = _a.startedContextPromise; | ||
this.setState({ toggleIsOn: false }); | ||
if (!(startedContextPromise !== undefined)) return [3 /*break*/, 2]; | ||
@@ -191,3 +204,2 @@ return [4 /*yield*/, startedContextPromise]; | ||
toggleIsOn = this.state.toggleIsOn; | ||
this.setState({ toggleIsOn: !toggleIsOn }); | ||
if (!toggleIsOn) { | ||
@@ -311,5 +323,7 @@ return [2 /*return*/, this.startContext()]; | ||
var _this = this; | ||
var _a = this.state, appId = _a.appId, recordingState = _a.recordingState, segment = _a.segment, tentativeTranscript = _a.tentativeTranscript, transcript = _a.transcript, tentativeEntities = _a.tentativeEntities, entity = _a.entity, tentativeIntent = _a.tentativeIntent, intent = _a.intent; | ||
var _a = this.state, appId = _a.appId, clientState = _a.clientState, recordingState = _a.recordingState, segment = _a.segment, tentativeTranscript = _a.tentativeTranscript, transcript = _a.transcript, tentativeEntities = _a.tentativeEntities, entity = _a.entity, tentativeIntent = _a.tentativeIntent, intent = _a.intent; | ||
return (react_1.default.createElement(exports.SpeechContext.Provider, { value: { | ||
initialise: this.initialiseAudio, | ||
startContext: this.startContext, | ||
stopContext: this.stopContext, | ||
toggleRecording: this.toggleRecording, | ||
@@ -320,2 +334,3 @@ switchApp: function (appId) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) { | ||
appId: appId, | ||
clientState: clientState, | ||
speechState: recordingState, | ||
@@ -322,0 +337,0 @@ segment: segment, |
@@ -0,3 +1,4 @@ | ||
export { ClientState } from '@speechly/browser-client'; | ||
export * from './types'; | ||
export * from './context'; | ||
export * from './hooks'; |
@@ -13,2 +13,5 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ClientState = void 0; | ||
var browser_client_1 = require("@speechly/browser-client"); | ||
Object.defineProperty(exports, "ClientState", { enumerable: true, get: function () { return browser_client_1.ClientState; } }); | ||
__exportStar(require("./types"), exports); | ||
@@ -15,0 +18,0 @@ __exportStar(require("./context"), exports); |
{ | ||
"name": "@speechly/react-client", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"description": "React client for Speechly SLU API", | ||
@@ -52,3 +52,3 @@ "keywords": [ | ||
"dependencies": { | ||
"@speechly/browser-client": "1.2.0" | ||
"@speechly/browser-client": "1.3.0" | ||
}, | ||
@@ -55,0 +55,0 @@ "peerDependencies": { |
Sorry, the diff of this file is not supported yet
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
62894
1299
1
+ Added@speechly/browser-client@1.3.0(transitive)
- Removed@speechly/browser-client@1.2.0(transitive)
- Removediso-3166-1-alpha-2@1.0.2(transitive)
- Removediso-639-1@2.1.15(transitive)
- Removediso-639-1-zh@2.0.4(transitive)
- Removedlocale-code@2.0.2(transitive)
- Removedmout@1.2.4(transitive)