@ada-cx/messaging-sdk 1.0.0-setup.0
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.
- package/README.md +211 -0
- package/dist/client/ada-settings-reader.d.ts +10 -0
- package/dist/client/client-channel-handlers.d.ts +92 -0
- package/dist/client/client-errors.d.ts +7 -0
- package/dist/client/client-frame-constants.d.ts +41 -0
- package/dist/client/client-frame-runtime.d.ts +54 -0
- package/dist/client/client-host-runtime.d.ts +73 -0
- package/dist/client/client-types.d.ts +231 -0
- package/dist/client/client.d.ts +843 -0
- package/dist/client/config-helpers.d.ts +157 -0
- package/dist/client/constants.d.ts +61 -0
- package/dist/client/core-channel-test-harness.d.ts +47 -0
- package/dist/client/embed-interface.d.ts +172 -0
- package/dist/client/embed-lifecycle.d.ts +12 -0
- package/dist/client/fallback-html.d.ts +1 -0
- package/dist/client/frame-manager.d.ts +64 -0
- package/dist/client/frame-styles.d.ts +164 -0
- package/dist/client/frame-visibility.d.ts +53 -0
- package/dist/client/integration-manager.d.ts +73 -0
- package/dist/client/legacy-callback-adapter.d.ts +22 -0
- package/dist/client/mask-element.d.ts +19 -0
- package/dist/client/proactive/index.d.ts +5 -0
- package/dist/client/proactive/proactive-channel.d.ts +33 -0
- package/dist/client/proactive/proactive-runtime.d.ts +65 -0
- package/dist/client/proactive/proactive-utils.d.ts +51 -0
- package/dist/client/sdk-error-reporter.d.ts +22 -0
- package/dist/client/sdk-event-bus.d.ts +116 -0
- package/dist/client/service-worker-notifications.d.ts +1 -0
- package/dist/client/url-business-events.d.ts +19 -0
- package/dist/frame-channel/frame-channel.d.ts +64 -0
- package/dist/frame-channel/frame-child.d.ts +45 -0
- package/dist/frame-channel/index.d.ts +3 -0
- package/dist/frame-channel/types.d.ts +736 -0
- package/dist/helpers/rollout.d.ts +18 -0
- package/dist/host-telemetry.d.ts +15 -0
- package/dist/index.d.ts +8 -0
- package/dist/logger.d.ts +59 -0
- package/dist/mobile-webview-runtime.d.ts +122 -0
- package/dist/npm/build-info.d.cts +17 -0
- package/dist/npm/build-info.d.ts +17 -0
- package/dist/npm/index.cjs +276 -0
- package/dist/npm/index.cjs.map +1 -0
- package/dist/npm/index.d.cts +15 -0
- package/dist/npm/index.d.ts +9 -0
- package/dist/npm/index.js +270 -0
- package/dist/npm/index.js.map +1 -0
- package/dist/npm/loader.d.cts +120 -0
- package/dist/npm/loader.d.ts +120 -0
- package/dist/npm/testing.cjs +155 -0
- package/dist/npm/testing.cjs.map +1 -0
- package/dist/npm/testing.d.cts +39 -0
- package/dist/npm/testing.d.ts +39 -0
- package/dist/npm/testing.js +154 -0
- package/dist/npm/testing.js.map +1 -0
- package/dist/sdk-module-loader.d.ts +1 -0
- package/dist/shared-utils/clusters.d.ts +5 -0
- package/dist/shared-utils/csat.d.ts +116 -0
- package/dist/shared-utils/host-telemetry.d.ts +35 -0
- package/dist/shared-utils/index.d.ts +3 -0
- package/dist/voice/voice-manager.d.ts +120 -0
- package/package.json +77 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
export interface VoiceManagerCallbacks {
|
|
2
|
+
/** Called when speech recognition updates transcript (interim or final) */
|
|
3
|
+
onTranscriptUpdate: (transcript: string, isFinal: boolean) => void;
|
|
4
|
+
/** Called when speech recognition encounters an error */
|
|
5
|
+
onError: (error: string) => void;
|
|
6
|
+
/** Called periodically with audio level 0-1 for waveform visualization */
|
|
7
|
+
onAudioLevel: (level: number) => void;
|
|
8
|
+
}
|
|
9
|
+
export interface VoiceManagerConfig {
|
|
10
|
+
/** Language code for speech recognition (e.g., "en-US") */
|
|
11
|
+
language: string;
|
|
12
|
+
/** Recording mode: toggle (click to start/stop) or push-to-talk (hold button) */
|
|
13
|
+
mode: "toggle" | "push-to-talk";
|
|
14
|
+
/** Callbacks for voice events */
|
|
15
|
+
callbacks: VoiceManagerCallbacks;
|
|
16
|
+
}
|
|
17
|
+
export declare class VoiceManager {
|
|
18
|
+
private recognition;
|
|
19
|
+
private audioContext;
|
|
20
|
+
private analyser;
|
|
21
|
+
private audioSource;
|
|
22
|
+
private mediaStream;
|
|
23
|
+
private audioLevelRafId;
|
|
24
|
+
/** Set to true when a fatal recognition error occurs to prevent restart loops. */
|
|
25
|
+
private _hadFatalError;
|
|
26
|
+
private config;
|
|
27
|
+
constructor(config: VoiceManagerConfig);
|
|
28
|
+
/**
|
|
29
|
+
* Check if Web Speech API is supported in the current browser.
|
|
30
|
+
*/
|
|
31
|
+
static isSupported(): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Start voice recording.
|
|
34
|
+
* Requests microphone permission and begins speech recognition.
|
|
35
|
+
* @returns Promise<boolean> - true if started successfully, false otherwise
|
|
36
|
+
*/
|
|
37
|
+
startRecording(): Promise<boolean>;
|
|
38
|
+
/**
|
|
39
|
+
* Stop voice recording and cleanup resources.
|
|
40
|
+
*/
|
|
41
|
+
stopRecording(): void;
|
|
42
|
+
/**
|
|
43
|
+
* Update recognition language.
|
|
44
|
+
*/
|
|
45
|
+
setLanguage(language: string): void;
|
|
46
|
+
/**
|
|
47
|
+
* Update recording mode (toggle or push-to-talk).
|
|
48
|
+
*/
|
|
49
|
+
setMode(mode: "toggle" | "push-to-talk"): void;
|
|
50
|
+
/**
|
|
51
|
+
* Start monitoring audio levels for waveform visualization.
|
|
52
|
+
* Uses requestAnimationFrame instead of setInterval to avoid firing
|
|
53
|
+
* while the tab is hidden and to align with the display refresh rate.
|
|
54
|
+
*/
|
|
55
|
+
private startAudioLevelMonitoring;
|
|
56
|
+
/**
|
|
57
|
+
* Stop audio level monitoring.
|
|
58
|
+
*/
|
|
59
|
+
private stopAudioLevelMonitoring;
|
|
60
|
+
/**
|
|
61
|
+
* Cleanup resources on destroy.
|
|
62
|
+
*/
|
|
63
|
+
destroy(): void;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Text-to-Speech helper function.
|
|
67
|
+
* Uses Web Speech Synthesis API to speak text.
|
|
68
|
+
*
|
|
69
|
+
* Note: `speechSynthesis.cancel()` cancels ALL pending speech globally —
|
|
70
|
+
* there is no namespacing in the Web Speech API. If the host page also uses
|
|
71
|
+
* speechSynthesis, Ada will cancel its speech. This is a known browser API
|
|
72
|
+
* limitation with no available workaround.
|
|
73
|
+
*/
|
|
74
|
+
export declare function speakText(text: string, language: string): void;
|
|
75
|
+
/**
|
|
76
|
+
* Type declarations for Web Speech API (may not be in all TypeScript versions).
|
|
77
|
+
*/
|
|
78
|
+
declare global {
|
|
79
|
+
interface Window {
|
|
80
|
+
SpeechRecognition: typeof SpeechRecognition;
|
|
81
|
+
webkitSpeechRecognition: typeof SpeechRecognition;
|
|
82
|
+
}
|
|
83
|
+
interface SpeechRecognition extends EventTarget {
|
|
84
|
+
continuous: boolean;
|
|
85
|
+
interimResults: boolean;
|
|
86
|
+
lang: string;
|
|
87
|
+
onresult: ((event: SpeechRecognitionEvent) => void) | null;
|
|
88
|
+
onerror: ((event: SpeechRecognitionErrorEvent) => void) | null;
|
|
89
|
+
onend: (() => void) | null;
|
|
90
|
+
start(): void;
|
|
91
|
+
stop(): void;
|
|
92
|
+
}
|
|
93
|
+
interface SpeechRecognitionEvent extends Event {
|
|
94
|
+
results: SpeechRecognitionResultList;
|
|
95
|
+
resultIndex: number;
|
|
96
|
+
}
|
|
97
|
+
interface SpeechRecognitionResultList {
|
|
98
|
+
readonly length: number;
|
|
99
|
+
item(index: number): SpeechRecognitionResult;
|
|
100
|
+
[index: number]: SpeechRecognitionResult;
|
|
101
|
+
}
|
|
102
|
+
interface SpeechRecognitionResult {
|
|
103
|
+
readonly isFinal: boolean;
|
|
104
|
+
readonly length: number;
|
|
105
|
+
item(index: number): SpeechRecognitionAlternative;
|
|
106
|
+
[index: number]: SpeechRecognitionAlternative;
|
|
107
|
+
}
|
|
108
|
+
interface SpeechRecognitionAlternative {
|
|
109
|
+
readonly transcript: string;
|
|
110
|
+
readonly confidence: number;
|
|
111
|
+
}
|
|
112
|
+
interface SpeechRecognitionErrorEvent extends Event {
|
|
113
|
+
error: string;
|
|
114
|
+
message: string;
|
|
115
|
+
}
|
|
116
|
+
const SpeechRecognition: {
|
|
117
|
+
prototype: SpeechRecognition;
|
|
118
|
+
new (): SpeechRecognition;
|
|
119
|
+
};
|
|
120
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ada-cx/messaging-sdk",
|
|
3
|
+
"version": "1.0.0-setup.0",
|
|
4
|
+
"description": "TypeScript types, test mocks, and a thin CDN loader for the Ada Messaging SDK. The runtime always resolves from Ada's CDN and is never bundled into this package.",
|
|
5
|
+
"homepage": "https://github.com/AdaSupport/monorepo/tree/main/messaging/packages/sdk#readme",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/AdaSupport/monorepo.git",
|
|
9
|
+
"directory": "messaging/packages/sdk"
|
|
10
|
+
},
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/AdaSupport/monorepo/issues"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"ada",
|
|
16
|
+
"ada.cx",
|
|
17
|
+
"chat",
|
|
18
|
+
"messaging",
|
|
19
|
+
"sdk",
|
|
20
|
+
"embed",
|
|
21
|
+
"loader"
|
|
22
|
+
],
|
|
23
|
+
"license": "ISC",
|
|
24
|
+
"type": "module",
|
|
25
|
+
"sideEffects": false,
|
|
26
|
+
"main": "./dist/npm/index.cjs",
|
|
27
|
+
"module": "./dist/npm/index.js",
|
|
28
|
+
"types": "./dist/npm/index.d.ts",
|
|
29
|
+
"exports": {
|
|
30
|
+
".": {
|
|
31
|
+
"import": {
|
|
32
|
+
"types": "./dist/npm/index.d.ts",
|
|
33
|
+
"default": "./dist/npm/index.js"
|
|
34
|
+
},
|
|
35
|
+
"require": {
|
|
36
|
+
"types": "./dist/npm/index.d.cts",
|
|
37
|
+
"default": "./dist/npm/index.cjs"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"./testing": {
|
|
41
|
+
"import": {
|
|
42
|
+
"types": "./dist/npm/testing.d.ts",
|
|
43
|
+
"default": "./dist/npm/testing.js"
|
|
44
|
+
},
|
|
45
|
+
"require": {
|
|
46
|
+
"types": "./dist/npm/testing.d.cts",
|
|
47
|
+
"default": "./dist/npm/testing.cjs"
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
"typesVersions": {
|
|
52
|
+
"*": {
|
|
53
|
+
"testing": [
|
|
54
|
+
"dist/npm/testing.d.ts"
|
|
55
|
+
]
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
"files": [
|
|
59
|
+
"dist/npm/",
|
|
60
|
+
"dist/**/*.d.ts",
|
|
61
|
+
"!dist/**/*.test.d.ts",
|
|
62
|
+
"!dist/npm/types-drift.d.ts",
|
|
63
|
+
"README_NPM.md"
|
|
64
|
+
],
|
|
65
|
+
"publishConfig": {
|
|
66
|
+
"access": "public",
|
|
67
|
+
"provenance": true
|
|
68
|
+
},
|
|
69
|
+
"scripts": {
|
|
70
|
+
"build": "vite build && vite build --mode npm && tsc -b && node scripts/finish-npm-package.mjs",
|
|
71
|
+
"dev": "vite",
|
|
72
|
+
"lint": "npx biome check"
|
|
73
|
+
},
|
|
74
|
+
"devDependencies": {
|
|
75
|
+
"uuid": "*"
|
|
76
|
+
}
|
|
77
|
+
}
|