@speechly/react-client
Advanced tools
Comparing version 1.1.0 to 1.1.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.1.0", | ||
"version": "1.1.1", | ||
"description": "React client for Speechly SLU API", | ||
@@ -33,3 +33,3 @@ "keywords": [ | ||
"check": "pnpm run build && npx api-extractor run --verbose", | ||
"docs": "pnpm run prepdist && npx typedoc --readme none --includeDeclarations --excludeExternals --excludeNotExported --excludePrivate --excludeProtected --out ./docs/ --plugin typedoc-plugin-markdown ./dist/index.d.ts", | ||
"docs": "pnpx typedoc --readme none --excludeExternals --excludePrivate --excludeProtected --out ./docs/ --entryPointStrategy expand --sort required-first --disableSources ./src/", | ||
"prepdist": "node ./config/prepare_dist.js", | ||
@@ -75,4 +75,4 @@ "precommit": "npx prettier --write src/**/*.ts && pnpm run build && npx api-extractor run --local && pnpm run docs", | ||
"tsc-watch": "^4.2.9", | ||
"typedoc": "^0.19.2", | ||
"typedoc-plugin-markdown": "^3.0.7", | ||
"typedoc": "^0.22.6", | ||
"typedoc-plugin-markdown": "^3.11.3", | ||
"typescript": "^4.3.5" | ||
@@ -79,0 +79,0 @@ }, |
<div align="center" markdown="1"> | ||
<a href="https://www.speechly.com/#gh-light-mode-only"> | ||
<a href="https://www.speechly.com"> | ||
<img src="https://d33wubrfki0l68.cloudfront.net/f15fc952956e1952d6bd23661b7a7ee6b775faaa/c1b30/img/speechly-logo-duo-black.svg" height="48" /> | ||
</a> | ||
<a href="https://www.speechly.com/#gh-dark-mode-only"> | ||
<img src="https://d33wubrfki0l68.cloudfront.net/5622420d87a4aad61e39418e6be5024c56d4cd1d/94452/img/speechly-logo-duo-white.svg" height="48" /> | ||
</a> | ||
@@ -9,0 +6,0 @@ ### The Fast, Accurate, and Simple Voice Interface API |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
47281
770
84