augnitosdk
Advanced tools
Comparing version 0.0.2 to 0.0.3
import { AugnitoConfig } from './config/AugnitoConfig'; | ||
import { AugnitoMobileConfig } from './config/AugnitoMobileConfig'; | ||
import { Recipe } from './recipe/Recipe'; | ||
import { AugnitoSocketResponse } from './support/AugnitoSocketResponse'; | ||
import { AugnitoMobile } from './AugnitoMobile'; | ||
/** | ||
@@ -7,3 +10,3 @@ * Augnito Manager | ||
*/ | ||
declare class Augnito { | ||
export declare class Augnito { | ||
private _logTag; | ||
@@ -13,8 +16,36 @@ /** Web Client */ | ||
/** Mobile Client */ | ||
private _mobileClient; | ||
/** Web Client Configuration */ | ||
private _config; | ||
private _augnitoMobile; | ||
/** Web Worker */ | ||
private _worker; | ||
private _editorHandler; | ||
/** | ||
* @callback Callback partial results | ||
* @description optional callback | ||
*/ | ||
onPartialResult?: (text: string) => void; | ||
/** | ||
* Callback to process Final Results | ||
* @description A final result is called when text has been processed by the Speech Server | ||
*/ | ||
onFinalResult?: (finalText: Partial<Recipe>) => boolean; | ||
/** | ||
* Callback to intercept Commands | ||
*/ | ||
onCommandResult?: (command: Partial<Recipe>) => boolean; | ||
/** | ||
* Callback for status changed | ||
* @description Mandatory field | ||
*/ | ||
onStateChanged?: (isConnected: boolean) => void; | ||
/** | ||
* Callback to intercept Session Events | ||
*/ | ||
onSessionEvent?: (data: AugnitoSocketResponse) => void; | ||
/** | ||
* Iddle Callback: When the Mic is iddle for 5 minutes | ||
* @description Mandatory field | ||
*/ | ||
onIdleMic?: () => void; | ||
constructor(config: AugnitoConfig); | ||
private get enableLogs(); | ||
/** | ||
@@ -43,13 +74,13 @@ * Toggles the Speech API connection | ||
*/ | ||
initMobileClient(config: AugnitoMobileConfig): void; | ||
initMobileClient(config?: AugnitoMobileConfig): AugnitoMobile; | ||
private onPartialResultsCallback; | ||
private onFinalResultsCallback; | ||
private onCommandResultsCallback; | ||
private interfaceCommand; | ||
private onError; | ||
private onPartialResults; | ||
private onIdleMicCallback; | ||
private onStateChangeCallback; | ||
private onSocketFinalResult; | ||
private onCommandResultsCallback; | ||
private onFinalResultsCallback; | ||
private interfaceCommand; | ||
private onEvent; | ||
private onSessionEvent; | ||
private onIdleMic; | ||
private onStateChange; | ||
private onSessionEventCallback; | ||
private createSDKConfig; | ||
@@ -59,2 +90,1 @@ private processResponseData; | ||
} | ||
export { Augnito }; |
@@ -6,6 +6,9 @@ import { WebClient } from './client/WebClient'; | ||
import { AugnitoCommands } from './commands/AugnitoCommands'; | ||
import { buildSDKConfig, buildMobileSDKConfig } from './config/ConfigMapper'; | ||
import { SDKConfig } from './config/SDKConfig'; | ||
import { validateConfig, validateMobileConfig } from './config/ConfigValidator'; | ||
import { AugnitoSDKEvent } from './support/AugnitoSDKEvent'; | ||
import { Logger } from './utils/Logger'; | ||
import { EditorHandler } from './interop/core/EditorHandler'; | ||
import { SDKConfigMobile } from './config/SDKConfigMobile'; | ||
import { AugnitoMobile } from './AugnitoMobile'; | ||
/** | ||
@@ -15,3 +18,3 @@ * Augnito Manager | ||
*/ | ||
class Augnito { | ||
export class Augnito { | ||
constructor(config) { | ||
@@ -32,3 +35,3 @@ Object.defineProperty(this, "_logTag", { | ||
/** Mobile Client */ | ||
Object.defineProperty(this, "_mobileClient", { | ||
Object.defineProperty(this, "_augnitoMobile", { | ||
enumerable: true, | ||
@@ -39,4 +42,4 @@ configurable: true, | ||
}); | ||
/** Web Client Configuration */ | ||
Object.defineProperty(this, "_config", { | ||
/** Web Worker */ | ||
Object.defineProperty(this, "_worker", { | ||
enumerable: true, | ||
@@ -47,4 +50,3 @@ configurable: true, | ||
}); | ||
/** Web Worker */ | ||
Object.defineProperty(this, "_worker", { | ||
Object.defineProperty(this, "_editorHandler", { | ||
enumerable: true, | ||
@@ -55,6 +57,67 @@ configurable: true, | ||
}); | ||
this._config = validateConfig(config); | ||
this._webClient = new WebClient(this.createSDKConfig()); | ||
/** | ||
* @callback Callback partial results | ||
* @description optional callback | ||
*/ | ||
Object.defineProperty(this, "onPartialResult", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
/** | ||
* Callback to process Final Results | ||
* @description A final result is called when text has been processed by the Speech Server | ||
*/ | ||
Object.defineProperty(this, "onFinalResult", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
/** | ||
* Callback to intercept Commands | ||
*/ | ||
Object.defineProperty(this, "onCommandResult", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
/** | ||
* Callback for status changed | ||
* @description Mandatory field | ||
*/ | ||
Object.defineProperty(this, "onStateChanged", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
/** | ||
* Callback to intercept Session Events | ||
*/ | ||
Object.defineProperty(this, "onSessionEvent", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
/** | ||
* Iddle Callback: When the Mic is iddle for 5 minutes | ||
* @description Mandatory field | ||
*/ | ||
Object.defineProperty(this, "onIdleMic", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
this._webClient = new WebClient(this.createSDKConfig(validateConfig(config))); | ||
this._worker = this.createWorker(this.processResponseData); | ||
this._editorHandler = new EditorHandler(config._listOfControls || [], this.enableLogs); | ||
} | ||
get enableLogs() { | ||
return this._webClient ? this._webClient.getConfig().enableLogs : false; | ||
} | ||
// #region Public Methods | ||
@@ -97,2 +160,6 @@ /** | ||
dispose() { | ||
if (this._augnitoMobile) { | ||
this._augnitoMobile.dispose(); | ||
this._augnitoMobile = null; | ||
} | ||
if (this._webClient) { | ||
@@ -106,6 +173,2 @@ this._webClient.dispose(); | ||
} | ||
if (this._mobileClient) { | ||
this._mobileClient.dispose(); | ||
this._mobileClient = null; | ||
} | ||
} | ||
@@ -121,29 +184,75 @@ /** | ||
} | ||
this._mobileClient = new MobileClient(buildMobileSDKConfig(validateMobileConfig(this._webClient, config)), this._webClient); | ||
this._mobileClient.createMobileWebSocket(); | ||
if (this._augnitoMobile) { | ||
throw 'augnito mobile client has already been initialized'; | ||
} | ||
this._augnitoMobile = new AugnitoMobile(new MobileClient(new SDKConfigMobile(validateMobileConfig(this._webClient, config || {}), this._webClient))); | ||
return this._augnitoMobile; | ||
} | ||
// #endregion | ||
// #region client callbacks | ||
onPartialResultsCallback(data) { | ||
if (this.enableLogs) { | ||
Logger.log({ type: 'onPartialResults', data: data }, this._logTag); | ||
} | ||
if (this.onPartialResult) { | ||
this.onPartialResult(data); | ||
} | ||
} | ||
onFinalResultsCallback(recipe) { | ||
if (this.enableLogs) { | ||
Logger.log({ type: 'FinalText', recipe: recipe }, this._logTag); | ||
} | ||
if (this.onFinalResult && this.onFinalResult(recipe)) { | ||
return; | ||
} | ||
this._editorHandler.onFinalResult(recipe); | ||
} | ||
onCommandResultsCallback(command) { | ||
if (this.enableLogs) { | ||
Logger.log({ type: 'Command', command: command }, this._logTag); | ||
} | ||
if (this.interfaceCommand(command)) { | ||
return; | ||
} | ||
if (this.onCommandResult && this.onCommandResult(command)) { | ||
return; | ||
} | ||
this._editorHandler.onCommandResult(command); | ||
} | ||
interfaceCommand(recipe) { | ||
var _a; | ||
// Any UI Command to be process here, before it reaches the editor | ||
if (AugnitoCommands.STOP_MIC === recipe.name) { | ||
(_a = this._webClient) === null || _a === void 0 ? void 0 : _a.stopListening(true); | ||
return true; | ||
} | ||
return false; | ||
} | ||
onError(error, data) { | ||
var _a; | ||
if ((_a = this._config) === null || _a === void 0 ? void 0 : _a.enableLogs) { | ||
if (this.enableLogs) { | ||
Logger.error({ type: 'onError', error: error, data: data }, this._logTag); | ||
} | ||
} | ||
onPartialResults(data) { | ||
var _a, _b; | ||
if ((_a = this._config) === null || _a === void 0 ? void 0 : _a.enableLogs) { | ||
Logger.log({ type: 'onSocketPartialResults', data: data }, this._logTag); | ||
onIdleMicCallback() { | ||
if (this.onIdleMic) { | ||
this.onIdleMic(); | ||
} | ||
if ((_b = this._config) === null || _b === void 0 ? void 0 : _b.onPartialResult) { | ||
this._config.onPartialResult(data); | ||
} | ||
onStateChangeCallback(isConnected) { | ||
if (isConnected) { | ||
this.onPartialResultsCallback(''); | ||
} | ||
if (this.enableLogs) { | ||
Logger.log(`AUGNITO STATUS CHANGED. Connected: ${isConnected}`, this._logTag); | ||
} | ||
if (this.onStateChanged) { | ||
this.onStateChanged(isConnected); | ||
} | ||
} | ||
onSocketFinalResult(data) { | ||
var _a; | ||
if ((_a = this._config) === null || _a === void 0 ? void 0 : _a.enableLogs) { | ||
if (this.enableLogs) { | ||
Logger.log({ type: 'onSocketFinalResult', data: data }, this._logTag); | ||
} | ||
// send empty partial | ||
this.onPartialResults(''); | ||
this.onPartialResultsCallback(''); | ||
// use worker to process final results | ||
@@ -164,37 +273,4 @@ if (this._worker) { | ||
} | ||
onCommandResultsCallback(command) { | ||
var _a, _b; | ||
if ((_a = this._config) === null || _a === void 0 ? void 0 : _a.enableLogs) { | ||
Logger.log({ type: 'Command', command: command }, this._logTag); | ||
} | ||
if (this.interfaceCommand(command)) { | ||
return; | ||
} | ||
if ((_b = this._config) === null || _b === void 0 ? void 0 : _b.onCommandResult) { | ||
this._config.onCommandResult(command); | ||
} | ||
} | ||
onFinalResultsCallback(recipe) { | ||
var _a, _b; | ||
// log output | ||
if ((_a = this._config) === null || _a === void 0 ? void 0 : _a.enableLogs) { | ||
Logger.log({ type: 'FinalText', recipe: recipe }, this._logTag); | ||
} | ||
// callback | ||
if ((_b = this._config) === null || _b === void 0 ? void 0 : _b.onFinalResult) { | ||
this._config.onFinalResult(recipe); | ||
} | ||
} | ||
interfaceCommand(recipe) { | ||
var _a; | ||
// Any UI Command to be process here, before it reaches the editor | ||
if (AugnitoCommands.STOP_MIC === recipe.name) { | ||
(_a = this._webClient) === null || _a === void 0 ? void 0 : _a.stopListening(true); | ||
return true; | ||
} | ||
return false; | ||
} | ||
onEvent(event, data) { | ||
var _a; | ||
if ((_a = this._config) === null || _a === void 0 ? void 0 : _a.enableLogs) { | ||
if (this.enableLogs) { | ||
Logger.log({ type: 'onEvent', event: event, data: data }, this._logTag); | ||
@@ -204,9 +280,9 @@ } | ||
case AugnitoSDKEvent.WS_CONNECTING: | ||
if (this._config.enableLogs) { | ||
if (this.enableLogs) { | ||
Logger.log('WS_CONNECTING', this._logTag); | ||
} | ||
this.onPartialResults(''); | ||
this.onPartialResultsCallback(''); | ||
break; | ||
case AugnitoSDKEvent.MSG_WEB_SOCKET_OPEN: | ||
if (this._config.enableLogs) { | ||
if (this.enableLogs) { | ||
Logger.log('MSG_WEB_SOCKET_OPEN', this._logTag); | ||
@@ -216,6 +292,6 @@ } | ||
case AugnitoSDKEvent.MSG_WEB_SOCKET_CLOSE: | ||
if (this._config.enableLogs) { | ||
if (this.enableLogs) { | ||
Logger.log('MSG_WEB_SOCKET_CLOSE', this._logTag); | ||
} | ||
this.onPartialResults(''); | ||
this.onPartialResultsCallback(''); | ||
break; | ||
@@ -226,9 +302,8 @@ default: | ||
} | ||
onSessionEvent(data) { | ||
var _a, _b, _c, _d, _e; | ||
if ((_a = this._config) === null || _a === void 0 ? void 0 : _a.enableLogs) { | ||
onSessionEventCallback(data) { | ||
if (this.enableLogs) { | ||
Logger.log({ type: 'onSessionEvent', data: data }, this._logTag); | ||
} | ||
if ((_b = this._config) === null || _b === void 0 ? void 0 : _b.onSessionEvent) { | ||
this._config.onSessionEvent(data); | ||
if (this.onSessionEvent) { | ||
this.onSessionEvent(data); | ||
} | ||
@@ -241,3 +316,3 @@ if (typeof data.Event == 'string' && data.Event === 'None') { | ||
if (eventType === 'SESSION_CREATED') { | ||
if ((_c = this._config) === null || _c === void 0 ? void 0 : _c.enableLogs) { | ||
if (this.enableLogs) { | ||
const sessionToken = eventValue; | ||
@@ -257,6 +332,6 @@ Logger.log('session Token ' + sessionToken, this._logTag); | ||
// In this case mic is on and user is not dictating any valid speech for trascription. Server can detect such situations and send an event to confirm from user. | ||
if ((_d = this._config) === null || _d === void 0 ? void 0 : _d.enableLogs) { | ||
if (this.enableLogs) { | ||
Logger.log('NO_DICTATION_STOP_MIC', this._logTag); | ||
} | ||
this.onIdleMic(); | ||
this.onIdleMicCallback(); | ||
} | ||
@@ -273,3 +348,3 @@ else if (eventType === 'INVALID_AUTH_CREDENTIALS') { | ||
// Client app can use this event to show un attendant popup to indicate network status. | ||
if ((_e = this._config) === null || _e === void 0 ? void 0 : _e.enableLogs) { | ||
if (this.enableLogs) { | ||
Logger.log('LOW_BANDWIDTH: Check internet connection', this._logTag); | ||
@@ -279,32 +354,14 @@ } | ||
} | ||
onIdleMic() { | ||
var _a; | ||
if ((_a = this._config) === null || _a === void 0 ? void 0 : _a.onIdleMic) { | ||
this._config.onIdleMic(); | ||
} | ||
} | ||
onStateChange(isConnected) { | ||
var _a; | ||
if (isConnected) { | ||
this.onPartialResults(''); | ||
} | ||
if (this._config.enableLogs) { | ||
Logger.log(`AUGNITO STATUS CHANGED. Connected: ${isConnected}`, this._logTag); | ||
} | ||
if ((_a = this._config) === null || _a === void 0 ? void 0 : _a.onStateChange) { | ||
this._config.onStateChange(isConnected); | ||
} | ||
} | ||
// #endregion | ||
//#region private | ||
createSDKConfig() { | ||
const clientConfig = buildSDKConfig(this._config); | ||
clientConfig.onError = this.onError.bind(this); | ||
clientConfig.onSocketPartialResult = this.onPartialResults.bind(this); | ||
clientConfig.onSocketFinalResult = this.onSocketFinalResult.bind(this); | ||
clientConfig.onReadyForSpeech = this.onStateChange.bind(this); | ||
clientConfig.onEndOfSession = this.onStateChange.bind(this); | ||
clientConfig.onEvent = this.onEvent.bind(this); | ||
clientConfig.onSessionEvent = this.onSessionEvent.bind(this); | ||
return clientConfig; | ||
createSDKConfig(config) { | ||
const sdkConfig = new SDKConfig(config); | ||
sdkConfig.onError = this.onError.bind(this); | ||
sdkConfig.onSocketPartialResult = this.onPartialResultsCallback.bind(this); | ||
sdkConfig.onSocketFinalResult = this.onSocketFinalResult.bind(this); | ||
sdkConfig.onReadyForSpeech = this.onStateChangeCallback.bind(this); | ||
sdkConfig.onEndOfSession = this.onStateChangeCallback.bind(this); | ||
sdkConfig.onEvent = this.onEvent.bind(this); | ||
sdkConfig.onSessionEvent = this.onSessionEventCallback.bind(this); | ||
return sdkConfig; | ||
} | ||
@@ -332,3 +389,3 @@ processResponseData(action) { | ||
const command = AugnitoCommandsStatic.prepareRecipe(actionRecipe); | ||
if ((_a = this._config) === null || _a === void 0 ? void 0 : _a.enableLogs) { | ||
if ((_a = this._webClient) === null || _a === void 0 ? void 0 : _a.getConfig().enableLogs) { | ||
Logger.log({ type: 'AugnitoCommandsStatic', command: command }, this._logTag); | ||
@@ -343,3 +400,3 @@ } | ||
// log output | ||
if ((_b = this._config) === null || _b === void 0 ? void 0 : _b.enableLogs) { | ||
if ((_b = this._webClient) === null || _b === void 0 ? void 0 : _b.getConfig().enableLogs) { | ||
Logger.log({ type: 'AugnitoCommandsRegex', command: command }, this._logTag); | ||
@@ -358,3 +415,2 @@ } | ||
} | ||
export { Augnito }; | ||
//# sourceMappingURL=Augnito.js.map |
@@ -1,9 +0,11 @@ | ||
import { WebClient } from './WebClient'; | ||
import { SDKConfigMobile } from '../config/SDKConfigMobile'; | ||
declare class MobileClient { | ||
export declare class MobileClient { | ||
private _config; | ||
private _logTag; | ||
private _pushNotificationSocket; | ||
private _config; | ||
private _webClient; | ||
constructor(config: SDKConfigMobile, augnitoClient: WebClient); | ||
/** Callback when a mobile client is requesting to connect */ | ||
onConnectionRequest?: () => void; | ||
/** Callback when a mobile client has scanned the QR Code */ | ||
onMobileScan?: () => void; | ||
constructor(_config: SDKConfigMobile); | ||
/** | ||
@@ -16,9 +18,6 @@ * Creates a web socket for getting notifications from client mobile application | ||
private createNotificationSocket; | ||
private prepareNotificationURL; | ||
private prepareSpeechMicURL; | ||
private getReplyMessage; | ||
private onMobileScan; | ||
private onConnectionRequest; | ||
private onMobileScanCallback; | ||
private onConnectionRequestCallback; | ||
private createWebSocketForMobileMic; | ||
} | ||
export { MobileClient }; |
@@ -1,6 +0,11 @@ | ||
import { AugnitoSource } from '../support/AugnitoSource'; | ||
import { createUniqueIdentifier, getCurrentTimestamp } from '../utils/AugnitoUtils'; | ||
import { Logger } from '../utils/Logger'; | ||
class MobileClient { | ||
constructor(config, augnitoClient) { | ||
export class MobileClient { | ||
constructor(_config) { | ||
Object.defineProperty(this, "_config", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: _config | ||
}); | ||
Object.defineProperty(this, "_logTag", { | ||
@@ -18,3 +23,4 @@ enumerable: true, | ||
}); | ||
Object.defineProperty(this, "_config", { | ||
/** Callback when a mobile client is requesting to connect */ | ||
Object.defineProperty(this, "onConnectionRequest", { | ||
enumerable: true, | ||
@@ -25,3 +31,4 @@ configurable: true, | ||
}); | ||
Object.defineProperty(this, "_webClient", { | ||
/** Callback when a mobile client has scanned the QR Code */ | ||
Object.defineProperty(this, "onMobileScan", { | ||
enumerable: true, | ||
@@ -32,4 +39,2 @@ configurable: true, | ||
}); | ||
this._config = config; | ||
this._webClient = augnitoClient; | ||
} | ||
@@ -48,3 +53,3 @@ /** | ||
} | ||
this.createNotificationSocket(this.prepareNotificationURL()); | ||
this.createNotificationSocket(this._config.prepareNotificationURL()); | ||
} | ||
@@ -57,5 +62,3 @@ closeMobileWebSocket() { | ||
} | ||
if (this._webClient) { | ||
this._webClient.stopListening(false); | ||
} | ||
this._config.stopListening(); | ||
return false; | ||
@@ -70,3 +73,3 @@ } | ||
this._pushNotificationSocket.onmessage = (e) => { | ||
if (this._webClient.getConfig().enableLogs) { | ||
if (this._config.enableLogs) { | ||
Logger.log({ message: 'NOTIFICATION CLIENT: Message received', data: e }, this._logTag); | ||
@@ -76,4 +79,4 @@ } | ||
const augnitoResponse = JSON.parse(e.data); | ||
if (this._webClient.getConfig().deviceId && | ||
this._webClient.getConfig().deviceId !== augnitoResponse.ToDeviceId) { | ||
if (this._config.deviceId && | ||
this._config.deviceId !== augnitoResponse.ToDeviceId) { | ||
if (this._pushNotificationSocket) { | ||
@@ -89,6 +92,6 @@ this._pushNotificationSocket.send(this.getReplyMessage(augnitoResponse, 'WRONG_DESTINATION')); | ||
if (augnitoResponse.Type === 'MOBILE_SCAN_SUCCESFULL') { | ||
this.onMobileScan(); | ||
this.onMobileScanCallback(); | ||
} | ||
else if (augnitoResponse.Type === 'MIC_CONNECTION_REQUEST') { | ||
this.onConnectionRequest(augnitoResponse); | ||
this.onConnectionRequestCallback(augnitoResponse); | ||
} | ||
@@ -116,26 +119,5 @@ } | ||
} | ||
prepareNotificationURL() { | ||
const webConfig = this._webClient.getConfig(); | ||
let pushURL = this._webClient.getConfig().pushNotificationURL; | ||
pushURL += `?devicecode=${webConfig.deviceId}`; | ||
pushURL += `&accountcode=${webConfig.accountCode}`; | ||
pushURL += `&accesskey=${webConfig.accessKey}`; | ||
//pushURL += `¤tTabId=${currentTabId}`; | ||
pushURL = pushURL.replace(new RegExp('amp;', 'gi'), ''); | ||
return pushURL; | ||
} | ||
prepareSpeechMicURL(JSONResponse) { | ||
const webConfig = this._webClient.getConfig(); | ||
let socketUrl = this._webClient.getConfig().speechMicURL; | ||
socketUrl += `?accountcode=${webConfig.accountCode}`; | ||
socketUrl += `&usertag=${webConfig.userTag}`; | ||
socketUrl += `&seqid=${JSONResponse.SeqId}`; | ||
socketUrl += `&mobiledevicecode=${JSONResponse.FromDeviceId}`; | ||
socketUrl += `&clientdevicecode=${webConfig.deviceId}`; | ||
socketUrl = socketUrl.replace(new RegExp('amp;', 'gi'), ''); | ||
return socketUrl; | ||
} | ||
getReplyMessage(JSONResponse, messageType) { | ||
const notification = { | ||
FromDeviceId: this._webClient.getConfig().deviceId, | ||
FromDeviceId: this._config.deviceId, | ||
ToDeviceId: JSONResponse.FromDeviceId, | ||
@@ -149,11 +131,11 @@ SeqId: createUniqueIdentifier(), | ||
} | ||
onMobileScan() { | ||
onMobileScanCallback() { | ||
if (this._config.enableLogs) { | ||
Logger.log('NOTIFICATION CLIENT: MOBILE_SCAN_SUCCESFULL', this._logTag); | ||
} | ||
if (this._config.onMobileScan) { | ||
this._config.onMobileScan(); | ||
if (this.onMobileScan) { | ||
this.onMobileScan(); | ||
} | ||
} | ||
onConnectionRequest(augnitoResponse) { | ||
onConnectionRequestCallback(augnitoResponse) { | ||
this.createWebSocketForMobileMic(augnitoResponse); | ||
@@ -163,4 +145,4 @@ if (this._config.enableLogs) { | ||
} | ||
if (this._config.onConnectionRequest) { | ||
this._config.onConnectionRequest(); | ||
if (this.onConnectionRequest) { | ||
this.onConnectionRequest(); | ||
} | ||
@@ -179,10 +161,9 @@ } | ||
} | ||
if (this._webClient.getConfig().userTag !== JSONResponse.Data.UserTag) { | ||
if (this._config.userTag !== JSONResponse.Data.UserTag) { | ||
this._pushNotificationSocket.send(this.getReplyMessage(JSONResponse, 'DIFFERENT_LOGIN_USER')); | ||
return; | ||
} | ||
this._webClient.startListening(this.prepareSpeechMicURL(JSONResponse), AugnitoSource.MOBILE_APP); | ||
this._config.startListening(JSONResponse); | ||
} | ||
} | ||
export { MobileClient }; | ||
//# sourceMappingURL=MobileClient.js.map |
@@ -48,3 +48,2 @@ import { SDKConfig } from '../config/SDKConfig'; | ||
dispose(): void; | ||
private prepareSpeechURL; | ||
private createWebSocket; | ||
@@ -51,0 +50,0 @@ private startAudioStream; |
@@ -79,3 +79,3 @@ import RecordRTC from '@scribetech/recordrtc-stereo-recorder-no-heads'; | ||
} | ||
this.startListening(this.prepareSpeechURL(), AugnitoSource.WEB_APP); | ||
this.startListening(this._config.prepareSpeechURL(), AugnitoSource.WEB_APP); | ||
} | ||
@@ -127,15 +127,2 @@ /** | ||
} | ||
prepareSpeechURL() { | ||
let speechURL = this._config.domainURL; | ||
speechURL += `?content-type=${this._config.contentType}`; | ||
speechURL += `&accountcode=${this._config.accountCode}`; | ||
speechURL += `&accesskey=${this._config.accessKey}`; | ||
speechURL += `&lmid=${this._config.lmId}`; | ||
speechURL += `&usertag=${this._config.userTag}`; | ||
speechURL += `&logintoken=${this._config.loginToken || ''}`; | ||
speechURL += `&noisect=${this._config.noiseCt}`; | ||
speechURL += `&otherinfo=${this._config.otherInfo || ''}`; | ||
speechURL += `&sourceapp=${this._config.sourceApp}`; | ||
return speechURL; | ||
} | ||
createWebSocket(socketUrl) { | ||
@@ -142,0 +129,0 @@ this._speechSocket = new WebSocket(socketUrl); |
@@ -11,2 +11,4 @@ import { AugnitoCommands } from './AugnitoCommands'; | ||
cmdText = cmdText.replace(new RegExp(AugnitoCommands.NEXT_LINE_TEXT, 'gi'), '\n'); | ||
command.name = cmdText; | ||
command.receivedTextWithoutSpace = cmdText; // Name may modify by dictionary,cmd and regex, But this one is same as received text. | ||
return this.fillDynamicCommand(command, cmdText); | ||
@@ -13,0 +15,0 @@ } |
@@ -1,7 +0,6 @@ | ||
import { Recipe } from '../recipe/Recipe'; | ||
import { AugnitoSocketResponse } from '../support/AugnitoSocketResponse'; | ||
import { TargetEditor } from '../interop/core/TargetEditor'; | ||
/** | ||
* Augnito Client Configuration | ||
*/ | ||
declare type AugnitoConfig = { | ||
interface AugnitoConfig { | ||
/** | ||
@@ -58,30 +57,6 @@ * Server configuration: India, UK, US | ||
/** | ||
* @callback Callback partial results | ||
* @description optional callback | ||
* The list of valid editors | ||
*/ | ||
onPartialResult?: (text: string) => void; | ||
/** | ||
* Callback to process Final Results | ||
* @description A final result iscalled when text has been processed by the Speech Server | ||
*/ | ||
onFinalResult?: (finalText: Partial<Recipe>) => void; | ||
/** | ||
* Callback to intercept Commands | ||
*/ | ||
onCommandResult?: (command: Partial<Recipe>) => void; | ||
/** | ||
* Callback for status changed | ||
* @description Mandatory field | ||
*/ | ||
onStateChange: (isConnected: boolean) => void; | ||
/** | ||
* Callback to intercept Session Events | ||
*/ | ||
onSessionEvent?: (data: AugnitoSocketResponse) => void; | ||
/** | ||
* Iddle Callback: When the Mic is iddle for 5 minutes | ||
* @description Mandatory field | ||
*/ | ||
onIdleMic: () => void; | ||
}; | ||
_listOfControls?: TargetEditor[]; | ||
} | ||
/** | ||
@@ -88,0 +63,0 @@ * Speech API Server |
@@ -1,6 +0,3 @@ | ||
declare type AugnitoMobileConfig = { | ||
export interface AugnitoMobileConfig { | ||
enableLogs: boolean; | ||
onConnectionRequest: () => void; | ||
onMobileScan: () => void; | ||
}; | ||
export { AugnitoMobileConfig }; | ||
} |
@@ -6,5 +6,5 @@ import { WebClient } from '../client/WebClient'; | ||
* Validates the augnito config has all the mandatory fields | ||
* @param augnitoConfig The config sent by the client application | ||
* @param config The config sent by the client application | ||
*/ | ||
declare const validateConfig: (augnitoConfig: AugnitoConfig) => AugnitoConfig; | ||
declare const validateConfig: (config: AugnitoConfig) => AugnitoConfig; | ||
/** | ||
@@ -11,0 +11,0 @@ * Validates the mobile augnito config has all the mandatory fields |
import { AugnitoAPIServer } from './AugnitoConfig'; | ||
/** | ||
* Validates the augnito config has all the mandatory fields | ||
* @param augnitoConfig The config sent by the client application | ||
* @param config The config sent by the client application | ||
*/ | ||
const validateConfig = (augnitoConfig) => { | ||
if (typeof augnitoConfig.onIdleMic != 'function') { | ||
throw 'On onIdleMic callback is not defined'; | ||
} | ||
if (typeof augnitoConfig.onStateChange != 'function') { | ||
throw 'On onStateChange callback is not defined'; | ||
} | ||
if (!augnitoConfig.userTag) { | ||
const validateConfig = (config) => { | ||
if (!config.userTag) { | ||
throw 'userTag is not defined'; | ||
} | ||
if (!augnitoConfig.lmId) { | ||
if (!config.lmId) { | ||
throw 'lmid is not defined'; | ||
} | ||
if (!augnitoConfig.accountCode) { | ||
if (!config.accountCode) { | ||
throw 'accountCode is not defined'; | ||
} | ||
if (!augnitoConfig.accessKey) { | ||
if (!config.accessKey) { | ||
throw 'accessKey is not defined'; | ||
} | ||
if (!augnitoConfig.sourceApp) { | ||
if (!config.sourceApp) { | ||
throw 'sourceApp is not defined'; | ||
} | ||
if (!(augnitoConfig.server in AugnitoAPIServer)) { | ||
if (!(config.server in AugnitoAPIServer)) { | ||
throw 'invalid Augnito server'; | ||
} | ||
return augnitoConfig; | ||
config.enableLogs = config.enableLogs || false; | ||
return config; | ||
}; | ||
@@ -42,11 +37,6 @@ /** | ||
} | ||
if (!webClient.getConfig().deviceId) { | ||
if (!webClient.getConfig().clientConfig.deviceId) { | ||
throw 'deviceId is not defined in AugnitoConfig'; | ||
} | ||
if (typeof config.onMobileScan != 'function') { | ||
throw 'onMobileScan callback is not defined'; | ||
} | ||
if (typeof config.onConnectionRequest != 'function') { | ||
throw 'onConnectionRequest callback is not defined'; | ||
} | ||
config.enableLogs = config.enableLogs || false; | ||
return config; | ||
@@ -53,0 +43,0 @@ }; |
@@ -9,11 +9,12 @@ import { AugnitoConfig } from './AugnitoConfig'; | ||
*/ | ||
declare type SDKConfig = { | ||
export declare class SDKConfig { | ||
private _config; | ||
qrCode: string; | ||
contentType: string; | ||
noiseCt: string; | ||
interval: number; | ||
domainURL: string; | ||
macroServiceURL: string; | ||
pushNotificationURL: string; | ||
speechMicURL: string; | ||
readonly contentType: string; | ||
readonly noiseCt: string; | ||
readonly interval: number; | ||
readonly domainURL: string; | ||
readonly macroServiceURL: string; | ||
readonly pushNotificationURL: string; | ||
readonly speechMicURL: string; | ||
source: AugnitoSource; | ||
@@ -27,3 +28,8 @@ onSocketPartialResult?: (data: string) => void; | ||
onError?: (e: AugnitoSDKError, data: string) => void; | ||
} & Omit<AugnitoConfig, 'onPartialResult' | 'onFinalResult' | 'onCommandResult' | 'onStateChange' | 'onSessionEvent' | 'onIdleMic'>; | ||
export { SDKConfig }; | ||
constructor(_config: AugnitoConfig); | ||
get clientConfig(): AugnitoConfig; | ||
get enableLogs(): boolean; | ||
prepareSpeechURL(): string; | ||
private getDomainName; | ||
private getQRCode; | ||
} |
@@ -1,2 +0,159 @@ | ||
export {}; | ||
import { AugnitoAPIServer } from './AugnitoConfig'; | ||
import { AugnitoSource } from '../support/AugnitoSource'; | ||
/** | ||
* Augnito SDK Config | ||
*/ | ||
export class SDKConfig { | ||
constructor(_config) { | ||
Object.defineProperty(this, "_config", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: _config | ||
}); | ||
Object.defineProperty(this, "qrCode", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: '' | ||
}); | ||
Object.defineProperty(this, "contentType", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: 'audio/x-raw,+layout=(string)interleaved,+rate=(int)16000,+format=(string)S16LE,+channels=(int)1' | ||
}); | ||
Object.defineProperty(this, "noiseCt", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: '1' | ||
}); | ||
Object.defineProperty(this, "interval", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: 100 | ||
}); | ||
Object.defineProperty(this, "domainURL", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
Object.defineProperty(this, "macroServiceURL", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
Object.defineProperty(this, "pushNotificationURL", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
Object.defineProperty(this, "speechMicURL", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
Object.defineProperty(this, "source", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: AugnitoSource.WEB_APP | ||
}); | ||
Object.defineProperty(this, "onSocketPartialResult", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
Object.defineProperty(this, "onSocketFinalResult", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
Object.defineProperty(this, "onEndOfSession", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
Object.defineProperty(this, "onReadyForSpeech", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
Object.defineProperty(this, "onEvent", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
Object.defineProperty(this, "onSessionEvent", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
Object.defineProperty(this, "onError", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
const domainName = this.getDomainName(_config.server); | ||
if (_config.deviceId) { | ||
this.qrCode = this.getQRCode(_config, domainName); | ||
} | ||
this.domainURL = `wss://${domainName}/speechapi`; | ||
this.macroServiceURL = `https://${domainName}/manage/`; | ||
this.pushNotificationURL = `wss://${domainName}/speechapi/notification/`; | ||
this.speechMicURL = `wss://${domainName}/speechapi/mobile/client/`; | ||
} | ||
get clientConfig() { | ||
return this._config; | ||
} | ||
get enableLogs() { | ||
return this._config.enableLogs; | ||
} | ||
prepareSpeechURL() { | ||
let speechURL = this.domainURL; | ||
speechURL += `?content-type=${this.contentType}`; | ||
speechURL += `&accountcode=${this._config.accountCode}`; | ||
speechURL += `&accesskey=${this._config.accessKey}`; | ||
speechURL += `&lmid=${this._config.lmId}`; | ||
speechURL += `&usertag=${this._config.userTag}`; | ||
speechURL += `&logintoken=${this._config.loginToken || ''}`; | ||
speechURL += `&noisect=${this.noiseCt}`; | ||
speechURL += `&otherinfo=${this._config.otherInfo || ''}`; | ||
speechURL += `&sourceapp=${this._config.sourceApp}`; | ||
return speechURL; | ||
} | ||
getDomainName(server) { | ||
let domainName = ''; | ||
switch (server) { | ||
case AugnitoAPIServer.INDIA: | ||
domainName = 'apis.augnito.ai'; | ||
break; | ||
case AugnitoAPIServer.US: | ||
domainName = 'us.apis.augnito.ai'; | ||
break; | ||
case AugnitoAPIServer.UK: | ||
domainName = 'uk.apis.augnito.ai'; | ||
break; | ||
default: | ||
throw 'Invalid domain'; | ||
} | ||
return domainName; | ||
} | ||
getQRCode(config, domainName) { | ||
return `${config.accountCode}|${config.accessKey}|${config.userTag}|${config.deviceId}|${config.lmId}|${config.sourceApp}|${domainName}`; | ||
} | ||
} | ||
//# sourceMappingURL=SDKConfig.js.map |
@@ -0,9 +1,19 @@ | ||
import { WebClient } from '../client/WebClient'; | ||
import { AugnitoMobileSocketResponse } from '../support/AugnitoMobileSocketResponse'; | ||
import { AugnitoMobileConfig } from './AugnitoMobileConfig'; | ||
/** | ||
* Mobile SDK Config | ||
*/ | ||
declare type SDKConfigMobile = { | ||
enableLogs: boolean; | ||
onMobileScan: () => void; | ||
onConnectionRequest: () => void; | ||
}; | ||
export { SDKConfigMobile }; | ||
export declare class SDKConfigMobile { | ||
private _config; | ||
private _webClient; | ||
constructor(_config: AugnitoMobileConfig, _webClient: WebClient); | ||
get clientConfig(): AugnitoMobileConfig; | ||
get enableLogs(): boolean; | ||
get deviceId(): string | undefined; | ||
get userTag(): string; | ||
startListening(JSONResponse: AugnitoMobileSocketResponse): void; | ||
stopListening(): void; | ||
prepareNotificationURL(): string; | ||
prepareSpeechMicURL(JSONResponse: AugnitoMobileSocketResponse): string; | ||
} |
@@ -1,2 +0,62 @@ | ||
export {}; | ||
import { AugnitoSource } from '../support/AugnitoSource'; | ||
/** | ||
* Mobile SDK Config | ||
*/ | ||
export class SDKConfigMobile { | ||
constructor(_config, _webClient) { | ||
Object.defineProperty(this, "_config", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: _config | ||
}); | ||
Object.defineProperty(this, "_webClient", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: _webClient | ||
}); | ||
} | ||
get clientConfig() { | ||
return this._config; | ||
} | ||
get enableLogs() { | ||
return this._config.enableLogs; | ||
} | ||
get deviceId() { | ||
return this._webClient.getConfig().clientConfig.deviceId; | ||
} | ||
get userTag() { | ||
return this._webClient.getConfig().clientConfig.userTag; | ||
} | ||
startListening(JSONResponse) { | ||
this._webClient.startListening(this.prepareSpeechMicURL(JSONResponse), AugnitoSource.MOBILE_APP); | ||
} | ||
stopListening() { | ||
if (this._webClient) { | ||
this._webClient.stopListening(false); | ||
} | ||
} | ||
prepareNotificationURL() { | ||
const config = this._webClient.getConfig(); | ||
let pushURL = config.pushNotificationURL; | ||
pushURL += `?devicecode=${config.clientConfig.deviceId}`; | ||
pushURL += `&accountcode=${config.clientConfig.accountCode}`; | ||
pushURL += `&accesskey=${config.clientConfig.accessKey}`; | ||
//pushURL += `¤tTabId=${currentTabId}`; | ||
pushURL = pushURL.replace(new RegExp('amp;', 'gi'), ''); | ||
return pushURL; | ||
} | ||
prepareSpeechMicURL(JSONResponse) { | ||
const config = this._webClient.getConfig(); | ||
let socketUrl = this._webClient.getConfig().speechMicURL; | ||
socketUrl += `?accountcode=${config.clientConfig.accountCode}`; | ||
socketUrl += `&usertag=${config.clientConfig.userTag}`; | ||
socketUrl += `&seqid=${JSONResponse.SeqId}`; | ||
socketUrl += `&mobiledevicecode=${JSONResponse.FromDeviceId}`; | ||
socketUrl += `&clientdevicecode=${config.clientConfig.deviceId}`; | ||
socketUrl = socketUrl.replace(new RegExp('amp;', 'gi'), ''); | ||
return socketUrl; | ||
} | ||
} | ||
//# sourceMappingURL=SDKConfigMobile.js.map |
export { Augnito } from './Augnito'; | ||
export { AugnitoMobile } from './AugnitoMobile'; | ||
export { AugnitoConfig, AugnitoMobileConfig, AugnitoAPIServer } from './config/'; | ||
export { EditorType } from './interop/core/EditorType'; | ||
export { TargetEditor } from './interop/core/TargetEditor'; | ||
export * from './commands'; | ||
export * from './recipe'; | ||
export * from './config'; |
export { Augnito } from './Augnito'; | ||
export { AugnitoMobile } from './AugnitoMobile'; | ||
export { AugnitoAPIServer } from './config/'; | ||
export { EditorType } from './interop/core/EditorType'; | ||
export * from './commands'; | ||
@@ -3,0 +6,0 @@ export * from './recipe'; |
import { EditorType } from './EditorType'; | ||
declare type TargetEditor = { | ||
export interface TargetEditor { | ||
controlId: string; | ||
controlName: string; | ||
type: EditorType | undefined; | ||
}; | ||
export { TargetEditor }; | ||
} |
@@ -7,2 +7,3 @@ import { EditorType } from '../core/EditorType'; | ||
declare class HTMLInteropProcessor extends BaseInteropProcessor implements InteropProcessor { | ||
constructor(loggingEnabled: boolean); | ||
private _buffer; | ||
@@ -9,0 +10,0 @@ get buffer(): string; |
@@ -7,4 +7,4 @@ import { EditorType } from '../core/EditorType'; | ||
class HTMLInteropProcessor extends BaseInteropProcessor { | ||
constructor() { | ||
super(...arguments); | ||
constructor(loggingEnabled) { | ||
super(loggingEnabled, 'HTMLInteropProcessor'); | ||
Object.defineProperty(this, "_buffer", { | ||
@@ -31,3 +31,2 @@ enumerable: true, | ||
}); | ||
// #endregion | ||
} | ||
@@ -52,79 +51,79 @@ get buffer() { | ||
let isCommandProcessed = false; | ||
switch (command.action) { | ||
case AugnitoCommands.PRESS_DELETE: | ||
if (this.isTextSelected(editor)) { | ||
this.deleteSelected(editor); | ||
} | ||
else { | ||
command.name = AugnitoCommands.SELECT_WORD; | ||
this.selectWordLineSentence(command, currentText, caretPosition, editor); | ||
this.deleteSelected(editor); | ||
} | ||
isCommandProcessed = true; | ||
break; | ||
case AugnitoCommands.SELECT_WORD: | ||
if (command.action === AugnitoCommands.PRESS_DELETE) { | ||
if (this.isTextSelected(editor)) { | ||
this.deleteSelected(editor); | ||
} | ||
else { | ||
command.name = AugnitoCommands.SELECT_WORD; | ||
this.selectWordLineSentence(command, currentText, caretPosition, editor); | ||
if (command.selectFor === AugnitoCommands.DELETE) { | ||
this.deleteSelected(editor); | ||
} | ||
isCommandProcessed = true; | ||
break; | ||
case AugnitoCommands.SELECT_LINE: | ||
this.selectWordLineSentence(command, currentText, caretPosition, editor); | ||
if (command.selectFor === AugnitoCommands.DELETE) { | ||
this.deleteSelected(editor); | ||
} | ||
isCommandProcessed = true; | ||
break; | ||
case AugnitoCommands.SELECT_ALL: | ||
editor.setSelectionRange(0, editor.value.length); | ||
isCommandProcessed = true; | ||
break; | ||
case AugnitoCommands.SELECT_SENTENCE: | ||
this.selectWordLineSentence(command, currentText, caretPosition, editor); | ||
if (command.selectFor === AugnitoCommands.DELETE) { | ||
this.deleteSelected(editor); | ||
} | ||
isCommandProcessed = true; | ||
break; | ||
case AugnitoCommands.GO_TO_LINE_START: | ||
this.setCaretPosition(this.getStartOfLine(currentText, caretPosition), editor); | ||
isCommandProcessed = true; | ||
break; | ||
case AugnitoCommands.GO_TO_DOCUMENT_START: | ||
this.setCaretPosition(0, editor); | ||
isCommandProcessed = true; | ||
break; | ||
case AugnitoCommands.GO_TO_DOCUMENT_END: | ||
this.setCaretPosition(currentText.length, editor); | ||
isCommandProcessed = true; | ||
break; | ||
case AugnitoCommands.GO_TO_LINE_END: | ||
this.setCaretPosition(this.getEndOfLine(currentText, caretPosition), editor); | ||
isCommandProcessed = true; | ||
break; | ||
case AugnitoCommands.COPY_IT: | ||
this.copySelected(editor); | ||
isCommandProcessed = true; | ||
break; | ||
case AugnitoCommands.UNDO_IT: | ||
this.undo(); | ||
this.setCaretPosition(editor.selectionEnd || editor.value.length, editor); | ||
isCommandProcessed = true; | ||
break; | ||
case AugnitoCommands.REDO_IT: | ||
this.redo(); | ||
isCommandProcessed = true; | ||
break; | ||
case AugnitoCommands.DOCUMENT_PRINT: | ||
this.print(); | ||
isCommandProcessed = true; | ||
break; | ||
case AugnitoCommands.SPACE_ADD: | ||
this.stringWriteAtCaret(currentText, ' ', caretPosition, editor); | ||
isCommandProcessed = true; | ||
break; | ||
default: | ||
break; | ||
this.deleteSelected(editor); | ||
} | ||
isCommandProcessed = true; | ||
} | ||
else if (command.name === AugnitoCommands.SELECT_WORD) { | ||
this.selectWordLineSentence(command, currentText, caretPosition, editor); | ||
if (command.selectFor === AugnitoCommands.DELETE) { | ||
this.deleteSelected(editor); | ||
} | ||
isCommandProcessed = true; | ||
} | ||
else if (command.name === AugnitoCommands.SELECT_LINE) { | ||
this.selectWordLineSentence(command, currentText, caretPosition, editor); | ||
if (command.selectFor === AugnitoCommands.DELETE) { | ||
this.deleteSelected(editor); | ||
} | ||
isCommandProcessed = true; | ||
} | ||
else if (command.action === AugnitoCommands.SELECT_ALL) { | ||
editor.setSelectionRange(0, editor.value.length); | ||
isCommandProcessed = true; | ||
} | ||
else if (command.name === AugnitoCommands.SELECT_SENTENCE) { | ||
this.selectWordLineSentence(command, currentText, caretPosition, editor); | ||
if (command.selectFor === AugnitoCommands.DELETE) { | ||
this.deleteSelected(editor); | ||
} | ||
isCommandProcessed = true; | ||
} | ||
else if (command.action === AugnitoCommands.GO_TO_LINE_START) { | ||
this.setCaretPosition(this.getStartOfLine(currentText, caretPosition), editor); | ||
isCommandProcessed = true; | ||
} | ||
else if (command.action === AugnitoCommands.GO_TO_DOCUMENT_START) { | ||
this.setCaretPosition(0, editor); | ||
isCommandProcessed = true; | ||
} | ||
else if (command.action === AugnitoCommands.GO_TO_DOCUMENT_END) { | ||
this.setCaretPosition(currentText.length, editor); | ||
isCommandProcessed = true; | ||
} | ||
else if (command.action === AugnitoCommands.GO_TO_LINE_END) { | ||
const newCaretPosition = this.getEndOfLine(currentText, caretPosition); | ||
this.setCaretPosition(newCaretPosition, editor); | ||
isCommandProcessed = true; | ||
} | ||
else if (command.action === AugnitoCommands.COPY_IT) { | ||
this.copySelected(editor); | ||
isCommandProcessed = true; | ||
} | ||
else if (command.action === AugnitoCommands.UNDO_IT) { | ||
this.undo(); | ||
this.setCaretPosition(editor.selectionEnd || editor.value.length, editor); | ||
isCommandProcessed = true; | ||
} | ||
else if (command.action === AugnitoCommands.REDO_IT) { | ||
this.redo(); | ||
isCommandProcessed = true; | ||
} | ||
else if (command.action === AugnitoCommands.DOCUMENT_PRINT) { | ||
this.print(); | ||
isCommandProcessed = true; | ||
} | ||
else if (command.action === AugnitoCommands.SPACE_ADD) { | ||
this.stringWriteAtCaret(currentText, ' ', caretPosition, editor); | ||
isCommandProcessed = true; | ||
} | ||
else { | ||
this.log('Command NOT Processed'); | ||
} | ||
return isCommandProcessed; | ||
@@ -131,0 +130,0 @@ } |
{ | ||
"name": "augnitosdk", | ||
"private": false, | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"license": "Restricted", | ||
@@ -6,0 +6,0 @@ "files": [ |
@@ -9,3 +9,3 @@ # Augnito Speech SDK | ||
npm install AugnitoSDK | ||
npm install augnitosdk | ||
@@ -15,2 +15,4 @@ Create the configuration file and instantiate Augnito Client | ||
```js | ||
import { Augnito, AugnitoConfig, AugnitoMobileConfig } from 'augnitosdk'; | ||
const augnitoConfig: AugnitoConfig = { | ||
@@ -22,8 +24,5 @@ server: AugnitoAPIServer.INDIA, | ||
sourceApp: 'MyAppName', | ||
lmId: '38', | ||
onIdleMic: () => {}, | ||
onPartialResult: (text: string) => {}, | ||
onFinalResult: (result: Partial<Recipe>) => {}, | ||
onCommandResult: (command: Partial<Recipe>) => {}, | ||
onStateChange: (isConnected: boolean) => {} | ||
lmId: '38' | ||
enableLogs: false, | ||
_listOfControls: myControlsArray | ||
}; | ||
@@ -36,4 +35,6 @@ | ||
// Toggles the Speech API connection | ||
augnito.toggleListening(); | ||
```js | ||
// Toggles the Speech API connection | ||
augnito.toggleListening(); | ||
``` | ||
@@ -50,7 +51,25 @@ That's all! | ||
const mobileConfig: AugnitoMobileConfig = { | ||
onConnectionRequest: () => {}, | ||
onMobileScan: () => {} | ||
enableLogs: false | ||
}; | ||
augnito.initMobileClient(mobileConfig); | ||
const augnitoMobile = augnito.initMobileClient(mobileConfig); | ||
const code = augnito.getQRCode(); | ||
``` | ||
## Augnito - Callbacks | ||
| Name | Signature | Description | | ||
| ------------------ | ----------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- | | ||
| `onPartialResult?` | `(text: string) => void` | Partial Result generated from the server | | ||
| `onFinalResult?` | `(finalText: Partial<Recipe>) => boolean` | A final result is called when text has been processed by the Speech Server. Returns `true` to stop the processing in the SDK | | ||
| `onCommandResult?` | `(command: Partial<Recipe>) => boolean` | A command generated from the server. Returns `true` to stop the processing in the SDK | | ||
| `onStateChanged?` | `(isConnected: boolean) => void` | Callback to indicate the status of the connection has changed. | | ||
| `onSessionEvent?` | `(data: AugnitoSocketResponse) => void` | Callback to intercept Session Events | | ||
| `onIdleMic?` | `() => void` | Callback when the Mic is idle for 5 minutes | | ||
## Augnito Mobile - Callbacks | ||
| Name | Signature | Description | | ||
| ---------------------- | ------------ | ------------------------------------------------------ | | ||
| `onConnectionRequest?` | `() => void` | Callback when a mobile client is requesting to connect | | ||
| `onMobileScan?` | `() => void` | Callback when a mobile client has scanned the QR Code | |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
214364
110
3454
71
0